varemo / piano

piano - An R/Bioconductor package for gene set analysis
https://varemo.github.io/piano/
12 stars 4 forks source link

Error in apply(tmp[iGeneSet, ], 1, function(x) mean(x[x >= 0])) #2

Open rronen opened 6 years ago

rronen commented 6 years ago

First, thanks for making piano. It is a super useful package.

I've had some cases where the fdr procedure implemented in fdrGSEA.R fails with:

Error in apply(tmp[iGeneSet, ], 1, function(x) mean(x[x >= 0]))
dim(X) must have a positive length

which happens if iGeneSet contains only a single element.

Introducing drop=FALSE in the two relevant lines seems to resolve the issue. I.e., changing tmp[iGeneSet, ] to tmp[iGeneSet, , drop=FALSE].

varemo commented 6 years ago

Hi, sorry for slow response here, I am abroad on vacation with limited time and access to a computer. Thanks for reporting this bug and suggesting the fix. I will implement it as soon as possible!

rronen commented 4 years ago

Update (>1 year later :) it is also necessary to add drop=FALSE in the following section:

      # Normalize ES:
      ES <- gsStatsAll[, iContrast]
      if(signMethod == "geneperm") {
          tmp <- randBgMat[as.character(sizeGS), , drop=FALSE]  # HERE
      } else {
          tmp <- randBgMat
      }