Summarizes the neighborhood of the nodes of a given graph. Specifically, letting $N$ be the set of nodes in the given graph, this function retrieves counts of relationship predicates (or node categories) of nodes connected to $N$ but not in $N$. This can be useful to examine the scale and scope of a graph's collective neighborhood in the larger KG.

summarize_neighborhood(
  graph,
  engine = NULL,
  direction = "both",
  summarize = "edges"
)

Arguments

graph

A query graph to summarize the surrounding neighborhood for

engine

(Optional) An engine to use. If not provided, the graph's most recent engine is used.

direction

The direction of edges to include in the neighborhood

summarize

Whether to summarize edges or nodes (default "edges")

Value

A tbl_kgx graph

Details

Note that the number of relationships returned may be larger than the number of nodes they connect to; use summarize = "edges" to see edge counts between nodes of different categories, and summarize = "nodes" to see counts of connected node categories.

Additionally, when using summarize = "edges", the summary will include edges that may already be present in the query graph.

It is also possible to specify the direction of edges to include in the neighborhood, using the direction parameter. The default is "both", which includes both incoming and outgoing edges.

Examples

monarch_search("fanconi anemia", limit = 5) |>
    summarize_neighborhood(direction = "both", summarize = "edges")
#> Trying to connect to https://neo4j.monarchinitiative.org
#> Connected to https://neo4j.monarchinitiative.org
#> # A tibble: 12 × 6
#>    count query_pcategory predicate               result_pcategory query_category
#>    <int> <chr>           <chr>                   <chr>            <list>        
#>  1   917 biolink:Disease biolink:causes          biolink:Sequenc… <list [7]>    
#>  2   227 biolink:Disease biolink:has_phenotype   biolink:Phenoty… <list [7]>    
#>  3    29 biolink:Disease biolink:subclass_of     biolink:Disease  <list [7]>    
#>  4    23 biolink:Disease biolink:gene_associate… biolink:Gene     <list [7]>    
#>  5    12 biolink:Disease biolink:model_of        biolink:Genotype <list [7]>    
#>  6     4 biolink:Disease biolink:has_disease     biolink:Organis… <list [7]>    
#>  7     3 biolink:Disease biolink:associated_wit… biolink:Sequenc… <list [7]>    
#>  8     3 biolink:Disease biolink:causes          biolink:Gene     <list [7]>    
#>  9     3 biolink:Disease biolink:has_mode_of_in… biolink:Phenoty… <list [7]>    
#> 10     3 biolink:Disease biolink:related_to      biolink:Gene     <list [7]>    
#> 11     1 biolink:Disease biolink:in_taxon        biolink:Organis… <list [7]>    
#> 12     1 biolink:Disease biolink:related_to      biolink:Disease  <list [7]>    
#> # ℹ 1 more variable: result_category <list>