In [4]:
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import sys,os
path='/'.join(os.getcwd().split('/')[:-4])
sys.path.insert(1,path)
import Utils.Util as utl
import pandas as pd
pd.options.display.max_rows = 20;
pd.options.display.expand_frame_repr = True
from IPython.display import display
import seaborn as sns
import Scripts.HLI.Kyrgyz.PBS as pbs
path=utl.home + 'kgz/Fst/'
a=pd.read_pickle(path+'fst.df')
b=-(a.dropna().rank(ascending=False)/a.shape[0]).apply(np.log10)

In [72]:
c=b.xs('fst',1,2)[['Healthy','Sick']]
c.columns = c.columns.tolist()
c['hue']='other'
def quan(x,q): return x>=x.quantile(q)
def plot(c,I):
    c['hue']='other';c.loc[I,'hue']='top';sns.pairplot(c,hue='hue',palette={'other':'b','top':'r'})

In [69]:
plot(c,quan(c[('Healthy','Sick')]))



In [73]:
plot(c,quan(-c[('Sick','EAS')],0.99))



In [120]:


In [191]:
pops=('Healthy','Sick')
x=a[pops].dropna()

#x.n= x.n.apply(lambda x: utl.roundto(x,))
l,u=a[('Healthy','Sick')].n.quantile(1-0.999),a[('Healthy','Sick')].n.quantile(0.9995)

#x=x[(x.n>l) & (x.n<u)]
x=x.set_index('n',append=True).reorder_levels([2,0,1]).sort_index().fst

o=x.groupby(level=0).apply(lambda x: x[x>x.quantile(0.9999)].loc[x.name])
o=o.reset_index('n',drop=True).sort_index()

#sns.jointplot(data=a[('Healthy','Sick')],x="n", y="fst", kind="kde");
ax=a[('Healthy','Sick')].plot.scatter(x='n',y='fst',alpha=0.075)
#a[('Healthy','Sick')].loc[o.index].plot.scatter(x='n',y='fst',alpha=0.5,color='r',ax=plt.gca())



In [193]:
pops=('Healthy','Sick')
x=a[pops].dropna()

#x.n= x.n.apply(lambda x: utl.roundto(x,))
l,u=a[('Healthy','Sick')].n.quantile(1-0.999),a[('Healthy','Sick')].n.quantile(0.9995)

#x=x[(x.n>l) & (x.n<u)]
x=x.set_index('n',append=True).reorder_levels([2,0,1]).sort_index().fst

o=x.groupby(level=0).apply(lambda x: x[x>x.quantile(0.9999)].loc[x.name])
o=o.reset_index('n',drop=True).sort_index()

#sns.jointplot(data=a[('Healthy','Sick')],x="n", y="fst", kind="kde");
ax=a[('Healthy','Sick')].plot.scatter(x='n',y='fst',alpha=0.075)
a[('Healthy','Sick')].loc[o.index].plot.scatter(x='n',y='fst',alpha=0.15,color='r',ax=plt.gca())


Out[193]:
<matplotlib.axes._subplots.AxesSubplot at 0x14a1b2550>

In [215]:
reload(pbs);
pbs.GeneLenNumSNPs('EYS')



In [5]:
reload(pbs);
pbs.pbs()


/Users/airanmehr/miniconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family [u'serif'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))