R build status CRAN_Status_Badge metacran downloads Project Status: Active – The project has reached a stable, usable state and is being actively developed.

accept

R package for the ACute COPD Exacerbation Prediction Tool (ACCEPT)

The package includes two main functions accept() and accept2(). accept() provides predictions of exacerbations for COPD patients per original published manuscript. accept2() is an updated version of ACCEPT that is fine tuned for improved precitions in patients who do not have a prior history of exacerbations. Please refer to the published paper for more information:

Adibi A, Sin DD, Safari A, Jonhson KM, Aaron SD, FitzGerald JM, Sadatsafavi M. The Acute COPD Exacerbation Prediction Tool (ACCEPT): a modelling study. The Lancet Respiratory Medicine. Published Online First 2020 March 13th; doi:10.1016/S2213-2600(19)30397-2

The following animation explains the accept model in 90 seconds:

IMAGE ALT TEXT HERE

Installation

The latest stable version can be downloaded from CRAN:
install.packages ('accept')

Alternatively, you can download the latest development version from GitHub:

install.packages("remotes")
remotes::install_github("resplab/accept")

Web App for ACCEPT

ACCEPT is also available as web app, accessible at http://resp.core.ubc.ca/ipress/accept

ACCEPT in R

Sample Data

To get started, there is an R data frame with the package of sample patient data. I have printed columns 1-13 and 14-19 separately because there isn’t enough space:

library(accept)
samplePatients <- accept::samplePatients

Exacerbation Prediction

To get a prediction for exacerbation rate, you will need to pass in a patient vector:

results <- accept2(samplePatients[1,]) #accept2 uses the updated prediction model
print(t(results))

The accept() function returns a data frame with the original patient data, along with the predictions for different treatment options.

To visualize the data, there is a graphing function called plotExacerbations(), which creates a Plotly bar graph. You have the option of selecting probability or rate for which prediction you want to see, and either CI or PI to select the confidence interval or prediction interval respectively.

plotExacerbations(results, type="probability", interval = "CI")
plotExacerbations(results, type="probability", interval = "PI")
plotExacerbations(results, type="rate", interval = "CI")

Probability of N Exacerbations (Poisson)

We can also calculate the predicted number of exacerbations in a year:

patientResults = accept(samplePatients[1,]) #accept uses the original prediction model
exacerbationsMatrix = predictCountProb(patientResults, n = 10, shortened = TRUE)
print(exacerbationsMatrix)

The shortened parameter groups the probabilities from 3-10 exacerbations into one category, “3 or more exacerbations.” To see all n exacerbation probabilities:

exacerbationsMatrix = predictCountProb(patientResults, n = 10, shortened = FALSE)
print(exacerbationsMatrix)

To visualize the matrix as a heatmap, we can use the function plotHeatMap:

plotHeatMap(patientResults, shortened = FALSE)

Cloud-based API Access

The Peer Models Network allows users to access ACCEPT through the cloud. A MACRO-enabled Excel-file can be used to interact with the model and see the results. To download the PRISM Excel template file for ACCEPT, please refer to the Peer Models Network model repository.

Python

import json
import requests
url = 'https://prism.peermodelsnetwork.com/route/accept/run'
headers = {'x-prism-auth-user': YOUR_API_KEY}
model_run = requests.post(url, headers=headers,
json = {"func":["prism_model_run"],"model_input":[{"ID": "10001","male": 1,"age": 57,"smoker": 0,"oxygen": 0,"statin": 0,"LAMA": 1,"LABA": 1,"ICS": 1,"FEV1": 51,"BMI": 18,"SGRQ": 63,"LastYrExacCount": 2,"LastYrSevExacCount": 1,"randomized_azithromycin": 0,"randomized_statin": 0,"randomized_LAMA": 0,"randomized_LABA": 0,"randomized_ICS": 0, "random_sampling_N" : 100,  "calculate_CIs" : "TRUE"}]})
print(model_run)
results = json.loads(model_run.text)
print(results)

Linux Bash

In Ubuntu, you can call the API with curl:

curl \
-X POST \
-H "x-prism-auth-user: REPLACE_WITH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"func":["prism_model_run"],"model_input":[{"ID": "10001","male": 1,"age": 57,"smoker": 0,"oxygen": 0,"statin": 0,"LAMA": 1,"LABA": 1,"ICS": 1,"FEV1": 51,"BMI": 18,"SGRQ": 63,"LastYrExacCount": 2,"LastYrSevExacCount": 1,"randomized_azithromycin": 0,"randomized_statin": 0,"randomized_LAMA": 0,"randomized_LABA": 0,"randomized_ICS": 0, "random_sampling_N" : 100, 
"calculate_CIs" : "TRUE"}]}' \
https://prism.peermodelsnetwork.com/route/accept/run

User Manual

An interactive user manual that describes the study, the web app, the API, and the R package is available here.

Citation

Please cite:

Adibi A, Sin DD, Safari A, Jonhson KM, Aaron SD, FitzGerald JM, Sadatsafavi M. The Acute COPD Exacerbation Prediction Tool (ACCEPT): a modelling study. The Lancet Respiratory Medicine. Published Online First 2020 March 13th; doi:10.1016/S2213-2600(19)30397-2