knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(dplyr) library(scmisc) set.seed(1)
You can install the release version of scmisc from Github with:
remotes::install_github("ddiez/scmisc")
This toy dataset contains 493 cells from mice in a SingleCellExperiment object.
sce
We can create some grouping variables.
sce$group1 <- sample(c("A", "B"), ncol(sce), replace = TRUE) sce$group2 <- sample(c("C", "D"), ncol(sce), replace = TRUE)
To calculate PCA we can use reduce_dim
.
sce <- reduce_dim(sce, method = "pca")
There are several plotting functions that work with Seurat and SingleCellExperiment objects.
plot_coord(sce) plot_coord(sce, color = "group1") plot_coord(sce, color = "group2")
Expand by grouping variable.
plot_coord(sce, expand = "group1") plot_coord(sce, expand = c("group1", "group2"))
The function plot_heatmap
is a wrapper around ComplexHeatmap::Heatmap
that simplifies plotting SingleCellExperiment and Seurat objects.
plot_heatmap(sce[1:20, ])
We can use ComplexHeatmap advance annotation features with the heatmap by passing them directly.
cols <- circlize::colorRamp2(c(-2, 0, 2), c("purple", "black", "yellow")) plot_heatmap(sce[1:20, ], col = cols)
plot_heatmap(sce[1:20, ], column_split = sce$group1)
For column annotations we can directly pass the variable names to use with the color specification using top_ann and top_ann_col.
col <- list(group1 = c(A = "lightgrey", B = "black"), group2 = c("C" = "limegreen", "D" = "violetred")) plot_heatmap(sce[1:20, ], column_split = sce$group1, top_ann = c("group1", "group2"), top_ann_col = col)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.