Question: nonamecheck not working in bedtools coverage
0
gravatar for roalva1
9 months ago by
roalva180
Spain
roalva180 wrote:

Hello,

I am running this command line in bedtools 2.27.1

bedtools coverage -nonamecheck -d -sorted -a file.bed -b file.bam  > file.cov

and I get this error

ERROR: Database file file.bam contains chromosome chrM, but the query file does not.
       Please rerun with the -g option for a genome file.
       See documentation for details.

I don't have access to the genome file and I guess nonamecheck is not working,

Thanks a lot

Best regards

bedtools • 374 views
ADD COMMENTlink modified 9 months ago by RamRS21k • written 9 months ago by roalva180
3
gravatar for finswimmer
9 months ago by
finswimmer11k
Germany
finswimmer11k wrote:

Hello,

the genome file is need if you want to use -sorted. You can extract this information from your bam file as all informations are in the header.

$ samtools view -H file.bam|grep @SQ|sed 's/@SQ\tSN://'|sed 's/LN://' > genome.txt

fin swimmer

(I'm sure there is more beautiful sed command ;) )


Edit: Just for documentation the sed commands can be combined in one:

sed 's/@SQ\tSN:\|LN://g'
ADD COMMENTlink modified 9 months ago • written 9 months ago by finswimmer11k

Wouldn't be -nonamecheck enaugh for this?

-nonamecheck    For sorted data, don't throw an error if the file has different naming conventions
        for the same chromosome. ex. "chr1" vs "chr01".
ADD REPLYlink written 9 months ago by roalva180

Are you mixing and matching the genomes by any chance? BED file from one provider where as BAM aligned to a different one?

ADD REPLYlink written 9 months ago by genomax65k

No no, I have got just a bam

ADD REPLYlink written 9 months ago by roalva180

Hm, I don't know what -nonamecheck does behind the scene.. Maybe it just ignores lower/upper cases and leading zeros?

genomax suggested to me, that it also could be a naming mismatch between the bam file and your bed file. How is the name for chrM in the bed file? Maybe chrMT or just MT.?

fin swimmer

ADD REPLYlink written 9 months ago by finswimmer11k

My bed file doesn't have any region in chrMT nor chrM

ADD REPLYlink written 9 months ago by roalva180

Interesting. Then why are you getting this? Or you just don't have any chrM regions in your bed file (and that is just a warning).

Database file file.bam contains chromosome chrM, but the query file does not.

ADD REPLYlink modified 9 months ago • written 9 months ago by genomax65k

Yes, I don't have any chrM regions in my bed file, but I do have in my bam. The message of bedtools should be a warning but it is not. Bedtools stops and the coverage in chrX regions are not calculated.

ADD REPLYlink written 9 months ago by roalva180

This has solved my problem, but still, with bedtools 2.17 we didn't need this, and I think it is not intuitive.

ADD REPLYlink written 9 months ago by roalva180

You can accept @fin swimmer's answer (green check mark) to provide to closure to this thread since your problem is solved.

ADD REPLYlink modified 9 months ago • written 9 months ago by genomax65k
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: 1518 users visited in the last hour