我正在尝试制作一个方框图,显示类型A和类型B之间的基因表达。但是,我想根据以下数据框“df”中提到的列表为点着色:

Samples   Type  List    GeneA
Sample1     B   Other   -4.778968547
Sample2     B   Other   -4.63232938
Sample3     B   Other   -5.695251042
Sample4     A   Sample4  2.820003188
Sample5     A   Other   7.487856546
Sample6     A   Other   2.290055318
Sample7     A   Other   -1.183807203
Sample8     B   Other   -4.534681343
Sample9     A   Other   -5.140540608
Sample10    B   Other   -5.695251042
Sample11    B   Other   -5.695251042
Sample12    B   Other   -5.695251042
Sample13    A   Other   -5.071179371
Sample14    A   Other   1.117824251
Sample15    A   Other   4.42672296
Sample16    B   Other   -2.607036764
Sample17    B   Other   -4.154979727
Sample18    A   Other   -4.773270932
Sample19    B   Other   -5.695251042
Sample20    A   Other   0.472999278
Sample21    A   Other   -0.12535742
Sample22    A   Other   -4.32895912
Sample23    A   Other   0.342990853
Sample24    B   Sample24    -5.169967041
Sample25    B   Other   -4.628633712
Sample26    A   Other   0.18030665
Sample27    B   Other   -5.695251042
Sample28    A   Sample28    3.274762509
Sample29    B   Other   1.133797461
Sample30    B   Other   -0.489134592
Sample31    A   Other   -0.580311566
Sample32    A   Other   -0.801258402
Sample33    B   Other   -5.695251042
Sample34    B   Sample34    -5.695251042
Sample35    B   Other   -3.627831566
Sample36    B   Other   -5.126528687
Sample37    B   Other   -3.658755234
Sample38    B   Other   -3.563236707

我绘制了以上数据,如下所示:
q <- ggplot(df, aes(Type, GeneA))
q + geom_boxplot() + geom_jitter(width = 0.2, aes(colour = List)) +
  labs(y = "GeneA expression (logCPM)")

r - 为什么在此箱形图中某些抖动点为黑色?-LMLPHP

在图例中,我可以看到这些点的颜色。但是奇怪的是我看到B型有两个黑点。这是怎么了?

最佳答案

geom_boxplot将异常值绘制为黑点。您可以使用outlier.shape参数禁用此功能。

+ geom_boxplot(outlier.shape = NA)

关于r - 为什么在此箱形图中某些抖动点为黑色?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52721111/

10-11 07:38