From 414e0c1f99bdb99915a47b2c2d908412b136e242 Mon Sep 17 00:00:00 2001 From: Bernd Jagla Date: Wed, 10 Apr 2024 16:02:28 +0200 Subject: [PATCH] allow more levels --- DESCRIPTION | 2 +- inst/app/outputs.R | 9 ++++++++- inst/app/reactives.R | 25 ++++++++++++++++++------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 27fb45bd..a10993b4 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: SCHNAPPs Type: Package Title: Single Cell Shiny Application for Analysing Single Cell Transcriptomics Data -Version: 1.15.15 +Version: 1.15.16 Authors@R: c(person("Bernd", "Jagla", role = c("aut", "cre"), email = "bernd.jagla@pasteur.fr", comment = c(ORCID = "0000-0002-7696-0484"))) Maintainer: Bernd Jagla Description: Single Cell sHiny APPlication (SCHNAPPs) is a R/Shiny based application to interact, manipulate, explore, and analyze single cell RNA-seq experiments, including MARS-seq and others. diff --git a/inst/app/outputs.R b/inst/app/outputs.R index 8683bc64..a350e926 100644 --- a/inst/app/outputs.R +++ b/inst/app/outputs.R @@ -811,7 +811,14 @@ output$ColorSelection <- renderUI({ # where and how to store the colors tabs= lapply(names(projections), FUN = function(name){ if(is.factor(projections[,name])){ - if(length(levels(projections[,name]))>30) return(NULL) + if(length(levels(projections[,name]))>100) { + showNotification( + paste(name," has more than 100 levels\n"), + type = "error", + duration = NULL + ) + return(NULL) + } return(tmpFun(name = name, value = paste0(name, "ColorPanel"), lev = levels(projections[,name]), idStr = paste0(name, ".col."), sampCol = defaultValue(paste0(name, ".colVec"), allowedColors[seq(levels(projections[,name]))]), allowedColors = allowedColors) diff --git a/inst/app/reactives.R b/inst/app/reactives.R index ae66c09d..42a92d6d 100644 --- a/inst/app/reactives.R +++ b/inst/app/reactives.R @@ -406,7 +406,7 @@ inputDataFunc <- function(inFile) { if (.schnappsEnv$DEBUGSAVE) { save(file = "~/SCHNAPPsDebug/readInp.RData", list = c(ls())) } - # load(file='~/SCHNAPPsDebug/readInp.RData') + # cp =load(file='~/SCHNAPPsDebug/readInp.RData') #' save orginial data @@ -3658,13 +3658,18 @@ inputSample <- reactive({ if (.schnappsEnv$DEBUGSAVE) { save(file = "~/SCHNAPPsDebug/inputSample.RData", list = c(ls())) } - # load(file='~/SCHNAPPsDebug/inputSample.RData') - + # cp=load(file='~/SCHNAPPsDebug/inputSample.RData') + if(!"sampleNames" %in% colnames(colData(scEx))){ + if (!is.null(getDefaultReactiveDomain())) { + showNotification("no sampleNames in colData(scEx)", id = "inputSampleErr", duration = NULL) + return(NULL) + } + } # TODO should come from sampleInfo - sampInf <- gsub(".*-(.*)", "\\1", scEx$barcode) + # sampInf <- gsub(".*-(.*)", "\\1", scEx$barcode) cellIds <- data.frame( cellName = colnames(scEx), - sample = sampInf, + sample = colData(scEx)$sampleNames, # number of genes per cell ngenes = Matrix::colSums(assays(scEx)[[1]]>0), nUMI = Matrix::colSums(assays(scEx)[[1]]) @@ -3707,12 +3712,18 @@ inputSampleOrg <- reactive({ save(file = "~/SCHNAPPsDebug/inputSample.RData", list = c(ls())) } # load(file='~/SCHNAPPsDebug/inputSample.RData') + if(!"sampleNames" %in% colnames(colData(scEx))){ + if (!is.null(getDefaultReactiveDomain())) { + showNotification("no sampleNames in colData(scEx)", id = "inputSampleErr", duration = NULL) + return(NULL) + } + } # TODO should come from sampleInfo - sampInf <- gsub(".*-(.*)", "\\1", dataTables$scEx$barcode) + # sampInf <- gsub(".*-(.*)", "\\1", dataTables$scEx$barcode) cellIds <- data.frame( cellName = colnames(dataTables$scEx), - sample = sampInf, + sample = colData(dataTables$scEx)$sampleNames, # number of genes per cell ngenes = Matrix::colSums(assays(dataTables$scEx)[[1]]>0), nUMI = Matrix::colSums(assays(dataTables$scEx)[[1]])