Skip to content

Commit 5d3c59b

Browse files
committed
📌 v0.2.2 release
1 parent fba97cf commit 5d3c59b

15 files changed

+1645
-184
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*.gz
2626
*.whl
2727
*.html
28+
*.DS_Store
2829

2930
# folder
3031
**/conda/

benchmark/analysis/aggr_datasets.ipynb

Lines changed: 147 additions & 66 deletions
Large diffs are not rendered by default.

benchmark/analysis/celltype_region_analysis.ipynb

Lines changed: 83 additions & 90 deletions
Large diffs are not rendered by default.

benchmark/analysis/check_MERFISH.ipynb

Lines changed: 248 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/analysis/hetero.ipynb

Lines changed: 245 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/analysis/plot_confusion_matrix.ipynb

Lines changed: 466 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/analysis/plot_keypoints.ipynb

Lines changed: 376 additions & 0 deletions
Large diffs are not rendered by default.

benchmark/config/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#-------------------------------- Global ----------------------------------#
22
timeout: 24h
33
timehold: 200h
4-
seed: 8
4+
seed: 1
55
sample: 0
66
fix_sample: True
77

88
use:
9-
# - benchmark
10-
- perturb
9+
- benchmark
10+
# - perturb
1111
# - split_data
1212
# - build_3d
1313

benchmark/profiles/impetus/impetus.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ __default__:
33
output: ".slurm/{rule}.out"
44
error: ".slurm/{rule}.err"
55
account: gglab
6-
partition: cpu2
6+
partition: fat2
77
n_node: 1
88
n_task: 1
99
n_cpu: "{threads}"

benchmark/workflow/notebooks/data_split.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"name": "python",
9696
"nbconvert_exporter": "python",
9797
"pygments_lexer": "ipython3",
98-
"version": "3.8.13"
98+
"version": "3.8.17"
9999
},
100100
"orig_nbformat": 4,
101101
"vscode": {

benchmark/workflow/notebooks/emb2metrics.ipynb

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"import pandas as pd\n",
1616
"import scanpy as sc\n",
1717
"import scipy.sparse as sp\n",
18-
"from sklearn.metrics import f1_score\n",
18+
"import matplotlib.pyplot as plt\n",
19+
"from sklearn.metrics import f1_score, confusion_matrix, ConfusionMatrixDisplay\n",
20+
"\n",
1921
"\n",
2022
"from scSLAT.model import spatial_match\n",
2123
"from scSLAT.metrics import global_score, euclidean_dis, rotation_angle\n",
@@ -108,6 +110,16 @@
108110
" spot_size = 5"
109111
]
110112
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": null,
116+
"metadata": {},
117+
"outputs": [],
118+
"source": [
119+
"out_dir = Path(os.path.dirname(metric_file))\n",
120+
"sc.settings.figdir = out_dir"
121+
]
122+
},
111123
{
112124
"cell_type": "markdown",
113125
"metadata": {},
@@ -190,7 +202,7 @@
190202
"cell_type": "markdown",
191203
"metadata": {},
192204
"source": [
193-
"## Ground truth (perturb)"
205+
"## Confusion Matrix"
194206
]
195207
},
196208
{
@@ -199,18 +211,55 @@
199211
"metadata": {},
200212
"outputs": [],
201213
"source": [
202-
"if 'perturb' in matching_file:\n",
203-
" match_ratio = (matching[0] == matching[1]).sum() / len(matching[0])\n",
204-
"else:\n",
205-
" match_ratio = -1"
214+
"celltype_label = adata2.obs[biology_meta].unique().tolist()\n",
215+
"region_label = adata2.obs[topology_meta].unique().tolist()\n",
216+
"celltype_region_label = adata2.obs['celltype_region'].unique().tolist()"
217+
]
218+
},
219+
{
220+
"cell_type": "code",
221+
"execution_count": null,
222+
"metadata": {},
223+
"outputs": [],
224+
"source": [
225+
"plt.figure(figsize=(len(celltype_region_label) / 2, len(celltype_region_label) /2))\n",
226+
"cm = confusion_matrix(adata2.obs['celltype_region'], adata2.obs['target_celltype_region'], labels=celltype_region_label)\n",
227+
"disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=celltype_region_label)\n",
228+
"disp.plot(cmap='Reds', xticks_rotation='vertical', ax=plt.gca())\n",
229+
"plt.savefig(out_dir / 'joint_confusing_matrix.png', dpi=300, bbox_inches='tight')"
230+
]
231+
},
232+
{
233+
"cell_type": "code",
234+
"execution_count": null,
235+
"metadata": {},
236+
"outputs": [],
237+
"source": [
238+
"plt.figure(figsize=(len(celltype_label) / 2, len(celltype_label) /2))\n",
239+
"cm = confusion_matrix(adata2.obs[biology_meta], adata2.obs['target_celltype'], labels=celltype_label)\n",
240+
"disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=celltype_label)\n",
241+
"disp.plot(cmap='Reds', xticks_rotation='vertical', ax=plt.gca())\n",
242+
"plt.savefig(out_dir / 'celltype_confusing_matrix.png', dpi=300, bbox_inches='tight')"
243+
]
244+
},
245+
{
246+
"cell_type": "code",
247+
"execution_count": null,
248+
"metadata": {},
249+
"outputs": [],
250+
"source": [
251+
"plt.figure(figsize=(len(region_label) / 2, len(region_label) /2))\n",
252+
"cm = confusion_matrix(adata2.obs[topology_meta], adata2.obs['target_region'], labels=region_label)\n",
253+
"disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=region_label)\n",
254+
"disp.plot(cmap='Reds', xticks_rotation='vertical', ax=plt.gca())\n",
255+
"plt.savefig(out_dir / 'region_confusing_matrix.png', dpi=300, bbox_inches='tight')"
206256
]
207257
},
208258
{
209-
"attachments": {},
210259
"cell_type": "markdown",
211260
"metadata": {},
212261
"source": [
213-
"# Save"
262+
"## Ground truth (perturb)"
214263
]
215264
},
216265
{
@@ -219,8 +268,18 @@
219268
"metadata": {},
220269
"outputs": [],
221270
"source": [
222-
"out_dir = Path(os.path.dirname(metric_file))\n",
223-
"sc.settings.figdir = out_dir"
271+
"if 'perturb' in matching_file:\n",
272+
" match_ratio = (matching[0] == matching[1]).sum() / len(matching[0])\n",
273+
"else:\n",
274+
" match_ratio = -1"
275+
]
276+
},
277+
{
278+
"attachments": {},
279+
"cell_type": "markdown",
280+
"metadata": {},
281+
"source": [
282+
"# Save"
224283
]
225284
},
226285
{

benchmark/workflow/notebooks/run_SLAT_dpca.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,21 @@
8484
" biology_meta = 'cell_type'\n",
8585
" topology_meta = 'layer_guess'\n",
8686
" alpha = 10\n",
87-
" LGCN_layer = 2\n",
8887
" spot_size = 5\n",
8988
"elif 'merfish' and 'hypothalamic' in adata1_file:\n",
9089
" biology_meta = 'Cell_class'\n",
9190
" topology_meta = 'region'\n",
9291
" alpha = 25\n",
93-
" LGCN_layer = 2\n",
9492
" spot_size = 15\n",
9593
"elif 'stereo' and 'embryo' in adata1_file:\n",
9694
" biology_meta = 'annotation'\n",
9795
" topology_meta = 'region'\n",
9896
" alpha = 3\n",
99-
" LGCN_layer = 1\n",
10097
" spot_size = 5\n",
10198
"elif 'brain' in adata1_file:\n",
10299
" biology_meta = 'layer_guess'\n",
103100
" topology_meta = 'layer_guess'\n",
104101
" alpha = 10\n",
105-
" LGCN_layer = 2\n",
106102
" spot_size = 5"
107103
]
108104
},
@@ -154,7 +150,7 @@
154150
"Cal_Spatial_Net(adata1, k_cutoff=20, model='KNN')\n",
155151
"Cal_Spatial_Net(adata2, k_cutoff=20, model='KNN')\n",
156152
"edges, features = load_anndatas([adata1, adata2], feature='dpca', singular=True, dim=30)\n",
157-
"embd0, embd1, time1 = run_SLAT(features, edges, 6, LGCN_layer=LGCN_layer)\n",
153+
"embd0, embd1, time1 = run_SLAT(features, edges, 6, LGCN_layer=3)\n",
158154
"run_time = str(time.time() - start)\n",
159155
"print('Runtime: ' + run_time)"
160156
]

