You don't need the samtools view there - you can pipe it straight to samtools sort
Hi, I have a set of human exome data sequenced with Agilent Sureselect XT HS2. I am following the Best practice document https://www.agilent.com/cs/library/software/public/AGeNTBestPractices.pdf
On p.3 the example for bwa, just want to check if this is correct before starting the long process for alignment.
especially the " at the end and the - after samtools view -b
bwa mem ‐C ‐t 2 /hg38.fa trimmed_dir/sample_R1.cut.fastq.gz trimmed_dir/sample_R2.cut.fastq.gz | samtools view ‐b ‐ > aligned_dir/sample.bam"
Any advice would be appreciated! Thanks
1 answer
I would even sort the bam file on the fly as well, e.g.,
bwa mem -R '@RG\tID:READ_GROUP\tPL:PLATFORM\tLB:LIB\tSM:SAMPLE_NAME' ‐C ‐t 2 hg38.fa sample_R1.cut.fastq.gz sample_R2.cut.fastq.gz \
| samtools view -Sbh - | samtools sort -m 2G --threads 4 -o aligned.sorted.bwa.bam
Really? I didn't know that. Is there any flag I needed on the sort function? I thought you couldn't pipe plain text into samtools hence the -b flag in samtools view.
No flag is needed.
By default, samtools tries to select a format based on the -o filename extension; if output is to standard output or no format can be deduced, bam is selected.
Log in to answer this question.
That extra
"at the end is not needed.-at the end ofsamtools viewcommand is ok. That indicates that the input tosamtools viewis coming from thebwaand is being piped in.your reference file is in the root folder. I am not sure if that is best practice.