
Load in Seurat to SingleCells
load_seurat.RdThis function takes a Seurat object and generates a SingleCells class
from it. The raw counts are extracted, written to the Rust binary format,
and the metadata is loaded into the DuckDB.
Usage
load_seurat(
object,
seurat,
sc_qc_param = params_sc_min_quality(),
streaming = 1L,
batch_size = 1000L,
max_genes_in_memory = 2000L,
cell_batch_size = 100000L,
.verbose = TRUE
)Arguments
- object
SingleCellsclass.- seurat
Seuratclass you want to transform.- sc_qc_param
List. Output of
params_sc_min_quality(). A list with the following elements:min_unique_genes - Integer. Minimum number of genes to be detected in the cell to be included.
min_lib_size - Integer. Minimum library size in the cell to be included.
min_cells - Integer. Minimum number of cells a gene needs to be detected to be included.
target_size - Float. Target size to normalise to. Defaults to
1e5.
- streaming
Integer. CSR-to-CSC conversion mode.
0L-> in-memory (fastest, highest memory),1L-> light streaming with cell batching,2L-> heavy streaming with memory upper boundaries. Defaults to1L.- batch_size
Integer. Cell batch size when
streaming = 1L. Defaults to1000L.- max_genes_in_memory
Integer. Maximum genes held in memory at once when
streaming = 2L. Defaults to2000L.- cell_batch_size
Integer. Cell batch size when
streaming = 2L. Defaults to100000L.- .verbose
Boolean. Controls the verbosity of the function.
Examples
# \donttest{
# a Seurat object holds genes x cells, the loader transposes it
data <- generate_single_cell_test_data(
syn_data_params = params_sc_synthetic_data(n_cells = 200L, n_genes = 40L)
)
seurat_obj <- Seurat::CreateSeuratObject(
counts = Matrix::t(data$counts),
meta.data = data.frame(data$obs, row.names = data$obs$cell_id)
)
#> Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
#> Warning: Data is of class dgRMatrix. Coercing to dgCMatrix.
dir_data <- tempfile("sc_seurat")
dir.create(dir_data, recursive = TRUE)
sc <- load_seurat(
object = SingleCells(dir_data = dir_data),
seurat = seurat_obj,
sc_qc_param = params_sc_min_quality(
min_unique_genes = 5L,
min_lib_size = 25L,
min_cells = 5L
),
streaming = 0L,
.verbose = FALSE
)
dim(sc)
#> [1] 200 40
unlink(dir_data, recursive = TRUE, force = TRUE)
# }