【发布时间】:2021-11-09 23:53:42
【问题描述】:
我在long format (data_long) 中有 3 列基因表达数据。它看起来像这样,其中 column1 表示基因名称,column2:Sample,column 3 表示表达值:
Genes sample value
A44 A 7357.891
AAR A 6950.868
A44 B 6771.266
AAR B 4978.734
A44 C 9441.985
AAR C 6061.017
我想生成一个线图,根据样本对所有基因进行分组,每个样本中所有基因的 + 均值以不同颜色绘制。这是我能够使用的东西
ggplot(data_long, aes(x=sample, y=value)) +
geom_line(aes(group=Genes), size=0.5, alpha=0.3, color="black") +
stat_summary(aes(x=as.numeric(sample)), fun=mean, geom='line',size=1, color='orange') +
theme_classic() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
scale_y_continuous(limits = c(0, 40000))
现在,我想添加 Group 列并根据 Group 填充背景。
Genes Group sample value
A44 A1 A 7357.891
AAR A1 A 6950.868
A44 A1 B 6771.266
AAR A1 B 4978.734
A44 A2 C 9441.985
AAR A2 C 6061.017
【问题讨论】:
-
查看收到错误的代码以及错误消息会很有帮助