knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of seurathelpeR is to provide convenience functions for working with Seurat v3 objects.
You can install seurathelpeR from GitHub with:
# install.packages("devtools") devtools::install_github("genomics-kl/seurathelpeR")
Below are some examples of how to use the functions in seurathelpeR.
library(seurathelpeR)
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")
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")
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]+$)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.