Homework 2C: Graphs

This homework is about creating graphics to display and communicate results

Homework 2C expectations

Read through the entire homework before starting to answer a question.

How to work this homework

You may work together, but each of your must turn in your own report. Don’t “plagiarize” from each other. Do include in your report who you worked with.

What to turn in: A pdf file containing your R code, statistical results, and your answer to the questions. Use of RMarkdown recommended; however copy/paste into a word document is also acceptable.

Submit your work to CANVAS. Obey proper file naming formats.

Resources for this homework

Mike’s Biostatistics Book: Chapter 4

Mike’s Workbook for Biostatistics: A quick look at R and R Commander, Part01 – Part10 and refer also to code presented in Homework 2 from this workbook.

Additional R commands and or code provided below.


Questions

  1. Make a bar chart of the basal five hour fasting plasma glucose-to-insulin ratio of four inbred strains of mice, in order DBA, BL6, FVB, and 129.
    x <- c(44, 100, 105, 107) #(data from Berglund et al 2008)
  2. Why should you use box plots and not bar charts to display comparisons for a ratio scale variable between categories? Obtain a copy of the article by Streit and Gehlenbor 2014 — it’s free! After reading, summarize the pro and cons for box plots over bar charts with error bars.
  3. Enter the following data into R. The data are sulfate levels in water, parts per million.
    type = c("Palolo Stream","Chaminade tap water", "Aquafina","Dasani") 
    sulfateppm =c(11, 14, 5, 12)
    try = data.frame(type,sulfateppm) 
    byWater = tapply(try$sulfateppm,list(Group=try$type),mean)

    Make a simple barchart using the boxplot2 function in gplots package.
    (a) Change the range of values on the vertical axis to 0, 20
    (b) Change the color of the bars from gray to blue
    (c) Add a label to the vertical axis, “Sulfates, ppm” (without the quotes)
    (d) Add a box around the graph.

  4. Make a scatterplot of Height (inches) of mothers by Height (inches) of fathers,
    mom <- c(67, 66.5, 64, 58.5, 68, 66.5) #(data from GaltonFamilies in R package HistData)
    and fathers,
    dad <- c(78.5, 75.5, 75, 75, 74, 74) #(data from GaltonFamilies in R package HistData)
  5. Make a plot of Carbon dioxide (CO2) readings from Mauna Loa for the month of December for demi-decade 1960 – 2020
    years <-c (1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020) #obviously, do not calculate statistics on years; you can use to make a plot
    co2 <- c(316.19, 319.42, 325.13, 330.62, 338.29, 346.12, 354.41, 360.82, 396.83, 380.31, 389.99, 402.06, 414.26) #data from Dr. Pieter Tans, NOAA/GML (gml.noaa.gov/ccgg/trends/) and Dr. Ralph Keeling, Scripps Institution of Oceanography (scrippsco2.ucsd.edu/)
  6. Make a box plot of body mass of Rhinella marina (formerly Bufo marinus),
    bufo <- c(71.3, 71.4, 74.1, 85.4, 85.4, 86.6, 97.4, 99.6, 107, 115.7, 135.7, 156.2)
  7. Re-create heat map for Comet assay experiment described in . The data, a R code to load the data, were
    myData <- read.table(header=TRUE, sep=",", text="
    Copper, Hazel, HazelCopper
    0.02404672, 0.007185706, 0.02663191
    0.06711479, 0.027020958, 0.03181153
    0.12196060, 0.037725842, 0.03743693
    0.13308991, 0.044762867, 0.03851548
    0.13344032, 0.045809398, 0.18787608
    0.17537831, 0.060942269, 0.19494708
    ")

    (a) Make the heat map with the default settings, including dendrograms.
    (b) Make another heat map, but do not make dendrograms.
    (c) Compare graph a and graph b. Did the order change?
    (d) Change the color pallet and recreate graph b

R commands, copy, paste & modify to Script

To access R help menu for a command, add question mark in front of the command. For example, ?plot brings up the help page in your default browser

See Mike’s Biostatistics Book, Chapter 4