gwaslab 3.5.7__tar.gz → 3.5.8__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.

Files changed (125) hide show
  1. {gwaslab-3.5.7/src/gwaslab.egg-info → gwaslab-3.5.8}/PKG-INFO +8 -6
  2. {gwaslab-3.5.7 → gwaslab-3.5.8}/README.md +5 -4
  3. {gwaslab-3.5.7 → gwaslab-3.5.8}/pyproject.toml +1 -1
  4. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/__init__.py +2 -0
  5. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/bd_common_data.py +1 -0
  6. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/bd_get_hapmap3.py +0 -1
  7. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/formatbook.json +78 -0
  8. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_Sumstats.py +98 -24
  9. gwaslab-3.5.8/src/gwaslab/g_SumstatsMulti.py +287 -0
  10. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_SumstatsPair.py +101 -16
  11. gwaslab-3.5.8/src/gwaslab/g_Sumstats_polars.py +245 -0
  12. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_headers.py +12 -3
  13. gwaslab-3.5.8/src/gwaslab/g_meta.py +135 -0
  14. gwaslab-3.5.8/src/gwaslab/g_meta_update.py +48 -0
  15. gwaslab-3.5.8/src/gwaslab/g_vchange_status_polars.py +44 -0
  16. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_version.py +2 -2
  17. gwaslab-3.5.8/src/gwaslab/hm_casting.py +315 -0
  18. gwaslab-3.5.8/src/gwaslab/hm_casting_polars.py +202 -0
  19. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/hm_harmonize_sumstats.py +19 -8
  20. gwaslab-3.5.8/src/gwaslab/io_load_ld.py +529 -0
  21. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_preformat_input.py +11 -0
  22. gwaslab-3.5.8/src/gwaslab/io_preformat_input_polars.py +632 -0
  23. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_process_args.py +25 -1
  24. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_read_ldsc.py +34 -3
  25. gwaslab-3.5.8/src/gwaslab/io_read_pipcs.py +79 -0
  26. gwaslab-3.5.8/src/gwaslab/prscs_gigrnd.py +122 -0
  27. gwaslab-3.5.8/src/gwaslab/prscs_mcmc_gtb.py +136 -0
  28. gwaslab-3.5.8/src/gwaslab/prscs_parse_genet.py +98 -0
  29. gwaslab-3.5.8/src/gwaslab/qc_build.py +53 -0
  30. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/qc_check_datatype.py +10 -8
  31. gwaslab-3.5.8/src/gwaslab/qc_check_datatype_polars.py +128 -0
  32. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/qc_fix_sumstats.py +25 -23
  33. gwaslab-3.5.8/src/gwaslab/qc_fix_sumstats_polars.py +193 -0
  34. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_calculate_ldmatrix.py +49 -19
  35. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_gwascatalog.py +71 -28
  36. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_ldsc.py +67 -21
  37. gwaslab-3.5.8/src/gwaslab/util_ex_match_ldmatrix.py +396 -0
  38. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_run_2samplemr.py +0 -2
  39. gwaslab-3.5.8/src/gwaslab/util_ex_run_ccgwas.py +155 -0
  40. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_run_coloc.py +1 -1
  41. gwaslab-3.5.8/src/gwaslab/util_ex_run_hyprcoloc.py +117 -0
  42. gwaslab-3.5.8/src/gwaslab/util_ex_run_mesusie.py +155 -0
  43. gwaslab-3.5.8/src/gwaslab/util_ex_run_mtag.py +92 -0
  44. gwaslab-3.5.8/src/gwaslab/util_ex_run_prscs.py +85 -0
  45. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_run_susie.py +40 -9
  46. gwaslab-3.5.8/src/gwaslab/util_in_estimate_ess.py +18 -0
  47. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_fill_data.py +20 -1
  48. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_filter_value.py +10 -5
  49. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_get_sig.py +71 -13
  50. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_meta.py +168 -4
  51. gwaslab-3.5.8/src/gwaslab/util_in_meta_polars.py +174 -0
  52. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_compare_effect.py +87 -23
  53. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_credible_sets.py +55 -11
  54. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_effect.py +22 -12
  55. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_miamiplot2.py +3 -2
  56. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_mqqplot.py +84 -81
  57. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_qqplot.py +6 -6
  58. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_regional2.py +2 -1
  59. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_stackedregional.py +4 -1
  60. {gwaslab-3.5.7 → gwaslab-3.5.8/src/gwaslab.egg-info}/PKG-INFO +8 -6
  61. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab.egg-info/SOURCES.txt +21 -0
  62. gwaslab-3.5.7/src/gwaslab/g_meta.py +0 -59
  63. gwaslab-3.5.7/src/gwaslab/hm_casting.py +0 -256
  64. gwaslab-3.5.7/src/gwaslab/io_read_pipcs.py +0 -23
  65. {gwaslab-3.5.7 → gwaslab-3.5.8}/LICENSE +0 -0
  66. {gwaslab-3.5.7 → gwaslab-3.5.8}/LICENSE_before_v3.4.39 +0 -0
  67. {gwaslab-3.5.7 → gwaslab-3.5.8}/setup.cfg +0 -0
  68. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/bd_config.py +0 -0
  69. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/bd_download.py +0 -0
  70. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/cache_manager.py +0 -0
  71. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/chrx_par/chrx_par_hg19.bed.gz +0 -0
  72. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/chrx_par/chrx_par_hg38.bed.gz +0 -0
  73. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz +0 -0
  74. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz +0 -0
  75. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/high_ld/high_ld_hla_hg19.bed.gz +0 -0
  76. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/high_ld/high_ld_hla_hg38.bed.gz +0 -0
  77. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/data/reference.json +0 -0
  78. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_Log.py +0 -0
  79. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_Phenotypes.py +0 -0
  80. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_SumstatsSet.py +0 -0
  81. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_SumstatsT.py +0 -0
  82. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_Sumstats_summary.py +0 -0
  83. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/g_vchange_status.py +0 -0
  84. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/hm_rsid_to_chrpos.py +0 -0
  85. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_read_tabular.py +0 -0
  86. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_to_formats.py +0 -0
  87. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/io_to_pickle.py +0 -0
  88. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_irwls.py +0 -0
  89. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_jackknife.py +0 -0
  90. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_ldscore.py +0 -0
  91. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_parse.py +0 -0
  92. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_regressions.py +0 -0
  93. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/ldsc_sumstats.py +0 -0
  94. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/run_script.py +0 -0
  95. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_abf_finemapping.py +0 -0
  96. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_calculate_prs.py +0 -0
  97. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_ldproxyfinder.py +0 -0
  98. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_plink_filter.py +0 -0
  99. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_process_h5.py +0 -0
  100. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_process_ref.py +0 -0
  101. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_ex_run_clumping.py +0 -0
  102. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_calculate_gc.py +0 -0
  103. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_calculate_power.py +0 -0
  104. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_convert_h2.py +0 -0
  105. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_correct_winnerscurse.py +0 -0
  106. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_get_density.py +0 -0
  107. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_merge.py +0 -0
  108. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/util_in_snphwe.py +0 -0
  109. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_annotate_plot.py +0 -0
  110. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_chromatin.py +0 -0
  111. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_property.py +0 -0
  112. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_quickfix.py +0 -0
  113. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_reposition_text.py +0 -0
  114. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_aux_save_figure.py +0 -0
  115. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_compare_af.py +0 -0
  116. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_forestplot.py +0 -0
  117. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_miamiplot.py +0 -0
  118. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_phe_heatmap.py +0 -0
  119. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_regionalplot.py +0 -0
  120. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_rg_heatmap.py +0 -0
  121. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_scatter_with_reg.py +0 -0
  122. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab/viz_plot_trumpetplot.py +0 -0
  123. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab.egg-info/dependency_links.txt +0 -0
  124. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab.egg-info/requires.txt +0 -0
  125. {gwaslab-3.5.7 → gwaslab-3.5.8}/src/gwaslab.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: gwaslab
