reformat.sh from BBMap suite also has downsampling options.
Sampling parameters:
reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit.
skipreads=-1 Skip (discard) this many INPUT reads before processing the rest.
samplerate=1 Randomly output only this fraction of reads; 1 means sampling is disabled.
sampleseed=-1 Set to a positive number to use that prng seed for sampling (allowing deterministic sampling).
samplereadstarget=0 (srt) Exact number of OUTPUT reads (or pairs) desired.
samplebasestarget=0 (sbt) Exact number of OUTPUT bases desired.
Important: srt/sbt flags should not be used with stdin, samplerate, qtrim, minlength, or minavgquality.
upsample=f Allow srt/sbt to upsample (duplicate reads) when the target is greater than input.
prioritizelength=f If true, calculate a length threshold to reach the target, and retain all reads of at least that length (must set srt or sbt).
I doubt there is a tool that can downsample taking into account the UMIs.
So what is the actual question? Do you need a tool for downsampling fastq?
Yes, I need to downsample fastq files based on UMI. I couldn't find any tools out there to do it.
I do not think they used a dedicated tool but simply counted how many reads were on average per UMi in the full dataset and then simply downsampled the total reads to somewhat match the expected number. Downsampling dataset with more than 60 million reads
Thank you for the explanation, I will try out seqtk mentioned in the link.