-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathREADME.Rmd
More file actions
177 lines (132 loc) · 13 KB
/
README.Rmd
File metadata and controls
177 lines (132 loc) · 13 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
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 -->
[](https://cran.r-project.org/package=bp)
[](https://CRAN.R-project.org/package=bp)
[](https://github.com/johnschwenck/bp/actions/workflows/R-CMD-check.yaml)
<!-- 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 (BP) data using a variety of statistical metrics and visualizations to bring more clarity to CVD.
### 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)
```
### Sample Data
The \code{bp} package includes six sample data sets:
- `bp_hypnos`: The data set contains ABPM measurements from n= 5subjects with type 2diabetes and obstructive sleep apnea. The recordings are taken every hour during the 24-hour period for each of the two visits that are 3 months apart. Additional information includes sleep/wake indicator for each recording inferred from a wrist-worn actigraphy device. The aim of original study (Rooney et al.2021) is to determine the effect of positive airway pressure treatment of sleep apnea on glycemic control and blood pressure of patients with type 2diabetes. The included data is a subset of the full data described in [Rooneyet al.(2021)](https://clinicaltrials.gov/ct2/show/NCT02454153)
- `bp_jhs`: The data set consists of HBPM measurements from a [2019 single-subject pilot study](https://dataverse.harvard.edu/dataverse/r4r) during an endured aerobic (endurance) exercise: cycling 5,775 miles from New York City, New York to Seward, Alaska over the course of 95 days. Data was collected using an Omron Evolv wireless blood pressure monitor twice per day (in the morning upon waking up and in the evening before bed). The aim of original study (Schwenck 2019) is to assess blood pressure variability across different environments through time.
- `bp_ghana`: The data set contains HBPM measurements on n= 757subjects across 32 community health centers from cluster-randomized trial in Ghana: 389 subjects are in the health insurance coverage (HIC) group and 368 subjects are in another group consisting of a combination of HIC with a nurse-led task-shifting strategy for hypertension control (TASSH)(this group is denoted TASSH + HIC). Baseline blood pressure measurements were collected, with 85% of subjects having available 12 month follow-up measurements. The aim of original study (Ogedegbe et al.2018) is to assess the comparative effectiveness of HIC alone versus the combination of TASSH + HIC on reducing systolic blood pressure among patients with uncontrolled hypertension in Ghana.
- `bp_preg`: The data set contains HBPM measurements from n= 209women, each of whom were recorded every 30 minutes during the Pregnancy Day Assessment Clinic (PDAC) observation window for up to a maximum of 240 minutes (i.e. a maximum of 8 total readings per subject per observation window) in addition to an initial "booking" reading before the PDAC assessment. The aim of the original study (McCarthy et al.2015) is to investigate the pregnancy-induced hypertension and pre-eclampsia prediction to determine whether the blood pressure assessment of the first observation window of 1 hour (60 minutes) is sufficiently accurate relative to the standard 4 hour (240 minute) window.
- `bp_children`: The data set contains HBPM measurements on n= 1,283 children from Bristol, UK. Three blood pressure readings per visit were collected over the course of two observation periods (at ages 9 and 11). Additionally, information on their physical activity has been collected. The aim of original study (Solomon-Moore et al.2020) is to examine how sedentary behavior affect children progressing through primary school, and to understand the relationship between elevated blood pressure in children and its impact on the development of cardiovascular disease into adulthood.
- `bp_rats`: The data set contains AP measurements sampled at 100 Hz of the SS (n1= 9) and SS.13 (n2= 6) genetic strains of Dahl rats. Each mouse was administered either a low sodium or a high sodium diet. The aim of original study (Bugenhagen et al.2010) is to investigate the connection between the dysfunction of the baroreflex control system in Dahl rats and salt-sensitive Hypertension
### Intended Functionality
The `bp` package is designed to allow the user to initialize a processed dataframe through the `process_data` function 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
* Arterial Pressure (`AP`) (if applicable)
* 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
There are also processing functionality for arterial pressure (AP) data which include the following inputs:
* A column corresponding to the AP data (`AP`)
* Time elapsed (`time_elap`)
Furthermore, there are a suite of processing capabilities within the `process_data` function such as:
* `DATE_TIME`: A column coreresponding to a date/time object (typically `as.POSIXct` format) such as `12/1/2020 13:42:07`
* `ID`: Identification of individuals
* `VISIT`: The visit of each individual, if more than one (integer)
* `WAKE`: A binary indicator where 1 denotes awake and 0 denotes asleep (binary 1 or 0)
* `GROUP`: An arbitrary column that can be used to group data according to this category (such as gender or age)
* `EOD`: Denotes the end-of-day which can be adjusted for situations where individuals may take readings after midnight
* `DATA_SCREEN`: A screening proceedure to remove outliers based on upper and lower limits of BP readings
* `AGG`: An aggregation option to average consecutive readings taken within quick succession
* `CHRON_ORDER`: Adjust the chronology of the readings (chronological vs reverse-chronological)
* `TZ`: Time zone adjustment
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 columns 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 (AHA)
* `DBP_CATEGORY` - Diastolic Blood Pressure Stages (Low, Normal, Elevated, Stage 1, Stage 2, Crisis) as defined by the American Heart Association (AHA)
* `BP_CLASS` - A two-to-one mapping of SBP and DBP readings that expands on the original AHA categories using a more recent adaptation by (Lee et al 2018)
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
------------------- | ------------------------------------------- | ----------
`bp_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_cv` | Coefficient of Variation | [Munter et al (2011)](https://doi.org/10.1097/HJH.0b013e32834cf213 )
`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)
`bp_sv` | Successive Variation | [Munter et al (2011)](https://doi.org/10.1097/HJH.0b013e32834cf213 )
`bp_sleep_metrics` | Blood Pressure Sleep Metrics | (Multiple - see documentation)
`bp_stages` | Blood Pressure Stages Classification | American Heart Association
`bp_stats` | Aggregation of statistical summaries | N/A
`dip_calc` | Nocturnal Dipping \% and Classification | [Okhubo et al (1997)](https://academic.oup.com/ajh/article/10/11/1201/148906)
The following visualization functions are currently offered through the `bp` package:
Function | Visualization Type
------------------- | -------------------------------------------
`bp_scatter` | Scatter plot of BP stages
`bp_ts_plots` | Time series plots
`bp_hist` | Histograms of BP stages
`dip_class_plot` | Dipping % category plot
`bp_report` | Exportable report of BP summary
## 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',
date_time = '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 included raw `bp_hypnos` dataset 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 `BP_CLASS`: we would include `add_groups = "BP_CLASS"` as an additional argument (note that capitalization does not matter).
```{r}
bp_stats(hypnos_proc, subj = c(70417, 70435), add_groups = "bp_class", bp_type = "both")
```
Here is an example of the `bp_scatter` function for subject 70417:
```{r}
bp_scatter(hypnos_proc, subj = 70417)
```