移除 geom_tile 中分隔样本的灰色垂直条纹

Remove grey vertical stripes separating samples in geom_tile

您好,我的数据 (data_long) 如下所示:

 genes  sample  value   Group Type
 A1 O7high  6796.448    G0   A
 AA O7high  4997.250    G0   A
 A3 O7high  9477.100    G0   A
 A4 O7high  6083.558    G0   A   
 A1 08low   075.364     G0   B
 AA 08low   13066.130   G0   B

p <- ggplot(data_long, aes(x=sample, y=value,group=genes,color=Group))  + 
  geom_tile(aes(fill = as.factor(Type),color = NA,y = 7000), height = Inf, alpha = 0.5) +
  geom_line(aes(linetype=Group,color=Group, size=Group)) + 
  stat_summary(aes(group = -1), fun=median, geom='line',size=2, 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_sqrt()+
  scale_colour_manual(values=c("black","blue"))+
  scale_size_manual(values=c(0.3,1.5))+
  scale_linetype_manual(values=c("dashed", "solid"))+
  theme_classic()

p + theme_bw() +
  theme(panel.grid = element_blank(),
        panel.border = element_blank())

我使用上面的代码绘制了中线并突出显示了我感兴趣的一些基因。一切正常,但当看到绘图时,有这些垂直的灰线(分隔每个样本?) 我不确定如何删除这些行。我希望相同类型的 geom_tile 没有任何行。请让我知道如何删除这些行

感谢您使用所需信息更新您的问题。或许您可以通过将 color = NA 移动到 aes() 之外来移除灰线,例如

library(tidyverse)
data_long <- read.table(text = "genes  sample  value   Group Type
A1 O7med  6796.448    G0   A
AA O7med  4997.250    G0   A
A3 O7high  9477.100    G0   A
A4 O7high  6083.558    G0   A   
A1 08low   075.364     G0   B
AA 08low   13066.130   G0   B", header = TRUE)

p <- ggplot(data_long, aes(x=sample, y=value,group=genes,color=Group))  + 
  geom_tile(aes(fill = as.factor(Type), y = 7000), color = NA, height = Inf, alpha = 0.5) +
  geom_line(aes(linetype=Group,color=Group, size=Group)) + 
  stat_summary(aes(group = -1), fun=median, geom='line',size=2, 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_sqrt()+
  scale_colour_manual(values=c("black","blue"))+
  scale_size_manual(values=c(0.3,1.5))+
  scale_linetype_manual(values=c("dashed", "solid"))

p + theme_bw() +
  theme(panel.grid = element_blank(),
        panel.border = element_blank())

reprex package (v2.0.1)

于 2021-10-13 创建

这对您的实际数据集有效吗?