-
Notifications
You must be signed in to change notification settings - Fork 5
/
class3solutions.Rmd
81 lines (68 loc) · 3.05 KB
/
class3solutions.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: 'Class 3 In-Class Exercises: Solutions'
author: "Amy Allen & Dayne Filer"
date: "June 28, 2016"
output:
pdf_document:
highlight: tango
html_document: null
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)
```
<!-- Here we style out button a little bit -->
<style>
.showopt {
background-color: #004c93;
color: #FFFFFF;
width: 100px;
height: 20px;
text-align: center;
vertical-align: middle !important;
border-radius: 8px;
float:right;
}
.showopt:hover {
background-color: #dfe4f2;
color: #004c93;
}
</style>
<!--Include script for hiding output chunks-->
<script src="hideOutput.js"></script>
Load the data
```{r}
setwd("~/Documents/rclass")
data <- read.csv("yeastmutants.csv", header = TRUE)
```
1. Plot the average pheromone response for all three cell types. Plot them as lines, not points (remember: the argument `type` for `plot` and the function `lines` which is similar to `points`). Make each cell type a different color and create a legend to match.
```{r}
plot(x = data$Time, y = data$sst2.avg, type = "l", main = "Yeast Response to Pheromone",
xlab = "Time (minutes)", ylab = "Mean pheromone response", col = "green")
lines(x = data$Time, y = data$gpa1.avg, col = "red")
lines(x = data$Time, y = data$wt.avg, col = "black")
legend("bottomright", c("sst2 mutant","gpa1 mutant","wild type"), lty = 1,
col = c("green","red","black"))
```
\pagebreak
2. Plot the standard deviation of the pheromone response for all three cell types. Plot them as points making each cell type a different color. Create a legend to match.
```{r}
plot(x = data$Time, y = data$sst2.stdev, type = "l", main = "Yeast Response to Pheromone",
xlab = "Time (minutes)", ylab = "Standard deviation of pheromone response", col = "green")
lines(x = data$Time, y = data$gpa1.stdev, col = "red")
lines(x = data$Time, y = data$wt.stdev, col = "black")
legend("bottomright", c("sst2 mutant","gpa1 mutant","wild type"), lty = 1,
col = c("green","red","black"))
```
\pagebreak
3. Noise in cells is often quantified by the coefficient of variation (CV) because it normalizes the standard deviation for differences in the mean. CV is defined as $CV=\sigma/\mu$ where $\sigma$ is the standard deviation and $\mu$ is mean. Create new variables in the data frame for the CV for each cell type. (Rememeber: you can use subsetting to assign new variables). Then create a plot of the CV for all cell types following the same guidelines as in questions 1 and 2.
```{r}
data$wt.cv <- data$wt.stdev/data$wt.avg
data$gpa1.cv <- data$gpa1.stdev/data$gpa1.avg
data$sst2.cv <- data$sst2.stdev/data$sst2.avg
plot(x = data$Time, y = data$gpa1.cv, type = "l", main = "Yeast Response to Pheromone",
xlab = "Time (minutes)", ylab = "Standard deviation of pheromone response", col = "red")
lines(x = data$Time, y = data$sst2.cv, col = "green")
lines(x = data$Time, y = data$wt.cv, col = "black")
legend("bottomright", c("sst2 mutant","gpa1 mutant","wild type"), lty = 1,
col = c("green","red","black"))
```