Skip to content

Commit fd0f28e

Browse files
Working docker | conda configuration found + better parametrization + small changes
1 parent 6264bdd commit fd0f28e

File tree

8 files changed

+128
-16
lines changed

8 files changed

+128
-16
lines changed

conf/modules.config

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,14 @@ process {
409409
]
410410
}
411411

412-
withName: EXPIMAP {
412+
withName: SCARCHES_EXPIMAP {
413+
ext.hidden_layer_sizes = { params.expimap_hidden_layer_sizes }
414+
ext.recon_loss = { params.expimap_recon_loss }
415+
ext.n_epochs = { params.expimap_n_epochs }
416+
ext.alpha_epoch_anneal = { params.expimap_alpha_epoch_anneal }
417+
ext.alpha = { params.expimap_alpha }
418+
ext.alpha_kl = { params.expimap_alpha_kl }
419+
ext.use_early_stopping = { params.expimap_use_early_stopping }
413420
publishDir = [
414421
path: { "${params.outdir}/combine/integrate/expimap" },
415422
mode: params.publish_dir_mode,
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
channels:
2-
- conda-forge
3-
- bioconda
2+
- conda-forge
3+
- bioconda
44
dependencies:
5-
- conda-forge::python=3.14
6-
- pip
7-
- pip:
8-
- scArches=0.6.1
5+
- conda-forge::pandas=1.5.3
6+
- conda-forge::python=3.10.0
7+
- pip
8+
- pip:
9+
- anndata==0.9.2
10+
- flax==0.6.11
11+
- jax==0.4.17
12+
- jaxlib==0.4.17
13+
- numpy==1.24.4
14+
- pytorch-lightning==1.9.5
15+
- scArches==0.6.1
16+
- scanpy==1.9.8
17+
- scipy==1.10.1
18+
- scvi-tools==0.20.3
19+
- setuptools==75.3.2
20+
- torch==2.4.1
21+
- torchmetrics==1.5.2

modules/local/scarches/expimap/main.nf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ process SCARCHES_EXPIMAP {
44

55
conda "${moduleDir}/environment.yml"
66
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
7-
? 'https://wave.seqera.io/view/builds/bd-e532922f69f9a648_1'
8-
: 'community.wave.seqera.io/library/pip_scarches:7e8c7e577326f6ad'}"
7+
? 'https://wave.seqera.io/view/builds/bd-c86ba663882352b6_1'
8+
: 'community.wave.seqera.io/library/pandas_python_pip_anndata_pruned:c86ba663882352b6'}"
99

1010
input:
1111
tuple val(meta), path(h5ad, arity: 1)
@@ -20,6 +20,13 @@ process SCARCHES_EXPIMAP {
2020

2121
script:
2222
prefix = task.ext.prefix ?: "${meta.id}"
23+
hidden_layer_sizes = task.ext.hidden_layer_sizes ?: [256, 256, 256]
24+
recon_loss = task.ext.recon_loss ?: "nb"
25+
n_epochs = task.ext.n_epochs ?: 400
26+
alpha_epoch_anneal = task.ext.alpha_epoch_anneal ?: 100
27+
alpha = task.ext.alpha ?: 0.7
28+
alpha_kl = task.ext.alpha_kl ?: 0.5
29+
use_early_stopping = task.ext.use_early_stopping ?: true
2330
if ("${prefix}.h5ad" == "${h5ad}") {
2431
error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
2532
}

modules/local/scarches/expimap/templates/expimap.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
if "${counts_layer}" != "X":
2424
adata_processing.X = adata.layers["${counts_layer}"]
2525

26+
# Ensure condition column exists
27+
condition_col = "${condition_col}"
28+
if condition_col not in adata_processing.obs.columns:
29+
adata_processing.obs[condition_col] = "condition"
30+
2631
# Prior biological knowledge in form of gene programs
2732
if "${reference_model}":
2833
sca.utils.add_annotations(adata_processing, "${reference_model}", min_genes=12, clean=True)
@@ -33,17 +38,18 @@
3338
intr_cvae = sca.models.EXPIMAP(
3439
adata=adata_processing,
3540
condition_key="${condition_col}",
36-
hidden_layer_sizes=[256, 256, 256],
37-
recon_loss="nb"
41+
hidden_layer_sizes=${hidden_layer_sizes},
42+
recon_loss="${recon_loss}"
3843
)
3944

4045
# Train the model
46+
use_early_stopping = "${use_early_stopping}".lower() == 'true'
4147
intr_cvae.train(
42-
n_epochs=400,
43-
alpha_epoch_anneal=100,
44-
alpha=0.7,
45-
alpha_kl=0.5,
46-
use_early_stopping=True
48+
n_epochs=${n_epochs},
49+
alpha_epoch_anneal=${alpha_epoch_anneal},
50+
alpha=${alpha},
51+
alpha_kl=${alpha_kl},
52+
use_early_stopping=use_early_stopping
4753
)
4854

4955
# Extract the interpretable latent representation

modules/local/scarches/expimap/tests/main.nf.test.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,19 @@
3737
"nf-test": "0.9.4",
3838
"nextflow": "25.10.4"
3939
}
40+
},
41+
"Should run without failures": {
42+
"content": [
43+
36984802,
44+
24776608,
45+
[
46+
"versions.yml:md5,b70dc00692171c2b140da84cca2e8be2"
47+
]
48+
],
49+
"timestamp": "2026-03-17T01:26:54.147983034",
50+
"meta": {
51+
"nf-test": "0.9.4",
52+
"nextflow": "25.10.4"
53+
}
4054
}
4155
}

