contrasts.fit             package:limma             R Documentation

_C_o_m_p_u_t_e _C_o_n_t_r_a_s_t_s _f_r_o_m _L_i_n_e_a_r _M_o_d_e_l _F_i_t

_D_e_s_c_r_i_p_t_i_o_n:

     Given a linear model fit to microarray data, compute estimated
     coefficients and standard errors for a given set of contrasts.

_U_s_a_g_e:

     contrasts.fit(fit, contrasts=NULL, coefficients=NULL)

_A_r_g_u_m_e_n_t_s:

     fit: an 'MArrayLM' object or a list object produced by the
          function 'lm.series' or equivalent. Must contain components
          'coefficients' and 'stdev.unscaled'.

contrasts: numeric matrix with row corresponding to coefficients in
          'fit' and columns containing contrasts. May be a vector if
          there is only one contrast.

coefficients: vector indicating which coefficients are to be kept in
          the revised fit object. An alternative way to specify the
          'contrasts'.

_D_e_t_a_i_l_s:

     This function accepts input from any of the functions 'lmFit',
     'lm.series', 'mrlm', 'gls.series' or 'lmscFit'. The function
     re-orientates the fitted model object from the coefficients of the
     original design matrix to any set of contrasts of the original
     coefficients. The coefficients, unscaled standard deviations and
     correlation matrix are re-calculated in terms of the contrasts.

     The idea of this function is to fit a full-rank model using
     'lmFit' or equivalent, then use 'contrasts.fit' to obtain
     coefficients and standard errors for any number of contrasts of
     the coefficients of the original model. Unlike the design matrix
     input to 'lmFit', which normally has one column for each treatment
     in the experiment, the matrix 'contrasts' may have any number of
     columns and these are not required to be linearly independent.
     Methods of assessing differential expression, such as 'eBayes' or
     'classifyTestsF', can then be applied to fitted model object.

     The 'coefficients' argument provides a simpler way to specify the
     'contrasts' matrix when the desired contrasts are just a subset of
     the original coefficients.

     Warning. For efficiency reasons, this function does not
     re-factorize the design matrix for each probe. A consequence is
     that, if the design matrix is non-orthogonal and the original fit
     included quality weights or missing values, then the unscaled
     standard deviations produced by this function are approximate
     rather than exact. The approximation is usually acceptable. The
     results are always exact if the original fit was a oneway model.

_V_a_l_u_e:

     An list object of the same class as 'fit'. This is a list with
     components components 

coefficients: numeric matrix containing the estimated coefficients for
          each contrast for each probe.

stdev.unscaled: numeric matrix conformal with 'coef' containing the
          unscaled standard deviations for the coefficient estimators.

cor.coefficients: numeric correlation matrix for the estimated
          coefficients

     ...: any other components input in 'fit'

_A_u_t_h_o_r(_s):

     Gordon Smyth

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     #  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 <- lmFit(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,contrast.matrix)
     fit2 <- eBayes(fit2)
     #  Large values of eb$t indicate differential expression
     results <- classifyTestsF(fit2)
     vennCounts(results)

