Downsample a SAM or BAM file.This tool applies a downsampling algorithm to a SAM or BAM file to retain only a (deterministically random) subset of the reads. Reads from the same template (e.g. read-pairs, secondary and supplementary reads) are all either kept or discarded as a unit, with the goal of retaining readsfrom PROBABILITY * input templates. The results will contain approximately PROBABILITY * input reads, however for very small PROBABILITIES this may not be the case. A number of different downsampling strategies are supported using the STRATEGY option: ConstantMemory: Downsamples a stream or file of SAMRecords using a hash-projection strategy such that it can run in constant memory. The downsampling is stochastic, and therefore the actual retained proportion will vary around the requested proportion. Due to working in fixed memory this strategy is good for large inputs, and due to the stochastic nature the accuracy of this strategy is highest with a high number of output records, and diminishes at low output volumes. HighAccuracy: Attempts (but does not guarantee) to provide accuracy up to a specified limit. Accuracy is defined as emitting a proportion of reads as close to the requested proportion as possible. In order to do so this strategy requires memory that is proportional to the number of template names in the incoming stream of reads, and will thus require large amounts of memory when running on large input files. Chained: Attempts to provide a compromise strategy that offers some of the advantages of both the ConstantMemory and HighAccuracy strategies. Uses a ConstantMemory strategy to downsample the incoming stream to approximately the desired proportion, and then a HighAccuracy strategy to finish. Works in a single pass, and will provide accuracy close to (but often not as good as) HighAccuracy while requiring memory proportional to the set of reads emitted from the ConstantMemory strategy to the HighAccuracy strategy. Works well when downsampling large inputs to small proportions (e.g. downsampling hundreds of millions of reads and retaining only 2%. Should be accurate 99.9% of the time when the input contains more than 50,000 templates (read names). For smaller inputs, HighAccuracy is recommended instead.
PROBABILITY * (input templates). The results will contain approximately
PROBABILITY * (input reads), however for very small probabilities this may not be the case. A number of different downsampling strategies are supported using the #STRATEGY option:
java -jar picard.jar DownsampleSam \ I=input.bam \ O=downsampled.bam \ P=0.1
java -jar picard.jar DownsampleSam \ I=input.bam \ O=downsampled.bam \ STRATEGY=Chained \ P=0.02 \ ACCURACY=0.0001
java -jar picard.jar DownsampleSam \ I=input.bam \ O=downsampled.bam \ STRATEGY=HighAccuracy \ P=0.00001 \ ACCURACY=0.0000001
This table summarizes the command-line arguments that are specific to this tool. For more details on each argument, see the list further down below the table or click on an argument name to jump directly to that entry in the list.
|Argument name(s)||Default value||Summary|
|null||The input SAM or BAM file to downsample.|
|null||The output, downsampled, SAM or BAM file to write.|
|Optional Tool Arguments|
|1.0E-4||The accuracy that the downsampler should try to achieve if the selected strategy supports it. Note that accuracy is never guaranteed, but some strategies will attempt to provide accuracy within the requested bounds.Higher accuracy will generally require more memory.|
||||read one or more arguments files and add them to the command line|
|false||display the help message|
|null||The metrics file (of type QualityYieldMetrics) which will contain information about the downsampled file.|
|1.0||The probability of keeping any individual read, between 0 and 1.|
|1||Random seed used for deterministic results. Setting to null will cause multiple invocations to produce different results.|
||null||The reference sequence file.|
|ConstantMemory||The downsampling strategy to use. See usage for discussion.|
||false||display the version number for this tool|
|Optional Common Arguments|
||5||Compression level for all compressed files created (e.g. BAM and VCF).|
||false||Whether to create a BAM index when writing a coordinate-sorted BAM file.|
||false||Whether to create an MD5 digest for any BAM or FASTQ files created.|
||client_secrets.json||Google Genomics API client_secrets.json file path.|
||500000||When writing files that need to be sorted, this will specify the number of records stored in RAM before spilling to disk. Increasing this number reduces the number of file handles needed to sort the file, and increases the amount of RAM needed.|
||false||Whether to suppress job-summary info on System.err.|
||||One or more directories with space available to be used by this program for temporary storage of working files|
|false||Use the JDK Deflater instead of the Intel Deflater for writing compressed output|
|false||Use the JDK Inflater instead of the Intel Inflater for reading compressed input|
||STRICT||Validation stringency for all SAM files read by this program. Setting stringency to SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded.|
||INFO||Control verbosity of logging.|
||false||display hidden arguments|
Arguments in this list are specific to this tool. Keep in mind that other arguments are available that are shared with other tools (e.g. command-line GATK arguments); see Inherited arguments above.
The accuracy that the downsampler should try to achieve if the selected strategy supports it. Note that accuracy is never guaranteed, but some strategies will attempt to provide accuracy within the requested bounds.Higher accuracy will generally require more memory.
double 1.0E-4 [ [ -∞ ∞ ] ]
read one or more arguments files and add them to the command line
Compression level for all compressed files created (e.g. BAM and VCF).
int 5 [ [ -∞ ∞ ] ]
Whether to create a BAM index when writing a coordinate-sorted BAM file.
Whether to create an MD5 digest for any BAM or FASTQ files created.
Google Genomics API client_secrets.json file path.
display the help message
The input SAM or BAM file to downsample.
R File null
Integer 500000 [ [ -∞ ∞ ] ]
The metrics file (of type QualityYieldMetrics) which will contain information about the downsampled file.
The output, downsampled, SAM or BAM file to write.
R File null
The probability of keeping any individual read, between 0 and 1.
double 1.0 [ [ -∞ ∞ ] ]
Whether to suppress job-summary info on System.err.
Random seed used for deterministic results. Setting to null will cause multiple invocations to produce different results.
Integer 1 [ [ -∞ ∞ ] ]
The reference sequence file.
display hidden arguments
The downsampling strategy to use. See usage for discussion.
The --STRATEGY argument is an enumerated type (Strategy), which can have one of the following values:
Use the JDK Deflater instead of the Intel Deflater for writing compressed output
Use the JDK Inflater instead of the Intel Inflater for reading compressed input
The --VALIDATION_STRINGENCY argument is an enumerated type (ValidationStringency), which can have one of the following values:
Control verbosity of logging.
The --VERBOSITY argument is an enumerated type (LogLevel), which can have one of the following values:
display the version number for this tool
GATK version 188.8.131.52 built at Tue, 23 Apr 2019 14:55:55 -0400.