despeckle {beadplexr}R Documentation

Despeckle parameters

Description

Remove lonely, noisy data points in a 2D scatter matrix

Usage

despeckle(df, .parameters, .bins = 256L, .neighbours = 4L, .data = NULL, ...)

Arguments

df

A tidy data.frame

.parameters

A character of the length of two giving the parameters to despeckle.

.bins

A numeric giving the resolution of the raster matrix.

.neighbours

A numeric giving the minimum number of neighbors. Points with fewer neighbors are removed.

.data

Deprecated. Use df.

...

Additional parameters passed to raster::clump()

Details

The values of the two parameters are binned into the given number of bins. They are then cast into a 2D matrix, with the bins of the first of the parameters ending up as rows, the bins of the second parameter as columns, and combinations are marked by 1.

This matrix is turned into a RasterLayer by raster::raster() and the number of neighbors are calculated by raster::clump().

The rows of the df where lonely points are found in .parameters are removed.

Value

A data.frame with noisy points removed.

Note

This function requires that the igraph package is available.

Examples

library(beadplexr)
library(magrittr)
library(ggplot2)

data("lplex")

lplex[[1]] %>%
  ggplot() +
  aes(x = `FL6-H`, y = `FL2-H`) +
  geom_point()

lplex[[1]] %>%
  despeckle(.parameters = c("FL6-H", "FL2-H"), .neighbours = 8) %>%
  ggplot() +
  aes(x = `FL6-H`, y = `FL2-H`) +
  geom_point()

lplex[[1]] %>%
  despeckle(.parameters = c("FL6-H", "FL2-H"), .bin = 128, direction = 4) %>%
  ggplot() +
  aes(x = `FL6-H`, y = `FL2-H`) +
  geom_point()


[Package beadplexr version 0.4.0 Index]