loop 可视化

image.png

未写完......

def show_map(self):
control,treat=self.samples
        fig=plt.figure(figsize=(8,4))
        x_start=0.1;awidth=0.7
        fig.suptitle("{}:{:,}-{:,}".format(self.chr,self.start,self.end),fontsize=14)
        #draw Gene annotation.....
        ax=fig.add_axes([x_start,0.1,awidth,0.2],axisbg='w')
        self.adjust_spines(ax,['top','left','right','bottom'],'Genes')
        Regions=["{}:{}-{}".format(self.chr,self.start,self.end),]
        gene_regions=Gene_annotation(self.gtfFile,Regions)
        gene_regions.draw_all_region_genes(ax)
        #draw RNA....
        ax=fig.add_axes([x_start,0.3,awidth,0.2])
        self.adjust_spines(ax,['top','left','right','bottom'],'RNA-seq')
        ax.plot([self.start,self.end],[0,0],linestyle='-', color='k', linewidth=0.5,label=self.chr,gid=self.chr)
        rna_max=self.cut_rna.describe().ix['max',0]
        rna_min=self.cut_rna.describe().ix['min',0]
        for i,r in self.cut_rna.iterrows():
            left=r['start'];height=r['Log2FoldChange'];bottom=0;
            color='#00A145' if r['updown']=='up' else 'blue'
            width=r['end']-r['start']
            ax.bar(left=left, height=height, width=width, bottom=bottom,color=color,align="edge",edgecolor=color)

        #draw treat loop
        ax=fig.add_axes([x_start,0.5,awidth,0.2])
        self.adjust_spines(ax,['top','left','right','bottom'],"{} loop".format(treat))
        print(self.cut_loop[treat])
        for i,r in self.cut_loop[treat].iterrows():
            x=(r['x1']+r['y2'])/2;y=0
            width=r['width'];height=r['height']
            ellipse = mpatches.Ellipse((x,y), width,height,fc='#F3DFEA',ec='#A03B95',linewidth=2,alpha=0.3)
            ax.add_patch(ellipse) 
        ax.set_xlim([self.start,self.end])
        ax.set_ylim([0,1])

        #draw control loop
        ax=fig.add_axes([x_start,0.7,awidth,0.2])
        self.adjust_spines(ax,['top','left','right','bottom'],"{} loop".format(control))
        for i,r in self.cut_loop[control].iterrows():
            x=(r['x1']+r['y2'])/2;y=0
            width=r['width'];height=r['height']
            ellipse = mpatches.Ellipse((x,y), width,height,fc='#D8EADE',ec='#00A144',linewidth=2,alpha=0.3)
            ax.add_patch(ellipse) 
        ax.set_ylim([0,1])


你可能感兴趣的:(loop 可视化)