gwaslab 3.4.35__py3-none-any.whl → 3.4.37__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 +1 -1
- gwaslab/bd_common_data.py +4 -2
- gwaslab/g_Sumstats.py +56 -33
- gwaslab/g_meta.py +13 -3
- gwaslab/g_version.py +2 -2
- gwaslab/hm_harmonize_sumstats.py +43 -18
- gwaslab/io_preformat_input.py +9 -0
- gwaslab/qc_check_datatype.py +14 -0
- gwaslab/qc_fix_sumstats.py +278 -119
- gwaslab/util_ex_process_h5.py +26 -17
- gwaslab/util_in_fill_data.py +50 -12
- gwaslab/viz_aux_quickfix.py +53 -52
- gwaslab/viz_plot_compare_effect.py +27 -8
- gwaslab/viz_plot_forestplot.py +1 -1
- gwaslab/viz_plot_mqqplot.py +127 -48
- gwaslab/viz_plot_regionalplot.py +20 -9
- gwaslab/viz_plot_rg_heatmap.py +8 -4
- {gwaslab-3.4.35.dist-info → gwaslab-3.4.37.dist-info}/METADATA +5 -6
- {gwaslab-3.4.35.dist-info → gwaslab-3.4.37.dist-info}/RECORD +22 -22
- {gwaslab-3.4.35.dist-info → gwaslab-3.4.37.dist-info}/LICENSE +0 -0
- {gwaslab-3.4.35.dist-info → gwaslab-3.4.37.dist-info}/WHEEL +0 -0
- {gwaslab-3.4.35.dist-info → gwaslab-3.4.37.dist-info}/top_level.txt +0 -0
gwaslab/viz_plot_mqqplot.py
CHANGED
|
@@ -104,6 +104,15 @@ def mqqplot(insumstats,
|
|
|
104
104
|
region_protein_coding = True,
|
|
105
105
|
region_flank_factor = 0.05,
|
|
106
106
|
region_anno_bbox_args = None,
|
|
107
|
+
cbar_title='LD $r^{2}$',
|
|
108
|
+
cbar_fontsize = None,
|
|
109
|
+
cbar_font_family = None,
|
|
110
|
+
track_n=4,
|
|
111
|
+
track_n_offset=0,
|
|
112
|
+
track_fontsize_ratio=0.95,
|
|
113
|
+
track_exon_ratio=1,
|
|
114
|
+
track_text_offset=1,
|
|
115
|
+
track_font_family = None,
|
|
107
116
|
taf = None,
|
|
108
117
|
# track_n, track_n_offset,font_ratio,exon_ratio,text_offset
|
|
109
118
|
tabix=None,
|
|
@@ -243,8 +252,14 @@ def mqqplot(insumstats,
|
|
|
243
252
|
region_ld_colors2 = ["#E4E4E4","#D8E2F2","#AFCBE3","#86B3D4","#5D98C4","#367EB7","#367EB7"]
|
|
244
253
|
if region_title_args is None:
|
|
245
254
|
region_title_args = {"size":10}
|
|
255
|
+
if cbar_fontsize is None:
|
|
256
|
+
cbar_fontsize = fontsize
|
|
257
|
+
if cbar_font_family is None:
|
|
258
|
+
cbar_font_family = font_family
|
|
259
|
+
if track_font_family is None:
|
|
260
|
+
track_font_family = font_family
|
|
246
261
|
if taf is None:
|
|
247
|
-
taf = [
|
|
262
|
+
taf = [track_n,track_n_offset,track_fontsize_ratio,track_exon_ratio,track_text_offset]
|
|
248
263
|
if maf_bins is None:
|
|
249
264
|
maf_bins=[(0, 0.01), (0.01, 0.05), (0.05, 0.25),(0.25,0.5)]
|
|
250
265
|
if maf_bin_colors is None:
|
|
@@ -289,13 +304,13 @@ def mqqplot(insumstats,
|
|
|
289
304
|
scatter_args["rasterized"]=True
|
|
290
305
|
qq_scatter_args["rasterized"]=True
|
|
291
306
|
|
|
292
|
-
if verbose: log.write("Start to
|
|
307
|
+
if verbose: log.write("Start to create MQQ plot with the following basic settings {}:".format(_get_version()))
|
|
293
308
|
if verbose: log.write(" -Genomic coordinates version: {}...".format(build))
|
|
294
309
|
if build is None or build=="99":
|
|
295
310
|
if verbose: log.write(" -WARNING: Genomic coordinates version is unknown...")
|
|
296
311
|
if verbose: log.write(" -Genome-wide significance level to plot is set to "+str(sig_level_plot)+" ...")
|
|
297
312
|
if verbose: log.write(" -Raw input contains "+str(len(insumstats))+" variants...")
|
|
298
|
-
if verbose: log.write(" -
|
|
313
|
+
if verbose: log.write(" -MQQ plot layout mode is : "+mode)
|
|
299
314
|
if len(anno_set)>0 and ("m" in mode):
|
|
300
315
|
if verbose: log.write(" -Variants to annotate : "+",".join(anno_set))
|
|
301
316
|
if len(highlight)>0 and ("m" in mode):
|
|
@@ -340,13 +355,14 @@ def mqqplot(insumstats,
|
|
|
340
355
|
# ax2 : qq plot
|
|
341
356
|
# ax3 : gene track
|
|
342
357
|
# ax4 : recombination rate
|
|
358
|
+
# cbar : color bar
|
|
343
359
|
# ax5 : miami plot lower panel
|
|
344
360
|
|
|
345
361
|
# "m" : Manhattan plot
|
|
346
362
|
# "qq": QQ plot
|
|
347
363
|
# "r" : regional plot
|
|
348
364
|
|
|
349
|
-
fig, ax1, ax2, ax3 = _process_layout(mode=mode,
|
|
365
|
+
fig, ax1, ax2, ax3, ax4, cbar = _process_layout(mode=mode,
|
|
350
366
|
figax=figax,
|
|
351
367
|
fig_args=fig_args,
|
|
352
368
|
mqqratio=mqqratio,
|
|
@@ -553,7 +569,7 @@ def mqqplot(insumstats,
|
|
|
553
569
|
if vcf_path is not None:
|
|
554
570
|
sumstats["chr_hue"]=sumstats["LD"]
|
|
555
571
|
|
|
556
|
-
if verbose:log.write("Start to create
|
|
572
|
+
if verbose:log.write("Start to create MQQ plot with "+str(len(sumstats))+" variants:")
|
|
557
573
|
## default seetings
|
|
558
574
|
|
|
559
575
|
palette = sns.color_palette(colors,n_colors=sumstats[chrom].nunique())
|
|
@@ -697,7 +713,7 @@ def mqqplot(insumstats,
|
|
|
697
713
|
# if regional plot : pinpoint lead , add color bar ##################################################
|
|
698
714
|
if (region is not None) and ("r" in mode):
|
|
699
715
|
|
|
700
|
-
ax1, ax3, lead_snp_i, lead_snp_i2 =_plot_regional(
|
|
716
|
+
ax1, ax3, ax4, cbar, lead_snp_i, lead_snp_i2 =_plot_regional(
|
|
701
717
|
sumstats=sumstats,
|
|
702
718
|
fig=fig,
|
|
703
719
|
ax1=ax1,
|
|
@@ -738,6 +754,7 @@ def mqqplot(insumstats,
|
|
|
738
754
|
region_recombination = region_recombination,
|
|
739
755
|
region_protein_coding=region_protein_coding,
|
|
740
756
|
region_flank_factor =region_flank_factor,
|
|
757
|
+
track_font_family=track_font_family,
|
|
741
758
|
taf=taf,
|
|
742
759
|
tabix=tabix,
|
|
743
760
|
chrom=chrom,
|
|
@@ -745,44 +762,11 @@ def mqqplot(insumstats,
|
|
|
745
762
|
verbose=verbose,
|
|
746
763
|
log=log
|
|
747
764
|
)
|
|
765
|
+
|
|
748
766
|
else:
|
|
749
767
|
lead_snp_i= None
|
|
750
768
|
lead_snp_i2=None
|
|
751
|
-
|
|
752
|
-
if region is None:
|
|
753
|
-
ax1 = _process_xtick(ax1, chrom_df, xtick_chr_dict, fontsize, font_family)
|
|
754
|
-
|
|
755
|
-
# genomewide significant line
|
|
756
|
-
ax1 = _process_line(ax1,
|
|
757
|
-
sig_line,
|
|
758
|
-
suggestive_sig_line,
|
|
759
|
-
additional_line,
|
|
760
|
-
lines_to_plot ,
|
|
761
|
-
sc_linewidth,
|
|
762
|
-
sig_line_color,
|
|
763
|
-
suggestive_sig_line_color,
|
|
764
|
-
additional_line_color,
|
|
765
|
-
mode,
|
|
766
|
-
bmean,
|
|
767
|
-
bmedian )
|
|
768
769
|
|
|
769
|
-
ax1 = _set_yticklabels(cut=cut,
|
|
770
|
-
cutfactor=cutfactor,
|
|
771
|
-
cut_log=cut_log,
|
|
772
|
-
ax1=ax1,
|
|
773
|
-
skip=skip,
|
|
774
|
-
maxy=maxy,
|
|
775
|
-
maxticker=maxticker,
|
|
776
|
-
ystep=ystep,
|
|
777
|
-
sc_linewidth=sc_linewidth,
|
|
778
|
-
cut_line_color=cut_line_color,
|
|
779
|
-
fontsize=fontsize,
|
|
780
|
-
font_family=font_family,
|
|
781
|
-
ytick3=ytick3,
|
|
782
|
-
ylabels=ylabels,
|
|
783
|
-
ylabels_converted=ylabels_converted
|
|
784
|
-
)
|
|
785
|
-
|
|
786
770
|
# Get top variants for annotation #######################################################
|
|
787
771
|
if (anno and anno!=True) or (len(anno_set)>0):
|
|
788
772
|
if len(anno_set)>0:
|
|
@@ -826,11 +810,72 @@ def mqqplot(insumstats,
|
|
|
826
810
|
verbose=verbose).rename(columns={"GENE":"Annotation"})
|
|
827
811
|
|
|
828
812
|
# Configure X, Y axes #######################################################
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
813
|
+
if region is None:
|
|
814
|
+
# if Manhattan plot
|
|
815
|
+
ax1 = _process_xtick(ax1=ax1,
|
|
816
|
+
chrom_df=chrom_df,
|
|
817
|
+
xtick_chr_dict=xtick_chr_dict,
|
|
818
|
+
fontsize = fontsize,
|
|
819
|
+
font_family=font_family)
|
|
832
820
|
|
|
833
|
-
|
|
821
|
+
ax1, ax3 = _process_xlabel(region=region,
|
|
822
|
+
xlabel=xlabel,
|
|
823
|
+
ax1=ax1,
|
|
824
|
+
gtf_path=gtf_path,
|
|
825
|
+
mode=mode,
|
|
826
|
+
fontsize=fontsize,
|
|
827
|
+
font_family=font_family,
|
|
828
|
+
ax3=ax3 )
|
|
829
|
+
|
|
830
|
+
ax1, ax4 = _process_ylabel(ylabel=ylabel,
|
|
831
|
+
ax1=ax1,
|
|
832
|
+
mode=mode,
|
|
833
|
+
bwindowsizekb=bwindowsizekb,
|
|
834
|
+
fontsize=fontsize,
|
|
835
|
+
font_family=font_family,
|
|
836
|
+
ax4=ax4)
|
|
837
|
+
|
|
838
|
+
ax1 = _set_yticklabels(cut=cut,
|
|
839
|
+
cutfactor=cutfactor,
|
|
840
|
+
cut_log=cut_log,
|
|
841
|
+
ax1=ax1,
|
|
842
|
+
skip=skip,
|
|
843
|
+
maxy=maxy,
|
|
844
|
+
maxticker=maxticker,
|
|
845
|
+
ystep=ystep,
|
|
846
|
+
sc_linewidth=sc_linewidth,
|
|
847
|
+
cut_line_color=cut_line_color,
|
|
848
|
+
fontsize=fontsize,
|
|
849
|
+
font_family=font_family,
|
|
850
|
+
ytick3=ytick3,
|
|
851
|
+
ylabels=ylabels,
|
|
852
|
+
ylabels_converted=ylabels_converted
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
ax1, ax4 = _process_ytick(ax1=ax1,
|
|
856
|
+
fontsize=fontsize,
|
|
857
|
+
font_family=font_family,
|
|
858
|
+
ax4=ax4)
|
|
859
|
+
|
|
860
|
+
if cbar is not None:
|
|
861
|
+
# regional plot cbar
|
|
862
|
+
cbar = _process_cbar(cbar, cbar_fontsize=fontsize, cbar_font_family=font_family, cbar_title=cbar_title)
|
|
863
|
+
|
|
864
|
+
ax1 = _process_spine(ax1, mode)
|
|
865
|
+
# genomewide significant line
|
|
866
|
+
ax1 = _process_line(ax1,
|
|
867
|
+
sig_line,
|
|
868
|
+
suggestive_sig_line,
|
|
869
|
+
additional_line,
|
|
870
|
+
lines_to_plot ,
|
|
871
|
+
sc_linewidth,
|
|
872
|
+
sig_line_color,
|
|
873
|
+
suggestive_sig_line_color,
|
|
874
|
+
additional_line_color,
|
|
875
|
+
mode,
|
|
876
|
+
bmean,
|
|
877
|
+
bmedian )
|
|
878
|
+
|
|
834
879
|
|
|
835
880
|
if mtitle and anno and len(to_annotate)>0:
|
|
836
881
|
pad=(ax1.transData.transform((skip, title_pad*maxy))[1]-ax1.transData.transform((skip, maxy)))[1]
|
|
@@ -872,7 +917,7 @@ def mqqplot(insumstats,
|
|
|
872
917
|
log=log,
|
|
873
918
|
_invert=_invert
|
|
874
919
|
)
|
|
875
|
-
# Manhatann plot Finished #####################################################################
|
|
920
|
+
# Manhatann-like plot Finished #####################################################################
|
|
876
921
|
|
|
877
922
|
# QQ plot #########################################################################################################
|
|
878
923
|
if "qq" in mode:
|
|
@@ -943,6 +988,8 @@ def mqqplot(insumstats,
|
|
|
943
988
|
# Return matplotlib figure object #######################################################################################
|
|
944
989
|
if _get_region_lead==True:
|
|
945
990
|
return fig, log, lead_snp_i, lead_snp_i2
|
|
991
|
+
|
|
992
|
+
if verbose: log.write("Finished creating MQQ plot successfully!")
|
|
946
993
|
return fig, log
|
|
947
994
|
|
|
948
995
|
##############################################################################################################################################################################
|
|
@@ -1173,11 +1220,34 @@ def _process_line(ax1, sig_line, suggestive_sig_line, additional_line, lines_to_
|
|
|
1173
1220
|
medianline = ax1.axhline(y=bmedian, linewidth = sc_linewidth,linestyle="--",color=sig_line_color,zorder=1000)
|
|
1174
1221
|
return ax1
|
|
1175
1222
|
|
|
1223
|
+
def _process_cbar(cbar, cbar_fontsize, cbar_font_family, cbar_title):
|
|
1224
|
+
if str(type(cbar))=="list":
|
|
1225
|
+
for cbar_single in cbar:
|
|
1226
|
+
cbar_yticklabels = cbar_single.ax.get_yticklabels()
|
|
1227
|
+
cbar_single.ax.set_yticklabels(cbar_yticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
|
|
1228
|
+
cbar_single.ax.set_title(cbar_title, fontsize=cbar_fontsize, family=cbar_font_family, loc="center",y=-0.2 )
|
|
1229
|
+
else:
|
|
1230
|
+
cbar_yticklabels = cbar.ax.get_yticklabels()
|
|
1231
|
+
cbar.ax.set_yticklabels(cbar_yticklabels, fontsize=cbar_fontsize, family=cbar_font_family )
|
|
1232
|
+
cbar.ax.set_title(cbar_title, fontsize=cbar_fontsize, family=cbar_font_family, loc="center",y=-0.2 )
|
|
1233
|
+
return cbar
|
|
1234
|
+
|
|
1176
1235
|
def _process_xtick(ax1, chrom_df, xtick_chr_dict, fontsize, font_family):
|
|
1177
1236
|
ax1.set_xticks(chrom_df.astype("float64"))
|
|
1178
1237
|
ax1.set_xticklabels(chrom_df.index.astype("Int64").map(xtick_chr_dict),fontsize=fontsize,family=font_family)
|
|
1179
1238
|
return ax1
|
|
1180
1239
|
|
|
1240
|
+
def _process_ytick(ax1, fontsize, font_family, ax4):
|
|
1241
|
+
ax1_yticklabels = ax1.get_yticklabels()
|
|
1242
|
+
#ax1.set_yticklabels(ax1_yticklabels,fontsize=fontsize,family=font_family)
|
|
1243
|
+
ax1_yticks = ax1.get_yticks()
|
|
1244
|
+
ax1.set_yticks(ax1_yticks,ax1_yticklabels,fontsize=fontsize,family=font_family)
|
|
1245
|
+
if ax4 is not None:
|
|
1246
|
+
ax4_yticklabels = ax4.get_yticklabels()
|
|
1247
|
+
ax4_yticks = ax4.get_yticks()
|
|
1248
|
+
ax4.set_yticks(ax4_yticks,ax4_yticklabels, fontsize=fontsize,family=font_family)
|
|
1249
|
+
return ax1, ax4
|
|
1250
|
+
|
|
1181
1251
|
def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family, ax3=None ):
|
|
1182
1252
|
if region is not None:
|
|
1183
1253
|
if xlabel is None:
|
|
@@ -1192,7 +1262,7 @@ def _process_xlabel(region, xlabel, ax1, gtf_path, mode, fontsize, font_family,
|
|
|
1192
1262
|
ax1.set_xlabel(xlabel,fontsize=fontsize,family=font_family)
|
|
1193
1263
|
return ax1, ax3
|
|
1194
1264
|
|
|
1195
|
-
def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family):
|
|
1265
|
+
def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family, ax4=None):
|
|
1196
1266
|
if "b" in mode:
|
|
1197
1267
|
if ylabel is None:
|
|
1198
1268
|
ylabel ="Density of GWAS \n SNPs within "+str(bwindowsizekb)+" kb"
|
|
@@ -1201,7 +1271,10 @@ def _process_ylabel(ylabel, ax1, mode, bwindowsizekb, fontsize, font_family):
|
|
|
1201
1271
|
if ylabel is None:
|
|
1202
1272
|
ylabel ="$-log_{10}(P)$"
|
|
1203
1273
|
ax1.set_ylabel(ylabel,fontsize=fontsize,family=font_family)
|
|
1204
|
-
|
|
1274
|
+
if ax4 is not None:
|
|
1275
|
+
ax4_ylabel = ax4.get_ylabel()
|
|
1276
|
+
ax4.set_ylabel(ax4_ylabel, fontsize=fontsize, family=font_family )
|
|
1277
|
+
return ax1, ax4
|
|
1205
1278
|
|
|
1206
1279
|
def _process_spine(ax1, mode):
|
|
1207
1280
|
ax1.spines["top"].set_visible(False)
|
|
@@ -1218,6 +1291,7 @@ def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
|
|
|
1218
1291
|
if mode=="qqm":
|
|
1219
1292
|
fig, (ax2, ax1) = plt.subplots(1, 2,gridspec_kw={'width_ratios': [1, mqqratio]},**fig_args)
|
|
1220
1293
|
ax3 = None
|
|
1294
|
+
|
|
1221
1295
|
elif mode=="mqq":
|
|
1222
1296
|
if figax is not None:
|
|
1223
1297
|
fig = figax[0]
|
|
@@ -1226,6 +1300,7 @@ def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
|
|
|
1226
1300
|
else:
|
|
1227
1301
|
fig, (ax1, ax2) = plt.subplots(1, 2,gridspec_kw={'width_ratios': [mqqratio, 1]},**fig_args)
|
|
1228
1302
|
ax3 = None
|
|
1303
|
+
|
|
1229
1304
|
elif mode=="m":
|
|
1230
1305
|
if figax is not None:
|
|
1231
1306
|
fig = figax[0]
|
|
@@ -1234,10 +1309,12 @@ def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
|
|
|
1234
1309
|
fig, ax1 = plt.subplots(1, 1,**fig_args)
|
|
1235
1310
|
ax2 = None
|
|
1236
1311
|
ax3 = None
|
|
1312
|
+
|
|
1237
1313
|
elif mode=="qq":
|
|
1238
1314
|
fig, ax2 = plt.subplots(1, 1,**fig_args)
|
|
1239
1315
|
ax1=None
|
|
1240
1316
|
ax3=None
|
|
1317
|
+
|
|
1241
1318
|
elif mode=="r":
|
|
1242
1319
|
if figax is not None:
|
|
1243
1320
|
fig = figax[0]
|
|
@@ -1257,4 +1334,6 @@ def _process_layout(mode, figax, fig_args, mqqratio, region_hspace):
|
|
|
1257
1334
|
ax3 = None
|
|
1258
1335
|
else:
|
|
1259
1336
|
raise ValueError("Please select one from the 5 modes: mqq/qqm/m/qq/r/b")
|
|
1260
|
-
|
|
1337
|
+
ax4=None
|
|
1338
|
+
cbar=None
|
|
1339
|
+
return fig, ax1, ax2, ax3, ax4, cbar
|
gwaslab/viz_plot_regionalplot.py
CHANGED
|
@@ -64,6 +64,7 @@ def _plot_regional(
|
|
|
64
64
|
region_recombination = True,
|
|
65
65
|
region_protein_coding=True,
|
|
66
66
|
region_flank_factor = 0.05,
|
|
67
|
+
track_font_family="Arial",
|
|
67
68
|
taf=[4,0,0.95,1,1],
|
|
68
69
|
# track_n, track_n_offset,font_ratio,exon_ratio,text_offset
|
|
69
70
|
tabix=None,
|
|
@@ -73,6 +74,8 @@ def _plot_regional(
|
|
|
73
74
|
log=Log()
|
|
74
75
|
):
|
|
75
76
|
|
|
77
|
+
# x axix: use i to plot (there is a gap between i and pos)
|
|
78
|
+
|
|
76
79
|
# if regional plot : pinpoint lead , add color bar ##################################################
|
|
77
80
|
if (region is not None) :
|
|
78
81
|
# pinpoint lead
|
|
@@ -102,21 +105,23 @@ def _plot_regional(
|
|
|
102
105
|
|
|
103
106
|
if (vcf_path is not None) and region_ld_legend:
|
|
104
107
|
if region_ref_second is None:
|
|
105
|
-
ax1 = _add_ld_legend(sumstats=sumstats,
|
|
108
|
+
ax1, cbar = _add_ld_legend(sumstats=sumstats,
|
|
106
109
|
ax1=ax1,
|
|
107
110
|
region_ld_threshold=region_ld_threshold,
|
|
108
111
|
region_ld_colors=region_ld_colors)
|
|
109
112
|
else:
|
|
110
|
-
|
|
113
|
+
|
|
114
|
+
ax1, cbar1 = _add_ld_legend(sumstats=sumstats,
|
|
111
115
|
ax1=ax1,
|
|
112
116
|
region_ld_threshold=region_ld_threshold,
|
|
113
117
|
region_ld_colors=region_ld_colors1,
|
|
114
118
|
position=1)
|
|
115
|
-
ax1 = _add_ld_legend(sumstats=sumstats,
|
|
119
|
+
ax1, cbar2 = _add_ld_legend(sumstats=sumstats,
|
|
116
120
|
ax1=ax1,
|
|
117
121
|
region_ld_threshold=region_ld_threshold,
|
|
118
122
|
region_ld_colors=region_ld_colors2,
|
|
119
123
|
position=2)
|
|
124
|
+
cbar = [cbar1, cbar2]
|
|
120
125
|
if region_title is not None:
|
|
121
126
|
ax1 = _add_region_title(region_title, ax1=ax1,region_title_args=region_title_args )
|
|
122
127
|
## recombinnation rate ##################################################
|
|
@@ -140,9 +145,10 @@ def _plot_regional(
|
|
|
140
145
|
# distance between leftmost variant position to region left bound
|
|
141
146
|
gene_track_offset = sumstats.loc[most_left_snp,pos] - region[1]
|
|
142
147
|
|
|
143
|
-
# rebase i to region[1]
|
|
148
|
+
# rebase i to region[1] : the i value when POS=0
|
|
144
149
|
gene_track_start_i = sumstats.loc[most_left_snp,"i"] - gene_track_offset - region[1]
|
|
145
150
|
|
|
151
|
+
|
|
146
152
|
#lead_id = sumstats["scaled_P"].idxmax()
|
|
147
153
|
lead_snp_y = sumstats.loc[lead_id,"scaled_P"]
|
|
148
154
|
#sumstats["scaled_P"].max()
|
|
@@ -173,6 +179,7 @@ def _plot_regional(
|
|
|
173
179
|
gene_track_start_i=gene_track_start_i,
|
|
174
180
|
gtf_chr_dict=gtf_chr_dict,
|
|
175
181
|
gtf_gene_name=gtf_gene_name,
|
|
182
|
+
track_font_family=track_font_family,
|
|
176
183
|
taf=taf,
|
|
177
184
|
build=build,
|
|
178
185
|
verbose=verbose,
|
|
@@ -228,7 +235,7 @@ def _plot_regional(
|
|
|
228
235
|
avoid_points=False,
|
|
229
236
|
lim =1000)
|
|
230
237
|
|
|
231
|
-
return ax1, ax3, lead_snp_i, lead_snp_i2
|
|
238
|
+
return ax1, ax3, ax4, cbar, lead_snp_i, lead_snp_i2
|
|
232
239
|
|
|
233
240
|
# + ###########################################################################################################################################################################
|
|
234
241
|
def _get_lead_id(sumstats=None, region_ref=None, log=None):
|
|
@@ -333,13 +340,16 @@ def _add_ld_legend(sumstats, ax1, region_ld_threshold, region_ld_colors,position
|
|
|
333
340
|
facecolor='white',
|
|
334
341
|
zorder=999998)
|
|
335
342
|
ax1.add_patch(rect)
|
|
336
|
-
return ax1
|
|
343
|
+
return ax1, cbar
|
|
337
344
|
|
|
338
345
|
# -############################################################################################################################################################################
|
|
339
346
|
def _plot_recombination_rate(sumstats,pos, region, ax1, rr_path, rr_chr_dict, rr_header_dict, build,rr_lim,rr_ylabel=True):
|
|
340
347
|
ax4 = ax1.twinx()
|
|
341
348
|
most_left_snp = sumstats["i"].idxmin()
|
|
349
|
+
|
|
350
|
+
# the i value when pos=0
|
|
342
351
|
rc_track_offset = sumstats.loc[most_left_snp,"i"]-sumstats.loc[most_left_snp,pos]
|
|
352
|
+
|
|
343
353
|
if rr_path=="default":
|
|
344
354
|
if rr_chr_dict is not None:
|
|
345
355
|
rr_chr = rr_chr_dict[region[0]]
|
|
@@ -379,6 +389,7 @@ def _plot_gene_track(
|
|
|
379
389
|
region_ld_colors2,
|
|
380
390
|
gene_track_start_i,
|
|
381
391
|
gtf_chr_dict,gtf_gene_name,
|
|
392
|
+
track_font_family,
|
|
382
393
|
taf,
|
|
383
394
|
build,
|
|
384
395
|
verbose=True,
|
|
@@ -446,15 +457,15 @@ def _plot_gene_track(
|
|
|
446
457
|
if row["end"] >= region[2]:
|
|
447
458
|
#right side
|
|
448
459
|
texts_to_adjust_right.append(ax3.text(x=gene_track_start_i+region[2],
|
|
449
|
-
y=row["stack"]*2+taf[4],s=gene_anno,ha="right",va="center",color="black",style='italic', size=font_size_in_points))
|
|
460
|
+
y=row["stack"]*2+taf[4],s=gene_anno,ha="right",va="center",color="black",style='italic', size=font_size_in_points,family=track_font_family))
|
|
450
461
|
|
|
451
462
|
elif row["start"] <= region[1] :
|
|
452
463
|
#left side
|
|
453
464
|
texts_to_adjust_left.append(ax3.text(x=gene_track_start_i+region[1],
|
|
454
|
-
y=row["stack"]*2+taf[4],s=gene_anno,ha="left",va="center",color="black",style='italic', size=font_size_in_points))
|
|
465
|
+
y=row["stack"]*2+taf[4],s=gene_anno,ha="left",va="center",color="black",style='italic', size=font_size_in_points,family=track_font_family))
|
|
455
466
|
else:
|
|
456
467
|
texts_to_adjust_middle.append(ax3.text(x=(gene_track_start_i+row["start"]+gene_track_start_i+row["end"])/2,
|
|
457
|
-
y=row["stack"]*2+taf[4],s=gene_anno,ha="center",va="center",color="black",style='italic',size=font_size_in_points))
|
|
468
|
+
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))
|
|
458
469
|
|
|
459
470
|
# plot exons
|
|
460
471
|
for index,row in exons.iterrows():
|
gwaslab/viz_plot_rg_heatmap.py
CHANGED
|
@@ -6,7 +6,7 @@ import matplotlib.ticker as ticker
|
|
|
6
6
|
import matplotlib.patches as patches
|
|
7
7
|
import matplotlib
|
|
8
8
|
from gwaslab.g_Log import Log
|
|
9
|
-
|
|
9
|
+
import scipy.stats as ss
|
|
10
10
|
from gwaslab.viz_aux_save_figure import save_figure
|
|
11
11
|
#################################################################################################
|
|
12
12
|
def convert_p_to_width(p,sig_level):
|
|
@@ -49,7 +49,7 @@ def plot_rg(ldscrg,
|
|
|
49
49
|
fig_args=None,
|
|
50
50
|
xticklabel_args=None,
|
|
51
51
|
yticklabel_args=None,
|
|
52
|
-
fdr_method="
|
|
52
|
+
fdr_method="bh",
|
|
53
53
|
fontsize=10,
|
|
54
54
|
save=None,
|
|
55
55
|
save_args=None):
|
|
@@ -124,9 +124,13 @@ def plot_rg(ldscrg,
|
|
|
124
124
|
|
|
125
125
|
#if correction=="fdr":
|
|
126
126
|
# fdr corrected p
|
|
127
|
-
dfp["fdr_p"]=fdrcorrection(dfp[p],alpha=1,method=fdr_method)[1]
|
|
127
|
+
#dfp["fdr_p"]=fdrcorrection(dfp[p],alpha=1,method=fdr_method)[1]
|
|
128
128
|
# is fdr < sig_level
|
|
129
|
-
dfp["fdr"]=fdrcorrection(dfp[p],alpha=0.05,method=fdr_method)[0]
|
|
129
|
+
#dfp["fdr"]=fdrcorrection(dfp[p],alpha=0.05,method=fdr_method)[0]
|
|
130
|
+
|
|
131
|
+
dfp["fdr_p"]=ss.false_discovery_control(dfp[p],method=fdr_method)
|
|
132
|
+
dfp["fdr"] =ss.false_discovery_control(dfp[p],method=fdr_method) < 0.05
|
|
133
|
+
|
|
130
134
|
if verbose: log.write(" -Significant correlations with FDR <0.05:",sum(dfp["fdr"]))
|
|
131
135
|
# convert to dict for annotation and plotting
|
|
132
136
|
df_rawp = dfp.set_index("p1p2").loc[:,p].to_dict()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gwaslab
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.37
|
|
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/
|
|
@@ -8,19 +8,18 @@ Project-URL: Github, https://github.com/Cloufield/gwaslab
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: <=3.10,>=3.
|
|
11
|
+
Requires-Python: <=3.10,>=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: pandas !=1.5
|
|
14
|
+
Requires-Dist: pandas !=1.5,>=1.3
|
|
15
15
|
Requires-Dist: numpy >=1.21.2
|
|
16
16
|
Requires-Dist: matplotlib !=3.7.2,>=3.5
|
|
17
17
|
Requires-Dist: seaborn >=0.11.1
|
|
18
|
-
Requires-Dist: scipy >=1.
|
|
18
|
+
Requires-Dist: scipy >=1.12
|
|
19
19
|
Requires-Dist: pySAM <0.20,>=0.18.1
|
|
20
20
|
Requires-Dist: Biopython >=1.79
|
|
21
21
|
Requires-Dist: adjustText <=0.8,>=0.7.3
|
|
22
22
|
Requires-Dist: liftover >=1.1.13
|
|
23
|
-
Requires-Dist: statsmodels ==0.13
|
|
24
23
|
Requires-Dist: scikit-allel >=1.3.5
|
|
25
24
|
Requires-Dist: pyensembl ==2.2.3
|
|
26
25
|
Requires-Dist: gtfparse ==1.3.0
|
|
@@ -45,7 +44,7 @@ Note: GWASLab is being updated very frequently for now. I will release the first
|
|
|
45
44
|
## Install
|
|
46
45
|
|
|
47
46
|
```
|
|
48
|
-
pip install gwaslab==3.4.
|
|
47
|
+
pip install gwaslab==3.4.35
|
|
49
48
|
```
|
|
50
49
|
|
|
51
50
|
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
gwaslab/__init__.py,sha256=
|
|
2
|
-
gwaslab/bd_common_data.py,sha256
|
|
1
|
+
gwaslab/__init__.py,sha256=dFnrh4L620F5JirsSF98SmkuligA-fybIGdBF6r9Ims,2386
|
|
2
|
+
gwaslab/bd_common_data.py,sha256=-YlytsRU3YnwI23EV0U_pFWZ0_0yL23_RwTfBajEuPw,11844
|
|
3
3
|
gwaslab/bd_config.py,sha256=TP-r-DPhJD3XnRYZbw9bQHXaDIkiRgK8bG9HCt-UaLc,580
|
|
4
4
|
gwaslab/bd_download.py,sha256=Nh09FP_d5kLsAyEF-WOYd7tty-ypvJv0PSTEO4JB2cc,15636
|
|
5
5
|
gwaslab/bd_get_hapmap3.py,sha256=poqV3Ko56xhRFKdSK0ROwDQ71b27-9bMOQ0XO36To5c,2034
|
|
6
6
|
gwaslab/g_Log.py,sha256=ICCzc2iP-toIRhXSnRufMqJrB6MtstJXk5qmC2yK6pY,821
|
|
7
7
|
gwaslab/g_Phenotypes.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
gwaslab/g_Sumstats.py,sha256=
|
|
8
|
+
gwaslab/g_Sumstats.py,sha256=9Qu5RFKgeZIkhHp-YwYZcECQOLV8dOGHvx2y9YVO3LA,33210
|
|
9
9
|
gwaslab/g_SumstatsPair.py,sha256=eFFcL0foi7KJ2t7yf98WIyUMv-Kl6IrvSdv3FtqZmXs,5971
|
|
10
10
|
gwaslab/g_SumstatsT.py,sha256=r3fAN-LsUIJhi7mhLH_4NBwHCOawVkbWULKY1vbmdZY,2113
|
|
11
11
|
gwaslab/g_Sumstats_summary.py,sha256=Q69702tABxTVk6QIbqQ4k6eSujhXr_MVVQ5saOdEhlk,6367
|
|
12
|
-
gwaslab/g_meta.py,sha256=
|
|
12
|
+
gwaslab/g_meta.py,sha256=htWlgURWclm9R6UqFcX1a93WN27xny7lGUeyJZOtszQ,2583
|
|
13
13
|
gwaslab/g_vchange_status.py,sha256=eX0jdIb6Spa07ZdpWNqUWqdVBWS0fuH2yrt4PDi3Res,1746
|
|
14
|
-
gwaslab/g_version.py,sha256=
|
|
14
|
+
gwaslab/g_version.py,sha256=nM7GpPDOdGl2i6-JJyZDrSlJfCCWoq9dFIfHrTcQTQg,1688
|
|
15
15
|
gwaslab/hm_casting.py,sha256=w8Qz0IlFwmn4_uUc7aOccWZCfY_e19ZZr-iYgCu-SnQ,10350
|
|
16
|
-
gwaslab/hm_harmonize_sumstats.py,sha256=
|
|
16
|
+
gwaslab/hm_harmonize_sumstats.py,sha256=l8kHWVJkveRfzeKjvh6Mx5Z_QLy52GSL_9euYnFtH-U,41692
|
|
17
17
|
gwaslab/hm_rsid_to_chrpos.py,sha256=-pKhY654zS4uULW7FP4yGHNy3e9Wc2ujc1VLBaoUO5A,6564
|
|
18
|
-
gwaslab/io_preformat_input.py,sha256=
|
|
18
|
+
gwaslab/io_preformat_input.py,sha256=vusQAi9vR1Bn8K4Zf9KmDwuwqrhSaAZNZ4zHp6yfjxY,19625
|
|
19
19
|
gwaslab/io_read_ldsc.py,sha256=mro3Vc3dQs6dQ2zsUaUYHOqJGIhJaNzxPeE3zsfO7dA,8659
|
|
20
20
|
gwaslab/io_read_tabular.py,sha256=_gI0EA4CDecTPHTDp6hW2PesagYHHbBQvI_tW8U3Tc8,2366
|
|
21
21
|
gwaslab/io_to_formats.py,sha256=tayh5qoxe9tn_g3mHTbfT3Jkz7kTo8BOPjpMtoMlfAY,21111
|
|
22
22
|
gwaslab/io_to_pickle.py,sha256=XmxhV5-38ED8aEyPYzsskv7HrxCyge9tHJ2F21QA8Ms,1824
|
|
23
|
-
gwaslab/qc_check_datatype.py,sha256=
|
|
24
|
-
gwaslab/qc_fix_sumstats.py,sha256=
|
|
23
|
+
gwaslab/qc_check_datatype.py,sha256=ue_C7bjuL7NllOJNv8ReQESxpbXogleKGlw8ntWFi6Y,3440
|
|
24
|
+
gwaslab/qc_fix_sumstats.py,sha256=XME1RzZqdoKc8bO7NLuyMu_t7gudt1tpMsNdiT6BIcU,87581
|
|
25
25
|
gwaslab/run_script.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
gwaslab/util_ex_calculate_ldmatrix.py,sha256=hjFOZqGfQixTjMSxgVbB-JQwP0QcQMKfbhs-dsLT5Qw,12112
|
|
27
27
|
gwaslab/util_ex_calculate_prs.py,sha256=uOcMRWujEYMYGuO-qGe3okQJYizXGvqDcomXlzLvln8,9049
|
|
28
28
|
gwaslab/util_ex_gwascatalog.py,sha256=Y3CiBu03yrJ4SDubl3mOq62fIkbr7bZ1lwbhWEVWKmA,7576
|
|
29
29
|
gwaslab/util_ex_ldproxyfinder.py,sha256=C705kiw673DaijrccJ8ifO2IXR9RHP8B7Jfp0_-7UWo,9398
|
|
30
30
|
gwaslab/util_ex_plink_filter.py,sha256=Ak09-tEIS_uq1OtiCmcDCXcEjzQHCEfp44AKkhgoOzY,1669
|
|
31
|
-
gwaslab/util_ex_process_h5.py,sha256=
|
|
31
|
+
gwaslab/util_ex_process_h5.py,sha256=1QzcQurnwedYFiF4ZaEOv0Wl41rBEUjS7yVcMWNIslE,2741
|
|
32
32
|
gwaslab/util_ex_process_ref.py,sha256=vB5tDnlpnStLJq1QgxwhJQ1wRlQ8hy-yI5smm2wUjaA,16445
|
|
33
33
|
gwaslab/util_ex_run_2samplemr.py,sha256=AvhpR_ihR052LBabR1wfEaBqfwCs88VW8Q2ijdKMfUs,9040
|
|
34
34
|
gwaslab/util_ex_run_clumping.py,sha256=fE-PHeYjl8I08ycwCbJrQjF3wixMDYKNe4EASupEMpo,6816
|
|
@@ -38,23 +38,23 @@ gwaslab/util_in_calculate_gc.py,sha256=HqyBBDorWoBlmD1i4K2Vr4vTTPqg5YLM8ktdvCpKe
|
|
|
38
38
|
gwaslab/util_in_calculate_power.py,sha256=Kk46GHKDcub6l1XTT-ZT5hrPmR8EUa_tS_LIPbLRvbU,10112
|
|
39
39
|
gwaslab/util_in_convert_h2.py,sha256=azqGs9whhhukVDFruAwTobor4-LnGHWIOrhK_avRnWs,6468
|
|
40
40
|
gwaslab/util_in_correct_winnerscurse.py,sha256=o7CjUwLp4B_60yrntV76ESNaoPcl-HPOzSw9cYWzpW4,2050
|
|
41
|
-
gwaslab/util_in_fill_data.py,sha256=
|
|
41
|
+
gwaslab/util_in_fill_data.py,sha256=vVtxWN-BRDPsGCIEIGJ9cWCayiWBYuOdV3kZyakhpFA,13847
|
|
42
42
|
gwaslab/util_in_filter_value.py,sha256=rF2Nv1H-dxJZIIvw0r1tCB2xAFXt75qbpNJOpnEVffw,14647
|
|
43
43
|
gwaslab/util_in_get_density.py,sha256=n4GFhuqyJ4HBepHJeMXVsddGRweFBaBQNueMg3hs4D8,3905
|
|
44
44
|
gwaslab/util_in_get_sig.py,sha256=hrZrLb50h2V-PtPXkwJ2F_jc1piMJ2wJqWTqSq9cnEg,19805
|
|
45
45
|
gwaslab/viz_aux_annotate_plot.py,sha256=BKwvyXydKjgFo2w2ZCwxtxRLGT-g5e6eayhkSje3Lfc,32124
|
|
46
|
-
gwaslab/viz_aux_quickfix.py,sha256=
|
|
46
|
+
gwaslab/viz_aux_quickfix.py,sha256=AP7Yg1TQ0q810BKRCM5jLXAjPSFehs2vxY2ocIFr7Ag,17904
|
|
47
47
|
gwaslab/viz_aux_reposition_text.py,sha256=N0jMQSAnFPFWwx9mUFTcVtntdA56I_3vB332jtpezU4,4233
|
|
48
48
|
gwaslab/viz_aux_save_figure.py,sha256=KfpYuSNxYv0EvcoR5n2AWjnGnJzFrYfyoGfJd71NYMQ,2083
|
|
49
49
|
gwaslab/viz_plot_compare_af.py,sha256=vVypmnF-l6JzXyi5HPYFr-GM-OmNQGvip8oTCBvvHsk,5532
|
|
50
|
-
gwaslab/viz_plot_compare_effect.py,sha256=
|
|
51
|
-
gwaslab/viz_plot_forestplot.py,sha256=
|
|
50
|
+
gwaslab/viz_plot_compare_effect.py,sha256=iUlp6tUS7OSlffgGyUIH4tPXQB_BK19OQZSo7xhToRA,49817
|
|
51
|
+
gwaslab/viz_plot_forestplot.py,sha256=xgOnefh737CgdQxu5naVyRNBX1NQXPFKzf51fbh6afs,6771
|
|
52
52
|
gwaslab/viz_plot_miamiplot.py,sha256=rCFEp7VNuVqeBBG3WRkmFAtFklbF79BvIQQYiSY70VY,31238
|
|
53
53
|
gwaslab/viz_plot_miamiplot2.py,sha256=aJcA5eEY44VuGMZMBKM6aPE1D_D6w2O2Jmw5QwUoyik,15371
|
|
54
|
-
gwaslab/viz_plot_mqqplot.py,sha256=
|
|
54
|
+
gwaslab/viz_plot_mqqplot.py,sha256=nMorIAlepN2IpeWtCfinIzsEfLdjIBCvRSE12b-Rk2U,59112
|
|
55
55
|
gwaslab/viz_plot_qqplot.py,sha256=XVnNbX5oXk2yvXT4uSuGtWW1fbr_FzAlWNjRW_bWmyU,7012
|
|
56
|
-
gwaslab/viz_plot_regionalplot.py,sha256=
|
|
57
|
-
gwaslab/viz_plot_rg_heatmap.py,sha256=
|
|
56
|
+
gwaslab/viz_plot_regionalplot.py,sha256=oTY-5eAnPpKyiKBbgXMer2nJHwWT3HBQokxWMit_0Gs,37404
|
|
57
|
+
gwaslab/viz_plot_rg_heatmap.py,sha256=nibSCUnY_ZskCpJx7ppOgyqOuXBaWy6r7c_1McrQmZ0,13877
|
|
58
58
|
gwaslab/viz_plot_stackedregional.py,sha256=Ne7ncUN4iwmYKaDR8ZXeAFYPw29o_M2JzAnZRkyeMA0,9894
|
|
59
59
|
gwaslab/viz_plot_trumpetplot.py,sha256=YAcLDgqPr9JK0vKo_ZDtfKgkhHpQVOxeg2UnbQ2HsA8,37002
|
|
60
60
|
gwaslab/data/formatbook.json,sha256=oZSIk4-TX1_ODFwArhAeGB4f3N_c5HNOqQ9R4NceLL0,38181
|
|
@@ -65,8 +65,8 @@ gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz,sha256=qD9RsC5S2h6l-OdpW
|
|
|
65
65
|
gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz,sha256=Y8ZT2FIAhbhlgCJdE9qQVAiwnV_fcsPt72usBa7RSBM,10225828
|
|
66
66
|
gwaslab/data/high_ld/high_ld_hla_hg19.bed.gz,sha256=R7IkssKu0L4WwkU9SrS84xCMdrkkKL0gnTNO_OKbG0Y,219
|
|
67
67
|
gwaslab/data/high_ld/high_ld_hla_hg38.bed.gz,sha256=76CIU0pibDJ72Y6UY-TbIKE9gEPwTELAaIbCXyjm80Q,470
|
|
68
|
-
gwaslab-3.4.
|
|
69
|
-
gwaslab-3.4.
|
|
70
|
-
gwaslab-3.4.
|
|
71
|
-
gwaslab-3.4.
|
|
72
|
-
gwaslab-3.4.
|
|
68
|
+
gwaslab-3.4.37.dist-info/LICENSE,sha256=GhLOU_1UDEKeOacYhsRN_m9u-eIuVTazSndZPeNcTZA,1066
|
|
69
|
+
gwaslab-3.4.37.dist-info/METADATA,sha256=f_nK22RXPBbzF69Zhhx4eIQVIYhsHxZMmZnh5Jkb-wM,6806
|
|
70
|
+
gwaslab-3.4.37.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
71
|
+
gwaslab-3.4.37.dist-info/top_level.txt,sha256=PyY6hWtrALpv2MAN3kjkIAzJNmmBTH5a2risz9KwH08,8
|
|
72
|
+
gwaslab-3.4.37.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|