Map ICD code occurrences to phecode occurrencesSource:
This is typically the first step of an analysis using phenotype risk scores,
the next is
A data.table of occurrences of ICD codes for each person in the cohort. 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.
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( demoSample, phecodeOccurrences, weights, diseasePhecodeMap[disease_id == diseaseId]) # calculate residual scores rscores = getResidualScores(demoSample, scores, lmFormula = ~ sex)