0
votes

I removed the boxplot from a ggpubr plot with the following line of code:

plot$layers <- plot$layers[-1]

I saw this solution on this Stack post: Boxplots with ggpaired() WITHOUT connecting lines

I am not as familiar with ggpubr but thought it would be fit for purpose for this particular set of plots. I was told to remove the boxplot and now to add it back in and now I am stuck. I am thinking I changed the environment settings and don't know how to revert it to the original way.

Any help is greatly appreciated! Plots provided with drug name removed.

Plot code:

ggpar(ggpaired(data, x = "treatment", y = "value", 
                       color = "treatment", palette = c("#202960", "#8CC63E"),
                       add = "dotplot", title = "Jiang (TIDE) CTL Panel - Mock vs. Drug",
                       xlab = "Treatment", ylab = "CTL Score",
                       width = 0, point.size = 2, 
                       linetype = "dashed", line.color = "gray") +
                stat_compare_means(method = "t.test", paired = TRUE, 
                                   label.x = 1.4, label.y = 1.8) +
                #geom_text_repel(data = data %>% filter(treatment == "Mock"), 
                #                aes(x = "Mock", y = value, label = subject), 
                #                nudge_x = -0.2, inherit.aes = FALSE, size = 3, 
                #                color = "#6c706d") +
                scale_y_continuous(breaks = c(0,0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5),
                                   labels = c("0","","0.5","","1.0","","1.5","","2.0","","2.5")) +
                coord_cartesian(ylim = c(0,2)), legend = "FALSE")

Current Plot Example:

current

Target Plot Example (minus geom_text_repel label):

target

Reprex:

data = structure(list(...1 = c("1", "2", "3", "4", "5", "6", "7", "1", 
"2", "3", "4", "5", "6", "7"), subject = c("G5", "G6", "G7", 
"G8", "G12", "G13", "G14", "G5", "G6", "G7", "G8", "G12", "G13", 
"G14"), value = c(0.733377605384461, 1.65662450012502, 1.38787220722645, 
1.37053666253192, 1.62679859595799, 0.541814589221617, 0.966081047005121, 
0.892329475047538, 1.75954000718932, 1.36253416559681, 1.22104521047091, 
1.61168414813187, 0.940537918248694, 1.00171611627718), treatment = c("Drug", 
"Drug", "Drug", "Drug", "Drug", "Drug", "Drug", "Mock", "Mock", 
"Mock", "Mock", "Mock", "Mock", "Mock")), row.names = c(NA, -14L
), class = "data.frame")