Bioconductor Digest, Vol 37, Issue 12
0
0
Entering edit mode
Lynn Amon ▴ 110
@lynn-amon-1601
Last seen 8.1 years ago
Hello Francois, I have a little function that makes all possible contrasts between all the groups in your design matrix. Call it like this: contrast.matrix <- conMatrix(colnames(design)) conMatrix <- function(A) { N <- length(A) columns <- 0; for(i in 1:N) { columns <- columns + N - i} Acol <- c(" ") [rep(c(1), times=columns)] mat <- matrix(0, N, columns) k<-0 for(i in 1:N) { j <- 1 while( j <= N ) { if( j>i) { k <- k+1 Acol[k] <- paste(A[i],A[j],sep="-") mat[i,k] <- 1 mat[j,k] <- -1 } j <- j+1 } } rownames(mat) <- A colnames(mat) <- Acol mat } Let me know if you have any problems with it. Lynn Lynn Amon Research Scientist Dept of Pathology University of Washington lynnamon at u.washington.edu > Date: Sat, 11 Mar 2006 15:16:38 -0500 > From: Francois Pepin <fpepin at="" cs.mcgill.ca=""> > Subject: [BioC] automating makeContrasts call in limma > To: bioconductor at stat.math.ethz.ch > Message-ID: <1142108198.5347.78.camel at elm.mcb.mcgill.ca> > Content-Type: text/plain > > Hi everyone, > > is there a way to automate calls to makeContrasts? Right now, all the > contrasts have to be typed in or hard-coded. We're dealing with a couple > of hundreds of samples and it would make my life a lot easier if we > could generate everything automatically. I've looked briefly in the > archives but didn't find anything. > > Ideally, I would want to have a way to do: > > myContrasts<-c("t1-t2","t1-3","t2-t3") > contrast.matrix<-makeContrasts(myContrasts,levels=design) > > I haven't found a way to properly go around the 'substitute(list(...))' > call inside of makeContrasts. > > Right now, I'm writing code to output the proper call and copy/paste it > back in the console. > > Another alternative would be to create the contrast matrix myself. That > would be a more elegant way of doing it, but I don't quite feel > comfortable enough (yet) with design matrices for that. > > Francois >
GO GO • 491 views
ADD COMMENT

Login before adding your answer.

Traffic: 232 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6