The NIH collected data for the GWAS to determine ancestry. There were 2,511 studies that involved nearly 35 million samples. The process was repeated in order to compare 2009 to 2016. From there analysis and trends could be observed.
Here we have created the labels we will use for our pie chart. They contain our data that will be in the pie chart.
labels1 <- c("European ancestry", "Asian ancestry", "non\n European\n ancestry")
labels2 <- c("European ancestry", "Asian ancestry", "non European\n ancestry")
We create a pie graph by using the following code. The code contains our heading for each one, the radius of our pie graph, the color of each slice, the angle to which it will orientated and our data. Once all this comes together to make the pie chart.
# 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( main = "2009",
radius = 1,
col = c(1,2,7),
init.angle = -82,
x <- c(96,3,1),
labels = labels1)
# pie graph 2
# add main, init.angle, radius, and col
pie(main = "2016",
radius = 1,
col = c(1,8,2),
init.angle = -50,
x <- c(81,14,5),
labels = labels2)
# 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)