Learn R Programming

beadplexr (version 0.5.0)

identify_analyte: Identify analyte

Description

Identify analyte

Usage

identify_analyte(
  df,
  .parameter,
  .analyte_id,
  .column_name = "analyte",
  .k = length(.analyte_id),
  .trim = 0,
  .desc = FALSE,
  .method = c("clara", "kmeans", "dbscan", "mclust", "density_cut"),
  .data = NULL,
  ...
)

Value

A data.frame with analyte IDs in a separate column

Arguments

df

A tidy data.frame.

.parameter

A character giving the name of column(s) where populations are identified.

.analyte_id

A character vector giving the ID of the analyte. The order is important and must match the expected order of analytes.

.column_name

A character giving the name of the column to store the population information.

.k

Numeric giving the number of expected clusters, or a set of initial cluster centers.

.trim

A numeric between 0 and 1, giving the fraction of points to remove by marking them NA.

.desc

A boolean to indicate if the centers of the analytes should be arranged in a descending fashion before assigning the names.

.method

A character giving the clustering method to use.

.data

Deprecated. Use df.

...

Additional arguments passed to appropriate methods, see below.

Additional parameters

Information on additional arguments passed, can be found here:

clara

cluster::clara()

kmeans

kmeans()

dbscan

fpc::dbscan()

mclust

mclust::Mclust()

density_cut

approx_adjust()

Details

This function is a wrapper around the process of:

  • Finding analyte clusters

  • Trimming the clusters by removing the cluster members most distant from the cluster center

  • Sorting the analyte clusters based on their centers

  • Giving each analyte cluster a useful name

See Also

cluster_events()

Examples

Run this code
if (FALSE) {
library(beadplexr)
library(ggplot2)

data("lplex")

df <- lplex[[1]]
df |>
  identify_analyte(.parameter = c("FSC-A", "SSC-A"),
                      .analyte_id = c("A", "B"),
                      .column_name = "analyte",
                      .method = "clara", .trim = 0.02) |>
  ggplot() +
  aes(x = `FSC-A`, y = `SSC-A`, colour = analyte) +
  geom_point()

df |>
  identify_analyte(.parameter = c("FSC-A", "SSC-A"),
                      .analyte_id = c("A", "B"),
                      .column_name = "analyte",
                      .method = "clara", .desc = TRUE) |>
  ggplot() +
  aes(x = `FSC-A`, y = `SSC-A`, colour = analyte) +
  geom_point()

df |>
  identify_analyte(.parameter = c("FSC-A", "SSC-A"),
                      .analyte_id = c("A", "B"),
                      .column_name = "analyte",
                      .method = "dbscan") |>
  ggplot() +
  aes(x = `FSC-A`, y = `SSC-A`, colour = analyte) +
  geom_point()
}

Run the code above in your browser using DataLab