I have been using ggplot2 to plot two sets of values from a data table called "TableFCvsFC". The two parameters that I am drawing are values from the column "SM" vs values from the column "SPL", which correspond to the same gene expression evaluated in different conditions. As I don't know how to import the data table to this post, I paste an image of a fragment of the table as an example:
So far I have used the next code to draw the following graph:
library(ggplot2) Change <- openxlsx::read.xlsx("/Users/Desktop/TableFCvsFC.xlsx") LC <- ggplot(Change, aes(x=SM, y=SPL, family = "sans")) LC + geom_vline(xintercept = 1e+00) + geom_hline(yintercept = 1e+00) + geom_abline(intercept = 0, slope = 1) + geom_point(size=2, shape=16, alpha = 1, color = "black") + scale_x_continuous(trans = "log10") + scale_y_continuous(trans = "log10")
What I need now is to highlight the dots located inside the orange rectangle by coloring them in red, while the rest of the dots should remain black. The particular characteristic of the dots to be red is that the value in "SM" column should be higher than 2, while the value in "SPL" column should be lower than 1. I suppose that one thing that I can do is to create a new vector with the rows that meet those requirements and then customize the colour according to that variable, but I don't know how write that part of the code.
What I also would like to do is to add a label to the 10 red dots with the highest values in "SM". Those labels should contain the corresponding "GeneName" for each of those dots.
Can anybody help me? As I do not provide the complete data table (sorry for that), you can create a similar data table with random values to evaluate the code. I can then adapt it to my own data.