Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsorted positions on sequence error #98

Closed
tjbencomo opened this issue Dec 17, 2019 · 10 comments
Closed

Unsorted positions on sequence error #98

tjbencomo opened this issue Dec 17, 2019 · 10 comments

Comments

@tjbencomo
Copy link

I'm trying to measure the exome coverage for a bam file I've recently processed with GATK. After downloading my BED file (all hg38 RefSeq exons) from the UCSC Table Browser, I'm running the following command

mosdepth --by hg38.refseq.exons.bed test control.hg38.bam

and encountering the following error

[E::hts_idx_push] Unsorted positions on sequence #81: 1 followed by 0
[hts-nim] error adding to csi index

hg38.refseq.exons.bed lines 80-83 look like this

chr1	169048	169264	XR_002958516.1_exon_3_0_chr1_169049_r	0	-
chr1	172556	172688	XR_002958516.1_exon_4_0_chr1_172557_r	0	-
chr1	172556	172688	XR_001737578.2_exon_5_0_chr1_172557_r	0	-
chr1	172556	172688	XR_002958515.1_exon_4_0_chr1_172557_r	0	-

I'm not very familiar with BED files, so I'm having difficulty understanding the error message. I've already tried sorting my BED file with bedtools sort but that doesn't fix it. I also saw #22 and tried that solution but the same error still appears. Any idea what could be causing this error?Thanks!

@brentp
Copy link
Owner

brentp commented Dec 17, 2019

hi, can you share the bam file to re-create? the exons get sorted by mosdepth, so that shouldn't be the problem. and the 81 is referring to the chromosome/contig.

@tjbencomo
Copy link
Author

Thanks for the reply. I'm processing the data for someone so I need to get the OK to share the bam file, but in the meantime is there a certain piece of the file that would be helpful to see? I can share the bam file's header with the contig information if that would help.

@brentp
Copy link
Owner

brentp commented Dec 19, 2019

if it helps, it should be sufficient just to share the alignments on the 81st contig (which should be a pretty small amount of data). You can do that by doing samtools view -H $bam | grep SQ | grep -n SQ
and seeing the row labelled 81. Though, I'm not sure if the error reported by htslib is 0-based or 1-based, so you might need to get the row labelled as 82.
You can extract that chrom from the bam and then verify you seem the same error, then send to me if possible.

@tjbencomo
Copy link
Author

I'm able to share the reads from contig 81 in bam format. I sent you an email with the subsetted bam file. The error persists when running on this subsetted file

@nextgenusfs
Copy link

I'm running into something similar and have traced it to the following coordinates (regions of interest) in my bed file which contains a overlapping coordinates, ie like this:

chr7	0	104910	region1
chr7	0	97201	region2
chr7	29359	48861	region3

This results in the following error:

$ mosdepth -b bam1.sorted.bed -n --fast-mode test-cov test.bam
[E::hts_idx_push] Unsorted positions on sequence #7: 1 followed by 0
[hts-nim] error adding to csi index

If I remove either of the first two regions, then it runs without error. If I reverse the order of the first two regions, it also errors, ie:

chr7	0	97201	region2
chr7	0	104910	region1
chr7	29359	48861	region3

@brentp
Copy link
Owner

brentp commented Jan 7, 2020

ok. this is helpful. i will have a look.

@nextgenusfs
Copy link

And sorry I didn't mention, but this is mosdepth 0.2.6 -- I can try 02.27 if you think it would make a difference.

@brentp
Copy link
Owner

brentp commented Jan 7, 2020

no need. I fixed a bug in hts-nim that resolves this. I'll release 0.3.1 shortly thanks for reporting and for the test-case.

brentp added a commit that referenced this issue Jan 7, 2020
@brentp
Copy link
Owner

brentp commented Jan 7, 2020

new release here: https://github.com/brentp/mosdepth/releases/tag/v0.2.8
thanks again

@nextgenusfs
Copy link

Thanks @brentp -- confirmed that v0.2.8 fixes this issue. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants