trim_population {beadplexr}R Documentation

Trim cluster.

Description

Remove the points furthest form the center of the cluster.

Usage

trim_population(
  df,
  .parameter,
  .column_name = "population",
  .trim = 0.1,
  .data = NULL
)

Arguments

df

The tidy data.frame with clusters to be modified.

.parameter

A character giving the name of dimensions to calculate distance on.

.column_name

A character giving the name of the column with the cluster information.

.trim

A numeric between 0 and 1, giving the fraction of points to remove.

.data

Deprecated. Use df.

Details

The euclidean distance is calculated for each point defined by .parameter to the center of the cluster. The cluster designation of the .trim most distant points are changed to NA.

Value

A data.frame

Examples

library(beadplexr)
library(dplyr)
library(ggplot2)

data("lplex")

lplex[[1]] %>%
  filter(`FSC-A` > 3.2e5L) %>%
  mutate(population = "1") %>%
  trim_population(.parameter = c("FSC-A", "SSC-A"), .column_name = "population", .trim = 0.1) %>%
  ggplot() +
  aes(x = `FSC-A`, y = `SSC-A`, colour = population) +
  geom_point()

lplex[[1]] %>%
  filter(`FSC-A` > 3.2e5L) %>%
  mutate(population = as.character(1)) %>%
  trim_population(.parameter = c("FSC-A", "SSC-A"),
                  .column_name = "population", .trim = 0.8) %>%
  ggplot() +
  aes(x = `FSC-A`, y = `SSC-A`, colour = population) +
  geom_point()

[Package beadplexr version 0.4.0 Index]