This is a test version of Biostars. For the public version, visit https://www.biostars.org.
fgsea tutorial issue with BiocParallel

I was trying to use this fgsea library for enrichment analysis but there was this error coming up due to some issue with BiocParallel , it was resolved by adding this line register(SerialParam()) to the code .

Original source with a bit of modification

Error in registered()[[bpparamClass]] : 
  attempt to select less than one element in get1index

 

library(fgsea)
library(BiocParallel)
res <- read.csv("HSC_LSC_deseq2_CDS.txt",sep ='\t') # deseq2 output
head(res)
library(dplyr)
res2 <- res %>% 
   dplyr::select(Symbol, stat) %>% 
   na.omit() %>% 
   distinct() %>% 
   group_by(Symbol) %>% 
   summarize(stat=mean(stat))
res2
library(tidyverse)
ranks <- deframe(res2)
head(ranks, 20)
pathways.hallmark <- gmtPathways('~/mysigdb/h.all.v6.2.symbols.gmt') # files from mysigdb 
pathways.hallmark %>% 
   head() %>% 
   lapply(head)

class(pathways.hallmark)
length(pathways.hallmark)
pathways.hallmark[1]

register(SerialParam())


fgseaRes <- fgsea(pathways=pathways.hallmark, stats=ranks, nperm=1000)

fgseaResTidy <- fgseaRes %>%  as_tibble() %>% arrange(desc(NES))

fgseaResTidy %>% 
   dplyr::select(-leadingEdge, -ES, -nMoreExtreme) %>% 
   arrange(padj) %>% 
   DT::datatable()

library(ggplot2)
ggplot(fgseaResTidy, aes(reorder(pathway, NES), NES)) +
   geom_col(aes(fill=padj<0.05)) +
   coord_flip() +
   labs(x="Pathway", y="Normalized Enrichment Score",
        title="Hallmark pathways NES from GSEA") + 
   theme_minimal()

Any mistakes in the code found would be welcomed if any issues in running

r rna-seq

1 answer

I experienced the same thing just now on a not so well patched computer running an older version (R3.4.4/fgsea_1.0.2/BiocParallel_1.8.2) but tried it on another computer that I keep better updated (R3.5.2/fgsea_1.8.0/BiocParallel_1.8.2) and it worked. My advice would be to upgrade your R installation to the latest one and reinstall the packages.

yes as i updated things were broken due to one or the other dependencies ..

I encountered the same error even with recent installs (R4.4.2/fgsea_1.32.2/BiocParallel_1.40.0). May I know if there are any workarounds to stop using BiocParallel (not even register workers=1 with BiocParallel)?

Another catch is that my institute blocks internet access, but I am not sure if that is the root of the problem. As when I tried to register BiocParallel, I got the error before showing the error as the author of this thread.

The order of those tied genes will be arbitrary, which may produce unexpected results.failed to open the port 11572, trying a new port... failed to open the port 11592, trying a new port... failed to open the port 11693, trying a new port... failed to open the port 11906, trying a new port... failed to open the port 11089, trying a new port... 'BiocParallel' did not register default BiocParallelParam: cannot find an open port. For manually specifying the port, see ?SnowParam failed to open the port 11693, trying a new port... failed to open the port 11701, trying a new port... failed to open the port 11695, trying a new port... failed to open the port 11528, trying a new port... failed to open the port 11116, trying a new port... 'BiocParallel' did not register default BiocParallelParam: cannot find an open port. For manually specifying the port, see ?SnowParam Error in registered()[[bpparamClass]] : attempt to select less than one element in get1index

Log in to answer this question.