pylimma.voom

pylimma.voom(counts, design=None, lib_size=None, offset=None, offset_prior=None, normalize_method='none', block=None, correlation=None, weights=None, span=0.5, adaptive_span=True, plot=False, save_plot=False, *, out_layer='voom_E', weights_layer='voom_weights', key='voom', layer=None)[source]

Transform RNA-seq counts for linear modelling with mean-variance weighting.

Transforms count data to log2-counts per million (log-CPM), estimates the mean-variance relationship, and computes observation weights that can be used in weighted linear models via lm_fit().

Parameters:
  • counts (ndarray) – Matrix of counts, shape (n_genes, n_samples). Must be non-negative with no NA values.

  • design (ndarray, optional) – Design matrix, shape (n_samples, n_coefficients). If None, uses an intercept-only model.

  • lib_size (ndarray, optional) – Library sizes for each sample. If None, computed as column sums of counts.

  • offset (ndarray, optional) – Offset matrix, shape (n_genes, n_samples). If provided without offset_prior, offset_prior is computed as offset - rowMeans(offset).

  • offset_prior (ndarray, optional) – Pre-centered offset matrix, shape (n_genes, n_samples). Applied as: lib_size_matrix = exp(log(lib_size_matrix) + offset_prior). Takes precedence over offset if both are provided.

  • normalize_method (str, default "none") – Normalization method. Currently only “none” is supported.

  • block (ndarray, optional) – Factor indicating blocking structure for samples.

  • correlation (float, optional) – Intra-block correlation (required if block is specified).

  • weights (ndarray, optional) – Prior weights for samples or observations.

  • span (float, default 0.5) – LOWESS span for trend fitting (used if adaptive_span=False).

  • adaptive_span (bool, default True) – If True, choose span adaptively based on number of genes.

  • save_plot (bool, default False) – If True, include trend data in output for plotting.

  • plot (bool)

  • out_layer (str)

  • weights_layer (str)

  • key (str)

  • layer (str | None)

Returns:

Endarray

Log2-CPM expression matrix, shape (n_genes, n_samples).

weightsndarray

Precision weights, shape (n_genes, n_samples).

designndarray

Design matrix used for fitting.

lib_sizendarray

Library sizes.

spanfloat, optional

LOWESS span used (only if adaptive_span=True).

voom_xydict, optional

Trend data for plotting (only if save_plot=True).

voom_linedict, optional

LOWESS fit for plotting (only if save_plot=True).

offset_priorndarray, optional

The offset_prior matrix used (only if offset or offset_prior provided).

Return type:

dict

Notes

The voom method [1] transforms count data to log2-CPM, then estimates the mean-variance trend from the residual standard deviations of a preliminary linear model fit. The trend is used to compute precision weights for each observation.

References