<jupyter_start><jupyter_text>Circadian Microbiome<jupyter_code>metadata = pd.read_table('../data/CircadianIHC/Microbiome/circadianIHC_metadata_cleaned.txt', sep='\t', index_col=0)
metadata.head()
cIHC_wUF_dm = pd.read_csv('../data/CircadianIHC/Microbiome/CircadianIHC-wUF-distance-matrix.tsv', sep='\t', index_col=0)
dm_samples = set(cIHC_wUF_dm.columns)
micro_rawreads_phyla = pd.read_table('../../Circadian_IHC/data/Microbiome/CircadianIHC_phylacounts.txt', sep='\t', index_col=0)
micro_rawreads_phyla
all_samples = set(micro_rawreads_phyla.columns)
keep_samples = dm_samples.intersection(all_samples)
lost_samples = all_samples - dm_samples
lost_samples
micro_rawreads_phyla2 = micro_rawreads_phyla[list(keep_samples)].copy()
micro_rawreads_phyla2
micro_rawreads_phyla_all = pd.merge(metadata, micro_rawreads_phyla2.T, left_index=True, right_index=True)
micro_rawreads_phyla_all.head()
micro_rawreads_phyla_all["Log_Bacteroidetes_Verrucomicrobia"] = np.log(micro_rawreads_phyla_all['k__Bacteria;p__Bacteroidetes']) - np.log(micro_rawreads_phyla_all['k__Bacteria;p__Verrucomicrobia'])
micro_rawreads_phyla_all["Both"] = micro_rawreads_phyla_all['exposure_type'].astype(str) + "_" + micro_rawreads_phyla_all['zt'].astype(str)
high_values = ["Air_18", "IHC_6"]
low_values = ["Air_22", "IHC_18"]
micro_rawreads_phyla_high  = micro_rawreads_phyla_all.loc[micro_rawreads_phyla_all['Both'].isin(high_values)]
micro_rawreads_phyla_low = micro_rawreads_phyla_all.loc[micro_rawreads_phyla_all['Both'].isin(low_values)]
ax = sns.boxplot(x="Both", y="Log_Bacteroidetes_Verrucomicrobia", 
            palette=['red', 'blue'], data=micro_rawreads_phyla_high)
