[BioC] cont.matrix error: Error in eval(expr, envir, enclos) : object "c96" not found

Martin Morgan mtmorgan at fhcrc.org
Sat Jan 26 18:54:28 CET 2008


Hi Sally --

I am having trouble reproducing your problem. Here's what I did:

> TS <- c("c.0", "c.0", "c.0", "c.0", "s.0", "s.0", "s.0", "c.24",
+         "c.24", "c.24", "s.24", "s.24", "s.24", "s.24", "c.48",
+         "c.48", "c.48", "s.48", "s.48", "s.48", "s.48", "c.96",
+         "c.96", "c.96", "s.96", "s.96", "s.96", "s.96")
> TS <- factor(TS)
> design <- model.matrix(~0+TS)
> colnames(design) <- levels(TS)
> cont.matrix <-
+     makeContrasts(s0vss24=s.0-s.24, s24vss48=s.24-s.48,
+                   s48vss96=s.48-s.96, s0vss48=s.0-s.48,
+                   s0vss96=s.0-s.96, c0vsc24=c.0-c.24,
+                   c24vsc48=c.24-c.48, c48vsc96=c.48-c.96,
+                   c0vsc48=c.0-c.48, c0vsc96=c.0-c.96, s0vsc0=s.0-c.0,
+                   s24vsc24=s.24-c.24, s48vsc48=s.48-c.48,
+                   s96vsc96=s.96-c.96, levels=design)

makeContrasts returns without errors.

I suggest you try to simplify your script as much as possible, to
isolate the problem. Can you get the code snippet above to work? If
so, what do you have to add to make things no longer work?

Identify a reproducible problem. 'Reproducible' means that users on the
list can easily copy and paste into their R session and reproduce it,
i.e., no need for additional files, and no code not relevant to the
problem. For instance, targets and lmFit seem to be irrelevant to the
problem you're having with makeContrasts (though maybe not, but then
you have to come up with a way for us to reproduce the problem with
data that is available to us, e.g., using sample data distributed in
one of the Bioconductor packages). Also, if there were a problem
above, I would have started by making 'TS' simpler, e.g., just two
time points and a single contrast.

Then copy and paste the script and its output exactly as it occurs
into an email. I notice below for instance that when you print the
results of 'design' it has column names that are only possible if you
evaluate the line *after* you print it!

I'd encourage you to send email as 'text only' or 'plain
text' (rather than html), because your email client (and mine) is less
likely to munge the content in a way that makes it difficult to
interpret.

Finally, I know you mention that you're using current R &
Bioconductor, but it's much more reliable to let R tell us about
itself. Here's my sessionInfo()

> sessionInfo()
R version 2.6.1 Patched (2007-12-23 r43769) 
x86_64-unknown-linux-gnu 

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] limma_2.12.0

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17

Hope this helps,

Martin

Sally <sagoldes at shaw.ca> writes:

