genal-python 1.3.2__tar.gz → 1.3.4__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.
Files changed (109) hide show
  1. {genal_python-1.3.2 → genal_python-1.3.4}/PKG-INFO +1 -1
  2. {genal_python-1.3.2 → genal_python-1.3.4}/genal/Geno.py +2 -1
  3. {genal_python-1.3.2 → genal_python-1.3.4}/genal/__init__.py +1 -1
  4. {genal_python-1.3.2 → genal_python-1.3.4}/genal/clump.py +2 -3
  5. {genal_python-1.3.2 → genal_python-1.3.4}/genal/extract_prs.py +11 -3
  6. {genal_python-1.3.2 → genal_python-1.3.4}/genal/geno_tools.py +3 -7
  7. {genal_python-1.3.2 → genal_python-1.3.4}/genal/lift.py +4 -1
  8. {genal_python-1.3.2 → genal_python-1.3.4}/genal/proxy.py +14 -8
  9. {genal_python-1.3.2 → genal_python-1.3.4}/pyproject.toml +1 -1
  10. {genal_python-1.3.2 → genal_python-1.3.4}/.DS_Store +0 -0
  11. {genal_python-1.3.2 → genal_python-1.3.4}/.gitignore +0 -0
  12. {genal_python-1.3.2 → genal_python-1.3.4}/.readthedocs.yaml +0 -0
  13. {genal_python-1.3.2 → genal_python-1.3.4}/Genal_flowchart.png +0 -0
  14. {genal_python-1.3.2 → genal_python-1.3.4}/LICENSE +0 -0
  15. {genal_python-1.3.2 → genal_python-1.3.4}/README.md +0 -0
  16. {genal_python-1.3.2 → genal_python-1.3.4}/docs/.DS_Store +0 -0
  17. {genal_python-1.3.2 → genal_python-1.3.4}/docs/Makefile +0 -0
  18. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.DS_Store +0 -0
  19. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.buildinfo +0 -0
  20. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/api.doctree +0 -0
  21. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/environment.pickle +0 -0
  22. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/genal.doctree +0 -0
  23. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/index.doctree +0 -0
  24. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/introduction.doctree +0 -0
  25. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/.doctrees/modules.doctree +0 -0
  26. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_images/MR_plot_SBP_AS.png +0 -0
  27. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/Geno.html +0 -0
  28. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/MR.html +0 -0
  29. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/MR_tools.html +0 -0
  30. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/MRpresso.html +0 -0
  31. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/association.html +0 -0
  32. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/clump.html +0 -0
  33. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/extract_prs.html +0 -0
  34. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/geno_tools.html +0 -0
  35. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/lift.html +0 -0
  36. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/proxy.html +0 -0
  37. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/snp_query.html +0 -0
  38. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/genal/tools.html +0 -0
  39. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_modules/index.html +0 -0
  40. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_sources/api.rst.txt +0 -0
  41. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_sources/genal.rst.txt +0 -0
  42. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_sources/index.rst.txt +0 -0
  43. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_sources/introduction.rst.txt +0 -0
  44. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_sources/modules.rst.txt +0 -0
  45. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/basic.css +0 -0
  46. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/badge_only.css +0 -0
  47. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/Roboto-Slab-Bold.woff +0 -0
  48. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/Roboto-Slab-Bold.woff2 +0 -0
  49. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/Roboto-Slab-Regular.woff +0 -0
  50. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/Roboto-Slab-Regular.woff2 +0 -0
  51. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/fontawesome-webfont.eot +0 -0
  52. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/fontawesome-webfont.svg +0 -0
  53. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/fontawesome-webfont.ttf +0 -0
  54. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/fontawesome-webfont.woff +0 -0
  55. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/fontawesome-webfont.woff2 +0 -0
  56. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-bold-italic.woff +0 -0
  57. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-bold-italic.woff2 +0 -0
  58. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-bold.woff +0 -0
  59. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-bold.woff2 +0 -0
  60. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-normal-italic.woff +0 -0
  61. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-normal-italic.woff2 +0 -0
  62. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-normal.woff +0 -0
  63. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/fonts/lato-normal.woff2 +0 -0
  64. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/css/theme.css +0 -0
  65. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/doctools.js +0 -0
  66. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/documentation_options.js +0 -0
  67. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/file.png +0 -0
  68. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/js/badge_only.js +0 -0
  69. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/js/html5shiv-printshiv.min.js +0 -0
  70. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/js/html5shiv.min.js +0 -0
  71. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/js/theme.js +0 -0
  72. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/language_data.js +0 -0
  73. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/minus.png +0 -0
  74. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/plus.png +0 -0
  75. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/pygments.css +0 -0
  76. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/searchtools.js +0 -0
  77. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/_static/sphinx_highlight.js +0 -0
  78. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/api.html +0 -0
  79. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/genal.html +0 -0
  80. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/genindex.html +0 -0
  81. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/index.html +0 -0
  82. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/introduction.html +0 -0
  83. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/modules.html +0 -0
  84. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/objects.inv +0 -0
  85. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/py-modindex.html +0 -0
  86. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/search.html +0 -0
  87. {genal_python-1.3.2 → genal_python-1.3.4}/docs/build/searchindex.js +0 -0
  88. {genal_python-1.3.2 → genal_python-1.3.4}/docs/make.bat +0 -0
  89. {genal_python-1.3.2 → genal_python-1.3.4}/docs/requirements.txt +0 -0
  90. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/.DS_Store +0 -0
  91. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/Images/Genal_flowchart.png +0 -0
  92. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/Images/MR_plot_SBP_AS.png +0 -0
  93. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/Images/genal_logo.png +0 -0
  94. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/api.rst +0 -0
  95. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/conf.py +0 -0
  96. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/index.rst +0 -0
  97. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/introduction.rst +0 -0
  98. {genal_python-1.3.2 → genal_python-1.3.4}/docs/source/modules.rst +0 -0
  99. {genal_python-1.3.2 → genal_python-1.3.4}/genal/MR.py +0 -0
  100. {genal_python-1.3.2 → genal_python-1.3.4}/genal/MR_tools.py +0 -0
  101. {genal_python-1.3.2 → genal_python-1.3.4}/genal/MRpresso.py +0 -0
  102. {genal_python-1.3.2 → genal_python-1.3.4}/genal/association.py +0 -0
  103. {genal_python-1.3.2 → genal_python-1.3.4}/genal/colocalization.py +0 -0
  104. {genal_python-1.3.2 → genal_python-1.3.4}/genal/constants.py +0 -0
  105. {genal_python-1.3.2 → genal_python-1.3.4}/genal/snp_query.py +0 -0
  106. {genal_python-1.3.2 → genal_python-1.3.4}/genal/tools.py +0 -0
  107. {genal_python-1.3.2 → genal_python-1.3.4}/genal_logo.png +0 -0
  108. {genal_python-1.3.2 → genal_python-1.3.4}/gitignore +0 -0
  109. {genal_python-1.3.2 → genal_python-1.3.4}/readthedocs.yaml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: genal-python
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: A python toolkit for polygenic risk scoring and mendelian randomization.
5
5
  Author-email: Cyprien Rivier <riviercyprien@gmail.com>
