# subsetPointsByGrid: Subset points for faster plotting In csoneson/iSEE: Interactive SummarizedExperiment Explorer

## Description

Subset points using a grid-based system, to avoid unnecessary rendering when plotting.

## Usage

 `1` ```subsetPointsByGrid(X, Y, resolution = 200) ```

## Arguments

 `X` A numeric vector of x-coordinates for all points. `Y` A numeric vector of y-coordinates for all points, of the same length as `X`. `resolution` A positive integer specifying the number of bins on each axis of the grid.

## Details

This function will define a grid of the specified resolution across the plot. Each point is allocated to a grid location (i.e., pair of bins on the x- and y-axes). If multiple points are allocated to a given location, only the last/right-most point is retained. This mimics the fact that plotting will overwrite earlier points with later points. In this manner, we can avoid unnecessary rendering of earlier points that would not show up anyway.

Note that the `resolution` should be a positive integer less than the square root of the maximum integer size, and will be coerced into the valid range if necessary. This enables fast calculation of the grid locations for all points.

For plots where `X` and `Y` are originally categorical, use the jittered versions as input to this function.

## Value

A logical vector indicating which points should be retained.

Aaron Lun

## Examples

 ```1 2 3 4 5 6 7 8``` ```X <- rnorm(100000) Y <- X + rnorm(100000) summary(subsetPointsByGrid(X, Y, resolution=100)) summary(subsetPointsByGrid(X, Y, resolution=200)) summary(subsetPointsByGrid(X, Y, resolution=1000)) ```

csoneson/iSEE documentation built on Dec. 13, 2018, 4:12 p.m.