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

seurathelpeR

Travis build status

The goal of seurathelpeR is to provide convenience functions for working with Seurat v3 objects.

Installation

You can install seurathelpeR from GitHub with:

# install.packages("devtools")
devtools::install_github("genomics-kl/seurathelpeR")

Usage

Below are some examples of how to use the functions in seurathelpeR.

library(seurathelpeR)

Count cells

Count the number of cells classified by two grouping variables and calculate percentages.

count_cells(seurat_obj = pbmc_small, group_by_var = "groups", subgroup_var = "RNA_snn_res.0.8")

Count the number of cells classified by just one grouping variable and calculate percentages.

count_cells(seurat_obj = pbmc_small, group_by_var = "groups")

Add title to Seurat plots

Seurat provides functions for many useful plots. Sometimes it is useful to add a 'title' to those plots to convey extra information.

# total number of cells in the title
add_title_ggplot(ggplot_obj = Seurat::DimPlot(pbmc_small, group.by = "RNA_snn_res.0.8", split.by = "groups"), plot_title = paste0("n=",(length(Seurat::Idents(pbmc_small)))))

# indicate how cells have been subsetted
add_title_ggplot(ggplot_obj = Seurat::DimPlot(subset(pbmc_small, subset = groups == "g1"), group.by = "RNA_snn_res.0.8"), plot_title = "Group g1")

Metrics table

It may be useful to obtain exact numbers for the standard filtering metrics as shown in the Seurat vignettes. The regex parameter can be used to parse out the cell name prefix that indicates the library; if a valid regex is provided, metrics will be calculated separately for each library. In this example, the data has no prefix so all the cells are calculated together.

seurat_fetch_dat <- Seurat::FetchData(pbmc_small, vars = c("nFeature_RNA", "nCount_RNA"))
head(rownames(seurat_fetch_dat))

table_summary_seurat(seurat_fetch_dat, "^\\S+(?=_[ACGT]+$)")


genomics-kl/seurathelpeR documentation built on Nov. 4, 2019, 1:04 p.m.