Class MeanVarianceEstimator

java.lang.Object
ubic.basecode.math.linearmodels.MeanVarianceEstimator

public class MeanVarianceEstimator extends Object
Estimate mean-variance relationship and use this to compute weights for least squares fitting. R's limma.voom() Charity Law and Gordon Smyth. See Law et al.

Running voom() on data matrices with NaNs is not currently supported.

Author:
ptan
  • Constructor Details

    • MeanVarianceEstimator

      public MeanVarianceEstimator(DesignMatrix designMatrix, DoubleMatrix<String,String> data, DoubleMatrix1D librarySize)
      Preferred interface if you want control over how the design is set up. Executes voom() to calculate weights.
      Parameters:
      designMatrix -
      data - expected to be log2cpm, and already filtered
      librarySize - library size (matrix column sum)
    • MeanVarianceEstimator

      public MeanVarianceEstimator(DesignMatrix designMatrix, DoubleMatrix2D data, DoubleMatrix1D librarySize)
      Executes voom() to calculate weights.
      Parameters:
      designMatrix -
      data - a normalized count matrix
      librarySize - library size (matrix column sum)
    • MeanVarianceEstimator

      public MeanVarianceEstimator(DoubleMatrix2D data)
      Generic method for calculating mean and variance, as a data diagnostic.

      voom() is not executed and therefore no weights are calculated.

      Parameters:
      data - data to be processed
  • Method Details

    • getLibrarySize

      public DoubleMatrix1D getLibrarySize()
      Returns:
      total library size
    • getLoess

      public DoubleMatrix2D getLoess()
      Returns:
      the loess fit of the mean-variance relationship
    • getMeanVariance

      public DoubleMatrix2D getMeanVariance()
      Returns:
      the mean and variance of the normalized data, columns 0 and 1 respectively
    • getNormalizedValue

      public DoubleMatrix2D getNormalizedValue()
      Returns:
      data, as supplied (should be log2cpm)
    • getWeights

      public DoubleMatrix2D getWeights()
      Returns:
      inverse variance weights if voom was applied
    • quarterRootVariance

      protected DoubleMatrix1D quarterRootVariance(LeastSquaresFit lsf)