Introduction

lipidr implements a series of functions to facilitate inspection, analysis and visualization of targeted lipidomics datasets. lipidr takes exported Skyline CSV as input, allowing for multiple methods to be analyzed together.

Input

lipidr represents Skyline files as SummarizedExperiment objects, which can easily be integrated with a wide variety of Bioconductor packages. Sample annotations, such as sample group or other clinical information can be loaded.

Quality control & visualization

lipidr generates various plots, such as PCA score plots and box plots, for quality control of samples and measured lipids. Normalization methods with and without internal standards are also supported.

Differential Analysis

Differential analysis can be performed using any of the loaded clinical variables, which can be readily visualized as volcano plots. A novel lipid set enrichment analysis (LSEA) is implemented to detect preferential enrichment of certain lipid classes, chain lengths or saturation patterns. Plots for the visualization of enrichment results are also implemented.

This vignette provides a step by step guide for downstream analysis of targeted lipidomics data, exported from Skyline.

Installation

From Bioconductor

In R console, type:

if (!requireNamespace("BiocManager", quietly=TRUE))
    install.packages("BiocManager")
BiocManager::install("lipidr")  

From GitHub using devtools

In R console, type:

library(devtools)   
install_github("ahmohamed/lipidr")

Analysis Workflow

Example Study

In this workflow, we will use serum lipidomics data from mice fed a normal or high-fat diet. Mice were fed a normal or high-fat diet (Diet column) and had access to normal drinking water or drinking water containing the bile acid deoxycholic acid (BileAcid column). Lipid peaks were integrated using Skyline and exported as CSV files.

Data Import & manipulation

Exporting files from Skyline

Integrated peaks should be exported from each Skyline file through File => Export => Report. Selecting Transition Results ensures that necessary information is exported from Skyline. Otherwise, you should ensure that peak Area or Height or a similar measure is exported. Regardless of the measure you choose for intensity, you can use lipidr workflow.

Replicates should either be exported, or the Pivot Replicate Name option must be used.

Reading files into R

lipidr can read multiple CSV files from different analysis methods together. Using our example dataset, three Skyline CSV files are used as input to read.skyline.

datadir = system.file("extdata", package="lipidr")
filelist = list.files(datadir, "data.csv", full.names = TRUE) # all csv files

d = read_skyline(filelist)
print(d)
## class: LipidomicsExperiment 
## dim: 279 58 
## metadata(2): summarized dimnames
## assays(3): Retention Time Area Background
## rownames(279): 1 2 ... 278 279
## rowData names(26): filename Molecule ... total_cs Class
## colnames(58): S1A S2A ... TQC_11 TQC_12
## colData names(0):

Datasets are represented in R as SummarizedExperiments to facilitate integration other Bioconductor packages.

Adding sample annotation

Sample annotation can be prepared in Excel and saved as CSV. The table should have at least two columns, first indicating sample names and other columns indicating clinical variables.

clinical_file = system.file("extdata", "clin.csv", package="lipidr")

d = add_sample_annotation(d, clinical_file)
colData(d)
## DataFrame with 58 rows and 3 columns
##                   group        Diet    BileAcid
##             <character> <character> <character>
## S1A    NormalDiet_water      Normal       water
## S2A    NormalDiet_water      Normal       water
## S3A    NormalDiet_water      Normal       water
## S4A    NormalDiet_water      Normal       water
## S5A    NormalDiet_water      Normal       water
## ...                 ...         ...         ...
## TQC_8                QC          QC          QC
## TQC_9                QC          QC          QC
## TQC_10               QC          QC          QC
## TQC_11               QC          QC          QC
## TQC_12               QC          QC          QC

Data subsetting

It is helpful to imagine LipidomicsExperiment object as a table with lipid molecules as rows and samples as columns. We can subset this table by selecting specific rows and columns. The general syntax is d[rows, cols].

In the example below we select the first 10 transitions and 10 samples. We can check the rowData and colData.

