
Process Spliced and Unspliced Counts from Velocyto Outputs
Source:R/star_solo_processing.R
make_velo_count.RdParses and processes spliced and unspliced gene expression matrices from one or more Velocyto output directories. The function applies barcode filtering using an external whitelist or filtered barcodes file, and optionally merges the results across samples into unified matrices.
Usage
make_velo_count(
velocyto_dirs,
sample_ids,
whitelist_barcodes = NULL,
use_internal_whitelist = TRUE,
merge_counts = FALSE
)Arguments
- velocyto_dirs
A character vector or list of strings. Each element should be a path to a Velocyto output directory. Each directory must contain subdirectories (typically
filteredorraw) with the required matrix files:spliced.mtx,unspliced.mtx,barcodes.tsv, andgenes.tsvorfeatures.tsv.- sample_ids
A character vector or list of unique sample identifiers corresponding to each entry in
velocyto_dirs.- whitelist_barcodes
A list of character vectors. Each element should provide a whitelist of barcodes to retain for the corresponding sample. If
NULL(default), the function will attempt to use the internally provided filtered barcodes whenuse_internal_whitelist = TRUE.- use_internal_whitelist
Logical (default
TRUE). IfTRUE, andwhitelist_barcodesisNULL, the function uses the filtered barcode file (if present in the directory). IfFALSE, all barcodes from the raw matrix will be used unless a whitelist is explicitly provided.- merge_counts
Logical (default
FALSE). IfTRUE, spliced and unspliced matrices across all samples are merged into two combined matrices (one for spliced, one for unspliced). IfFALSE, the results are returned per sample.
Value
A list containing processed gene expression matrices:
If
merge_counts = FALSE, returns a named list of sample-specific matrices. Each entry contains:splicedSparse matrix of spliced transcript counts.
unsplicedSparse matrix of unspliced transcript counts.
If
merge_counts = TRUE, returns a list with two elements:splicedMerged sparse matrix of spliced counts across all samples.
unsplicedMerged sparse matrix of unspliced counts across all samples.
Details
The function assumes that each Velocyto directory follows the 10X-like structure typically produced by tools like Loom or Velocyto CLI. Barcode filtering ensures that only high-quality or selected barcodes are retained for downstream RNA velocity analysis.
When merging matrices, barcodes are prefixed with their corresponding sample ID to avoid collisions and preserve traceability.