예제 #1
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
예제 #2
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)
예제 #3
0
def _func(
    self,
    key,
    signature_datasets,
    signature_profile,
    signature_CUTOFF,
    pyvis,
    #           WORKDIR,
):
    vdf = signature_datasets
    signature_score = vdf.dot(signature_profile)
    #     ax.set_ylim(0,5000)
    ppf = pyext.dist2ppf(signature_score)
    silent = 1
    if not silent:
        fig, ax = plt.subplots(1, 1)
        ax.set_ylabel('signature_score')
        ax.set_xlabel('percentage')
        plt.scatter(ppf, signature_score)
        ax = plt.gca()
        ax.set_xlim(0.95, 1.01)
        ax.grid(1)

        pyvis.abline(x0=signature_CUTOFF)


#     CUTOFF = 0.99 ### top 1% of
    _targets = vdf.index[ppf > signature_CUTOFF]
    #     with pyext.getPathStack([WORKDIR,key],force=1) as stack:
    pyext.printlines(_targets, pyext.f('_temp-{key}-.it'))
    return _targets
예제 #4
0
 def _worker(sample):
     sample = attrdict.AttrDict(sample)
     sample.title = "_".join([sample[k] for k in "data_acc,age,tissue,genotype,ztime,temperature".split(",")])
     res  = res= pyext.jf2( template_common())
     res = '\n'.join([x.strip() for x in res.splitlines()])
     sample.soft_text = res        
     pyext.printlines([sample.soft_text], OUTDIR / pyext.f("{sample.data_acc}.soft.txt"))
예제 #5
0
def job_process(d,context=None):
    if context is None:
        context = pymisca.header.get__frameDict(level=1)
    _ = pyext.printlines([pyext.ppJson(d)],d['OFNAME']+'.json')
    d['FUNCTION'] = tree__worker__interpret(d['FUNCTION'],context)
    res = d['FUNCTION'](d,context) 
    return res
예제 #6
0
 def job_saveFig(
     figs,
     DIR,
     templateFile,
     exts=[
         'png',
     ],
     dpi=160,
 ):
     templateFile = str(templateFile)
     dfig = saveFigDict(figs, DIR='.', exts=exts, dpi=dpi)
     dfig['fignames'] = [
         x for x in dfig['fignames'] if x.endswith('.png')
     ]
     buf = [pyext.ppJson(dfig)]
     ofname = 'figures.json'
     pyext.printlines(buf, ofname)
     return dfig
예제 #7
0
# OUTDIR = WORKDIR() / "final_soft"
OUTDIR = WORKDIR() / "get_soft_text"

pyext.real__dir(dirname=OUTDIR)
_samples = ns.sample_init_full()

for sample in _samples:
    print '[template_finalise]', sample['data_acc'], '...'
    try:
        ns.sample_template_find_curated(sample)
        #     continue
        ns.sample_template_finalise(sample)
        res = sample['template_final']
        res = '\n'.join([x.strip() for x in res.splitlines()])
        sample.soft_text = res
        pyext.printlines([sample.soft_text], OUTDIR /
                         pyext.f("{sample.data_acc}.autofilled.soft.txt"))
    except Exception as e:
        print('FAILED')
        print(str(e))

template = u'''
^SERIES = 0829-polyq
!Series_title = RNA-Seq and ChIP-Seq profiling of ELF3, an prion-like domain-containig in ELF3 that functions as a
thermosensor in Arabidopsis.
!Series_summary = Temperature is a major environmental variable governing plant growth and
development. ELF3 contains a polyglutamine (polyQ) repeat 8–10, embedded within a predicted prion domain (PrD). We find the length of the polyQ repeat correlates with thermal responsiveness. Plants from hotter climates appear to have lost the PrD domain, and these versions of ELF3 are stable at high temperature and lack thermal responsiveness. ELF3 temperature sensitivity is also modulated by the levels of ELF4, indicating that ELF4 can stabilise ELF3 function. This RNA-Seq dataset provides evidence for the hypothetical ELF3 function of temperature sensing .
!Series_overall design = Single samples were taken at each time point. RNA-Seqs and ChIP-Seqs were performed for different genotypes at different temperature and objective time. 
!Series_contributor = Jaehoon Jung
!Series_contributor = Katja, Jaeger
!Series_contributor = Feng, Geng
{% for sample in _samples %}
예제 #8
0
        "xlabel":"tempResponsive",
         "ylabel":"PIF7_Dependent",
        "title":"Fisher exact test: p={pval}",
    }
    },
   {
    "FUNCTION":"!{plotters.venn_diagram}",
    "OFNAME":"venn-diagram-2.svg",
    "index1":"!{pyext.readData('/home/feng/static/figures/1126__PIF7__Venn__pif7Resp-AND-pif7SimpleBound/Venn-index.csv',)['ind1']}",
    "index2":"!{pyext.readData('/home/feng/static/figures/1126__PIF7__Venn__pif7Resp-AND-pif7SimpleBound/Venn-index.csv',)['ind2']}",
    "axis":{
        "xlabel":"pif7_resp",
         "ylabel":"PIF7_bound",
        "title":"Fisher exact test: p={pval}",
    }
    },    
]
'''
pyext.printlines([d],'all-plots.json')
d_s = simpleeval.EvalWithCompoundTypes().eval(d)
# d_s = d_s[-2:]
htmlLines=['<a href="./">Parent_Directory</a><br>',
          '<a href="all-plots.json">all-plots.json</a>']

if __name__ == '__main__':
	with (Path(__file__)+'.result').makedirs_p() as d:
		# res = map(job_process,d_s);
		htmlLines.extend(res)
		pyext.printlines(htmlLines,'figure.html')
	print('[INFO] results created in %s'%d.realpath())