Skip to contents

This function adds new columns to the variable_info of a microbiome_dataset. It calculates various statistics like mean, median, sum of intensities, and proportions of NA and zero values, based on the provided samples.

Usage

mutate2variable(
  object,
  what = c("mean_intensity", "median_intensity", "sum_intensity", "na_number", "na_prop",
    "zero_number", "zero_prop"),
  according_to_samples = "all",
  ...
)

# S3 method for class 'microbiome_dataset'
mutate2variable(
  object,
  what = c("mean_intensity", "median_intensity", "sum_intensity", "na_number", "na_prop",
    "zero_number", "zero_prop"),
  according_to_samples = "all",
  ...
)

Arguments

object

A microbiome_dataset object on which the mutation will be performed.

what

A character vector specifying the statistics to be calculated and added. Options include "mean_intensity", "median_intensity", "sum_intensity", "na_number", "na_prop", "zero_number", "zero_prop". Default is all options.

according_to_samples

A character vector specifying the samples to be used for calculations. Default is "all", which uses all samples. If only specific samples are needed, provide their names as a vector.

...

Additional arguments passed to other methods.

Value

Returns the modified microbiome_dataset object with additional columns in variable_info.

Examples

data("global_patterns", package = "microbiomedataset")

x <- mutate2variable(global_patterns, what = "sum_intensity")
head(x@variable_info)
#>        variable_id Kingdom        Phylum        Class        Order
#> 549322      549322 Archaea Crenarchaeota Thermoprotei         <NA>
#> 522457      522457 Archaea Crenarchaeota Thermoprotei         <NA>
#> 951            951 Archaea Crenarchaeota Thermoprotei Sulfolobales
#> 244423      244423 Archaea Crenarchaeota        Sd-NA         <NA>
#> 586076      586076 Archaea Crenarchaeota        Sd-NA         <NA>
#> 246140      246140 Archaea Crenarchaeota        Sd-NA         <NA>
#>               Family      Genus                  Species sum_intensity
#> 549322          <NA>       <NA>                     <NA>           259
#> 522457          <NA>       <NA>                     <NA>             8
#> 951    Sulfolobaceae Sulfolobus Sulfolobusacidocaldarius             1
#> 244423          <NA>       <NA>                     <NA>            51
#> 586076          <NA>       <NA>                     <NA>             3
#> 246140          <NA>       <NA>                     <NA>             4