metid包来源于MetDNA中用于二级谱图匹配的算法,并进行了优化,又新加了能够用于in-house代谢物库构建的功能。
1. metid包的安装
metid是tidymass包一部分。包的作者是斯坦福大学博士后申小涛。
由于从gitbub多次安装失败,所以请教了申小涛博士,以下是他给我的命令。
source("https://www.tidymass.org/tidymass-packages/install_tidymass.txt")
library(tidyverse)
install_tidymass(from = "tidymass.org",which_package = "metid")
最后一行命令运行失败的话,再次运行。
remotes::install_gitlab("tidymass/metid", dependencies = TRUE)
2. 构建公共MS2数据库
massbank_database <- construct_mona_database(
file = "MassBank_NIST.msp",
path = ".",
version = "0.0.1",
source = "MoNA",
link = "https://mona.fiehnlab.ucdavis.edu/",
creater = "Xiaotao Shen",
email = "shenxt1990@163.com",
rt = FALSE,
threads = 5
)
结果报错
Reading msp data from MoNA...
Progress: ──────────────────────────────────────────────────────────────── 100%Done.
Error in `dplyr::select()`:
! Can't subset columns that don't exist.
✖ Column `Name` doesn't exist.
Run `rlang::last_error()` to see where the error occurred.
3. 代谢物鉴定
将xcms包导出的一级质谱信息和对应的二级质谱,以及要检索的数据库放到同一个文件夹下。
3.1 导入数据库
library(metid)
library(tidyverse)
#print(data(package='metid'))
load("hmdb_database0.0.3.rda")
3.2 代谢物鉴定
annotate_result3 <-
identify_metabolites(ms1.data = "feature2.csv",
ms2.data = "merged.mgf",
ms2.match.tol = 0.5,
ce = "all",
ms1.match.ppm = 15,
rt.match.tol = 30,
polarity = "positive",
column = "rp",
candidate.num = 3,
database = hmdb_database0.0.3,
threads = 3)
annotate_result3
which_has_identification(annotate_result3) %>% head()
which_has_identification(annotate_result3) %>% nrow()
ms2.plot1 <- ms2plot(object = annotate_result3,
database = hmdb_database0.0.3,
which.peak = "CP00243")
ms2.plot1
保存结果
ms2plot(
object = annotate_result3,
database = hmdb_database0.0.3,
which.peak = "all",
#path = file.path(path, "inhouse"),
threads = 3
)
参考资料:
Install metid • metid (tidymass.github.io)
Database provided for metid
• metid (tidymass.github.io)