cytocommunity2 0.1.7__tar.gz → 1.0.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.
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/LICENSE +21 -21
- {cytocommunity2-0.1.7/src/cytocommunity2.egg-info → cytocommunity2-1.0.0}/PKG-INFO +156 -166
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/README.md +136 -145
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/pyproject.toml +27 -31
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/setup.cfg +4 -4
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/__init__.py +23 -23
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/config.py +70 -69
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/__init__.py +16 -16
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/coherence.py +97 -115
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/communication/__init__.py +2 -2
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/communication/between.py +132 -142
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/communication/cca.py +319 -320
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/communication/utils.py +63 -63
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/communication/within.py +264 -264
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/differential_composition.py +218 -224
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/dominant_celltype.py +55 -63
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/moran.py +265 -309
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/__init__.py +3 -3
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/cn_selection.py +2 -11
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/coherence.py +0 -5
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/common.py +79 -79
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/communication.py +5 -7
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/composition.py +80 -80
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/dominant.py +3 -6
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/dotplots.py +255 -255
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/plotting/recurrence.py +0 -6
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/downstream/runtime.py +13 -13
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/ensemble.py +261 -255
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/__init__.py +7 -7
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/api.py +136 -141
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/dataset.py +129 -129
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/model.py +122 -122
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/selection.py +184 -200
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/learning/training.py +201 -201
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/paths.py +50 -50
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/visualization/__init__.py +5 -5
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/visualization/spatial.py +94 -116
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0/src/cytocommunity2.egg-info}/PKG-INFO +156 -166
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2.egg-info/requires.txt +3 -5
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2/colors.py +0 -0
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2.egg-info/SOURCES.txt +0 -0
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2.egg-info/dependency_links.txt +0 -0
- {cytocommunity2-0.1.7 → cytocommunity2-1.0.0}/src/cytocommunity2.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 huBioinfo
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 huBioinfo
|
|
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.
|
|
@@ -1,166 +1,156 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cytocommunity2
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Weakly supervised cellular-neighborhood learning for spatial omics
|
|
5
|
-
Requires-Python: >=3.10
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Requires-Dist:
|
|
9
|
-
Requires-Dist:
|
|
10
|
-
Requires-Dist:
|
|
11
|
-
Requires-Dist:
|
|
12
|
-
Requires-Dist:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
conda
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(
|
|
113
|
-
name]
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- Liukang Wu (yetong@stu.xidian.edu.cn)
|
|
158
|
-
- Yafei Xu (22031212416@stu.xidian.edu.cn)
|
|
159
|
-
- Yuxuan Hu (huyuxuan@xidian.edu.cn)
|
|
160
|
-
|
|
161
|
-
## Citation
|
|
162
|
-
|
|
163
|
-
Yuxuan Hu, Jiazhen Rong, Yafei Xu, Runzhi Xie, Jacqueline Peng, Lin Gao, and
|
|
164
|
-
Kai Tan. “Unsupervised and supervised discovery of tissue cellular
|
|
165
|
-
neighborhoods from cell phenotypes.” *Nature Methods* 21 (2024): 267–278.
|
|
166
|
-
https://doi.org/10.1038/s41592-023-02124-2
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cytocommunity2
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Weakly supervised cellular-neighborhood learning for spatial omics
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: esda<2.6,>=2.5
|
|
9
|
+
Requires-Dist: jupyter
|
|
10
|
+
Requires-Dist: libpysal<4.10,>=4.9
|
|
11
|
+
Requires-Dist: matplotlib>=3.6
|
|
12
|
+
Requires-Dist: numpy<2,>=1.23
|
|
13
|
+
Requires-Dist: pandas<3,>=1.5
|
|
14
|
+
Requires-Dist: sci-palettes
|
|
15
|
+
Requires-Dist: scikit-learn>=1.1
|
|
16
|
+
Requires-Dist: scipy>=1.11
|
|
17
|
+
Requires-Dist: seaborn>=0.12
|
|
18
|
+
Requires-Dist: torch-geometric>=2.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# CytoCommunity2
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
- [Overview](#overview)
|
|
26
|
+
- [Installation](#installation)
|
|
27
|
+
- [Usage](#usage)
|
|
28
|
+
- [Maintainers](#maintainers)
|
|
29
|
+
- [Citation](#citation)
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
|
|
33
|
+
To enhance CytoCommunity (https://github.com/huBioinfo/CytoCommunity), we
|
|
34
|
+
present CytoCommunity2, **a unified weakly-supervised framework** for
|
|
35
|
+
identifying and comparing tissue cellular neighborhoods (TCNs or CNs) across
|
|
36
|
+
**large-scale spatial omics samples with single or multiple biological
|
|
37
|
+
conditions**.
|
|
38
|
+
|
|
39
|
+
Inspired by histopathology workflows, CytoCommunity2 first hierarchically
|
|
40
|
+
partitions the large single-cell spatial map into small patches, performs graph
|
|
41
|
+
construction and weakly supervised CN learning for each patch, and finally
|
|
42
|
+
merges results through KNN-based CN reassignment at segmentation boundaries to
|
|
43
|
+
ensure CN spatial continuity. This strategy divides the original sample into
|
|
44
|
+
patches for CN learning, achieving **memory efficiency (typical 24G graphics
|
|
45
|
+
memory is enough)** and also increased sample throughput. These optimizations
|
|
46
|
+
significantly **enhance the robustness of CNs and cross-sample alignment
|
|
47
|
+
performance**.
|
|
48
|
+
|
|
49
|
+
Furthermore, to make CytoCommunity2 a unified framework that is also
|
|
50
|
+
**applicable for single-condition spatial omics datasets**, pseudo-samples with
|
|
51
|
+
artificial labels are generated, enabling automatic CN alignment across real
|
|
52
|
+
samples via **contrastive learning**.
|
|
53
|
+
|
|
54
|
+
**_In summary, the advantages of CytoCommunity2 include:_**
|
|
55
|
+
|
|
56
|
+
**_(1) Using significantly less memory for large-scale spatial omics samples
|
|
57
|
+
with millions of cells._**
|
|
58
|
+
|
|
59
|
+
**_(2) A unified weakly-supervised model applicable for both multi-condition
|
|
60
|
+
and single-condition datasets._**
|
|
61
|
+
|
|
62
|
+
**_(3) High CN alignment performance makes it well-suited for comparative
|
|
63
|
+
analysis in large cohort studies._**
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
### Hardware requirement
|
|
68
|
+
|
|
69
|
+
Graphics memory: 24G
|
|
70
|
+
|
|
71
|
+
Storage: 10GB or more
|
|
72
|
+
|
|
73
|
+
### Install CytoCommunity2
|
|
74
|
+
|
|
75
|
+
CytoCommunity2 requires Python 3.10 or newer. We recommend creating and
|
|
76
|
+
activating a Conda environment first:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
conda create -n cytocommunity2 python=3.10
|
|
80
|
+
conda activate cytocommunity2
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For an NVIDIA GPU on Windows or Linux, first install the appropriate
|
|
84
|
+
CUDA-enabled PyTorch build from the
|
|
85
|
+
[official PyTorch installation page](https://pytorch.org/get-started/locally/).
|
|
86
|
+
|
|
87
|
+
Install the package via pip:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install cytocommunity2
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
### 1. Prepare input data
|
|
96
|
+
|
|
97
|
+
The input data to CytoCommunity2 includes four types of files :
|
|
98
|
+
|
|
99
|
+
(1) An image (sample) name list file, named as "ImageNameList.txt".
|
|
100
|
+
|
|
101
|
+
(2) A cell type label file for each image (sample), named as "[image
|
|
102
|
+
name]_CellTypeLabel.txt". Note that [image_name] should be consistent with your
|
|
103
|
+
customized image names listed in the "ImageNameList.txt". This file lists cell
|
|
104
|
+
type names of all cells in an image (sample).
|
|
105
|
+
|
|
106
|
+
(3) A cell spatial coordinate file for each image (sample), named as "[image
|
|
107
|
+
name]_Coordinates.txt". Note that [image_name] should be consistent with your
|
|
108
|
+
customized image names listed in the "ImageNameList.txt". This file lists cell
|
|
109
|
+
coordinates (tab-delimited x/y) of all cells in an image (sample). The cell
|
|
110
|
+
orders should be exactly the same with "[image name]_CellTypeLabel.txt".
|
|
111
|
+
|
|
112
|
+
(4) A graph label file for each image (sample), named as "[image
|
|
113
|
+
name]_GraphLabel.txt". For multi-condition datasets, this file must be provided
|
|
114
|
+
for every image (sample) and contain one integer indicating its biological
|
|
115
|
+
condition. For single-condition datasets, graph label
|
|
116
|
+
files can be omitted for all images (samples), and CytoCommunity2 will generate
|
|
117
|
+
pseudo-samples for weakly-supervised learning.
|
|
118
|
+
|
|
119
|
+
### 2. Configure CytoCommunity2
|
|
120
|
+
|
|
121
|
+
Before running CytoCommunity2, set `input_dir` and review all
|
|
122
|
+
model and downstream parameters in
|
|
123
|
+
[`hyperparameters.json`](https://github.com/LiukangWu/CytoCommunity2/blob/main/hyperparameters.json). The Python workflow will use this configuration file.
|
|
124
|
+
|
|
125
|
+
### 3. Run CytoCommunity2
|
|
126
|
+
|
|
127
|
+
The tutorial uses a TNBC dataset as a worked example and demonstrates the
|
|
128
|
+
entire CytoCommunity2 workflow, from model training and CN identification to
|
|
129
|
+
downstream analysis:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
jupyter notebook tutorial/TNBC_workflow.ipynb
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 4. Output files
|
|
136
|
+
|
|
137
|
+
The main output directories are:
|
|
138
|
+
|
|
139
|
+
- `CNLearning_Output/`: CN-number screening, trained models, and final result
|
|
140
|
+
tables.
|
|
141
|
+
- `CNVisualization_Output/`: CN and cell-type spatial plots.
|
|
142
|
+
- `data/`: downstream analysis results.
|
|
143
|
+
- `plot/`: figures generated by downstream analyses.
|
|
144
|
+
|
|
145
|
+
## Maintainers
|
|
146
|
+
|
|
147
|
+
- Liukang Wu (yetong@stu.xidian.edu.cn)
|
|
148
|
+
- Yafei Xu (22031212416@stu.xidian.edu.cn)
|
|
149
|
+
- Yuxuan Hu (huyuxuan@xidian.edu.cn)
|
|
150
|
+
|
|
151
|
+
## Citation
|
|
152
|
+
|
|
153
|
+
Yuxuan Hu, Jiazhen Rong, Yafei Xu, Runzhi Xie, Jacqueline Peng, Lin Gao, and
|
|
154
|
+
Kai Tan. “Unsupervised and supervised discovery of tissue cellular
|
|
155
|
+
neighborhoods from cell phenotypes.” *Nature Methods* 21 (2024): 267–278.
|
|
156
|
+
https://doi.org/10.1038/s41592-023-02124-2
|