Question: Changing colour of dots group wise
0
gravatar for A
6 months ago by
A3.9k
A3.9k wrote:

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

enter image description here

But I want groups in different colours which I don't know how to change

ggplot2 R • 335 views
ADD COMMENTlink modified 6 months ago • written 6 months ago by A3.9k

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 cowplot or grid.arrange to "combine" them so they're side-by-side.

ADD REPLYlink modified 6 months ago • written 6 months ago by Ram32k

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

ADD REPLYlink written 6 months ago by A3.9k
1

Try to include color=Response between aes(), like this:

gplot(tmb, aes(x=Response, y=value, color=Response))

Then I think you need to remove the color="navyblue" option from geom_quasirandom(). Otherwise not sure if it'll work properly.

António

ADD REPLYlink modified 6 months ago • written 6 months ago by antonioggsousa2.0k

Thank you I tried to change default colouring as green and red by scale_fill_manual(values=c("#999999", "#E69F00")) but not working

ADD REPLYlink written 6 months ago by A3.9k
1

Did you try scale_color_manual(values=c("#999999", "#E69F00"))?

ADD REPLYlink modified 6 months ago • written 6 months ago by antonioggsousa2.0k
4
gravatar for H.Hasani
6 months ago by
H.Hasani980
Freiburg, Germany
H.Hasani980 wrote:

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

ADD COMMENTlink written 6 months ago by H.Hasani980
2
gravatar for antonioggsousa
6 months ago by
antonioggsousa2.0k
antonioggsousa2.0k wrote:

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")

enter image description here

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

ADD COMMENTlink modified 6 months ago • written 6 months ago by antonioggsousa2.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 991 users visited in the last hour
_