This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Average read length by position BAM file

Hello everyone! Is there a tool which can be used to extract the average length of mapped reads in each position per chromosome? Thanks in advance!

bam

May I ask what this would be useful for. No, probably no out-of-the-box tool. There are many posts on biostars on extracting read length from a BAM. It will be tedious as you describe it. Do you really need every genome position? For human that will be three billion "average read lengths".

1 answer

it sounds like a XY problem. What's the point of this ?

Anyway, using bioalcidaejdk http://lindenb.github.io/jvarkit/BioAlcidaeJdk.html and datamash:

java -jar ${JVARKIT_DIST}/bioalcidaejdk.jar -e 'stream().forEach(R->println(R.getContig()+":"+R.getStart()+"\t"+R.getReadLength()));' coord.sorted.bam | datamash -g 1 mean 2


(...)
RF01:1  70
RF01:8  70
RF01:11 70
RF01:12 70
RF01:27 70
RF01:44 70
RF01:67 70
RF01:94 70
RF01:102    70
RF01:110    70

No, probably no out-of-the-box tool

Is there anything that BioAlcidae cannot do? :-D

Log in to answer this question.