filter_categorize: Categorize continuous variables

View source: R/filter_categorize.R

filter_categorizeR Documentation

Categorize continuous variables

Description

Categorize continuous variables

Usage

filter_categorize(
  sam_table,
  sample_condition,
  new_label,
  nbins = NULL,
  bin_breaks = c(),
  bin_labels = c()
)

Arguments

sam_table

A sample x condition dataframe

sample_condition

Continuous variable to categorize

new_label

Column name for categorized variable

nbins

Auto select ranges for n bins/categories

bin_breaks

Manually select ranges for bins/categories

bin_labels

Manually label bins/categories

Value

A list with an updated sample table and before/after plots

Examples

library(SummarizedExperiment)
data_dir <- system.file("extdata/MAE.rds", package = "animalcules")
toy_data <- readRDS(data_dir)
microbe <- MultiAssayExperiment::experiments(toy_data)[[1]]
samples <- as.data.frame(colData(microbe))
result <- filter_categorize(samples,
  sample_condition = "AGE",
  new_label = "AGE_GROUP",
  bin_breaks = c(0, 55, 75, 100),
  bin_labels = c("Young", "Adult", "Elderly")
)
result$sam_table
result$plot.unbinned
result$plot.binned


compbiomed/animalcules documentation built on Feb. 7, 2024, 12:13 p.m.