polygenic-pgx 2.6.3__tar.gz → 2.6.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 (116) hide show
  1. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/CHANGELOG.md +26 -0
  2. {polygenic_pgx-2.6.3/polygenic_pgx.egg-info → polygenic_pgx-2.6.4}/PKG-INFO +27 -1
  3. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/README.md +26 -0
  4. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/data_accessor.py +8 -1
  5. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/model.py +165 -1
  6. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/pgstk.py +8 -0
  7. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/pgscompute.py +1 -0
  8. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/version.py +1 -1
  9. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4/polygenic_pgx.egg-info}/PKG-INFO +27 -1
  10. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/setup.py +1 -1
  11. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/LICENSE +0 -0
  12. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/MANIFEST.in +0 -0
  13. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/__init__.py +0 -0
  14. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/__main__.py +0 -0
  15. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/__init__.py +0 -0
  16. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/csv_accessor.py +0 -0
  17. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/gwas.py +0 -0
  18. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/mobigen_utils.py +0 -0
  19. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/polars_frame.py +0 -0
  20. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/snp_data.py +0 -0
  21. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/vcf_accessor.py +0 -0
  22. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/data/vcf_record.py +0 -0
  23. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/error/__init__.py +0 -0
  24. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/error/polygenic_exception.py +0 -0
  25. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/__init__.py +0 -0
  26. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/cnv_depth.py +0 -0
  27. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/core_variants.py +0 -0
  28. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/gene_defaults.json +0 -0
  29. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/hgnc.json +0 -0
  30. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/indel_alignment.py +0 -0
  31. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/panel.py +0 -0
  32. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/registry.py +0 -0
  33. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/source_releases.json +0 -0
  34. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/summary.py +0 -0
  35. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/model/utils.py +0 -0
  36. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/abcg2-pharmgkb-1.0.0.yml +0 -0
  37. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/apoe-1.0.0.yml +0 -0
  38. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/bche-1.0.0.yml +0 -0
  39. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cacna1s-pharmgkb-1.0.0.yml +0 -0
  40. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cftr-pharmgkb-1.0.0.yml +0 -0
  41. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/comt-1.0.0.yml +0 -0
  42. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp1a1-pharmgkb-1.0.0.yml +0 -0
  43. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp1a2-pharmvar-6.2.25.yml +0 -0
  44. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp26a1-pharmvar-5.1.8.yml +0 -0
  45. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2a13-pharmvar-6.2.29.yml +0 -0
  46. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2a6-pharmvar-6.2.29.yml +0 -0
  47. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2b6-pharmvar-6.2.29.yml +0 -0
  48. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2c19-pharmvar-5.1.8.yml +0 -0
  49. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2c19-pharmvar-6.2.29.yml +0 -0
  50. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2c8-pharmvar-5.1.8.yml +0 -0
  51. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2c9-pharmvar-6.2.29.yml +0 -0
  52. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2d6-pharmvar-5.1.8.yml +0 -0
  53. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2e1-pharmgkb-1.0.0.yml +0 -0
  54. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2f1-pharmvar-5.1.8.yml +0 -0
  55. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2j2-pharmvar-5.1.8.yml +0 -0
  56. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2r1-pharmvar-5.1.8.yml +0 -0
  57. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2s1-pharmvar-5.1.8.yml +0 -0
  58. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp2w1-pharmvar-5.1.8.yml +0 -0
  59. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp3a4-pharmvar-6.2.29.yml +0 -0
  60. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp3a43-pharmvar-5.1.8.yml +0 -0
  61. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp3a5-pharmvar-6.2.29.yml +0 -0
  62. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp3a7-pharmvar-5.1.8.yml +0 -0
  63. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/cyp4f2-pharmvar-6.2.29.yml +0 -0
  64. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/dpyd-clinpgx-1.0.0.yml +0 -0
  65. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/dpyd-pharmvar-6.2.29.yml +0 -0
  66. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/f2-1.0.0.yml +0 -0
  67. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/f5-1.0.0.yml +0 -0
  68. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/g6pd-pharmgkb-1.0.0.yml +0 -0
  69. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/ifnl3-1.0.0.yml +0 -0
  70. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/ifnl4-1.0.0.yml +0 -0
  71. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/manifest.json +0 -0
  72. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/mthfr-1.0.0.yml +0 -0
  73. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/mtrnr1-cpic-1.0.0.yml +0 -0
  74. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/nat2-pharmvar-6.2.29.yml +0 -0
  75. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/nudt15-pharmvar-6.2.29.yml +0 -0
  76. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/oprm1-1.0.0.yml +0 -0
  77. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/ryr1-pharmgkb-1.0.0.yml +0 -0
  78. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/slco1b1-pharmvar-6.2.29.yml +0 -0
  79. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/tpmt-cpic-1.0.0.yml +0 -0
  80. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/ugt1a1-pharmgkb-1.0.0.yml +0 -0
  81. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/ugt2b15-pharmgkb-1.0.0.yml +0 -0
  82. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/models/pgx/vkorc1-1.0.0.yml +0 -0
  83. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/resources/chromsizes/hg38.chrom.sizes +0 -0
  84. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/__init__.py +0 -0
  85. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/__main__.py +0 -0
  86. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/_version.py +0 -0
  87. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/cli.py +0 -0
  88. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/index.py +0 -0
  89. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/rsidx/search.py +0 -0
  90. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/templates/pgscompute-header.md +0 -0
  91. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/templates/pgscompute-model.md +0 -0
  92. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/__init__.py +0 -0
  93. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/data/__init__.py +0 -0
  94. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/data/chromsizes.py +0 -0
  95. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/data/colors.py +0 -0
  96. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/gwasfilecreate.py +0 -0
  97. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modelbiobankuk.py +0 -0
  98. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modeldiff.py +0 -0
  99. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modelgwasfile.py +0 -0
  100. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modellist.py +0 -0
  101. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modelmanifest.py +0 -0
  102. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/modelpgscat.py +0 -0
  103. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/plotmanhattan.py +0 -0
  104. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/tsvtovcf.py +0 -0
  105. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/utils.py +0 -0
  106. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/vcfimpute.py +0 -0
  107. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/vcfindex.py +0 -0
  108. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/vcfstatbaf.py +0 -0
  109. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic/tools/vcfstatzygosity.py +0 -0
  110. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic_pgx.egg-info/SOURCES.txt +0 -0
  111. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic_pgx.egg-info/dependency_links.txt +0 -0
  112. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic_pgx.egg-info/entry_points.txt +0 -0
  113. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic_pgx.egg-info/requires.txt +0 -0
  114. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/polygenic_pgx.egg-info/top_level.txt +0 -0
  115. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/pyproject.toml +0 -0
  116. {polygenic_pgx-2.6.3 → polygenic_pgx-2.6.4}/setup.cfg +0 -0
