This uses the network package to coerce the adjacency matrix into a network object. It also adds the fold change, label, and relative ontology level parameters to each node in the network.

make_igraph_object(
  phenos,
  hpo = get_hpo(),
  adjacency = adjacency_matrix(terms = phenos$hpo_id, hpo = hpo),
  colour_var = "fold_change",
  add_ont_lvl_absolute = FALSE,
  cols = list_columns(extra_cols = c(colour_var, grep("_count$|_values$", names(phenos),
    value = TRUE))),
  layout = "fruchtermanreingold",
  verbose = TRUE,
  ...
)

Arguments

phenos

dataframe of phenotypes and values / parameters.

hpo

Human Phenotype Ontology object, loaded from ontologyIndex.

adjacency

An adjacency matrix generated by adjacency_matrix.

colour_var

The column from phenos that you wish to map to node colour.

add_ont_lvl_absolute

Add the absolute ontology level of each HPO term. See get_ont_lvls for more details.

cols

Columns to add to metadata of ggnetwork object.

layout

a network layout supplied by gplot.layout, such as "fruchtermanreingold" (the default), or a two-column matrix with as many rows as there are nodes in the network, in which case the matrix is used as nodes coordinates.

verbose

Print messages.

...

Arguments passed on to ggnetwork::ggnetwork

x

an object of class network or igraph, or any object that can be coerced to that class, such as an adjacency or incidence matrix, or an edge list: see edgeset.constructors and network for details.

Value

A igraph object.

Details

It expects there to be a column of HPO IDs in the phenos dataframe called hpo_id.

Examples

phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#>  All local files already up-to-date!
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2023-10-09
#> Extracting data for 23 descendents.
#> Computing gene counts.
#> Getting absolute ontology level for 23 HPO IDs.
#> Computing ontology level / gene count ratio.
#> Adding term definitions.
#>  All local files already up-to-date!
#> Adding level-3 ancestor to each HPO ID.
#>  All local files already up-to-date!
g <- make_igraph_object(phenos = phenos)
#> Making phenotype network object.
#> Creating adjacency matrix for 23 term(s).
#>  All local files already up-to-date!
#> Creating ggnetwork object.
#> Adding new_column='hpo_name'
#> Adding new_column='hpo_id'
#> Adding new_column='ontLvl'
#> Adding new_column='ontLvl_geneCount_ratio'
#> Adding new_column='definition'
#> Adding new_column='ancestor'
#> Adding new_column='ancestor_name'
#> Adding n_edges per node.
#> Creating igraph object.