Samtools-remove host reads
1
1
Entering edit mode
4.2 years ago
a.oates ▴ 10

We are working with Nanopore reads using the rapid barcoding kit. We are interested in the bacterial and fungal microbiome of our samples so need to remove host (human) reads (single reads not paired)

For one barcode/sample I have mapped the reads to the human genome using minimap2 and generated the output aln.sam

I am now a little lost on how to use SamTools to remove the host reads -any help greatly appreciated!

samtools • 2.7k views
ADD COMMENT
4
Entering edit mode
4.2 years ago
cschu181 ★ 2.8k
samtools view -buSh -f 4 aln.sam | samtools fastq - | gzip -c - > non_human.fastq.gz

should write all the unaligned (-f 4) reads into a fastq.gz file.

Edit: changed formatting from blockquote to code

ADD COMMENT
0
Entering edit mode

Thank you so much!

Can i check my understanding... -buSh i am unsure what this indicates.

-f extracts only those reads which match the specified SAM flag the flag here is 4 which indicates un-mapped reads samtools fastq =output fasta and gzip to zip the file

ADD REPLY
1
Entering edit mode

-b: bam output, -u: uncompressed bam output (saves time when passing data to a downstream app), -S: sam input, -h: include the header in output (which might not be necessary for samtools fastq downstream, but better to be on the safe side)

Edit: added missing colon

ADD REPLY

Login before adding your answer.

Traffic: 2426 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6