How can I reassign assayData slot of ExpressionSet?
1
0
Entering edit mode
6.9 years ago
wangshx ▴ 10

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"’
microArray biobase bioconductor • 3.8k views
ADD COMMENT
3
Entering edit mode
6.9 years ago

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

.

Select first 10 features and samples

MyEset[c(1:10),c(1:10)]

ExpressionSet (storageMode: lockedEnvironment)
assayData: 10 features, 10 samples

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 COMMENT
1
Entering edit mode

Thank a lot. Your suggestion is practical.

ADD REPLY

Login before adding your answer.

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