Installation and help
MetCleaning is published in github (link). So you can install it according to github.
code 1: Installation of MetCleaning
##pcaMethods and impute should be installed form bioconductor
##pcaMethos
source("http://bioconductor.org/biocLite.R")
biocLite("pcaMethods")
##impute
source("http://bioconductor.org/biocLite.R")
biocLite("impute")
if(!require(devtools)) {
install.packages("devtools")
}
library(devtools)
install_github("jaspershen/MetCleaning")
library(MetCleaning)
help(package = "MetCleaning")
Data cleaning
Data cleaning is integrated as a function named as MetPre in MetCleaning. We use the demo data as the example. Copy the code below and paste in you R console.
code 2: Demo data of MetPre
##demo data
data(data, package = "MetCleaning")
data(sample.information, package = "MetCleaning")
##demo work directory
dir.create("Demo for MetCleaning")
setwd("Demo for MetCleaning")
path <- file.path(getwd(), "peak identification")
dir.create(path)
##write files
write.csv(data, "data.csv", row.names = FALSE)
write.csv(sample.information , "sample.information.csv", row.names = FALSE)
The demo data have been added in your work directory and organized in you work directory as Figure 2 shows. It contains two files, “data.csv” and “sample.information.csv”.
1. “data.csv” is the metabolomic dataset you want to process. Rows are features and columns are feature abundance of samples and tags of features. The information of features must contain “name” (feature name), “mz” (mass to change ratio) and “rt” (retention time). Other information of features are optional, for example “isotopes” and “adducts”. The name of sample can contain “.”, but cannot contain “-” and space. And the start of sample name cannot be number. For example, “A210.a” and “A210a” are valid, and “210a” or “210-a” are invalid.
Then you can run MetPre function to do data cleaning of data. All the arguments of MetPre can be found in the other functions in MetCleaning. You can use help(package = “MetCleaning”) to see the help page of MetCleaning.
code 3: Running of MetPre
##demo data
MetPre(polarity = "positive")
Running results of MetPre
Statistical analysis
Data statistical is integrated as a function named as MetStat in MetCleaning. We use the demo data as the example. Please note that now MetStat can only process two class data. Copy the code below and paste in you R console.
code 4: Demo data of MetStat
data("met.data.after.pre, package = "MetCleaning")
data(new.group, package = "MetCleaning")
##create a folder for MetStat demo
dir.create("Demo for MetStat")
setwd("Demo for MetStat")
## export the demo data as csv
write.csv(new.group, "new.group.csv", row.names = FALSE)
Running results of MetStat
2.Number of component selection in PLS-DA analysis. In PLS-DA analysis, you should manually select the best choice of the number of component. When the Console show “How many comps do you want to see?”, you can type 10 and enter “Enter” key. Then a MSE plot is showing, and the best number of component is the one has the smallest CV values. So type the number (in this example is 4) and enter “Enter” key.