Commits

Qian Zhu  committed fa25fba

make topological overlap calculation more efficient

  • Participants
  • Parent commits 13c34a8

Comments (0)

Files changed (2)

File src/seekwriter.cpp

 	fprintf(stderr, "Finished step 1: tranform z-score back to pearson\n");
 	vector<float> vecSum;
 	CSeekTools::InitVector(vecSum, trueSize, CMeta::GetNaN());
-	for(i=0; i<m.GetNumSet(); i++){	
+	for(i=0; i<m.GetNumSet(); i++)
 		vecSum[i] = 0;
-	}
 
 	for(i=0; i<m.GetNumSet(); i++){	
 		for(j=i+1; j<m.GetNumSet(); j++){
 	private(i, j, d) schedule(dynamic)
 	for(i=0; i<m.GetNumSet(); i++){	
 		for(j=i+1; j<m.GetNumSet(); j++){
-			double tsum = 0;
-			float *pi = &fs[i];
-			float *pj = &fs[j];
+			float tsum = 0;
+			float *pi = &fs[i*trueSize];
+			float *pj = &fs[j*trueSize];
 			for(k=0; k<m.GetNumSet(); k++){
-				tsum += (double) (*pi) * (double) (*pj);
-				pi++;
-				pj++; 
+				tsum += pi[k] * pj[k];
 			}
-			tsum -= (double)fs[i*trueSize + i] * (double)fs[j*trueSize + i];
-			tsum -= (double)fs[i*trueSize + j] * (double)fs[j*trueSize + j];
-			double tmin = 0;
+			tsum -= pi[i] * pj[i];
+			tsum -= pi[j] * pj[j];
+			float tmin = 0;
 			if(vecSum[i] < vecSum[j])
-				tmin = (double) vecSum[i];
+				tmin = vecSum[i];
 			else
-				tmin = (double) vecSum[j];
-			double to = (tsum + (double) d) / (tmin + 1.0 - (double) d);
+				tmin = vecSum[j];
+			float to = (tsum + d) / (tmin + 1.0 - d);
 			res.Set(i, j, (float) to); //temporary matrix to store the results
 			//fprintf(stderr, "%.3e\n", to);	
 		}

File tools/SeekReader/SeekReader.cpp

 			for(j=i+1; j<m.GetNumSet(); j++){
 				t = veciGenes[allRGenes[j]];
 				if(CMeta::IsNaN(d = Dat.Get(s,t))) continue;
-				vecSum[allRGenes[i]]+=d;
-				vecSum[allRGenes[j]]+=d;
+				vecSum[allRGenes[i]]+=pow(abs(d), 9);
+				vecSum[allRGenes[j]]+=pow(abs(d), 9);
 			}
 		}
 		vector<float> backupSum;
 		float percentile = vecSum[index];
 		vector<string> limitedGenes;
 		for(i=0; i<backupSum.size(); i++){
-			if(backupSum[i] >= percentile){
+			if(backupSum[i] > percentile){
 				limitedGenes.push_back(vecstrGenes[i]);
 			}
 		}