3
- Version: 3.5.7
3
+ Version: 3.5.8
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/
@@ -25,15 +25,15 @@ Requires-Dist: scikit-allel>=1.3.5
25
25
  Requires-Dist: pyensembl==2.2.3
26
26
  Requires-Dist: gtfparse==1.3.0
27
27
  Requires-Dist: h5py>=3.10.0
28
+ Dynamic: license-file
28
29
 
29
30
  # GWASLab
30
31
 
31
- <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
32
+ <img width="600" alt="image" src="https://github.com/user-attachments/assets/109262c6-c870-4078-94b5-66cf8c6b13c4" />
32
33
 
33
34
  ![badge](https://img.shields.io/pypi/v/gwaslab)
34
35
  [![Downloads](https://static.pepy.tech/badge/gwaslab)](https://pepy.tech/project/gwaslab)
35
36
  ![badge_pip](https://img.shields.io/pypi/dm/gwaslab)
36
- [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fcloufield.github.io%2Fgwaslab%2F&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
37
37
  ![badge_commit_m](https://img.shields.io/github/commit-activity/m/Cloufield/gwaslab)
38
38
 
39
39
  * A handy Python toolkit for handling GWAS summary statistics (sumstats).
@@ -42,7 +42,7 @@ Requires-Dist: h5py>=3.10.0
42
42
 
43
43
  Please check GWASLab documentation at [https://cloufield.github.io/gwaslab/](https://cloufield.github.io/gwaslab/)
44
44
 
45
- Note: GWASLab is being updated very frequently for now. I will release the first stable version soon! Please stay tuned.
45
+ Note: GWASLab is being updated very frequently for now. We will release the first stable version soon! Please stay tuned.
46
46
 
47
47
  Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/gwaslab/KnownIssues/](https://cloufield.github.io/gwaslab/KnownIssues/) .
48
48
 
@@ -50,8 +50,10 @@ Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/
50
50
 
51
51
  ### install via pip
52
52
 
53
+ The latest version of GWASLab now supports Python 3.9, 3.10, 3.11, and 3.12.
54
+
53
55
  ```
54
- pip install gwaslab==3.5.4
56
+ pip install gwaslab==3.5.7
55
57
  ```
56
58
 
57
59
  ```python
@@ -1,11 +1,10 @@
1
1
  # GWASLab
2
2
 
3
- <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
3
+ <img width="600" alt="image" src="https://github.com/user-attachments/assets/109262c6-c870-4078-94b5-66cf8c6b13c4" />
4
4
 
5
5
  ![badge](https://img.shields.io/pypi/v/gwaslab)
6
6
  [![Downloads](https://static.pepy.tech/badge/gwaslab)](https://pepy.tech/project/gwaslab)
7
7
  ![badge_pip](https://img.shields.io/pypi/dm/gwaslab)
8
- [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fcloufield.github.io%2Fgwaslab%2F&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
9
8
  ![badge_commit_m](https://img.shields.io/github/commit-activity/m/Cloufield/gwaslab)
10
9
 
11
10
  * A handy Python toolkit for handling GWAS summary statistics (sumstats).
@@ -14,7 +13,7 @@
14
13
 
15
14
  Please check GWASLab documentation at [https://cloufield.github.io/gwaslab/](https://cloufield.github.io/gwaslab/)
16
15
 
17
- Note: GWASLab is being updated very frequently for now. I will release the first stable version soon! Please stay tuned.
16
+ Note: GWASLab is being updated very frequently for now. We will release the first stable version soon! Please stay tuned.
18
17
 
19
18
  Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/gwaslab/KnownIssues/](https://cloufield.github.io/gwaslab/KnownIssues/) .
20
19
 
@@ -22,8 +21,10 @@ Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/
22
21
 
23
22
  ### install via pip
24
23
 
24
+ The latest version of GWASLab now supports Python 3.9, 3.10, 3.11, and 3.12.
25
+
25
26
  ```
26
- pip install gwaslab==3.5.4
27
+ pip install gwaslab==3.5.7
27
28
  ```
28
29
 
29
30
  ```python
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "gwaslab"
10
- version = "3.5.7"
10
+ version = "3.5.8"
11
11
  authors = [
12
12
  { name="Yunye", email="yunye@gwaslab.com" },
13
13
  ]
@@ -1,6 +1,8 @@
1
1
  from gwaslab.g_Sumstats import Sumstats
2
+ from gwaslab.g_Sumstats_polars import Sumstatsp
2
3
  from gwaslab.g_SumstatsT import SumstatsT
3
4
  from gwaslab.g_SumstatsPair import SumstatsPair
5
+ from gwaslab.g_SumstatsMulti import SumstatsMulti
4
6
  from gwaslab.util_in_convert_h2 import h2_obs_to_liab
5
7
  from gwaslab.util_in_convert_h2 import _get_per_snp_r2
6
8
  from gwaslab.util_in_convert_h2 import h2_se_to_p
@@ -337,6 +337,7 @@ def _maketrans(complement_mapping):
337
337
  """
338
338
  keys = "".join(complement_mapping.keys()).encode("ASCII")
339
339
  values = "".join(complement_mapping.values()).encode("ASCII")
340
+
340
341
  return bytes.maketrans(keys + keys.lower(), values + values.lower())
341
342
 
342
343
  ####################################################################################################################
@@ -43,7 +43,6 @@ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",b
43
43
  else:
44
44
  additional_cols=[]
45
45
  hapmap3_ref = pd.read_csv(data_path,sep="\s+",usecols=["#CHROM","POS","rsid"]+additional_cols, dtype={"#CHROM":"string","POS":"string"})
46
-
47
46
  #rsid A1 A2 #CHROM POS
48
47
  #rs3094315 G A 1 752566
49
48
 
@@ -237,6 +237,16 @@
237
237
  "TotalSampleSize": "N",
238
238
  "Nsample": "N",
239
239
  "num_samples": "N",
240
+ "Neff": "N_EFF",
241
+ "N_EFF": "N_EFF",
242
+ "N_CASE": "N_CASE",
243
+ "Ncase": "N_CASE",
244
+ "ncase": "N_CASE",
245
+ "n_case": "N_CASE",
246
+ "Ncontrol": "N_CONTROL",
247
+ "N_control": "N_CONTROL",
248
+ "N_Control": "N_CONTROL",
249
+ "NCONTROL": "N_CONTROL",
240
250
  "beta": "BETA",
241
251
  "BETA": "BETA",
242
252
  "Beta": "BETA",
@@ -461,6 +471,31 @@
461
471
  "Direction": "DIRECTION"
462
472
  }
463
473
  },
474
+ "genomicsem": {
475
+ "meta_data": {
476
+ "format_name": "genomicSEM",
477
+ "format_source": "https://github.com/GenomicSEM/GenomicSEM/wiki/4.-Common-Factor-GWAS",
478
+ "format_source2": "https://github.com/GenomicSEM/GenomicSEM/wiki/5.-Multivariate-GWAS",
479
+ "format_version": 20241210
480
+ },
481
+ "format_dict": {
482
+ "SNP": "rsID",
483
+ "A2": "NEA",
484
+ "A1": "EA",
485
+ "Frq": "EAF",
486
+ "MAF": "MAF",
487
+ "N": "N",
488
+ "est": "BETA",
489
+ "se_c": "SE",
490
+ "Pval_Estimate": "P",
491
+ "Z_Estimate": "Z",
492
+ "Q": "Q",
493
+ "Q_df": "DOF",
494
+ "Q_pval": "P_HET",
495
+ "CHR": "CHR",
496
+ "BP": "POS"
497
+ }
498
+ },
464
499
  "plink_fam": {
465
500
  "meta_data": {
466
501
  "format_name": "plink_fam",
@@ -880,6 +915,21 @@
880
915
  "POS": "POS"
881
916
  }
882
917
  },
918
+ "mesusie": {
919
+ "meta_data": {
920
+ "format_name": "MESuSiE",
921
+ "format_source": "https://borangao.github.io/meSuSie_Analysis/installation.html",
922
+ "format_version": 20221109
923
+ },
924
+ "format_dict": {
925
+ "SNP": "SNPID",
926
+ "N": "N",
927
+ "Beta": "BETA",
928
+ "Se": "SE",
929
+ "Z": "Z",
930
+ "POS": "POS"
931
+ }
932
+ },
883
933
  "plink2_linear": {
884
934
  "meta_data": {
885
935
  "format_name": "PLINK2 .glm.linear",
@@ -1032,6 +1082,34 @@
1032
1082
  "ci_upper": "OR_95U"
1033
1083
  }
1034
1084
  },
1085
+ "ccgwas": {
1086
+ "meta_data": {
1087
+ "format_name": "CCGWAS",
1088
+ "format_source": "https://github.com/wouterpeyrot/CCGWAS",
1089
+ "format_version": "20220901",
1090
+ "last_check_date": "20250416",
1091
+ "format_separator": "\t",
1092
+ "format_citation": "Peyrot, W. J., & Price, A. L. (2021). Identifying loci with different allele frequencies among cases of eight psychiatric disorders using CC-GWAS. Nature genetics, 53(4), 445-454.",
1093
+ "format_comment": null,
1094
+ "format_na": null,
1095
+ "format_other_cols": [
1096
+ "Exact_beta",
1097
+ "Exact_se",
1098
+ "Exact_pval",
1099
+ "CCGWAS_signif"
1100
+ ]
1101
+ },
1102
+ "format_dict": {
1103
+ "SNP": "SNPID",
1104
+ "CHR": "CHR",
1105
+ "BP": "POS",
1106
+ "A2": "NEA",
1107
+ "A1": "EA",
1108
+ "OLS_beta": "BETA",
1109
+ "OLS_se": "SE",
1110
+ "OLS_pval": "P"
1111
+ }
1112
+ },
1035
1113
  "fastgwa": {
1036
1114
  "meta_data": {
1037
1115
  "format_name": "fastgwa",
@@ -39,6 +39,7 @@ from gwaslab.util_in_filter_value import filterregionout
39
39
  from gwaslab.util_in_filter_value import _filter_indel
40
40
  from gwaslab.util_in_filter_value import _filter_palindromic
41
41
  from gwaslab.util_in_filter_value import _filter_snp
42
+ from gwaslab.util_in_filter_value import _filter_region
42
43
  from gwaslab.util_in_filter_value import _exclude_hla
43
44
  from gwaslab.util_in_filter_value import _search_variants
44
45
  from gwaslab.util_in_filter_value import inferbuild
@@ -67,13 +68,16 @@ from gwaslab.g_version import _show_version
67
68
  from gwaslab.g_version import gwaslab_info
68
69
  from gwaslab.g_meta import _init_meta
69
70
  from gwaslab.g_meta import _append_meta_record
71
+ from gwaslab.g_meta_update import _update_meta
70
72
  from gwaslab.util_ex_run_clumping import _clump
71
73
  from gwaslab.util_ex_calculate_ldmatrix import tofinemapping
74
+ from gwaslab.io_load_ld import tofinemapping_using_ld
72
75
  from gwaslab.util_ex_calculate_prs import _calculate_prs
73
76
  from gwaslab.viz_plot_mqqplot import mqqplot
74
77
  from gwaslab.viz_plot_trumpetplot import plottrumpet
75
78
  from gwaslab.viz_plot_compare_af import plotdaf
76
79
  from gwaslab.util_ex_run_susie import _run_susie_rss
80
+ from gwaslab.util_ex_run_susie import _get_cs_lead
77
81
  from gwaslab.qc_fix_sumstats import _check_data_consistency
78
82
  from gwaslab.util_ex_ldsc import _estimate_h2_by_ldsc
79
83
  from gwaslab.util_ex_ldsc import _estimate_rg_by_ldsc
@@ -84,9 +88,13 @@ from gwaslab.bd_get_hapmap3 import gethapmap3
84
88
  from gwaslab.util_abf_finemapping import abf_finemapping
85
89
  from gwaslab.util_abf_finemapping import make_cs
86
90
  from gwaslab.io_read_pipcs import _read_pipcs
91
+ from gwaslab.util_in_estimate_ess import _get_ess
87
92
  from gwaslab.viz_plot_credible_sets import _plot_cs
93
+ from gwaslab.hm_casting import _align_with_mold
94
+ from gwaslab.hm_casting import _merge_mold_with_sumstats_by_chrpos
88
95
  import gc
89
96
  from gwaslab.viz_plot_phe_heatmap import _gwheatmap
97
+ from gwaslab.util_ex_run_prscs import _run_prscs
90
98
 
91
99
  #20220309
92
100
  class Sumstats():
@@ -113,6 +121,7 @@ class Sumstats():
113
121
  f=None,
114
122
  t=None,
115
123
  p=None,
124
+ q=None,
116
125
  mlog10p=None,
117
126
  test=None,
118
127
  info=None,
@@ -126,6 +135,7 @@ class Sumstats():
126
135
  HR_95U=None,
127
136
  ncase=None,
128
137
  ncontrol=None,
138
+ neff=None,
129
139
  i2=None,
130
140
  phet=None,
131
141
  dof=None,
@@ -149,7 +159,7 @@ class Sumstats():
149
159
  self.log = Log()
150
160
  self.ldsc_h2 = None
151
161
  self.ldsc_h2_results = None
152
- self.ldsc_rg = None
162
+ self.ldsc_rg = pd.DataFrame()
153
163
  self.ldsc_h2_cts = None
154
164
  self.ldsc_partitioned_h2_summary = None
155
165
  self.ldsc_partitioned_h2_results = None
@@ -200,6 +210,7 @@ class Sumstats():
200
210
  f=f,
201
211
  t=t,
202
212
  p=p,
213
+ q=q,
203
214
  mlog10p=mlog10p,
204
215
  test=test,
205
216
  info=info,
@@ -217,6 +228,7 @@ class Sumstats():
217
228
  snpr2=snpr2,
218
229
  ncase=ncase,
219
230
  ncontrol=ncontrol,
231
+ neff=neff,
220
232
  direction=direction,
221
233
  study=study,
222
234
  build=build,
@@ -243,18 +255,8 @@ class Sumstats():
243
255
  gc.collect()
244
256
 
245
257
  #### healper #################################################################################
246
- def update_meta(self):
247
- self.meta["gwaslab"]["variants"]["variant_number"]=len(self.data)
248
- if "CHR" in self.data.columns:
249
- self.meta["gwaslab"]["variants"]["number_of_chromosomes"]=len(self.data["CHR"].unique())
250
- if "P" in self.data.columns:
251
- self.meta["gwaslab"]["variants"]["min_P"]=np.min(self.data["P"])
252
- if "EAF" in self.data.columns:
253
- self.meta["gwaslab"]["variants"]["min_minor_allele_freq"]=min (np.min(self.data["EAF"]) , 1- np.max(self.data["EAF"]))
254
- if "N" in self.data.columns:
255
- self.meta["gwaslab"]["samples"]["sample_size"] = int(self.data["N"].max())
256
- self.meta["gwaslab"]["samples"]["sample_size_median"] = self.data["N"].median()
257
- self.meta["gwaslab"]["samples"]["sample_size_min"] = int(self.data["N"].min())
258
+ def update_meta(self, **kwargs):
259
+ self.meta = _update_meta(self.meta, self.data,log = self.log, **kwargs)
258
260
 
259
261
  def summary(self):
260
262
  return summarize(self.data)
@@ -363,7 +365,8 @@ class Sumstats():
363
365
  self.data = parallelnormalizeallele(self.data,log=self.log,n_cores=n_cores,**normalizeallele_args)
364
366
 
365
367
  self.data = sortcolumn(self.data,log=self.log)
366
-
368
+
369
+ self.data = sortcoordinate(self.data,log=self.log)
367
370
  gc.collect()
368
371
 
369
372
  #####################################################
@@ -380,6 +383,7 @@ class Sumstats():
380
383
  # 3.2 infer strand for palindromic SNP (target build)
381
384
  #####################################################
382
385
  if ref_seq is not None:
386
+
383
387
  if ref_seq_mode=="v":
384
388
  self.data = checkref(self.data,ref_seq,log=self.log,**checkref_args)
385
389
  elif ref_seq_mode=="s":
@@ -441,6 +445,20 @@ class Sumstats():
441
445
  self.meta["is_sorted"] = True
442
446
  self.meta["is_harmonised"] = True
443
447
  return self
448
+
449
+ def align_with_template(self, template, **kwargs):
450
+ ## merge
451
+ molded_sumstats, sumstats1 = _merge_mold_with_sumstats_by_chrpos(mold=template,
452
+ sumstats=self.data,
453
+ log=self.log,
454
+ suffixes=("_MOLD",""),
455
+ return_not_matched_mold = True)
456
+ ## align
457
+ aligned_data = _align_with_mold(molded_sumstats)
458
+
459
+ ## flip
460
+ self.data =flipallelestats(aligned_data, log=self.log)
461
+
444
462
  ############################################################################################################
445
463
  #customizable API to build your own QC pipeline
446
464
  def fix_id(self,**kwargs):
@@ -507,6 +525,15 @@ class Sumstats():
507
525
 
508
526
  # utilities ############################################################################################################
509
527
  # filter series ######################################################################
528
+
529
+ def filter_region(self, inplace=False,**kwargs):
530
+ if inplace is False:
531
+ new_Sumstats_object = copy.deepcopy(self)
532
+ new_Sumstats_object.data = _filter_region(new_Sumstats_object.data, **kwargs)
533
+ return new_Sumstats_object
534
+ else:
535
+ self.data = _filter_region(self.data, **kwargs)
536
+
510
537
  def filter_flanking(self, inplace=False,**kwargs):
511
538
  if inplace is False:
512
539
  new_Sumstats_object = copy.deepcopy(self)
@@ -749,6 +776,7 @@ class Sumstats():
749
776
  chrom="CHR",
750
777
  pos="POS",
751
778
  p="P",
779
+ build=self.meta["gwaslab"]["genome_build"],
752
780
  log=self.log,
753
781
  **kwargs)
754
782
  # return sumstats object
@@ -789,7 +817,22 @@ class Sumstats():
789
817
  **kwargs)
790
818
  # return sumstats object
791
819
  return output
792
-
820
+
821
+ def check_cs_overlap(self, **kwargs):
822
+ if "SNPID" in self.pipcs.columns:
823
+ id_to_use = "SNPID"
824
+ else:
825
+ id_to_use = "rsID"
826
+ output = _check_novel_set(self.pipcs,
827
+ id=id_to_use,
828
+ chrom="CHR",
829
+ pos="POS",
830
+ p="P",
831
+ log=self.log,
832
+ **kwargs)
833
+ # return sumstats object
834
+ return output
835
+
793
836
  def anno_gene(self, **kwargs):
794
837
  if "SNPID" in self.data.columns:
795
838
  id_to_use = "SNPID"
@@ -806,6 +849,9 @@ class Sumstats():
806
849
  def get_per_snp_r2(self,**kwargs):
807
850
  self.data = _get_per_snp_r2(self.data, beta="BETA", af="EAF", n="N", log=self.log, **kwargs)
808
851
  #add data inplace
852
+
853
+ def get_ess(self, **kwargs):
854
+ self.data = _get_ess(self.data, log=self.log, **kwargs)
809
855
 
810
856
  def get_gc(self, mode=None, **kwargs):
811
857
  if mode is None:
@@ -831,40 +877,67 @@ class Sumstats():
831
877
  credible_sets = make_cs(region_data,threshold=0.95,log=self.log)
832
878
  return region_data, credible_sets
833
879
 
880
+ ######################################################################################################
881
+ def run_prscs(self, build=None, verbose=True, match_allele=True, how="inner", **kwargs):
882
+ if build is None:
883
+ build = self.meta["gwaslab"]["genome_build"]
884
+ insumstats = gethapmap3(self.data.copy(), build=build, verbose=verbose , match_allele=match_allele, how=how )
885
+ _run_prscs(sst_file = insumstats[["rsID","CHR","POS","EA","NEA","BETA","SE"]], log=self.log, **kwargs)
834
886
 
835
887
  ## LDSC ##############################################################################################
836
888
  def estimate_h2_by_ldsc(self, build=None, verbose=True, match_allele=True, how="right", **kwargs):
837
889
  if build is None:
838
890
  build = self.meta["gwaslab"]["genome_build"]
839
891
  insumstats = gethapmap3(self.data.copy(), build=build, verbose=verbose , match_allele=match_allele, how=how )
840
- self.ldsc_h2, self.ldsc_h2_results = _estimate_h2_by_ldsc(insumstats=insumstats, log=self.log, verbose=verbose, **kwargs)
892
+ self.ldsc_h2, self.ldsc_h2_results = _estimate_h2_by_ldsc(insumstats=insumstats,
893
+ meta=self.meta,
894
+ log=self.log,
895
+ verbose=verbose,
896
+ **kwargs)
841
897
 
842
898
  def estimate_rg_by_ldsc(self, build=None, verbose=True, match_allele=True, how="right",**kwargs):
843
899
  if build is None:
844
900
  build = self.meta["gwaslab"]["genome_build"]
845
901
  insumstats = gethapmap3(self.data.copy(), build=build, verbose=verbose , match_allele=match_allele, how=how )
846
- self.ldsc_rg = _estimate_rg_by_ldsc(insumstats=insumstats, log=self.log, verbose=verbose, **kwargs)
902
+ ldsc_rg = _estimate_rg_by_ldsc(insumstats=insumstats,
903
+ meta=self.meta,
904
+ log=self.log,
905
+ verbose=verbose,
906
+ **kwargs)
907
+ self.ldsc_rg = pd.concat([self.ldsc_rg, ldsc_rg],ignore_index=True)
847
908
 
848
909
  def estimate_h2_cts_by_ldsc(self, build=None, verbose=True, match_allele=True, how="right",**kwargs):
849
910
  if build is None:
850
911
  build = self.meta["gwaslab"]["genome_build"]
851
912
  insumstats = gethapmap3(self.data.copy(), build=build, verbose=verbose , match_allele=match_allele, how=how )
852
- self.ldsc_h2_cts = _estimate_h2_cts_by_ldsc(insumstats=insumstats, log=self.log, verbose=verbose, **kwargs)
913
+ self.ldsc_h2_cts = _estimate_h2_cts_by_ldsc(insumstats=insumstats,
914
+ log=self.log,
915
+ verbose=verbose,
916
+ **kwargs)
853
917
 
854
918
  def estimate_partitioned_h2_by_ldsc(self, build=None, verbose=True, match_allele=True, how="right",**kwargs):
855
919
  if build is None:
856
920
  build = self.meta["gwaslab"]["genome_build"]
857
921
  insumstats = gethapmap3(self.data.copy(), build=build, verbose=verbose , match_allele=match_allele, how=how )
858
- self.ldsc_partitioned_h2_summary, self.ldsc_partitioned_h2_results = _estimate_partitioned_h2_by_ldsc(insumstats=insumstats, log=self.log, verbose=verbose, **kwargs)
922
+ self.ldsc_partitioned_h2_summary, self.ldsc_partitioned_h2_results = _estimate_partitioned_h2_by_ldsc(insumstats=insumstats,
923
+ meta=self.meta,
924
+ log=self.log,
925
+ verbose=verbose,
926
+ **kwargs)
859
927
  # external ################################################################################################
860
928
 
861
929
  def calculate_ld_matrix(self,**kwargs):
862
930
  self.finemapping["path"],self.finemapping["file"],self.finemapping["plink_log"]= tofinemapping(self.data,study = self.meta["gwaslab"]["study_name"],**kwargs)
863
931
  #self.to_finemapping_file_path, self.to_finemapping_file, self.plink_log = tofinemapping(self.data,study = self.meta["gwaslab"]["study_name"],**kwargs)
864
-
932
+ def extract_ld_matrix(self,**kwargs):
933
+ self.finemapping["path"],self.finemapping["file"],self.finemapping["plink_log"]= tofinemapping_using_ld(self.data,study = self.meta["gwaslab"]["study_name"],**kwargs)
934
+
865
935
  def run_susie_rss(self,**kwargs):
866
- self.pipcs=_run_susie_rss(self.finemapping["path"],**kwargs)
936
+ self.pipcs=_run_susie_rss(self.finemapping["path"], main_sumstats = self.data[["SNPID","CHR","POS"]], **kwargs)
937
+ self.finemapping["pipcs"] = self.pipcs
867
938
  #self.pipcs=_run_susie_rss(self.to_finemapping_file_path,**kwargs)
939
+ def get_cs_lead(self,**kwargs):
940
+ return _get_cs_lead(self.pipcs,**kwargs)
868
941
 
869
942
  def clump(self,**kwargs):
870
943
  self.clumps["clumps"], self.clumps["clumps_raw"], self.clumps["plink_log"] = _clump(self.data, log=self.log, study = self.meta["gwaslab"]["study_name"], **kwargs)
@@ -875,10 +948,11 @@ class Sumstats():
875
948
 
876
949
  # loading aux data
877
950
  def read_pipcs(self,prefix,**kwargs):
878
- self.pipcs = _read_pipcs(self.data[["SNPID","CHR","POS"]],prefix, **kwargs)
951
+ self.pipcs = _read_pipcs(self.data[["SNPID","CHR","POS"]],prefix, study= self.meta["gwaslab"]["study_name"], **kwargs)
952
+ self.finemapping["pipcs"] = self.pipcs
879
953
 
880
- def plot_pipcs(self, region,**kwargs):
881
- _plot_cs(self.pipcs, region, **kwargs)
954
+ def plot_pipcs(self, region=None, locus=None, **kwargs):
955
+ _plot_cs(self.pipcs, region=region,locus=locus, **kwargs)
882
956
  # to_format ###############################################################################################
883
957
 
884
958
  def to_format(self, path, build=None, verbose=True, **kwargs):