> Hello Bioconductors:
>
> I am having difficulty formulating my comparisons (cont.matrix
> script).  My statistician suggested using the factorial example and
> adapting it to my data.  I am using Windows XP and running current
> versions of R and Limma.
>
> For each sample time I have 3 or 4 biological replicates.  I have 4
> sample times (0, 24, 48 and 96 hours) for each fish species.  I have
> two fish species (s=sockeye and c=coho).
>
> I'm feeling abit frustrated!!!!
>
> The following script gives the error message:
>
> cont.matrix<-makeContrasts(s0vss24=s.0-s.24, s24vss48=s.24-s.48, s48vss96=s.48-s.96, s0vss48=s.0-s.48, s0vss96=s.0-s.96, c0vsc24=c.0-c.24, c24vsc48=c.24-c.48, c48vsc96=c.48-c.96, c0vsc48=c.0-c.48, c0vsc96=c.0-c.96, s0vsc0=s.0-c.0, s24vsc24=s.24-c.24, s48vsc48=s.48-c.48, s96vsc96=s.96-c.96,levels=design)
>
>
> Error in eval(expr, envir, enclos) : object "c96" not found.
>
> Here is my script to that point:
>
> #Read in targets file
>
>  
>
> targets <- readTargets("targets.txt")
>
>  
>
>  
>
> targets
>
>  
>
>       FileName
>      Species
>      Time
>      
>       c0M1
>      c
>      0
>      
>       c0M2
>      c
>      0
>      
>       c0M3
>      c
>      0
>      
>       c0M4
>      c
>      0
>      
>       s0M1
>      s
>      0
>      
>       s0M2
>      s
>      0
>      
>       s0M3
>      s
>      0
>      
>       c24M1
>      c
>      24
>      
>       c24M2
>      c
>      24
>      
>       c24M3
>      c
>      24
>      
>       s24M1
>      s
>      24
>      
>       s24M2
>      s
>      24
>      
>       s24M3
>      s
>      24
>      
>       s24M4
>      s
>      24
>      
>       c48M1
>      c
>      48
>      
>       c48M2
>      c
>      48
>      
>       c48M3
>      c
>      48
>      
>       s48M1
>      s
>      48
>      
>       s48M2
>      s
>      48
>      
>       s48M3
>      s
>      48
>      
>       s48M4
>      s
>      48
>      
>       c96M1
>      c
>      96
>      
>       c96M2
>      c
>      96
>      
>       c96M3
>      c
>      96
>      
>       s96M1
>      s
>      96
>      
>       s96M2
>      s
>      96
>      
>       s96M3
>      s
>      96
>      
>       s96M4
>      s
>      96
>      
>
>  
>
>  
>
> # Set up character list defining your arrays, include replicates
>
> TS <- paste(targets$Species, targets$Time, sep=".")
>
> #This script returns the following:
>
> TS
>
> #[1] "c.0"  "c.0"  "c.0"  "c.0"  "s.0"  "s.0"  "s.0"  "c.24" "c.24" "c.24"
>
> #[11] "s.24" "s.24" "s.24" "s.24" "c.48" "c.48" "c.48" "s.48" "s.48" "s.48"
>
> #[21] "s.48" "c.96" "c.96" "c.96" "s.96" "s.96" "s.96" "s.96"
>
> # Turn TS into a factor variable which facilitates fitting
>
> TS <- factor(TS)
>
> #This script returns the following
>
> TS
>
> #[1] c.0  c.0  c.0  c.0  s.0  s.0  s.0  c.24 c.24 c.24 s.24 s.24 s.24 s.24 c.48
>
> #[16] c.48 c.48 s.48 s.48 s.48 s.48 c.96 c.96 c.96 s.96 s.96 s.96 s.96
>
> #Levels: c.0 c.24 c.48 c.96 s.0 s.24 s.48 s.96
>
> # Turn TS into a factor variable which facilitates fitting
>
> TS <- factor(TS)
>
> #This script returns the following
>
> TS
>
> #[1] c1.0  c2.0  c3.0  c4.0  s1.0  s2.0  s3.0  c1.24 c2.24 c3.24 s1.24 s2.24 s3.24 s4.24
>
> #[15] c1.48 c2.48 c3.48 s1.48 s2.48 s3.48 s4.48 c1.96 c2.96 c3.96 s1.96 s2.96 s3.96 s4.96
>
> #28 Levels: c1.0 c1.24 c1.48 c1.96 c2.0 c2.24 c2.48 c2.96 c3.0 c3.24 c3.48 c3.96 ... s4.96
>
> #do this as is
>
> design <- model.matrix(~0+TS)
>
> design
>
>   c.0 c.24 c.48 c.96 s.0 s.24 s.48 s.96
>
> 1    1    0    0    0   0    0    0    0
>
> 2    1    0    0    0   0    0    0    0
>
> 3    1    0    0    0   0    0    0    0
>
> 4    1    0    0    0   0    0    0    0
>
> 5    0    0    0    0   1    0    0    0
>
> 6    0    0    0    0   1    0    0    0
>
> 7    0    0    0    0   1    0    0    0
>
> 8    0    1    0    0   0    0    0    0
>
> 9    0    1    0    0   0    0    0    0
>
> 10   0    1    0    0   0    0    0    0
>
> 11   0    0    0    0   0    1    0    0
>
> 12   0    0    0    0   0    1    0    0
>
> 13   0    0    0    0   0    1    0    0
>
> 14   0    0    0    0   0    1    0    0
>
> 15   0    0    1    0   0    0    0    0
>
> 16   0    0    1    0   0    0    0    0
>
> 17   0    0    1    0   0    0    0    0
>
> 18   0    0    0    0   0    0    1    0
>
> 19   0    0    0    0   0    0    1    0
>
> 20   0    0    0    0   0    0    1    0
>
> 21   0    0    0    0   0    0    1    0
>
> 22   0    0    0    1   0    0    0    0
>
> 23   0    0    0    1   0    0    0    0
>
> 24   0    0    0    1   0    0    0    0
>
> 25   0    0    0    0   0    0    0    1
>
> 26   0    0    0    0   0    0    0    1
>
> 27   0    0    0    0   0    0    0    1
>
> 28   0    0    0    0   0    0    0    1
>
> attr(,"assign")
>
> [1] 1 1 1 1 1 1 1 1
>
> attr(,"contrasts")
>
> attr(,"contrasts")$TS
>
> [1] "contr.treatment"
>
> colnames(design) <- levels(TS)
>
> colnames(design)
>
> #[1] "c.0"  "c.24" "c.48" "c.96" "s.0"  "s.24" "s.48" "s.96"
>
> #for eset put in your M values - see ?lmFit for object types
>
> fit <- lmFit(eset, design)
>
> #  and extract the
>
> label for the difference = actual difference
>
> #Contrasts desired:
>
>       Comparisons
>       
>       
>       Sockeye Over Time
>      Formula
>      
>       
>       s0 versus s24
>      s0vss24=s.0-s.24,
>      
>       s24 versus s48
>      s24vss48=s.24-s.48,
>      
>       s48 versus s96
>      s48vss96=s.48-s.96,
>      
>       s0 versus s48
>      s0vss48=s.0-s.48,
>      
>       s0 versus s96
>      s0vss96=s.0-s.96,
>      
>       
>       Coho Over Time
>       
>       
>       c0 versus c24
>      c0vsc24=c.0-c.24,
>      
>       c24 versus c48
>      c24vsc48=c.24-c.48,
>      
>       c48 versus c96
>      c48vsc96=c.48-c.96,
>      
>       c0 versus c48
>      c0vsc48=c.0-c.48,
>      
>       c0 versus c96
>      c0vsc96=c.0-c.96,
>      
>       
>       
>       Coho vs Sockeye
>       
>       
>       s0 versus c0
>      s0vsc0=s.0-c.0,
>      
>       s24 versus c24
>      s24vsc24=s.24-c.24,
>      
>       s48 versus c48
>      s48vsc48=s.48-c.48,
>      
>       s96 versus c96
>      s96vsc96=s.96-c.96,
>      
>
>  
>
>  
>
> cont.matrix<-makeContrasts(s0vss24=s.0-s.24, s24vss48=s.24-s.48, s48vss96=s.48-s.96, s0vss48=s.0-s.48, s0vss96=s.0-s.96, c0vsc24=c.0-c.24, c24vsc48=c.24-c.48, c48vsc96=c.48-c.96, c0vsc48=c.0-c.48, c0vsc96=c.0-c.96, s0vsc0=s.0-c.0, s24vsc24=s.24-c.24, s48vsc48=s.48-c.48, s96vsc96=s.96-c.96,levels=design)
>
>  
>
> Error in eval(expr, envir, enclos) : object "c96" not found
>
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793



More information about the Bioconductor mailing list