mtopic.pp.feature_associations_data#
- mtopic.pp.feature_associations_data(mdata, mod_list, normalize=True)#
Prepare feature signatures for training feature associations.
Extracts and optionally row-normalizes signature matrices from multiple modalities in a MuData object. Each signature matrix is expected to be stored in varm[‘signatures’] of the respective modality. Matrices are returned in a dictionary keyed by modality name.
- Parameters:
mdata (muon.MuData) – A MuData object containing modalities with signature matrices in varm[‘signatures’].
mod_list (list[str]) – List of modality names to extract from mdata.
normalize (bool) – If True, rows of the signature matrices are normalized to sum to 1. (default: True)
- Returns:
A dictionary where keys are modality names and values are tuples (M, M_var), with: - M: torch.FloatTensor of shape (n_topics, n_features), the signature matrix. - M_var: The corresponding var DataFrame from the modality.
- Return type:
dict[str, tuple[torch.Tensor, pandas.DataFrame]]
- Example:
import muon as mu import torch mdata = mu.read('multiome_data.h5mu') # Extract signatures from RNA and ATAC modalities associations_input = feature_associations_data(mdata, ['rna', 'atac']) A, A_var = associations_input['rna'] B, B_var = associations_input['atac']