6
6
  Requires-Python: >=3.8
@@ -655,7 +655,8 @@ class Geno:
655
655
  kb=kb,
656
656
  r2=r2,
657
657
  window_snps=window_snps,
658
- threads=self.cpus
658
+ threads=self.cpus,
659
+ name=self.name
659
660
  )
660
661
  # Apply proxies if found
661
662
  if isinstance(ld, pd.DataFrame) and not ld.empty:
@@ -4,7 +4,7 @@ from .tools import default_config, write_config, set_plink, install_plink, delet
4
4
  from .geno_tools import Combine_Geno, filter_by_gene_func
5
5
  from .constants import CONFIG_DIR
6
6
 
7
- __version__ = "1.3.2"
7
+ __version__ = "1.3.4"
8
8
 
9
9
  config_path = os.path.join(CONFIG_DIR, "config.json")
10
10
 
@@ -1,5 +1,4 @@
1
1
  import os
2
- import subprocess
3
2
  import pandas as pd
4
3
  import uuid
5
4
  import re
@@ -13,7 +12,7 @@ def clump_data_plink2(
13
12
  r2=0.01,
14
13
  p1=5e-8,
15
14
  p2=0.01,
16
- name="",
15
+ name=None,
17
16
  ram=10000,
18
17
  ):
19
18
  """
@@ -37,7 +36,7 @@ def clump_data_plink2(
37
36
  """
38
37
 
39
38
  # Create unique ID for the name if none is passed
40
- if not name:
39
+ if name is None:
41
40
  name = str(uuid.uuid4())[:8]
42
41
 
43
42
  # Save the relevant data columns to a temporary file
@@ -1,5 +1,5 @@
1
1
  import pandas as pd
