SectorPlot {ggsector} | R Documentation |
Draw sector for seurat object
Description
A better alternative to Seurat::DotPlot()
.
For more details, please type vignette("ggsector")
.
Usage
SectorPlot(
object,
features,
features.level,
assay,
slot = c("data", "scale.data", "counts"),
group.by,
group.level,
split.by,
split.level,
col_low = "blue",
col_mid = "white",
col_high = "red",
col_midpoint,
...
)
Arguments
object |
Seurat object |
features |
Input vector of genes list. |
features.level |
Levels of genes list. |
assay |
Specific assay to get data from or set data for; defaults to the default assay. |
slot |
Specific assay data to get or set. |
group.by |
Column of metadata to group the cells by, default is Idents(). |
group.level |
Levels of group. |
split.by |
Column of metadata to split the cells by, default is NULL. |
split.level |
Levels of split vars. |
col_low |
Colours for low ends of the gradient. |
col_mid |
Colour for mid point. |
col_high |
Colours for high ends of the gradient. |
col_midpoint |
The midpoint (in data value) of the diverging scale. |
... |
Other arguments for |
Value
ggplot
Examples
## Download pbmc data from
# https://cf.10xgenomics.com/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz
library(Seurat)
path <- paste0(tempdir(), "/pbmc3k.tar.gz")
file <- paste0(tempdir(), "/filtered_gene_bc_matrices/hg19")
download.file(
"https://cf.10xgenomics.com/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz",
path
)
untar(path, exdir = tempdir())
pbmc.data <- Read10X(data.dir = file)
pbmc <- CreateSeuratObject(
counts = pbmc.data,
project = "pbmc3k",
min.cells = 3,
min.features = 200
)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
pbmc <- ScaleData(pbmc, features = rownames(pbmc))
pbmc <- RunPCA(pbmc)
pbmc <- RunUMAP(pbmc, dim = 1:10)
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 1)
pbmc <- FindClusters(pbmc, resolution = 0.5)
markers <- tibble::tribble(
~type, ~marker,
"Naive CD4+ T", "IL7R,CCR7",
"CD14+ Mono", "CD14,LYZ",
"Memory CD4+", "IL7R,S100A4",
"B", "MS4A1",
"CD8+ T", "CD8A",
"FCGR3A+ Mono", "FCGR3A,MS4A7",
"NK", "GNLY,NKG7",
"DC", "FCER1A,CST3",
"Platelet", "PPBP",
) %>%
tidyr::separate_rows(marker, sep = ", *") %>%
dplyr::distinct()
# Dotplot
DotPlot(pbmc, features = unique(markers$marker)) + coord_flip()
# contrast with DotPlot
SectorPlot(pbmc, markers$marker, features.level = unique(rev(markers$marker)))
SectorPlot(pbmc, markers$marker, group.by = "RNA_snn_res.1")
# split plot
# Assume a variable 'day', expressed as the number of days of cell development.
set.seed(1)
pbmc[["day"]] <- sample(1:3, ncol(pbmc), TRUE)
SectorPlot(pbmc, markers$marker, group.by = "RNA_snn_res.0.5", split.by = "day")
SectorPlot(
pbmc, markers$marker,
group.by = "day", split.by = "RNA_snn_res.0.5", nrow = 1
)
[Package ggsector version 1.6.6 Index]