From 766cf52f2aa3dfbe09977939269fbaee283f9ac5 Mon Sep 17 00:00:00 2001 From: Lea Seep <74967328+LeaSeep@users.noreply.github.com> Date: Fri, 25 Nov 2022 09:20:06 +0100 Subject: [PATCH] Fix 3 matrices data input Upload bug (#78) * Fix gather again (#76) * hot fix * load tidyr package for gather fucntion * fixed data Upload bug; added data upload name check NEEDS to be in main! * removed forgotten browser statment Co-authored-by: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com> --- program/shinyApp/R/pca/server.R | 2 +- program/shinyApp/server.R | 35 ++++++++++++++++++++++++--------- program/shinyApp/ui.R | 1 + 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/program/shinyApp/R/pca/server.R b/program/shinyApp/R/pca/server.R index 2a123800..30d7929d 100644 --- a/program/shinyApp/R/pca/server.R +++ b/program/shinyApp/R/pca/server.R @@ -526,7 +526,7 @@ pca_Server <- function(id, omic_type, row_select){ entitiesToInclude <- apply(df_loadings_filtered, 1, any) df_loadings <- df_loadings[entitiesToInclude,] %>% - gather(key = "PC", value = "loading", -entity) + tidyr::gather(key = "PC", value = "loading", -entity) global_max <- max(df_loadings$loading) global_min <- -global_max diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index e2d7434c..1c62a644 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -230,8 +230,14 @@ server <- function(input,output,session){ file = input$data_matrix1$datapath, header = T, row.names = 1, - check.names = F + check.names = T ) + Matrix2 <- read.csv( + file = input$data_matrix1$datapath, + header = T, + row.names = 1, + check.names = F + ) output$DataMatrix_VI <- DT::renderDataTable({ DT::datatable(data = Matrix) }) @@ -271,11 +277,12 @@ server <- function(input,output,session){ " }) - check1 <- ifelse(all(rownames(Matrix)==rownames(annotation_rows)),snippetYes,snippetNo) - check2 <- ifelse(all(colnames(Matrix)==rownames(sample_table)),snippetYes,snippetNo) - check3 <- ifelse(any(is.na(Matrix)==T),snippetNo,snippetYes) - check4 <- ifelse(any(is.na(sample_table)==T),snippetNo,snippetYes) - check5 <- ifelse(any(is.na(annotation_rows)==T),snippetNo,snippetYes) + check1 <- ifelse(all(rownames(Matrix) == rownames(annotation_rows)),snippetYes,snippetNo) + check2 <- ifelse(all(colnames(Matrix) == rownames(sample_table)),snippetYes,snippetNo) + check3 <- ifelse(any(is.na(Matrix) == T),snippetNo,snippetYes) + check4 <- ifelse(any(is.na(sample_table) == T),snippetNo,snippetYes) + check5 <- ifelse(any(is.na(annotation_rows) == T),snippetNo,snippetYes) + check6 <- ifelse(all(colnames(Matrix2) == colnames(Matrix)),snippetYes,snippetNo) if(check5 == snippetNo){ # Indicate columns with NA @@ -288,6 +295,15 @@ server <- function(input,output,session){ check5 <- paste0(snippetNo," Following columns are potentially problematic: ",paste0(colsWithNa, collapse = ", ")) } + if(check6 == snippetNo){ + # add help text + check6 <- paste0( + snippetNo, + "\n\t A syntactically valid name consists of letters, numbers and the dot or underline characters \n + and starts with a letter or the dot not followed by a number.\n + Therefore '12345' is invalid, 'ID_12345' is valid \n + Remember to change the Sample ID everywhere (Matrix & Sample Table") + } output$OverallChecks <- renderText({ paste0("Some overall Checks are running run ...\n Rownames of Matrix are the same as rownames of entitie table ",check1,"\n @@ -295,6 +311,7 @@ server <- function(input,output,session){ Matrix has no na ",check3,"\n Sample table no na ",check4,"\n Entitie table no na ",check5,"\n + Sample IDs have valid names ", check6, "\n ") }) } @@ -362,19 +379,19 @@ server <- function(input,output,session){ if(isTruthy(input$data_sample_anno1)){ data_input[[input$omicType]] <- list( type=as.character(input$omicType), - Matrix=read.csv( + Matrix = read.csv( file = input$data_matrix1$datapath, header = T, row.names = 1, check.names = F ), - sample_table <- read.csv( + sample_table = read.csv( file = input$data_sample_anno1$datapath, header = T, row.names = 1, check.names = F ), - annotation_rows <- read.csv( + annotation_rows = read.csv( file = input$data_row_anno1$datapath, header = T, row.names = 1, diff --git a/program/shinyApp/ui.R b/program/shinyApp/ui.R index 25ee0d99..9af7adbd 100644 --- a/program/shinyApp/ui.R +++ b/program/shinyApp/ui.R @@ -34,6 +34,7 @@ library(zip) library(cicerone) library(shinyalert) library(msigdbr) +library(tidyr) # library(svglite) source("R/C.R")