ax = sns.swarmplot(x="Both", y="Log_Bacteroidetes_Verrucomicrobia", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=micro_rawreads_phyla_high)
plt.title("Phyla Log Ratio(Bacteroidetes/Verrucomicrobia) High Beta Diversity")
ax.set(ylim=(-2.5, 1.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_highbeta_phyla.svg', dpi=300, bbox_inches="tight")
from scipy.stats import mannwhitneyu
x = list(micro_rawreads_phyla_high[micro_rawreads_phyla_high["Both"] == "Air_18"].Log_Bacteroidetes_Verrucomicrobia.values)
y = list(micro_rawreads_phyla_high[micro_rawreads_phyla_high["Both"] == "IHC_6"].Log_Bacteroidetes_Verrucomicrobia.values)

mannwhitneyu(x, y)
ax = sns.boxplot(x="Both", y="Log_Bacteroidetes_Verrucomicrobia", 
            palette=['red', 'blue'], data=micro_rawreads_phyla_low)
ax = sns.swarmplot(x="Both", y="Log_Bacteroidetes_Verrucomicrobia", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=micro_rawreads_phyla_low)
plt.title("Phyla Log Ratio(Bacteroidetes/Verrucomicrobia) Low Beta Diversity")
ax.set(ylim=(-2.5, 1.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_lowbeta_phyla.svg', dpi=300, bbox_inches="tight")
x = list(micro_rawreads_phyla_low[micro_rawreads_phyla_low["Both"] == "Air_22"].Log_Bacteroidetes_Verrucomicrobia.values)
y = list(micro_rawreads_phyla_low[micro_rawreads_phyla_low["Both"] == "IHC_18"].Log_Bacteroidetes_Verrucomicrobia.values)
mannwhitneyu(x, y)<jupyter_output><empty_output><jupyter_text>Family Level<jupyter_code>micro_rawreads_family = pd.read_table('../../Circadian_IHC/data/Microbiome/CircadianIHC_family_counts.txt', sep='\t', index_col=0)
micro_rawreads_family.head()
micro_rawreads_family_all = pd.merge(metadata, micro_rawreads_family.T, left_index=True, right_index=True)
micro_rawreads_family_all.head()
micro_rawreads_family_all.drop(['11548.132.133.4a', '11548.A27.128.1a'], axis=0, inplace=True)
micro_rawreads_family_all["Log_RS_V"] = (np.log(micro_rawreads_family_all['k__Bacteria;p__Firmicutes;c__Clostridia;o__Clostridiales;f__Ruminococcaceae']) + np.log(micro_rawreads_family_all['k__Bacteria;p__Bacteroidetes;c__Bacteroidia;o__Bacteroidales;f__S24-7'])) - np.log(micro_rawreads_family_all['k__Bacteria;p__Verrucomicrobia;c__Verrucomicrobiae;o__Verrucomicrobiales;f__Verrucomicrobiaceae'])
micro_rawreads_family_all["Both"] = micro_rawreads_family_all['exposure_type'].astype(str) + "_" + micro_rawreads_family_all['zt'].astype(str)
micro_rawreads_family_high  = micro_rawreads_family_all.loc[micro_rawreads_family_all['Both'].isin(high_values)]
micro_rawreads_family_low = micro_rawreads_family_all.loc[micro_rawreads_family_all['Both'].isin(low_values)]
sns.boxplot(x="Both", y="Log_RS_V", 
            palette=['red', 'blue'], data=micro_rawreads_family_high)
sns.swarmplot(x="Both", y="Log_RS_V", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=micro_rawreads_family_high)
plt.title("family Log Ratio(Ruminococcaceae+S24-7/Verrucomicrobia) High Beta Diversity")
ax.set(ylim=(4.5, 9.1))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_highbeta_family.svg', dpi=300, bbox_inches="tight")
x = list(micro_rawreads_family_high[micro_rawreads_family_high["Both"] == "Air_18"].Log_RS_V.values)
y = list(micro_rawreads_family_high[micro_rawreads_family_high["Both"] == "IHC_6"].Log_RS_V.values)

mannwhitneyu(x, y)
ax = sns.boxplot(x="Both", y="Log_RS_V", 
            palette=['red', 'blue'], data=micro_rawreads_family_low)
ax = sns.swarmplot(x="Both", y="Log_RS_V", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=micro_rawreads_family_low)
plt.title("family Log Ratio(Ruminococcaceae+S24-7/Verrucomicrobia) low Beta Diversity")
ax.set(ylim=(4.5, 9.1))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_lowbeta_family.svg', dpi=300, bbox_inches="tight")
x = list(micro_rawreads_family_low[micro_rawreads_family_low["Both"] == "Air_22"].Log_RS_V.values)
y = list(micro_rawreads_family_low[micro_rawreads_family_low["Both"] == "IHC_18"].Log_RS_V.values)

mannwhitneyu(x, y)<jupyter_output><empty_output><jupyter_text>Circadian Metabolome<jupyter_code>mmetadata = pd.read_table('../data/CircadianIHC/Metabolome/cIHC_metab_metadata_cleaned.txt', sep='\t', index_col=0)
mmetadata.head()
metab_rawreads = pd.read_table('../data/CircadianIHC/Metabolome/cIHC_allunique_noblanks.txt', sep='\t', index_col=0)
metab_rawreads.head()
metab_rawreads_all = pd.merge(mmetadata, metab_rawreads, left_index=True, right_index=True)
metab_rawreads_all.head()
metab_rawreads_all["Both"] = metab_rawreads_all['exposure_type'].astype(str) + "_" + metab_rawreads_all['zt'].astype(str)
bile_acids = [col for col in metab_rawreads_all.columns if 'holic' in col]
bile_acids
primary_BA = ['Cholic acid', 'Spectral Match to Cholic acid from NIST14', 
              'Tauro-b-muricholic acid', 'Taurocholic acid', 'taurocholic acid']
secondary_BA = ['Deoxycholic acid', 'Hyodeoxycholic acid', 
                'Spectral Match to 12-Ketodeoxycholic acid from NIST14',
                'Spectral Match to Ursodeoxycholic acid from NIST14',
                'Tauro-b-muricholic acid', 'Taurodeoxycholic acid', 'Ursodeoxycholic acid',
                'a-Muricholic acid', 'b-Muricholic acid', 'taurodeoxycholic acid']
cholines = [col for col in metab_rawreads_all.columns if 'choline' in col]
cholines2 = [col for col in metab_rawreads_all.columns if 'PC' in col]
cholines3 = cholines + cholines2
cholines3
metab_rawreads_all["Log_BA_PPC"] = np.log(metab_rawreads[bile_acids].sum(axis=1)) - np.log(metab_rawreads[cholines3].sum(axis=1))
metab_rawreads_all["Log_BA_origPPC"] = np.log(metab_rawreads[bile_acids].sum(axis=1)) - np.log(metab_rawreads[cholines].sum(axis=1))
metab_rawreads_all["Log_BA1_BA2"] = np.log(metab_rawreads[primary_BA].sum(axis=1)) - np.log(metab_rawreads[secondary_BA].sum(axis=1))
IHC_ppc = []
Air_ppc = []
metab_rawreads_all["Log_IHCppc_AIRppc"] = np.log(metab_rawreads[IHC_ppc].sum(axis=1)) - np.log(metab_rawreads[Air_ppc].sum(axis=1))
high_valuesm = ["Air_10.0", "IHC_2.0"]
low_valuesm = ["Air_2.0", "IHC_22.0"]
metab_rawreads_high  = metab_rawreads_all.loc[metab_rawreads_all['Both'].isin(high_valuesm)]
metab_rawreads_low = metab_rawreads_all.loc[metab_rawreads_all['Both'].isin(low_valuesm)]
ax = sns.boxplot(x="Both", y="Log_BA_PPC", 
            palette=['red', 'blue'], data=metab_rawreads_high)
ax = sns.swarmplot(x="Both", y="Log_BA_PPC", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_high)
plt.title("family Log Ratio(Bile Acids/Phosphocholines) High Beta Diversity")
ax.set(ylim=(-2.3, 0))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_highbeta_BA_PPC.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_high[metab_rawreads_high["Both"] == "Air_10.0"].Log_BA_PPC.values)
y = list(metab_rawreads_high[metab_rawreads_high["Both"] == "IHC_2.0"].Log_BA_PPC.values)

mannwhitneyu(x, y)
ax = sns.boxplot(x="Both", y="Log_BA_PPC", 
            palette=['red', 'blue'], data=metab_rawreads_low)
ax = sns.swarmplot(x="Both", y="Log_BA_PPC", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_low)
plt.title("family Log Ratio(Bile Acids/Phosphocholines) Low Beta Diversity")
ax.set(ylim=(-2.3, 0))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_lowbeta_BA_PPC.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_low[metab_rawreads_low["Both"] == "Air_2.0"].Log_BA_PPC.values)
y = list(metab_rawreads_low[metab_rawreads_low["Both"] == "IHC_22.0"].Log_BA_PPC.values)

mannwhitneyu(x, y)<jupyter_output><empty_output><jupyter_text>Original Phosphocholines<jupyter_code>ax = sns.boxplot(x="Both", y="Log_BA_origPPC", 
            palette=['red', 'blue'], data=metab_rawreads_high)
ax = sns.swarmplot(x="Both", y="Log_BA_origPPC", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_high)
plt.title("family Log Ratio(Bile Acids/Phosphocholines) High Beta Diversity")
ax.set(ylim=(-1.5, 0.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_highbeta_BA_origPPC.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_high[metab_rawreads_high["Both"] == "Air_10.0"].Log_BA_origPPC.values)
y = list(metab_rawreads_high[metab_rawreads_high["Both"] == "IHC_2.0"].Log_BA_origPPC.values)

mannwhitneyu(x, y)
ax = sns.boxplot(x="Both", y="Log_BA_origPPC", 
            palette=['red', 'blue'], data=metab_rawreads_low)
ax = sns.swarmplot(x="Both", y="Log_BA_origPPC", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_low)
plt.title("family Log Ratio(Bile Acids/Phosphocholines) Low Beta Diversity")
ax.set(ylim=(-1.5, 0.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_lowbeta_BA_origPPC.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_low[metab_rawreads_low["Both"] == "Air_2.0"].Log_BA_origPPC.values)
y = list(metab_rawreads_low[metab_rawreads_low["Both"] == "IHC_22.0"].Log_BA_origPPC.values)

mannwhitneyu(x, y)<jupyter_output><empty_output><jupyter_text>End<jupyter_code>ax = sns.boxplot(x="Both", y="Log_BA1_BA2", 
            palette=['red', 'blue'], data=metab_rawreads_high)
ax = sns.swarmplot(x="Both", y="Log_BA1_BA2", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_high)
plt.title("family Log Ratio(Primary Bile Acids/Secondary Bile Acids) High Beta Diversity")
ax.set(ylim=(-2.1, -0.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_highbeta_BA1_BA2.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_high[metab_rawreads_high["Both"] == "Air_10.0"].Log_BA1_BA2.values)
y = list(metab_rawreads_high[metab_rawreads_high["Both"] == "IHC_2.0"].Log_BA1_BA2.values)

mannwhitneyu(x, y)
ax = sns.boxplot(x="Both", y="Log_BA1_BA2", 
            palette=['red', 'blue'], data=metab_rawreads_low)
ax = sns.swarmplot(x="Both", y="Log_BA1_BA2", s=15, edgecolor='k', linewidth=1,
            palette=['red', 'blue'], data=metab_rawreads_low)
plt.title("family Log Ratio(Primary Bile Acids/Secondary Bile Acids) Low Beta Diversity")
ax.set(ylim=(-2.1, -0.5))
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['svg.fonttype'] = 'none'
plt.savefig('../figures/cIHC_logratio_lowbeta_BA1_BA2.svg', dpi=300, bbox_inches="tight")
x = list(metab_rawreads_low[metab_rawreads_low["Both"] == "Air_2.0"].Log_BA1_BA2.values)
y = list(metab_rawreads_low[metab_rawreads_low["Both"] == "IHC_22.0"].Log_BA1_BA2.values)

mannwhitneyu(x, y)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16469338190649666, 'fraction_numerical': 0.018518518518518517, 'mean_word_length': 7.640655737704918, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '285743', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 5879, 'n_tokens_neox': 5348, 'n_words': 614, 'path': 'notebooks/AllabandZarrinpar2021_Fig1_Log_ratios.ipynb', 'repo_name': 'knightlab-analyses/dynamics', 'size': '13176'}