delnx.tl.nb_deΒΆ

delnx.tl.nb_de(adata, condition_key=None, formula=None, design=None, design_column_names=None, reference=None, covariate_keys=None, size_factors='normed_sum', layer=None, contrast=None, multitest_method='fdr_bh', lfc_threshold=0.0, overdispersion=True, batch_size=512, maxiter=100, verbose=True, overdispersion_shrinkage=True, do_cox_reid_adjustment=True)[source]ΒΆ

One-shot negative binomial DE: fit model and test in one call.

Convenience wrapper around nb_fit() + nb_test(). For reusing a fit across multiple contrasts, call them separately.

Parameters:
  • adata (AnnData) – AnnData object containing count data.

  • condition_key (str | None (default: None)) – Column in adata.obs for condition labels. Mutually exclusive with formula.

  • formula (str | None (default: None)) – R-style formula for the design matrix (e.g., "~ treatment + batch"). Mutually exclusive with condition_key.

  • design (ndarray | None (default: None)) – Custom design matrix. Overrides condition_key and formula.

  • design_column_names (list[str] | None (default: None)) – Column names for a custom design matrix.

  • reference (str | None (default: None)) – Reference level for the condition.

  • covariate_keys (list[str] | None (default: None)) – Columns in adata.obs to include as covariates.

  • size_factors (str | ndarray | None (default: 'normed_sum')) – Size factors for normalization.

  • layer (str | None (default: None)) – Layer in adata.layers containing counts.

  • contrast (str | int | None (default: None)) – Contrast to test (passed to nb_test()).

  • multitest_method (str (default: 'fdr_bh')) – Method for multiple testing correction.

  • lfc_threshold (float (default: 0.0)) – Minimum absolute log2 fold change threshold.

  • overdispersion (bool (default: True)) – Whether to estimate overdispersion.

  • batch_size (int (default: 512)) – Number of genes per batch.

  • maxiter (int (default: 100)) – Maximum iterations for Newton-Raphson.

  • verbose (bool (default: True)) – Whether to show progress.

  • overdispersion_shrinkage (bool (default: True)) – Whether to apply quasi-likelihood shrinkage.

  • do_cox_reid_adjustment (bool (default: True)) – Whether to apply Cox-Reid adjustment.

Return type:

DataFrame

Returns:

pd.DataFrame DE results (same as nb_test()).

Examples

Simple condition comparison:

>>> results = dx.tl.nb_de(adata, condition_key="treatment", reference="control")

Formula-based with covariates:

>>> results = dx.tl.nb_de(adata, formula="~ treatment + batch",
...                       contrast="treatment[T.drugA]")