예제 #1
0
def _func(job, key, WORKDIR, chipseq_targets_peaks):
    fig, axs = plt.subplots(2, 2, figsize=[12, 12])
    axs = axs.ravel()

    with pyext.getPathStack([WORKDIR, key], force=1):
        GSIZE = "/home/feng/ref/ATH-TAIR10/genome.sizes"
        peakFile = chipseq_targets_peaks['LAST_FILE']
        featFile = sutil.bed__leftSummit(
            "/home/feng/ref/ATH-TAIR10/annotation/genes.gtf.cds", GSIZE=GSIZE)
        pyext.file__link(peakFile, "PEAK_FILE.bed", force=1)
        pyext.file__link(featFile, "FEAT_FILE.bed", force=1)
        res = synotil.qcplots.qc_summitDist(
            #             chipseq_targets_genes_peaks,
            peakFile,
            featFile,
            GSIZE=GSIZE,
            axs=axs,
            CUTOFF=500,
        )
        df = res[0]
        #         pyext.readData(peakFile,header=None).set_index(3,drop=0).reindex(df['acc'])
        #         df =  df.set_index('acc',drop=0).reindex(pyext.readData(peakFile,header=None).set_index(3))
        df.to_csv("PEAK_DIST.csv", index=0)

        lst = df.dropna()['feat_acc'].drop_duplicates().values.tolist()
        with pyext.getPathStack([WORKDIR, key], force=1) as stack:
            pyext.printlines(lst, "OUT.it")

    return dict(LAST_DIR=WORKDIR / key)
예제 #2
0
    def _run(self):
        kw = self._data
        BIGWIG_PAIRS = kw['BIGWIG_PAIRS']
        BIGWIG_FILES = kw['BIGWIG_FILES']
        BIGWIG_NAMES = kw['BIGWIG_NAMES']
        PARAMS = kw['PARAMS']
        FORCE = kw['FORCE']
        NCORE = kw['NCORE']
        #         PARAMS['NCORE'] = kw['NCORE']
        #         kw['LAST_FILE'] = kw['OFNAME'] = OFNAME = kw['OFNAME'].realpath()
        #         kw['LAST_DIR'] = OFNAME.dirname()
        kw['PEAK_FILE'] = PEAK_FILE = kw['PEAK_FILE'].realpath()
        assert kw['OUTDIR']
        kw['OUTDIR'] = OUTDIR = kw['OUTDIR'].realpath()
        AXIS_DICTS = kw['AXIS_DICTS']

        if BIGWIG_PAIRS:
            assert not BIGWIG_NAMES and not BIGWIG_FILES, (
                'conflict arguments')
            BIGWIG_FILES, BIGWIG_NAMES = zip(BIGWIG_PAIRS)
            pass
        else:
            assert BIGWIG_FILES
            if not BIGWIG_NAMES:
                BIGWIG_NAMES = map(pyext.getBname, BIGWIG_FILES)

        with pyext.getPathStack([OUTDIR], force=1):
            OFNAME = 'DONE'
            #         OFNAME =
            if not FORCE and pyext.file__notEmpty(OFNAME):
                pass
            else:
                figs, (bwTable, bwAvg) = sjob.figs__peakBW(
                    peakFile=PEAK_FILE,
                    bwFiles=BIGWIG_FILES,
                    outIndex=None if not len(BIGWIG_NAMES) else BIGWIG_NAMES,
                    NCORE=NCORE,
                    **PARAMS)
                fig = figs.values()[0]
                for (axis, d_ax) in zip(fig.axes, AXIS_DICTS):
                    pyext.obj__dict__call(axis, d_ax)

                for OFNAME in ['MAIN.png', 'MAIN.svg']:
                    plotters.fig__save(fig, OFNAME)
                bwTable.to_pickle('bwTable.pk')
                bwAvg.to_pickle('bwAvg.pk')
                pyext.printlines([pyext.dppJson(kw)], "DATA.json")
                pyext.printlines(['DONE'], 'DONE')


#         if not OFNAME:
#         if not OFNAME
#     "outerRadius":500,
#     "NCORE":4,
#     "peakFile":'/home/feng/static/lists/1112__ELF3__chipTarg.narrowPeak',
#     "bwFiles":lambda self,key,DATA_ACC_LIST,chipseq_db:
#         map(chipseq_db['get__chipseq__bwfile'],DATA_ACC_LIST)
#     "OFNAME":

#     return
예제 #3
0
def _func(job, key, WORKDIR):
    GSIZE = "/home/feng/ref/ATH-TAIR10/genome.sizes"
    with pyext.getPathStack([WORKDIR, key], force=1) as stack:
        res = sutil.bed__summit(
            '/home/feng/static/lists/1112__ELF3__chipTarg.narrowPeak',
            GSIZE=GSIZE,
            inplace=False)
        res = stack.d / res
    return dict(LAST_FILE=res)
예제 #4
0
def _func(
    self,
    key,
    OUTDIR,
    fig_meta,
    meta_chip,
    chipseq_targets_peaks_file,
):
    from pymisca.plotters import plotters
    plotters.fig__save
    #     key = 'figS4E_o'
    key = 'figS4E_0905'
    df = fig_meta[[key]].dropna().astype(int)
    df = df.sort_values(key)
    DATA_ACC_LIST = df.index.tolist()
    mcurr = meta_chip.reindex(DATA_ACC_LIST)
    bwFiles = mcurr['RPKMFile']

    # bedFile = '/home/feng/envs/Fig_POLYQ/bedFile.bed'
    #     bedFile = '/home/feng/static/lists/1112__ELF3__chipTarg.narrowPeak'
    res = sutil.extract_bigwig_multiple(
        bwFiles=mcurr.RPKMFile,
        bedFile=chipseq_targets_peaks_file,
        #         radius=100,stepSize=10,NCORE=6,
        radius=100,
        stepSize=10,
        NCORE=6,
        outIndex=pyext.df__format(mcurr, '{bname}_{index}'),
    )

    tab = dfc = pyutil.colGroupMean(res, ).apply(sutil.log2p1)

    with pyext.getPathStack([OUTDIR], force=1):
        plt.figure(figsize=[12, 8])
        dfc.boxplot(rot='vertical', )
        plt.ylabel('average binding in RPKM')
        #         plt.gcf().savefig('fig1.png')
        #         plt.gcf().
        plotters.fig__save(plt.gcf(), pyext.f('{key}.png'))

        # res.head()
        tab2 = res.mean(axis=0)
        pile = tab2.to_frame().reset_index().pivot_table(index='bwFile',
                                                         columns='pos',
                                                         values=0)
        pile = pile.T
        pyvis.df__heatmap(pile, figsize=[12, 12])
        #         pyvis.heatmap(pile, xtick=pile.columns,ytick=pile.index)
        plotters.fig__save(plt.gcf(), pyext.f('{key}_pileup_heatmap.png'))
예제 #5
0
def _func(self, key, OUTDIR, signature_targets):
    df = pd.DataFrame({"rnaseq_signature_targets": signature_targets})
    with pyext.getPathStack([OUTDIR], force=1):
        df.to_csv("gene_lists_dataframe.csv", index=0)
#     pyext.printlines(signature_targets)
    pass
예제 #6
0
 def export(self):
     df = pd.DataFrame({"rnaseq_signature_targets": self.signature_targets})
     with pyext.getPathStack([self.OUTDIR],force=1):
         df.to_csv("gene_lists_dataframe.csv",index=0)
     pass