This vignette demonstrates the QC plots generated by cellhashR and loading of data directly from 10X Genomics files.

library(cellhashR)
knitr::opts_chunk$set(message=FALSE, warning=FALSE, echo=TRUE, error=TRUE)
requiredVars <- c('rawCountData', 'callFile')
for (v in requiredVars) {
    if (!exists(v)) {
        stop(paste0('Need to define variable: ', v))
    }
}

if (!file.exists(rawCountData)) {
  stop(paste0('Could not find rawCountData: ', rawCountData))
}

optionalVars <- c('barcodeWhitelist', 'cellbarcodeWhitelist', 'citeSeqCountDir', 'minCountPerCell', 'metricsFile')
for (v in requiredVars) {
    if (!exists(v)) {
        if (v == 'minCountPerCell') {
            minCountPerCell <- 5
        } else {
            assign(v, NULL)
        }
    }
}

# If cellbarcodeWhitelist == inputMatrix, save/restore the set of cellbarcodes for reporting:
saveOriginalCellBarcodeFile <- NULL
if (!is.null(cellbarcodeWhitelist)) {
    if (cellbarcodeWhitelist == 'inputMatrix') {
        saveOriginalCellBarcodeFile <- 'originalBarcodes.txt'
    }
}

# Truncate metricsFile if provided:
if (!is.null(metricsFile)) {
  file.create(metricsFile)
}

Data Loading / QC

Data is loaded for analysis from the umi_count directory of 10X Genomics data using the cellhashR command ProcessCountMatrix. This function loads raw counts and performs basic filtering and QC. The input count matrix was generated to include all possible barcodes. The figures demonstrate that only MS-11 and MS-12 barcodes are present.

if (!is.null(citeSeqCountDir)) {
  saturation <- PlotLibrarySaturation(citeSeqCountDir, metricsFile = metricsFile)
}
rawCountData = "../tests/testdata/438-21-GEX/umi_count"
barcodeData <- ProcessCountMatrix(rawCountData = rawCountData, minCountPerCell = minCountPerCell, barcodeWhitelist = barcodeWhitelist, saveOriginalCellBarcodeFile = saveOriginalCellBarcodeFile, metricsFile = metricsFile)
if (nrow(barcodeData) == 0) {
  stop('No passing barcodes')
}

if (ncol(barcodeData) == 0) {
  stop('No passing cells')
}
knitr::include_graphics('QC-example_files/figure-html/QC-1.png')
knitr::include_graphics('QC-example_files/figure-html/QC-2.png')
knitr::include_graphics('QC-example_files/figure-html/QC-3.png')
knitr::include_graphics('QC-example_files/figure-html/QC-4.png')
knitr::include_graphics('QC-example_files/figure-html/QC-5.png')

Normalization / QC

The plots below are generated using the cellhashR command PlotNormalizationQC and are designed to provide visualization of potential normalizations.

PlotNormalizationQC(barcodeData)
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-1.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-2.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-3.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-4.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-5.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-6.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-7.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-8.png')

Bimodal Quantile Normalization (BQN)

knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-9.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-10.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-11.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-12.png')

Quantile Normalization

knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-13.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-14.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-15.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-16.png')

Log2Center Normalization

knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-17.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-18.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-19.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-20.png')

CLR Normalization

knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-21.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-22.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-23.png')
knitr::include_graphics('QC-example_files/figure-html/NormalizationQC-24.png')

Next Steps

The next step is performing classification, which is demonstrated in the Benchmark example vignette. Details on classification using Bimodal Flexible Fitting (BFF) are provided in the BFF vignette.



BimberLab/cellhashR documentation built on March 20, 2024, 9:23 a.m.