Example #1
0
 def generate(self, Q1, Q2, R1, log_scale=False):
     # Module #
     from gMiner.operations.genomic_manip.scores import mean_score_by_feature
     # Get all the values (fills memory) #
     manip = mean_score_by_feature()
     x = [feature[3] for chrom in R1 for feature in manip(Q1.read(chrom), R1.read(chrom))]
     y = [feature[3] for chrom in R1 for feature in manip(Q2.read(chrom), R1.read(chrom))]
     # Graph it #
     fig, axes = make_default_figure()
     axes.set_title('Scatter plot of "' + Q1.name + '" against "' + Q2.name + '"' + \
                    ' in "' + R1.name + '"')
     axes.set_xlabel('Score of "' + Q1.name + '" [unspecified units]')
     axes.set_ylabel('Score of "' + Q2.name + '" [unspecified units]')
     axes.plot(x,y,'.')
     # Logarithmic scale option #
     if log_scale:
         axes.set_xscale('log')
         axes.set_yscale('log')
     widen_axis(axes)
     # Return a figure #
     return fig
Example #2
0
def create_bins(X, num_of_bins=10):
    for x in X:
        length = (x[1] - x[0]) / num_of_bins
        for i in xrange(num_of_bins):
            yield (x[0]+i*length, x[0]+(i+1)*length, x[2], x[3], x[4])

from bbcflib import track
from gMiner.operations.genomic_manip.scores import mean_score_by_feature
manip = mean_score_by_feature()
with track.load('/scratch/genomic/tracks/pol2.sql') as a:
    with track.load('/scratch/genomic/tracks/ribosome_proteins.sql') as b:
        with track.new('/tmp/manual.sql') as r:
            for chrom in a:
                r.write(chrom, manip(a.read(chrom), create_bins(b.read(chrom))))
            r.meta_chr   = a.meta_chr
            r.meta_track = {'datatype': 'qualitative', 'name': 'Mean score per bin', 'created_by': 'gMiner example script'}