read10xMatrix {DropletUtils} | R Documentation

## Read in the 10x count matrix

### Description

Creates a sparse or HDF5-backed count matrix from the MatrixMarket file produced by CellRanger.

### Usage

    read10xMatrix(file, hdf5.out=FALSE, chunk.size)

### Arguments

`file` | String containing the path to a MatrixMarket file, usually named `"matrix.mtx"`.
`hdf5.out` | A logical scalar indicating whether a `HDF5Matrix` object should be produced.
`chunk.size` | An integer scalar specifying the chunk size when reading in records from `file`.

### Details

When `hdf5.out=FALSE`, `readMM` is used directly. However, for very large 10x experiments with more than `.Machine$integer.max` non-zero entries, `dgCMatrix` may encounter integer overflows. In such cases, setting `hdf5.out=TRUE` will produce a `HDF5Matrix` object instead.

### Value

A `dgCMatrix` object (or a `HDF5Matrix` object, if `hdf5.out=TRUE`) containing the counts for each gene (row) and cell barcode (column).

### Author(s)

Aaron Lun

### References

10X Genomics (2017). Gene-Barcode Matrices. https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/matrices

### See Also

`readMM`, `read10xCounts`

### Examples

    # Mocking up some 10X genomics output.
    example(write10xCounts)

    mm.path <- file.path(tmpdir, "matrix.mtx")
    X <- read10xMatrix(mm.path)
    altX <- read10xMatrix(mm.path, chunk.size=10, hdf5.out=TRUE)

[Package DropletUtils version 1.0.3 Index]