While downsampling (subsampling) FASTQ and BAM files is relatively simple with tools such as awk, samtools, seqtk, seqkit, etc., allows you to downsample a BAM file (or FASTQ(s)) by barcodes. That means you can keep all the reads associated with -d number of barcodes or fraction of barcodes (e.g. -d 0.5 will downsample to 50% of all barcodes).