Introduction

This data comes from Popejoy & Fullerton (2016) and is on the proportion of different ancestry representation in GWAS studies. It was gathered by Alice B. Popejoy and Stephanie M. Fullerton. Ancestry in each GWAS study was determined by analyzing the sample descriptions included in the studies. In 2009 the researchers did a similar study, thus they conducted it again in 2016 to track if any change had occurred.

Create data

This code creates vectors to contain the data and labels to make the pie graphs featured in this paper.

New line characters included for optimal spacing.

Ancestry2009 <- c(.81, .14, .05)
Ancestry2016 <- c(.96, .03, .01)
Labs <- c("\nEuropean ancestry\n", "\nAsian ancestry\n", "\nOther non-European\nancestry")

Pie graphs

Now we can create the pie graphs. First we use the par() command to specify our display parameters, then we can use pie() to create the graphs. We use the labels argument to add our labels vector, and the main argument to add a title. The radius argument lets us change the size of our graphs while the init.angle specifies what angle we want our slices to begin at. Finally, col = lets us enter a vector to specify the colors we want our slices to be.

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

# pie graph 2
# add main, init.angle, radius, and col
pie(Ancestry2016, labels = Labs, main = "2009",
    radius = 1, init.angle = -82, col = c(11,5,9))

Bar graphs

We can also make a stacked bar graph to represent this data.

# 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)