@merge( buildExpressionTracks, "expression.correlation")
def buildExpressionCorrelation( infiles, outfile):
    '''compute correlation between replicates in expression sets.'''

    outf = open(outfile, "w")
    outf.write( "track\treplicate1\treplicate2\t%s\n" % "\t".join(Stats.CorrelationTest().getHeaders()))
    offset = 10
    for filename in infiles:
        if not filename.endswith(".data"): continue
        vals = []
        headers = []
        track = filename[:-len(".data")]
        inf = open( filename, "r")
        for line in inf:
            if line.startswith("#"): continue
            data = line[:-1].split("\t")
            if line.startswith("cluster_id"):
                nreplicates = len(data) - offset
                for x in range(nreplicates):
                    headers.append( data[offset+x] )
                    vals.append( [] )
                continue
            for x in range( 0, nreplicates ):
                vals[x].append( float(data[offset+x]) )

        for x in range(1-nreplicates):
            for y in range( x+1, nreplicates):
                outf.write( "\t".join( (track,
                                        headers[x],
                                        headers[y],
                                        str( Stats.doCorrelationTest( vals[x],
                                                                      vals[y]) ) ) ) + "\n" )
    outf.close()

############################################################
############################################################
############################################################
## 
############################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD.py/buildExpressionCorrelation/swapped operands of `-`