-
Notifications
You must be signed in to change notification settings - Fork 0
/
mondet.Rmd
136 lines (108 loc) · 4.65 KB
/
mondet.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
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
---
title: "Varroa microbiome"
author: "Sasha Mikheyev"
date: "1/23/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache = T)
```
```{r library}
library(tidyverse)
library(sleuth)
```
```{r sleuth}
bacteria <- read_tsv("mondet/gene_calls_nr.bacteria.tsv", col_names = c("contig", "protein_id", "taxname"), col_types = "-c---c-c") %>% filter(grepl("Bacteria", taxname)) %>% mutate(wolbachia = ifelse(grepl("Wolbachia", taxname), "yes", "no")) %>% separate(taxname, sep = ";\\s+", into = c("Bacteria",LETTERS[1:6]), extra = 'drop') %>% mutate(F = sub(";", "", F))
samples <- tibble(id = dir(file.path("mondet/kallisto"))) %>% mutate(path = paste0("mondet/kallisto/", id)) %>%
left_join(read_tsv("mondet/treatments.tsv", col_types = cols())) %>% mutate(sample = id, condition = shortName)
```
### Comparing males vs young
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("young", "males")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Phoretics vs caged
There were nio
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("phoretic", "phoreticCaged")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Phoretic vs arresting
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("phoretic", "arresting")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Аrresting vs. pre-laying
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("phoretic", "prelaying")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Pre-laying vs. Laying
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("phoretic", "laying")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Laying vs. post-laying
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("laying", "postlaying")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```
### Post-laying vs. Emerging
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("postlaying", "emerging")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
sleuth_significant %>% left_join(bacteria, by = c("target_id" = "contig")) %>% dplyr::filter(!is.na(A)) %>% ggplot(aes(A))+geom_histogram(stat = "count") + scale_y_log10() + coord_flip()
```
### Post-laying vs. non-laying
```{r}
so <- sleuth_prep(dplyr::filter(samples, shortName %in% c("postlaying", "nonlaying")), extra_bootstrap_summary = TRUE)
so <- sleuth_fit(so, ~condition, 'full')
so <- sleuth_fit(so, ~1, 'reduced')
so <- sleuth_lrt(so, 'reduced', 'full')
sleuth_table <- sleuth_results(so, 'reduced:full', 'lrt', show_all = FALSE)
sleuth_significant <- dplyr::filter(sleuth_table, qval <= 0.05)
dim(sleuth_significant)
head(sleuth_significant)
```