came.datapair_from_adatas¶
- came.datapair_from_adatas(adatas: Sequence[AnnData], vars_feat: Sequence[Sequence], df_varmap: DataFrame, df_varmap_1v1: DataFrame | None = 'ignored', oo_adjs: Sequence[spmatrix] | None = None, vars_as_nodes: Sequence[Sequence] | None = None, union_var_nodes: bool = True, union_node_feats: bool = True, dataset_names: Sequence[str] = ('reference', 'query'), with_single_vnodes: bool = True, keep_non1v1_feats: bool = True, col_weight: str | None = None, non1v1_trans_to: int = 0, **kwds) DataPair ¶
Build
DataPair
object from a pair of adatas.Note that the node features will be extracted from
adata.raw
(if not None), so please make sure that these values are normalized.- Parameters:
adatas (list or tuple) – a list or tuple of 2 sc.AnnData objects.
vars_feat – a list or tuple of 2 variable name-lists. for example, differential expressed genes, highly variable features.
df_varmap – pd.DataFrame with 2 columns. relationships between features in 2 datasets, for making the adjacent matrix (vv_adj) between variables from these 2 datasets.
df_varmap_1v1 – dataframe containing only 1-to-1 correspondence between features in 2 datasets, if not provided, it will be inferred from df_varmap
oo_adjs – a sequence of (sparse) adjacent matrices of observations.
vars_as_nodes – list or tuple of 2; variables to be taken as the graph nodes
union_var_nodes (bool) – whether to take the union of the variable-nodes
union_node_feats (bool) – whether to take the union of the observation-node-features
dataset_names – list or tuple of 2. names to discriminate data source, e.g. (‘reference’, ‘query’)
with_single_vnodes – whether to include the varibales (node) that are ocurred in only one of the datasets
keep_non1v1_feats (bool) – whether to take into account the non-1v1 variables as the node features.
col_weight – A column in
df_varmap
specifying the weights between homologies.non1v1_trans_to (int) – the direction to transform non-1v1 features, should either be 0 or 1. Set as 0 to transform query data to the reference (default), 1 to transform the reference data to the query. If set
keep_non1v1_feats=False
, this parameter will be ignored.
- Returns:
dpair
- Return type:
Examples
>>> dpair = datapair_from_adatas( ... [adata1, adata2], ... vars_feat=[hvgs1, hvgs2], ... df_varmap=homo_gene_matches, ... vars_as_nodes=[], ... dataset_names=['reference', 'query'])
See also