limma_contrasts: Apply limma's lmFit, contrasts.fit, & eBayes to one or more...

View source: R/limma_contrasts.R

limma_contrastsR Documentation

Apply limma's lmFit, contrasts.fit, & eBayes to one or more contrasts and return a table

Description

Apply limma's lmFit, contrasts.fit, & eBayes to one or more contrasts, and return a table. See examples in vignette.

Usage

limma_contrasts(
  object,
  grp = NULL,
  contrast.v,
  design = NULL,
  weights = NA,
  trend = FALSE,
  ndups = NULL,
  spacing = NULL,
  block = NULL,
  correlation = NULL,
  adjust.method = "BH",
  add.means = !is.null(grp),
  treat.lfc = NULL,
  moderated = TRUE,
  check.names = TRUE,
  cols = c("P.Value", "adj.P.Val", "logFC")
)

Arguments

object

Matrix-like data object containing log-ratios or log-expression values, with rows corresponding to features (e.g. genes) and columns to samples. Must have row names that are non-duplicated and non-empty.

grp

Vector of sample groups. These must be valid variable names in R and the same length as ncol(object).

contrast.v

Named vector of contrasts, passed to makeContrasts.

design

Design matrix of the experiment, with rows corresponding to samples and columns to coefficients to be estimated.

weights

Non-negative observation weights. Can be a numeric matrix of individual weights of same size as the object, or a numeric vector of sample weights with length ncol(object), or a numeric vector of gene weights with length equal to nrow(object). Set to NULL to ignore object$weights. weights=NA (with length one) doesn't pass weights to limma.

trend

Logical; should an intensity-trend be allowed for the prior variance? Default is that the prior variance is constant.

ndups

Positive integer giving the number of times each distinct probe is measured in each sample. See Details.

spacing

Positive integer giving the spacing between duplicate occurrences of the same probe, with spacing=1 for consecutive rows. See Details.

block

Vector specifying a blocking variable on the samples. Has length = ncol(object). Must be NULL if ndups > 1.

correlation

Inter-duplicate or inter-technical replicate correlation. Must be given if ndups>1 or !is.null(block).

adjust.method

Method used to adjust the p-values for multiple testing. Options, in increasing conservatism, include "none", "BH", "BY", and "holm". See p.adjust for the complete list of options. A NULL value will result in the default adjustment method, which is "BH".

add.means

Logical indicating if (unweighted) group means per row should be added to the output.

treat.lfc

Vector of logFC passed to treat lfc. It is recycled as needed to match rows of object. If given, length(contrast.v) must be 1. McCarthy & Smyth suggest a 10 which is treat.lfc=log2(1.1).

moderated

Logical; should eBayes be used? Otherwise an unmoderated version for limma to produce ordinary least squares statistics is used.

check.names

Logical; should names(grp)==rownames(object) be checked? Ignored if is.null(design) and add.means is FALSE.

cols

Columns of topTable output to include. Possibilities include "logFC", "AveExpr", "z", "t", "P.Value", "adj.P.Val", "B". Some of these column names are then changed here. If logFC is specified, FC will automatically also be given.

Details

If design is NULL and grp is given, design will be calculated as model.matrix(~0+grp). However, grp isn't needed if design is provided & add.means is FALSE.

The defaults of arguments ndups and spacing are set to NULL, which allows these arguments to be overridden by the elements object$printer$ndups and object$printer$spacing, respectively, if these exist. Whereas, if an element does not exist, the corresponding argument is treated as being its default in lmFit, i.e. ndups=1 or spacing=1. If either of these arguments are specified, they would override the respective element of object$printer, if the element existed.

When moderated is FALSE, an error is generated if !is.null(treat.lfc) or trend is TRUE.

Value

Data frame.

References

McCarthy DJ & Smyth GK (2009). Testing significance relative to a fold-change threshold is a TREAT. Bioinformatics 25, 765-771.

See Also

lmFit; eBayes; limma_cor.


jdreyf/ezlimma documentation built on April 28, 2024, 1:10 p.m.