knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = TRUE, out.width = "100%" )
The massdataset
class object can be used to store the untargeted metabolomics data.
Let's first prepare the data objects according to the attached figure for each file.
sample_info
(required)The columns sample_id
(sample ID), injection.order
(injection order of samples), class
(Blank, QC, Subject, etc), group
(case, control, etc) are required.
![](../man/figures/Screen Shot 2021-12-27 at 2.56.52 PM.png)
variable_info
(required)The columns variable_id
(variable ID), mz
(mass to charge ratio), rt
(retention time, unit is second) are required.
![](../man/figures/Screen Shot 2021-12-27 at 3.00.14 PM.png)
expression_data
(required)Columns are samples are rows are features (variables).
The column names of expression_data should be completely same with sample_id in
sample_info
, and the row names of expression_data should be completely same with variable_id invariable_info
.
![](../man/figures/Screen Shot 2021-12-27 at 3.02.18 PM.png)
sample_info_note
(optional)This is the metadata for sample_info
.
![](../man/figures/Screen Shot 2021-12-27 at 3.09.42 PM.png)
variable_info_note
(optional)This is the metadata for variable_info
.
![](../man/figures/Screen Shot 2021-12-27 at 3.09.42 PM.png)
Here we use the demo data from masssprocesser
package. The demo data can be downloaded here.
Download this data and uncompress it. And then set the path where you put the folder as working directory.
Then prepare data.
library(tidyverse) peak_table_pos = readr::read_csv("feature_table/Peak_table_pos.csv") peak_table_neg = readr::read_csv("feature_table/Peak_table_neg.csv") sample_info_pos = readr::read_csv("feature_table/sample_info_pos.csv") sample_info_neg = readr::read_csv("feature_table/sample_info_neg.csv")
Variable information and expression data are in the peak table. Let's separate them.
expression_data_pos = peak_table_pos %>% dplyr::select(-c(variable_id:rt)) %>% as.data.frame() variable_info_pos = peak_table_pos %>% dplyr::select(variable_id:rt) %>% as.data.frame() rownames(expression_data_pos) = variable_info_pos$variable_id expression_data_neg = peak_table_neg %>% dplyr::select(-c(variable_id:rt)) %>% as.data.frame() variable_info_neg = peak_table_neg %>% dplyr::select(variable_id:rt) %>% as.data.frame() rownames(expression_data_neg) = variable_info_neg$variable_id colnames(expression_data_pos) == sample_info_pos$sample_id colnames(expression_data_neg) == sample_info_neg$sample_id
The orders of sample_id
in sample_info
and column names of expression_data
are different.
expression_data_pos = expression_data_pos[,sample_info_pos$sample_id] expression_data_neg = expression_data_neg[,sample_info_neg$sample_id] colnames(expression_data_pos) == sample_info_pos$sample_id colnames(expression_data_neg) == sample_info_neg$sample_id
mass_data
class objectThen we can create mass_data
class object using create_mass_dataset()
function.
library(massdataset) object_pos = create_mass_dataset( expression_data = expression_data_pos, sample_info = sample_info_pos, variable_info = variable_info_pos ) object_pos
Then negative mode.
object_neg = create_mass_dataset( expression_data = expression_data_neg, sample_info = sample_info_neg, variable_info = variable_info_neg ) object_neg
Then save them for next analysis.
save(object_pos, file = "feature_table/object_pos") save(object_neg, file = "feature_table/object_neg")
mass_dataset
class object to csv for xlsxexport_mass_dataset(object = object_pos, file_type = "xlsx", path = "demo_data_pos")
Then all the data will be in the demo_data_pos
folder.
![](../man/figures/Screen Shot 2021-12-27 at 3.33.20 PM.png)
mass_dataset
classWe can also directory convert feature table from mzMine to mass_dataset
class.
An example feature table from mzMine.
data("mzmine_table") library(kableExtra) library(magrittr) kbl(mzmine_table) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), fixed_thead = TRUE) %>% scroll_box(width = "100%", height = "600px")
data("mzmine_table") object = convet_mzmine2mass_dataset(x = mzmine_table) object
mass_dataset
classWe can also directory convert feature table from MS-DIAL to mass_dataset
class.
An example feature table from MS-DIAL.
data("msdial_table") library(kableExtra) library(magrittr) kbl(msdial_table) %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), fixed_thead = TRUE) %>% scroll_box(width = "100%", height = "600px")
data("msdial_table") object = convert_msdial2mass_dataset(x = msdial_table) object
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.