File size: 2,611 Bytes
90f526e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#
# This Makefile perform the Mission Impossible RNA-seq analysis.
#
#
# More info in the Biostar Handbook volume RNA-Seq by Example
#

# The reference genome.
REF = refs/genome.fa

# The file containing transcripts.
TRX = refs/transcripts.fa

# The name of the HISAT2 index.
HISAT2_INDEX = idx/genome

# The name of the salmon index
SALMON_INDEX = idx/transcripts.salmon

# The design file.
DESIGN = design.csv

# These targets are not files.
.PHONY: data align results

# Tell the user to read the source of this Makefile to understand it.
usage:
	@echo "#"
	@echo "# Use the the source, Luke!"
	@echo "#"

# Create the design file and ids.txt file.
${DESIGN}:

	# The design file
	@echo "sample,condition" > design.csv
	@echo "BORED_1,bored" >> design.csv
	@echo "BORED_2,bored" >> design.csv
	@echo "BORED_3,bored" >> design.csv
	@echo "EXCITED_1,excited" >> design.csv
	@echo "EXCITED_2,excited" >> design.csv
	@echo "EXCITED_3,excited" >> design.csv

	# Create the ids.txt file (first column only, delete first line)
	cat design.csv | cut -f1 -d , | sed 1d > ids.txt

# Download the data for the analysis.
data:
	# Download the reference genome.
	wget -nc http://data.biostarhandbook.com/books/rnaseq/data/golden.genome.tar.gz

	# Unpack the reference genome.
	tar xzvf golden.genome.tar.gz

	# Download the sequencing reads.
	wget -nc http://data.biostarhandbook.com/books/rnaseq/data/golden.reads.tar.gz

	# Unpack the sequencing reads.
	tar zxvf golden.reads.tar.gz

# Build the HISAT2 and salmon index for the reference genomes
index: ${REF}
	mkdir -p idx
	hisat2-build ${REF} ${HISAT2_INDEX}
	salmon index -t ${TRX} -i ${SALMON_INDEX}

# Runs a HISAT2 alignment.
align: ${DESIGN} ${HISAT2_INDEX_FILE}
	mkdir -p bam
	cat ids.txt | parallel --progress --verbose "hisat2 -x ${HISAT2_INDEX} -1 reads/{}_R1.fq -2 reads/{}_R2.fq | samtools sort > bam/{}.bam"
	cat ids.txt | parallel -j 1 echo "bam/{}.bam" | \
		xargs featureCounts -p -a refs/features.gff -o counts.txt
	RScript code/parse_featurecounts.r

# Run a SALMON classification.
classify: ${DESIGN} ${SALMON_INDEX}
	mkdir -p salmon
	cat ids.txt | parallel --progress --verbose "salmon quant -i ${SALMON_INDEX} -l A --validateMappings -1 reads/{}_R1.fq -2 reads/{}_R2.fq  -o salmon/{}"
	RScript code/combine_transcripts.r

# Runs an analysis on the aligned data.
results:
	mkdir -p res
	RScript code/deseq2.r
	RScript code/create_heatmap.r

# Required software
install:
	@echo ""
	@echo mamba install wget parallel samtools subread hisat2 salmon bioconductor-tximport bioconductor-edger bioconductor-biomart bioconductor-deseq2 r-gplots
	@echo ""