Introduction

The data shown in the following pie graphs is from the paper “Genomics is Failing on Diversity” written by Alice B. Popejoy and Stephanie M. Fullerton. They were investigating the proportions of different ethnicities and their representation in Genome-Wide Association Studies, where in 2009, 96% of data came from individuals of European descent. They collected the data through the GWAS Catalog, but with a surge of new findings, an updated 2016 study showed nearly 20% of individuals came from non-European descent, mainly of Asian descent. There was a repeat of the study in 2016 because of the noticeable shift in heritage.

Create data

In this step we create vectors to hold the percentages of European, Asian, and non-European descent from each study. We also make labels for their respective pie graphs.

study_2009 <- c(96, 3, 1)
study_2016 <- c(81, 14, 5)
labels1 <- c("European\nAncestry", "Asian\nAncestry", "Other\nNon-European\nAncestry")
labels2 <- c("European\nAncestry", "Asian\nAncestry", "Other\nNon-European\nAncestry")

Pie graphs

The par() function sets up dimensions for the pie graphs. Because we want our pie graphs next to each other, par() is set up as 1 row, 2 columns. The pie() function takes the vectors previously created as arguments to create the pie graph.

# set up par()
par(mfrow = c(1,2), mar = c(2,3,1,5))

#2009 Study
pie(x = study_2009,
    labels = labels1,
    main = "2009",
    init.angle = -82,
    radius = 1,
    col = c(5,6,1))

#2016 Study
pie(x = study_2016,
    labels = labels2,
    main = "2016",
    init.angle = -60,
    radius = 1,
    col = c(5,6,1))

Bar graphs

If you want, you can examine this code below to see how stacked 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)