R/0docs.R
, R/make_igraph_object.R
, R/make_network_object.R
, and 3 more
make_.Rd
Functions to make complex R objects.
make_igraph_object(
phenos,
hpo = get_hpo(),
colour_var = "fold_change",
cols = list_columns(extra_cols = c(colour_var, grep("_count$|_values$", names(phenos),
value = TRUE))),
...
)
make_network_object(
phenos,
hpo = get_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))),
as = c("ggnetwork", "tbl_graph"),
...
)
make_network_plot(
phenos,
colour_var = "ontLvl",
size_var = colour_var,
label_var = "hpo_name",
interactive = TRUE,
show_plot = TRUE,
hoverbox_column = "hover",
preferred_palettes = "brewer.reds",
method = c("ggnetwork", "visnetwork"),
...
)
make_phenos_dataframe(
ancestor = NULL,
hpo = get_hpo(),
phenotype_to_genes = load_phenotype_to_genes(),
add_ont_lvl_absolute = TRUE,
add_ont_lvl_relative = FALSE,
add_info_content = FALSE,
add_description = TRUE,
add_disease_data = FALSE,
add_ndiseases = add_disease_data,
add_onsets = add_disease_data,
add_deaths = add_disease_data,
add_pheno_frequencies = add_disease_data,
add_tiers = add_disease_data,
add_severities = add_disease_data,
add_disease_definitions = add_disease_data,
include_mondo = FALSE,
add_hoverboxes = FALSE,
columns = list_columns(),
interactive = TRUE,
verbose = TRUE
)
make_tiers(
hpo = get_hpo(),
terms = hpo@terms,
keyword_sets = list(Tier1 = c("intellectual disability", "death"), Tier2 =
c("impaired mobility", "malform"), Tier3 = c("sight", "vision", "immunodeficien",
"cancer", "hearing", "touch", "pain ", " pain", "mental illness", "dysmorphic"),
Tier4 = c("fertility")),
check_names = TRUE,
check_definitions = TRUE,
check_diseases = FALSE,
search_ancestors = TRUE,
search_descendants = TRUE,
as_datatable = FALSE,
verbose = TRUE
)
A data.table containing HPO IDs and other metadata.
Human Phenotype Ontology object, loaded from get_ontology.
The column from phenos that you wish to map to node colour.
Columns to add to metadata of ggnetwork object.
Arguments passed on to make_network_object
Add the absolute ontology level of each HPO term. See get_ontology_levels for more details.
R object class to return output as.
Column to scale node size by.
Column containing the label for each node in a graph (e.g. "hpo_name").
Make the plot interactive.
Show the plot.
Name of the new hoverbox column to add.
Preferred palettes to use for each column.
Method to construct plot with.
The ancestor to get all descendants of. If NULL
,
returns the entirely ontology.
Output of load_phenotype_to_genes mapping phenotypes to gene annotations.
Add the relative ontology level of each HPO term. See get_ontology_levels for more details.
Add information content column for each phenotype.
Whether to get the phenotype descriptions as well (slower).
Add all disease metadata columns.
This will expand the data using allow.cartesian=TRUE
.
Add the number of diseases per phenotype.
Add age of onset columns using add_onset.
Add age of death columns using add_death.
Add the frequency of each phenotype in each disease.
Add severity Tiers column using add_tier.
Add severity column using add_severity.
Add disease definitions.
Add MONDO IDs, names, and definitions to each disease.
Add hoverdata with add_hoverboxes.
A named vector of columns in phenos
to add to the hoverdata via add_hoverboxes.
Print messages.
A subset of HPO IDs to assign Tiers to.
A named list of regex queries to be used when searching for phenotypes that have matching metadata.
When regexsearching for matching terms, check the phenotype names.
When regex searching for matching terms, check the phenotype definition.
When regex searching for matching terms, check the names of diseases associated with the phenotype.
Inherit Tiers of ancestors.
Inherit Tiers of descendants.
Return the results as a data.table.
R object.
A igraph object.
A ggnetwork object.
A named list containing the graph data and the plot.
The HPO in dataframe format.
Tier assignments for each term in terms
.
Will be returned as either a named vector or a data.table.
make_igraph_object()
: make_
Make an igraph object
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.
It expects there to be a column of HPO IDs in the phenos dataframe called hpo_id.
make_network_object()
: make_
Make a ggnetwork object
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.
It expects there to be a column of HPO IDs in the phenos dataframe called hpo_id.
make_network_plot()
: make_
Generate network plot
This creates a network plot. It makes it possible to hover box that includes your results related to each phenotype and/or a description of the phenotypes.
make_phenos_dataframe()
: make_
Make phenotypes dataframe
Make a dataframe from a subset of the Human Phenotype Ontology.
make_tiers()
: make_
Make severity Tiers (auto)
Automatically add severity Tier for each HPO ID, in accordance with the rating system provided by Lazarin et al (2014). In order of increasing severity:
Tier 4 Reduced fertility
Tier 3 Sensory impairment: vision, Immunodeficiency/cancer, Sensory impairment: hearing, Sensory impairment: touch, other (including pain), Mental illness, Dysmorphic features
Tier 2 Shortened life span: premature adulthood, Impaired mobility, Internal physical malformation
Tier 1 Shortened life span: infancy, Shortened life span: childhood/adolescence, Intellectual disability
phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2024-12-12
#> Extracting data for 24 descendents.
#> Computing gene counts.
#> Adding term definitions.
#> Adding level-2 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Ancestor metadata already present. Use force_new=TRUE to overwrite.
#> 24 associations remain after filtering.
#> Getting absolute ontology level for 19,025 IDs.
#> Computing ontology level / gene count ratio.
g <- make_igraph_object(phenos = phenos)
#> Translating ontology terms to ids.
#> Converted ontology to: tbl_graph
#> Removing isolated nodes.
phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2024-12-12
#> Extracting data for 24 descendents.
#> Computing gene counts.
#> Adding term definitions.
#> Adding level-2 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Ancestor metadata already present. Use force_new=TRUE to overwrite.
#> 24 associations remain after filtering.
#> Getting absolute ontology level for 19,025 IDs.
#> Computing ontology level / gene count ratio.
phenoNet <- make_network_object(phenos = phenos,
colour_var = "ontLvl_geneCount_ratio")
#> Making phenotype network object.
#> Translating ontology terms to ids.
#> Converted ontology to: tbl_graph
#> Removing isolated nodes.
#> Loading required namespace: ggnetwork
#> Registered S3 method overwritten by 'ggnetwork':
#> method from
#> fortify.igraph ggtree
#> Converting graph to ggnetwork.
phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2024-12-12
#> Extracting data for 24 descendents.
#> Computing gene counts.
#> Adding term definitions.
#> Adding level-2 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Ancestor metadata already present. Use force_new=TRUE to overwrite.
#> 24 associations remain after filtering.
#> Getting absolute ontology level for 19,025 IDs.
#> Computing ontology level / gene count ratio.
plt <- make_network_plot(phenos = phenos)
#> Making phenotype network object.
#> Translating ontology terms to ids.
#> Converted ontology to: tbl_graph
#> Removing isolated nodes.
#> Converting graph to ggnetwork.
#> Creating ggnetwork plot.
phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2024-12-12
#> Extracting data for 24 descendents.
#> Computing gene counts.
#> Adding term definitions.
#> Adding level-2 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Ancestor metadata already present. Use force_new=TRUE to overwrite.
#> 24 associations remain after filtering.
#> Getting absolute ontology level for 19,025 IDs.
#> Computing ontology level / gene count ratio.
terms <- get_hpo()@terms[seq(100)]
tiers <- make_tiers(terms = terms)
#> Reading cached RDS file: phenotype.hpoa
#> + Version: v2024-12-12
#> keyword_set=Tier1: Found 0 terms matching category.
#> keyword_set=Tier2: Found 0 terms matching category.
#> keyword_set=Tier3: Found 0 terms matching category.
#> keyword_set=Tier4: Found 0 terms matching category.
#> Auto-assigning severity Tiers to 100 terms.