Skip to content

Commit

Permalink
Update the two shiny apps: add of theme_bw() in some plots
Browse files Browse the repository at this point in the history
  • Loading branch information
aursiber committed Dec 1, 2023
1 parent fed6244 commit 4af00f7
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 36 deletions.
47 changes: 31 additions & 16 deletions inst/DRomics-shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ server <- function(input, output, session) {

output$plotOmicData <- renderPlot({
ff <- filedata()
if(!"message"%in%names(ff))
plot(ff, range = 1e10)
if(!"message"%in%names(ff)) {
gg <- plot(ff, range = 1e10)
if(inTypeData() == 'continuousanchoringdata')
gg <- gg + ggplot2::theme_bw()
}
return(gg)
})

output$plotPCAData <- renderPlot({
if(inTypeData() != 'continuousanchoringdata') {
ff <- filedata()
PCAdataplot(ff, label = TRUE) +
ggplot2::ggtitle("Principal Component Analysis plot of omic data") +
ggplot2::theme(plot.title = element_text(face = "bold", hjust = 0.5))
ggplot2::theme(plot.title = ggplot2::element_text(face = "bold", hjust = 0.5)) +
ggplot2::theme_bw()
}
})

Expand Down Expand Up @@ -173,12 +178,14 @@ server <- function(input, output, session) {
if(input$splitby == 'none') {
bmdplotwithgradient(mybmdcalc$res, BMDtype = input$BMDtype,
BMD_log_transfo = as.logical(input$logbmd_ecdfgradient),
add.label = as.logical(input$label_ecdfgradient))
add.label = as.logical(input$label_ecdfgradient)) +
ggplot2::theme_bw()
} else {
bmdplotwithgradient(mybmdcalc$res, BMDtype = input$BMDtype,
facetby = input$splitby,
BMD_log_transfo = as.logical(input$logbmd_ecdfgradient),
add.label = as.logical(input$label_ecdfgradient))
add.label = as.logical(input$label_ecdfgradient)) +
ggplot2::theme_bw()
}

##### ecdf #####
Expand All @@ -187,13 +194,15 @@ server <- function(input, output, session) {
plottype = 'ecdf',
by = input$splitby,
hist.bins = input$histbin,
BMD_log_transfo = as.logical(input$logbmd_ecdf))
BMD_log_transfo = as.logical(input$logbmd_ecdf)) +
ggplot2::theme_bw()

} else {
plot(mybmdcalc, BMDtype = input$BMDtype,
plottype = myplottype,
by = input$splitby,
hist.bins = input$histbin)
hist.bins = input$histbin) +
ggplot2::theme_bw()
}
})

