Quick start guide

In order to set up ricu, download of datasets from several platforms is required. Two data sources, mimic_demo and eicu_demo are available directly as R packages, hosted on Github. The respective full-featured versions mimic and eicu, as well as the hirid dataset are available from PhysioNet, while access to the remaining standard dataset aumc is available from yet another website. The following steps guide through package installation, data source set up and conclude with some example data queries.

Package installation

Stable package releases are available from CRAN as

install.packages("ricu")

and the latest development version is available from GitHub as

remotes::install_github("eth-mds/ricu")

Demo datasets

The two demo datasets mimic_demo and eicu_demo are listed as Suggests dependencies and therefore their availability is determined by the value passed as dependencies to the above package installation function. The following call explicitly installs the demo dataset packages

install.packages(
  c("mimic.demo", "eicu.demo"),
  repos = "https://eth-mds.github.io/physionet-demo"
)

Full datasets

Included with ricu are functions for download and setup of the following datasets: mimic, eicu, hirid and aumc, which can be invoked in several different ways.

Concept loading

Many commonly used clinical data concepts are available for all data sources, where the required data exists. An overview of available concepts is available by calling explain_dictionary() and concepts can be loaded using load_concepts():

head(explain_dictionary(src = c("mimic_demo", "eicu_demo")))
#>       name     category            description
#> 1      abx  medications            antibiotics
#> 2 adh_rate  medications       vasopressin rate
#> 3      adm demographics patient admission type
#> 4      age demographics            patient age
#> 5      alb    chemistry                albumin
#> 6      alp    chemistry   alkaline phosphatase
load_concepts("alb", "mimic_demo", verbose = FALSE)
#> # A `ts_tbl`: 297 ✖ 3
#> # Id var:     `icustay_id`
#> # Units:      `alb` [g/dL]
#> # Index var:  `charttime` (1 hours)
#>     icustay_id charttime   alb
#>          <int> <drtn>    <dbl>
#>   1     201006   0 hours   2.4
#>   2     203766 -18 hours   2
#>   3     203766   4 hours   1.7
#>   4     204132   7 hours   3.6
#>   5     204201   9 hours   2.3
#>   …
#> 293     298685 130 hours   1.9
#> 294     298685 154 hours   2
#> 295     298685 203 hours   2
#> 296     298685 272 hours   2.2
#> 297     298685 299 hours   2.5
#> # … with 287 more rows

Concepts representing time-dependent measurements are loaded as ts_tbl objects, whereas static information is retrieved as id_tbl object. Both classes inherit from data.table (and therefore also from data.frame) and can be coerced to any of the base classes using as.data.table() and as.data.frame(), respectively. Using data.table ‘by-reference’ operations, this is available as zero-copy operation by passing by_ref = TRUE

(dat <- load_concepts("height", "eicu_demo", verbose = FALSE))
#> # An `id_tbl`: 2,449 ✖ 2
#> # Id var:      `patientunitstayid`
#> # Units:       `height` [cm]
#>       patientunitstayid height
#>                   <int>  <dbl>
#>     1            141764   158.
#>     2            141765   158.
#>     3            143870   167
#>     4            144815   173.
#>     5            145427   178.
#>     …
#> 2,445           3351763   165.
#> 2,446           3352230   178.
#> 2,447           3352231   178.
#> 2,448           3352333   178.
#> 2,449           3353113   188
#> # … with 2,439 more rows
head(as.data.frame(dat, by_ref = TRUE))
#>   patientunitstayid height
#> 1            141764  157.5
#> 2            141765  157.5
#> 3            143870  167.0
#> 4            144815  172.7
#> 5            145427  177.8
#> 6            147306  157.5

Many functions exported by ricu use id_tbl and ts_tbl objects in order to enable more concise semantics. Merging an id_tbl with a ts_tbl, for example, will automatically use the columns identified by id_vars() of both tables, as by.x/by.y arguments, while for two ts_tbl object, respective columns reported by id_vars() and index_var() will be used to merge on.

Extending the concept dictionary

In addition to the ~100 concepts that are available by default, adding user-defined concepts is possible either as R objects or more robustly, as JSON configuration files.