jamesbang

V1

2022/12/14阅读：72主题：雁栖湖

# 🤔 Aba | 全自动biomarker分析神包！~（原作者用这个包发了三篇Nature啦~）

## 2用到的包

``rm(list = ls())#devtools::install_github("ncullen93/abaR")library(aba)library(tidyverse)library(ggsci)``

## 3示例数据

``dat <- adnimerge %>%   dplyr::filter(VISCODE == 'bl')DT::datatable(dat)``

## 4变量一览

``str(dat)``

## 5建立模型

### 5.1 原函数

``  aba_model(   data = NULL,   groups = NULL,   outcomes = NULL,   predictors = NULL,   covariates = NULL,   stats = NULL,   evals = NULL,   include_basic = TRUE )``

### 5.2 pipeline形式

``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 拟合

``model <- model %>%   fit()model``

### 5.4 模型数据

``model_summary <- model %>%   summary()model_summary``

## 6模型结果的可视化

### 6.1 coeffficients可视化

``model_summary %>%   aba_plot_coef(coord_flip=T,                palette = 'nature') ``

### 6.2 AUC可视化

``model_summary %>%   aba_plot_metric(palette = 'nature')``

### 6.3 ROC可视化

``model_summary %>%   aba_plot_roc()``

### 6.4 Risk density plot

``fig <- model %>%  aba_plot_risk_density()fig``

``fig\$fig[1]``

## 7补充一下

• `aba_adjust()`

• `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

📍 往期精彩

##### jamesbang
V1

wx🔍: Grassssss 卷起来了