linnarsson-lab / loom-viewer

Tool for sharing, browsing and visualizing single-cell data stored in the Loom file format
BSD 2-Clause "Simplified" License
35 stars 6 forks source link

Is it possible to cap the zoom-level for which we compute tiles? #63

Closed JobLeonard closed 7 years ago

JobLeonard commented 7 years ago

If I zoom all the way in on the heatmap, I get tiles for individual cells:

image

This is of course ridiculous: there is no need to computer tiles where cells take up more than one pixel.

As good as PNG compression is with this type of image, it is still wasted bandwidth. More importantly, it clogs up the server, which has to computer individual tiles for each cell. Especially if we pre-compute this the effect is visible: seeing as a tile is 256 by 256 pixels, that's 2^2 + 4^2 + 8^2 + 16^2 + 32^2 + 64^2 + 128^2 + 256^2 = 87380x less tiles to compute.

slinnarsson commented 7 years ago

Only tiles that are zoomed out (one pixel is less than one datapoint) are precomputed and stored in the file; otherwise yes the files would be enormous. For zoomed-in tiles, I simply fetch the 1:1 tile containing the target square, and then crop and resize it. It would be more efficient to do this on the client side, if you can find a way to cache and reuse the relevant 1:1 tile.

I think the issue was that Leaflet will not zoom in beyond 1 pixel, and we do want to be able to zoom in to at least where the pixels are large enough that you can read text attributes on the side (e.g. gene names).

/Sten

Sten Linnarsson, PhD Professor of Molecular Systems Biology Karolinska Institutet Unit of Molecular Neurobiology Department of Medical Biochemistry and Biophysics Scheeles väg 1, 171 77 Stockholm, Sweden +46 8 52 48 75 77 (office) +46 70 399 32 06 (mobile)

On 28 Sep 2016, at 11:21, Job van der Zwan notifications@github.com<mailto:notifications@github.com> wrote:

If I zoom all the way in on the heatmap, I get tile for an individual cell:

[image]https://cloud.githubusercontent.com/assets/259840/18907582/7b145816-856c-11e6-8bc2-7dd61feac74a.png

This is of course ridiculous: there is no need to computer tiles where cells take up more than one pixel.

As good as PNG compression is with this, this is still wasted bandwidth. More importantly, it clogs up the server, which has to computer individual tiles for each cell. Especially if we pre-compute this the effect is visible: seeing as a tile is 256 by 256 pixels, that's 2^2 + 4^2 + 8^2 + 16^2 + 32^2 + 64^2 + 128^2 + 256^2 = 87380x less tiles to compute.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/linnarsson-lab/Loom/issues/63, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKKag7InK-iQn_W0CEpymRafKwJWCDNOks5qujGOgaJpZM4KImDD.

JobLeonard commented 7 years ago

I had a quick look at this again, the issue was actually quite simple to resolve client-side:

maxNativeZoom: Maximum zoom number the tiles source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxNativeZoom level and auto-scaled.

http://leafletjs.com/reference-1.0.0.html#tilelayer-maxnativezoom

The only issue (at first) was that zoomed in tiles were interpolated, but that was easy enough to fix with a bit of CSS.

https://github.com/linnarsson-lab/Loom/commit/c111e8a70b6312eef7ddbe158422c9878c346027