Assignment information: (delete this when you submit) In this assignment you will re-build the pie graphs shown in the paper “Genomics is failing on diversity” by Popejoy and Fullerton (https://www.nature.com/articles/538161a). Delete all instructions and replace with short explanatory text about all code chunks. Be sure to change the title in the YAML header.
If possible, save this file to your Teams folder.
Write a brief introduction about the data being plotted, including the information
Alice B. Popejoy and Stephanie M. Fullerton collected data on the ethnic backgrounds of participants in all GWAS studies performed upto 2009. This data was taken from 373 GWAS studies in the GWAS catalog. Results of this study showed that almost all participants included in these studies were of European descent. They repeated this study using new data in 2016 because there had been more than a 2000% increase in data collected.
Create vectors to contain the data and labels to make the pie graphs at the top of figures.
Each vector has 3 elements: European ancestry, Asian ancestry, and other non-European ancestry.
DO NOT name your vector for the labels “labels”, since this is the name of an existing R function.
Include new line characters in the text as needed to improve spacing.
study2009<-c(96, 3, 1)
study2016<-c(81, 14, 5)
labels<-c("European \nancestry","Asian","Other \nnon-European")
# set up par()
par(mfrow = c(1,2), mar = c(8,2, 8, 2))
#pie graphs 1
# add main, init.angle, radius, and col
pie(study2009, labels, main = 2009, init.angle = -182, radius = 1, col = c(1,2,3))
# pie graph 2
# add main, init.angle, radius, and col
pie(study2016, labels, main = 2016, init.angle = -182, radius = 1, col = c(1,2,3))
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)