-
Notifications
You must be signed in to change notification settings - Fork 7
/
work_with_mass_dataset.Rmd
executable file
·148 lines (114 loc) · 3.23 KB
/
work_with_mass_dataset.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
title: "metid support mass_dataaset class object"
author:
- name: Xiaotao Shen PhD (https://www.shen-lab.org/)
date: "Created on 2020-03-28 and updated on `r Sys.Date()`"
output:
html_document:
df_print: paged
toc: no
pdf_document:
toc: no
vignette: >
%\VignetteIndexEntry{metid_mass_dataset}
%\VignettePackage{metid}
% \VignetteEngine{knitr::rmarkdown}
% \usepackage[utf8]{inputenc}
%\VignetteEncoding{UTF-8}
---
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
***
# **Data preparation**
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
library(massdataset)
library(tidyverse)
library(metid)
ms1_data =
readr::read_csv(file.path(
system.file("ms1_peak", package = "metid"),
"ms1.peak.table.csv"
))
ms1_data = data.frame(ms1_data, sample1 = 1, sample2 = 2)
expression_data = ms1_data %>%
dplyr::select(-c(name:rt))
variable_info =
ms1_data %>%
dplyr::select(name:rt) %>%
dplyr::rename(variable_id = name)
sample_info =
data.frame(
sample_id = colnames(expression_data),
injection.order = c(1, 2),
class = c("Subject", "Subject"),
group = c("Subject", "Subject")
)
rownames(expression_data) = variable_info$variable_id
object = create_mass_dataset(
expression_data = expression_data,
sample_info = sample_info,
variable_info = variable_info
)
object
```
# **Add MS2 to `mass_dataset` object**
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
path = "./example"
dir.create(path)
ms2_data <- system.file("ms2_data", package = "metid")
file.copy(
from = file.path(ms2_data, "QC1_MSMS_NCE25.mgf"),
to = path,
overwrite = TRUE,
recursive = TRUE
)
object =
massdataset::mutate_ms2(
object = object,
column = "rp",
polarity = "positive",
ms1.ms2.match.mz.tol = 10,
ms1.ms2.match.rt.tol = 30
)
object
object@ms2_data
```
# **Identify metabolites according to MS1**
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
data("snyder_database_rplc0.0.3", package = "metid")
data_base <- snyder_database_rplc0.0.3
data_base@spectra.data <- list()
data_base@spectra.info$RT <- NA
object1 =
annotate_metabolites_mass_dataset(object = object,
database = data_base)
```
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
object1
```
# **Identify metabolites according to MS2**
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
data("snyder_database_rplc0.0.3", package = "metid")
object2 =
annotate_metabolites_mass_dataset(object = object1,
database = snyder_database_rplc0.0.3)
head(object2@annotation_table)
head(extract_variable_info(object = object2))
```
# **Identify metabolites according another database**
```{r,eval = TRUE,warning=FALSE, message=FALSE,R.options="",cache=TRUE}
data("orbitrap_database0.0.3", package = "metid")
object3 =
annotate_metabolites_mass_dataset(object = object2,
database = orbitrap_database0.0.3)
head(extract_variable_info(object = object3))
```
# **Session information**
```{r,eval=TRUE,warning=FALSE, R.options="", message=FALSE, cache=TRUE}
sessionInfo()
```