2
- import os, subprocess, re
2
+ import os, subprocess, re, uuid
3
3
  from functools import partial
4
4
  from concurrent.futures import ProcessPoolExecutor
5
5
 
@@ -10,13 +10,17 @@ from .tools import check_bfiles, check_pfiles, setup_genetic_path, get_plink_pat
10
10
  ### PRS functions
11
11
  ### ____________________
12
12
 
13
- def prs_func(data, weighted=True, path=None, ram=10000, name=""):
13
+ def prs_func(data, weighted=True, path=None, ram=10000, name=None):
14
14
  """
15
15
  Compute a PRS (Polygenic Risk Score) using provided SNP-level data. Corresponds to the :meth:`Geno.prs` method
16
16
  """
17
17
  # Get path and filetype
18
18
  path, filetype = setup_genetic_path(path)
19
19
 
20
+ # Generate a default name if none is provided
21
+ if name is None:
22
+ name = str(uuid.uuid4())[:8]
23
+
20
24
  # Call extract_snps
21
25
  extracted_path = extract_snps_func(data.SNP, name, path)
22
26
 
@@ -94,7 +98,7 @@ def prs_func(data, weighted=True, path=None, ram=10000, name=""):
94
98
 
95
99
  # We are currently excluding all multiallelic variants by forcing first on all duplicates.
96
100
  # Could be improved by keeping the relevant version of the multiallelic SNPs based on allele matching
97
- def extract_snps_func(snp_list, name, path=None):
101
+ def extract_snps_func(snp_list, name=None, path=None):
98
102
  """
99
103
  Extracts a list of SNPs from the given path. This function corresponds to the following Geno method: :meth:`Geno.extract_snps`.
100
104
 
@@ -114,6 +118,10 @@ def extract_snps_func(snp_list, name, path=None):
114
118
  print("The provided SNP list is empty.")
115
119
  return "FAILED"
116
120
 
121
+ # Generate a default name if none is provided
122
+ if name is None:
123
+ name = str(uuid.uuid4())[:8]
124
+
117
125
  # Get path and filetype
118
126
  path, filetype = setup_genetic_path(path)
119
127
 
@@ -406,7 +406,7 @@ def save_data(data, name, path="", fmt="h5", sep="\t", header=True):
406
406
  - data (pd.DataFrame): The data to be saved.
407
407
  - name (str): The name of the file without extension.
408
408
  - path (str, optional): Directory path for saving. Default is the current directory.
409
- - fmt (str, optional): Format for the file, e.g., "h5", "csv", "txt", "vcf", "vcf.gz". Default is "h5".
409
+ - fmt (str, optional): Format for the file, e.g., "h5", "csv", "txt". Default is "h5".
410
410
  - sep (str, optional): Delimiter for csv or txt files. Default is tab.
411
411
  - header (bool, optional): Whether to include header in csv or txt files. Default is True.
412
412
 
@@ -417,7 +417,7 @@ def save_data(data, name, path="", fmt="h5", sep="\t", header=True):
417
417
  - ValueError: If the provided format is not recognized.
418
418
  """
419
419
  if path:
420
- path_name = f"{path}/{name}.{fmt}"
420
+ path_name = os.path.join(path, f"{name}.{fmt}")
421
421
  else:
422
422
  path_name = f"{name}.{fmt}"
423
423
 
@@ -430,13 +430,9 @@ def save_data(data, name, path="", fmt="h5", sep="\t", header=True):
430
430
  elif fmt in ["csv", "txt"]:
431
431
  data.to_csv(path_name, sep=sep, header=header, index=False)
432
432
 
433
- elif fmt in ["vcf", "vcf.gz"]:
434
- # to do
435
- return
436
-
437
433
  else:
438
434
  raise ValueError(
439
- "The fmt argument takes value in (h5 (default), csv, txt, vcf, vcf.gz)."
435
+ "The fmt argument takes value in (h5 (default), csv, txt)."
440
436
  )
441
437
 
442
438
  print(f"Data saved to {path_name}")
@@ -4,7 +4,7 @@ import numpy as np
4
4
  import wget
5
5
  import gzip
6
6
  import shutil
7
- from tqdm import tqdm
7
+ import uuid
8
8
  import pandas as pd
9
9
  from concurrent.futures import ThreadPoolExecutor, as_completed
10
10
 
