<jupyter_start><jupyter_text>Calculate MotifTree UniFrac distances (feature based workflow) load libraries<jupyter_code>import pandas as pd
import os
import MetaboDistTrees 
motifs = pd.read_csv('../MetaboDistTrees/data/Mass2Motifs_Nodes_FeatureBased.tsv',sep='\t')
motifs.head()
bt = pd.read_csv('ftp://massive.ucsd.edu/MSV000082678/updates/2018-08-02_lfnothias_4ee107d3/other/MZmine-GNPS_AG_test_featuretable.csv')
bt.columns = bt.columns.str.replace(' Peak area','')
bt.head()
md = pd.read_csv('ftp://massive.ucsd.edu/MSV000082678/other/metadata_GNPS_table_AMG_key_ones_cleaned.txt', sep = '\t')
md = md.rename(columns = {'filename':'#SampleID'})
md.head()
set(bt.columns) - set(md['#SampleID'])
bt = bt.drop(['Unnamed: 26', 'row m/z','row number of detected peaks','row retention time'], axis=1)
bt = bt.rename(columns = {'row ID':'#OTU ID'})
MetaboDistTrees.get_motiftrees(motifs, bt, method = "ward", metric = "euclidean", outputdir = "MotifTree/")
md.to_csv("ClassyTree/MetaData_AGP_Example.tsv",sep='\t',index=False)<jupyter_output><empty_output><jupyter_text>Calculate UniFrac distances using Qiime2 make sure to run this part within your qiime2 environment<jupyter_code>import qiime2 as q2
import os
path = '/Users/madeleineernst/anaconda3/envs/qiime2-2018.11/bin/' # define path to qiime2 conda environment
os.environ['PATH'] += ':'+path
! biom convert \
    -i MotifTree/Buckettable_Motifs.tsv \
    -o MotifTree/Buckettable_Motifs.biom \
    --table-type="OTU table" --to-hdf5
! qiime tools import --type 'FeatureTable[Frequency]' \
    --input-path MotifTree/Buckettable_Motifs.biom \
    --output-path MotifTree/Buckettable_Motifs.qza
! qiime tools import --type 'Phylogeny[Rooted]' \
    --input-path MotifTree/Tree_Motifs.txt \
    --output-path MotifTree/Tree_Motifs.qza<jupyter_output>[32mImported MotifTree/Tree_Motifs.txt as NewickDirectoryFormat to MotifTree/Tree_Motifs.qza[0m<jupyter_text>weighted UniFrac<jupyter_code>! qiime diversity beta-phylogenetic \
    --i-table MotifTree/Buckettable_Motifs.qza \
    --i-phylogeny MotifTree/Tree_Motifs.qza \
    --p-metric weighted_unifrac \
    --o-distance-matrix MotifTree/weighted_unifrac_distance_matrix_Motifs.qza
! qiime diversity pcoa \
    --i-distance-matrix MotifTree/weighted_unifrac_distance_matrix_Motifs.qza \
    --o-pcoa MotifTree/weighted_unifrac_distance_matrix_Motifs_PCoA.qza
! qiime emperor plot \
    --i-pcoa MotifTree/weighted_unifrac_distance_matrix_Motifs_PCoA.qza \
    --m-metadata-file ClassyTree/MetaData_AGP_Example.tsv \
    --o-visualization MotifTree/wMotifTreeUniFrac.qzv
q2.Visualization.load('MotifTree/wMotifTreeUniFrac.qzv')<jupyter_output><empty_output><jupyter_text>unweighted UniFrac<jupyter_code>! qiime diversity beta-phylogenetic \
    --i-table MotifTree/Buckettable_Motifs.qza \
    --i-phylogeny MotifTree/Tree_Motifs.qza \
    --p-metric unweighted_unifrac \
    --o-distance-matrix MotifTree/unweighted_unifrac_distance_matrix_Motifs.qza
! qiime diversity pcoa \
    --i-distance-matrix MotifTree/unweighted_unifrac_distance_matrix_Motifs.qza \
    --o-pcoa MotifTree/unweighted_unifrac_distance_matrix_Motifs_PCoA.qza
! qiime emperor plot \
    --i-pcoa MotifTree/unweighted_unifrac_distance_matrix_Motifs_PCoA.qza \
    --m-metadata-file ClassyTree/MetaData_AGP_Example.tsv \
    --o-visualization MotifTree/uwMotifTreeUniFrac.qzv
q2.Visualization.load('MotifTree/uwMotifTreeUniFrac.qzv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12321999418773612, 'fraction_numerical': 0.015693112467306015, 'mean_word_length': 5.15742397137746, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '565419', 'license': 'MIT', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1316, 'n_words': 181, 'path': 'Example_notebooks/MotifTree_FeatureBased.ipynb', 'repo_name': 'mwang87/MetaboDistTrees', 'size': '3441'}