mutate_sample_zero_freq: Mutate Sample Zero Frequency in mass_dataset Object

View source: R/mutate_sample_zero.R

mutate_sample_zero_freqR Documentation

Mutate Sample Zero Frequency in mass_dataset Object

Description

This function adds a new column to the sample_info slot of a mass_dataset object, which contains the frequency of zero values for each sample according to the variables specified.

Usage

mutate_sample_zero_freq(object, according_to_variables = "all")

Arguments

object

A mass_dataset object.

according_to_variables

A character vector specifying the variable IDs to consider when calculating the frequency of zero values. Default is "all", which considers all variables.

Value

A modified mass_dataset object with an updated sample_info slot.

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

##calculate NA frequency according to all the variables
object2 =
  mutate_sample_zero_freq(object = object)

head(extract_sample_info(object))
head(extract_sample_info(object2))

##calculate NA frequency according to only variables with mz > 100
variable_id =
object2 %>%
  activate_mass_dataset(what = "variable_info") %>%
  filter(mz > 100) %>%
  pull(variable_id)

object3 =
  mutate_sample_zero_freq(object = object2,
                according_to_variables = variable_id)

object3

head(extract_sample_info(object3))

tidymass/massdataset documentation built on Jan. 30, 2024, 2:55 p.m.