コード例 #1
0
ファイル: workspace.py プロジェクト: airanmehr/bio
import popgen.Run.TimeSeries.RealData.Utils as rutl
import scipy as sc
import popgen.Plots as pplt
import popgen.Run.TimeSeries.RealData.Utils as rutl
import popgen.Run.TimeSeries.RealData.Data as dta
import popgen.TimeSeries.Markov as mkv
S=np.arange(-1,1,0.05).round(2);chroms=['2L','2R','3L','3R','X']
pd.read_pickle('/home/arya/out/real/HMM1x/h5.000000E-01.df').loc[i]
scores = utl.getEuChromatin(rutl.loadScores(skipHetChroms=True)).loc[chroms].rename('score')
cdAll=utl.getEuChromatin(pd.read_pickle('/home/arya/out/real/CD.F59.df').loc[chroms])
freq=lambda x:x.xs('C',level='READ',axis=1).sum(1)/x.xs('D',level='READ',axis=1).sum(1)
s=estimateS(cdAll.groupby(axis=1,level='GEN').apply(freq)[[0,37,59]])

x=pd.read_pickle('/home/arya/out/real/HMM1x/h5.000000E-01.df').loc[chroms,0.5]
pplt.Manhattan(utl.zpvalgenome(utl.scanGenome(utl.zpvalgenome2tail(s))))
(x.s*(x.alt-x.null)).hist(bins=100)
D=cdAll.xs('D',axis=1,level='READ')
d=D.median(1).rename('d')
f=lambda x:(x.alt-x.null)
pplt.Manhattan(utl.scanGenome(x2p(f(x))))
x2p=lambda X2: -pd.Series(1 - sc.stats.chi2.cdf(X2, 1),index=X2.index).apply(np.log)
y=(f(pd.read_pickle('/home/arya/out/real/HMM/h5.000000E-01.df')[0.5]).loc[chroms].rename('y')*pd.read_pickle('/home/arya/out/real/HMM/h5.000000E-01.df')[0.5].s).dropna()
y.sort_values()
y=utl.zpvalgenome(pd.read_pickle('/home/arya/out/real/HMM/h5.000000E-01.df')[0.5].s.loc[chroms])
i=utl.getEuChromatin(y.sort_values()).index[-20]

pplt.GenomeChromosomewise(utl.scanGenome(utl.zpvalgenome(y.abs())))
pplt.GenomeChromosomewise(utl.scanGenome(utl.zpvalgenome(s)))

scan=pd.concat([utl.scanGenome(utl.zpvalgenome(s)).rename('win'),utl.scanGenomeSNP(utl.zpvalgenome(s)).rename('snp')],1)
コード例 #2
0
ファイル: Yeast.py プロジェクト: airanmehr/bio
        cd=cd.reset_index()
        cd.CHROM=cd.CHROM.apply(lambda x:roman.fromRoman(x[3:]))
        cd=cd.set_index(['CHROM','POS'])
    except:
        pass
    return


a=load()
x0=a[(1,0,'C')]/a[(1,0,'D')]
xt=a.loc[:,pd.IndexSlice[:,540,'C']].sum(1)/a.loc[:,pd.IndexSlice[:,540,'D']].sum(1)-1e-3
import popgen.Plots as pplt
odd=xt.apply(utl.logit)- x0.apply(utl.logit)

dif=(xt-x0).abs()
pplt.Manhattan(utl.zpvalgenome2tail(odd))
import popgen.TimeSeries.Markov as mkv

c=mkv.Markov.computeTransition(0,N=100).loc[0.2].rename(100)
reload(mkv)
d=mkv.Markov.computeTransition(0,N=1000,nu0_N=100).loc[0.2].rename('appr100')
b=mkv.Markov.computeTransition(0,N=1000).loc[0.2].rename(1000)

a=pd.concat([b,d],1).dropna()
a.iloc[:,0]-a.iloc[:,1]
a=(a/a.sum())
a
a.plot()
d.plot()

a.loc[0.01]