-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDada2_VSearch.smk
845 lines (730 loc) · 31.5 KB
/
Dada2_VSearch.smk
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
"""
Snakemake Snakefile for Running Dada2, based on:
https://github.com/LangilleLab/microbiome_helper/wiki/Amplicon-SOP-v2
source activate qiime2-2020.6
"""
#snakemake -s '/home/microbiology/NICK/forwards.snakefile' --configfile '/home/microbiology/NICK/forwards.json' --cores 4
import multiprocessing
import subprocess
import qiime2
import pandas as pd
cpu_count=int(multiprocessing.cpu_count())
#rule all:
# input:
# file=config['output_dir'] + "/reads_trimmed.qzv"
#rule all:
# input:
# file=config['output_dir'] + "/denoising-stats.qzv"
rule all:
input:
biom=config['output_dir'] + "/phyloseq.biom"
#rule all:
# input:
# directory(config['output_dir'] + "/species/table_level_7_aa")
#rule all:
# input:
# tsv=config['output_dir'] + "/species/level_7_aa.tsv"
#TODO: add a primer trimming step, primers can be added to the config.json
# 1.5 Import fastq files (with primers trimmed)
rule import_raw_sequences:
input:
manifest=config["manifest_file"]
output:
seqs=config['output_dir'] + "/reads_trimmed.qza"
params:
type="SampleData[PairedEndSequencesWithQuality]",
input_format="PairedEndFastqManifestPhred33V2"
shell:
"qiime tools import --type {params.type} --input-path {input.manifest} --output-path {output.seqs} --input-format {params.input_format}"
# Visualization for 1.5
rule summarize_imported_seqs:
input:
seqs=config['output_dir'] + "/reads_trimmed.qza"
output:
file=config['output_dir'] + "/reads_trimmed.qzv"
shell:
"qiime demux summarize --i-data {input.seqs} --o-visualization {output.file}"
# 2 - Dada2
rule run_dada2:
input:
seqs=config['output_dir'] + "/reads_trimmed.qza",
file=config['output_dir'] + "/reads_trimmed.qzv"
output:
table=config['output_dir'] + "/table.qza",
seqs=config['output_dir'] + "/rep_seqs.qza",
stats=config['output_dir'] +"/denoising-stats.qza"
shell:
"""qiime dada2 denoise-paired --i-demultiplexed-seqs {input.seqs} \
--p-trunc-len-f 225 \
--p-trunc-len-r 225 \
--p-n-threads 4 \
--o-table {output.table} \
--o-representative-sequences {output.seqs} \
--o-denoising-stats {output.stats}"""
# Visualization for step 2
rule summary_table:
input:
table=config['output_dir'] + "/table.qza",
output:
table=config['output_dir'] + "/table_summary.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.table}"
rule summary_seqs:
input:
table=config['output_dir'] + "/table_summary.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs.qza",
stats=config['output_dir'] +"/denoising-stats.qza"
output:
file=config['output_dir'] + "/rep_seqs_summary.qzv"
shell:
"qiime feature-table tabulate-seqs --i-data {input.rep_seqs} --o-visualization {output.file}"
rule summary_stats:
input:
file=config['output_dir'] + "/rep_seqs_summary.qzv",
stats=config['output_dir'] +"/denoising-stats.qza"
output:
file=config['output_dir'] + "/denoising-stats.qzv"
shell:
"qiime metadata tabulate --m-input-file {input.stats} --o-visualization {output.file}"
rule annotate_rep_seqs:
input:
file=config['output_dir'] + "/denoising-stats.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs.qza",
ref_reads=config["ref_reads"],
ref_tax=config["ref_tax"]
output:
taxonomy=config['output_dir'] + "/taxonomy.qza"
shell:
"qiime feature-classifier classify-consensus-vsearch --i-reference-reads {input.ref_reads} --i-reference-taxonomy {input.ref_tax} --i-query {input.rep_seqs} --o-classification {output.taxonomy} --p-threads 2 --verbose"
rule visualize_taxonomy:
input:
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
file=config['output_dir'] + "/taxonomy.qzv"
shell:
"qiime metadata tabulate --m-input-file {input.taxonomy} --o-visualization {output.file}"
rule filter_mito_from_table:
input:
file=config['output_dir'] + "/taxonomy.qzv",
table=config['output_dir'] + "/table.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/table_nmc.qza"
shell:
"qiime taxa filter-table --i-table {input.table} --i-taxonomy {input.taxonomy} --p-exclude mitochondria --o-filtered-table {output.table}"
rule filter_mito_from_rep_seqs:
input:
rep_seqs=config['output_dir'] + "/rep_seqs.qza",
table=config['output_dir'] + "/table_nmc.qza"
output:
rep_seqs=config['output_dir'] + "/rep_seqs_nmc.qza",
shell:
"qiime feature-table filter-seqs --i-data {input.rep_seqs} --i-table {input.table} --o-filtered-data {output.rep_seqs}"
rule visualize_nmc_table:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_nmc.qza",
table=config['output_dir'] + "/table_nmc.qza"
output:
file=config['output_dir'] + "/table_nmc.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule visualize_nmc_rep_seqs:
input:
file=config['output_dir'] + "/table_nmc.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs_nmc.qza"
output:
file=config['output_dir'] + "/rep_seqs_nmc.qzv"
shell:
"qiime feature-table tabulate-seqs --i-data {input.rep_seqs} --o-visualization {output.file}"
rule filter_chloro_from_table:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_nmc.qzv",
table=config['output_dir'] + "/table_nmc.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/table_ncp_nmc.qza"
shell:
"qiime taxa filter-table --i-table {input.table} --i-taxonomy {input.taxonomy} --p-exclude chloroplast --o-filtered-table {output.table}"
rule filter_chloro_from_rep_seqs:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_nmc.qza",
table=config['output_dir'] + "/table_ncp_nmc.qza"
output:
rep_seqs=config['output_dir'] + "/rep_seqs_ncp_nmc.qza"
shell:
"qiime feature-table filter-seqs --i-data {input.rep_seqs} --i-table {input.table} --o-filtered-data {output.rep_seqs}"
rule visualize_nmc_ncp_table:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_ncp_nmc.qza",
table=config['output_dir'] + "/table_ncp_nmc.qza"
output:
file=config['output_dir'] + "/table_ncp_nmc.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule visualize_nmc_ncp_rep_seqs:
input:
file=config['output_dir'] + "/table_ncp_nmc.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs_ncp_nmc.qza"
output:
file=config['output_dir'] + "/rep_seqs_ncp_nmc.qzv"
shell:
"qiime feature-table tabulate-seqs --i-data {input.rep_seqs} --o-visualization {output.file}"
rule filter_Unassigned_from_table:
input:
file=config['output_dir'] + "/rep_seqs_ncp_nmc.qzv",
table=config['output_dir'] + "/table_ncp_nmc.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/table_final.qza"
shell:
"qiime taxa filter-table --i-table {input.table} --i-taxonomy {input.taxonomy} --p-exclude Unassigned --o-filtered-table {output.table}"
rule filter_Unassigned_from_rep_seqs:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_ncp_nmc.qza",
table=config['output_dir'] + "/table_final.qza"
output:
rep_seqs=config['output_dir'] + "/rep_seqs_final.qza"
shell:
"qiime feature-table filter-seqs --i-data {input.rep_seqs} --i-table {input.table} --o-filtered-data {output.rep_seqs}"
rule visualize_final_table:
input:
rep_seqs=config['output_dir'] + "/rep_seqs_final.qza",
table=config['output_dir'] + "/table_final.qza"
output:
file=config['output_dir'] + "/table_final.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule visualize_final_rep_seqs:
input:
table=config['output_dir'] + "/table_final.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs_final.qza"
output:
file=config['output_dir'] + "/rep_seqs_final.qzv"
shell:
"qiime feature-table tabulate-seqs --i-data {input.rep_seqs} --o-visualization {output.file}"
rule visualize_taxa_plots:
input:
file=config['output_dir'] + "/rep_seqs_final.qzv",
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza",
map_file=config["map_file"]
output:
file=config['output_dir'] + "/taxa-bar-plots.qzv"
shell:
"qiime taxa barplot --i-table {input.table} --i-taxonomy {input.taxonomy} --o-visualization {output.file} --m-metadata-file {input.map_file}"
rule align_mafft_rep_seqs:
input:
file=config['output_dir'] + "/taxa-bar-plots.qzv",
rep_seqs=config['output_dir'] + "/rep_seqs_final.qza"
output:
aligned_seqs=config['output_dir'] + "/aligned-rep-seqs.qza"
threads: cpu_count
shell:
"qiime alignment mafft --i-sequences {input.rep_seqs} --o-alignment {output.aligned_seqs} --verbose --p-parttree --p-n-threads 4"
rule align_mask_rep_seqs:
input:
aligned_seqs=config['output_dir'] + "/aligned-rep-seqs.qza"
output:
filtered_aligned_seqs=config['output_dir'] + "/masked-aligned-rep-seqs.qza"
shell:
"qiime alignment mask --i-alignment {input.aligned_seqs} --o-masked-alignment {output.filtered_aligned_seqs} --verbose"
rule create_phylogenic_tree:
input:
filtered_aligned_seqs=config['output_dir'] + "/masked-aligned-rep-seqs.qza"
output:
tree=config['output_dir'] + "/unrooted-tree.qza"
threads: cpu_count
shell:
"qiime phylogeny fasttree --i-alignment {input.filtered_aligned_seqs} --o-tree {output.tree} --verbose --p-n-threads {threads}"
rule create_midpoint_phylogenic_tree:
input:
tree=config['output_dir'] + "/unrooted-tree.qza"
output:
tree=config['output_dir'] + "/rooted-tree.qza"
shell:
"qiime phylogeny midpoint-root --i-tree {input.tree} --o-rooted-tree {output.tree}"
# Have to look into the table-nc-ncp-nmc-dn-97-0.005.qzv file for the sample-frequency-detail.csv and find the smallest number in the second column in order to define --p-sampling-depth
rule core_metrics:
input:
tree=config['output_dir'] + "/rooted-tree.qza",
table=config['output_dir'] + "/table_final.qza",
map_file=config["map_file"]
output:
rarefied_table=config['output_dir'] + "/rarefied_table.qza",
faith_pd_vector=config['output_dir'] + "/faith_pd_vector.qza",
observed_otus_vector=config['output_dir'] + "/observed_otus_vector.qza",
shannon_vector=config['output_dir'] + "/shannon_vector.qza",
evenness_vector=config['output_dir'] + "/evenness_vector.qza",
unweighted_unifrac_distance_matrix=config['output_dir'] + "/unweighted_unifrac_distance_matrix.qza",
weighted_unifrac_distance_matrix=config['output_dir'] + "/weighted_unifrac_distance_matrix.qza",
jaccard_distance_matrix=config['output_dir'] + "/jaccard_distance_matrix.qza",
bray_curtis_distance_matrix=config['output_dir'] + "/bray_curtis_distance_matrix.qza",
unweighted_unifrac_pcoa_results=config['output_dir'] + "/unweighted_unifrac_pcoa_results.qza",
weighted_unifrac_pcoa_results=config['output_dir'] + "/weighted_unifrac_pcoa_results.qza",
jaccard_pcoa_results=config['output_dir'] + "/jaccard_pcoa_results.qza",
bray_curtis_pcoa_results=config['output_dir'] + "/bray_curtis_pcoa_results.qza",
unweighted_unifrac_emperor=config['output_dir'] + "/unweighted_unifrac_emperor.qzv",
weighted_unifrac_emperor=config['output_dir'] + "/weighted_unifrac_emperor.qzv",
jaccard_emperor=config['output_dir'] + "/jaccard_emperor.qzv",
bray_curtis_emperor=config['output_dir'] + "/bray_curtis_emperor.qzv"
params:
dir=config['output_dir'] + ""
threads: cpu_count
run:
my_table = qiime2.Artifact.load(input.table)
my_tree = qiime2.Artifact.load(input.tree)
df = my_table.view(pd.DataFrame)
threshold = int(min(df.sum(axis=1)))
cmd = """qiime diversity core-metrics-phylogenetic --i-phylogeny {} --i-table {} \
--p-sampling-depth {} --m-metadata-file {} \
--o-rarefied-table {} \
--o-faith-pd-vector {} \
--o-observed-features-vector {} \
--o-shannon-vector {} \
--o-evenness-vector {} \
--o-unweighted-unifrac-distance-matrix {} \
--o-weighted-unifrac-distance-matrix {} \
--o-jaccard-distance-matrix {} \
--o-bray-curtis-distance-matrix {} \
--o-unweighted-unifrac-pcoa-results {} \
--o-weighted-unifrac-pcoa-results {} \
--o-jaccard-pcoa-results {} \
--o-bray-curtis-pcoa-results {} \
--o-unweighted-unifrac-emperor {} \
--o-weighted-unifrac-emperor {} \
--o-jaccard-emperor {} \
--o-bray-curtis-emperor {} \
--p-n-jobs-or-threads {} --verbose""".format(input.tree, input.table, threshold, input.map_file,
output.rarefied_table, output.faith_pd_vector, output.observed_otus_vector, output.shannon_vector,
output.evenness_vector, output.unweighted_unifrac_distance_matrix, output.weighted_unifrac_distance_matrix,
output.jaccard_distance_matrix, output.bray_curtis_distance_matrix, output.unweighted_unifrac_pcoa_results,
output.weighted_unifrac_pcoa_results, output.jaccard_pcoa_results, output.bray_curtis_pcoa_results,
output.unweighted_unifrac_emperor, output.weighted_unifrac_emperor, output.jaccard_emperor,
output.bray_curtis_emperor, threads)
try:
cmd_output = subprocess.check_output(cmd, shell=True)
except subprocess.CalledProcessError as c:
sys.exit("ERROR: command {} could not be run in the shell.\n Command failed with return code: {}.".format(c.cmd, c.returncode))
# Have to look into the table-nc-ncp-nmc-dn-97-0.005.qzv file for the sample-frequency-detail.csv and find the largest number in the second column in order to define --p-max-depth
rule alpha_rarefaction:
input:
tree=config['output_dir'] + "/rooted-tree.qza",
table=config['output_dir'] + "/table_final.qza",
map_file=config["map_file"],
rarefied_table=config['output_dir'] + "/rarefied_table.qza"
output:
file=config['output_dir'] + "/alpha-rarefaction.qzv"
run:
my_table = qiime2.Artifact.load(input.table)
df = my_table.view(pd.DataFrame)
threshold = int(max(df.sum(axis=1)))
cmd = """qiime diversity alpha-rarefaction --i-phylogeny {} \
--i-table {} --p-max-depth {} \
--m-metadata-file {} --o-visualization {}""".format(input.tree, input.table, threshold, input.map_file, output.file)
try:
cmd_output = subprocess.check_output(cmd, shell=True)
except subprocess.CalledProcessError as c:
sys.exit("ERROR: command {} could not be run in the shell.\n Command failed with return code: {}.".format(c.cmd, c.returncode))
#Prepare QIIME2 info for phyloseq
rule export_taxonomy:
input:
file=config['output_dir'] + "/alpha-rarefaction.qzv",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
taxonomy=config['output_dir'] + "/taxonomy/taxonomy.tsv"
params:
dir=config['output_dir'] + "/taxonomy"
shell:
"qiime tools export --input-path {input.taxonomy} --output-path {params.dir}"
rule export_table:
input:
table=config['output_dir'] + "/table_final.qza"
output:
table=config['output_dir'] + "/final_table/feature-table.biom"
params:
dir=config['output_dir'] + "/final_table"
shell:
"qiime tools export --input-path {input.table} --output-path {params.dir}"
rule convert_table_to_txt:
input:
table=config['output_dir'] + "/final_table/feature-table.biom"
output:
table=config['output_dir'] + "/feature-table.tsv"
shell:
"biom convert -i {input.table} -o {output.table} --to-tsv"
rule export_tree:
input:
table=config['output_dir'] + "/feature-table.tsv",
tree=config['output_dir'] + "/rooted-tree.qza"
output:
tree=config['output_dir'] + "/tree/tree.nwk"
params:
dir=config['output_dir'] + "/tree"
shell:
"qiime tools export --input-path {input.tree} --output-path {params.dir}"
rule change_taxonomy_label_1:
input:
tree=config['output_dir'] + "/tree/tree.nwk",
taxonomy=config['output_dir'] + "/taxonomy/taxonomy.tsv"
output:
taxonomy=temp(config['output_dir'] + "/taxonomy/taxonomy1.tsv")
shell:
"sed '1s/Feature ID/#OTUID/' {input.taxonomy} > {output.taxonomy}"
rule change_taxonomy_label_2:
input:
taxonomy=config['output_dir'] + "/taxonomy/taxonomy1.tsv"
output:
taxonomy=config['output_dir'] + "/taxonomy/taxonomy2.tsv"
shell:
"sed '1s/Taxon/taxonomy/' {input.taxonomy} > {output.taxonomy}"
rule combine_taxonomy_and_table:
input:
taxonomy=config['output_dir'] + "/taxonomy/taxonomy2.tsv",
table=config['output_dir'] + "/final_table/feature-table.biom"
output:
biom=config['output_dir'] + "/table-with-taxonomy.biom"
shell:
"biom add-metadata -i {input.table} -o {output.biom} --observation-metadata-fp {input.taxonomy} --sc-separated taxonomy --observation-header OTUID,taxonomy,Confidence"
rule convert_taxatable_to_phyloseq:
input:
biom=config['output_dir'] + "/table-with-taxonomy.biom"
output:
biom=config['output_dir'] + "/phyloseq.biom"
shell:
"biom convert -i {input.biom} -o {output.biom} --to-json --table-type='OTU table'"
#Create phylum level tables
rule level_2_absolute_abundance:
input:
biom=config['output_dir'] + "/phyloseq.biom",
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/phylum/table_level_2_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 2"
rule level_2_summarize:
input:
table=config['output_dir'] + "/phylum/table_level_2_aa.qza"
output:
file=config['output_dir'] + "/phylum/table_level_2.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_2_relative_frequency:
input:
table=config['output_dir'] + "/phylum/table_level_2_aa.qza",
file=config['output_dir'] + "/phylum/table_level_2.qzv"
output:
table=config['output_dir'] + "/phylum/table_level_2_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_2_rf_export:
input:
table=config['output_dir'] + "/phylum/table_level_2_rf.qza"
output:
directory(config['output_dir'] + "/phylum/table_level_2_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_2_aa_export:
input:
(config['output_dir'] + "/phylum/table_level_2_rf"),
table=config['output_dir'] + "/phylum/table_level_2_aa.qza"
output:
directory(config['output_dir'] + "/phylum/table_level_2_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
#Create class level tables
rule level_3_absolute_abundance:
input:
(config['output_dir'] + "/phylum/table_level_2_aa"),
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/class/table_level_3_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 3"
rule level_3_summarize:
input:
table=config['output_dir'] + "/class/table_level_3_aa.qza"
output:
file=config['output_dir'] + "/class/table_level_3.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_3_relative_frequency:
input:
table=config['output_dir'] + "/class/table_level_3_aa.qza",
file=config['output_dir'] + "/class/table_level_3.qzv"
output:
table=config['output_dir'] + "/class/table_level_3_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_3_rf_export:
input:
table=config['output_dir'] + "/class/table_level_3_rf.qza"
output:
directory(config['output_dir'] + "/class/table_level_3_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_3_aa_export:
input:
(config['output_dir'] + "/class/table_level_3_rf"),
table=config['output_dir'] + "/class/table_level_3_aa.qza"
output:
directory(config['output_dir'] + "/class/table_level_3_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
#Create order level tables
rule level_4_absolute_abundance:
input:
(config['output_dir'] + "/class/table_level_3_aa"),
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/order/table_level_4_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 4"
rule level_4_summarize:
input:
table=config['output_dir'] + "/order/table_level_4_aa.qza"
output:
file=config['output_dir'] + "/order/table_level_4.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_4_relative_frequency:
input:
table=config['output_dir'] + "/order/table_level_4_aa.qza",
file=config['output_dir'] + "/order/table_level_4.qzv"
output:
table=config['output_dir'] + "/order/table_level_4_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_4_rf_export:
input:
table=config['output_dir'] + "/order/table_level_4_rf.qza"
output:
directory(config['output_dir'] + "/order/table_level_4_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_4_aa_export:
input:
(config['output_dir'] + "/order/table_level_4_rf"),
table=config['output_dir'] + "/order/table_level_4_aa.qza"
output:
directory(config['output_dir'] + "/order/table_level_4_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
#Create family level tables
rule level_5_absolute_abundance:
input:
(config['output_dir'] + "/order/table_level_4_aa"),
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/family/table_level_5_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 5"
rule level_5_summarize:
input:
table=config['output_dir'] + "/family/table_level_5_aa.qza"
output:
file=config['output_dir'] + "/family/table_level_5.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_5_relative_frequency:
input:
table=config['output_dir'] + "/family/table_level_5_aa.qza",
file=config['output_dir'] + "/family/table_level_5.qzv"
output:
table=config['output_dir'] + "/family/table_level_5_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_5_rf_export:
input:
table=config['output_dir'] + "/family/table_level_5_rf.qza"
output:
directory(config['output_dir'] + "/family/table_level_5_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_5_aa_export:
input:
(config['output_dir'] + "/family/table_level_5_rf"),
table=config['output_dir'] + "/family/table_level_5_aa.qza"
output:
directory(config['output_dir'] + "/family/table_level_5_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
#Create genus level tables
rule level_6_absolute_abundance:
input:
(config['output_dir'] + "/family/table_level_5_aa"),
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/genus/table_level_6_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 6"
rule level_6_summarize:
input:
table=config['output_dir'] + "/genus/table_level_6_aa.qza"
output:
file=config['output_dir'] + "/genus/table_level_6.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_6_relative_frequency:
input:
table=config['output_dir'] + "/genus/table_level_6_aa.qza",
file=config['output_dir'] + "/genus/table_level_6.qzv"
output:
table=config['output_dir'] + "/genus/table_level_6_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_6_rf_export:
input:
table=config['output_dir'] + "/genus/table_level_6_rf.qza"
output:
directory(config['output_dir'] + "/genus/table_level_6_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_6_aa_export:
input:
(config['output_dir'] + "/genus/table_level_6_rf"),
table=config['output_dir'] + "/genus/table_level_6_aa.qza"
output:
directory(config['output_dir'] + "/genus/table_level_6_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
#Create species level tables
rule level_7_absolute_abundance:
input:
(config['output_dir'] + "/genus/table_level_6_aa"),
table=config['output_dir'] + "/table_final.qza",
taxonomy=config['output_dir'] + "/taxonomy.qza"
output:
table=config['output_dir'] + "/species/table_level_7_aa.qza"
shell:
"qiime taxa collapse --i-table {input.table} --i-taxonomy {input.taxonomy} --o-collapsed-table {output.table} --p-level 7"
rule level_7_summarize:
input:
table=config['output_dir'] + "/species/table_level_7_aa.qza"
output:
file=config['output_dir'] + "/species/table_level_7.qzv"
shell:
"qiime feature-table summarize --i-table {input.table} --o-visualization {output.file}"
rule level_7_relative_frequency:
input:
table=config['output_dir'] + "/species/table_level_7_aa.qza",
file=config['output_dir'] + "/species/table_level_7.qzv"
output:
table=config['output_dir'] + "/species/table_level_7_rf.qza"
shell:
"qiime feature-table relative-frequency --i-table {input.table} --o-relative-frequency-table {output.table}"
rule level_7_rf_export:
input:
table=config['output_dir'] + "/species/table_level_7_rf.qza"
output:
directory(config['output_dir'] + "/species/table_level_7_rf")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_7_aa_export:
input:
(config['output_dir'] + "/species/table_level_7_rf"),
table=config['output_dir'] + "/species/table_level_7_aa.qza"
output:
directory(config['output_dir'] + "/species/table_level_7_aa")
shell:
"qiime tools export --input-path {input.table} --output-path {output}"
rule level_2_convert_rf_table_to_txt:
input:
(config['output_dir'] + "/species/table_level_7_aa"),
table=config['output_dir'] + "/phylum/table_level_2_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/phylum/level_2_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_2_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/phylum/level_2_rf.tsv",
table=config['output_dir'] + "/phylum/table_level_2_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/phylum/level_2_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_3_convert_rf_table_to_txt:
input:
tsv=config['output_dir'] + "/phylum/level_2_aa.tsv",
table=config['output_dir'] + "/class/table_level_3_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/class/level_3_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_3_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/class/level_3_rf.tsv",
table=config['output_dir'] + "/class/table_level_3_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/class/level_3_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_4_convert_rf_table_to_txt:
input:
tsv=config['output_dir'] + "/class/level_3_aa.tsv",
table=config['output_dir'] + "/order/table_level_4_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/order/level_4_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_4_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/order/level_4_rf.tsv",
table=config['output_dir'] + "/order/table_level_4_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/order/level_4_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_5_convert_rf_table_to_txt:
input:
tsv=config['output_dir'] + "/order/level_4_aa.tsv",
table=config['output_dir'] + "/family/table_level_5_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/family/level_5_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_5_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/family/level_5_rf.tsv",
table=config['output_dir'] + "/family/table_level_5_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/family/level_5_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_6_convert_rf_table_to_txt:
input:
tsv=config['output_dir'] + "/family/level_5_aa.tsv",
table=config['output_dir'] + "/genus/table_level_6_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/genus/level_6_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_6_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/genus/level_6_rf.tsv",
table=config['output_dir'] + "/genus/table_level_6_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/genus/level_6_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_7_convert_rf_table_to_txt:
input:
tsv=config['output_dir'] + "/genus/level_6_aa.tsv",
table=config['output_dir'] + "/species/table_level_7_rf/feature-table.biom"
output:
tsv=config['output_dir'] + "/species/level_7_rf.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"
rule level_7_convert_aa_table_to_txt:
input:
tsv=config['output_dir'] + "/species/level_7_rf.tsv",
table=config['output_dir'] + "/species/table_level_7_aa/feature-table.biom"
output:
tsv=config['output_dir'] + "/species/level_7_aa.tsv"
shell:
"biom convert -i {input.table} -o {output.tsv} --to-tsv"