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
)

Misc Functions

scCustomize has a number of other functions which users may find helpful or can adapt for their own uses.

# Load Packages
library(ggplot2)
library(dplyr)
library(magrittr)
library(patchwork)
library(Seurat)
library(scCustomize)

Project Organization

In addition to aiding reproducibility through use of functions and reducing copy-paste errors scCustomize also contains function to aid in project setup which can be highly beneficial.

The function Setup_scRNAseq_Project() project serves as example for how to setup reproducible project structure just using R (although could be similarly achieved using shell script) but this way makes it very easy to use with RStudio Projects workflow. For more info on RStudio Project-oriented workflow see excellent overviews from Jennifer Bryan and Jim Hester's: What They Forgot to Teach You About R and RStudio Team

Basic use

The function is very simple with just simple function call that requires no additional parameters:

Setup_scRNAseq_Project()

This function will then create the following directory structure inside the working directory:

Working_Directory
├── 01_scripts
├── 02_raw_data
├── 03_meta_data
├── 04_data_objects
├── 05_plots
│   └── 01_QC_plots
│   └── 02_Round01_plots
│   └── 03_Round02_plots
├── 06_cluster_annotation
├── 07_csv_outputs
├── 08_final_plots_for_figures

Optional Parameters

Adapting Function Yourself

This function is the basic setup that I use for most projects but everyone has their own style. Instead of requiring you to call custom_dir_file every time I hope that this function might serve as example that users can modify defaults and implement in their own workflows. The function code is very simple to modify to any desired structure.

NOTE: If you do modify for you our own please remember to attribute code to scCustomize package and cite appropriately.



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