getDxStatus {phers}R Documentation

Identify cases and controls for Mendelian diseases

Description

This function is useful for verifying that raw or residual phenotype risk scores of diagnosed individuals (cases) tend to be higher than scores of undiagnosed individuals (controls).

Usage

getDxStatus(
  demos,
  icdOccurrences,
  minUniqueAges = 2L,
  diseaseDxIcdMap = phers::diseaseDxIcdMap
)

Arguments

demos

A data.table having one row per person in the cohort. Must have a column person_id.

icdOccurrences

A data.table of occurrences of ICD codes for each person in the cohort. Must have columns person_id, icd, flag, and occurrence_age.

minUniqueAges

Integer indicating the minimum number of unique ICD code entry ages required to classify a person as a case. Persons with at least one, but fewer than minUniqueAges entry ages, are assigned as neither cases nor controls.

diseaseDxIcdMap

A data.table of the mapping between diseases and the corresponding ICD codes that indicate a diagnosis. Must have columns disease_id, icd, and flag. Default is diseaseDxIcdMap.

Value

A data.table with columns person_id, disease_id, and dx_status (1 indicates a case, 0 indicates a control, -1 indicates neither).

Examples

library('data.table')


icdSample1 = merge(icdSample, demoSample[, .(person_id, dob)], by = 'person_id')
icdSample1[, occurrence_age := as.numeric((entry_date - dob)/365.25)]
icdSample1[, `:=`(entry_date = NULL, dob = NULL)]

dxStatus = getDxStatus(demoSample, icdSample1)

[Package phers version 1.0.2 Index]