mutate_variable_zero_number: Mutate Variable Zero Number in mass_dataset Object

View source: R/mutate_variable_zero.R

mutate_variable_zero_numberR Documentation

Mutate Variable Zero Number in mass_dataset Object

Description

This function adds a new column to the variable_info slot of a mass_dataset object, which contains the number of zeros for each variable according to the samples specified.

Usage

mutate_variable_zero_number(object, according_to_samples = "all")

Arguments

object

A mass_dataset object.

according_to_samples

A character vector specifying the sample IDs to consider when counting zeros. Default is "all", which considers all samples.

Value

A modified mass_dataset object with an updated variable_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 number according to all the samples
object2 =
  mutate_variable_zero_number(object = object)

colnames(extract_variable_info(object))
colnames(extract_variable_info(object2))
object2@variable_info_note

##calculate NA number according to only QC samples
object3 <-
  mutate_variable_zero_number(object = object2,
                according_to_samples =
              get_sample_id(object)[extract_sample_info(object)$class == "QC"])

object3

colnames(extract_variable_info(object3))
object3@variable_info_note

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