MPX Quality Control
This tutorial details the first steps of data analysis to quality control and clean up the MPX data output from Pixelator.
After completing this tutorial, you should be able to:
- Use the edge rank plot to manually set cell calling thresholds and filter low-quality cells.
- Aggregate data across samples and visualize sample-level QC metrics like number of cells.
- Check distributions of quality metrics like molecule counts and graph connectivity.
- Identify and remove cell outliers using the antibody count distribution metric Tau.
Setup
First, we will load packages necessary for downstream processing.
library(pixelatorR)
library(dplyr)
library(stringr)
library(SeuratObject)
library(here)
library(ggplot2)
library(tidyr)
Load data
We will continue where we left off after the previous tutorial Data handling where we combined MPX data from two samples.
# The folders the data is located in:
data_files <-
c(S1 = here("data/Sample01_human_pbmcs_unstimulated.dataset.pxl"),
S2 = here("data/Sample02_human_pbmcs_unstimulated.dataset.pxl"))
# Read .pxl files as a list of Seurat objects
pg_data <- lapply(data_files, ReadMPX_Seurat)
# Combine data to Seurat object
pg_data_combined <-
merge(pg_data[[1]],
y = pg_data[-1],
add.cell.ids = names(pg_data))
# Add sample column to meta data
pg_data_combined <-
AddMetaData(pg_data_combined,
metadata = str_remove(colnames(pg_data_combined), "_.*"),
col.name = "sample")
Cell calling: Edge rank plot
Here, we use the edge rank plot to perform an additional quality control of the called cells, to make a manual adjustment to the number of cells that were called by Pixelator. This removes cells that deviate from the component size distribution, and might not represent whole cells.
edgerank_plot <- EdgeRankPlot(pg_data_combined, group_by = "sample")
edgerank_plot
It looks like components are declining rapidly in size at around 5000 edges, and we will thus set a manual cutoff at that point, represented by a dashed line.
edgerank_plot +
geom_hline(yintercept = 5000,
linetype = "dashed")
# Filter cells to have at least 5000 edges
pg_data_combined <-
pg_data_combined %>%
subset(edges >= 5000)
pg_data_combined
An object of class Seurat
80 features across 864 samples within 1 assay
Active assay: mpxCells (80 features, 80 variable features)
2 layers present: counts.1, counts.2
Here, we plot the number of called cells per condition and replicate.
CellCountPlot(pg_data_combined, color_by = "sample")
Here, we visualize the distribution of some metrics among components.
pg_data_combined[[]] %>%
select(sample, edges, umi_per_upia, mean_reads) %>%
pivot_longer(cols = c("edges", "umi_per_upia", "mean_reads"), names_to = "metric", values_to = "value") %>%
ggplot(aes(sample, value)) +
geom_violin(draw_quantiles = 0.5,
fill = "gray") +
facet_grid(metric ~ ., scales = "free") +
scale_y_log10() +
theme_minimal()
Antibody count distribution outlier removal
Here, we have plotted umi_per_upia against Tau, and colored each component by Pixelator’s classification of Tau (low, normal, or high). It looks like Pixelator has accurately picked out a single outlier that might be an antibody aggregate or a component that has low specificity, binding many more different types of antibodies than we would expect from a normal cell. As this outlier is likely a technical artefact, will remove it from the analysis.
### Pixel content vs Marker specificity
TauPlot(pg_data_combined, group_by = "sample")
# Only keep the components where tau_type is normal
pg_data_combined <-
pg_data_combined %>%
subset(tau_type == "normal")
pg_data_combined
An object of class Seurat
80 features across 863 samples within 1 assay
Active assay: mpxCells (80 features, 80 variable features)
2 layers present: counts.1, counts.2
Going through the above steps we have performed critical quality control by filtering low-quality cells and identifying outliers. With a clean, high-quality MPX dataset in hand, we are ready to proceed to the next step, in which we will be leveraging protein abundance for the annotation of different cell populations.