It really is amazing what you can do with a little practice in R.  The kinds of graphs that you can generate are really only limited by your own imagination.  I have an MCMC log file from BayesTraits that contains a sample of the posterior distribution of 7 transition rates.  For some time I have just been viewing these with the program Tracer that is distributed with beast.  These graphs aren't bad at all and they are super easy to generate.

 Graph from Tracer:
The problem with this graph is that everything has to be added piece by piece after the fact.  The axis doesn't really work the way it is produced and neither does the legend (i added the lines and text in another program).

So what can we do with R to display this data in a clear and convincing way?  If we like this kind of line density plot we can take advantage of the density function in R a simple command along the lines of:

>plot(density(data))

This will produce a simple line graph of the density type shown above. All of the normal par variables are available to make it as pretty or customized as desired.

I was interested in some different ways of representing this data instead of using this line density plot and for these I turned to box, violin, and scatter plots.

The easiest of these is probably the ready made function boxplot.  With box plot we have a call and graph like this:

>boxplot(data1,data2,data3,data4,data5,data6)
 


The length of the whiskers as well as just about everything else you see here can be customized in anyway you would like.  Personally though I don't feel like boxplot graphs give me a good feel for the variability in a dataset.  My goal was to get something that spoke to me visually more clearly.  So the next thing that I tried was the package vioplot.
The vioplot argument line is more or less the same as that for boxplot, I have added a couple of extra lines to place means and 95% HPD on top of the violin plots
>vioplot(data[,1],data[,2],data[,3],data[,4],data[,5])
> arrows(...)
>points(....)

 I feel like I am really starting to get somewhere with this.  With this I feel we get a much better idea about the real variability in our estimates.  Seeing this though really made me want to do better and so I decided to start from scratch and see what I could come up with.

My thought was to plot the actual points and introduce a jitter to the x value allowing the data to be spread out enough that the density of data points would be obvious when you look at the graph.  I am still working on the code but as it sits right now we get something along these lines.
 
This isn't bad but I feel like it could be improved by making the jitter value being given to the X proportional to the distance from the mean value of the estimate.  If we do this we then get something along these lines.



Once I figure out what the best way to do this is I will post the code.  Have a great weekend

Cheers


0

Add a comment

Great Blogs
Great Blogs
About Me
About Me
My Photo
I am broadly interested in the application and development of comparative methods to better understand genome evolution at all scales from nucleotides to chromosomes.
Subscribe
Subscribe
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.