Commits

Aaron Wong committed 49223e3

Added Quantize method that returns -1 for an edge if a gene is missing in a dataset

Comments (0)

Files changed (3)

 	m_fQuantized = true;
 }
 
+size_t CDataPair::Quantize( size_t iY, size_t iX, size_t iZero ) const {
+    float d;
+    if( iY == -1 || iX == -1 ) {
+	return -1;
+    }
+    else if( CMeta::IsNaN( (d = Get( iY, iX )) ) ) {
+	return iZero;
+    }
+    else {
+	return Quantize(d); 
+    }
+}
+
+
+
+
 void CDataPairImpl::Reset( bool fContinuous ) {
 
 	m_vecdQuant.clear( );
 	void SetQuants( const std::vector<float>& vecdBinEdges );
 	size_t Quantize( float dValue ) const;
 	void Quantize( );
+        size_t Quantize( size_t iY, size_t iX, size_t iZero ) const;
+
 	void Save( const char* szFile ) const;
 	
 	
 	size_t Quantize( float dValue, size_t iExperiment ) const;
 	void Quantize( );
 
-
 	/*!
 	 * \brief
 	 * Returns the number of discrete values taken by this PCL pair.
 
 		return ( m_pFilter ? m_pFilter->Quantize( dValue ) : ( m_pDat ? m_pDat->Quantize( dValue ) : -1 ) ); }
 
+
+        size_t Quantize( size_t iY, size_t iX, size_t iZero ) const {
+            float d;
+            if( iY == -1 || iX == -1 ) {
+                return -1;
+            }
+            else if( CMeta::IsNaN( (d = Get( iY, iX )) ) ) {
+                return iZero;
+            }
+            else {
+                return Quantize(d); 
+            }
+        }
+
+
+
 	/*!
 	 * \brief
 	 * Returns the (potentially filtered) value at the requested indices.

tools/Counter/Counter.cpp

             if( psData->m_pDat ) {
                 iTwo = veciGenes[ j ];
                 iVal = -1;
+		/*
                 if( ( iOne != -1 ) && ( iTwo != -1 ) )
                     iVal = psData->m_pDat->Quantize( psData->m_pDat->Get( iOne, iTwo ) );
                 if( iVal == -1 )
                     iVal = psData->m_iZero;
                 if( iVal == -1 )
                     continue;
+		*/
+		iVal = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
+		if( iVal == -1 )
+		    continue;
                 psData->m_pMatCounts->Get( iVal, iAnswer )++;
                 psData->m_pRegularize->Add( psData->m_iDat, *psData->m_pDat, i, j, iVal );
             }
         for( j = ( i + 1 ); j < psData->m_pYes->GetGenes( ); ++j ) {
             if( ( ( iTwo = (*psData->m_pveciGenes)[ j ] ) == -1 ) && ( psData->m_iZero == -1 ) )
                 continue;
-            if( ( iOne == -1 ) || ( iTwo == -1 ) ||
-                    ( ( iBin = psData->m_pDat->Quantize( psData->m_pDat->Get( iOne, iTwo ) ) ) == -1 ) )
-                iBin = psData->m_iZero;
+            //if( ( iOne == -1 ) || ( iTwo == -1 ) ||
+            //        ( ( iBin = psData->m_pDat->Quantize( psData->m_pDat->Get( iOne, iTwo ) ) ) == -1 ) )
+            //    iBin = psData->m_iZero;
+	    iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
             if( iBin == -1 )
                 continue;
             if( CMeta::IsNaN( adYes[ iIndex = ( j - i - 1 ) ] ) ) {
         for( j = ( i + 1 ); j < psData->m_pYes->GetGenes( ); ++j ) {
             if( ( ( iTwo = (*psData->m_pveciGenes)[ j ] ) == -1 ) && ( psData->m_iZero == -1 ) )
                 continue;
-            if( ( iOne == -1 ) || ( iTwo == -1 ) || ( ( iBin = psData->m_pDat->Quantize( psData->m_pDat->Get( iOne, iTwo ) ) ) == -1 ) )
-                iBin = psData->m_iZero;
+            //if( ( iOne == -1 ) || ( iTwo == -1 ) || ( ( iBin = psData->m_pDat->Quantize( psData->m_pDat->Get( iOne, iTwo ) ) ) == -1 ) )
+            //    iBin = psData->m_iZero;
+	    iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
             if( iBin == -1 )
                 continue;
             if( ( iBNTwo = (*psData->m_pveciBNs)[ j ] ) != -1 )