<jupyter_start><jupyter_text>Procrustes transformation for comparing 90- vs 150-bp Deblur tables<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Note: this notebook requires operating on the original UniFrac distances matrices, which are very large. To reproduce, download the following files from ftp://ftp.microbio.me/emp/release1/results/beta_diversity/deblur/:```emp_150_gg_1k_unweighted_unifrac.txtemp_90_gg_1k_unweighted_unifrac.txt```<jupyter_code># read in samples 

samples_150 = pd.read_csv('./emp_150_gg_1k_unweighted_unifrac.txt', nrows=1, sep ='\t', header=None).T[0][1:]
samples_90 = pd.read_csv('./emp_90_gg_1k_unweighted_unifrac.txt', nrows=1, sep ='\t', header=None).T[0][1:]
# read in sample map

subset_2k_map = pd.read_csv('../../data/mapping-files/emp_qiime_mapping_subset_2k.tsv', header=0, sep='\t')
subset_2k_map.head()
# reduce map

subset_2k_map_90_100 = subset_2k_map.loc[(subset_2k_map['#SampleID'].isin(samples_150)) &
                                         (subset_2k_map['#SampleID'].isin(samples_90)),]
# pick N random sequences and write to file

subset_2k_map_90_100.sample(n=200)['#SampleID'].to_csv('./200_samples.txt', index=False)
# filter distance matrices by 

!filter_distance_matrix.py -i ./emp_150_gg_1k_unweighted_unifrac.txt \
-o ./emp_150_gg_1k_unweighted_unifrac.200.txt \
--sample_id_fp ./200_samples.txt

!filter_distance_matrix.py -i ./emp_90_gg_1k_unweighted_unifrac.txt \
-o ./emp_90_gg_1k_unweighted_unifrac.200.txt \
--sample_id_fp ./200_samples.txt
# compute PC

!principal_coordinates.py -i ./emp_150_gg_1k_unweighted_unifrac.200.txt -o ./emp_150_gg_1k_unweighted_unifrac.200.txt.pc
!principal_coordinates.py -i ./emp_90_gg_1k_unweighted_unifrac.200.txt -o ./emp_90_gg_1k_unweighted_unifrac.200.txt.pc
# compute procrustes

!transform_coordinate_matrices.py -i emp_90_gg_1k_unweighted_unifrac.200.txt.pc,emp_150_gg_1k_unweighted_unifrac.200.txt.pc  \
-r 999 \
-o procrustes_results/
# make emperor plot of procrustes

!make_emperor.py -c -i procrustes_results/ \
-o procrustes_results/plots/ \
-m ./emp_qiime_mapping_subset_2k_20170606.tsv<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12051517939282429, 'fraction_numerical': 0.06347746090156393, 'mean_word_length': 5.5119760479041915, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '240381', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 960, 'n_tokens_neox': 857, 'n_words': 129, 'path': 'code/06-beta-diversity/procrustes_90_150.ipynb', 'repo_name': 'justinshaffer/emp', 'size': '2174'}