make.contrast: Create a contrast matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/make.contrast.R

Description

Create a contrast matrix based on a given design matrix

Usage

1
2
  make.contrast(design.matrix, compare1=NULL, compare2=NULL, level=NULL, 
    interaction=FALSE)

Arguments

design.matrix

a design matrix returned from the make.design funcion

compare1

the first value of the main covariate. For example, suppose that the main covariate is "drug", and there are three unique values: "drug1", "drug2", and "placebo". You would like to compare "drug1" to "drug2". Then you would use "drug1" as compare1. If interaction==TRUE, do not specify this value.

compare2

the second value of the main covariate. Based on the example above, if you would like to compare "drug1" vs "drug2", then you would use "drug2" as compare2. If interaction ==TRUE, do not specify this value

level

you only specify this term when the design matrix contains an interaction term. Suppose that you would like to compare "drug1" to "drug2" only when estrogen is "present", where "present" is one of the values of the estrogen variable. You will use "present" as level. If interaction==TRUE, do not specify this value

interaction

you only specify interaction=TRUE when you would like to detect the interaction effect between two covariates. When you specify interaction=TRUE, do not provide values for compare1, compare2, and level

Value

contrast matrix for the linear model

Author(s)

Xiwei Wu xwu@coh.org, Xuejun Arthur Li xueli@coh.org

See Also

make.design

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
target<-data.frame(drug=(c(rep("A",4),rep("B",4),rep("C",4))), 
gender=factor(c(rep("M",6),rep("F",6))), 
group=factor(rep(c(1,2,3),4)))

# Example1:  Compare drug "A" vs. "B"
design1<-make.design(target, "drug")
contrast1<-make.contrast(design1, "A", "B")

# Example2:  Compare drug "A" vs. "B", adjusting for "group" variable
design2<-make.design(target, c("drug","group"))
contrast2<-make.contrast(design2, "A", "B")

# Example3:  Suppose you are interested in "drug", "group" interaction
design3<-make.design(target, c("drug","group"), int=c(1,2))
contrast3<-make.contrast(design3, interaction=TRUE)

# Example4:  Compare drug "A" vs. "B" among "male"
# Notice that you must use an design matrix containing an interaction term
design4<-make.design(target, c("drug","gender"), int=c(1,2))
contrast4<-make.contrast(design4, "A", "B", "M")

Example output

Loading required package: affy
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: limma

Attaching package: 'limma'

The following object is masked from 'package:BiocGenerics':

    plotMA


Attaching package: 'AffyExpress'

The following object is masked from 'package:BiocGenerics':

    Filter

The following object is masked from 'package:base':

    Filter

Warning message:
In read.dcf(con) :
  URL 'http://bioconductor.org/BiocInstaller.dcf': status was 'Couldn't resolve host name'

AffyExpress documentation built on Nov. 8, 2020, 7:50 p.m.