An open API service indexing awesome lists of open source software.

https://github.com/konstantinryabov/dmtools

Tools for Clinical Data Management
https://github.com/konstantinryabov/dmtools

cdisc clinical-data-management laboratory-reference-range-validate

Last synced: 8 months ago
JSON representation

Tools for Clinical Data Management

Awesome Lists containing this project

README

          

---
title: "README"
author: "Konstantin"
date: "07 04 2020"
output: md_document
---
# dmtools
[![CRAN status](https://www.r-pkg.org/badges/version/dmtools)](https://CRAN.R-project.org/package=dmtools)
[![Build Status](https://travis-ci.com/chachabooms/dmtools.svg?token=pmH5ZxVz4xaZTjx5TDKs&branch=master)](https://travis-ci.com/chachabooms/dmtools) [![codecov](https://codecov.io/gh/KonstantinRyabov/dmtools/branch/master/graph/badge.svg?token=AEKUFWUUXZ)](https://codecov.io/gh/KonstantinRyabov/dmtools)

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

## Installation
```{r install, eval = FALSE}
install.packages("dmtools")

# dev-version
devtools::install_github("KonstantinRyabov/dmtools")

library(dmtools)
```

## Overview
For checking the dataset from EDC in clinical trials.
Notice, your dataset should have a postfix( \_V1 ) or a prefix( V1\_ ) in the names of variables. Column names should be unique.

* `date()` - create object date to check dates in the dataset
* `lab()` - create object lab to check lab reference range
* `short()` - create object short to reshape the dataset in a tidy view.
* `check()` - check objects
* `get_result()` - get the final result of object
* `choose_test()` - filter the final result of `check()`
* `rename_dataset()` - rename the dataset

## Usage

For example, you want to check laboratory values, you need to create the excel table like in the example.

* AGELOW - number, >= number
* AGEHIGH - if none, type Inf, <= number
* SEX - for both sex, use `|`
* LBTEST - What was the lab test name? (can be any convenient name for you)
* LBORRES* - What was the result of the lab test?
* LBNRIND* - How [did/do] the reported values compare within the [reference/normal/expected] range?
* LBORNRLO - What was the lower limit of the reference range for this lab test, >=
* LBORNRHI - What was the high limit of the reference range for this lab test, <=

*column names without prefix or postfix

```{r refer, echo = FALSE, result = 'asis', warning = FALSE, message = FALSE}
library(knitr)
library(dmtools)
library(dplyr)

refs <- system.file("labs_refer.xlsx", package = "dmtools")
refers <- readxl::read_xlsx(refs)
kable(refers, caption = "lab reference ranges")
```

```{r dataset, echo = FALSE, result = 'asis'}

ID <- c("01", "02", "03")
AGE <- c("19", "20", "22")
SEX <- c("f", "m", "m")
GLUC_V1 <- c("5.5", "4.1", "9.7")
GLUC_IND_V1 <- c("norm", NA, "norm")
AST_V2 <- c("30", "48", "31")
AST_IND_V2 <- c("norm", "norm", "norm")

df <- data.frame(
ID, AGE, SEX,
GLUC_V1, GLUC_IND_V1,
AST_V2, AST_IND_V2,
stringsAsFactors = F
)

kable(df, caption = "dataset")
```

```{r lab}
# "norm" and "no" it is an example, necessary variable for the estimate, get from the dataset
refs <- system.file("labs_refer.xlsx", package = "dmtools")
obj_lab <- lab(refs, ID, AGE, SEX, "norm", "no")
obj_lab <- obj_lab %>% check(df)

# ok - analysis, which has a correct estimate of the result
obj_lab %>% choose_test("ok")

# mis - analysis, which has an incorrect estimate of the result
obj_lab %>% choose_test("mis")

# skip - analysis, which has an empty value of the estimate
obj_lab %>% choose_test("skip")
```

```{r strange_dataset, echo = FALSE, result = 'asis'}

ID <- c("01", "02", "03")
AGE <- c("19", "20", "22")
SEX <- c("f", "m", "m")
V1_GLUC <- c("5,5", "4,1", "9,7")
V1_GLUC_IND <- c("norm", NA, "norm")
V2_AST <- c(" < 5", "48", "31")
V2_AST_IND <- c("norm", "norm", "norm")

strange_df <- data.frame(
ID, AGE, SEX,
V1_GLUC, V1_GLUC_IND,
V2_AST, V2_AST_IND,
stringsAsFactors = F
)

kable(strange_df, caption = "strange_dataset")
```

```{r stange_lab}
# dmtools can work with the dataset as strange_df
# parameter is_post has value FALSE because a dataset has a prefix( V1_ ) in the names of variables
obj_lab <- lab(refs, ID, AGE, SEX, "norm", "no", is_post = F)
obj_lab <- obj_lab %>% check(strange_df)

# dmtools can understand the value with a comma like 6,6
obj_lab %>% choose_test("ok")

# Notice, if dmtools can't understand the value of lab_vals e.g. < 5, it puts Inf in the RES_TYPE_NUM
obj_lab %>% choose_test("mis")

obj_lab %>% choose_test("skip")
```