cellxgene_census.get_presence_matrix

cellxgene_census.get_presence_matrix(census: Collection, organism: str, measurement_name: str = 'RNA') csr_matrix

Read the feature dataset presence matrix and return as a scipy.sparse.csr_array. The returned sparse matrix is indexed on the first dimension by the dataset soma_joinid values, and on the second dimension by the var pandas.DataFrame soma_joinid values.

Parameters:
  • census – The census from which to read the presence matrix.

  • organism – The organism to query, usually one of "Homo sapiens" or "Mus musculus".

  • measurement_name – The measurement object to query. Deafults to "RNA".

Returns:

A scipy.sparse.csr_array object containing the presence matrix.

Raises:

ValueError – if the organism cannot be found.

Lifecycle

maturing

Examples

>>> get_presence_matrix(census, "Homo sapiens", "RNA")
<321x60554 sparse array of type '<class 'numpy.uint8'>'
with 6441269 stored elements in Compressed Sparse Row format>