Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5127 new module xenium ranger #6826

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9ec866c
Initial commit for the xeniumranger module
May 17, 2024
ae9bc52
test file correction, placeholder code for relabel
May 17, 2024
631481c
minor fix for segmentation input for xenium import-segmentation
May 17, 2024
fe10e6a
test cases for xenium modules
May 20, 2024
e2a05e2
changes in test config, minor fixes for dockerfile versioning, test s…
May 21, 2024
8294642
updated container image for xeniumranger
May 24, 2024
fee6db0
Updated xeniumranger version hence the dockerfile, added newer submod…
khersameesh24 Oct 10, 2024
54a02a8
Updated xeniumranger version hence the dockerfile, added newer submod…
khersameesh24 Oct 10, 2024
79ed3ba
testing xenium modules, tests for rename module
khersameesh24 Oct 18, 2024
9fff425
minor fixes for relabel
Oct 18, 2024
bf94049
fix for outs directory
Oct 18, 2024
147e3b3
minor fixes for resegment
Oct 18, 2024
bb1893b
tested xeniumranger modules with test data, fixed nf-test, testdata f…
Oct 21, 2024
f407f0d
fixed linting issues with xenium modules
Oct 22, 2024
9b34ee1
minor typo fix
Oct 22, 2024
e636fa5
minor typo fix
Oct 22, 2024
b2c99ad
Merge branch '5127-new-module-xenium-ranger' of https://github.com/kh…
Tobiaspk Oct 22, 2024
840b977
linting fix, nf-test fix for unstable checksums
khersameesh24 Oct 23, 2024
9278936
Merge branch 'master' into 5127-new-module-xenium-ranger
khersameesh24 Oct 23, 2024
28fbeb3
Add import-segmentation tests
Tobiaspk Oct 24, 2024
e44b6b5
Rename viz_polygon parameter
Tobiaspk Oct 24, 2024
4967ce0
Fix testdata source
Tobiaspk Oct 24, 2024
7df986f
Merge branch '5127-new-module-xenium-ranger' of https://github.com/kh…
Tobiaspk Oct 24, 2024
c09464e
conda fix for ci workflow, test with resegment
khersameesh24 Oct 28, 2024
7cd6c88
Merge pull request #2 from Tobiaspk/5127-new-module-xenium-ranger
khersameesh24 Oct 28, 2024
72e2c4b
fix for some snapshots, added newer segmentation tests
khersameesh24 Oct 29, 2024
4c7b5f3
Merge branch 'master' into 5127-new-module-xenium-ranger
khersameesh24 Oct 29, 2024
b4bb59a
snapshot fix for xenium modules - import-segmentation, relabel
khersameesh24 Oct 29, 2024
9352e67
minor changes for snapshots
khersameesh24 Oct 29, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,15 @@ jobs:
path: subworkflows/nf-core/fastq_align_bwa
- profile: conda
path: subworkflows/nf-core/fasta_newick_epang_gappa
- profile: conda
path: modules/nf-core/xeniumranger/relabel
- profile: conda
path: modules/nf-core/xeniumranger/rename
- profile: conda
path: modules/nf-core/xeniumranger/resegment
- profile: conda
path: modules/nf-core/xeniumranger/import-segmentation

env:
NXF_ANSI_LOG: false
NFTEST_VER: "0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rev: "v4.0.0-alpha.8"
rev: "v3.1.0"

please keep the original version. We want to use the currently stable version of prettier.

hooks:
- id: prettier
additional_dependencies:
Expand Down
Empty file.
29 changes: 29 additions & 0 deletions modules/nf-core/xeniumranger/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use a base image with the required operating system
FROM ubuntu:20.04 AS builder

LABEL authors="Sameesh Kher <[email protected]>" \
description="Docker image containing Xenium Ranger"

