Skip to main content

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,
		labels=design_matrix_dataframe)

See the documentation for more details and examples.

Metadata

Release files for pyplsc 0.0.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyplsc 0.0.36
File Size Uploaded
pyplsc-0.0.36.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyplsc 0.0.36
File Interpreter ABI Platform
pyplsc-0.0.36-py3-none-any.whl Python 3 none any Details

Total release size: 43.3 kB

Release files / pyplsc-0.0.36.tar.gz

Download URL pyplsc-0.0.36.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d16b551a1536b158364bea6a9d3703a35866d8a37af0806b6bdad3e11fd6d997
BLAKE2b-256 checksum
How to use checksums
1f13fb78b19ec939c83d30cf84208cdbc4403a6458101bb36d19ad5341fca33c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pyplsc-0.0.36-py3-none-any.whl

Download URL pyplsc-0.0.36-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ccb965cb6c81b9541173a167d121da0aceaeb679023f57e97668336a60ccb48
BLAKE2b-256 checksum
How to use checksums
ee64053a3d4d39b3526ecc4a45e291e0d00cb872adf83d47dc0e9e43d4ff4706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.0.40

2 release files

0.0.39

2 release files

0.0.37

2 release files

This release

0.0.36 This release

2 release files

0.0.33

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.27

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.18

2 release files

0.0.15

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page