r - How to specify two thresholds for ggplot? -
i have dataset called volcano looks this:
diffmean p.value -0.0246757556 0.1 0.0050993889 0.002 -0.0169992614 0.008 0.0039905857 0.03 -0.0081568420 0.02 -0.0279989935 0.03 0.0313951281 0.44 -0.0097932018 0.22 -0.1033745673 0.003 0.1143251388 0.02 -0.0738617112 0.004 -0.0011579184 0.1 -0.0008561962 0.022 0.0435398270 0.11 -0.0380242369 0.05 0.1533720177 0.03 i want plot using ggplot, want colors reddish if diffmean < 0 , p.value < 0.05 or bluish if diffmean > 0 , p.value < 0.05.
what have far is:
volcano$threshold = as.factor(abs(volcano$diffmean)>0 & volcano$p.value.adj< 0.05) ggplot(data=volcano, aes(x=diffmean, y=-1*log10(p.value), colour=threshold)) + geom_point(aes(alpha=0.4, size=1.75)) + xlim(c(-1,1)) + ylim(c(0,25)) but don't know how utilize 2 thresholds.
i :
volcano$threshold <- factor(ifelse(volcano$diffmean>0 & volcano$p.value< 0.05, 1, ifelse(volcano$diffmean<0 & volcano$p.value< 0.05, -1, 0) )) library(ggplot2) ggplot(data=volcano, aes(x=diffmean, y=-1*log10(p.value), colour=threshold)) + geom_point(alpha=0.4, size=5) + scale_y_log10() r colors ggplot2
No comments:
Post a Comment