Skip to content
Merged
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
26 changes: 10 additions & 16 deletions assets/multiqc_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,19 @@ export_plots: true

disable_version_detection: true

run_module:
- xenium

module_order:
- xenium

log_filesize_limit: 5000000000 # 5GB

sp:
cell_feature_matrix:
fn: cell_feature_matrix.h5
cells:
fn: cells.parquet
experiment:
fn: experiment.xenium
xenium/cell_feature_matrix:
fn: "*/cell_feature_matrix.h5"
xenium/cells:
fn: "*/cells.parquet"
xenium/experiment:
fn: "*/experiment.xenium"
num_lines: 50
metrics:
xenium/metrics:
contents: num_cells_detected
fn: metrics_summary.csv
fn: "*/metrics_summary.csv"
num_lines: 5
transcripts:
fn: transcripts.parquet
xenium/transcripts:
fn: "*/transcripts.parquet"
22 changes: 22 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ process {
path: "${params.outdir}/xeniumranger/resegment",
mode: params.publish_dir_mode
]
ext.prefix = {"${meta.id}"}
}

withName: XENIUMRANGER_IMPORT_SEGMENTATION {
publishDir = [
path: "${params.outdir}/xeniumranger/import_segementation",
mode: params.publish_dir_mode
]
ext.prefix = {"${meta.id}"}
}

