Skip to content

Commit 47882e3

Browse files
committed
working
1 parent 4f08836 commit 47882e3

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

src/metrics/ksim/config.vsh.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ info:
1919
maximize: true
2020

2121
arguments:
22-
- name: "--rep"
23-
type: "string"
24-
default: "pca"
25-
description: The embedding representation to consider.
2622
- name: "--K"
2723
type: "integer"
2824
default: 24

src/metrics/ksim/script.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
import anndata as ad
22
import sys
33
import pegasus as pg
4+
import pegasusio
5+
from scipy.sparse import csr_matrix
46

5-
## VIASH START
6-
# Note: this section is auto-generated by viash at runtime. To edit it, make changes
7-
# in config.vsh.yaml and then run `viash config inject config.vsh.yaml`.
8-
par = {
9-
'input_integrated': 'resources_test/task_batch_integration/cxg_immune_cell_atlas/integrated_full.h5ad',
10-
'input_solution': 'resources_test/.../solution.h5ad',
11-
'output': 'output.h5ad',
12-
"rep": "pca",
13-
"K": 24,
14-
"min_rate": 0.9,
15-
"n_jobs": -1,
16-
"random_state": 0,
17-
"use_cache": True
18-
}
19-
meta = {
20-
'name': 'ksim'
21-
}
22-
## VIASH END
237

248
sys.path.append(meta["resources_dir"])
259
from read_anndata_partial import read_anndata
@@ -28,20 +12,24 @@
2812
adata = read_anndata(par['input_integrated'], obs='obs', obsm='obsm', uns='uns')
2913
adata.obs = read_anndata(par['input_solution'], obs='obs').obs
3014
adata.uns |= read_anndata(par['input_solution'], uns='uns').uns
15+
print(adata)
16+
17+
print('Convert to pegasusio.MultimodalData...', flush=True)
18+
adata.X = csr_matrix(adata.shape)
19+
mmdata = pegasusio.MultimodalData(adata)
3120

3221
print('Compute metrics', flush=True)
3322
score = pg.calc_kSIM(
34-
adata,
23+
mmdata,
3524
attr='cell_type',
36-
rep=par["rep"],
25+
rep='emb',
3726
K=par["K"],
3827
min_rate=par["min_rate"],
3928
n_jobs=par["n_jobs"],
4029
random_state=par["random_state"],
4130
use_cache=par["use_cache"]
42-
)[1]
43-
44-
# TODO RETURNS A TOUPLE OF TWO THINGS: kSIM_mean (float) – Mean kSIM rate over all the cells., kSIM_accept_rate (float) – kSIM Acceptance rate of the sample
31+
)
32+
print("score:", score)
4533

4634
print('Create output AnnData object', flush=True)
4735
output = ad.AnnData(

0 commit comments

Comments
 (0)