contrasts.fit {limma} | R Documentation

## Contrast Information from Linear Model Fit

### Description

Given an `lm.series` fit for a oneway model, compute estimated coefficients and standard errors for a given set of contrasts.

### Usage

    contrasts.fit(fit,contrasts)

### Arguments

`fit` | object produced by the function `lm.series` or equivalent. A list containing components `coefficients` and `stdev.unscaled`.
`contrasts` | matrix with columns containing contrasts. May be a vector if there is only one contrast.

### Details

This function accepts input from any of the functions `lm.series`, `rlm.series` or `gls.series`. The design matrix used for this fit must have orthogonal columns.

The idea is to fit a saturated oneway model using of the above functions, then use `contrasts.fit` to obtain coefficients and standard errors for any number of contrasts of the coefficients of the oneway model.

### Value

An object of the same type as produced by `lm.series`. This is a list components

`coefficients` | numeric matrix containing the estimated coefficients for each contrasts for each gene.
`stdev.unscaled` | numeric matrix conformal with `coef` containing the unscaled standard deviations for the coefficient estimators.
`...` | any other components input in `fit`

### Author(s)

Gordon Smyth

### See Also

An overview of linear model functions in limma is given by 5.LinearModels.

### Examples

    #  Simulate gene expression data,
    #  6 microarrays and 100 genes with one gene differentially expressed in first 3 arrays
    M <- matrix(rnorm(100*6,sd=0.3),100,6)
    M[1,1:3] <- M[1,1:3] + 2
    #  Design matrix corresponds to oneway layout, columns are orthogonal
    design <- cbind(First3Arrays=c(1,1,1,0,0,0),Last3Arrays=c(0,0,0,1,1,1))
    fit <- lm.series(M,design=design)
    #  Would like to consider original two estimates plus difference between first 3 and last 3 arrays
    contrast.matrix <- cbind(First3=c(1,0),Last3=c(0,1),"Last3-First3"=c(-1,1))
    fit2 <- contrasts.fit(fit,contrasts=contrast.matrix)
    eb <- ebayes(fit2)
    #  Large values of eb$t indicate differential expression
    clas <- classifyTests(eb$t,design=design,contrasts=contrast.matrix,df=fit2$df+eb$df)

[Package Contents]