The Phenotype Toolkit
Project description
PheTK - The Phenotype Toolkit
The official repository of PheTK, a fast python library for Phenome Wide Association Studies (PheWAS) utilizing both phecode 1.2 and phecodeX 1.0.
Reference: Tam C Tran, David J Schlueter, Chenjie Zeng, Huan Mo, Robert J Carroll, Joshua C Denny, PheWAS analysis on large-scale biobank data with PheTK, Bioinformatics, Volume 41, Issue 1, January 2025, btae719, https://doi.org/10.1093/bioinformatics/btae719
Contact: PheTK@mail.nih.gov
Releases: check GitHub Releases for the latest versions and changelogs.
CURRENT MAJOR FUNCTIONALITIES (v0.3 — June 2026)
- Cohort generation - Build genotype-based cohorts from VCF or Hail data, add demographic and genetic covariates. Cohort generation and covariate retrieval require the All of Us Researcher Workbench (CDR v7-v9); custom platforms are supported with user-provided data paths and BigQuery datasets.
- Phecode mapping - Map ICD codes to phecodes (phecode 1.2, phecodeX 1.0), compute counts, age-at-first-event, and time-to-event. ICD extraction from OMOP requires All of Us or a compatible BigQuery dataset; phecode mapping and time-to-event computation work cross-platform with local files.
- PheWAS analysis - Run phenome-wide association studies with logistic, Cox, Firth logistic, and Firth Cox regression. Works cross-platform on any pre-built dataset.
- Visualization - Generate Manhattan plots and Forest plots. Works cross-platform.
- CLI support - Full command-line interface for all modules (
phetk phewas,phetk cohort,phetk phecode) - Distributed computing - Built-in dsub integration for large-scale analyses on Google Cloud on the All of Us Researcher Workbench.
QUICK LINKS
- Installation
- 1-minute PheWAS demo
- PheTK description
- Usage examples
- System requirements & computing resources
- Platform specific tutorial(s):
- All of Us: Tutorial notebooks - Interactive Jupyter notebooks demonstrating PheTK usage on the All of Us Researcher Workbench with various analysis examples. Please note that all examples require All of Us registered user access.
- Changelogs and releases: from v0.1.45, please use GitHub Releases for the latest versions and changelogs. Legacy changelogs were archived in CHANGELOG.md.
- Resource to learn about PheWAS and phecode: The PheWAS Catalog.
1. INSTALLATION
Using pip
The latest version (v0.3+) of PheTK can be installed using the pip install command in the terminal (note that the lowercase package name "phetk" starts from version 0.2+):
pip install phetk --upgrade
Users can also specify a version, e.g., for the last stable version of version 0.1:
pip install phetk==0.1.47
To check current installed version:
pip show phetk | grep Version
Using Docker
Please refer to https://hub.docker.com/r/phetk/phetk/tags for the latest docker images.
docker pull phetk/phetk:latest
2. 1-MINUTE PHEWAS DEMO
User can run the quick 1-minute PheWAS demo with the following command in a terminal:
phetk demo
Or in Jupyter Notebook:
from phetk import demo
demo.run()
The example files (example_cohort.tsv, example_phecode_counts.tsv, and example_phewas_results.tsv)
generated in this Demo should be in users' current working directory.
New-to-PheWAS users could explore these files to get a sense of what data are used or generated in PheWAS with PheTK.
3. DESCRIPTIONS
PheTK is a fast python library for Phenome Wide Association Studies (PheWAS) utilizing both phecode 1.2 and phecodeX 1.0.
Standard PheWAS workflow. Green italicized texts are PheTK module names.
Black components are supported while gray ones are not supported by PheTK currently.
All of Us: the All of Us Research Program (https://allofus.nih.gov/)
4. USAGE
For detailed usage examples and documentation for each module, please refer to the individual module documentation:
- Cohort module - Generate genetic cohorts and add covariates
- Phecode module - Map ICD codes to phecodes and generate counts
- PheWAS module - Run PheWAS analysis with logistic or Cox regression
- Plot module - Generate Manhattan plots and other visualizations
5. SYSTEM REQUIREMENTS
PheTK was developed for efficient processing of large data while being resource-friendly. It was tested on different platforms from laptops to different cloud environments.
General Requirements
PheTK's resource requirements vary by usage context. The information in this section is tailored towards cloud computing platforms where large biobanks are often hosted.
- All PheTK functions run on standard machines. The
by_genotype()Cohort function supports VCF (default, no Spark needed) and Hail (requires a Spark cluster) data formats. - Both logistic regression and Cox regression scale with CPU counts for faster processing. See figure S2 below from PheTK publication for more information. In our experience, 4 CPU machines are the most cost-efficient, especially for large-scale analyses.
- For an end-to-end pipeline, the system requirements should be based on the most demanding steps. For example, for the All of Us data v8/v9, a VM with 16CPU 104GB RAM should work; if users only need to run PheWAS analysis, it can be run at a much lower configuration as shown in figure S2.
Figure S2: Logistic regression performance benchmarks from PheTK publication showing scalability with different CPU configurations and cohort sizes.
PheWAS Module - Logistic Regression
- Minimal resources required - Can run efficiently on lightweight configurations
- Minimum tested configuration: GCP
X-highcpu-4(4 vCPUs, 8GB RAM, X=GCP machine type, e.g., c2d) or equivalent - Uses multithreading for parallel processing with lower memory overhead
PheWAS Module - Cox Regression
- Slightly higher resources required - Uses multiprocessing which demands more memory
- Minimum tested configuration: GCP
X-standard-4(4 vCPUs, 16GB RAM, X=GCP machine type, e.g., c2d) or equivalent - The additional memory accommodates the multiprocessing overhead for survival analysis
Phecode Module (ICD Code Mapping)
- Memory requirements scale with cohort size - Large cohorts require higher memory configurations
- Recommended: For All of Us database v8 with over 500k participants, phecode mapping could be done with a 16 vCPU 104GB RAM machine.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phetk-0.3.3.tar.gz.
File metadata
- Download URL: phetk-0.3.3.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3294af9bbf6ffa5a66649ac2bcf6cc5c1b3cacd5784317a6e3c2aec799a19436
|
|
| MD5 |
0163496bbc554831e3526c3bc2d55a07
|
|
| BLAKE2b-256 |
e150bcb80b9e87333ac5e7d1b45e81e52ae6baa45edc85c54192c4e2d509efaa
|
Provenance
The following attestation bundles were made for phetk-0.3.3.tar.gz:
Publisher:
publish.yml on nhgritctran/PheTK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
phetk-0.3.3.tar.gz -
Subject digest:
3294af9bbf6ffa5a66649ac2bcf6cc5c1b3cacd5784317a6e3c2aec799a19436 - Sigstore transparency entry: 2025330732
- Sigstore integration time:
-
Permalink:
nhgritctran/PheTK@f47902e572c4d37a75569f733c5e4e4e20e26f32 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/nhgritctran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f47902e572c4d37a75569f733c5e4e4e20e26f32 -
Trigger Event:
release
-
Statement type:
File details
Details for the file phetk-0.3.3-py3-none-any.whl.
File metadata
- Download URL: phetk-0.3.3-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
904e85f03aeef98b3a95cccf67efc01677fdc6be4647e8a68c103d2246c68efe
|
|
| MD5 |
e12d9f00dfc6b4c8f9937684fc7bd64c
|
|
| BLAKE2b-256 |
729556aefebb06c67554822cc9c943caa87135519af4938f50caefd6af9bd2f1
|
Provenance
The following attestation bundles were made for phetk-0.3.3-py3-none-any.whl:
Publisher:
publish.yml on nhgritctran/PheTK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
phetk-0.3.3-py3-none-any.whl -
Subject digest:
904e85f03aeef98b3a95cccf67efc01677fdc6be4647e8a68c103d2246c68efe - Sigstore transparency entry: 2025330746
- Sigstore integration time:
-
Permalink:
nhgritctran/PheTK@f47902e572c4d37a75569f733c5e4e4e20e26f32 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/nhgritctran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f47902e572c4d37a75569f733c5e4e4e20e26f32 -
Trigger Event:
release
-
Statement type: