parafac2 1.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: parafac2
3
+ Version: 1.6.0
4
+ Summary: An implementation of PARAFAC2 that handles sparsity for single cell data.
5
+ Keywords: parafac2,tensor decomposition,single-cell,anndata
6
+ Author: Aaron Meyer
7
+ Author-email: Aaron Meyer <git@asmlab.org>
8
+ License-Expression: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
14
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
15
+ Requires-Dist: numpy>=2.2
16
+ Requires-Dist: scipy>=1.18
17
+ Requires-Dist: tensorly>=0.8.1
18
+ Requires-Dist: tqdm>=4.68
19
+ Requires-Dist: anndata>=0.12
20
+ Requires-Dist: mlx ; platform_machine == 'arm64' and sys_platform == 'darwin' and extra == 'gpu'
21
+ Requires-Dist: cupy-cuda12x[ctk] ; sys_platform != 'darwin' and extra == 'gpu'
22
+ Requires-Dist: sparse-dot-mkl>=0.9 ; platform_machine == 'x86_64' and extra == 'mkl'
23
+ Requires-Python: >=3.13
24
+ Project-URL: Homepage, https://github.com/meyer-lab/parafac2
25
+ Project-URL: Documentation, https://meyer-lab.github.io/parafac2/
26
+ Project-URL: Repository, https://github.com/meyer-lab/parafac2
27
+ Project-URL: Issues, https://github.com/meyer-lab/parafac2/issues
28
+ Provides-Extra: gpu
29
+ Provides-Extra: mkl
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Integrative, high-resolution analysis of single cells across experimental conditions with PARAFAC2
33
+
34
+ `parafac2` contains the code for the PARAFAC2 (Pf2) python package, a tensor decomposition technique, used in our study for identifying variation patterns in single-cell populations across conditions. In our [study](https://www.biorxiv.org/content/10.1101/2024.07.29.605698v1.article-info), we discovered association patterns to specific cell populations, genes, and experimental conditions in both a drug perturbational study and systemic lupus erythematosus cohort study.
35
+
36
+ Full package documentation is available at [meyer-lab.github.io/parafac2](https://meyer-lab.github.io/parafac2/).
37
+
38
+ ## Installation
39
+ To install `parafac2` with standard CPU support:
40
+ ```bash
41
+ pip install parafac2
42
+ ```
43
+
44
+ ### Hardware Acceleration (`[gpu]` extra)
45
+ `parafac2` supports hardware acceleration (`mlx` on Apple Silicon and `cupy` on Linux/Windows) via a single `gpu` extra:
46
+
47
+ ```bash
48
+ pip install "parafac2[gpu]"
49
+ ```
50
+
51
+ Or with `uv`:
52
+ ```bash
53
+ uv sync --extra gpu
54
+ ```
55
+
56
+ Environment markers automatically select `mlx` when on macOS Apple Silicon, and `cupy` on other platforms. If no GPU backend is installed, `parafac2` falls back to CPU computation seamlessly.
57
+
58
+ ## Input Requirements
59
+ 1. Your AnnData object must include an observations `column condition_unique_idxs` that is a 0-indexed array of which condition each cell is derived from along with the cell barcode
60
+ Preprocessing your data
61
+ 2. Your AnnData object must be preprocessed (removed doublets, normalized, log transformed) before running the algorithm
62
+ 3. The function `parafac2_nd` is the Pf2 algorithm with various parameters that can be altered such as rank, tolerance, etc.
63
+
64
+ ## Outputs
65
+ The output of `parafac2_nd` is the first AnnData object and the reconstruction error (R2X). The results of `parafac2_nd` are added to the AnnData object. These include:
66
+ 1. The weights for each component `X.uns["Pf2_weights"]`
67
+ 2. The factors with respect to each dimension in the data where `X.uns[“Pf2_A”]` is the condition factors, `X.uns[“Pf2_B”]` is the eigen-state factors, and `X.varm[“Pf2_C”]` is the genes, where the width of the matrix is the rank used for the algorithm
68
+ 3. Each cell will have the corresponding values for the projections, `X.obsm["projections"]`, where the width of the matrix is the rank used for the algorithm
69
+ 4. In addition, each cell has the corresponding weighted projections for each cell in the `X.obsm["weighted_projections"]` for all components, to determine how each cell related to each component pattern, where the width of the matrix is the rank used for the algorithm
70
+ 5. We recommend implementing an embedding algorithm such as PaCMAP or UMAP on the `X.obsm["projections"]` to visualize cell-to-cell heterogeneity, creating a new columns coined `X.obsm["embedding"]` for example
71
+
72
+ ## Examples
73
+ You can find example scripts that load single-cell scRNA-seq data across conditions, implement Pf2, and various ways to interpret and plot Pf2 on Github via the [RISE repository](https://github.com/meyer-lab/RISE) (Basic familiarity with the python programming languages is recommended to navigate repository).
@@ -0,0 +1,42 @@
1
+ # Integrative, high-resolution analysis of single cells across experimental conditions with PARAFAC2
2
+
3
+ `parafac2` contains the code for the PARAFAC2 (Pf2) python package, a tensor decomposition technique, used in our study for identifying variation patterns in single-cell populations across conditions. In our [study](https://www.biorxiv.org/content/10.1101/2024.07.29.605698v1.article-info), we discovered association patterns to specific cell populations, genes, and experimental conditions in both a drug perturbational study and systemic lupus erythematosus cohort study.
4
+
5
+ Full package documentation is available at [meyer-lab.github.io/parafac2](https://meyer-lab.github.io/parafac2/).
6
+
7
+ ## Installation
8
+ To install `parafac2` with standard CPU support:
9
+ ```bash
10
+ pip install parafac2
11
+ ```
12
+
13
+ ### Hardware Acceleration (`[gpu]` extra)
14
+ `parafac2` supports hardware acceleration (`mlx` on Apple Silicon and `cupy` on Linux/Windows) via a single `gpu` extra:
15
+
16
+ ```bash
17
+ pip install "parafac2[gpu]"
18
+ ```
19
+
20
+ Or with `uv`:
21
+ ```bash
22
+ uv sync --extra gpu
23
+ ```
24
+
25
+ Environment markers automatically select `mlx` when on macOS Apple Silicon, and `cupy` on other platforms. If no GPU backend is installed, `parafac2` falls back to CPU computation seamlessly.
26
+
27
+ ## Input Requirements
28
+ 1. Your AnnData object must include an observations `column condition_unique_idxs` that is a 0-indexed array of which condition each cell is derived from along with the cell barcode
29
+ Preprocessing your data
30
+ 2. Your AnnData object must be preprocessed (removed doublets, normalized, log transformed) before running the algorithm
31
+ 3. The function `parafac2_nd` is the Pf2 algorithm with various parameters that can be altered such as rank, tolerance, etc.
32
+
33
+ ## Outputs
34
+ The output of `parafac2_nd` is the first AnnData object and the reconstruction error (R2X). The results of `parafac2_nd` are added to the AnnData object. These include:
35
+ 1. The weights for each component `X.uns["Pf2_weights"]`
36
+ 2. The factors with respect to each dimension in the data where `X.uns[“Pf2_A”]` is the condition factors, `X.uns[“Pf2_B”]` is the eigen-state factors, and `X.varm[“Pf2_C”]` is the genes, where the width of the matrix is the rank used for the algorithm
37
+ 3. Each cell will have the corresponding values for the projections, `X.obsm["projections"]`, where the width of the matrix is the rank used for the algorithm
38
+ 4. In addition, each cell has the corresponding weighted projections for each cell in the `X.obsm["weighted_projections"]` for all components, to determine how each cell related to each component pattern, where the width of the matrix is the rank used for the algorithm
39
+ 5. We recommend implementing an embedding algorithm such as PaCMAP or UMAP on the `X.obsm["projections"]` to visualize cell-to-cell heterogeneity, creating a new columns coined `X.obsm["embedding"]` for example
40
+
41
+ ## Examples
42
+ You can find example scripts that load single-cell scRNA-seq data across conditions, implement Pf2, and various ways to interpret and plot Pf2 on Github via the [RISE repository](https://github.com/meyer-lab/RISE) (Basic familiarity with the python programming languages is recommended to navigate repository).
@@ -0,0 +1,20 @@
1
+ """
2
+ Main exports.
3
+ """
4
+
5
+ from .backend import GPUMatrix, get_backend, to_gpu
6
+ from .compress import CompressedData, compress_dataset
7
+ from .normalize import prepare_dataset
8
+ from .parafac2 import parafac2_init, parafac2_nd, store_pf2
9
+
10
+ __all__ = [
11
+ "CompressedData",
12
+ "GPUMatrix",
13
+ "compress_dataset",
14
+ "get_backend",
15
+ "parafac2_init",
16
+ "parafac2_nd",
17
+ "prepare_dataset",
18
+ "store_pf2",
19
+ "to_gpu",
20
+ ]