Here we will be continuing the cystic fibrosis study, and examining the results in depth using the Python API.

In [1]:
import os
import qiime2
import numpy as np
import pandas as pd
from skbio import TreeNode
%matplotlib inline

# Obtain raw OTU counts
table = table_art.view(pd.DataFrame)

# Obtain the balances
balances = balance_art.view(pd.DataFrame)

# Obtain the tree
tree = tree_art.view(TreeNode)

# Obtain the taxa
taxa = taxa_art.view(pd.DataFrame)

# Unpack the results from the regression
viz.export_data('regression_summary_dir')



We will visualize the entire tree, and resize the internal nodes reflect the pvalues with respect to ph. Specifically, we want to test to determine if pH is a driving factor. We also want to visualize the mean ph values for each OTU and load the tree.

In [2]:
from gneiss.sort import mean_niche_estimator


Then we'll want to populate the tree with attributes that we would like to visualize.

In [3]:
for n in tree.postorder():
n.color = '#FF00FF'  # color all nodes magenta
if n.is_tip():       # display mean ph in hover tool
n.mean_ph = mean_ph.loc[n.name]
else:                # resize node by pvalue
pval = pvals.loc[n.name, 'ph']
n.ph_pvalue = -np.log(pval) / 10 # scale down for visual purposes


Now we can specify the machinery to visualize the plots.

In [4]:
from gneiss.plot import radialplot
from bokeh.io import show, output_notebook
output_notebook()
node_color='color', edge_color='edge_color',
hover_var='mean_ph')
show(p)

import seaborn as sns