-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemux.sh
207 lines (187 loc) · 8.97 KB
/
demux.sh
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
#!/bin/bash
#SBATCH --job-name=demux_five
#SBATCH --output=demux_five_species_%j.out
#SBATCH --time=20:00:00
#SBATCH --cpus-per-task=8
#SBATCH --mem=32G
#SBATCH --partition=campus-new
#SBATCH --mail-type=END,FAIL
#SBATCH [email protected]
# Load modules
ml CellRanger
ml STAR
ml pipseeker
# Paths to FASTA files
fasta1="./genomes/Cat/Felis_catus.Felis_catus_9.0.dna.toplevel.fa"
fasta2="./genomes/Chicken/Gallus_gallus.bGalGal1.mat.broiler.GRCg7b.dna.primary_assembly_combined.fa"
fasta3="./genomes/Green_Monkey/Chlorocebus_sabaeus.ChlSab1.1.dna.toplevel.fa"
fasta4="./genomes/Rabbit/Oryctolagus_cuniculus.OryCun2.0.dna.toplevel.fa"
fasta5="./genomes/Rat/Rattus_norvegicus_mRatBN7.2.dna.primary_assembly_combined.fa"
# Paths to GTF files
gtf1="./genomes/Cat/Felis_catus.Felis_catus_9.0.111.gtf"
gtf2="./genomes/Chicken/Gallus_gallus.bGalGal1.mat.broiler.GRCg7b.111.gtf"
gtf3="./genomes/Green_Monkey/Chlorocebus_sabaeus.ChlSab1.1.111.gtf"
gtf4="./genomes/Rabbit/Oryctolagus_cuniculus.OryCun2.0.111.gtf"
gtf5="./genomes/Rat/Rattus_norvegicus.mRatBN7.2.111.gtf"
# Check if files exist
for file in $fasta1 $fasta2 $fasta3 $fasta4 $fasta5 $gtf1 $gtf2 $gtf3 $gtf4 $gtf5; do
if [[ ! -f $file ]]; then
echo "Error: $file not found!" >&2
exit 1
fi
done
# Step 1: Concatenate FASTA files for different species
# Add prefixes for each of the species
sed 's/^>/>fc_/' $fasta1 > ./genomes/Cat/Felis_catus_prefixed.fa
sed 's/^>/>gg_/' $fasta2 > ./genomes/Chicken/Gallus_gallus_prefixed.fa
sed 's/^>/>cs_/' $fasta3 > ./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed.fa
sed 's/^>/>oc_/' $fasta4 > ./genomes/Rabbit/Oryctolagus_cuniculus_prefixed.fa
sed 's/^>/>rn_/' $fasta5 > ./genomes/Rat/Rattus_norvegicus_prefixed.fa
# Paths to prefixed FASTA files
pf_fasta1="./genomes/Cat/Felis_catus_prefixed.fa"
pf_fasta2="./genomes/Chicken/Gallus_gallus_prefixed.fa"
pf_fasta3="./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed.fa"
pf_fasta4="./genomes/Rabbit/Oryctolagus_cuniculus_prefixed.fa"
pf_fasta5="./genomes/Rat/Rattus_norvegicus_prefixed.fa"
cat $pf_fasta1 $pf_fasta2 $pf_fasta3 $pf_fasta4 $pf_fasta5 > five_species_combined_genome.fa
# Step 2: Filter the GTF files
# Felis catus
cellranger \
mkgtf $gtf1 ./genomes/Cat/Felis_catus.Felis_catus_9.0.111.filtered.gtf \
--attribute=gene_biotype:protein_coding \
--attribute=gene_biotype:lncRNA \
--attribute=gene_biotype:IG_C_gene \
--attribute=gene_biotype:IG_D_gene \
--attribute=gene_biotype:IG_J_gene \
--attribute=gene_biotype:IG_LV_gene \
--attribute=gene_biotype:IG_V_gene \
--attribute=gene_biotype:TR_C_gene \
--attribute=gene_biotype:TR_D_gene \
--attribute=gene_biotype:TR_J_gene \
--attribute=gene_biotype:TR_V_gene \
--attribute=gene_biotype:IG_V_pseudogene \
--attribute=gene_biotype:IG_J_pseudogene \
--attribute=gene_biotype:IG_C_pseudogene \
--attribute=gene_biotype:TR_V_pseudogene \
--attribute=gene_biotype:TR_J_pseudogene
# Gallus gallus
cellranger \
mkgtf $gtf2 ./genomes/Chicken/Gallus_gallus.bGalGal1.mat.broiler.GRCg7b.111.filtered.gtf \
--attribute=gene_biotype:protein_coding \
--attribute=gene_biotype:lncRNA \
--attribute=gene_biotype:IG_C_gene \
--attribute=gene_biotype:IG_D_gene \
--attribute=gene_biotype:IG_J_gene \
--attribute=gene_biotype:IG_LV_gene \
--attribute=gene_biotype:IG_V_gene \
--attribute=gene_biotype:TR_C_gene \
--attribute=gene_biotype:TR_D_gene \
--attribute=gene_biotype:TR_J_gene \
--attribute=gene_biotype:TR_V_gene \
--attribute=gene_biotype:IG_V_pseudogene \
--attribute=gene_biotype:IG_J_pseudogene \
--attribute=gene_biotype:IG_C_pseudogene \
--attribute=gene_biotype:TR_V_pseudogene \
--attribute=gene_biotype:TR_J_pseudogene
# Chlorocebus sabaeus
cellranger \
mkgtf $gtf3 ./genomes/Green_Monkey/Chlorocebus_sabaeus.ChlSab1.1.111.filtered.gtf \
--attribute=gene_biotype:protein_coding \
--attribute=gene_biotype:lncRNA \
--attribute=gene_biotype:IG_C_gene \
--attribute=gene_biotype:IG_D_gene \
--attribute=gene_biotype:IG_J_gene \
--attribute=gene_biotype:IG_LV_gene \
--attribute=gene_biotype:IG_V_gene \
--attribute=gene_biotype:TR_C_gene \
--attribute=gene_biotype:TR_D_gene \
--attribute=gene_biotype:TR_J_gene \
--attribute=gene_biotype:TR_V_gene \
--attribute=gene_biotype:IG_V_pseudogene \
--attribute=gene_biotype:IG_J_pseudogene \
--attribute=gene_biotype:IG_C_pseudogene \
--attribute=gene_biotype:TR_V_pseudogene \
--attribute=gene_biotype:TR_J_pseudogene
# Oryctolagus cuniculus
cellranger \
mkgtf $gtf4 ./genomes/Rabbit/Oryctolagus_cuniculus.OryCun2.0.111.filtered.gtf \
--attribute=gene_biotype:protein_coding \
--attribute=gene_biotype:lncRNA \
--attribute=gene_biotype:IG_C_gene \
--attribute=gene_biotype:IG_D_gene \
--attribute=gene_biotype:IG_J_gene \
--attribute=gene_biotype:IG_LV_gene \
--attribute=gene_biotype:IG_V_gene \
--attribute=gene_biotype:TR_C_gene \
--attribute=gene_biotype:TR_D_gene \
--attribute=gene_biotype:TR_J_gene \
--attribute=gene_biotype:TR_V_gene \
--attribute=gene_biotype:IG_V_pseudogene \
--attribute=gene_biotype:IG_J_pseudogene \
--attribute=gene_biotype:IG_C_pseudogene \
--attribute=gene_biotype:TR_V_pseudogene \
--attribute=gene_biotype:TR_J_pseudogene
# Rattus norvegicus
cellranger \
mkgtf $gtf5 ./genomes/Rat/Rattus_norvegicus.mRatBN7.2.111.filtered.gtf \
--attribute=gene_biotype:protein_coding \
--attribute=gene_biotype:lncRNA \
--attribute=gene_biotype:IG_C_gene \
--attribute=gene_biotype:IG_D_gene \
--attribute=gene_biotype:IG_J_gene \
--attribute=gene_biotype:IG_LV_gene \
--attribute=gene_biotype:IG_V_gene \
--attribute=gene_biotype:TR_C_gene \
--attribute=gene_biotype:TR_D_gene \
--attribute=gene_biotype:TR_J_gene \
--attribute=gene_biotype:TR_V_gene \
--attribute=gene_biotype:IG_V_pseudogene \
--attribute=gene_biotype:IG_J_pseudogene \
--attribute=gene_biotype:IG_C_pseudogene \
--attribute=gene_biotype:TR_V_pseudogene \
--attribute=gene_biotype:TR_J_pseudogene
# Step 3: Concatenate filtered GTF files for different species
# Paths to filtered GTF files
filtered_gtf1="./genomes/Cat/Felis_catus.Felis_catus_9.0.111.filtered.gtf"
filtered_gtf2="./genomes/Chicken/Gallus_gallus.bGalGal1.mat.broiler.GRCg7b.111.filtered.gtf"
filtered_gtf3="./genomes/Green_Monkey/Chlorocebus_sabaeus.ChlSab1.1.111.filtered.gtf"
filtered_gtf4="./genomes/Rabbit/Oryctolagus_cuniculus.OryCun2.0.111.filtered.gtf"
filtered_gtf5="./genomes/Rat/Rattus_norvegicus.mRatBN7.2.111.filtered.gtf"
# Add prefixes for each of the species
sed '/^#!/!s/^/fc_/; s/gene_id "\([^"]*\)"/gene_id "fc_\1"/; s/gene_name "\([^"]*\)"/gene_name "fc_\1"/' $filtered_gtf1 > ./genomes/Cat/Felis_catus_prefixed.gtf
sed '/^#!/!s/^/gg_/; s/gene_id "\([^"]*\)"/gene_id "gg_\1"/; s/gene_name "\([^"]*\)"/gene_name "gg_\1"/' $filtered_gtf2 > ./genomes/Chicken/Gallus_gallus_prefixed.gtf
sed '/^#!/!s/^/cs_/; s/gene_id "\([^"]*\)"/gene_id "cs_\1"/; s/gene_name "\([^"]*\)"/gene_name "cs_\1"/' $filtered_gtf3 > ./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed.gtf
sed '/^#!/!s/^/oc_/; s/gene_id "\([^"]*\)"/gene_id "oc_\1"/; s/gene_name "\([^"]*\)"/gene_name "oc_\1"/' $filtered_gtf4 > ./genomes/Rabbit/Oryctolagus_cuniculus_prefixed.gtf
sed '/^#!/!s/^/rn_/; s/gene_id "\([^"]*\)"/gene_id "rn_\1"/; s/gene_name "\([^"]*\)"/gene_name "rn_\1"/' $filtered_gtf5 > ./genomes/Rat/Rattus_norvegicus_prefixed.gtf
# Remove metadata header from subsequent files
sed '/^#!/d' ./genomes/Chicken/Gallus_gallus_prefixed.gtf > ./genomes/Chicken/Gallus_gallus_prefixed_noheader.gtf
sed '/^#!/d' ./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed.gtf > ./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed_noheader.gtf
sed '/^#!/d' ./genomes/Rabbit/Oryctolagus_cuniculus_prefixed.gtf > ./genomes/Rabbit/Oryctolagus_cuniculus_prefixed_noheader.gtf
sed '/^#!/d' ./genomes/Rat/Rattus_norvegicus_prefixed.gtf > ./genomes/Rat/Rattus_norvegicus_prefixed_noheader.gtf
# No header GTF files
no_head_gtf2="./genomes/Chicken/Gallus_gallus_prefixed_noheader.gtf"
no_head_gtf3="./genomes/Green_Monkey/Chlorocebus_sabaeus_prefixed_noheader.gtf"
no_head_gtf4="./genomes/Rabbit/Oryctolagus_cuniculus_prefixed_noheader.gtf"
no_head_gtf5="./genomes/Rat/Rattus_norvegicus_prefixed_noheader.gtf"
cat ./genomes/Cat/Felis_catus_prefixed.gtf $no_head_gtf2 $no_head_gtf3 $no_head_gtf4 $no_head_gtf5 > five_species_combined_genes.gtf
# Step 4: Create a combined genome reference using Cell Ranger
STAR --runThreadN 40 \
--runMode genomeGenerate \
--genomeDir five_species_reference_genome \
--genomeFastaFiles five_species_combined_genome.fa \
--genomeSAsparseD 3 \
--sjdbGTFfile five_species_combined_genes.gtf \
--sjdbOverhang 69 \
--limitGenomeGenerateRAM 38000000000 \
--limitSjdbInsertNsj 1062830
# Step 5: Run PIPseeker for FASTQ processing, alignment, and transcript counting
pipseeker full \
--fastq sequence_fastq/. \
--star-index-path five_species_reference_genome \
--hto-fastq hto_fastq/. \
--hto-tags tags.csv \
--hto-position 0 \
--chemistry v4 \
--output-path pipseeker_output \
--skip-version-check \
--resume-last-run