Learn R Programming

dispersionIndicators (version 0.1.5)

convex_analysis_of_variables: Analyze a set of variables using convex hulls.

Description

Analyze a set of variables using convex hulls.

Usage

convex_analysis_of_variables(
  data,
  variable_columns,
  batch_col = "batch",
  sample_order_col = "order",
  impute_if_needed = c("median", "mean"),
  mode = c("global", "batchwise")
)

Value

A list containing the following elements:

  • data: List of data frames for each variable.

  • indicators: Data frame with convex hull indicators for each variable.

  • convex_hulls: List of data frames of convex hulls for each varaible.

Arguments

data

Data frame containing the data of multiple variable on multiple ordered and potentially batched sample.

variable_columns

Character vector of variable column names to analyse.

batch_col

Name of the column containing batch information.

sample_order_col

Name of the column containing the sample time order.

impute_if_needed

Method for imputing missing values, either "mean" or "median".

mode

Analysis mode, either "global" or "batchwise"

Examples

Run this code
# Example usage on toy metabolomics data:
data <- data.frame(
  batch = rep(c("A","B","C"), each = 10),
  injectionOrder = rep(1:30, times = 1),
  metabolite1 = rnorm(30, mean = 100, sd = 10),
  metabolite2 = rnorm(30, mean = 200, sd = 20)
)
result <- convex_analysis_of_variables(
  data = data,
  variable_columns = c("metabolite1", "metabolite2"),
  batch_col = "batch",
  sample_order_col = "injectionOrder",
  impute_if_needed = "median",
  mode = "global"
)
plot_all_convex_hulls(
  target_file_path = file.path(tempdir(), "convex_hulls.pdf"),
  convex_analysis_res = result,
  show_points = TRUE,
  mode = "global"
)

Run the code above in your browser using DataLab