biPCA 1.1.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.
Files changed (122) hide show
  1. bipca-1.1.0/.gitignore +6 -0
  2. bipca-1.1.0/LICENSE +29 -0
  3. bipca-1.1.0/PKG-INFO +147 -0
  4. bipca-1.1.0/README.rst +97 -0
  5. bipca-1.1.0/biPCA.egg-info/PKG-INFO +147 -0
  6. bipca-1.1.0/biPCA.egg-info/SOURCES.txt +120 -0
  7. bipca-1.1.0/biPCA.egg-info/dependency_links.txt +1 -0
  8. bipca-1.1.0/biPCA.egg-info/entry_points.txt +3 -0
  9. bipca-1.1.0/biPCA.egg-info/requires.txt +26 -0
  10. bipca-1.1.0/biPCA.egg-info/top_level.txt +1 -0
  11. bipca-1.1.0/bipca/__init__.py +10 -0
  12. bipca-1.1.0/bipca/_vendor/__init__.py +0 -0
  13. bipca-1.1.0/bipca/_vendor/pyalra/LICENSE +28 -0
  14. bipca-1.1.0/bipca/_vendor/pyalra/__init__.py +21 -0
  15. bipca-1.1.0/bipca/_vendor/pyalra/alra.py +94 -0
  16. bipca-1.1.0/bipca/_vendor/pyalra/choose_k.py +28 -0
  17. bipca-1.1.0/bipca/_vendor/pyalra/logging.py +48 -0
  18. bipca-1.1.0/bipca/_vendor/pychebfun/LICENSE +11 -0
  19. bipca-1.1.0/bipca/_vendor/pychebfun/__init__.py +11 -0
  20. bipca-1.1.0/bipca/_vendor/pychebfun/chebfun.py +335 -0
  21. bipca-1.1.0/bipca/_vendor/pychebfun/chebfun_init.py +50 -0
  22. bipca-1.1.0/bipca/_vendor/pychebfun/plotting.py +180 -0
  23. bipca-1.1.0/bipca/_vendor/pychebfun/polyfun.py +415 -0
  24. bipca-1.1.0/bipca/base.py +469 -0
  25. bipca-1.1.0/bipca/bipca.py +1818 -0
  26. bipca-1.1.0/bipca/bipca.py.save +1329 -0
  27. bipca-1.1.0/bipca/command_line.py +218 -0
  28. bipca-1.1.0/bipca/data_examples.py +607 -0
  29. bipca-1.1.0/bipca/experiments/__init__.py +2 -0
  30. bipca-1.1.0/bipca/experiments/base.py +3 -0
  31. bipca-1.1.0/bipca/experiments/datasets/__init__.py +1 -0
  32. bipca-1.1.0/bipca/experiments/datasets/allcools_preprocess.sh +11 -0
  33. bipca-1.1.0/bipca/experiments/datasets/base.py +1471 -0
  34. bipca-1.1.0/bipca/experiments/datasets/datasets.py +2608 -0
  35. bipca-1.1.0/bipca/experiments/datasets/modalities.py +663 -0
  36. bipca-1.1.0/bipca/experiments/datasets/plink_preprocess.sh +6 -0
  37. bipca-1.1.0/bipca/experiments/datasets/utils.py +162 -0
  38. bipca-1.1.0/bipca/experiments/exceptions.py +25 -0
  39. bipca-1.1.0/bipca/experiments/experiments.py +809 -0
  40. bipca-1.1.0/bipca/experiments/figures/Figure1_Suppfig1.ipynb +42695 -0
  41. bipca-1.1.0/bipca/experiments/figures/__init__.py +1 -0
  42. bipca-1.1.0/bipca/experiments/figures/base.py +614 -0
  43. bipca-1.1.0/bipca/experiments/figures/figures.py +7436 -0
  44. bipca-1.1.0/bipca/experiments/figures/plotting_constants.py +114 -0
  45. bipca-1.1.0/bipca/experiments/figures/utils.py +264 -0
  46. bipca-1.1.0/bipca/experiments/normalizations.py +284 -0
  47. bipca-1.1.0/bipca/experiments/types.py +5 -0
  48. bipca-1.1.0/bipca/experiments/utils.py +358 -0
  49. bipca-1.1.0/bipca/math.py +3845 -0
  50. bipca-1.1.0/bipca/plotting.py +1395 -0
  51. bipca-1.1.0/bipca/safe_basics.py +555 -0
  52. bipca-1.1.0/bipca/utils.py +1350 -0
  53. bipca-1.1.0/doc/Makefile +20 -0
  54. bipca-1.1.0/doc/_static/numpy.css +40 -0
  55. bipca-1.1.0/doc/_templates/autosummary/attribute.rst +13 -0
  56. bipca-1.1.0/doc/_templates/autosummary/base.rst +17 -0
  57. bipca-1.1.0/doc/_templates/autosummary/class.rst +27 -0
  58. bipca-1.1.0/doc/_templates/autosummary/member.rst +13 -0
  59. bipca-1.1.0/doc/_templates/autosummary/method.rst +17 -0
  60. bipca-1.1.0/doc/_templates/autosummary/minimal_module.rst +8 -0
  61. bipca-1.1.0/doc/_templates/autosummary/module.rst +40 -0
  62. bipca-1.1.0/doc/_templates/indexcontent.html +75 -0
  63. bipca-1.1.0/doc/_templates/indexsidebar.html +5 -0
  64. bipca-1.1.0/doc/_templates/layout.html +10 -0
  65. bipca-1.1.0/doc/_templates/searchbox.html +23 -0
  66. bipca-1.1.0/doc/conf.py +201 -0
  67. bipca-1.1.0/doc/index.rst +12 -0
  68. bipca-1.1.0/doc/make.bat +35 -0
  69. bipca-1.1.0/doc/reference/bipca.rst +0 -0
  70. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.PCA.rst +15 -0
  71. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.S.rst +15 -0
  72. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.U.rst +15 -0
  73. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.V.rst +15 -0
  74. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.algorithm.rst +15 -0
  75. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.exact.rst +15 -0
  76. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.fit.rst +15 -0
  77. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.fit_transform.rst +15 -0
  78. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.get_params.rst +15 -0
  79. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.k.rst +15 -0
  80. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.kwargs.rst +15 -0
  81. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.n_components.rst +15 -0
  82. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.rst +43 -0
  83. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.set_params.rst +15 -0
  84. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.svd.rst +15 -0
  85. bipca-1.1.0/doc/reference/generated/bipca.math.SVD.transform.rst +15 -0
  86. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.fit.rst +15 -0
  87. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.fit_transform.rst +15 -0
  88. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.frobenius.rst +15 -0
  89. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.get_params.rst +15 -0
  90. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.hard.rst +15 -0
  91. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.nuclear.rst +15 -0
  92. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.operator.rst +15 -0
  93. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.rst +47 -0
  94. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.set_params.rst +15 -0
  95. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.soft.rst +15 -0
  96. bipca-1.1.0/doc/reference/generated/bipca.math.Shrinker.transform.rst +15 -0
  97. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.Z.rst +15 -0
  98. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.fit.rst +15 -0
  99. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.fit_transform.rst +15 -0
  100. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.get_params.rst +15 -0
  101. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.rst +42 -0
  102. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.scale.rst +15 -0
  103. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.set_params.rst +15 -0
  104. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.transform.rst +15 -0
  105. bipca-1.1.0/doc/reference/generated/bipca.math.Sinkhorn.unscale.rst +15 -0
  106. bipca-1.1.0/doc/reference/index.rst +17 -0
  107. bipca-1.1.0/doc/reference/math.rst +30 -0
  108. bipca-1.1.0/experiments-requirements.txt +12 -0
  109. bipca-1.1.0/pyproject.toml +48 -0
  110. bipca-1.1.0/requirements.txt +12 -0
  111. bipca-1.1.0/setup.cfg +4 -0
  112. bipca-1.1.0/tests/speedtest.py +179 -0
  113. bipca-1.1.0/tests/test_bipca.py +144 -0
  114. bipca-1.1.0/tests/test_command_line.py +54 -0
  115. bipca-1.1.0/tests/test_data/__init__.py +28 -0
  116. bipca-1.1.0/tests/test_experiments.py +33 -0
  117. bipca-1.1.0/tests/test_math.py +327 -0
  118. bipca-1.1.0/tests/test_utils.py +454 -0
  119. bipca-1.1.0/tests/testing_utils.py +21 -0
  120. bipca-1.1.0/tutorials/Figure1.png +0 -0
  121. bipca-1.1.0/tutorials/tutorial-0-quick_start.ipynb +386 -0
  122. bipca-1.1.0/tutorials/tutorial-1-pbmc_scrna_scanpy.ipynb +572 -0
