This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Collapse mapped reads in sorted bam file based on the start and end position coordinates

Dear Biostars Users,

Is there a way to collapse mapped reads in sorted bam files based on the start and end position coordinates regardless of sequences? I would like to collapse the number of reads with the same start and end position as "1" although these reads have different sequences. I attach an image here [ https://ibb.co/J7Fj00T] to illustrate my points if not clear in words.

collapse-duplicates-in-bam-file Thanks ahead.

Xiao

rna-seq

Thanks, I followed your suggestions and re-uploaded my image. Feel free to let me know if there is any problem.

You could do this in R with GenomicRanges/Alignments relatively easily

1 answer

Sounds like you need to clumpify your reads BEFORE you align them (to remove sequence duplicates): A: Introducing Clumpify: Create 30% Smaller, Faster Gzipped Fastq Files

Thanks Genomax, could Clumpify remove sequence duplicates with different sequences? I removed my sequence duplicates with FastX-toolkits (FASTQ/A Collapser) before mapping. Now I consider more stringent criteria of duplicates: reads mapped to the references that have the same start and end position in the alignment. Note that the sequences of these reads can be different.

clumpify will do that but not using the aligned BAM files. To get the result you need, you will need to first collapse the reads (clumpify allows errors, hdist=Number parameter, so reads containing one or more SNP's can be treated as having identical sequence). Then follow that by alignment.

Log in to answer this question.