if (!("ggplot2" %in% installed.packages())) {
    install.packages('ggplot2')
}
library('ggplot2')
if (!("Seurat" %in% installed.packages())) {
    install.packages('Seurat')
}
library('Seurat')
## Loading required package: SeuratObject
## Loading required package: sp
## 
## Attaching package: 'SeuratObject'
## The following objects are masked from 'package:base':
## 
##     intersect, t
if (!("devtools" %in% installed.packages())) {
    install.packages('devtools')
}
if (!("canvasXpress" %in% installed.packages())) {
    devtools::install_github('neuhausi/canvasXpress')
}
#devtools::install_local("~/git/canvas/R/canvasXpress.tar.gz", build_manual = TRUE, upgrade = "always")
library('canvasXpress')

Load data and Libraries

https://satijalab.org/seurat/articles/visualization_vignette.html

SeuratData::InstallData("pbmc3k")
## Warning: The following packages are already installed and will not be
## reinstalled: pbmc3k
library(Seurat)
library(SeuratData)
## ── Installed datasets ──────────────────────────────── SeuratData v0.2.2.9001 ──
## ✔ cbmc   3.1.4                          ✔ pbmc3k 3.1.4
## ────────────────────────────────────── Key ─────────────────────────────────────
## ✔ Dataset loaded successfully
## ❯ Dataset built with a newer version of Seurat than installed
## ❓ Unknown version of Seurat installed
library(ggplot2)
library(ggridges)
library(patchwork)
pbmc3k.final <- LoadData("pbmc3k", type = "pbmc3k.final")
## Validating object structure
## Updating object slots
## Ensuring keys are in the proper structure
## Updating matrix keys for DimReduc 'pca'
## Updating matrix keys for DimReduc 'umap'
## Warning: Assay RNA changing from Assay to Assay
## Warning: Graph RNA_nn changing from Graph to Graph
## Warning: Graph RNA_snn changing from Graph to Graph
## Warning: DimReduc pca changing from DimReduc to DimReduc
## Warning: DimReduc umap changing from DimReduc to DimReduc
## Ensuring keys are in the proper structure
## Ensuring feature names don't have underscores or pipes
## Updating slots in RNA
## Updating slots in RNA_nn
## Setting default assay of RNA_nn to RNA
## Updating slots in RNA_snn
## Setting default assay of RNA_snn to RNA
## Updating slots in pca
## Updating slots in umap
## Setting umap DimReduc to global
## Setting assay used for NormalizeData.RNA to RNA
## Setting assay used for FindVariableFeatures.RNA to RNA
## Setting assay used for ScaleData.RNA to RNA
## Setting assay used for RunPCA.RNA to RNA
## Setting assay used for JackStraw.RNA.pca to RNA
## No assay information could be found for ScoreJackStraw
## Warning: Adding a command log without an assay associated with it
## Setting assay used for FindNeighbors.RNA.pca to RNA
## No assay information could be found for FindClusters
## Warning: Adding a command log without an assay associated with it
## Setting assay used for RunUMAP.RNA.pca to RNA
## Validating object structure for Assay 'RNA'
## Validating object structure for Graph 'RNA_nn'
## Validating object structure for Graph 'RNA_snn'
## Validating object structure for DimReduc 'pca'
## Validating object structure for DimReduc 'umap'
## Object representation is consistent with the most current Seurat version
## Warning: Assay RNA changing from Assay to Assay5
pbmc3k.final$groups <- sample(c("group1", "group2"), size = ncol(pbmc3k.final), replace = TRUE)
features <- c("LYZ", "CCL5", "IL32", "PTPRCAP", "FCGR3A", "PF4")
pbmc3k.final
## An object of class Seurat 
## 13714 features across 2638 samples within 1 assay 
## Active assay: RNA (13714 features, 2000 variable features)
##  3 layers present: data, counts, scale.data
##  2 dimensional reductions calculated: pca, umap

Five visualizations of marker feature expression

Ridge plots - from ggridges. Visualize single cell expression distributions in each cluster

r = RidgePlot(pbmc3k.final, features = features, ncol = 2)
r
## Picking joint bandwidth of 0.318
## Picking joint bandwidth of 0.177
## Picking joint bandwidth of 0.161
## Picking joint bandwidth of 0.15
## Picking joint bandwidth of 0.0894
## Picking joint bandwidth of 0.0298

canvasXpress(r)
## Picking joint bandwidth of 0.318
## Picking joint bandwidth of 0.177
## Picking joint bandwidth of 0.161
## Picking joint bandwidth of 0.15
## Picking joint bandwidth of 0.0894
## Picking joint bandwidth of 0.0298