R/AnnotateResults.R

Defines functions AnnotateResults

# Adds the field "Term" of each GO/KO ID to the results.
#
# Args:
#   defs: (list) a CALANGO-type list object (generated internally by the
#   CALANGO functions)
#   results: (list)  MHT-corrected p-values of all GO/KO IDs
#   ontology: (char) which ontology is used: GO, KO, other.
# Returns:
#   annotation: (list) translation of the ontology's terms.
AnnotateResults <- function(defs, results, ontology) {

  x <- switch(tolower(ontology),
              "go"            = as.list(AnnotationDbi::Term(GO.db::GOTERM[names(results)])),
              "gene ontology" = as.list(AnnotationDbi::Term(GO.db::GOTERM[names(results)])),
              "kegg"          = as.list(defs$allKOs[names(results)]),
              "other"         = defs$dictionary[names(results)])

  return(x)
}

Try the CALANGO package in your browser

Any scripts or data that you put into this service are public.

CALANGO documentation built on April 26, 2023, 5:13 p.m.