I have a dataframe df
with the following data. I want to plot the logCPM
expression of the gene between two groups A and B.
Samples Type GeneA
Sample1 B 14.82995162
Sample2 B 12.90512275
Sample3 B 9.196524783
Sample4 A 19.42866012
Sample5 A 19.70386922
Sample6 A 16.22906914
Sample7 A 12.48966785
Sample8 B 15.53280377
Sample9 A 9.345795955
Sample10 B 9.196524783
Sample11 B 9.196524783
Sample12 B 9.196524783
Sample13 A 9.434355615
Sample14 A 15.27604692
Sample15 A 18.90867329
Sample16 B 11.71503095
Sample17 B 13.7632545
Sample18 A 9.793864295
Sample19 B 9.196524783
Sample20 A 14.52562066
Sample21 A 13.85116605
Sample22 A 9.958492229
Sample23 A 17.57075876
Sample24 B 13.04499079
Sample25 B 15.33577937
Sample26 A 13.95849295
Sample27 B 9.196524783
Sample28 A 18.20524388
Sample29 B 17.7058873
Sample30 B 14.0199393
Sample31 A 16.21499069
Sample32 A 14.171432
Sample33 B 9.196524783
Sample34 B 9.196524783
Sample35 B 15.16648035
Sample36 B 12.9435081
Sample37 B 13.81971106
Sample38 B 15.82901231
I tried making a violin plot using ggviolin
.
library("ggpubr")
pdf("eg.pdf", width = 5, height = 5)
p <- ggviolin(df, x = "Type", y = "GeneA", fill = "Type",
color = "Type", palette = c("#00AFBB", "#FC4E07"),
add="boxplot",add.params = list(fill="white"),
order = c("A", "B"),
ylab = "GeneA (logCPM)", xlab = "Groups")
ggpar(p, ylim = c(5,25))
dev.off()
I got the violin plot like this .
1) In this I don't see any whiskers and any points on violin.
2) Is there a way to show which point is which sample? like giving a different color to the point (for eg: I'm interested in Sample 10. I want to give different color to that point because I'm interested to see the expression of that)
Thank you
May I suggest using
elephant
/raincloud
orhybrid boxplot
plots instead?From the blog post linked above:
raincloud plot
hybrid boxplot using
geom_boxjitter()
from theggpol
packageBonus: you can also replace
geom_point()
withgeom_quasirandom()
from the ggbeeswarm package. Here is one example..
.
.
Created on 2018-10-03 by the reprex package (v0.2.1.9000)