netmap.utils.data_utils.merge_all_to_obs

netmap.utils.data_utils.merge_all_to_obs(target_adata, source_adata, replace=True)[source]

Copies all variables from source_adata into target_adata.obs for convenient Scanpy plotting.

All columns in source_adata.var_names are appended as new columns to target_adata.obs. When columns named 'regulon' are already present in target_adata.obs and replace=True, those existing regulon columns are dropped before the new values are concatenated.

Parameters:
  • target_adata – AnnData object whose obs DataFrame will be extended. Must have the same number of cells as source_adata.

  • source_adata – AnnData object whose X matrix (cells x variables) is used as the source of new obs columns.

  • replace – If True (default), any existing columns whose name contains 'regulon' in target_adata.obs are removed before adding the new columns. If False, the merge is skipped when overlapping column names are detected and a message is printed.

Returns:

The input target_adata with updated obs columns.

Return type:

target_adata

Raises:

ValueError – If the cell counts of target_adata and source_adata do not match.