How to construct matrix and fit linear model for this microarray?
1
0
Entering edit mode
June. ▴ 10
@june-23879
Last seen 3.8 years ago

Hi!

I'm trying to analyse a specific set of CEL files. In these datasets, the effect of a stress agent (H2O2) on yeast performance was tested. There are two control replicates and 4 tests of stress condition done during different time points (15-30-45 and 90 minutes), all with a single replicate. All quality filtering and annotation steps have been done and saved in the file: file_final

I would like to know how gene expression differ among all the conditions first and if there is any difference between control and each of the 4 tests as among the stress conditions. At the end, I'd like to get a whole view of difference among the control and stress condition. However, I have serious problem in constructing appropriate matrix and I don't know what I must do for my analysis here:

In my phenodata file, the information for $Comment..Sample_source_name. is:

H2O2 treated S. cerevisiae cells Untreated S. cerevisiae cells Untreated S. cerevisiae cells H2O2 treated S. cerevisiae cells H2O2 treated S. cerevisiae cells H2O2 treated S. cerevisiae cells

And the corresponding $Comment..Sample_characteristics. is:

4741; oxidative stress; 30 min 4741; untreated; 0 min 4741; untreated; 0 min 4741; oxidative stress; 90 min 4741; oxidative stress; 15 min 4741; oxidative stress; 45 min

My code is:

 i_in <- as.character(Biobase::pData(file_final)$Comment..Sample_source_name.)
  i_in <- ifelse(individual == "treatment","treated", "untreated")

  condition <- str_replace_all(Biobase::pData(file_final)$Comment..Sample_characteristics., " ", "_")

   condition <- ifelse(phenotype == "treatment", "control", "h2o2")

   condition <- factor(c(1,1,2,3,4,5), levels = c("control", "h15", "h30", "h45", "h90"))

    i_in <- factor(c(1,1,1,1, 2, 2), levels = c("treated", "untreated"))

design_gene <- model.matrix(~0 + condition)
colnames(design_gene)<- c("control", "h15", "h30", "h45", "h90")
rownames(design_gene) <- i_in
head(design_gene)

contrast_matrix <- makeContrasts(control-h15, control-h30, control-h90, control-h45, h15-h45, h15-h30, h15-h90, h30-h45, h30-h90, h45-h90, levels = design_gene)
design_gene_fit <- eBayes(contrasts.fit(lmFit(file_final, design = design_gene),
                                        contrast_matrix))

With head(design_gene), I get: control h15 h30 h45 h90

So, there is no row when I type: rownames(design_gene) <- i_in Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent

Any help would be highly appreciated.

microarray dge matrix makecontrasts limma • 895 views
ADD COMMENT
1
Entering edit mode
@gordon-smyth
Last seen 3 hours ago
WEHI, Melbourne, Australia

I can see from the code that you're having trouble with basic programming in R.

One problem is that the code

condition <- factor(c(1,1,2,3,4,5), levels = c("control", "h15", "h30", "h45", "h90"))

doesn't produce anything, because the levels that you've set don't appear in the vector. I suspect what you were after was:

condition <- factor(c(1,1,2,3,4,5))
levels(condition) <- c("control", "h15", "h30", "h45", "h90")

Naturally the design matrix you created from the factor with no content also has no content.

Why did you create the condition factor twice? What was wrong with the first version?

Another problem is that you can't set the rownames of a matrix equal to a factor, that doesn't make any sense really. You don't need to set the rownames but, if you do, the rownames should be a character vector and all the values should be unique.

ADD COMMENT

Login before adding your answer.

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