Skip to content

Commit

Permalink
minor tweaks to the cell cycle component
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Jan 17, 2025
1 parent 488e06a commit 160d101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/metrics/cell_cycle_conservation/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ engines:
setup:
- type: python
pypi:
- git+https://github.com/theislab/scib.git@extend_cell_cycle_genes
- scib==1.1.7
runners:
- type: executable
- type: nextflow
Expand Down
22 changes: 8 additions & 14 deletions src/metrics/cell_cycle_conservation/script.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import sys
import anndata as ad
from scib.metrics import cell_cycle
import numpy as np

## VIASH START
par = {
'input_integrated': 'resources_test/task_batch_integration/cxg_immune_cell_atlas/integrated_full.h5ad',
"input_solution": "resources_test/task_batch_integration/cxg_immune_cell_atlas/output_solution.h5ad",
'output': 'output.h5ad'
}

meta = {
'name': 'foo'
"resources_dir": "target/executable/metrics/cell_cycle_conservation",
}
## VIASH END

sys.path.append(meta["resources_dir"])
from read_anndata_partial import read_anndata


print('Read input', flush=True)
adata_solution = read_anndata(
par['input_solution'],
Expand All @@ -25,34 +24,29 @@
var='var',
uns='uns'
)
print(f"adata_solution: {adata_solution}")

adata_integrated = read_anndata(
par['input_integrated'],
obs='obs',
obsm='obsm',
uns='uns'
)
print(f"adata_integrated: {adata_integrated}")

print("Copy batch information", flush=True)
adata_integrated.obs['batch'] = adata_solution.obs['batch']

print('Use gene symbols for features', flush=True)
adata_solution.var_names = adata_solution.var['feature_name']

dataset_organism = adata_solution.uns['dataset_organism']
translator = {
"homo_sapiens": "human",
"mus_musculus": "mouse",
}
assert dataset_organism in translator, \
f"dataset organism ({dataset_organism}) not in translator!"

print('Compute score', flush=True)
score = cell_cycle(
adata_solution,
adata_integrated,
batch_key='batch',
embed='X_emb',
organism=translator[dataset_organism],
organism=adata_solution.uns['dataset_organism'],
)

print('Create output AnnData object', flush=True)
Expand All @@ -65,7 +59,7 @@
'metric_values': [ score ]
}
)

print(f"output: {output}")

print('Write data to file', flush=True)
output.write_h5ad(par['output'], compression='gzip')

0 comments on commit 160d101

Please sign in to comment.