forked from johnschwenck/bp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
155 lines (111 loc) · 8.93 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# bp
<!-- badges: start -->
[![Travis build status](https://travis-ci.com/johnschwenck/bp.svg?branch=master)](https://travis-ci.com/johnschwenck/bp)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/johnschwenck/bp?branch=master&svg=true)](https://ci.appveyor.com/project/johnschwenck/bp)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/bp)](https://cran.r-project.org/package=bp)
[![](https://cranlogs.r-pkg.org/badges/bp)](https://CRAN.R-project.org/package=bp)
<!-- badges: end -->
## bp: Blood Pressure Analysis for R
Cardiovascular disease (CVD) is the leading cause of death worldwide with Hypertension, specifically, affecting over 1.1 billion people annually. The goal of the \code{bp} package is to provide a comprehensive toolbox for analyzing blood pressure data using a variety of statistical metrics and visualizations to bring more clarity to CVD.
The \code{bp} package includes two sample data sets:
- `bp_hypnos`: a sample of a larger [HYPNOS study](https://clinicaltrials.gov/ct2/show/NCT02454153) containing ABPM data for multiple subjects using continuous monitoring devices
- `bp_jhs`: a single-subject data set from a [2019 pilot study](https://dataverse.harvard.edu/dataverse/r4r) containing non-ABPM data from a self-monitoring Omron Evolv device
### Installation
You can install the released version of bp from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("bp")
```
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("johnschwenck/bp")
```
For installation with vignettes:
```r
devtools::install_github("johnschwenck/bp", build_vignettes = TRUE)
```
### Intended Functionality
The `bp` package is designed to allow the user to initialize a processed dataframe by specifying any combination of the following variables present in the user-supplied data set (with the minimum requirement that `SBP` and `DBP` are included). The package will then utilize the processed dataframe to calculate various metrics from medical and statistical literature and provide visualizations. Perhaps the most useful user-friendly feature of the package is the ability to generate a visualization report to discern relationships and assess blood pressure stage progression among subjects.
The package has the ability to make use of the following physiological variables (expressed as integers):
* Systolic Blood Pressure (`SBP`) measured in mmHg
* Diastolic Blood Pressure (`DBP`) measured in mmHg
* Heart Rate (`HR`) measured in bpm
* Pulse Pressure (`PP`) measured in mmHg which is calculated as SBP - DBP
* Mean Arterial Pressure (`MAP`) measured in mmHg
* Rate Pressure Product (`RPP`) which is calculated as SBP multiplied by resting HR
The data can be further refined on a more granular scale, depending on the type of data supplied. In most instances, ABPM data will include some kind of binary column corresponding to awake vs asleep which the user will assign when initializing the processed data. Further, most blood pressure data sets contain a timestamp associated with each reading. The additional variables are as follows:
* `DATE_TIME` combination such as `12/1/2020 13:42:07` (`as.POSIXct` format)
* `ID` of individuals, if more than one
* `VISIT` corresponding to the visit of each individual, if more than one (integer)
* `WAKE` as a binary indicator where 1 denotes awake and 0 denotes asleep (binary 1 or 0)
After all available variables are identified and processed, the resulting processed dataframe is used for all other functions.
Unique to the `bp` package is the ability to create additional column that might not originally be present in the supplied data set. At current, the following additional columns will be created:
* `TIME_OF_DAY` - Corresponds to the Time of Day (Morning, Afternoon, Evening, or Night) based on `DATE_TIME` column
* `DAY_OF_WEEK` - Corresponds to the Day of the week: a useful column for table visuals. Based on `DATE_TIME` column
* `SBP_CATEGORY` - Systolic Blood Pressure Stages (Low, Normal, Elevated, Stage 1, Stage 2, Crisis) as defined by the American Heart Association
* `DBP_CATEGORY` - Diastolic Blood Pressure Stages (Low, Normal, Elevated, Stage 1, Stage 2, Crisis) as defined by the American Heart Association
See examples below for further details.
### Available Metrics
The package will then utilize the above variables to calculate various metrics from medical and statistical literature in order to quantify and classify the variability of the readings into their respective categories of hypertension (normal, elevated, or hypertensive).
The following metrics are currently offered through the `bp` package:
Function | Metric Name | Source
----------- | ------------------------------------------- | ----------
arv | Average Real Variability | [Mena et al (2005)](https://doi.org/10.1097/01.hjh.0000160205.81652.5a)
bp_center | Mean and Median | [Amaro Lijarcio et al (2006)](https://doi.org/10.1016/j.ejim.2006.07.023)
bp_mag | Blood Pressure Magnitude (peak and trough) | [Munter et al (2011)](https://doi.org/10.1097/HJH.0b013e32834cf213 )
bp_range | Blood Pressure Range | [Levitan et al (2013)](https://doi.org/10.1038/jhh.2013.19)
cv | Coefficient of Variation | [Munter et al (2011)](https://doi.org/10.1097/HJH.0b013e32834cf213 )
sv | Successive Variation | [Munter et al (2011)](https://doi.org/10.1097/HJH.0b013e32834cf213 )
dip_calc | Nocturnal Dipping \% and Classification | [Okhubo et al (1997)](https://academic.oup.com/ajh/article/10/11/1201/148906)
## Example - HYPNOS data
There are two main steps involved with the `bp` package: The data processing step and the functionality / analysis step.
1. Load and process data into a new usable dataframe for all further analysis using the `process_data` function
```{r}
#devtools::install_github("johnschwenck/bp")
library(bp)
## Load bp_hypnos
data(bp_hypnos)
## Process bp_hypnos
hypnos_proc <- process_data(bp_hypnos,
sbp = 'syst',
dbp = 'diast',
bp_datetime = 'date.time',
hr = 'hr',
pp = 'PP',
map = 'MaP',
rpp = 'Rpp',
id = 'id',
visit = 'Visit',
wake = 'wake')
```
**NOTE:** the `process_data` function is insensitive to capitalization of the supplied data column names. For this example, even though the original column name "SYST" exists in the `bp_hypnos`, "syst" is still an acceptable name to be given to the function as shown. For emphasis, all of the above column names were intentionally entered using the wrong capitalization.
`SBP` and `DBP` must be specified for any other functions to work properly.
2. Using the newly processed `hypnos_proc`, we can now calculate various metrics. Now that the `bp_hypnos` has been processed into `hypnos_proc`, we can now instead rely on this new dataframe to calculate various metrics and visualizations. The calculation of the nocturnal dipping classification is shown below, using a subset of only two of the subjects for comparison (subjects 70417 and 70435):
```{r}
dip_calc(hypnos_proc, subj = c(70417, 70435))
```
In terms of statistical metrics, the `bp_stats` function aggregates many of the variability and center metrics into one table which makes comparing the different measures to one another very convenient. Let's suppose for this example that we wanted to further analyze these two subjects by their `SBP_CATEGORY` and were not concerned about DBP output: we would set `bp_type = 1` to subset on only SBP measures, and we would include `add_groups = "SBP_category"` as an additional argument (note that capitalization does not matter).
```{r}
bp_stats(hypnos_proc, subj = c(70417, 70435), add_groups = "sbp_category", bp_type = 1)
```
The `bp` package has multiple visualization tools available:
* `bp_hist` - Histograms for various stages of blood pressure
* `bp_scatter` - Scatter plot of the blood pressure stages as denoted by the American Heart Association
* `dow_tod_plots` - Table visuals to break down readings by time of day and day of week
* `bp_report` - An exportable blood pressure report that aggregates the individual visualization outputs in a clean digestible format
Here is an example of the individual visual function `bp_scatter` for subject #70417:
```{r}
bp_scatter(hypnos_proc, subj = 70417)
```