@@ -3,6 +3,32 @@
3
3
  Release history for `polygenic-pgx`. Newest first. The three most recent entries are also
4
4
  repeated in `README.md` (which is the PyPI project page).
5
5
 
6
+ ### 2.6.4
7
+
8
+ **CYP2D6/CYP2D7 hybrids named by a structural caller are called as the caller reports them.** When
9
+ the structural record that carries the copy number also carries the caller's hybrid tags
10
+ (`HYBRID_CONFIDENCE` = `named` / `flagged-not-named`, with `HYBRID_ALLELE`, `HYBRID_TANDEM_WITH`,
11
+ `CNTOTAL`, `CNWHOLE`, `KCONV`), those tags decide the name, the tandem and the replaced allele,
12
+ instead of the model's first partial allele and the span of the record:
13
+
14
+ - a copy gain is a **tandem** whatever part of the gene the record spans, never an `xN`; it is
15
+ named from `HYBRID_ALLELE` (`*36x2+*10` when `KCONV` > 1), with the partner from phase or from
16
+ `HYBRID_TANDEM_WITH`. Before, every partial event was named `*68` and a record over >= 90 % of
17
+ the gene went the `xN` path;
18
+ - a hybrid **replacing a whole copy** (a partial `<DEL>`, `CN` = whole copies) replaces the base
19
+ allele its SNVs look like (`*36` -> `*10`, `*4N` -> `*4`): `*3/*4` becomes `*3/*4N`. `CN` 0 is
20
+ `*5/<hybrid>`. A survivor that cannot be told apart makes the call `Indeterminate`, with both
21
+ candidates in `possible_calls`;
22
+ - a hybrid the caller could **not name** stays unnamed (`hybrid_not_named`): it is never called
23
+ `*68`, and its slot is `Indeterminate` when it replaces a copy.
24
+
25
+ New `--hybrid-in-diplotype[=GENES]`, **default off**: a named tandem with a resolved partner
26
+ becomes the call itself (`CYP2D6*3/CYP2D6*68+CYP2D6*4.001`, flag `tandem_in_diplotype`) instead of
27
+ being listed under `copy_number.tandem` beside an unchanged `*3/*4`.
28
+
29
+ Records without `HYBRID_CONFIDENCE` take every earlier path unchanged, so no existing output
30
+ moves. Details: `docs/pgx-cnv.md`.
31
+
6
32
  ### 2.6.3
7
33
 
8
34
  **`cyp2c19-pharmvar-5.1.8` is back, as a second CYP2C19 model you select by name.** It is the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polygenic-pgx
3
- Version: 2.6.3
3
+ Version: 2.6.4
4
4
  Summary: Polygenic score toolkit
5
5
  Home-page: https://github.com/marpiech/polygenic
6
6
  Author: Marcin Piechota, Wojciech Galan
@@ -555,6 +555,32 @@ Proprietary (contact@intelliseq.pl)
555
555
 
556
556
  ## Updates
557
557
 
558
+ ### 2.6.4
559
+
560
+ **CYP2D6/CYP2D7 hybrids named by a structural caller are called as the caller reports them.** When
561
+ the structural record that carries the copy number also carries the caller's hybrid tags
562
+ (`HYBRID_CONFIDENCE` = `named` / `flagged-not-named`, with `HYBRID_ALLELE`, `HYBRID_TANDEM_WITH`,
563
+ `CNTOTAL`, `CNWHOLE`, `KCONV`), those tags decide the name, the tandem and the replaced allele,
564
+ instead of the model's first partial allele and the span of the record:
565
+
566
+ - a copy gain is a **tandem** whatever part of the gene the record spans, never an `xN`; it is
567
+ named from `HYBRID_ALLELE` (`*36x2+*10` when `KCONV` > 1), with the partner from phase or from
568
+ `HYBRID_TANDEM_WITH`. Before, every partial event was named `*68` and a record over >= 90 % of
569
+ the gene went the `xN` path;
570
+ - a hybrid **replacing a whole copy** (a partial `<DEL>`, `CN` = whole copies) replaces the base
571
+ allele its SNVs look like (`*36` -> `*10`, `*4N` -> `*4`): `*3/*4` becomes `*3/*4N`. `CN` 0 is
572
+ `*5/<hybrid>`. A survivor that cannot be told apart makes the call `Indeterminate`, with both
573
+ candidates in `possible_calls`;
574
+ - a hybrid the caller could **not name** stays unnamed (`hybrid_not_named`): it is never called
575
+ `*68`, and its slot is `Indeterminate` when it replaces a copy.
576
+
577
+ New `--hybrid-in-diplotype[=GENES]`, **default off**: a named tandem with a resolved partner
578
+ becomes the call itself (`CYP2D6*3/CYP2D6*68+CYP2D6*4.001`, flag `tandem_in_diplotype`) instead of
579
+ being listed under `copy_number.tandem` beside an unchanged `*3/*4`.
580
+
581
+ Records without `HYBRID_CONFIDENCE` take every earlier path unchanged, so no existing output
582
+ moves. Details: `docs/pgx-cnv.md`.
583
+
558
584
  ### 2.6.3
