def test_bin_distance2(self):
     ''' Test log2 calculation with short window. '''
     maskMatrix = analyseInteraction.maskMatrix(self.inMatrix2)
     maskMatrix.binDirection(maxl=1)
     df = maskMatrix.binDF
     self.assertTrue(self.compna(df['log2'], pd.Series(
         [np.nan, 1, 0, 0])))
Пример #2
0
 def test_dataframe_generation(self):
     ''' checking bin directionality calculation '''
     maskMatrix = analyseInteraction.maskMatrix(self.inMatrix1)
     maskMatrix.binDirection()
     df = maskMatrix.binDF
     self.assertTrue(
         self.compna(
             df['group'],
             pd.Series([
                 'chr1', 'chr1', 'chr1', 'chr2', np.nan, 'chr2', 'chr2',
                 'chr2', 'chr3'
             ])))
     self.assertTrue(
         self.compna(
             df['up'],
             pd.Series([0, 0.125, 0.25, 0, np.nan, 0.125, 0.25, 0.375, 0])))
     self.assertTrue(
         self.compna(
             df['down'],
             pd.Series([0.25, 0.125, 0, 0.375, np.nan, 0.25, 0.125, 0, 0])))
     self.assertTrue(
         self.compna(
             df['inter'],
             pd.Series(
                 [0.625, 0.625, 0.625, 0.5, np.nan, 0.5, 0.5, 0.5, 0.875])))
     self.assertTrue(
         self.compna(
             df['log2'],
             pd.Series(
                 [np.nan, 0, np.nan, np.nan, np.nan, 0, 0, np.nan,
                  np.nan])))
 def test_dataframe_generation(self):
     ''' checking bin directionality calculation '''
     maskMatrix = analyseInteraction.maskMatrix(self.inMatrix1)
     maskMatrix.binDirection()
     df = maskMatrix.binDF
     self.assertTrue(self.compna(df['group'], pd.Series(
     ['chr1', 'chr1', 'chr1', 'chr2', np.nan, 'chr2', 'chr2', 'chr2', 'chr3'])))
     self.assertTrue(self.compna(df['up'], pd.Series(
         [0, 0.125, 0.25, 0, np.nan, 0.125, 0.25, 0.375, 0])))
     self.assertTrue(self.compna(df['down'], pd.Series(
         [0.25, 0.125, 0, 0.375, np.nan, 0.25, 0.125, 0, 0])))
     self.assertTrue(self.compna(df['inter'], pd.Series(
         [0.625, 0.625, 0.625, 0.5, np.nan, 0.5, 0.5, 0.5, 0.875])))
     self.assertTrue(self.compna(df['log2'], pd.Series(
         [np.nan, 0, np.nan, np.nan, np.nan, 0, 0, np.nan, np.nan])))
Пример #4
0
        '    median bin count: %.0f' %(np.median(colSums))
    )
# Extract combined bin data
logData += '\nCombined Samples:\n  Bin Data:\n%s\n%s\n' %(
    '    bin number: %s' %(genomeBins.binCount),
    '    bins below minimum: %s' %(sum(failedBins))
)
# Save log files
for prefix in prefixList:
    with open(prefix + '.matrixLog', 'w') as outFile:
        outFile.write(logData)
# Normalise matrices
if sum(failedBins) < genomeBins.binCount:
    # Loop through count matrices
    for prefix in prefixList:
        # Normalise matrix
        normMatrix, biasData = interactionMatrix.normaliseMatrix(
            prefix + '.countMatrix.gz', failedBins)
        # Save normalised interactions
        np.savetxt(prefix + '.normMatrix.gz', normMatrix, '%.6f', '\t',
            header = '\t'.join(genomeBins.binNames), comments = '')
        # Extract bin level data
        maskMatrix = analyseInteraction.maskMatrix(prefix + '.normMatrix.gz')
        maskMatrix.binDF['bias'] = biasData
        maskMatrix.binDirection()
        maskMatrix.binDistance()
        maskMatrix.binDF.to_csv(prefix + '.binData', '\t', '')
        # Extract global data
        distance = maskMatrix.combinedDistance(0.1)
        np.savetxt(prefix + '.dist.gz', distance, '%s', '\t')
Пример #5
0
 def test_bin_distance1(self):
     ''' Test log2 calculation with standard window. '''
     maskMatrix = analyseInteraction.maskMatrix(self.inMatrix2)
     maskMatrix.binDirection()
     df = maskMatrix.binDF
     self.assertTrue(self.compna(df['log2'], pd.Series([np.nan, 1, -1, 0])))