comflow 0.0.3__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 (31) hide show
  1. comflow-0.0.3/LICENSE.md +21 -0
  2. comflow-0.0.3/MANIFEST.in +2 -0
  3. comflow-0.0.3/PKG-INFO +82 -0
  4. comflow-0.0.3/README.md +58 -0
  5. comflow-0.0.3/comflow/__init__.py +10 -0
  6. comflow-0.0.3/comflow/_optimal_transport/__init__.py +13 -0
  7. comflow-0.0.3/comflow/_optimal_transport/_cot.py +850 -0
  8. comflow-0.0.3/comflow/_optimal_transport/_cot_preRevise.py +850 -0
  9. comflow-0.0.3/comflow/_optimal_transport/_unot.py +485 -0
  10. comflow-0.0.3/comflow/_optimal_transport/_usot.py +117 -0
  11. comflow-0.0.3/comflow/_utils/__init__.py +20 -0
  12. comflow-0.0.3/comflow/_utils/_binarization.py +43 -0
  13. comflow-0.0.3/comflow/_utils/_clustering.py +57 -0
  14. comflow-0.0.3/comflow/_utils/_plotting.py +398 -0
  15. comflow-0.0.3/comflow/_utils/_similarity.py +479 -0
  16. comflow-0.0.3/comflow/plotting/__init__.py +5 -0
  17. comflow-0.0.3/comflow/plotting/_plotting.py +794 -0
  18. comflow-0.0.3/comflow/preprocessing/__init__.py +3 -0
  19. comflow-0.0.3/comflow/preprocessing/_infer_spatial.py +161 -0
  20. comflow-0.0.3/comflow/preprocessing/_ligand_receptor_database.py +153 -0
  21. comflow-0.0.3/comflow/tools/__init__.py +12 -0
  22. comflow-0.0.3/comflow/tools/_downstream_analysis.py +870 -0
  23. comflow-0.0.3/comflow/tools/_spatial_communication.py +1250 -0
  24. comflow-0.0.3/comflow.egg-info/PKG-INFO +82 -0
  25. comflow-0.0.3/comflow.egg-info/SOURCES.txt +30 -0
  26. comflow-0.0.3/comflow.egg-info/dependency_links.txt +1 -0
  27. comflow-0.0.3/comflow.egg-info/not-zip-safe +1 -0
  28. comflow-0.0.3/comflow.egg-info/requires.txt +35 -0
  29. comflow-0.0.3/comflow.egg-info/top_level.txt +1 -0
  30. comflow-0.0.3/pyproject.toml +2 -0
  31. comflow-0.0.3/setup.cfg +74 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Zixuan Cang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include commot/preprocessing/_data/LRdatabase/CellChat/*.csv
2
+ include commot/preprocessing/_data/LRdatabase/CellPhoneDB_v4.0/*.csv
comflow-0.0.3/PKG-INFO ADDED
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.1
2
+ Name: comflow
3
+ Version: 0.0.3
4
+ Summary: ComFlow: an optimal transport framework for deciphering intra- and intercellular signaling landscapes in 2D and 3D tissue systems.
5
+ Home-page: UNKNOWN
6
+ License: MIT License
7
+ Keywords: cell-cell communicaiton,spatial transcriptomics,optimal transport,intracellular signaling,intercellular signaling
8
+ Platform: UNKNOWN
9
+ Classifier: Programming Language :: Python :: 3.7
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.7
18
+ Description-Content-Type: text/markdown
19
+ Provides-Extra: tradeSeq
20
+ Provides-Extra: docs
21
+ License-File: LICENSE.md
22
+
23
+ # ComFlow
24
+ ComFlow: an optimal transport framework for deciphering intra-
25
+ and intercellular signaling landscapes in 2D and 3D tissue systems
26
+
27
+ [![PyPI](https://img.shields.io/pypi/v/comflow?logo=PyPI)](https://pypi.org/project/comflow)
28
+ ![pytest](https://github.com/zcang/comflow/actions/workflows/python-package.yml/badge.svg)
29
+ [![Read the Docs](https://readthedocs.org/projects/comflow/badge/?version=latest)](https://comflow.readthedocs.io/en/latest/)
30
+
31
+
32
+ ## Installation
33
+ Install from PyPI by `pip install comflow` or install from source by cd to this directory and `pip install .`
34
+
35
+ [Optional] Install [tradeSeq](https://github.com/statOmics/tradeSeq) in R to analyze the CCC differentially expressed genes. \
36
+ Currently, tradeSeq version 1.0.1 with R version 3.6.3 has been tested to work. \
37
+ In order for the R-python interface to work properly, rpy2==3.4.2 and anndata2ri==1.0.6 should be installed.
38
+ To use this feature, install from PyPI by `pip install comflow[tradeSeq]` or from source by `pip install .[tradeSeq]`.
39
+
40
+ ## Usage
41
+ **Basic usage**
42
+
43
+ _Import packages_
44
+ ```
45
+ import comflow as ct
46
+ import scanpy as sc
47
+ import pandas as pd
48
+ import numpy as np
49
+ ```
50
+ _Load a spatial dataset_ \
51
+ (e.g., a Visium dataset)
52
+ ```
53
+ adata = sc.datasets.visium_sge(sample_id='V1_Mouse_Brain_Sagittal_Posterior')
54
+ adata.var_names_make_unique()
55
+ ```
56
+ _Basic processing_
57
+ ```
58
+ sc.pp.normalize_total(adata, inplace=True)
59
+ sc.pp.log1p(adata)
60
+ ```
61
+ _Specify ligand-receptor pairs_
62
+ ```
63
+ LR=np.array([['Tgfb1', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'],['Tgfb2', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'],['Tgfb3', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway']],dtype=str)
64
+ df_ligrec = pd.DataFrame(data=LR)
65
+ ```
66
+ (or use pairs from a ligand-receptor database `df_ligrec=ct.pp.ligand_receptor_database(database='CellChat', species='mouse')`.)
67
+
68
+ _Construct CCC networks_ \
69
+ Use collective optimal transport to construct CCC networks for the ligand-receptor pairs with a spatial distance constraint of 200 (coupling between cells with distance greater than 200 is prohibited). For example, the spot-by-spot matrix for the pair Tgfb1 (ligand) and Tgfbr1_Tgfbr2 (receptor)is stored in `adata.obsp['comflow-user_database-Tgfb1-Tgfbr1_Tgfbr2']`. The total sent or received signal for each pair is stored in `adata.obsm['comflow-user_database-sum-sender']` and `adata.obsm['comflow-user_database-sum-receiver']`.
70
+ ```
71
+ ct.tl.spatial_communication(adata,
72
+ database_name='user_database', df_ligrec=df_ligrec, dis_thr=200, heteromeric=True)
73
+ ```
74
+ ## Documentation
75
+
76
+ See detailed documentation and examples at [https://comflow.readthedocs.io/en/latest/index.html](https://comflow.readthedocs.io/en/latest/index.html).
77
+
78
+ ## References
79
+
80
+ Xie, M. B., Zhu, Y., Hu, Y., Kim, M., Liu, Y. H., Huang, J., Li, B., Rafat, M., Meltzer,S., Hwang, T. H., Cang, Z., Zhao, Y., Zhou, X. M.. ComFlow: an optimal transport framework for deciphering intra- and intercellular signaling landscapes in 2D and 3D tissue systems.
81
+
82
+
@@ -0,0 +1,58 @@
1
+ # ComFlow
2
+ ComFlow: an optimal transport framework for deciphering intra-
3
+ and intercellular signaling landscapes in 2D and 3D tissue systems
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/comflow?logo=PyPI)](https://pypi.org/project/comflow)
6
+ ![pytest](https://github.com/zcang/comflow/actions/workflows/python-package.yml/badge.svg)
7
+ [![Read the Docs](https://readthedocs.org/projects/comflow/badge/?version=latest)](https://comflow.readthedocs.io/en/latest/)
8
+
9
+
10
+ ## Installation
11
+ Install from PyPI by `pip install comflow` or install from source by cd to this directory and `pip install .`
12
+
13
+ [Optional] Install [tradeSeq](https://github.com/statOmics/tradeSeq) in R to analyze the CCC differentially expressed genes. \
14
+ Currently, tradeSeq version 1.0.1 with R version 3.6.3 has been tested to work. \
15
+ In order for the R-python interface to work properly, rpy2==3.4.2 and anndata2ri==1.0.6 should be installed.
16
+ To use this feature, install from PyPI by `pip install comflow[tradeSeq]` or from source by `pip install .[tradeSeq]`.
17
+
18
+ ## Usage
19
+ **Basic usage**
20
+
21
+ _Import packages_
22
+ ```
23
+ import comflow as ct
24
+ import scanpy as sc
25
+ import pandas as pd
26
+ import numpy as np
27
+ ```
28
+ _Load a spatial dataset_ \
29
+ (e.g., a Visium dataset)
30
+ ```
31
+ adata = sc.datasets.visium_sge(sample_id='V1_Mouse_Brain_Sagittal_Posterior')
32
+ adata.var_names_make_unique()
33
+ ```
34
+ _Basic processing_
35
+ ```
36
+ sc.pp.normalize_total(adata, inplace=True)
37
+ sc.pp.log1p(adata)
38
+ ```
39
+ _Specify ligand-receptor pairs_
40
+ ```
41
+ LR=np.array([['Tgfb1', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'],['Tgfb2', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway'],['Tgfb3', 'Tgfbr1_Tgfbr2', 'Tgfb_pathway']],dtype=str)
42
+ df_ligrec = pd.DataFrame(data=LR)
43
+ ```
44
+ (or use pairs from a ligand-receptor database `df_ligrec=ct.pp.ligand_receptor_database(database='CellChat', species='mouse')`.)
45
+
46
+ _Construct CCC networks_ \
47
+ Use collective optimal transport to construct CCC networks for the ligand-receptor pairs with a spatial distance constraint of 200 (coupling between cells with distance greater than 200 is prohibited). For example, the spot-by-spot matrix for the pair Tgfb1 (ligand) and Tgfbr1_Tgfbr2 (receptor)is stored in `adata.obsp['comflow-user_database-Tgfb1-Tgfbr1_Tgfbr2']`. The total sent or received signal for each pair is stored in `adata.obsm['comflow-user_database-sum-sender']` and `adata.obsm['comflow-user_database-sum-receiver']`.
48
+ ```
49
+ ct.tl.spatial_communication(adata,
50
+ database_name='user_database', df_ligrec=df_ligrec, dis_thr=200, heteromeric=True)
51
+ ```
52
+ ## Documentation
53
+
54
+ See detailed documentation and examples at [https://comflow.readthedocs.io/en/latest/index.html](https://comflow.readthedocs.io/en/latest/index.html).
55
+
56
+ ## References
57
+
58
+ Xie, M. B., Zhu, Y., Hu, Y., Kim, M., Liu, Y. H., Huang, J., Li, B., Rafat, M., Meltzer,S., Hwang, T. H., Cang, Z., Zhao, Y., Zhou, X. M.. ComFlow: an optimal transport framework for deciphering intra- and intercellular signaling landscapes in 2D and 3D tissue systems.
@@ -0,0 +1,10 @@
1
+ # __init__ file
2
+ import warnings
3
+ warnings.filterwarnings('ignore')
4
+
5
+ from . import preprocessing as pp
6
+ from . import tools as tl
7
+ from . import plotting as pl
8
+
9
+ import sys
10
+ sys.modules.update({f'{__name__}.{m}': globals()[m] for m in ['pp','tl','pl']})
@@ -0,0 +1,13 @@
1
+ # __init__ file
2
+ from ._cot import cot_dense
3
+ from ._cot import cot_row_dense
4
+ from ._cot import cot_col_dense
5
+ from ._cot import cot_blk_dense
6
+ from ._cot import cot_combine_sparse
7
+ from ._cot import cot_sparse
8
+ from ._cot import cot_row_sparse
9
+ from ._cot import cot_col_sparse
10
+ from ._cot import cot_blk_sparse
11
+ from ._cot import generate_ggi_res, generate_tf_res, generate_tf_gene_all, random_walk_vectorized, calculate_TF_scores
12
+ from ._usot import usot
13
+ from ._usot import uot