read10XFiles: Read 10X cellranger files (matrix, barcodes and features)...

View source: R/import.R

read10XFilesR Documentation

Read 10X cellranger files (matrix, barcodes and features) into R session

Description

This function works for loading a single sample with specifying the paths to the matrix.mtx, barcodes.tsv, and features.tsv files. This function is internally used by read10X functions for loading individual samples from cellranger output directory, while it can also be convenient when out-of-standard files are presented (e.g. data downloaded from GEO).

Usage

read10XFiles(
  matrixPath,
  barcodesPath,
  featuresPath,
  sampleName = NULL,
  geneCol = 2,
  cellCol = 1,
  isATAC = FALSE,
  returnList = FALSE
)

Arguments

matrixPath

Character string, path to the matrix MTX file. Can be gzipped.

barcodesPath

Character string, path to the barcodes TSV file. Can be gzipped.

featuresPath

Character string, path to the features TSV file. Can be gzipped.

sampleName

Character string attached as a prefix to the cell barcodes loaded from the barcodes file. Default NULL does not add any prefix. Useful when users plan to merge multiple samples into one matrix and need to avoid duplicated cell barcodes from different batches.

geneCol

An integer indicating which column in the features file to extract as the feature identifiers. Default 2.

cellCol

An integer indicating which column in the barcodes file to extract as the cell identifiers. Default 1.

isATAC

Logical, whether the data is for ATAC-seq. Default FALSE. If TRUE, feature identifiers will be generated by combining the first three columns of the features file in the format of "chr:start-end".

returnList

Logical, used internally by wrapper functions. Whether to force putting the loaded matrix in a list even if there's only one matrix. Default FALSE.

Value

For a single-modal sample, a dgCMatrix object, or a list of one dgCMatrix when returnList = TRUE. A list of multiple dgCMatrix objects when multiple feature types are detected.

Examples

## Not run: 
matrix <- read10XFiles(
    matrixPath = "path/to/matrix.mtx.gz",
    barcodesPath = "path/to/barcodes.tsv.gz",
    featuresPath = "path/to/features.tsv.gz"
)

## End(Not run)

rliger documentation built on Oct. 30, 2024, 1:07 a.m.