To calculate the length of aligned genome
1
0
Entering edit mode
5.6 years ago

Dear All,

I have a bam file aligned to a reference genome. I would like to know if there is a way to calculate the over all length of aligned genome.

Thanks in advance. Sam.

next-gen • 1.1k views
ADD COMMENT
0
Entering edit mode
5.6 years ago

genomecov should do what you are asking for

Edit :

May take a while :

output=$(bedtools genomecov -ibam in_file.bam -d -split) && (echo "scale=2; $(echo "$output" | cut -f3 | grep -vc "0")/$(echo "$output" | wc -l)" | bc)
ADD COMMENT
0
Entering edit mode

Thanks Bastien. Is this the command to do so: bedtools genomecov -ibam bamfile.bam -bga -g genomelength.txt

ADD REPLY
0
Entering edit mode

More something like this (get the depth at each position):

bedtools genomecov -ibam input_file.bam -d -split > output_depth.txt

From the output file (output_depth.txt), count the number of line with NOT 0 in the 3rd column (with awk for example) divided by the number of line in the file. You will get the percentage of reference positions covered by at least one read.

ADD REPLY

Login before adding your answer.

Traffic: 2657 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