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
yes as i updated things were broken due to one or the other dependencies ..