Question: how to read indexed bamfiles
0
gravatar for onemore100iq
2.0 years ago by
onemore100iq20
onemore100iq20 wrote:

I am trying to calculate depth by region using samtools depth command to extract depth information for specific region in chromosome_3 in a bam file.bam I indexed the bam file using samtools index bamfile.bam to bamfile.bam.bai when I typed samtools depth -r chromosome_3:10001-10010 bamfile.bam.bai
it gave erorr : could not open "bamfile.bam.bai" : Success how it could not open the bam.bai file and count it as success?

any help would be highly apprciated

next-gen • 980 views
ADD COMMENTlink modified 2.0 years ago by Chris Miller21k • written 2.0 years ago by onemore100iq20

Was this bam files sorted before it was indexed?

ADD REPLYlink written 2.0 years ago by genomax74k

yes. and it worked now thanks

ADD REPLYlink written 2.0 years ago by onemore100iq20

You could have a look at https://github.com/brentp/mosdepth

ADD REPLYlink written 2.0 years ago by WouterDeCoster42k
3
gravatar for Chris Miller
2.0 years ago by
Chris Miller21k
Washington University in St. Louis, MO
Chris Miller21k wrote:

samtools depth -r chromosome_3:10001-10010 bamfile.bam.bai

You should point samtools to the bam file, not the index file.

ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by Chris Miller21k
1

Correctly said by Chris, Input requirement for samtools depth is .bam file not .bai (indexed) file

samtools depth -r <chr:from-to> .bam

Above command should work. (Also make sure that .bam and .bai are in the same directory)

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by Samarth Kulshrestha200

Thanks i did as u said and it worked. Thank u so much

ADD REPLYlink written 2.0 years ago by onemore100iq20

Thanks Chris, it worked. La

ADD REPLYlink written 2.0 years ago by onemore100iq20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1287 users visited in the last hour