Skip to content

Commit

Permalink
create output directory if it does not exist already
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgherardini committed Jul 27, 2018
1 parent 49648a0 commit 90d6f01
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 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.1
Version: 0.4.2
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
10 changes: 8 additions & 2 deletions R/cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion man/cluster_fcs_files.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cluster_fcs_files_groups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cluster_fcs_files_in_dir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/process_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/process_files_groups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 90d6f01

Please sign in to comment.