I think you need to identify a principled way to set text for the points you want, I chose the first 4 letters, and the highest value per gene per sample to show it for (others Na).
library(tidyverse)
structure(list(
Sample = c(
-25, -25, -25, -17, -17, -17, -1, -1,
-1, 7, 7, 7, -25, -25, -25, -17, -17, -17, -1, -1, -1, 7, 7,
7, -25, -25, -25, -17, -17, -17, -1, -1, -1, 7, 7, 7
), Gene = structure(c(
1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L
), .Label = c("CpNRT1.5", "CpNR", "CpNiR"), class = "factor"),
delCt = c(
-5.921332359, -6.145671844, -5.677146912, -2.748710632,
-3.19631958, -2.737405777, 1.386582375, 1.850103378, 0.789480209,
-6.969926834, -3.663425446, -5.600616455, -3.526859283, -4.287014008,
-5.624802589, 0.251309395, -0.86595726, -1.414552689, 3.509215355,
3.678625107, 2.386909485, -2.047849655, -0.381763458, -2.709918022,
-2.374889374, -2.108045578, -2.310191154, -2.656218529, -2.271496773,
-1.574661255, 2.764549255, 2.920114517, 2.368210793, -5.035234451,
-2.270872116, -3.361042023
)
), row.names = c(NA, -36L), spec = structure(list(
cols = list(Sample = structure(list(), class = c(
"collector_double",
"collector"
)), Gene = structure(list(), class = c(
"collector_character",
"collector"
)), delCt = structure(list(), class = c(
"collector_double",
"collector"
))), default = structure(list(), class = c(
"collector_guess",
"collector"
)), skip = 1
), class = "col_spec"), class = c(
"spec_tbl_df",
"tbl_df", "tbl", "data.frame"
)) -> qPCR_data
#arbitrary label text for first sample of every gene
qPCR_data2 <- qPCR_data %>% group_by(Gene) %>% mutate(label_text=letters[dense_rank(Sample)])
qPCR_data3 <- arrange(qPCR_data2,Gene,Sample,desc(delCt)) %>% group_by(Gene,label_text) %>% slice(1)
qPCR_data4 <- left_join(qPCR_data,
qPCR_data3)
sp_NR_qPCR <- ggplot(qPCR_data4, mapping=aes(x=Sample, y=delCt, color=Gene))+
geom_point(show.legend=FALSE)+
geom_smooth(aes(fill=Gene), show.legend=FALSE)+
geom_text(aes(label=label_text), color="Black",nudge_y = 1.1) +
facet_grid(.~Gene)+
scale_x_continuous(breaks=c(-25, -17, -1, 7))+
labs(y="Relative abundance (∆Ct)", x="Hours relative to peak secretion (0 h)")+
theme_classic()+
theme(axis.title.x=element_text(size=10, face="bold"), axis.title.y=element_text(size=10, face="bold"))+
theme(axis.text.x=element_text(size=10), axis.text.y=element_text(size=10))+
theme(strip.text.x=element_text(size=12, face="italic"))+
scale_color_brewer(palette="Set1")+
scale_fill_brewer(palette="Set1")+
theme(panel.border=element_rect(fill = NA, color="black"))
sp_NR_qPCR