## ----style, echo = FALSE, results = 'asis'------------------------------- knitr::opts_chunk$set( eval=as.logical(Sys.getenv("KNITR_EVAL", "TRUE")), cache=as.logical(Sys.getenv("KNITR_CACHE", "TRUE")) ) options(width = 75) ## ---- message=FALSE------------------------------------------------------ library(EnrichmentBrowser) ## ---- message = FALSE, echo = FALSE-------------------------------------- library(DESeq2) library(airway) library(dplyr) library(org.Hs.eg.db) library(GO.db) library(limma) ## ------------------------------------------------------------------------ library(airway) data(airway) airway$dex <- relevel(airway$dex, "untrt") ## ------------------------------------------------------------------------ library(DESeq2) des <- DESeqDataSet(airway, design = ~ cell + dex) des <- DESeq(des) res <- results(des) ## ------------------------------------------------------------------------ library(dplyr) library(tibble) tbl <- res %>% as.data.frame() %>% rownames_to_column("ENSEMBL") %>% as_tibble() tbl ## ------------------------------------------------------------------------ library(org.Hs.eg.db) tbl <- tbl %>% mutate( ENTREZID = mapIds( org.Hs.eg.db, ENSEMBL, "ENTREZID", "ENSEMBL" ) %>% unname() ) tbl ## ------------------------------------------------------------------------ tbl <- tbl %>% filter(!is.na(padj), !is.na(ENTREZID)) tbl ## ------------------------------------------------------------------------ library(limma) go <- goana(tbl$ENTREZID[tbl$padj < .05], tbl$ENTREZID, "Hs") %>% as_tibble() ## ------------------------------------------------------------------------ library(GO.db) go <- go %>% mutate( GOID = mapIds( GO.db, .$Term, "GOID", "TERM" ) %>% unname() ) %>% dplyr::select(GOID, everything()) %>% arrange(P.DE) ## ------------------------------------------------------------------------ go %>% filter(grepl("glucocorticoid", Term)) ## ------------------------------------------------------------------------ genesets <- AnnotationDbi::select(org.Hs.eg.db, tbl$ENTREZID, "GO", "ENTREZID") %>% as_tibble() %>% dplyr::select(ENTREZID, GO, ONTOLOGY) %>% distinct() genesets ## ------------------------------------------------------------------------ sessionInfo()