Skip to content

Commit 32eee33

Browse files
committed
Pass checks
1 parent 7c2d7dd commit 32eee33

18 files changed

+135
-48
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: HPOExplorer
22
Title: Analysis and Visualisation of the Human Phenotype Ontology
3-
Version: 1.0.2
3+
Version: 1.0.3
44
Authors@R:
55
c(
66
person(given = "Brian",
@@ -52,7 +52,8 @@ Suggests:
5252
piggyback,
5353
patchwork,
5454
tidygraph,
55-
colorspace
55+
colorspace,
56+
BiocParallel
5657
Remotes:
5758
github::neurogenomics/KGExplorer
5859
VignetteBuilder: knitr

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export(filter_descendants)
2727
export(get_gene_lists)
2828
export(get_hpo)
2929
export(get_hpo_id_direct)
30+
export(get_mappings)
3031
export(get_top_phenos)
3132
export(gpt_annot_check)
3233
export(gpt_annot_class)

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# HPOExplorer 1.0.3
2+
3+
## New features
4+
5+
* Upgrade `add_disease` to use cached definitions.
6+
7+
## Bug fixes
8+
9+
* Fix tests for `make_phenos_dataframe`.
10+
* Deprecate `hpo_api` as the HPO API was deprecated in the 2.0.0 Release (https://hpo.jax.org/data/api).
11+
112
# HPOExplorer 1.0.1
213

314
## New features

R/add_death.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
add_death <- function(phenos,
4444
keep_deaths = NULL,
4545
all.x = TRUE,
46-
allow.cartesian = FALSE,
46+
allow.cartesian = TRUE,
4747
agg_by = NULL){
4848

4949
# devoptera::args2vars(add_death)

R/add_disease.R

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#' Add diseases
22
#'
33
#' Annotate each HPO term with diseases that they are associated with.
4-
#' @param extra_cols Extra metadata columns from the"phenotype.hpoa"
5-
#' annotations file to include.
6-
#' See
7-
#' \href{https://hpo-annotation-qc.readthedocs.io/en/latest/annotationFormat.html}{
8-
#' here for column descriptions}.
4+
#' @param add_descriptions Add disease names and descriptions.
95
#' @inheritParams add_
106
#' @inheritParams map_disease
117
#'
@@ -18,7 +14,7 @@
1814
add_disease <- function(phenos,
1915
phenotype_to_genes = load_phenotype_to_genes(),
2016
hpo = get_hpo(),
21-
extra_cols = NULL,
17+
add_descriptions=FALSE,
2218
all.x = TRUE,
2319
use_api=FALSE,
2420
workers=NULL,
@@ -34,13 +30,16 @@ add_disease <- function(phenos,
3430
all.x = all.x,
3531
allow.cartesian = allow.cartesian)
3632
}
37-
phenos <- map_disease(dat=phenos,
38-
id_col="disease_id",
39-
fields=c("disease"),
40-
use_api=use_api,
41-
return_dat=TRUE,
42-
all.x = all.x,
43-
allow.cartesian = allow.cartesian,
44-
workers=workers)
33+
if(isTRUE(add_descriptions)){
34+
phenos <- map_disease(dat=phenos,
35+
id_col="disease_id",
36+
fields=c("disease"),
37+
use_api=use_api,
38+
return_dat=TRUE,
39+
all.x = all.x,
40+
allow.cartesian = allow.cartesian,
41+
workers=workers)
42+
}
43+
4544
return(phenos)
4645
}

R/add_genes.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ add_genes <- function(phenos = NULL,
4747
hpo = hpo)
4848
#### Add Gene col to data ####
4949
if(!"gene_symbol" %in% names(phenos)){
50+
messager("Adding genes and disease IDs.")
5051
by <- by[by %in% names(phenos)]
5152
# ## Merge with input data
5253
phenos <- data.table::merge.data.table(phenos,

R/annotate_phenos.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ annotate_phenos <- function(phenos,
7777
}
7878
#### Add phenotype-disease freqs ####
7979
if(isTRUE(add_disease_definitions)){
80-
phenos <- add_mondo(phenos = phenos)
80+
phenos <- add_disease(phenos = phenos,
81+
add_descriptions = TRUE)
8182
}
8283
#### Add hoverboxes ####
8384
if(isTRUE(add_hoverboxes)){

R/get_hpo.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#' @import KGExplorer
1818
#' @examples
1919
#' hpo <- get_hpo()
20-
get_hpo <- function(lvl,
21-
add_ancestors = 2,
20+
get_hpo <- function(lvl = 2,
2221
force_new = FALSE,
2322
terms=NULL,
2423
## rols imports the international version for some reason
@@ -29,7 +28,7 @@ get_hpo <- function(lvl,
2928
file <- file.path(save_dir,"hp.rds")
3029
if(!file.exists(file) || isTRUE(force_new)){
3130
ont <- KGExplorer::get_ontology(name = "hp",
32-
add_ancestors = add_ancestors,
31+
lvl = lvl,
3332
force_new = force_new,
3433
terms = terms,
3534
method = method,

R/get_mappings.R

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#' @describeIn get_ get_
2+
#' Get Human Phenotype Ontology (HPO) mappings
3+
#'
4+
#' Get mappings between HPO terms and their corresponding IDs in
5+
#' other medical ontologies (e.g. SNOMED CT, UMLS, ICD-9/10).
6+
#' @param to Medical ontologies to provide mappings to.
7+
#' @param max_dist Maximum cross-ontology distance to search for mappings.
8+
#' A distance of 1 means only direct mappings are returned.
9+
#' Greater distances mean that mappings are found through intermediate terms
10+
#' and are therefore less reliable.
11+
#' @inheritDotParams get_data
12+
#' @returns A named list of \link{data.table} objects containing mappings.
13+
#'
14+
#' @export
15+
#' @examples
16+
#' mappings <- get_mappings()
17+
get_mappings <- function(terms=NULL,
18+
to=c("UMLS","SNOMED","ICD9","ICD10"),
19+
max_dist=1,
20+
force_new=FALSE,
21+
save_dir=KGExplorer::cache_dir(package="HPOExplorer"),
22+
23+
...){
24+
file_name <- distance <- NULL;
25+
26+
files <- piggyback::pb_list(repo = "neurogenomics/HPOExplorer")
27+
files <- data.table::data.table(files)[grepl("*_to_HPO_dist3\\.csv\\.gz$",
28+
file_name)]
29+
files$to <- strsplit(files$file_name,"_to_HPO_dist3\\.csv\\.gz$")|>unlist()
30+
opts <- intersect(toupper(unique(files$to)),
31+
toupper(to))
32+
if(length(opts)==0){
33+
stop("`to` must be one of: ",paste0(shQuote(opts),collapse=", "))
34+
}
35+
out <- lapply(stats::setNames(opts,opts), function(x){
36+
f <- get_data(file=files[opts==x]$file_name[1],
37+
overwrite = force_new,
38+
save_dir = save_dir,
39+
...)
40+
d <- data.table::fread(f)
41+
if(is.numeric(max_dist)){
42+
d <- d[distance<=max_dist]
43+
}
44+
d
45+
})
46+
return(out)
47+
}

R/hpo_api.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
#' @export
1313
#' @import data.table
1414
#' @examples
15+
#' \dontrun{
1516
#' dat <- hpo_api(hpo_id="HP:0011420", type="diseases")
17+
#' }
1618
hpo_api <- function(hpo_id,
1719
type = list(NULL,"genes","diseases")[[1]],
1820
url = paste("hpo.jax.org/api/hpo/term",hpo_id,type,sep="/")
1921
){
2022

23+
.Deprecated(msg="hpo_api is deprecated. For details, see: https://hpo.jax.org/data/api")
24+
stop()
2125
requireNamespace("httr")
2226
requireNamespace("jsonlite")
2327

R/map_disease.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
map_disease <- function(dat,
1919
id_col="disease_id",
2020
fields=c("disease","categories","genes")[1],
21-
use_api=TRUE,
21+
use_api=FALSE,
2222
return_dat=FALSE,
2323
workers=NULL,
2424
all.x = TRUE,
@@ -29,17 +29,17 @@ map_disease <- function(dat,
2929
# httr::add_headers(accept = "application/json")
3030
# )
3131
# cont <- httr::content(res)
32-
3332
# Define the URL and headers
3433
if(!id_col %in% names(dat)){
3534
stop("id_col not found in dat.")
3635
}
3736
if(!all(c("disease_name","disease_description") %in% names(dat))){
3837
messager("Adding disease_name and disease_description.")
38+
requireNamespace("BiocParallel")
3939
#### Slow but up-to-date ####
4040
if(use_api || length(fields)>1){
4141
map_disease_i <- function(id){
42-
url <- URLencode(
42+
url <- utils::URLencode(
4343
## encode URL
4444
paste0("https://ontology.jax.org/api/network/annotation/",id)
4545
)

R/map_phenotypes.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ map_phenotypes <- function(terms,
2525
KGExplorer::map_ontology_terms
2626
)$ignore_char),
2727
invert = FALSE){
28+
to <- match.arg(to)
2829
KGExplorer::map_ontology_terms(terms = terms,
2930
ont = hpo,
3031
to = to,

man/add_.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/add_disease.Rd

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_.Rd

Lines changed: 40 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/hpo_api.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/map_disease.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)