
Load in a 10x CellRanger h5 file to SingleCells
load_tenx_h5.RdLoads the gene-expression modality from a CellRanger v2/v3 h5 file. The
counts go into the Rust-binarised format (with log normalisation applied on
read) and the barcodes/features into the DuckDB. Non-gene modalities (e.g.
Antibody Capture) are filtered out via feature_type.
Usage
load_tenx_h5(
object,
h5_path,
sc_qc_param = params_sc_min_quality(),
feature_type = "Gene Expression",
csc_mem_gb = NULL,
streaming = deprecated(),
batch_size = deprecated(),
max_genes_in_memory = deprecated(),
cell_batch_size = deprecated(),
.verbose = TRUE
)Arguments
- object
SingleCellsclass.- h5_path
File path to the 10x h5 file.
- sc_qc_param
List. Output of
params_sc_min_quality().- feature_type
String. Modality to keep. Defaults to
"Gene Expression". Ignored for v2 (single modality)."Peaks"errors, seeload_atac_tenx()andadd_atac_tenx_sc().- csc_mem_gb
Optional numeric. Memory in GB for the buffers of the cell-to-gene (CSR to CSC) conversion, at 10 bytes per non-zero.
NULL(default) converts in one pass and holds the whole matrix. Set a cap for large data sets; every extra phase re-reads the cell file once.- streaming, batch_size, max_genes_in_memory, cell_batch_size
- .verbose
Boolean.
Examples
# read back a CellRanger v3 h5, gene expression only
data <- generate_single_cell_test_data(
syn_data_params = params_sc_synthetic_data(n_cells = 200L, n_genes = 40L)
)
f_path <- tempfile(fileext = ".h5")
write_tenx_h5_sc(
f_path = f_path,
counts = data$counts,
barcodes = data$obs$cell_id,
features = data.table::data.table(
id = data$var$gene_id,
name = data$var$ensembl_id,
feature_type = "Gene Expression"
)
)
dir_data <- tempfile("sc_tenx")
dir.create(dir_data, recursive = TRUE)
sc <- load_tenx_h5(
object = SingleCells(dir_data = dir_data),
h5_path = f_path,
sc_qc_param = params_sc_min_quality(
min_unique_genes = 5L,
min_lib_size = 25L,
min_cells = 5L
),
.verbose = FALSE
)
dim(sc)
#> [1] 200 40
unlink(c(f_path, dir_data), recursive = TRUE, force = TRUE)