d_subset = d[1:10, 1:10]
rowData(d_subset)
## DataFrame with 10 rows and 26 columns
##       filename    Molecule Precursor.Mz Precursor.Charge Product.Mz
##    <character> <character>    <numeric>        <integer>  <numeric>
## 1  A1_data.csv     PE 32:0        692.5                1      551.5
## 2  A1_data.csv     PE 32:1        690.5                1      549.5
## 3  A1_data.csv     PE 32:2        688.5                1      547.5
## 4  A1_data.csv     PE 34:1        718.5                1      577.5
## 5  A1_data.csv PE 34:1 NEG        716.5                1        196
## 6  A1_data.csv     PE 34:2        716.5                1      575.5
## 7  A1_data.csv     PE 34:3        714.5                1      573.5
## 8  A1_data.csv     PE 36:0        748.6                1      607.6
## 9  A1_data.csv     PE 36:1        746.6                1      605.6
## 10 A1_data.csv PE 36:1 NEG        744.6                1        196
##    Product.Charge clean_name     ambig not_matched      istd  class_stub
##         <integer>   <factor> <logical>   <logical> <logical> <character>
## 1               1    PE 32:0     FALSE       FALSE     FALSE          PE
## 2               1    PE 32:1     FALSE       FALSE     FALSE          PE
## 3               1    PE 32:2     FALSE       FALSE     FALSE          PE
## 4               1    PE 34:1     FALSE       FALSE     FALSE          PE
## 5               1    PE 34:1     FALSE       FALSE     FALSE          PE
## 6               1    PE 34:2     FALSE       FALSE     FALSE          PE
## 7               1    PE 34:3     FALSE       FALSE     FALSE          PE
## 8               1    PE 36:0     FALSE       FALSE     FALSE          PE
## 9               1    PE 36:1     FALSE       FALSE     FALSE          PE
## 10              1    PE 36:1     FALSE       FALSE     FALSE          PE
##         chain1       l_1       s_1      chain2       l_2       s_2
##    <character> <integer> <integer> <character> <integer> <integer>
## 1         32:0        32         0                    NA        NA
## 2         32:1        32         1                    NA        NA
## 3         32:2        32         2                    NA        NA
## 4         34:1        34         1                    NA        NA
## 5         34:1        34         1                    NA        NA
## 6         34:2        34         2                    NA        NA
## 7         34:3        34         3                    NA        NA
## 8         36:0        36         0                    NA        NA
## 9         36:1        36         1                    NA        NA
## 10        36:1        36         1                    NA        NA
##         chain3       l_3       s_3      chain4       l_4       s_4
##    <character> <logical> <logical> <character> <logical> <logical>
## 1                     NA        NA                    NA        NA
## 2                     NA        NA                    NA        NA
## 3                     NA        NA                    NA        NA
## 4                     NA        NA                    NA        NA
## 5                     NA        NA                    NA        NA
## 6                     NA        NA                    NA        NA
## 7                     NA        NA                    NA        NA
## 8                     NA        NA                    NA        NA
## 9                     NA        NA                    NA        NA
## 10                    NA        NA                    NA        NA
##     total_cl  total_cs       Class
##    <integer> <integer> <character>
## 1         32         0          PE
## 2         32         1          PE
## 3         32         2          PE
## 4         34         1          PE
## 5         34         1          PE
## 6         34         2          PE
## 7         34         3          PE
## 8         36         0          PE
## 9         36         1          PE
## 10        36         1          PE
colData(d)
## DataFrame with 58 rows and 3 columns
##                   group        Diet    BileAcid
##             <character> <character> <character>
## S1A    NormalDiet_water      Normal       water
## S2A    NormalDiet_water      Normal       water
## S3A    NormalDiet_water      Normal       water
## S4A    NormalDiet_water      Normal       water
## S5A    NormalDiet_water      Normal       water
## ...                 ...         ...         ...
## TQC_8                QC          QC          QC
## TQC_9                QC          QC          QC
## TQC_10               QC          QC          QC
## TQC_11               QC          QC          QC
## TQC_12               QC          QC          QC

We can also apply conditional selections (indexing). For example, we can select all quality control samples.

