We aim to provide a modern interface to Gene Ontology. We use the Semantic SQL serialization in SQLite produced by the INCAtools project.
This package can be compared to GO.db. GO.ddb aims to capitalize on modern approaches to ontology management and data representation.
Before Bioconductor 3.24 is released, use
BiocManager::install("vjcitn/GO.ddb")
With Bioconductor versions 3.24 and beyond, use
BiocManager::install("GO.ddb")
Tidyverse practices are supported. Within the database, the GO CURIE is in the
id column.
## # A query: ?? x 5
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id label ontology definition deprecated
## <chr> <chr> <chr> <chr> <lgl>
## 1 GO:0002436 immune complex clearance by monocy… biologi… The proce… FALSE
## 2 GO:0002437 inflammatory response to antigenic… biologi… An inflam… FALSE
## 3 GO:0002438 acute inflammatory response to ant… biologi… An acute … FALSE
## 4 GO:0002439 chronic inflammatory response to a… biologi… A chronic… FALSE
## 5 GO:0002440 production of molecular mediator o… biologi… The synth… FALSE
## 6 GO:0002441 histamine secretion involved in in… biologi… The regul… FALSE
## 7 GO:0002442 serotonin secretion involved in in… biologi… The regul… FALSE
## 8 GO:0002443 leukocyte mediated immunity biologi… Any proce… FALSE
## 9 GO:0002444 myeloid leukocyte mediated immunity biologi… Any proce… FALSE
## 10 GO:0002445 type II hypersensitivity biologi… An inflam… FALSE
## # ℹ more rows
## [1] "id" "label" "ontology" "definition" "deprecated"
## # A query: ?? x 5
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id label ontology definition deprecated
## <chr> <chr> <chr> <chr> <lgl>
## 1 GO:0010656 negative regulation of muscle cell… biologi… Any proce… FALSE
## 2 GO:0010657 muscle cell apoptotic process biologi… A form of… FALSE
## 3 GO:0010658 striated muscle cell apoptotic pro… biologi… A form of… FALSE
## 4 GO:0010659 cardiac muscle cell apoptotic proc… biologi… A form of… FALSE
## 5 GO:0010660 regulation of muscle cell apoptoti… biologi… Any proce… FALSE
## 6 GO:0010661 positive regulation of muscle cell… biologi… Any proce… FALSE
## 7 GO:0010662 regulation of striated muscle cell… biologi… Any proce… FALSE
## 8 GO:0010663 positive regulation of striated mu… biologi… Any proce… FALSE
## 9 GO:0010664 negative regulation of striated mu… biologi… Any proce… FALSE
## 10 GO:0010665 regulation of cardiac muscle cell … biologi… Any proce… FALSE
## # ℹ more rows
go_terms() |> dplyr::filter(id %in% c("GO:0042267", "GO:0042268",
"GO:0042269", "GO:0042270")) |> dplyr::select(id, ontology, label)## # A query: ?? x 3
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id ontology label
## <chr> <chr> <chr>
## 1 GO:0042267 biological_process natural killer cell mediated cytotoxicity
## 2 GO:0042268 biological_process regulation of cytolysis
## 3 GO:0042269 biological_process regulation of natural killer cell mediated cyto…
## 4 GO:0042270 biological_process protection from natural killer cell mediated cy…
A shortcut for term lookup:
## # A query: ?? x 2
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id label
## <chr> <chr>
## 1 GO:0001795 type IIb hypersensitivity
## 2 GO:0006953 acute-phase response
go_ancestors utilizes the pre-computed ‘entailed_edge’
table in the Semantic SQL representation of GO.
go_ancestors("GO:0006954", relations = GO_RELATIONS["is_a"]) |>
inner_join(
go_terms() |> dplyr::select(ancestor_id = id, label),
by = "ancestor_id"
)## # A query: ?? x 4
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id ancestor_id relation label
## <chr> <chr> <chr> <chr>
## 1 GO:0006954 GO:0006950 rdfs:subClassOf response to stress
## 2 GO:0006954 GO:0006952 rdfs:subClassOf defense response
## 3 GO:0006954 GO:0008150 rdfs:subClassOf biological_process
## 4 GO:0006954 GO:0050896 rdfs:subClassOf response to stimulus
go_descendants("GO:0006954", relations = GO_RELATIONS["is_a"]) |>
inner_join(
go_terms() |> dplyr::select(descendant_id = id, label),
by = "descendant_id"
)## # A query: ?? x 4
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id descendant_id relation label
## <chr> <chr> <chr> <chr>
## 1 GO:0006954 GO:0001660 rdfs:subClassOf fever generation
## 2 GO:0006954 GO:0001788 rdfs:subClassOf antibody-dependent cellular cytotox…
## 3 GO:0006954 GO:0001794 rdfs:subClassOf type IIa hypersensitivity
## 4 GO:0006954 GO:0001795 rdfs:subClassOf type IIb hypersensitivity
## 5 GO:0006954 GO:0001802 rdfs:subClassOf type III hypersensitivity
## 6 GO:0006954 GO:0001806 rdfs:subClassOf type IV hypersensitivity
## 7 GO:0006954 GO:0002254 rdfs:subClassOf kinin cascade
## 8 GO:0006954 GO:0002255 rdfs:subClassOf tissue kallikrein-kinin cascade
## 9 GO:0006954 GO:0002353 rdfs:subClassOf plasma kallikrein-kinin cascade
## 10 GO:0006954 GO:1902483 rdfs:subClassOf cytotoxic T cell pyroptotic cell de…
## # ℹ more rows
Briefly, the fundamental representation of Gene Ontology is RDF (Resource Description Format). Each ontological assertion (statement) has the form of an ordered triple (subject, predicate, object).
All the implications of statements in Gene Ontology are available in the Semantic SQL representation. “Implication” here refers to derivability in a logical system implemented in an OWL reasoner. See OAK (ontology access kit) for more background.
To express certain concepts precisely, references to external ontologies are employed.
go_entailed_edges() |> dplyr::select(predicate) |>
group_by(predicate) |> summarise(n=n()) |>
arrange(desc(n))## # A query: ?? x 2
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## # Ordered by: desc(n)
## predicate n
## <chr> <dbl>
## 1 RO:0002131 1378323
## 2 rdfs:subClassOf 1367716
## 3 BFO:0000051 1053425
## 4 RO:0000057 659418
## 5 RO:0018038 481870
## 6 BFO:0000050 350002
## 7 RO:0002162 345293
## 8 RO:0004007 309651
## 9 RO:0018033 308277
## 10 RO:0018034 228886
## # ℹ more rows
Let’s check on the interpretation of a few of these frequently encountered CURIEs.
## Connected to SemanticSQL database: /github/home/.cache/R/BiocFileCache/15907c2183ce_ro.db
## Primary ontology prefix: RO
## Connected to SemanticSQL database: /github/home/.cache/R/BiocFileCache/159033af6a15_go.db
## Primary ontology prefix: GO
We can use ontoProc2 to help resolve details of predicates used to state relationships beyond those related to class membership (“is a”, “part of”).
The following code probes the first 20 statements available in the Semantic SQL representation of BSPO. There is in principle no guarantee that such a search would yield useful records.
## <SemsqlConn> prefix: BSPO | labeled terms: 402
The select procedure of AnnotationDbi can be replaced by
a filter on go_terms.
## Loading required package: AnnotationDbi
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: generics
##
## Attaching package: 'generics'
## The following object is masked from 'package:dplyr':
##
## explain
## The following objects are masked from 'package:base':
##
## as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
## setequal, union
##
## Attaching package: 'BiocGenerics'
## The following object is masked from 'package:dplyr':
##
## combine
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following object is masked from 'package:utils':
##
## data
## The following objects are masked from 'package:base':
##
## anyDuplicated, aperm, append, as.data.frame, basename, cbind,
## colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
## get, grep, grepl, is.unsorted, lapply, Map, mapply, match, mget,
## order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
## rbind, Reduce, rownames, sapply, saveRDS, scale, sequence, table,
## tapply, transform, unique, unsplit, which.max, which.min
## Loading required package: Biobase
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
## Loading required package: IRanges
## Loading required package: S4Vectors
##
## Attaching package: 'S4Vectors'
## The following objects are masked from 'package:dplyr':
##
## first, rename
## The following object is masked from 'package:utils':
##
## findMatches
## The following objects are masked from 'package:base':
##
## expand.grid, I, unname
##
## Attaching package: 'IRanges'
## The following objects are masked from 'package:dplyr':
##
## collapse, desc, slice
##
## Attaching package: 'AnnotationDbi'
## The following object is masked from 'package:dplyr':
##
## select
##
## 'select()' returned 1:1 mapping between keys and columns
## GOID TERM
## 1 GO:0006954 inflammatory response
## DEFINITION
## 1 The immediate defensive reaction (by vertebrate tissue) to infection or injury caused by chemical or physical agents. The process is characterized by local vasodilation, extravasation of plasma into intercellular spaces and accumulation of white blood cells and macrophages.
## ONTOLOGY
## 1 BP
Similar content is provided using go_terms:
## id label ontology
## 1 GO:0006954 inflammatory response biological_process
## definition
## 1 The immediate defensive reaction (by vertebrate tissue) to infection or injury caused by chemical or physical agents. The process is characterized by local vasodilation, extravasation of plasma into intercellular spaces and accumulation of white blood cells and macrophages.
## deprecated
## 1 FALSE
The GO.db package includes environments for efficient management of key-value pairs.
We’ll illustrate migration activities for one, the management of generalization of a selected concept via traversal of the GO graph. Here we use GO:0000112, denoting nucleotide-excision repair factor 3 complex. A view of the graph is provided here. Note that we do not include in this example any edges other than “is a” and “part of”, although other edge types can be explored with the “entailed_edge” table.
## [1] "GO" "GO_dbconn" "GO_dbfile" "GO_dbInfo"
## [5] "GO_dbschema" "GO.db" "GOBPANCESTOR" "GOBPCHILDREN"
## [9] "GOBPOFFSPRING" "GOBPPARENTS" "GOCCANCESTOR" "GOCCCHILDREN"
## [13] "GOCCOFFSPRING" "GOCCPARENTS" "GOMAPCOUNTS" "GOMFANCESTOR"
## [17] "GOMFCHILDREN" "GOMFOFFSPRING" "GOMFPARENTS" "GOOBSOLETE"
## [21] "GOSYNONYM" "GOTERM"
## [1] "GO:0000109" "GO:0005575" "GO:0005622" "GO:0005634" "GO:0032991"
## [6] "GO:0043226" "GO:0043227" "GO:0043229" "GO:0043231" "GO:0110165"
## [11] "GO:0140513" "all"
We use go_ancestors to obtain this information.
## id ancestor_id relation
## 1 GO:0000112 BFO:0000040 rdfs:subClassOf
## 2 GO:0000112 BFO:0000002 rdfs:subClassOf
## 3 GO:0000112 COB:0000080 rdfs:subClassOf
## 4 GO:0000112 GO:0032991 rdfs:subClassOf
## 5 GO:0000112 GO:0140513 rdfs:subClassOf
## 6 GO:0000112 BFO:0000004 rdfs:subClassOf
## 7 GO:0000112 GO:0005575 rdfs:subClassOf
## 8 GO:0000112 GO:0000109 rdfs:subClassOf
## 9 GO:0000112 BFO:0000002 BFO:0000050
## 10 GO:0000112 BFO:0000004 BFO:0000050
## 11 GO:0000112 BFO:0000040 BFO:0000050
## 12 GO:0000112 UBERON:0001062 BFO:0000050
## 13 GO:0000112 GO:0005575 BFO:0000050
## 14 GO:0000112 UBERON:0000465 BFO:0000050
## 15 GO:0000112 GO:0110165 BFO:0000050
## 16 GO:0000112 UBERON:0000061 BFO:0000050
## 17 GO:0000112 GO:0043226 BFO:0000050
## 18 GO:0000112 GO:0005622 BFO:0000050
## 19 GO:0000112 CL:0000000 BFO:0000050
## 20 GO:0000112 GO:0043227 BFO:0000050
## 21 GO:0000112 GO:0043229 BFO:0000050
## 22 GO:0000112 GO:0043231 BFO:0000050
## 23 GO:0000112 GO:0005634 BFO:0000050
Filtering down to the relevant GO terms:
## id ancestor_id relation
## 1 GO:0000112 GO:0032991 rdfs:subClassOf
## 2 GO:0000112 GO:0140513 rdfs:subClassOf
## 3 GO:0000112 GO:0005575 rdfs:subClassOf
## 4 GO:0000112 GO:0000109 rdfs:subClassOf
## 5 GO:0000112 GO:0005575 BFO:0000050
## 6 GO:0000112 GO:0110165 BFO:0000050
## 7 GO:0000112 GO:0043226 BFO:0000050
## 8 GO:0000112 GO:0005622 BFO:0000050
## 9 GO:0000112 GO:0043227 BFO:0000050
## 10 GO:0000112 GO:0043229 BFO:0000050
## 11 GO:0000112 GO:0043231 BFO:0000050
## 12 GO:0000112 GO:0005634 BFO:0000050
In summary, migration of AnnotationDbi-dependent code should be possible, although different functions and data structures will be encountered. If a particular legacy computation seems infeasible with GO.ddb, please raise an issue. We do not plan to update AnnotationDbi or GO.db in Bioconductor 3.24 or beyond, although the GO.db package will remain available with 2026 content.
Here’s a simple function to search for a regular expression in the ontology.
go_ids = function (regexpr, use = "label")
{
dplyr::filter(go_terms(), grepl(regexpr, !!sym(use)))
}We use this to enumerate specialized concepts related to “gonad development”.
## ✔ Overwriting dplyr methods with duckplyr methods.
## ℹ Turn off with `duckplyr::methods_restore()`.
gd = go_ids("gonad development") |>
dplyr::select(id) |>
collect() |>
pull(id) |>
go_descendants(include_self=TRUE) |>
left_join(go_terms(), by = c("descendant_id" = "id")) |>
dplyr::select(id = descendant_id, label)## duckdb keeps downloaded extensions and secrets in a temporary directory:
## ℹ /tmp/Rtmp2mpXyA/duckdb
## This is removed when the R session ends.
## • Extensions are re-downloaded each session.
## • Secrets are lost.
## ℹ Run duckdb(shared_home = TRUE) (or create ~/.duckdb) to keep them (suitable for most users).
## ℹ Run duckdb(shared_home = FALSE) to accept the temporary directory (and silence this message).
## ℹ See ?duckdb_storage for details and alternatives.
## # A query: ?? x 2
## # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1012-azure:R 4.6.1/:memory:]
## id label
## <chr> <chr>
## 1 GO:2000195 negative regulation of female gonad development
## 2 GO:2000872 positive regulation of progesterone secretion
## 3 GO:2000196 positive regulation of female gonad development
## 4 GO:2000020 positive regulation of male gonad development
## 5 GO:2000019 negative regulation of male gonad development
## 6 GO:1905940 negative regulation of gonad development
## 7 GO:2000870 regulation of progesterone secretion
## 8 GO:2000194 regulation of female gonad development
## 9 GO:1905939 regulation of gonad development
## 10 GO:1905941 positive regulation of gonad development
## # ℹ more rows
This section depends on the availability of an experimental package.
To get it, use
BiocManager::install("vjcitn/GOAnno4Bioc").
Briefly get_gaf obtains a representation of the Gene
Annotation Format resource for a model organism. We get a lazy
representation of this resource, filter it to the GO terms derived in
the previous section, and report on the distinct genes and aspects of
the annotation assertions.
if (requireNamespace("GOAnno4Bioc")) {
hu = GOAnno4Bioc::get_gaf("human")
hulim = inner_join( hu, gd, by=c(go_id="id"), copy=TRUE, relationship = "many-to-many") |>
dplyr::select(-db_reference,-evidence_code,-with_or_from,-date,-assigned_by) |> distinct()
hulim
}## Loading required namespace: GOAnno4Bioc