Skip to content

Commit 8af1d2a

Browse files
authored
Merge pull request #43 from sbslee/0.11.0-dev
0.11.0 dev
2 parents bce25b1 + 823f990 commit 8af1d2a

218 files changed

Lines changed: 654 additions & 69 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
Changelog
22
*********
33

4+
0.11.0 (2022-01-01)
5+
-------------------
6+
7+
* Add CNV caller for CYP4F2 and SULT1A1.
8+
* Fix minor bug in :command:`compute-copy-number` command.
9+
* Update :command:`plot-cn-af` command to check input files more rigorously.
10+
* Improve CNV caller for CYP2A6, CYP2D6, SLC22A2, and SULT1A1.
11+
* Add new method :meth:`sdk.utils.add_cn_samples` method.
12+
* Update :command:`compare-genotypes` command to output CNV comparison results as well.
13+
* Update :command:`estimate-phase-beagle` command. From now on, the 'chr' prefix in contig names (e.g. 'chr1' vs. '1') will be automatically added or removed as necessary to match the reference VCF’s contig names.
14+
* Add index files for 1KGP reference haplotype panels.
15+
* Add new argument ``--panel`` to :command:`run-chip-pipeline` command.
16+
* Remove 1KGP reference haplotype panels for GSTT1 and UGT2B17 because these genes only have star alleles defined with SV.
17+
* Change 1KGP reference haplotype panels for GRCh38. Previously, PyPGx was using the panels from `Lowy-Gallego et al., 2019 <https://wellcomeopenresearch.org/articles/4-50>`__ where the authors had aligned sequence reads against the full GRCh38 reference, including ALT contigs, decoy, and EBV/IMGT/HLA sequences. This resulted in poor phasing/imputation performance for highly polymorphic PGx genes (e.g. CYP2D6) presumably because the panels were missing haplotype information for lots of SNVs/indels as sequence reads with those variants were mapped to ALT contigs; however, the panels were still the best option at the time (definitely better than lifting over GRCh37 panels). Fortunately, `Byrska-Bishop et al., 2021 <https://www.biorxiv.org/content/10.1101/2021.02.06.430068v2>`__ from New York Genome Center has recently published a new set of GRCh38 panels which apparently has less of this problem despite still having sequence reads aligned in the presence of ALT contigs, etc. When empirically tested, these panels showed a significant increase in phasing/imputation performance. Therefore, from now on, PyPGx will use these panels for GRCh38 data.
18+
* Update GRCh38 variant information for following alleles: CYP2D6\*35, CYP2D6\*45, CYP2D6\*46.
19+
* Update gene region for SLC22A2 to match GRCh37 and GRCh38.
20+
421
0.10.1 (2021-12-20)
522
-------------------
623

@@ -72,7 +89,7 @@ Changelog
7289
* Fix minor bug in :command:`estimate-phase-beagle` command on not properly exiting the program even though there was an error raised by Beagle.
7390
* Update :meth:`api.utils.create_consolidated_vcf` method to check synonymous variants as well when performing phase-extension algorithm.
7491
* Update :command:`run-ngs-pipeline` command to output a warning when user provides CovFrame[DepthOfCoverage] even though target gene does not have any star alleles defined by SVs.
75-
* Add new argument ``--fontsize`` argument to :command:`plot-bam-copy-number` command.
92+
* Add new argument ``--fontsize`` to :command:`plot-bam-copy-number` command.
7693
* Remove ``--ymin`` and ``--ymax`` arguments from :command:`plot-vcf-allele-fraction` command.
7794
* Update ``--ymin`` and ``--ymax`` arguments of :command:`plot-bam-copy-number` command to have a default value.
7895
* Add new command :command:`plot-cn-af`.

README.rst

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,46 @@ you can access a development branch with the ``git checkout`` command. When
158158
you do this, please make sure your environment already has all the
159159
dependencies installed.
160160

