Skip to contents

Introduction

The metabolyseR package provides a suite of methods that encompass three elements of metabolomics data analysis:

  • data pre-treatment
  • modelling / data mining
  • correlation analyses

The package also distinguishes between the flexibility and simplicity required for exploratory analyses compared to the convenience needed for more complex routine analyses. This is reflected in the underlying S4 object-oriented implementations and associated methods defined within the package. It should be noted that it is useful to understand the principles involved in using metabolyseR for exploratory analyses to aid in extracting and wrangling the results generated from routine analyses.

The following document will provide an introduction to the basic usage of the package and includes how to create and use the base classes that are the foundation of metabolyseR. This will be focused around the applications for both exploratory and routine analyses. For more detailed information on the individual analysis elements see their associated vignette using:

browseVignettes('metabolyseR')

There is also an example quick start analysis vignette provided.

vignette('quick_start','metabolyseR')

Any issues, bugs or errors encountered while using the package should be reported here.

The examples shown here will use the abr1 data set from the metaboData package (?metaboData::abr1). This is a nominal mass flow-injection mass spectrometry (FI-MS) fingerprinting data set from a plant-pathogen infection time course experiment. The examples will also include use of the pipe %>% from the magrittr package.

Firstly load the necessary packages:

Parallel processing

The package supports parallel processing using the future package.

By default, processing by metabolyseR will be done sequentially. However, parallel processing can be activated, prior to analysis, by specifying a parallel back-end using plan(). The following example specifies using the multisession implementation (multiple background R sessions) with two worker processes.

plan(future::multisession,workers = 2)

See the future package documentation for more information on the types of parallel implementations that are available.

Exploratory analyses

For exploratory analyses, simple questions of the data need to be answered quickly, requiring few steps. Key requirements for any tool used by investigators are that it should be both simple and flexible.

In metabolyseR, the AnalysisData class is the base S4 class that provides these requirements. The following sections will give an overview of the basics in constructing and using these objects as the base for analysis.

Analysis data

We can firstly construct an AnalysisData object which requires two data tables. The first is the metabolomic data where the columns are the metabolome features, the rows the sample observations and contains the abundance values. The second is the sample meta-information where the row order should match to that of the metabolome data table. Using the example data, his can be constructed and assigned to the variable d by:

d <- analysisData(data = abr1$neg,
                  info = abr1$fact)

Where abr1$neg is the negative ionisation mode data and abr1$fact is the corresponding sample information. By printing d we can view some basic information about our data.

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

We can also return the numbers of samples and numbers of features respectively using the following:

## [1] 120
## [1] 2000

The data table can be extracted using the dat method:

dat(d)
## # A tibble: 120 × 2,000
##       N1    N2    N3    N4    N5    N6    N7    N8    N9   N10   N11   N12   N13
##    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1     0     0     0     0     0     0     0     0     0     0     0     0     0
##  2     0     0     0     0     0     0     0     0     0     0     0     0     0
##  3     0     0     0     0     0     0     0     0     0     0     0     0     0
##  4     0     0     0     0     0     0     0     0     0     0     0     0     0
##  5     0     0     0     0     0     0     0     0     0     0     0     0     0
##  6     0     0     0     0     0     0     0     0     0     0     0     0     0
##  7     0     0     0     0     0     0     0     0     0     0     0     0     0
##  8     0     0     0     0     0     0     0     0     0     0     0     0     0
##  9     0     0     0     0     0     0     0     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0     0     0     0     0
## # ℹ 110 more rows
## # ℹ 1,987 more variables: N14 <dbl>, N15 <dbl>, N16 <dbl>, N17 <dbl>,
## #   N18 <dbl>, N19 <dbl>, N20 <dbl>, N21 <dbl>, N22 <dbl>, N23 <dbl>,
## #   N24 <dbl>, N25 <dbl>, N26 <dbl>, N27 <dbl>, N28 <dbl>, N29 <dbl>,
## #   N30 <dbl>, N31 <dbl>, N32 <dbl>, N33 <dbl>, N34 <dbl>, N35 <dbl>,
## #   N36 <dbl>, N37 <dbl>, N38 <dbl>, N39 <dbl>, N40 <dbl>, N41 <dbl>,
## #   N42 <dbl>, N43 <dbl>, N44 <dbl>, N45 <dbl>, N46 <dbl>, N47 <dbl>, …

