scirpy.io.AirrCell

class scirpy.io.AirrCell(cell_id, cell_attribute_fields=(), *, logger=<module 'scanpy.logging' from 'C:\\\\hostedtoolcache\\\\windows\\\\Python\\\\3.9.13\\\\x64\\\\lib\\\\site-packages\\\\scanpy\\\\logging.py'>)

Data structure for a Cell with immune receptors. Represents one row of adata.obsm["airr"].

This data structure is compliant with the AIRR rearrangement schema v1.0. An AirrCell can hold multiple chains (i.e. rows from the rearrangement TSV) which belong to the same cell. A chain is represented as a dictionary, where the keys are AIRR-rearrangement fields.

The AirrCell can, additionally, hold cell-level attributes which can be set in a dict-like fashion. Keys marked as “cell-level” via cell_attribute_fields will be automatically transferred to the cell-level when added through a chain. They are required to have the same value for all chains.

Parameters
cell_id : str

cell id or barcode. Needs to match the cell id used for transcriptomics data, if any.

cell_attribute_fields : Collection[str] (default: ())

List of field-names which are supposed to be stored at the cell-level rather than the chain level. If a chain with these fields is added to the cell, they are set on the cell-level instead. If the values already exist on the cell-level, a ValueError is raised, if they differ from the values that are already present.

logger : Any (default: <module 'scanpy.logging' from 'C:\\\\hostedtoolcache\\\\windows\\\\Python\\\\3.9.13\\\\x64\\\\lib\\\\site-packages\\\\scanpy\\\\logging.py'>)

A logger to write messages to. If not specified, use scanpy’s default logger.

Attributes

VALID_LOCI

Valid chains are IMGT locus names see https://docs.airr-community.org/en/latest/datarep/rearrangements.html#locus-names

VDJ_LOCI

Identifiers of loci with a V-D-J junction

VJ_LOCI

Identifiers of loci with a V-J junction

cell_id

Unique identifier (barcode) of the cell.

chains

List of chain-dictionaries added to the cell.

fields

Return a list of all fields (chain-level and cell-level)

Methods

add_chain(chain)

Add a chain to the cell.

add_serialized_chains(serialized_chains)

Add chains serialized as JSON.

clear()

empty_chain_dict()

Generate an empty chain dictionary, containing all required AIRR columns, but set to None

get(k[,d])

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

to_airr_records()

Iterate over chains as AIRR-Rearrangent compliant dictonaries.

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()