dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
226 stars 68 forks source link

Bug report (?): Inconsistencies in BAM alignments rendered at a given bp rendered at different magnification #65

Closed ymen closed 10 years ago

ymen commented 10 years ago

Hello Dalliance developers,

I've been trying out Dalliance for a couple of days to visualize alignment data and it's been awesome! Thank you!

I wanted to raise a problem that I have encountered in my experience, however. When viewing alignment (from BAM files), I seem to get different number of reads rendered at the same base position at different magnification levels (less reads rendered at high magnification and more at lower magnification). It is a somewhat finicky problem, but I think this example shows this.

Observations/Triggers of Bug

I will use the column of non-ref base (pos at ~41,063,465; the thin red column, boxed in orange) as a reference base position. At a more zoomed out level, there is a large number of reads (>40) that are present at that base. zoomed_out

But when I zoom in to the maximum, there are only about 20 reads that I can visualize (the 2nd screenshot reaches the bottom of scroll, I promise)

zoomed_in_1 zoomed_in_2

If I fiddle with the magnification a little scroll around to force Dalliance to re-render by going out of this viewing range, and scroll back into the same range, I can (sometimes) see the full depth of reads.

zoomed_in_3

Hypotheses

I have 2 hypotheses on why this might be happening:

(In this case, the reads which extends far to the left seems to be not rendered). The BAM file I'm using have longer reads (~100bp). I'm thinking that only reads that has a start within some constant value of the start of the viewing window may be loaded.

   var width = (this.viewEnd - this.viewStart) + 1;

    var minExtraW = (100.0/this.scale)|0;

    var maxExtraW = (1000.0/this.scale)|0;

This was a bit worrying for me because I wanted to be sure that all reads at a specific bp are rendered when I am at max magnification.

I'm sorry I can't share this BAM file that I'm visualizing but if there's any programmatic ways to help pin down the problem I'd be totally up to try it out. I would also be happy to provide a smaller subset of the BAM file which is share-able and can trigger the bug. Would also appreciate any pointers on what else to investigate.

Thank you!

Best, Yifei

dasmoth commented 10 years ago

I've checked the BAM fetching code carefully, and it's should definitely be fetching all the reads it should be.

But there's a slightly different issue at work here: I think your BAM files are hitting a limit of 100 subtiers when "bumping" features to overlap. Historically, this wasn't an issue because BAM files rarely got close to 100x coverage -- but I realize that things have moved on!

There are two ways you can fix this:

There are a couple of Dalliance issues here that I'll try to resolve next week:

ymen commented 10 years ago

There are two ways you can fix this:

If you've added the track via the API, you can override this setting on a per-track basis by adding the option subtierMax: 1000 (or whatever) to a track config.

Alternatively, you can just edit DEFAULT_SUBTIER_MAX around line 63 of feature-draw.js.

Thanks Thomas for your prompt response, up-ing the subtierMax seems to do the trick, I've not considered this problem at all!

I think the changes you're proposing will be awesome, will be looking forward to them. Thanks again!

dasmoth commented 10 years ago

As discussed, there is now a warning when subtierMax is exceeded, and a way of configuring it in the track editor.

These changes have been made on the 0.12.x and master branches, and will be included in the next release.

ymen commented 10 years ago

Thank you for following up with this, works great! :)