From fb51e0c284741b1a41ef7868a0a634f708522962 Mon Sep 17 00:00:00 2001 From: Malte Londschien Date: Wed, 26 Jul 2023 10:40:15 +0200 Subject: [PATCH 1/8] Fix typo. --- R/setup-download.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/setup-download.R b/R/setup-download.R index 65b673cc..985ce13f 100644 --- a/R/setup-download.R +++ b/R/setup-download.R @@ -228,7 +228,7 @@ download_src.aumc_cfg <- function(x, data_dir = src_data_dir(x), fil <- file.path(tmp, name) if (isTRUE(verbose)) { - prg <- progress_init(size, msg = "Donwloading `aumc` data", + prg <- progress_init(size, msg = "Downloading `aumc` data", what = FALSE) } else { prg <- FALSE From d161178e536bf85c09a89c5860d43383dbb20024 Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Sun, 3 Sep 2023 20:29:30 +0200 Subject: [PATCH 2/8] maintenance release --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ cran-comments.md | 3 +-- vignettes/ricu.Rmd | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3aded6ab..df824129 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ Description: Focused on (but not exclusive to) data sets hosted on PhysioNet functions for running arbitrary queries against available data sets, a system for defining clinical concepts and encoding their representations in tabular ICU data is presented. -Version: 0.5.5 +Version: 0.5.6 Authors@R: c( person(given = "Nicolas", family = "Bennett", diff --git a/NEWS.md b/NEWS.md index 7532d584..7e881dd5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# ricu 0.5.6 + +* maintenance release: fixes non-character numeric version input issues + # ricu 0.5.5 * maintenance release: fixes an issue introduced by pillar 1.9.0 via an update diff --git a/cran-comments.md b/cran-comments.md index 47ced910..317d0f8c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -10,5 +10,4 @@ 0 errors | 0 warnings | 0 notes -* Maintenance release (fixes an issue introduced by pillar 1.9.0 via an update - to 0.2.0 of prt) +* Maintenance release (fixes non-character numeric version input issues) diff --git a/vignettes/ricu.Rmd b/vignettes/ricu.Rmd index 75951fe8..63e74a9b 100644 --- a/vignettes/ricu.Rmd +++ b/vignettes/ricu.Rmd @@ -56,7 +56,7 @@ vignette: > %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} output: > - if (packageVersion("rticles") < 0.5 || rmarkdown::pandoc_version() >= 2) + if (packageVersion("rticles") < "0.5" || rmarkdown::pandoc_version() >= "2") rticles::jss_article else rmarkdown::html_vignette documentclass: jss classoption: From cd67675081823cafac23fd6f15ce99166c98a34f Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:10:11 +0200 Subject: [PATCH 3/8] fix exports --- NAMESPACE | 3 ++ R/concept-utils.R | 1 + R/tbl-class.R | 4 +- man/change_id.Rd | 58 ++++++++++++++++----------- man/data_env.Rd | 99 +++++++++++++++++++++++++++++++++-------------- 5 files changed, 112 insertions(+), 53 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 15748ab3..2010f7ad 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -43,6 +43,8 @@ S3method(as_item,item) S3method(as_item,itm) S3method(as_item,list) S3method(as_item,rec_cncpt) +S3method(as_ptype,data.frame) +S3method(as_ptype,data.table) S3method(as_ptype,default) S3method(as_ptype,id_tbl) S3method(as_src_cfg,default) @@ -249,6 +251,7 @@ S3method(set_callback,default) S3method(set_callback,itm) S3method(set_target,cncpt) S3method(set_target,concept) +S3method(set_target,default) S3method(set_target,item) S3method(set_target,itm) S3method(setup_src_data,character) diff --git a/R/concept-utils.R b/R/concept-utils.R index 114bd1ea..ae77feac 100644 --- a/R/concept-utils.R +++ b/R/concept-utils.R @@ -806,6 +806,7 @@ set_target.concept <- function(x, target) { new_concept(lapply(x, set_target, target)) } +#' @export set_target.default <- function(x, target) stop_generic(x, .Generic) #' @rdname item_utils diff --git a/R/tbl-class.R b/R/tbl-class.R index a19707c5..3adf82ee 100644 --- a/R/tbl-class.R +++ b/R/tbl-class.R @@ -636,11 +636,11 @@ as_ptype.id_tbl <- function(x) { reclass_tbl(as.data.table(lapply(x, `[`, 0L)[meta_vars(x)]), x) } -#' @method reclass_tbl data.table +#' @method as_ptype data.table #' @export as_ptype.data.table <- function(x) data.table() -#' @method reclass_tbl data.frame +#' @method as_ptype data.frame #' @export as_ptype.data.frame <- function(x) data.frame() diff --git a/man/change_id.Rd b/man/change_id.Rd index 6193adf5..d1770344 100644 --- a/man/change_id.Rd +++ b/man/change_id.Rd @@ -57,19 +57,34 @@ and \code{downgrade_id()} when the target ID system is of lower cardinality } \details{ In order to provide ID system conversion for a data source, the (internal) -function [id_map()] must be able to construct an ID mapping for that data +function \code{\link[=id_map]{id_map()}} must be able to construct an ID mapping for that data source. Constructing such a mapping can be expensive w.r.t. the frequency -it might be re-used and therefore, [id_map()] provides caching +it might be re-used and therefore, \code{\link[=id_map]{id_map()}} provides caching infrastructure. The mapping itself is constructed by the (internal) -function [id_map_helper()], which is expected to provide source and +function \code{\link[=id_map_helper]{id_map_helper()}}, which is expected to provide source and destination ID columns as well as start and end columns corresponding to the destination ID, relative to the source ID system. In the following -example, we request for `mimic_demo`, with ICU stay IDs as source and +example, we request for \code{mimic_demo}, with ICU stay IDs as source and hospital admissions as destination IDs. -```{r, eval = is_data_avail("mimic_demo")} -id_map_helper(mimic_demo, "icustay_id", "hadm_id") -``` +\if{html}{\out{
}}\preformatted{id_map_helper(mimic_demo, "icustay_id", "hadm_id") +#> # An `id_tbl`: 136 x 4 +#> # Id var: `icustay_id` +#> icustay_id hadm_id hadm_id_start hadm_id_end +#> +#> 1 201006 198503 ~17h ~6d +#> 2 201204 114648 ~23h ~4d +#> 3 203766 126949 ~1h ~6d +#> 4 204132 157609 ~23h ~7d +#> 5 204201 177678 ~17h ~6d +#> ... +#> 132 295043 170883 ~18h ~21d +#> 133 295741 176805 ~23h ~2d +#> 134 296804 110244 ~2h ~3d +#> 135 297782 167612 ~23h ~3h +#> 136 298685 151323 ~23h ~13d +#> # i 131 more rows +}\if{html}{\out{
}} Both start and end columns encode the hospital admission windows relative to each corresponding ICU stay start time. It therefore comes as no @@ -78,22 +93,21 @@ occurs before ICU stay start time), while end times are often days in the future (as hospital discharge typically occurs several days after ICU admission). -In order to use the ID conversion infrastructure offered by `ricu` for a -new dataset, it typically suffices to provide an `id_cfg` entry in the -source configuration (see [load_src_cfg()]), outlining the available ID +In order to use the ID conversion infrastructure offered by \code{ricu} for a +new dataset, it typically suffices to provide an \code{id_cfg} entry in the +source configuration (see \code{\link[=load_src_cfg]{load_src_cfg()}}), outlining the available ID systems alongside an ordering, as well as potentially a class specific -implementation of [id_map_helper()] for the given source class, specifying +implementation of \code{\link[=id_map_helper]{id_map_helper()}} for the given source class, specifying the corresponding time windows in 1 minute resolution (for every possible pair of IDs). -While both up- and downgrades for `id_tbl` objects, as well as downgrades -for `ts_tbl` objects are simple merge operations based on the ID mapping -provided by [id_map()], ID upgrades for `ts_tbl` objects are slightly more -involved. As an example, consider the following setting: we have `data` -associated with `hadm_id` IDs and times relative to hospital admission: +While both up- and downgrades for \code{id_tbl} objects, as well as downgrades +for \code{ts_tbl} objects are simple merge operations based on the ID mapping +provided by \code{\link[=id_map]{id_map()}}, ID upgrades for \code{ts_tbl} objects are slightly more +involved. As an example, consider the following setting: we have \code{data} +associated with \code{hadm_id} IDs and times relative to hospital admission: -``` - 1 2 3 4 5 6 7 8 +\if{html}{\out{
}}\preformatted{ 1 2 3 4 5 6 7 8 data ---*------*-------*--------*-------*-------*--------*------*--- 3h 10h 18h 27h 35h 43h 52h 59h @@ -103,17 +117,17 @@ hadm_id |-------------------------------------------------------------| icustay_id |------------------| |---------------| 0h 19h 0h 16h ICU_1 ICU_2 -``` +}\if{html}{\out{
}} -The mapping of data points from `hadm_id` to `icustay_id` is created as +The mapping of data points from \code{hadm_id} to \code{icustay_id} is created as follows: ICU stay end times mark boundaries and all data that is recorded after the last ICU stay ended is assigned to the last ICU stay. Therefore -data points 1-3 are assigned to `ICU_1`, while 4-8 are assigned to `ICU_2`. +data points 1-3 are assigned to \code{ICU_1}, while 4-8 are assigned to \code{ICU_2}. Times have to be shifted as well, as timestamps are expected to be relative to the current ID system. Data points 1-3 therefore are assigned to time stamps -4h, 3h and 11h, while data points 4-8 are assigned to -10h, -2h, 6h, 15h and 22h. Implementation-wise, the mapping is computed using an -efficient `data.table` rolling join. +efficient \code{data.table} rolling join. } \examples{ if (require(mimic.demo)) { diff --git a/man/data_env.Rd b/man/data_env.Rd index 6249b595..0fd9d2a0 100644 --- a/man/data_env.Rd +++ b/man/data_env.Rd @@ -42,57 +42,98 @@ hosted data source is available as well. As with the PhysioNet datasets, access is public but has to be granted by the data collectors. } \details{ -Setting up a dataset for use with `ricu` requires a configuration object. +Setting up a dataset for use with \code{ricu} requires a configuration object. For the included datasets, configuration can be loaded from -``` -system.file("extdata", "config", "data-sources.json", package = "ricu") -``` +\if{html}{\out{
}}\preformatted{system.file("extdata", "config", "data-sources.json", package = "ricu") +}\if{html}{\out{
}} -by calling [load_src_cfg()] and for dataset that are external to `ricu`, +by calling \code{\link[=load_src_cfg]{load_src_cfg()}} and for dataset that are external to \code{ricu}, additional configuration can be made available by setting the environment -variable `RICU_CONFIG_PATH` (for more information, refer to -[load_src_cfg()]). Using the dataset configuration object, data can be -downloaded ([download_src()]), imported ([import_src()]) and attached -([attach_src()]). While downloading and importing are one-time procedures, +variable \code{RICU_CONFIG_PATH} (for more information, refer to +\code{\link[=load_src_cfg]{load_src_cfg()}}). Using the dataset configuration object, data can be +downloaded (\code{\link[=download_src]{download_src()}}), imported (\code{\link[=import_src]{import_src()}}) and attached +(\code{\link[=attach_src]{attach_src()}}). While downloading and importing are one-time procedures, attaching of the dataset is repeated every time the package is loaded. Briefly, downloading loads the raw dataset from the internet (most likely -in `.csv` format), importing consists of some preprocessing to make the -data available more efficiently (by converting it to [`.fst`][fst::fst()] +in \code{.csv} format), importing consists of some preprocessing to make the +data available more efficiently (by converting it to \code{\link[fst:fst]{.fst}} format) and attaching sets up the data for use by the package. For more information on the individual steps, refer to the respective documentation pages. A dataset that has been successfully made available can interactively be explored by typing its name into the console and individual tables can be -inspected using the `$` function. For example for the MIMIC-III demo -dataset and the `icustays` table, this gives - -```{r, eval = is_data_avail("mimic_demo")} -mimic_demo +inspected using the \code{$} function. For example for the MIMIC-III demo +dataset and the \code{icustays} table, this gives + +\if{html}{\out{
}}\preformatted{mimic_demo +#> +#> admissions callout caregivers chartevents +#> [129 x 19] [77 x 24] [7,567 x 4] [758,355 x 15] +#> cptevents d_cpt d_icd_diagnoses d_icd_procedures +#> [1,579 x 12] [134 x 9] [14,567 x 4] [3,882 x 4] +#> d_items d_labitems datetimeevents diagnoses_icd +#> [12,487 x 10] [753 x 6] [15,551 x 14] [1,761 x 5] +#> drgcodes icustays inputevents_cv inputevents_mv +#> [297 x 8] [136 x 12] [34,799 x 22] [13,224 x 31] +#> labevents microbiologyevents outputevents patients +#> [76,074 x 9] [2,003 x 16] [11,320 x 13] [100 x 8] +#> prescriptions procedureevents_mv procedures_icd services +#> [10,398 x 19] [753 x 25] [506 x 5] [163 x 6] +#> transfers +#> [524 x 13] mimic_demo$icustays -``` +#> # : [136 x 12] +#> # ID options: subject_id (patient) < hadm_id (hadm) < icustay_id (icustay) +#> # Defaults: `intime` (index), `last_careunit` (val) +#> # Time vars: `intime`, `outtime` +#> row_id subject_id hadm_id icustay_id dbsource first_careunit last_careunit +#> +#> 1 12742 10006 142345 206504 carevue MICU MICU +#> 2 12747 10011 105331 232110 carevue MICU MICU +#> 3 12749 10013 165520 264446 carevue MICU MICU +#> 4 12754 10017 199207 204881 carevue CCU CCU +#> 5 12755 10019 177759 228977 carevue MICU MICU +#> ... +#> 132 42676 44083 198330 286428 metavision CCU CCU +#> 133 42691 44154 174245 217724 metavision MICU MICU +#> 134 42709 44212 163189 239396 metavision MICU MICU +#> 135 42712 44222 192189 238186 metavision CCU CCU +#> 136 42714 44228 103379 217992 metavision SICU SICU +#> # i 131 more rows +#> # i 5 more variables: first_wardid , last_wardid , intime , +#> # outtime , los +}\if{html}{\out{
}} Table subsets can be loaded into memory for example using the -[base::subset()] function, which uses non-standard evaluation (NSE) to +\code{\link[base:subset]{base::subset()}} function, which uses non-standard evaluation (NSE) to determine a row-subsetting. This design choice stems form the fact that some tables can have on the order of 10^8 rows, which makes loading full tables into memory an expensive operation. Table subsets loaded into -memory are represented as [`data.table`][data.table::data.table()] objects. +memory are represented as \code{\link[data.table:data.table]{data.table}} objects. Extending the above example, if only ICU stays corresponding to the patient -with `subject_id == 10124` are of interest, the respective data can be +with \code{subject_id == 10124} are of interest, the respective data can be loaded as -```{r, eval = is_data_avail("mimic_demo")} -subset(mimic_demo$icustays, subject_id == 10124) -``` - -Much care has been taken to make `ricu` extensible to new datasets. For -example the publicly available ICU database [AmsterdamUMCdb -](https://amsterdammedicaldatascience.nl/amsterdamumcdb/) +\if{html}{\out{
}}\preformatted{subset(mimic_demo$icustays, subject_id == 10124) +#> row_id subject_id hadm_id icustay_id dbsource first_careunit last_careunit +#> 1: 12863 10124 182664 261764 carevue MICU MICU +#> 2: 12864 10124 170883 222779 carevue MICU MICU +#> 3: 12865 10124 170883 295043 carevue CCU CCU +#> 4: 12866 10124 170883 237528 carevue MICU MICU +#> first_wardid last_wardid intime outtime los +#> 1: 23 23 2192-03-29 10:46:51 2192-04-01 06:36:00 2.8258 +#> 2: 50 50 2192-04-16 20:58:32 2192-04-20 08:51:28 3.4951 +#> 3: 7 7 2192-04-24 02:29:49 2192-04-26 23:59:45 2.8958 +#> 4: 23 23 2192-04-30 14:50:44 2192-05-15 23:34:21 15.3636 +}\if{html}{\out{
}} + +Much care has been taken to make \code{ricu} extensible to new datasets. For +example the publicly available ICU database \href{https://amsterdammedicaldatascience.nl/amsterdamumcdb/}{AmsterdamUMCdb } provided by the Amsterdam University Medical Center, currently is not part -of the core datasets of `ricu`, but code for integrating this dataset is -available on [github](https://github.com/eth-mds/aumc). +of the core datasets of \code{ricu}, but code for integrating this dataset is +available on \href{https://github.com/eth-mds/aumc}{github}. } \section{MIMIC-III}{ From 88c61e9366dc9fe98e688219f130609a40b918db Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 11:31:35 +0200 Subject: [PATCH 4/8] rm empty first lines --- R/assertions.R | 1 - R/callback-cncpt.R | 1 - R/callback-itm.R | 1 - R/callback-scores.R | 1 - R/callback-sep3.R | 1 - R/callback-sofa.R | 1 - R/concept-load.R | 1 - R/concept-utils.R | 1 - R/config-class.R | 1 - R/config-utils.R | 1 - R/data-env.R | 1 - R/data-load.R | 1 - R/data-utils.R | 1 - R/ricu.R | 1 - R/setup-attach.R | 1 - R/setup-download.R | 1 - R/setup-import.R | 1 - R/tbl-base.R | 1 - R/tbl-class.R | 1 - R/tbl-utils.R | 1 - R/utils-cli.R | 1 - R/utils-export.R | 1 - R/utils-file.R | 1 - R/utils-misc.R | 1 - R/utils-ts.R | 1 - R/zzz.R | 1 - README.md | 1 - _pkgdown.yml | 1 - man/change_id.Rd | 20 ++++++++++---------- tests/testthat.R | 1 - tests/testthat/helpers.R | 1 - tests/testthat/test-assertions.R | 1 - tests/testthat/test-callback.R | 1 - tests/testthat/test-concept.R | 1 - tests/testthat/test-config.R | 1 - tests/testthat/test-data-env.R | 1 - tests/testthat/test-data-tbl.R | 1 - tests/testthat/test-data-utils.R | 1 - tests/testthat/test-helpers.R | 1 - tests/testthat/test-scores.R | 1 - tests/testthat/test-setup-attach.R | 1 - tests/testthat/test-setup-download.R | 1 - tests/testthat/test-setup-import.R | 1 - tests/testthat/test-tbl-base.R | 1 - tests/testthat/test-tbl-class.R | 1 - tests/testthat/test-tbl-utils.R | 1 - tests/testthat/test-utils-cli.R | 1 - tests/testthat/test-utils-export.R | 1 - tests/testthat/test-utils-file.R | 1 - tests/testthat/test-utils-ts.R | 1 - vignettes/ricu.bib | 1 - 51 files changed, 10 insertions(+), 60 deletions(-) diff --git a/R/assertions.R b/R/assertions.R index 14e40701..3bef13b2 100644 --- a/R/assertions.R +++ b/R/assertions.R @@ -1,4 +1,3 @@ - #' @importFrom assertthat see_if on_failure<- validate_that #' @importFrom assertthat is.string is.flag is.dir is.count is.scalar #' @importFrom assertthat has_name has_attr are_equal is.number diff --git a/R/callback-cncpt.R b/R/callback-cncpt.R index 4d416ae4..cd919e0f 100644 --- a/R/callback-cncpt.R +++ b/R/callback-cncpt.R @@ -1,4 +1,3 @@ - collect_dots <- function(concepts, interval, ..., merge_dat = FALSE) { assert_that(is.character(concepts)) diff --git a/R/callback-itm.R b/R/callback-itm.R index 5f2521be..3e0f5a75 100644 --- a/R/callback-itm.R +++ b/R/callback-itm.R @@ -1,4 +1,3 @@ - vent_flag <- function(x, val_var, ...) { x <- x[as.logical(get(val_var)), ] set(x, j = c(index_var(x), val_var), diff --git a/R/callback-scores.R b/R/callback-scores.R index a38dce02..8ec0c956 100644 --- a/R/callback-scores.R +++ b/R/callback-scores.R @@ -1,4 +1,3 @@ - #' SIRS score label #' #' The SIRS (Systemic Inflammatory Response Syndrome) score is a commonly used diff --git a/R/callback-sep3.R b/R/callback-sep3.R index 79e4de72..b49aba12 100644 --- a/R/callback-sep3.R +++ b/R/callback-sep3.R @@ -1,4 +1,3 @@ - #' Sepsis 3 label #' #' The sepsis 3 label consists of a suspected infection combined with an acute diff --git a/R/callback-sofa.R b/R/callback-sofa.R index 07a1fa27..a2fff8fa 100644 --- a/R/callback-sofa.R +++ b/R/callback-sofa.R @@ -1,4 +1,3 @@ - #' SOFA score label #' #' The SOFA (Sequential Organ Failure Assessment) score is a commonly used diff --git a/R/concept-load.R b/R/concept-load.R index a420f1bf..6774a5dd 100644 --- a/R/concept-load.R +++ b/R/concept-load.R @@ -1,4 +1,3 @@ - #' Load concept data #' #' Concept objects are used in `ricu` as a way to specify how a clinical diff --git a/R/concept-utils.R b/R/concept-utils.R index ae77feac..47f7d96b 100644 --- a/R/concept-utils.R +++ b/R/concept-utils.R @@ -1,4 +1,3 @@ - #' Data items #' #' Item objects are used in `ricu` as a way to specify how individual data diff --git a/R/config-class.R b/R/config-class.R index a0190db3..39cef8cd 100644 --- a/R/config-class.R +++ b/R/config-class.R @@ -1,4 +1,3 @@ - #' Internal utilities for working with data source configurations #' #' Data source configuration objects store information on data sources used diff --git a/R/config-utils.R b/R/config-utils.R index faf09d75..ca9e6a49 100644 --- a/R/config-utils.R +++ b/R/config-utils.R @@ -1,4 +1,3 @@ - #' @param x Object to coerce/query #' #' @rdname src_cfg diff --git a/R/data-env.R b/R/data-env.R index cc16b4d8..fb55bdeb 100644 --- a/R/data-env.R +++ b/R/data-env.R @@ -1,4 +1,3 @@ - #' ICU datasets #' #' The [Laboratory for Computational Physiology diff --git a/R/data-load.R b/R/data-load.R index 711f6d43..53187a3c 100644 --- a/R/data-load.R +++ b/R/data-load.R @@ -1,4 +1,3 @@ - #' Low level functions for loading data #' #' Data loading involves a cascade of S3 generic functions, which can diff --git a/R/data-utils.R b/R/data-utils.R index 5dcac99a..ebb3a6f3 100644 --- a/R/data-utils.R +++ b/R/data-utils.R @@ -1,4 +1,3 @@ - #' Data loading utilities #' #' Two important tools for smoothing out differences among used datasets are diff --git a/R/ricu.R b/R/ricu.R index faece7fb..37af4d6e 100644 --- a/R/ricu.R +++ b/R/ricu.R @@ -1,4 +1,3 @@ - #' @keywords internal #' @importFrom data.table setattr setcolorder set setnames setorderv #' @importFrom data.table setDT setDF fifelse rbindlist data.table diff --git a/R/setup-attach.R b/R/setup-attach.R index 57fa650e..2ec2df5b 100644 --- a/R/setup-attach.R +++ b/R/setup-attach.R @@ -1,4 +1,3 @@ - #' Data attach utilities #' #' Making a dataset available to `ricu` consists of 3 steps: downloading diff --git a/R/setup-download.R b/R/setup-download.R index 65b673cc..6d9e41e2 100644 --- a/R/setup-download.R +++ b/R/setup-download.R @@ -1,4 +1,3 @@ - #' Data download utilities #' #' Making a dataset available to `ricu` consists of 3 steps: downloading diff --git a/R/setup-import.R b/R/setup-import.R index 95640867..0d2e536d 100644 --- a/R/setup-import.R +++ b/R/setup-import.R @@ -1,4 +1,3 @@ - #' Data import utilities #' #' Making a dataset available to `ricu` consists of 3 steps: downloading diff --git a/R/tbl-base.R b/R/tbl-base.R index e32dc377..c7547b0d 100644 --- a/R/tbl-base.R +++ b/R/tbl-base.R @@ -1,4 +1,3 @@ - #' @export `[.id_tbl` <- function(x, ...) wrap_ptype(as_ptype(x), NextMethod()) diff --git a/R/tbl-class.R b/R/tbl-class.R index 3adf82ee..2eff5eae 100644 --- a/R/tbl-class.R +++ b/R/tbl-class.R @@ -1,4 +1,3 @@ - #' Tabular ICU data classes #' #' In order to simplify handling or tabular ICU data, `ricu` provides diff --git a/R/tbl-utils.R b/R/tbl-utils.R index ad40ba51..7d23c402 100644 --- a/R/tbl-utils.R +++ b/R/tbl-utils.R @@ -1,4 +1,3 @@ - #' ICU class meta data utilities #' #' The two data classes `id_tbl` and `ts_tbl`, used by `ricu` to represent ICU diff --git a/R/utils-cli.R b/R/utils-cli.R index c013e251..715d9498 100644 --- a/R/utils-cli.R +++ b/R/utils-cli.R @@ -1,4 +1,3 @@ - is_interactive <- function() { !isTRUE(getOption('knitr.in.progress')) && interactive() } diff --git a/R/utils-export.R b/R/utils-export.R index d25a55e1..cb86ea88 100644 --- a/R/utils-export.R +++ b/R/utils-export.R @@ -1,4 +1,3 @@ - #' Read and write utilities #' #' Support for reading from and writing to pipe separated values (`.psv`) diff --git a/R/utils-file.R b/R/utils-file.R index a970f3f5..4ee8465a 100644 --- a/R/utils-file.R +++ b/R/utils-file.R @@ -1,4 +1,3 @@ - #' File system utilities #' #' Determine the location where to place data meant to persist between diff --git a/R/utils-misc.R b/R/utils-misc.R index d3a1de5f..fcedbd37 100644 --- a/R/utils-misc.R +++ b/R/utils-misc.R @@ -1,4 +1,3 @@ - agg_or_na <- function(agg_fun) { function(x) { if (all(is.na(x))) return(x[1L]) diff --git a/R/utils-ts.R b/R/utils-ts.R index 9bfcf103..c62796de 100644 --- a/R/utils-ts.R +++ b/R/utils-ts.R @@ -1,4 +1,3 @@ - #' Time series utility functions #' #' ICU data as handled by `ricu` is mostly comprised of time series data and as diff --git a/R/zzz.R b/R/zzz.R index ea11a390..be7ea631 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,4 +1,3 @@ - .onLoad <- function(libname, pkgname) { # nocov start fix_base_fun <- function(fun, fix) { diff --git a/README.md b/README.md index 09df4ea1..c9498e0e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # [ricu](https://eth-mds.github.io/ricu/) diff --git a/_pkgdown.yml b/_pkgdown.yml index 45fc8806..4d0e4b13 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,3 @@ - title: ICU data with R url: https://eth-mds.github.io/ricu diff --git a/man/change_id.Rd b/man/change_id.Rd index d1770344..8c3fa01e 100644 --- a/man/change_id.Rd +++ b/man/change_id.Rd @@ -72,17 +72,17 @@ hospital admissions as destination IDs. #> # Id var: `icustay_id` #> icustay_id hadm_id hadm_id_start hadm_id_end #> -#> 1 201006 198503 ~17h ~6d -#> 2 201204 114648 ~23h ~4d -#> 3 203766 126949 ~1h ~6d -#> 4 204132 157609 ~23h ~7d -#> 5 204201 177678 ~17h ~6d +#> 1 201006 198503 -3290 mins 9114 mins +#> 2 201204 114648 -2 mins 6949 mins +#> 3 203766 126949 -1336 mins 8818 mins +#> 4 204132 157609 -1 mins 10103 mins +#> 5 204201 177678 -368 mins 9445 mins #> ... -#> 132 295043 170883 ~18h ~21d -#> 133 295741 176805 ~23h ~2d -#> 134 296804 110244 ~2h ~3d -#> 135 297782 167612 ~23h ~3h -#> 136 298685 151323 ~23h ~13d +#> 132 295043 170883 -10413 mins 31258 mins +#> 133 295741 176805 -1 mins 3153 mins +#> 134 296804 110244 -1294 mins 4599 mins +#> 135 297782 167612 -1 mins 207 mins +#> 136 298685 151323 -1 mins 19082 mins #> # i 131 more rows }\if{html}{\out{}} diff --git a/tests/testthat.R b/tests/testthat.R index adccaadd..0b68b1cb 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,3 @@ - library(testthat) library(ricu) diff --git a/tests/testthat/helpers.R b/tests/testthat/helpers.R index f7e35fdf..2cbfbee1 100644 --- a/tests/testthat/helpers.R +++ b/tests/testthat/helpers.R @@ -1,4 +1,3 @@ - expect_all_identical <- function(object, expected = object[[1L]], ..., info = NULL, label = NULL, expected_label = NULL) { diff --git a/tests/testthat/test-assertions.R b/tests/testthat/test-assertions.R index 5ae3a024..c2ec5596 100644 --- a/tests/testthat/test-assertions.R +++ b/tests/testthat/test-assertions.R @@ -1,4 +1,3 @@ - test_that("assertions", { expect_true(is_dt(data.table::data.table(a = 1, b = 2))) diff --git a/tests/testthat/test-callback.R b/tests/testthat/test-callback.R index 5fabd919..0d151157 100644 --- a/tests/testthat/test-callback.R +++ b/tests/testthat/test-callback.R @@ -1,4 +1,3 @@ - test_that("aumc callbacks", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-concept.R b/tests/testthat/test-concept.R index 114be0fc..bde36140 100644 --- a/tests/testthat/test-concept.R +++ b/tests/testthat/test-concept.R @@ -1,4 +1,3 @@ - test_that("load hirid items", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-config.R b/tests/testthat/test-config.R index a14b9ff9..73810d48 100644 --- a/tests/testthat/test-config.R +++ b/tests/testthat/test-config.R @@ -1,4 +1,3 @@ - skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) test_that("config classes", { diff --git a/tests/testthat/test-data-env.R b/tests/testthat/test-data-env.R index d5703483..c6830363 100644 --- a/tests/testthat/test-data-env.R +++ b/tests/testthat/test-data-env.R @@ -1,4 +1,3 @@ - skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) test_that("demo envs", { diff --git a/tests/testthat/test-data-tbl.R b/tests/testthat/test-data-tbl.R index 5b2b7241..76afab76 100644 --- a/tests/testthat/test-data-tbl.R +++ b/tests/testthat/test-data-tbl.R @@ -1,4 +1,3 @@ - skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) test_that("load_src()", { diff --git a/tests/testthat/test-data-utils.R b/tests/testthat/test-data-utils.R index 63864547..f537ee5b 100644 --- a/tests/testthat/test-data-utils.R +++ b/tests/testthat/test-data-utils.R @@ -1,4 +1,3 @@ - skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) test_that("stay windows", { diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index c2620d72..14b7093f 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,4 +1,3 @@ - test_that("expect_all_identical", { expect_success(expect_all_identical("foo", "foo")) diff --git a/tests/testthat/test-scores.R b/tests/testthat/test-scores.R index db79d72f..169c43c4 100644 --- a/tests/testthat/test-scores.R +++ b/tests/testthat/test-scores.R @@ -1,4 +1,3 @@ - skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) so_mi <- load_concepts("sofa", "mimic_demo", verbose = FALSE) diff --git a/tests/testthat/test-setup-attach.R b/tests/testthat/test-setup-attach.R index d577d84c..6eea978b 100644 --- a/tests/testthat/test-setup-attach.R +++ b/tests/testthat/test-setup-attach.R @@ -1,4 +1,3 @@ - test_that("auto attach env var", { srcs <- c("mimic_demo", "eicu_demo") diff --git a/tests/testthat/test-setup-download.R b/tests/testthat/test-setup-download.R index cfd4789c..7c862eda 100644 --- a/tests/testthat/test-setup-download.R +++ b/tests/testthat/test-setup-download.R @@ -1,4 +1,3 @@ - mock_fetch_memory <- function(url, handle, ...) { file <- system.file("testdata", paste0(basename(url), ".rds"), diff --git a/tests/testthat/test-setup-import.R b/tests/testthat/test-setup-import.R index 2efc9394..999e5337 100644 --- a/tests/testthat/test-setup-import.R +++ b/tests/testthat/test-setup-import.R @@ -1,4 +1,3 @@ - skip_on_cran() tmp_cars <- withr::local_tempdir() diff --git a/tests/testthat/test-tbl-base.R b/tests/testthat/test-tbl-base.R index 0d16ef9c..5ed86e16 100644 --- a/tests/testthat/test-tbl-base.R +++ b/tests/testthat/test-tbl-base.R @@ -1,4 +1,3 @@ - test_that("icu_tbl subsetting", { col <- runif(10) diff --git a/tests/testthat/test-tbl-class.R b/tests/testthat/test-tbl-class.R index 3862604e..86115420 100644 --- a/tests/testthat/test-tbl-class.R +++ b/tests/testthat/test-tbl-class.R @@ -1,4 +1,3 @@ - test_that("id_tbl constructors", { tbl <- id_tbl(a = 1:10, b = rnorm(10)) diff --git a/tests/testthat/test-tbl-utils.R b/tests/testthat/test-tbl-utils.R index 5c5cf477..87c5a367 100644 --- a/tests/testthat/test-tbl-utils.R +++ b/tests/testthat/test-tbl-utils.R @@ -1,4 +1,3 @@ - test_that("rename_cols for id_tbl", { tbl <- id_tbl(a = 1:10, b = rnorm(10), c = rnorm(10)) diff --git a/tests/testthat/test-utils-cli.R b/tests/testthat/test-utils-cli.R index c6977a86..0f118fe9 100644 --- a/tests/testthat/test-utils-cli.R +++ b/tests/testthat/test-utils-cli.R @@ -1,4 +1,3 @@ - test_that("cli progress", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-utils-export.R b/tests/testthat/test-utils-export.R index eec6aa9f..eb810932 100644 --- a/tests/testthat/test-utils-export.R +++ b/tests/testthat/test-utils-export.R @@ -1,4 +1,3 @@ - skip_on_cran() test_that("psv export", { diff --git a/tests/testthat/test-utils-file.R b/tests/testthat/test-utils-file.R index fae1467c..09c368aa 100644 --- a/tests/testthat/test-utils-file.R +++ b/tests/testthat/test-utils-file.R @@ -1,4 +1,3 @@ - test_that("data dir", { dir <- withr::with_envvar( diff --git a/tests/testthat/test-utils-ts.R b/tests/testthat/test-utils-ts.R index ca51ff18..bb3e7735 100644 --- a/tests/testthat/test-utils-ts.R +++ b/tests/testthat/test-utils-ts.R @@ -1,4 +1,3 @@ - test_that("collapse/expand", { tbl <- ts_tbl(x = 1:5, y = hours(1:5), z = hours(2:6), val = rnorm(5), diff --git a/vignettes/ricu.bib b/vignettes/ricu.bib index 0b2d25ab..27535199 100644 --- a/vignettes/ricu.bib +++ b/vignettes/ricu.bib @@ -1,4 +1,3 @@ - @article{johnson2016, title = {MIMIC-III, A Freely Accessible Critical Care Database}, author = {Johnson, Alistair EW and Pollard, Tom J and Shen, Lu and Li-wei, H Lehman and Feng, Mengling and Ghassemi, Mohammad and Moody, Benjamin and Szolovits, Peter and Celi, Leo Anthony and Mark, Roger G}, From 47f99d2ae8342e4e2ce0d9c67ce0cb4044fe4560 Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:08:18 +0200 Subject: [PATCH 5/8] rm omr for now --- inst/extdata/config/data-sources.json | 31 --------------------------- 1 file changed, 31 deletions(-) diff --git a/inst/extdata/config/data-sources.json b/inst/extdata/config/data-sources.json index b8548290..a7ceea6e 100644 --- a/inst/extdata/config/data-sources.json +++ b/inst/extdata/config/data-sources.json @@ -7173,37 +7173,6 @@ } } }, - "omr" : { - "files": "core/omr.csv.gz", - "defaults": { - "time_vars": ["chartdate"], - "val_var": "result_value" - }, - "num_rows": 6439169, - "cols" : { - "subject_id": { - "name": "subject_id", - "spec": "col_integer" - }, - "chartdate": { - "name": "chartdate", - "spec": "col_datetime", - "format": "%Y-%m-%d" - }, - "seq_num": { - "name": "seq_num", - "spec": "col_integer" - }, - "result_name": { - "name": "result_name", - "spec": "col_character" - }, - "result_value": { - "name": "result_value", - "spec": "col_character" - } - } - }, "transfers": { "files": "core/transfers.csv.gz", "defaults": { From 91c60be1ce7ddd449e06d95775a1ebef078f887d Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:46:38 +0200 Subject: [PATCH 6/8] dont run ts util examples --- R/utils-ts.R | 2 ++ man/ts_utils.Rd | 2 ++ 2 files changed, 4 insertions(+) diff --git a/R/utils-ts.R b/R/utils-ts.R index c62796de..74afa62a 100644 --- a/R/utils-ts.R +++ b/R/utils-ts.R @@ -63,6 +63,7 @@ #' `has_gaps()`/`has_no_gaps()`/`is_regular()`, which return logical flags. #' #' @examples +#' if (FALSE) { #' tbl <- ts_tbl(x = 1:5, y = hours(1:5), z = hours(2:6), val = rnorm(5), #' index_var = "y") #' exp <- expand(tbl, "y", "z", step_size = 1L, new_index = "y", @@ -88,6 +89,7 @@ #' tbl[6, 2] <- hours(2) #' has_no_gaps(tbl) #' is_regular(tbl) +#' } #' #' @rdname ts_utils #' @export diff --git a/man/ts_utils.Rd b/man/ts_utils.Rd index 6412598e..79315042 100644 --- a/man/ts_utils.Rd +++ b/man/ts_utils.Rd @@ -168,6 +168,7 @@ can be seen as a compromise between the two, where windows are spanned for certain time-points, specified by \code{index}. } \examples{ +if (FALSE) { tbl <- ts_tbl(x = 1:5, y = hours(1:5), z = hours(2:6), val = rnorm(5), index_var = "y") exp <- expand(tbl, "y", "z", step_size = 1L, new_index = "y", @@ -193,5 +194,6 @@ is_regular(tbl) tbl[6, 2] <- hours(2) has_no_gaps(tbl) is_regular(tbl) +} } From 680e13b3dbbb40c15d6fdc4c83c0b47011e302eb Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 14:33:25 +0200 Subject: [PATCH 7/8] skip ts utils tests on cran --- tests/testthat/test-utils-ts.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-utils-ts.R b/tests/testthat/test-utils-ts.R index bb3e7735..e58c45cc 100644 --- a/tests/testthat/test-utils-ts.R +++ b/tests/testthat/test-utils-ts.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("collapse/expand", { tbl <- ts_tbl(x = 1:5, y = hours(1:5), z = hours(2:6), val = rnorm(5), From 3c72261c4f049b49e7040a588b28eeb974a2f177 Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:35:51 +0200 Subject: [PATCH 8/8] skip most tests on cran --- tests/testthat/test-callback.R | 2 ++ tests/testthat/test-concept.R | 2 ++ tests/testthat/test-helpers.R | 2 ++ tests/testthat/test-scores.R | 2 ++ tests/testthat/test-setup-attach.R | 2 ++ tests/testthat/test-setup-download.R | 2 ++ tests/testthat/test-tbl-base.R | 2 ++ tests/testthat/test-tbl-class.R | 2 ++ tests/testthat/test-tbl-utils.R | 2 ++ tests/testthat/test-utils-cli.R | 2 ++ tests/testthat/test-utils-file.R | 2 ++ 11 files changed, 22 insertions(+) diff --git a/tests/testthat/test-callback.R b/tests/testthat/test-callback.R index 0d151157..b4ec6014 100644 --- a/tests/testthat/test-callback.R +++ b/tests/testthat/test-callback.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("aumc callbacks", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-concept.R b/tests/testthat/test-concept.R index bde36140..a96827fb 100644 --- a/tests/testthat/test-concept.R +++ b/tests/testthat/test-concept.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("load hirid items", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 14b7093f..82b828dd 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("expect_all_identical", { expect_success(expect_all_identical("foo", "foo")) diff --git a/tests/testthat/test-scores.R b/tests/testthat/test-scores.R index 169c43c4..8ff24de9 100644 --- a/tests/testthat/test-scores.R +++ b/tests/testthat/test-scores.R @@ -1,3 +1,5 @@ +skip_on_cran() + skip_if_srcs_missing(c("mimic_demo", "eicu_demo")) so_mi <- load_concepts("sofa", "mimic_demo", verbose = FALSE) diff --git a/tests/testthat/test-setup-attach.R b/tests/testthat/test-setup-attach.R index 6eea978b..9508a395 100644 --- a/tests/testthat/test-setup-attach.R +++ b/tests/testthat/test-setup-attach.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("auto attach env var", { srcs <- c("mimic_demo", "eicu_demo") diff --git a/tests/testthat/test-setup-download.R b/tests/testthat/test-setup-download.R index 7c862eda..77971fe3 100644 --- a/tests/testthat/test-setup-download.R +++ b/tests/testthat/test-setup-download.R @@ -1,3 +1,5 @@ +skip_on_cran() + mock_fetch_memory <- function(url, handle, ...) { file <- system.file("testdata", paste0(basename(url), ".rds"), diff --git a/tests/testthat/test-tbl-base.R b/tests/testthat/test-tbl-base.R index 5ed86e16..4f902465 100644 --- a/tests/testthat/test-tbl-base.R +++ b/tests/testthat/test-tbl-base.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("icu_tbl subsetting", { col <- runif(10) diff --git a/tests/testthat/test-tbl-class.R b/tests/testthat/test-tbl-class.R index 86115420..3e2308a9 100644 --- a/tests/testthat/test-tbl-class.R +++ b/tests/testthat/test-tbl-class.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("id_tbl constructors", { tbl <- id_tbl(a = 1:10, b = rnorm(10)) diff --git a/tests/testthat/test-tbl-utils.R b/tests/testthat/test-tbl-utils.R index 87c5a367..2346056e 100644 --- a/tests/testthat/test-tbl-utils.R +++ b/tests/testthat/test-tbl-utils.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("rename_cols for id_tbl", { tbl <- id_tbl(a = 1:10, b = rnorm(10), c = rnorm(10)) diff --git a/tests/testthat/test-utils-cli.R b/tests/testthat/test-utils-cli.R index 0f118fe9..b7195ba2 100644 --- a/tests/testthat/test-utils-cli.R +++ b/tests/testthat/test-utils-cli.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("cli progress", { skip_if_not_installed("mockthat") diff --git a/tests/testthat/test-utils-file.R b/tests/testthat/test-utils-file.R index 09c368aa..1f78e874 100644 --- a/tests/testthat/test-utils-file.R +++ b/tests/testthat/test-utils-file.R @@ -1,3 +1,5 @@ +skip_on_cran() + test_that("data dir", { dir <- withr::with_envvar(