Title: | The Acute COPD Exacerbation Prediction Tool (ACCEPT) |
---|---|
Description: | Allows clinicians to predict the rate and severity of future acute exacerbation in Chronic Obstructive Pulmonary Disease (COPD) patients, based on the clinical prediction models published in Adibi et al. (2020) <doi:10.1016/S2213-2600(19)30397-2> and Safari et al. (2022) <doi:10.1016/j.eclinm.2022.101574>. |
Authors: | Amin Adibi [aut, cre], Mohsen Sadatsafavi [aut, cph], Abdollah Safari [aut], Ainsleigh Hill [aut] |
Maintainer: | Amin Adibi <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0.999 |
Built: | 2024-10-12 05:27:41 UTC |
Source: | https://github.com/resplab/accept |
A flexible version of ACCEPT 2.0 model, which imputes predictors using MICE approach.
accept( newdata, format = "tibble", version = "flexccept", prediction_interval = FALSE, return_predictors = FALSE, ... )
accept( newdata, format = "tibble", version = "flexccept", prediction_interval = FALSE, return_predictors = FALSE, ... )
newdata |
new patient data with missing values to be imputed before prediction with the same format as accept samplePatients. |
format |
default is "tibble". Can also be set to "json". |
version |
indicates which version of ACCEPT needs to be called. |
prediction_interval |
default is FALSE. If set to TRUE, returns prediction intervals of the predictions. |
return_predictors |
default is FALSE. IF set to TRUE, returns the predictors along with prediction results. |
... |
for other versions of accept. |
patientData with prediction.
results <- accept(newdata = samplePatients)
results <- accept(newdata = samplePatients)
Predicts COPD exacerbation rate by severity level based on Acute COPD Exacerbation Tool (ACCEPT)
accept1( patientData, random_sampling_N = 100, lastYrExacCol = "LastYrExacCount", lastYrSevExacCol = "LastYrSevExacCount", ... )
accept1( patientData, random_sampling_N = 100, lastYrExacCol = "LastYrExacCount", lastYrSevExacCol = "LastYrSevExacCount", ... )
patientData |
patient data matrix. Can have one or many patients in it |
random_sampling_N |
number of random sampling. Default is 100. |
lastYrExacCol |
the column specifying last year all exacerbation count |
lastYrSevExacCol |
the column specifying last year severe exacerbation count |
... |
for backward compatibility |
patientData with prediction
results <- accept1(samplePatients)
results <- accept1(samplePatients)
Predicts COPD exacerbation rate by severity level based on the updated accept2 model, which improves accuracy in patients without an exacerbation history.
accept2( patientData, random_sampling_N = 100, lastYrExacCol = "LastYrExacCount", lastYrSevExacCol = "LastYrSevExacCount", KeepSGRQ = TRUE, KeepMeds = TRUE, ... )
accept2( patientData, random_sampling_N = 100, lastYrExacCol = "LastYrExacCount", lastYrSevExacCol = "LastYrSevExacCount", KeepSGRQ = TRUE, KeepMeds = TRUE, ... )
patientData |
patient data matrix. Can have one or many patients in it |
random_sampling_N |
number of random sampling. Default is 100. |
lastYrExacCol |
the column specifying last year all exacerbation count |
lastYrSevExacCol |
the column specifying last year severe exacerbation count |
KeepSGRQ |
default is TRUE. If set to false, the reduced model without SGRQ will be used. |
KeepMeds |
default is TRUE. If set to false, the reduced model without medication predictors will be used. |
... |
for backward compatibility |
patientData with prediction
results <- accept2(samplePatients)
results <- accept2(samplePatients)
Useful for supporting accept_model class in vetiver
## S3 method for class 'accept_model' handler_predict(vetiver_model, ...)
## S3 method for class 'accept_model' handler_predict(vetiver_model, ...)
vetiver_model |
A deployable [vetiver_model()] object |
... |
any other inputs |
A 'handler_startup' function should return invisibly, while a 'handler_predict' function should return a function with the signature 'function(req)'. The request body ('req$body') consists of the new data at prediction time; this function should return predictions either as a tibble or as a list coercable to a tibble via [tibble::as_tibble()].
Creates bar graph comparing no treatment with azithromycin treatment
plotExacerbations( patientResults, type = "rate", interval = "PI", colors = c("#007bff", "rgb(204,204,204)") )
plotExacerbations( patientResults, type = "rate", interval = "PI", colors = c("#007bff", "rgb(204,204,204)") )
patientResults |
patient results vector, produced by accept. |
type |
string: either "probability" or "rate" |
interval |
string: either "CI" or "PI" PI = Predicted Interval CI = Confidence Interval |
colors |
vector: a vector of colors to be used in the graph must be length 2 can use hexadecimal, rgb, or R color codes |
a bar graph
results <- accept1(samplePatients[1,]) plotExacerbations(results)
results <- accept1(samplePatients[1,]) plotExacerbations(results)
Creates heatmap of number of exacerbations
plotHeatMap(patientResults, n = 10, shortened = TRUE)
plotHeatMap(patientResults, n = 10, shortened = TRUE)
patientResults |
patient results vector, produced by accept. |
n |
how many exacerbations to consider |
shortened |
boolean |
a heatmap
results <- accept1(samplePatients[1,]) plotHeatMap(results)
results <- accept1(samplePatients[1,]) plotHeatMap(results)
Model predictions
## S3 method for class 'accept_model' predict(object, ...)
## S3 method for class 'accept_model' predict(object, ...)
object |
a model object |
... |
new data for which the prediction is needed |
prediction results from ACCEPT model
Predicts probability of observing n exacerbations in the next year
predictCountProb(patientResults, n = 10, shortened = TRUE)
predictCountProb(patientResults, n = 10, shortened = TRUE)
patientResults |
patient results vector, produced by accept. |
n |
how many exacerbations |
shortened |
boolean: Shortened results groups into 0, 1, 2, and 3 or more exacerbations |
a matrix of probabilities with the number of exacerbations as rows and number of severe exacerbations as columns
results <- accept2(samplePatients[1,]) predictCountProb (results)
results <- accept2(samplePatients[1,]) predictCountProb (results)
A dataset containing sample patient characteristics to run the prediction model variables are as follows:
A data frame with 2 rows and 19 variables
ID. A unique character string identifying a patients
male. whether the patient is male
age. the age of the patient (40–90)
smoker. whether the patient is currently a smoker
oxygen. whether the patient has had supplemental oxygen therapy within the past year (0,1)
FEV1. forced expiratory volume in 1 second in percent predicted
BMI. body mass index (10–60)
SGRQ. St. George’s Respiratory Questionnaire score (0–100)
statin. whether the patient is taking statins due to cardiovascular conditions
LAMA. whether the patient is on long acting muscarinic antagonist
LABA. whether the patient is on long acting beta agonist
ICS. whether the patient is on inhaled corticosteroids
LastYrExacCount. total number of exacerbations in the previous year
LastYrSevExacCount. number of severe exacerbations in the previous year
NLP functionalities require a paid OpenAI API key to communicate with Open AI models.
set_openai_api_key(key, overwrite = FALSE, temporary = FALSE)
set_openai_api_key(key, overwrite = FALSE, temporary = FALSE)
key |
an OpenAI API key. For more information on keys see the OpenAI API blog |
overwrite |
Option to overwrite any existing OpenAI keys already stored locally. |
temporary |
Option to not store thew API key for use across sessions. |
## Not run: set_openai_api_key("YOUR_OPENAI_API_KEY") # This will set the key permanently until overwritten again set_openai_api_key("YOUR_OPENAI_API_KEY") ## End(Not run)
## Not run: set_openai_api_key("YOUR_OPENAI_API_KEY") # This will set the key permanently until overwritten again set_openai_api_key("YOUR_OPENAI_API_KEY") ## End(Not run)
View saved API key'
show_openai_api_key()
show_openai_api_key()
show_openai_api_key()
show_openai_api_key()
Create a vetiver model object description
## S3 method for class 'accept_model' vetiver_create_description(model)
## S3 method for class 'accept_model' vetiver_create_description(model)
model |
model name |
the description of the model
Useful for supporting accept_model class in vetiver
## S3 method for class 'accept_model' vetiver_create_meta(model, metadata)
## S3 method for class 'accept_model' vetiver_create_meta(model, metadata)
model |
a trained model object |
metadata |
list containing additional metadata to store with the pin |
The vetiver_create_meta function returns a 'vetiver_meta()' list.
Create a vetiver input data prototype
## S3 method for class 'accept_model' vetiver_ptype(model, ...)
## S3 method for class 'accept_model' vetiver_ptype(model, ...)
model |
a vetiver model object |
... |
any other inputs |
A 'vetiver_ptype' method returns a zero-row dataframe, and 'vetiver_create_ptype()' returns either such a zero-row dataframe, 'NULL', or the dataframe passed to 'save_prototype'.