-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbioanalyzer_analysis.R
97 lines (83 loc) · 4.28 KB
/
bioanalyzer_analysis.R
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
# >> Bioanalyzer analysis << #
# load libraries ----
library(here)
source(here("Rscripts/load_libraries.R"))
# data ----
## Bioanalyzer data - polyA tailing ====
### read in data and change dataset names ####
index <- data.table(sample.index = 1:11,
dataset = c("raw_RNA_replicate1", "raw_RNA_replicate2", "raw_RNA_replicate3", "raw_RNA_replicate4",
"polyA_RNA_replicate1","polyA_RNA_replicate2","polyA_RNA_replicate3","polyA_RNA_replicate4",
"empty", "empty", "ladder"))
RIN_polyA_sample <- bioanalyzeR::read.electrophoresis(here("data/bioanalyzer_data/RIN/RIN.xml"))
### make sample table ####
RIN_polyA_sample_table <- RIN_polyA_sample$data %>%
as_tibble() %>%
left_join(index) %>%
dplyr::filter(!dataset %in% c("ladder", "empty")) %>%
dplyr::filter(!is.na(fluorescence)) %>%
group_by(dataset) %>%
dplyr::filter(!is.na(fluorescence)) %>%
dplyr::mutate(f_scale = scales::rescale(fluorescence, to = c(0,100))) %>%
ungroup() %>%
dplyr::mutate(group = ifelse(str_sub(dataset,1,3) == "raw", "raw", "polyA"),
rep = paste0("Replicate ",str_sub(dataset,-1,-1)))
### extract ladder peaks ####
ladder <- RIN_polyA_sample$peaks %>%
filter(sample.index == 11,
peak.observations == "Ladder Peak")
## Bioanalyzer data - PCR effect ====
sample_names2 <- data.table(sample.index = 1:12,
dataset = c("cDNA_NOTEX_replicate1_PCR11",
"cDNA_NOTEX_replicate1_PCR12", "cDNA_NOTEX_replicate1_PCR12_dil",
"cDNA_NOTEX_replicate1_PCR13","cDNA_NOTEX_replicate1_PCR13_dil",
"cDNA_NOTEX_replicate1_PCR14","cDNA_NOTEX_replicate1_PCR14_dil",
"cDNA_NOTEX_replicate1_PCR15_dil","cDNA_NOTEX_replicate1_PCR15",
"cDNA_NOTEX_replicate2_PCR13", "cDNA_NOTEX_replicate2_PCR13_dil",
"Ladder"))
bio2 <- bioanalyzeR::read.electrophoresis(here("data/bioanalyzer_data/PCR_effect/PCR.xml"))
peaks <- bio2$data %>%
as_tibble() %>%
left_join(sample_names2) %>%
dplyr::filter(!dataset %in% c("Ladder",
"cDNA_NOTEX_replicate1_PCR11",
"cDNA_NOTEX_replicate2_PCR13"),
str_sub(dataset, -3,-1) != "dil") %>%
#left_join(marker, by = sample.index)
group_by(dataset) %>%
dplyr::filter(!is.na(fluorescence)) %>%
dplyr::filter(aligned.time >= 60 & aligned.time <= 110) %>%
dplyr::mutate(fluorescence2 = scales::rescale(fluorescence, to = c(0,100))) %>%
ungroup() %>%
dplyr::mutate(group_tex = ifelse(str_sub(dataset,6,7) != "TE", "NOTEX", "TEX"),
dataset = str_sub(dataset, nchar(dataset)-1, nchar(dataset)))
sizes <- bio2$peaks %>%
filter(sample.index == 12,
peak.observations == "Ladder Peak")
# plot ----
## RIN & effect of polyA tailing - Supplementary Fig. 2A ====
ggplot(data = RIN_polyA_sample_table,
aes(x = aligned.time, y = f_scale,
fill = group)) +
facet_grid(rows = vars(rep)) +
geom_area(alpha = 0.75) +
geom_line(color = "black", size = 0.5) +
scale_x_log10(limits = c(30,55),breaks = c(22.5, (ladder$aligned.time)), labels = c(25, (ladder$length))/1000, expand = c(0,0)) +
scale_y_continuous(limits = c(0,100), expand = c(0,0)) +
scale_fill_manual(values = c("#648FFF", "#595959")) +
theme_Publication_white() +
ylab("Relative fluorescence") +
xlab("Size (kb, bioanalyzer scale") +
theme(panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(linetype = "dashed", color = "black"))
## PCR effect - Supplementary Fig. 2B ====
ggplot(data = peaks, aes(x = aligned.time, y = fluorescence2)) +
geom_line() +
facet_grid(rows = vars(dataset)) +
geom_area(alpha = 0.75, fill = "#595959") +
scale_x_log10(limits = c(60,110),breaks = c(22.5, (sizes$aligned.time)), labels = c(25, (sizes$length))/1000, expand = c(0,0)) +
theme_Publication_white() +
ylab("Relative fluorescence") +
xlab("Size (kb, bioanalyzer scale") +
theme(panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(linetype = "dashed", color = "black"))