Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (79 sloc) 3.29 KB
---
title: "2 - Describing the study cohort"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{2 - Describing the study cohort}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
_bllflow_ builds from the `tableone` package to present the study cohort and description statistics. Also planned are tools to help create a study codebook.
## Create "Table 1"
Create "Table 1- description of study data" for all variables in your database. This method is from the `tableone` package.
```{r warning=FALSE}
library(survival)
data(pbc)
library("tableone")
catVars <- c("status", "trt", "ascites", "hepato", "spiders", "edema", "stage")
CreateTableOne(data = pbc, factorVars = catVars)
```
## Create Table 1 using the Model Specification Workbook
Create a Table 1 with only the variables in your model, using the Model Specification Workbook.
First initialize the BLLFlow model.
```{r}
library(bllflow)
variablesSheet <- read.csv(file.path(getwd(), '../inst/extdata/PBC-variables.csv'))
variablesDetailsSheet <- read.csv(file.path(getwd(), '../inst/extdata/PBC-variableDetails.csv'))
pbcModel <- BLLFlow(pbc, variablesSheet, variablesDetailsSheet)
CreateTableOne(pbcModel)
```
## Create Table 1 with stratification
You can stratify Table 1 in two methods.
1) Stratify with columns. This is how to describe your data for manuscripts. This method is supported with the `CreateTableOne` library.
```{r}
TableOne <- CreateTableOne(data = pbc,strata = c("trt"), factorVars = catVars)
```
2) Stratify with rows. This method is helpful if there are many strata. We use this format for interactive visualizations or when we create figures.
For example, see an '[algorithm viewer](http://algorithm-viewer.projectbiglife.ca/#/respect)' that shows Table 1 stratified for 61 strata (bins).
```{r}
TableOneLong <- SummaryDataLong(TableOne)
```
## Add labels and metadata
For all tables, metadata such as labels are added from the Model Specification Workbook and/or DDI documents.
Initialize the model with the DDI document.
```{r}
ddi <- bllflow::ReadDDI(system.file("extdata", "", package = "bllflow"), "pbcDDI.xml")
pbcModel <- bllflow::UpdateMSW(bllModel = pbcModel, newDDI = ddi)
longTableWithLabels <- SummaryDataLong(tableOne = TableOne, bllFlowModel = pbcModel, longTable = TableOneLong)
```
## Check for small cells
Our team works with personal health data in secure settings. For privacy, no summary tables can be exported from the data centre with small cells.
```{r}
TableOne <- CreateTableOne(data = pbc,strata = c("trt","stage"), factorVars = catVars)
checkedTableOne <- CheckSmallCells(TableOne)
```
To obtain print of the actual small cells pass print as TRUE
```{r}
checkedTableOne <- CheckSmallCells(TableOne, print = TRUE)
```
Find out which rows and variables contain the small cells.
```{r}
checkedTableOne$MetaData$smallCells
```
You can also check small cells inside your Summary Data in case you have multiple tables
```{r}
checkedLongTable <- CheckSmallCells(longTableWithLabels)
```
For a print of the found rows pass print as TRUE
```{r}
checkedLongTable <- CheckSmallCells(longTableWithLabels, print = TRUE)
```
Find out which rows and variables contain the small cells.
```{r}
checkedLongTable$MetaData$smallCells
```
You can’t perform that action at this time.