1 Background

Duguet et al. 2017 compared the proteomes of mouse regulatory T cells (Treg) and conventional T cells (Tconv) in order to discover differentially regulated proteins between these two cell populations. For each biological repeat the proteomes were extracted for both Treg and Tconv cell pools, which were purified by flow cytometry. The data in data/quantification/mouseTcell on the pdaData repository are a subset of the data PXD004436 on PRIDE.

We first analyse a subset of the data that have a completely randomized design, i.e. 4 mice per group for the first group only regulatory T cells are assessed for the second group only conventional T cells are assessed.

2 Data

We first import the peptides.txt file. This is the file that contains your peptide-level intensities. For a MaxQuant search [6], this peptides.txt file can be found by default in the “path_to_raw_files/combined/txt/” folder from the MaxQuant output, with “path_to_raw_files” the folder where raw files were saved. In this tutorial, we will use a MaxQuant peptides file from MaxQuant that can be found in the data tree of the SGA2020 github repository https://github.com/statOmics/SGA2020/tree/data/quantification/mouseTcell .

To import the data we use the QFeatures package.

We generate the object peptideRawFile with the path to the peptideRaws.txt file. Using the grepEcols function, we find the columns that contain the expression data of the peptideRaws in the peptideRaws.txt file.

library(tidyverse)
library(limma)
library(QFeatures)
library(msqrob2)
library(plotly)

peptidesFile <- "https://raw.githubusercontent.com/statOmics/SGA2020/data/quantification/mouseTcell/peptidesCRD.txt"

ecols <- MSnbase::grepEcols(
  peptidesFile,
  "Intensity ",
  split = "\t")

pe <- readQFeatures(
  table = peptidesFile,
  fnames = 1,
  ecol = ecols,
  name = "peptideRaw", sep="\t")

pe
## An instance of class QFeatures containing 1 assays:
##  [1] peptideRaw: SummarizedExperiment with 55814 rows and 8 columns
pe[["peptideRaw"]]
## class: SummarizedExperiment 
## dim: 55814 8 
## metadata(0):
## assays(1): ''
## rownames(55814): AAAAAAAAAAGAAGGR AAAAAAAAAAGDSDSWDADTFSMEDPVRK ...
##   YYYDGDMICK YYYDKNIIHK
## rowData names(74): Sequence N.term.cleavage.window ...
##   Oxidation..M..site.IDs MS.MS.Count
## colnames(8): Intensity.Tconv.M11_R2_inj1 Intensity.Tconv.M12_1 ...
##   Intensity.Treg.M5_inj1 Intensity.Treg.M5_inj2
## colData names(0):

We will make use from data wrangling functionalities from the tidyverse package. The %>% operator allows us to pipe the output of one function to the next function.

colData(pe)$celltype <- substr(
  colnames(pe[["peptideRaw"]]),
  11,
  14) %>%
  unlist %>%  
  as.factor

We calculate how many non zero intensities we have per peptide and this will be useful for filtering.

rowData(pe[["peptideRaw"]])$nNonZero <- rowSums(assay(pe[["peptideRaw"]]) > 0)

Peptides with zero intensities are missing peptides and should be represent with a NA value rather than 0.

pe <- zeroIsNA(pe, "peptideRaw") # convert 0 to NA

2.1 Data exploration

We can inspect the missingness in our data with the plotNA() function provided with MSnbase. 41% of all peptide intensities are missing and for some peptides we do not even measure a signal in any sample. The missingness is similar across samples.

MSnbase::plotNA(assay(pe[["peptideRaw"]])) +
  xlab("Peptide index (ordered by data completeness)")

3 Preprocessing

This section preforms standard preprocessing for the peptide data. This include log transformation, filtering and summarisation of the data.

3.1 Log transform the data

pe <- logTransform(pe, base = 2, i = "peptideRaw", name = "peptideLog")
limma::plotDensities(assay(pe[["peptideLog"]]))

3.2 Filtering

3.2.1 Handling overlapping protein groups

In our approach a peptide can map to multiple proteins, as long as there is none of these proteins present in a smaller subgroup.

pe[["peptideLog"]] <-
 pe[["peptideLog"]][rowData(pe[["peptideLog"]])$Proteins
 %in% smallestUniqueGroups(rowData(pe[["peptideLog"]])$Proteins),]

