Skip to content

Commit

Permalink
Merge branch 'main' into load-rec-args
Browse files Browse the repository at this point in the history
  • Loading branch information
prockenschaub authored Oct 4, 2023
2 parents 4a9f169 + 9979eb1 commit 1225437
Show file tree
Hide file tree
Showing 81 changed files with 2,005 additions and 3,793 deletions.
4 changes: 2 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
^Meta$
^cran-comments\.md$
^CRAN-RELEASE$
^vignettes/jss\.(aux|bbl|blg|bst|cls|knit\.md|log|out|pdf|R|tex)$
^vignettes/(jss|uom)_(cache|files)$
^vignettes/ricu\.(aux|bbl|blg|bst|cls|knit\.md|log|out|pdf|R|tex)$
^vignettes/(ricu|uom)_(cache|files)$
^inst/local_testdata
^CRAN-SUBMISSION$
3 changes: 2 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ jobs:
any::rcmdcheck
eth-mds/mimic-demo
eth-mds/eicu-demo
needs: check
nbenn/mockthat
- uses: r-lib/actions/check-r-package@v2
env:
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_DOC_SIZES_: false
with:
upload-snapshots: true
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
any::covr
eth-mds/mimic-demo
eth-mds/eicu-demo
needs: coverage
nbenn/mockthat
- name: Test coverage
run: covr::codecov(quiet = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
local::.
eth-mds/mimic-demo
eth-mds/eicu-demo
needs: website
nbenn/mockthat
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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.3
Version: 0.5.6
Authors@R: c(
person(given = "Nicolas",
family = "Bennett",
Expand Down Expand Up @@ -68,8 +68,9 @@ Suggests:
kableExtra,
units,
pdftools,
magick
RoxygenNote: 7.2.0
magick,
pillar
RoxygenNote: 7.2.3
Additional_repositories: https://eth-mds.github.io/physionet-demo
VignetteBuilder: knitr
Config/testthat/edition: 3
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -170,10 +172,12 @@ S3method(load_concepts,cncpt)
S3method(load_concepts,concept)
S3method(load_concepts,default)
S3method(load_concepts,fct_cncpt)
S3method(load_concepts,integer)
S3method(load_concepts,item)
S3method(load_concepts,itm)
S3method(load_concepts,lgl_cncpt)
S3method(load_concepts,num_cncpt)
S3method(load_concepts,numeric)
S3method(load_concepts,rec_cncpt)
S3method(load_concepts,unt_cncpt)
S3method(load_difftime,aumc_tbl)
Expand Down Expand Up @@ -247,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)
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 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
to 0.2.0 of prt

# ricu 0.5.4

* maintenance release: tests using `mockthat` are only run when available

# ricu 0.5.3

* maintenance release for compatibility with an update to `prt`
Expand Down
11 changes: 9 additions & 2 deletions R/assertions.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -62,7 +61,15 @@ is_intish <- function(x) {
}

on_failure(is_intish) <- function(call, env) {
format_assert("{as_label(call$x)} integer-values", "is_intish_assert")
format_assert("{as_label(call$x)} contains non integer values",
"is_intish_assert")
}

no_na <- function(x) !anyNA(x)

on_failure(no_na) <- function(call, env) {
format_assert("{as_label(call$x)} contains NA values",
"no_na_assert")
}

has_length <- function(x, length = NA) {
Expand Down
38 changes: 11 additions & 27 deletions R/callback-cncpt.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

collect_dots <- function(concepts, interval, ..., merge_dat = FALSE) {

assert_that(is.character(concepts))
Expand Down Expand Up @@ -89,32 +88,21 @@ rename_data_var <- function(new_name, old_name = NULL) {
#' values might not be ideal for some datasets and/or analysis tasks.
#'
#' ## `pafi`
#' In order to calculate the PaO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}}/FiO\ifelse{
#' latex}{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} (or
#' Horowitz index), for a given time point, both a PaO\ifelse{
#' latex}{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} and a
#' FiO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} measurement is required. As the two are often
#' not measured at the same time, some form of imputation or matching
#' procedure is required. Several options are available:
#' In order to calculate the PaO\subs{2}/FiO\subs{2} (or Horowitz index), for
#' a given time point, both a PaO\subs{2} and an FiO\subs{2} measurement is
#' required. As the two are often not measured at the same time, some form of
#' imputation or matching procedure is required. Several options are available:
#'
#' * `match_vals` allows for a time difference of maximally `match_win`
#' between two measurements for calculating their ratio
#' * `extreme_vals` uses the worst PaO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} and a
#' FiO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} values within the time window spanned by
#' `match_win`
#' * `extreme_vals` uses the worst PaO\subs{2} and FiO\subs{2} values within
#' the time window spanned by `match_win`
#' * `fill_gaps` represents a variation of `extreme_vals`, where ratios are
#' evaluated at every time-point as specified by `interval`as opposed to
#' only the time points where either a PaO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} or a
#' FiO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} measurement is available
#' only the time points where either a PaO\subs{2} or an FiO\subs{2}
#' measurement is available
#'
#' Finally, `fix_na_fio2` imputes all remaining missing FiO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} with 21,
#' Finally, `fix_na_fio2` imputes all remaining missing FiO\subs{2} with 21,
#' the percentage (by volume) of oxygen in (tropospheric) air.
#'
#' ## `vent_ind`
Expand Down Expand Up @@ -165,13 +153,9 @@ rename_data_var <- function(new_name, old_name = NULL) {
#'
#' @param ... Data input used for concept calculation
#' @param match_win Time-span during which matching of values is allowed
#' @param mode Method for matching PaO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html}{\out{<sub>2</sub>}}{2}} and
#' FiO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} values
#' @param mode Method for matching PaO\subs{2} and FiO\subs{2} values
#' @param fix_na_fio2 Logical flag indicating whether to impute missing
#' FiO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} values with 21
#' FiO\subs{2} values with 21
#' @param interval Expected time series step size (determined from data if
#' `NULL`)
#'
Expand Down
1 change: 0 additions & 1 deletion R/callback-itm.R
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
1 change: 0 additions & 1 deletion R/callback-scores.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' SIRS score label
#'
#' The SIRS (Systemic Inflammatory Response Syndrome) score is a commonly used
Expand Down
113 changes: 81 additions & 32 deletions R/callback-sep3.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Sepsis 3 label
#'
#' The sepsis 3 label consists of a suspected infection combined with an acute
Expand All @@ -19,38 +18,88 @@
#' increase in the SOFA score (see [sofa_score()]) of 2 points or more within
#' the suspected infection (SI) window (see [susp_inf()]):
#'
#' ```{tikz sofa-sep-3, echo = FALSE}
#' ```{tikz}
#' #| sofa-sep-3,
#' #| echo = FALSE,
#' #| engine.opts = list(
#' #| extra.preamble = c(
#' #| "\\usepackage{pgfplots}", "\\pgfplotsset{compat=newest}"
#' #| )
#' #| )
#'
#' \begin{tikzpicture}
#' \draw (-6,0) -- (3,0);
#' \draw (-6,-0.25) -- (-6,0.25);
#' \draw (3,-0.25) -- (3,0.25);
#' \draw (0,-0.25) -- (0,0.25);
#' \node[align = center] at (0,-0.75) {SI time};
#' \node[align = center] at (3,-0.75) {SI window\\ end};
#' \node[align = center] at (-6,-0.75) {SI window\\ start};
#' \filldraw (-6, 1) circle (2pt);
#' \draw (-6,1) -- (-5.5, 1);
#' \filldraw (-5.5, 1) circle (2pt);
#' \draw (-5.5,1) -- (-5, 1);
#' \node at (-4.25, 1) {$\dots$} ;
#' \filldraw (-5, 1) circle (2pt);
#' \filldraw (-3.5, 1) circle (2pt);
#' \filldraw (-3, 1.5) circle (2pt);
#' \filldraw (-2.5, 1.5) circle (2pt);
#' \filldraw (-2, 2.5) circle (2pt);
#' \draw (-3.5,1) -- (-3, 1.5);
#' \draw (-3,1.5) -- (-2.5, 1.5);
#' \draw (-2.5,1.5) -- (-2, 2.5);
#' \node [black] at (-0.25, 1.75) {$\Delta$SOFA $\geq 2$};
#' \draw (-6.5, 1) -- (-6.5, 2.5) ;
#' \node at (-6.5, 3) {SOFA} ;
#' \draw (-6.5,1)--(-6.6,1) node[left,font=\small]{$0$};
#' \draw (-6.5,1.5)--(-6.6,1.5) node[left,font=\small]{$1$};
#' \draw (-6.5,2)--(-6.6,2) node[left,font=\small]{$2$};
#' \draw (-6.5,2.5)--(-6.6, 2.5) node[left,font=\small]{$3$};
#' \draw[red] (-2,-0.25) -- (-2,0.25);
#' \draw[dashed,red] (-2, 2.35) -- (-2, 0) ;
#' \node[red] at (-2, -0.75) {Sepsis-3 time};
#'
#' \draw (-5.5, 0) -- (3.5, 0);
#' \draw (-5.5, -0.2) -- (-5.5, 0.2);
#' \draw (3.5, -0.2) -- (3.5, 0.2);
#' \draw (0.5, -0.2) -- (0.5, 0.2);
#'
#' \node[align = center] at (0.5, 0.5) {SI time};
#' \node[align = center] at (3.5, 0.5) {SI window end};
#' \node[align = center] at (-5.5, -0.5) {SI window start};
#'
#' \draw (-1.5, -0.2) -- (-1.5, 0.2);
#' \draw[dashed] (-1.5, 2) -- (-1.5, 0);
#' \node[align = center] at (-1.5, -0.5) {Sepsis-3 time};
#'
#' \node[align = center] at (-2.75, 0.5) {-48 hours};
#' \node[align = center] at (2, -0.5) {24 hours};
#'
#' \draw[dashed] (0.5, 0) -- (0.5, -1);
#'
#' \draw (0.5, -1) -- (3.5, -1);
#' \draw (3.5, -1.2) -- (3.5, -0.8);
#' \draw (0.5, -1.2) -- (0.5, -0.8);
#'
#' \node at (5.25, -1) {within 24 hours};
#'
#' \node[align = center] at (0.5, -1.5) {ABX};
#' \node[align = center] at (3.5, -1.5) {Sampling};
#'
#' \draw (0.5, -2) -- (9.5, -2);
#' \draw (9.5, -2.2) -- (9.5, -1.8);
#' \draw (0.5, -2.2) -- (0.5, -1.8);
#'
#' \node[align = center] at (5.25, -2.5) {within 72 hours};
#'
#' \node[align = center] at (0.5, -2.5) {Sampling};
#' \node[align = center] at (9.5, -2.5) {ABX};
#'
#' \draw [decorate, decoration = {brace, mirror, amplitude=5pt, raise=4pt},
#' yshift=0pt] (0, -0.9) -- (0, -2.1);
#' \node at (-3, -1.5) {Either option is permissible};
#'
#' \filldraw (-6, 1.5) circle (1pt);
#' \draw (-6, 1.5) -- (-5.5, 1.5);
#' \filldraw (-5.5, 1.5) circle (1pt);
#' \draw (-5.5, 1.5) -- (-5, 1);
#' \filldraw (-5, 1) circle (1pt);
#' \draw (-5, 1) -- (-4.5, 1);
#' \filldraw (-4.5, 1) circle (1pt);
#' \draw (-4.5, 1) -- (-4, 1);
#' \filldraw (-4, 1) circle (1pt);
#' \draw (-4, 1) -- (-3.5, 1);
#' \filldraw (-3.5, 1) circle (1pt);
#' \draw (-3.5, 1) -- (-3, 1.5);
#' \filldraw (-3, 1.5) circle (1pt);
#' \draw (-3, 1.5) -- (-2.5, 1.5);
#' \filldraw (-2.5, 1.5) circle (1pt);
#' \draw (-2.5, 1.5) -- (-2, 1.5);
#' \filldraw (-2, 1.5) circle (1pt);
#' \draw (-2, 1.5) -- (-1.5, 2.0);
#' \filldraw (-1.5, 2.0) circle (1pt);
#'
#' \draw [decorate, decoration = {brace, amplitude=5pt, mirror, raise=4pt},
#' yshift=0pt] (-1.25, 1) -- (-1.25, 2);
#' \node [black] at (0.25, 1.5) {$\Delta$SOFA $\geq 2$};
#'
#' \draw (-6.5, 1) -- (-6.5, 2.5);
#' \node at (-6.5, 3) {SOFA};
#' \draw (-6.5, 1) -- (-6.6, 1) node[left]{0};
#' \draw (-6.5, 1.5) -- (-6.6, 1.5) node[left]{1};
#' \draw (-6.5, 2) -- (-6.6, 2) node[left]{2};
#' \draw (-6.5, 2.5) -- (-6.6, 2.5) node[left]{3};
#'
#' \end{tikzpicture}
#' ```
#'
Expand Down
31 changes: 8 additions & 23 deletions R/callback-sofa.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' SOFA score label
#'
#' The SOFA (Sequential Organ Failure Assessment) score is a commonly used
Expand Down Expand Up @@ -38,40 +37,26 @@
#' | **SOFA score** | 1 | 2 | 3 | 4 |
#' | --------------------------- | --------- | --------- | -------- | ------ |
#' | **Respiration** | | | | |
#' | PaO\ifelse{latex}{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}}/FiO\ifelse{latex
#' }{\out{\textsubscript{2}}}{\ifelse{html
#' }{\out{<sub>2</sub>}}{2}} \[mmHg\] | < 400 | < 300 | < 200 | < 100 |
#' | PaO\subs{2}/FiO\subs{2} \[mmHg\] | < 400 | < 300 | < 200 | < 100 |
#' | and mechanical ventilation | | | yes | yes |
#' | **Coagulation** | | | | |
#' | Platelets \[\ifelse{latex}{\out{$\times$}}{\ifelse{html
#' }{\out{&times;}}{x}}10\ifelse{latex}{\out{\textsuperscript{3}}}{\ifelse{
#' html}{\out{<sup>3</sup>}}{3}}/mm\ifelse{latex
#' }{\out{\textsuperscript{3}}}{\ifelse{html
#' }{\out{<sup>3</sup>}}{3}}\] | < 150 | < 100 | < 50 | < 20 |
#' | Platelets \[\tims{}10\sups{3}/mm\sups{3}\] | < 150 | < 100 | < 50 | < 20 |
#' | **Liver** | | | | |
#' | Bilirubin \[mg/dl\] | 1.2-1.9 | 2.0-5.9 | 6.0-11.9 | > 12.0 |
#' | **Cardiovascular**\ifelse{latex}{\out{\textsuperscript{a}}}{\ifelse{html
#' }{\out{<sup>a</sup>}}{a}} | | | | |
#' | **Cardiovascular**\sups{a} | | | | |
#' | MAP | < 70 mmHg | | | |
#' | or dopamine | | \ifelse{latex}{\out{$\le$}}{\ifelse{html
#' }{\out{&leq;}}{<=}} 5 | > 5 | > 15 |
#' | or dopamine | | \leq{}5 | > 5 | > 15 |
#' | or dobutamine | | any dose | | |
#' | or epinephrine | | | \ifelse{latex}{\out{$\le$}}{\ifelse{html
#' }{\out{&leq;}}{<=}} 0.1 | > 0.1 |
#' | or norepinephrine | | | \ifelse{latex}{\out{$\le$}}{\ifelse{html
#' }{\out{&leq;}}{<=}} 0.1 | > 0.1 |
#' | or epinephrine | | | \leq{}0.1 | > 0.1 |
#' | or norepinephrine | | | \leq{}0.1 | > 0.1 |
#' | **Central nervous system** | | | | |
#' | Glasgow Coma Score | 13-14 | 10-12 | 6-9 | < 6 |
#' | **Renal** | | | | |
#' | Creatinine \[mg/dl\] | 1.2-1.9 | 2.0-3.4 | 3.5-4.9 | > 5.0 |
#' | or urine output \[ml/day\] | | | < 500 | < 200 |
#'
#' \ifelse{latex}{\out{\textsuperscript{a}}}{\ifelse{html
#' }{\out{<sup>a</sup>}}{a}}Adrenergic agents administered for at least 1h
#' (doses given are in \[\ifelse{latex}{\out{$\mu$}}{\ifelse{html
#' }{\out{&mu;}}{u}}g/kg \ifelse{latex}{\out{$\cdot$}}{\ifelse{html
#' }{\out{&middot;}}{.}} min\]
#' Adrenergic\sups{a} agents administered for at least 1h
#' (doses given are in \[\smu{}g/kg \dotm{} min\]
#'
#' At default, for each patient, a score is calculated for every time step,
#' from the first available measurement to the last. In instead of a regularly
Expand Down
Loading

0 comments on commit 1225437

Please sign in to comment.