Subsampling Bam File With Samtools
2
21
Entering edit mode
8.4 years ago
madbessoul ▴ 220

Hi,

I am trying to subsample from a bam file using the samtools view -s command. This is working when sampling 50% or lower (-s 42.50, 42 being the seed), but anything higher fails (returns an empty file).

He are the exact commands i use

samtools view -s 0.25 -b chr6_all.bam > chr6_25p.sam

Working.

samtools view -s 0.50 -b chr6_all.bam > chr6_50p.sam

Working.

samtools view -s 0.75 -b chr6_all.bam > chr6_75p.sam

Not working.

I also made sure that 49% is working, but 51% is not. Any ideas, suggestions, or is this an intented mechanic ? There doesn't seem to by any documentation about the subsampling parameter in samtools docfile.

Thanks.

samtools bam • 40k views
ADD COMMENT
1
Entering edit mode

Thank you very much, updating to the lastest version right now.

ADD REPLY
1
Entering edit mode

You could accept one of the answers as the final answer.

ADD REPLY
10
Entering edit mode
8.4 years ago

Subsampling not working for fractions above 50% is a known bug in samtools 0.1.18. (See [Samtools-help] Randomized Subsampling Bam File / Subsampling above 50%.)

The bug was fixed in March last year; samtools 0.1.19 contains the corrected version.

ADD COMMENT
7
Entering edit mode
8.4 years ago

I have also tried sambamba, and found it to be faster in multi-threaded mode compared to samtools 0.1.19

~/src/sambamba/sambamba_v0.3.3 view -h -t $numThreads -s $fractionOfReads -f bam --subsampling-seed=$seed $testBam -o $subsampledTestBam
ADD COMMENT
0
Entering edit mode

When subsampling with samtools or sambamba do all the mappings (uniques, multiple and null) of a read are included in the new bam file?

ADD REPLY

Login before adding your answer.

Traffic: 2083 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