Or alternatively, can be used to assign a new data table:

dat(d) <- abr1$pos
d
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 2000 
## Info: 9

The sample information table can be extracted using the sinfo method:

## # A tibble: 120 × 9
##    injorder pathcdf              filecdf name.org remark name    rep day   class
##       <int> <fct>                <fct>   <fct>    <fct>  <fct> <int> <fct> <int>
##  1        1 C:/Xcalibur/ANDI-LT… 01.cdf  12_2     ok     12_2      2 2         2
##  2        2 C:/Xcalibur/ANDI-LT… 02.cdf  13_3     ok     13_4      3 3         3
##  3        3 C:/Xcalibur/ANDI-LT… 03.cdf  15_4     ok     15_5      5 4         4
##  4        4 C:/Xcalibur/ANDI-LT… 04.cdf  12_1     ok     12_2      2 1         1
##  5        5 C:/Xcalibur/ANDI-LT… 05.cdf  12_2     ok     12_2      2 2         2
##  6        6 C:/Xcalibur/ANDI-LT… 06.cdf  11_1     ok     11_2      1 1         1
##  7        7 C:/Xcalibur/ANDI-LT… 07.cdf  14_2     ok     14_3      4 2         2
##  8        8 C:/Xcalibur/ANDI-LT… 08.cdf  11_4     ok     11_5      1 4         4
##  9        9 C:/Xcalibur/ANDI-LT… 09.cdf  13_H     ok     13_H      3 H         6
## 10       10 C:/Xcalibur/ANDI-LT… 10.cdf  15_H     ok     15_H      5 H         6
## # ℹ 110 more rows

And similarly used to assign a new sample information table:

sinfo(d) <- abr1$fact[,1:2]
d
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 2000 
## Info: 2

Sample information

There are a number of methods that provide utility for querying and altering the sample information within an AnalysisData object. These methods are all named with the prefix cls and include:

  • clsAdd
  • clsArrange
  • clsAvailable
  • clsExtract
  • clsRemove
  • clsRename
  • clsReplace

The names of the available sample information columns can be shown using clsAvailable().

## [1] "injorder" "pathcdf"  "filecdf"  "name.org" "remark"   "name"     "rep"     
## [8] "day"      "class"

A given column can be extracted using clsExtract(). Here, the day column is extracted.

clsExtract(d,cls = 'day')
##   [1] 2 3 4 1 2 1 2 4 H H 4 5 1 2 H 5 3 3 2 H 4 3 5 4 H H 3 H H 1 1 1 5 5 3 4 H
##  [38] 1 5 5 1 2 4 3 2 4 3 2 5 4 4 H 3 4 2 4 4 1 5 4 4 1 1 H 3 2 H 3 3 1 2 H H 2
##  [75] 3 5 3 2 5 2 4 3 H 2 3 2 1 1 4 5 3 2 1 H 5 2 4 H 1 4 4 1 1 5 H 5 1 3 3 5 5
## [112] 5 3 2 5 H 5 H 2 1
## Levels: 1 2 3 4 5 H

Sample class frequencies could then be computed.

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

It can be seen that there are 20 samples available in each class.

Another example is the addition of a new sample information column. In the following, a column called new_class will be added with all samples labelled 1.

d <- clsAdd(d,cls = 'new_class',value = rep(1,nSamples(d)))
clsAvailable(d)
##  [1] "injorder"  "pathcdf"   "filecdf"   "name.org"  "remark"    "name"     
##  [7] "rep"       "day"       "class"     "new_class"

Keeping / removing samples or features

Samples or features can easily be kept or removed from an AnalysisData object as is most convenient.

Below can be seen the first 6 sample indexes in the injorder column of the sample information.

samples <- d %>%
  clsExtract(cls = 'injorder') %>%
  head()

print(samples)
## [1] 1 2 3 4 5 6

Only these samples could be kept using:

d %>%
  keepSamples(idx = 'injorder',samples = samples)
## 
## AnalysisData object containing:
## 
## Samples: 6 
## Features: 2000 
## Info: 10

Or removed using:

d %>%
  removeSamples(idx = 'injorder',samples = samples)
## 
## AnalysisData object containing:
## 
## Samples: 114 
## Features: 2000 
## Info: 10

The process is very similar for keeping or removing specific metabolome features from the data table. Below can be seen the first 6 feature names in the data table.

feat <- d %>%
  features() %>%
  head()

