Skip to content

Commit 79c8d9d

Browse files
authored
Merge pull request #27 from sbslee/0.6.0-dev
0.6.0 dev
2 parents fa8deab + 9f67b9a commit 79c8d9d

23 files changed

+2396
-2025
lines changed

CHANGELOG.rst

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

4+
0.6.0 (2021-10-09)
5+
------------------
6+
7+
* :issue:`25`: Add new extension ``sphinx-issues`` to Read the Docs.
8+
* :issue:`26`: Add new extension ``sphinx.ext.linkcode`` to Read the Docs.
9+
* Add ``by`` argument to :meth:`api.utils.sort_alleles` method. When ``by='name'`` it will sort star alleles by allele number.
10+
* Update :command:`call-genotypes` command to output genotypes with number-sorted alleles (e.g. '\*4/\*10' instead of '\*10/\*4').
11+
* Add new semantic type ``SampleTable[Phenotypes]``.
12+
* Add new method :meth:`api.utils.call_phenotypes`.
13+
* Add new command :command:`call-phenotypes`.
14+
* Add ``--phenotypes`` argument to :command:`combine-results` command.
15+
* Deprecate :meth:`api.utils.load_control_table` method.
16+
* Split ``api.utils`` submodule into two submodules ``api.utils`` and ``api.core``.
17+
* Update :command:`run-ngs-pipeline` command to include phenotype calling step.
18+
* Update :command:`plot-bam-copy-number` command to run faster when ``--samples`` argument is used.
19+
* Change 'Unassigned' genotype to 'Indeterminate' genotype.
20+
* Add new method :meth:`api.core.get_variant_synonyms`.
21+
* Update :meth:`api.core.list_variants` method to accept multiple star alleles.
22+
* Update :command:`predict-alleles` command to support multiallelic variants.
23+
* Update :meth:`api.utils.sort_alleles` method to give priority to non-reference or non-default alleles when breaking ties (i.e. alleles have the same functional status and same number of variants).
24+
* Update variant information for following alleles: CYP2D6\*122, CYP2D6\*127, CYP2D6\*139.
25+
426
0.5.0 (2021-10-02)
527
------------------
628

@@ -23,7 +45,7 @@ Changelog
2345
* Update :command:`create-consolidated-vcf` command to implement phase-extension algorithm.
2446
* Remove ``SO`` and ``Type`` columns from the variant table.
2547
* Update :class:`api.genotype.GSTM1Genotyper` class.
26-
* Update variant information for following alleles: CYP1A2*1C, CYP1A2*1F, CYP1A2*1K, CYP1A2*1L, CYP2B6*17, CYP2D6*15, CYP2D6*21, SLCO1B1*S1, SLCO1B1*S2.
48+
* Update variant information for following alleles: CYP1A2\*1C, CYP1A2\*1F, CYP1A2\*1K, CYP1A2\*1L, CYP2B6\*17, CYP2D6\*15, CYP2D6\*21, SLCO1B1\*S1, SLCO1B1\*S2.
2749
* Add ``NotTargetGeneError`` error.
2850
* Add new method ``api.utils.is_target_gene``.
2951
* Update :command:`run-ngs-pipeline` command to check whether input gene is one of the target genes before attempting to run the pipeline.

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ Notably, all archive files have defined semantic types, which allows us to ensur
136136
- ``SampleTable[Genotypes]``
137137
* TSV file for storing target gene's genotype call for each sample.
138138
* Requires following metadata: ``Gene``, ``Assembly``, ``SemanticType``.
139+
- ``SampleTable[Phenotypes]``
140+
* TSV file for storing target gene's phenotype call for each sample.
141+
* Requires following metadata: ``Gene``, ``SemanticType``.
139142
- ``SampleTable[Results]``
140143
* TSV file for storing various results for each sample.
141144
* Requires following metadata: ``Gene``, ``Assembly``, ``SemanticType``.
@@ -167,6 +170,7 @@ For getting help on the CLI:
167170
positional arguments:
168171
COMMAND
169172
call-genotypes Call genotypes for target gene.
173+
call-phenotypes Call phenotypes for the target gene.
170174
combine-results Combine various results for the target gene.
171175
compute-control-statistics
172176
Compute various statistics for control gene with BAM data.
@@ -211,10 +215,11 @@ For getting help on a specific command (e.g. call-genotypes):
211215
212216
Below is the list of submodules available in the API:
213217

