0

I am using the following code:

all_bray_curtis_pcoa$data$Vectors %>%
  select(SampleID, PC1, PC2) %>%
  left_join(all_metadata) %>%
  ggplot(aes(x = PC1, y = PC2, color = Txt)) +
    geom_point(aes(shape = Sex), alpha = 0.8, size = 3) +
    stat_ellipse(size = 1.1) +
    xlab(paste("PC1: ", round(100*all_bray_curtis_pcoa$data$ProportionExplained[1]), "%")) +
    ylab(paste("PC2: ", round(100*all_bray_curtis_pcoa$data$ProportionExplained[2]), "%")) +
    theme_q2r() +
    scale_shape_manual(name = "Txt_Sex", labels = c("Female", "Male"), values = c(15, 19)) +
    scale_color_manual(name = "Txt_Sex", labels = c("Morphine", "Vehicle"), values = c("purple", "gray")) 
    

Which produces the following image:

enter image description here

The plot itself looks great, but I want to change the legend so it shows a purple square (Morphine Female), purple circle (Morphine Male), gray square (Vehicle Female), and gray circle (Vehicle Male). I've tried a few different things but it messes up my ellipses. I do have a column that is Txt_Sex, but I don't know how to use that for just the legend (as if I put it in the global it messes up my ellipses). Any advice is appreciated. The all_bray_curtis_pcoa file is a QZA format, which I can email if requested (I cannot share here).

0 Answers0