print(feat)
## [1] "N1" "N2" "N3" "N4" "N5" "N6"

Only these features can be kept using:

d %>%
  keepFeatures(features = feat)
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 6 
## Info: 10

Or to remove these features:

d %>%
  removeFeatures(features = feat)
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 1994 
## Info: 10

Routine analyses

Routine analyses are those that are often made up of numerous steps where parameters have likely already been previously established. The emphasis here is on convenience with as little code as possible required. In these analyses, the necessary analysis elements, order and parameters are first prepared and then the analysis routine subsequently performed in a single step. This section will introduce how this type of analysis can be performed using metabolyseR and will include four main topics:

  • analysis parameter selection
  • performing an analysis
  • performing a re-analysis
  • extracting analysis results

Analysis parameters

Parameter selection is the fundamental aspect for performing routine analyses using metabolyseR and will be the step requiring the most input from the user. The parameters for an analysis are stored in an S4 object of class AnalysisParameters containing the relevant parameters of the selected analysis elements.

The parameters have been named so that they denote the same functionality commonly across all analysis element methods. Discussion of the specific parameters can be found withing the vignettes of the relevant analysis elements. These can be accessed using:

browseVignettes('metabolyseR')

There are several ways to specify the parameters to use for analysis. The first is programatically and the second is through the use of the YAML format.

Programatic specification

The available analysis elements can be shown using:

## [1] "pre-treatment" "modelling"     "correlations"

The analysisParameters() function can be used to create an AnalysisParameters object containing the default parameters. For example, the code below will return default parameters for all the metabolyseR analysis elements.

## Parameters:
## pre-treatment
##  QC
##      occupancyFilter
##          cls = class
##          QCidx = QC
##          occupancy = 2/3
##      impute
##          cls = class
##          QCidx = QC
##          occupancy = 2/3
##          parallel = variables
##          seed = 1234
##      RSDfilter
##          cls = class
##          QCidx = QC
##          RSDthresh = 50
##      removeQC
##          cls = class
##          QCidx = QC
##  occupancyFilter
##      maximum
##          cls = class
##          occupancy = 2/3
##  impute
##      class
##          cls = class
##          occupancy = 2/3
##          seed = 1234
##  transform
##      TICnorm
##          refactor = TRUE
## 
## modelling
##  randomForest
##      cls = class
##      rf = list()
##      reps = 1
##      binary = FALSE
##      comparisons = list()
##      perm = 0
##      returnModels = FALSE
##      seed = 1234
## 
## correlations
##  method = pearson
##  pAdjustMethod = bonferroni
##  corPvalue = 0.05
##  minCoef = 0
##  maxCor = Inf

To retrieve parameters for a subset of analysis elements the following can be run, returning parameters for only the pre-treatment and modelling elements.

p <- analysisParameters(c('pre-treatment','modelling'))
p
## Parameters:
## pre-treatment
##  QC
##      occupancyFilter
##          cls = class
##          QCidx = QC
##          occupancy = 2/3
##      impute
##          cls = class
##          QCidx = QC
##          occupancy = 2/3
##          parallel = variables
##          seed = 1234
##      RSDfilter
##          cls = class
##          QCidx = QC
##          RSDthresh = 50
##      removeQC
##          cls = class
##          QCidx = QC
##  occupancyFilter
##      maximum
##          cls = class
##          occupancy = 2/3
##  impute
##      class
##          cls = class
##          occupancy = 2/3
##          seed = 1234
##  transform
##      TICnorm
##          refactor = TRUE
## 
## modelling
##  randomForest
##      cls = class
##      rf = list()
##      reps = 1
##      binary = FALSE
##      comparisons = list()
##      perm = 0
##      returnModels = FALSE
##      seed = 1234

The changeParameter() function can be used to uniformly change these parameters across all of the selected methods. The example below changes the defaults of all the parameters named cls from the default class to day.

