Created
August 22, 2017 08:49
-
-
Save mlist/06915e72e5a0e03e2a2350509681f931 to your computer and use it in GitHub Desktop.
function for reading gmt files as data frames with 1st column gene set id, 2nd column gene id.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(foreach) | |
library(stringr) | |
library(biomaRt) | |
read_gmt <- function(gmt_file){ | |
conn <- file(gmt_file,open="r") | |
all_lines <-readLines(conn) | |
result <- foreach(line = str_split(all_lines, "\t"), .combine = bind_rows) %do% { | |
data_frame(id = line[1], gene_id = line[-c(1,2)]) | |
} | |
close(conn) | |
return(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment