Background
Eighteen Estrogen Receptor Positive Breast cancer tissues from from patients treated with tamoxifen upon recurrence have been assessed in a proteomics study. Nine patients had a good outcome (or) and the other nine had a poor outcome (pd). The proteomes have been assessed using an LTQ-Orbitrap and the thermo output .RAW files were searched with MaxQuant (version 1.4.1.2) against the human proteome database (FASTA version 2012-09, human canonical proteome).
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/cancer .
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/cancer/peptides6vs6.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 34205 rows and 12 columns
## class: SummarizedExperiment
## dim: 34205 12
## metadata(0):
## assays(1): ''
## rownames(34205): AAAAAAAAAAAAAAAGAGAGAK AAAAAAAAAAGAAGGR ...
## YYWGGQYTWDMAK YYYDGKDYIEFNK
## rowData names(38): Sequence Proteins ... Best.MS.MS
## Oxidation..M..site.IDs
## colnames(12): Intensity.OR.01 Intensity.OR.04 ... Intensity.PD.07
## Intensity.PD.08
## 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)$outcome <- substr(
colnames(pe[["peptideRaw"]]),
11,
12) %>%
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
Data exploration
We can inspect the missingness in our data with the plotNA()
function provided with MSnbase
. 46% 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)")
Preprocessing
This section preforms standard preprocessing for the peptide data. This include log transformation, filtering and summarisation of the data.
Filtering
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),]
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"]])$
Contaminant != "+", ]
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.
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] 25452
We keep 25452 peptides after filtering.
Quantile normalize the data
pe <- normalize(pe, i = "peptideLog", method = "quantiles", name = "peptideNorm")
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)$outcome))
The first axis in the plot is showing the leading log fold changes (differences on the log scale) between the samples.
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)$outcome))
Data Analysis
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 = ~outcome)
Inference
First, we extract the parameter names of the model.
getCoef(rowData(pe[["proteinRobust"]])$msqrobModels[[1]])
## (Intercept) outcomePD
## 20.148650 0.559795
Spike-in outcome a is the reference class. So the mean log2 expression for samples from outcome a is ‘(Intercept). The mean log2 expression for samples from outcome B is’(Intercept)+outcomePD’. Hence, the average log2 fold change between outcome b and outcome a is modelled using the parameter ‘outcomePD’. Thus, we assess the contrast ‘outcomePD=0’ with our statistical test.
L <- makeContrast("outcomePD=0", parameterNames = c("outcomePD"))
pe <- hypothesisTest(object = pe, i = "proteinRobust", contrast = L)
Plots
Volcano-plot
volcano <- ggplot(rowData(pe[["proteinRobust"]])$outcomePD,
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
Heatmap
We first select the names of the proteins that were declared signficant.
sigNames <- rowData(pe[["proteinRobust"]])$outcomePD %>%
rownames_to_column("proteinRobust") %>%
filter(adjPval<0.05) %>%
pull(proteinRobust)
heatmap(assay(pe[["proteinRobust"]])[sigNames, ])
There are 36 differentially expressed proteins.
Detail plots
We first extract the normalized peptideRaw expression values for a particular protein.
for (protName in sigNames[1:5])
{
pePlot <- pe[protName, , c("peptideNorm","proteinRobust")]
pePlotDf <- data.frame(longFormat(pePlot))
pePlotDf$assay <- factor(pePlotDf$assay,
levels = c("peptideNorm", "proteinRobust"))
pePlotDf$outcome <- as.factor(colData(pePlot)[pePlotDf$colname, "outcome"])
# 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 = outcome)) +
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)
}
LS0tCnRpdGxlOiAiUHJvdGVvbWljcyBkYXRhIGFuYWx5c2lzOiBjYW5jZXIgZXhhbXBsZSA2eDYiCmF1dGhvcjogIkxpZXZlbiBDbGVtZW50IgpkYXRlOiAic3RhdE9taWNzLCBHaGVudCBVbml2ZXJzaXR5IChodHRwczovL3N0YXRvbWljcy5naXRodWIuaW8pIgpvdXRwdXQ6CiAgICBodG1sX2RvY3VtZW50OgogICAgICBjb2RlX2Rvd25sb2FkOiB0cnVlCiAgICAgIHRoZW1lOiBjb3NtbwogICAgICB0b2M6IHRydWUKICAgICAgdG9jX2Zsb2F0OiB0cnVlCiAgICAgIGhpZ2hsaWdodDogdGFuZ28KICAgICAgbnVtYmVyX3NlY3Rpb25zOiB0cnVlCi0tLQoKIyBCYWNrZ3JvdW5kCkVpZ2h0ZWVuIEVzdHJvZ2VuIFJlY2VwdG9yIFBvc2l0aXZlIEJyZWFzdCBjYW5jZXIgdGlzc3VlcyBmcm9tIGZyb20gcGF0aWVudHMgdHJlYXRlZCB3aXRoIHRhbW94aWZlbiB1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