Perform multiple steps of an analysis using phenotype risk scoresSource:
This function can map ICD occurrences to phecode occurrences, calculate weights for each phecode, and calculate raw and residual phenotype risk scores.
A data.table having one row per person in the cohort. Must have a column
coxmethod also requires
last_agecolumns corresponding to the first and last age of visit (in years).
A data.table of occurrences of ICD codes for each person in the cohort. Must have columns
flag. The cox and "loglinear methods require an additional
occurrence_agecolumn corresponding to the age (in years) a person acquired an ICD code.
A data.table of the mapping between diseases and phecodes. Must have columns
A data.table of the mapping between ICD codes and phecodes. Must have columns
flag. Default is the map included in this package.
A data.table of ICD codes to exclude from mapping to phecodes. Must have columns
flag. Default is the table of Mendelian diseases and the corresponding ICD codes that indicate a genetic diagnosis. If
NULL, no ICD codes will be excluded.
A data.table of phecodes and their corresponding weights. Must have columns
NULL(the default), weights will be calculated based on data for the cohort provided. If the cohort is small or its phecode prevalences do not reflect those in the population of interest, it is recommended to use preCalcWeights.
A string indicating the statistical model for calculating weights.
A formula representing the right hand side of the model corresponding to
method. All terms in the formula must correspond to columns in
demos. A method formula is not required for the
Logical indicating whether to calculate the weights in parallel if a parallel backend is already set up, e.g., using
doParallel::registerDoParallel(). Recommended to minimize runtime.
A formula representing the linear model to use for calculating residual scores. All terms in the formula must correspond to columns in
NULL, no residual scores will be calculated.
A list with elements:
phecodeOccurences: A data.table of phecode occurrences for each person in the cohort.
weights: A data.table of phecodes and their corresponding weights.
scores: A data.table of raw and possibly residual phenotype risk scores for each person and each disease.
library('data.table') # OMIM disease IDs for which to calculate phenotype risk scores diseaseId = 154700 # map diseases to phecodes diseasePhecodeMap = mapDiseaseToPhecode() diseasePhecodeMap = diseasePhecodeMap[disease_id == diseaseId] # calculate raw and residal scores using weights based on the sample cohort scores = phers( demoSample, icdSample, diseasePhecodeMap, residScoreFormula = ~ sex) # calculate scores using pre-calculated weights scores = phers( demoSample, icdSample, diseasePhecodeMap, weights = phers::preCalcWeights, residScoreFormula = ~ sex)