Introduction

The data was analyzed by Alice B. Popejoy who is a PhD candisate and Stephanie M. Fullerton who is an associate professor.

The data is accessed through the GWAS Catalog (collection of human genome-associated studies); race, ethnicity, and ancestry is extranted from this comprehensive summary of genetic research.

#The process had to be repeated in 2016 because a vast majority (96%) of the participants in the genome-wide association studies (GWAS) were of European descent, lacking diversity. The diversity increase is due to an increased amount of asian studies, leaving out Africans and hispanics.

Create data

Create vectors to contain the data and labels to make the pie graphs at the top of figures.

Each vector has 3 elements: European ancestry, Asian ancestry, and other non-European ancestry.

DO NOT name your vector for the labels “labels”, since this is the name of an existing R function.

Include new line characters in the text as needed to improve spacing.

euro_noneuro <- c(81, 19)
labels1 <- c("European", "Non-european")

sum(euro_noneuro)
## [1] 100
pie(x = euro_noneuro, labels = labels1)

euro_asian_other <- c(81, 14, 4)
labels2 <- c("European\nancestry", "Asian\nancestry", "Other\nnon-European\nancestry")

sum(euro_asian_other)
## [1] 99
par(mfrow = c(1,3), mar = c(1, 1, 1, 1))
pie(x = euro_asian_other, labels = labels2, main = "2009")
pie(x = euro_asian_other, labels = labels2, main = "2016")
pie(x = euro_asian_other, labels = labels2, main = "2019")

Pro Tip: adding a new line character in front of the text or behind it in your labels and help you adjust spacing. E.g. “European” or “” (note - if you don’t delete this instruction the preceding text will have some weird features.)

Pie graphs

  1. Create a 1 x 2 grid using the command par(mfrow = c(1,2))
  2. Plot the 2009 data on the left and 2016 data on the right.
  3. This will require setting up the pie command twomce
  4. Use the argument main = … to add a title to above the plots
  5. Set the argument init.angle = … to -82. Experiment with how this affects the plot.
  6. Set the argument radius = … to 1. Experiment with how this affects the plot.
  7. Set the argument col = … to c(1,2,3), then experiment with different numbers. Try to make it ugly.
# 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(...)
# pie graph 2
# add main, init.angle, radius, and col
#pie(...)

euro_noneuro <- c(81, 19)
labels1 <- c("European", "Non-european")

sum(euro_noneuro)
## [1] 100
pie(x = euro_noneuro, labels = labels1)

euro_asian_other <- c(81, 14, 4)
labels2 <- c("European\nancestry", "Asian\nancestry", "Other\nnon-European\nancestry")

sum(euro_asian_other)
## [1] 99
par(mfrow = c(1,2), mar = c(1, 1, 1, 1))

pie(x = euro_asian_other, labels = labels2, main = "2009")
pie(x = euro_asian_other, labels = labels2, main = "2016")

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)