Sure. This is what I got from the dput()
structure(list(DrugAConc = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1.667, 1.667, 1.667, 1.667, 1.667, 1.667, 1.667, 1.667, 1.667,
1.667, 1.667, 1.667), DrugBConc = c(0, 0, 0, 1.5625, 1.5625,
1.5625, 3.125, 3.125, 3.125, 6.25, 6.25, 6.25, 0, 0, 0, 1.5625,
1.5625, 1.5625, 3.125, 3.125, 3.125, 6.25, 6.25, 6.25), CellLines = c("A2058",
"A375", "FB", "A2058", "A375", "FB", "A2058", "A375", "FB", "A2058",
"A375", "FB", "A2058", "A375", "FB", "A2058", "A375", "FB", "A2058",
"A375", "FB", "A2058", "A375", "FB"), AverageAbsorb = c(0.16,
0.223666667, 0.328333333, 0.113666667, 0.176333333, 0.244333333,
0.105666667, 0.146333333, 0.217, 0.084666667, 0.12, 0.202, 0.198,
0.226, 0.315666667, 0.140666667, 0.171, 0.248666667, 0.129333333,
0.150666667, 0.227, 0.107, 0.127666667, 0.198), StdDevAbsorb = c(0.029297326,
0.005567764, 0.012503333, 0.003605551, 0.006658328, 0.007767453,
0.005, 0.010785793, 0.006658328, 0.004582576, 0.010503968, 0.007767453,
0.009451631, 0.002081666, 0.008544004, 0.01473092, 0.006806859,
0.001, 0.007505553, 0.005567764, 0.009451631, 0.010016653, 0.008185353,
0.011846237), CountAbsorb = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L
), CellViability = c(1, 1, 1, 0.710416667, 0.788375559, 0.744162437,
0.660416667, 0.654247392, 0.660913706, 0.529166667, 0.536512668,
0.615228426, 1.2375, 1.010432191, 0.96142132, 0.879166667, 0.764530551,
0.757360406, 0.808333333, 0.673621461, 0.691370558, 0.66875,
0.570789866, 0.603045685), PooledStdDev = c(0.022524061, 0.009678154,
0.012503333, 0.006055301, 0.007234178, 0.007767453, 0.005887841,
0.008962886, 0.006658328, 0.006377042, 0.009237604, 0.007767453,
0.009009255, 0.006218253, 0.008544004, 0.010440307, 0.00486484,
0.001, 0.008534245, 0.007756718, 0.009451631, 0.010969655, 0.010181683,
0.011846237), StdError = c(0.018390819, 0.00790218, 0.010208929,
0.004944132, 0.005906682, 0.006342099, 0.004807402, 0.007318166,
0.005436502, 0.005206833, 0.007542472, 0.006342099, 0.007356025,
0.005077182, 0.00697615, 0.008524475, 0.003972125, 0.000816497,
0.006968182, 0.006333333, 0.007717225, 0.008956686, 0.008313309,
0.009672412), tValue = c(-9.153117849, -13.24529058, 0, -26.42863461,
-11.51238602, 0, -23.15873319, -9.656335396, 0, -22.53449087,
-10.87176676, 0, -15.99595688, -17.66071522, 0, -12.66940257,
-19.55292565, 0, -14.01609079, -12.05263158, 0, -10.16000796,
-8.460329215, 0), pValue = c(0.00079083, 0.00018775, 1, 1.22e-05,
0.000325053, 1, 2.06e-05, 0.000643387, 1, 2.3e-05, 0.000406297,
1, 8.93e-05, 6.04e-05, 1, 0.000223512, 4.03e-05, 1, 0.000150331,
0.000271738, 1, 0.000528488, 0.001069541, 1), SignificanceOfChange = c("***",
"***", "NS", "***", "***", "NS", "***", "***", "NS", "***", "***",
"NS", "***", "***", "NS", "***", "***", "NS", "***", "***", "NS",
"***", "**", "NS")), class = "data.frame", row.names = c(NA,
-24L))
I think my major issue is how to construct the right annotation_df. Since I only want to show A375 vs FB and A2058 vs. FB, I don't know how to skip the FB vs.FB pairs.
Also my code so far:
annotation_df <- data.frame(DrugAConc=viability_csv$DrugAConc,
DrugBConc=viability_csv$DrugBConc,
start=viability_csv$CellLines,
end="FB",
y=3.6,
label=viability_csv$SignificanceOfChange )
bar_plot2 <- ggplot(viability_csv, aes(x=CellLines, y=CellViability,ymin=CellViability-StdDevAbsorb, ymax=CellViability+StdDevAbsorb, fill=factor(ifelse(CellLines=="FB", "FB control", "Melanoma")))) + # Label the 2 FB references FB with distinct colors so you can tell them apart from the experiment cell lines easily
geom_bar(stat = "identity", color = 'black', position=position_dodge()) +
geom_errorbar(aes(y=stat(ymax)), width=.2, position=position_dodge(.9)) + # Move the ymax and ymin statements into the ggplot() such that other layers can access it as well--this allows the data label's height to be automatically adjusted by the respective error bar
geom_text(aes(label=sprintf("%0.2f", round(CellViability, digits = 2))), position=position_dodge(width=0.9), vjust=-2) +
facet_grid(DrugAConc~DrugBConc) +
geom_signif(data=annotation_df,
aes(xmin=start, xmax=end, annotations=label, y_position=y),
textsize = 3, vjust = -0.2,
manual=TRUE) +
labs(title="6 cell lines' viability with different 2-DG or DLAD dosages for 24, 48, and 72 hrs", x = "Cell lines", y = "Cell viability", fill="Legends") +
theme_bw()+
theme(plot.title = element_text(size = 20,face = "bold"),axis.title=element_text(size=20,face="bold"),axis.text = element_text(size = 20, face="bold"), strip.text.x = element_text(size = 20, colour = "blue"), strip.text.y = element_text(size = 20, colour = "blue", angle=0), legend.title=element_text(size=20),legend.text=element_text(size=15))
bar_plot2