Hi there,
I'm currently struggling with ggplot geombar.
To present quickly the data, we've computed the proportion of several virus in diferent kind of samples (column sample). 3 different protocols have been used (column proto) in triplets (column dupli).
I would like to plot the proportion of each virus in each assay, depending on protocol used, and separate results for each kind of samples
Here is an extract from my data:
sample proto dupli virus prop
1 HSV E S3 Mastadenovirus 0.00000770
2 HSV E S3 Orthopneumovirus 0
3 HSV E S3 Simplexvirus 0.996
4 HSV E S3 Alphainfluenzavirus 0
5 VRS E S3 Enterovirus 0
6 HSV E S3 Dependoparvovirus 0
7 HSV E S3 Levivirus 0.0000847
8 HSV E S3 others 0.00373
9 HSV E S10 Mastadenovirus 0.0000136
10 HSV E S10 Orthopneumovirus 0
11 MOCK E S3 Levivirus 0.0000847
I had a start of anwsers on Stackoverflow for plotting an incomplete result like this:
ggplot(subtable2, aes(fill=virus,x=proto, y=prop))+
geom_bar(position="stack", stat="identity")+
facet_grid(.~sample)
How can I improve my code to visualize the proportion results for each "dupli" members, and get something like this?
I tried to create a new variable with:
subtable2$sampledupli<-paste0(subtable2$sample,"_",subtable2$dupli)
But i'm not sure this is the right way. Do you have some clues to do this, or should I rework my data and visualisation?
Thx, have a nice WE
Hello! I hope you're keeping well.
What happens when you use
sampledupli
as your faceting variable?I'm trying to generate a toy dataset that I can work with to help you with this problem, but I'm having trouble figuring out what
prop
is referring to exactly. Am I correct in assuming that it is the proportion of a given virus for that particular sample, protocol, and duplicate?Thanks!
Thx for the anwser!
prop is the viral proportion in the triplicat. If you sum prop for each one: