SparsePointers: Convert sparse matrix pointers to indices and vice versa

SparsePointersR Documentation

Convert sparse matrix pointers to indices and vice versa

Description

Convert sparse matrix pointers to indices and vice versa

Usage

IndexToPointer(j)

PointerToIndex(p)

Arguments

j

A vector of sparse matrix colum indices

p

A vector of sparse matrix pointers

Value

IndexToPointer: A vector of index pointers (p)

PointerToIndex: A vector of column (j) indices

Author(s)

PointerToIndex was written by Josh O'Brien on StackOverflow

Source

PointerToIndex came from StackOverflow

Examples


dat <- dat <- c(0, 0, 1, 4, 0, 2, 0, 9, 0)
smat <- Matrix::Matrix(data = dat, nrow = 3, sparse = TRUE)
j <- SeuratDisk:::PointerToIndex(p = smat@p)
Matrix::sparseMatrix(i = smat@i + 1, j = j, x = smat@x)
p <- SeuratDisk:::IndexToPointer(j = j)
Matrix::sparseMatrix(i = smat@i + 1, p = p, x= smat@x)


mojaveazure/seurat-disk documentation built on Nov. 5, 2023, 9:40 a.m.