Skip to content

Commit f1e53ba

Browse files
Deepro BanerjeeDeepro Banerjee
authored andcommitted
revision-2-ancestry-specific-variants
1 parent 19399fd commit f1e53ba

2 files changed

Lines changed: 131 additions & 21 deletions

File tree

notebooks/11_supplementary_tables.ipynb

Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"# STable 1: Cross ancestry meta analysis statistics"
18+
"# Legend"
1919
]
2020
},
2121
{
@@ -24,7 +24,67 @@
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"meta_file = \"../data/meta/tables/all_ancestry.xlsx\"\n",
27+
"import pandas as pd\n",
28+
"\n",
29+
"# Define the data\n",
30+
"data = {\n",
31+
" \"Name\": [\n",
32+
" \"Supplementary Table 1\", \"Supplementary Table 2\", \"Supplementary Table 3\",\n",
33+
" \"Supplementary Table 4\", \"Supplementary Table 5\", \"Supplementary Table 6\",\n",
34+
" \"Supplementary Table 7\", \"Supplementary Table 8\", \"Supplementary Table 9\",\n",
35+
" \"Supplementary Table 10\", \"Supplementary Table 11\", \"Supplementary Table 12\",\n",
36+
" \"Supplementary Table 13\", \"Supplementary Table 14\", \"Supplementary Table 15\",\n",
37+
" \"Supplementary Table 16\", \"Supplementary Table 17\", \"Supplementary Table 18\",\n",
38+
" \"Supplementary Table 19\"\n",
39+
" ],\n",
40+
" \"Description\": [\n",
41+
" \"Cross ancestry meta analysis statistics (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
42+
" \"Cross ancestry meta analysis statistics using METAL (two-sided Wald Z-tests from fixed-effects meta-analysis implemented in METAL).\",\n",
43+
" \"Cross ancestry meta analysis conditioned on common variants (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
44+
" \"Leave one variant out stats for five study-identified associations (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
45+
" \"Cochran's Q statistics for ancestral heterogeneity (Cochran’s Q test).\",\n",
46+
" \"Ancestral heterogeneity ANCOVA statistics for APBA1 gene (ANCOVA, two-sided F statistic).\",\n",
47+
" \"Ancestral heterogeneity ANCOVA statistics for GRM7 gene (ANCOVA, two-sided F statistic).\",\n",
48+
" \"Cross ancestry meta analysis conditioned on medications (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
49+
" \"Obesity category enrichment statistics for 13 genes (two-sided Fisher’s exact test).\",\n",
50+
" \"Obesity associated comorbidity statistics for 13 genes (two-sided Fisher’s exact test).\",\n",
51+
" \"Structural equation modelling statistics for four genes (SEM, two-sided Wald Z-tests for path coefficients).\",\n",
52+
" \"Singificant PheWAS results for five previously unrepoted genes (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
53+
" \"Interaction statistics between rare variants and PGS in BMI-associated genes (two-sided Wald Z-tests from inverse-variance–weighted fixed-effects meta-analysis).\",\n",
54+
" \"BMI distribution statistics in Europeans stratified by PGS quintiles (descriptive statistics with two-sided t-tests for group comparisons).\",\n",
55+
" \"Plasma protein model coefficients of BMI-associated gene carrier status (linear regression with two-sided t-tests statistics).\",\n",
56+
" \"Plasma protein model coefficients for BMI (linear regression with two-sided t-tests statistics).\",\n",
57+
" \"Cross ancestry meta analysis statistics of known obesity genes (two-sided Wald Z-tests from fixed-effects meta-analysis).\",\n",
58+
" \"Cross ancestry meta analysis statistics of known sex-specific obesity genes (two-sided Wald Z-tests from fixed-effects meta-analysis, stratified by sex).\",\n",
59+
" \"Comorbidity selected (list of ICD-10 codes for each comorbidity along with reference for the codes aggregated for each trait).\"\n",
60+
" ],\n",
61+
" \"Manuscript heading\": [\n",
62+
" \"Result 1\", \"Result 1\", \"Result 1\", \"Result 1\", \"Result 1\", \"Result 1\", \"Result 1\", \"Result 1\",\n",
63+
" \"Result 2\", \"Result 2\", \"Result 2\", \"Result 2\", \"Result 3\", \"Result 3\",\n",
64+
" \"Result 4\", \"Result 4\", \"Result 5\", \"Result 5\", \"Methods\",\n",
65+
"\n",
66+
" ]\n",
67+
"}\n",
68+
"\n",
69+
"# Create the DataFrame\n",
70+
"df = pd.DataFrame(data)\n",
71+
"\n"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"metadata": {},
77+
"source": [
78+
"# STable 1: Cross ancestry meta analysis statistics"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": 3,
84+
"metadata": {},
85+
"outputs": [],
86+
"source": [
87+
"meta_file = \"../data/meta/tables/all_ancestry_with_nvariants.xlsx\"\n",
2888
"meta_df = pd.read_excel(meta_file, index_col=[0,1], header=[0,1,2])"
2989
]
3090
},
@@ -37,7 +97,7 @@
3797
},
3898
{
3999
"cell_type": "code",
40-
"execution_count": 3,
100+
"execution_count": 4,
41101
"metadata": {},
42102
"outputs": [],
43103
"source": [
@@ -54,7 +114,7 @@
54114
},
55115
{
56116
"cell_type": "code",
57-
"execution_count": 4,
117+
"execution_count": 5,
58118
"metadata": {},
59119
"outputs": [],
60120
"source": [
@@ -71,7 +131,7 @@
71131
},
72132
{
73133
"cell_type": "code",
74-
"execution_count": 5,
134+
"execution_count": 6,
75135
"metadata": {},
76136
"outputs": [],
77137
"source": [
@@ -88,7 +148,7 @@
88148
},
89149
{
90150
"cell_type": "code",
91-
"execution_count": 6,
151+
"execution_count": 7,
92152
"metadata": {},
93153
"outputs": [],
94154
"source": [
@@ -105,7 +165,7 @@
105165
},
106166
{
107167
"cell_type": "code",
108-
"execution_count": 7,
168+
"execution_count": 8,
109169
"metadata": {},
110170
"outputs": [],
111171
"source": [
@@ -122,7 +182,7 @@
122182
},
123183
{
124184
"cell_type": "code",
125-
"execution_count": 8,
185+
"execution_count": 9,
126186
"metadata": {},
127187
"outputs": [],
128188
"source": [
@@ -139,7 +199,7 @@
139199
},
140200
{
141201
"cell_type": "code",
142-
"execution_count": 9,
202+
"execution_count": 10,
143203
"metadata": {},
144204
"outputs": [],
145205
"source": [
@@ -156,7 +216,7 @@
156216
},
157217
{
158218
"cell_type": "code",
159-
"execution_count": 10,
219+
"execution_count": 11,
160220
"metadata": {},
161221
"outputs": [],
162222
"source": [
@@ -173,7 +233,7 @@
173233
},
174234
{
175235
"cell_type": "code",
176-
"execution_count": 11,
236+
"execution_count": 12,
177237
"metadata": {},
178238
"outputs": [],
179239
"source": [
@@ -192,7 +252,7 @@
192252
},
193253
{
194254
"cell_type": "code",
195-
"execution_count": 12,
255+
"execution_count": 13,
196256
"metadata": {},
197257
"outputs": [],
198258
"source": [
@@ -209,7 +269,7 @@
209269
},
210270
{
211271
"cell_type": "code",
212-
"execution_count": 13,
272+
"execution_count": 14,
213273
"metadata": {},
214274
"outputs": [],
215275
"source": [
@@ -226,7 +286,7 @@
226286
},
227287
{
228288
"cell_type": "code",
229-
"execution_count": 14,
289+
"execution_count": 15,
230290
"metadata": {},
231291
"outputs": [],
232292
"source": [
@@ -243,7 +303,7 @@
243303
},
244304
{
245305
"cell_type": "code",
246-
"execution_count": 15,
306+
"execution_count": 16,
247307
"metadata": {},
248308
"outputs": [],
249309
"source": [
@@ -260,7 +320,7 @@
260320
},
261321
{
262322
"cell_type": "code",
263-
"execution_count": 16,
323+
"execution_count": 17,
264324
"metadata": {},
265325
"outputs": [],
266326
"source": [
@@ -277,7 +337,7 @@
277337
},
278338
{
279339
"cell_type": "code",
280-
"execution_count": 17,
340+
"execution_count": 18,
281341
"metadata": {},
282342
"outputs": [],
283343
"source": [
@@ -313,7 +373,7 @@
313373
},
314374
{
315375
"cell_type": "code",
316-
"execution_count": 18,
376+
"execution_count": 19,
317377
"metadata": {},
318378
"outputs": [],
319379
"source": [
@@ -329,7 +389,7 @@
329389
},
330390
{
331391
"cell_type": "code",
332-
"execution_count": 19,
392+
"execution_count": 20,
333393
"metadata": {},
334394
"outputs": [],
335395
"source": [
@@ -345,11 +405,11 @@
345405
},
346406
{
347407
"cell_type": "code",
348-
"execution_count": 20,
408+
"execution_count": 21,
349409
"metadata": {},
350410
"outputs": [],
351411
"source": [
352-
"with pd.ExcelWriter('../manuscript/drafts_review1/Supplementary.xlsx', engine='xlsxwriter', mode=\"w\") as writer:\n",
412+
"with pd.ExcelWriter('../manuscript/drafts_review3/Supplementary.xlsx', engine='xlsxwriter', mode=\"w\") as writer:\n",
353413
" for i, df in enumerate(supp_dfs):\n",
354414
" df.to_excel(writer, sheet_name=f\"Supplementary Table {i+1}\", index=True)\n"
355415
]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pandas as pd
2+
3+
if __name__ == "__main__":
4+
meta_file = "../data/meta/tables/all_ancestry_with_nvariants.xlsx"
5+
meta_df = pd.read_excel(meta_file, index_col=[0,1], header=[0,1,2])
6+
7+
aou_nvars = pd.read_csv("../data/meta/tables/per_gene_variants_aou.csv", index_col=0)
8+
ukb_nvars = pd.read_csv("../data/meta/tables/per_gene_variants_ukb.csv", index_col=0).drop(columns=["oth"])
9+
10+
aou_nvars.columns = [f"{col}_aou" for col in aou_nvars.columns]
11+
ukb_nvars.columns = [f"{col}_ukb" for col in ukb_nvars.columns]
12+
13+
nvars_df = aou_nvars.merge(ukb_nvars, left_index=True, right_index=True, how="outer").T
14+
variant_type_map = dict(zip(meta_df.columns.get_level_values(0), meta_df.columns.get_level_values(1)))
15+
category_map = dict(zip(meta_df.index.get_level_values(1), meta_df.index.get_level_values(0)))
16+
17+
nvars_df.columns = pd.MultiIndex.from_tuples([(g, variant_type_map[g], "nvariants") for g in nvars_df.columns], names=["Gene", "Gene Mask", "Statistic"])
18+
nvars_df.index = pd.MultiIndex.from_tuples([(category_map[c], c) for c in nvars_df.index], names = ["Group", "Category"])
19+
20+
group_sums = nvars_df.groupby(level=0).sum()
21+
group_sums.index = pd.MultiIndex.from_tuples(
22+
[("European", "eur_meta"),
23+
("Non-european","non_eur_meta")],
24+
names=nvars_df.index.names
25+
)
26+
all_meta = group_sums.sum(axis=0).to_frame().T
27+
all_meta.index = pd.MultiIndex.from_tuples(
28+
[("All-ancestry","meta")],
29+
names=nvars_df.index.names
30+
)
31+
nvars_with_meta = pd.concat([nvars_df, group_sums, all_meta])
32+
33+
meta_with_nvariants = meta_df.merge(nvars_with_meta, how="left", left_index=True, right_index=True)
34+
stat_order = ["beta","se","ci_low","ci_high","p_value","nsamples","nvariants"]
35+
genes = meta_df.columns.get_level_values(0).unique()
36+
masks_dict = dict(zip(meta_df.columns.get_level_values(0), meta_df.columns.get_level_values(1)))
37+
38+
new_cols = []
39+
for gene in genes:
40+
for stat in stat_order:
41+
new_cols.append((gene, masks_dict[gene], stat))
42+
43+
new_index = pd.MultiIndex.from_tuples(
44+
new_cols,
45+
names=meta_with_nvariants.columns.names # should be ["Gene","Gene Mask","Statistic"]
46+
)
47+
meta_with_nvariants = meta_with_nvariants.reindex(columns=new_index)
48+
49+
meta_with_nvariants.to_excel("../data/meta/tables/all_ancestry_with_nvariants.xlsx")
50+

0 commit comments

Comments
 (0)