split_mass_dataset: Split and Update mass_dataset Object Based on Criteria

View source: R/split-mass_dataset.R

split_mass_datasetR Documentation

Split and Update mass_dataset Object Based on Criteria

Description

This function splits a mass_dataset object into multiple subsets based on a specified column in either sample_info or variable_info. It also updates the process_info slot with the splitting parameters.

Usage

split_mass_dataset(object, by, fun)

Arguments

object

A mass_dataset object to be split.

by

The column name in sample_info or variable_info used for splitting.

fun

A function to apply when by is numeric. This function should return a logical vector.

Value

A list of subsetted mass_dataset objects.

Author(s)

Xiaotao Shen shenxt1990@outlook.com

Examples

data("expression_data")
data("sample_info")
data("variable_info")

object =
  create_mass_dataset(
    expression_data = expression_data,
    sample_info = sample_info,
    variable_info = variable_info,
  )

object <-
activate_mass_dataset(object, what = "sample_info")

new_object <-
  split_mass_dataset(object = object, by = "group")

new_object %>% lapply(dim)
new_object %>% lapply(colnames)

object <-
  activate_mass_dataset(object, what = "variable_info")

new_object <-
  split_mass_dataset(object = object, by = "rt", fun = function(rt) rt > 600)

new_object %>% lapply(dim)
plot(extract_variable_info(new_object[[1]])$rt)
plot(extract_variable_info(new_object[[2]])$rt)

tidymass/massdataset documentation built on Sept. 14, 2024, 4:41 p.m.