vignettes/HPOExplorer.Rmd
HPOExplorer.Rmd
Within R:
if (!require("remotes")) install.packages("remotes")
if (!require("HPOExplorer")) remotes::install_github("neurogenomics/HPOExplorer")
## Error in get(paste0(generic, ".", class), envir = get_method_env()) :
## object 'type_sum.accel' not found
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.
hpo <- get_hpo()
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"
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)
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")
plt$plot
utils::sessionInfo()
## R Under development (unstable) (2024-12-15 r87442)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] HPOExplorer_1.0.4
##
## loaded via a namespace (and not attached):
## [1] grr_0.9.5 httr2_1.0.7
## [3] rlang_1.1.4 magrittr_2.0.3
## [5] clue_0.3-66 GetoptLong_1.0.5
## [7] matrixStats_1.4.1 compiler_4.5.0
## [9] png_0.1-8 systemfonts_1.1.0
## [11] vctrs_0.6.5 maps_3.4.2.1
## [13] gprofiler2_0.2.3 stringr_1.5.1
## [15] rvest_1.0.4 shape_1.4.6.1
## [17] pkgconfig_2.0.3 crayon_1.5.3
## [19] fastmap_1.2.0 backports_1.5.0
## [21] labeling_0.4.3 promises_1.3.2
## [23] rmarkdown_2.29 ragg_1.3.3
## [25] purrr_1.0.2 xfun_0.49
## [27] cachem_1.1.0 pals_1.9
## [29] aplot_0.2.4 jsonlite_1.8.9
## [31] later_1.4.1 BiocParallel_1.41.0
## [33] cluster_2.1.8 broom_1.0.7
## [35] parallel_4.5.0 R6_2.5.1
## [37] rols_3.3.0 stringi_1.8.4
## [39] RColorBrewer_1.1-3 bslib_0.8.0
## [41] car_3.1-3 jquerylib_0.1.4
## [43] Rcpp_1.0.13-1 iterators_1.0.14
## [45] knitr_1.49 IRanges_2.41.2
## [47] httpuv_1.6.15 igraph_2.1.2
## [49] Matrix_1.7-1 tidyselect_1.2.1
## [51] dichromat_2.0-0.1 abind_1.4-8
## [53] yaml_2.3.10 doParallel_1.0.17
## [55] codetools_0.2-20 lattice_0.22-6
## [57] tibble_3.2.1 withr_3.0.2
## [59] shiny_1.10.0 Biobase_2.67.0
## [61] treeio_1.31.0 evaluate_1.0.1
## [63] gridGraphics_0.5-1 desc_1.4.3
## [65] xml2_1.3.6 circlize_0.4.16
## [67] pillar_1.10.0 ggtree_3.15.0
## [69] ggpubr_0.6.0 carData_3.0-5
## [71] stats4_4.5.0 foreach_1.5.2
## [73] ggfun_0.1.8 plotly_4.10.4
## [75] generics_0.1.3 S4Vectors_0.45.2
## [77] ggplot2_3.5.1 munsell_0.5.1
## [79] scales_1.3.0 tidytree_0.4.6
## [81] ggnetwork_0.5.13 xtable_1.8-4
## [83] glue_1.8.0 orthogene_1.13.0
## [85] mapproj_1.2.11 scatterplot3d_0.3-44
## [87] lazyeval_0.2.2 tools_4.5.0
## [89] data.table_1.16.4 KGExplorer_0.99.03
## [91] ggsignif_0.6.4 babelgene_22.9
## [93] fs_1.6.5 tidygraph_1.3.1
## [95] grid_4.5.0 tidyr_1.3.1
## [97] ape_5.8-1 crosstalk_1.2.1
## [99] colorspace_2.1-1 nlme_3.1-166
## [101] patchwork_1.3.0 homologene_1.4.68.19.3.27
## [103] Formula_1.2-5 cli_3.6.3
## [105] rappdirs_0.3.3 Polychrome_1.5.1
## [107] textshaping_0.4.1 viridisLite_0.4.2
## [109] ComplexHeatmap_2.23.0 dplyr_1.1.4
## [111] gtable_0.3.6 rstatix_0.7.2
## [113] yulab.utils_0.1.8 sass_0.4.9
## [115] digest_0.6.37 BiocGenerics_0.53.3
## [117] ggplotify_0.1.2 rjson_0.2.23
## [119] htmlwidgets_1.6.4 farver_2.1.2
## [121] htmltools_0.5.8.1 pkgdown_2.1.1
## [123] simona_1.5.0 lifecycle_1.0.4
## [125] httr_1.4.7 mime_0.12
## [127] GlobalOptions_0.1.2