knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of disscat is to quantify the differences between categorical factors in single cell RNA sequencing data.
The development version of this package is available from GitHub with:
# install.packages("devtools") devtools::install_github("sbrn3/disscat")
For full tutorials on importing data, integration, normalisation, visualisation, pseudotime analysis and distance analysis have a look at the vignettes.
In this example dataset there are two groups: cells that were stimulated with interferon beta("STIM") and control cells("CTRL"). In our analysis we will be trying to quantify the differences between these two groups. Additionally there are a number of different cell types so we can look at which cell types seem to be most effected by interferon beta.
disscat is built on top of Seurat. It just needs a matrix of RNA counts for every cell and gene. Here we install an example dataset from the SeuratData package.
# Import disscat library(disscat) library(Seurat) library(SeuratData) library(ggplot2) # Download the data InstallData("ifnb") # load the data data("ifnb") # Subset ifnb ifnb <- subset(ifnb, cells = sample(x = rownames(ifnb@meta.data), size = 2000)) # View the S4 Seurat object ifnb
Normalisation and dimensionality reduction
# Normalise the data ifnb <- Seurat::NormalizeData(ifnb) # Find the variable features ifnb <- FindVariableFeatures(ifnb, selection.method = "vst", nfeatures = 2000) # Scale data ifnb <- ScaleData(ifnb, features = rownames(ifnb)) # Run PCA ifnb <- RunPCA(ifnb, npcs = 10, verbose = FALSE)
We can now calculate the distance between two groups using the average linkage distance method (UPGMA).
# Calculate Average linkage distance ifnb <- AverageDistance(ifnb, group = "stim", reduction = "pca", dims = 1:4, distance = "euclidean", split_by = "seurat_annotations")
And plot all the cell types next to each other to see which ones are most affected by the interferon treatment.
PlotAverageDistance(seurat_object = ifnb, group = "stim", group_start = "CTRL", group_destination = "STIM", split_by = "seurat_annotations", error_bars = "sd", mode = "bar", rotate_x = 45) + theme(axis.text.x = element_text(angle = 45, hjust = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.