R is a great plotting program for making publication quality bar plots of your data. I often need to make quick bar plots to help collaborators quickly visualize data, so I thought I would put together a very generalized script that can be modified and built on as a template to make future bar plots in R.
In this script you manually enter your data (as you would see it in a 2x2 table) and then calculate the estimated frequency and 95% CI around that frequency using the binom.confint function in the binom package. Next, a parametric and non-parametric p-value is calculated with the binom.test and fisher.test commands, respectively. These statistics are then plotted using the R's barplot function. The example code is below along with what the plot will look like. P-values and N's are automatically filled and the y limits are calculated to ensure the graph includes all the plotted details.
Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.