Thank a lot. Your suggestion is practical.
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"’
1 answer
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.
Log in to answer this question.