rvandewater / YAIB-cohorts

🏥Generate task cohort for the YAIB framework.
https://github.com/stars/rvandewater/lists/yaib
MIT License
8 stars 4 forks source link

Can't load mimic-iv; Error in `vec_as_col_index()`: ! Can't subset elements that don't exist. ✖ Element `race` doesn't exist. #7

Open leoleoasd opened 7 months ago

leoleoasd commented 7 months ago

I'm using mimic-iv 1.0 since ricu don't support 2.2. When I'm running base.R I encountered this error:

.....
── Loading 1 concept ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
• ethnic
Error in `vec_as_col_index()`:
! Can't subset elements that don't exist.
✖ Element `race` doesn't exist.
Backtrace:
     ▆
  1. ├─global load_step(dict[static_vars], cache = TRUE)
  2. ├─global load_step.concept(dict[static_vars], cache = TRUE)
  3. │ └─base::lapply(x, load_step, ...)
  4. │   ├─global FUN(X[[i]], ...)
  5. │   └─global load_step.cncpt(X[[i]], ...)
  6. │     ├─ricu::load_concepts(as_concept(x), src = src, ...)
  7. │     └─ricu:::load_concepts.concept(as_concept(x), src = src, ...)
  8. │       ├─ricu:::with_progress(...)
  9. │       │ └─base::withCallingHandlers(expr, msg_progress = create_progress_handler(progress_bar))
 10. │       └─base::Map(...)
 11. │         └─base::mapply(FUN = f, ..., SIMPLIFY = FALSE)
 12. │           └─ricu (local) `<fn>`(...)
 13. │             ├─ricu::load_concepts(x, aggregate, ..., progress = progress)
 14. │             └─ricu:::load_concepts.fct_cncpt(x, aggregate, ..., progress = progress)
 15. │               ├─ricu::load_concepts(as_item(x), ..., progress = progress)
 16. │               └─ricu:::load_concepts.item(as_item(x), ..., progress = progress)
 17. │                 ├─ricu::rbind_lst(...)
 18. │                 └─base::lapply(x, load_one, progress, id_type, interval, ...)
 19. │                   └─ricu (local) FUN(X[[i]], ...)
 20. │                     ├─ricu::load_concepts(x, patient_ids[[src]], ...)
 21. │                     └─ricu:::load_concepts.itm(x, patient_ids[[src]], ...)
 22. │                       ├─ricu::do_itm_load(x, id_type, interval = interval)
 23. │                       ├─ricu:::do_itm_load.col_itm(x, id_type, interval = interval)
 24. │                       ├─base::NextMethod()
 25. │                       └─ricu:::do_itm_load.itm(x, id_type, interval = interval)
 26. │                         ├─ricu (local) fun(x, id_var = idv, interval = ivl)
 27. │                         └─ricu:::load_id.itm(x, id_var = idv, interval = ivl)
 28. │                           ├─ricu::load_id(...)
 29. │                           └─ricu:::load_id.src_tbl(...)
 30. │                             ├─ricu::load_difftime(...)
 31. │                             └─ricu:::load_difftime.miiv_tbl(...)
 32. │                               └─ricu:::load_mihi(...)
 33. │                                 ├─ricu::load_src(...)
 34. │                                 └─ricu:::load_src.src_tbl(...)
 35. │                                   ├─base::subset(...)
 36. │                                   └─prt:::subset.prt(...)
 37. │                                     └─prt::subset_quo(x, subset, select, part_safe)
 38. │                                       └─prt:::vec_as_col_index(cols, colnames(x))
 39. │                                         └─vctrs::vec_as_location(j, length(cols), cols)
 40. └─vctrs (local) `<fn>`()
 41.   └─vctrs:::stop_subscript_oob(...)
 42.     └─vctrs:::stop_subscript(...)
 43.       └─rlang::abort(...)
Execution halted
rvandewater commented 6 months ago

MIMIC-IV version 1.0 called the relevant column “ethnicity”. In one of the later versions (most likely 2.0), this was changed to “race”. ricu does support MIMIC-IV version 2.2 now as far as I know. Perhaps you are using the version 2.2 config with version 1.0 data?