ChristopherBarrington / helpr

tools to make r life easier
https://christopherbarrington.github.io/helpr
0 stars 0 forks source link

read msigdb file #3

Closed ChristopherBarrington closed 3 years ago

ChristopherBarrington commented 3 years ago
'~/db/msigdb/h.all.v7.4.entrez.gmt' %>%
  {list(path=., ncol={count.fields(., sep='\t') %>% max()})} %>%
  {read.table(file=.$path, sep='\t', fill=TRUE, header=FALSE, col.names=c('pathway', 'url', str_c('id.', 1:.$ncol)))} %>%
  dlply(~pathway, function(x) list(url=x$url, ids=select(x, starts_with('id.')) %>% unlist(use.names=FALSE) %>% na.omit())) -> hallmark_pathways
ChristopherBarrington commented 3 years ago
```r
'~/db/msigdb/h.all.v7.4.symbols.gmt' %>%
  {list(path=., ncol={count.fields(., sep='\t') %>% max()})} %>%
  {read.table(file=.$path, sep='\t', fill=TRUE, header=FALSE, col.names=c('pathway', 'url', str_c('id.', 1:.$ncol)))} %>%
  dlply(~pathway, function(x) list(url=x$url, ids=select(x, starts_with('id.')) %>% unlist(use.names=FALSE) %>% na.omit() %>% str_subset('^$', negate=TRUE))) -> hallmark_pathways

poi <- c('HALLMARK_TNFA_SIGNALING_VIA_NFKB', 'HALLMARK_INTERFERON_GAMMA_RESPONSE', 'HALLMARK_INTERFERON_ALPHA_RESPONSE')
hallmark_pathways[poi] %>%
  lapply(pluck, 'ids') %>%
  unlist(use.names=FALSE) %>%
  unique() -> goi

dds %>%
  metadata() %>%
  pluck('gene_information') %>%
  filter(gene_name %in% goi) %>%
  pluck('ensembl_gene_id') -> goi