Expand Down Expand Up @@ -234,26 +243,26 @@ server <- function(input, output, session) {
if(input$splitby == 'none') {
bmdplotwithgradient(mybmdcalc$res, BMDtype = input$BMDtype,
BMD_log_transfo = as.logical(input$logbmd_ecdfgradient),
add.label = as.logical(input$label_ecdfgradient))
add.label = as.logical(input$label_ecdfgradient)) + ggplot2::theme_bw()
} else {
bmdplotwithgradient(mybmdcalc$res, BMDtype = input$BMDtype,
facetby = input$splitby,
BMD_log_transfo = as.logical(input$logbmd_ecdfgradient),
add.label = as.logical(input$label_ecdfgradient))
add.label = as.logical(input$label_ecdfgradient)) + ggplot2::theme_bw()
}

} else if(myplottype == 'ecdf') {
plot(mybmdcalc, BMDtype = input$BMDtype,
plottype = 'ecdf',
by = input$splitby,
hist.bins = input$histbin,
BMD_log_transfo = as.logical(input$logbmd_ecdf))
BMD_log_transfo = as.logical(input$logbmd_ecdf)) + ggplot2::theme_bw()

} else {
plot(mybmdcalc, BMDtype = input$BMDtype,
plottype = myplottype,
by = input$splitby,
hist.bins = input$histbin)
hist.bins = input$histbin) + ggplot2::theme_bw()

})
dev.off()
Expand Down Expand Up @@ -311,7 +320,12 @@ server <- function(input, output, session) {
paste0("continuousanchoringdata('", input$datafile_anchoring$name, "', backgrounddose = ", input$bgdose_anchoring, ", check = TRUE)")
)))),
"print(o)",
"plot(o)",
ifelse(input$typeData == 'continuousanchoringdata', "plot(o) + theme_bw()", "plot(o)"),
if(input$typeData != 'continuousanchoringdata') {
paste0("PCAdataplot(o, label = TRUE) +
ggplot2::ggtitle('Principal Component Analysis plot of omic data') +
ggplot2::theme(plot.title = ggplot2::element_text(face = 'bold', hjust = 0.5)) +
ggplot2::theme_bw()")},
"",
"# Step 2",
paste0("s <- itemselect(o, select.method = '", inSelectMethod(), "', FDR = ", inFDR(), ")"),
Expand All @@ -328,18 +342,19 @@ server <- function(input, output, session) {
if(input$plottype == 'ecdfcolorgradient') {
if(input$splitby == 'none') {
paste0("bmdplotwithgradient(r$res, BMDtype = '", input$BMDtype,
", BMD_log_transfo = ", as.logical(input$logbmd_ecdfgradient), ", add.label = ", as.logical(input$label_ecdfgradient), ")")
", BMD_log_transfo = ", as.logical(input$logbmd_ecdfgradient), ", add.label = ", as.logical(input$label_ecdfgradient),
") + ggplot2::theme_bw()")
} else {
paste0("bmdplotwithgradient(r$res, BMDtype = '", input$BMDtype,
", BMD_log_transfo = ", as.logical(input$logbmd_ecdfgradient), ", add.label = ", as.logical(input$label_ecdfgradient),
", facetby = '", input$splitby, "')")
", facetby = '", input$splitby, "') + ggplot2::theme_bw()")
}
} else if(input$plottype == 'ecdf') {
paste0("plot(r, BMDtype = '", input$BMDtype, "', plottype = 'ecdf', by = '", input$splitby, "', hist.bins = ",
input$histbin, ", BMD_log_transfo = ", as.logical(input$logbmd_ecdf), ")")
input$histbin, ", BMD_log_transfo = ", as.logical(input$logbmd_ecdf), ") + ggplot2::theme_bw()")
} else {
paste0("plot(r, BMDtype = '", input$BMDtype, "', plottype = '", input$plottype, "', by = '", input$splitby, "', hist.bins = ",
input$histbin, ")")
input$histbin, ") + ggplot2::theme_bw()")
},
paste0("plot(f, plot.type = 'dose_fitted', BMDoutput = r, BMDtype = '", input$BMDtype_plot2pdf,
"', dose_log_transfo = ", input$logbmd_plot2pdf, ")")
Expand Down
49 changes: 33 additions & 16 deletions inst/DRomicsInterpreter-shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,17 @@ server <- function(input, output, session) {
colorby = "experimental_level",
ECDF_plot = FALSE,
BMDsummary = BMDsummarysensitivityPlot(),
BMD_log_transfo = BMDlogtransfoSensitivityplot())
BMD_log_transfo = BMDlogtransfoSensitivityplot()) +
ggplot2::theme_bw()
} else {
myECDFplot <- if(orderingOnelev() == "BMDorder_onelev") {TRUE} else {FALSE}
mysensitivityplot <- DRomics::sensitivityplot(myextendedmergeddata,
BMDtype = BMDtype(),
group = mypathclasslabel,
ECDF_plot = myECDFplot,
BMDsummary = BMDsummarysensitivityPlot(),
BMD_log_transfo = BMDlogtransfoSensitivityplot())
BMD_log_transfo = BMDlogtransfoSensitivityplot()) +
ggplot2::theme_bw()
}

