limma design matrix and contrast specification for time course PCR data with two conditions and variable replicate number
2
1
Entering edit mode
@linus-schumacher-6695
Last seen 9.6 years ago
Dear list, I’m trying to find differential expression between two conditions, as well as within a condition over time. The data are RTqPCR, log10 relative expression of 96 genes (by 55), under 2 conditions, at 8 unevenly spaced timepoints with some missing data (NA) and variable number of replicates (2-3): nReplicates <- c(3,3,3,3,3,3,2,3, 2,3,2,3,2,2,3,3) replicates <- rep(c(1:16), nReplicates) timePoints <- rep(rep(c(2,4,8,16,30,45,60,90),2), nReplicates) cond <- factor(rep(rep(0:1, each=8), nReplicates)) I’ve managed to run the analysis, but I’m unfamiliar with the syntax for specifying the design matrix and would greatly appreciate if someone could confirm the design matrix is set up correctly. I couldn’t find an intuitive explanation, so I have been working of examples from related cases. design <- model.matrix(~cond+timePoints:cond) (Intercept) cond1 cond0:timePoints cond1:timePoints 1 1 0 2 0 2 1 0 2 0 ... 23 1 0 90 0 24 1 1 0 2 ... 43 1 1 0 90 attr(,"assign") [1] 0 1 2 2 attr(,"contrasts") attr(,"contrasts")$cond [1] "contr.treatment" Now to determine which gene are differentially expressed between the two conditions, dupfit <- duplicateCorrelation(data,design,block=replicates) fit <- lmFit(data,design,block=replicates,correlation=dupfit$consensus) fit <- eBayes(fit) topTable(fit,coef="cond1”) (I have checked dupfit$consensus and is positive, if small (0.11)) And to determine difference in slope of genes under two conditions, I tried cont.VEGF <- makeContrasts(contrasts="cond0:timePoints- cond1:timePoints",levels=design) fit2 <- contrasts.fit(fit, cont.VEGF) fit2 <- ebayes(fit2) topTable(fit2) but I seem to have the wrong contrast specification, as I got the following error: Error in makeContrasts(contrasts = "cond0:timePoints- cond1:timePoints", : The levels must by syntactically valid names in R, see help(make.names). Non-valid names: cond0:timePoints,cond1:timePoints Is it the semi-colon? If so, how do I change this in the design matrix specification (where the semicolon comes from), while still getting the same model fitting? Apologies if this question is already answered elsewhere, I could only find parts of it in the list archives and the documentation. With kind regards, Linus Schumacher [[alternative HTML version deleted]]
• 5.6k views
ADD COMMENT
2
Entering edit mode
@gordon-smyth
Last seen 1 hour ago
WEHI, Melbourne, Australia

Dear Linus,

Yes, the problem is the colon in the column names. (Just to be pedantic, it's a full colon rather than a "semi-colon".). The error message asks you to see help(make.names), which says

"A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number."

You might find it informative to try see what make.names(colnames(design)) does.

Anyway, to form your contrast you could use:

cont.VEGF <-
   makeContrasts(contrasts="cond0.timePoints-cond1.timePoints",
   levels=make.names(colnames(design)))

or just make it yourself by

cont.VEGF <- c(0,0,-1,1)

Best wishes
Gordon

ADD COMMENT
0
Entering edit mode
Rao,Xiayu ▴ 550
@raoxiayu-6003
Last seen 8.9 years ago
United States
Hi, Linus There is a section called Time course Experiments (9.6) in the Limma user's guide. You can find the design similar to yours there as well as other designs. Thanks, Xiayu -----Original Message----- From: bioconductor-bounces@r-project.org [mailto:bioconductor- bounces@r-project.org] On Behalf Of Linus Schumacher Sent: Monday, August 11, 2014 7:38 PM To: bioconductor at r-project.org Subject: [BioC] limma design matrix and contrast specification for time course PCR data with two conditions and variable replicate number Dear list, I'm trying to find differential expression between two conditions, as well as within a condition over time. The data are RTqPCR, log10 relative expression of 96 genes (by 55), under 2 conditions, at 8 unevenly spaced timepoints with some missing data (NA) and variable number of replicates (2-3): nReplicates <- c(3,3,3,3,3,3,2,3, 2,3,2,3,2,2,3,3) replicates <- rep(c(1:16), nReplicates) timePoints <- rep(rep(c(2,4,8,16,30,45,60,90),2), nReplicates) cond <- factor(rep(rep(0:1, each=8), nReplicates)) I've managed to run the analysis, but I'm unfamiliar with the syntax for specifying the design matrix and would greatly appreciate if someone could confirm the design matrix is set up correctly. I couldn't find an intuitive explanation, so I have been working of examples from related cases. design <- model.matrix(~cond+timePoints:cond) (Intercept) cond1 cond0:timePoints cond1:timePoints 1 1 0 2 0 2 1 0 2 0 ... 23 1 0 90 0 24 1 1 0 2 ... 43 1 1 0 90 attr(,"assign") [1] 0 1 2 2 attr(,"contrasts") attr(,"contrasts")$cond [1] "contr.treatment" Now to determine which gene are differentially expressed between the two conditions, dupfit <- duplicateCorrelation(data,design,block=replicates) fit <- lmFit(data,design,block=replicates,correlation=dupfit$consensus) fit <- eBayes(fit) topTable(fit,coef="cond1") (I have checked dupfit$consensus and is positive, if small (0.11)) And to determine difference in slope of genes under two conditions, I tried cont.VEGF <- makeContrasts(contrasts="cond0:timePoints- cond1:timePoints",levels=design) fit2 <- contrasts.fit(fit, cont.VEGF) fit2 <- ebayes(fit2) topTable(fit2) but I seem to have the wrong contrast specification, as I got the following error: Error in makeContrasts(contrasts = "cond0:timePoints- cond1:timePoints", : The levels must by syntactically valid names in R, see help(make.names). Non-valid names: cond0:timePoints,cond1:timePoints Is it the semi-colon? If so, how do I change this in the design matrix specification (where the semicolon comes from), while still getting the same model fitting? Apologies if this question is already answered elsewhere, I could only find parts of it in the list archives and the documentation. With kind regards, Linus Schumacher [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

Traffic: 632 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