gwaslab 3.4.37__py3-none-any.whl → 3.4.39__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.

Files changed (57) hide show
  1. gwaslab/bd_common_data.py +6 -3
  2. gwaslab/bd_download.py +9 -9
  3. gwaslab/bd_get_hapmap3.py +43 -9
  4. gwaslab/data/formatbook.json +722 -721
  5. gwaslab/g_Log.py +22 -5
  6. gwaslab/g_Sumstats.py +110 -163
  7. gwaslab/g_SumstatsPair.py +76 -25
  8. gwaslab/g_SumstatsT.py +2 -2
  9. gwaslab/g_Sumstats_summary.py +3 -3
  10. gwaslab/g_version.py +10 -10
  11. gwaslab/hm_casting.py +36 -17
  12. gwaslab/hm_harmonize_sumstats.py +354 -221
  13. gwaslab/hm_rsid_to_chrpos.py +1 -1
  14. gwaslab/io_preformat_input.py +49 -43
  15. gwaslab/io_read_ldsc.py +49 -1
  16. gwaslab/io_to_formats.py +428 -295
  17. gwaslab/ldsc_irwls.py +198 -0
  18. gwaslab/ldsc_jackknife.py +514 -0
  19. gwaslab/ldsc_ldscore.py +417 -0
  20. gwaslab/ldsc_parse.py +294 -0
  21. gwaslab/ldsc_regressions.py +747 -0
  22. gwaslab/ldsc_sumstats.py +629 -0
  23. gwaslab/qc_check_datatype.py +3 -3
  24. gwaslab/qc_fix_sumstats.py +891 -778
  25. gwaslab/util_ex_calculate_ldmatrix.py +31 -13
  26. gwaslab/util_ex_gwascatalog.py +25 -25
  27. gwaslab/util_ex_ldproxyfinder.py +10 -10
  28. gwaslab/util_ex_ldsc.py +189 -0
  29. gwaslab/util_ex_process_ref.py +3 -3
  30. gwaslab/util_ex_run_coloc.py +26 -4
  31. gwaslab/util_in_calculate_gc.py +6 -6
  32. gwaslab/util_in_calculate_power.py +42 -43
  33. gwaslab/util_in_convert_h2.py +8 -8
  34. gwaslab/util_in_fill_data.py +30 -30
  35. gwaslab/util_in_filter_value.py +201 -74
  36. gwaslab/util_in_get_density.py +10 -10
  37. gwaslab/util_in_get_sig.py +445 -71
  38. gwaslab/viz_aux_annotate_plot.py +12 -12
  39. gwaslab/viz_aux_quickfix.py +42 -37
  40. gwaslab/viz_aux_reposition_text.py +10 -7
  41. gwaslab/viz_aux_save_figure.py +18 -8
  42. gwaslab/viz_plot_compare_af.py +32 -33
  43. gwaslab/viz_plot_compare_effect.py +63 -71
  44. gwaslab/viz_plot_miamiplot2.py +34 -26
  45. gwaslab/viz_plot_mqqplot.py +126 -75
  46. gwaslab/viz_plot_qqplot.py +11 -8
  47. gwaslab/viz_plot_regionalplot.py +36 -33
  48. gwaslab/viz_plot_rg_heatmap.py +28 -26
  49. gwaslab/viz_plot_stackedregional.py +40 -21
  50. gwaslab/viz_plot_trumpetplot.py +65 -61
  51. gwaslab-3.4.39.dist-info/LICENSE +674 -0
  52. {gwaslab-3.4.37.dist-info → gwaslab-3.4.39.dist-info}/METADATA +5 -4
  53. gwaslab-3.4.39.dist-info/RECORD +80 -0
  54. gwaslab-3.4.37.dist-info/RECORD +0 -72
  55. /gwaslab-3.4.37.dist-info/LICENSE → /gwaslab-3.4.39.dist-info/LICENSE_before_v3.4.39 +0 -0
  56. {gwaslab-3.4.37.dist-info → gwaslab-3.4.39.dist-info}/WHEEL +0 -0
  57. {gwaslab-3.4.37.dist-info → gwaslab-3.4.39.dist-info}/top_level.txt +0 -0
