Authors and scientists Alice Popejoy and Stephanie Fullerton collected this data on the failing diversity of genomics. This data was collected by analyzing sample descriptions in the GWAS catalog through a similar approach used in 2009. This process was repeated in 2016 in order to determine representation of participants of non-European descent in GWAS. They found that the proportion of samples used of individuals of non-European descent increased fivefold, but as an increase of Asians were included, there still existed underrepresentation of other ethnicities.
In this code chunk, 2 vectors are created containing the percentage data of European ancestry, Asian ancestry, and other non-European ancestry in 2009 and 2016. Another vector is also created with the names of each label for the different sections of the pie graph.
euro_asian_other2009 <- c(96, 3, 1)
euro_asian_other2016 <- c(81, 14, 5)
labels1 <- c("European", "Asian", "Other")
A 1 x 2 grid is creating using the par() command. The pie() command creates each pie graph. One pie graph represents the ancestry distribution in 2009 and the other in 2016. Regarding the arguments, main = sets a title for the bar graph, init.angle changes the appearance of the graph as it sets the starting angle for the first segment of the pie graph, radius sets the radius, and col allows you to change the color of each segment of the pie graph.
# 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_other2009, labels = labels1, main = "2009", init.angle = -82, radius = 1, col = c(1, 2, 3))
# pie graph 2
# add main, init.angle, radius, and col
pie(x = euro_asian_other2016, labels = labels1, main = "2016", init.angle = -82, 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)