dasmoth / dalliance

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

Fetching Behavior for Multiple Tracks with the Same Source #86

Closed ymen closed 10 years ago

ymen commented 10 years ago

Hi Thomas,

I've been toying the idea of displaying a coverage track in conjunction with BAM reads (similar to what IGV does). A relatively simple-minded way to achieve this is to make two tracks with the same URI source but with different style parameters, roughly along the lines of:

// Style for visualizing BAMs.
var bamStyle = [
    {
        "zoom": "low",
        "style": {
            "glyph": "__NONE"
        }
    },
    {
        "zoom": "medium",
        "style": {
            "glyph": "__NONE"
        },
    },
    {
        "type": "bam",
        "zoom": "high",
        "style": {
            "glyph": "__SEQUENCE"
        },
    }
];

// Style for visualizing BAM coverage.
var coverageStyle = [
    {
        "type": "density",
        "style": {
            "glyph": "HISTOGRAM",
            "COLOR1": "black",
            "COLOR2": "red",
            "HEIGHT": 30
        }
    }
];

However, when the coverage track is placed above the BAM track, the __SEQUENCE glyphs in the BAM track are not rendered. I believe the coverage track's settings for light fetching (https://github.com/dasmoth/dalliance/blob/master/js/sourceadapters.js#L1151) seems to suppress the more detailed fetch that is usually done for that are of glyph type __SEQUENCE. The overall result, for example, is that no seq is fetched for features and no reads are drawn: screen shot 2014-08-01 at 1 42 54 pm

Putting the coverage below the BAM track (and triggering refetch) will cause the actual sequences to be fetched.

screen shot 2014-08-01 at 1 43 13 pm

I'm wondering if there's an inherent logic in Dalliance that suppresses re-fetching of the same region from the same file multiple times?

On another note, we would be interested to work on a slightly more detailed density style that shows composition of different bases at each position, similar to what IGV does screen shot 2014-08-01 at 1 48 59 pm

dasmoth commented 10 years ago

Yes, you're right about the "light" BAM fetching mode interaction badly with caching. The logic to combine multiple fetches from a single source is in CachingFeatureSource (and the code at the top of createFeatureSource which reuses existing FeatureSources if something exists.)

Solution is going to be something along the lines of checking in CachingFeatureSource.fetch whether the types array matches that from the cached request, and skip the cache if it doesn't. I'll try to sort this out over the weekend unless someone else gets there first.

On another note, we would be interested to work on a slightly more detailed density style that shows > composition of different bases at each position, similar to what IGV does

This would be great. Any chance you could file a separate issue so we don't lose track of it?

ymen commented 10 years ago

Thanks Thomas for the super-prompt response

This would be great. Any chance you could file a separate issue so we don't lose track of it?

Filed at #87.

dasmoth commented 10 years ago

Fixed now.

Will discuss better BAM summary tracks at #87.