今天介绍一个Github
上的神包吧, 主要是用于Biomarker
的临床分析, 原作者用这个包已经发了3篇Nature
了, 一起看看吧:👇
在一些针对Biomarker
的临床研究中, 我们常常需对Biomarker
进行模型拟合
, 预测效果评估
等等.🥰
这个包可以完美解决这些问题, 并且直接输出发表级
图表, 简单介绍一下用法给大家吧.🥳
rm(list = ls())
#devtools::install_github("ncullen93/abaR")
library(aba)
library(tidyverse)
library(ggsci)
dat <- adnimerge %>%
dplyr::filter(VISCODE == 'bl')
DT::datatable(dat)
看一下都有什么变量, 都是什么类型. 🤞
str(dat)
大家可以通过这种方式来建立模型.
aba_model(
data = NULL,
groups = NULL,
outcomes = NULL,
predictors = NULL,
covariates = NULL,
stats = NULL,
evals = NULL,
include_basic = TRUE
)
这里也提供了pipeline
的形式来编写代码, 个人也是更倾向于这种方式, 大家试一下吧. 😏
我们在这里设定两个结局指标: ConvertedToAlzheimers
和CSF_ABETA_STATUS_bl
.🤒
两个预测指标, 即Biomarker
, PLASMA_PTAU181_bl
和PLASMA_NFL_bl
. 🤫
模型为logistic regression
. 📈
model <- aba_model() %>%
set_data(dat) %>%
set_groups(DX_bl %in% c('MCI','AD')) %>%
set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
set_predictors(
PLASMA_PTAU181_bl,
PLASMA_NFL_bl,
c(PLASMA_PTAU181_bl, PLASMA_NFL_bl)
) %>%
set_covariates(AGE, GENDER, EDUCATION) %>%
set_stats(stat_glm(std.beta=T))
model
Note! 这里我们注意下如何进行Biomarker
的联合应用, 可写为 c(PLASMA_PTAU181_bl, PLASMA_NFL_bl)
. 😘
model <- model %>%
fit()
model
拟合完以后我们就获得了模型的结果, 大家可以大致看一下.🤓
model_summary <- model %>%
summary()
model_summary
这个包提供了很多可视化的参数, 可以直接将summary
的结果传递给画图函数, 非常简单. 😘
这里需要说明一下, 函数内自带的配色只有4
种, 即jama
, nature
, lancet
, none
.
但是大家可以按照ggplot
语法更改颜色.🤜
model_summary %>%
aba_plot_coef(coord_flip=T,
palette = 'nature')
看看各个模型的AUC
吧.😗
model_summary %>%
aba_plot_metric(palette = 'nature')
model_summary %>%
aba_plot_roc()
批量出图, 大家想看哪个predictor
的Risk density plot
就提取哪个吧. 🤪
fig <- model %>%
aba_plot_risk_density()
fig
随便提取一个看看吧~~~😉
fig$fig[1]
这个包还有很多其他强大的功能, 大家可以去进一步地探索一下。😘
欢迎大家留言说一下其他强大的函数哦~
这里附上所有函数官方解释:👇
aba_adjust()
Create an aba_adjust object.aba_control()
Create an aba control object.aba_demographics()
Create a demographics table from a fitted aba model.aba_diagnosticpower()
Caclulate diagnostic power based on a fitted aba modelaba_emmeans()
Calculated estimated marginal means.aba_evaluate()
Evaluate a fitted aba model on new dataaba_fit()
Fit an aba model.aba_longpower()
Run power analysis on a longitudinal-based aba model.aba_model()
Create an aba model.aba_plot()
Plot an aba objectaba_plot_coef()
Plot coefficients of an aba model summaryaba_plot_metric()
Plot metrics of an aba model summaryaba_plot_predictor_risk()
Plot predictor values versus predicted risk from fitted aba modelaba_plot_risk_density()
Plot risk density split by binary outcome classaba_plot_roc()
Plot ROC curves from an aba modelaba_predict()
Get individual predictions from a fitted aba modelaba_read()
Read an aba object from fileaba_robust()
Evaluate the robustness of an aba model to systematic and random error.aba_screen()
Create an aba screen object.aba_selection()
Run model selection on an aba model.aba_summary()
Summarise a fitted aba model.aba_write()
Write an aba object to file.adnimerge
A sample of ADNI data in long formatall_combos()
Create all possible combinations of a set of variablesall_levels()
Create groups from all levels of one or more variablesas_reactable()
Convert an aba summary to a interactive react tableas_reactable(*<abaSummary>*)
Convert an aba summary to a interactive react tableas_table()
Convert an aba summary to a nicely formatted tableas_table(*<abaSummary>*)
Convert an aba summary to a nicely formatted tableeval_boot()
Create a bootstrap evaluatoreval_cv()
Create a cross validation evaluatoreval_standard()
Create a standard evaluatoreval_traintest()
Create a train-test evaluatoreveryone()
Use all data rows as a group in an aba model.fit(*<abaModel>*)
Fit an aba model.predict(*<abaModel>*)
Get individual predictions from a fitted aba modelset_covariates()
Set the covariates of an aba model.set_data()
Set the data of an aba modelset_evals()
Set the evals of an aba modelset_groups()
Set the groups of an aba model.set_outcomes()
Set the outcomes of an aba model.set_predictors()
Set the predictors of an aba model.set_stats()
Set the stats of an aba modelstat_ancova()
Create an ancova stat object.stat_cox()
Create a glm stat object.stat_glm()
Create a glm stat object.stat_lm()
Create an lm stat object.stat_lme()
Create an lme stat object.stat_lmer()
Create an lmer stat object.stat_mmrm()
Create an mmrm stat object.stat_retest()
Create a retest stat object.stat_roc()
Create a roc stat object.theme_aba()
Custom aba ggplot2 theme最后祝大家早日不卷!~