nextflow.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ params {
7373
scvi_categorical_covariates = ''
7474
scvi_continuous_covariates = ''
7575

76+
// Expimap options
77+
expimap_hidden_layer_sizes = [256, 256, 256]
78+
expimap_recon_loss = "nb"
79+
expimap_n_epochs = 400
80+
expimap_alpha_epoch_anneal = 100
81+
expimap_alpha = 0.7
82+
expimap_alpha_kl = 0.5
83+
expimap_use_early_stopping = true
84+
7685
// Pseudobulking options
7786
pseudobulk_groupby_labels = 'batch'
7887
pseudobulk_min_num_cells = 5

nextflow_schema.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,54 @@
383383
}
384384
}
385385
},
386+
"expimap_options": {
387+
"title": "EXPIMAP options",
388+
"type": "object",
389+
"fa_icon": "fas fa-microscope",
390+
"description": "Options for the EXPIMAP integration method",
391+
"properties": {
392+
"expimap_hidden_layer_sizes": {
393+
"type": "array",
394+
"items": {
395+
"type": "integer"
396+
},
397+
"default": [256, 256, 256],
398+
"description": "Hidden layer sizes for EXPIMAP neural network"
399+
},
400+
"expimap_recon_loss": {
401+
"type": "string",
402+
"default": "nb",
403+
"enum": ["nb", "zinb", "poisson", "normal"],
404+
"description": "Reconstruction loss for EXPIMAP",
405+
"help_text": "Reconstruction loss for EXPIMAP. Can be 'nb', 'zinb', 'poisson', or 'normal'."
406+
},
407+
"expimap_n_epochs": {
408+
"type": "integer",
409+
"default": 400,
410+
"description": "Number of epochs for training EXPIMAP"
411+
},
412+
"expimap_alpha_epoch_anneal": {
413+
"type": "integer",
414+
"default": 100,
415+
"description": "Epoch for alpha annealing in EXPIMAP"
416+
},
417+
"expimap_alpha": {
418+
"type": "number",
419+
"default": 0.7,
420+
"description": "Alpha parameter for EXPIMAP"
421+
},
422+
"expimap_alpha_kl": {
423+
"type": "number",
424+
"default": 0.5,
425+
"description": "KL divergence alpha parameter for EXPIMAP"
426+
},
427+
"expimap_use_early_stopping": {
428+
"type": "boolean",
429+
"default": true,
430+
"description": "Whether to use early stopping for EXPIMAP training"
431+
}
432+
}
433+
},
386434
"pseudobulking_options": {
387435
"title": "Pseudobulking options",
388436
"type": "object",
@@ -593,6 +641,9 @@
593641
{
594642
"$ref": "#/$defs/scVI_options"
595643
},
644+
{
645+
"$ref": "#/$defs/expimap_options"
646+
},
596647
{
597648
"$ref": "#/$defs/pseudobulking_options"
598649
},

tests/nextflow.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ process {
2323
withName: CELLBENDER_REMOVEBACKGROUND {
2424
ext.args = '--epochs 2'
2525
}
26+
withName: SCARCHES_EXPIMAP {
27+
ext.n_epochs = 1
28+
ext.hidden_layer_sizes = [16, 16]
29+
ext.alpha_epoch_anneal = 1
30+
}
2631
}

0 commit comments

Comments
 (0)