-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMetaboMzML.R
More file actions
131 lines (115 loc) · 3.68 KB
/
MetaboMzML.R
File metadata and controls
131 lines (115 loc) · 3.68 KB
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
# Author: Benben Miao
# Email: [email protected]
# Rversion: 4.2.0
# Date: 2022-11-30
Sys.setlocale("LC_ALL", "en_US.UTF-8")
options(warn = -1)
# -> 0. Install and Library
# getOption("repos")
# options(repos = c(CRAN = "https://cran.rstudio.com"))
# options(repos = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
# options(BioC_mirror = "https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
# install.packages(c("ggplot2", "ggsci"))
# BiocManager::install(c("impute", "pcaMethods", "globaltest",
# "GlobalAncova", "Rgraphviz", "preprocessCore",
# "genefilter", "sva", "limma",
# "KEGGgraph", "siggenes", "BiocParallel",
# "MSnbase", "multtest", "RBGL",
# "edgeR", "fgsea", "devtools", "crmn"), force = TRUE)
# remotes::install_github("xia-lab/MetaboAnalystR", build = TRUE,
# build_vignettes = F, build_manual = F)
library("MetaboAnalystR")
# remotes::install_github("xia-lab/OptiLCMS", build = TRUE,
# build_vignettes = FALSE, build_manual = FALSE)
# library(R.utils)
# <- 0. Install and Library
# -> 1. File Read
# qcPath <- "./data/Q2G2S8mzML/QCs/"
# samplePath <- "./data/Q2G2S8mzML/Samples/"
# sampleGroup <- "./data/Q2G2S8mzML/sample-group.txt"
#
# tempPath <- "./temp/"
#
# # for (item in list.files(qcPath)) {
# # gunzip(filename = paste(qcPath, item, sep = ""),
# # ext = "gz", FUN = gzfile,
# # destname = paste("./temp/QCs/", substr(item, 1, nchar(item)-3), sep = ""), overwrite = TRUE)
# # }
#
# dir.create(paste(tempPath, "QCs/", sep = ""))
# tempQCsPath <- paste(tempPath, "QCs/", sep = "")
# for (item in list.files(qcPath)) {
# unzip(zipfile = paste(qcPath, item, sep = ""), files = NULL, list = FALSE,
# overwrite = TRUE, junkpaths = FALSE, exdir = tempQCsPath,
# unzip = "internal", setTimes = FALSE)
# }
#
# dir.create(paste(tempPath, "Samples/", sep = ""))
# tempSamplesPath <- paste(tempPath, "Samples/", sep = "")
# for (item in list.files(samplePath)) {
# unzip(zipfile = paste(samplePath, item, sep = ""), files = NULL, list = FALSE,
# overwrite = TRUE, junkpaths = FALSE, exdir = tempSamplesPath,
# unzip = "internal", setTimes = FALSE)
# }
#
# file.copy(sampleGroup, tempPath)
mzMLzipPath <- "./data/Q2G2S8mzML/QCs/QC_PREFA02.zip"
# TextArea:
file_name <- substr(strsplit(mzMLzipPath, split = "/")[[1]][length(strsplit(mzMLzipPath, split = "/")[[1]])],
1, nchar(strsplit(mzMLzipPath, split = "/")[[1]][length(strsplit(mzMLzipPath, split = "/")[[1]])]) - 4)
tempPath <- "./temp/"
filePath <- paste(tempPath, file_name, ".mzML", sep = "")
unzip(zipfile = mzMLzipPath, files = NULL, list = FALSE,
overwrite = TRUE, junkpaths = FALSE, exdir = tempPath,
unzip = "internal", setTimes = FALSE)
# <- 1. File Read
# -> 2. Data Operation
# set.seed(123)
# wdata = data.frame(
# sex = factor(rep(c("F", "M"), each=200)),
# weight = c(rnorm(200, 55), rnorm(200, 58)))
# <- 2. Data Operation
# -> 3. Plot Parameters
# fonts <- "Times"
# # ChoiceBox: "Times", "Palatino", "Bookman", "Courier", "Helvetica", "URWGothic", "NimbusMon", "NimbusSan"
dimPlot <- "2D"
# ChoiceBox: "3D", "2D"
resMZ <- "100"
# TextArea:
# <- 3. Plot Parameters
# # -> 4. Plot
plot <- function(){
p <- PerformDataInspect(filePath,
dimension = dimPlot,
res = as.numeric(resMZ))
}
# # <- 4. Plot
# -> 5. Save parameters
pdf_name <- "results.pdf"
jpeg_name <- "results.jpeg"
width <- 10.00
height <- 6.18
units <- "in"
# font <- fonts
# <- 5. Save parameters
# -> 6. PDF
pdf(file = pdf_name,
width = width,
height = height
# family = font
)
plot()
dev.off()
# <- 6. PDF
# -> 7. JPEG
jpeg(filename = jpeg_name,
width = width,
height = height,
units = units,
res = 300,
quality = 100
# family = font
)
plot()
dev.off()
# <- 7. JPEG