Examining Diversity in Genomics. The following data was collected by Alice B. Popejoy and Stephanie M. Fullerton. To determine the diversity data, they analysed the sample descriptions included in the GWAS Catalog. The authors recollected the data in 2016 to examine if the diversity in genomics had increased considering its abismal result from the 2009 analysis.
Initialize vectors containing the ancestory data for both 2009 and 2016, assign respective labels in a seperate vector to be used in the pie charts.
euro_asian_other_2016 <- c(81, 14, 5)
labels2016 <- c("European ancestory\n", "Asian ancestory\n", "Other Non-Euro ancestory\n")
euro_asian_other_2009 <- c(96, 3, 1)
labels2009 <- c("European ancestory\n", "Asian ancestory\n", "Other Non-Euro ancestory\n")
Create 2 pie charts containing the respective ancestory data from both 2009 and 2016. The colors were deliberately choosen to look bad.
# 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(x=euro_asian_other_2009, labels=labels2009, main="2009", init.angle= 0, radius=1, col=c(6,7,8))
# pie graph 2
# add main, init.angle, radius, and col
pie(x=euro_asian_other_2016,labels =labels2016, main="2016", init.angle= -50, radius=1, col=c(3,4,5))
If you want, you can examine this code below to see how stracked bar graphs are made
# 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)