颜色突出显示火山图(R)中的特定基因

时间:2019-02-13 00:32:43

标签: r

我对此很陌生。我想构造一个看起来像这样的火山图: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”的基因涂成黑色。我尝试了不同的组合,但似乎无法使其工作。谢谢!

1 个答案:

答案 0 :(得分:0)

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

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"))