Pipelines¶
Filter, TMM, fit, test and table in one call. Worked through in Bulk differential expression and Pseudobulk with bixverse.
edgeR and limma-voom differential expression, in Rust.
NumPy in, polars out. Counts are (n_genes, n_samples) as in edgeR, every
index is 0-based, and a design is a NumPy matrix or a polars frame whose column
names become coefficient names.
One call:
>>> res = edge_rs.run_edger_ql(counts, design, feature_ids=genes, coef="treated")
>>> res = edge_rs.run_limma_voom(counts, design, feature_ids=genes, coef="treated")
Step by step, as in edgeR and limma:
>>> keep = edge_rs.filter_by_expr(counts, design=design)
>>> lib = counts.sum(axis=0)
>>> nf = edge_rs.calc_norm_factors(counts[keep], lib_size=lib)
>>> fit = edge_rs.glm_ql_fit(counts[keep], design, lib_size=lib, norm_factors=nf)
>>> edge_rs.top_tags(edge_rs.glm_ql_ftest(fit, coef="treated"))
NEBULA on an AnnData, cells x genes as scanpy keeps them, with the
anndata extra:
>>> fit = edge_rs.nebula(adata, "donor", "~ condition", genes=hvgs)
>>> res = fit.test(coef="condition[T.treated]")
device="gpu" runs its penalised fits on the wgpu device; gpu_available()
says whether this machine has one.
Every function that takes counts also takes a DgeList from make_dgelist,
which carries lib_size and norm_factors and keeps the library sizes of the
full matrix through a gene subset.
run_edger_ql
¶
run_edger_ql(
counts: ndarray,
design: Design,
*,
feature_ids: Labels | None = None,
coef: Coef | None = None,
contrast: Contrast | None = None,
norm_method: NormMethod = "TMM",
filter: bool = True,
robust: bool = False,
legacy: bool = False,
) -> DataFrame
edgeR's quasi-likelihood pipeline in one call.
filter_by_expr, calc_norm_factors, glm_ql_fit, glm_ql_ftest and
top_tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counts
|
ndarray
|
|
required |
design
|
Design
|
|
required |
feature_ids
|
Labels | None
|
One id per row of |
None
|
coef
|
Coef | None
|
0-based design column(s) or names to test. |
None
|
contrast
|
Contrast | None
|
Weights over the design columns. Exclusive with |
None
|
norm_method
|
NormMethod
|
Normalisation, see |
'TMM'
|
filter
|
bool
|
Run |
True
|
robust
|
bool
|
Robust empirical Bayes. |
False
|
legacy
|
bool
|
edgeR's pre-4.0 pipeline. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
row per gene that passed the filter, in input order. |
References
Chen, Lun and Smyth, F1000Research, 2016.
run_limma_voom
¶
run_limma_voom(
counts: ndarray,
design: Design,
*,
feature_ids: Labels | None = None,
coef: int | str | None = None,
contrast: Contrast | None = None,
norm_method: NormMethod = "TMM",
filter: bool = True,
robust: bool = False,
span: float = 0.5,
adaptive_span: bool = True,
proportion: float = 0.01,
) -> DataFrame
limma-voom in one call.
filter_by_expr, calc_norm_factors, voom_lm_fit, contrasts_fit when
a contrast is given, ebayes and top_table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counts
|
ndarray
|
|
required |
design
|
Design
|
|
required |
feature_ids
|
Labels | None
|
One id per row of |
None
|
coef
|
int | str | None
|
0-based design column or name to test. |
None
|
contrast
|
Contrast | None
|
A single contrast over the design columns. Exclusive with
|
None
|
norm_method
|
NormMethod
|
Normalisation, see |
'TMM'
|
filter
|
bool
|
Run |
True
|
robust
|
bool
|
Robust empirical Bayes. |
False
|
span
|
float
|
Lowess span for the voom trend, used only without
|
0.5
|
adaptive_span
|
bool
|
Pick the span from the number of genes. |
True
|
proportion
|
float
|
Assumed proportion of differentially expressed genes. |
0.01
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
filter, in input order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On both |
References
Law, Chen, Shi and Smyth, Genome Biology, 2014.