This function takes a Cypher query and parameters, executes the query using the given engine, and returns the result as a tbl_kgx graph.
cypher_query(engine, query, parameters = NULL, ...)
A neo4j KG engine
A string representing the Cypher query. Multiple queries may be passed as a vector; if so, Neo2R::multicypher if used and the result is returned as a single joined graph.
A list of parameters for the Cypher query. Default is an empty list.
Additional arguments passed to the function.
The result of the Cypher query as a tbl_kgx graph.
engine <- monarch_engine()
#> Trying to connect to https://neo4j.monarchinitiative.org
#> Connected to https://neo4j.monarchinitiative.org
query <- "MATCH (n) WHERE n.id IN $ids RETURN n LIMIT 10"
ids <- c("MONDO:0007525", "MONDO:0020066", "MONDO:0034021")
parameters <- list(ids = ids)
result <- cypher_query(engine, query, parameters)
print(result)
#> # A tbl_graph: 3 nodes and 0 edges
#> #
#> # A rooted forest with 3 trees
#> #
#> # Node Data: 3 × 10 (active)
#> id pcategory name description synonym category iri xref namespace
#> <chr> <chr> <chr> <chr> <named> <named > <chr> <nam> <chr>
#> 1 MONDO:0007… biolink:… Ehle… Arthrochal… <chr> <chr> http… <chr> MONDO
#> 2 MONDO:0020… biolink:… Ehle… The Ehlers… <chr> <chr> http… <chr> MONDO
#> 3 MONDO:0034… biolink:… spon… NA <chr> <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>