| Title: | Ontology Facilities Based on INCAtools Semantic SQL |
|---|---|
| Description: | This package provides ontology facilities based on INCAtools Semantic SQL. Tooling is provided to retrieve and cache SQLite databases representing curated ontologies. ontologyIndex ontology_index instances can be produced. Anthropic's Claude was used in the development of S7 classes and methods and in the production of documentation. |
| Authors: | Vincent Carey [aut, cre] (ORCID: <https://orcid.org/0000-0003-4046-0063>), Anthropic-Claude Sonnet4.6 [eng], NIH NHGRI 2U24HG004059-17 [fnd] |
| Maintainer: | Vincent Carey <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 0.99.28 |
| Built: | 2026-07-15 11:25:26 UTC |
| Source: | https://github.com/bioc/ontoProc2 |
retrieve and cache all filenames of Semantic SQL ontologies available, checking for updated content relative to cache via ETag
bbop_sqlite_db_gz( url = "https://s3.amazonaws.com/bbop-sqlite", bfc = BiocFileCache::BiocFileCache(), rname = "bbop_sqlite_listing", timeout_connect = 5, timeout_total = 15 )bbop_sqlite_db_gz( url = "https://s3.amazonaws.com/bbop-sqlite", bfc = BiocFileCache::BiocFileCache(), rname = "bbop_sqlite_listing", timeout_connect = 5, timeout_total = 15 )
url |
source address |
bfc |
an instance of BiocFileCache |
rname |
a string to use to identify the cached listing |
timeout_connect |
passed to httr2::req_options connecttimeout parameter |
timeout_total |
passed to httr2::req_options seconds parameter |
a character vector
There is no real etag discipline for the metadata, so full metadata content is extracted on each call, digested, and compared to digest in cache. Cache is updated when there is a discrepancy, except there is a guard against rewriting cache with corrupted or zero-length data at endpoint. Note this code was negotiated at length with claude.ai Sonnet 4.6.
gzs = bbop_sqlite_db_gz() head(gzs) length(gzs)gzs = bbop_sqlite_db_gz() head(gzs) length(gzs)
produce a table with cells exhibiting given proteins on plasma membrane according to CL
cells_with_pmp(curies)cells_with_pmp(curies)
curies |
a character vector in format "PR:nnnnnnnnn" |
a data.frame with columns cl, celltype, pr, protein
# 2064: microsialin, 1874: KLRB1-like protein cells_with_pmp(c("PR:000002064", "PR:000001874"))# 2064: microsialin, 1874: KLRB1-like protein cells_with_pmp(c("PR:000002064", "PR:000001874"))
a named vector with mapping from cell type phrase to CURIE for CL.owl of 2025-12-17
data(cn2tag)data(cn2tag)
names character vector
data("cn2tag", package = "ontoProc2") cn2tag["Kupffer cell"]data("cn2tag", package = "ontoProc2") cn2tag["Kupffer cell"]
Count labeled terms grouped by CURIE prefix
count_by_prefix(x, ...)count_by_prefix(x, ...)
x |
A |
... |
not used. |
data.frame with columns prefix and n, ordered by
n descending.
goref <- semsql_connect(ontology = "go") count_by_prefix(goref) disconnect(goref)goref <- semsql_connect(ontology = "go") count_by_prefix(goref) disconnect(goref)
Count the number of descendants of a term
count_descendants(x, term_id, predicate = "rdfs:subClassOf", ...)count_descendants(x, term_id, predicate = "rdfs:subClassOf", ...)
x |
A |
term_id |
character(1) CURIE. |
predicate |
character(1) predicate to traverse
(default |
... |
not used |
integer(1).
goref <- semsql_connect(ontology = "go") count_descendants(goref, "GO:0006915") # all apoptosis subtypes disconnect(goref)goref <- semsql_connect(ontology = "go") count_descendants(goref, "GO:0006915") # all apoptosis subtypes disconnect(goref)
Describe the columns of a table in a SemsqlConn database
describe_table(x, table_name, ...)describe_table(x, table_name, ...)
x |
A |
table_name |
character(1) name of the table. |
... |
not used |
data.frame with PRAGMA table_info output (columns: cid, name, type, notnull, dflt_value, pk).
goref <- semsql_connect(ontology = "go") describe_table(goref, "rdfs_label_statement") disconnect(goref)goref <- semsql_connect(ontology = "go") describe_table(goref, "rdfs_label_statement") disconnect(goref)
Disconnect a SemsqlConn from its database
disconnect(x, quiet = FALSE, ...)disconnect(x, quiet = FALSE, ...)
x |
A |
quiet |
logical(1) if TRUE suppresses the disconnection message (default FALSE). |
... |
not used |
The SemsqlConn object invisibly.
Find terms that have a given OWL someValuesFrom restriction
find_by_restriction( x, property, filler, include_filler_descendants = FALSE, ... )find_by_restriction( x, property, filler, include_filler_descendants = FALSE, ... )
x |
A |
property |
character(1) property CURIE
(e.g. |
filler |
character(1) filler class CURIE. |
include_filler_descendants |
logical(1) if TRUE also match subclasses
of |
... |
not used |
data.frame with columns id and label.
goref <- semsql_connect(ontology = "go") # cellular components that are part_of nucleus (GO:0005634) find_by_restriction(goref, "BFO:0000050", "GO:0005634") disconnect(goref)goref <- semsql_connect(ontology = "go") # cellular components that are part_of nucleus (GO:0005634) find_by_restriction(goref, "BFO:0000050", "GO:0005634") disconnect(goref)
Find terms that are descendants of a superclass and have a given restriction
find_intersection(x, superclass_id, relation_property, related_to_id, ...)find_intersection(x, superclass_id, relation_property, related_to_id, ...)
x |
A |
superclass_id |
character(1) CURIE of the superclass. |
relation_property |
character(1) property CURIE for the restriction. |
related_to_id |
character(1) filler CURIE for the restriction. |
... |
not used |
data.frame with columns id and label.
goref <- semsql_connect(ontology = "go") # CC terms (GO:0005575) that are part_of nucleus (GO:0005634) find_intersection(goref, "GO:0005575", "BFO:0000050", "GO:0005634") disconnect(goref)goref <- semsql_connect(ontology = "go") # CC terms (GO:0005575) that are part_of nucleus (GO:0005634) find_intersection(goref, "GO:0005575", "BFO:0000050", "GO:0005634") disconnect(goref)
Get all ancestors of a term via entailed edges
get_ancestors( x, term_id, predicates = "rdfs:subClassOf", include_self = FALSE, ... )get_ancestors( x, term_id, predicates = "rdfs:subClassOf", include_self = FALSE, ... )
x |
A |
term_id |
character(1) CURIE. |
predicates |
character vector of predicate CURIEs to follow.
Defaults to |
include_self |
logical(1) whether to include the term itself
(default |
... |
not used |
data.frame with columns id, label, predicate.
goref <- semsql_connect(ontology = "go") get_ancestors(goref, "GO:0006915") disconnect(goref)goref <- semsql_connect(ontology = "go") get_ancestors(goref, "GO:0006915") disconnect(goref)
Convenience wrapper around get_ancestors() that follows both
rdfs:subClassOf and BFO:0000050 (part-of) edges.
get_ancestors_partonomy(conn, term_id, include_self = FALSE)get_ancestors_partonomy(conn, term_id, include_self = FALSE)
conn |
A |
term_id |
character(1) CURIE. |
include_self |
logical(1) whether to include the term itself
(default |
data.frame with columns id, label, predicate.
goref <- semsql_connect(ontology = "go") get_ancestors_partonomy(goref, "GO:0005739") # mitochondrion disconnect(goref)goref <- semsql_connect(ontology = "go") get_ancestors_partonomy(goref, "GO:0005739") # mitochondrion disconnect(goref)
Get the text definition for a term
get_definition(x, term_id, ...)get_definition(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE. |
... |
not used |
character(1) definition text, or NA_character_ if not found.
goref <- semsql_connect(ontology = "go") get_definition(goref, "GO:0006915") disconnect(goref)goref <- semsql_connect(ontology = "go") get_definition(goref, "GO:0006915") disconnect(goref)
Get all descendants of a term via entailed edges
get_descendants( x, term_id, predicates = "rdfs:subClassOf", include_self = FALSE, ... )get_descendants( x, term_id, predicates = "rdfs:subClassOf", include_self = FALSE, ... )
x |
A |
term_id |
character(1) CURIE. |
predicates |
character vector of predicate CURIEs to follow.
Defaults to |
include_self |
logical(1) whether to include the term itself
(default |
... |
not used |
data.frame with columns id, label, predicate.
goref <- semsql_connect(ontology = "go") get_descendants(goref, "GO:0006915") disconnect(goref)goref <- semsql_connect(ontology = "go") get_descendants(goref, "GO:0006915") disconnect(goref)
Convenience wrapper around get_descendants() that follows both
rdfs:subClassOf and BFO:0000051 (has-part) edges.
get_descendants_partonomy(conn, term_id, include_self = FALSE)get_descendants_partonomy(conn, term_id, include_self = FALSE)
conn |
A |
term_id |
character(1) CURIE. |
include_self |
logical(1) whether to include the term itself
(default |
data.frame with columns id, label, predicate.
goref <- semsql_connect(ontology = "go") get_descendants_partonomy(goref, "GO:0005634") # nucleus sub-components disconnect(goref)goref <- semsql_connect(ontology = "go") get_descendants_partonomy(goref, "GO:0005634") # nucleus sub-components disconnect(goref)
Get direct edges in the ontology graph for a term
get_direct_edges( x, term_id, direction = c("outgoing", "incoming", "both"), ... )get_direct_edges( x, term_id, direction = c("outgoing", "incoming", "both"), ... )
x |
A |
term_id |
character(1) CURIE. |
direction |
character(1) one of |
... |
not used |
data.frame with columns subject, subject_label,
predicate, predicate_label, object,
object_label.
goref <- semsql_connect(ontology = "go") get_direct_edges(goref, "GO:0006915") get_direct_edges(goref, "GO:0006915", direction = "both") disconnect(goref)goref <- semsql_connect(ontology = "go") get_direct_edges(goref, "GO:0006915") get_direct_edges(goref, "GO:0006915", direction = "both") disconnect(goref)
Get direct subclasses of a term
get_direct_subclasses(x, term_id, ...)get_direct_subclasses(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE. |
... |
not used |
data.frame with columns id and label, ordered by
label.
goref <- semsql_connect(ontology = "go") # direct children of "apoptotic process" (GO:0006915) get_direct_subclasses(goref, "GO:0006915") disconnect(goref)goref <- semsql_connect(ontology = "go") # direct children of "apoptotic process" (GO:0006915) get_direct_subclasses(goref, "GO:0006915") disconnect(goref)
Get direct superclasses of a term
get_direct_superclasses(x, term_id, ...)get_direct_superclasses(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE. |
... |
not used |
data.frame with columns id and label, ordered by
label.
goref <- semsql_connect(ontology = "go") get_direct_superclasses(goref, "GO:0006915") disconnect(goref)goref <- semsql_connect(ontology = "go") get_direct_superclasses(goref, "GO:0006915") disconnect(goref)
Get the rdfs:label for a term
get_label(x, term_id, ...)get_label(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE, e.g. |
... |
not used |
character(1) label, or NA_character_ if not found.
goref <- semsql_connect(ontology = "go") get_label(goref, "GO:0006915") # "apoptotic process" disconnect(goref)goref <- semsql_connect(ontology = "go") get_label(goref, "GO:0006915") # "apoptotic process" disconnect(goref)
Retrieve the ontology prefix from a SemsqlConn
get_prefix(x, ...)get_prefix(x, ...)
x |
A |
... |
not used |
character(1) the primary ontology prefix (e.g. "GO").
goref <- semsql_connect(ontology = "go") get_prefix(goref) disconnect(goref)goref <- semsql_connect(ontology = "go") get_prefix(goref) disconnect(goref)
produce a table with list of proteins from protein ontology identified as present on cell membranes for input cell type CURIEs
get_present_pmp(curies)get_present_pmp(curies)
curies |
a character vector in format "CL:nnnnnnn" |
a data.frame with columns cl, celltype, pr, protein
get_present_pmp(c("CL:0000091", "CL:0000926"))get_present_pmp(c("CL:0000091", "CL:0000926"))
Get OWL someValuesFrom restrictions for a term
get_restrictions(x, term_id, ...)get_restrictions(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE. |
... |
not used |
data.frame with columns restriction_id, property,
property_label, filler, filler_label.
goref <- semsql_connect(ontology = "go") # mitochondrion (GO:0005739) has part-of restrictions to cell get_restrictions(goref, "GO:0005739") disconnect(goref)goref <- semsql_connect(ontology = "go") # mitochondrion (GO:0005739) has part-of restrictions to cell get_restrictions(goref, "GO:0005739") disconnect(goref)
Get synonyms for a term
get_synonyms( x, term_id, type = c("all", "exact", "broad", "narrow", "related"), ... )get_synonyms( x, term_id, type = c("all", "exact", "broad", "narrow", "related"), ... )
x |
A |
term_id |
character(1) CURIE. |
type |
character(1) synonym scope: one of |
... |
not used |
data.frame with columns subject, predicate,
synonym.
goref <- semsql_connect(ontology = "go") get_synonyms(goref, "GO:0006915") get_synonyms(goref, "GO:0006915", type = "exact") disconnect(goref)goref <- semsql_connect(ontology = "go") get_synonyms(goref, "GO:0006915") get_synonyms(goref, "GO:0006915", type = "exact") disconnect(goref)
Retrieve a summary of information about a term
get_term_info(x, term_id, ...)get_term_info(x, term_id, ...)
x |
A |
term_id |
character(1) CURIE. |
... |
not used |
list with elements id, label, definition,
synonyms, superclasses, subclasses.
goref <- semsql_connect(ontology = "go") info <- get_term_info(goref, "GO:0006915") info$label info$superclasses disconnect(goref)goref <- semsql_connect(ontology = "go") info <- get_term_info(goref, "GO:0006915") info$label info$superclasses disconnect(goref)
inject linefeeds for node names for graph, with textual annotation from ontology
improve_nodes(g, ont)improve_nodes(g, ont)
g |
graphNEL instance |
ont |
instance of ontology from ontologyIndex |
graphNEL instance
requireNamespace("Rgraphviz") requireNamespace("graph") clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) p3k <- ontologyPlot::onto_plot(cl, cl3k) gnel <- make_graphNEL_from_ontology_plot(p3k) head(graph::nodes(gnel)) # before improving gnel <- improve_nodes(gnel, cl) head(graph::nodes(gnel))requireNamespace("Rgraphviz") requireNamespace("graph") clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) p3k <- ontologyPlot::onto_plot(cl, cl3k) gnel <- make_graphNEL_from_ontology_plot(p3k) head(graph::nodes(gnel)) # before improving gnel <- improve_nodes(gnel, cl) head(graph::nodes(gnel))
Test whether a SemsqlConn has a valid open connection
is_connected(x, ...)is_connected(x, ...)
x |
A |
... |
not used |
logical(1).
goref <- semsql_connect(ontology = "go") is_connected(goref) # TRUE disconnect(goref) is_connected(goref) # FALSEgoref <- semsql_connect(ontology = "go") is_connected(goref) # TRUE disconnect(goref) is_connected(goref) # FALSE
List tables in a SemsqlConn database
list_tables(x, ...)list_tables(x, ...)
x |
A |
... |
not used |
character vector of table names.
goref <- semsql_connect(ontology = "go") list_tables(goref) disconnect(goref)goref <- semsql_connect(ontology = "go") list_tables(goref) disconnect(goref)
obtain graphNEL from ontology_plot instance of ontologyPlot
make_graphNEL_from_ontology_plot(x)make_graphNEL_from_ontology_plot(x)
x |
instance of S3 class ontology_plot |
instance of S4 graphNEL class
requireNamespace("Rgraphviz") requireNamespace("graph") clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) p3k <- ontologyPlot::onto_plot(cl, cl3k) gnel <- make_graphNEL_from_ontology_plot(p3k) gnel <- improve_nodes(gnel, cl) graph::graph.par(list(nodes = list(shape = "plaintext", cex = .8))) gnel <- Rgraphviz::layoutGraph(gnel) Rgraphviz::renderGraph(gnel)requireNamespace("Rgraphviz") requireNamespace("graph") clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) p3k <- ontologyPlot::onto_plot(cl, cl3k) gnel <- make_graphNEL_from_ontology_plot(p3k) gnel <- improve_nodes(gnel, cl) graph::graph.par(list(nodes = list(shape = "plaintext", cex = .8))) gnel <- Rgraphviz::layoutGraph(gnel) Rgraphviz::renderGraph(gnel)
a named vector with values rdfs labels in NCI thesaurus, and names the corresponding formal ontology tags
data(ncit_map)data(ncit_map)
named character vector
data("ncit_map", package = "ontoProc2") ncit_map["EFO:1000899"]data("ncit_map", package = "ontoProc2") ncit_map["EFO:1000899"]
high-level use of graph/Rgraphviz for rendering ontology relations
onto_plot2(ont, terms2use, cex = 0.8, ...)onto_plot2(ont, terms2use, cex = 0.8, ...)
ont |
instance of ontology from ontologyIndex |
terms2use |
character vector |
cex |
numeric(1) defaults to .8, supplied to Rgraphviz::graph.par |
... |
passed to onto_plot of ontologyPlot |
graphNEL instance (invisibly)
clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) onto_plot2(cl, cl3k)clcon <- retrieve_semsql_conn("cl") cl <- semsql_to_oi(clcon) cl3k <- c( "CL:0000492", "CL:0001054", "CL:0000236", "CL:0000625", "CL:0000576", "CL:0000623", "CL:0000451", "CL:0000556" ) onto_plot2(cl, cl3k)
A named list of commonly used predicate CURIEs in OBO-format ontologies,
for use with get_ancestors(), get_descendants(),
and related functions.
PREDICATESPREDICATES
A named list with elements subclass_of, part_of,
has_part, develops_from, located_in,
has_characteristic.
a named list
goref <- semsql_connect(ontology = "go") # apoptotic process (GO:0006915) ancestors via is-a and part-of anc <- get_ancestors(goref, "GO:0006915", predicates = c(PREDICATES$subclass_of, PREDICATES$part_of) ) head(anc) disconnect(goref)goref <- semsql_connect(ontology = "go") # apoptotic process (GO:0006915) ancestors via is-a and part-of anc <- get_ancestors(goref, "GO:0006915", predicates = c(PREDICATES$subclass_of, PREDICATES$part_of) ) head(anc) disconnect(goref)
SemsqlConn object is
auto-printed at the R prompt.Show method for SemsqlConn.
Concise one-line summary displayed when a SemsqlConn object is
auto-printed at the R prompt.
## S7 method for class <ontoProc2::SemsqlConn> print(x, ...)## S7 method for class <ontoProc2::SemsqlConn> print(x, ...)
x |
A |
... |
not used |
x, invisibly
Attempts to reconnect a disconnected SemsqlConn object to its
database. Returns a new SemsqlConn; the original cannot be modified
in place due to S7 value semantics.
reconnect(x, ...)reconnect(x, ...)
x |
A |
... |
not used |
A new SemsqlConn object with an active connection.
goref <- semsql_connect(ontology = "go") disconnect(goref) goref <- reconnect(goref) disconnect(goref)goref <- semsql_connect(ontology = "go") disconnect(goref) goref <- reconnect(goref) disconnect(goref)
Displays a verbose, formatted representation of a SemsqlConn object
including connection status, database statistics (labeled terms, edges,
definitions), prefix breakdown, and available key tables. More informative
than print(), intended for interactive exploration.
report(object, ...) ## S7 method for class <ontoProc2::SemsqlConn> report(object, ...)report(object, ...) ## S7 method for class <ontoProc2::SemsqlConn> report(object, ...)
object |
A |
... |
additional arguments (currently unused) |
The SemsqlConn object invisibly.
goref <- semsql_connect(ontology = "go") report(goref) disconnect(goref)goref <- semsql_connect(ontology = "go") report(goref) disconnect(goref)
return a SQLite connection (read only) to an INCAtools Semantic SQL ontology
retrieve_semsql_conn( ontology = "efo", cache = BiocFileCache::BiocFileCache(), cacheid = NULL, ... )retrieve_semsql_conn( ontology = "efo", cache = BiocFileCache::BiocFileCache(), cacheid = NULL, ... )
ontology |
character(1) short string prefixing .db.gz in the INCAtools collection |
cache |
a BiocFileCache instance, defaulting to BiocFileCache::BiocFileCache() |
cacheid |
character(1) or NULL; if non-null, the associated SQLite resource will be used from cache |
... |
passed to download.file |
an RSQLite DBI connection instance
When the cache is searched, the string given as 'ontology' will be prefixed with '^'. This helps avoid confusion between pcl.db and cl.db, for example.
# first time will involve a download and decompression aionto <- retrieve_semsql_conn("aio") head(DBI::dbListTables(aionto)) dplyr::tbl(aionto, "class_node") |> head()# first time will involve a download and decompression aionto <- retrieve_semsql_conn("aio") head(DBI::dbListTables(aionto)) dplyr::tbl(aionto, "class_node") |> head()
Run an arbitrary SQL query against a SemsqlConn database
run_query(x, sql, ...)run_query(x, sql, ...)
x |
A |
sql |
character(1) SQL query string. |
... |
not used |
data.frame with query results.
goref <- semsql_connect(ontology = "go") run_query( goref, "SELECT subject, value AS label FROM rdfs_label_statement LIMIT 5" ) disconnect(goref)goref <- semsql_connect(ontology = "go") run_query( goref, "SELECT subject, value AS label FROM rdfs_label_statement LIMIT 5" ) disconnect(goref)
Search term labels in a SemsqlConn database
search_labels(x, pattern, limit = 20L)search_labels(x, pattern, limit = 20L)
x |
A |
pattern |
character(1) substring to match against rdfs:label values (SQL LIKE pattern, case-insensitive on most SQLite builds). |
limit |
integer(1) maximum number of rows to return (default 20). |
data.frame with columns subject and label.
goref <- semsql_connect(ontology = "go") search_labels(goref, "apoptosis") disconnect(goref)goref <- semsql_connect(ontology = "go") search_labels(goref, "apoptosis") disconnect(goref)
Opens a connection to a SemanticSQL SQLite database, either by supplying
a direct file path or by referencing a short ontology name that is
retrieved and cached via BiocFileCache.
semsql_connect( db_path = NULL, ontology_prefix = NULL, ontology = NULL, cache = BiocFileCache::BiocFileCache(), validate = TRUE, ... )semsql_connect( db_path = NULL, ontology_prefix = NULL, ontology = NULL, cache = BiocFileCache::BiocFileCache(), validate = TRUE, ... )
db_path |
character(1) or NULL. Path to an existing SQLite database
file. Either |
ontology_prefix |
character(1) or NULL. Primary CURIE prefix for the
ontology (e.g. |
ontology |
character(1) or NULL. Short name of an INCAtools ontology
(e.g. |
cache |
a |
validate |
logical(1) if TRUE (the default value) the ontology code is checked against available Semantic SQL resources at INCAtools. Set to FALSE if using off line. |
... |
passed to |
A SemsqlConn() object.
The connection has flag SQLITE_RO for read-only access. There will
be an attempt to validate the ontology tag that is supplied, against all
available Semantic SQL resources available at INCAtools bucket. Function fails
if a match cannot be made, which in general requires network access.
# by ontology short name (downloads if not cached) goref <- semsql_connect(ontology = "go") goref disconnect(goref)# by ontology short name (downloads if not cached) goref <- semsql_connect(ontology = "go") goref disconnect(goref)
produce an ontology_index instance from semantic sql sqlite connection
semsql_to_oi(con)semsql_to_oi(con)
con |
DBI::dbConnect value for sqlite table |
result of ontologyIndex::ontology_index evaluated for the labels and parent-child relations in tables statements and edge of the semantic sql resource
## Not run: conn <- semsql_connect(ontology = "aio") oi <- suppressWarnings(semsql_to_oi(conn@con)) names(oi) ## End(Not run)## Not run: conn <- semsql_connect(ontology = "aio") oi <- suppressWarnings(semsql_to_oi(conn@con)) names(oi) ## End(Not run)
produce INCAtools distribution URL
semsql_url(ontology = "efo")semsql_url(ontology = "efo")
ontology |
short string that is the prefix to .db.gz in the bbop-sqlite collection |
a string with URL for INCAtools resource
semsql_url("cl")semsql_url("cl")
An S7 class that encapsulates a SQLite connection to an ontology database following the SemanticSQL schema. Provides methods for common ontology queries including label lookup, ancestor/descendant traversal, and relationship queries.
Properties:
The DBI connection object (SQLiteConnection)
character(1) path to the SQLite database file
character(1) primary ontology prefix,
e.g. "CL" for the Cell Ontology
SemsqlConn(con = NULL, db_path = character(0), ontology_prefix = character(0))SemsqlConn(con = NULL, db_path = character(0), ontology_prefix = character(0))
con |
DBI connection object |
db_path |
character path to SQLite database file |
ontology_prefix |
character, e.g., 'CL' for cell ontology |
wrapped connection
a named vector with mapping from CURIE to cell type phrase for CL.owl of 2025-12-17
data(tag2cn)data(tag2cn)
names character vector
data("tag2cn", package = "ontoProc2") tag2cn[c("CL:0000000", "CL:0000006")]data("tag2cn", package = "ontoProc2") tag2cn[c("CL:0000000", "CL:0000006")]
Opens a connection, evaluates an expression with conn bound to the
open SemsqlConn, then closes the connection even if an error occurs.
Analogous to Python's context manager (with statement).
with_connection(db_path, expr)with_connection(db_path, expr)
db_path |
character(1) path to the SQLite database. |
expr |
an expression to evaluate; |
the value of expr.
## Not run: result <- with_connection("cl.db", { get_ancestors(conn, "CL:0000540") }) ## End(Not run)## Not run: result <- with_connection("cl.db", { get_ancestors(conn, "CL:0000540") }) ## End(Not run)