Skip to main content

Python implementation of partial least squares correlation (PLSC)

Project description

Python implementation of partial least squares correlation (PLSC)

tests codecov

Background

PLSC is a multivariate statistical technique used in neuroscience (McIntosh et al., 1994; McIntosh & Lobaugh, 2004; Krishnan et al., 2011), among other fields. It uses compact singular value decomposition (SVD) to analyze relationships between a multivariate data array and a design matrix. When the object of study is brain-behaviour correlations or functional connectivity, this method is referred to as "behaviour PLSC" or "seed PLSC". In pyplsc, these are implemented by the PLSC model class.

Multivariate categorical differences across experimental conditions can also be analyzed by applying SVD to matrices of condition-wise averages. This approach is called "mean-centred PLSC" or "barycentric discriminant analysis" (BDA; Abdi et al., 2018) and is implemented in pyplsc by the BDA model class.

Finally, associations between continuous variables within participants (e.g., trial-by-trial ratings versus brain data) can be analyzed using within-participants PLSC (Roberts et al., 2016) as implemented in the WPLSC model class.

Installation

pyplsc can be installed from PyPI with:

pip install pyplsc

pyplsc is tested with Python 3.10 and above but may also work with earlier versions.

Usage

pyplsc replicates the statistical functionality of the PLS Matlab package, much like the pyls library. A major difference is that pyplsc uses a scikit-learn-style model-fitting syntax and accepts tabular (pandas.DataFrame) input:

from pyplsc import PLSC, BDA

mod = PLSC(random_state=123)
mod.fit(data=data_array, covariates=cov_table)

Permutation testing and bootstrap resampling are then run as separate steps (possibly in parallel using the n_jobs parameter):

perm_dist = mod.permute(n_perm=1000, n_jobs=3)
boot_dist = mod.bootstrap(n_boot=1000)

In contrast to other PLS implementations, pyplsc does not require data to be pre-sorted by (between-participant) group and (within-participant) condition:

mod = BDA()
mod.fit(data=data_array,
		design=design_matrix_dataframe,
		between='group',
		within='cond',
		participant='subj')

See the documentation for more details and examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyplsc-0.0.28.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyplsc-0.0.28-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file pyplsc-0.0.28.tar.gz.

File metadata

  • Download URL: pyplsc-0.0.28.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyplsc-0.0.28.tar.gz
Algorithm Hash digest
SHA256 b70e2eca06527e5d3c3c230cdf681f323bb762a08a19f7c2e215517ea4019af2
MD5 2e7f34149fb8596103e798ed63644fd4
BLAKE2b-256 a7e3971f1a22acfc109cd22fdcaa6aff870ece8825bca835714404d8f71c4773

See more details on using hashes here.

File details

Details for the file pyplsc-0.0.28-py3-none-any.whl.

File metadata

  • Download URL: pyplsc-0.0.28-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyplsc-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 9d45dd4e40a7bbc0335bbb23a5c4012fcd343b5b1d777bdcff915bb0c8d553e7
MD5 7c52b17c3f1602a383786c4d51853897
BLAKE2b-256 e8a1a58948b8cbfc24d2a74ab98d15c743e17692c5f3907c37aee96a12afd7f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page