-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwasabi_sleuth_workflow.Rmd
More file actions
95 lines (86 loc) · 2.29 KB
/
wasabi_sleuth_workflow.Rmd
File metadata and controls
95 lines (86 loc) · 2.29 KB
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
---
title: "WASABI Sleuth Workflow"
author: "suresh"
date: "20 May 2018"
output: html_document
---
### Load libraries
```{R}
suppressMessages(library(tximport))
suppressMessages(library(readr))
suppressMessages(library(stringr))
suppressMessages(library(assertr))
suppressMessages(library(ggplot2))
suppressMessages(library(wasabi))
suppressMessages(library(sleuth))
suppressMessages(library(pheatmap))
```
### Create directory to store results
```{R}
dir.create("results/sleuth_results")
```
### Prepare the sample names and condition
```{R}
# Load sample information
samples=data.frame(samples=col_concat(str_split_fixed(list.files("./results/salmon"),"_",5)[,2:3],"_"), condition=str_split_fixed(list.files("./results/salmon"),"_",5)[,2])
samples
```
### store the sammple (parent) directory information
```{R}
sfdirs <- file.path("results/salmon", c(list.files("results/salmon")))
sfdirs
```
### Create files necessary for Sleuth analysis. Function is provided by Wasabi.
```{R}
prepare_fish_for_sleuth(sfdirs)
```
### Preparation for sleuth
```{R}
sfdata=data.frame(sample=list.files("results/salmon"), path=sfdirs, condition=samples$condition, stringsAsFactors = F)
```
```{R}
design = ~condition
```
```{R}
tx2gene=read.csv("reference/t2gene.dedup.tsv", sep = "\t",stringsAsFactors = F, header=F)
names(tx2gene)=c("target_id","HGNC")
```
### Sleuth object
```{R}
so <- sleuth_prep(sfdata, design, target_mapping = tx2gene,num_cores = 1)
```
### Sleuth fit
```{R}
so <- sleuth_fit(so)
```
### Extract expression data
```{R}
oe <- sleuth_wt(so, 'conditiontumor')
```
### Sleuth results as data frame
```{R}
sleuth_results_oe=sleuth_results(oe, 'conditiontumor', show_all = TRUE)
```
### Remove rows with no data # Remove rows with no data
```{R}
sloe=sleuth_results_oe[complete.cases(sleuth_results_oe),]
```
### Write the results to hard disk
```{R}
write.csv(sloe, "results/sleuth_results/sleuth_expression_results.txt", sep="\t")
```
### Merge gene names from tx2gene object and order by qvalue
```{R}
mer_sloe=merge(sloe, tx2gene, all.x=T)
```
```{R}
head(mer_sloe[order(mer_sloe$qval),])
```
### Write the results to hard disk
```{R}
write.csv(sloe, "results/sleuth_results/sleuth_expression_results_merged.txt", sep="\t")
```
### Save the workflow to HDD
```{R}
save.image("results/sleuth_results/sleuth_results.Rdata")
```