Commit fd935ad8 authored by Hanna  JULIENNE's avatar Hanna JULIENNE
Browse files

Update save_output.py

parent 334f61a0
Pipeline #61488 failed with stage
in 24 seconds
...@@ -12,19 +12,22 @@ def save_output_by_chromosome(mgwas, ImpG_output_Folder, my_study): ...@@ -12,19 +12,22 @@ def save_output_by_chromosome(mgwas, ImpG_output_Folder, my_study):
mgwas_copy.dropna(subset=["computed_z"], how="any", inplace=True) mgwas_copy.dropna(subset=["computed_z"], how="any", inplace=True)
print(mgwas_copy.index.unique()) print(mgwas_copy.index.unique())
for chrom in mgwas_copy.index.unique(): for chrom in mgwas_copy.index.unique():
print(mgwas_copy.loc[chrom]) if type(mgwas_copy.loc[chrom]) is pd.core.frame.DataFrame:
mgwas_chr = pd.DataFrame({ print(mgwas_copy.loc[chrom])
'rsID': mgwas_copy.loc[chrom].snp_id, mgwas_chr = pd.DataFrame({
'pos': mgwas_copy.loc[chrom].pos, 'rsID': mgwas_copy.loc[chrom].snp_id,
'A0': mgwas_copy.loc[chrom].ref, 'pos': mgwas_copy.loc[chrom].pos,
'A1':mgwas_copy.loc[chrom].alt, 'A0': mgwas_copy.loc[chrom].ref,
'Z': mgwas_copy.loc[chrom].computed_z, 'A1':mgwas_copy.loc[chrom].alt,
'P': mgwas_copy.loc[chrom].pval 'Z': mgwas_copy.loc[chrom].computed_z,
}, columns= ['rsID', 'pos', 'A0', "A1", "Z", "P" ]) 'P': mgwas_copy.loc[chrom].pval
}, columns= ['rsID', 'pos', 'A0', "A1", "Z", "P" ])
impg_output_file = ImpG_output_Folder + 'z_'+ my_study +'_chr'+str(chrom)+".txt"
print("WRITING CHR {} results for {} to: {}".format(chrom, my_study, ImpG_output_Folder)) impg_output_file = ImpG_output_Folder + 'z_'+ my_study +'_chr'+str(chrom)+".txt"
mgwas_chr.sort_values(by="pos").to_csv(impg_output_file, sep="\t", index=False) print("WRITING CHR {} results for {} to: {}".format(chrom, my_study, ImpG_output_Folder))
mgwas_chr.sort_values(by="pos").to_csv(impg_output_file, sep="\t", index=False)
else:
print("NO or 1 value for CHR {} results for {} to: {}".format(chrom, my_study, ImpG_output_Folder))
def save_output(mgwas, ImpG_output_Folder, my_study): def save_output(mgwas, ImpG_output_Folder, my_study):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment