R/preprocess_cim.R

Defines functions preprocess_cim

Documented in preprocess_cim

#' preprocess cim
#' @export
preprocess_cim <- function(cim, scale1, icd_prefix = "CIM10:", nb_occurrences = 1) {
  
  cim$CODE <- gsub(stringr::str_interp("${icd_prefix}"),"", cim$CODE)
  cim <- dplyr::inner_join(cim, scale1, by = c('CODE' = 'ICD10_CODE') )
  cim$PARENT_CODE <- cim$PHEWAS_CODE
  cim$PARENT_LABEL<- cim$STR
  
  cim %>% group_by(PATIENT_NUM, PARENT_CODE, PARENT_LABEL,SEX, BIRTH_YEAR, group) %>% 
    summarise(count = n()) %>%
    dplyr::filter(count >= nb_occurrences)
  
}
aneuraz/multiWAS documentation built on July 29, 2017, 3:39 a.m.