218+
- **core** : The core submodule is the main suite of tools for PGx research.
214219
- **genotype** : The genotype submodule is a suite of tools for accurately predicting genotype calls.
215220
- **pipeline** : The pipeline submodule is used to provide convenient methods that combine multiple PyPGx actions and automatically handle semantic types.
216221
- **plot** : The plot submodule is used to plot various kinds of profiles such as read depth, copy number, and allele fraction.
217-
- **utils** : The utils submodule is the main suite of tools for PGx research.
222+
- **utils** : The utils submodule contains main actions of PyPGx.
218223

219224

220225
For getting help on a specific submodule (e.g. utils):

docs/api.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ This section describes the application programming interface (API) for PyPGx.
1111

1212
Below is the list of submodules available in the API:
1313

14+
- **core** : The core submodule is the main suite of tools for PGx research.
1415
- **genotype** : The genotype submodule is a suite of tools for accurately predicting genotype calls.
1516
- **pipeline** : The pipeline submodule is used to provide convenient methods that combine multiple PyPGx actions and automatically handle semantic types.
1617
- **plot** : The plot submodule is used to plot various kinds of profiles such as read depth, copy number, and allele fraction.
17-
- **utils** : The utils submodule is the main suite of tools for PGx research.
18+
- **utils** : The utils submodule contains main actions of PyPGx.
1819

1920

2021
For getting help on a specific submodule (e.g. utils):
@@ -24,6 +25,12 @@ For getting help on a specific submodule (e.g. utils):
2425
from pypgx.api import utils
2526
help(utils)
2627
28+
core
29+
====
30+
31+
.. automodule:: pypgx.api.core
32+
:members:
33+
2734
genotype
2835
========
2936

docs/cli.rst

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ For getting help on the CLI:
2121
positional arguments:
2222
COMMAND
2323
call-genotypes Call genotypes for target gene.
24+
call-phenotypes Call phenotypes for the target gene.
2425
combine-results Combine various results for the target gene.
2526
compute-control-statistics
2627
Compute various statistics for control gene with BAM data.
@@ -86,31 +87,54 @@ call-genotypes
8687
--alleles PATH Archive file with the semantic type SampleTable[Alleles].
8788
--cnv-calls PATH Archive file with the semantic type SampleTable[CNVCalls].
8889
90+
call-phenotypes
91+
===============
92+
93+
.. code-block:: text
94+
95+
$ pypgx call-phenotypes -h
96+
usage: pypgx call-phenotypes [-h] genotypes phenotypes
97+
98+
########################################
99+
# Call phenotypes for the target gene. #
100+
########################################
101+
102+
Usage examples:
103+
$ pypgx call-phenotypes CYP2D6-genotypes.zip CYP2D6-phenotypes.zip
104+
105+
Positional arguments:
106+
genotypes Archive file with the semantic type SampleTable[Genotypes].
107+
phenotypes Archive file with the semantic type SampleTable[Phenotypes].
108+
109+
Optional arguments:
110+
-h, --help Show this help message and exit.
111+
89112
combine-results
90113
===============
91114

92115
.. code-block:: text
93116
94117
$ pypgx combine-results -h
95-
usage: pypgx combine-results [-h] [--genotypes PATH] [--alleles PATH]
96-
[--cnv-calls PATH]
118+
usage: pypgx combine-results [-h] [--genotypes PATH] [--phenotypes PATH]
119+
[--alleles PATH] [--cnv-calls PATH]
97120
results
98121
99122
################################################
100123
# Combine various results for the target gene. #
101124
################################################
102125
103126
Usage examples:
104-
$ pypgx combine-results CYP2D6-results.zip --genotypes CYP2D6-genotypes.zip --alleles CYP2D6-alleles.zip --cnv-calls CYP2D6-cnv-calls.zip
127+
$ pypgx combine-results CYP2D6-results.zip --genotypes CYP2D6-genotypes.zip --phenotypes CYP2D6-phenotypes.zip --alleles CYP2D6-alleles.zip --cnv-calls CYP2D6-cnv-calls.zip
105128
106129
Positional arguments:
107-
results Archive file with the semantic type SampleTable[Results].
130+
results Archive file with the semantic type SampleTable[Results].
108131
109132
Optional arguments:
110-
-h, --help Show this help message and exit.
111-
--genotypes PATH Archive file with the semantic type SampleTable[Genotypes].
112-
--alleles PATH Archive file with the semantic type SampleTable[Alleles].
113-
--cnv-calls PATH Archive file with the semantic type SampleTable[CNVCalls].
133+
-h, --help Show this help message and exit.
134+
--genotypes PATH Archive file with the semantic type SampleTable[Genotypes].
135+
--phenotypes PATH Archive file with the semantic type SampleTable[Phenotypes].
136+
--alleles PATH Archive file with the semantic type SampleTable[Alleles].
137+
--cnv-calls PATH Archive file with the semantic type SampleTable[CNVCalls].
114138
115139
compute-control-statistics
116140
==========================

docs/conf.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131
'sphinx.ext.autodoc',
3232
'sphinx.ext.napoleon',
3333
'sphinx_rtd_theme',
34+
'sphinx.ext.linkcode',
3435
'autodocsumm',
36+
'sphinx_issues',
3537
]
3638

3739
autodoc_default_options = {
3840
'autosummary': True,
3941
}
4042

43+
issues_github_path = 'sbslee/pypgx'
44+
4145
napoleon_use_param = False
4246

4347
# Add any paths that contain templates here, relative to this directory.
@@ -60,3 +64,52 @@
6064
# relative to this directory. They are copied after the builtin static files,
6165
# so a file named "default.css" will overwrite the builtin "default.css".
6266
html_static_path = []
67+
68+
# -- Add external links to source code with sphinx.ext.linkcode --------------
69+
70+
import inspect
71+
import pypgx
72+
73+
def linkcode_resolve(domain, info):
74+
if domain != 'py':
75+
return None
76+
77+
modname = info['module']
78+
79+
if not modname:
80+
return None
81+
82+
submod = sys.modules.get(modname)
83+
84+
if submod is None:
85+
return None
86+
87+
fullname = info['fullname']
88+
obj = submod
89+
90+
for part in fullname.split('.'):
91+
try:
92+
obj = getattr(obj, part)
93+
except AttributeError:
94+
return None
95+
96+
try:
97+
fn = inspect.getsourcefile(inspect.unwrap(obj))
98+
except TypeError:
99+
fn = None
100+
if not fn:
101+
return None
102+
103+
try:
104+
source, lineno = inspect.getsourcelines(obj)
105+
except OSError:
106+
lineno = None
107+
108+
if lineno:
109+
linespec = f'#L{lineno}-L{lineno + len(source) - 1}'
110+
else:
111+
linespec = ''
112+
113+
fn = os.path.relpath(fn, start=os.path.dirname(pypgx.__file__))
114+
115+
return f'https://github.com/sbslee/pypgx/tree/master/pypgx/{fn}/{linespec}'

docs/create.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import pypgx
55
import pypgx.api
6-
from pypgx.api import utils
6+
from pypgx.api import core
77
from pypgx.cli import commands
88

9-
submodules = ['genotype', 'pipeline', 'plot', 'utils']
9+
submodules = ['core', 'genotype', 'pipeline', 'plot', 'utils']
1010

1111
credit = """
1212
..
@@ -163,6 +163,9 @@
163163
- ``SampleTable[Genotypes]``
164164
* TSV file for storing target gene's genotype call for each sample.
165165
* Requires following metadata: ``Gene``, ``Assembly``, ``SemanticType``.
166+
- ``SampleTable[Phenotypes]``
167+
* TSV file for storing target gene's phenotype call for each sample.
168+
* Requires following metadata: ``Gene``, ``SemanticType``.
166169
- ``SampleTable[Results]``
167170
* TSV file for storing various results for each sample.
168171
* Requires following metadata: ``Gene``, ``Assembly``, ``SemanticType``.
@@ -285,7 +288,7 @@
285288
'Ultrarapid Metabolizer'
286289
""".format(**d)
287290

288-
readme_file = f'{utils.PROGRAM_PATH}/README.rst'
291+
readme_file = f'{core.PROGRAM_PATH}/README.rst'
289292

290293
with open(readme_file, 'w') as f:
291294
f.write(readme.lstrip())
@@ -332,7 +335,7 @@
332335
s += '\n'
333336
cli += s
334337

335-
cli_file = f'{utils.PROGRAM_PATH}/docs/cli.rst'
338+
cli_file = f'{core.PROGRAM_PATH}/docs/cli.rst'
336339

337340
with open(cli_file, 'w') as f:
338341
f.write(cli.lstrip())
@@ -371,7 +374,7 @@
371374
s += '\n'
372375
api += s
373376

374-
with open(f'{utils.PROGRAM_PATH}/docs/api.rst', 'w') as f:
377+
with open(f'{core.PROGRAM_PATH}/docs/api.rst', 'w') as f:
375378
f.write(api.lstrip())
376379

377380
# -- sdk.rst -----------------------------------------------------------------
@@ -394,5 +397,5 @@
394397
395398
""".format(**d)
396399

397-
with open(f'{utils.PROGRAM_PATH}/docs/sdk.rst', 'w') as f:
400+
with open(f'{core.PROGRAM_PATH}/docs/sdk.rst', 'w') as f:
398401
f.write(sdk.lstrip())

docs/genes.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Genes
2+
*****
3+
4+
CYP2D6
5+
======
6+
7+
Some alleles in PharmVar will not be called by PyPGx because one or more of their variants have a high false positive rate, likely due to read misalignment to the *CYP2D7* pseudogene. Those alleles are listed in below table. If problematic variants are present in gnomAD, their links are provided so that you can look at filtering status, allele imbalance for heterozygotes, etc.
8+
9+
.. list-table::
10+
:widths: 25 25 25 25
11+
:header-rows: 1
12+
13+
* - Problematic Variant
14+
- Star Alleles
15+
- GRCh37
16+
- GRCh38
17+
* - rs61745683 (V370I)
18+
- \*122
19+
- `22-42523514-C-T <https://gnomad.broadinstitute.org/variant/22-42523514-C-T?dataset=gnomad_r2_1>`__
20+
- `22-42127512-C-T <https://gnomad.broadinstitute.org/variant/22-42127512-C-T?dataset=gnomad_r3>`__
21+
* - rs1058172 (R365H)
22+
- \*139
23+
- `22-42523528-C-T <https://gnomad.broadinstitute.org/variant/22-42523528-C-T?dataset=gnomad_r2_1>`__
24+
- `22-42127526-C-T <https://gnomad.broadinstitute.org/variant/22-42127526-C-T?dataset=gnomad_r3>`__
25+
* - rs202102799 (Y355C)
26+
- \*127
27+
- `22-42523558-T-C <https://gnomad.broadinstitute.org/variant/22-42523558-T-C?dataset=gnomad_r2_1>`__
28+
- `22-42127556-T-C <https://gnomad.broadinstitute.org/variant/22-42127556-T-C?dataset=gnomad_r3>`__

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Welcome to PyPGx's documentation!
66
:caption: Contents:
77

88
readme
9+
genes
910
tutorials
1011
dpsv
1112
cli

0 commit comments

Comments
 (0)