2D Posterior Density Plots in R

I have been grappling with visualizing two dimensional histograms of posterior density distributions of parameters, as estimated by one of your favorite programs – IMa2, MIGRATE-n, MSVAR, etc. All these programs print out distributions of estimated parameters, and here’s a neat and innovative way to visualize them in two dimensions. As an example, I used the output of MSVAR v.1.3 for some simulated microsatellite data with a bottleneck – that can be accessed at this link. A little Googling led me to this great post on five different ways to build two dimensional histograms in R – I use the hexbinplot() function here to obtain my plots. Feel free to play around with the other methods, and program outputs!

rf <- colorRampPalette(rev(brewer.pal(11,'Spectral')))
r <- rf(32)
hexbinplot(V6~V4,data=hpars,xlab="Log10(Current population size N0)",
ylab="Log10(Past population size Na)",colramp=rf)

2D density plot of estimated ancestral and current population sizes using MSVAR.

2D density plot of estimated ancestral and current population sizes using MSVAR.

And voila! Simple, yet fun and intuitive visualization of densities!


About Arun Sethuraman

I am a computational biologist, and I build statistical models and tools for population genetics. I am particularly interested in studying the dynamics of structured populations, genetic admixture, and ancestral demography.
This entry was posted in bioinformatics, howto, population genetics, R, software and tagged , , , . Bookmark the permalink.