knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  fig.align = "center",
  out.width = "75%"
)

scbp

R build status

scbp is a collection of utility functions for single cell analyses. Mostly plotting and thin wrapper functions extending Seurat utilities.

Installation

remotes::install_github("rnabioco/scbp")

plotting

library(scbp)
library(Seurat)

so <- get_example_data()

plot_tsne(so, c("groups", "CST3"))
plot_tsne(so, c("groups", "CST3"), group = "letter.idents")
plot_tsne(so, "RNA_snn_res.1",
          label_text = TRUE, # show group labels 
          minimal_theme = TRUE, # no axes or legend
          .cols = palette_OkabeIto) # use other colors

Wrappers for common projections:

plot_feature() plot_umap() plot_pca() plot_tsne() plot_harmony()

Generate heatmaps with annotations for meta.data variables (or plot average per group).

genes <- VariableFeatures(so)

plot_heatmap(so, 
             features = genes,
             group = "RNA_snn_res.1",
             annotations = c("nCount_RNA", "letter.idents"),
             average = FALSE)
genes <- VariableFeatures(so)

plot_heatmap(so, 
             features = genes,
             group = "RNA_snn_res.1",
             annotations = c("nCount_RNA", "letter.idents"),
             average = TRUE)

Make violin plots

 plot_violins(so, 
              group = "RNA_snn_res.1", 
              features = VariableFeatures(so)[1:10],
              split_by = "groups")

Summarizing functions

get_metadata(so)
plot_cell_proportions(so, 
                      "groups",
                      "RNA_snn_res.1")
plot_cell_proportions(so, 
                      "groups",
                      "RNA_snn_res.1", 
                      facet_by = "letter.idents")
plot_cell_proportions(so, 
                      "groups",
                      "RNA_snn_res.1",
                      facet_by = "letter.idents",
                      summary_boxplot = TRUE)
so <- calc_diversity(so,
               sample_id = "letter.idents",
               group_id = "RNA_snn_res.1") 

plot_tsne(so, "entropy")

UCSC cellbrowser utils

Wrappers around UCSC cellbrowser generation routines. Uses data.table fwrite to speed up generating files.

make_cellbrowser(so, 
                 column_list = c("orig.ident", "groups"),
                 project = "pbmcs",
                 primary_color_palette = RColorbrewer::brewer.pal("Paired"),
                 secondary_color_palette = scbp::palette_OkabeIto,
                 secondary_cols = "groups",
                 outdir = "cell_browser",
                 marker_file = "path/to/presto_or_seurat_marker_file.tsv",
                 ident = "groups",
                 embeddings = c("pca"),
                 config = list(priority = 4,   # options for cellbrowser.conf
                               radius = 5,
                               tags = "10x"),
                 description = list(    # options for summary.html
                   title = "Example cellbrowser",
                   description = "An informative description of this dataset"
)

build_cellbrowser(dataset_paths = "pbmcs/cell_browser/cellbrowser.conf",
                  outdir = file.path(cb_outdir, "pbmc_browser"))

Others

preprocess_bustools read in bustools output and process with DropletUtils::emptyDrops()

plot_bc() plot barcode distribution generated by DropletUtils::barcodeRanks()



rnabioco/scbp documentation built on July 7, 2023, 10:10 p.m.