Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly plots Design Experiments | MSstatsTMT Plotly plots adaptation for Shiny #89

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions R/module-expdes-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,54 +48,8 @@ expdesServer <- function(input, output, session,parent_session, loadpage_input,
power= power_x)
}

# plot output
designSampleSizePlots_ggplotly <- function(data) {
index <- if (length(unique(data$numSample)) > 1) {
"numSample"
} else if (length(unique(data$power)) > 1) {
"power"
} else if (length(unique(data$numSample)) == 1 & length(unique(data$power)) == 1) {
"numSample"
} else {
stop("Invalid input")
}

text.size <- 12
axis.size <- 13
lab.size <- 17

if (index == "numSample") {
p <- plot_ly(data, x = ~desiredFC, y = ~numSample, type = "scatter", mode = "lines")
p <- layout(p, xaxis = list(title = "Desired fold change"),
yaxis = list(title = "Minimal number of biological replicates"),
showlegend = TRUE,
annotations = list(text = paste("FDR is", unique(data$FDR),
"<br>Statistical power is", unique(data$power))),
font = list(size = text.size, family = "Arial"),
title = "")
}

if (index == "power") {
p <- plot_ly(data, x = ~desiredFC, y = ~power, type = "scatter", mode = "lines")
p <- layout(p, xaxis = list(title = "Desired fold change"),
yaxis = list(title = "Power"),
showlegend = TRUE,
annotations = list(text = paste("Number of replicates is", unique(data$numSample),
"<br>FDR is", unique(data$FDR))),
font = list(size = text.size, family = "Arial"),
title = "")
}

return(p)
}






output$result_plot = renderPlotly({
designSampleSizePlots_ggplotly(future_exp())
designSampleSizePlots(future_exp(), isPlotly = TRUE)
})

#download
Expand All @@ -117,4 +71,4 @@ expdesServer <- function(input, output, session,parent_session, loadpage_input,
})
})

}
}
18 changes: 9 additions & 9 deletions R/module-qc-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d
# }

if(loadpage_input()$DDA_DIA == "TMT"){

dataProcessPlotsTMT(preprocess_data(),
plot <- dataProcessPlotsTMT(preprocess_data(),
type=input$type1,
featureName = input$fname,
ylimUp = FALSE,
ylimDown = FALSE,
which.Protein = protein,
originalPlot = TRUE,
originalPlot = original,
summaryPlot = input$summ,
address = file
)

address = file, isPlotly = TRUE
)[[1]]
return(plot)

} else if (loadpage_input()$BIO == "PTM"){

Expand Down Expand Up @@ -370,8 +370,8 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d
output$showplot = renderUI({
ns<- session$ns

# TMT and PTM plotly plots are still under development
if ((loadpage_input()$DDA_DIA == "TMT") || (loadpage_input()$BIO == "PTM")) {
# PTM plotly plots are still under development
if (loadpage_input()$BIO == "PTM") {
output$theplot = renderPlot(theplot())
op <- plotOutput(ns("theplot"))
} else {
Expand Down Expand Up @@ -491,4 +491,4 @@ qcServer <- function(input, output, session,parent_session, loadpage_input,get_d
preprocessData = preprocess_data
)
)
}
}
2 changes: 1 addition & 1 deletion R/module-qc-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ qcUI <- function(id) {
# tags$br(),
# tags$h4("Calculation in progress...")),
uiOutput(ns("showplot")),
disabled(downloadButton(ns("saveplot"), "Save this plot"))
# disabled(downloadButton(ns("saveplot"), "Save this plot"))
),
tabPanel("Download Data",
#verbatimTextOutput('effect'),
Expand Down
30 changes: 16 additions & 14 deletions R/module-statmodel-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,20 @@ statmodelServer <- function(input, output, session,parent_session, loadpage_inpu

} else if(loadpage_input()$DDA_DIA=="TMT"){
tryCatch({
plot1 = MSstatsShiny::groupComparisonPlots2(data=data_comparison()$ComparisonResult,
type=input$typeplot,
sig=input$sig,
FCcutoff=input$FC,
logBase.pvalue=input$logp,
ProteinName=input$pname,
numProtein=input$nump,
clustering=input$cluster,
which.Comparison=input$whichComp,
which.Protein = input$whichProt,
address=path1(),
savePDF=pdf)
# makes use of MSstats groupComparisonPlots function
plot1 = groupComparisonPlots(data=data_comparison()$ComparisonResult,
type=input$typeplot,
sig=input$sig,
FCcutoff=input$FC,
logBase.pvalue=as.numeric(input$logp),
ProteinName=input$pname,
numProtein=input$nump,
clustering=input$cluster,
which.Comparison=input$whichComp,
which.Protein = input$whichProt,
height = input$height,
address="Ex_",
isPlotly = TRUE)[[1]]
remove_modal_spinner()
},
error = function(e){
Expand Down Expand Up @@ -715,8 +717,8 @@ statmodelServer <- function(input, output, session,parent_session, loadpage_inpu

observeEvent(input$viewresults, {
ns <- session$ns
# TMT and PTM plotly plots are still under development
if ((loadpage_input()$DDA_DIA == "TMT") || (loadpage_input()$BIO == "PTM")) {
# PTM plotly plots are still under development
if (loadpage_input()$BIO == "PTM") {
output$comp_plots = renderPlot({
group_comparison(FALSE, FALSE)
})
Expand Down