Beispiel #1
0
 def run(self):
     lens1 = base.newlens(self.lens1, self.position)
     lens2 = base.newlens(self.lens2, self.position)
     if re.search('\d', self.figsize):
         self.figsize = [float(k) for k in self.figsize.split(',')]
     else:
         self.figsize = np.array(
             [1, float(lens1.sum())/float(lens2.sum())])*10
     plt.rcParams['ytick.major.pad'] = 0
     fig, ax = plt.subplots(figsize=self.figsize)
     ax.xaxis.set_ticks_position('top')
     step1 = 1 / float(lens1.sum())
     step2 = 1 / float(lens2.sum())
     base.dotplot_frame(fig, ax, lens1, lens2, step1, step2,
                        self.genome1_name, self.genome2_name)
     gff1 = base.newgff(self.gff1)
     gff2 = base.newgff(self.gff2)
     gff1 = base.gene_location(gff1, lens1, step1, self.position)
     gff2 = base.gene_location(gff2, lens2, step2, self.position)
     block_list = pd.read_csv(self.block_list, header=None)
     bkinfo = pd.read_csv(self.blockinfo,index_col=0)
     bkinfo['chr1'] = bkinfo['chr1'].astype(str)
     bkinfo['chr2'] = bkinfo['chr2'].astype(str)
     align = self.alignment(gff1, gff2, block_list, bkinfo)
     alignment = align[gff1.columns[-int(len(block_list[0].drop_duplicates())):]]
     alignment.to_csv(self.savefile, sep='\t', header=None)
     df = self.pair_positon(
         alignment, gff1['loc'], gff2['loc'], self.colors)
     plt.scatter(df['loc2'], df['loc1'], s=float(self.markersize), c=df['color'],
                 alpha=0.5, edgecolors=None, linewidths=0, marker='o')
     plt.subplots_adjust(left=0.07, right=0.97, top=0.93, bottom=0.03)
     plt.savefig(self.savefig, dpi=500)
     sys.exit(0)
Beispiel #2
0
 def run(self):
     lens1 = base.newlens(self.lens1, self.position)
     lens2 = base.newlens(self.lens2, self.position)
     if re.search('\d', self.figsize):
         self.figsize = [float(k) for k in self.figsize.split(',')]
     else:
         self.figsize = np.array(
             [1, float(lens1.sum()) / float(lens2.sum())]) * 10
     plt.rcParams['ytick.major.pad'] = 0
     fig, ax = plt.subplots(figsize=self.figsize)
     ax.xaxis.set_ticks_position('top')
     step1 = 1 / float(lens1.sum())
     step2 = 1 / float(lens2.sum())
     base.dotplot_frame(fig, ax, lens1, lens2, step1, step2,
                        self.genome1_name, self.genome2_name)
     gff1 = base.newgff(self.gff1)
     gff2 = base.newgff(self.gff2)
     gff1 = base.gene_location(gff1, lens1, step1, self.position)
     gff2 = base.gene_location(gff2, lens2, step2, self.position)
     blast = base.newblast(self.blast, int(self.score), float(self.evalue),
                           gff1, gff2)
     df = self.pair_positon(blast, gff1, gff2, int(self.multiple),
                            int(self.repnum))
     plt.scatter(df['loc2'],
                 df['loc1'],
                 s=float(self.markersize),
                 c=df['color'],
                 alpha=0.5,
                 edgecolors=None,
                 linewidths=0,
                 marker='o')
     plt.subplots_adjust(left=0.07, right=0.97, top=0.93, bottom=0.03)
     plt.savefig(self.savefile, dpi=500)
     sys.exit(0)
Beispiel #3
0
 def run(self):
     axis = [0, 1, 1, 0]
     lens1 = base.newlens(self.lens1, self.position)
     lens2 = base.newlens(self.lens2, self.position)
     if re.search('\d', self.figsize):
         self.figsize = [float(k) for k in self.figsize.split(',')]
     else:
         self.figsize = np.array(
             [1, float(lens1.sum()) / float(lens2.sum())]) * 10
     plt.rcParams['ytick.major.pad'] = 0
     fig, ax = plt.subplots(figsize=self.figsize)
     ax.xaxis.set_ticks_position('top')
     step1 = 1 / float(lens1.sum())
     step2 = 1 / float(lens2.sum())
     base.dotplot_frame(fig, ax, lens1, lens2, step1, step2,
                        self.genome1_name, self.genome2_name, [0, 1])
     gff1 = base.newgff(self.gff1)
     gff2 = base.newgff(self.gff2)
     gff1 = base.gene_location(gff1, lens1, step1, self.position)
     gff2 = base.gene_location(gff2, lens2, step2, self.position)
     bkinfo = pd.read_csv(self.blockinfo, index_col='id')
     if self.blockinfo_reverse == True or self.blockinfo_reverse.upper(
     ) == 'TRUE':
         bkinfo[['chr1', 'chr2']] = bkinfo[['chr2', 'chr1']]
         bkinfo[['block1', 'block2']] = bkinfo[['block2', 'block1']]
     bkinfo['chr1'] = bkinfo['chr1'].astype(str)
     bkinfo['chr2'] = bkinfo['chr2'].astype(str)
     bkinfo[self.classid] = bkinfo[self.classid].astype(str)
     bkinfo = bkinfo[bkinfo['chr1'].isin(lens1.index)
                     & (bkinfo['chr2'].isin(lens2.index))]
     align = self.alignment(gff1, gff2, bkinfo)
     alignment = align[
         gff1.columns[-int(len(bkinfo[self.classid].drop_duplicates())):]]
     alignment.to_csv(self.savefile, header=None)
     df = self.pair_positon(alignment, gff1['loc'], gff2['loc'],
                            self.colors)
     plt.scatter(df['loc2'],
                 df['loc1'],
                 s=float(self.markersize),
                 c=df['color'],
                 alpha=0.5,
                 edgecolors=None,
                 linewidths=0,
                 marker='o')
     ax.axis(axis)
     plt.subplots_adjust(left=0.07, right=0.97, top=0.93, bottom=0.03)
     plt.savefig(self.savefig, dpi=500)
     plt.show()
     sys.exit(0)
Beispiel #4
0
 def run(self):
     length = 1
     axis = [0, 1, 1, 0]
     left, right, top, bottom = 0.07, 0.97, 0.93, 0.03
     lens1 = base.newlens(self.lens1, self.position)
     lens2 = base.newlens(self.lens2, self.position)
     step1 = 1 / float(lens1.sum())
     step2 = 1 / float(lens2.sum())
     if self.ancestor_left != None:
         axis[0] = -0.02
         lens_ancestor_left = pd.read_csv(self.ancestor_left,
                                          sep="\t",
                                          header=None)
         lens_ancestor_left[0] = lens_ancestor_left[0].astype(str)
         lens_ancestor_left[3] = lens_ancestor_left[3].astype(str)
         lens_ancestor_left[4] = lens_ancestor_left[4].astype(int)
         lens_ancestor_left[
             4] = lens_ancestor_left[4] / lens_ancestor_left[4].max()
         lens_ancestor_left = lens_ancestor_left[lens_ancestor_left[0].isin(
             lens1.index)]
     if self.ancestor_top != None:
         axis[3] = -0.02
         lens_ancestor_top = pd.read_csv(self.ancestor_top,
                                         sep="\t",
                                         header=None)
         lens_ancestor_top[0] = lens_ancestor_top[0].astype(str)
         lens_ancestor_top[3] = lens_ancestor_top[3].astype(str)
         lens_ancestor_top[4] = lens_ancestor_top[4].astype(int)
         lens_ancestor_top[
             4] = lens_ancestor_top[4] / lens_ancestor_top[4].max()
         lens_ancestor_top = lens_ancestor_top[lens_ancestor_top[0].isin(
             lens2.index)]
     if re.search('\d', self.figsize):
         self.figsize = [float(k) for k in self.figsize.split(',')]
     else:
         self.figsize = np.array(
             [1, float(lens1.sum()) / float(lens2.sum())]) * 10
     plt.rcParams['ytick.major.pad'] = 0
     fig, ax = plt.subplots(figsize=self.figsize)
     ax.xaxis.set_ticks_position('top')
     base.dotplot_frame(fig, ax, lens1, lens2, step1, step2,
                        self.genome1_name, self.genome2_name,
                        [axis[0], axis[3]])
     gff1 = base.newgff(self.gff1)
     gff2 = base.newgff(self.gff2)
     gff1 = base.gene_location(gff1, lens1, step1, self.position)
     gff2 = base.gene_location(gff2, lens2, step2, self.position)
     if self.ancestor_top != None:
         top = top
         self.ancestor_posion(ax, gff2, lens_ancestor_top, 'top')
     if self.ancestor_left != None:
         left = left
         self.ancestor_posion(ax, gff1, lens_ancestor_left, 'left')
     blast = base.newblast(self.blast, int(self.score), float(self.evalue),
                           gff1, gff2, self.blast_reverse)
     df = self.pair_positon(blast, gff1, gff2, int(self.multiple),
                            int(self.repeat_number))
     ax.scatter(df['loc2'],
                df['loc1'],
                s=float(self.markersize),
                c=df['color'],
                alpha=0.5,
                edgecolors=None,
                linewidths=0,
                marker='o')
     ax.axis(axis)
     plt.subplots_adjust(left=left, right=right, top=top, bottom=bottom)
     plt.savefig(self.savefig, dpi=500)
     plt.show()
     sys.exit(0)