m->mothurOut("[ERROR]: " + metric + " is not a valid metric option for the cooccurrence command. Choices are cscore, checker, combo, vratio."); m->mothurOutEndLine(); abort = true;
}
- matrix = validParameter.validFile(parameters, "matrix", false); if (matrix == "not found") { matrix = "sim2"; }
+ matrix = validParameter.validFile(parameters, "matrixmodel", false); if (matrix == "not found") { matrix = "sim2"; }
if ((matrix != "sim1") && (matrix != "sim2") && (matrix != "sim3") && (matrix != "sim4") && (matrix != "sim5" ) && (matrix != "sim6" ) && (matrix != "sim7" ) && (matrix != "sim8" ) && (matrix != "sim9" )) {
m->mothurOut("[ERROR]: " + matrix + " is not a valid matrix option for the cooccurrence command. Choices are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8, sim9."); m->mothurOutEndLine(); abort = true;
//reset groups parameter
delete input;
+ m->clearGroups();
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp, ofstream& out){
try {
int numOTUS = thisLookUp[0]->getNumBins();
- vector< vector<int> > initmatrix (thisLookUp.size());
- vector< vector<int> > co_matrix (thisLookUp[0]->getNumBins());
+ vector< vector<int> > initmatrix; initmatrix.resize(thisLookUp.size());
+ vector< vector<int> > co_matrix; co_matrix.resize(thisLookUp[0]->getNumBins());
for (int i = 0; i < thisLookUp[0]->getNumBins(); i++) { co_matrix[i].resize((thisLookUp.size()), 0); }
for (int i = 0; i < thisLookUp.size(); i++) { initmatrix[i].resize((thisLookUp[i]->getNumBins()), 0); }
- vector<int> columntotal(thisLookUp.size(), 0);
- vector<int> rowtotal(numOTUS, 0);
+ vector<int> columntotal; columntotal.resize(thisLookUp.size(), 0);
+ vector<int> rowtotal; rowtotal.resize(numOTUS, 0);
- int rowcount = 0;
for (int i = 0; i < thisLookUp.size(); i++) {
for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) {
if (m->control_pressed) { return 0; }
if(abund > 0) {
initmatrix[i][j] = 1;
co_matrix[j][i] = 1;
- rowcount++;
- columntotal[j]++;
+ rowtotal[j]++;
+ columntotal[i]++;
}
}
- rowtotal[i] = rowcount;
- rowcount = 0;
}
//nrows is ncols of inital matrix. All the functions need this value. They assume the transposition has already taken place and nrows and ncols refer to that matrix.
//comatrix and initmatrix are still vectors of vectors of ints as in the original script. The abundancevector is only what was read in ie not a co-occurrence matrix!
- int ncols = numOTUS;//rows of inital matrix
- int nrows = thisLookUp.size();//OTUs
+ int nrows = numOTUS;//rows of inital matrix
+ int ncols = thisLookUp.size();//groups
double initscore = 0.0;
- //transpose matrix
- int newmatrows = ncols;
- int newmatcols = nrows;
-
- //swap for transposed matrix
- nrows = newmatrows;//ncols;
- ncols = newmatcols;//nrows;
-
- vector<int> initcolumntotal(ncols, 0);
- vector<int> initrowtotal(nrows, 0);
+
+ vector<int> initcolumntotal; initcolumntotal.resize(ncols, 0);
+ vector<int> initrowtotal; initrowtotal.resize(nrows, 0);
vector<double> stats;
TrialSwap2 trial;
}
//
//
- trial.update_row_col_totals(co_matrix, rowtotal, columntotal);
+ //trial.update_row_col_totals(co_matrix, rowtotal, columntotal);
if (metric == "cscore") {
stats.push_back(trial.calc_c_score(co_matrix, rowtotal));