## [1] "clusterProfiler" "DOSE"            "pathview"        "org.Mm.eg.db"
invisible(lapply(
    X = basename(packages),
    FUN = function(package) {
        # Use `BiocInstaller::biocLite()` to install missing packages
        stopifnot(require(package, character.only = TRUE))
    }
))
# Bioconductor 3.6
stopifnot(packageVersion("clusterProfiler") >= 3.6)
stopifnot(packageVersion("DOSE") >= 3.4)
stopifnot(packageVersion("pathview") >= 1.18)

# Prepare template =============================================================
bcbioRNASeq::prepareRNASeqTemplate()
source("_setup.R")

# Directory paths ==============================================================
kegg_plots_dir <- file.path(params$results_dir, "kegg_plots")
invisible(mapply(
    FUN = dir.create,
    path = c(params$data_dir, params$results_dir, kegg_plots_dir),
    MoreArgs = list(showWarnings = FALSE, recursive = TRUE)
))

# Load objects =================================================================
dds_name <- load(params$dds_file)
dds <- get(dds_name, inherits = FALSE)
stopifnot(is(dds, "DESeqDataSet"))
invisible(validObject(dds))
# Require `entrezID` mappings column in `rowData()`.
stopifnot(is(rowData(dds)$entrezID, "list"))

res_name <- load(params$res_file)
res <- get(res_name, inherits = FALSE)
stopifnot(is(res, "DESeqResults"))
invisible(validObject(res))

# Ensure that DESeqDataSet and DESeqResults are matched
stopifnot(identical(rownames(dds), rownames(res)))

# KEGG organism code (e.g. "hsa" for Homo sapiens)
kegg_code <- params$organism %>%
    search_kegg_organism("scientific_name") %>%
    pull("kegg_code")
stopifnot(length(kegg_code) == 1)
stopifnot(grepl("^[a-z]{3}$", kegg_code))

# Check for valid GO class
# BP: Biological Process
# CC: Cellular Component
# MF: Molecular Function
stopifnot(params$go_class %in% c("BP", "CC", "MF"))

GO enrichment analysis

Gene Ontology (GO) term enrichment is a technique for interpreting sets of genes making use of the Gene Ontology system of classification, in which genes are assigned to a set of predefined bins depending on their functional characteristics.

## Saving enrich_go.rda, enrich_go_tbl.rda to /Users/travis/build/hbc/bcbio_rnaseq_output_example/report/data