Add age of onset for each HPO ID. onset IDs and assigned "onset_score" values:

  • HP:0011461 "Fetal onset" (onset_score=1)

  • HP:0030674 "Antenatal onset" (onset_score=2)

  • HP:0003577 "Congenital onset" (onset_score=3)

  • HP:0003623 "Neonatal onset" (onset_score=4)

  • HP:0003593 "Infantile onset" (onset_score=5)

  • HP:0011463 "Childhood onset" (onset_score=6)

  • HP:0003621 "Juvenile onset" (onset_score=7)

  • HP:0011462 "Young adult onset" (onset_score=8)

  • HP:0003581 "Adult onset" (onset_score=9)

  • HP:0003596 "Middle age onset" (onset_score=10)

  • HP:0003584 "Late onset" (onset_score=11)

add_onset(
  phenos,
  keep_onsets = NULL,
  agg_by = NULL,
  all.x = TRUE,
  allow.cartesian = FALSE,
  verbose = TRUE
)

Arguments

phenos

dataframe of phenotypes and values / parameters.

keep_onsets

The age of onset associated with each HPO ID to keep. If >1 age of onset is associated with the term, only the earliest age is considered. See add_onset for details.

agg_by

Column to aggregate age of onset metadata by.

all.x

logical; if TRUE, then extra rows will be added to the output, one for each row in x that has no matching row in y. These rows will have 'NA's in those columns that are usually filled with values from y. The default is FALSE, so that only rows with data from both x and y are included in the output.

allow.cartesian

See allow.cartesian in [.data.table.

verbose

Print messages.

Value

phenos data.table with extra columns:

  • "onset": onset HPO IDs of disease phenotypes associated with the target hpo_id phenotype.

  • "onset_names": onset HPO names of disease phenotypes associated with the target hpo_id phenotype.

  • "onset_counts": The number of times each term in "onset_names" appears across associated disease phenotypes.

  • "onset_score_mean": Mean onset score.

  • "onset_score_min": Minimum onset score.

  • "onset_top": The most common onset term.

  • "onset_earliest": The earliest age of onset.

  • "onset_latest": The latest age of onset.

Examples

phenos <- example_phenos()
#>  All local files already up-to-date!
phenos2 <- add_onset(phenos = phenos)
#> Annotating phenos with onset.
#> Annotating phenos with Disease
#> Reading cached RDS file: phenotype.hpoa
#> + Version: v2023-10-09