This is a test version of Biostars. For the public version, visit https://www.biostars.org.
working with .gmt files

Hi!

I have downloaded a pathway data set in .gmt format form the GSEA website.

I'm wondering how can I properly read this data set in R.

Could anyone help me?

Thank you!

gsea r

This post is related to R.

Thank you Zhilong!

Following the installation procedure (https://github.com/zhilongjia/cogena )

I tried to install devtools. However, I have Rstudio 2.15.2 and the devtools is not available.

Any recommendations?

you can install cogena via the following code:

source("https://bioconductor.org/biocLite.R")
biocLite("cogena")

Also, the package you used should be suitable for your research goal (I believe it's not only read a gmt file.), as Deepak listed two as well.

I tried the url but I get the following error:

Error in file(filename, "r", encoding = encoding) :
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) : unsupported URL scheme

By the way I use Mac, if that makes any difference.

3 answers

You can read using read.gmt function from qusage package.

or by GSA.read.gmt function from GSA package.

you can try msigdbr package on https://cran.r-project.org/web/packages/msigdbr/vignettes/msigdbr-intro.html

it provides you with msigdb that compatable with fgsea and clusterProfiler. For example, I use it to do the fgea with human hallmark gene sets

library(msigdbr)
library(fgsea)

#Retrieve human H (hallmark gene sets) 
msigdbr_df <- msigdbr(species = "human", category = "H")


head(msigdbr_df)
# A tibble: 6 x 15
  gs_cat gs_subcat gs_name gene_symbol entrez_gene ensembl_gene human_gene_symb…
  <chr>  <chr>     <chr>   <chr>             <int> <chr>        <chr>           
1 H      ""        HALLMA… ABCA1                19 ENSG0000016… ABCA1           
2 H      ""        HALLMA… ABCB8             11194 ENSG0000019… ABCB8           
3 H      ""        HALLMA… ACAA2             10449 ENSG0000016… ACAA2           
4 H      ""        HALLMA… ACADL                33 ENSG0000011… ACADL           
5 H      ""        HALLMA… ACADM                34 ENSG0000011… ACADM           
6 H      ""        HALLMA… ACADS                35 ENSG0000012… ACADS      

# fixing format to work with fgsea
pathwaysH = split(x = msigdbr_df$entrez_gene, f = msigdbr_df$gs_name)

# run fgsea enrichment
fgseaRes <- fgsea(pathways=pathwaysH, ranks, ..)
  1. GSEABase package. http://svitsrv25.epfl.ch/R-doc/library/GSEABase/html/getObjects.html
  2. cogena::gmt2list()

Log in to answer this question.