<jupyter_start><jupyter_text>Tannin data<jupyter_code>tan14 = pd.read_csv("../data/nir_SC_2014.txt", sep='\t', lineterminator='\n')
tan14 = tan14[["taxa", "Tannin"]]
tan14_mean = tan14.groupby("taxa").mean()
print(tan14_mean)
tan14_mean_zeroFilter = tan14_mean.loc[tan14_mean.Tannin < 0, "Tannin"] = 0
print(tan14_mean_zeroFilter)
tan13 = pd.read_csv("../data/nir_SC_2013.txt", sep='\t', lineterminator='\n')
tan13 = tan13[["taxa", "Tannins"]]
tan13_mean = tan13.groupby("taxa").mean()
print(tan13_mean)
dfs = [tan14_mean, tan13_mean]
all_tan = reduce(lambda left, right: pd.merge(left, right, on = "taxa"), dfs)
all_tan = all_tan.rename(columns = {'taxa':'PI',
                                    'Tannin':'Tan_14', 'Tannins':'Tan_13'})
print(all_tan.shape)
all_tan.head()<jupyter_output>(327, 2)<jupyter_text>Clostridium<jupyter_code>clostridium_df = pd.read_excel("../data/Supplemental_F2.xlsx", sheet_name= "Clostridium")
clostridium_df.head()
clostridium_df = clostridium_df[["cp_AMA", "PI","Testa","TP_avg"]]
clostridium_df.head()
ama_mean = clostridium_df.groupby("PI").mean()
ama_mean.reset_index(inplace=True)
ama_mean.head()
tan_and_ama = all_tan.merge(ama_mean, left_on = "taxa", right_on ="PI")
tan_and_ama.head()<jupyter_output><empty_output><jupyter_text>T-Test<jupyter_code>x = tan_and_ama.Tan_14
y = tan_and_ama.Tan_13
pg.ttest(x, y, correction='auto')<jupyter_output><empty_output><jupyter_text>Testa<jupyter_code>mean_tan_13_14 = tan14_mean.merge(tan13_mean, on = "taxa")
print(mean_tan_13_14)
min_tan= mean_tan_13_14.groupby("taxa").mean()
print(min_tan)
col =mean_tan_13_14.loc[: , "Tannin":"Tannins"]
mean_tan_13_14['tannin_mean']=col.mean(axis=1)
mean_tan_13_14
mean_tan_and_ama = mean_tan_13_14.merge(ama_mean, left_on = "taxa", right_on ="PI")
mean_tan_and_ama<jupyter_output><empty_output><jupyter_text>Figure S3<jupyter_code>testa_ama_violin=sns.violinplot(x="Testa", y="cp_AMA", data=clostridium_df)
testa_ama_violin.set(ylabel="Inhibition zone(mm)")
plt.xticks([0,1])
testa_ama_violin.figure.savefig("testa_ama_violin.png", bbox_inches='tight', dpi=600)<jupyter_output><empty_output><jupyter_text>Figure2a<jupyter_code>tp_ama_joint = sns.jointplot(x="cp_AMA", y="TP_avg", data=mean_tan_and_ama, kind="reg", stat_func=R2, color="darkseagreen").annotate(stats.pearsonr)
tp_ama_joint.set_axis_labels( "Inhibition Zone (mm)","Total phenol [GAE/g]]")
tp_ama_joint.savefig("tp_ama_joint.png", bbox_inches='tight', dpi=600)<jupyter_output><empty_output><jupyter_text>Figure2b<jupyter_code>tan_ama_joint = sns.jointplot(x="cp_AMA", y="tannin_mean", data=mean_tan_and_ama, kind="reg", stat_func=R2, color="darkseagreen").annotate(stats.pearsonr)
tan_ama_joint.set_axis_labels( "Inhibition Zone (mm)","Tannins [mg of CE/g]")
tan_ama_joint.savefig("tan_ama_joint.png", bbox_inches='tight', dpi=600)<jupyter_output><empty_output><jupyter_text>Salmonella<jupyter_code>salmonella_df=pd.read_excel("../data/Supplemental_F2.xlsx", sheet_name= "Salmonella")
salmonella_df.head()
salmonella_df.dropna(inplace=True)
salmonella_df["Testa"] = salmonella_df.Testa.astype(int)
salmonella_df.Tannins.replace("ND", 0, inplace=True)
salmonella_df.head()<jupyter_output><empty_output><jupyter_text>Table S2<jupyter_code>pd.crosstab(np.array(salmonella_df.Testa), 
            [np.array(salmonella_df.se_AMA)])
se_mean = salmonella_df.groupby("PI").mean()
se_mean.reset_index(inplace=True)
se_mean.head()
tan_and_se = all_tan.merge(se_mean, left_on = "taxa", right_on ="PI")
tan_and_se.head()
mean_tan_and_seama = mean_tan_13_14.merge(se_mean, left_on = "taxa", right_on ="PI")
mean_tan_and_seama<jupyter_output><empty_output><jupyter_text>Figure S2<jupyter_code>sns.set_style("white")
se_joint = sns.jointplot(x="se_AMA", y="tannin_mean", data=mean_tan_and_seama, kind="reg", stat_func=R2, color="coral").annotate(stats.pearsonr)
se_joint.set_axis_labels( "Antimicrobial activity","Tannins [mg of CE/g]")
plt.xticks([0,0.5,1])
se_joint.savefig("se_joint.png", bbox_inches='tight', dpi=600)<jupyter_output><empty_output><jupyter_text>Figure S1<jupyter_code>sns.set_style("white")
se_TP_joint = sns.jointplot(x="se_AMA", y="TP_avg", data=mean_tan_and_seama, kind="reg", stat_func=R2, color="coral").annotate(stats.pearsonr)
se_TP_joint.set_axis_labels( "Antimicrobial activity","Total phenol [GAE/g]")
plt.xticks([0,0.5,1])
se_TP_joint.savefig("se_TP_joint.png", bbox_inches='tight', dpi=600)<jupyter_output><empty_output><jupyter_text>Germplasm filtering<jupyter_code>ama = list(clostridium_df["cp_AMA"])
new_ama = []
for i in ama:
    if i < 1:
        new_ama.append("none")
    if ((i >3.5) and (i<4)):
        new_ama.append("weak")
    if (i>=4):
        new_ama.append("strong")
