【发布时间】:2020-01-19 01:23:16
【问题描述】:
我正在尝试使用 ggplot2 绘制数据并使用 ggsignif 显示成对统计比较。 ggsignif 注释的字体大小太小,线宽太细。帮助说明 textsize 和 size 参数应分别更改字体大小和括号粗细,但是,这些对我不起作用。我尝试在 theme() 中调整文本大小并设置 base_size。所有其他文本都是响应式的。我正在使用我认为是所有内容的最新版本(R v3.6.1,ggsignif v0.6.0)。
我不确定它是否相关,但我还发现 geom_signif() 放错了注释(例如“*”)但正确放置了比较括号。每当我在一个 geom_signif() 中添加多个比较时,就会发生这种情况。如果我添加多个 geom_signif() 每个都进行单对比较(请参见下面的代码),那么我不会遇到这个问题。即使我只添加一个 geom_signif() 也不会影响 textsize/size 问题。
p = ggplot(population, aes(x=Cluster, y=Cells)) +
geom_jitter(aes(colour=Sample), position=position_jitterdodge(jitter.width=0.3, dodge.width=0.7), size=1, alpha=0.1) +
geom_point(data=population.sum, aes(y=Cells, fill=Sample), size=10, position=position_dodge(0.7)) +
geom_errorbar(data=population.sum, aes(fill=Sample, ymin=CI.Lower, ymax=CI.Upper), width=0.2, size=2, position=position_dodge(0.7)) +
scale_y_continuous(limits=c(0,1200), expand=c(0, 0)) +
scale_color_brewer(palette="Paired") +
theme_classic(base_size = 60) +
theme(
legend.justification=c(0, 1),
legend.position=c(0.01, 1),
legend.title=element_blank(),
axis.text.x=element_text(angle=45, hjust=1),
axis.title.x=element_blank(),
plot.margin=unit(c(25.5,5.5,5.5,5.5),"pt")
)
for (i in seq_along(cluster.levels)) # Shouldn't have to add individually?
p = p + geom_signif(
stat="identity",
data=population.sig[i,],
size=10, # This doesn't work!
textsize=200, # This doesn't work!
aes(x=x.start, xend=x.end, y=y, yend=y, annotation=Annotation)
)
png("Population Scatter Plot.png", 4500, 3000)
p
dev.off()
数据集是:
人口个人数据点。 30k 条记录(每个集群 1k * 样本)。列:
- 集群(因子):图表列的组
- 样本(因子):图列组中的对中的个体
- 细胞(int):绘制的微弱点
population.sum 汇总数据。 30 条记录(每簇 1 条 * 样本)。列:
- 集群(因子):同上
- 样本(因子):同上
- 单元格 (int):绘制的大黑点
- CI.Lower (num):绘制的误差线的下限
- CI.Upper (num):绘制的误差线的上限
population.sig 格式数据用于显着性括号。 15 条记录(每个集群 1 条)。列:
- x.start (num): 比较括号的左侧范围
- x.end (num): 比较括号的右范围
- y (num): 比较括号的垂直位置
- 注释 (chr):要注释的文本(“*”或“NS”)
Example graph. The comparison bracket is too faint and the annotation text is too small
【问题讨论】:
标签: r ggplot2 significance