bipca-1.1.0/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.ipynb*
2
+ *.egg-info
3
+ */_build/
4
+ *_version.py
5
+ *__pycache__*
6
+ *.DS_store*
bipca-1.1.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023 Jay S. Stanley III, Kluger Lab
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bipca-1.1.0/PKG-INFO ADDED
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: biPCA
3
+ Version: 1.1.0
4
+ Summary: Biwhitened Principal Components Analysis
5
+ Author: Ruiqi Li, Ofir Lindenbaum, Dmitry Kobak, Boris Landa, Yuval Kluger
6
+ Author-email: "Jay S. Stanley III" <jay.s.stanley.3@gmail.com>, Junchen Yang <junchen.yang@yale.edu>
7
+ License-Expression: BSD-3-Clause
8
+ Keywords: PCA,biwhitening,whitening,dimensionality reduction,machine learning,data science,denoising,linear algebra
9
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
10
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Framework :: Jupyter
14
+ Classifier: Environment :: Console
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Operating System :: MacOS :: MacOS X
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Development Status :: 4 - Beta
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ Requires-Dist: scipy>=1.5.2
25
+ Requires-Dist: tasklogger>=1.0.0
26
+ Requires-Dist: pandas>=1.1.3
27
+ Requires-Dist: numpy
28
+ Requires-Dist: anndata>=0.7.5
29
+ Requires-Dist: torch>=1.12
30
+ Requires-Dist: matplotlib>=3.6.0
31
+ Requires-Dist: scikit_learn>=0.24.2
32
+ Requires-Dist: threadpoolctl
33
+ Requires-Dist: typing_extensions
34
+ Requires-Dist: typeguard
35
+ Requires-Dist: loguru>=0.7.2
36
+ Provides-Extra: experiments
37
+ Requires-Dist: openTSNE; extra == "experiments"
38
+ Requires-Dist: requests; extra == "experiments"
39
+ Requires-Dist: ALLCools; extra == "experiments"
40
+ Requires-Dist: dask; extra == "experiments"
41
+ Requires-Dist: pyarrow; extra == "experiments"
42
+ Requires-Dist: biomart; extra == "experiments"
43
+ Requires-Dist: pandas-plink; extra == "experiments"
44
+ Requires-Dist: pyreadr; extra == "experiments"
45
+ Requires-Dist: imageio; extra == "experiments"
46
+ Requires-Dist: openpyxl; extra == "experiments"
47
+ Requires-Dist: scanpy; extra == "experiments"
48
+ Requires-Dist: muon; extra == "experiments"
49
+ Dynamic: license-file
50
+
51
+ Biwhitened Principal Component Analysis (BiPCA)
52
+ ===============================================
53
+
54
+ BiPCA is a Python package for processing high-dimensional omics count data, such as
55
+ scRNAseq, spatial transcriptomics, scATAC-seq, and many others.
56
+ BiPCA first scales the rows and columns of the data to make the noise approximately
57
+ homoscedastic (biwhitening step), which reveals the underlying rank of the data
58
+ (based on MP distribution). Then, BiPCA performs optimal shrinkage of singular
59
+ values to recover the biological signal (denoising step).
60
+
61
+ Installation
62
+ ------------
63
+
64
+ Pip installation
65
+ ~~~~~~~~~~~~~~~~
66
+
67
+ You can install BiPCA from PyPI:
68
+
69
+ .. code-block:: bash
70
+
71
+ pip install biPCA
72
+
73
+ To install with optional experiment dependencies:
74
+
75
+ .. code-block:: bash
76
+
77
+ pip install biPCA[experiments]
78
+
79
+ Alternatively, to install from source:
80
+
81
+ .. code-block:: bash
82
+
83
+ pip install 'git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
84
+
85
+ Or from source with experiment dependencies:
86
+
87
+ .. code-block:: bash
88
+
89
+ pip install 'biPCA[experiments] @ git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
90
+
91
+ Docker installation
92
+ ~~~~~~~~~~~~~~~~~~~
93
+
94
+ Alternatively, we recommend installing BiPCA with the accompanied
95
+ ``bipca-experiment`` Docker environment. This image reproduces the environment
96
+ we used to make the BiPCA manuscript. The pre-built docker image can be downloaded using:
97
+
98
+ .. code-block:: bash
99
+
100
+ docker pull jyc34/bipca-experiment:lastest
101
+
102
+ and to run the Docker container:
103
+
104
+ .. code-block:: bash
105
+
106
+ docker run -it --rm -e USER=john -e USERID=$(id -u) --name bipca -p 8080:8080 -p 8029:8787 \
107
+ -v /data/:/data/ docker.io/jyc34/bipca-experiment:lastest /bin/bash
108
+
109
+ Here, change ``/data/:/data`` to ``<your_local_data_directory>:/data``.
110
+ A JupyterLab will be launched on host port 8080 and an RStudio will be on port 8029.
111
+ If you would like to link a local bipca installation (for package development, for instance),
112
+ you can use ``-v <your_local_bipca_directory>:/bipca``.
113
+
114
+ See detailed `descriptions <https://github.com/KlugerLab/bipca-experiment>`_ regarding
115
+ the Docker image usage and information on the corresponding Dockerfile.
116
+
117
+ Getting Started
118
+ ---------------
119
+
120
+ - Running BiPCA with a built-in dataset:
121
+ `tutorial-0-quick_start.ipynb <tutorials/tutorial-0-quick_start.ipynb>`_
122
+
123
+ - Running BiPCA with an unfiltered dataset from scanpy:
124
+ `tutorial-1-pbmc_scrna_scanpy.ipynb <tutorials/tutorial-1-pbmc_scrna_scanpy.ipynb>`_
125
+
126
+ Reproducing figures
127
+ -------------------
128
+
129
+ Codes for generating the figures used in the manuscript are documented as individual
130
+ functions in `figure.py <bipca/experiments/figures/figures.py>`_. For example, run
131
+ the following to reproduce the marker gene figure:
132
+
133
+ .. code-block:: python
134
+
135
+ from bipca.experiments.figures import Figure_marker_genes
136
+ fig_obj = Figure_marker_genes(base_plot_directory="./result/",
137
+ output_dir="./data/",
138
+ formatstr="png")
139
+ fig_obj.plot_figure(save=True)
140
+
141
+ `Figure1_Suppfig1.ipynb <bipca/experiments/figures/Figure1_Suppfig1.ipynb>`_ regenerates
142
+ Fig1 and Supplemental Fig1 used in the manuscript.
143
+
144
+ Reference
145
+ ---------
146
+
147
+ *If you use BiPCA for your research, please cite accordingly.*
bipca-1.1.0/README.rst ADDED
@@ -0,0 +1,97 @@
1
+ Biwhitened Principal Component Analysis (BiPCA)
2
+ ===============================================
3
+
4
+ BiPCA is a Python package for processing high-dimensional omics count data, such as
5
+ scRNAseq, spatial transcriptomics, scATAC-seq, and many others.
6
+ BiPCA first scales the rows and columns of the data to make the noise approximately
7
+ homoscedastic (biwhitening step), which reveals the underlying rank of the data
8
+ (based on MP distribution). Then, BiPCA performs optimal shrinkage of singular
9
+ values to recover the biological signal (denoising step).
10
+
11
+ Installation
12
+ ------------
13
+
14
+ Pip installation
15
+ ~~~~~~~~~~~~~~~~
16
+
17
+ You can install BiPCA from PyPI:
18
+
19
+ .. code-block:: bash
20
+
21
+ pip install biPCA
22
+
23
+ To install with optional experiment dependencies:
24
+
25
+ .. code-block:: bash
26
+
27
+ pip install biPCA[experiments]
28
+
29
+ Alternatively, to install from source:
30
+
31
+ .. code-block:: bash
32
+
33
+ pip install 'git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
34
+
35
+ Or from source with experiment dependencies:
36
+
37
+ .. code-block:: bash
38
+
39
+ pip install 'biPCA[experiments] @ git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
40
+
41
+ Docker installation
42
+ ~~~~~~~~~~~~~~~~~~~
43
+
44
+ Alternatively, we recommend installing BiPCA with the accompanied
45
+ ``bipca-experiment`` Docker environment. This image reproduces the environment
46
+ we used to make the BiPCA manuscript. The pre-built docker image can be downloaded using:
47
+
48
+ .. code-block:: bash
49
+
50
+ docker pull jyc34/bipca-experiment:lastest
51
+
52
+ and to run the Docker container:
53
+
54
+ .. code-block:: bash
55
+
56
+ docker run -it --rm -e USER=john -e USERID=$(id -u) --name bipca -p 8080:8080 -p 8029:8787 \
57
+ -v /data/:/data/ docker.io/jyc34/bipca-experiment:lastest /bin/bash
58
+
59
+ Here, change ``/data/:/data`` to ``<your_local_data_directory>:/data``.
60
+ A JupyterLab will be launched on host port 8080 and an RStudio will be on port 8029.
61
+ If you would like to link a local bipca installation (for package development, for instance),
62
+ you can use ``-v <your_local_bipca_directory>:/bipca``.
63
+
64
+ See detailed `descriptions <https://github.com/KlugerLab/bipca-experiment>`_ regarding
65
+ the Docker image usage and information on the corresponding Dockerfile.
66
+
67
+ Getting Started
68
+ ---------------
69
+
70
+ - Running BiPCA with a built-in dataset:
71
+ `tutorial-0-quick_start.ipynb <tutorials/tutorial-0-quick_start.ipynb>`_
72
+
73
+ - Running BiPCA with an unfiltered dataset from scanpy:
74
+ `tutorial-1-pbmc_scrna_scanpy.ipynb <tutorials/tutorial-1-pbmc_scrna_scanpy.ipynb>`_
75
+
76
+ Reproducing figures
77
+ -------------------
78
+
79
+ Codes for generating the figures used in the manuscript are documented as individual
80
+ functions in `figure.py <bipca/experiments/figures/figures.py>`_. For example, run
81
+ the following to reproduce the marker gene figure:
82
+
83
+ .. code-block:: python
84
+
85
+ from bipca.experiments.figures import Figure_marker_genes
86
+ fig_obj = Figure_marker_genes(base_plot_directory="./result/",
87
+ output_dir="./data/",
88
+ formatstr="png")
89
+ fig_obj.plot_figure(save=True)
90
+
91
+ `Figure1_Suppfig1.ipynb <bipca/experiments/figures/Figure1_Suppfig1.ipynb>`_ regenerates
92
+ Fig1 and Supplemental Fig1 used in the manuscript.
93
+
94
+ Reference
95
+ ---------
96
+
97
+ *If you use BiPCA for your research, please cite accordingly.*
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: biPCA
3
+ Version: 1.1.0
4
+ Summary: Biwhitened Principal Components Analysis
5
+ Author: Ruiqi Li, Ofir Lindenbaum, Dmitry Kobak, Boris Landa, Yuval Kluger
6
+ Author-email: "Jay S. Stanley III" <jay.s.stanley.3@gmail.com>, Junchen Yang <junchen.yang@yale.edu>
7
+ License-Expression: BSD-3-Clause
8
+ Keywords: PCA,biwhitening,whitening,dimensionality reduction,machine learning,data science,denoising,linear algebra
9
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
10
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Framework :: Jupyter
14
+ Classifier: Environment :: Console
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Operating System :: MacOS :: MacOS X
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Development Status :: 4 - Beta
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ Requires-Dist: scipy>=1.5.2
25
+ Requires-Dist: tasklogger>=1.0.0
26
+ Requires-Dist: pandas>=1.1.3
27
+ Requires-Dist: numpy
28
+ Requires-Dist: anndata>=0.7.5
29
+ Requires-Dist: torch>=1.12
30
+ Requires-Dist: matplotlib>=3.6.0
31
+ Requires-Dist: scikit_learn>=0.24.2
32
+ Requires-Dist: threadpoolctl
33
+ Requires-Dist: typing_extensions
34
+ Requires-Dist: typeguard
35
+ Requires-Dist: loguru>=0.7.2
36
+ Provides-Extra: experiments
37
+ Requires-Dist: openTSNE; extra == "experiments"
38
+ Requires-Dist: requests; extra == "experiments"
39
+ Requires-Dist: ALLCools; extra == "experiments"
40
+ Requires-Dist: dask; extra == "experiments"
41
+ Requires-Dist: pyarrow; extra == "experiments"
42
+ Requires-Dist: biomart; extra == "experiments"
43
+ Requires-Dist: pandas-plink; extra == "experiments"
44
+ Requires-Dist: pyreadr; extra == "experiments"
45
+ Requires-Dist: imageio; extra == "experiments"
46
+ Requires-Dist: openpyxl; extra == "experiments"
47
+ Requires-Dist: scanpy; extra == "experiments"
48
+ Requires-Dist: muon; extra == "experiments"
49
+ Dynamic: license-file
50
+
51
+ Biwhitened Principal Component Analysis (BiPCA)
52
+ ===============================================
53
+
54
+ BiPCA is a Python package for processing high-dimensional omics count data, such as
55
+ scRNAseq, spatial transcriptomics, scATAC-seq, and many others.
56
+ BiPCA first scales the rows and columns of the data to make the noise approximately
57
+ homoscedastic (biwhitening step), which reveals the underlying rank of the data
58
+ (based on MP distribution). Then, BiPCA performs optimal shrinkage of singular
59
+ values to recover the biological signal (denoising step).
60
+
61
+ Installation
62
+ ------------
63
+
64
+ Pip installation
65
+ ~~~~~~~~~~~~~~~~
66
+
67
+ You can install BiPCA from PyPI:
68
+
69
+ .. code-block:: bash
70
+
71
+ pip install biPCA
72
+
73
+ To install with optional experiment dependencies:
74
+
75
+ .. code-block:: bash
76
+
77
+ pip install biPCA[experiments]
78
+
79
+ Alternatively, to install from source:
80
+
81
+ .. code-block:: bash
82
+
83
+ pip install 'git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
84
+
85
+ Or from source with experiment dependencies:
86
+
87
+ .. code-block:: bash
88
+
89
+ pip install 'biPCA[experiments] @ git+https://github.com/KlugerLab/bipca.git#subdirectory=python'
90
+
91
+ Docker installation
92
+ ~~~~~~~~~~~~~~~~~~~
93
+
94
+ Alternatively, we recommend installing BiPCA with the accompanied
95
+ ``bipca-experiment`` Docker environment. This image reproduces the environment
96
+ we used to make the BiPCA manuscript. The pre-built docker image can be downloaded using:
97
+
98
+ .. code-block:: bash
99
+
100
+ docker pull jyc34/bipca-experiment:lastest
101
+
102
+ and to run the Docker container:
103
+
104
+ .. code-block:: bash
105
+
106
+ docker run -it --rm -e USER=john -e USERID=$(id -u) --name bipca -p 8080:8080 -p 8029:8787 \
107
+ -v /data/:/data/ docker.io/jyc34/bipca-experiment:lastest /bin/bash
108
+
109
+ Here, change ``/data/:/data`` to ``<your_local_data_directory>:/data``.
110
+ A JupyterLab will be launched on host port 8080 and an RStudio will be on port 8029.
111
+ If you would like to link a local bipca installation (for package development, for instance),
112
+ you can use ``-v <your_local_bipca_directory>:/bipca``.
113
+
114
+ See detailed `descriptions <https://github.com/KlugerLab/bipca-experiment>`_ regarding
115
+ the Docker image usage and information on the corresponding Dockerfile.
116
+
117
+ Getting Started
118
+ ---------------
119
+
120
+ - Running BiPCA with a built-in dataset:
121
+ `tutorial-0-quick_start.ipynb <tutorials/tutorial-0-quick_start.ipynb>`_
122
+
123
+ - Running BiPCA with an unfiltered dataset from scanpy:
124
+ `tutorial-1-pbmc_scrna_scanpy.ipynb <tutorials/tutorial-1-pbmc_scrna_scanpy.ipynb>`_
125
+
126
+ Reproducing figures
127
+ -------------------
128
+
129
+ Codes for generating the figures used in the manuscript are documented as individual
130
+ functions in `figure.py <bipca/experiments/figures/figures.py>`_. For example, run
131
+ the following to reproduce the marker gene figure:
132
+
133
+ .. code-block:: python
134
+
135
+ from bipca.experiments.figures import Figure_marker_genes
136
+ fig_obj = Figure_marker_genes(base_plot_directory="./result/",
137
+ output_dir="./data/",
138
+ formatstr="png")
139
+ fig_obj.plot_figure(save=True)
140
+
141
+ `Figure1_Suppfig1.ipynb <bipca/experiments/figures/Figure1_Suppfig1.ipynb>`_ regenerates
142
+ Fig1 and Supplemental Fig1 used in the manuscript.
143
+
144
+ Reference
145
+ ---------
146
+
147
+ *If you use BiPCA for your research, please cite accordingly.*
@@ -0,0 +1,120 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.rst
4
+ experiments-requirements.txt
5
+ pyproject.toml
6
+ requirements.txt
7
+ biPCA.egg-info/PKG-INFO
8
+ biPCA.egg-info/SOURCES.txt
9
+ biPCA.egg-info/dependency_links.txt
10
+ biPCA.egg-info/entry_points.txt
11
+ biPCA.egg-info/requires.txt
12
+ biPCA.egg-info/top_level.txt
13
+ bipca/__init__.py
14
+ bipca/base.py
15
+ bipca/bipca.py
16
+ bipca/bipca.py.save
17
+ bipca/command_line.py
18
+ bipca/data_examples.py
19
+ bipca/math.py
20
+ bipca/plotting.py
21
+ bipca/safe_basics.py
22
+ bipca/utils.py
23
+ bipca/_vendor/__init__.py
24
+ bipca/_vendor/pyalra/LICENSE
25
+ bipca/_vendor/pyalra/__init__.py
26
+ bipca/_vendor/pyalra/alra.py
27
+ bipca/_vendor/pyalra/choose_k.py
28
+ bipca/_vendor/pyalra/logging.py
29
+ bipca/_vendor/pychebfun/LICENSE
30
+ bipca/_vendor/pychebfun/__init__.py
31
+ bipca/_vendor/pychebfun/chebfun.py
32
+ bipca/_vendor/pychebfun/chebfun_init.py
33
+ bipca/_vendor/pychebfun/plotting.py
34
+ bipca/_vendor/pychebfun/polyfun.py
35
+ bipca/experiments/__init__.py
36
+ bipca/experiments/base.py
37
+ bipca/experiments/exceptions.py
38
+ bipca/experiments/experiments.py
39
+ bipca/experiments/normalizations.py
40
+ bipca/experiments/types.py
41
+ bipca/experiments/utils.py
42
+ bipca/experiments/datasets/__init__.py
43
+ bipca/experiments/datasets/allcools_preprocess.sh
44
+ bipca/experiments/datasets/base.py
45
+ bipca/experiments/datasets/datasets.py
46
+ bipca/experiments/datasets/modalities.py
47
+ bipca/experiments/datasets/plink_preprocess.sh
48
+ bipca/experiments/datasets/utils.py
49
+ bipca/experiments/figures/Figure1_Suppfig1.ipynb
50
+ bipca/experiments/figures/__init__.py
51
+ bipca/experiments/figures/base.py
52
+ bipca/experiments/figures/figures.py
53
+ bipca/experiments/figures/plotting_constants.py
54
+ bipca/experiments/figures/utils.py
55
+ doc/Makefile
56
+ doc/conf.py
57
+ doc/index.rst
58
+ doc/make.bat
59
+ doc/_static/numpy.css
60
+ doc/_templates/indexcontent.html
61
+ doc/_templates/indexsidebar.html
62
+ doc/_templates/layout.html
63
+ doc/_templates/searchbox.html
64
+ doc/_templates/autosummary/attribute.rst
65
+ doc/_templates/autosummary/base.rst
66
+ doc/_templates/autosummary/class.rst
67
+ doc/_templates/autosummary/member.rst
68
+ doc/_templates/autosummary/method.rst
69
+ doc/_templates/autosummary/minimal_module.rst
70
+ doc/_templates/autosummary/module.rst
71
+ doc/reference/bipca.rst
72
+ doc/reference/index.rst
73
+ doc/reference/math.rst
74
+ doc/reference/generated/bipca.math.SVD.PCA.rst
75
+ doc/reference/generated/bipca.math.SVD.S.rst
76
+ doc/reference/generated/bipca.math.SVD.U.rst
77
+ doc/reference/generated/bipca.math.SVD.V.rst
78
+ doc/reference/generated/bipca.math.SVD.algorithm.rst
79
+ doc/reference/generated/bipca.math.SVD.exact.rst
80
+ doc/reference/generated/bipca.math.SVD.fit.rst
81
+ doc/reference/generated/bipca.math.SVD.fit_transform.rst
82
+ doc/reference/generated/bipca.math.SVD.get_params.rst
83
+ doc/reference/generated/bipca.math.SVD.k.rst
84
+ doc/reference/generated/bipca.math.SVD.kwargs.rst
85
+ doc/reference/generated/bipca.math.SVD.n_components.rst
86
+ doc/reference/generated/bipca.math.SVD.rst
87
+ doc/reference/generated/bipca.math.SVD.set_params.rst
88
+ doc/reference/generated/bipca.math.SVD.svd.rst
89
+ doc/reference/generated/bipca.math.SVD.transform.rst
90
+ doc/reference/generated/bipca.math.Shrinker.fit.rst
91
+ doc/reference/generated/bipca.math.Shrinker.fit_transform.rst
92
+ doc/reference/generated/bipca.math.Shrinker.frobenius.rst
93
+ doc/reference/generated/bipca.math.Shrinker.get_params.rst
94
+ doc/reference/generated/bipca.math.Shrinker.hard.rst
95
+ doc/reference/generated/bipca.math.Shrinker.nuclear.rst
96
+ doc/reference/generated/bipca.math.Shrinker.operator.rst
97
+ doc/reference/generated/bipca.math.Shrinker.rst
98
+ doc/reference/generated/bipca.math.Shrinker.set_params.rst
99
+ doc/reference/generated/bipca.math.Shrinker.soft.rst
100
+ doc/reference/generated/bipca.math.Shrinker.transform.rst
101
+ doc/reference/generated/bipca.math.Sinkhorn.Z.rst
102
+ doc/reference/generated/bipca.math.Sinkhorn.fit.rst
103
+ doc/reference/generated/bipca.math.Sinkhorn.fit_transform.rst
104
+ doc/reference/generated/bipca.math.Sinkhorn.get_params.rst
105
+ doc/reference/generated/bipca.math.Sinkhorn.rst
106
+ doc/reference/generated/bipca.math.Sinkhorn.scale.rst
107
+ doc/reference/generated/bipca.math.Sinkhorn.set_params.rst
108
+ doc/reference/generated/bipca.math.Sinkhorn.transform.rst
109
+ doc/reference/generated/bipca.math.Sinkhorn.unscale.rst
110
+ tests/speedtest.py
111
+ tests/test_bipca.py
112
+ tests/test_command_line.py
113
+ tests/test_experiments.py
114
+ tests/test_math.py
115
+ tests/test_utils.py
116
+ tests/testing_utils.py
117
+ tests/test_data/__init__.py
118
+ tutorials/Figure1.png
119
+ tutorials/tutorial-0-quick_start.ipynb
120
+ tutorials/tutorial-1-pbmc_scrna_scanpy.ipynb
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ bipca = bipca.command_line:bipca_main
3
+ bipca-plot = bipca.command_line:bipca_plot
@@ -0,0 +1,26 @@
1
+ scipy>=1.5.2
2
+ tasklogger>=1.0.0
3
+ pandas>=1.1.3
4
+ numpy
5
+ anndata>=0.7.5
6
+ torch>=1.12
7
+ matplotlib>=3.6.0
8
+ scikit_learn>=0.24.2
9
+ threadpoolctl
10
+ typing_extensions
11
+ typeguard
12
+ loguru>=0.7.2
13
+
14
+ [experiments]
15
+ openTSNE
16
+ requests
17
+ ALLCools
18
+ dask
19
+ pyarrow
20
+ biomart
21
+ pandas-plink
22
+ pyreadr
23
+ imageio
24
+ openpyxl
25
+ scanpy
26
+ muon
@@ -0,0 +1 @@
1
+ bipca
@@ -0,0 +1,10 @@
1
+ from __future__ import absolute_import
2
+
3
+ from importlib.metadata import version, PackageNotFoundError
4
+
5
+ try:
6
+ __version__ = version("biPCA")
7
+ except PackageNotFoundError:
8
+ __version__ = "unknown"
9
+
10
+ from .bipca import BiPCA
File without changes
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Miles Smith
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,21 @@
1
+ """
2
+ .. module:: pyalra
3
+ :platform: Unix, Windows
4
+ :synopsis: Translation of the ALRA R package
5
+
6
+ .. moduleauthor:: Miles Smith <miles-smith@omrf.org>
7
+
8
+ Vendored from https://github.com/milescsmith/pyalra (v1.6.2)
9
+ License: BSD-3-Clause
10
+ """
11
+
12
+ from loguru import logger
13
+
14
+ from bipca._vendor.pyalra.alra import alra
15
+ from bipca._vendor.pyalra.choose_k import choose_k
16
+
17
+ __version__ = "1.6.2"
18
+
19
+ logger.disable("bipca._vendor.pyalra")
20
+
21
+ __all__ = ["alra", "choose_k"]