benchmark/workflow/notebooks/run_SLAT_dpca_one2many.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,21 @@
8282
" biology_meta = 'cell_type'\n",
8383
" topology_meta = 'layer_guess'\n",
8484
" alpha = 10\n",
85-
" LGCN_layer = 2\n",
8685
" spot_size = 5\n",
8786
"elif 'merfish' and 'hypothalamic' in adata1_file:\n",
8887
" biology_meta = 'Cell_class'\n",
8988
" topology_meta = 'region'\n",
9089
" alpha = 25\n",
91-
" LGCN_layer = 2\n",
9290
" spot_size = 15\n",
9391
"elif 'stereo' and 'embryo' in adata1_file:\n",
9492
" biology_meta = 'annotation'\n",
9593
" topology_meta = 'region'\n",
9694
" alpha = 3\n",
97-
" LGCN_layer = 1\n",
9895
" spot_size = 5\n",
9996
"elif 'brain' in adata1_file:\n",
10097
" biology_meta = 'layer_guess'\n",
10198
" topology_meta = 'layer_guess'\n",
10299
" alpha = 10\n",
103-
" LGCN_layer = 2\n",
104100
" spot_size = 5"
105101
]
106102
},
@@ -152,7 +148,7 @@
152148
"Cal_Spatial_Net(adata1, k_cutoff=20, model='KNN')\n",
153149
"Cal_Spatial_Net(adata2, k_cutoff=20, model='KNN')\n",
154150
"edges, features = load_anndatas([adata1, adata2], feature='dpca', singular=True, dim=30)\n",
155-
"embd0, embd1, time1 = run_SLAT(features, edges, 6, LGCN_layer=LGCN_layer)\n",
151+
"embd0, embd1, time1 = run_SLAT(features, edges, 6, LGCN_layer=3)\n",
156152
"run_time = str(time.time() - start)\n",
157153
"print('Runtime: ' + run_time)"
158154
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ classifiers = [
3131
[tool.poetry.dependencies]
3232
python = "^3.8"
3333
numpy = ">1.19"
34-
scipy = ">1.3"
34+
scipy = ">1.3, <1.9"
3535
pandas = ">1.1, <2.0"
3636
matplotlib = ">3.1.2, <3.7"
3737
seaborn = ">0.9"

scSLAT/viz/multi_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ class match_3D_celltype(match_3D_multi):
462462
highlight_cell
463463
color to highlight the cell
464464
meta
465-
dataframe colname of meta, such as celltype
465+
dataframe col name of meta, such as celltype
466466
expr
467-
dataframe colname of gene expr
467+
dataframe col name of gene expr
468468
subsample_size
469469
subsample size of matches
470470
reliability

0 commit comments

Comments
 (0)