This is not what I needed for this particular use case, as capping the coverage would lose the information on regions of copy number amplification / the variation in coverage across the genome
Im looking for the best way to downsample nanopore long-reads. Ideally I would want to downsample to a specific average read depth e.g. 5x
I have found a few methods e.g. using samtools but this seems to work for downsampling to a specific number or fraction of reads. Rasusa downsamples to a specific coverage /depth but requires fastq input and I would prefer to downsample my BAM files so I don't have to re-run my alignment on many samples again.
2 answers
I'm not sure if this is what you want. I wrote Biostar154220
https://jvarkit.readthedocs.io/en/latest/Biostar154220/#biostar154220
(see Capping coverage in bam file Truncate unevenly covered BAM file at certain coverage )
Is this what you used ultimately? Did this tool satisfy the "specific average depth" requirement?
You could accept (green check mark) this answer to provide closure to this thread. If @Pierre's answer was also useful then it can also be accepted.
rasusa aln subsamples all sites to a specified coverage but it does not randomly subsample to a specified random coverage which is important to note if you are interested in preserving copy number alterations
Log in to answer this question.
You can use
reformat.shfrom BBMap suite. But this may not satisfy the "specific avg depth".Okay, thanks. Just double-checking this will work with long-reads?
Yes it should work with long read BAM's.