我为4个样本组创建了细胞成分数据的箱线图,由下面的代码表示并链接到图。我的问题(可能是非常基本的)是如何在每个单元格类型之间的x轴上插入间距,以便每个单元格类型的4个框更清晰地分组?
par(mfrow=c(1,1))
a = cellCounts[targets$Sample_Group == "CTL",]
b = cellCounts[targets$Sample_Group == "SRF",]
c = cellCounts[targets$Sample_Group == "REM",]
d = cellCounts[targets$Sample_Group == "REF",]
boxplot(a, at=0:5*4 + 1, xlim=c(0, 25), ylim=range(a, d), xaxt="n",
col=col.pal[1], main="", ylab="Cell type proportion")
boxplot(b, at=0:5*4 + 2, xaxt="n", add=TRUE, col=col.pal[2])
axis(1, at=0:5*4 + 2.5, labels=colnames(a), tick=TRUE)
boxplot(c, at=0:5*4 + 3, xaxt="n", add=TRUE, col=col.pal[3])
axis(1, at=0:5*4 + 2.5, labels=colnames(a), tick=TRUE)
boxplot(d, at=0:5*4 + 4, xaxt="n", add=TRUE, col=col.pal[4])
axis(1, at=0:5*4 + 2.5, labels=colnames(a), tick=TRUE)
legend("topleft", legend=c("CTL","SRF","REM","REF"), fill=col.pal)
(改编自Maksimovic et al。 2016的代码)