alphapepttools.pp.add_metadata

Contents

alphapepttools.pp.add_metadata#

alphapepttools.pp.add_metadata(adata, incoming_metadata, axis, *, keep_data_shape=False, keep_existing_metadata=False, verbose=False)#

Add metadata to an AnnData object while checking for matching indices or shape

If axis is 0, assume metadata.index <-> data.index and add metadata as ‘.obs’ of the AnnData object. If axis is 1, assume metadata.index <-> data.columns and add metadata as ‘.var’ of the AnnData object.

Parameters:
  • adata (ad.AnnData) – Anndata object to add metadata to.

  • metadata (incoming) – Metadata dataframe to add. The matching entity is always the INDEX, depending on axis it is matched against obs (axis = 0) or var (axis = 1).

  • axis (int) – Axis to add metadata to. 0 for obs and 1 for var.

  • keep_data_shape (bool = False) – If True, the incoming data is left-joined to the existing data, which may result in nan-padded rows in the incoming data. If False, incoming data is added via inner join, which may change the shape of the adata object.

  • keep_existing_metadata (bool = False) – If True, incoming metadata is added to the existing metadata. If False, incoming metadata replaces existing metadata. If columns between existing and incoming metadata are synonymous, the corresponding incoming metadata columns are ignored.

  • verbose (bool = False) – If True, print additional information about the operation.

Return type:

AnnData