Hi
I am visualising the difference of mutation burden between to group
My data looks like this
> head(tmb)
Response variable value
1 Responders total_perMB 0.14
2 Responders total_perMB 0.98
3 Responders total_perMB 1.10
4 Responders total_perMB 1.16
5 Responders total_perMB 1.18
6 Responders total_perMB 1.26
>
> tail(tmb)
Response variable value
59 Non-responders total_perMB 2.46
60 Non-responders total_perMB 2.54
61 Non-responders total_perMB 2.58
62 Non-responders total_perMB 2.70
63 Non-responders total_perMB 2.74
64 Non-responders total_perMB 3.42
>
I used this
> ggplot(tmb, aes(x=Response, y=value),color=Response) +
+ geom_quasirandom(size = 2, method = "frowney",width=0.3,color="navyblue")+ stat_summary(fun.data=data_summary, color="red")+labs(title="Plot of length by dose",x="", y = "Total Mutation Burden per Mega base")+
+ theme_classic2(base_size =18)+stat_compare_means(aes(group = Response),method = "t.test", size=6)
>
I got this

But I want groups in different colours which I don't know how to change
2 answers
In short yes, you can use ggbeeswarm to plot the individual observations along with with ggsignif to produce the statisics. However, if you are comparing the two groups that were measured by the same scale (MB) then you should plot them on the same scale, it will avoid misinterpreting the data & delevers the plot's message clearly & correctly
hth
Hi,
Yes, you can with facet_wrap() scales="free" or scales="free_y" only. See below:
## library
library("ggplot2")
## create df
Response <- rep( c("Responders", "Non-responders"), each = 6 )
Variable <- rep("total_perMB", 12)
value <- c(0.14, 0.98, 1.10, 1.16, 1.18, 1.26,
2.46, 2.54, 2.58, 2.70, 2.74, 3.42)
df <- data.frame(Response, Variable, value)
## plot
ggplot(data = df, aes(x = Response, y = value)) +
geom_point() +
facet_wrap(~Response, scales = "free") +
theme_minimal() +
ylab("TMB/MB")

Though I don't see which is your x-axis column. I'm mean if you have two numerical axis in a plot, you need to provide data with two numerical columns to ggplot2.
I hope this answers your question,
António
Log in to answer this question.
You're using facets, correct? There's an option to let the scales be free (i.e. independent of each other) - you can check if that works. If not, you can generate 2 plots and use
cowplotorgrid.arrangeto "combine" them so they're side-by-side.The first plot coming from maftools and no way to do the same scale, by plotting one by one again the scale to line the median for two groups is different so that I plotted by box which is fine but my boss demands something which is not box plot or violin
Try to include
color=Responsebetweenaes(), like this:Then I think you need to remove the
color="navyblue"option fromgeom_quasirandom(). Otherwise not sure if it'll work properly.António
Thank you I tried to change default colouring as green and red by
scale_fill_manual(values=c("#999999", "#E69F00"))but not workingDid you try
scale_color_manual(values=c("#999999", "#E69F00"))?