RUN apt-get update --allow-releaseinfo-change \
&& apt-get install -y \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# copy over xeniumranger
# the latest version of the xeniumranger tool has been downloaded from https://www.10xgenomics.com/support/software/xenium-ranger/downloads
COPY xeniumranger-3.0.1.tar.gz /xeniumranger-3.0.1.tar.gz

# install xenium ranger
RUN tar -xzvf /xeniumranger-3.0.1.tar.gz && \
rm /xeniumranger-3.0.1.tar.gz

# Set environment variables
# ENV PATH="xeniumranger-xenium3.0/bin:$PATH"

# multistage to reduce image size
FROM ubuntu:20.04

# Set environment variables
ENV PATH="/xeniumranger-xenium3.0/bin:$PATH"

# copy over xenium from builder
COPY --from=builder /xeniumranger-xenium3.0 /xeniumranger-xenium3.0/
20 changes: 20 additions & 0 deletions modules/nf-core/xeniumranger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Updating the docker container and making a new module release

Xenium Ranger is a commercial tool from 10X Genomics. The container provided for the xeniumranger nf-core module is not provided nor supported by 10x Genomics. Updating the Xenium Ranger versions in the container and pushing the update to Dockerhub needs to be done manually.

1. Navigate to the appropriate download page. - [Xenium Ranger](https://www.10xgenomics.com/support/software/xenium-ranger/downloads): download the tar ball of the desired Xenium Ranger version with `curl` or `wget`. Place this file in the same folder where the Dockerfile lies.

2. Edit the Dockerfile. Update the Xenium Ranger versions in this line:
(current version for xenium ranger is fixated at [3.0.1](https://www.10xgenomics.com/support/software/xenium-ranger/downloads) in the dockerfile)

3. Create and test the container:

```bash
docker build . -t quay.io/nf-core/xeniumranger:<VERSION>
```

4. Access rights are needed to push the container to the Dockerhub nfcore organization, please ask a core team member to do so.

```bash
docker push quay.io/nf-core/xeniumranger:<VERSION>
```
82 changes: 82 additions & 0 deletions modules/nf-core/xeniumranger/import-segmentation/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
process XENIUMRANGER_IMPORT_SEGMENTATION {
tag "$meta.id"
label 'process_high'

container "nf-core/xeniumranger:3.0.1"

input:
val(meta)
path(xenium_bundle)
val(expansion_distance)
path(coordinate_transform)
path(nuclei)
path(cells)
path(transcript_assignment)
path(viz_polygons)

output:
tuple val(meta), path("**/outs/**"), emit: outs
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 "XENIUMRANGER_IMPORT-SEGMENTATION module does not support Conda. Please use Docker / Singularity / Podman instead."
}
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

// image based segmentation options
def expansion_distance = expansion_distance ? "--expansion-distance=\"${expansion_distance}\"": "" // expansion distance (default - 5, range - 0 - 100)
def coordinate_transform = coordinate_transform ? "--coordinate-transform=\"${coordinate_transform}\"": ""

def nuclei_detection = nuclei ? "--nuclei=\"${nuclei}\"": ""
def cells = cells ? "--cells=\"${cells}\"": ""

// transcript based segmentation
def transcript_assignment = transcript_assignment ? "--transcript-assignment=\"${transcript_assignment}\"": ""
def viz_polygons = viz_polygons ? "--viz-polygons=\"${viz_polygons}\"":""

// shared argument
def units = coordinate_transform ? "--units=microns": "--units=pixels"

"""
xeniumranger import-segmentation \\
--id="${prefix}" \\
--xenium-bundle="${xenium_bundle}" \\
--localcores=${task.cpus} \\
--localmem=${task.memory.toGiga()} \\
${coordinate_transform} \\
${nuclei_detection} \\
${cells} \\
${expansion_distance} \\
${transcript_assignment} \\
${viz_polygons} \\
${units} \\
${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
xeniumranger: \$(xeniumranger -V | sed -e "s/xeniumranger-/- /g")
END_VERSIONS
"""

stub:
// Exit if running this module with -profile conda / -profile mamba
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
error "XENIUMRANGER_IMPORT-SEGMENTATION module does not support Conda. Please use Docker / Singularity / Podman instead."
}
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir -p "${prefix}/outs/"
touch "${prefix}/outs/fake_file.txt"

cat <<-END_VERSIONS > versions.yml
"${task.process}":
xeniumranger: \$(xeniumranger -V | sed -e "s/xeniumranger-/- /g")
END_VERSIONS
"""
}
84 changes: 84 additions & 0 deletions modules/nf-core/xeniumranger/import-segmentation/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: xeniumranger_import_segmentation
description: The xeniumranger import-segmentation module allows you to specify 2D
nuclei and/or cell segmentation results for assigning transcripts to cells and recalculate
all Xenium Onboard Analysis (XOA) outputs that depend on segmentation. Segmentation
results can be generated by community-developed tools or prior Xenium segmentation
result.
keywords:
- spatial
- segmentation
- import segmentation
- nuclear segmentation
- cell segmentation
- xeniumranger
- imaging
tools:
- xeniumranger:
description: |
Xenium Ranger is a set of analysis pipelines that process Xenium In Situ Gene Expression data to relabel, resegment, or import new segmentation results from community-developed tools. Xenium Ranger provides flexible off-instrument reanalysis of Xenium In Situ data. Relabel transcripts, resegment cells with the latest 10x segmentation algorithms, or import your own segmentation data to assign transcripts to cells.
homepage: "https://www.10xgenomics.com/support/software/xenium-ranger/latest"
documentation: "https://www.10xgenomics.com/support/software/xenium-ranger/latest/getting-started"
tool_dev_url: "https://www.10xgenomics.com/support/software/xenium-ranger/latest/analysis"
licence:
- "10x Genomics EULA"
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing run information
e.g. [id:'xenium_bundle_path']
- - xenium_bundle:
type: directory
description: Path to the xenium output bundle generated by the Xenium Onboard
Analysis pipeline
- - expansion_distance:
type: integer
description: Nuclei boundary expansion distance in µm. Only for use when nucleus
segmentation provided as input. Default-5 (accepted range 0 - 100)
- - coordinate_transform:
type: file
description: Image alignment file containing similarity transform matrix e.g.,
the _imagealignment.csv file exported from Xenium Explorer
- - nuclei:
type: file
description: |
Label mask (TIFF or NPY), polygons of nucleus segmentations (GeoJSON FeatureCollection), or Xenium Onboard Analysis cells.zarr.zip (the nucleus masks as input).
--nuclei will use nucleusGeometry polygon if it exists in the GeoJSON (i.e., for QuPath-like GeoJSON files),
or geometry if it does not. Error if --transcript-assignment argument is used.
- - cells:
type: file
description: |
Label mask (TIFF or NPY), polygons of cell segmentations (GeoJSON FeatureCollection), or Xenium Onboard Analysis cells.zarr.zip (the cell masks as input).
Features with a non-cell objectType will be ignored. Error if --transcript-assignment argument is used.
In Xenium Ranger v2.0, --nuclei no longer needs to be used with --cells.
- - transcript_assignment:
type: file
description: |
Transcript CSV with cell assignment from Baysor v0.6. Error if --cells or --nuclei arguments are used.
- - viz_polygons:
type: file
description: |
Cell boundary polygons (GeoJSON) for visualization from Baysor v0.6. Required if --transcript-assignment argument used. Error if --cells or --nuclei arguments used.
output:
- outs:
- meta:
type: file
description: Files containing the outputs of Cell Ranger, see official 10X Genomics
documentation for a complete list
pattern: "${meta.id}/outs/*"
- "**/outs/**":
type: file
description: Files containing the outputs of xenium ranger, see official 10X
Genomics documentation for a complete list of outputs
pattern: "${meta.id}/outs/*"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@khersameesh24"
maintainers:
- "@khersameesh24"
Loading
Loading