sync_sparse_rows
sync_sparse_rows.Rd
Synchronize Rows of a Sparse Matrix to Match Target Row Names
Arguments
- sparse_mat
A sparse matrix of class `dgCMatrix`, with rownames defined.
- target_rownames
A character vector of desired rownames in the final matrix.
Value
A sparse matrix with the same number of columns and rownames exactly matching `target_rownames`.
Details
Ensures that a sparse matrix of class `dgCMatrix` has rows that exactly match a target set of row names. Adds missing rows filled with zeros if necessary, and reorders existing rows to match the specified order.
This is useful when aligning matrices from different sources (e.g., profiles, probabilities, annotations) in cases where missing rows should be treated as zero.