Description Usage Arguments Value Examples
Read10xRaw
is a one-line handy function for reading
10x Cell Ranger output data, producing a count matrix for input to
CB2FindCell
. Read10xRawH5
is for reading 10x Cell Ranger output
HDF5 file (ended with .h5). Works under both old (<3) and new (>=3)
Cell Ranger version.
1 2 3 | Read10xRaw(dir = NULL, row.name = "symbol", meta = FALSE)
Read10xRawH5(h5file, row.name = "symbol", meta = FALSE)
|
dir |
The directory of 10x output data. For Cell Ranger version <3, directory should include three files: barcodes.tsv, genes.tsv, matrix.mtx. For Cell Ranger version >=3, directory should include three files: barcodes.tsv.gz, features.tsv.gz, matrix.mtx.gz. |
row.name |
Specify either using gene symbols
( |
meta |
Logical. If |
h5file |
The path of 10x output HDF5 file (ended with .h5). |
If meta = TRUE
, returns a list of two elements: a
"dgCMatrix" sparse matrix containing expression counts and a data
frame containing metadata of genes (features). For the count matrix,
each row is a gene (feature) and each column is a barcode. If
meta = FALSE
, only returns the count matrix.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # simulate 10x output files
data(mbrainSub)
data_dir <- file.path(tempdir(),"CB2example")
dir.create(data_dir)
gene_name <- rownames(mbrainSub)
# For simplicity, use gene names to generate gene IDs to fit the format.
gene_id <- paste0("ENSG_fake_",gene_name)
barcode_id <- colnames(mbrainSub)
Matrix::writeMM(mbrainSub,file = file.path(data_dir,"matrix.mtx"))
write.table(barcode_id,file = file.path(data_dir,"barcodes.tsv"),
sep = "\t", quote = FALSE, col.names = FALSE, row.names = FALSE)
write.table(cbind(gene_id,gene_name),file = file.path(data_dir,"genes.tsv"),
sep = "\t", quote = FALSE, col.names = FALSE, row.names = FALSE)
# read files
list.files(data_dir)
mbrainSub_new <- Read10xRaw(data_dir)
str(mbrainSub_new)
identical(mbrainSub, mbrainSub_new)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.