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,
...
)
dataframe of phenotypes and values / parameters.
Human Phenotype Ontology object, loaded from ontologyIndex.
An adjacency matrix generated by adjacency_matrix.
The column from phenos that you wish to map to node colour.
Add the absolute ontology level of each HPO term. See get_ont_lvls for more details.
Columns to add to metadata of ggnetwork object.
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.
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.
A igraph object.
It expects there to be a column of HPO IDs in the phenos dataframe called hpo_id.
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.