split_mass_dataset: split_mass_dataset

View source: R/split-mass_dataset.R

split_mass_datasetR Documentation

split_mass_dataset

Description

Split one mass_dataset into several mass_dataset objects.

Usage

split_mass_dataset(object, by, fun)

Arguments

object

(required) A mass_dataset class object.

by

column name of sample_info or variable_info

fun

function used to split by. For example, mz, should set it as > 100.

Value

A list of mass_dataset.

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 Oct. 17, 2022, 7:25 a.m.