@@ -66,7 +66,7 @@ def plottrumpet(mysumstats,
66
66
  anno_source = "ensembl",
67
67
  anno_max_iter=100,
68
68
  arm_scale=1,
69
- repel_force=0.05,
69
+ repel_force=0.01,
70
70
  ylabel="Effect size",
71
71
  xlabel="Minor allele frequency",
72
72
  xticks = None,
@@ -99,7 +99,7 @@ def plottrumpet(mysumstats,
99
99
  xticks = [0,0.01,0.05,0.1,0.2,0.5]
100
100
  xticklabels = xticks
101
101
  if figargs is None:
102
- figargs={"figsize":(10,15)}
102
+ figargs={"figsize":(10,8)}
103
103
  if scatter_args is None:
104
104
  scatter_args ={}
105
105
  if hue is not None:
@@ -108,36 +108,34 @@ def plottrumpet(mysumstats,
108
108
  scatter_args["color"]=markercolor
109
109
 
110
110
  #Checking columns#################################################################################################################
111
- if verbose: log.write("Start to create trumpet plot...")
111
+ log.write("Start to create trumpet plot...", verbose=verbose)
112
112
 
113
113
  #parameter check##################################################################################################################
114
114
  if (beta not in mysumstats.columns) or (eaf not in mysumstats.columns):
115
- if verbose:
116
- log.write(" -No EAF or BETA columns. Skipping...")
115
+ log.write(" -No EAF or BETA columns. Skipping...", verbose=verbose)
117
116
  return None
118
117
  if mode=="b":
119
118
  if ncase is None or ncontrol is None:
120
- if verbose:
121
- log.write(" -No scase or scontrol. Skipping...")
119
+ log.write(" -No scase or scontrol. Skipping...", verbose=verbose)
122
120
  return None
123
121
  if prevalence is None:
124
122
  prevalence= ncase/(ncase + ncontrol)
125
- log.write(" -Prevalence is not given. Estimating based on scase and scontrol :{}...".format(prevalence))
123
+ log.write(" -Prevalence is not given. Estimating based on scase and scontrol :{}...".format(prevalence), verbose=verbose)
126
124
 
127
125
  #print settings##################################################################################################################
128
- if verbose:
129
- log.write(" -Settings:")
130
- log.write(" -Mode: {}".format(mode))
131
- if mode == "q" :
132
- log.write(" -N: {}".format(n))
133
- if mode == "b" :
134
- log.write(" -N_CASE: {}".format(ncase))
135
- log.write(" -N_CONTROL: {}".format(ncontrol))
136
- log.write(" -PREVALENCE: {}".format(prevalence))
137
- log.write(" -BETA: {}".format(beta))
138
- log.write(" -Significance level: {}".format(sig_level))
139
- log.write(" -Power thresholds: {}".format(ts))
140
- log.write(" -Power line smoothness: {}".format(n_matrix))
126
+
127
+ log.write(" -Settings:", verbose=verbose)
128
+ log.write(" -Mode: {}".format(mode), verbose=verbose)
129
+ if mode == "q" :
130
+ log.write(" -N: {}".format(n), verbose=verbose)
131
+ if mode == "b" :
132
+ log.write(" -N_CASE: {}".format(ncase), verbose=verbose)
133
+ log.write(" -N_CONTROL: {}".format(ncontrol), verbose=verbose)
134
+ log.write(" -PREVALENCE: {}".format(prevalence), verbose=verbose)
135
+ log.write(" -BETA: {}".format(beta), verbose=verbose)
136
+ log.write(" -Significance level: {}".format(sig_level), verbose=verbose)
137
+ log.write(" -Power thresholds: {}".format(ts), verbose=verbose)
138
+ log.write(" -Power line smoothness: {}".format(n_matrix), verbose=verbose)
141
139
 
142
140
  #loading columns #################################################################################################################
143
141
  cols_to_use = [snpid, beta, eaf, n, p]
@@ -145,7 +143,7 @@ def plottrumpet(mysumstats,
145
143
  if anno is not None:
146
144
  if anno != "GENENAME":
147
145
  if anno!=True:
148
- log.write(" -Loading column {} for annotation...".format(anno))
146
+ log.write(" -Loading column {} for annotation...".format(anno), verbose=verbose)
149
147
  if anno not in cols_to_use:
150
148
  cols_to_use.append(anno)
151
149
  else:
@@ -160,17 +158,17 @@ def plottrumpet(mysumstats,
160
158
  #filter by p #################################################################################################################
161
159
  if p in mysumstats.columns:
162
160
  sumstats = mysumstats.loc[mysumstats[p]< p_level,cols_to_use ].copy()
163
- if verbose: log.write(" -Excluding variants with P values > {}".format(p_level))
161
+ log.write(" -Excluding variants with P values > {}".format(p_level), verbose=verbose)
164
162
  else:
165
163
  cols_to_use.remove(p)
166
164
  sumstats = mysumstats[[beta,eaf,n]].copy()
167
- if verbose: log.write(" -Plotting {} variants...".format(len(sumstats)))
165
+ log.write(" -Plotting {} variants...".format(len(sumstats)), verbose=verbose)
168
166
 
169
167
  #add maf column #################################################################################################################
170
168
  if maf not in sumstats.columns:
171
169
  sumstats = filldata(sumstats,to_fill=["MAF"],verbose=False)
172
170
  is_filpped = (sumstats["MAF"] < sumstats[eaf]) & (sumstats[eaf] > 0.5)& (sumstats["MAF"] < 0.5)
173
- if verbose: log.write(" -Flipping {} variants...".format(sum(is_filpped)))
171
+ log.write(" -Flipping {} variants...".format(sum(is_filpped)), verbose=verbose)
174
172
  sumstats.loc[is_filpped, beta] = -sumstats.loc[is_filpped, beta]
175
173
 
176
174
  #configure n #################################################################################################################
@@ -185,8 +183,7 @@ def plottrumpet(mysumstats,
185
183
  n = sumstats["N"].median()
186
184
  elif n == "mean":
187
185
  n = sumstats["N"].mean()
188
- if verbose:
189
- log.write(" -N for power calculation: {}".format(n))
186
+ log.write(" -N for power calculation: {}".format(n), verbose=verbose)
190
187
 
191
188
  #configure beta and maf range ###################################################################################################
192
189
  if maf_range is None:
@@ -307,6 +304,7 @@ def plottrumpet(mysumstats,
307
304
 
308
305
  if ylim is not None:
309
306
  ax.set_ylim(ylim)
307
+
310
308
  if yticks is not None:
311
309
  ax.set_yticks(yticks, yticklabels)
312
310
 
@@ -337,8 +335,8 @@ def plottrumpet(mysumstats,
337
335
  texts_d=[]
338
336
 
339
337
  if len(variants_toanno)>0:
340
-
341
- maxy = max(variants_toanno[beta].abs().max(),1.5)
338
+ maxy = variants_toanno[beta].abs().max()
339
+ #maxy = max(variants_toanno[beta].abs().max(),1.5)
342
340
  variants_toanno["ADJUSTED_i"] = np.nan
343
341
  y_span = 0.5
344
342
 
@@ -348,6 +346,9 @@ def plottrumpet(mysumstats,
348
346
  variants_toanno = variants_toanno.sort_values(by=maf, key= np.abs, ascending = True)
349
347
 
350
348
  if anno_style == "expand":
349
+
350
+ min_factor=None
351
+
351
352
  if len(variants_toanno.loc[variants_toanno[beta]>0, "ADJUSTED_i"])>1:
352
353
  variants_toanno.loc[variants_toanno[beta]>0, "ADJUSTED_i"] = adjust_text_position(variants_toanno.loc[variants_toanno[beta]>0,maf].values.copy(),
353
354
  y_span,
@@ -355,7 +356,7 @@ def plottrumpet(mysumstats,
355
356
  max_iter=anno_max_iter,
356
357
  log=log,
357
358
  amode=xscale,
358
- verbose=verbose)
359
+ verbose=verbose,min_factor=min_factor)
359
360
 
360
361
  if len(variants_toanno.loc[variants_toanno[beta]<0, "ADJUSTED_i"])>1:
361
362
  variants_toanno.loc[variants_toanno[beta]<0, "ADJUSTED_i"] = adjust_text_position(variants_toanno.loc[variants_toanno[beta]<0,maf].values.copy(),
@@ -364,10 +365,12 @@ def plottrumpet(mysumstats,
364
365
  max_iter=anno_max_iter,
365
366
  log=log,
366
367
  amode=xscale,
367
- verbose=verbose)
368
+ verbose=verbose,min_factor=min_factor)
368
369
 
369
370
 
370
371
  for variants_toanno_half in [variants_toanno.loc[variants_toanno[beta]<0,:], variants_toanno.loc[variants_toanno[beta]>0,:]]:
372
+ if len(variants_toanno_half)<1:
373
+ continue
371
374
  last_pos = min(variants_toanno_half[maf])/2
372
375
  for index, row in variants_toanno_half.iterrows():
373
376
 
@@ -395,6 +398,7 @@ def plottrumpet(mysumstats,
395
398
 
396
399
  if anno_style=="tight":
397
400
  texts_d.append(ax.text(row[maf], row[beta], row[anno]))
401
+
398
402
  if anno_style=="tight":
399
403
  adjust_text(texts_d,
400
404
  autoalign =True,
@@ -404,13 +408,15 @@ def plottrumpet(mysumstats,
404
408
  expand_points=(0.5,0.5),
405
409
  force_objects=(0.5,0.5),
406
410
  ax=ax)
411
+
412
+
407
413
  ############ Annotation ##################################################################################################
408
414
  if mode=="q":
409
415
  save_figure(fig, save, keyword="trumpet_q",save_args=save_args, log=log, verbose=verbose)
410
416
  elif mode=="b":
411
417
  save_figure(fig, save, keyword="trumpet_b",save_args=save_args, log=log, verbose=verbose)
412
418
 
413
- if verbose: log.write("Finished creating trumpet plot!")
419
+ log.write("Finished creating trumpet plot!", verbose=verbose)
414
420
  return fig
415
421
 
416
422
  ####################################################################
@@ -460,12 +466,11 @@ def plot_power( ns=1000,
460
466
  xticklabels = xticks
461
467
 
462
468
  #Checking columns#################################################################################################################
463
- if verbose: log.write("Start to create trumpet plot...")
469
+ log.write("Start to create trumpet plot...", verbose=verbose)
464
470
 
465
471
  if mode=="b":
466
472
  if ncases is None or ncontrols is None:
467
- if verbose:
468
- log.write(" -No scase or scontrol. Skipping...")
473
+ log.write(" -No scase or scontrol. Skipping...", verbose=verbose)
469
474
  return None
470
475
 
471
476
  #configure beta and maf range ###################################################################################################
@@ -619,7 +624,7 @@ def plot_power( ns=1000,
619
624
  elif mode=="b":
620
625
  save_figure(fig, save, keyword="power_b",save_args=save_args, log=log, verbose=verbose)
621
626
 
622
- if verbose: log.write("Finished creating trumpet plot!")
627
+ log.write("Finished creating trumpet plot!", verbose=verbose)
623
628
  return fig
624
629
 
625
630
 
@@ -658,29 +663,29 @@ def plot_power_x(
658
663
  log=Log()):
659
664
 
660
665
  #Checking columns#################################################################################################################
661
- if verbose: log.write("Start to create power plot...")
666
+ log.write("Start to create power plot...", verbose=verbose)
662
667
  matplotlib.rc('font', family=font_family)
663
- if verbose:
664
- log.write(" -Settings:")
665
- log.write(" -Mode: {}".format(mode))
666
- if mode == "q" :
667
- log.write(" -X axis: {}".format(x))
668
- if x!="N":
669
- log.write(" -N: {}".format(ns))
670
- if x!="MAF":
671
- log.write(" -MAF: {}".format(mafs))
672
- if mode == "b" :
673
- log.write(" -X axis: {}".format(x))
674
- if x!="N_CASE":
675
- log.write(" -N_CASE: {}".format(ncases))
676
- if x!="N_CASE":
677
- log.write(" -N_CONTROL: {}".format(ncontrols))
678
- if x!="PREVALENCE":
679
- log.write(" -PREVALENCE: {}".format(prevalences))
680
- if x!="BETA":
681
- log.write(" -BETA: {}".format(betas))
682
-
683
- log.write(" -Significance level: {}".format(sig_levels))
668
+
669
+ log.write(" -Settings:", verbose=verbose)
670
+ log.write(" -Mode: {}".format(mode), verbose=verbose)
671
+ if mode == "q" :
672
+ log.write(" -X axis: {}".format(x), verbose=verbose)
673
+ if x!="N":
674
+ log.write(" -N: {}".format(ns), verbose=verbose)
675
+ if x!="MAF":
676
+ log.write(" -MAF: {}".format(mafs), verbose=verbose)
677
+ if mode == "b" :
678
+ log.write(" -X axis: {}".format(x), verbose=verbose)
679
+ if x!="N_CASE":
680
+ log.write(" -N_CASE: {}".format(ncases), verbose=verbose)
681
+ if x!="N_CASE":
682
+ log.write(" -N_CONTROL: {}".format(ncontrols), verbose=verbose)
683
+ if x!="PREVALENCE":
684
+ log.write(" -PREVALENCE: {}".format(prevalences), verbose=verbose)
685
+ if x!="BETA":
686
+ log.write(" -BETA: {}".format(betas), verbose=verbose)
687
+
688
+ log.write(" -Significance level: {}".format(sig_levels), verbose=verbose)
684
689
 
685
690
  if x is None:
686
691
  if mode=="b":
@@ -698,8 +703,7 @@ def plot_power_x(
698
703
 
699
704
  if mode=="b":
700
705
  if ncases is None or ncontrols is None:
701
- if verbose:
702
- log.write(" -No scase or scontrol. Skipping...")
706
+ log.write(" -No scase or scontrol. Skipping...", verbose=verbose)
703
707
  return None
704
708
 
705
709
  #configure beta and maf range ###################################################################################################
@@ -914,5 +918,5 @@ def plot_power_x(
914
918
  elif mode=="b":
915
919
  save_figure(fig, save, keyword="power_xb",save_args=save_args, log=log, verbose=verbose)
916
920
 
917
- if verbose: log.write("Finished creating power plot!")
921
+ log.write("Finished creating power plot!", verbose=verbose)
918
922
  return fig