From a070f465dbb9b915df8caafc3e955baaefd0cc92 Mon Sep 17 00:00:00 2001
From: Lea Seep <74967328+LeaSeep@users.noreply.github.com>
Date: Thu, 19 Dec 2024 14:17:46 +0100
Subject: [PATCH] fixed to work with SumExp #404 (#425)
---
program/shinyApp/server.R | 65 ++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 5 deletions(-)
diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R
index f064bfac..2964d4d3 100644
--- a/program/shinyApp/server.R
+++ b/program/shinyApp/server.R
@@ -1096,13 +1096,68 @@ server <- function(input,output,session){
} else if(uploaded_from() == "precompiled"){
+ # Expand to work with any SummarizedExperiment object
+ # (also works with an 'old' pre-compiled object generated by the app)
uploadedFile <- readRDS(file = input$data_preDone$datapath)
- if(any(names(uploadedFile) %in% input[[paste0("omic_type_", uploaded_from())]])){
- # This is a file precompiled before 14.March.2023
- data_input <- uploadedFile[[input[[paste0("omic_type_", uploaded_from())]]]]
- } else {
- data_input[[paste0(input[[paste0("omic_type_", uploaded_from())]],"_SumExp")]] <- uploadedFile
+ # Check if the object is a SummarizedExperiment
+ if (is(uploadedFile, "SummarizedExperiment")) {
+ # a SE object - only esnure that naming of the obeject list fits or re-do
+ data_input[[paste0(omic_type(),"_SumExp")]] <- uploadedFile
+ count_matrix <- assay(data_input[[paste0(omic_type(),"_SumExp")]])
+ if (any(is.na(count_matrix))){
+ output$debug <- renderText({
+ "The assay data contains missing values, those will be removed."
+ })
+ }else{
+ if (any(count_matrix < 0)) {
+ output$debug <- renderText({
+ "The assay data contains negative values, which are invalid for some pre-processing procedures."
+ })
+ }
+ if (!all(count_matrix == round(count_matrix))) {
+ output$debug <- renderText({
+ "The assay data contains non-integer values, which is invalid for DESeq2 pre-processing procedure."
+ })
+ }
+ }
+ } else if(is.list(uploadedFile) & any(sapply(uploadedFile, function(x) is(x, "SummarizedExperiment")))){
+ # get the sum exp from the list
+ getIdxOfSumExp <- sapply(uploadedFile, function(x) is(x, "SummarizedExperiment"))
+ if(length(which(getIdxOfSumExp)) > 1){
+ output$debug <- renderText({
+ "Upload failed. The provided input contains more than one Summarized Experiment object. Please only provide one"
+ return(NULL)
+ })
+ }else{
+ data_input[[paste0(omic_type(),"_SumExp")]] <- uploadedFile[[which(getIdxOfSumExp)]]
+ count_matrix <- assay(data_input[[paste0(omic_type(),"_SumExp")]])
+ if (any(is.na(count_matrix))){
+ output$debug <- renderText({
+ "The assay data contains missing values, those will be removed."
+ })
+ }else{
+ if (any(count_matrix < 0)) {
+ output$debug <- renderText({
+ "The assay data contains negative values, which are invalid for some pre-processing procedures."
+ })
+ }
+ if (!all(count_matrix == round(count_matrix))) {
+ output$debug <- renderText({
+ "The assay data contains non-integer values, which is invalid for DESeq2 pre-processing procedure."
+ })
+ }
+ }
+
+ }
+ }else{
+ # not a SE object
+ output$debug <- renderText({
+ "Upload failed. Is the provided input Summarized Experiment object?"
+ })
+ return(NULL)
}
+
+
} else if(uploaded_from() == "testdata"){
data_input <- readRDS(
file = "www/Transcriptomics_only_precompiled-LS.RDS"