gemmr.sample_analysis.analyzers.analyze_resampled
- gemmr.sample_analysis.analyzers.analyze_resampled(estr, X, Y, Xorig=None, Yorig=None, x_align_ref=None, y_align_ref=None, addons=(), resample_addons=None, n_bs=0, perm=None, loo=False, random_state=None, saved_perm_features='all', show_progress=True, n_jobs=1, fit_params=None, **kwargs)
Analyze a given dataset and resampled versions of it with a given estimator.
In addition to the dataset itself resampled versions of it are analyzed in the same way. Provided resampling strategies include:
bootstrap
leave-one-out
permutation
- Parameters:
estr (sklearn-style estimator) – for performing CCA or PLS. Must have method
fit
and (after fitting) attributesassocs_
,x_rotations_
,y_rotations_
,x_scores_
,y_scores_
X (np.ndarray (n_samples, n_features)) – dataset X
Y (np.ndarray (n_samples, n_features)) – dataset Y
Xorig (
None
or np.ndarray (n_samples, n_orig_features)) – can beNone
. Allows to provide an alternative set of X features for calculating loadings. I.e. an implicit assumption is that the rows inX
andXorig
correspond to the same samples (subjects).Yorig (
None
or np.ndarray (n_samples, n_orig_features)) – can beNone
. Allows to provide an alternative set of Y features for calculating loadings. I.e. an implicit assumption is that the rows inY
andYorig
correspond to the same samples (subjects).x_align_ref ((n_features,)) – after fitting, the sign of X weights is chosen such that the cosine-distance between fitted X weights and
x_align_ref
is positivey_align_ref ((n_features,)) – after fitting, the sign of Y weights is chosen such that the cosine-distance between fitted Y weights and
y_align_ref
is positiveaddons (list-like of add-on functions) –
After fitting the estimator and saving association strengths, weights and loadings in
results
additional analyses can be performed with these functions. They are called in the given order, and must have the signatureaddana_fun(estr, X, Y, Xorig, Yorig, x_align_ref, y_align_ref, results, **kwargs)
and are expected to save their respective outcome features
results
. Various such functions are provided in modulesample_analysis_addons
resample_addons (None or list-like of add-on functions) – if
None
thenaddons
is usedn_bs (int) – number of bootstrap iterations to perform on the data
perm (None, int, or iterable) – if
None
no permutations are performed, ifint
gives the number of permutations to perform on the data, if iterable each element is an array giving the permuted indices to useloo (bool) – if
True
leave-one-out analysis is performed on the datarandom_state (
None
, int or random number generator instance) – used to generate random numberssaved_perm_features ('all' or list-like of 'str') – if ‘all’ all outcome features resulting from the permutations are returned, otherwise only data variables indicated by this list are
show_progress (bool) – whether to show progress bar
n_jobs (int or None) – number of parallel jobs (see
joblib.Parallel
)fit_params (dict) – keyword-arguments for estr.fit
kwargs (dict) – forwarded to additional analysis functions
- Returns:
results – containing data variables for outcome features generated by analyses. Data variables obtained from bootstrapping are suffixed ‘_bs’, from permutations ‘_perm’ and from leave-one-out ‘_loo’
- Return type:
xr.Dataset