for i in range(max_gen): p=x[-1];q=1-p x+=[(w11*p*p+w01*p*q)/(w11*p*p+2*w01*p*q+w00*q*q)] return pd.Series(x) df=[];dom=[] H = [0, 0.5, 1, 2] index = map(lambda h: '$h$={}'.format(h), H) max_gen = 200 for h in H: df+=[f(x0,s,h,max_gen)] dom+=[(1+s,1+h*s, 1)] df=pd.DataFrame(df,index=index).T dom=pd.DataFrame(dom,index=index,columns=['AA','aA','aa']).T.iloc[::-1] plt.figure(figsize=(4, 2.5), dpi=dpi) # ax=plt.subplot(1,3,1); df.plot(ax=plt.gca(), linewidth=1, legend=False, color=pplt.getColorMap(len(H))); plt.ylim([0, 1.01]) plt.xlabel('Generations'); plt.ylabel('Carrier Frequency') # pd.Series(utl.sig((np.arange(max_gen)+1)*s/2 + utl.logit(x0))).plot(style='--',linewidth=2,color='k') plt.grid() # ax=plt.subplot(1,3,2); # df=2*df*(1-df) # df.plot(ax=ax,linewidth=2,legend=False);plt.xlabel('Generations');plt.ylabel('Heterozygosity ($2pq$)') # plt.grid();plt.ylim([0,0.55]) # ax=plt.subplot(1,3,3); # dom.plot(ax=ax,grid=True,linewidth=2);plt.xlabel('Genotype');plt.ylabel('Relative Fitness') plt.legend(loc='best'); plt.gca().locator_params(nbins=3); plt.gcf().subplots_adjust(bottom=0.2)
df = pd.concat([a[col].rank(ascending=False).loc[v.FBID.values] for col in paddings], axis=1) pvals = a[paddings].apply(lambda xy: getPvalAUC(xy, v)) # df = pd.DataFrame(a[col].rank(ascending=False).loc[v.FBID.values]) dff = pd.DataFrame( [pd.Series(df[col].sort_values(ascending=False).values, index=range(1, df.shape[0] + 1), name=col) for col in df.columns]).T dff.columns = map(lambda x: 'AUC={}, {}'.format(1 - np.round(x[3] / Genes.shape[0], 2), pvals[x[0]]), zip(dff.columns, dff.median(), dff.min(), dff.mean())) dff = N - dff if df.shape[1] == 1: dff.plot(ax=plt.gca(), color='r') else: dff.plot(ax=plt.gca(), colors=pplt.getColorMap(df.shape[1]), rotation=90) # plt.title('padding={:.0f}K'.format(padding / 1000)) plt.plot([1, df.shape[0]], [1, N], ls="--", c=".3") xticks = np.unique(np.append((np.round(plt.xticks()[0][:-1])).astype(int), df.shape[0])) if v.shape[0] < 10: plt.xticks(xticks, v.name, rotation=30) else: plt.xticks(xticks) yticks = plt.yticks()[0] # yticks=yticks.max()-yticks plt.xlim([1, df.shape[0]]) # plt.yticks(yticks,N-yticks) plt.ylim([0, 16995]) plt.yticks([0, 2000, 7000, 12000, 17000], [17000, 15000, 10000, 5000, 0])