clostridium_df["AMA"] = new_ama
set(new_ama)
rep_agreement = clostridium_df.groupby("PI").min()
rep_agreement = rep_agreement[rep_agreement["cp_AMA"] != 0]
print(rep_agreement)<jupyter_output><empty_output><jupyter_text>Table 3<jupyter_code>pd.crosstab(np.array(clostridium_df.Testa), 
            [np.array(clostridium_df.AMA)])
strong = rep_agreement[rep_agreement.AMA.str.contains("strong", case=False)]
print(strong)
pis = ["PI533869","PI533871","PI533940","PI533948","PI533979",
       "PI534114","PI534115","PI542406","PI576393","PI595739",
       "PI597957","PI597972","PI641836","PI642998","PI655980",
       "PI655983","PI655995","PI656014","PI656088","PI656112"]
pi_values = clostridium_df[clostridium_df.PI.isin(pis)].sort_values(by="PI")
print(pi_values.PI.unique())<jupyter_output><empty_output><jupyter_text>Compositional data<jupyter_code>nir_raw = pd.read_excel("../data/Supplemental_F1.xlsx", index_col=0)
columns = ["_".join(i.split()) for i in list(nir_raw.columns)]
nir_raw.columns = columns
nir_raw.head()
numeric_columns = nir_raw.columns[3:len(nir_raw.columns)-4]
fl17_ama = pd.read_excel("../data/Supplemental_F1.xlsx", index_col=0)
print(fl17_ama.shape)
fl17_ama.head()
 def r(x, y):
     return stats.pearsonr(x, y)

 p_values = []

 for i in list(numeric_columns.values):
     if i not in ["Sodium"]:
         sns.jointplot(x="cp_AMA", 
                       y=i, 
                       data=fl17_ama, 
                       kind="reg", 
                       marginal_kws=dict(kde=False), 
                       stat_func=r)
         p_values.append(r(fl17_ama.cp_AMA, fl17_ama.loc[:,i]))
         plt.show()
corr_pval = pd.DataFrame(p_values, columns=["r","pvalue"])
corr_pval.head()
sms.stats.multipletests(corr_pval["pvalue"], alpha=0.05, method="fdr_bh")<jupyter_output><empty_output><jupyter_text>Comparing GWAS<jupyter_code>amGWAS = pd.read_csv("/panicle/lindsay/gemma/thin/output/plink.pruned.assoc.txt", sep='\t', lineterminator='\n')
amGWAS= amGWAS[["rs", "p_wald"]]
amGWAS.head()
tcGWAS = tcGWAS = pd.read_csv("/panicle/lindsay/gemma_tan_covariate/output/plink.pruned_ama_tan_BLUP.assoc.txt", sep='\t', lineterminator='\n')
tcGWAS = tcGWAS[["rs", "p_wald"]]
tcGWAS.head()
dfs = [amGWAS, tcGWAS]

gwas = reduce(lambda left, right: pd.merge(left, right, on = "rs"), dfs)

gwas.head()

x = gwas.p_wald_x
y = gwas.p_wald_y
pg.ttest(x, y, correction='auto')<jupyter_output><empty_output><jupyter_text>Figure S7<jupyter_code>df= pd.read_csv("../data/cp_ama_genotypes.csv")
df = df.rename(columns={"Unnamed: 0":"PI", "0":"S2_8924006", "1":"S10_56476103"})
df = df[df.S10_56476103 != "0/1"]
df.head()
df= df.replace({"./.": np.nan})
df.S2_8924006 = df.S2_8924006.replace({"0/0":"T/T", "1/1":"C/C"})
df.S10_56476103 = df.S10_56476103.replace({"0/0":"G/G", "1/1":"T/T"})
df.head()
df.shape
ax = snpplot = sns.swarmplot(x="S2_8924006", y="cp_AMA", hue="S10_56476103", data = df,
                       dodge=True)
ax =sns.boxplot(x="S2_8924006", y="cp_AMA", hue = "S10_56476103", data=df, 
                showmeans=True,showcaps=False,boxprops={'facecolor':'None'},
                 showfliers=False,whiskerprops={'linewidth':0}, ax=ax)
ax.set(ylabel="Inhibition zone (mm)")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17609189598586217, 'fraction_numerical': 0.049987376925018936, 'mean_word_length': 6.805911330049261, 'pattern_counts': {'":': 9, '<': 67, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '246211', 'license': 'MIT', 'n_tokens_mistral': 3675, 'n_tokens_neox': 3357, 'n_words': 369, 'path': 'notebooks/ACRE1.ipynb', 'repo_name': 'lkshiel/ACRE', 'size': '7922'}