-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
738 lines (613 loc) · 24.2 KB
/
Makefile
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
# Makefile
# Hannigan-2016-ColonCancerVirome
# Geoffrey Hannigan
# Pat Schloss Lab
############################################# METADATA ############################################
metadatafiles = ./data/metadata/NexteraXT003Map.tsv ./data/metadata/NexteraXT004Map.tsv
# Make a master metadata file
./data/metadata/MasterMeta.tsv : $(metadatafiles)
cat ./data/metadata/NexteraXT003Map.tsv ./data/metadata/NexteraXT004Map.tsv > ./data/metadata/MasterMeta.tsv
########################################## VIRUS DATABASE #########################################
./data/metadata/virus.txt:
wget http://www.ebi.ac.uk/genomes/virus.txt -O $@
./data/metadata/phage.txt:
wget http://www.ebi.ac.uk/genomes/phage.txt -O $@
# Merge the reference databases
./data/metadata/VirusPhageReference.tsv: ./data/metadata/virus.txt ./data/metadata/phage.txt
cat ./data/metadata/virus.txt ./data/metadata/phage.txt > ./data/metadata/VirusPhageReference.tsv
# Download Viral Sequences
./data/metadata/VirusPhageReference.fa : ./data/metadata/VirusPhageReference.tsv
bash ./bin/DownloadVirusesFromENA.sh \
$< \
$@
# Download Bacterial Sequences
./data/metadata/BacteriaReference.fa : ./data/metadata/bacteria.txt
bash ./bin/DownloadVirusesFromENA.sh \
$< \
$@
# Format reference fasta
./data/metadata/VirusPhageReferenceFormat.fa : ./data/metadata/VirusPhageReference.fa
perl ./bin/remove_block_fasta_format.pl $< ./data/tmpreference.fa
egrep -A 1 "complete genome" ./data/tmpreference.fa | egrep -v "\-\-" > $@
sed -i 's/ /_/g' $@
rm ./data/tmpreference.fa
# Note that the integrase gene had to be downloaded from the uniprot database manually.
# I used the same search query as my recent PeerJ manuscript.
######################################### QUALITY CONTROL #########################################
###################
# Quality Control #
###################
setfile1: ./data/metadata/MasterMeta.tsv
$(eval SAMPLELIST_R1 := $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/_R1.fastq/' \
| sed 's/^/data\/QC\//'))
echo 'variable1 = $(SAMPLELIST_R1)' > $@
setfile2: ./data/metadata/MasterMeta.tsv
$(eval SAMPLELIST_R2 = $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq/' \
| sed 's/^/data\/QC\//'))
echo 'variable2 = $(SAMPLELIST_R2)' > $@
DATENAME := $(shell date | sed 's/ /_/g' | sed 's/\:/\./g')
runqc:
include setfile1
include setfile2
runqc: $(variable1) $(variable2)
$(variable): data/QC/%_R1.fastq:
echo Target is $@
$(variable1): data/QC/%_R1.fastq: data/raw/hiseqcat/%_R1.fastq
echo $(shell date) : Performing QC and contig alignment on samples $@ >> ${DATENAME}.makelog
mkdir -p ./data/QC
bash ./bin/QualityProcess.sh \
$< \
data/metadata/MasterMeta.tsv \
$@
$(variable2): data/QC/%_R2.fastq: data/raw/hiseqcat/%_R2.fastq
echo $(shell date) : Performing QC and contig alignment on samples $@ >> ${DATENAME}.makelog
mkdir -p ./data/QC
bash ./bin/QualityProcess.sh \
$< \
data/metadata/MasterMeta.tsv \
$@
#########################
# Human Decontamination #
#########################
setfile3: ./data/metadata/MasterMeta.tsv
$(eval DECON_R1 = $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/_R1.fastq/' \
| sed 's/^/data\/HumanDecon\//'))
echo 'variable3 = $(DECON_R1)' > $@
setfile4: ./data/metadata/MasterMeta.tsv
$(eval DECON_R2 = $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq/' \
| sed 's/^/data\/HumanDecon\//'))
echo 'variable4 = $(DECON_R2)' > $@
humandeconseq:
include setfile3
include setfile4
humandeconseq: $(variable3) $(variable4)
$(variable3): data/HumanDecon/%_R1.fastq: data/QC/%_R1.fastq
echo $(shell date) : Performing HumanDecon and contig alignment on samples $@ >> ${DATENAME}.makelog
mkdir -p ./data/HumanDecon
bash ./bin/HumanDeconSeq.sh \
$< \
$@
$(variable4): data/HumanDecon/%_R2.fastq: data/QC/%_R2.fastq
echo $(shell date) : Performing HumanDecon and contig alignment on samples $@ >> ${DATENAME}.makelog
mkdir -p ./data/HumanDecon
bash ./bin/HumanDeconSeq.sh \
$< \
$@
####################
# Sequencing Depth #
####################
./data/ProjectSeqDepth.tsv :
bash ./bin/getPairedCount.sh \
./data/HumanDecon \
./data/ProjectSeqDepth.tsv \
./data/ProjectSeqDepthHumanCon.tsv
./figures/qualitycontrol.pdf :
Rscript ./bin/QualityControlStats.R \
--input ./data/ProjectSeqDepth.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--metadatat ./data/metadata/NexteraXT004Map.tsv \
--out ./figures/qualitycontrol.pdf \
--sdepth 1000000 \
--contamination ./data/ProjectSeqDepthHumanCon.tsv \
--contout ./figures/qualitycontrolcont.pdf
############################################# CONTIGS #############################################
###################
# Contig Assembly #
###################
setfile5: ./data/metadata/MasterMeta.tsv
$(eval CONTIGS_R1 = $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/.fastq/' \
| sed 's/^/data\/contigs\//'))
echo 'variable5 = $(CONTIGS_R1)' > $@
setfile6: ./data/metadata/MasterMeta.tsv
$(eval MOVE_CONTIGS = $(shell awk '{ print $$2 }' ./data/metadata/MasterMeta.tsv \
| sort \
| uniq \
| sed 's/$$/.fastq/' \
| sed 's/^/data\/contigfastq\//'))
echo 'variable6 = $(MOVE_CONTIGS)' > $@
assemblecontigs:
include setfile5
assemblecontigs: $(variable5)
movecontigs:
include setfile6
movecontigs: $(variable6)
$(variable5): data/contigs/%.fastq : data/HumanDecon/%_R1.fastq
mkdir -p ./data/contigs
bash ./bin/ContigAssembly.sh \
$< \
$(subst R1,R2,$<) \
$@
$(variable6): data/contigfastq/%.fastq :
mkdir -p data/contigfastq
cp $(subst contigfastq,contigs,$@)/final.contigs.fa $@
# Get a master file for bacterial and viral contigs
setfile7: ./data/metadata/MasterMeta.tsv
$(eval VIRUS_CONTIGS := $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT003Map.tsv \
| sort \
| uniq \
| sed 's/$$/.fastq/' \
| sed 's/^/data\/makerecorddump\//'))
echo 'variable7 = $(VIRUS_CONTIGS)' > $@
setfile8: ./data/metadata/MasterMeta.tsv
$(eval BACTERIA_CONTIGS := $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT004Map.tsv \
| sort \
| uniq \
| sed 's/$$/.fastq/' \
| sed 's/^/data\/makerecorddump\//'))
echo 'variable8 = $(BACTERIA_CONTIGS)' > $@
contigpairs:
include setfile7
include setfile8
cleancontigpairs:
rm -f ./data/totalcontigsvirus.fa
rm -f ./data/totalcontigsbacteria.fa
rm -rf data/makerecorddump
contigpairs: $(variable7) $(variable8)
$(variable7): data/makerecorddump/%.fastq : data/contigfastq/%.fastq
mkdir -p data/makerecorddump
touch $@
cat $< >> ./data/totalcontigsvirus.fa
sed -i 's/ /_/g' ./data/totalcontigsvirus.fa
$(variable8): data/makerecorddump/%.fastq : data/contigfastq/%.fastq
mkdir -p data/makerecorddump
touch $@
cat $< >> ./data/totalcontigsbacteria.fa
sed -i 's/ /_/g' ./data/totalcontigsbacteria.fa
######################################### CONTIG ABUNDANCE ########################################
###############################
# Contig Abundance Per Sample #
###############################
# Viruses
setfile9: ./data/metadata/MasterMeta.tsv
$(eval VIRUS_MOVE = $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT003Map.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq/' \
| sed 's/^/data\/virusseqsfastq\//'))
echo 'variable9 = $(VIRUS_MOVE)' > $@
movevirusabund:
include setfile9
movevirusabund: $(variable9)
$(variable9): data/virusseqsfastq/%_R2.fastq : data/HumanDecon/%_R2.fastq
mkdir -p data/virusseqsfastq
cp $< $@
setfile9_1: ./data/metadata/MasterMeta.tsv
$(eval BUILD_VIRUS_ABUND = $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT003Map.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq-noheader-forcat/' \
| sed 's/^/data\/virusseqsfastq\//'))
echo 'variable9_1 = $(BUILD_VIRUS_ABUND)' > $@
virusabund:
include setfile9_1
virusabund: $(variable9_1)
./data/virusbowtieReference/bowtieReference.1.bt2 : ./data/totalcontigsvirus.fa
mkdir -p ./data/virusbowtieReference
bowtie2-build \
-q ./data/totalcontigsvirus.fa \
./data/virusbowtieReference/bowtieReference
$(variable9_1): data/virusseqsfastq/%_R2.fastq-noheader-forcat : data/virusseqsfastq/%_R2.fastq ./data/virusbowtieReference/bowtieReference.1.bt2
qsub ./bin/CreateContigRelAbundTable.pbs -F './data/virusbowtieReference/bowtieReference $<'
# Bacteria
setfile10: ./data/metadata/MasterMeta.tsv
$(eval BACTERIA_MOVE = $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT004Map.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq/' \
| sed 's/^/data\/bacteriaseqsfastq\//'))
echo 'variable10 = $(BACTERIA_MOVE)' > $@
movebacteriaabund:
include setfile10
movebacteriaabund: $(variable10)
$(variable10): data/bacteriaseqsfastq/%_R2.fastq : data/HumanDecon/%_R2.fastq
mkdir -p data/bacteriaseqsfastq
cp $< $@
setfile10_1: ./data/metadata/MasterMeta.tsv
$(eval BUILD_BACTERIA_ABUND = $(shell awk '{ print $$2 }' ./data/metadata/NexteraXT004Map.tsv \
| sort \
| uniq \
| sed 's/$$/_R2.fastq-noheader-forcat/' \
| sed 's/^/data\/bacteriaseqsfastq\//'))
echo 'variable10_1 = $(BUILD_BACTERIA_ABUND)' > $@
bacteriaabund:
include setfile10_1
bacteriaabund: movebacteriaabund $(variable10_1)
./data/bacteriabowtieReference/bowtieReference.1.bt2 : ./data/totalcontigsbacteria.fa
mkdir -p ./data/bacteriabowtieReference
bowtie2-build \
-q ./data/totalcontigsbacteria.fa \
./data/bacteriabowtieReference/bowtieReference
$(variable10_1): data/bacteriaseqsfastq/%_R2.fastq-noheader-forcat : data/bacteriaseqsfastq/%_R2.fastq ./data/bacteriabowtieReference/bowtieReference.1.bt2
qsub ./bin/CreateContigRelAbundTable.pbs -F './data/bacteriabowtieReference/bowtieReference $<'
# The results from each of these rule sets (bacteria and virus) need to be combined
./data/ContigRelAbundForGraphVirus.tsv : virusabund
cat ./data/virusseqsfastq/*_R2.fastq-noheader-forcat > $@
sed -i 's/_R2.fastq//g' $@
sed -i 's/data\/virusseqsfastq\///g' $@
./data/ContigRelAbundForGraphBacteria.tsv : bacteriaabund
cat ./data/bacteriaseqsfastq/*_R2.fastq-noheader-forcat > $@
sed -i 's/_R2.fastq//g' $@
sed -i 's/data\/bacteriaseqsfastq\///g' $@
######################################## CONTIG CLUSTERING ########################################
#####################
# Contig Clustering #
#####################
# Bacteria
# Lower sample number because of memory limitations
./data/ContigAbundForConcoctBacteria.tsv : ./data/ContigRelAbundForGraphBacteria.tsv
Rscript ./bin/ReshapeAlignedAbundance.R \
-i ./data/ContigRelAbundForGraphBacteria.tsv \
-o ./data/ContigAbundForConcoctBacteria.tsv \
-p 0.25
./data/ContigClustersBacteria/clustering_gt2000.csv : \
./data/totalcontigsbacteria.fa \
./data/ContigAbundForConcoctBacteria.tsv
mkdir ./data/ContigClustersBacteria
concoct \
--coverage_file ./data/ContigAbundForConcoctBacteria.tsv \
--composition_file ./data/totalcontigsbacteria.fa \
--clusters 500 \
--kmer_length 4 \
--length_threshold 2000 \
--read_length 150 \
--basename ./data/ContigClustersBacteria/ \
--no_total_coverage \
--iterations 50
# Virus
./data/ContigAbundForConcoctVirus.tsv : ./data/ContigRelAbundForGraphVirus.tsv
Rscript ./bin/ReshapeAlignedAbundance.R \
-i ./data/ContigRelAbundForGraphVirus.tsv \
-o ./data/ContigAbundForConcoctVirus.tsv \
-p 0.5
./data/ContigClustersVirus/clustering_gt1000.csv : \
./data/totalcontigsvirus.fa \
./data/ContigAbundForConcoctVirus.tsv
mkdir ./data/ContigClustersVirus
concoct \
--coverage_file ./data/ContigAbundForConcoctVirus.tsv \
--composition_file ./data/totalcontigsvirus.fa \
--clusters 500 \
--kmer_length 4 \
--length_threshold 1000 \
--read_length 150 \
--basename ./data/ContigClustersVirus/ \
--no_total_coverage \
--iterations 50
####################################### CLUSTERED ABUNDANCE #######################################
############################
# Cluster Contig Abundance #
############################
# Virus
# Get table of contig IDs and their lengths
./data/VirusContigLength.tsv : \
./data/totalcontigsvirus.fa
perl ./bin/ContigLengthTable.pl \
-i ./data/totalcontigsvirus.fa \
-o ./data/VirusContigLength.tsv
./data/CorrectedContigRelAbundForGraph.tsv : \
./data/VirusContigLength.tsv
perl ./bin/AbundLengthCorrection.pl \
-i ./data/ContigRelAbundForGraphVirus.tsv \
-l ./data/VirusContigLength.tsv \
-o ./data/CorrectedContigRelAbundForGraphVirus.tsv \
-f 1000
./data/VirusClusteredContigAbund.tsv : \
./data/CorrectedContigRelAbundForGraphVirus.tsv
bash ./bin/ClusterContigAbund.sh \
./data/CorrectedContigRelAbundForGraphVirus.tsv \
./data/ContigClustersVirus/clustering_gt1000.csv \
./data/VirusClusteredContigAbund.tsv
# Bacteria
# Get table of contig IDs and their lengths
./data/BacteriaContigLength.tsv : \
./data/totalcontigsbacteria.fa
perl ./bin/ContigLengthTable.pl \
-i ./data/totalcontigsbacteria.fa \
-o ./data/BacteriaContigLength.tsv
./data/CorrectedContigRelAbundForGraphBacteria.tsv : \
./data/BacteriaContigLength.tsv
perl ./bin/AbundLengthCorrection.pl \
-i ./data/ContigRelAbundForGraphBacteria.tsv \
-l ./data/BacteriaContigLength.tsv \
-o ./data/CorrectedContigRelAbundForGraphBacteria.tsv \
-f 2000
./data/BacteriaClusteredContigAbund.tsv : \
./data/CorrectedContigRelAbundForGraphBacteria.tsv
bash ./bin/ClusterContigAbund.sh \
./data/CorrectedContigRelAbundForGraphBacteria.tsv \
./data/ContigClustersBacteria/clustering_gt2000.csv \
./data/BacteriaClusteredContigAbund.tsv
################################### OPERATIONAL PROTEIN FAMILIES ##################################
#################
# Identify OPFs #
#################
idorfs: ./data/totalcontigorfsvirus.fa ./data/totalcontigorfsbacteria.fa
# Virus
./data/totalcontigorfsvirus.fa : ./data/totalcontigsvirus.fa
bash ./bin/ClusterOPFs.sh \
$< \
$@
# Bacteria
./data/totalcontigorfsbacteria.fa : ./data/totalcontigsbacteria.fa
bash ./bin/ClusterOPFs.sh \
$< \
$@
############################
# ORF Abundance Per Sample #
############################
orfalign:
bash ./bin/getOrfAbundance.sh \
./data/tmp-opfs/ContigOrfsNoSpec.fa \
./data/HumanDecon
./data/orfabund.tsv:
bash ./bin/catOrfAbundance.sh \
./data/HumanDecon \
./data/orfabund.tsv
#######################
# OPF Abundance Table #
#######################
./data/ClusteredOpfAbund.tsv : \
./data/totalopfs.fa.tsv \
./data/orfabund.tsv
$(shell awk '{ print $$2"\t"$$1 }' ./data/totalopfs.fa.tsv > ./data/OpfClusters.tsv)
$(shell awk '{ print $$2"\t"$$1"\t"$$3 }' ./data/orfabund.tsv > ./data/orfabundOrdered.tsv)
bash ./bin/ClusterContigAbund.sh \
./data/orfabundOrdered.tsv \
./data/OpfClusters.tsv \
./data/ClusteredOpfAbund.tsv
############################################ DIVERSITY ############################################
#######################
# OGU Alpha Diversity #
#######################
./figures/diversity-alpha-ogu.pdf : \
./data/ClusteredContigAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-alpha.R \
--input ./data/ClusteredContigAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 100000 \
--out ./figures/diversity-alpha-ogu.pdf
#######################
# OPF Alpha Diversity #
#######################
./figures/diversity-alpha-opf.pdf : \
./data/ClusteredOpfAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-alpha.R \
--input ./data/ClusteredOpfAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 100000 \
--out ./figures/diversity-alpha-opf.pdf
#######################
# OGU Beta Diversity #
#######################
./figures/diversity-beta-ogu.pdf \
./figures/diversity-beta-ogu-negative.pdf : \
./data/ClusteredContigAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-beta.R \
--input ./data/ClusteredContigAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 100000 \
--out ./figures/diversity-beta-ogu.pdf \
--negout ./figures/diversity-beta-ogu-negative.pdf
./figures/diversity-betajaccard-ogu.pdf \
./figures/diversity-betajaccard-ogu-negative.pdf : \
./data/ClusteredContigAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-beta.R \
--input ./data/ClusteredContigAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 100000 \
--divmetric jaccard \
--out ./figures/diversity-betajaccard-ogu.pdf \
--negout ./figures/diversity-betajaccard-ogu-negative.pdf
#######################
# OPF Beta Diversity #
#######################
./figures/diversity-beta-opf.pdf : \
./data/ClusteredOpfAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-beta.R \
--input ./data/ClusteredOpfAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 50000 \
--out ./figures/diversity-beta-opf.pdf
./figures/diversity-betajaccard-opf.pdf : \
./data/ClusteredOpfAbund.tsv \
./data/metadata/NexteraXT003Map.tsv
Rscript ./bin/diversity-beta.R \
--input ./data/ClusteredOpfAbund.tsv \
--metadata ./data/metadata/NexteraXT003Map.tsv \
--subsample 50000 \
--divmetric jaccard \
--out ./figures/diversity-betajaccard-opf.pdf
############################################### 16S ###############################################
#################
# Bacterial 16S #
#################
# Download the 16S reads from the SRA
mothurproc :
mkdir -p ./data/mothur16S
bash ./bin/Mothur16S.sh \
./data/mothur16S \
./data/raw/Zackular_16S
precluster :
bash ./bin/mothurPreCluster.sh \
./data/mothur16S
mothurcluster :
bash ./bin/mothurCluster.sh \
./data/mothur16S
####################################### INTERACTION NETWORKS ######################################
##################################
# Score Contigs for Interactions #
##################################
VREF=./data/ViromeAgainstReferenceBacteria
# In this case the samples will get run against the bacteria reference genome set
ViromeRefRun : ${VREF}/BenchmarkCrisprsFormat.tsv \
${VREF}/BenchmarkProphagesFormatFlip.tsv \
${VREF}/MatchesByBlastxFormatOrder.tsv \
${VREF}/PfamInteractionsFormatScoredFlip.tsv
${VREF}/BenchmarkCrisprsFormat.tsv \
${VREF}/BenchmarkProphagesFormatFlip.tsv \
${VREF}/MatchesByBlastxFormatOrder.tsv \
${VREF}/PfamInteractionsFormatScoredFlip.tsv : \
./data/totalcontigsvirus.fa \
./data/totalcontigsbacteria.fa \
./bin/BenchmarkingModel.sh
bash ./bin/BenchmarkingModel.sh \
./data/totalcontigsvirus.fa \
./data/totalcontigsbacteria.fa \
${VREF}/BenchmarkCrisprsFormat.tsv \
${VREF}/BenchmarkProphagesFormatFlip.tsv \
${VREF}/MatchesByBlastxFormatOrder.tsv \
${VREF}/PfamInteractionsFormatScoredFlip.tsv \
"ViromeAgainstReferenceBacteria"
#########################
# Cluster Contig Scores #
#########################
# Annotate contig IDs with cluster IDs and further compress
clusterrun : ${VREF}/BenchmarkProphagesFormatFlipClustered.tsv \
${VREF}/MatchesByBlastxFormatOrderClustered.tsv \
${VREF}/PfamInteractionsFormatScoredFlipClustered.tsv
${VREF}/BenchmarkProphagesFormatFlipClustered.tsv \
${VREF}/MatchesByBlastxFormatOrderClustered.tsv \
${VREF}/PfamInteractionsFormatScoredFlipClustered.tsv :
bash ./bin/ClusterContigScores.sh \
${VREF}/BenchmarkProphagesFormatFlip.tsv \
${VREF}/MatchesByBlastxFormatOrder.tsv \
${VREF}/PfamInteractionsFormatScoredFlip.tsv \
${VREF}/BenchmarkProphagesFormatFlipClustered.tsv \
${VREF}/MatchesByBlastxFormatOrderClustered.tsv \
${VREF}/PfamInteractionsFormatScoredFlipClustered.tsv \
./data/ContigClustersVirus/clustering_gt1000.csv \
./data/ContigClustersBacteria/clustering_gt2000.csv \
"ViromeAgainstReferenceBacteria" \
${VREF}/BenchmarkCrisprsFormat.tsv \
${VREF}/BenchmarkCrisprsFormatClustered.tsv
# Make a graph database from the experimental information
expnetwork :
# Note that this resets the graph database and erases
# the validation information we previously added.
rm -r ../../bin/neo4j-enterprise-2.3.0/data/graph.db/
mkdir ../../bin/neo4j-enterprise-2.3.0/data/graph.db/
bash ./bin/CreateProteinNetwork \
./data/ValidationSet/Interactions.tsv \
${VREF}/BenchmarkCrisprsFormatClustered.tsv \
${VREF}/BenchmarkProphagesFormatFlipClustered.tsv \
${VREF}/PfamInteractionsFormatScoredFlipClustered.tsv \
${VREF}/MatchesByBlastxFormatOrderClustered.tsv \
"FALSE"
# Predict interactions between nodes
./data/PredictedRelationshipTable.tsv :
bash ./bin/RunPredictionsWithNeo4j.sh \
./data/metadata/rfinteractionmodel.RData \
./data/PredictedRelationshipTable.tsv
# Add relationships
finalrelationships \
./figures/BacteriaPhageNetworkDiagram.pdf \
./figures/BacteriaPhageNetworkDiagram.png \
./figures/PhageHostHist.pdf \
./figures/PhageHostHist.png \
./figures/BacteriaEdgeCount.pdf \
./figures/BacteriaEdgeCount.png : \
./data/PredictedRelationshipTable.tsv \
./bin/AddRelationshipsWrapper.sh
echo $(shell date) : Adding relationships to network and plotting total graph >> ${DATENAME}.makelog
bash ./bin/AddRelationshipsWrapper.sh \
./data/PredictedRelationshipTable.tsv
################################## CONTIG CLUSTER IDENTIFICATION ##################################
# Get ID for longest contig in each clustered virus
./data/contigclustersidentity/longestcontigsvirus.tsv : ./data/VirusContigLength.tsv
mkdir -p ./data/contigclustersidentity
Rscript ./bin/GetLongestContig.R \
--input ./data/VirusContigLength.tsv \
--clusters ./data/ContigClustersVirus/clustering_gt1000.csv \
--toplength 1 \
--out $@
# Align the contig seqs to the virus reference database
./data/contigclustersidentity/clustax.tsv :
bash ./bin/IdentifyContigs.sh \
./data/totalcontigsvirus.fa \
./data/metadata/VirusPhageReferenceFormat.fa \
./data/contigclustersidentity/longestcontigsvirus.tsv \
./data/contigclustersidentity/clustax.tsv \
"/nfs/turbo/schloss-lab/bin/ncbi-blast-2.4.0+/bin/" \
"false"
# Also align the contig seqs to the bacteria reference database
# Not rerunning this here with updated max_target_seqs because it is for p/a
./data/contigclustersidentity/VirusRepsetIdsAgainstBacteria.tsv :
bash ./bin/IdentifyContigs.sh \
./data/totalcontigsvirus.fa \
./data/metadata/BacteriaReference.fa \
./data/contigclustersidentity/longestcontigsvirus.tsv \
./data/contigclustersidentity/VirusRepsetIdsAgainstBacteria.tsv \
"/nfs/turbo/schloss-lab/bin/ncbi-blast-2.4.0+/bin/" \
"true"
# Get a list of the virus clusters that hit bacteria but not phage references
cut -f 1 ./data/contigclustersidentity/VirusRepsetIds_backup.tsv | sort | uniq > ./data/contigclustersidentity/VirusVirusIds.tsv
cut -f 1 ./data/contigclustersidentity/VirusRepsetIdsAgainstBacteria.tsv | sort | uniq > ./data/contigclustersidentity/VirusBacteriaIds.tsv
# Use grep to get the final list
grep -xv --file=./data/contigclustersidentity/VirusVirusIds.tsv ./data/contigclustersidentity/VirusBacteriaIds.tsv | sort | uniq > ./data/contigclustersidentity/BacteriaNotVirus.tsv
./rtables/idcount.tsv :
bc <<< "scale=8; 100 * `wc -l < ./data/contigclustersidentity/clustax.tsv` / `wc -l < ./data/contigclustersidentity/longestcontigsvirus.tsv`" > ./rtables/idcount.tsv
./rtables/phagecount.tsv :
bc <<< "scale=8; 100 * `egrep "Caudovirales|[Pp]hage" ./data/contigclustersidentity/clustax.tsv | wc -l` / `wc -l < ./data/contigclustersidentity/clustax.tsv`" > ./rtables/phagecount.tsv
################################# BACTERIA CLUSTER IDENTIFICATION #################################
# Get ID for longest contig in each cluster
./data/contigclustersidentity/longestcontigsbacteria.tsv : ./data/BacteriaContigLength.tsv
mkdir -p ./data/contigclustersidentity
Rscript ./bin/GetLongestContig.R \
--input ./data/BacteriaContigLength.tsv \
--clusters ./data/ContigClustersBacteria/clustering_gt2000.csv \
--toplength 1 \
--out $@
# Align the contig seqs to the bacteria reference database
./data/contigclustersidentity/BacteriaRepsetIds.tsv :
bash ./bin/IdentifyContigsBac.sh \
./data/totalcontigsbacteria.fa \
./data/metadata/BacteriaReference.fa \
./data/contigclustersidentity/longestcontigsbacteria.tsv \
./data/contigclustersidentity/BacteriaRepsetIds.tsv \
"/home/ghannig/bin/ncbi-blast-2.4.0+/bin/"
################################# PHAGE REPLICATION CYCLE #################################
./data/tmpidlytic/phagebacteriablastout.tsv :
bash ./bin/IdentLyticPhages.sh \
./data/totalcontigsvirus.fa \
./data/contigclustersidentity/longestcontigsvirus.tsv \
"/home/ghannig/bin/ncbi-blast-2.4.0+/bin/"