From 86c31e4f4b9a44ba7f3ab0fa2484d47035b7600e Mon Sep 17 00:00:00 2001 From: Hubble <hubble@HubbledeMacBook-Pro.local> Date: Mon, 13 Nov 2023 00:08:39 +0100 Subject: [PATCH] save log in csv --- raiss/sanity_log.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/raiss/sanity_log.py b/raiss/sanity_log.py index 11df959..5e26181 100644 --- a/raiss/sanity_log.py +++ b/raiss/sanity_log.py @@ -77,9 +77,22 @@ def report_snps(res_dict, trait, filename="raiss_report"): f.write(res_dict['R2_quality'].to_string()) f.close() +def report_snps_csv(res_dict, trait, filename="raiss_report"): + # I save the log in three .csv files. + df = pd.DataFrame({'Number of SNPs in harmonized file': [res_dict["total_harmonized"]], + 'Number of SNPs in imputed file': [res_dict["total_imputed"]], + 'Proportion imputed': [res_dict['proportion']]}) + df.to_csv("{}_{}_Number_of_SNPs.csv".format(filename, trait), index=False) + + # Number of SNPs by level of significance + res_dict['signif_count'].to_csv("{}_{}_Number_of_SNPs_by_level_of_significance.csv".format(filename, trait)) + + # Number of imputed SNPs by level of imputation quality + res_dict['R2_quality'].to_csv = "{}_{}_Number_of_SNPs_by_level_of_imputation_quality.csv".format(filename, trait) + def raiss_report(trait, harmonized_folder, imputed_folder, filename="raiss_report", chr_list=range(1,23)): """ Function to compute a report for one trait """ res_dict = count_snps(trait, harmonized_folder, imputed_folder, chr_list) - report_snps(res_dict, trait, filename) + report_snps_csv(res_dict, trait, filename) -- GitLab