gwaslab 3.5.2__tar.gz → 3.5.3__tar.gz
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-3.5.2/src/gwaslab.egg-info → gwaslab-3.5.3}/PKG-INFO +1 -1
- {gwaslab-3.5.2 → gwaslab-3.5.3}/pyproject.toml +1 -1
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_version.py +2 -2
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_process_args.py +13 -1
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_to_formats.py +90 -23
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_annotate_plot.py +3 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_chromatin.py +1 -1
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_mqqplot.py +23 -12
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_regional2.py +50 -29
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_stackedregional.py +20 -3
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_trumpetplot.py +4 -4
- {gwaslab-3.5.2 → gwaslab-3.5.3/src/gwaslab.egg-info}/PKG-INFO +1 -1
- {gwaslab-3.5.2 → gwaslab-3.5.3}/LICENSE +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/LICENSE_before_v3.4.39 +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/README.md +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/setup.cfg +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/__init__.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/bd_common_data.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/bd_config.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/bd_download.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/bd_get_hapmap3.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/cache_manager.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/chrx_par/chrx_par_hg19.bed.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/chrx_par/chrx_par_hg38.bed.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/formatbook.json +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/high_ld/high_ld_hla_hg19.bed.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/high_ld/high_ld_hla_hg38.bed.gz +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/data/reference.json +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_Log.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_Phenotypes.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_Sumstats.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_SumstatsPair.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_SumstatsT.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_Sumstats_summary.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_meta.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/g_vchange_status.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/hm_casting.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/hm_harmonize_sumstats.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/hm_rsid_to_chrpos.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_preformat_input.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_read_ldsc.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_read_tabular.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/io_to_pickle.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_irwls.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_jackknife.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_ldscore.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_parse.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_regressions.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/ldsc_sumstats.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/qc_check_datatype.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/qc_fix_sumstats.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/run_script.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_abf_finemapping.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_calculate_ldmatrix.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_calculate_prs.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_gwascatalog.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_ldproxyfinder.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_ldsc.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_plink_filter.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_process_h5.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_process_ref.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_run_2samplemr.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_run_clumping.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_run_coloc.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_ex_run_susie.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_calculate_gc.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_calculate_power.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_convert_h2.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_correct_winnerscurse.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_fill_data.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_filter_value.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_get_density.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_get_sig.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_meta.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/util_in_snphwe.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/vis_plot_credible sets.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_property.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_quickfix.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_reposition_text.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_aux_save_figure.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_compare_af.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_compare_effect.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_forestplot.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_miamiplot.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_miamiplot2.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_phe_heatmap.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_qqplot.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_regionalplot.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_rg_heatmap.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab/viz_plot_scatter_with_reg.py +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab.egg-info/SOURCES.txt +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab.egg-info/dependency_links.txt +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab.egg-info/requires.txt +0 -0
- {gwaslab-3.5.2 → gwaslab-3.5.3}/src/gwaslab.egg-info/top_level.txt +0 -0
|
@@ -9,14 +9,26 @@ def _extract_kwargs(prefix:str, default:dict, kwargs:dict) -> dict:
|
|
|
9
9
|
# kwargs: all local kwargs + args + kwargs
|
|
10
10
|
|
|
11
11
|
extracted = []
|
|
12
|
+
extracted_single=dict()
|
|
12
13
|
for key,value in kwargs.items():
|
|
14
|
+
# kwargs or args
|
|
13
15
|
if key=="kwargs" or key=="args":
|
|
14
16
|
for key_nested,value_nested in kwargs[key].items():
|
|
15
17
|
if prefix in key_nested and "arg" in key_nested:
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
if len(key_nested.split("_"))<3:
|
|
20
|
+
extracted.append(value_nested)
|
|
21
|
+
##
|
|
22
|
+
## prefix_arg_fontsize
|
|
23
|
+
else:
|
|
24
|
+
print(key_nested.split("_")[-1], value)
|
|
25
|
+
extracted_single[key_nested.split("_")[-1]] = value_nested
|
|
17
26
|
else:
|
|
27
|
+
# local kwargs
|
|
18
28
|
if prefix in key and "arg" in key:
|
|
19
29
|
extracted.append(value)
|
|
30
|
+
if len(extracted_single.keys()) >0:
|
|
31
|
+
extracted.append(extracted_single)
|
|
20
32
|
merged_arg = _merge_and_sync_dic(extracted, default)
|
|
21
33
|
return merged_arg
|
|
22
34
|
|
|
@@ -28,6 +28,7 @@ from gwaslab.util_in_filter_value import _extract
|
|
|
28
28
|
def _to_format(sumstats,
|
|
29
29
|
path="./sumstats",
|
|
30
30
|
fmt="gwaslab",
|
|
31
|
+
tab_fmt="tsv",
|
|
31
32
|
extract=None,
|
|
32
33
|
exclude=None,
|
|
33
34
|
cols=None,
|
|
@@ -39,7 +40,6 @@ def _to_format(sumstats,
|
|
|
39
40
|
n=None,
|
|
40
41
|
no_status=False,
|
|
41
42
|
output_log=True,
|
|
42
|
-
to_csvargs=None,
|
|
43
43
|
float_formats=None,
|
|
44
44
|
xymt_number=False,
|
|
45
45
|
xymt=None,
|
|
@@ -47,20 +47,30 @@ def _to_format(sumstats,
|
|
|
47
47
|
meta=None,
|
|
48
48
|
ssfmeta=False,
|
|
49
49
|
md5sum=False,
|
|
50
|
+
gzip=True,
|
|
50
51
|
bgzip=False,
|
|
51
52
|
tabix=False,
|
|
52
53
|
tabix_indexargs={},
|
|
54
|
+
to_csvargs=None,
|
|
55
|
+
to_tabular_kwargs=None,
|
|
53
56
|
log=Log(),
|
|
54
57
|
verbose=True):
|
|
55
58
|
|
|
56
|
-
if
|
|
57
|
-
to_csvargs
|
|
59
|
+
if to_csvargs is None:
|
|
60
|
+
to_csvargs=dict()
|
|
61
|
+
if tabix_indexargs is None:
|
|
62
|
+
tabix_indexargs=dict()
|
|
63
|
+
if to_tabular_kwargs is None:
|
|
64
|
+
to_tabular_kwargs=dict()
|
|
58
65
|
if float_formats is None:
|
|
59
|
-
float_formats=
|
|
66
|
+
float_formats=dict()
|
|
60
67
|
if cols is None:
|
|
61
68
|
cols=[]
|
|
62
69
|
if xymt is None:
|
|
63
70
|
xymt = ["X","Y","MT"]
|
|
71
|
+
non_gzip_tab_fmt = ["parquet"]
|
|
72
|
+
non_md5sum_tab_fmt = ["parquet"]
|
|
73
|
+
|
|
64
74
|
onetime_log = copy.deepcopy(log)
|
|
65
75
|
|
|
66
76
|
#######################################################################################################
|
|
@@ -154,6 +164,7 @@ def _to_format(sumstats,
|
|
|
154
164
|
tofmt(output,
|
|
155
165
|
path=path,
|
|
156
166
|
fmt=fmt,
|
|
167
|
+
tab_fmt=tab_fmt,
|
|
157
168
|
cols=cols,
|
|
158
169
|
suffix=suffix,
|
|
159
170
|
build=build,
|
|
@@ -164,9 +175,13 @@ def _to_format(sumstats,
|
|
|
164
175
|
chr_prefix=chr_prefix,
|
|
165
176
|
meta=meta,
|
|
166
177
|
ssfmeta=ssfmeta,
|
|
178
|
+
gzip=gzip,
|
|
167
179
|
bgzip=bgzip,
|
|
180
|
+
non_gzip_tab_fmt=non_gzip_tab_fmt,
|
|
181
|
+
non_md5sum_tab_fmt=non_md5sum_tab_fmt,
|
|
168
182
|
tabix=tabix,
|
|
169
183
|
tabix_indexargs=tabix_indexargs,
|
|
184
|
+
to_tabular_kwargs=to_tabular_kwargs,
|
|
170
185
|
md5sum=md5sum,
|
|
171
186
|
xymt_number=xymt_number,
|
|
172
187
|
xymt=xymt)
|
|
@@ -186,6 +201,7 @@ def tofmt(sumstats,
|
|
|
186
201
|
path=None,
|
|
187
202
|
suffix=None,
|
|
188
203
|
fmt=None,
|
|
204
|
+
tab_fmt="csv",
|
|
189
205
|
cols=[],
|
|
190
206
|
xymt_number=False,
|
|
191
207
|
xymt=["X","Y","MT"],
|
|
@@ -194,15 +210,16 @@ def tofmt(sumstats,
|
|
|
194
210
|
ssfmeta=False,
|
|
195
211
|
md5sum=False,
|
|
196
212
|
bgzip=False,
|
|
213
|
+
gzip=True,
|
|
214
|
+
non_gzip_tab_fmt=None,
|
|
215
|
+
non_md5sum_tab_fmt=None,
|
|
197
216
|
tabix=False,
|
|
198
|
-
tabix_indexargs=
|
|
217
|
+
tabix_indexargs=None,
|
|
199
218
|
verbose=True,
|
|
200
219
|
no_status=False,
|
|
201
220
|
log=Log(),
|
|
202
|
-
to_csvargs=None
|
|
203
|
-
|
|
204
|
-
if to_csvargs is None:
|
|
205
|
-
to_csvargs=dict()
|
|
221
|
+
to_csvargs=None,
|
|
222
|
+
to_tabular_kwargs=None):
|
|
206
223
|
|
|
207
224
|
if fmt in ["ssf"]:
|
|
208
225
|
xymt_number=True
|
|
@@ -336,36 +353,86 @@ def tofmt(sumstats,
|
|
|
336
353
|
_bgzip_tabix_md5sum(path, fmt, bgzip, md5sum, tabix, tabix_indexargs, log, verbose)
|
|
337
354
|
|
|
338
355
|
####################################################################################################################
|
|
339
|
-
elif fmt in get_formats_list():
|
|
356
|
+
elif fmt in get_formats_list() :
|
|
340
357
|
# tabular
|
|
341
358
|
log.write(" -"+fmt+" format will be loaded...",verbose=verbose)
|
|
342
359
|
meta_data,rename_dictionary = get_format_dict(fmt,inverse=True)
|
|
343
360
|
print_format_info(fmt=fmt, meta_data=meta_data,rename_dictionary=rename_dictionary,verbose=verbose, log=log, output=True)
|
|
344
361
|
|
|
345
|
-
|
|
346
|
-
|
|
362
|
+
# determine if gzip or not / create path for output
|
|
363
|
+
if gzip ==True and tab_fmt not in non_gzip_tab_fmt:
|
|
364
|
+
path = path + "."+suffix+".{}.gz".format(tab_fmt)
|
|
365
|
+
else:
|
|
366
|
+
path = path + "."+suffix+".{}".format(tab_fmt)
|
|
367
|
+
|
|
368
|
+
yaml_path = path + "."+suffix+".{}-meta.yaml".format(tab_fmt)
|
|
347
369
|
log.write(" -Output path:",path, verbose=verbose)
|
|
348
|
-
|
|
370
|
+
|
|
349
371
|
sumstats,to_csvargs = _configure_output_cols_and_args(sumstats, rename_dictionary, cols, no_status, path, meta_data, to_csvargs, log, verbose)
|
|
350
372
|
|
|
351
373
|
log.write(" -Writing sumstats to: {}...".format(path),verbose=verbose)
|
|
352
|
-
try:
|
|
353
|
-
fast_to_csv(sumstats, path, to_csvargs=to_csvargs, compress=True, write_in_chunks=True)
|
|
354
|
-
except:
|
|
355
|
-
log.write(f"Error in using fast_to_csv. Falling back to original implementation.",verbose=verbose)
|
|
356
|
-
sumstats.to_csv(path, index=None, **to_csvargs)
|
|
357
|
-
|
|
358
|
-
if md5sum == True:
|
|
359
|
-
md5_value = md5sum_file(path,log,verbose)
|
|
360
|
-
else:
|
|
361
|
-
md5_value = calculate_md5sum_file(path)
|
|
362
374
|
|
|
375
|
+
#if tab_fmt=="tsv" or tab_fmt=="csv":
|
|
376
|
+
# try:
|
|
377
|
+
# log.write(f" -Fast to csv mode...",verbose=verbose)
|
|
378
|
+
# fast_to_csv(sumstats, path, to_csvargs=to_csvargs, compress=True, write_in_chunks=True)
|
|
379
|
+
# except:
|
|
380
|
+
# log.write(f"Error in using fast_to_csv. Falling back to original implementation.",verbose=verbose)
|
|
381
|
+
# sumstats.to_csv(path, index=None, **to_csvargs)
|
|
382
|
+
#
|
|
383
|
+
#elif tab_fmt=="parquet":
|
|
384
|
+
# sumstats.to_parquet(path, index=None, **to_tabular_kwargs)
|
|
385
|
+
_write_tabular(sumstats,rename_dictionary, path, tab_fmt, to_csvargs, to_tabular_kwargs, log, verbose)
|
|
386
|
+
|
|
387
|
+
if tab_fmt not in non_md5sum_tab_fmt and "@" not in path:
|
|
388
|
+
if md5sum == True:
|
|
389
|
+
# write a md5sum file
|
|
390
|
+
md5_value = md5sum_file(path,log,verbose)
|
|
391
|
+
else:
|
|
392
|
+
# calculate md5sum without saveing a file
|
|
393
|
+
md5_value = calculate_md5sum_file(path)
|
|
394
|
+
else:
|
|
395
|
+
md5_value = "NA"
|
|
396
|
+
|
|
363
397
|
## update ssf-style meta data and export to yaml file
|
|
364
398
|
_configure_ssf_meta(sumstats, fmt, ssfmeta, meta, meta_data, path, md5_value, yaml_path, log, verbose)
|
|
365
399
|
|
|
366
400
|
return sumstats
|
|
367
401
|
|
|
368
402
|
####################################################################################################################
|
|
403
|
+
def _write_tabular(sumstats,rename_dictionary, path, tab_fmt, to_csvargs, to_tabular_kwargs, log, verbose):
|
|
404
|
+
chr_header = rename_dictionary["CHR"]
|
|
405
|
+
if tab_fmt=="tsv" or tab_fmt=="csv":
|
|
406
|
+
try:
|
|
407
|
+
log.write(f" -Fast to csv mode...",verbose=verbose)
|
|
408
|
+
if "@" in path:
|
|
409
|
+
log.write(f" -@ detected: writing each chromosome to a single file...",verbose=verbose)
|
|
410
|
+
log.write(" -Chromosomes:{}...".format(list(sumstats["CHR"].unique())),verbose=verbose)
|
|
411
|
+
for single_chr in list(sumstats["CHR"].unique()):
|
|
412
|
+
single_path = path.replace("@",single_chr)
|
|
413
|
+
|
|
414
|
+
fast_to_csv(sumstats.loc[sumstats[chr_header]==single_chr,:],
|
|
415
|
+
single_path,
|
|
416
|
+
to_csvargs=to_csvargs, compress=True, write_in_chunks=True)
|
|
417
|
+
else:
|
|
418
|
+
fast_to_csv(sumstats, path, to_csvargs=to_csvargs, compress=True, write_in_chunks=True)
|
|
419
|
+
except:
|
|
420
|
+
log.write(f"Error in using fast_to_csv. Falling back to original implementation.",verbose=verbose)
|
|
421
|
+
if "@" in path:
|
|
422
|
+
log.write(f" -@ detected: writing each chromosome to a single file...",verbose=verbose)
|
|
423
|
+
log.write(" -Chromosomes:{}...".format(list(sumstats["CHR"].unique())),verbose=verbose)
|
|
424
|
+
for single_chr in list(sumstats["CHR"].unique()):
|
|
425
|
+
single_path = path.replace("@",single_chr)
|
|
426
|
+
|
|
427
|
+
sumstats.loc[sumstats[chr_header]==single_chr,:].to_csv(path, index=None, **to_csvargs)
|
|
428
|
+
else:
|
|
429
|
+
sumstats.to_csv(path, index=None, **to_csvargs)
|
|
430
|
+
|
|
431
|
+
elif tab_fmt=="parquet":
|
|
432
|
+
sumstats.to_parquet(path, index=None, **to_tabular_kwargs)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
369
436
|
def fast_to_csv(dataframe, path, to_csvargs=None, compress=True, write_in_chunks=True):
|
|
370
437
|
df_numpy = dataframe.to_numpy()
|
|
371
438
|
|
|
@@ -31,6 +31,7 @@ def annotate_single(
|
|
|
31
31
|
arm_scale_d,
|
|
32
32
|
arm_offset,
|
|
33
33
|
anno_adjust,
|
|
34
|
+
anno_xshift,
|
|
34
35
|
anno_fixed_arm_length,
|
|
35
36
|
maxy,
|
|
36
37
|
anno_fontsize,
|
|
@@ -158,6 +159,8 @@ def annotate_single(
|
|
|
158
159
|
if anno_fixed_arm_length is not None:
|
|
159
160
|
xytext=(row["i"],row["scaled_P"] + 0.2 + anno_fixed_arm_length)
|
|
160
161
|
|
|
162
|
+
if anno_xshift is not None:
|
|
163
|
+
xytext = (xytext[0] +(anno_xshift*y_span), xytext[1])
|
|
161
164
|
################################################################################################################################
|
|
162
165
|
# if not changing the directions of some annotation arror arms
|
|
163
166
|
if anno_count not in anno_d.keys():
|
|
@@ -99,7 +99,7 @@ def _plot_chromatin_state(region_chromatin_files,
|
|
|
99
99
|
color=color_dict_i[row["STATE_i"]]
|
|
100
100
|
ax.plot([offset_i + row["START"] ,offset_i + row["END"]],
|
|
101
101
|
[i*0.1,i*0.1],
|
|
102
|
-
c=color/255,linewidth=points_for_01,solid_capstyle="butt")
|
|
102
|
+
c=color/255,linewidth=points_for_01,solid_capstyle="butt",rasterized=True)
|
|
103
103
|
|
|
104
104
|
## add stripe label
|
|
105
105
|
if len(region_chromatin_labels) == len(region_chromatin_files):
|
|
@@ -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.viz_plot_regional2 import _get_lead_id
|
|
28
29
|
from gwaslab.viz_aux_quickfix import _get_largenumber
|
|
29
30
|
from gwaslab.viz_aux_quickfix import _quick_fix_p_value
|
|
30
31
|
from gwaslab.viz_aux_quickfix import _quick_fix_pos
|
|
@@ -107,6 +108,7 @@ def mqqplot(insumstats,
|
|
|
107
108
|
region_flank_factor = 0.05,
|
|
108
109
|
region_anno_bbox_args = None,
|
|
109
110
|
region_marker_shapes=None,
|
|
111
|
+
region_legend_marker=True,
|
|
110
112
|
cbar_title='LD $r^{2}$ with variant',
|
|
111
113
|
cbar_fontsize = None,
|
|
112
114
|
cbar_font_family = None,
|
|
@@ -138,6 +140,7 @@ def mqqplot(insumstats,
|
|
|
138
140
|
anno_source = "ensembl",
|
|
139
141
|
anno_gtf_path=None,
|
|
140
142
|
anno_adjust=False,
|
|
143
|
+
anno_xshift=None,
|
|
141
144
|
anno_max_iter=100,
|
|
142
145
|
arrow_kwargs=None,
|
|
143
146
|
arm_offset=None,
|
|
@@ -233,7 +236,7 @@ def mqqplot(insumstats,
|
|
|
233
236
|
if "dpi" not in fig_args.keys():
|
|
234
237
|
fig_args["dpi"] = dpi
|
|
235
238
|
if region_anno_bbox_args is None:
|
|
236
|
-
region_anno_bbox_args =
|
|
239
|
+
region_anno_bbox_args = {"ec":"None","fc":"None"}
|
|
237
240
|
if anno_set is None:
|
|
238
241
|
anno_set=list()
|
|
239
242
|
if anno_alias is None:
|
|
@@ -626,7 +629,8 @@ def mqqplot(insumstats,
|
|
|
626
629
|
sumstats["chr_hue"]=sumstats["LD"]
|
|
627
630
|
|
|
628
631
|
## default seetings
|
|
629
|
-
|
|
632
|
+
# assign to_plot for scatter plot
|
|
633
|
+
to_plot = None
|
|
630
634
|
palette = sns.color_palette(colors,n_colors=sumstats[chrom].nunique())
|
|
631
635
|
|
|
632
636
|
legend = None
|
|
@@ -639,14 +643,17 @@ def mqqplot(insumstats,
|
|
|
639
643
|
legend=None
|
|
640
644
|
linewidth=1
|
|
641
645
|
if len(region_ref) == 1:
|
|
646
|
+
# hide lead variants -> add back in region plot
|
|
642
647
|
palette = {100+i:region_ld_colors[i] for i in range(len(region_ld_colors))}
|
|
643
648
|
scatter_args["markers"]= {(i+1):m for i,m in enumerate(region_marker_shapes[:2])}
|
|
644
649
|
if region_ref[0] is None:
|
|
645
650
|
id_to_hide = sumstats["scaled_P"].idxmax()
|
|
646
|
-
sumstats.
|
|
651
|
+
to_plot = sumstats.drop(id_to_hide, axis=0)
|
|
647
652
|
else:
|
|
648
|
-
sumstats
|
|
649
|
-
|
|
653
|
+
#id_to_hide = sumstats[sumstats["SNPID"]==region_ref[0],"scaled_P"].idxmax()
|
|
654
|
+
id_to_hide = _get_lead_id(sumstats, region_ref, log=log, verbose=verbose)
|
|
655
|
+
if id_to_hide is not None:
|
|
656
|
+
to_plot = sumstats.drop(id_to_hide, axis=0)
|
|
650
657
|
style="SHAPE"
|
|
651
658
|
else:
|
|
652
659
|
palette = {}
|
|
@@ -671,12 +678,13 @@ def mqqplot(insumstats,
|
|
|
671
678
|
scatter_args["markers"]= {(i+1):m for i,m in enumerate(region_marker_shapes[:len(region_ref)])}
|
|
672
679
|
style="SHAPE"
|
|
673
680
|
|
|
674
|
-
|
|
681
|
+
|
|
675
682
|
## if highlight
|
|
676
683
|
highlight_i = pd.DataFrame()
|
|
677
684
|
if len(highlight) >0:
|
|
685
|
+
to_plot = sumstats
|
|
678
686
|
log.write(" -Creating background plot...",verbose=verbose)
|
|
679
|
-
plot = sns.scatterplot(data=
|
|
687
|
+
plot = sns.scatterplot(data=to_plot, x='i', y='scaled_P',
|
|
680
688
|
hue='chr_hue',
|
|
681
689
|
palette=palette,
|
|
682
690
|
legend=legend,
|
|
@@ -688,7 +696,7 @@ def mqqplot(insumstats,
|
|
|
688
696
|
if pd.api.types.is_list_like(highlight[0]) and highlight_chrpos==False:
|
|
689
697
|
for i, highlight_set in enumerate(highlight):
|
|
690
698
|
log.write(" -Highlighting set {} target loci...".format(i+1),verbose=verbose)
|
|
691
|
-
sns.scatterplot(data=
|
|
699
|
+
sns.scatterplot(data=to_plot.loc[to_plot["HUE"]==i], x='i', y='scaled_P',
|
|
692
700
|
hue="HUE",
|
|
693
701
|
palette={i:highlight_color[i%len(highlight_color)]},
|
|
694
702
|
legend=legend,
|
|
@@ -697,10 +705,10 @@ def mqqplot(insumstats,
|
|
|
697
705
|
sizes=(marker_size[0]+1,marker_size[1]+1),
|
|
698
706
|
linewidth=linewidth,
|
|
699
707
|
zorder=3+i,ax=ax1,edgecolor=edgecolor,**scatter_args)
|
|
700
|
-
highlight_i =
|
|
708
|
+
highlight_i = to_plot.loc[~to_plot["HUE"].isna(),"i"].values
|
|
701
709
|
else:
|
|
702
710
|
log.write(" -Highlighting target loci...",verbose=verbose)
|
|
703
|
-
sns.scatterplot(data=
|
|
711
|
+
sns.scatterplot(data=to_plot.loc[to_plot["HUE"]==0], x='i', y='scaled_P',
|
|
704
712
|
hue="HUE",
|
|
705
713
|
palette={0:highlight_color},
|
|
706
714
|
legend=legend,
|
|
@@ -711,7 +719,7 @@ def mqqplot(insumstats,
|
|
|
711
719
|
zorder=3,ax=ax1,edgecolor=edgecolor,**scatter_args)
|
|
712
720
|
# for annotate
|
|
713
721
|
if highlight_chrpos==False:
|
|
714
|
-
highlight_i =
|
|
722
|
+
highlight_i = to_plot.loc[to_plot[snpid].isin(highlight),"i"].values
|
|
715
723
|
else:
|
|
716
724
|
highlight_i = []
|
|
717
725
|
|
|
@@ -749,7 +757,8 @@ def mqqplot(insumstats,
|
|
|
749
757
|
s = "s"
|
|
750
758
|
hue = 'chr_hue'
|
|
751
759
|
hue_norm=None
|
|
752
|
-
to_plot
|
|
760
|
+
if to_plot is None:
|
|
761
|
+
to_plot = sumstats
|
|
753
762
|
log.write(" -Creating background plot...",verbose=verbose)
|
|
754
763
|
plot = sns.scatterplot(data=to_plot, x='i', y='scaled_P',
|
|
755
764
|
hue=hue,
|
|
@@ -824,6 +833,7 @@ def mqqplot(insumstats,
|
|
|
824
833
|
region_title=region_title,
|
|
825
834
|
region_title_args=region_title_args,
|
|
826
835
|
region_ld_legend = region_ld_legend,
|
|
836
|
+
region_legend_marker=region_legend_marker,
|
|
827
837
|
region_ld_threshold = region_ld_threshold,
|
|
828
838
|
region_ld_colors = region_ld_colors,
|
|
829
839
|
palette = palette,
|
|
@@ -1006,6 +1016,7 @@ def mqqplot(insumstats,
|
|
|
1006
1016
|
arm_scale_d=arm_scale_d,
|
|
1007
1017
|
arm_offset=arm_offset,
|
|
1008
1018
|
anno_adjust=anno_adjust,
|
|
1019
|
+
anno_xshift=anno_xshift,
|
|
1009
1020
|
anno_fixed_arm_length=anno_fixed_arm_length,
|
|
1010
1021
|
maxy=maxy,
|
|
1011
1022
|
anno_fontsize= anno_fontsize,
|
|
@@ -70,6 +70,7 @@ def _plot_regional(
|
|
|
70
70
|
palette=None,
|
|
71
71
|
region_recombination = True,
|
|
72
72
|
region_protein_coding=True,
|
|
73
|
+
region_legend_marker=True,
|
|
73
74
|
region_flank_factor = 0.05,
|
|
74
75
|
track_font_family="Arial",
|
|
75
76
|
taf=[4,0,0.95,1,1],
|
|
@@ -133,6 +134,7 @@ def _plot_regional(
|
|
|
133
134
|
region_ref_index_dic=region_ref_index_dic,
|
|
134
135
|
region_marker_shapes=region_marker_shapes,
|
|
135
136
|
palette=palette,
|
|
137
|
+
region_legend_marker=region_legend_marker,
|
|
136
138
|
fig=fig)
|
|
137
139
|
else:
|
|
138
140
|
cbar=None
|
|
@@ -244,6 +246,10 @@ def _plot_regional(
|
|
|
244
246
|
|
|
245
247
|
# + ###########################################################################################################################################################################
|
|
246
248
|
def _get_lead_id(sumstats=None, region_ref=None, log=None, verbose=True):
|
|
249
|
+
# region_ref_single (not none) -> specified variant ID
|
|
250
|
+
# convert region_ref_single -> lead_id(index)
|
|
251
|
+
|
|
252
|
+
#
|
|
247
253
|
region_ref_to_check = copy.copy(region_ref)
|
|
248
254
|
try:
|
|
249
255
|
if len(region_ref_to_check)>0 and type(region_ref_to_check) is not str:
|
|
@@ -253,24 +259,30 @@ def _get_lead_id(sumstats=None, region_ref=None, log=None, verbose=True):
|
|
|
253
259
|
|
|
254
260
|
lead_id=None
|
|
255
261
|
|
|
262
|
+
# match by rsID
|
|
256
263
|
if "rsID" in sumstats.columns:
|
|
257
264
|
lead_id = sumstats.index[sumstats["rsID"] == region_ref_to_check].to_list()
|
|
258
|
-
|
|
265
|
+
# match by SNPID
|
|
259
266
|
if lead_id is None and "SNPID" in sumstats.columns:
|
|
260
267
|
lead_id = sumstats.index[sumstats["SNPID"] == region_ref_to_check].to_list()
|
|
261
268
|
|
|
269
|
+
# if duplicated, select the first one
|
|
262
270
|
if type(lead_id) is list:
|
|
263
271
|
if len(lead_id)>0:
|
|
264
272
|
lead_id = int(lead_id[0])
|
|
265
273
|
|
|
274
|
+
|
|
266
275
|
if region_ref_to_check is not None:
|
|
267
276
|
if type(lead_id) is list:
|
|
268
277
|
if len(lead_id)==0 :
|
|
269
278
|
#try:
|
|
279
|
+
# if region_ref_to_check is in CHR:POS:NEA:EA format
|
|
270
280
|
matched_snpid = re.match("(chr)?[0-9]+:[0-9]+:[ATCG]+:[ATCG]+", region_ref_to_check, re.IGNORECASE)
|
|
271
281
|
if matched_snpid is None:
|
|
282
|
+
# if not, pass
|
|
272
283
|
pass
|
|
273
284
|
else:
|
|
285
|
+
# if region_ref_to_check is in CHR:POS:NEA:EA format, match by CHR:POS:NEA:EA
|
|
274
286
|
lead_snpid = matched_snpid.group(0).split(":")
|
|
275
287
|
if len(lead_snpid)==4:
|
|
276
288
|
lead_chr= int(lead_snpid[0])
|
|
@@ -311,12 +323,13 @@ def _pinpoint_lead(sumstats,ax1,region_ref, region_ref_total_n, lead_color, mark
|
|
|
311
323
|
else:
|
|
312
324
|
lead_id = _get_lead_id(sumstats, region_ref, log, verbose)
|
|
313
325
|
|
|
314
|
-
if
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
326
|
+
if lead_id is not None:
|
|
327
|
+
if region_ref_total_n <2:
|
|
328
|
+
# single-ref mode
|
|
329
|
+
marker_shape = region_marker_shapes[sumstats.loc[lead_id,"SHAPE"]]
|
|
330
|
+
else:
|
|
331
|
+
# multi-ref mode
|
|
332
|
+
marker_shape = region_marker_shapes[sumstats.loc[lead_id,"SHAPE"]-1]
|
|
320
333
|
|
|
321
334
|
if lead_id is not None:
|
|
322
335
|
ax1.scatter(sumstats.loc[lead_id,"i"],sumstats.loc[lead_id,"scaled_P"],
|
|
@@ -332,7 +345,7 @@ def _add_region_title(region_title, ax1,region_title_args):
|
|
|
332
345
|
ax1.text(0.015,0.97, region_title, transform=ax1.transAxes, va="top", ha="left", region_ref=None, **region_title_args )
|
|
333
346
|
return ax1
|
|
334
347
|
|
|
335
|
-
def _add_ld_legend(sumstats, ax1, region_ld_threshold, region_ref,region_ref_index_dic,region_marker_shapes,fig, palette =None, position=1):
|
|
348
|
+
def _add_ld_legend(sumstats, ax1, region_ld_threshold, region_ref,region_ref_index_dic,region_marker_shapes,fig, region_legend_marker=True,palette =None, position=1):
|
|
336
349
|
|
|
337
350
|
width_pct = "11%"
|
|
338
351
|
height_pct = "{}%".format( 14 + 7 * len(region_ref))
|
|
@@ -370,26 +383,30 @@ def _add_ld_legend(sumstats, ax1, region_ld_threshold, region_ref,region_ref_ind
|
|
|
370
383
|
axins1.set_xlim(xmin,xmax)
|
|
371
384
|
|
|
372
385
|
############### ##############plot marker ############## ##############
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
if region_legend_marker==True:
|
|
387
|
+
for group_index, ref in enumerate(region_ref):
|
|
388
|
+
x= -0.1
|
|
389
|
+
y= 0.1 + 0.2 * group_index
|
|
390
|
+
|
|
391
|
+
if len(region_ref) <2:
|
|
392
|
+
# single-ref mode
|
|
393
|
+
marker = region_marker_shapes[group_index+1]
|
|
394
|
+
c = palette[(region_ref_index_dic[region_ref[group_index]]+1)*100 + len(ld_ticks)]
|
|
395
|
+
else:
|
|
396
|
+
# multi-ref mode
|
|
397
|
+
marker = region_marker_shapes[group_index]
|
|
398
|
+
c = palette[(region_ref_index_dic[region_ref[group_index]]+1)*100 + len(ld_ticks)-1]
|
|
399
|
+
|
|
400
|
+
# ([x0,y0][x1,y1])
|
|
401
|
+
data_to_point =(axins1.bbox.get_points()[1][0]-axins1.bbox.get_points()[0][0]) / (xmax - xmin)
|
|
402
|
+
s = (data_to_point * 0.15*0.11/(fig.dpi/72))**2
|
|
403
|
+
|
|
404
|
+
axins1.scatter(x, y, s=s, marker=marker,c=c, edgecolors="black", linewidths = 1, clip_on=False, zorder=100)
|
|
405
|
+
axins1.tick_params(axis="y", pad=data_to_point* 0.11* 0.19/(fig.dpi/72))
|
|
389
406
|
|
|
390
407
|
axins1.set_xlim(0,1)
|
|
391
408
|
axins1.set_aspect('equal', adjustable='box')
|
|
392
|
-
axins1.tick_params(axis="y", pad=
|
|
409
|
+
#axins1.tick_params(axis="y", pad=data_to_point* 0.11* 0.19/(fig.dpi/72))
|
|
393
410
|
axins1.set_title('LD $r^{2}$ with variant',loc="center",y=-0.2)
|
|
394
411
|
cbar = axins1
|
|
395
412
|
return ax1, cbar
|
|
@@ -467,6 +484,7 @@ def _plot_gene_track(
|
|
|
467
484
|
font_size_in_pixels= taf[2] * pixels_per_track
|
|
468
485
|
font_size_in_points = font_size_in_pixels * pixels_per_point
|
|
469
486
|
linewidth_in_points= pixels_per_track * pixels_per_point
|
|
487
|
+
|
|
470
488
|
log.write(" -plotting gene track..", verbose=verbose)
|
|
471
489
|
|
|
472
490
|
sig_gene_name = "Undefined"
|
|
@@ -479,6 +497,7 @@ def _plot_gene_track(
|
|
|
479
497
|
sig_gene_names=[]
|
|
480
498
|
sig_gene_lefts=[]
|
|
481
499
|
sig_gene_rights=[]
|
|
500
|
+
log.write(" -plotting genes: {}..".format(len(uniq_gene_region)), verbose=verbose)
|
|
482
501
|
for index,row in uniq_gene_region.iterrows():
|
|
483
502
|
|
|
484
503
|
gene_color="#020080"
|
|
@@ -497,9 +516,9 @@ def _plot_gene_track(
|
|
|
497
516
|
sig_gene_lefts.append(gene_track_start_i+row["start"])
|
|
498
517
|
sig_gene_rights.append(gene_track_start_i+row["end"])
|
|
499
518
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
519
|
+
# plot gene line
|
|
520
|
+
ax3.plot((gene_track_start_i+row["start"],gene_track_start_i+row["end"]),
|
|
521
|
+
(row["stack"]*2,row["stack"]*2),color=gene_color,linewidth=linewidth_in_points/10,solid_capstyle="butt")
|
|
503
522
|
|
|
504
523
|
# plot gene name
|
|
505
524
|
if row["end"] >= region[2]:
|
|
@@ -516,6 +535,7 @@ def _plot_gene_track(
|
|
|
516
535
|
y=row["stack"]*2+taf[4],s=gene_anno,ha="center",va="center",color="black",style='italic',size=font_size_in_points,family=track_font_family))
|
|
517
536
|
|
|
518
537
|
# plot exons
|
|
538
|
+
log.write(" -plotting exons: {}..".format(len(exons)), verbose=verbose)
|
|
519
539
|
for index,row in exons.iterrows():
|
|
520
540
|
exon_color="#020080"
|
|
521
541
|
for sig_gene_name, sig_gene_left, sig_gene_right in zip(sig_gene_names,sig_gene_lefts,sig_gene_rights):
|
|
@@ -698,7 +718,8 @@ def process_vcf(sumstats,
|
|
|
698
718
|
sumstats[final_rsq_col] = 0.0
|
|
699
719
|
|
|
700
720
|
if len(region_ref)==1:
|
|
701
|
-
|
|
721
|
+
if lead_id is not None:
|
|
722
|
+
sumstats.loc[lead_id, final_shape_col] +=1
|
|
702
723
|
|
|
703
724
|
for i in range(len(region_ref)):
|
|
704
725
|
ld_single = "LD_{}".format(i)
|
|
@@ -80,6 +80,8 @@ def plot_stacked_mqq(objects,
|
|
|
80
80
|
|
|
81
81
|
if fig_args is None:
|
|
82
82
|
fig_args = {"dpi":200}
|
|
83
|
+
if save_args is None:
|
|
84
|
+
save_args = {"dpi":400,"facecolor":"white"}
|
|
83
85
|
if region_lead_grid_line is None:
|
|
84
86
|
region_lead_grid_line = {"alpha":0.5,"linewidth" : 2,"linestyle":"--","color":"#FF0000"}
|
|
85
87
|
if region_chromatin_files is None:
|
|
@@ -94,6 +96,19 @@ def plot_stacked_mqq(objects,
|
|
|
94
96
|
else:
|
|
95
97
|
if "family" not in title_args.keys():
|
|
96
98
|
title_args["family"] = "Arial"
|
|
99
|
+
|
|
100
|
+
if save is not None:
|
|
101
|
+
if type(save) is not bool:
|
|
102
|
+
if len(save)>3:
|
|
103
|
+
if save[-3:]=="pdf" or save[-3:]=="svg":
|
|
104
|
+
log.write(" -Adjusting options for saving as pdf/svg...",verbose=verbose)
|
|
105
|
+
fig_args["dpi"]=72
|
|
106
|
+
if "scatter_args" not in mqq_args.keys():
|
|
107
|
+
mqq_args["scatter_args"]={"rasterized":True}
|
|
108
|
+
else:
|
|
109
|
+
mqq_args["scatter_args"]["rasterized"] = True
|
|
110
|
+
else:
|
|
111
|
+
fig_args["dpi"] = save_args["dpi"]
|
|
97
112
|
# create figure and axes ##################################################################################################################
|
|
98
113
|
#
|
|
99
114
|
# subplot_height : subplot height
|
|
@@ -141,6 +156,8 @@ def plot_stacked_mqq(objects,
|
|
|
141
156
|
region_lead_grids = [i for i in range(len(axes))]
|
|
142
157
|
##########################################################################################################################################
|
|
143
158
|
mqq_args_for_each_plot = _sort_args(mqq_args, n_plot)
|
|
159
|
+
|
|
160
|
+
|
|
144
161
|
##########################################################################################################################################
|
|
145
162
|
# get x axis dict
|
|
146
163
|
if mode=="m" or mode=="r":
|
|
@@ -238,7 +255,6 @@ def plot_stacked_mqq(objects,
|
|
|
238
255
|
# adjust labels
|
|
239
256
|
# drop labels for each plot
|
|
240
257
|
# set a common laebl for all plots
|
|
241
|
-
|
|
242
258
|
#if title_box is None:
|
|
243
259
|
# title_box = dict(boxstyle='square', facecolor='white', alpha=1.0, edgecolor="black")
|
|
244
260
|
# title_box = {}
|
|
@@ -270,8 +286,9 @@ def plot_stacked_mqq(objects,
|
|
|
270
286
|
#else:
|
|
271
287
|
if title_pos is None:
|
|
272
288
|
title_pos = [0.01,0.97]
|
|
273
|
-
|
|
274
|
-
|
|
289
|
+
if titles is not None:
|
|
290
|
+
for index,title in enumerate(titles):
|
|
291
|
+
axes[index].text(title_pos[0], title_pos[1] , title, transform=axes[index].transAxes,ha="left", va='top',zorder=999999, **title_args)
|
|
275
292
|
|
|
276
293
|
##########################################################################################################################################
|
|
277
294
|
# draw the line for lead variants
|
|
@@ -283,6 +283,8 @@ def plottrumpet(mysumstats,
|
|
|
283
283
|
##################################################################################################
|
|
284
284
|
size_norm = (sumstats[size].min(), sumstats[size].max())
|
|
285
285
|
## if highlight ##################################################################################################
|
|
286
|
+
|
|
287
|
+
log.write(" -Creating scatter plot...", verbose=verbose)
|
|
286
288
|
dots = sns.scatterplot(data=sumstats,
|
|
287
289
|
x=maf,
|
|
288
290
|
y=beta,
|
|
@@ -295,7 +297,7 @@ def plottrumpet(mysumstats,
|
|
|
295
297
|
alpha=0.8,
|
|
296
298
|
zorder=2,
|
|
297
299
|
**scatter_args)
|
|
298
|
-
|
|
300
|
+
log.write(" -Finished screating scatter plot...", verbose=verbose)
|
|
299
301
|
if len(highlight) >0:
|
|
300
302
|
|
|
301
303
|
legend = None
|
|
@@ -380,15 +382,13 @@ def plottrumpet(mysumstats,
|
|
|
380
382
|
####################################################################################################################
|
|
381
383
|
|
|
382
384
|
#second_legend = ax.legend(title="Power", loc="upper right",fontsize =fontsize,title_fontsize=fontsize)
|
|
383
|
-
|
|
385
|
+
log.write(" -Creating legends...")
|
|
384
386
|
h,l = ax.get_legend_handles_labels()
|
|
385
387
|
if len(ts)>0:
|
|
386
388
|
l1 = ax.legend(h[:int(len(ts))],l[:int(len(ts))], title="Power", loc="upper right",fontsize =fontsize,title_fontsize=fontsize)
|
|
387
389
|
for line in l1.get_lines():
|
|
388
390
|
line.set_linewidth(5.0)
|
|
389
391
|
if hue is None:
|
|
390
|
-
l2 = ax.legend(h[int(len(ts)):],l[int(len(ts)):], title=size, loc="lower right",fontsize =fontsize,title_fontsize=fontsize)
|
|
391
|
-
else:
|
|
392
392
|
l2 = ax.legend(h[int(len(ts)):],l[int(len(ts)):], title=None, loc="lower right",fontsize =fontsize,title_fontsize=fontsize)
|
|
393
393
|
if len(ts)>0:
|
|
394
394
|
ax.add_artist(l1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|