gwaslab 3.5.6__py3-none-any.whl → 3.5.8__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/g_Sumstats.py +98 -24
- 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 +123 -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_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_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_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 +165 -141
- gwaslab/viz_plot_qqplot.py +6 -6
- gwaslab/viz_plot_regional2.py +5 -13
- gwaslab/viz_plot_rg_heatmap.py +6 -1
- gwaslab/viz_plot_stackedregional.py +21 -6
- {gwaslab-3.5.6.dist-info → gwaslab-3.5.8.dist-info}/METADATA +9 -7
- gwaslab-3.5.8.dist-info/RECORD +117 -0
- {gwaslab-3.5.6.dist-info → gwaslab-3.5.8.dist-info}/WHEEL +1 -1
- gwaslab-3.5.6.dist-info/RECORD +0 -96
- {gwaslab-3.5.6.dist-info → gwaslab-3.5.8.dist-info/licenses}/LICENSE +0 -0
- {gwaslab-3.5.6.dist-info → gwaslab-3.5.8.dist-info/licenses}/LICENSE_before_v3.4.39 +0 -0
- {gwaslab-3.5.6.dist-info → gwaslab-3.5.8.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,7 +114,14 @@ def mqqplot(insumstats,
|
|
|
111
114
|
region_marker_shapes=None,
|
|
112
115
|
region_legend_marker=True,
|
|
113
116
|
region_ref_alias = None,
|
|
114
|
-
|
|
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,
|
|
124
|
+
cbar_title='LD $\mathregular{r^2}$ with variant',
|
|
115
125
|
cbar_fontsize = None,
|
|
116
126
|
cbar_scale=True,
|
|
117
127
|
cbar_font_family = None,
|
|
@@ -205,7 +215,9 @@ def mqqplot(insumstats,
|
|
|
205
215
|
title_pad=1.08,
|
|
206
216
|
title_fontsize=13,
|
|
207
217
|
fontsize = 9,
|
|
208
|
-
font_family=
|
|
218
|
+
font_family=None,
|
|
219
|
+
fontfamily="Arial",
|
|
220
|
+
math_fontfamily="dejavusans",
|
|
209
221
|
anno_fontsize = 9,
|
|
210
222
|
figargs=None,
|
|
211
223
|
fig_args= None,
|
|
@@ -230,34 +242,26 @@ def mqqplot(insumstats,
|
|
|
230
242
|
):
|
|
231
243
|
|
|
232
244
|
# log.writeing meta info #######################################################################################
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
rr_chr_dict = get_number_to_chr()
|
|
241
|
-
if fig_args is None:
|
|
242
|
-
fig_args= dict(figsize=(15,5))
|
|
243
|
-
if figargs is not None:
|
|
244
|
-
fig_args = figargs
|
|
245
|
+
chr_dict = _update_args(chr_dict, get_chr_to_number())
|
|
246
|
+
xtick_chr_dict = _update_args(xtick_chr_dict, get_number_to_chr())
|
|
247
|
+
gtf_chr_dict = _update_args(gtf_chr_dict, get_number_to_chr())
|
|
248
|
+
rr_chr_dict = _update_args(rr_chr_dict, get_number_to_chr())
|
|
249
|
+
|
|
250
|
+
fig_args = _update_args(fig_args, dict(figsize=(15,5)))
|
|
251
|
+
fig_args = _update_args(figargs, fig_args)
|
|
245
252
|
if "dpi" not in fig_args.keys():
|
|
246
253
|
fig_args["dpi"] = dpi
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
colors=["#597FBD","#74BAD3"]
|
|
259
|
-
if arrow_kwargs is None:
|
|
260
|
-
arrow_kwargs=dict()
|
|
254
|
+
|
|
255
|
+
anno_set = _update_arg(anno_set, list())
|
|
256
|
+
anno_alias = _update_args(anno_alias, dict())
|
|
257
|
+
anno_d = _update_args(anno_d,dict())
|
|
258
|
+
anno_args = _update_args(anno_args,dict())
|
|
259
|
+
arrow_kwargs = _update_args(arrow_kwargs,dict())
|
|
260
|
+
|
|
261
|
+
colors = _update_arg(colors, ["#597FBD","#74BAD3"])
|
|
262
|
+
|
|
263
|
+
ld_map_kwargs = _update_args(ld_map_kwargs,dict())
|
|
264
|
+
|
|
261
265
|
if region is not None:
|
|
262
266
|
if marker_size == (5,20):
|
|
263
267
|
marker_size=(45,65)
|
|
@@ -274,84 +278,59 @@ def mqqplot(insumstats,
|
|
|
274
278
|
region_ref.append(region_ref_second)
|
|
275
279
|
region_ref_index_dic = {value: index for index,value in enumerate(region_ref)}
|
|
276
280
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
281
|
+
taf = _update_args(taf, [track_n,track_n_offset,track_fontsize_ratio,track_exon_ratio,track_text_offset])
|
|
282
|
+
region_marker_shapes = _update_arg(region_marker_shapes, ['o', '^','s','D','*','P','X','h','8'])
|
|
283
|
+
region_grid_line = _update_args(region_grid_line, {"linewidth": 2,"linestyle":"--"})
|
|
284
|
+
region_lead_grid_line = _update_args(region_lead_grid_line, {"alpha":0.5,"linewidth" : 2,"linestyle":"--","color":"#FF0000"})
|
|
285
|
+
region_ld_threshold = _update_arg(region_ld_threshold, [0.2,0.4,0.6,0.8])
|
|
286
|
+
region_anno_bbox_args = _update_args(region_anno_bbox_args, {"ec":"None","fc":"None"})
|
|
287
|
+
region_ld_colors = _update_arg(region_ld_colors, ["#E4E4E4","#020080","#86CEF9","#24FF02","#FDA400","#FF0000","#FF0000"])
|
|
288
|
+
region_ld_colors_m = _update_arg(region_ld_colors_m, ["#E51819","#367EB7","green","#F07818","#AD5691","yellow","purple"])
|
|
289
|
+
region_title_args = _update_args(region_title_args, {"size":fontsize})
|
|
290
|
+
|
|
291
|
+
font_family = _update_arg(font_family, fontfamily)
|
|
292
|
+
cbar_fontsize = _update_arg(cbar_fontsize, fontsize)
|
|
293
|
+
cbar_font_family = _update_arg(cbar_font_family, font_family)
|
|
294
|
+
track_font_family = _update_arg(track_font_family, font_family)
|
|
289
295
|
|
|
290
|
-
|
|
291
|
-
|
|
296
|
+
build = _update_arg(build,"19")
|
|
297
|
+
|
|
298
|
+
save_args = _update_args(save_args, {"dpi":600,"transparent":True})
|
|
299
|
+
save_args = _update_args(saveargs , save_args)
|
|
300
|
+
|
|
301
|
+
pinpoint = _update_arg(pinpoint,list())
|
|
302
|
+
highlight = _update_arg(highlight,list())
|
|
303
|
+
highlight_anno_args = _update_args(highlight_anno_args)
|
|
292
304
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if taf is None:
|
|
302
|
-
taf = [track_n,track_n_offset,track_fontsize_ratio,track_exon_ratio,track_text_offset]
|
|
303
|
-
if maf_bins is None:
|
|
304
|
-
maf_bins=[(0, 0.01), (0.01, 0.05), (0.05, 0.25),(0.25,0.5)]
|
|
305
|
-
if maf_bin_colors is None:
|
|
306
|
-
maf_bin_colors = ["#f0ad4e","#5cb85c", "#5bc0de","#000042"]
|
|
307
|
-
if save_args is None:
|
|
308
|
-
save_args = {"dpi":400,"facecolor":"white"}
|
|
309
|
-
if highlight is None:
|
|
310
|
-
highlight = list()
|
|
311
|
-
if highlight_anno_args is None:
|
|
312
|
-
highlight_anno_args = {}
|
|
313
|
-
if pinpoint is None:
|
|
314
|
-
pinpoint = list()
|
|
315
|
-
if build is None:
|
|
316
|
-
build = "19"
|
|
317
|
-
if scatter_args is None:
|
|
318
|
-
scatter_args={}
|
|
319
|
-
if scatterargs is not None:
|
|
320
|
-
scatter_args = scatterargs
|
|
321
|
-
if qq_scatter_args is None:
|
|
322
|
-
qq_scatter_args={}
|
|
323
|
-
if qqscatterargs is not None:
|
|
324
|
-
qq_scatter_args = qqscatterargs
|
|
325
|
-
if saveargs is not None:
|
|
326
|
-
save_args = saveargs
|
|
305
|
+
maf_bins = _update_arg(maf_bins,[(0, 0.01), (0.01, 0.05), (0.05, 0.25),(0.25,0.5)])
|
|
306
|
+
maf_bin_colors = _update_arg(maf_bin_colors,["#f0ad4e","#5cb85c", "#5bc0de","#000042"])
|
|
307
|
+
qq_scatter_args = _update_args(qq_scatter_args)
|
|
308
|
+
qq_scatter_args = _update_args(qqscatterargs, qq_scatter_args)
|
|
309
|
+
|
|
310
|
+
scatter_args = _update_args(scatter_args)
|
|
311
|
+
scatter_args = _update_args(scatter_args, scatterargs)
|
|
312
|
+
|
|
327
313
|
if sig_level is None:
|
|
328
314
|
sig_level_plot=sig_level_plot
|
|
329
315
|
sig_level_lead=sig_level_lead
|
|
330
316
|
else:
|
|
331
317
|
sig_level_plot = sig_level
|
|
332
318
|
sig_level_lead = sig_level
|
|
333
|
-
|
|
319
|
+
|
|
334
320
|
if check==True and _if_quick_qc==True:
|
|
335
321
|
_if_quick_qc = True
|
|
336
322
|
else:
|
|
337
323
|
_if_quick_qc = False
|
|
338
324
|
|
|
339
|
-
if save is not None:
|
|
340
|
-
if type(save) is not bool:
|
|
341
|
-
if len(save)>3:
|
|
342
|
-
if save[-3:]=="pdf" or save[-3:]=="svg":
|
|
343
|
-
fig_args["dpi"]=72
|
|
344
|
-
scatter_args["rasterized"]=True
|
|
345
|
-
qq_scatter_args["rasterized"]=True
|
|
346
|
-
else:
|
|
347
|
-
fig_args["dpi"] = save_args["dpi"]
|
|
348
|
-
|
|
349
325
|
# configure dpi if saving the plot
|
|
350
|
-
fig_args, scatter_args, qq_scatter_args, save_args = _configure_fig_save_kwargs(
|
|
326
|
+
fig_args, scatter_args, qq_scatter_args, save_args = _configure_fig_save_kwargs(mode=mode,
|
|
327
|
+
save = save,
|
|
351
328
|
fig_args = fig_args,
|
|
352
329
|
scatter_args = scatter_args,
|
|
353
330
|
qq_scatter_args = qq_scatter_args,
|
|
354
|
-
save_args = save_args
|
|
331
|
+
save_args = save_args,
|
|
332
|
+
log=log,
|
|
333
|
+
verbose=verbose)
|
|
355
334
|
|
|
356
335
|
|
|
357
336
|
if len(anno_d) > 0 and arm_offset is None:
|
|
@@ -616,7 +595,25 @@ def mqqplot(insumstats,
|
|
|
616
595
|
verbose=verbose,
|
|
617
596
|
vcf_chr_dict=vcf_chr_dict,
|
|
618
597
|
tabix=tabix)
|
|
619
|
-
|
|
598
|
+
elif ld_path is not None:
|
|
599
|
+
sumstats = process_ld(
|
|
600
|
+
ld_path=ld_path,
|
|
601
|
+
ld_map_path = ld_map_path,
|
|
602
|
+
sumstats=sumstats,
|
|
603
|
+
region=region,
|
|
604
|
+
region_ref=region_ref,
|
|
605
|
+
log=log ,
|
|
606
|
+
pos=pos,
|
|
607
|
+
ea=ea,
|
|
608
|
+
nea=nea,
|
|
609
|
+
region_ld_threshold=region_ld_threshold,
|
|
610
|
+
verbose=verbose,
|
|
611
|
+
ld_fmt = ld_fmt,
|
|
612
|
+
ld_if_square = ld_if_square,
|
|
613
|
+
ld_if_add_T = ld_if_add_T,
|
|
614
|
+
ld_map_rename_dic = ld_map_rename_dic,
|
|
615
|
+
ld_map_kwargs = ld_map_kwargs
|
|
616
|
+
)
|
|
620
617
|
#sort & add id
|
|
621
618
|
## Manhatann plot ###################################################
|
|
622
619
|
if ("m" in mode) or ("r" in mode):
|
|
@@ -634,7 +631,7 @@ def mqqplot(insumstats,
|
|
|
634
631
|
sumstats["chr_hue"]=sumstats[chrom].astype("string")
|
|
635
632
|
|
|
636
633
|
if "r" in mode:
|
|
637
|
-
if vcf_path is None:
|
|
634
|
+
if vcf_path is None and ld_path is None:
|
|
638
635
|
sumstats["LD"]=100
|
|
639
636
|
sumstats["SHAPE"]=1
|
|
640
637
|
sumstats["chr_hue"]=sumstats["LD"]
|
|
@@ -780,9 +777,10 @@ def mqqplot(insumstats,
|
|
|
780
777
|
sizes=marker_size,
|
|
781
778
|
hue_norm=hue_norm,
|
|
782
779
|
linewidth=linewidth,
|
|
783
|
-
edgecolor = edgecolor,
|
|
780
|
+
edgecolor = edgecolor,
|
|
784
781
|
zorder=2,ax=ax1,**scatter_args)
|
|
785
782
|
|
|
783
|
+
ax1.set_rasterization_zorder(0)
|
|
786
784
|
|
|
787
785
|
## if pinpoint variants
|
|
788
786
|
if (len(pinpoint)>0):
|
|
@@ -817,10 +815,9 @@ def mqqplot(insumstats,
|
|
|
817
815
|
ax3=ax3,
|
|
818
816
|
region=region,
|
|
819
817
|
vcf_path=vcf_path,
|
|
818
|
+
ld_path=ld_path,
|
|
820
819
|
marker_size=marker_size,
|
|
821
|
-
fontsize=fontsize,
|
|
822
820
|
build=build,
|
|
823
|
-
chrom_df=chrom_df,
|
|
824
821
|
cbar_scale=cbar_scale,
|
|
825
822
|
cbar_fontsize=cbar_fontsize,
|
|
826
823
|
cbar_bbox_to_anchor=cbar_bbox_to_anchor,
|
|
@@ -829,9 +826,7 @@ def mqqplot(insumstats,
|
|
|
829
826
|
cbar_equal_aspect=cbar_equal_aspect,
|
|
830
827
|
cbar_downward_offset =cbar_downward_offset,
|
|
831
828
|
cbar_borderpad=cbar_borderpad,
|
|
832
|
-
xtick_chr_dict=xtick_chr_dict,
|
|
833
829
|
cut_line_color=cut_line_color,
|
|
834
|
-
vcf_chr_dict =vcf_chr_dict,
|
|
835
830
|
gtf_path=gtf_path,
|
|
836
831
|
gtf_chr_dict = gtf_chr_dict,
|
|
837
832
|
gtf_gene_name=gtf_gene_name,
|
|
@@ -849,13 +844,11 @@ def mqqplot(insumstats,
|
|
|
849
844
|
region_grid_line = region_grid_line,
|
|
850
845
|
region_lead_grid = region_lead_grid,
|
|
851
846
|
region_lead_grid_line = region_lead_grid_line,
|
|
852
|
-
region_hspace=region_hspace,
|
|
853
847
|
region_title=region_title,
|
|
854
848
|
region_title_args=region_title_args,
|
|
855
849
|
region_ld_legend = region_ld_legend,
|
|
856
850
|
region_legend_marker=region_legend_marker,
|
|
857
851
|
region_ld_threshold = region_ld_threshold,
|
|
858
|
-
region_ld_colors = region_ld_colors,
|
|
859
852
|
palette = palette,
|
|
860
853
|
region_marker_shapes = region_marker_shapes,
|
|
861
854
|
region_recombination = region_recombination,
|
|
@@ -863,8 +856,6 @@ def mqqplot(insumstats,
|
|
|
863
856
|
region_flank_factor =region_flank_factor,
|
|
864
857
|
track_font_family=track_font_family,
|
|
865
858
|
taf=taf,
|
|
866
|
-
tabix=tabix,
|
|
867
|
-
chrom=chrom,
|
|
868
859
|
pos=pos,
|
|
869
860
|
verbose=verbose,
|
|
870
861
|
log=log
|
|
@@ -923,10 +914,10 @@ def mqqplot(insumstats,
|
|
|
923
914
|
|
|
924
915
|
# Configure X, Y axes #######################################################
|
|
925
916
|
log.write("Start to process figure arts.",verbose=verbose)
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
917
|
+
|
|
918
|
+
ax1, ax3 = _process_xtick(ax1=ax1,
|
|
919
|
+
ax3=ax3,
|
|
920
|
+
mode=mode,
|
|
930
921
|
chrom_df=chrom_df,
|
|
931
922
|
xtick_chr_dict=xtick_chr_dict,
|
|
932
923
|
fontsize = fontsize,
|
|
@@ -950,7 +941,8 @@ def mqqplot(insumstats,
|
|
|
950
941
|
mode=mode,
|
|
951
942
|
bwindowsizekb=bwindowsizekb,
|
|
952
943
|
fontsize=fontsize,
|
|
953
|
-
font_family=font_family,
|
|
944
|
+
font_family=font_family,
|
|
945
|
+
math_fontfamily=math_fontfamily,
|
|
954
946
|
ax4=ax4,
|
|
955
947
|
log=log,
|
|
956
948
|
verbose=verbose)
|
|
@@ -1132,11 +1124,14 @@ def mqqplot(insumstats,
|
|
|
1132
1124
|
|
|
1133
1125
|
##############################################################################################################################################################################
|
|
1134
1126
|
|
|
1135
|
-
def _configure_fig_save_kwargs(
|
|
1127
|
+
def _configure_fig_save_kwargs(mode="m",
|
|
1128
|
+
save=None,
|
|
1136
1129
|
fig_args=None,
|
|
1137
1130
|
scatter_args=None,
|
|
1138
1131
|
qq_scatter_args=None,
|
|
1139
|
-
save_args=None
|
|
1132
|
+
save_args=None,
|
|
1133
|
+
log=Log(),
|
|
1134
|
+
verbose=True):
|
|
1140
1135
|
if fig_args is None:
|
|
1141
1136
|
fig_args = dict()
|
|
1142
1137
|
if scatter_args is None:
|
|
@@ -1152,8 +1147,15 @@ def _configure_fig_save_kwargs(save=None,
|
|
|
1152
1147
|
if save[-3:]=="pdf" or save[-3:]=="svg":
|
|
1153
1148
|
# to save as vectorized plot
|
|
1154
1149
|
fig_args["dpi"]=72
|
|
1155
|
-
|
|
1156
|
-
|
|
1150
|
+
|
|
1151
|
+
if mode!="r":
|
|
1152
|
+
scatter_args["rasterized"]=True
|
|
1153
|
+
qq_scatter_args["rasterized"]=True
|
|
1154
|
+
qq_scatter_args["antialiased"]=False,
|
|
1155
|
+
log.write("Saving as pdf/svg: scatter plot will be rasterized for mqq...", verbose=verbose)
|
|
1156
|
+
else:
|
|
1157
|
+
scatter_args["rasterized"]=False
|
|
1158
|
+
qq_scatter_args["rasterized"]=False
|
|
1157
1159
|
else:
|
|
1158
1160
|
fig_args["dpi"] = save_args["dpi"]
|
|
1159
1161
|
return fig_args, scatter_args, qq_scatter_args, save_args
|
|
@@ -1414,45 +1416,52 @@ def _process_line(ax1, sig_line, suggestive_sig_line, additional_line, lines_to_
|
|
|
1414
1416
|
|
|
1415
1417
|
def _process_cbar(cbar, cbar_fontsize, cbar_font_family, cbar_title, log=Log(),verbose=True):
|
|
1416
1418
|
log.write(" -Processing color bar...",verbose=verbose)
|
|
1417
|
-
|
|
1418
|
-
# for cbar_single in cbar:
|
|
1419
|
-
# cbar_yticklabels = cbar_single.ax.get_yticklabels()
|
|
1420
|
-
# cbar_single.ax.set_yticklabels(cbar_yticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
|
|
1421
|
-
# cbar_single.ax.set_title(cbar_title, fontsize=cbar_fontsize, family=cbar_font_family, loc="center",y=-0.2 )
|
|
1422
|
-
#else:
|
|
1423
|
-
|
|
1419
|
+
|
|
1424
1420
|
cbar_yticklabels = cbar.get_yticklabels()
|
|
1425
|
-
cbar.set_yticklabels(cbar_yticklabels,
|
|
1421
|
+
cbar.set_yticklabels(cbar_yticklabels,
|
|
1422
|
+
fontsize=cbar_fontsize,
|
|
1423
|
+
family=cbar_font_family )
|
|
1426
1424
|
cbar_xticklabels = cbar.get_xticklabels()
|
|
1427
|
-
cbar.set_xticklabels(cbar_xticklabels,
|
|
1425
|
+
cbar.set_xticklabels(cbar_xticklabels,
|
|
1426
|
+
fontsize=cbar_fontsize,
|
|
1427
|
+
family=cbar_font_family )
|
|
1428
1428
|
|
|
1429
|
-
cbar.set_title(cbar_title, fontsize=cbar_fontsize,
|
|
1429
|
+
cbar.set_title(cbar_title, fontsize=cbar_fontsize,
|
|
1430
|
+
family=cbar_font_family,
|
|
1431
|
+
loc="center", y=1.00 )
|
|
1430
1432
|
return cbar
|
|
1431
1433
|
|
|
1432
|
-
def _process_xtick(ax1, chrom_df, xtick_chr_dict, fontsize, font_family, log=Log(),verbose=True):
|
|
1434
|
+
def _process_xtick(ax1, mode, chrom_df, xtick_chr_dict, fontsize, font_family="Arial", ax3=None , log=Log(),verbose=True):
|
|
1435
|
+
|
|
1433
1436
|
log.write(" -Processing X ticks...",verbose=verbose)
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
+
|
|
1438
|
+
if mode!="r":
|
|
1439
|
+
ax1.set_xticks(chrom_df.astype("float64"))
|
|
1440
|
+
ax1.set_xticklabels(chrom_df.index.astype("Int64").map(xtick_chr_dict),
|
|
1441
|
+
fontsize=fontsize,
|
|
1442
|
+
family=font_family)
|
|
1443
|
+
|
|
1444
|
+
if ax3 is not None:
|
|
1445
|
+
ax3.tick_params(axis='x',
|
|
1446
|
+
labelsize=fontsize,
|
|
1447
|
+
labelfontfamily=font_family)
|
|
1448
|
+
|
|
1449
|
+
return ax1, ax3
|
|
1437
1450
|
|
|
1438
1451
|
def _process_ytick(ax1, fontsize, font_family, ax4, log=Log(),verbose=True):
|
|
1439
1452
|
log.write(" -Processing Y labels...",verbose=verbose)
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
#ax1.set_yticklabels(ax1_yticklabels,fontsize=fontsize,family=font_family)
|
|
1446
|
-
ax1.tick_params(axis='y', labelsize=fontsize,labelfontfamily=font_family)
|
|
1447
|
-
#ax1.set_yticks(ax1_yticks,ax1_yticklabels,fontsize=fontsize,family=font_family)
|
|
1453
|
+
|
|
1454
|
+
ax1.tick_params(axis='y',
|
|
1455
|
+
labelsize=fontsize,
|
|
1456
|
+
labelfontfamily=font_family)
|
|
1457
|
+
|
|
1448
1458
|
if ax4 is not None:
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
#ax4.set_yticks(ax4_yticks,ax4_yticklabels, fontsize=fontsize,family=font_family)
|
|
1459
|
+
ax4.tick_params(axis='y',
|
|
1460
|
+
labelsize=fontsize,
|
|
1461
|
+
labelfontfamily=font_family)
|
|
1453
1462
|
return ax1, ax4
|
|
1454
1463
|
|
|
1455
|
-
def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family, ax3=None , log=Log(),verbose=True):
|
|
1464
|
+
def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family="Arial", ax3=None , log=Log(),verbose=True):
|
|
1456
1465
|
log.write(" -Processing X labels...",verbose=verbose)
|
|
1457
1466
|
if region is not None:
|
|
1458
1467
|
if xlabel is None:
|
|
@@ -1467,19 +1476,29 @@ def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family,
|
|
|
1467
1476
|
ax1.set_xlabel(xlabel,fontsize=fontsize,family=font_family)
|
|
1468
1477
|
return ax1, ax3
|
|
1469
1478
|
|
|
1470
|
-
def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family, ax4=None, log=Log(),verbose=True):
|
|
1479
|
+
def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family, math_fontfamily, ax4=None, log=Log(),verbose=True):
|
|
1471
1480
|
log.write(" -Processing Y labels...",verbose=verbose)
|
|
1472
1481
|
if "b" in mode:
|
|
1473
1482
|
if ylabel is None:
|
|
1474
1483
|
ylabel ="Density of GWAS \n SNPs within "+str(bwindowsizekb)+" kb"
|
|
1475
|
-
ax1.set_ylabel(ylabel,ha="center",va="bottom",
|
|
1484
|
+
ax1.set_ylabel(ylabel,ha="center",va="bottom",
|
|
1485
|
+
fontsize=fontsize,
|
|
1486
|
+
family=font_family,
|
|
1487
|
+
math_fontfamily=math_fontfamily)
|
|
1476
1488
|
else:
|
|
1477
1489
|
if ylabel is None:
|
|
1478
|
-
ylabel ="
|
|
1479
|
-
ax1.set_ylabel(ylabel,
|
|
1490
|
+
ylabel ="$\mathregular{-log_{10}(P)}$"
|
|
1491
|
+
ax1.set_ylabel(ylabel,
|
|
1492
|
+
fontsize=fontsize,
|
|
1493
|
+
family=font_family,
|
|
1494
|
+
math_fontfamily=math_fontfamily)
|
|
1495
|
+
|
|
1480
1496
|
if ax4 is not None:
|
|
1481
1497
|
ax4_ylabel = ax4.get_ylabel()
|
|
1482
|
-
ax4.set_ylabel(ax4_ylabel,
|
|
1498
|
+
ax4.set_ylabel(ax4_ylabel,
|
|
1499
|
+
fontsize=fontsize,
|
|
1500
|
+
family=font_family,
|
|
1501
|
+
math_fontfamily=math_fontfamily )
|
|
1483
1502
|
return ax1, ax4
|
|
1484
1503
|
|
|
1485
1504
|
def _process_spine(ax1, mode):
|
|
@@ -1494,6 +1513,11 @@ def _process_spine(ax1, mode):
|
|
|
1494
1513
|
|
|
1495
1514
|
|
|
1496
1515
|
def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
|
|
1516
|
+
#ax1 m / r
|
|
1517
|
+
#ax2 qq
|
|
1518
|
+
#ax3 gene track
|
|
1519
|
+
#ax4 recombination
|
|
1520
|
+
|
|
1497
1521
|
if mode=="qqm":
|
|
1498
1522
|
fig, (ax2, ax1) = plt.subplots(1, 2,gridspec_kw={'width_ratios': [1, mqqratio]},**fig_args)
|
|
1499
1523
|
ax3 = None
|
gwaslab/viz_plot_qqplot.py
CHANGED
|
@@ -94,15 +94,15 @@ def _plot_qq(
|
|
|
94
94
|
|
|
95
95
|
expected = -np.log10(np.linspace(minit,upper_bound_p,max(len(databin_raw),len(databin))))[:len(observed)]
|
|
96
96
|
|
|
97
|
-
label ="("+str(lower)+","+str(upper) +"]"
|
|
97
|
+
label ="( "+str(lower)+","+str(upper) +" ]"
|
|
98
98
|
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=
|
|
99
|
+
ax2_legend= ax2.legend(loc="best",fontsize=fontsize,markerscale=1.5,frameon=False, handletextpad=0.4, borderaxespad=0.4)
|
|
100
100
|
plt.setp(ax2_legend.texts, family=font_family)
|
|
101
101
|
|
|
102
102
|
qq_x = max(skip, expected_min_mlog10p)
|
|
103
103
|
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
|
|
104
|
+
ax2.set_xlabel("Expected $\mathregular{-log_{10}(P)}$",fontsize=fontsize,family=font_family)
|
|
105
|
+
ax2.set_ylabel("Observed $\mathregular{-log_{10}(P)}$",fontsize=fontsize,family=font_family)
|
|
106
106
|
ax2.spines["top"].set_visible(False)
|
|
107
107
|
ax2.spines["right"].set_visible(False)
|
|
108
108
|
ax2.spines["left"].set_visible(True)
|
|
@@ -127,7 +127,7 @@ def _plot_qq(
|
|
|
127
127
|
verbose=verbose)
|
|
128
128
|
|
|
129
129
|
# annotate lambda gc to qq plot
|
|
130
|
-
ax2.text(0.10, 1.03,"
|
|
130
|
+
ax2.text(0.10, 1.03,"$\mathregular{\\lambda_{GC}}$ = "+"{:.4f}".format(lambdagc),
|
|
131
131
|
horizontalalignment='left',
|
|
132
132
|
verticalalignment='top',
|
|
133
133
|
transform=ax2.transAxes,
|
|
@@ -179,7 +179,7 @@ def _plot_qq(
|
|
|
179
179
|
# ax2.set_yticklabels([x for x in range(skip,cut-step,step)]+[cut],fontsize=fontsize,family=font_family)
|
|
180
180
|
# ax2.set_ylim(bottom = skip)
|
|
181
181
|
|
|
182
|
-
ax2.tick_params(axis='both', which='both', labelsize=fontsize)
|
|
182
|
+
ax2.tick_params(axis='both', which='both', labelsize=fontsize,labelfontfamily=font_family)
|
|
183
183
|
#
|
|
184
184
|
if qtitle:
|
|
185
185
|
ax2.set_title(qtitle,fontsize=title_fontsize,pad=10,family=font_family)
|
gwaslab/viz_plot_regional2.py
CHANGED
|
@@ -35,13 +35,10 @@ def _plot_regional(
|
|
|
35
35
|
ax3,
|
|
36
36
|
region,
|
|
37
37
|
vcf_path,
|
|
38
|
+
ld_path,
|
|
38
39
|
marker_size,
|
|
39
|
-
fontsize,
|
|
40
40
|
build,
|
|
41
|
-
chrom_df,
|
|
42
|
-
xtick_chr_dict,
|
|
43
41
|
cut_line_color,
|
|
44
|
-
vcf_chr_dict = None,
|
|
45
42
|
gtf_path="default",
|
|
46
43
|
gtf_chr_dict = get_number_to_chr(),
|
|
47
44
|
gtf_gene_name=None,
|
|
@@ -50,7 +47,6 @@ def _plot_regional(
|
|
|
50
47
|
rr_chr_dict = get_number_to_chr(),
|
|
51
48
|
rr_lim = (0,100),
|
|
52
49
|
rr_ylabel = True,
|
|
53
|
-
rr_title=None,
|
|
54
50
|
region_ld_legend=True,
|
|
55
51
|
region_title=None,
|
|
56
52
|
mode="mqq",
|
|
@@ -64,9 +60,7 @@ def _plot_regional(
|
|
|
64
60
|
region_lead_grid = True,
|
|
65
61
|
region_lead_grid_line = {"alpha":0.5,"linewidth" : 2,"linestyle":"--","color":"#FF0000"},
|
|
66
62
|
region_title_args = None,
|
|
67
|
-
region_hspace=0.02,
|
|
68
63
|
region_ld_threshold = [0.2,0.4,0.6,0.8],
|
|
69
|
-
region_ld_colors = ["#E4E4E4","#020080","#86CEF9","#24FF02","#FDA400","#FF0000","#FF0000"],
|
|
70
64
|
region_marker_shapes=None,
|
|
71
65
|
cbar_fontsize=None,
|
|
72
66
|
cbar_scale=False,
|
|
@@ -84,8 +78,6 @@ def _plot_regional(
|
|
|
84
78
|
track_font_family="Arial",
|
|
85
79
|
taf=[4,0,0.95,1,1],
|
|
86
80
|
# track_n, track_n_offset,font_ratio,exon_ratio,text_offset
|
|
87
|
-
tabix=None,
|
|
88
|
-
chrom="CHR",
|
|
89
81
|
pos="POS",
|
|
90
82
|
verbose=True,
|
|
91
83
|
log=Log()
|
|
@@ -134,7 +126,7 @@ def _plot_regional(
|
|
|
134
126
|
|
|
135
127
|
##########################################################################################################
|
|
136
128
|
|
|
137
|
-
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:
|
|
138
130
|
## plot cbar
|
|
139
131
|
ax1, cbar = _add_ld_legend(sumstats=sumstats,
|
|
140
132
|
ax1=ax1,
|
|
@@ -225,7 +217,7 @@ def _plot_regional(
|
|
|
225
217
|
if "r" in mode:
|
|
226
218
|
if gtf_path is not None:
|
|
227
219
|
ax3.set_xticks(np.linspace(gene_track_start_i+region[1], gene_track_start_i+region[2], num=region_step))
|
|
228
|
-
ax3.set_xticklabels(region_ticks,rotation=45
|
|
220
|
+
ax3.set_xticklabels(region_ticks,rotation=45)
|
|
229
221
|
|
|
230
222
|
if region_grid==True:
|
|
231
223
|
for i in np.linspace(gene_track_start_i+region[1], gene_track_start_i+region[2], num=region_step):
|
|
@@ -241,7 +233,7 @@ def _plot_regional(
|
|
|
241
233
|
else:
|
|
242
234
|
# set x ticks m plot
|
|
243
235
|
ax1.set_xticks(np.linspace(gene_track_start_i+region[1], gene_track_start_i+region[2], num=region_step))
|
|
244
|
-
ax1.set_xticklabels(region_ticks,rotation=45
|
|
236
|
+
ax1.set_xticklabels(region_ticks,rotation=45)
|
|
245
237
|
|
|
246
238
|
ax1.set_xlim([gene_track_start_i+region[1], gene_track_start_i+region[2]])
|
|
247
239
|
|
|
@@ -498,7 +490,7 @@ def _add_ld_legend(sumstats, ax1, region_ld_threshold, region_ref,region_ref_ind
|
|
|
498
490
|
return ax1, cbar
|
|
499
491
|
|
|
500
492
|
# -############################################################################################################################################################################
|
|
501
|
-
def _plot_recombination_rate(sumstats,pos, region, ax1, rr_path, rr_chr_dict, rr_header_dict, build,rr_lim,rr_ylabel=True):
|
|
493
|
+
def _plot_recombination_rate(sumstats,pos, region, ax1, rr_path, rr_chr_dict, rr_header_dict, build,rr_lim, rr_ylabel=True):
|
|
502
494
|
ax4 = ax1.twinx()
|
|
503
495
|
most_left_snp = sumstats["i"].idxmin()
|
|
504
496
|
|
gwaslab/viz_plot_rg_heatmap.py
CHANGED
|
@@ -37,7 +37,7 @@ def plot_rg(ldscrg,
|
|
|
37
37
|
corrections=None,
|
|
38
38
|
panno_texts=None,
|
|
39
39
|
equal_aspect=True,
|
|
40
|
-
cmap =
|
|
40
|
+
cmap = None,
|
|
41
41
|
full_cell =None,
|
|
42
42
|
log=Log(),
|
|
43
43
|
panno_args=None,
|
|
@@ -57,6 +57,11 @@ def plot_rg(ldscrg,
|
|
|
57
57
|
|
|
58
58
|
log.write("Start to create ldsc genetic correlation heatmap..." ,verbose=verbose)
|
|
59
59
|
# configure arguments
|
|
60
|
+
if cmap is None:
|
|
61
|
+
try: #matplotlib <3.9
|
|
62
|
+
cmap = matplotlib.cm.get_cmap('RdBu')
|
|
63
|
+
except:
|
|
64
|
+
cmap = matplotlib.colormaps.get_cmap('RdBu')
|
|
60
65
|
if fig_args is None:
|
|
61
66
|
fig_args = {"dpi":300}
|
|
62
67
|
if colorbar_args is None:
|