今天介绍一个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 model
aba_emmeans()
Calculated estimated marginal means.
aba_evaluate()
Evaluate a fitted aba model on new data
aba_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 object
aba_plot_coef()
Plot coefficients of an aba model summary
aba_plot_metric()
Plot metrics of an aba model summary
aba_plot_predictor_risk()
Plot predictor values versus predicted risk from fitted aba model
aba_plot_risk_density()
Plot risk density split by binary outcome class
aba_plot_roc()
Plot ROC curves from an aba model
aba_predict()
Get individual predictions from a fitted aba model
aba_read()
Read an aba object from file
aba_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 format
all_combos()
Create all possible combinations of a set of variables
all_levels()
Create groups from all levels of one or more variables
as_reactable()
Convert an aba summary to a interactive react table
as_reactable(*
*) Convert an aba summary to a interactive react table
as_table()
Convert an aba summary to a nicely formatted table
as_table(*
*) Convert an aba summary to a nicely formatted table
eval_boot()
Create a bootstrap evaluator
eval_cv()
Create a cross validation evaluator
eval_standard()
Create a standard evaluator
eval_traintest()
Create a train-test evaluator
everyone()
Use all data rows as a group in an aba model.
fit(*
*) Fit an aba model.
predict(*
*) Get individual predictions from a fitted aba model
set_covariates()
Set the covariates of an aba model.
set_data()
Set the data of an aba model
set_evals()
Set the evals of an aba model
set_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 model
stat_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
点个在看吧各位~ ✐.ɴɪᴄᴇ ᴅᴀʏ 〰
ComplexHeatmap | 颜狗写的高颜值热图代码!
ComplexHeatmap | 你的热图注释还挤在一起看不清吗!?
Google | 谷歌翻译崩了我们怎么办!?(附完美解决方案)
scRNA-seq | 吐血整理的单细胞入门教程
NetworkD3 | 让我们一起画个动态的桑基图吧~
RColorBrewer | 再多的配色也能轻松搞定!~
rms | 批量完成你的线性回归
CMplot | 完美复刻Nature上的曼哈顿图
Network | 高颜值动态网络可视化工具
boxjitter | 完美复刻Nature上的高颜值统计图
linkET | 完美解决ggcor安装失败方案(附教程)
......
本文由 mdnice 多平台发布