Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Nextflow runtime
.nextflow/
.nextflow.log*
work/

# Python cache
__pycache__/
*.pyc
Expand Down
Empty file modified bin/compare_same_species_models.py
100644 → 100755
Empty file.
Empty file modified bin/encode_split.py
100644 → 100755
Empty file.
Empty file modified bin/label.py
100644 → 100755
Empty file.
Empty file modified bin/model_processing.py
100644 → 100755
Empty file.
Empty file modified bin/normalize.py
100644 → 100755
Empty file.
Empty file modified bin/preprocess.py
100644 → 100755
Empty file.
Empty file modified bin/profiling.py
100644 → 100755
Empty file.
2 changes: 0 additions & 2 deletions main.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { PROMOTER_SEQUENCE_PIPELINE } from './workflows/main.nf'

workflow {
Expand Down
10 changes: 7 additions & 3 deletions modules/local/encode_and_split_pairs.nf
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
process ENCODE_AND_SPLIT_PAIRS {
tag { dataset_name }

publishDir { "${params.outdir}/${dataset_name}/Encoded" }, mode: params.publish_mode
publishDir "${params.outdir}/${dataset_name}/Encoded", mode: params.publish_mode

input:
tuple val(dataset_name), path(labeled_pairs)
path human_fasta
path mouse_fasta
path original_gene_list
path project_lib

output:
tuple val(dataset_name), path("results/${dataset_name}/splits/${params.split_mode}"), emit: split_directory

script:
def random_seqs_flag = params.random_seqs ? '--random-seqs' : ''
"""
python ${projectDir}/bin/encode_split.py \
export PYTHONPATH="${project_lib}/..:${project_lib}"
encode_split.py \
--input ${labeled_pairs} \
--name ${dataset_name} \
--human-fasta ${human_fasta} \
Expand All @@ -24,6 +27,7 @@ process ENCODE_AND_SPLIT_PAIRS {
--gene-list ${original_gene_list} \
--val-frac ${params.val_frac} \
--test-frac ${params.test_frac} \
--seed ${params.seed}
--seed ${params.seed} \
${random_seqs_flag}
"""
}
8 changes: 5 additions & 3 deletions modules/local/label_gene_pairs.nf
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
process LABEL_GENE_PAIRS {
tag { dataset_name }

publishDir { "${params.outdir}/${dataset_name}/Labeling" }, mode: params.publish_mode
publishDir "${params.outdir}/${dataset_name}/Labeling", mode: params.publish_mode

input:
tuple val(dataset_name), path(raw_expression_dataset)
path project_lib

output:
tuple val(dataset_name), path("results/${dataset_name}/Labeling/${params.profiling}_labeling_*"), emit: labeled_pairs
tuple val(dataset_name), path("results/${dataset_name}/Labeling/*.tsv"), emit: labeled_pairs

script:
"""
python ${projectDir}/bin/label.py \
export PYTHONPATH="${project_lib}/..:${project_lib}"
label.py \
--input ${raw_expression_dataset} \
--name ${dataset_name} \
--normalization ${params.normalization} \
Expand Down
9 changes: 5 additions & 4 deletions modules/local/train_and_evaluate_model.nf
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
process TRAIN_AND_EVALUATE_MODEL {
tag "${dataset_name}"

publishDir {"${params.outdir}/${dataset_name}/Model"}, mode: params.publish_mode
publishDir "${params.outdir}/${dataset_name}/Model", mode: params.publish_mode

input:
tuple val(dataset_name), path(split_directory)
path project_lib

output:
tuple val(dataset_name), path("results/${dataset_name}/Model"), emit: model_directory

script:
optimize_argument = params.optimize ? '--optimize' : ''

def optimize_argument = params.optimize ? '--optimize' : ''
"""
python ${projectDir}/bin/model_processing.py \
export PYTHONPATH="${project_lib}/..:${project_lib}"
model_processing.py \
--data ${split_directory} \
--name ${dataset_name} \
--metric ${params.profiling} \
Expand Down
42 changes: 27 additions & 15 deletions workflows/main.nf
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
nextflow.enable.dsl = 2

include { LABEL_GENE_PAIRS } from '../modules/local/label_gene_pairs.nf'
include { ENCODE_AND_SPLIT_PAIRS } from '../modules/local/encode_and_split_pairs.nf'
include { TRAIN_AND_EVALUATE_MODEL } from '../modules/local/train_and_evaluate_model.nf'

workflow PROMOTER_SEQUENCE_PIPELINE {

// --- Validate required parameters ---
if (params.input == null) {
error "Missing required parameter: --input"
}

if (params.name == null) {
error "Missing required parameter: --name"
}

if (params.human_fasta == null) {
error "Missing required parameter: --human_fasta"
}

if (params.mouse_fasta == null) {
error "Missing required parameter: --mouse_fasta"
}

raw_expression_dataset_channel = Channel
// --- Stage the lib/ directory so Python scripts can import from it ---
ch_lib = Channel.value(file("${projectDir}/lib", checkIfExists: true))

// --- Input channels ---
// Queue channel: one tuple per dataset
ch_expression = Channel
.fromPath(params.input, checkIfExists: true)
.map { raw_expression_dataset -> tuple(params.name, raw_expression_dataset) }
.map { f -> tuple(params.name, f) }

human_promoter_fasta_channel = Channel.fromPath(params.human_fasta, checkIfExists: true)
mouse_promoter_fasta_channel = Channel.fromPath(params.mouse_fasta, checkIfExists: true)
original_gene_list_channel = Channel.fromPath(params.input, checkIfExists: true)
// Value channels for single files (reusable across all items in the queue)
ch_human_fasta = Channel.value(file(params.human_fasta, checkIfExists: true))
ch_mouse_fasta = Channel.value(file(params.mouse_fasta, checkIfExists: true))
ch_gene_list = Channel.value(file(params.input, checkIfExists: true))

LABEL_GENE_PAIRS(raw_expression_dataset_channel)
// --- Step 1: Label gene pairs ---
LABEL_GENE_PAIRS(
ch_expression,
ch_lib
)

// --- Step 2: Encode sequences and split into train/val/test ---
ENCODE_AND_SPLIT_PAIRS(
LABEL_GENE_PAIRS.out.labeled_pairs,
human_promoter_fasta_channel,
mouse_promoter_fasta_channel,
original_gene_list_channel
ch_human_fasta,
ch_mouse_fasta,
ch_gene_list,
ch_lib
)

TRAIN_AND_EVALUATE_MODEL(ENCODE_AND_SPLIT_PAIRS.out.split_directory)
// --- Step 3: Train and evaluate the model ---
TRAIN_AND_EVALUATE_MODEL(
ENCODE_AND_SPLIT_PAIRS.out.split_directory,
ch_lib
)
}