|
mappedICD9Codes <- NULL |
|
icd9map_new <- list() |
|
for(i in 1:nrow(icd9map)){ |
|
mapped9 <- grep(icd9map$ICD9[i],codeICD9) |
|
if(length(mapped9) > 0) { |
|
mappedICD9Codes <- unique(c(mappedICD9Codes,codeICD9[mapped9])) |
|
icd9map_new[[icd9map$ICD9[i]]] <- data.table( |
|
'phecode'=icd9map$PheCode[i], |
|
'ICD9'=codeICD9[mapped9]) |
|
} |
|
} |
|
icd9key <- rbindlist(icd9map_new) |
These codes are better applied only to ICD codes that are not successfully mapped, so as to prevent the creation of an excessive number of new ICD–phecode mappings.
notmappedcodeICD9 <- unique(codeICD9[!codeICD9 %in% icd9map$ICD9])
mappedICD9Codes <- NULL
icd9map_new <- list()
for (i in 1:nrow(icd9map)) {
pattern <- paste0("^", gsub("([][{}()+*^$|\\?.])", "\\\1", icd9map$ICD9[i]))
mapped9 <- grep(pattern, notmappedcodeICD9)
if (length(mapped9) > 0) {
mappedICD9Codes <- unique(c(mappedICD9Codes, notmappedcodeICD9[mapped9]))
icd9map_new[[icd9map$ICD9[i]]] <- data.table(
"phecode" = icd9map$phecode[i],
"ICD9" = notmappedcodeICD9[mapped9]
)
}
}
mappedcodeICD9 <- rbindlist(icd9map_new) %>% unique()
createUKBphenome/scripts/function.createUKBphenome.r
Lines 94 to 105 in dcc06c8
These codes are better applied only to ICD codes that are not successfully mapped, so as to prevent the creation of an excessive number of new ICD–phecode mappings.
notmappedcodeICD9 <- unique(codeICD9[!codeICD9 %in% icd9map$ICD9])
mappedICD9Codes <- NULL
icd9map_new <- list()
for (i in 1:nrow(icd9map)) {
pattern <- paste0("^", gsub("([][{}()+*^$|\\?.])", "\\\1", icd9map$ICD9[i]))
mapped9 <- grep(pattern, notmappedcodeICD9)
if (length(mapped9) > 0) {
mappedICD9Codes <- unique(c(mappedICD9Codes, notmappedcodeICD9[mapped9]))
icd9map_new[[icd9map$ICD9[i]]] <- data.table(
"phecode" = icd9map$phecode[i],
"ICD9" = notmappedcodeICD9[mapped9]
)
}
}
mappedcodeICD9 <- rbindlist(icd9map_new) %>% unique()