stratify | R Documentation |
stratify
stratifies operations.
stratify(population, sample, reducer, strata, ...)
population |
tbl with grouping (metadata) and observation variables. |
sample |
tbl with the same structure as |
reducer |
operation that is to applied in a stratified manner. |
strata |
optional character vector specifying grouping variables for stratification. |
... |
arguments passed to operation. |
population
with potentially extra columns.
suppressMessages(suppressWarnings(library(magrittr)))
population <- tibble::tibble(
Metadata_group = sample(c("a", "b"), 100, replace = TRUE),
Metadata_type = sample(c("control", "trt"), 100, replace = TRUE),
AreaShape_Area = c(rnorm(98), 20, 30),
AreaShape_Eccentricity = rnorm(100)
)
variables <- c("AreaShape_Area", "AreaShape_Eccentricity")
strata <- c("Metadata_group")
sample <- population %>% dplyr::filter(Metadata_type == "control")
population_marked <-
cytominer::stratify(
reducer = cytominer::mark_outlier_rows,
method = "svd+iqr",
population = population,
variables = variables,
sample = sample,
strata = strata
)
population_marked %>%
dplyr::group_by(is_outlier) %>%
dplyr::sample_n(3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.