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 inadata.obsm["airr"]
will be unchanged (ifdrop_duplicate_chains
isTrue
). 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 asambiguous
using thescirpy.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:
If you want to merge AIRR data with transcriptomics data, use
MuData
instead, as shown in Working with multimodal data.If you want to concatenante mutliple
AnnData
objects, useanndata.concat()
instead, as shown in Combining multiple samples.
- Parameters:
adata (
Union
[AnnData
,MuData
,DataHandler
]) – first AnnData object containing IR informationadata2 (
Union
[AnnData
,MuData
,DataHandler
]) – second AnnData object containing IR informationairr_mod (default:
'airr'
) – Name of the modality with AIRR information is stored in theMuData
object. if anAnnData
object is passed to the function, this parameter is ignored.airr_mod2 (default:
'airr'
) – Likeairr_mod
, but for adata2airr_key (default:
'airr'
) – Key under which the AIRR information is stored in adata.obsm as an awkward array.airr_key2 (default:
'airr'
) – Likeairr_key
, but for adata2drop_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:
- Returns:
new AnnData object with merged AIRR data.