-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture-07-inclass.Rmd
94 lines (72 loc) · 1.54 KB
/
lecture-07-inclass.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
82
83
84
85
86
87
88
89
```{r}
library(tidyverse)
library(readxl)
```
```{r}
chr16 <- read_tsv("~/Desktop/chr16_roi.tsv",
col_names = c("Chrom",
"Start",
"End",
"Sequence",
"Count",
"Strand"))
```
```{r}
chr16 <-
chr16 |>
mutate(Midpoint = (Start + End)/2)
```
```{r}
ggplot(chr16, aes(x = Midpoint, y = Count)) +
geom_point() +
ylim(0,7)
```
```{r}
pileup <- function(start, end){
coords <- c()
for (i in 1:length(start)) {
newcoords <- start[i]:end[i]
coords <- c(coords, newcoords)
}
coords
}
```
```{r}
pileup(c(1, 3), c(5,8))
```
```{r}
pileup_coords <- pileup(chr16$Start, chr16$End)
```
```{r}
hist(pileup_coords, breaks = 400)
```
```{r}
pileup_df <- data_frame(coords = pileup_coords)
```
```{r}
ggplot(pileup_df, aes(x = coords)) +
geom_histogram(bins = 400) +
scale_y_continuous(trans = "log2")
```
```{r}
library(readxl)
```
```{r}
ts4 <- read_excel(
"~/Desktop/Nagalakshmi_etal_2008_from_TableS4.xls")
```
```{r}
ggplot(ts4,
aes(x = SGD_Start,
y = Chrom,
width = SGD_End - SGD_Start + 1,
fill = Transcription_level_log2,
height=0.5)) +
scale_fill_distiller(palette="RdYlBu",
#direction=-1,
na.value = "white",
limits = c(0,10)) +
geom_tile() +
theme_classic()
ggsave("expression-output.png", dpi=600)
```