alanocallaghan / scater

Clone of the Bioconductor repository for the scater package.
https://bioconductor.org/packages/devel/bioc/html/scater.html
95 stars 40 forks source link

Create rasters for plots involving many, many points #173

Closed LTLA closed 2 years ago

LTLA commented 2 years ago

We could explore an option to wrap geom_point calls with rasterize in the functions that involve plotting many thousands of points, e.g., plotReducedDim for large datasets. This would allow users to easily save the plots to PDF for editing in Illustrator or whatever in publication prep, without worrying about their computer crashing from attempting to load in >100000 vector objects.

It might be as simple as wrapping things in rasterize on request. I remember seeing another method for rasterizing points but maybe it was the same.

alanocallaghan commented 2 years ago

I'm semi-reluctant to do this given that users can already do this but I guess the whole point of the package at this point is to abstract away technicalities and provide some decent defaults

alanocallaghan commented 2 years ago

8e14600

Might change the default based on the input dim

LTLA commented 2 years ago

My thinking was that we could apply the rasterize specifically to the geom_point layer with lots of points, so as to avoid accidental rasterization of other layers. Not sure how relevant this concern is, but if the ggrastr authors decide to change the defaults to include, e.g., rasterization of text, then our cluster labels might end up rasterized in the current implementation.

If we were to rasterize the specific geom_point layer, it would have to be done inside the central plotter function; it wouldn't be something that the user could do on the returned ggplot object.

alanocallaghan commented 2 years ago

I guess for anything that's plot_grided it wouldn't; anything else could use rasterise(p, layers="Point")