all_times <- list()  # store the time for each chunk
knitr::knit_hooks$set(time_it = local({
  now <- NULL
  function(before, options) {
    if (before) {
      now <<- Sys.time()
    } else {
      res <- difftime(Sys.time(), now, units = "secs")
      all_times[[options$label]] <<- res
    }
  }
}))
knitr::opts_chunk$set(
  tidy = TRUE,
  tidy.opts = list(width.cutoff = 95),
  message = FALSE,
  warning = FALSE,
  time_it = TRUE
)

Iterative Plotting Functions

Often times creating large numbers of plots (either as individual files or in single PDF) is part of normal workflow. This process can be simplified by creating the plots in looping functions.

scCustomize simplifies this process by allowing for the creation of many plots in multiple formats with self-contained loop functions.

Iterative functions available are:

Required Parameters

Most functions that begin with Iterate_ have shared parameters that are used to dictate file location, file name, and file type. *The exception is Iterate_PC_Loading_Plots() which is slightly different (see manual entry for more info.)

Added functionality

Iterate_FeaturePlot_scCustom() has an additional helpful feature when the list of features provided is named. See Marker Identification & Cluster Annotation Vignette.

When provided with named vector such as the output from Extract_Top_Markers() then Iterate_FeaturePlot_scCustom() can detect the names and add them either to the title of the plot (if single_pdf = TRUE) or the file names if FALSE.

Iterate_FeaturePlot_scCustom(seurat_object = pbmc, gene_list = top_5_presto, single_pdf = T)

Example plot showing the gene name and additional name of the plot.

Optional Parameters

Remaining parameters for each function are similar or identical to their non-iterative counterparts.

More Information

For more info on each functions and optional parameters check out the manual entry using ?Function_Name or browsing the Reference Manual



samuel-marsh/scCustomize documentation built on Dec. 20, 2024, 7:41 a.m.