thinPoints: Thin Data Points

View source: R/thinpoints.R

thinPointsR Documentation

Thin Data Points

Description

Reduce the number of cluttered data points.

Usage

thinPoints(dat, value, n = 3000, nbins = 200, groupBy = NULL)

Arguments

dat

a data frame

value

column name of dat to be used for partitioning (see details)

n

number of points to sample for each partition

nbins

number of partitions

groupBy

column name of dat to group by before partitioning (e.g. chromosome)

Details

The result of Genome Wide Association Study can be very large, with the majority of points being being clustered below significance threshold. This unnecessarily increases the time to plot while making almost no difference. This function reduces the number of points by partitioning the points by a numberic column value into nbins and sampling n points.

Value

a data.frame

Examples

dat <- data.frame(
   A1 = c(1:20, 20, 20),
   A2 = c(rep(1, 12), rep(1,5), rep(20, 3), 20, 20) ,
   B = rep(c("a", "b", "c", "d"), times = c(5, 7, 8, 2))
)
# partition "A1" into 2 bins and then sample 6 data points
thinPoints(dat, value = "A1", n = 6, nbins = 2)
# partition "A2" into 2 bins and then sample 6 data points
thinPoints(dat, value = "A2", n = 6, nbins = 2)
# group by "B", partition "A2" into 2 bins and then sample 3 data points
thinPoints(dat, value = "A2", n = 3, nbins = 2, groupBy = "B")


leejs-abv/ggmanh documentation built on March 25, 2024, 11:17 a.m.