前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >🤔 Aba | 全自动biomarker分析神包!~(原作者用这个包发了三篇Nature啦~)

🤔 Aba | 全自动biomarker分析神包!~(原作者用这个包发了三篇Nature啦~)

作者头像
生信漫卷
发布2023-02-24 14:19:15
4170
发布2023-02-24 14:19:15
举报
文章被收录于专栏:R语言及实用科研软件

1写在前面

今天介绍一个Github上的神包吧, 主要是用于Biomarker的临床分析, 原作者用这个包已经发了3篇Nature了, 一起看看吧:👇


在一些针对Biomarker的临床研究中, 我们常常需对Biomarker进行模型拟合, 预测效果评估等等.🥰 这个包可以完美解决这些问题, 并且直接输出发表级图表, 简单介绍一下用法给大家吧.🥳

2用到的包

代码语言:javascript
复制
rm(list = ls())
#devtools::install_github("ncullen93/abaR")
library(aba)
library(tidyverse)
library(ggsci)

3示例数据

代码语言:javascript
复制
dat <- adnimerge %>% 
  dplyr::filter(VISCODE == 'bl')

DT::datatable(dat)

4变量一览

看一下都有什么变量, 都是什么类型. 🤞

代码语言:javascript
复制
str(dat)

5建立模型

5.1 原函数

大家可以通过这种方式来建立模型.

代码语言:javascript
复制
  aba_model(
   data = NULL,
   groups = NULL,
   outcomes = NULL,
   predictors = NULL,
   covariates = NULL,
   stats = NULL,
   evals = NULL,
   include_basic = TRUE
 )

5.2 pipeline形式

这里也提供了pipeline的形式来编写代码, 个人也是更倾向于这种方式, 大家试一下吧. 😏

我们在这里设定两个结局指标: ConvertedToAlzheimersCSF_ABETA_STATUS_bl.🤒 两个预测指标, 即Biomarker, PLASMA_PTAU181_blPLASMA_NFL_bl. 🤫

模型为logistic regression. 📈

代码语言:javascript
复制
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). 😘


5.3 拟合

代码语言:javascript
复制
model <- model %>% 
  fit()
model

5.4 模型数据

拟合完以后我们就获得了模型的结果, 大家可以大致看一下.🤓

代码语言:javascript
复制
model_summary <- model %>% 
  summary()

model_summary

6模型结果的可视化

这个包提供了很多可视化的参数, 可以直接将summary的结果传递给画图函数, 非常简单. 😘

6.1 coeffficients可视化

这里需要说明一下, 函数内自带的配色只有4种, 即jama, nature, lancet, none. 但是大家可以按照ggplot语法更改颜色.🤜

代码语言:javascript
复制
model_summary %>% 
  aba_plot_coef(coord_flip=T,
                palette = 'nature')

6.2 AUC可视化

看看各个模型的AUC吧.😗

代码语言:javascript
复制
model_summary %>% 
  aba_plot_metric(palette = 'nature')

6.3 ROC可视化

代码语言:javascript
复制
model_summary %>% 
  aba_plot_roc()

6.4 Risk density plot

批量出图, 大家想看哪个predictorRisk density plot就提取哪个吧. 🤪

代码语言:javascript
复制
fig <- model %>%
  aba_plot_risk_density()
fig

随便提取一个看看吧~~~😉

代码语言:javascript
复制
fig$fig[1]

7补充一下

这个包还有很多其他强大的功能, 大家可以去进一步地探索一下。😘

欢迎大家留言说一下其他强大的函数哦~


这里附上所有函数官方解释:👇

  • 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(*<abaSummary>*) Convert an aba summary to a interactive react table
  • as_table() Convert an aba summary to a nicely formatted table
  • as_table(*<abaSummary>*) 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(*<abaModel>*) Fit an aba model.
  • predict(*<abaModel>*) 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

最后祝大家早日不卷!~


本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-12-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 生信漫卷 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1写在前面
  • 2用到的包
  • 3示例数据
  • 4变量一览
  • 5建立模型
    • 5.1 原函数
      • 5.2 pipeline形式
        • 5.3 拟合
          • 5.4 模型数据
          • 6模型结果的可视化
            • 6.1 coeffficients可视化
              • 6.2 AUC可视化
                • 6.3 ROC可视化
                  • 6.4 Risk density plot
                  • 7补充一下
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档