getResidualScores | R Documentation |
The residual score indicates to what extent a person's phenotype risk score for a given disease deviates from the expected score, after adjusting for the person's characteristics in a linear model.
getResidualScores(demos, scores, lmFormula)
demos |
A data.table of characteristics for each person in the cohort.
Must have column |
scores |
A data.table containing the phenotype risk score for each
person for each disease. Must have columns |
lmFormula |
A formula representing the linear model to use for
calculating residual scores. All terms in the formula must correspond to
columns in |
A data.table, based on scores
, with an additional column
resid_score
. Residual scores for each disease are standardized to have
unit variance.
stats::rstandard()
, getScores()
library('data.table')
# map ICD codes to phecodes
phecodeOccurrences = getPhecodeOccurrences(icdSample)
# calculate weights (using the prevalence method)
weights = getWeights(demoSample, phecodeOccurrences)
# OMIM disease IDs for which to calculate phenotype risk scores
diseaseId = 154700
# map diseases to phecodes
diseasePhecodeMap = mapDiseaseToPhecode()
# calculate scores
scores = getScores(weights, diseasePhecodeMap[disease_id == diseaseId])
# calculate residual scores
rscores = getResidualScores(demoSample, scores, lmFormula = ~ sex)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.