gemmr.sample_analysis.analyzers.analyze_dataset

gemmr.sample_analysis.analyzers.analyze_dataset(estr, X, Y, Xorig=None, Yorig=None, x_align_ref=None, y_align_ref=None, addons=(), fit_params=None, **kwargs)

Analyze a given dataset with a given estimator

Fits an estimator to a given dataset, stores association strengths, weights and loadings and optionally runs additional analyses with fitted estimator.

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

  • 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

Return type:

xr.Dataset