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

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.37
File Size Uploaded
pyplsc-0.0.37.tar.gz 24.4 kB Details

Built distribution (wheel)

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

Total release size: 45.9 kB

Release files / pyplsc-0.0.37.tar.gz

Download URL pyplsc-0.0.37.tar.gz
Size 24.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fed21e20a8ac7478faa04a02f790f97d33d1a77a75081c3c6d6d973266053f50
BLAKE2b-256 checksum
How to use checksums
9f5c266126a9ebb0466df27d431f0176d8b1eb3bc503a24048d68cac917f3ed9
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.37-py3-none-any.whl

Download URL pyplsc-0.0.37-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28bbf06b4710f97681f5e1d124282d401484b89d0bfb773886a243728e3f675b
BLAKE2b-256 checksum
How to use checksums
fc30eed8d3295fefc3377663826d4bcbb20ac4851966887a742e2b06b5c0a3b1
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

This release

0.0.37 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