This function updates the slots of a mass_dataset object to ensure consistency among sample_info, variable_info, and expression_data. It also logs the update process.

update_mass_dataset(object)

Arguments

object

A mass_dataset object that you want to update.

Value

A mass_dataset object with updated slots and process information.

Author

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
#> -------------------- 
#> massdataset version: 1.0.33 
#> -------------------- 
#> 1.expression_data:[ 1000 x 8 data.frame]
#> 2.sample_info:[ 8 x 4 data.frame]
#> 8 samples:Blank_3 Blank_4 QC_1 ... PS4P3 PS4P4
#> 3.variable_info:[ 1000 x 3 data.frame]
#> 1000 variables:M136T55_2_POS M79T35_POS M307T548_POS ... M232T937_POS M301T277_POS
#> 4.sample_info_note:[ 4 x 2 data.frame]
#> 5.variable_info_note:[ 3 x 2 data.frame]
#> 6.ms2_data:[ 0 variables x 0 MS2 spectra]
#> -------------------- 
#> Processing information
#> 1 processings in total
#> create_mass_dataset ---------- 
#>       Package         Function.used                Time
#> 1 massdataset create_mass_dataset() 2024-09-06 08:50:01

####only remain QC samples
sample_info = extract_sample_info(object = object)

sample_info =
  dplyr::filter(sample_info, class == "QC")

object@sample_info = sample_info

object = update_mass_dataset(object = object)
object
#> -------------------- 
#> massdataset version: 1.0.33 
#> -------------------- 
#> 1.expression_data:[ 1000 x 2 data.frame]
#> 2.sample_info:[ 2 x 4 data.frame]
#> 2 samples:QC_1 QC_2
#> 3.variable_info:[ 1000 x 3 data.frame]
#> 1000 variables:M136T55_2_POS M79T35_POS M307T548_POS ... M232T937_POS M301T277_POS
#> 4.sample_info_note:[ 4 x 2 data.frame]
#> 5.variable_info_note:[ 3 x 2 data.frame]
#> 6.ms2_data:[ 0 variables x 0 MS2 spectra]
#> -------------------- 
#> Processing information
#> 2 processings in total
#> create_mass_dataset ---------- 
#>       Package         Function.used                Time
#> 1 massdataset create_mass_dataset() 2024-09-06 08:50:01
#> update_mass_dataset ---------- 
#>       Package         Function.used                Time
#> 1 massdataset update_mass_dataset() 2024-09-06 08:50:01

####only remain feature with mz < 300
variable_info = extract_variable_info(object = object)

variable_info =
  dplyr::filter(variable_info, mz < 300)

object@variable_info = variable_info

object = update_mass_dataset(object = object)
object
#> -------------------- 
#> massdataset version: 1.0.33 
#> -------------------- 
#> 1.expression_data:[ 740 x 2 data.frame]
#> 2.sample_info:[ 2 x 4 data.frame]
#> 2 samples:QC_1 QC_2
#> 3.variable_info:[ 740 x 3 data.frame]
#> 740 variables:M136T55_2_POS M79T35_POS M183T224_POS ... M236T543_POS M232T937_POS
#> 4.sample_info_note:[ 4 x 2 data.frame]
#> 5.variable_info_note:[ 3 x 2 data.frame]
#> 6.ms2_data:[ 0 variables x 0 MS2 spectra]
#> -------------------- 
#> Processing information
#> 2 processings in total
#> create_mass_dataset ---------- 
#>       Package         Function.used                Time
#> 1 massdataset create_mass_dataset() 2024-09-06 08:50:01
#> update_mass_dataset ---------- 
#>       Package         Function.used                       Time
#> 1 massdataset update_mass_dataset() 2024-09-06 08:50:01.979211
#> 2 massdataset update_mass_dataset() 2024-09-06 08:50:01.982263