shinyjs::showElement('text2_step2', time = 0)
Expand All @@ -378,11 +380,13 @@ server <- function(input, output, session) {
mytrendplot <- DRomics::trendplot(myextendedmergeddata,
group = mypathclasslabel,
facetby = "experimental_level",
add.color = TRUE)
add.color = TRUE) +
ggplot2::theme_bw()
} else {
mytrendplot <- DRomics::trendplot(myextendedmergeddata,
group = mypathclasslabel,
add.color = TRUE)
add.color = TRUE) +
ggplot2::theme_bw()
}
shinyjs::showElement('text1_step2', time = 0)
output$buttonDownloadTrendplot <- downloadHandler(
Expand Down Expand Up @@ -554,15 +558,17 @@ server <- function(input, output, session) {
colorby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
} else {
mybmdplot <- DRomics::bmdplot(myextendedresforBMD$myextendedresforBMD,
facetby = myfacetbycolumnsBMDplot,
shapeby = "trend",
colorby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
}
} else {
if(input$nbLevel > 1) {
Expand All @@ -572,14 +578,17 @@ server <- function(input, output, session) {
shapeby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()

} else {
mybmdplot <- DRomics::bmdplot(myextendedresforBMD$myextendedresforBMD,
facetby = myfacetbycolumnsBMDplot,
shapeby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
}
}
} else {
Expand Down Expand Up @@ -609,14 +618,16 @@ server <- function(input, output, session) {
colorby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
} else {
mybmdplot <- DRomics::bmdplot(myextendedresforBMD$myextendedresforBMD,
facetby = myfacetbycolumnsBMDplot,
colorby = "trend",
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
}
} else {
if(input$nbLevel > 1) {
Expand All @@ -625,13 +636,15 @@ server <- function(input, output, session) {
facetby2 = myfacetbyrowsBMDplot,
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
} else {
mybmdplot <- DRomics::bmdplot(myextendedresforBMD$myextendedresforBMD,
facetby = myfacetbycolumnsBMDplot,
add.CI = addciBMDplot(),
add.label = addlabelBMDplot(),
BMD_log_transfo = BMDlogtransfoBMDplot())
BMD_log_transfo = BMDlogtransfoBMDplot()) +
ggplot2::theme_bw()
}
}
}
Expand Down Expand Up @@ -804,7 +817,8 @@ server <- function(input, output, session) {
facetby = myfacetbycolumnsCurvesplot,
facetby2 = myfacetbyrowsCurvesplot,
colorby = "trend") +
ggplot2::labs(col = "trend")
ggplot2::labs(col = "trend") +
ggplot2::theme_bw()
} else {
mycurvesplot <- DRomics::curvesplot(myextendedresforCurvesplot$myextendedresforCurvesplot,
free.y.scales = TRUE, scaling = TRUE,
Expand All @@ -814,7 +828,8 @@ server <- function(input, output, session) {
addBMD = addBMDCurvesplot(),
facetby = myfacetbycolumnsCurvesplot,
colorby = "trend") +
ggplot2::labs(col = "trend")
ggplot2::labs(col = "trend") +
ggplot2::theme_bw()
}
} else {
if(input$nbLevel > 1) {
Expand All @@ -825,15 +840,17 @@ server <- function(input, output, session) {
dose_log_transfo = doselogtransfoCurvesplot(),
addBMD = addBMDCurvesplot(),
facetby = myfacetbycolumnsCurvesplot,
facetby2 = myfacetbyrowsCurvesplot)
facetby2 = myfacetbyrowsCurvesplot) +
ggplot2::theme_bw()
} else {
mycurvesplot <- DRomics::curvesplot(myextendedresforCurvesplot$myextendedresforCurvesplot,
free.y.scales = TRUE, scaling = TRUE,
xmin = mindoseCurvesplot(),
xmax = maxDoseXScale(),
dose_log_transfo = doselogtransfoCurvesplot(),
addBMD = addBMDCurvesplot(),
facetby = myfacetbycolumnsCurvesplot)
facetby = myfacetbycolumnsCurvesplot) +
ggplot2::theme_bw()
}
}
output$buttonDownloadCurvesplot <- downloadHandler(
Expand Down
8 changes: 4 additions & 4 deletions share/todolist.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ of this modification at the launch of the package ? Ajouter un encart en haut de
1. [X] Mettre sur le share un fichier de test sur des gros jeux de données, à tester sur une VM de l'IFB de temps en temps, avec fichiers stockés ailleurs, pour le moment sur SeaFile (ML)
1. [X] Ajouter des arguments line.alpha et line.size et point.alpha à sensitivityplot
et bmdplot (ML)
1. [ ] dans les applis shiny et la vignette enlever les fonds gris avec un +theme_bw()
1. [X] dans les applis shiny et la vignette enlever les fonds gris avec un +theme_bw()
quand le theme n'est pas défini dans la fonction.
FAIT dans vignette à faire dans shiny (A)
A FAIRE dans DRomics-shiny pour les fonctions plot.continuousanchoringdata(), PCAdataplot() et plot.bmdcalc()
A FAIRE dans DRomicsInterpreter-shiny pour les fonctions sensitivityplot(), trendplot(), bmdplot() et curvesplot()
FAIT dans vignette.
FAIT dans DRomics-shiny pour les fonctions plot.continuousanchoringdata(), PCAdataplot() et plot.bmdcalc().
FAIT dans DRomicsInterpreter-shiny pour les fonctions sensitivityplot(), trendplot(), bmdplot() et curvesplot().
1. [X] Ajouter une fonction bmdfilter permettant de filtrer les sorties de DRomics notamment sur la base des résultats du bootstrap (par défaut on ne garde
que les items avec BMD et IC de la BMD définis, pour la BMD-zSD par défaut) - penser à faire de la prog défensive si les utilisateurs ne mettent pas le bootstrap, filtre possible sur autre chose.... (ML)
1. [ ] Envisager la sortie de figures en plotly, dans la vignette et dans l'appli shiny.
Expand Down

0 comments on commit 4af00f7

Please sign in to comment.