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) attributes assocs_, 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 be None. Allows to provide an alternative set of X features for calculating loadings. I.e. an implicit assumption is that the rows in X and Xorig correspond to the same samples (subjects).

  • Yorig (None or np.ndarray (n_samples, n_orig_features)) – can be None. Allows to provide an alternative set of Y features for calculating loadings. I.e. an implicit assumption is that the rows in Y and Yorig 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 positive

  • y_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 positive

  • addons (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 signature

    addana_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 module sample_analysis_addons

  • resample_addons (None or list-like of add-on functions) – if None then addons is used

  • n_bs (int) – number of bootstrap iterations to perform on the data

  • perm (None, int, or iterable) – if None no permutations are performed, if int gives the number of permutations to perform on the data, if iterable each element is an array giving the permuted indices to use

  • loo (bool) – if True leave-one-out analysis is performed on the data

  • random_state (None, int or random number generator instance) – used to generate random numbers

  • saved_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