Skip to contents

Builds the conventional scSidekick analysis folder layout under base_dir and returns every created path as a named list. Replaces the usual pile of paste0() + dir.create() lines at the top of an analysis script.

The tree created is:

base_dir/
  R_Objects/                  # saved Seurat objects (.rds)
  R_Code/                     # analysis scripts
  Output/                     # all figures / tables
    <subset>/                 # one analysis branch (e.g. "All_Clusters")
      Featuremaps/            # (and any other `output_subdirs`)

Usage

GenerateDirectories(
  base_dir,
  subset = "All_Clusters",
  object_name = NULL,
  resolution = NULL,
  output_subdirs = "Featuremaps",
  extra_top = NULL,
  set_wd = FALSE,
  verbose = TRUE
)

Arguments

base_dir

Character. Project root directory. Created if absent.

subset

Character. Name of the analysis branch under Output/ (e.g. "All_Clusters", "Tcells"). Default "All_Clusters".

object_name

Character or NULL. Project label. Stored on the returned list (and used by downstream functions for file prefixes); does not affect the folder structure. Default NULL.

resolution

Numeric or NULL. Clustering resolution. Stored on the returned list for reference only. Default NULL.

output_subdirs

Character vector. Subfolders to create inside the Output/<subset>/ branch. Default "Featuremaps". Pass character(0) for none, or e.g. c("Featuremaps", "DotPlots", "Pathways").

extra_top

Character vector or NULL. Additional top-level folders to create directly under base_dir (beyond R_Objects, R_Code, Output). Default NULL.

set_wd

Logical. Set the working directory to base_dir? Default FALSE.

verbose

Logical. Message each folder as it is created? Default TRUE.

Value

Invisibly, a named list of absolute paths:

base_dir

the project root

robj_dir

base_dir/R_Objects

rcode_dir

base_dir/R_Code

output_root

base_dir/Output

output_dir

base_dir/Output/<subset> - the per-analysis branch

one entry per output_subdirs

keyed by a lower-case, snake-case version of the folder name, e.g. featuremaps

one entry per extra_top

keyed the same way

object_name, subset, resolution

echoed back for convenience

Use output_dir directly with PrepObject() or any plotting function.

Examples

if (FALSE) { # \dontrun{
dirs <- GenerateDirectories(
  base_dir    = "~/Projects/YAP_scRNAseq",
  subset      = "All_Clusters",
  object_name = "YAP project",
  resolution  = 1,
  output_subdirs = c("Featuremaps", "DotPlots", "Pathways"))

# Wire the paths straight into the rest of the workflow:
obj <- PrepObject(obj, variables = "celltype.l1",
                  output_dir = dirs$output_dir, object_name = dirs$object_name)
saveRDS(obj, file.path(dirs$robj_dir, "obj.rds"))
RunGSEA(obj, output_dir = dirs$pathways)
} # }