addVDJtoSCE: Add 10X CellRanger V(D)J data to SingleCellExperiment

addVDJtoSCER Documentation

Add 10X CellRanger V(D)J data to SingleCellExperiment

Description

Matches CellRanger V(D)J data to paired data in an existing SingleCellExperiment object.

Usage

addVDJtoSCE(samples, sce, ...)

## S4 method for signature 'SplitDataFrameList,SingleCellExperiment'
addVDJtoSCE(samples, sce, sample.names = NULL, barcode = "Barcode")

## S4 method for signature 'character,SingleCellExperiment'
addVDJtoSCE(samples, sce, sample.names = names(samples), barcode = "Barcode")

Arguments

samples

A character vector containing one or more directory names, each corresponding to a 10X sample. Each directory should contain a file named filtered_contig_annotations.csv. Alternatively, a SplitDataFrameList, the output of readVDJcontigs.

sce

A SingleCellExperiment object.

...

additional arguments.

sample.names

A character vector of length equal to samples containing the sample names to store in the output object. If NULL and samples is a character vector, the basenames of each directory will be used.

barcode

The column name from the colData of sce containing cell barcodes. These should match the barcodes in the V(D)J data (see Details). Alternatively, a vector of cell barcodes of length equal to ncol(sce).

Details

Matching cell barcodes between data objects can cause problems, because different methods have different ways of ensuring barcodes are unique across all samples. This function and readVDJcontigs follow the naming conventions of read10xCounts, where the sample index (in the samples vector) is appended to each cell barcode, to ensure that each barcode is unique, across all samples. If sce was created by a different method, such as conversion from a Seurat object, you may need to check the barcode naming convention.

Value

A SingleCellExperiment object with an element named "contigs" added to the colData, representing the V(D)J data.

Examples

# load example V(D)J data
data('contigs')
# make SCE object with matching barcodes and sample IDs
ncells <- 24
u <- matrix(rpois(1000 * ncells, 5), ncol = ncells)
barcodes <- vapply(contigs[,'barcode'], function(x){ x[1] }, 'A')
samples <- vapply(contigs[,'sample'], function(x){ x[1] }, 'A')
sce <- SingleCellExperiment::SingleCellExperiment(assays = list(counts = u),
                            colData = data.frame(Barcode = barcodes,
                                                 sample = samples))
sce <- addVDJtoSCE(contigs, sce)
sce$contigs


kstreet13/VDJdive documentation built on May 31, 2024, 1:26 p.m.