d_qc = d[, d$group == "QC"]
rowData(d_qc)
## DataFrame with 279 rows and 26 columns
##        filename         Molecule Precursor.Mz Precursor.Charge Product.Mz
##     <character>      <character>    <numeric>        <integer>  <numeric>
## 1   A1_data.csv          PE 32:0        692.5                1      551.5
## 2   A1_data.csv          PE 32:1        690.5                1      549.5
## 3   A1_data.csv          PE 32:2        688.5                1      547.5
## 4   A1_data.csv          PE 34:1        718.5                1      577.5
## 5   A1_data.csv      PE 34:1 NEG        716.5                1        196
## ...         ...              ...          ...              ...        ...
## 275 F2_data.csv       PC(P-40:3)        824.6                1      184.1
## 276 F2_data.csv       PC(P-40:4)        822.6                1      184.1
## 277 F2_data.csv       PC(P-40:5)        820.6                1      184.1
## 278 F2_data.csv       PC(P-40:6)        818.6                1      184.1
## 279 F2_data.csv 15:0-18:1(d7) PC      753.615                1     184.07
##     Product.Charge       clean_name     ambig not_matched      istd
##          <integer>         <factor> <logical>   <logical> <logical>
## 1                1          PE 32:0     FALSE       FALSE     FALSE
## 2                1          PE 32:1     FALSE       FALSE     FALSE
## 3                1          PE 32:2     FALSE       FALSE     FALSE
## 4                1          PE 34:1     FALSE       FALSE     FALSE
## 5                1          PE 34:1     FALSE       FALSE     FALSE
## ...            ...              ...       ...         ...       ...
## 275              1         PCP-40:3     FALSE       FALSE     FALSE
## 276              1         PCP-40:4     FALSE       FALSE     FALSE
## 277              1         PCP-40:5     FALSE       FALSE     FALSE
## 278              1         PCP-40:6     FALSE       FALSE     FALSE
## 279              1 PC 15:0-18:1(d7)     FALSE       FALSE      TRUE
##      class_stub      chain1       l_1       s_1      chain2       l_2
##     <character> <character> <integer> <integer> <character> <integer>
## 1            PE        32:0        32         0                    NA
## 2            PE        32:1        32         1                    NA
## 3            PE        32:2        32         2                    NA
## 4            PE        34:1        34         1                    NA
## 5            PE        34:1        34         1                    NA
## ...         ...         ...       ...       ...         ...       ...
## 275         PCP        40:3        40         3                    NA
## 276         PCP        40:4        40         4                    NA
## 277         PCP        40:5        40         5                    NA
## 278         PCP        40:6        40         6                    NA
## 279          PC        15:0        15         0        18:1        18
##           s_2      chain3       l_3       s_3      chain4       l_4
##     <integer> <character> <logical> <logical> <character> <logical>
## 1          NA                    NA        NA                    NA
## 2          NA                    NA        NA                    NA
## 3          NA                    NA        NA                    NA
## 4          NA                    NA        NA                    NA
## 5          NA                    NA        NA                    NA
## ...       ...         ...       ...       ...         ...       ...
## 275        NA                    NA        NA                    NA
## 276        NA                    NA        NA                    NA
## 277        NA                    NA        NA                    NA
## 278        NA                    NA        NA                    NA
## 279         1                    NA        NA                    NA
##           s_4  total_cl  total_cs       Class
##     <logical> <integer> <integer> <character>
## 1          NA        32         0          PE
## 2          NA        32         1          PE
## 3          NA        32         2          PE
## 4          NA        34         1          PE
## 5          NA        34         1          PE
## ...       ...       ...       ...         ...
## 275        NA        40         3          PC
## 276        NA        40         4          PC
## 277        NA        40         5          PC
## 278        NA        40         6          PC
## 279        NA        33         1          PC
colData(d_qc)
## DataFrame with 12 rows and 3 columns
##              group        Diet    BileAcid
##        <character> <character> <character>
## TQC_1           QC          QC          QC
## TQC_2           QC          QC          QC
## TQC_3           QC          QC          QC
## TQC_4           QC          QC          QC
## TQC_5           QC          QC          QC
## ...            ...         ...         ...
## TQC_8           QC          QC          QC
## TQC_9           QC          QC          QC
## TQC_10          QC          QC          QC
## TQC_11          QC          QC          QC
## TQC_12          QC          QC          QC

Note that we leave rows index empty (d[,cols]) to select all lipids. We can also subset based on lipid annotations, selecting a specific class for example.

pc_lipids = rowData(d)$Class %in% c("PC", "PCO", "PCP")
d_pc = d[pc_lipids,]
rowData(d_pc)
## DataFrame with 82 rows and 26 columns
##        filename         Molecule Precursor.Mz Precursor.Charge Product.Mz
##     <character>      <character>    <numeric>        <integer>  <numeric>
## 160 F1_data.csv          PC 30:0        706.5                1      184.1
## 161 F1_data.csv          PC 30:1        704.5                1      184.1
## 162 F1_data.csv          PC 30:2        702.5                1      184.1
## 163 F1_data.csv          PC 32:0        734.6                1      184.1
## 164 F1_data.csv          PC 32:1        732.6                1      184.1
## ...         ...              ...          ...              ...        ...
## 275 F2_data.csv       PC(P-40:3)        824.6                1      184.1
## 276 F2_data.csv       PC(P-40:4)        822.6                1      184.1
## 277 F2_data.csv       PC(P-40:5)        820.6                1      184.1
## 278 F2_data.csv       PC(P-40:6)        818.6                1      184.1
## 279 F2_data.csv 15:0-18:1(d7) PC      753.615                1     184.07
##     Product.Charge       clean_name     ambig not_matched      istd
##          <integer>         <factor> <logical>   <logical> <logical>
## 160              1          PC 30:0     FALSE       FALSE     FALSE
## 161              1          PC 30:1     FALSE       FALSE     FALSE
## 162              1          PC 30:2     FALSE       FALSE     FALSE
## 163              1          PC 32:0     FALSE       FALSE     FALSE
## 164              1          PC 32:1     FALSE       FALSE     FALSE
## ...            ...              ...       ...         ...       ...
## 275              1         PCP-40:3     FALSE       FALSE     FALSE
## 276              1         PCP-40:4     FALSE       FALSE     FALSE
## 277              1         PCP-40:5     FALSE       FALSE     FALSE
## 278              1         PCP-40:6     FALSE       FALSE     FALSE
## 279              1 PC 15:0-18:1(d7)     FALSE       FALSE      TRUE
##      class_stub      chain1       l_1       s_1      chain2       l_2
##     <character> <character> <integer> <integer> <character> <integer>
## 160          PC        30:0        30         0                    NA
## 161          PC        30:1        30         1                    NA
## 162          PC        30:2        30         2                    NA
## 163          PC        32:0        32         0                    NA
## 164          PC        32:1        32         1                    NA
## ...         ...         ...       ...       ...         ...       ...
## 275         PCP        40:3        40         3                    NA
## 276         PCP        40:4        40         4                    NA
## 277         PCP        40:5        40         5                    NA
## 278         PCP        40:6        40         6                    NA
## 279          PC        15:0        15         0        18:1        18
##           s_2      chain3       l_3       s_3      chain4       l_4
##     <integer> <character> <logical> <logical> <character> <logical>
## 160        NA                    NA        NA                    NA
## 161        NA                    NA        NA                    NA
## 162        NA                    NA        NA                    NA
## 163        NA                    NA        NA                    NA
## 164        NA                    NA        NA                    NA
## ...       ...         ...       ...       ...         ...       ...
## 275        NA                    NA        NA                    NA
## 276        NA                    NA        NA                    NA
## 277        NA                    NA        NA                    NA
## 278        NA                    NA        NA                    NA
## 279         1                    NA        NA                    NA
##           s_4  total_cl  total_cs       Class
##     <logical> <integer> <integer> <character>
## 160        NA        30         0          PC
## 161        NA        30         1          PC
## 162        NA        30         2          PC
## 163        NA        32         0          PC
## 164        NA        32         1          PC
## ...       ...       ...       ...         ...
## 275        NA        40         3          PC
## 276        NA        40         4          PC
## 277        NA        40         5          PC
## 278        NA        40         6          PC
## 279        NA        33         1          PC
colData(d_pc)
## DataFrame with 58 rows and 3 columns
##                   group        Diet    BileAcid
##             <character> <character> <character>
## S1A    NormalDiet_water      Normal       water
## S2A    NormalDiet_water      Normal       water
## S3A    NormalDiet_water      Normal       water
## S4A    NormalDiet_water      Normal       water
## S5A    NormalDiet_water      Normal       water
## ...                 ...         ...         ...
## TQC_8                QC          QC          QC
## TQC_9                QC          QC          QC
## TQC_10               QC          QC          QC
## TQC_11               QC          QC          QC
## TQC_12               QC          QC          QC

For demonstration purposes, we select only 3 lipids classes, Ceramides (Cer), PhosphatidylCholines (PC) and LysoPhosphatidylCholines (LPC). We also BileAcid treated group from our dataset.

lipid_classes = rowData(d)$Class %in% c("Cer", "PC", "LPC")
groups = d$BileAcid != "DCA"
d = d[lipid_classes, groups]

#QC sample subset
d_qc = d[, d$group == "QC"]

Raw Data Quality Check

To ensure data quality, we can look at total lipid intensity as bar chart or distribution of samples as a boxplot.

plot_samples(d, type = "tic", log = TRUE)

We can also look at intensity and retention time distributions for each lipid molecule using plot_molecules(type = boxplot). It is recommended to assess the variation across quality control samples.

plot_molecules(d_qc, "sd", measure = "Retention Time", log = FALSE)