The data that is plotted represents the percentage of people participating in genome-wide association studies (GWAS) who are of European, Asian, and other non-European descents. Summaries from GWAS studies are available in the GWAS catalog, which is produced by the US National Human Genome Research Institute and the European Bioinformatics Institute; the data undergoes extraction and validation before being added to the catalog. To determine the proportion of individuals of each ethnicity, Popejoy and Fullerton analyzed the catalog. Since the 2009 study revealed that an overwhelming majority of participants were of European descent, the study encouraged that a broader range of populations should be studied in order to prevent just one group from being the blueprint of these studies. The process was repeated in 2016 in order to see if there was a significant rise in non-European participation, which there was; but only because participation increased drastically among the Asian population.
In this code chunk, I create 4 vectors to denote the labels and percentages used to create the pie charts for the 2009 and 2016 data. The vectors labels2009 and labels 2016 contain the text labels used on the pie chart, while percents2009 and percents2016 denote the percentage corresponding to each group.
labels2009 <- c("European", "\nAsian", "\nOther")
percents2009 <- c(96, 3, 1)
labels2016 <- c("European", "\nAsian", "\nOther")
percents2016 <- c(81, 14, 5)
In the subsequent code chunk, I make a grid and set up its margins using the par() function and mfrow and mar arguments. I use the pie() function along with different arguments to make and customize my pie chart. The arguments used to customize my pie chart are main, init.angle, radius, and col; main gives the pie chart its title. The first two arguments in my pie chart are the vectors for label and percent that I created initially.
# set up par()
par(mfrow = c(1,2), mar = c(2,3,1,5))
#pie graphs 1
# add main, init.angle, radius, and col
pie(percents2009, labels2009, main = "2009", init.angle = -82, radius = 1, col = c(1, 2, 3))
# pie graph 2
# add main, init.angle, radius, and col
pie(percents2016, labels2016, main = "2009", init.angle = -82, radius = 1, col = c(1, 2, 3))
The last code chunk shows how to make a stacked bar graph using the barplot() function in R.
# data
dat2016 <- c(14, 3,1,0.54,0.28,0.08,0.05)
dat2016_rev <- rev(dat2016)
barplotdata2016 <- matrix(c(dat2016_rev))
# labels
labels_x <- rev(c("Asian","African","Mixed", "Hispanic &\nLatin American",
"Pacific Islander","Arab & Middle East","Native peoples"))
par(mfrow = c(1,1))
barplot(barplotdata2016,
width = 0.01,
xlim = c(0,0.1),
axes = F,
col = c(1,2,3,4,5,6,7),
legend.text = labels_x)