[BioC] automating makeContrasts call in limm

Francois Pepin fpepin at cs.mcgill.ca
Mon Mar 13 17:31:21 CET 2006


> > Ideally, I would want to have a way to do:
> >
> > myContrasts<-c("t1-t2","t1-3","t2-t3")
> > contrast.matrix<-makeContrasts(myContrasts,levels=design)
> 
> Your question isn't clear, at least not to me.  What is wrong with the code you've just given?

Sorry, I thought this was a well-known "feature" of the makeContrasts
function, so I didn't go into the details.

So to complete the toy example with 3 treatments and dye swaps of each:

> design
     t1 t2 t3
[1,] -1  0  0
[2,]  1  0  0
[3,]  0 -1  0
[4,]  0  1  0
[5,]  0  0 -1
[6,]  0  0  1

> myContrasts
[1] "t1-t2" "t1-3"  "t2-t3"

> contrast.matrix<-makeContrasts(myContrasts,levels=design)
> contrast.matrix
   myContrasts
t1 "t1-t2"
t2 "t1-3"
t3 "t2-t3"

Which doesn't make for a usable design matrix. The expected behavior is:

> contrast.matrix<-makeContrasts("t1-t2","t1-t3","t2-t3",levels=design)
> contrast.matrix
   t1-t2 t1-t3 t2-t3
t1     1     1     0
t2    -1     0     1
t3     0    -1    -1

> sessionInfo()
R version 2.1.0, 2005-04-18, x86_64-unknown-linux-gnu

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"
"datasets"
[7] "base"

other attached packages:
  limma
"1.9.6"



> Is your question that you'd like to compute all pairwise comparisons between hundreds of different
> treatments or patients?

No. I have tumors and normal samples for each patient. One of the things
I'd like to do is tumor vs normal for all each of the patients. Another
would be to automate the comparisons between clinical variables. It's
just cumbersome (and error-prone) to do by hand when there are over 50
patients.

Francois



More information about the Bioconductor mailing list