BAMDOWNSAMPLERANDOM(1)
π NAME π
bamdownsamplerandom β downsample a SAM, BAM or CRAM file β¨
so yeah, this is the manual page for bamdownsamplerandom in section 1 of the manual (General Commands Manual), and she is iconic. let's go π«Ά
π¦ SYNOPSIS π¦
bamdownsamplerandom [options]
πΈ DESCRIPTION πΈ
okay so here's the vibe: bamdownsamplerandom reads a SAM, BAM or CRAM file from standard input, randomly discards reads, and writes whatever's left to standard output in BAM format. no cap.
and bestie, the pair thing matters: for a pair of reads, either both ends get discarded or both ends get kept. never one and not the other, we don't do that here π
one lil heads up though β the order of reads in the output file may be different from the order in the input if the reads in the input file are not collated by their read name. so if you're side-eyeing the output like "why are you like this", that's why π
here are the key=value pairs you can give:
p=<1>β the probability for a pair of reads, or a single end read, to be kept. default behaviour? everything gets kept. all of it. πseed=<>β the seed for the random number generator. by default the current time is used, which means every run of the program picks a different subset of reads from an input file (chaotic, honestly, but that's the default). if you need the program's behaviour to be reproducible, plug in a fixed number as the random seed. periodt.I=<stdin>β input file name. if you don't give this option, the data is read from standard input.inputformat=<bam>β input file format. every version ofbamtofastqcomes with support for the BAM input format. if the program is in addition linked to the io_lib package, then these options are valid too:bamβ BAM (see http://samtools.sourceforge.net/SAM1.pdf)samβ SAM (see http://samtools.sourceforge.net/SAM1.pdf)cramβ CRAM (see http://www.ebi.ac.uk/ena/about/cram_toolkit)
level=<-1|0|1|9|11>β sets the compression level of the output BAM file. valid values are:-1β zlib/gzip default compression level0β uncompressed1β zlib/gzip level 1 (fast) compression9β zlib/gzip level 9 (best) compression
and if libmaus has been compiled with support for igzip (see https://software.intel.com/en-us/articles/igzip-a-high-performance-deflate-compressor-with-optimizations-for-genomic-data) then there's one more valid value:
11β igzip compression π₯
exclude=<SECONDARY,SUPPLEMENTARY>β do not include reads in the output that have any of the given flags set. you give the flags separated by commas. valid flags are:PAIREDβ read was paired in sequencingPROPER_PAIRβ read has been mapped as part of a proper pairUNMAPβ read was not mappedMUNMAPβ mate of read was not mappedREVERSEβ read was mapped to the reverse strandMREVERSEβ mate of read was mapped to the reverse strandREAD1β read was first read of a pair during sequencingREAD2β read was second read of a pair during sequencingSECONDARYβ alignment is secondary, i.e. an alternative mapping to the primary alignment in the same fileQCFAILβ read as marked as having failed quality controlDUPβ read is marked as a duplicate of another read in the same file (seebammarkduplicates)SUPPLEMENTARYβ read is marked as supplementary alignment
disablevalidation=<0>β valid values are:0β run input file validation on alignments (this is the default)1β do not check the validity of the input file (this may help for some broken input files, but it is a security risk as it can lead to the execution of arbitrary code through a forged input file).
π¨ bestie. do NOT casually set disablevalidation=1. yes it can rescue your cursed broken input file, but it's a security risk β a forged input file can lead to the execution of arbitrary code. literally read that twice. π
colhlog=<18>β base two logarithm of the size of the hash table used for collation. the default value is18and should work reasonably well for most input files. please see the biobambam paper at arxiv.org/abs/1306.0836 for details.colsbs=<128M>β size of hash table overflow list in bytes. the default is128MBand should work reasonably well for most input files. please see the biobambam paper at arxiv.org/abs/1306.0836 for details.T=<bamdownsamplerandom_hostname_pid_time>β file name of temporary file used for collation.ranges=<>β coordinate ranges selected from input. this option is only available for input files in BAM format which have a corresponding index (.baifile) and if input is via file (i.e. theIargument is set). valid ranges consist either of:- whole reference sequence β a whole reference sequence (e.g.
"chr1") - half open interval on reference sequence β an interval on a reference sequence half open on the right (e.g.
"chr1:50000"which means alignments overlappingchr1from position50000to the end ofchr1) - interval on reference sequence β an interval on a reference sequence (e.g.
"chr1:50000-60000"which means alignments overlapping positions50000to60000onchr1)
- whole reference sequence β a whole reference sequence (e.g.
multiple ranges are separated by space characters (e.g. ranges="chr1:10000-20000 chr1:30000-40000").
reference=β file name of the reference for CRAM input files. if this key is unset, then the CRAM file header will be scanned for obtaining a reference file name.tmpfile=<filename>β prefix for temporary files. by default the temporary files are created in the current directory.outputformat=<bam>β output file format. all versions ofbamsortcome with support for the BAM output format. if the program is in addition linked to the io_lib package, then these options are valid too:bamβ BAM (see http://samtools.sourceforge.net/SAM1.pdf)samβ SAM (see http://samtools.sourceforge.net/SAM1.pdf)cramβ CRAM (see http://www.ebi.ac.uk/ena/about/cram_toolkit). this format is not advisable for data sorted by query name.
O=<[stdout]>β output filename, standard output if unset.outputthreads=<[1]>β output helper threads, only valid foroutputformat=bam.md5=<0|1>β md5 checksum creation for output file. this option can only be given ifoutputformat=bam. then valid values are:0β do not compute checksum. this is the default.1β compute checksum. if themd5filenamekey is set, then the checksum is written to the given file. ifmd5filenameis unset, then no checksum will be computed.
md5filenameβ file name for md5 checksum ifmd5=1.index=<0|1>β compute BAM index for output file. this option can only be given ifoutputformat=bam. then valid values are:0β do not compute BAM index. this is the default.1β compute BAM index. if theindexfilenamekey is set, then the BAM index is written to the given file. ifindexfilenameis unset, then no BAM index will be computed.
indexfilenameβ file name for output BAM index ifindex=1.hash=<0|1>β use hash of query name instead of a random number for selection. this makes the output depend on how random the hashes produced for the query names are, but it has the advantage of not requiring collation to keep pairs together. in contrast, the order of retained reads does not change forhash=1. π
π AUTHOR π
written by German Tischler.
π REPORTING BUGS π
report bugs to <germant@miltenyibiotec.de>
π COPYRIGHT π
copyright Β© 2009-2014 German Tischler, Β© 2011-2014 Genome Research Limited. License GPLv3+: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>
this is free software: you are free to change and redistribute it. there is NO WARRANTY, to the extent permitted by law. (yes, all caps, they mean it π)
that's the whole page bestie, hope you slayed your downsampling πβ¨ β this is from biobambam, dated October 2014 ππ¦
π¦ where this page comes from
- debian bookworm: biobambam2 2.0.185+ds-1 Β· GPL-3.0-or-later
- debian trixie: biobambam2 2.0.185+ds-2 Β· GPL-3.0-or-later
- ubuntu jammy: biobambam2 2.0.183+ds-1 Β· GPL-3.0-or-later
- ubuntu noble: biobambam2 2.0.185+ds-1 Β· GPL-3.0-or-later
- ubuntu questing: biobambam2 2.0.185+ds-2
- ubuntu resolute: biobambam2 2.0.185+ds-2build1 Β· GPL-3.0-or-later
- ubuntu stonking: biobambam2 2.0.185+ds-2build1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms