1. Overview
CpGtools is a Python package providing command-line tools for DNA methylation data analysis. It supports data from Illumina methylation arrays (450K, EPIC, and EPIC v2) and bisulfite sequencing platforms such as RRBS and WGBS.
Most CpGtools commands that operate on methylation matrices expect CpGs in rows and samples in columns, unless otherwise stated by the individual command.
Some key functions of CpGtools include:
Basic data manipulation (e.g., quality control, annotation, visualization, and Beta-to-M value transformation)
Dimensionality reduction (PCA, t-SNE, and UMAP)
Missing-value imputation (KNN, Random Forest, iterative linear regression, and MOREL [Ma2026])
Cell-type deconvolution (12 immune cell types)
Differential methylation analysis (linear regression, logistic regression, beta-binomial regression, t-test, ANOVA, and Bayesian methods)
Epigenetic clock estimation (30+ clocks for humans, mice, and mammals)
Phenotype prediction (multiple traits; under development)
The main command groups are summarized below.
1.1. CpG Position Analysis
Tools for annotating CpGs and characterizing/visualizing their genomic distribution.
Command |
Description |
|---|---|
|
Aggregate CpG methylation values within genomic regions. |
|
Annotate CpGs using genomic coordinates. |
|
Annotate Illumina 450K, EPIC, and EPIC v2 probes. |
|
Calculate CpG density across gene-centered regions. |
|
Summarize the chromosomal distribution of CpGs. |
|
Summarize CpG distribution across gene-centered features. |
|
Summarize CpG distribution across user-defined regions. |
|
Generate sequence logos for CpGs and flanking sequences. |
|
Assign CpGs to putative target genes using a GREAT-like approach. |
1.2. CpG Signal Analysis
Tools for transforming, summarizing, visualizing, and exploring DNA methylation matrices.
Command |
Description |
|---|---|
|
Correct batch effects using ComBat. |
|
Visualize sample methylation distributions. |
|
Convert between Beta-values and M-values. |
|
Perform principal component analysis. |
|
Plot methylation profiles across gene-centered regions. |
|
Plot methylation profiles across user-defined regions. |
|
Select informative CpGs using feature-selection methods. |
|
Summarize methylation states with stacked bar plots. |
|
Calculate methylation statistics. |
|
Select highly variable CpGs. |
|
Classify CpGs into methylation states. |
|
Perform t-SNE dimensionality reduction. |
|
Perform UMAP dimensionality reduction. |
1.3. Differential Methylation Analysis
Tools for identifying differentially methylated CpGs (DMCs) using array Beta-values or sequencing-derived methylation counts.
Command |
Description |
|---|---|
|
Bayesian differential methylation analysis. |
|
Beta-binomial analysis of RRBS/WGBS methylation counts. |
|
Fisher’s exact test for sequencing-derived methylation counts. |
|
Generalized linear model analysis. |
|
Logistic-regression analysis of methylation counts. |
|
Mann–Whitney U and Kruskal–Wallis tests. |
|
Student’s t-test for methylation-array data. |
1.4. Missing-value Imputation
beta_impute provides a unified interface for detecting, simulating,
evaluating, and imputing missing values in methylation matrices. Imputation
performance can optionally be evaluated against a truth matrix using MAE,
RMSE, and \(R^2\).
Method |
Brief description |
|---|---|
|
Replace all missing values with a user-specified constant. |
|
Replace missing values with row-wise or column-wise means. |
|
Replace missing values with row-wise or column-wise medians. |
|
Replace missing values with row-wise or column-wise minima or maxima. |
|
Replace missing values using randomly selected observed values from the same row or column. |
|
Use K-nearest neighbors from an external complete reference matrix. |
|
Impute from neighboring values in a moving window using the mean or median. |
|
Use scikit-learn KNN imputation within the input methylation matrix. |
|
Iterative regression imputation based on the method of Buck (1960). |
|
Iteratively predict missing values with Random Forest regression. |
|
Low-rank matrix completion using iterative soft-thresholded SVD. |
|
Impute systematic block-wise missingness using Random Forest or a dense neural network, with KNN for sporadic missing values. |
|
Impute from genomically neighboring CpGs, optionally restricted by candidate cis-regulatory elements. |
The command also provides utilities such as toy, insertna,
dropna, and countna for generating test matrices and inspecting
missingness.
For details, see beta_impute.
Tao Ma, Jinfu Nie, Jian Huang, Yong-Biao Zhang, Joanna M. Biernacka, Liguo Wang. Multi-output learning for systematic missing value imputation in DNA methylation arrays. Bioinformatics Advances, Volume 6, Issue 1, 2026, vbag052. https://doi.org/10.1093/bioadv/vbag052
1.5. Cell-type Deconvolution
beta_deconvolution estimates cell-type proportions from bulk DNA
methylation profiles using NNLS or constrained least-squares methods.
The current reference panel includes the following 12 cell types labeled in red text:
Use beta_deconvolution -h for input requirements and available options.
1.6. Epigenetic Aging Analysis
epical provides a unified interface for DNA methylation age prediction
and related epigenetic aging measures. It includes human, pediatric,
gestational-age, tissue-specific, mouse, and pan-mammalian models.
Clock / model |
Brief description |
|---|---|
|
Original Horvath multi-tissue human DNAm age clock. |
|
Reduced-CpG version of the Horvath multi-tissue clock. |
|
Horvath skin-and-blood clock for several cultured and primary tissues. |
|
DNAm PhenoAge, developed to capture aging-related phenotypic risk in blood. |
|
Blood-based human DNAm age clock. |
|
Zhang human age predictor fitted using elastic-net regression. |
|
Zhang human age predictor based on a BLUP model. |
|
Deep-learning DNAm age predictor. |
|
DNA methylation estimator of telomere length. |
|
Compact human blood DNAm age predictor. |
|
Human DNAm age predictor based on age-associated CpGs. |
|
Epigenetic age model based on the EN/Cen 100-CpG signature. |
|
Reduced 40-CpG version of the EN/Cen model. |
|
Estimates the pace of biological aging rather than chronological age. |
|
Pediatric DNAm age model. |
|
Pediatric buccal epigenetic age clock. |
|
Gestational-age predictor developed by Bohlin and colleagues. |
|
Gestational-age predictor developed by Haftorn and colleagues. |
|
Gestational-age predictor developed by Knight and colleagues. |
|
Gestational-age predictor developed by Mayne and colleagues. |
|
Lee gestational-age model based on cord-blood cell proportions/CpGs. |
|
Lee robust placental/gestational-age model. |
|
Refined version of the Lee RPC gestational-age model. |
|
DNAm age clock optimized for human cortical tissue. |
|
Muscle Epigenetic Age Test for skeletal muscle. |
|
Epigenetic Pacemaker model for estimating epigenetic state changes. |
|
Whole-lifespan, multi-tissue mouse DNAm age clock. |
|
Multi-tissue mouse DNAm age predictor. |
|
Mouse liver-specific DNAm age predictor. |
|
Mouse blood-specific DNAm age predictor. |
|
Pan-mammalian multi-tissue DNAm age clock. |
|
Pan-mammalian multi-tissue DNAm age clock using an alternative CpG set. |
|
Pan-mammalian multi-tissue DNAm age clock using an alternative CpG set. |
Use epical -h to list available clocks and epical CLOCK -h for
clock-specific requirements.
1.7. Command-line Usage
CpGtools commands are installed as console programs. Use -h or
--help to display command-specific input requirements and options, for
example:
epical -h
beta_impute -h
beta_deconvolution -h
dmc_bb -h
Individual commands may require specialized input formats. See the corresponding documentation pages for detailed examples.