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 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 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.


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

  • adata (Union[AnnData, MuData, DataHandler]) – first AnnData object containing IR information

  • adata2 (Union[AnnData, MuData, DataHandler]) – second AnnData object containing IR information

  • airr_mod (default: 'airr') – 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 (default: 'airr') – Like airr_mod, but for adata2

  • airr_key (default: 'airr') – Key under which the AIRR information is stored in adata.obsm as an awkward array.

  • airr_key2 (default: 'airr') – Like airr_key, but for adata2

  • drop_duplicate_chains (default: True) – 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:



new AnnData object with merged AIRR data.