Skip to content

Instantly share code, notes, and snippets.

@opplatek
Last active May 6, 2024 12:55
Show Gist options
  • Save opplatek/8f64229ff219f81ba65ce35184f64222 to your computer and use it in GitHub Desktop.
Save opplatek/8f64229ff219f81ba65ce35184f64222 to your computer and use it in GitHub Desktop.
Subset a BAM file by a number or fraction of mappings or reads
#!/bin/bash
#
# Subsample BAM to $SUBSAMPLE_MAPPINGS mappings (approximately)
#
# TODO: Make subsampling by number of reads, not mappings (a single read can be mapped multiple times so the final number
# or "lines" will be different than the $SUBSAMPLE_READS)
# check out https://www.biostars.org/p/9592303/#9593989
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment