diff --git a/DESCRIPTION b/DESCRIPTION index bba6c24..324c9e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: grappolo Type: Package Title: Feature generation from single-cell data -Version: 0.4.1 +Version: 0.4.2 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/R/cluster.R b/R/cluster.R index 76c8e08..ec13978 100644 --- a/R/cluster.R +++ b/R/cluster.R @@ -201,10 +201,13 @@ cluster_fcs_files_in_dir <- function(wd, ...) { #' @param num.clusters The desired number of clusters #' @param asinh.cofactor Cofactor for asinh transformation. If this is \code{NULL} no transformation is performed (see \code{convert_fcs}) #' @param num.samples Number of samples to be used for the CLARA algorithm (see \code{cluster::clara}) -#' @param output.dir The directory in which all the output files (and directories) will be created +#' @param output.dir The name of the output directory, it will be created if it does not exist #' @return Returns either \code{NULL} or a \code{try-error} object if some error occurred during the computation #' @export cluster_fcs_files <- function(files.list, num.cores, col.names, num.clusters, asinh.cofactor, num.samples = 50, output.dir = ".") { + if(!dir.exists(output.dir)) + dir.create(output.dir, recursive = TRUE, showWarnings = TRUE) + parallel::mclapply(files.list, mc.cores = num.cores, mc.preschedule = FALSE, process_file, col.names = col.names, num.clusters = num.clusters, num.samples = num.samples, asinh.cofactor = asinh.cofactor, output.dir = output.dir) @@ -217,7 +220,7 @@ cluster_fcs_files <- function(files.list, num.cores, col.names, num.clusters, as #' @param files.list A named list of vectors detailing how the files should be pooled before clustering. Files in the same vector will #' be pooled together. The name of the output is going to correspond to the name of the corresponding list element. #' @param downsample.to The number of events that should be randomly sampled from each file before pooling. If this is 0, no sampling is performed -#' @param output.dir The name of the output directory +#' @param output.dir The name of the output directory, it will be created if it does not exist #' @inheritParams cluster_fcs_files #' #' @return Returns either \code{NULL} or a \code{try-error} object if some error occurred during the computation @@ -230,6 +233,9 @@ cluster_fcs_files_groups <- function(files.list, num.cores, col.names, num.clust c(x, files.list[[x]]) }) + if(!dir.exists(output.dir)) + dir.create(output.dir, recursive = TRUE, showWarnings = TRUE) + parallel::mclapply(files.list, mc.cores = num.cores, mc.preschedule = FALSE, process_files_groups, col.names = col.names, num.clusters = num.clusters, num.samples = num.samples, asinh.cofactor = asinh.cofactor, downsample.to = downsample.to, output.dir = output.dir) diff --git a/man/cluster_fcs_files.Rd b/man/cluster_fcs_files.Rd index 3500e3a..70fd802 100644 --- a/man/cluster_fcs_files.Rd +++ b/man/cluster_fcs_files.Rd @@ -20,7 +20,7 @@ cluster_fcs_files(files.list, num.cores, col.names, num.clusters, \item{num.samples}{Number of samples to be used for the CLARA algorithm (see \code{cluster::clara})} -\item{output.dir}{The directory in which all the output files (and directories) will be created} +\item{output.dir}{The name of the output directory, it will be created if it does not exist} } \value{ Returns either \code{NULL} or a \code{try-error} object if some error occurred during the computation diff --git a/man/cluster_fcs_files_groups.Rd b/man/cluster_fcs_files_groups.Rd index 1cf763f..92052b4 100644 --- a/man/cluster_fcs_files_groups.Rd +++ b/man/cluster_fcs_files_groups.Rd @@ -23,7 +23,7 @@ be pooled together. The name of the output is going to correspond to the name of \item{downsample.to}{The number of events that should be randomly sampled from each file before pooling. If this is 0, no sampling is performed} -\item{output.dir}{The name of the output directory} +\item{output.dir}{The name of the output directory, it will be created if it does not exist} } \value{ Returns either \code{NULL} or a \code{try-error} object if some error occurred during the computation diff --git a/man/cluster_fcs_files_in_dir.Rd b/man/cluster_fcs_files_in_dir.Rd index f71c2fa..8d05d8e 100644 --- a/man/cluster_fcs_files_in_dir.Rd +++ b/man/cluster_fcs_files_in_dir.Rd @@ -16,7 +16,7 @@ cluster_fcs_files_in_dir(wd, ...) \item{num.clusters}{The desired number of clusters} \item{asinh.cofactor}{Cofactor for asinh transformation. If this is \code{NULL} no transformation is performed (see \code{convert_fcs})} \item{num.samples}{Number of samples to be used for the CLARA algorithm (see \code{cluster::clara})} - \item{output.dir}{The directory in which all the output files (and directories) will be created} + \item{output.dir}{The name of the output directory, it will be created if it does not exist} }} } \value{ diff --git a/man/process_file.Rd b/man/process_file.Rd index be4c75b..b7b9be9 100644 --- a/man/process_file.Rd +++ b/man/process_file.Rd @@ -18,7 +18,7 @@ process_file(f, col.names, num.clusters, num.samples, asinh.cofactor, \item{asinh.cofactor}{Cofactor for asinh transformation. If this is \code{NULL} no transformation is performed (see \code{convert_fcs})} -\item{output.dir}{The directory in which all the output files (and directories) will be created} +\item{output.dir}{The name of the output directory, it will be created if it does not exist} } \description{ Process an individual file for clustering diff --git a/man/process_files_groups.Rd b/man/process_files_groups.Rd index 1a5e6e9..8bebd90 100644 --- a/man/process_files_groups.Rd +++ b/man/process_files_groups.Rd @@ -21,7 +21,7 @@ the remaining strings are the paths of the files that will be pooled together fo \item{downsample.to}{The number of events that should be randomly sampled from each file before pooling. If this is 0, no sampling is performed} -\item{output.dir}{The name of the output directory} +\item{output.dir}{The name of the output directory, it will be created if it does not exist} } \description{ Process a group of files for clustering