559
585
 
560
586
  **`cyp2c19-pharmvar-5.1.8` is back, as a second CYP2C19 model you select by name.** It is the
@@ -509,6 +509,32 @@ Proprietary (contact@intelliseq.pl)
509
509
 
510
510
  ## Updates
511
511
 
512
+ ### 2.6.4
513
+
514
+ **CYP2D6/CYP2D7 hybrids named by a structural caller are called as the caller reports them.** When
515
+ the structural record that carries the copy number also carries the caller's hybrid tags
516
+ (`HYBRID_CONFIDENCE` = `named` / `flagged-not-named`, with `HYBRID_ALLELE`, `HYBRID_TANDEM_WITH`,
517
+ `CNTOTAL`, `CNWHOLE`, `KCONV`), those tags decide the name, the tandem and the replaced allele,
518
+ instead of the model's first partial allele and the span of the record:
519
+
520
+ - a copy gain is a **tandem** whatever part of the gene the record spans, never an `xN`; it is
521
+ named from `HYBRID_ALLELE` (`*36x2+*10` when `KCONV` > 1), with the partner from phase or from
522
+ `HYBRID_TANDEM_WITH`. Before, every partial event was named `*68` and a record over >= 90 % of
523
+ the gene went the `xN` path;
524
+ - a hybrid **replacing a whole copy** (a partial `<DEL>`, `CN` = whole copies) replaces the base
525
+ allele its SNVs look like (`*36` -> `*10`, `*4N` -> `*4`): `*3/*4` becomes `*3/*4N`. `CN` 0 is
526
+ `*5/<hybrid>`. A survivor that cannot be told apart makes the call `Indeterminate`, with both
527
+ candidates in `possible_calls`;
528
+ - a hybrid the caller could **not name** stays unnamed (`hybrid_not_named`): it is never called
529
+ `*68`, and its slot is `Indeterminate` when it replaces a copy.
530
+
531
+ New `--hybrid-in-diplotype[=GENES]`, **default off**: a named tandem with a resolved partner
532
+ becomes the call itself (`CYP2D6*3/CYP2D6*68+CYP2D6*4.001`, flag `tandem_in_diplotype`) instead of
533
+ being listed under `copy_number.tandem` beside an unchanged `*3/*4`.
534
+
535
+ Records without `HYBRID_CONFIDENCE` take every earlier path unchanged, so no existing output
536
+ moves. Details: `docs/pgx-cnv.md`.
537
+
512
538
  ### 2.6.3
513
539
 
514
540
  **`cyp2c19-pharmvar-5.1.8` is back, as a second CYP2C19 model you select by name.** It is the
@@ -141,7 +141,14 @@ class DataAccessor(object):
141
141
  ("breakpoint", "HYBRID_BREAKPOINT"),
142
142
  ("evidence", "HYBRID_EVIDENCE"),
143
143
  ("confidence", "HYBRID_CONFIDENCE"),
144
- ("suppressed", "SUPPRESSED")):
144
+ ("suppressed", "SUPPRESSED"),
145
+ # BT-2787: copy-number shape of a hybrid caller's record (cyp2d6-hybrid-calling):
146
+ # which record it is (CALL / HYBRID), all gene copies, whole CYP2D6-type
147
+ # copies, converted copies. Read only when the caller wrote them.
148
+ ("record", "RECORD"),
149
+ ("cn_total", "CNTOTAL"),
150
+ ("cn_whole", "CNWHOLE"),
151
+ ("k_conv", "KCONV")):
145
152
  try:
146
153
  value = record.get_info_field(tag)
147
154
  except Exception:
@@ -857,7 +857,24 @@ class HaplotypeModel(SeqqlOperator):
857
857
  deletion_allele = self._deletion_allele(config, cn_info, haplotypes_obj)
