Skip to main content

PheTK - The Phenotype Toolkit

Tests PyPI version Python versions License: GPL v3 DOI

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)

  • Variant selection - Retrieve ClinVar variants for a gene symbol or genomic region with ClinVar.search(), filtering by clinical significance, review star rating, variant type, and allele frequency. Output columns feed directly into by_genotype(). Works cross-platform.
  • Cohort generation - Build genotype-based cohorts from VCF or Hail data with by_genotype(), add demographic and genetic covariates with add_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) with count_phecode(), and compute 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. The bundled mapping tables are also directly loadable via get_phecode_map().
  • 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, Miami, and forest plots. Works cross-platform.
  • CLI support - Full command-line interface for all modules (phetk clinvar, 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.

📋 View full changelog


QUICK LINKS


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.

PheWAS workflow and PheTK modules 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:

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, which is usually phecode mapping. Since v0.2.7, the phecode module uses DuckDB by default, which brought the memory requirement for the full All of Us v8 cohort down substantially: a 4 vCPU / 26GB RAM VM is sufficient for the entire pipeline. If users only need to run PheWAS analysis, it can be run at a much lower configuration as shown in figure S2.

PheTK Performance Benchmarks 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, but the default engine="duckdb" keeps memory bounded via a streaming, spill-capable pipeline
  • Recommended: For All of Us database v8 with over 500k participants, count_phecode() has been tested and runs successfully on a 4 vCPU / 26GB RAM machine with the default DuckDB engine
  • engine="polars" runs fully in memory and is somewhat faster, but needs considerably more RAM — roughly 16 vCPU / 104GB RAM for the full v8 cohort
  • memory_limit sets the DuckDB memory ceiling explicitly; it defaults to ~90% of currently available RAM. See the phecode module docs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phetk-0.3.6.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phetk-0.3.6-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file phetk-0.3.6.tar.gz.

File metadata

  • Download URL: phetk-0.3.6.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for phetk-0.3.6.tar.gz
Algorithm Hash digest
SHA256 e405939c85e5f59a0f1f27aa1d5ce240d1aac60154a0412d0327808efc657372
MD5 596ee7b1756118d11dfe41938afd180e
BLAKE2b-256 36df2a40a8cfae897b7ae0839df3e582f255c5bc775d4c4bb057a3b64958fa96

See more details on using hashes here.

Provenance

The following attestation bundles were made for phetk-0.3.6.tar.gz:

Publisher: publish.yml on nhgritctran/PheTK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phetk-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: phetk-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for phetk-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 777f4d11950d5162ee656f13113b7603f98ff6effcdc3b7d3e558152e5a3830b
MD5 918b48189b62c22323e66e3904893a0c
BLAKE2b-256 2bd5d39a2dd0cc6bf88ea2d6c3418aeff9d038fbd5f63cdf69daff14df18f6ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for phetk-0.3.6-py3-none-any.whl:

Publisher: publish.yml on nhgritctran/PheTK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.6 This release

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

1 file

0.2.1

1 file

0.1.47

2 files

0.1.46

2 files

0.1.45

2 files

0.1.44

2 files

0.1.43

2 files

0.1.42

2 files

0.1.41

2 files

0.1.40

2 files

0.1.39

2 files

0.1.38

2 files

0.1.37

2 files

0.1.36

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.30

2 files

0.1.29

2 files

0.1.28

2 files

0.1.27

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page