Commit d72d0476 authored by wuzekai's avatar wuzekai

update

parent 22652dec
...@@ -10,17 +10,16 @@ RUN R -e "install.packages(c('shiny', 'shinydashboard', 'remotes','readxl'), rep ...@@ -10,17 +10,16 @@ RUN R -e "install.packages(c('shiny', 'shinydashboard', 'remotes','readxl'), rep
RUN echo 'options(radiant.shinyFiles = FALSE)' >> /usr/local/lib/R/etc/Rprofile.site RUN echo 'options(radiant.shinyFiles = FALSE)' >> /usr/local/lib/R/etc/Rprofile.site
COPY . /srv/shiny-server/ COPY . /srv/shiny-server/
COPY set_path.R /usr/local/lib/R/etc/Rprofile.site.d/00-radiant-path.R COPY set_path.R /usr/local/lib/R/etc/Rprofile.site.d/00-radiant-path.R
RUN echo 'source("/srv/shiny-server/radiant.model/R/coxp.R")' >> /usr/local/lib/R/etc/Rprofile.site
# 安装所有子模块 # 安装所有模块
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.data',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.data',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.basics',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.basics',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.model',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.model',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.multivariate',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.multivariate',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.design',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.design',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant.quickgen',dependencies=TRUE, type='source', upgrade='never')" RUN R -e "remotes::install_local('/srv/shiny-server/radiant.quickgen',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
RUN R -e "remotes::install_local('/srv/shiny-server/radiant-master',dependencies=TRUE, type='source', upgrade='never',force=TRUE)"
# 安装主 radiant 应用
RUN R -e "remotes::install_local('/srv/shiny-server/radiant-master',dependencies=TRUE, type='source', upgrade='never')"
WORKDIR /data WORKDIR /data
CMD ["R", "-e", "radiant::radiant(host='0.0.0.0', port=3838)"] CMD ["R", "-e", "radiant::radiant(host='0.0.0.0', port=3838)"]
......
...@@ -137,6 +137,7 @@ Probabilities:,概率:,"goodness_ui.R,randomizer_ui.R" ...@@ -137,6 +137,7 @@ Probabilities:,概率:,"goodness_ui.R,randomizer_ui.R"
"Enter probabilities (e.g., 1/2 1/2)",输入概率(例如:1/2 1/2),"goodness_ui.R,randomizer_ui.R" "Enter probabilities (e.g., 1/2 1/2)",输入概率(例如:1/2 1/2),"goodness_ui.R,randomizer_ui.R"
Discrete,离散分布,"prob_calc_ui.R,simulater_ui.R" Discrete,离散分布,"prob_calc_ui.R,simulater_ui.R"
F,F 分布,prob_calc_ui.R F,F 分布,prob_calc_ui.R
t,t 分布,prob_calc_ui.R
Log normal,对数正态分布,"prob_calc_ui.R,simulater_ui.R" Log normal,对数正态分布,"prob_calc_ui.R,simulater_ui.R"
Poisson,泊松分布,"prob_calc_ui.R,simulater_ui.R" Poisson,泊松分布,"prob_calc_ui.R,simulater_ui.R"
Values,数值,prob_calc_ui.R Values,数值,prob_calc_ui.R
...@@ -456,7 +457,7 @@ All,全部,"view_ui.R,evalbin_ui.R, evalreg_ui.R" ...@@ -456,7 +457,7 @@ All,全部,"view_ui.R,evalbin_ui.R, evalreg_ui.R"
"Table slice {input$view_tab_slice} will be applied on Download, Store, or Report",表格切片 {input$view_tab_slice} 将应用于下载、存储或报告,view_ui.R "Table slice {input$view_tab_slice} will be applied on Download, Store, or Report",表格切片 {input$view_tab_slice} 将应用于下载、存储或报告,view_ui.R
Dataset ',数据集 ',view_ui.R Dataset ',数据集 ',view_ui.R
' was successfully added to the datasets dropdown. Add code to Report > Rmd or Report > R to (re)create the dataset by clicking the report icon on the bottom left of your screen.,' 已成功添加到数据集下拉菜单中。通过点击左下角的报告图标,在 Report > Rmd 或 Report > R 中添加代码以(重新)创建数据集。,view_ui.R ' was successfully added to the datasets dropdown. Add code to Report > Rmd or Report > R to (re)create the dataset by clicking the report icon on the bottom left of your screen.,' 已成功添加到数据集下拉菜单中。通过点击左下角的报告图标,在 Report > Rmd 或 Report > R 中添加代码以(重新)创建数据集。,view_ui.R
Distribution,分布,"visualize_ui.R,logistic_ui.R" Distribution,分布,"visualize_ui.R,logistic_ui.R"
Surface,表面图,visualize_ui.R Surface,表面图,visualize_ui.R
Line,折线图,"visualize_ui.R,regress_ui.R" Line,折线图,"visualize_ui.R,regress_ui.R"
Box-plot,箱线图,visualize_ui.R Box-plot,箱线图,visualize_ui.R
...@@ -818,7 +819,7 @@ Odds, "赔率", "logistic_ui.R" ...@@ -818,7 +819,7 @@ Odds, "赔率", "logistic_ui.R"
Correlations, "相关性", "logistic_ui.R" Correlations, "相关性", "logistic_ui.R"
Model fit, "模型拟合", "logistic_ui.R" Model fit, "模型拟合", "logistic_ui.R"
Coefficient (OR) plot, "系数(OR)图", "logistic_ui.R" Coefficient (OR) plot, "系数(OR)图", "logistic_ui.R"
Influential observations, "影响观察值", "logistic_ui.R" Influential observations, "影响点图", "logistic_ui.R"
This analysis requires a response variable with two levels and one or more explanatory variables. If these variables are not available please select another dataset.,该分析需要一个具有两个级别的响应变量以及一个或多个解释变量。如果这些变量不可用,请选择另一个数据集。, "logistic_ui.R" This analysis requires a response variable with two levels and one or more explanatory variables. If these variables are not available please select another dataset.,该分析需要一个具有两个级别的响应变量以及一个或多个解释变量。如果这些变量不可用,请选择另一个数据集。, "logistic_ui.R"
Drop intercept,去除截距项,mnl_ui.R Drop intercept,去除截距项,mnl_ui.R
RRRs,相对风险比 (RRR),mnl_ui.R RRRs,相对风险比 (RRR),mnl_ui.R
...@@ -1182,8 +1183,12 @@ Estimate class probabilities,估计类别概率,svm_ui.R ...@@ -1182,8 +1183,12 @@ Estimate class probabilities,估计类别概率,svm_ui.R
Choose Excel file:,选择Excel文件:,manage_ui.R Choose Excel file:,选择Excel文件:,manage_ui.R
Sheet index (1-based):,工作表索引(从1开始):,manage_ui.R Sheet index (1-based):,工作表索引(从1开始):,manage_ui.R
First row as header,第一行为表头,manage_ui.R First row as header,第一行为表头,manage_ui.R
Time variable:,生存时间变量:,cox_ui.R Time variable:,生存时间变量:,coxp_ui.R
Status variable:,事件状态变量:,cox_ui.R Status variable:,事件状态变量:,coxp_ui.R
AI running...,大模型运行中...,quickgen_ai_ui.R AI running...,大模型运行中...,quickgen_ai_ui.R
Warning:Please enter a request related to descriptive statistics or visualization.,警告:请输入与描述性统计或可视化相关的请求。,quickgen_ai_ui.R Warning:Please enter a request related to descriptive statistics or visualization.,警告:请输入与描述性统计或可视化相关的请求。,quickgen_ai_ui.R
Boxplot,箱型图,homo_variance_test_ui.R Boxplot,箱型图,homo_variance_test_ui.R
Survival curves,生存曲线,coxp_ui.R
Cumulative hazard,累积风险,coxp_ui.R
Schoenfeld residuals,Schoenfeld残差图,coxp_ui.R
Martingale residuals,鞅残差图,coxp_ui.R
This diff is collapsed.
...@@ -8,11 +8,11 @@ coxp_lines <- setNames(c("line", "loess", "jitter"), ...@@ -8,11 +8,11 @@ coxp_lines <- setNames(c("line", "loess", "jitter"),
c(i18n$t("Line"), i18n$t("Loess"), i18n$t("Jitter"))) c(i18n$t("Line"), i18n$t("Loess"), i18n$t("Jitter")))
coxp_plots <- setNames( coxp_plots <- setNames(
c("none", "dist", "vip", "pred_plot", "pdp", "coef", "influence"), c("none", "dist", "vip", "coef", "survival", "cumhaz", "schoenfeld", "martingale"),
c(i18n$t("None"), i18n$t("Distribution"), c(i18n$t("None"), i18n$t("Distribution"),
i18n$t("Permutation Importance"), i18n$t("Prediction plots"), i18n$t("Permutation Importance"), i18n$t("Coefficient plot"),
i18n$t("Partial Dependence"), i18n$t("Coefficient plot"), i18n$t("Survival curves"), i18n$t("Cumulative hazard"),
i18n$t("Influential observations")) i18n$t("Schoenfeld residuals"), i18n$t("Martingale residuals"))
) )
## 2. 参数收集 ------------------------------------------------------------- ## 2. 参数收集 -------------------------------------------------------------
...@@ -34,7 +34,41 @@ coxp_inputs <- reactive({ ...@@ -34,7 +34,41 @@ coxp_inputs <- reactive({
args args
}) })
coxp_plot_inputs <- reactive({ list() }) coxp_plot_inputs <- reactive({
args <- list()
# 传递用户设置的置信水平
args$conf_lev <- input$coxp_conf_lev %||% 0.95
# 1. 处理 plots 参数
if (is.empty(input$coxp_plots, "none")) {
args$plots <- character(0)
} else {
args$plots <- c(input$coxp_plots)
}
# 2. 处理 incl 参数 (用于 coef)
if (input$coxp_plots == "coef") {
args$incl <- input$coxp_incl
args$intercept <- input$coxp_intercept
}
# 3. 处理 lines 参数 (用于 martingale)
if (input$coxp_plots == "martingale") {
args$lines <- input$coxp_lines
}
# 4. 处理 nrobs 参数
if (input$coxp_plots %in% c("dist", "martingale")) {
args$nrobs <- input$coxp_nrobs
}
# 5. 添加 shiny 标志
args$shiny <- TRUE
return(args)
})
coxp_pred_inputs <- reactive({ coxp_pred_inputs <- reactive({
args <- coxp_pred_args args <- coxp_pred_args
...@@ -99,27 +133,6 @@ output$ui_coxp_incl <- renderUI({ ...@@ -99,27 +133,6 @@ output$ui_coxp_incl <- renderUI({
) )
}) })
output$ui_coxp_incl_int <- renderUI({
req(available(input$coxp_evar))
choices <- character(0)
vars <- input$coxp_evar
if (length(vars) > 1) {
choices <- iterms(vars, 2)
} else {
updateSelectInput(session, "coxp_incl_int", choices = choices, selected = choices)
return()
}
selectInput(
"coxp_incl_int",
label = i18n$t("2-way interactions to explore:"),
choices = choices,
selected = state_multiple("coxp_incl_int", choices),
multiple = TRUE,
size = min(8, length(choices)),
selectize = FALSE
)
})
## 5. 预测 / 绘图 / 刷新按钮 ---------------------------------------------- ## 5. 预测 / 绘图 / 刷新按钮 ----------------------------------------------
observeEvent(input$dataset, { observeEvent(input$dataset, {
updateSelectInput(session, "coxp_predict", selected = "none") updateSelectInput(session, "coxp_predict", selected = "none")
...@@ -187,15 +200,10 @@ output$ui_coxp <- renderUI({ ...@@ -187,15 +200,10 @@ output$ui_coxp <- renderUI({
selectInput("coxp_plots", i18n$t("Plots:"), choices = coxp_plots, selectInput("coxp_plots", i18n$t("Plots:"), choices = coxp_plots,
selected = state_single("coxp_plots", coxp_plots)), selected = state_single("coxp_plots", coxp_plots)),
conditionalPanel( conditionalPanel(
condition = "input.coxp_plots == 'coef' || input.coxp_plots == 'pdp' || input.coxp_plots == 'pred_plot'", condition = "input.coxp_plots == 'martingale'",
uiOutput("ui_coxp_incl"), checkboxGroupInput(
conditionalPanel( "coxp_lines", i18n$t("Add lines:"), coxp_lines,
condition = "input.coxp_plots == 'coef'", selected = state_group("coxp_lines", "loess")
checkboxInput("coxp_intercept", i18n$t("Include intercept"), state_init("coxp_intercept", FALSE))
),
conditionalPanel(
condition = "input.coxp_plots == 'pdp' | input.coxp_plots == 'pred_plot'",
uiOutput("ui_coxp_incl_int")
) )
) )
) )
...@@ -214,30 +222,34 @@ coxp_plot <- reactive({ ...@@ -214,30 +222,34 @@ coxp_plot <- reactive({
if (is.empty(input$coxp_plots, "none")) return() if (is.empty(input$coxp_plots, "none")) return()
plot_width <- 650 plot_width <- 650
plot_height <- 500 plot_height <- 500
nr_vars <- length(input$coxp_evar) + 1 nr_vars <- length(input$coxp_evar)
switch(input$coxp_plots,
if (input$coxp_plots == "dist") { "dist" = {
plot_height <- (plot_height / 2) * ceiling(nr_vars / 2) plot_height <- (plot_height / 2) * ceiling((nr_vars + 2) / 2) # +2 for time/status
} else if (input$coxp_plots == "dashboard") { },
plot_height <- 1.5 * plot_height "coef" = {
} else if (input$coxp_plots == "correlations") { incl <- paste0("^(", paste0(input$coxp_incl, "[|]*", collapse = "|"), ")")
plot_height <- 150 * nr_vars nr_coeff <- if (is.empty(input$coxp_incl)) nr_vars else length(input$coxp_incl)
plot_width <- 150 * nr_vars plot_height <- 300 + 20 * nr_coeff
} else if (input$coxp_plots == "coef") { },
incl <- paste0("^(", paste0(input$coxp_incl, "[|]*", collapse = "|"), ")") "vip" = {
nr_coeff <- sum(grepl(incl, .coxp()$coeff$label)) plot_height <- max(500, 30 * nr_vars)
plot_height <- 300 + 20 * nr_coeff },
} else if (input$coxp_plots %in% c("scatter", "resid_pred")) { "survival" = {
plot_height <- (plot_height / 2) * ceiling((nr_vars - 1) / 2) plot_height <- 400
} else if (input$coxp_plots == "vip") { plot_width <- 600
plot_height <- max(500, 30 * nr_vars) },
} else if (input$coxp_plots %in% c("pdp", "pred_plot")) { "cumhaz" = {
nr_vars <- length(input$coxp_incl) + length(input$coxp_incl_int) plot_height <- 400
plot_height <- max(250, ceiling(nr_vars / 2) * 250) plot_width <- 600
if (length(input$coxp_incl_int) > 0) { },
plot_width <- plot_width + min(2, length(input$coxp_incl_int)) * 90 "schoenfeld" = {
} plot_height <- 400
} },
"martingale" = {
plot_height <- 400
}
)
list(plot_width = plot_width, plot_height = plot_height) list(plot_width = plot_width, plot_height = plot_height)
}) })
...@@ -398,7 +410,7 @@ coxp_available <- reactive({ ...@@ -398,7 +410,7 @@ coxp_available <- reactive({
if (not_pressed(input$coxp_run)) return(i18n$t("** Press the Estimate button to estimate the model **")) if (not_pressed(input$coxp_run)) return(i18n$t("** Press the Estimate button to estimate the model **"))
if (is.empty(input$coxp_plots, "none")) return(i18n$t("Please select a plot from the drop-down menu")) if (is.empty(input$coxp_plots, "none")) return(i18n$t("Please select a plot from the drop-down menu"))
if (coxp_available() != "available") return(coxp_available()) if (coxp_available() != "available") return(coxp_available())
valid_plots <- c("coef", "dist", "vip", "pdp", "pred_plot", "influence") valid_plots <- c("dist", "vip", "coef", "survival", "cumhaz", "schoenfeld", "martingale")
if (!input$coxp_plots %in% valid_plots) { if (!input$coxp_plots %in% valid_plots) {
return(i18n$t("Selected plot type is not supported for Cox models.")) return(i18n$t("Selected plot type is not supported for Cox models."))
} }
...@@ -406,7 +418,7 @@ coxp_available <- reactive({ ...@@ -406,7 +418,7 @@ coxp_available <- reactive({
check_for_pdp_pred_plots("coxp") check_for_pdp_pred_plots("coxp")
} }
withProgress(message = i18n$t("Generating plots"), value = 1, { withProgress(message = i18n$t("Generating plots"), value = 1, {
do.call(plot, c(list(x = .coxp()), coxp_plot_inputs(), shiny = TRUE)) do.call(plot, c(list(x = .coxp()), coxp_plot_inputs()))
}) })
}) })
...@@ -417,7 +429,11 @@ coxp_report <- function() { ...@@ -417,7 +429,11 @@ coxp_report <- function() {
inp_out <- list(list(prn = TRUE), "") inp_out <- list(list(prn = TRUE), "")
figs <- FALSE figs <- FALSE
if (!is.empty(input$coxp_plots, "none")) { if (!is.empty(input$coxp_plots, "none")) {
inp <- check_plot_inputs(coxp_plot_inputs()) plot_inp <- coxp_plot_inputs()
if (is.null(plot_inp$plots) || length(plot_inp$plots) == 0) {
plot_inp$plots <- ""
}
inp <- check_plot_inputs(plot_inp)
inp_out[[2]] <- clean_args(inp, list()) inp_out[[2]] <- clean_args(inp, list())
inp_out[[2]]$custom <- FALSE inp_out[[2]]$custom <- FALSE
outputs <- c(outputs, "plot") outputs <- c(outputs, "plot")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment