knitr::opts_chunk$set( collapse = TRUE, comment = "#>", # dev.args = list(png = list(type = "cairo")), dpi = 900, out.width = "100%", message = FALSE, warning = FALSE ) library(kableExtra) library(xfun) format_table <- function(mydf) { mydf %>% kableExtra::kbl() %>% kable_material() %>% scroll_box(width = "800px", height = "200px") }
First step is to load seuratTools package and all other packages required
library(seuratTools) library(Seurat) library(tidyverse) library(ggraph)
seuratTools provides a single command to:
construct Seurat objects
filter genes by minimum expression and ubiquity
normalize and scale expression by any of several methods packaged in Seurat
By default clustering will be run at ten different resolutions between 0.2 and 2.0. Any resolution can be specified by providing the resolution argument as a numeric vector.
clustered_seu <- clustering_workflow(human_gene_transcript_seu, experiment_name = "seurat_hu_trans", organism = "human" )
DimPlot(clustered_seu, group.by = "gene_snn_res.0.6")
minimalSeuratApp(clustered_seu)
We start with a gene by cell matrix of count/UMI values and a table of cell metadata
human_count[1:5, 1:5] head(human_meta)
human_count[1:10, 1:10] %>% format_table()
head(human_meta) %>% format_table()
Then using these 2 datasets we can create a Seurat object in the usual manner using the CreateSeuratObject
function
myseu <- CreateSeuratObject(human_count, assay = "gene", meta.data = human_meta) myseu
seuratTools includes a handy function to preprocess the data that handles normalization and scaling required for downstream analysis. Preprocessing is performed using existing Seurat functions. If needed, parameters can be specified by the user.
myseu <- seurat_preprocess(myseu)
This single function includes sub-functions that normalizes, identifies highly variable features and scales the data:
preprocess_seu <- NormalizeData(myseu, verbose = FALSE)
preprocess_seu <- FindVariableFeatures(preprocess_seu, selection.method = "vst", verbose = FALSE )
pre_process_seu <- ScaleData(preprocess_seu)
seuratTools also implements a standardized dimension reduction step to select variable features at a user-specified threshold and perform PCA, tSNE, and UMAP. The default assay the dimension reduction is being run on is "gene".
myseu <- seurat_reduce_dimensions(myseu, assay = "RNA") DimPlot(myseu)
This function includes existing seurat functions which performs dimension reduction techniques.
Dim_Red_seu <- RunPCA(myseu, features = VariableFeatures(myseu), do.print = FALSE )
Dim_Red_seu <- RunUMAP(Dim_Red_seu, dims = 1:30)
Clustering analysis is performed via Louvain(default) or alternative algorithms available in Seurat. Clustering is performed at a range of resolutions with default value ranging from 0.2 to 2 and pca reduction
seu <- seurat_cluster(seu = Dim_Red_seu, resolution = seq(0.2, 2, by = 0.2))
This function produces clustering analysis via two steps performed using two different sub-functions
FindNeighbours
: This function computes the nearest neighbors for a given dataset using k-nearest neighbor algorithm.
FindClusters
: The output from FindNeighbours is then used to identify clusters of cells based on clustering algorithm.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.