R Graphics Exercise¶
Do exercises 1-4 and if you have lots of time, exercise 5. In each case, your aim is to create a figure similar to the one shown for the pilot data set.
[1]:
library(tidyverse)
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
✔ ggplot2 3.1.1 ✔ purrr 0.3.2
✔ tibble 2.1.2 ✔ dplyr 0.8.1
✔ tidyr 0.8.3 ✔ stringr 1.4.0
✔ readr 1.3.1 ✔ forcats 0.4.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
[2]:
options(repr.plot.width=4, repr.plot.height=3)
[3]:
data <- read_tsv('data/gene_counts_raw.txt')
Parsed with column specification:
cols(
.default = col_double(),
Label = col_character(),
Media = col_character(),
Strain = col_character()
)
See spec(...) for full column specifications.
0. The Label column has 3 pieces of information Sample, Method andd Person in a single cell. Fix this and save the tidy DataFrame as df.
1. Plot a scatter plot of gene100 against gene 1001. Color points by the method used. Save the image as a PNG file ‘fig1.png’ in the ‘figs’ folder.
2. Make a boxplot plot of gene100 counts by method.
3. Make a jitter plot of gene100 counts by Media and color the points by method. Set the jitter width to be 0.2.
4. Make a grid of histograms of counts for gene100, with rows showing the person and columns showing the method used.
5. Make a row of boxplots of log counts of the top 5 genes where each column shows a different method.
Warning: This involves quite a bit of data processing.