Entering edit mode
Hello,
I'm trying to analyse an RNA-seq dataset where I have three treatment levels, "early", "late", and "untreated". I would like to know how to do a nested comparison in DESeq2 such that I compare ((early Vs untreated) Vs (late Vs untreated)).
I've pasted my code below:
samples = read.csv("samples.csv",header=TRUE) #start edgeR, which you will use to collapse replicates and make the count matrix library("edgeR") #proceed to read in count data from .count files, collapse replicates, write count matrix counts = readDGE(samples$countf)$counts colnames(counts) = samples$shortname d = DGEList(counts=counts, group=colnames(counts)) #attach the column data to from the sample sheet to the variable coldata coldata = with(samples,data.frame(shortname = I(shortname), condition = condition)) #attach the count data to the variable countdata countdata = counts #start DESeq2 library("DESeq2") #construct your DESeq2 data set, making sure to specify the design matrix here dds <- DESeqDataSetFromMatrix(countData = countdata, colData = coldata, design = ~ condition) #relevel controls dds$condition <- relevel(dds$condition, "uninfected") #run DESeq2 on the dataset dds <- DESeq(dds) #print out results names resultsNames(dds) #get the following: [1] "Intercept" "conditionuninfected" "conditionearly" [4] "conditionlate" #input contrast formula to get results resdds <- results(dds, contrast = list(c( c("conditionearly", "conditionuninfected")),(c("conditionlate","conditionuninfected")))) #get the following error Error in cleanContrast(object, contrast, expanded = isExpanded, listValues = listValues, : elements in the contrast list should only appear in the numerator (first element of contrast list) or the denominator (second element of contrast list), but not both
What is the correct contrast formula to use here?
Erin
Results of sessionInfo():
R version 3.1.3 (2015-03-09) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.2 LTS locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] parallel stats4 stats graphics grDevices utils datasets [8] methods base other attached packages: [1] DESeq2_1.6.3 RcppArmadillo_0.4.650.1.1 [3] Rcpp_0.11.5 GenomicRanges_1.18.4 [5] GenomeInfoDb_1.2.4 IRanges_2.0.1 [7] S4Vectors_0.4.0 BiocGenerics_0.12.1 [9] edgeR_3.8.6 limma_3.22.7 loaded via a namespace (and not attached): [1] acepack_1.3-3.3 annotate_1.44.0 AnnotationDbi_1.28.2 [4] base64enc_0.1-2 BatchJobs_1.6 BBmisc_1.9 [7] Biobase_2.26.0 BiocParallel_1.0.3 brew_1.0-6 [10] checkmate_1.5.2 cluster_2.0.1 codetools_0.2-11 [13] colorspace_1.2-6 DBI_0.3.1 digest_0.6.8 [16] fail_1.2 foreach_1.4.2 foreign_0.8-63 [19] Formula_1.2-0 genefilter_1.48.1 geneplotter_1.44.0 [22] ggplot2_1.0.1 grid_3.1.3 gtable_0.1.2 [25] Hmisc_3.15-0 iterators_1.0.7 lattice_0.20-31 [28] latticeExtra_0.6-26 locfit_1.5-9.1 MASS_7.3-40 [31] munsell_0.4.2 nnet_7.3-9 plyr_1.8.1 [34] proto_0.3-10 RColorBrewer_1.1-2 reshape2_1.4.1 [37] rpart_4.1-9 RSQLite_1.0.0 scales_0.2.4 [40] sendmailR_1.2-1 splines_3.1.3 stringr_0.6.2 [43] survival_2.38-1 tools_3.1.3 XML_3.98-1.1 [46] xtable_1.7-4 XVector_0.6.0