scirpy.pp.merge_airr

scirpy.pp.merge_airr(adata, adata2, *, airr_mod='airr', airr_mod2='airr', airr_key='airr', airr_key2='airr', drop_duplicate_chains=True, **kwargs)

Merge two AnnData objects with IR information (e.g. BCR with TCR).

Decomposes the IR information back into scirpy.io.AirrCell objects and merges them on a chain-level. If both objects contain the same cell-id, and the same chains, the corresponding row in adata.obsm["airr"] will be unchanged (if drop_duplicate_chains is True). If both objects contain the same cell-id, but different chains, the chains will be merged into a single cell such that it can be annotated as ambiguous or multi-chain if appropriate. If a cell contains both TCR and BCR chains, they will both be kept and can be identified as ambiguous using the scirpy.tl.chain_qc() function.

The function performs a “outer join”, i.e. all cells from both objects will be retained. All information except .obsm[airr_key] and .obs will be lost.

Note

There is no need to use this function for the following use-cases:

Parameters
adata : AnnData | MuData | DataHandlerUnion[AnnData, MuData, DataHandler]

first AnnData object containing IR information

adata2 : AnnData | MuData | DataHandlerUnion[AnnData, MuData, DataHandler]

second AnnData object containing IR information

airr_mod

Name of the modality with AIRR information is stored in the MuData object. if an AnnData object is passed to the function, this parameter is ignored.

airr_mod2

Like airr_mod, but for adata2

airr_key

Key under which the AIRR information is stored in adata.obsm as an awkward array.

airr_key2

Like airr_key, but for adata2

drop_duplicate_chains

If True, if there are identical chains associated with the same cell only one of them is kept.

**kwargs

passed to from_airr_cells()

Return type

AnnData

Returns

new AnnData object with merged AIRR data.