Quick start example analysis

This example analysis will use the abr1 data set from the metaboData package. It is nominal mass flow-injection mass spectrometry (FI-MS) fingerprinting data from a plant-pathogen infection time course experiment. The analysis will also include use of the pipe %>% from the magrittr package. First load the necessary packages.

library(pretreateR)
library(metaboData)

For this example we will use only the negative acquisition mode data (abr1$neg) and sample meta-information (abr1$fact). Create an AnalysisData class object using the following:

d <- analysisData(abr1$neg,abr1$fact)

The data includes 120 samples and 2000 mass spectral features as shown below.

d
#> 
#> AnalysisData object containing:
#> 
#> Samples: 120 
#> Features: 2000 
#> Info: 9

The clsAvailable() function can be used to identify the columns available in our meta-information table.

clsAvailable(d)
#> [1] "injorder" "pathcdf"  "filecdf"  "name.org" "remark"   "name"     "rep"     
#> [8] "day"      "class"

For this analysis, we will be using the infection time course class information contained in the day column. This can be extracted and the class frequencies tabulated using the following:

d %>%
  clsExtract(cls = 'day') %>%
  table()
#> .
#>  1  2  3  4  5  H 
#> 20 20 20 20 20 20

As can be seen above, the experiment is made up of six infection time point classes that includes a healthy control class (H) and five day infection time points (1-5), each with 20 replicates.

For data pre-treatment prior to statistical analysis, a two-thirds maximum class occupancy filter can be applied. Features where the maximum proportion of non-missing data per class is above two-thirds are retained. A total ion count normalisation will also be applied.

d <- d %>%
  occupancyMaximum(cls = 'day', occupancy = 2/3) %>%
  transformTICnorm() %>% 
  transformLog10()
d
#> 
#> AnalysisData object containing:
#> 
#> Samples: 120 
#> Features: 1760 
#> Info: 9

This has reduced the data set to 1760 relevant features.

PCA can help inspect the structure of the pre-treated data and identify unusual samples.

plotPCA(d,cls = 'day',xAxis = 'PC1',yAxis = 'PC2')

Individual features can also be inspected after pre-treatment.

plotFeature(d,feature = 'N341',cls = 'day')

For a reusable routine, define the steps and pass them to metabolyse().

p <- analysisParameters()
parameters(p,'pre-treatment') <- preTreatmentParameters(
  list(occupancyFilter = 'maximum', transform = 'TICnorm')
)
changeParameter(p,'cls') <- 'day'
analysis <- metabolyse(abr1$neg,abr1$fact,p,verbose = FALSE)
preTreated(analysis)
#> 
#> AnalysisData object containing:
#> 
#> Samples: 120 
#> Features: 1760 
#> Info: 9