|
31 | 31 | 'S-R2_1.0': '#F28E2B'
|
32 | 32 | }
|
33 | 33 |
|
34 |
| -methods = ['S-D2_0.0', 'S-D2_0.25', 'S-D2_0.5', 'S-D2_0.75', 'S-D2_1.0'] |
| 34 | +partitioned = False |
| 35 | +methods = ['R2_0.0', 'R2_0.25', 'R2_0.5', 'R2_0.75', 'R2_1.0'] |
| 36 | + |
| 37 | +if partitioned: |
| 38 | + methods = ['S-' + m for m in methods] |
| 39 | + |
35 | 40 | metrics = [
|
36 | 41 | 'Mean Difference',
|
37 | 42 | 'Weighted Mean Difference',
|
|
44 | 49 |
|
45 | 50 | annot_res = []
|
46 | 51 | global_res = []
|
47 |
| -avg_chi2 = [] |
| 52 | +all_snps_chi2 = [] |
48 | 53 |
|
49 | 54 | for trait_file in glob.glob("results/regression/EUR/M_5_50_chi2filt/*/*.pbz2"):
|
50 | 55 | trait_res = read_pbz2(trait_file)
|
|
63 | 68 | 'Method': m
|
64 | 69 | })
|
65 | 70 |
|
66 |
| - avg_chi2.append({ |
67 |
| - 'Trait': trait_name, |
68 |
| - 'Score': trait_res['Predictive Performance']['Overall']['Mean Predicted Chisq'], |
69 |
| - 'Method': m |
70 |
| - }) |
71 |
| - |
72 |
| - for ann, ann_res in trait_res['Annotations']['Predictive Performance'].items(): |
73 |
| - for mbin, mbin_res in ann_res['Per MAF bin'].items(): |
74 |
| - for metric in metrics: |
75 |
| - |
76 |
| - annot_res.append({ |
77 |
| - 'Annotation': ann, |
78 |
| - 'Trait': trait_name, |
79 |
| - 'MAFbin': mbin, |
80 |
| - 'Metric': metric, |
81 |
| - 'Score': mbin_res[metric], |
82 |
| - 'Method': m |
83 |
| - }) |
| 71 | + for metric in metrics + ['Mean Predicted Chisq']: |
| 72 | + all_snps_chi2.append({ |
| 73 | + 'Trait': trait_name, |
| 74 | + 'Metric': metric, |
| 75 | + 'Score': trait_res['Predictive Performance']['Overall'][metric], |
| 76 | + 'Method': m |
| 77 | + }) |
| 78 | + |
| 79 | + if partitioned: |
| 80 | + for ann, ann_res in trait_res['Annotations']['Predictive Performance'].items(): |
| 81 | + for mbin, mbin_res in ann_res['Per MAF bin'].items(): |
| 82 | + for metric in metrics: |
| 83 | + |
| 84 | + annot_res.append({ |
| 85 | + 'Annotation': ann, |
| 86 | + 'Trait': trait_name, |
| 87 | + 'MAFbin': mbin, |
| 88 | + 'Metric': metric, |
| 89 | + 'Score': mbin_res[metric], |
| 90 | + 'Method': m |
| 91 | + }) |
84 | 92 |
|
85 | 93 | annot_res = pd.DataFrame(annot_res)
|
86 | 94 | global_res = pd.DataFrame(global_res)
|
87 |
| -avg_chi2 = pd.DataFrame(avg_chi2) |
| 95 | +all_snps_chi2 = pd.DataFrame(all_snps_chi2) |
88 | 96 |
|
89 | 97 | print(f'Average {metric} across all traits and SNP categories:')
|
90 |
| -print(avg_chi2.groupby('Method').mean()) |
| 98 | +print(all_snps_chi2.groupby(['Method', 'Metric']).mean()) |
91 | 99 |
|
92 | 100 | print('= = = = = = =')
|
93 | 101 |
|
|
107 | 115 | plt.savefig(f"figures/analysis/global/{metric}{fig_format}")
|
108 | 116 | plt.close()
|
109 | 117 |
|
110 |
| - plt.subplots(figsize=(10, 8)) |
111 |
| - sns.barplot(x='MAFbin', y='Score', hue='Method', |
112 |
| - data=annot_res.loc[annot_res['Metric'] == metric], ci=None, |
113 |
| - hue_order=methods, |
114 |
| - palette=ld_scores_colors) |
115 |
| - plt.xlabel('MAF Decile bin') |
116 |
| - plt.ylabel(metric) |
117 |
| - plt.savefig(f"figures/analysis/annotation/{metric}{fig_format}") |
118 |
| - plt.close() |
119 |
| - |
120 |
| - highly_enriched_cats = [ |
121 |
| - 'Coding_UCSC', |
122 |
| - 'Conserved_LindbladToh', |
123 |
| - 'GERP.RSsup4', |
124 |
| - 'synonymous', |
125 |
| - 'Conserved_Vertebrate_phastCons46way', |
126 |
| - 'Conserved_Mammal_phastCons46way', |
127 |
| - 'Conserved_Primate_phastCons46way', |
128 |
| - 'BivFlnk', |
129 |
| - 'Ancient_Sequence_Age_Human_Promoter', |
130 |
| - 'Human_Promoter_Villar_ExAC' |
131 |
| - ] |
132 |
| - |
133 |
| - plt.subplots(figsize=(10, 8)) |
134 |
| - sns.barplot(x='MAFbin', y='Score', hue='Method', |
135 |
| - hue_order=methods, |
136 |
| - data=annot_res.loc[annot_res['Annotation'].isin(highly_enriched_cats) & |
137 |
| - (annot_res['Metric'] == metric)], ci=None, |
138 |
| - palette=ld_scores_colors) |
139 |
| - plt.xlabel('MAF Decile bin') |
140 |
| - plt.ylabel(metric) |
141 |
| - plt.savefig(f"figures/analysis/highly_enriched_annotation/{metric}{fig_format}") |
142 |
| - plt.close() |
| 118 | + if partitioned: |
| 119 | + plt.subplots(figsize=(10, 8)) |
| 120 | + sns.barplot(x='MAFbin', y='Score', hue='Method', |
| 121 | + data=annot_res.loc[annot_res['Metric'] == metric], ci=None, |
| 122 | + hue_order=methods, |
| 123 | + palette=ld_scores_colors) |
| 124 | + plt.xlabel('MAF Decile bin') |
| 125 | + plt.ylabel(metric) |
| 126 | + plt.savefig(f"figures/analysis/annotation/{metric}{fig_format}") |
| 127 | + plt.close() |
| 128 | + |
| 129 | + highly_enriched_cats = [ |
| 130 | + 'Coding_UCSC', |
| 131 | + 'Conserved_LindbladToh', |
| 132 | + 'GERP.RSsup4', |
| 133 | + 'synonymous', |
| 134 | + 'Conserved_Vertebrate_phastCons46way', |
| 135 | + 'Conserved_Mammal_phastCons46way', |
| 136 | + 'Conserved_Primate_phastCons46way', |
| 137 | + 'BivFlnk', |
| 138 | + 'Ancient_Sequence_Age_Human_Promoter', |
| 139 | + 'Human_Promoter_Villar_ExAC' |
| 140 | + ] |
| 141 | + |
| 142 | + plt.subplots(figsize=(10, 8)) |
| 143 | + sns.barplot(x='MAFbin', y='Score', hue='Method', |
| 144 | + hue_order=methods, |
| 145 | + data=annot_res.loc[annot_res['Annotation'].isin(highly_enriched_cats) & |
| 146 | + (annot_res['Metric'] == metric)], ci=None, |
| 147 | + palette=ld_scores_colors) |
| 148 | + plt.xlabel('MAF Decile bin') |
| 149 | + plt.ylabel(metric) |
| 150 | + plt.savefig(f"figures/analysis/highly_enriched_annotation/{metric}{fig_format}") |
| 151 | + plt.close() |
0 commit comments