858
858
  reference_allele = (config.get("gene") + "*1") if config.get("gene") else None
859
859
 
860
- if cn <= 0:
860
+ # BT-2787: the consumed record carries a structural caller's hybrid tags (HYBRID_CONFIDENCE).
861
+ # Name, tandem and placement then come from the caller, not from the model's first partial
862
+ # allele and the span. Records without the tags never reach this branch.
863
+ caller_hybrid = self._caller_hybrid(config, cn_info)
864
+ if caller_hybrid is not None and cn <= 1:
865
+ self._caller_hybrid_replaces_copy(
866
+ cnv, caller_hybrid, cn, base_first, base_second, haplotypes_obj)
867
+ elif caller_hybrid is not None and cn >= 3 and caller_hybrid["record"] != "HYBRID":
868
+ if not self.has("multiplication"):
869
+ return cnv
870
+ self._caller_hybrid_tandem(
871
+ cnv, caller_hybrid, cn, cn_info, config, base_first, base_second,
872
+ base_call_source, genotypes, haplotypes_obj, data_accessor)
873
+ if cnv["applied"]:
874
+ haplotypes["haplotype_id"] = cnv["call"]
875
+ haplotypes["id"] = cnv["call"]
876
+ return cnv
877
+ elif cn <= 0:
861
878
  # whole/partial homozygous deletion -> e.g. *5/*5
862
879
  if deletion_allele is not None:
863
880
  cnv["call"] = deletion_allele + "/" + deletion_allele
@@ -1081,6 +1098,153 @@ class HaplotypeModel(SeqqlOperator):
1081
1098
  for a, b in ((first, second), (second, first))}),
1082
1099
  }
1083
1100
 
