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:
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