Skip to main content

pyedger

A pure-Python port of Bioconductor edgeR (Robinson, McCarthy & Smyth, Bioinformatics 2010) — negative-binomial models for differential expression of count data.

  • No rpy2, no R install — the edgeR negative-binomial GLM workflow reimplemented in NumPy / SciPy, vectorised over genes
  • Matches Bioconductor edgeR 4.10 numerically (see Numerical parity)
  • The canonical pipelines: DGEList → calcNormFactors → estimateDisp → glmQLFit → glmQLFTest and the classic exactTest
  • TMM normalization, common / trended / tagwise dispersion, GLM and quasi-likelihood F-tests, filterByExpr, cpm / aveLogCPM
  • Both Python-style (glm_fit, estimate_disp, top_tags) and R-style (glmFit, estimateDisp, topTags) names exported

This is a standalone mirror of the implementation developed in omicverse, where it powers the edgeR differential-expression backend of ov.bulk / pyDEG.

Install

pip install pyedger

Genes are processed in parallel; the number of threads follows numba's NUMBA_NUM_THREADS (or PYEDGER_NUM_THREADS). Results do not depend on it.

Quick start

The calls mirror an edgeR script line by line.

import numpy as np
import pandas as pd
import pyedger

# counts: genes x samples DataFrame of raw counts; group: one label per sample
group = pd.Categorical(group, categories=["control", "treated"])   # first level = reference
y = pyedger.DGEList(counts, group=group)
keep = pyedger.filterByExpr(y)
y = y.subset(keep, keep_lib_sizes=False)        # R: y[keep, , keep.lib.sizes = FALSE]
y = pyedger.normLibSizes(y)                      # TMM

design = np.column_stack([np.ones(len(group)), group == "treated"]).astype(float)   # ~ group
y = pyedger.estimateDisp(y, design)

# Quasi-likelihood F-test (the recommended edgeR pipeline)
fit = pyedger.glmQLFit(y, design)
qlf = pyedger.glmQLFTest(fit, coef=1)            # 0-based: R's coef = 2
res = pyedger.topTags(qlf, n=np.inf)

Classic exact test

y = pyedger.estimateDisp(y)                      # classic mode, no design
et = pyedger.exactTest(y, pair=("control", "treated"))
pyedger.topTags(et)

Differences from R to keep in mind

  • Coefficients are 0-based (coef=1 is R's coef = 2); coefficient names are also accepted.
  • y[keep] keeps the original library sizes, as R's default does; use y.subset(keep, keep_lib_sizes=False) for keep.lib.sizes = FALSE.
  • pyedger 0.2.x tracks edgeR 4.10.5. Results from edgeR < 4.2 differ (new QL method); glmQLFit(legacy=True) gives the classic one.

API

Python R counterpart
DGEList DGEList
calc_norm_factors / calcNormFactors calcNormFactors (TMM)
filter_by_expr / filterByExpr filterByExpr
estimate_disp / estimateDisp estimateDisp
glm_fit / glmFit, glm_lrt / glmLRT glmFit, glmLRT
glm_ql_fit / glmQLFit, glm_qlf_test / glmQLFTest glmQLFit, glmQLFTest
exact_test / exactTest exactTest
glm_treat / glmTreat glmTreat
cpm, ave_log_cpm / aveLogCPM cpm, aveLogCPM
top_tags / topTags topTags
decide_tests_dge / decideTests decideTestsDGE
DGEGLM, DGELRT, DGEExact, TestResults the corresponding S4 classes

Numerical parity with edgeR

tests/test_r_parity.py checks pyedger against edgeR 4.10.5 (R 4.5.3, limma 3.68.5, locfit 1.5-9.12) on a paired design with zero-count library pairs, a Milo-style design and limma hyperparameter cases; the reference values are regenerated by tests/data/make_reference.R. The GLM kernels follow edgeR's compiled code step by step and run vectorised over all genes:

Step Ported from Agreement with R
glmFit (Levenberg, one-way shortcut, start values) glm.c ~1e-9
estimateDisp with a design (Cox-Reid APL, zero-fit groups) and classic mode compute_apl.c, q2qnbinom ~1e-10
Trend: locfitByCol locfit tree evaluation + interpolation bit-identical
squeezeVar (fitFDist, fitFDistUnequalDF1, fitFDistRobustly) limma 3.68 ~1e-11
glmQLFit(legacy=False) (new QL) given a dispersion ql_glm.c ~1e-9
glmQLFit(legacy=True), exactTest, glmTreat ~1e-10

glmQLFit(legacy=False) without a dispersion and estimateGLMCommonDisp estimate the NB dispersion with edgeR's optimize(tol=1e-5) over dispersion^(1/4); R's own value is only defined to ~4e-5 relative, and agreement there is at that level (p-values ~1e-4 relative on the test data). On real data the agreement is usually much closer: on four GSE274113 pseudobulk ATAC comparisons (~170k peaks x 26 samples, ~ library + condition, default new QL) p-values agreed to < 1e-7 relative with identical FDR < 0.1 calls.

Defaults follow edgeR 4.10: glmQLFit(legacy=False, abundance_trend=True), estimateDisp(prior_df=None) with the chooseLowessSpan span.

Citation

Robinson, M.D., McCarthy, D.J., Smyth, G.K. edgeR: a Bioconductor package for differential expression analysis of digital gene expression data. Bioinformatics 26(1), 139–140 (2010).

…and acknowledge omicverse / this repo for the Python port.

License

LGPL-3.0-or-later — matches the upstream Bioconductor package.

Metadata

Release files for pyedger 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyedger 0.2.3
File Size Uploaded Provenance Actions
pyedger-0.2.3.tar.gz 105.2 kB With provenance Details for pyedger-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyedger 0.2.3
File Interpreter ABI Platform Actions
pyedger-0.2.3-py3-none-any.whl Python 3 none any Details for pyedger-0.2.3-py3-none-any.whl

Total release size: 203.5 kB

Release files / pyedger-0.2.3.tar.gz

Download URL pyedger-0.2.3.tar.gz
Size 105.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f97416c1d21180917599ecb82b990b655e86253cb84b477485df18f6a5a3325a
BLAKE2b-256 checksum
How to use checksums
3a7ead2847d0f6f5e02ac2c64a95f8e121ff34146801b35e120335309f1922dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / pyedger-0.2.3-py3-none-any.whl

Download URL pyedger-0.2.3-py3-none-any.whl
Size 98.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4b22ab2d5dd9256008627e04a62223248a8d8cf0c6e375990d7141a00942b3b
BLAKE2b-256 checksum
How to use checksums
309e6e2bcb78b35e36abdc4ee40d993058cbdb390093d17add50301dba04ab95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for pyedger 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyedger-0.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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