Installation

Within R:

if (!require("remotes")) install.packages("remotes")
if (!require("HPOExplorer")) remotes::install_github("neurogenomics/HPOExplorer")
library(HPOExplorer)

Introduction

The HPOExplorer package provides useful functions for working with the Human Phenotype Ontology (HPO). The main HPO ontology object comes with the simona R package.

This tutorial will focus on creating an interactive network plot of a subset of the HPO, where disease descriptions and results from your analysis appear in a hover box when a specific phenotype is selected from the graph.

Load ontology data

hpo <- get_hpo()

Choose subset of HPO phenotypes to plot

The figure we are going to create is a bit arbitrary, but it should outline the main features of the package. First we are going to get a subset of HPO terms to plot. We will select phenotypes that are descendants of "Neurodevelopmental delay".

ancestor <- "Neurodevelopmental delay"

Create dataframe of phenotypes and parameters

To create the network object we need a dataframe of the selected phenotypes with columns for associated parameters. We will be able to map these parameters onto the colour of the nodes in the figure. We can also use them to subset the selected phenotypes further.

Typically, these parameters would be results from an analysis you have done. For example, you may have p values associated with each phenotype and you might want to only show phenotypes where p<0.05, or use them to colour the nodes, or have the p values displayed in the hover box.

For this example we will have to make up a parameter for demonstration purposes. We are going to divide ontology level of the phenotypes by the number of associated genes. We will also include the ontology level its self and the disease description.

HPOExplorer has some useful functions for obtaining the ontology level of terms. Ontology level describes the number of generations of descendants vertically below a term (note that this is not the same as the raw number of descendants which is also capturing the horizontal spread of branching off terms). For example "Phenotypic abnormality" is high up in the HPO and all other disease phenotypes are descendants of it. It is at ontology level 13. A term with no descendants is at ontology level 0.

phenos <- make_phenos_dataframe(hpo = hpo, 
                                ancestor = ancestor)

Plot it

Then we can make the plot with make_network_plot. Again you need to give the column name for the variable you want mapped to colour in the colour_var argument. We also need to provide a nice label for this column in colour_label. This will be used for the figure legend.

The colour_var argument is where you choose the column name from the phenos dataframe which you want to be mapped to the colour of the nodes. In this case we created the family arbitrary variable of ontology level to number of associated genes ratio and its column name is ontLvl_geneCount_ratio.

plt <- make_network_plot(phenos = phenos, 
                         colour_var = "ontLvl_geneCount_ratio")
methods::show(plt)

Session Info

utils::sessionInfo()





neurogenomics/HPOExplorer documentation built on Aug. 24, 2024, 1:39 a.m.