1101
+ # BT-2787: the base allele a converted copy is SEEN AS by SNV genotyping. A *36 copy carries the
1102
+ # *10 lineage variants, a *4N copy the *4 ones, so a sample *1/*36 genotypes as *1/*10 from SNVs.
1103
+ # *68 is CYP2D7-derived from intron 1 down and adds next to no CYP2D6 SNVs of its own.
1104
+ HYBRID_LOOKALIKE = {"36": "10", "4N": "4"}
1105
+
1106
+ @staticmethod
1107
+ def _star_core(allele):
1108
+ """`CYP2D6*10.003` -> `10`, `CYP2D6*4N` -> `4N`, `*36x2` -> `36`; None when there is no star."""
1109
+ import re
1110
+ m = re.search(r"\*(\d+[A-Z]*)", str(allele or ""))
1111
+ return m.group(1) if m else None
1112
+
1113
+ @staticmethod
1114
+ def _caller_hybrid(config, cn_info):
1115
+ """The hybrid a structural caller wrote on the CONSUMED record, or None.
1116
+
1117
+ Keyed on HYBRID_CONFIDENCE (`named` | `flagged-not-named`), which only a hybrid caller
1118
+ writes; without it (CNVkit, client CNV files, older producers) this returns None and every
1119
+ pre-BT-2787 path runs unchanged."""
1120
+ confidence = cn_info.get("confidence")
1121
+ if not confidence:
1122
+ return None
1123
+ gene = config.get("gene") or ""
1124
+
1125
+ def full(allele):
1126
+ if not allele:
1127
+ return None
1128
+ allele = str(allele)
1129
+ if gene and allele.startswith(gene):
1130
+ return allele
1131
+ return gene + (allele if allele.startswith("*") else "*" + allele)
1132
+
1133
+ def number(key):
1134
+ try:
1135
+ return int(cn_info.get(key))
1136
+ except (TypeError, ValueError):
1137
+ return None
1138
+
1139
+ return {
1140
+ "name": full(cn_info.get("hybrid_allele")) if confidence == "named" else None,
1141
+ "tandem_with": full(cn_info.get("tandem_with")),
1142
+ "confidence": confidence,
1143
+ "record": cn_info.get("record"),
1144
+ "cn_total": number("cn_total"),
1145
+ "cn_whole": number("cn_whole"),
1146
+ "k_conv": number("k_conv"),
1147
+ }
1148
+
1149
+ def _caller_hybrid_tandem(self, cnv, hybrid, cn, cn_info, config, base_first, base_second,
1150
+ base_call_source, genotypes, haplotypes_obj, data_accessor):
1151
+ """A copy gain the caller attributes to a hybrid in tandem with two whole copies.
1152
+
1153
+ Tandem because the caller says so (its tags on the record), whatever part of the gene the
1154
+ record spans: a *36 switching at exon 9 spans ~93 % of the region and the span rule would
1155
+ make it an xN. Never an xN. The partner comes from phase, else from HYBRID_TANDEM_WITH when
1156
+ that allele is one of the two base alleles. Becomes the call only with
1157
+ --hybrid-in-diplotype, a named hybrid, a resolved partner and an SNV base pair from the
1158
+ assembler; otherwise the base call stands and the tandem is listed beside it."""
1159
+ extra = hybrid["k_conv"] or max(1, cn - (hybrid["cn_whole"] or 2))
1160
+ name = hybrid["name"]
1161
+ shown = None if name is None else (name if extra == 1 else name + "x" + str(extra))
1162
+ fraction = self._span_fraction(config, cn_info)
1163
+ tandem = {
1164
+ "hybrid": shown,
1165
+ "named_by": "caller",
1166
+ "confidence": hybrid["confidence"],
1167
+ "span_fraction": None if fraction is None else round(fraction, 4),
1168
+ "extra_copies": extra,
1169
+ "arrangements": [],
1170
+ }
1171
+ cnv["tandem"] = tandem
1172
+ cnv["flags"].append("tandem_hybrid_suppressed_xn")
1173
+ if name is None:
1174
+ cnv["flags"].append("hybrid_not_named")
1175
+ cnv["possible_calls"] = []
1176
+ return
1177
+ if not base_first:
1178
+ # no SNV pair to put the tandem next to: no *1 is invented for it
1179
+ cnv["flags"].append("tandem_base_unresolved")
1180
+ cnv["possible_calls"] = []
1181
+ return
1182
+ first, second = base_first, base_second or base_first
1183
+ tandem["arrangements"] = sorted({self._canonical_pair_or_join(shown + "+" + a, b)
1184
+ for a, b in ((first, second), (second, first))})
1185
+ partner = self._duplicated_haplotype(cn_info, [first, second], genotypes, haplotypes_obj)
1186
+ resolved_by = "phase" if partner is not None else None
1187
+ if partner is None and hybrid["tandem_with"]:
1188
+ want = self._star_core(hybrid["tandem_with"])
1189
+ matching = [a for a in dict.fromkeys((first, second)) if self._star_core(a) == want]
1190
+ if len(matching) == 1:
1191
+ partner, resolved_by = matching[0], "caller"
1192
+ if partner is not None and len(tandem["arrangements"]) > 1:
1193
+ other = second if partner == first else first
1194
+ tandem["arrangements"] = [self._canonical_pair_or_join(shown + "+" + partner, other)]
1195
+ if len(tandem["arrangements"]) == 1:
1196
+ tandem["partner"] = partner if partner is not None else first
1197
+ tandem["resolved_by"] = resolved_by or "single_arrangement"
1198
+ cnv["possible_calls"] = tandem["arrangements"]
1199
+ if len(tandem["arrangements"]) > 1:
1200
+ cnv["flags"].append("tandem_partner_unresolved")
1201
+ return
1202
+ parameters = data_accessor.get_parameters()
1203
+ if parameters.get("hybrid_in_diplotype", False) and base_call_source == "assembler":
1204
+ cnv["call"] = tandem["arrangements"][0]
1205
+ cnv["applied"] = True
1206
+ cnv["flags"].append("tandem_in_diplotype")
1207
+
1208
+ def _caller_hybrid_replaces_copy(self, cnv, hybrid, cn, base_first, base_second, haplotypes_obj):
1209
+ """A hybrid standing in for a whole copy: the caller's partial <DEL>, CN = whole copies.
1210
+
1211
+ CN 1: one whole copy plus the hybrid. The SNV pair still sees the hybrid's CYP2D6 part
1212
+ (*36 reads as *10, *4N as *4), so the hybrid replaces THAT allele and the other one is the
1213
+ whole copy. CN 0: no whole copy, the hybrid on one chromosome and a deletion on the other.
1214
+ An unnamed hybrid fills its slot as `Indeterminate`; a survivor that cannot be told apart
1215
+ makes the whole call Indeterminate rather than a guess."""
1216
+ structural = haplotypes_obj.structural_haplotypes()
1217
+ whole_deletion = next((hid for hid, meta in structural.items()
1218
+ if (meta or {}).get("scope") == "whole"), None)
1219
+ slot = hybrid["name"] or "Indeterminate"
1220
+ detail = {"hybrid": hybrid["name"], "named_by": "caller", "confidence": hybrid["confidence"]}
1221
+ cnv["hybrid_replaces_copy"] = detail
1222
+ if hybrid["name"] is None:
1223
+ cnv["flags"].append("hybrid_not_named")
1224
+ if cn <= 0:
1225
+ if whole_deletion is None:
1226
+ return
1227
+ cnv["call"] = whole_deletion + "/" + slot
1228
+ cnv["applied"] = True
1229
+ return
1230
+ candidates = list(dict.fromkeys(a for a in (base_first, base_second) if a))
1231
+ survivor = None
1232
+ if len(candidates) == 1:
1233
+ survivor = candidates[0]
1234
+ elif len(candidates) == 2:
1235
+ lookalike = self.HYBRID_LOOKALIKE.get(self._star_core(hybrid["name"]))
1236
+ seen = [a for a in candidates if self._star_core(a) == lookalike]
1237
+ if lookalike is not None and len(seen) == 1:
1238
+ survivor = candidates[1] if seen[0] == candidates[0] else candidates[0]
1239
+ cnv["applied"] = True
1240
+ if survivor is None:
1241
+ cnv["flags"].append("hybrid_survivor_unresolved")
1242
+ cnv["possible_calls"] = [a + "/" + slot for a in candidates]
1243
+ cnv["call"] = "Indeterminate"
1244
+ return
1245
+ detail["survivor"] = survivor
1246
+ cnv["call"] = survivor + "/" + slot
1247
+
1084
1248
  @staticmethod