3.2.2 Remove reverse sequences (decoys) and contaminants

We now remove the contaminants, peptides that map to decoy sequences, and proteins which were only identified by peptides with modifications.

pe[["peptideLog"]] <- pe[["peptideLog"]][rowData(pe[["peptideLog"]])$Reverse != "+", ]
pe[["peptideLog"]] <- pe[["peptideLog"]][rowData(pe[["peptideLog"]])$
Potential.contaminant != "+", ]

3.2.3 Remove peptides of proteins that were only identified with modified peptides

I will skip this step for the moment. Large protein groups file needed for this.

3.2.4 Drop peptides that were only identified in one sample

We keep peptides that were observed at last twice.

pe[["peptideLog"]] <- pe[["peptideLog"]][rowData(pe[["peptideLog"]])$nNonZero >= 2, ]
nrow(pe[["peptideLog"]])
## [1] 43401

We keep 43401 peptides after filtering.

3.3 Quantile normalize the data

pe <- normalize(pe, i = "peptideLog", method = "quantiles", name = "peptideNorm")

3.4 Explore quantile normalized data

After quantile normalisation the density curves for all samples coincide.

limma::plotDensities(assay(pe[["peptideNorm"]]))

This is more clearly seen is a boxplot.

boxplot(assay(pe[["peptideNorm"]]), col = palette()[-1],
       main = "Peptide distribtutions after normalisation", ylab = "intensity")

We can visualize our data using a Multi Dimensional Scaling plot, eg. as provided by the limma package.

limma::plotMDS(assay(pe[["peptideNorm"]]), col = as.numeric(colData(pe)$celltype))

The first axis in the plot is showing the leading log fold changes (differences on the log scale) between the samples.

3.5 Summarization to protein level

We use robust summarization in aggregateFeatures. This is the default workflow of aggregateFeatures so you do not have to specifiy the argument fun. However, because we compare methods we have included the fun argument to show the summarization method explicitely.

pe <- aggregateFeatures(pe,
 i = "peptideNorm",
 fcol = "Proteins",
 na.rm = TRUE,
 name = "proteinRobust",
 fun = MsCoreUtils::robustSummary)
## Your quantitative and row data contain missing values. Please read the
## relevant section(s) in the aggregateFeatures manual page regarding the
## effects of missing values on data aggregation.
plotMDS(assay(pe[["proteinRobust"]]), col = as.numeric(colData(pe)$celltype))

4 Data Analysis

4.1 Estimation

We model the protein level expression values using msqrob. By default msqrob2 estimates the model parameters using robust regression.

pe <- msqrob(object = pe, i = "proteinRobust", formula = ~celltype)

4.2 Inference

First, we extract the parameter names of the model.

getCoef(rowData(pe[["proteinRobust"]])$msqrobModels[[1]])
##  (Intercept) celltypeTreg 
##  21.08825654   0.08451369

Spike-in celltype a is the reference class. So the mean log2 expression for samples from celltype a is ‘(Intercept). The mean log2 expression for samples from celltype B is’(Intercept)+celltypeTreg’. Hence, the average log2 fold change between celltype b and celltype a is modelled using the parameter ‘celltypeTreg’. Thus, we assess the contrast ‘celltypeTreg=0’ with our statistical test.

L <- makeContrast("celltypeTreg=0", parameterNames = c("celltypeTreg"))
pe <- hypothesisTest(object = pe, i = "proteinRobust", contrast = L)

4.3 Plots

4.3.1 Volcano-plot

volcano <- ggplot(rowData(pe[["proteinRobust"]])$celltypeTreg,
                 aes(x = logFC, y = -log10(pval), color = adjPval < 0.05)) +
 geom_point(cex = 2.5) +
 scale_color_manual(values = alpha(c("black", "red"), 0.5)) + theme_minimal()
volcano

4.3.2 Heatmap

We first select the names of the proteins that were declared signficant.

sigNames <- rowData(pe[["proteinRobust"]])$celltypeTreg %>%
 rownames_to_column("proteinRobust") %>%
 filter(adjPval<0.05) %>%
 pull(proteinRobust)
heatmap(assay(pe[["proteinRobust"]])[sigNames, ])

There are 21 proteins significantly differentially expressed at the 5% FDR level.

