Thank you so, so much. This worked. I lost half a day to this. Thanks again. Also just followed you on Twitter.
Hello,
I updated all of my Bioconductor packages and now I'm getting errors I've never seen before.
For this one, I'm trying to remove NA values from expression data downloaded from GEO with GEO2R's code.
After log2 transform and making negative values NaN, I removed all rows with NaN from gset:
ex <- exprs(gset)
probe_with_atLeastOneNA = list()
for(i in 1:nrow(ex)) {
row <- ex[i,]
nan_counter = 0
for(x in row) {
ifis.na(x)){
nan_counter = nan_counter + 1
}
}
if(nan_counter > 0){
probe_with_atLeastOneNA = append(probe_with_atLeastOneNA, rownames(ex)[i])
}
}
gset@featureData@data <- gset@featureData@data[!rownames(gset@featureData@data) %in% probe_with_atLeastOneNA,]
Following this, I removed these same NaN values from the expressionSet:
exprs(gset) <- na.omit(exprs(gset))
This has been working just fine up until the update. Now I get this error:
Error in .validate_assayDataElementReplace(obj, value) :
object and replacement value have different dimensions
Any help or insight on this is greatly appreciated.
Thank you.
1 answer
That this ever worked is surprising. The following will likely work:
RMV = which(apply(exprs(gset), 1, function(x) any ( is.na(x))))
gset = gset[-RMV,]
Edit: Annoyingly, I had to add some extra spaces so things would render on the site.
Hello I have the same problem and i want to remove Nan data out of my analysis. These are the codes i use for log2 transformation:
ex<-exprs(gset)
ex<- log2(ex+1)
exprs(gset) <- ex
I did try your both ways to get rid of them but they didn't work for me.
Still i get Nan results and can not heat map or plot my analysis.
Hope you can help me. Thnks by the way
Post a reproducible example as a new question.
Hi,
First, you need to convert ExpressionSet into a matrix, following replace NaNs with zero and convert the matrix into ExpressionSet again.
> ex <- exprs(gset)
> ex<- log2(ex+1)
> ex[is.nan(ex)] <- 0
> exprs(gset) <- ex
Log in to answer this question.