Package 'OmaDB'

Title: R wrapper for the OMA REST API
Description: A package for the orthology prediction data download from the OMA browser database (https://omabrowser.org). It provides access to proteins, genomes, Hierarchical Orthologous Groups (HOGs), OMA Groups, pairwise orthologs, the taxonomy and (ancestral) synteny via the OMA REST API. The results are returned as data.frames or objects using standard Bioconductor classes such as GRanges and AAString, and can be used for downstream analyses, e.g. Gene Ontology enrichment with topGO. Responses are cached in memory and optionally on disk.
Authors: Klara Kaleb [aut], Adrian Altenhoff [aut, cre] (ORCID: <https://orcid.org/0000-0001-7492-1273>)
Maintainer: Adrian Altenhoff <[email protected]>
License: GPL-3
Version: 2.31.0
Built: 2026-11-24 04:32:11 UTC
Source: https://github.com/bioc/OmaDB

Help Index


Map GO annotation to a sequence that is not available in the OMA Browser

Description

This function obtain Gene Ontology annotation for a given sequence that does not need to exist in the OMA Browser so far. The query sequence will analysed and a fast homology detection approach based on kmers will be used to detect the closest sequences in OMA. GO annotations for these top hits will be used to annotated the query sequence.

Usage

annotateSequence(query)

Arguments

query

the sequence to be annotated, it can be either a string or an AAString object from the Biostrings package

Value

a data.frame containing the GO annotations (in GAF format columns) of the most similar protein to the query sequence

Examples

seq <- paste0("MNDPSLLGYPNVGPQQQQQQQQQQHAGLLGKGTPNALQQQLHMNQLTGIPPPGLMN",
    "NSDVHTSSNNNSRQLLDQLANGNANMLNMNMDNNNNNNNNNNNNNNNGGGSGVMMNASTAAVNSIGM")
go <- annotateSequence(query = seq)
head(go[, c("GO_ID", "GO_name", "Aspect")])

Format the GO annotations data

Description

The function creates a list of GO annotations that is compatible with topGO from proteins or GO annotations retrieved from the OMA Browser.

Usage

formatTopGO(geneList, format)

Arguments

geneList

either a list of protein objects (as returned by getProtein for several ids), or a data.frame of GO annotations, e.g. as returned by getProtein(ids, attribute = "gene_ontology") or getHOG(id, attribute = "gene_ontology"). For a data.frame, the genes are identified by the column query_id if present, id otherwise.

format

format for the data to be returned in - either 'GO2geneID' or 'geneID2GO'

Value

a named list containing the GO2geneID or geneID2GO information

Examples

geneList <- getProtein(id = c("YEAST00001", "YEAST00003"))
annotations <- formatTopGO(geneList, format = "geneID2GO")
lengths(annotations)

Get the value of an attribute of an object

Description

Returns the value of an attribute of an object returned by the package. If the attribute is a url pointing to the OMA Browser API, the data behind the url is loaded and returned. This is equivalent to obj$attribute.

Usage

getAttribute(obj, attribute)

Arguments

obj

an object of class omadb_obj

attribute

the name of the attribute

Value

the value of the attribute

Examples

members <- getAttribute(getOMAGroup(id = "YEAST58"), "members")
head(members$omaid)

Retrieve a genome from the OMA Browser database

Description

This function obtains the basic information for one specific genome available on the OMA Browser, or - if no id is provided - a data.frame with all available genomes.

Usage

getGenome(id = NULL, attribute = NULL)

Arguments

id

A genome identifier. By default, all available genomes will be returned.

attribute

An extra attribute to be returned ('proteins' or 'genes').

Details

Ids can be either the scientific name of a species, the NCBI taxonomy id or the UniProtKB mnemonic species code.

The optional argument attribute can be used to directly load the proteins (all proteins, including alternative splicing isoforms) or the genes (only the main isoform of each gene) of the genome. Alternatively, you can access the proteins attribute of the result which will transparently load the proteins from the OMA Browser.

Value

If no id is given, a data.frame with all genomes. Otherwise an omadb_obj with the genome's attributes, or - if attribute is given - a data.frame with the proteins or genes of the genome.

Examples

genomes <- getGenome()
head(genomes[, c("code", "taxon_id", "species")])
getGenome(id = "HUMAN")
getGenome(id = 9606)
prots <- getGenome(id = "ASHGO", attribute = "proteins")
nrow(prots)

Retrieves the pairwise relations among two genomes

Description

This function retrieves the pairwise relations among two genomes from the OMA Browser database. The relations are orthologs in case the genomes are different and "close paralogs" and "homeologs" in case they are the same.

Usage

getGenomePairs(
  genome_id1,
  genome_id2,
  chr1 = NULL,
  chr2 = NULL,
  rel_type = NULL,
  ...
)

Arguments

genome_id1

an identifier for the first genome, which can be either its taxon id or UniProt species code

genome_id2

an identifier for the second genome, which can be either its taxon id or UniProt species code

chr1

the chromosome of interest for the first genome

chr2

the chromosome of interest for the second genome

rel_type

the pairs relationship type

...

ignored; kept for backwards compatibility.

Details

By using the parameters chr1 and chr2, one can limit the relations to a certain chromosome for one or both genomes. The id of the chromosome corresponds to the chromosome ids from the getGenome result.

The rel_type parameter further limits the returned relations to a specific subtype of orthologs (i.e. "1:1", "1:n", "m:1", "m:n") or - within a genome to either "close paralogs" or "homeologs".

Value

a data.frame containing information about both the entries in the pair (columns starting with entry_1. and entry_2.) and their relationship.

Examples

pairs <- getGenomePairs(genome_id1 = "YEAST", genome_id2 = "ASHGO",
    chr2 = "I", rel_type = "1:1")
head(pairs[, c("entry_1.omaid", "entry_2.omaid", "rel_type")])

Retrieve a HOG from the OMA Browser

Description

The function retrieves a specific Hierarchical Orthologous Group (HOG) from the OMA Browser database. A HOG is a set of genes that have all descended from a single ancestral gene at a specific taxonomic level.

Usage

getHOG(id, level = NULL, members = FALSE, attribute = NULL, max_results = NULL)

Arguments

id

an identifier for the HOG to be returned - either its HOG ID or a protein id.

level

a specific level for the HOG to be restricted to. level can either be 'root', or the name of a taxonomic level that is part of the HOG, e.g. 'Fungi'. By default it will retrieve the deepest level of the most specific subhog for the given ID.

members

logical, if TRUE returns a data.frame containing the member proteins of the HOG at the given level. This is equivalent to attribute = "members".

attribute

an extra attribute of the HOG to be returned, see details.

max_results

for attribute = "similar_profile_hogs", the maximum number of similar HOGs to return.

Details

A HOG can be identified by its member proteins and a taxonomic level, or a HOG ID. As a taxonomic level, you can use either 'root' to retrieve the HOG at its deepest level, or the name of NCBI taxonomy level, or leave it out in which case the deepest level that doesn't include a duplication node is used.

The optional argument attribute can be used to directly retrieve

members

the member proteins of the HOG at the given level

gene_ontology

the Gene Ontology annotations of the HOG, i.e. of the ancestral gene at the given level, with a score

similar_profile_hogs

HOGs with a similar phylogenetic profile, i.e. similar pattern of gene losses and duplications

Value

Without attribute, a data.frame with one row per HOG matching the query (a HOG ID can refer to several sub-HOGs at a given level), each with information on the HOG at the given level. With attribute (or members = TRUE), a data.frame with the requested data.

Examples

getHOG(id = "YEAST00001")
getHOG(id = "YEAST00001", level = "root")[, c("hog_id", "level")]
members <- getHOG(id = "HOG:F0411479", level = "Saccharomycetaceae",
    members = TRUE)
head(members$omaid)
getHOG(id = "HOG:F0411479", attribute = "gene_ontology")

Retrieve all HOGs at a taxonomic level

Description

The function retrieves all Hierarchical Orthologous Groups (HOGs) that are defined at a given taxonomic level. Each HOG corresponds to an ancestral gene of the ancestral genome at that level, so this function can be used to retrieve the gene content of an ancestral genome.

Usage

getHOGs(level, compare_with = NULL)

Arguments

level

the taxonomic level of interest (scientific name or NCBI taxon id).

compare_with

optional, a more ancestral taxonomic level to compare with.

Details

If compare_with is set to a more ancestral taxonomic level, each HOG is annotated with the evolutionary event that happened to the corresponding ancestral gene between the two levels: whether it was retained, duplicated, gained (i.e. it originated between the levels) or lost.

Value

a data.frame with one row per HOG. The column members_url can be used with resolveURL to retrieve the members of a HOG. If compare_with is given, the column event contains the evolutionary event.

Examples

hogs <- getHOGs(level = "Saccharomycetaceae")
nrow(hogs)
head(hogs[, c("hog_id", "completeness_score", "nr_genes")])

Get loci for a given list of proteins

Description

Function to obtain the genomic loci of a set of proteins as a GRanges object.

Usage

getLocus(proteins)

Arguments

proteins

the proteins of interest. Either a character vector of protein ids, a data.frame with protein data (e.g. the members of an OMA group or HOG, which have the columns omaid, chromosome, locus.start, locus.end and locus.strand), a list of such data.frames or an omadb_obj of a protein.

Value

a GRanges object with the loci of the proteins. The seqnames are the chromosomes, the names are the OMA ids of the proteins.

Examples

loci <- getLocus(proteins = getOMAGroup("YEAST58")$members)
loci
getLocus(c("YEAST00001", "YEAST00002"))

Get the attributes of an object

Description

Lists the attributes of an object returned by the package and their data types. Attributes of type "url" are loaded from the OMA Browser when they are accessed.

Usage

getObjectAttributes(obj)

Arguments

obj

an object of class omadb_obj

Value

a named character vector with the data type of each attribute

Examples

getObjectAttributes(getOMAGroup(id = "YEAST58"))

Retrieve an OMA Group from the OMA Browser

Description

This function obtains an OMA Group from the OMA Browser database. An OMA Group is defined to be a clique of proteins that are all orthologous to each other, i.e. they are all related through speciation events only. An OMA Group can thus by definition not contain any inparalogs. It is a very stringent orthology grouping approach. OMA Groups are mostly useful to infer phylogenetic species tree where they can be used as marker genes.

Usage

getOMAGroup(id, attribute = NULL)

Arguments

id

An identifier for the group. See above for possible types of IDs.

attribute

an extra attribute to be returned ('close_groups', the sorted list of closely related groups).

Details

Retrieving an OMA Group can be done using a group nr as id, its fingerprint (a 7mer AA sequence which is unique to proteins in that group), a member protein id or any sequence pattern that is unique to the group.

Value

an omadb_obj with the group's attributes (the members are a data.frame), or a data.frame with the closely related groups.

Examples

grp <- getOMAGroup(id = "YEAST58")
grp$fingerprint
head(grp$members[, c("omaid", "canonicalid")])
getOMAGroup(id = "ACCQRNQ")$group_nr

Retrieve a HOG in OrthoXML format

Description

The function retrieves a Hierarchical Orthologous Group (HOG) in the OrthoXML format (https://orthoxml.org), which contains the full nested structure of the HOG including all duplication and speciation events. The result can for example be analysed with dedicated tools for HOGs such as pyHam.

Usage

getOrthoXML(id, augmented = FALSE)

Arguments

id

the root HOG ID (e.g. "HOG:F0411479") or the id of a member protein, in which case the root HOG of the protein is returned.

augmented

logical, whether to return an augmented version of the OrthoXML that contains more information (e.g. the taxonomic level of each group), but which does not strictly follow the OrthoXML schema.

Value

a character string with the OrthoXML document.

Examples

xml <- getOrthoXML("HOG:F0411479")
substr(xml, 1, 200)

Retrieve a protein from the OMA Browser

Description

This function enables to retrieve information on one or several proteins from the OMA Browser database.

Usage

getProtein(id, attribute = NULL, rel_type = NULL)

Arguments

id

Identifier(s) for the entry or entries to be returned. A character string for a single entry or a vector for several entries.

attribute

Instead of the protein, return the attribute property of the protein. See details for the available attributes. 'homeologs' is accepted as an alias for 'homoeologs'.

rel_type

For attribute = "orthologs", restrict the orthologs to a type of relationship, i.e. '1:1', '1:n', 'm:1' or 'm:n'.

Details

In its simplest form the function returns the base data of the query protein. The query protein can be selected with any unique id, for example with a UniProtKB accession (P12345), an OMA id (YEAST00012), or a RefSeq id (NP_001226). To retrieve more than one protein, pass a vector of IDs.

Non-scalar properties of proteins such as their domains, GO annotations, orthologs or homoeologs are loaded upon accessing them, or - if you only need this information - you can set the attribute parameter to the property name and retrieve this information directly:

orthologs

the orthologs of the protein, optionally restricted to a type of relationship with rel_type

hog_derived_orthologs

the orthologs of the protein derived from its hierarchical orthologous groups

homoeologs

the homoeologs of the protein (only for proteins of polyploid genomes)

gene_ontology

the Gene Ontology annotations of the protein

domains

the domain annotations of the protein

xref

the cross-references of the protein to other databases

isoforms

the splicing isoforms of the protein's gene

locus

the genomic locus of the protein as a GRanges object

Value

For a single id, an omadb_obj with the protein's attributes. For several ids, a named list of such objects (with NULL for ids that are not found). If attribute is given, a data.frame with the requested data (combined for all ids, with a column query_id), except for 'locus' which returns a GRanges object and 'domains' which returns an omadb_obj for a single id and a list of them for several ids.

See Also

For non-unique IDs or partial ID lookup, use searchProtein instead.

Examples

getProtein(id = "YEAST00001")
head(getProtein(id = "YEAST00001", attribute = "orthologs"))
prots <- getProtein(id = c("YEAST00001", "YEAST00002", "YEAST00012"))
names(prots)
go <- getProtein(id = c("YEAST00001", "YEAST00002"),
    attribute = "gene_ontology")
table(go$query_id)

Get the shared ancestry of two genomes

Description

The function retrieves summary statistics on the shared ancestry of two genomes, i.e. the fraction of genes of the two genomes that have an ortholog in the other genome, and the most recent common ancestor of the two genomes.

Usage

getSharedAncestry(genome_id1, genome_id2)

Arguments

genome_id1

an identifier for the first genome, which can be either its taxon id or UniProt species code

genome_id2

an identifier for the second genome, which can be either its taxon id or UniProt species code

Value

an omadb_obj with the attributes fraction, details (a data.frame with the number of genes and orthologs per genome) and mrca (the most recent common ancestor).

Examples

res <- getSharedAncestry("YEAST", "ASHGO")
res$fraction
res$details

Retrieve synteny information from the OMA Browser

Description

The function retrieves the (ancestral) synteny graph, i.e. the gene order, at a given taxonomic level. Nodes of the graph are genes (HOGs for ancestral levels, proteins for extant genomes), edges connect genes that are (inferred to be) neighbours on a chromosome.

Usage

getSynteny(
  level,
  id = NULL,
  evidence = c("linearized", "parsimonious", "any"),
  context = 2L,
  break_circular_contigs = TRUE
)

Arguments

level

the taxonomic level of interest. Ancestral levels accept the scientific name or the NCBI taxon id, extant genomes also accept the UniProt species code.

id

optional, a HOG ID (for ancestral levels) or protein id (for extant genomes) to retrieve its neighbourhood.

evidence

the minimum evidence of the edges of the ancestral synteny graph: 'linearized' (default), 'parsimonious' or 'any'.

context

the size of the neighbourhood around id, in number of edges.

break_circular_contigs

logical, whether to break circular ancestral contigs at their weakest edge. Only used if evidence is 'linearized'.

Details

If id is given, only the neighbourhood of the given HOG or protein is returned, otherwise the synteny graph of the whole (ancestral) genome.

The result can easily be converted into a graph object, e.g. with igraph::graph_from_data_frame(res$links, directed = FALSE). Note that for a neighbourhood, the links of the outermost nodes may point to nodes that are not included in nodes.

Value

a list with two data.frames: nodes with one row per gene (the first column id identifies the gene) and links with one row per edge (the first columns source and target, followed by weight and further information on the edge).

Examples

syn <- getSynteny(level = "Saccharomycetaceae", id = "HOG:F0411479",
    context = 2)
syn$nodes
syn$links[, c("source", "target", "weight")]

Get the taxonomy of the genomes in the OMA Browser

Description

The function obtains the taxonomic tree of the genomes in the OMA Browser, either as a newick string (that can for example be converted into a phylo object with getTree) or as a nested object.

Usage

getTaxonomy(root = NULL, members = NULL, newick = TRUE, collapse = TRUE)

Arguments

root

optional parameter, the root of the subtree of interest, i.e. a taxonomic level, a taxon id or a UniProt species code.

members

optional parameter, vector (or comma-separated string) of NCBI taxon ids, species codes or taxonomic levels that should be included in the induced taxonomy.

newick

logical, whether to return the taxonomy in newick format (default) or as a nested object.

collapse

logical, whether levels with a single child should be collapsed (default TRUE).

Details

The taxonomy can be restricted to a subtree by specifying its root, or to the taxonomy induced by a set of member genomes or taxonomic levels. Only one of root and members can be specified.

Value

an omadb_obj. If newick = TRUE, it contains the attributes newick (labels containing special characters are quoted) and root_taxon. Otherwise it contains the attributes name, id and children, a data.frame with one row per child taxon, where a list column children again contains the children of internal nodes and the column code the species code of leaves.

Examples

getTaxonomy(members = c("YEAST", "ASHGO"))$newick
tax <- getTaxonomy(root = "Alveolata", newick = FALSE)
tax$name

Get the topGO Object

Description

The function creates a topGOdata object containing the GO annotations for the given genes, which can be used to perform a GO enrichment analysis with the topGO package.

Usage

getTopGO(annotations, format, foregroundGenes, ontology)

Arguments

annotations

list of GO annotations obtained from formatTopGO

format

Format of the annotations - either 'GO2geneID' or 'geneID2GO'

foregroundGenes

identifiers of the foreground genes, i.e. the genes of interest. Either a character vector or a data.frame with a column omaid.

ontology

The ontology for which the enrichment should be done ('BP', 'MF' or 'CC'). This parameter is passed directly to the topGOdata constructor.

Details

The topGO package must be attached with library(topGO) before calling this function, as topGO requires it to find its GO term environments.

Value

a topGOdata object

Examples

library(topGO)
members <- getHOG("HOG:F0411479", level = "Saccharomycetaceae",
    members = TRUE)
go <- getProtein(members$omaid, attribute = "gene_ontology")
annotations <- formatTopGO(go, format = "geneID2GO")
GOdata <- getTopGO(annotations, foregroundGenes = head(members$omaid, 3),
    format = "geneID2GO", ontology = "BP")
GOdata

Get the Tree Object

Description

A convenience function to obtain a tree object from a newick tree, essentially wraps read.tree from the ape package.

Usage

getTree(newick)

Arguments

newick

The newick tree to be instantiated, or the result of getTaxonomy with newick = TRUE.

Value

a tree object of class phylo

Examples

taxonomy <- getTaxonomy(root = "Alveolata")
tree <- getTree(newick = taxonomy)
head(tree$tip.label)

Get the API and database version

Description

The function obtains the version of the OMA Browser database release and of the REST API that the package is using.

Usage

getVersion()

Value

an omadb_obj with the attributes oma_version and api_version

Examples

getVersion()

Map a protein sequence to the OMA Browser

Description

The function identifies the protein(s) in the OMA Browser that match a query sequence, either exactly or approximately.

Usage

mapSequence(query, search = NULL, full_length = FALSE)

Arguments

query

the sequence to be searched, it can be either a string or an AAString object from the Biostrings package

search

argument to choose search strategy. Can be set to 'exact', 'approximate' or 'mixed'. Defaults to 'mixed', meaning first tries to find exact match. If no target can be found, uses approximate search strategy to identify query sequence in database.

full_length

a logical indicating whether or not for exact matches, the query sequence must be matching the full target sequence. By default, a partial exact match is also reported as exact match.

Value

an omadb_obj with the attributes query, identified_by (the type of match) and targets, a data.frame with the matching proteins.

Examples

seq <- paste0("MNDPSLLGYPNVGPQQQQQQQQQQHAGLLGKGTPNALQQQLHMNQLTGIPPPGLMN",
    "NSDVHTSSNNNSRQLLDQLANGNANMLNMNMDNNNNNNNNNNNNNNNGGGSGVMMNASTAAVNSIGM")
res <- mapSequence(query = seq)
res$identified_by
res$targets[, c("omaid", "canonicalid")]

Objects returned by the OmaDB package

Description

Functions that retrieve a single entity from the OMA Browser (e.g. a protein, a genome, an OMA group or a HOG) return an object of class omadb_obj. It is a named list with one element per attribute of the entity. Attributes that hold a list of entities (e.g. the members of an OMA group) are data.frames, protein and cDNA sequences are AAString and DNAString objects and genomic loci are GRanges objects.

Usage

## S3 method for class 'omadb_obj'
x$name

## S3 method for class 'omadb_obj'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S3 method for class 'omadb_obj'
print(x, ...)

Arguments

x

an object of class omadb_obj

name

the name of the attribute

row.names, optional, ...

passed on to/ignored as for as.data.frame

Details

Some attributes are not included in the response from the OMA Browser, but are given as a url pointing to the API endpoint that provides the data. Accessing such an attribute with $ (or getAttribute) loads the data transparently. The responses are cached (see setOmaCache), so accessing an attribute repeatedly does not query the server again. Use [[ to access the url itself.

as.data.frame converts an object into a data.frame with a single row. Nested attributes are flattened into columns named <attribute>.<subattribute>; attributes that are not scalars (vectors, data.frames, sequences, ...) become list columns.

Value

$ returns the value of the attribute, loading it from the OMA Browser if necessary. as.data.frame returns a data.frame with one row. print returns x invisibly.

Examples

prot <- getProtein("YEAST00001")
prot$omaid
## the orthologs are loaded on access
head(prot$orthologs[, c("omaid", "rel_type")])
as.data.frame(prot)[, c("omaid", "species.code", "oma_group")]

Example data retrieved from the OMA Browser

Description

Example responses of the OMA Browser REST API, as returned by the functions of this package. They were retrieved from the OMA Browser release All.May2026 with the script system.file("scripts", "make-data.R", package = "OmaDB").

Format

see the description of the corresponding function.

Details

protein

getProtein("YEAST00001"): an omadb_obj with the data of a protein.

orthologs

getProtein("YEAST00001", attribute = "orthologs"): a data.frame with the orthologs of the protein.

group

getOMAGroup("YEAST00058"): an omadb_obj with the OMA Group of protein YEAST00058, including its members.

hog

getHOG("YEAST00001"): a data.frame with the HOG of protein YEAST00001.

pairs

head(getGenomePairs("YEAST", "ASHGO", chr1 = "I"), 100): a data.frame with orthologous pairs between the genomes of Saccharomyces cerevisiae and Ashbya gossypii.

taxonomy

getTaxonomy(members = c("YEAST", "ASHGO", "SCHPO")): an omadb_obj with the taxonomy of three yeast species in newick format.

xref

searchProtein("P53_RAT"): a data.frame with the cross-references matching the query.

sequence_map

mapSequence(seq): an omadb_obj with the proteins matching a query sequence.

sequence_annotation

annotateSequence(seq): a data.frame with the predicted GO annotations of a query sequence.

Source

https://omabrowser.org/api/

Examples

data(protein, package = "OmaDB")
protein$omaid
data(pairs, package = "OmaDB")
table(pairs$rel_type)

Load data for a given url from the OMA Browser API

Description

Loads the data behind a url of the OMA Browser API. This is usually not needed, as attributes containing a url are loaded automatically when accessed with $. It is useful for urls that are stored in a data.frame, e.g. the members_url column of the result of getHOGs.

Usage

resolveURL(url)

Arguments

url

the url of interest

Details

The type of the result depends only on the type of data provided by the endpoint: endpoints that provide a single entity return an omadb_obj, endpoints that provide a list of entities always return a data.frame (also if the list contains a single or no element). Paginated endpoints are loaded completely.

Value

an omadb_obj or a data.frame

Examples

go <- resolveURL(paste0("https://omabrowser.org/api/protein/YEAST00001/",
    "gene_ontology/"))
head(go)

Search for proteins by a (partial) identifier

Description

The function lists all the cross-references to other databases (e.g. UniProtKB, RefSeq, Ensembl) of proteins in the OMA Browser that match a pattern.

Usage

searchProtein(pattern)

Arguments

pattern

the pattern to query the OMA database with - needs to be at least 3 characters long. If the pattern matches too many cross-references, an error is raised.

Value

a data.frame containing information on the cross references matching the pattern, including the OMA id of the protein (column omaid).

Examples

res <- searchProtein(pattern = "P53_RAT")
res[, c("xref", "source", "omaid")]

Set the url to the OMA Browser API

Description

Sets the base url of the OMA Browser REST API used by all functions of the package. If no url is given, the default OMA Browser API (https://omabrowser.org/api/) is used. This can be used to access other instances of the OMA Browser, e.g. the Corona OMA Browser at https://corona.omabrowser.org/api/.

Usage

setAPI(url)

Arguments

url

Base url to the API

Details

Changing the API url does not invalidate cached responses, as the url is part of the cache key.

Value

The previously used API url, invisibly.

Examples

old <- setAPI("https://corona.omabrowser.org/api/")
setAPI(old)

Configure the caching of OMA Browser API responses

Description

All responses from the OMA Browser API are cached in memory for the duration of the R session, so repeated queries (including accessing attributes of objects that are loaded lazily) do not hit the server again. Optionally, responses can also be stored in a persistent cache on disk, which is reused across R sessions.

Usage

setOmaCache(
  persistent = TRUE,
  dir = tools::R_user_dir("OmaDB", which = "cache"),
  max_size = 1024^3
)

clearOmaCache()

Arguments

persistent

logical, whether responses should also be cached on disk.

dir

directory of the persistent cache.

max_size

maximum size of the persistent cache in bytes.

Details

The persistent cache is stored by default in the user cache directory given by tools::R_user_dir("OmaDB", which = "cache"). As the data in the OMA Browser only changes with a new release, the persistent cache is cleared automatically if the OMA release or the API version of the server differ from those of the cached data.

The persistent cache can also be enabled by setting the option OmaDB.persistentCache to TRUE before the first request, e.g. in the .Rprofile file. The option OmaDB.cacheDir can then be used to set its directory.

Value

setOmaCache returns the directory of the persistent cache (or NULL if it is disabled) invisibly. clearOmaCache returns NULL invisibly.

Examples

## use a temporary directory for the persistent cache
setOmaCache(persistent = TRUE, dir = file.path(tempdir(), "omadb"))
clearOmaCache()
setOmaCache(persistent = FALSE)