liana.mt.MistyData.__call__#
- MistyData.__call__(model, bypass_intra=False, predict_self=False, maskby=None, k_cv=10, alphas=array([0.1, 1., 10.]), seed=1337, inplace=True, verbose=False, **kwargs)#
A Multi-view Learning for dissecting Spatial Transcriptomics data (MISTy) model.
- Parameters:
- model
type[SingleViewModel] Single-view model of class SingleViewModel. Default options are RandomForestModel, LinearModel, and RobustLinearModel available via
liana.method.sp._misty._single_view_models.- bypass_intra
bool(default:False) Whether to bypass modeling the intraview via leave-one-feature-out (LOFO). In other words, whether to bypass modelling each target by LOFO within the same spots.
- predict_self
bool(default:False) Whether to predict self-interactions. These are determined purely by the feature names.
- maskby
str|None(default:None) Column in the .obs attribute used to group or mask observations in the intra-view If None, all cells are considered as one group.
- k_cv
int(default:10) Number of folds for cross-validation used in the multi-view model, and single-view models if model is ‘linear’.
- alphas
float|NDArray[floating] |list[float] (default:array([ 0.1, 1. , 10. ])) List of alpha values used to choose from, that control the strength of the ridge regression, used for the multi-view part of the model. Only used if there are more than 2 views being modeled (including intra).
- seed
int(default:1337) Random seed for reproducibility.
- inplace
bool(default:True) Whether to store results in place, or else to return them.
- verbose
bool|None(default:False) Verbosity flag.
False, the default, hides progress and info messages but still warns about data-altering conditions;Trueshows both;Nonesilences everything, warnings included.- **kwargs
Any Keyword arguments passed to the Regressors. Note that random_state is already set via
seed.n_jobsis instead used to cross-validate each target and defaults to 1, as the folds are few and each fit is cheap; raise it only for expensive regressors.
- model
- Return type:
- Returns:
- If inplace is True, two DataFrames are written to
misty.uns.'target_metrics'is one row per target: how well the intra view alone explains it (
intra_R2), how well all views together do (multi_R2), what the extra views add (gain_R2), and each view’s contribution.'interactions'is one row per predictor-target pair per view, with the importance the model gave it.
Otherwise the two DataFrames are returned, one for target metrics and one for importances.
- If inplace is True, two DataFrames are written to
Examples
Each variable of the
'intra'view is modelled in turn, from the other intra-view variables and from every other view:>>> import liana as li >>> adata = li.ds.generate_toy_spatial() >>> adata = adata[:, adata.var_names[:5]].copy() >>> misty = li.mt.genericMistyData(intra=adata, bandwidth=200, set_diag=True) >>> misty(model=li.mt.sp.LinearModel)