CellTagData Class

class celltag_tools.celltag_data.CellTagData(ct_reads=None, thresholds=None, seq_sat=None, clone_graph=None, jaccard_mtx=None, clone_table=None, clone_info=None)

Bases: object

A container class for storing and managing CellTag data, including read data, thresholds, various matrices, and clone information. Provides methods for serialization and easy attribute access.

Attributes:
ct_reads (pd.DataFrame | None):

The raw or processed CellTag read data.

thresholds (dict | None):

A dictionary of thresholds used at various processing steps (e.g., ‘starcode’, ‘triplet’, ‘binarization’, etc.).

seq_sat (float | None):

Sequencing saturation value.

clone_graph (igraph.Graph | None):

Graph representing clone relationships among cells.

allow_mtx (celltag_mtx_dict):

Dictionary-like container for the allow matrix and its axes.

bin_mtx (celltag_mtx_dict):

Dictionary-like container for the binarized matrix and its axes.

metric_mtx (celltag_mtx_dict):

Dictionary-like container for the metric-filtered matrix and its axes.

jaccard_mtx (scipy.sparse.spmatrix | None):

Jaccard similarity matrix.

clone_table (pd.DataFrame | None):

Table mapping cells to their clones.

clone_info (pd.DataFrame | None):

Table containing clone level metadata. Defaults to None.

save(path)

Saves the current CellTagData object to a file using pickle serialization.

Args:
path (str):

The file path where the serialized object will be stored.

class celltag_tools.celltag_data.celltag_mtx_dict(initial_data)

Bases: object

A specialized dictionary-like container for a sparse matrix (‘mtx’) and its associated row (‘cells’) and column (‘celltags’) labels, specifically tailored for the CellTagData workflow.

This class strictly maintains three keys:
  • ‘mtx’: A scipy.sparse matrix representing the cell-tag matrix.

  • ‘cells’: A numpy.ndarray of cell identifiers (e.g., barcodes).

  • ‘celltags’: A numpy.ndarray of tag identifiers (e.g., CellTags).

Any attempt to add keys beyond these three raises a KeyError. Standard dictionary operations (e.g., indexing, iteration) are supported, but the structure is ensured to remain consistent with these fixed keys.

Key Features:
  • Only three keys (‘mtx’, ‘cells’, ‘celltags’) are permitted.

  • You can retrieve or set each key via subscript notation (e.g., obj[‘mtx’]).

  • The is_empty() method returns True if all three keys are set to None.

  • The length (len(obj)) is always 3.

  • The __repr__ method provides a concise, formatted view of the data.

Example Usage:

ctdict = celltag_mtx_dict({‘mtx’: None, ‘cells’: None, ‘celltags’: None}) if ctdict.is_empty():

print(“All entries are currently None.”)

ctdict[‘mtx’] = my_sparse_matrix ctdict[‘cells’] = my_cell_array ctdict[‘celltags’] = my_celltag_array

keys()
values()
items()
is_empty()

Check if all keys are set to None.