p <- analysisParameters()
changeParameter(p,'cls') <- 'day'
p
## Parameters:
## pre-treatment
##  QC
##      occupancyFilter
##          cls = day
##          QCidx = QC
##          occupancy = 2/3
##      impute
##          cls = day
##          QCidx = QC
##          occupancy = 2/3
##          parallel = variables
##          seed = 1234
##      RSDfilter
##          cls = day
##          QCidx = QC
##          RSDthresh = 50
##      removeQC
##          cls = day
##          QCidx = QC
##  occupancyFilter
##      maximum
##          cls = day
##          occupancy = 2/3
##  impute
##      class
##          cls = day
##          occupancy = 2/3
##          seed = 1234
##  transform
##      TICnorm
##          refactor = TRUE
## 
## modelling
##  randomForest
##      cls = day
##      rf = list()
##      reps = 1
##      binary = FALSE
##      comparisons = list()
##      perm = 0
##      returnModels = FALSE
##      seed = 1234
## 
## correlations
##  method = pearson
##  pAdjustMethod = bonferroni
##  corPvalue = 0.05
##  minCoef = 0
##  maxCor = Inf

Alternatively the parameters of a specific analysis elements can be targeted using the elements argument. The following will only alter the cls parameter back to class for the pre-treatment element parameters:

changeParameter(p,'cls',elements = 'pre-treatment') <- 'class'

Parameters can be extracted from the AnalysisParameters class using the parameters() function for a specified element.

parameters(p,'correlations')
## $method
## [1] "pearson"
## 
## $pAdjustMethod
## [1] "bonferroni"
## 
## $corPvalue
## [1] 0.05
## 
## $minCoef
## [1] 0
## 
## $maxCor
## [1] Inf

Each analysis element has a function for returning default parameters for specific methods. These include preTreatmentParameters(), modellingParameters() and correlationParameters(). Each returns a list of the default parameters for a specified methods as shown in the example for modellingParameters() below.

## $anova
## $anova$cls
## [1] "class"
## 
## $anova$pAdjust
## [1] "bonferroni"
## 
## $anova$comparisons
## list()
## 
## $anova$returnModels
## [1] FALSE

Refer to the documentation (?) of each function for sepecific usage details.

The parameters returned by these functions can be assigned to an AnalysisParameters object, again using parameters()

parameters(p,'pre-treatment') <- preTreatmentParameters(
  list(
    occupancyFilter = 'maximum',
    transform = 'TICnorm'
      )
  )

YAML specification

Due to the relatively complex structure of the parameters needed for analyses containing many components, it is also possible to specify analysis parameters using the YAML file format. YAML parameter files (.yaml) can be parsed using the parseParameters() function. The example below shows the YAML specification for the defaults returned by analysisParameters().

pre-treatment:
  QC:
    occupancyFilter:
      cls: class
      QCidx: QC
      occupancy: 0.6666667
    impute:
      cls: class
      QCidx: QC
      occupancy: 0.6666667
      parallel: variables
      seed: 1234.0
    RSDfilter:
      cls: class
      QCidx: QC
      RSDthresh: 50.0
    removeQC:
      cls: class
      QCidx: QC
  occupancyFilter:
    maximum:
      cls: class
      occupancy: 0.6666667
  impute:
    class:
      cls: class
      occupancy: 0.6666667
      seed: 1234.0
  transform:
    TICnorm: {}
modelling:
  randomForest:
    cls: class
    rf: []
    reps: 1.0
    binary: no
    comparisons: []
    perm: 0.0
    returnModels: no
    seed: 1234.0
correlations:
  method: pearson
  pAdjustMethod: bonferroni
  corPvalue: 0.05
  minCoef: 0.0
  maxCor: .inf

This can be passed directly into an AnalysisParameters object using the following:

paramFile <- system.file('defaultParameters.yaml',package = 'metabolyseR')
p <- parseParameters(paramFile)

For more complex pre-treatment situations such as the following:

pre-treatment:
  remove:
    sample:
      idx: fileOrder
      samples: 1
  remove1:
    class:
      cls: day
      classes:
      - H
      - 1
  occupancyFilter:
    maximum:
      cls: class
      occupancy: 0.667
  transform:
    TICnorm: ~

Where multiple steps of the same method needed (here is remove), these are numbered sequentially. Where multiple values also need to be provided to a particular argument (e.g. classes = c('H','1')), these should be supplied as a hyphenated list.

Existing AnalysisParameters objects can also be exported to YAML format as shown below:

p <- analysisParameters()
exportParameters(p,file = 'analysis_parameters.yaml')

Performing an analysis

The analysis is performed in a single step using the metabolyse() function. This accepts the metabolomic data, the sample information and the analysis parameters.

The metabolomic data table of abundance values where the columns are the metabolome features and the rows are each sample observation. Similarly, the sample meta-information table should consist of the observations as rows and the meta information as columns. The order of the observation rows of the sample information table should be concordant with the rows in the metabolomics data table.