1085
1249
  def _canonical_pair_or_join(cis_side, other_side):
1086
1250
  """`A+B` / `C` with the two SLOTS in a stable order. Never reorders within a cis side -
@@ -147,6 +147,14 @@ def main(args=None):
147
147
  'Bare = all genes; --no-ad-arrangement=cyp2d6 = that gene only. Thresholds '
148
148
  '(ad_arrangement_min_sites, _min_depth, _min_margin, _max_deviation, '
149
149
  '_overdispersion, _max_fs, _max_sor) are settable via -p/--parameters JSON.')
150
+ # BT-2787: a tandem the structural caller named and placed (e.g. CYP2D6 *3/*68+*4) becomes the
151
+ # call itself instead of being listed beside an unchanged 2-allele diplotype.
152
+ pgs_compute_parser.add_argument('--hybrid-in-diplotype', dest='hybrid_in_diplotype',
153
+ nargs='?', const='', default=None, metavar='GENES',
154
+ help='write a hybrid tandem named and resolved from the structural caller\'s tags '
155
+ '(HYBRID_ALLELE, HYBRID_TANDEM_WITH or phase) into the call, e.g. CYP2D6 '
156
+ '*3/*68+*4 instead of *3/*4 with the tandem listed under copy_number.tandem. '
157
+ 'DEFAULT: off. Bare = all genes; --hybrid-in-diplotype=cyp2d6 = that gene only.')
150
158
 
151
159
  ### gwas file ###
152
160
  # tsv-to-vcf
@@ -57,6 +57,7 @@ PER_GENE_TOGGLES = {
57
57
  "no_ad_arrangement": ("ad_arrangement", False),
58
58
  "all_model_variants": ("all_model_variants", True),
59
59
  "no_exclude_absent": ("exclude_absent_haplotypes", False),
60
+ "hybrid_in_diplotype": ("hybrid_in_diplotype", True), # BT-2787, default off
60
61
  }
61
62
 
62
63
 
@@ -1,3 +1,3 @@
1
1
 
2
2
  # THIS FILE IS GENERATED FROM SETUP.PY
3
- __version__ = '2.6.3'
3
+ __version__ = '2.6.4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polygenic-pgx
3
- Version: 2.6.3
3
+ Version: 2.6.4
4
4
  Summary: Polygenic score toolkit
5
5
  Home-page: https://github.com/marpiech/polygenic
6
6
  Author: Marcin Piechota, Wojciech Galan
@@ -555,6 +555,32 @@ Proprietary (contact@intelliseq.pl)
555
555
 
556
556
  ## Updates
557
557
 
558
+ ### 2.6.4
559
+
560
+ **CYP2D6/CYP2D7 hybrids named by a structural caller are called as the caller reports them.** When
561
+ the structural record that carries the copy number also carries the caller's hybrid tags
562
+ (`HYBRID_CONFIDENCE` = `named` / `flagged-not-named`, with `HYBRID_ALLELE`, `HYBRID_TANDEM_WITH`,
563
+ `CNTOTAL`, `CNWHOLE`, `KCONV`), those tags decide the name, the tandem and the replaced allele,
564
+ instead of the model's first partial allele and the span of the record:
565
+
566
+ - a copy gain is a **tandem** whatever part of the gene the record spans, never an `xN`; it is
567
+ named from `HYBRID_ALLELE` (`*36x2+*10` when `KCONV` > 1), with the partner from phase or from
568
+ `HYBRID_TANDEM_WITH`. Before, every partial event was named `*68` and a record over >= 90 % of
569
+ the gene went the `xN` path;
570
+ - a hybrid **replacing a whole copy** (a partial `<DEL>`, `CN` = whole copies) replaces the base
571
+ allele its SNVs look like (`*36` -> `*10`, `*4N` -> `*4`): `*3/*4` becomes `*3/*4N`. `CN` 0 is
572
+ `*5/<hybrid>`. A survivor that cannot be told apart makes the call `Indeterminate`, with both
573
+ candidates in `possible_calls`;
574
+ - a hybrid the caller could **not name** stays unnamed (`hybrid_not_named`): it is never called
575
+ `*68`, and its slot is `Indeterminate` when it replaces a copy.
576
+
577
+ New `--hybrid-in-diplotype[=GENES]`, **default off**: a named tandem with a resolved partner
578
+ becomes the call itself (`CYP2D6*3/CYP2D6*68+CYP2D6*4.001`, flag `tandem_in_diplotype`) instead of
579
+ being listed under `copy_number.tandem` beside an unchanged `*3/*4`.
580
+
581
+ Records without `HYBRID_CONFIDENCE` take every earlier path unchanged, so no existing output
582
+ moves. Details: `docs/pgx-cnv.md`.
583
+
558
584
  ### 2.6.3
559
585
 
560
586
  **`cyp2c19-pharmvar-5.1.8` is back, as a second CYP2C19 model you select by name.** It is the
@@ -5,7 +5,7 @@ import setuptools
5
5
  from typing import List
6
6
  from setuptools import setup, find_packages
7
7
 
8
- PACKAGE_VERSION = '2.6.3'
8
+ PACKAGE_VERSION = '2.6.4'
9
9
 
10
10
  def write_version_py(filename='polygenic/version.py'):
11
11
  cnt = """
File without changes
File without changes
File without changes