Skip to content

A draft of a simple module to discuss nf-core - #1

Draft
Claptar wants to merge 23 commits into
mainfrom
anndatautils_toh5ad
Draft

A draft of a simple module to discuss nf-core#1
Claptar wants to merge 23 commits into
mainfrom
anndatautils_toh5ad

Conversation

@Claptar

@Claptar Claptar commented May 2, 2025

Copy link
Copy Markdown

This PR is my attempt to stick to nf-core best practices as much as possible

The following changes were introduced:

  • Created a new tool anndatautils for any modules related to AnnData manipulations
  • Added anndatautils/toh5ad module
  • Created tests/data folder for test data
  • Created tests/configs folder for all test related configs
  • Created nf-test.config file

⚠️ TODO: add conversion of .zarr file

cellgeni added 16 commits April 30, 2025 16:08
- Added new binary files: pbmc_1k.h5, barcodes.tsv.gz, features.tsv.gz, and matrix.mtx.gz to the anndatautils directory.
- Updated the Nextflow test for the anndatautils/toh5ad module to validate the conversion of .h5 files to .h5ad format.
- Improved assertions in the test to check for successful process execution and correct output file generation.
- Added pbmc_1k.h5 file containing the PBMC 1K dataset.
- Included barcodes.tsv.gz, features.tsv.gz, and matrix.mtx.gz files in the raw_feature_bc_matrix directory for the dataset.
…ta paths to use params for improved flexibility

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the new tool module "anndatautils/toh5ad" designed for converting AnnData-compatible files into AnnData objects saved as .h5ad files.

  • New meta file defines module metadata
  • Module configuration for input/output and authorship is added
Files not reviewed (7)
  • modules/sanger/anndatautils/toh5ad/Dockerfile: Language not supported
  • modules/sanger/anndatautils/toh5ad/main.nf: Language not supported
  • modules/sanger/anndatautils/toh5ad/module.config: Language not supported
  • modules/sanger/anndatautils/toh5ad/tests/main.nf.test: Language not supported
  • modules/sanger/anndatautils/toh5ad/tests/main.nf.test.snap: Language not supported
  • nf-test.config: Language not supported
  • tests/configs/nf-test.config: Language not supported

Comment thread modules/sanger/anndatautils/toh5ad/meta.yml Outdated
@Claptar

Claptar commented May 2, 2025

Copy link
Copy Markdown
Author

I still need to add .zarr file conversion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dockerfile goes to dockage?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Docker file for this module is already on dockage. I think it would still be good to reference Dockerfile somehow. Either by putting it in the module directory or by leaving a link to dockage in meta.yml or README.md file

type: string
description: |
Sample ID to be used as obs_names in the AnnData object
- - input:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be a single dash. Otherwise, it means sample_id, input and delimiter are the same level.
Also, maybe it's worth renaming input to be some thing more concrete? What type of data do you have in mind?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fix dashes, thank you! Well, input can be either file or directory, so I struggled to come up with better name

params {
publish_dir_mode = "copy"
singularity_pull_docker_container = false
test_data_base = "${projectDir}/tests/data/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we may need a collective decision on this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. I added this just as a draft to enable testing

Claptar and others added 2 commits May 3, 2025 11:45
@Claptar Claptar self-assigned this May 3, 2025
@Claptar Claptar changed the title Anndatautils toh5ad A draft of a simple module to discuss nf-core May 3, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 14 changed files in this pull request and generated 2 comments.

Suppressed comments (11)

modules/sanger/anndatautils/toh5ad/tests/main.nf.test:54

  • Typo in comment: "basec run health" → "basic run health".
            // basec run health

modules/sanger/anndatautils/toh5ad/tests/main.nf.test:90

  • Typo in comment: "basec run health" → "basic run health".
            // basec run health

tests/config/nf-test.config:21

  • This singularity profile hard-codes site-specific bind mounts and a cache directory (/lustre, /nfs, /nfs/cellgeni/...). That makes the test config non-portable and likely to fail in CI or on other environments.
        singularity.enabled    = true
        singularity.autoMounts = true
        singularity.runOptions = '-B /lustre,/nfs'
        singularity.cacheDir   = '/nfs/cellgeni/singularity/images/'
    }

modules/sanger/anndatautils/toh5ad/main.nf:8

  • path(input, name: 'input/*') uses an option name that isn't used elsewhere in this repo for staging paths (e.g. other modules use stageAs:). This may not stage inputs into input/* as intended.
        tuple val(sample_id), path(input, name: 'input/*')

modules/sanger/anndatautils/toh5ad/main.nf:5

  • The module container is pinned to :latest, which is non-reproducible and inconsistent with the rest of this repo (no other module uses :latest). Please pin to a specific tag or digest.
    container 'docker://quay.io/cellgeni/metacells-python:latest'

modules/sanger/anndatautils/toh5ad/meta.yml:37

  • The metadata says sample_id is used as obs_names, but the implementation stores it in adata.obs["sample"] (and only affects obs.index when --delimiter is set). This is misleading for module users.
        description: |
          Sample ID to be used as obs_names in the AnnData object
    - input:

modules/sanger/anndatautils/toh5ad/meta.yml:44

  • The metadata describes the delimiter behavior as sample_id + delimiter + barcode, but the script builds barcode + delimiter + sample_id (and names the index barcode_sample). The meta.yml should match the implemented behavior.
        type: string
        description: |
          Delimiter to be used to create obs_names in the format sample_id + delimiter + barcode

modules/sanger/anndatautils/toh5ad/meta.yml:52

  • The output metadata says sample_id was used as obs_names, but the script uses it as an obs["sample"] value (and may incorporate it into obs_names only when delimiter is set).
        type: string
        description: |
          Sample ID that was used as obs_names in the AnnData object
    - "*.h5ad":

modules/sanger/anndatautils/toh5ad/Dockerfile:33

  • This Dockerfile installs several large notebook/interactive packages (e.g. jupyterlab, notebook, ipywidgets, papermill) that aren't needed by convert_to_h5ad.py and will significantly increase image size and build time.
    uv pip install --no-cache-dir \
    scanpy \
    numpy \
    pandas \
    muon \
    scikit-network \
    jupyterlab \
    notebook \
    tqdm \
    ipywidgets \
    papermill

modules/sanger/anndatautils/toh5ad/tests/main.nf.test:9

  • Trailing whitespace after tag "anndatautils".
    tag "anndatautils" 

modules/sanger/anndatautils/toh5ad/tests/main.nf.test:23

  • Typo in comment: "basec run health" → "basic run health".

This issue also appears in the following locations of the same file:

  • line 54
  • line 90
            // basec run health

Comment thread nf-test.config
config {
testsDir "."
workDir ".nf-test"
configFile "./tests/configs/nf-test.config"
Comment on lines +1 to +12
process {
withName: "*ANNDATAUTILS_TOH5AD" {
queue = 'normal'
cpus = 4
memory = { 16.GB + 32.GB * (task.attempt - 1) }
publishDir = [
mode : params.publish_mode,
path : "${outputDir}/adata/raw",
overwrite: true
]
}
} No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants