I want to change the color of my points in the graph however the vector I created isn't doing that. All my code seems to be running fine but the graph won't print as how I want it.
The left side should be colored blue and the right side should be red.
# Basic Volcano Plot
VP <- ggplot(df.7vsNO, aes(x = log2FC, y = logpv)) + geom_point() + theme_minimal()
print(VP)
VP2 <- VP + geom_vline(xintercept=c(-1.6, 1.6), col="red") +
geom_hline(yintercept=-log10(0.05), col="red")
print(VP2)
# add a column of NAs
df.7vsNO$diffexpressed <- "NO"
# if log2FoldChange > 1, set as "UP"
df.7vsNO$diffexpressed[df.7vsNO$log2FC > 1] <- "UP"
#if log2FoldChange < 1, set as "DOWN"
df.7vsNO$diffexpressed[df.7vsNO$log2FC < 1] <- "DOWN"
# Re-plot but this time time color the points w/ "diffexpressed"
VP <- ggplot(df.7vsNO, aes(x = log2FC, y = logpv, col(diffexpressed))) + geom_point() + theme_minimal()
print(VP)
# Add lines as before...
VP2 <- VP + geom_vline(xintercept=c(-1.6, 1.6), col="red") +
geom_hline(yintercept=-log10(0.05), col="red")
print(VP2)
# Change point color
VP3 <- VP2 + scale_color_manual(values=c("blue", "black", "red"))
# named vector
mycolors <- c("blue", "red", "black")
names(mycolors) <- c("DOWN", "UP", "NO")
VP3 <- VP2 + scale_color_manual(values = mycolors)
print(VP3)