Skip to contents

A person's phenotype risk score for a given disease corresponds to the sum of the weights of the disease-relevant phecodes that the person has received.


getScores(demos, phecodeOccurrences, weights, diseasePhecodeMap)



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


A data.table of phecode occurrences for each person in the cohort. Must have columns person_id and phecode.


A data.table of phecodes and their corresponding weights. Must have columns phecode and w when weights are unique to the population (e.g., calculated using the prevalence method) and person_id, phecode, and w when weights are unique to each person (e.g., calculated using logistic, cox, or loglinear methods).


A data.table of the mapping between diseases and phecodes. Must have columns disease_id and phecode.


A data.table containing the phenotype risk score for each person for each disease.



# 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(
  demoSample, phecodeOccurrences, weights, diseasePhecodeMap[disease_id == diseaseId])

# calculate residual scores
rscores = getResidualScores(demoSample, scores, lmFormula = ~ sex)