In [1]:
GENENAME = 'AGO1'

In [2]:
%run '../ipython_startup.py'


Importing commonly used libraries: 
            os, sys 
            numpy as np 
            scipy as sp 
            pandas as pd 
            matplotlib as mp 
            matplotlib.pyplot as plt
            datetime as dt 
            mclib_Python/flagging as fg

Creating project level variables: 
        MCLAB = /home/jfear/mclab 
        PROJ = /home/jfear/mclab/cegs_ase_paper 
        TODAY = 20151115

Adding ['scripts/mclib_Python', 'scripts/ase_Python'] to PYTHONPATH


In [3]:
import gff as mcgff
import bam as mcbam
import numpy as np
from glob import glob
import pandas as pd
import seaborn
import matplotlib.pyplot as plt
%matplotlib inline

In [4]:
# Import GFF File and Get gene location
db = mcgff.FlyGff('/home/jfear/mclab/useful_dmel_data/flybase551/flybase_files/dmel-all-no-analysis-r5.51.gff')
gene = mcgff.FlyGene(GENENAME, db)

In [5]:
def get_pileup(fname, chrom, start, end):
    """ Function to pull out reads from BAM files. """
    bam = mcbam.Bam(fname)
    pileup = bam.get_pileup(chrom, start, end)
    return pd.Series(pileup)

In [20]:
# Get list of lines
with open('/home/jfear/lines.txt', 'r') as FH:
    lines = FH.read().rstrip('\n').split('\n')

# Iterate over lines
matrix = list()
for LINE in lines:    
    pileups = list()
    for FILE in glob('/home/jfear/cegs_oe/combined/{}_*.sorted.bam'.format(LINE)):
        pileups.append(get_pileup(FILE, gene.chrom, gene.start, gene.end))

    # Sum coverage
    matrix.append(pd.concat(pileups, axis=1).fillna(0).sum(axis=1))

In [25]:
df = pd.concat(matrix, axis=1).fillna(0)

In [28]:
df.columns = lines

In [31]:
seaborn.heatmap(df.T)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-31-dac86c793b49> in <module>()
----> 1 seaborn.heatmap(df.T)

/home/jfear/opt/miniconda2/envs/ase/lib/python2.7/site-packages/seaborn/matrix.pyc in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, ax, xticklabels, yticklabels, mask, **kwargs)
    444     if square:
    445         ax.set_aspect("equal")
--> 446     plotter.plot(ax, cbar_ax, kwargs)
    447     return ax
    448 

/home/jfear/opt/miniconda2/envs/ase/lib/python2.7/site-packages/seaborn/matrix.pyc in plot(self, ax, cax, kws)
    224         # Possibly rotate them if they overlap
    225         plt.draw()
--> 226         if axis_ticklabels_overlap(xtl):
    227             plt.setp(xtl, rotation="vertical")
    228         if axis_ticklabels_overlap(ytl):

/home/jfear/opt/miniconda2/envs/ase/lib/python2.7/site-packages/seaborn/utils.pyc in axis_ticklabels_overlap(labels)
    467     try:
    468         bboxes = [l.get_window_extent() for l in labels]
--> 469         overlaps = [b.count_overlaps(bboxes) for b in bboxes]
    470         return max(overlaps) > 1
    471     except RuntimeError:

/home/jfear/opt/miniconda2/envs/ase/lib/python2.7/site-packages/matplotlib/transforms.pyc in count_overlaps(self, bboxes)
    668         """
    669         return count_bboxes_overlapping_bbox(
--> 670             self, np.atleast_3d([np.array(x) for x in bboxes]))
    671 
    672     def expanded(self, sw, sh):

KeyboardInterrupt: 

In [ ]: