【问题标题】:Color highlight specific genes in volcano plot (R)颜色突出显示火山图中的特定基因 (R)
【发布时间】:2019-02-13 09:58:21
【问题描述】:

我在这方面还很陌生。我想构建一个看起来像这样的火山图:This is what I have so far

使用以下代码:

genes <- read_excel("VolcanoData.xlsx")
genes$Significant <- ifelse(genes$pvalue < 0.00000519, "FDR < 0.00000519", "Not Sig")

ggplot(data=genes, aes(x = rho, y = -log10(pvalue)))+
  geom_point(aes(color = Significant), size=0.1)+
  theme_bw(base_size = 12) + theme(legend.position = "bottom")+
  scale_color_manual(values = c("red", "grey"))

以及看起来像这样的数据

head(genes)
# A tibble: 6 x 5
  gene       rho   pvalue label  Significant     
  <chr>    <dbl>    <dbl> <chr>  <chr>           
1 NUBPL   -0.936 9.79e-30 normal FDR < 0.00000519
2 EPB41L5 -0.931 2.41e-29 ND     FDR < 0.00000519
3 PIGU    -0.930 4.49e-29 normal FDR < 0.00000519
4 TSHR    -0.920 6.78e-27 normal FDR < 0.00000519
5 ENPEP   -0.916 1.11e-26 normal FDR < 0.00000519
6 SEC22A  -0.910 3.88e-26 normal FDR < 0.00000519

tail(genes)
# A tibble: 6 x 5
  gene          rho pvalue label  Significant
  <chr>       <dbl>  <dbl> <chr>  <chr>      
1 HIGD1B  0.00144    0.993 normal Not Sig    
2 CHST3  -0.000712   0.996 normal Not Sig    
3 TLR10   0.000418   0.998 normal Not Sig    
4 AVPR1A -0.000333   0.998 ND     Not Sig    
5 MFSD10 -0.000314   0.998 normal Not Sig    
6 PARP10  0.0000317  1.000 normal Not Sig 

我只想将标记为“ND”的基因涂成黑色。我尝试了不同的组合,但我似乎无法让它发挥作用。谢谢!

【问题讨论】:

  • 您能否通过分享您的数据样本和您正在处理的代码使您的问题可重现,以便其他人可以提供帮助(请不要使用str()head() 或屏幕截图)?您可以使用 reprexdatapasta 包来帮助您。另见Help me Help you & How to make a great R reproducible example?
  • 听起来你可能想使用gghighlight
  • @Tung,我不知道 reprex 是如何工作的,但我已经粘贴了代码,df 的示例与我使用的相同
  • @GordonShumway 我不知道如何只突出显示我想要的那些

标签: r


【解决方案1】:

您可以尝试通过在geom_point 中使用grepl 函数来使用gene 数据的子集:

ggplot(data=genes, aes(x = rho, y = -log10(pvalue)))+
  geom_point( data = genes[grepl("ND", genes$label),], 
              aes(color = Significant), 
              size=0.1)+
  theme_bw(base_size = 12) + 
  theme(legend.position = "bottom")+
  scale_color_manual(values = c("red", "grey"))

【讨论】:

    猜你喜欢
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2022-11-11
    相关资源
    最近更新 更多