-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCBrev.txt
2315 lines (1385 loc) · 62.7 KB
/
CBrev.txt
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
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## start over, see if we can redo our original biom table construction.
## we already rearranged the split barcodes on the leaf reads, is that
## still laying around?
## they're here:
ls -lh /home/daniel/Documents/taiwan/taiwan_dada2/rearranged_leafR1.fastq
ls -lh /home/daniel/Documents/taiwan/taiwan_dada2/rearranged_leafR2.fastq
## let's make a link to these:
ln -s /home/daniel/Documents/taiwan/taiwan_dada2/rearranged_leafR1.fastq reLeafR1.fastq
ln -s /home/daniel/Documents/taiwan/taiwan_dada2/rearranged_leafR2.fastq reLeafR2.fastq
rm reLeafR*.fastq
## confused - it looks like I used to have an aggregate wood reads file,
## all the R1s in one file, R2s in the other.
## whatever it was, I don't have it anymore.
## without this, do we just loop through the wood reads, trim as we go?
## wood directory
wooddir='/home/daniel/Documents/taiwan/woodreads/'
i='lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_001.fastq'
cut <(echo $i) -d "-" -f 1
echo $i
for i in $wooddir*"_R1_"*; do
echo $i
done
fastx_trimmer -l 255 -i $i -o woodR1_trimmed.fastq
fastx_trimmer -l 210 -i woodR2.fastq -o woodR2_trimmed.fastq
## okay, but we don't have single wood forward and reverse files,
## we have a forward and a reverse for each sample
## so apply the trim across all reads in the wood files.
## where are these?
wooddir=/home/daniel/Documents/taiwan/woodreads/
mkdir trimmed_wood
mkdir trimmed_wood/R1
mkdir trimmed_wood/R2
## trims.sh
########################################
wooddir=/home/daniel/Documents/taiwan/woodreads/
cd /home/daniel/Documents/taiwan/taiwan_combined_biom
R1trimdir='/home/daniel/Documents/taiwan/taiwan_combined_biom/trimmed_wood/R1/'
for i in $wooddir*_R1_*; do
echo $i
out=$R1trimdir$(basename ${i/_001\.fastq/_trimmed\.fastq})
fastx_trimmer -l 255 -i $i -o $out && echo $out
done
R2trimdir='/home/daniel/Documents/taiwan/taiwan_combined_biom/trimmed_wood/R2/'
for j in $wooddir*_R2_*; do
echo $j
out=$R2trimdir$(basename ${j/_001\.fastq/_trimmed\.fastq})
fastx_trimmer -l 210 -i $j -o $out && echo $out
done
########################################
time ./trims.sh
echo "zoop"
## and the leaf reads?
mkdir trimmed_leaf
mkdir trimmed_leaf/R{1..2}
### okay, but I think we gotta do this on Talapas.
## I recall it's sometimes weird using outputs from
## the 32-bit home version of usearch with the 64-bit
## software, etc, so best to stick with the 64bit
## version on Talapas...
scp reLeafR1.fastq [email protected]:/projects/xylaria/dthomas
scp reLeafR2.fastq [email protected]:/projects/xylaria/dthomas
## gotta get the wood reads (trimmed) there too:
scp trimmed_wood -r [email protected]:/projects/xylaria/dthomas
cp trimmed_wood -r [email protected]:/projects/xylaria/dthomas
## merging is next....
## on the new cluster (Talapas) the
## batch info is included as comments
## in the script:
## merge_leaves.sh
###########################
#! /usr/bin/env bash
#SBATCH --job-name=merge_leaves
#SBATCH --output=merge_leaves.out
#SBATCH --error=merge_leaves.err
#SBATCH --time=0-04:00:00
#SBATCH --nodes=1
leafdir=/projects/xylaria/dthomas/leaf/
module load usearch/8.0
usearch -fastq_mergepairs $leafdir"reLeafR2.fastq" -reverse $leafdir"reLeafR1.fastq" -fastqout $leafdir"leafmerged.fastq"
usearch -fastq_mergepairs $leafdir"Roo_R2_trimmed.fastq" -reverse $leafdir"Roo_R1_trimmed.fastq" -fastqout $leafdir"leaftrimmedmerged.fastq"
################################
## didn't work. they don't have the license for
## usearch 64bit, just 32bit.
## what file size can usearch 32-bit handle?
## our wood reads are demultiplexed, much
## smaller, let's try these:
## merge_wood.sh
################################
#!usr/bin/env bash
#SBATCH --job-name=merge_wood
#SBATCH --output=merge_wood.out
#SBATCH --error=merge_wood.err
#SBATCH --time=0-05:00:00
#SBATCH --nodes=1
module load usearch/8.0
cd projects/xylaria/dthomas/
R1d=/projects/xylaria/dthomas/trimmed_wood/R1/
for forward in $R1d*; do
echo $forward
reverse=${forward//R1/R2}
aa=$(basename $forward); output="/projects/xylaria/dthomas/merged_wood/"${aa/_R1_trimmed.fastq/_merged.fastq}
usearch -fastq_mergepairs $forward -reverse $reverse -fastqout $output
done
###########################
## did that work?
## looks good. So what was our largest file size?
ls -Slhr
## 51 meg.
## our leaf files after trimming are 10 and 6.8 gig.
## this largest file size is 374560 lines
## let's split up the leaves in to files with line
## numbers in multiples of four.
## pipeline:
## 1) split leaf and wood reads down to ~1 gig files
## 2) run usearch on all
## 3) combine with cat
## 1) split leaf into 1 gig files:
## trimmed, unpaired leaves are here in talapas:
cd /projects/xylaria/dthomas/leaf
## how many lines in these leaf read files?
wc -l Roo_R1_trimmed.fastq ## 72806460
wc -l Roo_R2_trimmed.fastq ## same, 72806460
expr 72806460 / 4 ## 18201615 reads... is that about right?
## anyway, multiple of four
## we should probably write a script for this, get off the
## head node:
## split_leaf.sh
################################
#!/bin/bash
#SBATCH --job-name=split_leaf
#SBATCH --output=split_leaf.out
#SBATCH --error=split_leaf.err
#SBATCH --time=0-05:00:00
#SBATCH --nodes=1
cd /projects/xylaria/dthomas/leaf/split_leaf
for i in ../Roo_R*_*; do
ls $i
split -d -l 500000 $i ${i/fastq/split\.fastq}
done
###########################
## Submitted batch job 1731251
## worked?:
cd /projects/xylaria/dthomas/leaf/split_leaf
expr 72806460 / 500000 ## should be 145 or so files:
for i in *; do
wc -l $i
done
## looks good, matches up
## can we cycle through these and merge?
######################
#!/bin/bash
#SBATCH --job-name=leaf_merge
#SBATCH --output=leaf_merge.out
#SBATCH --error=leaf_merge.err
#SBATCH --time=0-05:00:00
#SBATCH --nodes=1
module load usearch/8.0
cd /projects/xylaria/dthomas/leaf/split_leaf/
for i in Roo_R2_trimmed.split.fastq*; do
usearch -fastq_mergepairs $i -reverse ${i/_R2_/_R1_} -fastqout "merged/"${i/_R2_/_merged_}
done
###################################
## seems like it worked...
scp [email protected]:/home/dthomas/leaf_merge.out ./
scp [email protected]:/home/dthomas/leaf_merge.err ./
## okay, can we recombine these? or is there an order issue now?
cat * > Roo_merged_trimmed.split.fastq
## that may be a bit much for the head node ...
srun --pty --partition=short --mem=1024M --time=60 bash
## rerun
ls -l Roo_merged_trimmed.split.fastq
wc -l Roo_merged_trimmed.split.fastq ## 65858336
expr 65858336 / 4 ## 16,464,584 reads.
echo $((18201615 - 16464584)) ## 1,737,031 reads lost.
## anyway, what happens next?
## I think we next demultiplex our leaf reads.
## but let's catch up the jupyter notebook...
## it looks like more than half of our wood reads didn't pair.
## check this:
cd /projects/xylaria/dthomas/merged_wood
tot=0
for i in *; do
tot=$(( $tot + $(wc -l $i | cut -f 1 -d " ") ))
done
echo $(( tot / 4 )) reads
## 1.86 million reads. Something is fucked.
## so... what happened?
## if we rerun just one of our merges, do we get the same result?
## for instance, we got really bad results from our second file, 33% matched
## this is ...
## lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R1_trimmed.fastq
## to rerun this:
forward="/projects/xylaria/dthomas/trimmed_wood/R1/lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R1_trimmed.fastq"
reverse="/projects/xylaria/dthomas/trimmed_wood/R2/lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R2_trimmed.fastq"
module load usearch/8.0
usearch -fastq_mergepairs $forward -reverse $reverse -fastqout ./test.fastq
usearch -fastq_mergepairs $forward -reverse $reverse -fastqout ./test.fastq -notrunclabels
## get some error reports:
usearch -fastq_mergepairs $forward -reverse $reverse -alnout aln.txt
usearch -fastq_mergepairs $forward -reverse $reverse -fastqout ./test.fastq -alnout aln.txt
## it looks like most of our reads aligned, ~95%, and they looks pretty good on visual
## inspection, but we need to relax our permitted numbers of mismatches.
## in newer versions, this is the "-fastq_maxdiffs" parameter, defautl = 5.
## True for 8.0?
usearch -fastq_mergepairs $forward -reverse $reverse -fastq_maxdiffs 10 -alnout aln_10.txt
usearch -fastq_mergepairs $forward -reverse $reverse -fastq_maxdiffs 20 -alnout aln_20.txt
## none of this is helping. "mismatches" and "differences" are different types of error in
## this version, though not in the more recent versions. And I can't find documentation
## for older versions. What is the difference between these errors? Most of our reads aligned
## very well.
## let's try this on my own computer, with v8.1.x of usearch
cd mergetest
forward='lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R1_trimmed.fastq'
reverse='lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R2_trimmed.fastq'
usearch -fastq_mergepairs $forward -reverse $reverse -fastqout ./test.fastq
## better results. Still not perfect (67%) but maybe that's okay.
usearch -fastq_mergepairs $forward -reverse $reverse -fastq_maxdiffs 10 -fastqout ./test2.fastq
## even better,
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffs 10 \
-alnout aln_2.txt \
-report test2.report.txt
## maybe wiser to use a percentage?
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffpct 40 \
-alnout aln_3.txt \
-report test3.report.txt \
-fastqout ./test3.fastq
## drops us back to 67.7%
## sleepy. Time for bed.
## so in the future, need to rerun the merging for wood and split up leaf reads,
## because usearch 8.1 seems so much more forgiving that 8.0.
## is there something I can set to running tonight?
## split up leaf files on the optiplex?
## run the merge on all of them?
## we need to
## 1 get all trimmed wood onto the optiplex
## 2 and all trimmed leaves
## 3 install usearch 8.1 onto optiplex
## 4 split up the leaves
## 5 run mergepair on on all wood
## 6 run mergepair on on all leaf
## 7 recombine leaves
## or just sleep. Let's do that.
##### try again #########
## get trimmed wood onto optiplex ...
scp -r ./trimmed_wood/ [email protected]:/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/
## trimmed leaves - better to do the trimming on site? or copy?
## where are our leaves? put them on optiplex
scp [email protected]:/projects/xylaria/dthomas/leaf/Roo_R{1..2}_trimmed.fastq ./
## so we're loading the trimmed wood and leaves onto the optiplex
## split up the leaves:
## split_leaf.sh
################################
#!/usr/bin/env bash
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves
for i in Roo_R*_*; do
ls $i
split -d -l 500000 $i ${i/fastq/split\.fastq}
done
###########################
## can we record our outputs from usearch?
cd mergetest
forward='lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R1_trimmed.fastq'
reverse='lane1-s161-index-AAGCACTG-TTCGTACGNNNN-Dc-PosG_S161_L001_R2_trimmed.fastq'
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffpct 40 \
-alnout aln_3.txt \
-report reports/$i.report.txt \
-fastqout ./test3.fastq
## merge wood on optiplex
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/R1
for forward in *fastq; do
ls -l $forward
reverse="../R2/${forward/R1/R2}"
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffpct 40 \
-alnout aln_3.txt \ ## oops, fix this if reused
-report ../reports/$forward.report.txt \
-fastqout ./$forward.merged.fastq
echo $reverse
done
## oops, deleted a file - redo just this:
forward=lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_trimmed.fastq
ls -l $forward
reverse="../R2/${forward/R1/R2}"
ls -l $reverse
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffpct 40 \
-report ../reports/$forward.report.txt \
-fastqout ./$forward.merged.fastq
## look, this publication and the others need to get out.
## the expedition needs to happen.
## then I can move on the next los Cedros project... some
## thing beautiful for Rosa in this dying world.
## I think we're ready to merge wood reads ...
## and the leaves, still on optiplex:
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/split
## did the splitting mess up order?
head -n 1 Roo_R1_trimmed.split.fastq9054
head -n 1 Roo_R2_trimmed.split.fastq9054
tail -n 4 Roo_R1_trimmed.split.fastq72
tail -n 4 Roo_R2_trimmed.split.fastq72
## looks good
for forward in *_R1_*; do
#ls $forward
reverse=${forward/_R1_/_R2_}
usearch -fastq_mergepairs $forward \
-reverse $reverse \
-fastq_maxdiffpct 40 \
-alnout aln_3.txt \ ## oops, fix this if reused
-report ../reports/$forward.report.txt \
-fastqout ../merged/$forward.merged.fastq
#ls $reverse
done
## seems to be working ...
## okay, so to revisit the wood
## did we lose a lot?
cat lane1-s160-index-AAGCACTG-GTGATCCANNNN-Dc-X_S160_L001_R1_trimmed.fastq.report.txt
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged
clear
wc -l lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_trimmed.fastq.merged.fastq
grep "^@M" lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_trimmed.fastq.merged.fastq | wc -l
head lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_trimmed.fastq.merged.fastq
bb=$(wc -l lane1-s257-index-GAGGACTT-CCTAAGTCNNNN-PosI_S257_L001_R1_trimmed.fastq.merged.fastq | cut -f 1 -d " ")
echo "bb="$bb
aa=$(( $bb / 4 ))
echo aa=$aa
echo aaX4=$(( $aa * 4 ))
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged
lines=0
for i in *; do
bb=$(wc -l $i | cut -f 1 -d " ")
aa=$(( $bb / 4 ))
lines=$(( aa + lines ))
done
echo $lines ## 3745085
## or maybe just
grep "^@M" -r | wc -l ## yeah. 3745085
## vs..
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/R1
grep "^@M" -r | wc -l ## 5608274
## 3745085 / 5608274 = ## 66%. Hmm, not great, but what can I do? Why is this so different
## from when we did this last year? What did I do differently?
## And the leaves?
## merged
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/merged
(grep "^@HWI" -r | wc -l &)
## 14813290
## 14,813,290
## unmerged:
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/
(grep "^@HWI" Roo_R2_trimmed.fastq | wc -l &)
## 18201615
## 18,201,615
## 81%, a lot better. Why? The wood library has generally better qscores. And when we
## merged them before with the 64-bit version of usearch, we had nearly 100% merging
## with the wood. Something seems off.
## Oh well, let's march through to the biom table, and see how biom tables compare.
## If they are drastically different from last years results, we'll see what can be
## tweaked.
## onward
## cat the leaf files:
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/merged
cat * > leaf_trimmed_merged.fastq
## cat the wood files, for quality charts:
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged
cat * > wood_trimmed_merged.fastq
## then what?
## get trimmed, merged files onto laptop
## visualize qualities
## quality filter
## go to fasta
## demultiplex leaves
## remove leaf primers
## remove floating primers
## chimera check
## combine
## trim to ITS1 region
## combine
## oh, lotsa shit. I'm far from finished. Trek on.
## tonight
## run fastq stats on optiplex
## get all files onto laptop
## after visualization, organize files, update github and notebook
## stats, on optiplex. What do we want to look at? Unmerged forward
## and reverse, both trimmmed and un-. The merged, trimmed reads.
## leaves:
## leafQcharts.sh
#####################################
#!/usr/bin/env bash
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/qCharts/leaf
rawLeafReadsR1="/home/daniel/Documents/taiwan_supp/roo_reads/TaiwanFA_R1.fastq"
rawLeafReadsR2="/home/daniel/Documents/taiwan_supp/roo_reads/TaiwanFA_R2.fastq"
trimmedLeafReadsR1="/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/Roo_R1_trimmed.fastq"
trimmedLeafReadsR2="/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/Roo_R2_trimmed.fastq"
leafmerg="/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/merged/leaf_trimmed_merged.fastq"
## leaf quality stats:
fastx_quality_stats -i $rawLeafReadsR1 -o rawLeafReadsR1_fastxstats.txt
fastx_quality_stats -i $rawLeafReadsR2 -o rawLeafReadsR2_fastxstats.txt
fastx_quality_stats -i $trimmedLeafReadsR1 -o trimmedLeafReadsR1_fastxstats.txt
fastx_quality_stats -i $trimmedLeafReadsR2 -o trimmedLeafReadsR2_fastxstats.txt
fastx_quality_stats -i $leafmerg -o leafmerged_fastxstats.txt
#####################################
(./leafQcharts.sh &) &
## wood reads
## make a combined files for the various prep stages so far:
cat /home/daniel/Documents/taiwan_supp/wood_reads/*R1* > /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/rawWoodReadsR1.fastq
cat /home/daniel/Documents/taiwan_supp/wood_reads/*R2* > /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/rawWoodReadsR2.fastq
cat /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/R1/* > /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmedWoodR1.fastq
cat /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/R2/* > /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmedWoodR2.fastq
cat /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged/* > /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/woodMerged.fastq
## how?
## woodQcharts.sh
############################
#!/usr/bin/env bash
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom
fastx_quality_stats -i rawWoodReadsR1.fastq -o qCharts/wood/rawWoodReadsR1_fastxstats.txt
fastx_quality_stats -i rawWoodReadsR2.fastq -o qCharts/wood/rawWoodReadsR2_fastxstats.txt
fastx_quality_stats -i trimmedWoodR1.fastq -o qCharts/wood/trimmedWoodR1_fastxstats.txt
fastx_quality_stats -i trimmedWoodR2.fastq -o qCharts/wood/trimmedWoodR2_fastxstats.txt
fastx_quality_stats -i woodMerged.fastq -o qCharts/wood/woodMerged_fastxstats.txt
##########################
(./woodQcharts.sh &) &
#################### quality filtering ######################
## get an example file
scp [email protected]:/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged/lane1-s255-index-TGCGAACT-CCTAAGTCNNNN-Neg_S255_L001_R1_trimmed.fastq.merged.fastq ./
exFastq='lane1-s255-index-TGCGAACT-CCTAAGTCNNNN-Neg_S255_L001_R1_trimmed.fastq.merged.fastq'
## let's try quality filtering
## and what if we want to pipe out the screen messages to a file?
usearch -fastq_filter $exFastq -fastq_maxee_rate .01 -fastqout exampleOut.fastq -notrunclabels 2> exError.txt
## doesn't catch the licensing, but everything else.
## can we do both - see the sterr on the screen and in file?
usearch -fastq_filter $exFastq -fastq_maxee_rate .01 -fastqout exampleOut.fastq -notrunclabels 1> exStdout.txt 2> exError.txt
## works, but can we put them on the same file?
usearch -fastq_filter $exFastq -fastq_maxee_rate .01 -fastqout exampleOut.fastq -notrunclabels &> exStdout.txt
## yeah, that's what I need. To remember all this, 0 is input, 1 in stdout, 2 is stderr, & is both 1 & 2.
## anyway, do this on the optiplex, all wood files. Where are they?
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged
for i in *; do
out=${i/.fastq.merged.fastq/\.merge\.filt\.fastq}
usearch -fastq_filter $i -fastq_maxee_rate .01 -fastqout $out -notrunclabels &>> mergeStdout.txt
done
## looks like we kept almost all, so maybe the hard filtering happened in the pairing step.
scp [email protected]/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged/mergeStdout.txt ./
## do we need to use our split up leaves? probably.
## try the single merged file first:
usearch -fastq_filter leaf_trimmed_merged.fastq -fastq_maxee_rate 0.01 -fastqout leaf_filtered.fastq
## yeah, too big. So go through the split files:
mkdir ../filtered
#!/usr/bin/env bash
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/merged
for i in *; do
out=${i/.merged.fastq/\.merged\.filt\.fastq}
#echo $i $out
usearch -fastq_filter $i -fastq_maxee_rate .01 -fastqout "../filtered/"$out -notrunclabels &>> ../filtered/leaf_mergeStdout.txt
done
(./filterleaves.sh &) &
## so as I understand it, we should have quality filtered reads, for both leaves and wood.
## check out these reports:
## leaves:
lR=/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/filtered/leaf_mergeStdout.txt
less $lR
grep "....\%.passed" $lR
## looks generally successful
## leaves?
lL=/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/merged/mergeStdout.txt
less $lL
grep "....\%.passed" $lL
## whoah, way higher...
grep "....\%.passed" $lL | cut -d " " -f 8
## can we convert these to fasta, then update the notebook?
## let's do this with bbmap:
## got to bbmap directory on my laptop, put it on the optiplex:
scp -r ./bbmap [email protected]:/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom
bb=/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/bbmap
## let's do leaves first. Recombine the leaf reads:
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/filtered
cat *fastq > leaf_merged_filt.fastq
$bb/reformat.sh in=leaf_merged_filt.fastq out=leaf_merged_filt.fasta
## worked, but can we get rid of the line breaks? maybe by setting
## "fastawrap" to 0? Or 600?
head -n 20 leaf_merged_filt.fastq > submergedLeaf.fastq
$bb/reformat.sh in=submergedLeaf.fastq out=test.fasta fastawrap=600
## that worked. Just curious, how about 0?
$bb/reformat.sh in=submergedLeaf.fastq out=test.fasta fastawrap=0
## also works, let's go with this.
$bb/reformat.sh in=leaf_merged_filt.fastq out=leaf_merged_filt.fasta fastawrap=0 &> makeLeafFasta.txt
## this worked?
head -n 1 leaf_merged_filt.fastq
head -n 1 leaf_merged_filt.fasta
tail -n 20 leaf_merged_filt.fasta | grep ">HWI"
tail -n 40 leaf_merged_filt.fastq | grep "@HWI"
## looks okay. Onward...
## let's demultiplex and update the notebook if there is still time:
## to dumultiplex - which script, if any, will do the job?
## on the dada pipeline I had to split up the file, apply one of the
## python scripts, and reassemble...
## huh. confused. Looks like I should have done this a while ago, before
## merging...
## shit. can we do this now? Were these barcodes lost in trimming or
## merging?
## how to tell?
## look at a few?
head leafread_fastx_map.txt
head
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/filtered
sed -n '4000000,4000001p' leaf_merged_filt.fasta
head leaf_merged_filt.fasta
grep ^ACCCAT leaf_merged_filt.fasta -B 1 | grep ">HWI" | wc -l ## 780,301 reads, makes sense.
## do the other ends of these reads still have the other half of these barcodes?
grep ">HWI" leaf_merged_filt.fasta -B 1 | grep ATATCC$
grep ">HWI" leaf_merged_filt.fasta -B 1 | grep ATATCC$ | wc -l ## 301, not many.
## Reverse compliment?
grep ">HWI" leaf_merged_filt.fasta -B 1 | grep GGATAT$ | wc -l ## 499. Fuck.
grep ">HWI" leaf_merged_filt.fasta -B 1 | grep TATAGG$ | wc -l ## 184.
## oh, shoot, it looks like I did do this, already
## I'm going nuts.
## check that really quick:
grep ">HWI" leaf_merged_filt.fasta -A 1 | grep ^ACCCATATATCC | wc -l ## 227,705 seems reasonable. Maybe low, but possible.
## okay, so we're good to start the demultiplexing then. We can use fastx to do this:
ld="/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/demult/"
(cat leaf_merged_filt.fasta | fastx_barcode_splitter.pl \
--bcfile leafread_fastx_map.txt \
--prefix $ld"leaf_" \
--suffix ".fa" \
--bol --mismatches 1 --partial 1 \
&>> "leaf_demult_log.txt" &) &
## don't need to do this for wood. But I think we do need the FASTA versions
## of the wood...
bb=/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/bbmap
wfd=/home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/woodFasta/
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trimmed_wood/filtered
for i in *; do
$bb/reformat.sh in=$i \
out=$wfd${i/_R1_trimmed.merge.filt.fastq/.fasta} \
fastawrap=0 \
&>> ../../woodFastaStdout.txt
done
## so where are we now?
## next step is to trim off the primers from the leaves. But the
## demultiplexing is taking a while. So let's catch up our notebook.
tail leaf_merged_filt.fasta
head leaf_merged_filt.fasta
## did the barcodes on the opposite ends of our merged pairs
## remain?
## did we get reasonable results from the demultiplexing?
cd $ld
less leaf_104.fa
## now what?
## trim primers off of leaf reads.
## did the barcodes on the opposite ends of our merged pairs
## remain?
cd /home/daniel/Documents/submissions/taibioinfo/taiwan_combined_biom/trim_leaves/demult
## sample 94 should have a barcode of CGTGATAAGACG
cd demult
wc leaf_94.fa -l
grep >HWI leaf_94.fa -l ## 91439 reads
grep CGTGATAAGACG leaf_94.fa | wc -l ## 84480
grep CGTCTTATCACG leaf_94.fa | wc -l ## 84462
grep CGTCTTATCACG$ leaf_94.fa | wc -l ## 84462, all at the end
## so these plus primers will need to be cut. Are the primers still
## on there?
## check, primers still there? ITS2 was our linker primer for
## the leaf run, so it should be our forward primer:
grep GCTGCGTTCTTCATCGATGC leaf_94.fa | wc -l ## 87084 yup
grep GCTGCGTTCTTCATCGATGC <(head leaf_94.fa)
aa=CGTGATAAGACGGCTGCGTTCTTCATCGATGC
echo ${#aa}
grep TTACTTCCTCTAAATGACCAAG leaf_94.fa | wc -l
grep TTACTTCCTCTAAATGACCAAG <(head -n 1000 leaf_94.fa)
bb=TTACTTCCTCTAAATGACCAAGCGTCTTATCACG
echo ${#bb}
grep TTACTTCCTCTAAATGACCAAG.{1} <(head leaf_94.fa)
## anyway, trim the primers off the leaves:
for i in *; do
fastx_trimmer -i $i -f 33 | fastx_trimmer -t 34 -o ../leafNoPrim/${i/leaf/leafNoPrim}
done
## wood has no primers, don't need to do this.
## the next step would be?
## chimera checks.
wget https://unite.ut.ee/sh_files/uchime_reference_dataset_28.06.2017.zip
## where to put this...
ITS1_ref='/home/daniel/Documents/taiwan/uchime_reference_dataset_28.06.2017/'\
'ITS1_ITS2_datasets/uchime_reference_dataset_ITS1_28.06.2017.fasta'
## do the check. Try one.
cd /home/daniel/Documents/taiwan/taiwan_combined_biom/leafNoPrim
usearch -uchime_ref leafNoPrim_89.fa \
-db $ITS1_ref \
-nonchimeras test_notchim.fasta \
-uchimeout test.log \
-strand plus \
-notrunclabels \
&> uchime_stdout.txt
less uchime_stdout.txt
## works. do with all files, leaf reads:
cd /home/daniel/Documents/taiwan/taiwan_combined_biom/leafNoPrim
for i in *; do
echo $i
j="../leaf_notchim/"${i/NoPrim/NotChim}
k=${j/\.fa/\.log}
#echo $j
#echo $k
usearch -uchime_ref $i \
-db $ITS1_ref \
-nonchimeras $j \
-uchimeout $k \
-strand plus \
-notrunclabels \
&>> uchime_stdout.txt
done