Skip to content

Commit

Permalink
Merge branch 'develop' into show_codeGeneration_process
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaSeep authored Oct 30, 2024
2 parents c69a50d + cb9095b commit b4a3534
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 34 deletions.
6 changes: 3 additions & 3 deletions docs/interface-details/pre-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ The Pre-processing tab is divided into two main sections: the side panel and the

In the side panel, you have the following options:

- **Pre-Processing Procedures**: You can select from various pre-processing procedures.

- Options: none, filterOnly, vst_DESeq, simpleCenterScaling, Scaling_0_1, log10, pareto_scaling, ln
- vst_DESeq also requires the selection of a design formula.
- **Pre-Processing Procedures**: You can select from various pre-processing procedures.
- Options: none, filterOnly, vst_DESeq, simpleCenterScaling, Scaling_0_1, log10, log2, pareto_scaling, ln
- vst_DESeq also requires the selection of a design formula.

- **Select Batch Effect Column**: Choose a batch effect if applicable. Possible choices are taken from the sample annotation columns.

Expand Down
32 changes: 16 additions & 16 deletions program/shinyApp/R/C.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ MANUALLY <- FALSE # change to TRUE, if you want to set the paths manually
if(MANUALLY){
# Adjust the path to the data file
envList <- readRDS('path/to/Data.rds')
envList <- readRDS('path/to/Data.RDS')
# Adjust the path to the utils.R file
source('path/to/utils.R')
print('Path manually set')
}else{
# if you get an error try to set paths manually
# remember to set MANUALLY <- TRUE
direcoty_of_files <- dirname(rstudioapi::getSourceEditorContext()$path)
envList <- readRDS(paste0(direcoty_of_files,'/','Data.rds'))
envList <- readRDS(paste0(direcoty_of_files,'/','Data.RDS'))
if('utils.R' %in% list.files(direcoty_of_files)){
source(file.path(direcoty_of_files,'utils.R'))
}
Expand Down Expand Up @@ -220,21 +220,21 @@ CUSTOM_THEME <<- theme_bw(base_size = 15) +
plot.title = element_text(size = 17, face = "bold") # Plot title
)



LOADING_SCREEN <<- tagList(
LOADING_SCREEN <- tagList(
div(
style = "position: relative; display: flex; justify-content: center; align-items: center;",
div(
style = "display: flex;",
img(src = "bored_panda_11.png", style = "max-width: 100%; height: auto;"),
img(src = "bored_panda_12.png", style = "max-width: 100%; height: auto;")
),
style = "position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; padding: 0; margin: 0; box-sizing: border-box; overflow: hidden; background-color: rgba(225, 225, 225, 0.5);", # Light background color
div(
style = "position: absolute; top: 20%; left: 60%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; color: white; font-size: 24px; font-weight: bold;",
spin_flower(),
span("Computing...")
style = "display: flex; flex-direction: column; align-items: center; width: auto; height: auto; padding: 20px; margin: 0; box-sizing: border-box; background-color: rgba(225, 225, 225, 0); border-radius: 10px;", # Slightly darker background behind images
# Centered Images
img(src = "bored_panda_11.png", style = "width: 50%; height: auto; object-fit: contain; margin-bottom: 10px; padding: 0;"),
img(src = "bored_panda_12.png", style = "width: 50%; height: auto; object-fit: contain; margin: 0; padding: 0;"),

# Centered Spinner and Text
div(
style = "position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; color: white; font-size: 24px; font-weight: bold;",
spin_flower(),
span("Computing...")
)
)
)
)

)
2 changes: 2 additions & 0 deletions program/shinyApp/R/Report_text_snippets.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ snippet_preprocessing <- function(
snippet <- paste0(snippet, "The base-10 logarithm of each data point was calculated. If a single zero value was present, 1 was added to all points to avoid undefined results.\n")
} else if (params$PreProcessing_Procedure == "ln") {
snippet <- paste0(snippet, "The natural logarithm of each data point was calculated. If a single zero value was present, 1 was added to all points to avoid undefined results.\n")
} else if (params$PreProcessing_Procedure == "log2") {
snippet <- paste0(snippet, "The base-2 logarithm of each data point was calculated. If a single zero value was present, 1 was added to all points to avoid undefined results.\n")
} else if (params$PreProcessing_Procedure == "pareto_scaling") {
snippet <- paste0(snippet, "The data was parteo scaled. Pareto scaling emphasizes the importance of small values by dividing each data point by the square root of its standard deviation.\n")
} else if(params$PreProcessing_Procedure == "None") {
Expand Down
2 changes: 1 addition & 1 deletion program/shinyApp/R/data_selection/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ data_selection_sidebar_panel <- sidebarPanel(
selectInput(
inputId = "omic_type_testdata",
label = "Omic Type that is uploaded",
choices = c("Transcriptomics", "Lipidomics", "Metabolomics"),
choices = c("Transcriptomics"),
selected = "",
width = "80%"
)
Expand Down
1 change: 0 additions & 1 deletion program/shinyApp/R/enrichment_analysis/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ enrichment_analysis_Server <- function(id, data, params, updates){
observeEvent(input$enrichmentGO,{
ea_reactives$ea_info <- "Enrichment is running..."
waiter <- Waiter$new(
id=ns("EnrichmentTabs"),
html = LOADING_SCREEN,
color="#70BF4F47"
)
Expand Down
2 changes: 1 addition & 1 deletion program/shinyApp/R/fun_getCodeSnippets.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ lapply(ls(pattern="violin"), get)
pca <- prcomp(
x = as.data.frame(t(assay(res_tmp$data))),
center = T,
scale. = FALSE
scale. = ifelse(par_tmp$PCA$scale_data == "Yes",T,F)
)
pcaData <- data.frame(pca$x,colData(res_tmp$data))
Expand Down
1 change: 0 additions & 1 deletion program/shinyApp/R/heatmap/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ heatmap_server <- function(id, data, params, updates){
)
req(selectedData_processed())
waiter <- Waiter$new(
id=ns("HeatmapPlot"),
html = LOADING_SCREEN,
color="#70BF4F47"
)
Expand Down
10 changes: 6 additions & 4 deletions program/shinyApp/R/pca/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ pca_Server <- function(id, data, params, row_select){
check <- check_calculations(list(
sample_selection_pca = input$sample_selection_pca,
SampleAnnotationTypes_pca = input$SampleAnnotationTypes_pca,
batch = ifelse(par_tmp[[session$token]]$BatchColumn != "NULL" && input$UseBatch == "Yes",T,F)
batch = ifelse(par_tmp[[session$token]]$BatchColumn != "NULL" && input$UseBatch == "Yes",T,F),
scale_data = input$scale_data
), "PCA")
if (check == "No Result yet"){
output$PCA_Info <- renderText("PCA computed.")
Expand All @@ -157,7 +158,6 @@ pca_Server <- function(id, data, params, row_select){
req(data$data)
req(input$Do_PCA[1] > 0)
waiter <- Waiter$new(
id="plot_panels_pca",
html = LOADING_SCREEN,
color="#70BF4F47"
)
Expand Down Expand Up @@ -200,7 +200,7 @@ pca_Server <- function(id, data, params, row_select){
pca <- prcomp(
x = as.data.frame(t(as.data.frame(assay(data2plot)))),
center = T,
scale. = FALSE
scale. = ifelse(input$scale_data == "Yes",T,F)
)
}, error = function(e){
error_modal(e)
Expand All @@ -223,7 +223,9 @@ pca_Server <- function(id, data, params, row_select){
# assign par_temp as empty list
par_tmp[[session$token]][["PCA"]] <<- list(
sample_selection_pca = input$sample_selection_pca,
SampleAnnotationTypes_pca = input$SampleAnnotationTypes_pca
SampleAnnotationTypes_pca = input$SampleAnnotationTypes_pca,
batch = ifelse(par_tmp[[session$token]]$BatchColumn != "NULL" && input$UseBatch == "Yes",T,F),
scale_data = input$scale_data
)
} else {
# otherwise read the reactive values
Expand Down
8 changes: 8 additions & 0 deletions program/shinyApp/R/pca/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ pca_sidebar_panel <- function(ns){
),
uiOutput(outputId = ns("SampleAnnotationTypes_pca_ui")),
uiOutput(outputId = ns("sample_selection_pca_ui")),
# Scale data to unit variance y/n
radioGroupButtons(
inputId = ns("scale_data"),
label = "Scale data to unit variance?",
choices = c("Yes","No"),
direction = "horizontal",
selected = "No"
),
### start pca ---
actionButton(
inputId = ns("Do_PCA"),
Expand Down
1 change: 1 addition & 0 deletions program/shinyApp/R/pre_processing/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pre_processing_sidebar_panel <- sidebarPanel(
"centering to 0 and scaling" = "simpleCenterScaling",
"scaling values to be within 0 and 1" = "Scaling_0_1",
"log10" = "log10",
"log2" = "log2",
"Pareto scaling (mean-centered and scaled by the square root of the standard deviation)" = "pareto_scaling",
"natural logarithm" = "ln"
),
Expand Down
15 changes: 13 additions & 2 deletions program/shinyApp/R/pre_processing/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ preprocessing <- function(data, omic_type, procedure){
if(procedure %in% c("Scaling_0_1", "pareto_scaling")){
return(scaling_normalisation(data, omic_type, procedure))
}
if(procedure %in% c("log10", "ln")){
if(procedure %in% c("log10", "ln", "log2")){
return(ln_normalisation(data, omic_type, procedure))
}
if(procedure == "none"){
Expand Down Expand Up @@ -72,7 +72,18 @@ scaling_normalisation <- function(data, omic_type, scaling_procedure){

ln_normalisation <- function(data, omic_type, logarithm_procedure){
# Center and scale the data
logarithm <- ifelse(logarithm_procedure == "log10", log10, log)
if(logarithm_procedure == "log10")
{
logarithm = log10
}
else if(logarithm_procedure == "log2")
{
logarithm = log2
}
else
{
logarithm = log
}
# prefilter the data
data <- prefiltering(data, omic_type)
# log the data and always add 1 to avoid -Inf
Expand Down
1 change: 0 additions & 1 deletion program/shinyApp/R/sample_correlation/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ sample_correlation_server <- function(id, data, params){
req(input$SampleAnnotationChoice)
req(input$Do_SampleCorrelation > 0)
waiter <- Waiter$new(
id=ns("SampleCorrelationPlot"),
html = LOADING_SCREEN,
color="#A208BA35"
)
Expand Down
1 change: 0 additions & 1 deletion program/shinyApp/R/significance_analysis/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ significance_analysis_server <- function(id, data, params){
observeEvent(sig_ana_reactive$start_analysis,{
req(sig_ana_reactive$start_analysis > 0)
waiter <- Waiter$new(
id=ns("significance_analysis_results"),
html = LOADING_SCREEN,
color="#70BF4F47",
hide_on_render=F
Expand Down
8 changes: 7 additions & 1 deletion program/shinyApp/helpfiles/PreProcessing_Procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@
- Special consideration is given to handling zero values to avoid undefined
results: If any zero values are present, +1 is added to all values before applying
the logarithm.


- **Logarithm Base 2 (log2):**
- The base-2 logarithm of each data point is calculated.
- Special consideration is given to handling zero values to avoid undefined
results: If any zero values are present, +1 is added to all values before applying
the logarithm.

- **Pareto Scaling:**
- Pareto scaling emphasizes the importance of small values by dividing each data point by the square root of its standard deviation.
- This method is suitable for datasets with a wide range of values.
Expand Down
12 changes: 10 additions & 2 deletions program/shinyApp/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,18 @@ server <- function(input,output,session){
)){
output$debug <- renderText("The Upload has failed, or you haven't uploaded anything yet")
} else if (uploaded_from() == "testdata"){
show_toast(
title = paste(par_tmp[[session$token]]['omic_type'],"Example Upload"),
text = paste(par_tmp[[session$token]]['omic_type'],"- Example upload was successful"),
position = "top",
timer = 1500,
timerProgressBar = T
)
output$debug <- renderText({"The Test Data Set was used"})
} else {
show_toast(
title = paste(par_tmp[[session$token]]['omic_type'],"Data Upload"),
text = paste(par_tmp[[session$token]]['omic_type'],"-data upload was successful"),
text = paste(par_tmp[[session$token]]['omic_type'],"- data upload was successful"),
position = "top",
timer = 1500,
timerProgressBar = T
Expand Down Expand Up @@ -528,6 +535,7 @@ server <- function(input,output,session){

}
showTab(inputId = "tabsetPanel1", target = "Pre-processing")

}
})

Expand Down Expand Up @@ -680,7 +688,6 @@ server <- function(input,output,session){
"Number. of anno options annotation_rows lost: ",
nrow(res_tmp[[session$token]]$data_original) - nrow(res_tmp[[session$token]]$data)
))

return("DataUploadSuccesful")
})
#data_input_shiny = is the res object now which is global => not needed ?!
Expand Down Expand Up @@ -910,6 +917,7 @@ server <- function(input,output,session){
html = LOADING_SCREEN,
color = "#3897F147",
hide_on_render = FALSE

)
waiter$show()
print("Do Preprocessing")
Expand Down

0 comments on commit b4a3534

Please sign in to comment.