We can run an example analysis using the abr1 data set by first generating the default parameters for pre-treatment and modelling (random forest) analysis elements.

p <- analysisParameters(c('pre-treatment','modelling'))

Custom pre-treatment parameters can then be specified to only inlude occupancy filtering and total ion count normalisation.

parameters(p,'pre-treatment') <- preTreatmentParameters(
  list(
  occupancyFilter = 'maximum',
  transform = 'TICnorm')
)

Next the cls parameters can be changed to use the day sample information column throughout the analysis.

changeParameter(p,'cls') <- 'day'

Finally, the analysis can be run in a single step. Here only the fist 200 features of the negative ionisation mode data are specified to reduce the analysis time needed for this example.

analysis <- metabolyse(abr1$neg[,1:200],abr1$fact,p) 
## 
## metabolyseR  v0.15.4 Tue Sep 12 15:15:25 2023
## ________________________________________________________________________________
## Parameters:
## pre-treatment
##  occupancyFilter
##      maximum
##          cls = day
##          occupancy = 2/3
##  transform
##      TICnorm
##          refactor = TRUE
## 
## modelling
##  randomForest
##      cls = day
##      rf = list()
##      reps = 1
##      binary = FALSE
##      comparisons = list()
##      perm = 0
##      returnModels = FALSE
##      seed = 1234
## ________________________________________________________________________________
## 
[34mPre-treatment 
[39m…


[34mPre-treatment 
[39m    
[32m✔
[39m [0.2S]
## 
[34mModelling 
[39m…

[34m
Modelling 
[39m 
[32m✔
[39m [2.3S]
## ________________________________________________________________________________
## 
## 
[32mComplete! 
[39m[2.5S]

Note: If a data pre-treatment step is not performed prior to modelling or correlation analysis, the raw data will automatically be used.

The analysis object containing the analysis results can be printed to provide some basic information about the results of the analysis.

print(analysis)
## 
## metabolyseR v0.15.4
## Analysis:
##     Tue Sep 12 15:15:25 2023
## 
##  Raw Data:
##      No. samples = 120
##      No. features = 200
## 
##  Pre-treated Data:
##      Tue Sep 12 15:15:25 2023
##      No. samples = 120
##      No. features = 48
## 
##  Modelling:
##      Tue Sep 12 15:15:28 2023
##      Methods: randomForest

Performing a re-analysis

There are likely to be occasions where an analysis will need to be re-analysed using a new set of parameters. This can be achieved using the reAnalyse() function.

In the example below we will run a correlation analysis in addition to the pre-treatment and modelling elements already performed.

Firstly, we can specify the correlation parameters:

parameters <- analysisParameters('correlations')

Then perform the re-analysis on our previously analysed Analysis object, specifying the additional parameters.

analysis <- reAnalyse(analysis,parameters)
## 
## metabolyseR v0.15.4 Tue Sep 12 15:15:28 2023
## ________________________________________________________________________________
## Parameters:
## correlations
##  method = pearson
##  pAdjustMethod = bonferroni
##  corPvalue = 0.05
##  minCoef = 0
##  maxCor = Inf
## ________________________________________________________________________________
## 
[34mCorrelations 
[39m…

[34m
Correlations 
[39m  
[32m✔
[39m [0.1S]
## ________________________________________________________________________________
## 
## Complete! [0.1S]

An overview of the results of the analysis (now including correlations) can then be printed.

print(analysis)
## 
## metabolyseR v0.15.4
## Analysis:
##     Tue Sep 12 15:15:25 2023
## 
##  Raw Data:
##      No. samples = 120
##      No. features = 200
## 
##  Pre-treated Data:
##      Tue Sep 12 15:15:25 2023
##      No. samples = 120
##      No. features = 48
## 
##  Modelling:
##      Tue Sep 12 15:15:28 2023
##      Methods: randomForest
## 
##  Correlations:
##      Tue Sep 12 15:15:28 2023
##      No. correlations = 140

Extracting analysis results

An analysis performed by metabolyse() returns an S4 object of class Analysis. There are a number of ways of extracting analysis results from this object.

Similarly to the AnalysisData class, the dat() and sinfo() functions can be used to extract the metabolomics data or sample information tables directly for either the raw or pre-treated data.

For example, to extract the pre-treated metabolomics data from our object analysis:

dat(analysis,type = 'pre-treated')
## # A tibble: 120 × 48
##     N113  N115  N117   N118  N119  N127  N128   N129  N130  N131   N132    N133
##    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>  <dbl>   <dbl>
##  1 10.3  0     0.269 0      2.57  51.7  0.424 0.448      0 0      0.561  51.5  
##  2 18.1  1.24  1.64  0      2.29  13.7  0     0.632      0 0      1.59  435.   
##  3 14.9  0.962 4.32  0.0996 8.93   0    0     0.168      0 1.04   1.74  238.   
##  4 12.8  0     0     0      0.259 13.6  0     0.648      0 0.204  0.827  12.9  
##  5 16.9  0     0     0      0     10.5  0     3.16       0 0      0      45.8  
##  6  7.28 0     0.397 0.521  0.850  3.31 0     0.316      0 0      1.23    1.88 
##  7 18.8  0     1.83  0      0.703  9.66 0     0.646      0 0     21.2    60.2  
##  8 12.6  3.77  2.29  0.244  6.76   4.64 0.445 0.0922     0 0      3.43  531.   
##  9  2.18 0.300 1.31  0.300  0     97.7  0.210 0.837      0 0      2.57  108.   
## 10 14.4  0.682 3.29  0      1.34   1.70 1.24  0          0 0      3.81    0.633
## # ℹ 110 more rows
## # ℹ 36 more variables: N134 <dbl>, N135 <dbl>, N136 <dbl>, N137 <dbl>,
## #   N139 <dbl>, N143 <dbl>, N145 <dbl>, N146 <dbl>, N147 <dbl>, N149 <dbl>,
## #   N153 <dbl>, N155 <dbl>, N157 <dbl>, N161 <dbl>, N163 <dbl>, N164 <dbl>,
## #   N165 <dbl>, N168 <dbl>, N169 <dbl>, N170 <dbl>, N171 <dbl>, N173 <dbl>,
## #   N174 <dbl>, N175 <dbl>, N179 <dbl>, N180 <dbl>, N181 <dbl>, N183 <dbl>,
## #   N187 <dbl>, N191 <dbl>, N192 <dbl>, N193 <dbl>, N195 <dbl>, N196 <dbl>, …

Or to extract the raw sample information:

sinfo(analysis,type = 'raw')
## # A tibble: 120 × 9
##    injorder pathcdf              filecdf name.org remark name    rep day   class
##       <int> <fct>                <fct>   <fct>    <fct>  <fct> <int> <fct> <int>
##  1        1 C:/Xcalibur/ANDI-LT… 01.cdf  12_2     ok     12_2      2 2         2
##  2        2 C:/Xcalibur/ANDI-LT… 02.cdf  13_3     ok     13_4      3 3         3
##  3        3 C:/Xcalibur/ANDI-LT… 03.cdf  15_4     ok     15_5      5 4         4
##  4        4 C:/Xcalibur/ANDI-LT… 04.cdf  12_1     ok     12_2      2 1         1
##  5        5 C:/Xcalibur/ANDI-LT… 05.cdf  12_2     ok     12_2      2 2         2
##  6        6 C:/Xcalibur/ANDI-LT… 06.cdf  11_1     ok     11_2      1 1         1
##  7        7 C:/Xcalibur/ANDI-LT… 07.cdf  14_2     ok     14_3      4 2         2
##  8        8 C:/Xcalibur/ANDI-LT… 08.cdf  11_4     ok     11_5      1 4         4
##  9        9 C:/Xcalibur/ANDI-LT… 09.cdf  13_H     ok     13_H      3 H         6
## 10       10 C:/Xcalibur/ANDI-LT… 10.cdf  15_H     ok     15_H      5 H         6
## # ℹ 110 more rows

Alternatively the raw or preTreated functions can be used to extract the AnalysisData class objects containing both the metabolomics data and sample information for the raw and pre-treated data respectively.

raw(analysis)
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 200 
## Info: 9
preTreated(analysis)
## 
## AnalysisData object containing:
## 
## Samples: 120 
## Features: 48 
## Info: 9

Lastly the analysisResults function can be used to extract the results of any of the analysis elements. The following will extract the modelling results:

analysisResults(analysis,element = 'modelling')
## $randomForest
## 
## Random forest classification 
## 
## Samples:  120 
## Features:     48 
## Response:     day 
## # comparisons:    1