Downsample BAM file according to coverage
1
2
Entering edit mode
9.8 years ago

I have a BAM file that has 33X whole genome coverage.

I would like to create a new BAM file from the original that has 10X genome coverage.

Is this the correct method?

samtools view -h -s 0.3 in.bam >10x.bam

Also what methods do you use for fast calculation of whole genome coverage? GATK is bloody slow.

reads sequencing BAM SAMtools • 7.2k views
ADD COMMENT
0
Entering edit mode

~/programs/jvarkit/dist/bamstats04 is pretty good, but it's a pain to compile with ant. Nevertheless, I managed after a day or so and now I'm happy, it's really useful.

USAGE: BamStats04 [options]
 Coverage statistics for a BED file. It uses the Cigar string instead of the start/end to get the voverageVersion: 1.0
Version: null

Options:

--help
-h                            Displays options specific to this tool.
--stdhelp
-H                            Displays options specific to this tool AND options common to all Picard command line
                              tools.
--version                     Displays program version.
IN=File
I=File                        BAM file to process.  Required.
BEDILE=File
BED=File                      BED File.  Required.
NO_DUP=Boolean
NODUP=Boolean                 discard duplicates  Default value: true. This option can be set to 'null' to clear the
                              default value. Possible values: {true, false}
NO_ORPHAN=Boolean
NOORPHAN=Boolean              discard not properly paired  Default value: true. This option can be set to 'null' to
                              clear the default value. Possible values: {true, false}
NO_VENDOR=Boolean
NOVENDOR=Boolean              discard failing Vendor Quality  Default value: true. This option can be set to 'null' to
                              clear the default value. Possible values: {true, false}
MMQ=Integer
MIN_MAPING_QUALITY=Integer    min mapping quality  Default value: 0. This option can be set to 'null' to clear the
                              default value.
MIN_COVERAGE=Integer
MIN_COV=Integer               min coverage to say the position is not covered  Default value: 0. This option can be set
                              to 'null' to clear the default value.
ADD REPLY
3
Entering edit mode
9.8 years ago

Yes, the -s 0.3 will result in an average 10x coverage. One simple method to get total coverage is to simply parse the output of samtools depth.

ADD COMMENT

Login before adding your answer.

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