dittoSeq 是一款對單細胞和批量 RNA 測序數據進行分析和可視化的工具,提供了多種可視化效果,并且允許自定義超陆。
對于單細胞數據,dittoSeq 直接處理在其他軟件包(Seurat浦马、scater时呀、scran 等)中預處理的數據。對于批量 RNAseq 數據晶默,dittoSeq 的導入函數會將各種不同結構的批量 RNAseq 數據轉換為 dittoSeq 幫助程序和可視化函數可以使用的集合結構
1.
數據
dittoSeq 本身可與 Seurat 和 SingleCellExperiment 對象配合使用谨娜,只需加載數據即可
# 安裝并加載所需的R包
# BiocManager::install("dittoSeq")
library(dittoSeq)
library(dplyr)
load("sce.Rdata") # 加載自己的單細胞數據
dittoPlot(sce,
"MS4A1", # 感興趣的基因
group.by = "orig.ident", # 講將細胞/樣本分組的選項
plots = c("vlnplot", "boxplot"), # 設置繪圖類型,包括:jitter, boxplot, vlnplot, ridgeplot磺陡。注意順序
boxplot.fill = F, # 是否顯示異常值
boxplot.color = 'white', # 箱線圖線條顏色
theme = theme(axis.text = element_text(size = 12, color = 'black'),
axis.line = element_line(size = 1),
axis.title.y = element_text(size = 15, color = 'black'),
plot.title = element_text(size=15, hjust=0.5, color = 'black')),
ylab = 'Expression',
y.breaks = seq(0, 5, 1),
max = 5, min = 0,
xlab = '',
x.labels.rotate =F,
main = "MS4A1",
legend.show = F)
dittoSeq-1
1.2 細胞比例圖
# seurat等單細胞可視化工具在查看細胞比例柱狀圖時趴梢,需先進行細胞比例計算漠畜,這里可以直接作圖。數據可以表示為百分比或計數坞靶,由"scale"輸入控制的
p1 <- dittoBarPlot(sce, "Major.CellType", group.by = "orig.ident")
p2 <- dittoBarPlot(sce, "Major.CellType", group.by = "orig.ident", scale = "count")
p1|p2
dittoSeq-2
# dittoFreqPlot可按每種細胞類型分面憔狞,sample.by可將組內的細胞分組,group.by成單獨的樣本
dittoFreqPlot(sce, "Major.CellType", sample.by = "orig.ident", group.by = "class")
dittoSeq-3
2.
數據
# 加載數據(制作模擬的表達數據和條件數據)
exp <- matrix(rpois(20000, 5), ncol=20)
colnames(exp) <- paste0("donor", seq_len(ncol(exp)))
rownames(exp) <- paste0("gene", seq_len(nrow(exp)))
logexp <- logexp <- log2(exp + 1)
logexp[1:3,1:6]
## donor1 donor2 donor3 donor4 donor5 donor6
## gene1 2.584963 1.584963 3.000000 2.000000 2.584963 2.584963
## gene2 1.000000 2.807355 2.584963 2.584963 2.807355 1.584963
## gene3 2.000000 3.000000 2.000000 2.807355 1.584963 3.000000
pca <- matrix(rnorm(20000), nrow=20)
conditions <- factor(rep(1:4, 5))
sex <- c(rep("M", 9), rep("F", 11))
# dittoSeq 本身可處理存儲為 SummarizedExperiment 對象的批量 RNAseq 數據
library(SummarizedExperiment)
bulkSE <- SummarizedExperiment(
assays = list(counts = exp,
logcounts = logexp), # 每個相當于一個表達矩陣彰阴,可存儲counts矩陣瘾敢、TPM矩陣和FPKM矩陣等
colData = data.frame(conditions = conditions,
sex = sex) # 可添加行信息(基因信息,比如gene id, gene name, gene type等)和列信息(樣本信息尿这,比如生存時間簇抵、生存狀態(tài)等)
)
# 或者,也可以使用 importDittoBulk() 函數將以其他形式存儲的批量數據轉換為 SingleCellExperiment 結構
bulkSCE <- importDittoBulk(
x = list(counts = exp,
logcounts = logexp), # x可以是 DGEList妻味、DESeqDataSet正压、SummarizedExperiment 或數據矩陣列表
metadata = data.frame(conditions = conditions,
sex = sex),
reductions = list(pca = pca)
)
# meta數據和降維也可以后續(xù)添加
bulkSCE$conditions <- conditions
bulkSCE$sex <- sex
bulkSCE <- addDimReduction(
object = bulkSCE,
embeddings = pca,
name = "pca",
key = "PC")
# 可視化
dittoDimPlot(bulkSCE, "sex", size = 3, do.ellipse = TRUE)
dittoBarPlot(bulkSCE, "sex", group.by = "conditions")
dittoBoxPlot(bulkSCE, "gene1", group.by = "sex")
dittoHeatmap(bulkSCE, getGenes(bulkSCE)[1:10],
annot.by = c("conditions", "sex"))
dittoSeq-4
3.
設置
3.1 dittoDimPlot & dittoScatterPlot
# dittoScatterPlot() 的軸是基因表達數據或meta數據欣福,dittoDimPlot() 的軸是降維责球,如 tsne、pca拓劝、umap 或類似數據
dittoScatterPlot(
object = sce,
x.var = "nCount_RNA", y.var = "nFeature_RNA",
color.var = "percent.mito")
dittoDimPlot(sce, "cluster",
do.label = TRUE,
labels.repel = FALSE,
add.trajectory.lineages = list(
c("9","3"),
c("8","7","2","4"),
c("8","7","1"),
c("5","11","6"),
c("10","0")),
trajectory.cluster.meta = "cluster")
dittoSeq-5
3.2 dittoDimHex & dittoScatterHex
# 與“Plot”版本類似雏逾,繪圖區(qū)域被分成六邊形箱
dittoScatterHex(
object = sce,
x.var = "PPY", y.var = "INS",
color.var = "label",
colors = c(1:4,7), max.density = 15)
dittoDimHex(sce, "INS")
dittoSeq-6
3.3 dittoPlot (and dittoRidgePlot + dittoBoxPlot wrappers)
# dittoPlot() 是主函數,dittoRidgePlot() 和 dittoBoxPlot() 本質上只是將輸入圖的默認值從 c(“jitter”, “vlnplot”) 調整為c(“ridgeplot”) 或 or c(“boxplot”,“jitter”)
dittoPlot(sce, "ENO1", group.by = "label",
plots = c("jitter", "vlnplot", "boxplot"), # <- order matters
# change the color and size of jitter points
jitter.color = "blue", jitter.size = 0.5,
# change the outline color and width, and remove the fill of boxplots
boxplot.color = "white", boxplot.width = 0.1,
boxplot.fill = FALSE,
# change how the violin plot widths are normalized across groups
vlnplot.scaling = "count"
)
dittoRidgePlot(sce, "ENO1", group.by = "label")
dittoBoxPlot(sce, "ENO1", group.by = "label")
dittoSeq-7
3.4 dittoHeatmap
# Pick Genes
genes <- c("SST", "REG1A", "PPY", "INS", "CELA3A", "PRSS2", "CTRB1",
"CPA1", "CTRB2" , "REG3A", "REG1B", "PRSS1", "GCG", "CPB1",
"SPINK1", "CELA3B", "CLPS", "OLFM4", "ACTG1", "FTL")
dittoHeatmap(sce, genes,
annot.by = c("label", "donor"),
order.by = "donor",
scaled.to.max = TRUE,
show_colnames = FALSE,
show_rownames = FALSE)
# Highlight certain genes
dittoHeatmap(sce, genes,
annot.by = c("label", "donor"),
highlight.features = genes[1:3],
complex = TRUE)
dittoSeq-8
3.5 Multi-Plotters (創(chuàng)建多個圖郑临,或將多個變量的數據匯總在一個圖中)
3.5.1 dittoDotPlot
delta.genes <- c(
"SST", "RBP4", "LEPR", "PAPPA2", "LY6H",
"CBLN4", "GPX3", "BCHE", "HHEX", "DPYSL3",
"SERPINA1", "SEC11C", "ANXA2", "CHGB", "RGS2",
"FXYD6", "KCNIP1", "SMOC1", "RPL10", "LRFN5")
dittoDotPlot(sce, vars = delta.genes,
group.by = "label",
scale = FALSE)
dittoSeq-9
3.5.2 multi_dittoPlot & dittoPlotVarsAcrossGroups
multi_dittoPlot(sce, delta.genes[1:6],
group.by = "label",
vlnplot.lineweight = 0.2, jitter.size = 0.3)
dittoPlotVarsAcrossGroups(sce, delta.genes,
group.by = "label",
main = "Delta-cell Markers")
dittoSeq-10
3.5.3 multi_dittoDimPlot & multi_dittoDimPlotVaryCells
multi_dittoDimPlot(sce, delta.genes[1:6])
multi_dittoDimPlotVaryCells(sce, delta.genes[1],
vary.cells.meta = "label")
dittoSeq-11