Question: How can I reassign assayData slot of ExpressionSet?
0
gravatar for wangshx
19 months ago by
wangshx10
China/Shanghai/ShanghaiTech. University
wangshx10 wrote:

When I use exprs function to reassign expression matrix to an ExpressionSet object, it does not work and an error occur. I want to remove the rows which cannot match any gene symbol.

A minimal code as follows can reproduce my error, someone who know how to do this correctly please help me, thanks.

> dataDirectory <- system.file("extdata", package="Biobase")
> exprsFile <- file.path(dataDirectory, "exprsData.txt")
> exprs <- as.matrix(read.table(exprsFile, header=TRUE, sep="\t",
+                               row.names=1,
+                               as.is=TRUE))
> minimalSet <- ExpressionSet(assayData=exprs)
> sdata <- matrix(0, nrow=400, ncol=26)
> exprs(minimalSet) <- sdata
Error in .validate_assayDataElementReplace(obj, value) : 
  object and replacement value have different dimensions
> exprs(minimalSet) <- NULL  # here I want to assign NULL to arrayData and reassign sdata to it, but it fails
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘exprs<-’ for signature ‘"ExpressionSet", "NULL"’
ADD COMMENTlink modified 18 months ago by Kevin Blighe45k • written 19 months ago by wangshx10
2
gravatar for Kevin Blighe
18 months ago by
Kevin Blighe45k
Kevin Blighe45k wrote:

If you are filtering genes or samples from an ExpressionSet object, you do not have to access via the exprs() function. Just filter based on the name of the ExpressionSet object:

MyEset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 194706 features, 22 samples 
  element names: exprs 
...

#Select first 10 features and samples
MyEset[c(1:10),c(1:10)]
ExpressionSet (storageMode: lockedEnvironment)
assayData: 10 features, 10 samples 
  element names: exprs 
...

If you're trying to re-assign an entire 'new' expression matrix to your ExpressionSet object, then I do not see the utility in this. Just create another ExpressionSet object based on the new data matrix.

ADD COMMENTlink modified 18 months ago • written 18 months ago by Kevin Blighe45k
1

Thank a lot. Your suggestion is practical.

ADD REPLYlink written 18 months ago by wangshx10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1840 users visited in the last hour