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][1] with a bit of modification 


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

&nbsp;   

    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()


  [1]: https://stephenturner.github.io/deseq-to-fgsea/

Any mistakes in the code found would be welcomed if any issues in running 
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.