i making plot pvalues plotted text using geom_text. pvalues given in file pvaluesmir21combined.
i want add red colour text (fdr) if value < 5e-02. idea how can done?
ggplot(tumornormalmir21_5p.m3, aes(x2,value)) + geom_dotplot(aes(fill=variable),binaxis = "y") + coord_flip() + theme_bw(base_size=8) + theme(axis.text.y=element_text(hjust = 0)) + geom_text(aes(x, y, label=fdr, group=null),data=pvaluesmir21combined,size=2) > pvaluesmir21combined fdr x y 1 p = 8.3e-02 1 13 2 p = 6.3e-05 2 13 3 p = 3.2e-17 3 13 4 p = 4.8e-22 4 13 5 p = 3.1e-10 5 13 6 p = 6.7e-11 6 13 7 p = 3.2e-24 7 13 8 p = 2.1e-06 8 13 9 p = 1.9e-02 9 13 10 p = 9.4e-06 10 13 11 p = 1.5e-03 11 13
you can try function scale_color_manual
ggplot(tumornormalmir21_5p.m3, aes(x2,value)) + geom_dotplot(aes(fill=variable),binaxis = "y") + coord_flip() + theme_bw(base_size=8) + theme(axis.text.y=element_text(hjust = 0)) + geom_text(aes(x, y, label=fdr, group=null, color = ifelse(as.numeric(sub("p = ", "", fdr)) < 5e-02, 0, 1),data=pvaluesmir21combined,size=2) + scale_color_manuel(values = c("red", "black"))
Comments
Post a Comment