-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kraken2 -> Qiime Taxonomic Barcharts
282 lines (220 loc) · 8.82 KB
/
Kraken2 -> Qiime Taxonomic Barcharts
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
Qiime Taxonomic Analysis (after Kraken2)
# Create Taxonomic Abundance Barcharts (All Kingdoms, >1% abundance)
## -------------------------------
## Step 1: Convert raw frequency & taxonomy (classic) tables from Kraken2 to .biom
## -------------------------------
### Change directory
cd /projects/academic/pidiazmo/Projects/Shotgun_summary/NIH_result_summary/Kraken2std/
### Convert classic table to biom table (raw frequency)
biom convert -i NIH_table.txt -o table.from_txt_json.biom --table-type="OTU table" --to-json
### Convert classic table to .biom table (taxonomy file)
biom convert -i taxa.txt -o taxa.from_txt_json.biom --table-type="OTU table" --to-json
##--------------------------------
## Step 2: Import frequency & taxa tables to Qiime
## -------------------------------
### Load Qiime
module load qiime2
### Import frequency table to Qiime (create qiime artifact)
qiime tools import \
--input-path table.from_txt_json.biom \
--type 'FeatureTable[Frequency]' \
--input-format BIOMV100Format \
--output-path table.qza
### Import taxonomy table to Qiime (create qiime artifact)
qiime tools import \
--input-path taxa.from_txt_json.biom \
--type 'FeatureData[Taxonomy]' \
--input-format BIOMV100Format \
--output-path taxa.qza
##--------------------------------
## Step 3: Remove human and mice reads at the genus level
## -------------------------------
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxa.qza \
--p-exclude primates,rodentia \
--o-filtered-table table_no_h_m.qza
##--------------------------------
## Step 4: Summarize frequency feature table
## -------------------------------
### Summarize feature table
qiime feature-table summarize \
--i-table table.qza \
--o-visualization overall_summary
### Export summary and determine what feature frequency (a raw number) is 1% of total feature frequency from summary
qiime tools export \
--input-path overall_summary.qzv \
--output-path overall_summary
##--------------------------------
## Step 5: Filter out features (taxa) that have less than <1% total abundance
## -------------------------------
qiime feature-table filter-features \
--i-table table.qza \
--p-min-frequency 2679650 \
--o-filtered-table freq_filtered_table.qza
##--------------------------------
## Step 6: Visualize Barchart
## -------------------------------
### Visualize barchart
qiime taxa barplot \
--i-table freq_filtered_table.qza \
--i-taxonomy taxa.qza \
--m-metadata-file sample-metadata.txt \
--o-visualization taxa-bar-plots.qzv
##--------------------------------
## Step 6: View barchart in qiime2 viewer
## -------------------------------
### Filter by taxonomic level and metadata. Download svg file of legend and plot. Edit in Inkscape or other SVG editor.
# Create Taxonomic Abundance Barcharts (Bacteria only, >1% abundance)
## -------------------------------
## Step 1: Filter features for bacteria taxa only
## -------------------------------
### Filter out archaea, eukaryota, and viruses
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxa.qza \
--p-exclude archaea,eukaryota,viruses \
--o-filtered-table bacteria_only.qza
##--------------------------------
## Step 2: Filter out features (taxa) that have less than <1% total abundance
## -------------------------------
qiime feature-table filter-features \
--i-table bacteria_only.qza \
--p-min-frequency 2674897 \
--o-filtered-table bacteria_freq_filtered_table.qza
##--------------------------------
## Step 3: Visualize Barchart
## -------------------------------
### Visualize barchart
qiime taxa barplot \
--i-table bacteria_freq_filtered_table.qza \
--i-taxonomy taxa.qza \
--m-metadata-file sample-metadata_2.txt \
--o-visualization bacteria_only_bar.qzv
##--------------------------------
## Step 4: View barchart in qiime2 viewer
## -------------------------------
### Filter by taxonomic level and metadata. Download svg file of legend and plot. Edit in Inkscape or other SVG editor.
# Create Taxonomic Abundance Barcharts (Eukaryota only)
## -------------------------------
## Step 1: Filter features for eukaryota taxa only
## -------------------------------
### Filter out archaea, bacteria, and viruses
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxa.qza \
--p-include eukaryota \
--o-filtered-table eukaryota_only.qza
##--------------------------------
## Step 2: Summarize eukaryota frequency feature table
## -------------------------------
### Summarize feature table
qiime feature-table summarize \
--i-table eukaryota_only.qza \
--o-visualization eukaryota_summary
### Export summary and determine what feature frequency (a raw number) is 1% of total feature frequency from summary
qiime tools export \
--input-path eukaryota_summary.qzv \
--output-path eukaryota_summary
##--------------------------------
## Step 3: Filter out features (taxa) that aren't top-20
## -------------------------------
qiime feature-table filter-features \
--i-table eukaryota_only.qza \
--p-min-frequency 359 \
--o-filtered-table freq_eukaryota_only.qza
##--------------------------------
## Step 4: Visualize Barchart
## -------------------------------
### Visualize barchart
qiime taxa barplot \
--i-table freq_eukaryota_only.qza \
--i-taxonomy taxa.qza \
--m-metadata-file sample-metadata_2.txt \
--o-visualization freq_eukaryota_only_bar.qzv
##--------------------------------
## Step 5: View barchart in qiime2 viewer
## -------------------------------
### Filter by taxonomic level and metadata. Download svg file of legend and plot. Edit in Inkscape or other SVG editor.
# Create Taxonomic Abundance Barcharts (Viruses only)
## -------------------------------
## Step 1: Filter features for viruses taxa only
## -------------------------------
### Filter out archaea, bacteria, and eukaryota
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxa.qza \
--p-include viruses \
--o-filtered-table viruses_only.qza
##--------------------------------
## Step 2: Summarize viruses frequency feature table
## -------------------------------
### Summarize feature table
qiime feature-table summarize \
--i-table viruses_only.qza \
--o-visualization viruses_summary
### Export summary and determine what feature frequency (a raw number) is 1% of total feature frequency from summary
qiime tools export \
--input-path viruses_summary.qzv \
--output-path viruses_summary
##--------------------------------
## Step 3: Filter out features (taxa) that aren't top-20
## -------------------------------
qiime feature-table filter-features \
--i-table viruses_only.qza \
--p-min-frequency 157 \
--o-filtered-table freq_viruses_only.qza
##--------------------------------
## Step 4: Visualize Barchart
## -------------------------------
### Visualize barchart
qiime taxa barplot \
--i-table freq_viruses_only.qza \
--i-taxonomy taxa.qza \
--m-metadata-file sample-metadata_2.txt \
--o-visualization freq_viruses_only_bar.qzv
##--------------------------------
## Step 5: View barchart in qiime2 viewer
## -------------------------------
### Filter by taxonomic level and metadata. Download svg file of legend and plot. Edit in Inkscape or other SVG editor.
# Create Taxonomic Abundance Barcharts (Archaea only)
## -------------------------------
## Step 1: Filter features for archaea taxa only
## -------------------------------
### Filter out eukaryota, bacteria, and viruses
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxa.qza \
--p-include archaea \
--o-filtered-table archaea_only.qza
##--------------------------------
## Step 2: Summarize archaea frequency feature table
## -------------------------------
### Summarize feature table
qiime feature-table summarize \
--i-table archaea_only.qza \
--o-visualization archaea_summary
### Export summary and determine what feature frequency (a raw number) is 1% of total feature frequency from summary
qiime tools export \
--input-path archaea_summary.qzv \
--output-path archaea_summary
##--------------------------------
## Step 3: Filter out features (taxa) that aren't top-20
## -------------------------------
qiime feature-table filter-features \
--i-table archaea_only.qza \
--p-min-frequency 112 \
--o-filtered-table freq_archaea_only.qza
##--------------------------------
## Step 2: Visualize Barchart
## -------------------------------
### Visualize barchart
qiime taxa barplot \
--i-table freq_archaea_only.qza \
--i-taxonomy taxa.qza \
--m-metadata-file sample-metadata_2.txt \
--o-visualization freq_archaea_only_bar.qzv
##--------------------------------
## Step 3: View barchart in qiime2 viewer
## -------------------------------
### Filter by taxonomic level and metadata. Download svg file of legend and plot. Edit in Inkscape or other SVG editor.