withName: FICTURE_PREPROCESS {
Expand Down Expand Up @@ -152,4 +154,24 @@ process {
ext.args = { "--diameter 9 --channel_axis 0 --save_flows" }
}

withName: OPT_FLIP {
Comment thread
khersameesh24 marked this conversation as resolved.
publishDir = [
path: { "${params.outdir}/opt/flip" },
mode: params.publish_dir_mode,
]
}

withName: OPT_TRACK {
publishDir = [
path: { "${params.outdir}/opt/track" },
mode: params.publish_dir_mode,
]
}

withName: OPT_STAT {
publishDir = [
path: { "${params.outdir}/opt/stat" },
mode: params.publish_dir_mode,
]
}
}
9 changes: 6 additions & 3 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
"opt/flip": {
"branch": "master",
"git_sha": "66d5baa4e9b6ac3ab95e84f88709b8e3ebf4b62b",
"installed_by": ["modules"]
"installed_by": ["modules"],
"patch": "modules/nf-core/opt/flip/opt-flip.diff"
},
"opt/stat": {
"branch": "master",
"git_sha": "66d5baa4e9b6ac3ab95e84f88709b8e3ebf4b62b",
"installed_by": ["modules"]
"installed_by": ["modules"],
"patch": "modules/nf-core/opt/stat/opt-stat.diff"
},
"opt/track": {
"branch": "master",
"git_sha": "66d5baa4e9b6ac3ab95e84f88709b8e3ebf4b62b",
"installed_by": ["modules"]
"installed_by": ["modules"],
"patch": "modules/nf-core/opt/track/opt-track.diff"
},
"untar": {
"branch": "master",
Expand Down
11 changes: 8 additions & 3 deletions modules/local/baysor/create_dataset/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ process BAYSOR_CREATE_DATASET {
val(sample_fraction)

output:
tuple val(meta), path("sampled_transcripts.csv"), emit: sampled_transcripts
path("versions.yml") , emit: versions
tuple val(meta), path("${prefix}/sampled_transcripts.csv"), emit: sampled_transcripts
path("versions.yml") , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -21,6 +21,8 @@ process BAYSOR_CREATE_DATASET {
error "BAYSOR_CREATE_DATASET module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

template 'create_dataset.py'

stub:
Expand All @@ -29,8 +31,11 @@ process BAYSOR_CREATE_DATASET {
error "BAYSOR_CREATE_DATASET module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

"""
touch sampled_transcripts.csv
mkdir -p ${prefix}
touch "${prefix}/sampled_transcripts.csv"

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
11 changes: 7 additions & 4 deletions modules/local/baysor/create_dataset/templates/create_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def generate_dataset(
transcripts: Path,
sampled_transcripts: Path,
sample_fraction: float = 0.3,
random_state: int = 42
random_state: int = 42,
prefix: str = ""
) -> None:
"""
Reads a csv file & randomly samples a fraction of rows,
Expand All @@ -28,8 +29,8 @@ def generate_dataset(
"""

random.seed(random_state)

with open(transcripts, mode='rt', newline='') as infile, \
output_path = f"{prefix}/{transcripts}"
with open(output_path, mode='rt', newline='') as infile, \
open(sampled_transcripts, mode='wt', newline='') as outfile:

reader = csv.reader(infile)
Expand Down Expand Up @@ -61,13 +62,15 @@ def main() -> None:
"""
transcripts: str = "${transcripts}"
sample_fraction: float = "${sample_fraction}"
prefix: str = "${meta.id}"
sampled_transcripts: str = "sampled_transcripts.csv"

# generate dataset
BaysorPreview.generate_dataset (
transcripts=transcripts,
sampled_transcripts=sampled_transcripts,
sample_fraction=sample_fraction
sample_fraction=sample_fraction,
prefix=prefix
)

# generate versions.yml
Expand Down
21 changes: 17 additions & 4 deletions modules/local/baysor/preprocess/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,35 @@ process BAYSOR_PREPROCESS_TRANSCRIPTS {
val(min_y)

output:
tuple val(meta), path("*.parquet"), emit: transcripts_parquet
path("versions.yml") , emit: versions
tuple val(meta),
path("${prefix}/filtered_transcripts.parquet"), emit: transcripts_parquet
path("versions.yml") , emit: versions

when:
task.ext.when == null || task.ext.when

script:
// Exit if running this module with -profile conda / -profile mamba
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error "PREPROCESS_TRANSCRIPTS module does not support Conda. Please use Docker / Singularity / Podman instead."
error "BAYSOR_PREPROCESS_TRANSCRIPTS module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

template 'preprocess_transcripts.py'

stub:
// Exit if running this module with -profile conda / -profile mamba
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error "BAYSOR_PREPROCESS_TRANSCRIPTS module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

"""
touch ${transcripts}.parquet
mkdir -p ${prefix}
touch ${prefix}/filtered_transcripts.parquet

cat <<-END_VERSIONS > versions.yml
"${task.process}":
baysor_preprocess_transcripts: "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def filter_transcripts (
min_x: float = 0.0,
max_x: float = 24000.0,
min_y: float = 0.0,
max_y: float = 24000.0
max_y: float = 24000.0,
prefix: str = ""
) -> None:
"""
Filter transcripts based on the specified thresholds
Expand Down Expand Up @@ -48,7 +49,7 @@ def filter_transcripts (

# Output filtered transcripts to parquet
filtered_df.to_parquet(
'_'.join(["X"+str(min_x)+"-"+str(max_x), "Y"+str(min_y)+"-"+str(max_y), "filtered_transcripts.parquet"]),
'_'.join(["X"+str(min_x)+"-"+str(max_x), "Y"+str(min_y)+"-"+str(max_y), f"{prefix}/filtered_transcripts.parquet"]),
index=False
)

Expand All @@ -66,9 +67,11 @@ def generate_version_yml() -> None:
if __name__ == "__main__":

transcripts: str = "${transcripts}"
prefix: str = "${meta.id}"

filter_transcripts (
transcripts=transcripts,
prefix=prefix
)

generate_version_yml()
17 changes: 12 additions & 5 deletions modules/local/baysor/preview/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ process BAYSOR_PREVIEW {
path(config)

output:
tuple val(meta), path("preview.html"), emit: preview_html
path("preview_preview_log.log") , emit: preview_log
path("versions.yml") , emit: versions
tuple val(meta), path("${prefix}/preview.html"), emit: preview_html
path("versions.yml") , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -21,14 +20,20 @@ process BAYSOR_PREVIEW {
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error "BAYSOR_PREVIEW module does not support Conda. Please use Docker / Singularity / Podman instead."
}

def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"

"""
mkdir -p ${prefix}

baysor preview \\
${transcripts} \\
--config ${config} \\
${args}

mv preview.html ${prefix}/preview.html

cat <<-END_VERSIONS > versions.yml
"${task.process}":
baysor: 0.7.1
Expand All @@ -41,9 +46,11 @@ process BAYSOR_PREVIEW {
error "BAYSOR_PREVIEW module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

"""
touch preview.html
touch preview_preview_log.log
mkdir -p ${prefix}
touch "${prefix}/preview.html"

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
40 changes: 19 additions & 21 deletions modules/local/baysor/run/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ process BAYSOR_RUN {
container "khersameesh24/baysor:0.7.1"

input:
tuple val(meta), path(transcripts)
path(prior_segmentation)
path(config)
val(scale)
tuple val(meta),
path(transcripts),
path(prior_segmentation),
path(config),
val(scale)

output:
tuple val(meta), path("segmentation.csv"), emit: segmentation
path("segmentation_polygons_2d.json") , emit: polygons2d
path("segmentation_polygons_3d.json") , emit: polygons3d
path("*.toml") , emit: params
path("*.log") , emit: log
path("*.loom") , emit: loom
path("*.html") , emit: htmls
path("segmentation_cell_stats.csv") , emit: stats
path("versions.yml") , emit: versions
tuple val(meta),
path("${prefix}/segmentation.csv"),
path("${prefix}/segmentation_polygons_2d.json"), emit: segmentation
path("versions.yml") , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -29,15 +25,20 @@ process BAYSOR_RUN {
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error "BAYSOR_RUN module does not support Conda. Please use Docker / Singularity / Podman instead."
}

def args = task.ext.args ?: ''
def prior_seg = "${prior_segmentation}" ? "${prior_segmentation}" : ""
def scaling_factor = scale ? "--scale=${scale}": ""
prefix = task.ext.prefix ?: "${meta.id}"

"""
mkdir -p ${prefix}

baysor run \\
${transcripts} \\
${prior_seg} \\
${scaling_factor} \\
--output="${prefix}/segmentation.csv" \\
--config=${config} \\
--plot \\
--polygon-format=GeometryCollectionLegacy \\
Expand All @@ -55,15 +56,12 @@ process BAYSOR_RUN {
error "BAYSOR_RUN module does not support Conda. Please use Docker / Singularity / Podman instead."
}

prefix = task.ext.prefix ?: "${meta.id}"

"""
touch segmentation.csv
touch segmentation_polygons_2d.json
touch segmentation_polygons_3d.json
touch segmentation_log.log
touch segmentation_counts.loom
touch segmentation_cell_stats.csv
touch segmentation_params.dump.toml
touch segmentation_run.html
mkdir -p ${prefix}
touch "${prefix}/segmentation.csv"
touch "${prefix}/segmentation_polygons_2d.json"

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
Loading
Loading