bpcells.experimental.MemMatrix#

class bpcells.experimental.MemMatrix(dir: str, threads: int = 0)[source]#

In-memory BPCells integer matrix

This reads BPCells-format matrices from disk, returning scipy.sparse.csc_matrix objects when sliced. It is much more memory-intensive, but consistently fast for random reads

Parameters:

dir (str) – Path of the matrix directory

Examples

>>> from bpcells import MemMatrix
>>> mat = MemMatrix("/path/to/matrix")
>>> mat[:,[1,3,2,4]]
<3x4 sparse matrix of type '<class 'numpy.uint32'>'
    with 6 stored elements in Compressed Sparse Column format>

Attributes

MemMatrix.T

Return a transposed view of the matrix

MemMatrix.shape

Dimensions of matrix

MemMatrix.threads

Threads used for reads (default=1)

Methods

MemMatrix.transpose()

Return at transposed view of the matrix