@@ -44,6 +44,9 @@ def lift_data(
44
44
  Notes:
45
45
  Function for the :meth:`Geno.lift` method.
46
46
  """
47
+ # Generate a default name if none is provided
48
+ if name is None:
49
+ name = str(uuid.uuid4())[:8]
47
50
 
48
51
  # Prepare chain file and get its path
49
52
  chain_path = prepare_chain_file(chain_file, start, end)
@@ -3,6 +3,7 @@ import numpy as np
3
3
  import os
4
4
  import subprocess
5
5
  import re
6
+ import uuid
6
7
 
7
8
  from .tools import get_reference_panel_path, get_plink_path, run_plink_command
8
9
 
@@ -196,7 +197,8 @@ def find_proxies(
196
197
  kb=5000,
197
198
  r2=0.8,
198
199
  window_snps=1000000,
199
- threads=1
200
+ threads=1,
201
+ name=None
200
202
  ):
201
203
  """
202
204
  Given a list of SNPs, return a table of proxies using PLINK 2.0.
@@ -219,6 +221,10 @@ def find_proxies(
219
221
  # Ensure tmp_GENAL directory exists
220
222
  os.makedirs(f"tmp_GENAL/", exist_ok=True)
221
223
 
224
+ # Generate a default name if none is provided
225
+ if name is None:
226
+ name = str(uuid.uuid4())[:8]
227
+
222
228
  # Convert snp_list to numpy array
223
229
  snp_list = np.array(list(snp_list))
224
230
 
@@ -227,13 +233,13 @@ def find_proxies(
227
233
  extract_arg = ""
228
234
  else:
229
235
  print("Searching proxies in the provided searchspace.")
230
- with open("tmp_GENAL/searchspace.txt", "w") as file:
236
+ with open(f"tmp_GENAL/{name}_searchspace.txt", "w") as file:
231
237
  for s in searchspace + snp_list:
232
238
  file.write(str(s) + "\n")
233
- extract_arg = "--extract tmp_GENAL/searchspace.txt"
239
+ extract_arg = "--extract tmp_GENAL/{name}_searchspace.txt"
234
240
 
235
241
  # Save snp_list to a file
236
- np.savetxt("tmp_GENAL/snps_to_proxy.txt", snp_list, fmt="%s", delimiter=" ")
242
+ np.savetxt(f"tmp_GENAL/{name}_snps_to_proxy.txt", snp_list, fmt="%s", delimiter=" ")
237
243
 
238
244
  # Get reference panel path and type
239
245
  ref_path, filetype = get_reference_panel_path(reference_panel)
@@ -256,18 +262,18 @@ def find_proxies(
256
262
  command = (
257
263
  f"{base_cmd} {extract_arg} "
258
264
  f"--r-unphased 'cols=chrom,pos,id,maj,nonmaj,freq' "
259
- f"--ld-snp-list tmp_GENAL/snps_to_proxy.txt "
265
+ f"--ld-snp-list tmp_GENAL/{name}_snps_to_proxy.txt "
260
266
  f"--ld-window-kb {kb} "
261
267
  f"--ld-window-r2 {r2} "
262
268
  f"--ld-window {window_snps} "
263
269
  f"--threads {threads} "
264
- f"--out tmp_GENAL/proxy.targets"
270
+ f"--out tmp_GENAL/{name}_proxy.targets"
265
271
  )
266
272
 
267
273
  run_plink_command(command)
268
274
 
269
275
  # Read log file to return amount of SNPs to be proxied present in the ref panel
270
- log_path = os.path.join("tmp_GENAL", "proxy.targets.log")
276
+ log_path = os.path.join("tmp_GENAL", f"{name}_proxy.targets.log")
271
277
  log_content = open(log_path).read()
272
278
  match = re.search(r'(\d+) variant[s] remaining', log_content)
273
279
  if match:
@@ -280,7 +286,7 @@ def find_proxies(
280
286
 
281
287
  # Read and process the output
282
288
  try:
283
- ld = pd.read_csv("tmp_GENAL/proxy.targets.vcor", sep="\s+")
289
+ ld = pd.read_csv(f"tmp_GENAL/{name}_proxy.targets.vcor", sep="\s+")
284
290
  except FileNotFoundError:
285
291
  print("No proxies found that meet the specified criteria.")
286
292
  return None
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
4
4
 
5
5
  [project]
6
6
  name = "genal-python" # Updated name for PyPI
7
- version = "1.3.2"
7
+ version = "1.3.4"
8
8
  authors = [{name = "Cyprien Rivier", email = "riviercyprien@gmail.com"}]
9
9
  description = "A python toolkit for polygenic risk scoring and mendelian randomization."
10
10
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes