[BioC] How to create a MAList or ExprSet object from a matrix

Martin Morgan mtmorgan at fhcrc.org
Wed Aug 16 01:28:31 CEST 2006


swang <swang2000 at gmail.com> writes:

> Dear List:
>
> I got a file like the following, I guess the data is M ( log2 expression
> ratio) from microarray:
>
>     56071 1052 1062 3061 3081 8052 8072 10061 10062 10072 1415670_at
> 8.430148 8.899385 8.625973 8.708319 8.759182 8.281378 8.905347 8.625347

> the rows are Affymetrix probe and columns are different mice number (arrays)
> I need to do a category analysis using category package, so I need to
> generate a MAList or ExprSet object.

Starting with a data matrix

> samples <- 3
> sampleNames <- letters[1:samples]
> features <- 1000
> ## raw data
> exprMatrix <- matrix(0, ncol=samples,
+                      nrow=features,
+                      dimnames=list(1:features, sampleNames))

To create an old-style exprSet (not sure what an ExprSet is, or which
package you mean by Category ;):
 
> ## phenoData for exprSet
> pd2 <- new("phenoData",
+            pData=data.frame(1:samples,
+              row.names=sampleNames),
+            varLabels=list(id="sample identifier"))
> new("exprSet",
+     phenoData=pd2,
+     exprs=exprMatrix)
Expression Set (exprSet) with 
	1000 genes
	3 samples
	phenoData object with 1 variables and 3 cases
	varLabels
		id: sample identifier

To create an ExpressionSet (using this will require different commands
from the vignette that comes with Category) object:

> ## phenoData for ExpressionSet
> pd1 <- new("AnnotatedDataFrame",
+            data=
+            data.frame(sampleId=1:samples,
+                       row.names=sampleNames),
+            varMetadata=
+            data.frame(labelDescription=I(c("Sample numeric identifier")),
+                       row.names=c("sampleId")))
> new("ExpressionSet",
+     phenoData=pd1, exprs=exprMatrix)
Instance of ExpressionSet 

assayData
  Storage mode: lockedEnvironment 
  featureNames: 1, 2, 3, ..., 999, 1000 (1000 total)
  Dimensions:
        exprs
Rows     1000
Samples     3

phenoData
  sampleNames: a, b, c
  varLabels and descriptions:
    sampleId: Sample numeric identifier

Experiment data
  Experimenter name:  
  Laboratory:  
  Contact information:  
  Title:  
  URL:  
  PMIDs:  
  No abstract available.

Annotation character(0)

Much of the functionality of exprSet and ExpressionSet come from
associating phenoData with expression values; the skeletons above do
not have any meaningful phenoData. Typically you might incorporate
this by reading phenotypic data from a spreadsheet or tab-delimited
file (e.g., using read.table) into data.frames, and then incorporating
the data.frame into an ExpressionSet as outlined above.


> sessionInfo()
Version 2.3.1 Patched (2006-06-20 r38364) 
x86_64-unknown-linux-gnu 

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

other attached packages:
 Biobase 
"1.10.1" 


Martin
-- 
Bioconductor



More information about the Bioconductor mailing list