rowData(pe[["proteinRobust"]])$celltypeTreg %>%
  filter(adjPval<0.05)
##            logFC        se       df          t         pval     adjPval
## O09131  2.893916 0.4129547 8.102188   7.007830 1.051117e-04 0.025163703
## P07356  2.131621 0.2489229 8.161783   8.563379 2.359680e-05 0.015160946
## P08207  2.196939 0.2704150 7.215957   8.124326 6.989332e-05 0.020726057
## P09055  1.494367 0.1542525 8.758950   9.687798 5.668430e-06 0.010925899
## P13020 -1.756084 0.2111367 8.758950  -8.317285 1.913640e-05 0.015160946
## P21550  2.165270 0.2729643 8.758950   7.932431 2.772549e-05 0.015268823
## P24452  2.573449 0.1883969 8.758950  13.659718 3.321573e-07 0.001280466
## P24472  3.743802 0.3641473 5.758950  10.281010 6.401761e-05 0.020565658
## P51807 -1.883514 0.2127218 8.578556  -8.854350 1.335847e-05 0.015160946
## P54071 -1.532303 0.2362293 8.622988  -6.486507 1.370863e-04 0.029359307
## Q00417 -1.481234 0.2124633 8.122204  -6.971718 1.077299e-04 0.025163703
## Q05186  1.848291 0.2591296 7.848988   7.132691 1.084596e-04 0.025163703
## Q60611 -1.711644 0.2775818 8.654619  -6.166271 1.947343e-04 0.035747650
## Q7TMB8  3.832110 0.2901988 5.471437  13.205121 2.336202e-05 0.015160946
## Q7TPR4 -1.581189 0.2193479 8.738485  -7.208587 5.862597e-05 0.020565658
## Q7TSJ2 -4.881439 0.4572180 5.650325 -10.676392 5.874158e-05 0.020565658
## Q80SU7  1.256627 0.1982723 8.455675   6.337884 1.764867e-04 0.034017817
## Q8BGW0 -1.931776 0.2764667 8.045951  -6.987370 1.109683e-04 0.025163703
## Q8K157  1.429718 0.2230018 8.642567   6.411239 1.477643e-04 0.029980597
## Q9CQ62  1.514052 0.2035701 8.480153   7.437496 5.417358e-05 0.020565658
## Q9DC16  2.213867 0.2868986 8.565419   7.716550 3.889659e-05 0.018743294

4.3.3 Detail plots

for (protName in sigNames)
{
pePlot <- pe[protName, , c("peptideNorm","proteinRobust")]
pePlotDf <- data.frame(longFormat(pePlot))
pePlotDf$assay <- factor(pePlotDf$assay,
                       levels = c("peptideNorm", "proteinRobust"))
pePlotDf$celltype <- as.factor(colData(pePlot)[pePlotDf$colname, "celltype"])

# plotting
p1 <- ggplot(data = pePlotDf,
      aes(x = colname, y = value, group = rowname)) +
   geom_line() + geom_point() +  theme_minimal() +
   facet_grid(~assay) + ggtitle(protName)
print(p1)

# plotting 2
p2 <- ggplot(pePlotDf, aes(x = colname, y = value, fill = celltype)) +
 geom_boxplot(outlier.shape = NA) + geom_point(position = position_jitter(width = .1),
                                               aes(shape = rowname)) +
 scale_shape_manual(values = 1:nrow(pePlotDf)) +
 labs(title = protName, x = "sample", y = "peptide intensity (log2)") + theme_minimal()
 facet_grid(~assay)
print(p2)
}

LS0tCnRpdGxlOiAiUHJvdGVvbWljcyBkYXRhIGFuYWx5c2lzOiBtb3VzZSBUY2VsbCBleGFtcGxlIHdpdGggQ1JEIGRlc2lnbiIKYXV0aG9yOiAiTGlldmVuIENsZW1lbnQiCmRhdGU6ICJzdGF0T21pY3MsIEdoZW50IFVuaXZlcnNpdHkgKGh0dHBzOi8vc3RhdG9taWNzLmdpdGh1Yi5pbykiCm91dHB1dDoKICAgIGh0bWxfZG9jdW1lbnQ6CiAgICAgIGNvZGVfZG93bmxvYWQ6IHRydWUKICAgICAgdGhlbWU6IGNvc21vCiAgICAgIHRvY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