diff --git a/DESCRIPTION b/DESCRIPTION index 324c9e9..c1f7b7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: grappolo Type: Package Title: Feature generation from single-cell data -Version: 0.4.2 +Version: 0.4.3 Authors@R: "Pier Federico Gherardini [aut, cre]" Description: This is a package to cluster single-cell flow data and generate features that can be used for model building diff --git a/inst/shinyGUI/server.R b/inst/shinyGUI/server.R index 467db49..87f1c09 100644 --- a/inst/shinyGUI/server.R +++ b/inst/shinyGUI/server.R @@ -8,7 +8,7 @@ get_cluster_groups_table <- function(v, key) { tags$span(class = "glyphicon glyphicon-trash") ) )), - ifelse(length(v > 1), + ifelse(length(v > 1), tagList(lapply(tail(v, n = -1), function(x) {tags$tr(tags$td(x))})), tagList() ) @@ -24,7 +24,7 @@ render_clustering_ui <- function(working.directory, ...) {renderUI({ selectInput("clusteringui_markers", "Choose the markers for clustering", choices = c(""), multiple = T, width = "100%") ) ), - + conditionalPanel( condition = "input.clusteringui_clustering_mode == 'Pooled'", fluidRow( @@ -44,12 +44,12 @@ render_clustering_ui <- function(working.directory, ...) {renderUI({ ) ), fluidRow( - column(12, - + column(12, + numericInput("clusteringui_num_clusters", "Number of clusters", value = 200, min = 1, max = 2000), - numericInput("clusteringui_num_samples", "Number of samples (lower numbers lead to faster but less accurate results)", value = 50, min = 2), - numericInput("clusteringui_asinh_cofactor", "Cofactor for asinh transformation", value = 5), - numericInput("clusteringui_num_cores", "Number of CPU cores to use", value = 1), + numericInput("clusteringui_num_samples", "Number of samples (lower numbers lead to faster but less accurate results)", value = 50, min = 2), + numericInput("clusteringui_asinh_cofactor", "Cofactor for asinh transformation", value = 5), + numericInput("clusteringui_num_cores", "Number of CPU cores to use", value = 1), actionButton("clusteringui_start", "Start clustering") ) ) @@ -59,7 +59,7 @@ render_clustering_ui <- function(working.directory, ...) {renderUI({ shinyServer(function(input, output, session) { working.directory <- dirname(file.choose()) output$clusteringUI <- render_clustering_ui(working.directory, input, output, session) - + observe({ if(!is.null(input$clusteringui_file_for_markers) && grepl("*.fcs$", input$clusteringui_file_for_markers)) { v <- grappolo:::get_fcs_col_names(file.path(working.directory, input$clusteringui_file_for_markers)) @@ -76,7 +76,7 @@ shinyServer(function(input, output, session) { observe({ key <- input$clusteringui_remove_clustering_group$key - if(!is.null(key) && key != "") + if(!is.null(key) && key != "") isolate({ clusteringui_reactive_values$clustering_groups[key] <- NULL }) @@ -87,38 +87,48 @@ shinyServer(function(input, output, session) { clusteringui_reactive_values$clustering_groups <- c(clusteringui_reactive_values$clustering_groups, setNames(list(files_list), files_list[1]) ) - print(clusteringui_reactive_values$clustering_groups) }) - observeEvent(input$clusteringui_start, + observeEvent(input$clusteringui_start, isolate({ showModal(modalDialog( sprintf("Clustering started with markers %s ", paste(input$clusteringui_markers, collapse = " ")), br(), "please wait..." )) - + + # This calls to force are necessary because the clustering functions will spawn + # a different process, see https://github.com/rstudio/shiny/issues/2163 + + num.cores <- force(input$clusteringui_num_cores) + col.names <- force(input$clusteringui_markers) + num.clusters <- force(input$clusteringui_num_clusters) + asinh.cofactor <- force(input$clusteringui_asinh_cofactor) + num.samples <- force(input$clusteringui_num_samples) + downsample.to <- force(input$clusteringui_downsample_to) + output.dir <- force(working.directory) + if(input$clusteringui_clustering_mode == "Pooled") { input.files <- lapply(clusteringui_reactive_values$clustering_groups, function(s) {file.path(working.directory, s)}) - grappolo::cluster_fcs_files_groups(input.files, - num.cores = input$clusteringui_num_cores, - col.names = input$clusteringui_markers, - num.clusters = input$clusteringui_num_clusters, - asinh.cofactor = input$clusteringui_asinh_cofactor, - num.samples = input$clusteringui_num_samples, - downsample.to = input$clusteringui_downsample_to, - output.dir = working.directory + grappolo::cluster_fcs_files_groups(input.files, + num.cores = num.cores, + col.names = col.names, + num.clusters = num.clusters, + asinh.cofactor = asinh.cofactor, + num.samples = num.samples, + downsample.to = downsample.to, + output.dir = output.dir ) } else { - grappolo::cluster_fcs_files_in_dir(working.directory, - num.cores = input$clusteringui_num_cores, - col.names = input$clusteringui_markers, - num.clusters = input$clusteringui_num_clusters, - asinh.cofactor = input$clusteringui_asinh_cofactor, - num.samples = input$clusteringui_num_samples, - output.dir = working.directory + grappolo::cluster_fcs_files_in_dir(output.dir, + num.cores = num.cores, + col.names = col.names, + num.clusters = num.clusters, + asinh.cofactor = asinh.cofactor, + num.samples = num.samples, + output.dir = output.dir ) } - + showModal(modalDialog( sprintf("Clustering completed. The output files can be found in %s", working.directory) @@ -126,4 +136,4 @@ shinyServer(function(input, output, session) { }) ) -}) \ No newline at end of file +}) diff --git a/man/hello.Rd b/man/hello.Rd deleted file mode 100644 index 0fa7c4b..0000000 --- a/man/hello.Rd +++ /dev/null @@ -1,12 +0,0 @@ -\name{hello} -\alias{hello} -\title{Hello, World!} -\usage{ -hello() -} -\description{ -Prints 'Hello, world!'. -} -\examples{ -hello() -}