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
)

Arguments

phenos

A data.table containing HPO IDs and other metadata.

hpo

Human Phenotype Ontology object, loaded from get_ontology.

colour_var

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

cols

Columns to add to metadata of ggnetwork object.

...

Arguments passed on to make_network_object

add_ont_lvl_absolute

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

as

R object class to return output as.

size_var

Column to scale node size by.

label_var

Column containing the label for each node in a graph (e.g. "hpo_name").

interactive

Make the plot interactive.

show_plot

Show the plot.

hoverbox_column

Name of the new hoverbox column to add.

preferred_palettes

Preferred palettes to use for each column.

method

Method to construct plot with.

ancestor

The ancestor to get all descendants of. If NULL, returns the entirely ontology.

phenotype_to_genes

Output of load_phenotype_to_genes mapping phenotypes to gene annotations.

add_ont_lvl_relative

Add the relative ontology level of each HPO term. See get_ontology_levels for more details.

add_info_content

Add information content column for each phenotype.

add_description

Whether to get the phenotype descriptions as well (slower).

add_disease_data

Add all disease metadata columns. This will expand the data using allow.cartesian=TRUE.

add_ndiseases

Add the number of diseases per phenotype.

add_onsets

Add age of onset columns using add_onset.

add_deaths

Add age of death columns using add_death.

add_pheno_frequencies

Add the frequency of each phenotype in each disease.

add_tiers

Add severity Tiers column using add_tier.

add_severities

Add severity column using add_severity.

add_disease_definitions

Add disease definitions.

include_mondo

Add MONDO IDs, names, and definitions to each disease.

add_hoverboxes

Add hoverdata with add_hoverboxes.

columns

A named vector of columns in phenos to add to the hoverdata via add_hoverboxes.

verbose

Print messages.

terms

A subset of HPO IDs to assign Tiers to.

keyword_sets

A named list of regex queries to be used when searching for phenotypes that have matching metadata.

check_names

When regexsearching for matching terms, check the phenotype names.

check_definitions

When regex searching for matching terms, check the phenotype definition.

check_diseases

When regex searching for matching terms, check the names of diseases associated with the phenotype.

search_ancestors

Inherit Tiers of ancestors.

search_descendants

Inherit Tiers of descendants.

as_datatable

Return the results as a data.table.

Value

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.

Functions

  • 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

Examples

phenos <- make_phenos_dataframe(ancestor = "Neurodevelopmental delay")
#> Reading cached RDS file: phenotype_to_genes.txt
#> + Version: v2024-04-26
#> Extracting data for 23 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.
#> 23 associations remain after filtering.
#> Getting absolute ontology level for 18,536 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-04-26
#> Extracting data for 23 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.
#> 23 associations remain after filtering.
#> Getting absolute ontology level for 18,536 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-04-26
#> Extracting data for 23 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.
#> 23 associations remain after filtering.
#> Getting absolute ontology level for 18,536 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-04-26
#> Extracting data for 23 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.
#> 23 associations remain after filtering.
#> Getting absolute ontology level for 18,536 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-04-26
#> 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.