Entering edit mode
He, Yiwen NIH/CIT
▴
360
@he-yiwen-nihcit-1177
Last seen 10.3 years ago
Hi,
In limma, what is the best way to automatically generate a contrast
matrix
with all possible pairs? For example, if I have 4 groups, is there a
way to
generate the matrix with 6 columns each corresponding to a pair-wise
comparison, other than having to specify the 6 expressions explicitly
when
calling makeContrasts?
I tried to first create a vector with those expressions and use that
in
makeContrasts:
> pair<-c()
> ind<-1
> for (i in 2:numg){
+ for (j in i:numg) {
+ pair[ind] <- paste(groupname[j], "-", groupname[(j-i+1)])
+ ind<- ind+1}}
> pair
[1] "GroupB - GroupA" "GroupC - GroupB" "GroupC - GroupA"
> makeContrasts(pair, levels=design)
pair
GroupA "GroupB - GroupA"
GroupB "GroupC - GroupB"
GroupC "GroupC - GroupA"
A related problem: I noticed that expressions have to be separated by
comma.
However, even when I tried:
> makeContrasts(pair[1], levels=design)
pair[1]
GroupA "GroupB - GroupA"
GroupB "GroupB - GroupA"
GroupC "GroupB - GroupA"
Compare to the result by doing:
> pair[1]
[1] "GroupB - GroupA"
> makeContrasts("GroupB - GroupA", levels=design)
GroupB - GroupA
GroupA -1
GroupB 1
GroupC 0
The help page says:
"...: expressions, or character strings which can be parsed to
expressions"
But my string doesn't seem to be converted.
Any suggestions? Will it be more convenient to use if the ... argument
is a
vector of expressions or something similar?
Thank you, Yiwen
NIH/CIT