Introduction

The data being plotted involves the percentages of general ethnicities around the world that are included in GWAS (genome-wide association studies). This data was collected by the US National Human Genome Research Institute in partnership with the European Bioinformatics Institute and displayed in the GWAS catalog. The data is collected whenever the curators receive news of a new GWAS report. The report goes through two rounds of data extraction and validation before it is added to the catalog. The process was repeated again in 2016 to see if there were any visible changes to the statistics since 2009.

Create data

This code chunk creates vectors for both the 2009 and 2016 data, with both percentages stored as integers in the vector. There are also two sets of labels created for both pie charts.

euro_non_euro_2016 <- c(81, 19)
labels1 <- c("European ancestry", "Non-European ancestry")

euro_non_euro_2009 <- c(96,4)
labels2 <- c("European ancestry", "Non-European ancestry")

Pie graphs

This code chunk plots both pie graphs at the top of the article next to each other with the correct percentage chunks. The left one is with the 2009 data and the right one is with the 2016 data.

# 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(euro_non_euro_2009, main = "2009", init.angle = -82, radius = 1, col = c(7,1,9), labels = labels2)

# pie graph 2
# add main, init.angle, radius, and col
pie(euro_non_euro_2016, main = "2016", init.angle = -82, radius = 1, col = c(2,8,3), labels = labels1)

Bar graphs

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)