First computes of each node in a graph. Then adds the centrality score as an node attribute.

graph_centrality(
  graph,
  fun = igraph::harmonic_centrality,
  col = "centrality",
  ...
)

Arguments

graph

A graph object

fun

The centrality function to use. Default is harmonic_centrality.

col

Name of the new node attribute to store the centrality score.

...

Additional arguments passed to the centrality function (sim_fun).

Value

Graph object with centrality added as a new node attribute.

Examples

filename <- system.file("extdata", "eds_marfan_kg.tar.gz", package = "monarchr")
g <- file_engine(filename) |>
          fetch_nodes(query_ids = "MONDO:0007525") |>
          expand(predicates = "biolink:has_phenotype",
                 categories = "biolink:PhenotypicFeature")|>
          expand(categories = "biolink:Gene")
g <- graph_centrality(g)
#> Computing node centrality.
nodes(g)$centrality
#>                         Ehlers-Danlos syndrome, arthrochalasia type 
#>                                                                  48 
#>                                                Hyperextensible skin 
#>                                                                   0 
#>                                                 Joint hypermobility 
#>                                                                   0 
#>                                                     Inguinal hernia 
#>                                                                   0 
#>                                                           Thin skin 
#>                                                                   0 
#>                                             Bruising susceptibility 
#>                                                                   0 
#>                                                   Soft, doughy skin 
#>                                                                   0 
#>                                                  Poor wound healing 
#>                                                                   0 
#>                                                      Atrophic scars 
#>                                                                   0 
#>                                                   Joint dislocation 
#>                                                                   0 
#>                                                          Pes planus 
#>                                                                   0 
#>                                                       Hallux valgus 
#>                                                                   0 
#>                                                           Scoliosis 
#>                                                                   0 
#>                                               Generalized hypotonia 
#>                                                                   1 
#>                                     Delayed gross motor development 
#>                                                                   0 
#>                                                   Joint subluxation 
#>                                                                   1 
#>                                                            Kyphosis 
#>                                                                   0 
#>                                                     Hip dislocation 
#>                                                                   0 
#>                                                 Breech presentation 
#>                                                                   0 
#>                                                           Hypotonia 
#>                                                                   0 
#>                                                        Micrognathia 
#>                                                                   0 
#>                                Congenital bilateral hip dislocation 
#>                                                                   1 
#>                                                        Retrognathia 
#>                                                                   0 
#>                                            Premature osteoarthritis 
#>                                                                   0 
#>                                                    Malar flattening 
#>                                                                   0 
#>                                                          Osteopenia 
#>                                                                   0 
#>                                                          Epicanthus 
#>                                                                   0 
#>                                              Depressed nasal bridge 
#>                                                                   0 
#>                          Delayed closure of the anterior fontanelle 
#>                                                                   0 
#>                                                              Mutism 
#>                                                                   0 
#>                                                             Aphasia 
#>                                                                   0 
#>                                                          Coxa valga 
#>                                                                   0 
#>                                                           Coxa vara 
#>                                                                   0 
#>                                                Severe short stature 
#>                                                                   0 
#>                 Avascular necrosis of the capital femoral epiphysis 
#>                                                                   0 
#>                                                           Echolalia 
#>                                                                   0 
#>                                                            Scarring 
#>                                                                   0 
#>                                                      Femoral hernia 
#>                                                                   0 
#>                              Abnormality of subcutaneous fat tissue 
#>                                                                   0 
#>                                                       Hip dysplasia 
#>                                                                   0 
#>                                                     Joint stiffness 
#>                                                                   0 
#>                                                       Hypertelorism 
#>                                                                   0 
#>                                                   Midface retrusion 
#>                                                                   0 
#>                               Increased susceptibility to fractures 
#>                                                                   0 
#>                                         Congenital knee dislocation 
#>                                                                   0 
#> Contracture of the proximal interphalangeal joint of the 2nd finger 
#>                                                                   0 
#>                                                  Mild short stature 
#>                                                                   0 
#> Contracture of the proximal interphalangeal joint of the 3rd finger 
#>                                                                   0 
#>                                                   Muscle flaccidity 
#>                                                                   0 
#>                                                              COL1A1 
#>                                                                  25 
#>                                                              COL1A2 
#>                                                                  25