Skip to main content

array_weights

Function array_weights 

Source
pub fn array_weights(
    y: &[f64],
    n_genes: usize,
    n_samples: usize,
    design: &[f64],
    n_coef: usize,
    weights: Option<&Recycled<f64>>,
    params: Option<ArrayWeightParams>,
) -> Result<Vec<f64>, EdgeErrors>
Expand description

Per-sample quality weights, limma’s arrayWeights.

Sample j has residual variance sigma_g^2 / w_j, shared across genes. A weight below one marks a noisier array; the logs of the weights sum to zero over the variance design. The estimator is REML on the variance components, solved per gene or pooled (see ArrayWeightMethod). Both return all-ones weights when there is nothing to estimate from: fewer than two genes, or fewer than two residual degrees of freedom.

Zero weights become missing expression values and unit weights, as in limma, so the gene-by-gene sweep skips those observations.

§Params

  • y - Row-major n_genes * n_samples log-expression values. Non-finite entries are treated as missing.
  • n_genes - Number of genes
  • n_samples - Number of samples
  • design - Row-major n_samples * n_coef design matrix
  • n_coef - Number of design columns. A rank deficient design is reduced to its independent columns rather than rejected.
  • weights - Optional gene by sample observation weights, non-negative
  • params - See ArrayWeightParams; None takes the defaults

§Returns

One weight per sample, or EdgeErrors on a shape mismatch, an invalid weight, an out-of-domain parameter, or a singular information matrix.

§edgePython

edgepython/voom_lmfit.py:834 differs from limma in five places (no .arrayWeightsPrWtsREML, fully pivoted QR, pinv for solve, clamping, looser gene admission). This follows limma. See UPSTREAM_DEVIATIONS.md A14.

§References

Ritchie, Diyagama, Neilson, van Laar, Dobrovic, Holloway and Smyth, BMC Bioinformatics 7:261, 2006