161+
Structural variation detection
162+
==============================
163+
164+
Many pharmacogenes are known to have `structural variation (SV)
165+
<https://pypgx.readthedocs.io/en/latest/glossary.html#structural-variation-
166+
sv>`__ such as gene deletions, duplications, and hybrids. You can visit the
167+
`Genes <https://pypgx.readthedocs.io/en/latest/genes.html>`__ page to see the
168+
list of genes with SV.
169+
170+
Some of the SV events can be quite challenging to detect accurately with
171+
next-generation sequencing (NGS) data due to misalignment of sequence reads
172+
caused by sequence homology with other gene family members (e.g. CYP2D6 and
173+
CYP2D7). PyPGx attempts to address this issue by training a `support vector
174+
machine (SVM) <https://scikit-learn.org/stable/modules/generated/sk
175+
learn.svm.SVC.html>`__-based multiclass classifier using the `one-vs-rest
176+
strategy <https://scikit-learn.org/stable/modules/generated/sklearn.multi
177+
class.OneVsRestClassifier.html>`__ for each gene for each GRCh build. Each
178+
classifier is trained using copy number profiles of real NGS samples as well
179+
as simulated ones.
180+
181+
You can plot copy number profile and allele fraction profile with PyPGX to
182+
visually inspect SV calls. Below are CYP2D6 examples:
183+
184+
.. list-table::
185+
:header-rows: 1
186+
:widths: 20 80
187+
188+
* - SV Name
189+
- Profile
190+
* - Normal
191+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-8.png
192+
* - DeletionHet
193+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-1.png
194+
* - Duplication
195+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-2.png
196+
* - Tandem3
197+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-9.png
198+
* - Tandem2C
199+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-7.png
200+
161201
GRCh37 vs. GRCh38
162202
=================
163203

@@ -170,6 +210,15 @@ do this). The good news is, PyPGx supports both of the builds!
170210
In many of the PyPGx actions, you can simply indicate which human genome
171211
build to use. For example, you can use ``assembly`` for the API and
172212
``--assembly`` for the CLI. **Note that GRCh37 will always be the default.**
213+
Below is an example of using the API:
214+
215+
.. code:: python3
216+
217+
>>> import pypgx
218+
>>> pypgx.list_variants('CYP2D6', alleles=['*4'], assembly='GRCh37')
219+
['22-42524947-C-T']
220+
>>> pypgx.list_variants('CYP2D6', alleles=['*4'], assembly='GRCh38')
221+
['22-42128945-C-T']
173222
174223
However, there is one important caveat to consider if your sequencing data is
175224
GRCh38. That is, sequence reads must be aligned only to the main contigs
@@ -314,6 +363,29 @@ Please visit the `Genes <https://pypgx.readthedocs.io/en/latest/
314363
genes.html>`__ page to see the list of genes with a genotype-phenotype
315364
table and each of their prediction method.
316365

366+
To perform phenotype prediction with the API, you can use the
367+
``pypgx.predict_phenotype`` method:
368+
369+
.. code:: python3
370+
371+
>>> import pypgx
372+
>>> pypgx.predict_phenotype('CYP2D6', '*4', '*5') # Both alleles have no function
373+
'Poor Metabolizer'
374+
>>> pypgx.predict_phenotype('CYP2D6', '*5', '*4') # The order of alleles does not matter
375+
'Poor Metabolizer'
376+
>>> pypgx.predict_phenotype('CYP2D6', '*1', '*22') # *22 has uncertain function
377+
'Indeterminate'
378+
>>> pypgx.predict_phenotype('CYP2D6', '*1', '*1x2') # Gene duplication
379+
'Ultrarapid Metabolizer'
380+
381+
To perform phenotype prediction with the CLI, you can use the
382+
``call-phenotypes`` command. It takes a ``SampleTable[Genotypes]`` file as
383+
input and outputs a ``SampleTable[Phenotypes]`` file:
384+
385+
.. code-block:: text
386+
387+
$ pypgx call-phenotypes genotypes.zip phenotypes.zip
388+
317389
Getting help
318390
============
319391

@@ -333,7 +405,7 @@ For getting help on the CLI:
333405
call-genotypes Call genotypes for the target gene.
334406
call-phenotypes Call phenotypes for the target gene.
335407
combine-results Combine various results for the target gene.
336-
compare-genotypes Calculate concordance rate between two genotype results.
408+
compare-genotypes Calculate concordance between two genotype results.
337409
compute-control-statistics
338410
Compute summary statistics for the control gene from BAM files.
339411
compute-copy-number
@@ -385,20 +457,23 @@ Below is the list of submodules available in the API:
385457
- **plot** : The plot submodule is used to plot various kinds of profiles such as read depth, copy number, and allele fraction.
386458
- **utils** : The utils submodule contains main actions of PyPGx.
387459

388-
For getting help on a specific submodule (e.g. utils):
460+
For getting help on a specific submodule (e.g. ``utils``):
389461

390462
.. code:: python3
391463
392464
>>> from pypgx.api import utils
393465
>>> help(utils)
394466
395-
For getting help on a specific method (e.g. predict_phenotype):
467+
For getting help on a specific method (e.g. ``predict_phenotype``):
396468

397469
.. code:: python3
398470
399471
>>> import pypgx
400472
>>> help(pypgx.predict_phenotype)
401473
474+
In Jupyter Notebook and Lab, you can see the documentation for a python
475+
function by hitting ``SHIFT + TAB``. Hit it twice to expand the view.
476+
402477
CLI examples
403478
============
404479

docs/cli.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For getting help on the CLI:
2323
call-genotypes Call genotypes for the target gene.
2424
call-phenotypes Call phenotypes for the target gene.
2525
combine-results Combine various results for the target gene.
26-
compare-genotypes Calculate concordance rate between two genotype results.
26+
compare-genotypes Calculate concordance between two genotype results.
2727
compute-control-statistics
2828
Compute summary statistics for the control gene from BAM files.
2929
compute-copy-number
@@ -137,9 +137,10 @@ compare-genotypes
137137
$ pypgx compare-genotypes -h
138138
usage: pypgx compare-genotypes [-h] [--verbose] first second
139139
140-
Calculate concordance rate between two genotype results.
140+
Calculate concordance between two genotype results.
141141
142-
The command will only use samples that appear in both genotype results.
142+
Only samples that appear in both genotype results will be used to calculate
143+
concordance for genotype calls as well as CNV calls.
143144
144145
Positional arguments:
145146
first First archive file with the semantic type
@@ -149,7 +150,8 @@ compare-genotypes
149150
150151
Optional arguments:
151152
-h, --help Show this help message and exit.
152-
--verbose Whether to print the verbose version of output.
153+
--verbose Whether to print the verbose version of output, including
154+
discordant calls.
153155
154156
compute-control-statistics
155157
==========================
@@ -327,6 +329,10 @@ estimate-phase-beagle
327329
328330
Estimate haplotype phase of observed variants with the Beagle program.
329331
332+
Note that the 'chr' prefix in contig names (e.g. 'chr1' vs. '1') will be
333+
automatically added or removed as necessary to match the reference VCF’s
334+
contig names.
335+
330336
Positional arguments:
331337
imported-variants Archive file with the semantic type VcfFrame[Imported].
332338
phased-variants Archive file with the semantic type VcfFrame[Phased].
@@ -674,7 +680,8 @@ run-chip-pipeline
674680
.. code-block:: text
675681
676682
$ pypgx run-chip-pipeline -h
677-
usage: pypgx run-chip-pipeline [-h] [--assembly TEXT] [--impute] [--force]
683+
usage: pypgx run-chip-pipeline [-h] [--assembly TEXT] [--panel PATH]
684+
[--impute] [--force]
678685
[--samples TEXT [TEXT ...]] [--exclude]
679686
gene output variants
680687
@@ -692,6 +699,9 @@ run-chip-pipeline
692699
-h, --help Show this help message and exit.
693700
--assembly TEXT Reference genome assembly (default: 'GRCh37') (choices:
694701
'GRCh37', 'GRCh38').
702+
--panel PATH VCF file corresponding to a reference haplotype panel
703+
(compressed or uncompressed). By default, the 1KGP
704+
panel is used.
695705
--impute Perform imputation of missing genotypes.
696706
--force Overwrite output directory if it already exists.
697707
--samples TEXT [TEXT ...]

docs/create.py

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,46 @@
185185
you do this, please make sure your environment already has all the
186186
dependencies installed.
187187
188+
Structural variation detection
189+
==============================
190+
191+
Many pharmacogenes are known to have `structural variation (SV)
192+
<https://pypgx.readthedocs.io/en/latest/glossary.html#structural-variation-
193+
sv>`__ such as gene deletions, duplications, and hybrids. You can visit the
194+
`Genes <https://pypgx.readthedocs.io/en/latest/genes.html>`__ page to see the
195+
list of genes with SV.
196+
197+
Some of the SV events can be quite challenging to detect accurately with
198+
next-generation sequencing (NGS) data due to misalignment of sequence reads
199+
caused by sequence homology with other gene family members (e.g. CYP2D6 and
200+
CYP2D7). PyPGx attempts to address this issue by training a `support vector
201+
machine (SVM) <https://scikit-learn.org/stable/modules/generated/sk
202+
learn.svm.SVC.html>`__-based multiclass classifier using the `one-vs-rest
203+
strategy <https://scikit-learn.org/stable/modules/generated/sklearn.multi
204+
class.OneVsRestClassifier.html>`__ for each gene for each GRCh build. Each
205+
classifier is trained using copy number profiles of real NGS samples as well
206+
as simulated ones.
207+
208+
You can plot copy number profile and allele fraction profile with PyPGX to
209+
visually inspect SV calls. Below are CYP2D6 examples:
210+
211+
.. list-table::
212+
:header-rows: 1
213+
:widths: 20 80
214+
215+
* - SV Name
216+
- Profile
217+
* - Normal
218+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-8.png
219+
* - DeletionHet
220+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-1.png
221+
* - Duplication
222+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-2.png
223+
* - Tandem3
224+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-9.png
225+
* - Tandem2C
226+
- .. image:: https://raw.githubusercontent.com/sbslee/pypgx-data/main/dpsv/GRCh37-CYP2D6-7.png
227+
188228
GRCh37 vs. GRCh38
189229
=================
190230
@@ -197,6 +237,15 @@
197237
In many of the PyPGx actions, you can simply indicate which human genome
198238
build to use. For example, you can use ``assembly`` for the API and
199239
``--assembly`` for the CLI. **Note that GRCh37 will always be the default.**
240+
Below is an example of using the API:
241+
242+
.. code:: python3
243+
244+
>>> import pypgx
245+
>>> pypgx.list_variants('CYP2D6', alleles=['*4'], assembly='GRCh37')
246+
['22-42524947-C-T']
247+
>>> pypgx.list_variants('CYP2D6', alleles=['*4'], assembly='GRCh38')
248+
['22-42128945-C-T']
200249
201250
However, there is one important caveat to consider if your sequencing data is
202251
GRCh38. That is, sequence reads must be aligned only to the main contigs
@@ -341,6 +390,29 @@
341390
genes.html>`__ page to see the list of genes with a genotype-phenotype
342391
table and each of their prediction method.
343392
393+
To perform phenotype prediction with the API, you can use the
394+
``pypgx.predict_phenotype`` method:
395+
396+
.. code:: python3
397+
398+
>>> import pypgx
399+
>>> pypgx.predict_phenotype('CYP2D6', '*4', '*5') # Both alleles have no function
400+
'Poor Metabolizer'
401+
>>> pypgx.predict_phenotype('CYP2D6', '*5', '*4') # The order of alleles does not matter
402+
'Poor Metabolizer'
403+
>>> pypgx.predict_phenotype('CYP2D6', '*1', '*22') # *22 has uncertain function
404+
'Indeterminate'
405+
>>> pypgx.predict_phenotype('CYP2D6', '*1', '*1x2') # Gene duplication
406+
'Ultrarapid Metabolizer'
407+
408+
To perform phenotype prediction with the CLI, you can use the
409+
``call-phenotypes`` command. It takes a ``SampleTable[Genotypes]`` file as
410+
input and outputs a ``SampleTable[Phenotypes]`` file:
411+
412+
.. code-block:: text
413+
414+
$ pypgx call-phenotypes genotypes.zip phenotypes.zip
415+
344416
Getting help
345417
============
346418
@@ -364,20 +436,23 @@
364436
Below is the list of submodules available in the API:
365437
366438
{submodule_help}
367-
For getting help on a specific submodule (e.g. utils):
439+
For getting help on a specific submodule (e.g. ``utils``):
368440
369441
.. code:: python3
370442
371443
>>> from pypgx.api import utils
372444
>>> help(utils)
373445
374-
For getting help on a specific method (e.g. predict_phenotype):
446+
For getting help on a specific method (e.g. ``predict_phenotype``):
375447
376448
.. code:: python3
377449
378450
>>> import pypgx
379451
>>> help(pypgx.predict_phenotype)
380452
453+
In Jupyter Notebook and Lab, you can see the documentation for a python
454+
function by hitting ``SHIFT + TAB``. Hit it twice to expand the view.
455+
381456
CLI examples
382457
============
383458

0 commit comments

Comments
 (0)