In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import statsmodels
from statsmodels.sandbox.stats.multicomp import multipletests
import matplotlib.pyplot as plt
% matplotlib inline
In [2]:
# check FDR threshold
multipletests(np.repeat(0.002, 4), method = 'fdr_bh')[1]
Out[2]:
In [3]:
alpha = pd.DataFrame({'type': np.tile(['Independent', 'Cumulative'], 4),
'covariate': np.repeat(['study_id', 'empo_3', 'host_scientific_name', 'envo_biome_3'], 2),
'value_ES': [0.847, 0.847, 0.8, 0.024, 0.839, 0.0024, 0.817, 0.0007]})
In [4]:
alpha
Out[4]:
In [5]:
sns.set_style("ticks")
fig, ax = plt.subplots()
fig = sns.barplot(x='covariate', y='value_ES', hue='type', data=alpha)
fig.set_xticklabels(ax.get_xticklabels(), rotation=45)
fig.set(xlabel='RDA selected covariates', ylabel='effect size')
sns.plt.legend(loc='center left',bbox_to_anchor=(1,0.5))
sns.despine()
fig = fig.get_figure()
fig.tight_layout()
fig.savefig('alpha_ef.pdf')
In [6]:
######## beta_unweighted ##########
In [7]:
# check FDR threshold
multipletests(np.hstack([np.repeat(0.002, 4), 0.008]), method = 'fdr_bh')[1]
Out[7]:
In [8]:
beta_uw = pd.DataFrame({'type': np.tile(['Independent', 'Cumulative'], 5),
'covariate': np.repeat(['study_id', 'empo_3', 'host_scientific_name', 'envo_biome_3', 'longitude_deg'], 2),
'value_ES': [0.544, 0.544, 0.442, 0.151, 0.511, 0.003, 0.403, 0.001, 0.237, 0.0002]})
In [9]:
beta_uw
Out[9]:
In [10]:
sns.set_style("ticks")
fig, ax = plt.subplots()
fig = sns.barplot(x='covariate', y='value_ES', hue='type', data=beta_uw)
fig.set_xticklabels(ax.get_xticklabels(), rotation=45)
fig.set(xlabel='RDA selected covariates', ylabel='effect size')
sns.plt.legend(loc='center left',bbox_to_anchor=(1,0.5))
sns.despine()
fig = fig.get_figure()
fig.tight_layout()
fig.savefig('beta_uw_ef.pdf')
In [11]:
######## beta_weighted ##########
In [12]:
# check FDR threshold
multipletests(np.repeat(0.002, 5), method = 'fdr_bh')[1]
Out[12]:
In [13]:
beta_w = pd.DataFrame({'type': np.tile(['Independent', 'Cumulative'], 5),
'covariate': np.repeat(['study_id', 'empo_3', 'host_scientific_name', 'envo_biome_3', 'longitude_deg'], 2),
'value_ES': [0.427, 0.427, 0.401, 0.185, 0.371, 0.004, 0.143, 0.002, 0.272, 0.0004]})
In [14]:
beta_w
Out[14]:
In [15]:
sns.set_style("ticks")
fig, ax = plt.subplots()
fig = sns.barplot(x='covariate', y='value_ES', hue='type', data=beta_w)
fig.set_xticklabels(ax.get_xticklabels(), rotation=45)
fig.set(xlabel='RDA selected covariates', ylabel='effect size')
sns.plt.legend(loc='center left',bbox_to_anchor=(1,0.5))
sns.despine()
fig = fig.get_figure()
fig.tight_layout()
fig.savefig('beta_w_ef.pdf')
In [ ]: