gwaslab 3.4.40__tar.gz → 3.4.42__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 (85) hide show
  1. {gwaslab-3.4.40/src/gwaslab.egg-info → gwaslab-3.4.42}/PKG-INFO +33 -5
  2. {gwaslab-3.4.40 → gwaslab-3.4.42}/README.md +32 -4
  3. {gwaslab-3.4.40 → gwaslab-3.4.42}/pyproject.toml +1 -1
  4. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/bd_common_data.py +14 -1
  5. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/bd_get_hapmap3.py +7 -3
  6. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_Sumstats.py +156 -138
  7. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_SumstatsPair.py +15 -15
  8. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_version.py +2 -2
  9. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/hm_harmonize_sumstats.py +365 -12
  10. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/io_read_tabular.py +7 -7
  11. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/io_to_formats.py +96 -21
  12. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/io_to_pickle.py +1 -1
  13. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_ldscore.py +1 -1
  14. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/qc_fix_sumstats.py +2 -2
  15. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_calculate_ldmatrix.py +2 -2
  16. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_calculate_prs.py +2 -2
  17. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_ldsc.py +163 -110
  18. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_plink_filter.py +2 -2
  19. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_run_clumping.py +2 -2
  20. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_filter_value.py +27 -9
  21. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_regionalplot.py +2 -2
  22. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_trumpetplot.py +115 -4
  23. {gwaslab-3.4.40 → gwaslab-3.4.42/src/gwaslab.egg-info}/PKG-INFO +33 -5
  24. {gwaslab-3.4.40 → gwaslab-3.4.42}/LICENSE +0 -0
  25. {gwaslab-3.4.40 → gwaslab-3.4.42}/LICENSE_before_v3.4.39 +0 -0
  26. {gwaslab-3.4.40 → gwaslab-3.4.42}/setup.cfg +0 -0
  27. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/__init__.py +0 -0
  28. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/bd_config.py +0 -0
  29. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/bd_download.py +0 -0
  30. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/chrx_par/chrx_par_hg19.bed.gz +0 -0
  31. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/chrx_par/chrx_par_hg38.bed.gz +0 -0
  32. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/formatbook.json +0 -0
  33. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db150_hg19.snplist.gz +0 -0
  34. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/hapmap3_SNPs/hapmap3_db151_hg38.snplist.gz +0 -0
  35. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/high_ld/high_ld_hla_hg19.bed.gz +0 -0
  36. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/high_ld/high_ld_hla_hg38.bed.gz +0 -0
  37. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/data/reference.json +0 -0
  38. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_Log.py +0 -0
  39. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_Phenotypes.py +0 -0
  40. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_SumstatsT.py +0 -0
  41. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_Sumstats_summary.py +0 -0
  42. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_meta.py +0 -0
  43. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/g_vchange_status.py +0 -0
  44. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/hm_casting.py +0 -0
  45. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/hm_rsid_to_chrpos.py +0 -0
  46. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/io_preformat_input.py +0 -0
  47. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/io_read_ldsc.py +0 -0
  48. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_irwls.py +0 -0
  49. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_jackknife.py +0 -0
  50. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_parse.py +0 -0
  51. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_regressions.py +0 -0
  52. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/ldsc_sumstats.py +0 -0
  53. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/qc_check_datatype.py +0 -0
  54. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/run_script.py +0 -0
  55. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_gwascatalog.py +0 -0
  56. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_ldproxyfinder.py +0 -0
  57. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_process_h5.py +0 -0
  58. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_process_ref.py +0 -0
  59. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_run_2samplemr.py +0 -0
  60. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_run_coloc.py +0 -0
  61. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_ex_run_susie.py +0 -0
  62. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_calculate_gc.py +0 -0
  63. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_calculate_power.py +0 -0
  64. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_convert_h2.py +0 -0
  65. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_correct_winnerscurse.py +0 -0
  66. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_fill_data.py +0 -0
  67. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_get_density.py +0 -0
  68. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/util_in_get_sig.py +0 -0
  69. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_aux_annotate_plot.py +0 -0
  70. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_aux_quickfix.py +0 -0
  71. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_aux_reposition_text.py +0 -0
  72. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_aux_save_figure.py +0 -0
  73. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_compare_af.py +0 -0
  74. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_compare_effect.py +0 -0
  75. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_forestplot.py +0 -0
  76. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_miamiplot.py +0 -0
  77. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_miamiplot2.py +0 -0
  78. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_mqqplot.py +0 -0
  79. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_qqplot.py +0 -0
  80. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_rg_heatmap.py +0 -0
  81. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab/viz_plot_stackedregional.py +0 -0
  82. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab.egg-info/SOURCES.txt +0 -0
  83. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab.egg-info/dependency_links.txt +0 -0
  84. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab.egg-info/requires.txt +0 -0
  85. {gwaslab-3.4.40 → gwaslab-3.4.42}/src/gwaslab.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gwaslab
3
- Version: 3.4.40
3
+ Version: 3.4.42
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,10 +25,10 @@ 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
 
28
- <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
29
-
30
28
  # GWASLab
31
29
 
30
+ <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
31
+
32
32
  ![badge](https://img.shields.io/pypi/v/gwaslab)
33
33
  [![Downloads](https://static.pepy.tech/badge/gwaslab)](https://pepy.tech/project/gwaslab)
34
34
  ![badge_pip](https://img.shields.io/pypi/dm/gwaslab)
@@ -40,15 +40,19 @@ Requires-Dist: gtfparse==1.3.0
40
40
  * Sumstats-specific manipulations are designed as methods of a Python object, `gwaslab.Sumstats`.
41
41
 
42
42
  Please check GWASLab documentation at [https://cloufield.github.io/gwaslab/](https://cloufield.github.io/gwaslab/)
43
+
43
44
  Note: GWASLab is being updated very frequently for now. I will release the first stable version soon! Please stay tuned.
44
45
 
46
+ Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/gwaslab/KnownIssues/](https://cloufield.github.io/gwaslab/KnownIssues/) .
47
+
45
48
  ## Install
46
49
 
50
+ ### install via pip
51
+
47
52
  ```
48
- pip install gwaslab==3.4.39
53
+ pip install gwaslab==3.4.41
49
54
  ```
50
55
 
51
-
52
56
  ```python
53
57
  import gwaslab as gl
54
58
  # load plink2 output
@@ -78,6 +82,27 @@ mysumstats.plot_mqq()
78
82
  ...
79
83
  ```
80
84
 
85
+ ### install in conda environment
86
+
87
+ Create a Python 3.9 environment and install gwaslab using pip:
88
+
89
+ ```
90
+ conda env create -n gwaslab_test -c conda-forge python=3.9
91
+ conda activate gwaslab
92
+ pip install gwaslab==3.4.41
93
+ ```
94
+
95
+ or create a new environment using yml file [environment_3.4.40.yml](https://github.com/Cloufield/gwaslab/blob/main/environment_3.4.40.yml)
96
+
97
+ ```
98
+ conda env create -n gwaslab -f environment_3.4.40.yml
99
+ ```
100
+
101
+
102
+ ### install using docker
103
+
104
+ A docker file is available [here](https://github.com/Cloufield/gwaslab/blob/main/docker/Dockerfile) for building local images.
105
+
81
106
  ## Functions
82
107
 
83
108
  ### Loading and Formatting
@@ -176,6 +201,9 @@ dependencies:
176
201
  ## Sample Data
177
202
  - Sample GWAS data used in GWASLab is obtained from: http://jenger.riken.jp/ (Suzuki, Ken, et al. "Identification of 28 new susceptibility loci for type 2 diabetes in the Japanese population." Nature genetics 51.3 (2019): 379-386.).
178
203
 
204
+ ## Acknowledgement
205
+
206
+ Thanks to @sup3rgiu, @soumickmj and @gmauro for their contributions to the source codes.
179
207
 
180
208
  ## Contacts
181
209
  * Github: [https://github.com/Cloufield/gwaslab](https://github.com/Cloufield/gwaslab)
@@ -1,7 +1,7 @@
1
- <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
2
-
3
1
  # GWASLab
4
2
 
3
+ <img width="600" alt="image" src="https://user-images.githubusercontent.com/40289485/197167760-5f761f5e-5856-4b27-a540-8b9cd90bdadb.png">
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)
@@ -13,15 +13,19 @@
13
13
  * Sumstats-specific manipulations are designed as methods of a Python object, `gwaslab.Sumstats`.
14
14
 
15
15
  Please check GWASLab documentation at [https://cloufield.github.io/gwaslab/](https://cloufield.github.io/gwaslab/)
16
+
16
17
  Note: GWASLab is being updated very frequently for now. I will release the first stable version soon! Please stay tuned.
17
18
 
19
+ Warning: Known issues of GWASLab are summarized in [https://cloufield.github.io/gwaslab/KnownIssues/](https://cloufield.github.io/gwaslab/KnownIssues/) .
20
+
18
21
  ## Install
19
22
 
23
+ ### install via pip
24
+
20
25
  ```
21
- pip install gwaslab==3.4.39
26
+ pip install gwaslab==3.4.41
22
27
  ```
23
28
 
24
-
25
29
  ```python
26
30
  import gwaslab as gl
27
31
  # load plink2 output
@@ -51,6 +55,27 @@ mysumstats.plot_mqq()
51
55
  ...
52
56
  ```
53
57
 
58
+ ### install in conda environment
59
+
60
+ Create a Python 3.9 environment and install gwaslab using pip:
61
+
62
+ ```
63
+ conda env create -n gwaslab_test -c conda-forge python=3.9
64
+ conda activate gwaslab
65
+ pip install gwaslab==3.4.41
66
+ ```
67
+
68
+ or create a new environment using yml file [environment_3.4.40.yml](https://github.com/Cloufield/gwaslab/blob/main/environment_3.4.40.yml)
69
+
70
+ ```
71
+ conda env create -n gwaslab -f environment_3.4.40.yml
72
+ ```
73
+
74
+
75
+ ### install using docker
76
+
77
+ A docker file is available [here](https://github.com/Cloufield/gwaslab/blob/main/docker/Dockerfile) for building local images.
78
+
54
79
  ## Functions
55
80
 
56
81
  ### Loading and Formatting
@@ -149,6 +174,9 @@ dependencies:
149
174
  ## Sample Data
150
175
  - Sample GWAS data used in GWASLab is obtained from: http://jenger.riken.jp/ (Suzuki, Ken, et al. "Identification of 28 new susceptibility loci for type 2 diabetes in the Japanese population." Nature genetics 51.3 (2019): 379-386.).
151
176
 
177
+ ## Acknowledgement
178
+
179
+ Thanks to @sup3rgiu, @soumickmj and @gmauro for their contributions to the source codes.
152
180
 
153
181
  ## Contacts
154
182
  * Github: [https://github.com/Cloufield/gwaslab](https://github.com/Cloufield/gwaslab)
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "gwaslab"
10
- version = "3.4.40"
10
+ version = "3.4.42"
11
11
  authors = [
12
12
  { name="Yunye", email="yunye@gwaslab.com" },
13
13
  ]
@@ -298,9 +298,22 @@ def gtf_to_protein_coding(gtfpath,log=Log(),verbose=True):
298
298
 
299
299
  return protein_coding_path
300
300
 
301
+ ####################################################################################################################
302
+ # From BioPython: https://github.com/biopython/biopython/blob/c5a6b1374267d769b19c1022b4b45472316e78b4/Bio/Seq.py#L36
303
+ def _maketrans(complement_mapping):
304
+ """Make a python string translation table.
305
+
306
+ Arguments:
307
+ - complement_mapping - a dictionary.
301
308
 
302
-
309
+ Returns a translation table (a bytes object of length 256) for use with
310
+ the python string's translate method.
303
311
 
312
+ Compatible with lower case and upper case sequences.
313
+ """
314
+ keys = "".join(complement_mapping.keys()).encode("ASCII")
315
+ values = "".join(complement_mapping.values()).encode("ASCII")
316
+ return bytes.maketrans(keys + keys.lower(), values + values.lower())
304
317
 
305
318
  ####################################################################################################################
306
319
 
@@ -12,7 +12,7 @@ from gwaslab.qc_fix_sumstats import finished
12
12
  #A P-value
13
13
  #A signed summary statistic (beta, OR, log odds, Z-score, etc)
14
14
 
15
- def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",build="19", verbose=True, match_allele= True, log=Log()):
15
+ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",build="19", verbose=True, match_allele= True, how="inner", log=Log()):
16
16
  ##start function with col checking##########################################################
17
17
  _start_line = "extract HapMap3 SNPs"
18
18
  _end_line = "extracting HapMap3 SNPs"
@@ -47,7 +47,7 @@ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",b
47
47
  #rsid A1 A2 #CHROM POS
48
48
  #rs3094315 G A 1 752566
49
49
 
50
- if rsid in sumstats.columns:
50
+ if rsid in sumstats.columns and how=="inner":
51
51
  output = sumstats.loc[sumstats[rsid].isin(hapmap3_ref["rsid"].values),:].copy()
52
52
  return output
53
53
 
@@ -56,11 +56,15 @@ def gethapmap3(sumstats,rsid="rsID",chrom="CHR", pos="POS", ea="EA", nea="NEA",b
56
56
  sumstats ["chr:pos"] = sumstats[chrom].astype("string")+":"+sumstats[pos].astype("string")
57
57
  hapmap3_ref["chr:pos"] = hapmap3_ref["#CHROM"]+":"+hapmap3_ref["POS"]
58
58
  hapmap3_ref = hapmap3_ref.rename(columns={"rsid":"rsID"})
59
- output = pd.merge(sumstats,hapmap3_ref.loc[:,["chr:pos","rsID"]+additional_cols],left_on="chr:pos",right_on="chr:pos",how="inner",suffixes=('', '_hapmap3')).copy()
59
+ output = pd.merge(sumstats,hapmap3_ref.loc[:,["chr:pos","rsID"]+additional_cols],left_on="chr:pos",right_on="chr:pos",how=how,suffixes=('', '_hapmap3')).copy()
60
60
  if match_allele:
61
61
  log.write(" -Checking if alleles are same...")
62
62
  is_matched = ((output[ea].astype("string") == output["A1"]) & (output[nea].astype("string") == output["A2"])) \
63
63
  | ((output[ea].astype("string") == output["A2"]) & (output[nea].astype("string") == output["A1"]))
64
+ if how=="right":
65
+ is_matched = ((output[ea].astype("string") == output["A1"]) & (output[nea].astype("string") == output["A2"])) \
66
+ | ((output[ea].astype("string") == output["A2"]) & (output[nea].astype("string") == output["A1"])) | output[ea].isna()
67
+
64
68
  log.write(" -Variants with macthed alleles: {}".format(sum(is_matched)))
65
69
  output = output.loc[is_matched,:]
66
70
  output = output.drop(columns=["chr:pos"]+additional_cols)