extract_subpopulations: Extract subpopulations.

View source: R/extract_subpopulations.R

extract_subpopulationsR Documentation

Extract subpopulations.

Description

extract_subpopulations identifies clusters in the reference and population sets and reports the frequency of points in each cluster for the two sets.

Usage

extract_subpopulations(population, reference, variables, k)

Arguments

population

tbl with grouping (metadata) and observation variables.

reference

tbl with grouping (metadata) and observation variables. Columns of population and reference should be identical.

variables

character vector specifying observation variables.

k

scalar specifying number of clusters.

Value

list containing clusters centers (subpop_centers), two normalized histograms specifying frequency of each clusters in population and reference (subpop_profiles), and cluster prediction and distance to the predicted cluster for all input data (population_clusters and reference_clusters).

Examples

data <- tibble::tibble(
  Metadata_group = c(
    "control", "control", "control", "control",
    "experiment", "experiment", "experiment", "experiment"
  ),
  AreaShape_Area = c(10, 12, NA, 16, 8, 8, 7, 7),
  AreaShape_Length = c(2, 3, NA, NA, 4, 5, 1, 5)
)
variables <- c("AreaShape_Area", "AreaShape_Length")
population <- dplyr::filter(data, Metadata_group == "experiment")
reference <- dplyr::filter(data, Metadata_group == "control")
extract_subpopulations(
  population = population,
  reference = reference,
  variables = variables,
  k = 3
)

cytomining/cytominer documentation built on July 5, 2023, 3:34 a.m.