diff --git a/DESCRIPTION b/DESCRIPTION index 01dcc80..2f49fd1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: vite Type: Package Title: Analyzing single-cell data using graphs -Version: 0.4.0 +Version: 0.4.1 Authors@R: "Pier Federico Gherardini [aut, cre]" Description: This is a package for visualization and analysis of high-dimensional single-cell data using graphs diff --git a/R/unsupervised.R b/R/unsupervised.R index fb6ab0d..f8b7ae7 100644 --- a/R/unsupervised.R +++ b/R/unsupervised.R @@ -123,6 +123,8 @@ get_unsupervised_graph <- function(tab, col.names, filtering.threshold) { #' will be processed using the \code{\link{write_clusters_data}} function. This processing is used for downstream data visualization #' but it is not strictly necessary to create the graph. If \code{use.basename} is \code{TRUE} the \code{basename} of the files in #' \code{files.list} will be used for processing. +#' @param clusters.data.out.dir Only used if \code{process.clusters.data == TRUE}. The output directory where the clusters data +#' will be written #' @param downsample.to The target number of events for downsampling. Only used if \code{process.clusters.data == TRUE}. This is only #' used for downstream data visualization and does not affect the construction of the graph #' @@ -130,7 +132,8 @@ get_unsupervised_graph <- function(tab, col.names, filtering.threshold) { #' #' @export get_unsupervised_graph_from_files <- function(files.list, col.names, filtering.threshold, - metadata.tab = NULL, metadata.filename.col = NULL, use.basename = TRUE, process.clusters.data = TRUE, downsample.to = 1000) { + metadata.tab = NULL, metadata.filename.col = NULL, use.basename = TRUE, process.clusters.data = TRUE, + clusters.data.out.dir = "./", downsample.to = 1000) { if(!is.null(metadata.tab) && c("sample", "name", "Label", "type") %in% names(metadata.tab)) stop("Metadata column names cannot include sample, name, Label or type") @@ -166,7 +169,7 @@ get_unsupervised_graph_from_files <- function(files.list, col.names, filtering.t tab <- downsample_by(tab, "cellType", downsample.to) if(use.basename) f <- basename(f) - write_clusters_data(tab, f, pooled.only = TRUE) + write_clusters_data(tab, f, output.dir = clusters.data.out.dir, pooled.only = TRUE) } } diff --git a/inst/shinyGUI/server.R b/inst/shinyGUI/server.R index 1e41e44..199ae81 100644 --- a/inst/shinyGUI/server.R +++ b/inst/shinyGUI/server.R @@ -51,7 +51,7 @@ render_scaffold_ui <- function(working.directory, ...) {renderUI({ column(6, checkboxInput("scaffoldui_transform_landmarks_data", "Transform landmarks data", value = TRUE) ), - column(6, + column(6, conditionalPanel(condition = "input.scaffoldui_transform_landmarks_data", numericInput("scaffoldui_asinh_cofactor", "Cofactor for asinh transformation", 5) ) @@ -64,7 +64,7 @@ render_scaffold_ui <- function(working.directory, ...) {renderUI({ checkboxInput("scaffoldui_inter_cluster_connections", "Add inter-cluster connections", value = TRUE), conditionalPanel( condition = "input.scaffoldui_inter_cluster_connections == true", - selectInput("scaffoldui_markers_inter_cluster", "Markers for inter-cluster connections (if different)", choices = c(""), multiple = T, width = "100%"), + selectInput("scaffoldui_markers_inter_cluster", "Markers for inter-cluster connections (if different)", choices = c(""), multiple = T, width = "100%"), numericInput("scaffoldui_inter_cluster_weight", "Weight factor for inter-cluster connections", 0.7, min = 0, max = 10, step = 0.1) ), selectInput("scaffoldui_overlap_method", "Overlap resolution method", choices = c("Repel", "Expand")), @@ -90,7 +90,7 @@ shinyServer(function(input, output, session) { observeEvent(input$unsupervisedui_select_metadata, { unsupervisedui.reactive.values$metadata.file <- file.choose() }) - + observe({ if(!is.null(input$unsupervisedui_markers_file) && input$unsupervisedui_markers_file != "") { tab <- read.table(file.path(working.directory, input$unsupervisedui_markers_file), header = TRUE, sep = "\t", check.names = FALSE) @@ -114,16 +114,17 @@ shinyServer(function(input, output, session) { files.list <- file.path(working.directory, input$unsupervisedui_files_list) metadata.tab <- NULL - + if(!is.null(input$unsupervisedui_metadata_file) && input$unsupervisedui_metadata_file != "") metadata.tab <- read.table(input$unsupervisedui_metadata_file, header = TRUE, sep = "\t", check.names = FALSE, stringsAsFactors = FALSE) - + G <- vite::get_unsupervised_graph_from_files( files.list = files.list, col.names = input$unsupervisedui_markers, filtering.threshold = input$unsupervisedui_filtering_threshold, metadata.tab = metadata.tab, - metadata.filename.col = "filename" + metadata.filename.col = "filename", + clusters.data.out.dir = working.directory ) out.name <- file.path(working.directory, sprintf("%s.graphml", input$unsupervisedui_out_name)) @@ -177,11 +178,11 @@ shinyServer(function(input, output, session) { )) files.list <- list.files(working.directory, pattern = "*.clustered.txt$", full.names = TRUE) - landmarks.data <- load_landmarks_from_dir(scaffoldui.reactive.values$landmarks.dir, + landmarks.data <- load_landmarks_from_dir(scaffoldui.reactive.values$landmarks.dir, input$scaffoldui_asinh_cofactor, input$scaffoldui_transform_landmarks_data) inter.cluster.col.names <- NULL - + if(input$scaffoldui_inter_cluster_connections) { if(length(input$scaffoldui_markers_inter_cluster) > 0) inter.cluster.col.names <- input$scaffoldui_markers_inter_cluster @@ -203,9 +204,9 @@ shinyServer(function(input, output, session) { ) - if(input$scaffoldui_ew_influence_type == "Fixed") + if(input$scaffoldui_ew_influence_type == "Fixed") args.list <- c(args.list, list(ew.influence = input$scaffoldui_ew_influence)) - + do.call(vite::run_scaffold_analysis, args.list) showModal(modalDialog( @@ -214,4 +215,4 @@ shinyServer(function(input, output, session) { )) }) }) -}) \ No newline at end of file +}) diff --git a/man/get_unsupervised_graph_from_files.Rd b/man/get_unsupervised_graph_from_files.Rd index e96eabf..662a745 100644 --- a/man/get_unsupervised_graph_from_files.Rd +++ b/man/get_unsupervised_graph_from_files.Rd @@ -6,7 +6,8 @@ \usage{ get_unsupervised_graph_from_files(files.list, col.names, filtering.threshold, metadata.tab = NULL, metadata.filename.col = NULL, use.basename = TRUE, - process.clusters.data = TRUE, downsample.to = 1000) + process.clusters.data = TRUE, clusters.data.out.dir = "./", + downsample.to = 1000) } \arguments{ \item{files.list}{The list of files to process. The function will first determine the set of columns that are common to all @@ -36,6 +37,9 @@ will be processed using the \code{\link{write_clusters_data}} function. This pro but it is not strictly necessary to create the graph. If \code{use.basename} is \code{TRUE} the \code{basename} of the files in \code{files.list} will be used for processing.} +\item{clusters.data.out.dir}{Only used if \code{process.clusters.data == TRUE}. The output directory where the clusters data +will be written} + \item{downsample.to}{The target number of events for downsampling. Only used if \code{process.clusters.data == TRUE}. This is only used for downstream data visualization and does not affect the construction of the graph} }