gwaslab 3.5.7__py3-none-any.whl → 3.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gwaslab might be problematic. Click here for more details.
- gwaslab/__init__.py +2 -0
- gwaslab/bd_common_data.py +1 -0
- gwaslab/bd_get_hapmap3.py +0 -1
- gwaslab/data/formatbook.json +78 -0
- gwaslab/data/reference.json +3 -1
- gwaslab/g_Sumstats.py +110 -25
- gwaslab/g_SumstatsMulti.py +287 -0
- gwaslab/g_SumstatsPair.py +101 -16
- gwaslab/g_Sumstats_polars.py +245 -0
- gwaslab/g_headers.py +12 -3
- gwaslab/g_meta.py +124 -47
- gwaslab/g_meta_update.py +48 -0
- gwaslab/g_vchange_status_polars.py +44 -0
- gwaslab/g_version.py +2 -2
- gwaslab/hm_casting.py +169 -110
- gwaslab/hm_casting_polars.py +202 -0
- gwaslab/hm_harmonize_sumstats.py +19 -8
- gwaslab/io_load_ld.py +529 -0
- gwaslab/io_preformat_input.py +11 -0
- gwaslab/io_preformat_input_polars.py +632 -0
- gwaslab/io_process_args.py +25 -1
- gwaslab/io_read_ldsc.py +34 -3
- gwaslab/io_read_pipcs.py +62 -6
- gwaslab/prscs_gigrnd.py +122 -0
- gwaslab/prscs_mcmc_gtb.py +136 -0
- gwaslab/prscs_parse_genet.py +98 -0
- gwaslab/qc_build.py +53 -0
- gwaslab/qc_check_datatype.py +10 -8
- gwaslab/qc_check_datatype_polars.py +128 -0
- gwaslab/qc_fix_sumstats.py +25 -23
- gwaslab/qc_fix_sumstats_polars.py +193 -0
- gwaslab/util_ex_calculate_ldmatrix.py +49 -19
- gwaslab/util_ex_gwascatalog.py +71 -28
- gwaslab/util_ex_infer_ancestry.py +65 -0
- gwaslab/util_ex_ldsc.py +67 -21
- gwaslab/util_ex_match_ldmatrix.py +396 -0
- gwaslab/util_ex_run_2samplemr.py +0 -2
- gwaslab/util_ex_run_ccgwas.py +155 -0
- gwaslab/util_ex_run_coloc.py +1 -1
- gwaslab/util_ex_run_hyprcoloc.py +117 -0
- gwaslab/util_ex_run_magma.py +74 -0
- gwaslab/util_ex_run_mesusie.py +155 -0
- gwaslab/util_ex_run_mtag.py +92 -0
- gwaslab/util_ex_run_prscs.py +85 -0
- gwaslab/util_ex_run_susie.py +40 -9
- gwaslab/util_in_estimate_ess.py +18 -0
- gwaslab/util_in_fill_data.py +20 -1
- gwaslab/util_in_filter_value.py +10 -5
- gwaslab/util_in_get_sig.py +71 -13
- gwaslab/util_in_meta.py +168 -4
- gwaslab/util_in_meta_polars.py +174 -0
- gwaslab/viz_aux_annotate_plot.py +13 -2
- gwaslab/viz_plot_compare_effect.py +87 -23
- gwaslab/viz_plot_credible_sets.py +55 -11
- gwaslab/viz_plot_effect.py +22 -12
- gwaslab/viz_plot_miamiplot2.py +3 -2
- gwaslab/viz_plot_mqqplot.py +94 -84
- gwaslab/viz_plot_qqplot.py +9 -7
- gwaslab/viz_plot_regional2.py +2 -1
- gwaslab/viz_plot_stackedregional.py +4 -1
- {gwaslab-3.5.7.dist-info → gwaslab-3.6.0.dist-info}/METADATA +46 -68
- gwaslab-3.6.0.dist-info/RECORD +119 -0
- {gwaslab-3.5.7.dist-info → gwaslab-3.6.0.dist-info}/WHEEL +1 -1
- gwaslab-3.5.7.dist-info/RECORD +0 -96
- {gwaslab-3.5.7.dist-info → gwaslab-3.6.0.dist-info/licenses}/LICENSE +0 -0
- {gwaslab-3.5.7.dist-info → gwaslab-3.6.0.dist-info/licenses}/LICENSE_before_v3.4.39 +0 -0
- {gwaslab-3.5.7.dist-info → gwaslab-3.6.0.dist-info}/top_level.txt +0 -0
gwaslab/viz_plot_mqqplot.py
CHANGED
|
@@ -25,6 +25,7 @@ from gwaslab.viz_plot_qqplot import _plot_qq
|
|
|
25
25
|
from gwaslab.hm_harmonize_sumstats import auto_check_vcf_chr_dict
|
|
26
26
|
from gwaslab.viz_plot_regional2 import _plot_regional
|
|
27
27
|
from gwaslab.viz_plot_regional2 import process_vcf
|
|
28
|
+
from gwaslab.io_load_ld import process_ld
|
|
28
29
|
from gwaslab.viz_plot_regional2 import _get_lead_id
|
|
29
30
|
from gwaslab.viz_aux_quickfix import _get_largenumber
|
|
30
31
|
from gwaslab.viz_aux_quickfix import _quick_fix_p_value
|
|
@@ -42,6 +43,8 @@ from gwaslab.viz_aux_quickfix import _quick_assign_marker_relative_size
|
|
|
42
43
|
from gwaslab.viz_aux_quickfix import _cut
|
|
43
44
|
from gwaslab.viz_aux_quickfix import _set_yticklabels
|
|
44
45
|
from gwaslab.viz_aux_quickfix import _jagged_y
|
|
46
|
+
from gwaslab.io_process_args import _update_args
|
|
47
|
+
from gwaslab.io_process_args import _update_arg
|
|
45
48
|
from gwaslab.viz_aux_save_figure import save_figure
|
|
46
49
|
from gwaslab.g_Log import Log
|
|
47
50
|
from gwaslab.util_in_calculate_gc import lambdaGC
|
|
@@ -111,6 +114,13 @@ def mqqplot(insumstats,
|
|
|
111
114
|
region_marker_shapes=None,
|
|
112
115
|
region_legend_marker=True,
|
|
113
116
|
region_ref_alias = None,
|
|
117
|
+
ld_path=None,
|
|
118
|
+
ld_map_path=None,
|
|
119
|
+
ld_fmt = "npz",
|
|
120
|
+
ld_if_square = False,
|
|
121
|
+
ld_if_add_T = False,
|
|
122
|
+
ld_map_rename_dic = None,
|
|
123
|
+
ld_map_kwargs = None,
|
|
114
124
|
cbar_title='LD $\mathregular{r^2}$ with variant',
|
|
115
125
|
cbar_fontsize = None,
|
|
116
126
|
cbar_scale=True,
|
|
@@ -144,6 +154,7 @@ def mqqplot(insumstats,
|
|
|
144
154
|
anno_alias=None,
|
|
145
155
|
anno_d=None,
|
|
146
156
|
anno_args=None,
|
|
157
|
+
anno_args_single=None,
|
|
147
158
|
anno_style="right",
|
|
148
159
|
anno_fixed_arm_length=None,
|
|
149
160
|
anno_source = "ensembl",
|
|
@@ -199,7 +210,9 @@ def mqqplot(insumstats,
|
|
|
199
210
|
drop_chr_start=False,
|
|
200
211
|
title =None,
|
|
201
212
|
mtitle=None,
|
|
213
|
+
mtitle_pad=1.08,
|
|
202
214
|
qtitle=None,
|
|
215
|
+
qtitle_pad=1.08,
|
|
203
216
|
ylabel=None,
|
|
204
217
|
xlabel=None,
|
|
205
218
|
title_pad=1.08,
|
|
@@ -232,35 +245,27 @@ def mqqplot(insumstats,
|
|
|
232
245
|
):
|
|
233
246
|
|
|
234
247
|
# log.writeing meta info #######################################################################################
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if rr_chr_dict is None:
|
|
243
|
-
rr_chr_dict = get_number_to_chr()
|
|
244
|
-
if fig_args is None:
|
|
245
|
-
fig_args= dict(figsize=(15,5))
|
|
246
|
-
if figargs is not None:
|
|
247
|
-
fig_args = figargs
|
|
248
|
+
chr_dict = _update_args(chr_dict, get_chr_to_number())
|
|
249
|
+
xtick_chr_dict = _update_args(xtick_chr_dict, get_number_to_chr())
|
|
250
|
+
gtf_chr_dict = _update_args(gtf_chr_dict, get_number_to_chr())
|
|
251
|
+
rr_chr_dict = _update_args(rr_chr_dict, get_number_to_chr())
|
|
252
|
+
|
|
253
|
+
fig_args = _update_args(fig_args, dict(figsize=(15,5)))
|
|
254
|
+
fig_args = _update_args(figargs, fig_args)
|
|
248
255
|
if "dpi" not in fig_args.keys():
|
|
249
256
|
fig_args["dpi"] = dpi
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if arrow_kwargs is None:
|
|
263
|
-
arrow_kwargs=dict()
|
|
257
|
+
|
|
258
|
+
anno_set = _update_arg(anno_set, list())
|
|
259
|
+
anno_alias = _update_args(anno_alias, dict())
|
|
260
|
+
anno_d = _update_args(anno_d,dict())
|
|
261
|
+
anno_args = _update_args(anno_args,dict())
|
|
262
|
+
anno_args_single = _update_args(anno_args_single,dict())
|
|
263
|
+
arrow_kwargs = _update_args(arrow_kwargs,dict())
|
|
264
|
+
|
|
265
|
+
colors = _update_arg(colors, ["#597FBD","#74BAD3"])
|
|
266
|
+
|
|
267
|
+
ld_map_kwargs = _update_args(ld_map_kwargs,dict())
|
|
268
|
+
|
|
264
269
|
if region is not None:
|
|
265
270
|
if marker_size == (5,20):
|
|
266
271
|
marker_size=(45,65)
|
|
@@ -277,64 +282,45 @@ def mqqplot(insumstats,
|
|
|
277
282
|
region_ref.append(region_ref_second)
|
|
278
283
|
region_ref_index_dic = {value: index for index,value in enumerate(region_ref)}
|
|
279
284
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
285
|
+
taf = _update_args(taf, [track_n,track_n_offset,track_fontsize_ratio,track_exon_ratio,track_text_offset])
|
|
286
|
+
region_marker_shapes = _update_arg(region_marker_shapes, ['o', '^','s','D','*','P','X','h','8'])
|
|
287
|
+
region_grid_line = _update_args(region_grid_line, {"linewidth": 2,"linestyle":"--"})
|
|
288
|
+
region_lead_grid_line = _update_args(region_lead_grid_line, {"alpha":0.5,"linewidth" : 2,"linestyle":"--","color":"#FF0000"})
|
|
289
|
+
region_ld_threshold = _update_arg(region_ld_threshold, [0.2,0.4,0.6,0.8])
|
|
290
|
+
region_anno_bbox_args = _update_args(region_anno_bbox_args, {"ec":"None","fc":"None"})
|
|
291
|
+
region_ld_colors = _update_arg(region_ld_colors, ["#E4E4E4","#020080","#86CEF9","#24FF02","#FDA400","#FF0000","#FF0000"])
|
|
292
|
+
region_ld_colors_m = _update_arg(region_ld_colors_m, ["#E51819","#367EB7","green","#F07818","#AD5691","yellow","purple"])
|
|
293
|
+
region_title_args = _update_args(region_title_args, {"size":fontsize})
|
|
294
|
+
|
|
295
|
+
font_family = _update_arg(font_family, fontfamily)
|
|
296
|
+
cbar_fontsize = _update_arg(cbar_fontsize, fontsize)
|
|
297
|
+
cbar_font_family = _update_arg(cbar_font_family, font_family)
|
|
298
|
+
track_font_family = _update_arg(track_font_family, font_family)
|
|
292
299
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
maf_bin_colors = ["#f0ad4e","#5cb85c", "#5bc0de","#000042"]
|
|
311
|
-
if save_args is None:
|
|
312
|
-
save_args = {"dpi":600,"facecolor":"none"}
|
|
313
|
-
if highlight is None:
|
|
314
|
-
highlight = list()
|
|
315
|
-
if highlight_anno_args is None:
|
|
316
|
-
highlight_anno_args = {}
|
|
317
|
-
if pinpoint is None:
|
|
318
|
-
pinpoint = list()
|
|
319
|
-
if build is None:
|
|
320
|
-
build = "19"
|
|
321
|
-
if scatter_args is None:
|
|
322
|
-
scatter_args={}
|
|
323
|
-
if scatterargs is not None:
|
|
324
|
-
scatter_args = scatterargs
|
|
325
|
-
if qq_scatter_args is None:
|
|
326
|
-
qq_scatter_args={}
|
|
327
|
-
if qqscatterargs is not None:
|
|
328
|
-
qq_scatter_args = qqscatterargs
|
|
329
|
-
if saveargs is not None:
|
|
330
|
-
save_args = saveargs
|
|
300
|
+
build = _update_arg(build,"19")
|
|
301
|
+
|
|
302
|
+
save_args = _update_args(save_args, {"dpi":600,"transparent":True})
|
|
303
|
+
save_args = _update_args(saveargs , save_args)
|
|
304
|
+
|
|
305
|
+
pinpoint = _update_arg(pinpoint,list())
|
|
306
|
+
highlight = _update_arg(highlight,list())
|
|
307
|
+
highlight_anno_args = _update_args(highlight_anno_args)
|
|
308
|
+
|
|
309
|
+
maf_bins = _update_arg(maf_bins,[(0, 0.01), (0.01, 0.05), (0.05, 0.25),(0.25,0.5)])
|
|
310
|
+
maf_bin_colors = _update_arg(maf_bin_colors,["#f0ad4e","#5cb85c", "#5bc0de","#000042"])
|
|
311
|
+
qq_scatter_args = _update_args(qq_scatter_args)
|
|
312
|
+
qq_scatter_args = _update_args(qqscatterargs, qq_scatter_args)
|
|
313
|
+
|
|
314
|
+
scatter_args = _update_args(scatter_args)
|
|
315
|
+
scatter_args = _update_args(scatter_args, scatterargs)
|
|
316
|
+
|
|
331
317
|
if sig_level is None:
|
|
332
318
|
sig_level_plot=sig_level_plot
|
|
333
319
|
sig_level_lead=sig_level_lead
|
|
334
320
|
else:
|
|
335
321
|
sig_level_plot = sig_level
|
|
336
322
|
sig_level_lead = sig_level
|
|
337
|
-
|
|
323
|
+
|
|
338
324
|
if check==True and _if_quick_qc==True:
|
|
339
325
|
_if_quick_qc = True
|
|
340
326
|
else:
|
|
@@ -613,7 +599,25 @@ def mqqplot(insumstats,
|
|
|
613
599
|
verbose=verbose,
|
|
614
600
|
vcf_chr_dict=vcf_chr_dict,
|
|
615
601
|
tabix=tabix)
|
|
616
|
-
|
|
602
|
+
elif ld_path is not None:
|
|
603
|
+
sumstats = process_ld(
|
|
604
|
+
ld_path=ld_path,
|
|
605
|
+
ld_map_path = ld_map_path,
|
|
606
|
+
sumstats=sumstats,
|
|
607
|
+
region=region,
|
|
608
|
+
region_ref=region_ref,
|
|
609
|
+
log=log ,
|
|
610
|
+
pos=pos,
|
|
611
|
+
ea=ea,
|
|
612
|
+
nea=nea,
|
|
613
|
+
region_ld_threshold=region_ld_threshold,
|
|
614
|
+
verbose=verbose,
|
|
615
|
+
ld_fmt = ld_fmt,
|
|
616
|
+
ld_if_square = ld_if_square,
|
|
617
|
+
ld_if_add_T = ld_if_add_T,
|
|
618
|
+
ld_map_rename_dic = ld_map_rename_dic,
|
|
619
|
+
ld_map_kwargs = ld_map_kwargs
|
|
620
|
+
)
|
|
617
621
|
#sort & add id
|
|
618
622
|
## Manhatann plot ###################################################
|
|
619
623
|
if ("m" in mode) or ("r" in mode):
|
|
@@ -631,7 +635,7 @@ def mqqplot(insumstats,
|
|
|
631
635
|
sumstats["chr_hue"]=sumstats[chrom].astype("string")
|
|
632
636
|
|
|
633
637
|
if "r" in mode:
|
|
634
|
-
if vcf_path is None:
|
|
638
|
+
if vcf_path is None and ld_path is None:
|
|
635
639
|
sumstats["LD"]=100
|
|
636
640
|
sumstats["SHAPE"]=1
|
|
637
641
|
sumstats["chr_hue"]=sumstats["LD"]
|
|
@@ -777,9 +781,10 @@ def mqqplot(insumstats,
|
|
|
777
781
|
sizes=marker_size,
|
|
778
782
|
hue_norm=hue_norm,
|
|
779
783
|
linewidth=linewidth,
|
|
780
|
-
edgecolor = edgecolor,
|
|
784
|
+
edgecolor = edgecolor,
|
|
781
785
|
zorder=2,ax=ax1,**scatter_args)
|
|
782
786
|
|
|
787
|
+
ax1.set_rasterization_zorder(0)
|
|
783
788
|
|
|
784
789
|
## if pinpoint variants
|
|
785
790
|
if (len(pinpoint)>0):
|
|
@@ -814,6 +819,7 @@ def mqqplot(insumstats,
|
|
|
814
819
|
ax3=ax3,
|
|
815
820
|
region=region,
|
|
816
821
|
vcf_path=vcf_path,
|
|
822
|
+
ld_path=ld_path,
|
|
817
823
|
marker_size=marker_size,
|
|
818
824
|
build=build,
|
|
819
825
|
cbar_scale=cbar_scale,
|
|
@@ -1000,7 +1006,7 @@ def mqqplot(insumstats,
|
|
|
1000
1006
|
|
|
1001
1007
|
|
|
1002
1008
|
if mtitle and anno and len(to_annotate)>0:
|
|
1003
|
-
pad=(ax1.transData.transform((skip,
|
|
1009
|
+
pad=(ax1.transData.transform((skip, mtitle_pad*maxy))[1]-ax1.transData.transform((skip, maxy)))[1]
|
|
1004
1010
|
ax1.set_title(mtitle,pad=pad,fontsize=title_fontsize,family=font_family)
|
|
1005
1011
|
elif mtitle:
|
|
1006
1012
|
ax1.set_title(mtitle,fontsize=title_fontsize,family=font_family)
|
|
@@ -1021,6 +1027,7 @@ def mqqplot(insumstats,
|
|
|
1021
1027
|
anno_alias=anno_alias,
|
|
1022
1028
|
anno_style=anno_style,
|
|
1023
1029
|
anno_args=anno_args,
|
|
1030
|
+
anno_args_single=anno_args_single,
|
|
1024
1031
|
arm_scale=arm_scale,
|
|
1025
1032
|
anno_max_iter=anno_max_iter,
|
|
1026
1033
|
arm_scale_d=arm_scale_d,
|
|
@@ -1072,6 +1079,7 @@ def mqqplot(insumstats,
|
|
|
1072
1079
|
fontsize=fontsize,
|
|
1073
1080
|
font_family=font_family,
|
|
1074
1081
|
qtitle=qtitle,
|
|
1082
|
+
qtitle_pad=qtitle_pad,
|
|
1075
1083
|
title_fontsize=title_fontsize,
|
|
1076
1084
|
include_chrXYMT=include_chrXYMT,
|
|
1077
1085
|
cut_line_color=cut_line_color,
|
|
@@ -1104,9 +1112,10 @@ def mqqplot(insumstats,
|
|
|
1104
1112
|
# Titles
|
|
1105
1113
|
if title and anno and len(to_annotate)>0:
|
|
1106
1114
|
# increase height if annotation
|
|
1107
|
-
fig.suptitle(title , fontsize = title_fontsize ,x=0.5, y=
|
|
1115
|
+
fig.suptitle(title , fontsize = title_fontsize ,x=0.5, y=title_pad)
|
|
1108
1116
|
else:
|
|
1109
|
-
|
|
1117
|
+
title_pad = title_pad -0.05
|
|
1118
|
+
fig.suptitle(title , fontsize = title_fontsize, x=0.5,y=title_pad)
|
|
1110
1119
|
## Add annotation arrows and texts
|
|
1111
1120
|
|
|
1112
1121
|
# Saving figure
|
|
@@ -1149,6 +1158,7 @@ def _configure_fig_save_kwargs(mode="m",
|
|
|
1149
1158
|
if mode!="r":
|
|
1150
1159
|
scatter_args["rasterized"]=True
|
|
1151
1160
|
qq_scatter_args["rasterized"]=True
|
|
1161
|
+
qq_scatter_args["antialiased"]=False,
|
|
1152
1162
|
log.write("Saving as pdf/svg: scatter plot will be rasterized for mqq...", verbose=verbose)
|
|
1153
1163
|
else:
|
|
1154
1164
|
scatter_args["rasterized"]=False
|
gwaslab/viz_plot_qqplot.py
CHANGED
|
@@ -30,6 +30,7 @@ def _plot_qq(
|
|
|
30
30
|
fontsize,
|
|
31
31
|
font_family,
|
|
32
32
|
qtitle,
|
|
33
|
+
qtitle_pad,
|
|
33
34
|
title_fontsize,
|
|
34
35
|
include_chrXYMT,
|
|
35
36
|
cut_line_color,
|
|
@@ -94,15 +95,15 @@ def _plot_qq(
|
|
|
94
95
|
|
|
95
96
|
expected = -np.log10(np.linspace(minit,upper_bound_p,max(len(databin_raw),len(databin))))[:len(observed)]
|
|
96
97
|
|
|
97
|
-
label ="("+str(lower)+","+str(upper) +"]"
|
|
98
|
+
label ="( "+str(lower)+","+str(upper) +" ]"
|
|
98
99
|
ax2.scatter(expected,observed,s=marker_size[1],color=maf_bin_colors[i],label=label,**qq_scatter_args)
|
|
99
|
-
ax2_legend= ax2.legend(loc="best",fontsize=fontsize,markerscale=
|
|
100
|
+
ax2_legend= ax2.legend(loc="best",fontsize=fontsize,markerscale=1.5,frameon=False, handletextpad=0.4, borderaxespad=0.4)
|
|
100
101
|
plt.setp(ax2_legend.texts, family=font_family)
|
|
101
102
|
|
|
102
103
|
qq_x = max(skip, expected_min_mlog10p)
|
|
103
104
|
ax2.plot([qq_x,-np.log10(minit)],[qq_x,-np.log10(minit)],linestyle="--",color=qq_line_color)
|
|
104
|
-
ax2.set_xlabel("Expected
|
|
105
|
-
ax2.set_ylabel("Observed
|
|
105
|
+
ax2.set_xlabel("Expected $\mathregular{-log_{10}(P)}$",fontsize=fontsize,family=font_family)
|
|
106
|
+
ax2.set_ylabel("Observed $\mathregular{-log_{10}(P)}$",fontsize=fontsize,family=font_family)
|
|
106
107
|
ax2.spines["top"].set_visible(False)
|
|
107
108
|
ax2.spines["right"].set_visible(False)
|
|
108
109
|
ax2.spines["left"].set_visible(True)
|
|
@@ -127,7 +128,7 @@ def _plot_qq(
|
|
|
127
128
|
verbose=verbose)
|
|
128
129
|
|
|
129
130
|
# annotate lambda gc to qq plot
|
|
130
|
-
ax2.text(0.10, 1.03,"
|
|
131
|
+
ax2.text(0.10, 1.03,"$\mathregular{\\lambda_{GC}}$ = "+"{:.4f}".format(lambdagc),
|
|
131
132
|
horizontalalignment='left',
|
|
132
133
|
verticalalignment='top',
|
|
133
134
|
transform=ax2.transAxes,
|
|
@@ -179,10 +180,11 @@ def _plot_qq(
|
|
|
179
180
|
# ax2.set_yticklabels([x for x in range(skip,cut-step,step)]+[cut],fontsize=fontsize,family=font_family)
|
|
180
181
|
# ax2.set_ylim(bottom = skip)
|
|
181
182
|
|
|
182
|
-
ax2.tick_params(axis='both', which='both', labelsize=fontsize)
|
|
183
|
+
ax2.tick_params(axis='both', which='both', labelsize=fontsize,labelfontfamily=font_family)
|
|
183
184
|
#
|
|
184
185
|
if qtitle:
|
|
185
|
-
ax2.
|
|
186
|
+
pad=(ax2.transData.transform((skip, qtitle_pad*maxy))[1]-ax2.transData.transform((skip, maxy)))[1]
|
|
187
|
+
ax2.set_title(qtitle,fontsize=title_fontsize,pad=pad,family=font_family)
|
|
186
188
|
|
|
187
189
|
log.write("Finished creating QQ plot successfully!",verbose=verbose)
|
|
188
190
|
|
gwaslab/viz_plot_regional2.py
CHANGED
|
@@ -35,6 +35,7 @@ def _plot_regional(
|
|
|
35
35
|
ax3,
|
|
36
36
|
region,
|
|
37
37
|
vcf_path,
|
|
38
|
+
ld_path,
|
|
38
39
|
marker_size,
|
|
39
40
|
build,
|
|
40
41
|
cut_line_color,
|
|
@@ -125,7 +126,7 @@ def _plot_regional(
|
|
|
125
126
|
|
|
126
127
|
##########################################################################################################
|
|
127
128
|
|
|
128
|
-
if (vcf_path is not None) and region_ld_legend:
|
|
129
|
+
if ((vcf_path is not None) or (ld_path is not None)) and region_ld_legend:
|
|
129
130
|
## plot cbar
|
|
130
131
|
ax1, cbar = _add_ld_legend(sumstats=sumstats,
|
|
131
132
|
ax1=ax1,
|
|
@@ -86,11 +86,14 @@ def plot_stacked_mqq( objects,
|
|
|
86
86
|
if "P" in each_object.data.columns or "MLOG10P" in each_object.data.columns:
|
|
87
87
|
sumstats_list.append(each_object.data)
|
|
88
88
|
pm.append("m")
|
|
89
|
-
|
|
89
|
+
if type(each_object) is pd.DataFrame:
|
|
90
90
|
if "PIP" in each_object.columns:
|
|
91
91
|
sumstats_list.append(each_object)
|
|
92
92
|
pm.append("pip")
|
|
93
93
|
common_ylabel=False
|
|
94
|
+
else:
|
|
95
|
+
sumstats_list.append(each_object)
|
|
96
|
+
pm.append("m")
|
|
94
97
|
|
|
95
98
|
if common_ylabel==True:
|
|
96
99
|
rr_ylabel=False
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: gwaslab
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.6.0
|
|
4
4
|
Summary: A collection of handy tools for GWAS SumStats
|
|
5
5
|
Author-email: Yunye <yunye@gwaslab.com>
|
|
6
6
|
Project-URL: Homepage, https://cloufield.github.io/gwaslab/
|
|
7
7
|
Project-URL: Github, https://github.com/Cloufield/gwaslab
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved ::
|
|
9
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: <3.13,>=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
@@ -25,52 +25,74 @@ Requires-Dist: scikit-allel>=1.3.5
|
|
|
25
25
|
Requires-Dist: pyensembl==2.2.3
|
|
26
26
|
Requires-Dist: gtfparse==1.3.0
|
|
27
27
|
Requires-Dist: h5py>=3.10.0
|
|
28
|
+
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# GWASLab
|
|
30
31
|
|
|
31
|
-
<img width="600" alt="image" src="https://
|
|
32
|
+
<img width="600" alt="image" src="https://github.com/user-attachments/assets/109262c6-c870-4078-94b5-66cf8c6b13c4" />
|
|
32
33
|
|
|
33
34
|

|
|
34
35
|
[](https://pepy.tech/project/gwaslab)
|
|
35
36
|

|
|
36
|
-
[](https://hits.seeyoufarm.com)
|
|
37
37
|

|
|
38
38
|
|
|
39
|
-
* A handy Python toolkit for handling GWAS summary statistics (sumstats).
|
|
39
|
+
* A handy Python-based toolkit for handling GWAS summary statistics (sumstats).
|
|
40
40
|
* Each process is modularized and can be customized to your needs.
|
|
41
41
|
* Sumstats-specific manipulations are designed as methods of a Python object, `gwaslab.Sumstats`.
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
## Installation
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### install via pip
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
The latest version of GWASLab now supports Python 3.9, 3.10, 3.11, and 3.12.
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
```bash
|
|
50
|
+
pip install gwaslab
|
|
51
|
+
```
|
|
50
52
|
|
|
51
|
-
### install
|
|
53
|
+
### install in conda environment
|
|
54
|
+
|
|
55
|
+
Create a Python 3.9, 3.10, 3.11 or 3.12 environment and install gwaslab using pip:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
conda env create -n gwaslab -c conda-forge python=3.12
|
|
59
|
+
|
|
60
|
+
conda activate gwaslab
|
|
52
61
|
|
|
62
|
+
pip install gwaslab
|
|
53
63
|
```
|
|
54
|
-
|
|
64
|
+
|
|
65
|
+
or create a new environment using yml file [environment.yml](https://github.com/Cloufield/gwaslab/blob/main/environment.yml)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
conda env create -n gwaslab -f environment.yml
|
|
55
69
|
```
|
|
56
70
|
|
|
71
|
+
### install using docker (deprecated)
|
|
72
|
+
|
|
73
|
+
A docker file is available [here](https://github.com/Cloufield/gwaslab/blob/main/docker/Dockerfile) for building local images.
|
|
74
|
+
|
|
75
|
+
## Quick start
|
|
76
|
+
|
|
57
77
|
```python
|
|
78
|
+
|
|
58
79
|
import gwaslab as gl
|
|
80
|
+
|
|
59
81
|
# load plink2 output
|
|
60
|
-
mysumstats = gl.Sumstats("
|
|
82
|
+
mysumstats = gl.Sumstats("sumstats.txt.gz", fmt="plink2")
|
|
61
83
|
|
|
62
|
-
# load sumstats with auto mode (auto-detecting
|
|
84
|
+
# or load sumstats with auto mode (auto-detecting commonly used headers)
|
|
63
85
|
# assuming ALT/A1 is EA, and frq is EAF
|
|
64
|
-
mysumstats = gl.Sumstats("
|
|
86
|
+
mysumstats = gl.Sumstats("sumstats.txt.gz", fmt="auto")
|
|
65
87
|
|
|
66
88
|
# or you can specify the columns:
|
|
67
|
-
mysumstats = gl.Sumstats("
|
|
89
|
+
mysumstats = gl.Sumstats("sumstats.txt.gz",
|
|
68
90
|
snpid="SNP",
|
|
69
91
|
chrom="CHR",
|
|
70
92
|
pos="POS",
|
|
71
93
|
ea="ALT",
|
|
72
94
|
nea="REF",
|
|
73
|
-
|
|
95
|
+
eaf="Frq",
|
|
74
96
|
beta="BETA",
|
|
75
97
|
se="SE",
|
|
76
98
|
p="P",
|
|
@@ -83,26 +105,9 @@ mysumstats.plot_mqq()
|
|
|
83
105
|
...
|
|
84
106
|
```
|
|
85
107
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Create a Python 3.9 environment and install gwaslab using pip:
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
conda env create -n gwaslab_test -c conda-forge python=3.9
|
|
92
|
-
conda activate gwaslab
|
|
93
|
-
pip install gwaslab==3.4.45
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
or create a new environment using yml file [environment_3.4.40.yml](https://github.com/Cloufield/gwaslab/blob/main/environment_3.4.40.yml)
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
conda env create -n gwaslab -f environment_3.4.40.yml
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### install using docker
|
|
108
|
+
## Documentation and tutorials
|
|
104
109
|
|
|
105
|
-
|
|
110
|
+
Documentation and tutorials for GWASLab are avaiable at [here](https://cloufield.github.io/gwaslab/).
|
|
106
111
|
|
|
107
112
|
## Functions
|
|
108
113
|
|
|
@@ -149,7 +154,7 @@ A docker file is available [here](https://github.com/Cloufield/gwaslab/blob/main
|
|
|
149
154
|
- Scatter plot: allele frequency comparison
|
|
150
155
|
- Scatter plot: trumpet plot (plot of MAF and effect size with power lines)
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
#### Visualization Examples
|
|
153
158
|
|
|
154
159
|
<img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/233836639-34b03c47-5a59-4fd4-9677-5e13b02aab15.png">
|
|
155
160
|
<img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197393168-e3e7076f-2801-4d66-9526-80778d44f3da.png">
|
|
@@ -165,42 +170,15 @@ A docker file is available [here](https://github.com/Cloufield/gwaslab/blob/main
|
|
|
165
170
|
- Sumstats summary: give you a quick overview of the sumstats.
|
|
166
171
|
- ...
|
|
167
172
|
|
|
168
|
-
##
|
|
169
|
-
|
|
170
|
-
environment.yml
|
|
173
|
+
## Issues
|
|
171
174
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
channels:
|
|
175
|
-
- conda-forge
|
|
176
|
-
- defaults
|
|
177
|
-
dependencies:
|
|
178
|
-
- python=3.8.16=h7a1cb2a_3
|
|
179
|
-
- jupyter==1.0.0
|
|
180
|
-
- pip==23.1.2
|
|
181
|
-
- pip:
|
|
182
|
-
- adjusttext==0.8
|
|
183
|
-
- biopython==1.81
|
|
184
|
-
- gwaslab==3.4.16
|
|
185
|
-
- liftover==1.1.16
|
|
186
|
-
- matplotlib==3.7.1
|
|
187
|
-
- numpy==1.24.2
|
|
188
|
-
- pandas==1.4.4
|
|
189
|
-
- scikit-allel==1.3.5
|
|
190
|
-
- scikit-learn==1.2.2
|
|
191
|
-
- scipy==1.10.1
|
|
192
|
-
- seaborn==0.11.2
|
|
193
|
-
- statsmodels==0.13
|
|
194
|
-
- adjustText==0.8
|
|
195
|
-
- pysam==0.19
|
|
196
|
-
- pyensembl==2.2.3
|
|
197
|
-
- h5py==3.10.0
|
|
198
|
-
```
|
|
175
|
+
- GWASLab is currently under active development, with frequent updates.
|
|
176
|
+
- Note: Known issues are documented at https://cloufield.github.io/gwaslab/KnownIssues/.
|
|
199
177
|
|
|
200
178
|
## How to cite
|
|
201
179
|
- GWASLab preprint: He, Y., Koido, M., Shimmori, Y., Kamatani, Y. (2023). GWASLab: a Python package for processing and visualizing GWAS summary statistics. Preprint at Jxiv, 2023-5. https://doi.org/10.51094/jxiv.370
|
|
202
180
|
|
|
203
|
-
## Sample
|
|
181
|
+
## Sample data used for tutorial
|
|
204
182
|
- Sample GWAS data used in GWASLab is obtained from: http://jenger.riken.jp/ (Suzuki, Ken, et al. "Identification of 28 new susceptibility loci for type 2 diabetes in the Japanese population." Nature genetics 51.3 (2019): 379-386.).
|
|
205
183
|
|
|
206
184
|
## Acknowledgement
|