-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
269 lines (269 loc) · 14.3 KB
/
.Rhistory
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none")
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right", limits = c(0, 0.30))
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), limits = c(0, 0.30))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
long_5p_single_stranded
llong_3p_single_stranded
long_3p_single_stranded
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), limits = c(0, 0.30))
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none")
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right", limits = c(0, 0.30))
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), limits = c(0, 0.30))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
View(raw_5p_single_stranded)
View(long_5p_single_stranded)
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none")
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right", limits = c(0, 0.40))
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), limits = c(0, 0.40))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none") +
ggplot2::coord_cartesian(ylim = c(0, 0.3))
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right")
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_bw() +
ggplot2::theme(legend.position = "none") +
ggplot2::coord_cartesian(ylim = c(0, 0.3))
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right")
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
library(readr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(patchwork)
type_colours <- c("C>T" = "red", "G>A" = "blue", "A>C" = "grey", "A>G" = "grey", "A>T" = "grey", "C>A" = "grey", "C>G" = "grey", "G>C" = "grey", "G>T" = "grey", "T>A" = "grey", "T>C" = "grey", "T>G" = "grey", "insertion" = "grey", "deletion" = "grey")
raw_5p_single_stranded <- readr::read_tsv("assets/data/single-stranded/5p_freq_misincorporations.txt", comment = "#")
raw_3p_single_stranded <- readr::read_tsv("assets/data/single-stranded/3p_freq_misincorporations.txt", comment = "#")
pivot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- x %>%
dplyr::rename(insertion = `->ACGT`, deletion = `ACGT>-`, Position = Pos) %>%
tidyr::pivot_longer(tidyr::contains(c(">", "insertion", "deletion")), names_to = "Mutation Type", values_to = "Frequency") %>%
dplyr::mutate(`Mutation Type` = factor(`Mutation Type`, levels = rev(names(type_colours))))
if (reverse) {
result <- result %>%
dplyr::mutate(Position = Position * -1)
}
result
}
plot_longer_freqmisincorporation <- function(x, reverse, type_colours) {
result <- ggplot2::ggplot(x, aes(x = Position, y = Frequency, colour = `Mutation Type`)) +
ggplot2::geom_line() +
ggplot2::scale_colour_manual(values = type_colours, guide = ggplot2::guide_legend(reverse = TRUE)) +
ggplot2::facet_wrap(~end, ncol = 2) +
ggplot2::theme_classic() +
ggplot2::theme(legend.position = "none") +
ggplot2::coord_cartesian(ylim = c(0, 0.3))
if (reverse) {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, -14, -1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05), position = "right")
} else {
result <- result +
ggplot2::scale_x_continuous(breaks = seq(0, 14, 1)) +
ggplot2::scale_y_continuous(breaks = seq(0, 0.30, 0.05))
}
result
}
long_5p_single_stranded <- pivot_longer_freqmisincorporation(raw_5p_single_stranded, reverse = FALSE, type_colours = type_colours) %>% mutate(end = "5p")
long_3p_single_stranded <- pivot_longer_freqmisincorporation(raw_3p_single_stranded, reverse = TRUE, type_colours = type_colours) %>% mutate(end = "3p")
smiley_5p_single_stranded <- plot_longer_freqmisincorporation(long_5p_single_stranded, reverse = FALSE, type_colours)
smiley_3p_single_stranded <- plot_longer_freqmisincorporation(long_3p_single_stranded, reverse = TRUE, type_colours)
smiley_5p_single_stranded
styler:::style_active_file()
styler:::style_active_file()
options(languageserver.formatting_style = function(options)
{
styler::tidyverse_style(strict = TRUE)
})