Creates a knowledge graph engine backed by the publicly hosted Monarch Neo4j database, used to fetch nodes and edges from the database as local graph objects.

monarch_engine(
  url = c("http://neo4j.monarchinitiative.org:7474",
    "https://neo4j.monarchinitiative.org:7473", "http://neo4j.monarchinitiative.org",
    "https://neo4j.monarchinitiative.org"),
  api_url = "https://api.monarchinitiative.org/v3/api",
  preferences = NULL,
  timeout = 2,
  ...
)

Arguments

url

(Optional) May be specified to override the default Monarch Neo4j URL. If given a vector, each will be tried in sequence; if a URL times out (see timeout) or fails, the next is tried.

api_url

(Optional) May be specified to override the default Monarch API URL (specifying the location of the /search endpoint used by search_nodes()).

preferences

A named list of preferences for the engine.

timeout

Number of seconds to wait before trying the next url.

...

Additional arguments passed to neo2R::startGraph().

Value

An object of class monarch_engine

Details

Engines store preference information specifying how data are fetched and manipulated; for example, while node category is multi-valued (nodes may have multiple categories, for example "biolink:Gene" and "biolink:NamedThing"), typically a single category is used to represent the node in a graph, and is returned as the nodes' pcategory. A preference list of categories to use for pcategory is stored in the engine's preferences. A default set of preferences is stored in the package for use with this and other KGX (BioLink-compatible) graphs (see https://github.com/biolink/kgx/blob/master/specification/kgx-format.md), but these can be overridden by the user.

The monarch_engine() overrides search_nodes() to use the Monarch search API, so setting node_search_properties in the preferences will not affect the search behavior. To use regex-based searching with the Monarch Neo4j instance, use neo4j_engine() instead and specify the Monarch Neo4j URL (https://neo4j.monarchinitiative.org).

Examples

library(tidygraph)
library(dplyr)

monarch <- monarch_engine()
#> Trying to connect to https://neo4j.monarchinitiative.org
#> Connected to https://neo4j.monarchinitiative.org
res <- monarch |> fetch_nodes(query_ids = c("MONDO:0007522", "MONDO:0007947"))
#> Fetching; counting matching nodes... 
#>  total: 2.
#> Fetching; fetched 2 of 2
print(res)
#> # A tbl_graph: 2 nodes and 0 edges
#> #
#> # A rooted forest with 2 trees
#> #
#> # Node Data: 2 × 10 (active)
#>   id          category pcategory name  description synonym iri   xref  namespace
#>   <chr>       <list>   <chr>     <chr> <chr>       <named> <chr> <nam> <chr>    
#> 1 MONDO:0007… <chr>    biolink:… Ehle… Ehlers-Dan… <chr>   http… <chr> MONDO    
#> 2 MONDO:0007… <chr>    biolink:… Marf… A disorder… <chr>   http… <chr> MONDO    
#> # ℹ 1 more variable: provided_by <named list>
#> #
#> # Edge Data: 0 × 5
#> # ℹ 5 variables: from <int>, to <int>, subject <chr>, predicate <chr>,
#> #   object <chr>