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.40

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.40
File Size Uploaded
pyplsc-0.0.40.tar.gz 24.6 kB Details

Built distribution (wheel)

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

Total release size: 46.5 kB

Release files / pyplsc-0.0.40.tar.gz

Download URL pyplsc-0.0.40.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16decd211c299ade839045474e0ef52cf46c04fccf12da23dc61b9f79b9de277
BLAKE2b-256 checksum
How to use checksums
dd1b2eecd2ffc1e05933c77a6a476dd8316d2ca186239661ab4913da5d541a65
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.40-py3-none-any.whl

Download URL pyplsc-0.0.40-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aaa3b8cfb91bf0a2e787abe991512289df0e09a8fda4c5bbebf60c95046026a2
BLAKE2b-256 checksum
How to use checksums
682621a254de1c63f6b1c83dbd790daf4e72350bf848ae1c27d9b53ecef9b61a
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

This release

0.0.40 This release

2 release files

0.0.39

2 release files

0.0.37

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