【单细胞】堆叠小提琴图展示marker基因

avatar
作者
筋斗云
阅读量:154

前面学习过单细胞marker基因常见的展示图一般有:点图,气泡图,小提琴图等。但是经常面临的问题是多个marker基因的同时展示,大多数paper使用的是气泡图,今天我们来测试怎么用小提琴图好好的展示。

测试数据,我们还是用pbmc4k和pbmc8k的测试数据。

先常规的合并,聚类降维等分析,因为只做测试,没去调参数的细节。

library(Seurat)

library(dittoSeq)

library(ggplot2)

library(harmony)

pbmc4k.data <- Read10X(data.dir = "pbmc4k/filtered_gene_bc_matrices/GRCh38/")

pbmc4k <- CreateSeuratObject(counts = pbmc4k.data, project = "PBMC4K")

pbmc4k

pbmc8k.data <- Read10X(data.dir = "pbmc8k/filtered_gene_bc_matrices/GRCh38/")

pbmc8k <- CreateSeuratObject(counts = pbmc8k.data, project = "PBMC8K")

pbmc8k

pbmc.combined <- merge(pbmc4k, y = pbmc8k, add.cell.ids = c("4K", "8K"), project = "PBMC12K")

pbmc.combined

head(colnames(pbmc.combined))

table(pbmc.combined$orig.ident)


all <- pbmc.combined

all<- NormalizeData(all, normalization.method ="LogNormalize", scale.factor =10000)

all <- FindVariableFeatures(all, selection.method ="vst", nfeatures =5000)

all.genes <- rownames(all)

all <- ScaleData(all, features = all.genes)

all <- RunPCA(all, features = VariableFeatures(object = all))

all <- RunHarmony(all, "orig.ident",assay.use="RNA")

all <- FindNeighbors(all, dims = 1:30,reduction = "harmony")

all <- FindClusters(all, resolution = 0.8)

all <- RunUMAP(all, dims = 1:30,reduction = "harmony")

all <- RunTSNE(all, dims = 1:30,reduction = "harmony")


#我们展示一些常见的marker基因。

makers <- c("MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A")


#下面是一个常规的堆叠小提琴图

VlnPlot(all,features = makers,stack=T,pt.size=0,flip = T,add.noise = T)+

theme(axis.text.y = element_blank(),

        axis.ticks.y = element_blank(),

        axis.title = element_blank(),

        axis.text.x = element_text(colour = 'black',size = 10,angle = 90),

        legend.position = 'none')

因为我们有2组不同的来源,还可以展示分组小提琴图。

VlnPlot(all, features = makers,stack=T,pt.size=0,split.by = 'orig.ident',flip = T,add.noise = T)+

theme(axis.text.y = element_blank(),

        axis.ticks.y = element_blank(),

        axis.title = element_blank(),

        axis.text.x = element_text(colour = 'black',size = 10,angle = 90),

        legend.position = 'top',

        legend.title=element_blank(),

        legend.box.background = element_blank(),

        legend.text = element_text(color="black",size=10),

        legend.spacing.x=unit(0.2,'cm'),

        legend.key.width=unit(0.4,'cm'),

        legend.key.height=unit(0.4,'cm'),

        legend.background=element_blank())

#还可以用split参数进行分半小提琴图展示:

VlnPlot(all, features = makers,stack=T,pt.size=0,flip = T,add.noise = T,split.by = 'orig.ident',split.plot = T)+

theme(axis.text.y = element_blank(),

        axis.ticks.y = element_blank(),

        axis.title = element_blank(),

        axis.text.x = element_text(colour = 'black',size = 10,angle = 90),

        legend.position = 'none')

#也可以进行改颜色,对其进行调整。

VlnPlot(all, features = makers,stack=T,pt.size=0,flip = T,add.noise = T,split.by = 'orig.ident',

        cols = c("limegreen", "navy"),

        split.plot = T)+

theme(axis.text.y = element_blank(),

        axis.ticks.y = element_blank(),

        axis.title = element_blank(),

        axis.text.x = element_text(colour = 'black',size = 10,angle = 90),

        legend.position = 'none')

    广告一刻

    为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!