Get the percentage of fragment length that is less than 120bp
1
0
Entering edit mode
3.0 years ago
munaj86 ▴ 30

Hi,

I'm working with Cut&Run data and I would like to get the percentage of the fragment length that is less than 120bp. I used bampefragmest size from deep tools to get a plot of all the fragment length that is present in my sample. And now I would like to get the proportion of fragment length that is less than 120bp in the whole sample in order to assess my data.

Can anyone suggest a way to get this, maybe with awk?

Thanks

CutAndRun • 919 views
ADD COMMENT
1
Entering edit mode

You asked multiple questions but seem to have neither upvoted nor followed up on most of them. Please upvote helpful comments, consider accepting answers that solved the problem.

ADD REPLY
0
Entering edit mode

I wil do that for the coming question. Thanks

ADD REPLY
0
Entering edit mode
3.0 years ago

You could collect the fragment lengths from the ninth column of the BAM file, and then accumulate them in awk:

$ bam2bed --do-not-sort < reads.bam | awk -v FS="\t" -v THRESHOLD=120 'BEGIN { s = 0; a = 0; } { s += 1; if (($9 < THRESHOLD) && ($9 > -THRESHOLD)) { a += 1 } } END { print a / s; }'
ADD COMMENT
0
Entering edit mode

Hi Alex,

I tried the above command and it gives me 0 with each file. Do you have an idea what might goes wrong?

Thanks

ADD REPLY

Login before adding your answer.

Traffic: 1356 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6