Skip to content

Commit

Permalink
closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgherardini committed Aug 21, 2018
1 parent 90d6f01 commit eba2ec4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> [aut, cre]"
Description: This is a package to cluster single-cell flow data and generate
features that can be used for model building
Expand Down
68 changes: 39 additions & 29 deletions inst/shinyGUI/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand All @@ -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(
Expand All @@ -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")
)
)
Expand All @@ -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))
Expand All @@ -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
})
Expand All @@ -87,43 +87,53 @@ 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)

))
})
)

})
})
12 changes: 0 additions & 12 deletions man/hello.Rd

This file was deleted.

0 comments on commit eba2ec4

Please sign in to comment.