2
$\begingroup$

Similar to: How to convert data in gmt format to dataframe?

I have downloaded a GMT file from the GSEA database (https://www.gsea-msigdb.org/gsea/msigdb/download_file.jsp?filePath=/msigdb/release/2022.1.Hs/c2.all.v2022.1.Hs.symbols.gmt)

I have imported this into R using the GSA.read.gmt tool from GSA as I want to do pathway analysis using GAUSS (https://github.com/diptavo/GAUSS/blob/master/example_gmt.txt).

GAUSS needs the table to have the genes in a comma separated manner as well as there being headers in the table.

I have tried using the gsub function on the third column but it doesn't work, I feel this is because a GMT file is not the same as a dataframe.

Would anyone be able to help me turn this column into a comma separated one please?

Many thanks

$\endgroup$

1 Answer 1

2
$\begingroup$

I used the unite function from tidyr but first I read the gmt file in as a data table using the read.delim function (with header set to False). Then I used unite:

library(tidyr)

gmt_file <- read.delim("~/path_to_file/file.gmt", header = F)
gmt_file <- gmt_file %>% unite(genes,3:ncol(gmt_file), sep=",")
colnames(gmt_file) <- c("pathway", "source", "genes")
write.table.... 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.