name: "harmony_leiden"
namespace: "workflows/integration"
scope: "public"
description: "Run harmony integration followed by neighbour calculations, leiden clustering and run umap on the result."
authors:
  - __merge__: /src/authors/dries_schaumont.yaml
    roles: [ author ]
info:
  test_dependencies:
argument_groups:
  - name: "Inputs"
    arguments:
      - name: "--input"
        required: false
        type: file
        description: Path to the sample. Mutually exclusive with the 'input_uri' argument.
        example: dataset.h5mu
      - name: "--tiledb_input_uri"
        type: string
        description: "A URI containing the TileDB-SOMA objects. Mutually exclusive with the 'input' argument."
        example: "s3://bucket/path"
      - name: "--tiledb_s3_region"
        type: string
        description: |
          Region where the TileDB-SOMA database is hosted.
        type: string
        example: "us-west-2"
      - name: "--tiledb_endpoint"
        type: string
        description: |
          Custom endpoint to use to connect to S3
        required: false
      - name: "--tiledb_s3_no_sign_request"
        description: | 
          Do not sign S3 requests. Credentials will not be loaded if this argument is provided.
        type: boolean
        default: false
  - name: "Input slots"
    arguments:
      - name: "--layer"
        default: "log_normalized"
        type: string
        description: use specified layer for expression values instead of the .X object from the modality.
        required: false
      - name: "--modality"
        description: Which modality to process.
        type: string
        default: "rna"
        required: false
  - name: "Outputs"
    arguments:
      - name: "--output"
        type: file
        required: true
        direction: output
        description: Destination path to the output.
        example: output.h5mu
      - name: "--output_tiledb"
        type: file
        direction: output
        description: |
          Output the TileDB database to the specified directory instead of adding it to the existing database.
        required: false
  - name: Neighbour calculation
    arguments:
      - name: "--uns_neighbors"
        type: string
        default: harmonypy_integration_neighbors
        description: In which .uns slot to store various neighbor output objects.
      - name: "--obsp_neighbor_distances"
        type: string
        default: "harmonypy_integration_distances"
        description: "In which .obsp slot to store the distance matrix between the resulting neighbors."
      - name: "--obsp_neighbor_connectivities"
        type: string
        default: "harmonypy_integration_connectivities"
        description: "In which .obsp slot to store the connectivities matrix between the resulting neighbors."
  - name: Harmony integration options
    arguments:
      - name: "--embedding"
        default: "X_pca"
        type: string
        description: "Embedding to use as input"
      - name: "--obsm_integrated"
        type: string
        default: "X_pca_integrated"
        required: false
        description: "In which .obsm slot to store the resulting integrated embedding."
      - name: "--obs_covariates"
        type: string
        description: "The .obs field(s) that define the covariate(s) to regress out."
        example: ["batch", "sample"]
        multiple: true
        required: true
      - name: "--theta"
        type: double
        description: |
          Diversity clustering penalty parameter. Can be set as a single value for all batch observations or as multiple values, one for each observation in the batches defined by --obs_covariates. theta=0 does not encourage any diversity. Larger values of theta
          result in more diverse clusters."
        default: 2
        multiple: true
  - name: Clustering options
    arguments:
      - name: "--obs_cluster"
        type: string
        description: |
          Prefix for the .obs keys under which to add the cluster labels. Newly created columns in .obs will 
          be created from the specified value for '--obs_cluster' suffixed with an underscore and one of the resolutions
          resolutions specified in '--leiden_resolution'.
        default: "harmony_integration_leiden"
      - name: "--leiden_resolution"
        type: double
        description: Control the coarseness of the clustering. Higher values lead to more clusters.
        default: [1]
        multiple: true
  - name: Umap options
    arguments:
      - name: "--obsm_umap"
        type: string
        default: "X_leiden_harmony_umap"
        required: false
        description: "In which .obsm slot to store the resulting UMAP embedding."
dependencies:
  - name: integrate/harmonypy
  - name: workflows/multiomics/neighbors_leiden_umap
  - name: convert/from_tiledb_to_h5mu
  - name: tiledb/move_mudata_obsm_to_tiledb
  - name: tiledb/move_mudata_obs_to_tiledb
resources:
  - type: nextflow_script
    path: main.nf
    entrypoint: run_wf
  - type: file
    path: /src/workflows/utils/
test_resources:
  - type: nextflow_script
    path: test.nf
    entrypoint: test_wf
  - type: nextflow_script
    path: test.nf
    entrypoint: test_tiledb_wf
  - type: nextflow_script
    path: test.nf
    entrypoint: test_wf2
  - path: /resources_test/pbmc_1k_protein_v3
runners:
  - type: nextflow