Skip to content

Commit

Permalink
refactoring update boxplot
Browse files Browse the repository at this point in the history
  • Loading branch information
borishejblum committed Feb 2, 2024
1 parent babf5a6 commit 0b2cadf
Showing 1 changed file with 27 additions and 54 deletions.
81 changes: 27 additions & 54 deletions R/boxplot_VICI.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#'Default is \code{TRUE}.
#'@param baseline baseline value used in title when \code{inter} is \code{FALSE}.
#'Default is \code{NULL}.
#'@param fill a logical flag indicating if the boxplot is filled
#'Default if \code{FALSE}
#'
#'@return a \code{ggpubr} plot object
#'
Expand All @@ -19,75 +21,46 @@
#'@import ggpubr
#'@import RColorBrewer

boxplot_VICI <- function(data_df, pval_2plot, response_name, input, inter=TRUE, baseline=NULL){
boxplot_VICI <- function(data_df, pval_2plot, response_name, input, inter=TRUE, baseline=NULL,fill=FALSE){

if(!is.numeric(data_df$response)){
data_df$response <- as.numeric(data_df$response)
}

p <- NULL

if(inter){
data_df$arm <- relevel(data_df$arm, ref=input$selectRefArmInter)
suppressWarnings(
if(input$jiter == "None"){
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "arm", palette = "RdGy",
alpha=0.3,)+
theme_classic() +
theme(panel.grid.major.x = element_blank()) +
scale_color_brewer(palette = input$color) +
stat_pvalue_manual(data = pval_2plot, label = "pvalue_format",
tip.length = 0.025) +
ylab(paste0("Response ", response_name)) +
xlab("Stimulation") +
ggtitle(paste0("Arm effect on ", response_name),
subtitle = "p-values taking into account background response levels through bivariate modeling") +
labs(caption = "made with VICI")
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "arm",
palette = "RdGy", fill = "stim", alpha=0.3)
}else{
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "arm", palette = "RdGy",
alpha=0.3,
add="jitter",
shape = as.numeric(input$jiter))+
theme_classic() +
theme(panel.grid.major.x = element_blank()) +
scale_color_brewer(palette = input$color) +
stat_pvalue_manual(data = pval_2plot, label = "pvalue_format",
tip.length = 0.025) +
ylab(paste0("Response ", response_name)) +
xlab("Stimulation") +
ggtitle(paste0("Arm effect on ", response_name),
subtitle = "p-values taking into account background response levels through bivariate modeling") +
labs(caption = "made with VICI")
},
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "arm", palette = "RdGy",fill = "stim",
alpha=0.3, add="jitter", shape = as.numeric(input$jiter))
}
)
}else{
data_df$time <- relevel(data_df$time, ref=input$selectRefTimeIntra)

if(input$jiter == "None"){
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "time", palette = "RdGy",
alpha=0.3,) +
theme_classic() +
theme(panel.grid.major.x = element_blank()) +
scale_color_brewer(palette = input$color)+
stat_pvalue_manual(data = pval_2plot, label = "pvalue_format",
tip.length = 0.025) +
ylab(paste0("Response ", response_name)) +
xlab("Stimulation") +
ggtitle(paste0("Intra-arm vaccine effect on ", response_name, " compared to baseline ", baseline),
subtitle = "p-values taking into account background response levels through bivariate modeling") +
labs(caption = "made with VICI")
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "time", palette = "RdGy", alpha=0.3)
}else{
p <- ggboxplot(na.omit(data_df), x="stim", y="response", color= "time", palette = "RdGy",
alpha=0.3,
add="jitter",
shape = as.numeric(input$jiter))+
theme_classic() +
theme(panel.grid.major.x = element_blank()) +
scale_color_brewer(palette = input$color)+
stat_pvalue_manual(data = pval_2plot, label = "pvalue_format",
tip.length = 0.025) +
ylab(paste0("Response ", response_name)) +
xlab("Stimulation") +
ggtitle(paste0("Intra-arm vaccine effect on ", response_name, " compared to baseline ", baseline),
subtitle = "p-values taking into account background response levels through bivariate modeling") +
labs(caption = "made with VICI")
alpha=0.3, add="jitter", shape = as.numeric(input$jiter))
}
}

p <- p + theme_grey() +
theme(panel.grid.major.x = element_blank()) +
scale_color_brewer(palette = input$color) +
stat_pvalue_manual(data = pval_2plot, label = "pvalue_format", tip.length = 0.025) +
ylab(paste0("Response ", response_name)) +
xlab("Stimulation") +
ggtitle(paste0("Arm effect on ", response_name),
subtitle = "p-values taking into account background response levels through bivariate modeling") +
labs(caption = "made with VICI")

return(p)

}

0 comments on commit 0b2cadf

Please sign in to comment.