1

I have this data and code by which I have this plot

In the plot you are seeing non-responders come at first then responders come

Nowhere in the code I can see how I change the group

                                                                                                                                                                                                                                          "Non-responders")), row.names = c(NA, -22L), class = "data.frame")
library(dplyr)
library(ggplot2)
library(ggrepel)

x <- x %>%
  rename(log10_qvalue = log10_pvalue)

ggplot(data = x, aes(x = log10_qvalue, y = Percentage_altered/100, color = CNV)) +
  geom_point( ) +
  scale_discrete_manual(aesthetics = "colour", values = c("Deletion" = "blue", "Amplification" = "red")) +
  geom_text_repel(aes(label = gene), size = 5) +
  facet_grid(CNV ~ group) +
  labs(x = "-log10(qvalue)", y = "Net frequency of gain and deletion (%)") +
  theme_bw() +
  theme(
    legend.position = "none",
    axis.title = element_text(size = 12, face = "bold"),
    axis.text = element_text(size = 12, face = "bold"),
    strip.text = element_text(size = 12, face = "bold")
  )

enter image description here

How I change this code so that first responders come in left and non-responders in right?

Ian Campbell
  • 23,484
  • 14
  • 36
  • 57
user6517
  • 33
  • 5

1 Answers1

3

Change group to a 'factor'. This way the order is defined by the order in the factor rather than alphabetical order.

x$group <- factor(x$group, levels = c("Responders", "Non-responders"))
Daniel V
  • 1,305
  • 7
  • 23