{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "process_integrate_annotate",
  "description": "A pipeline to process, integrate and annotate single cell (multi-)omics data.\nAvailable integration methods:\n- Harmony\n- scVI\nAvailable annotation methods:\n- CellTypist\n- scANVI (with scArches)\n",
  "type": "object",
  "$defs": {
    "outputs": {
      "title": "Outputs",
      "type": "object",
      "description": "The output file to write the annotated dataset to.",
      "properties": {
        "output": {
          "type": "string",
          "format": "path",
          "description": "The output file.\n",
          "help_text": "Type: `file`, multiple: `False`, required, default: `\"$id.$key.output.h5mu\"`, direction: `output`, example: `\"output.h5mu\"`. ",
          "default": "$id.$key.output.h5mu"
        }
      }
    },
    "input (query) data arguments": {
      "title": "Input (query) data arguments",
      "type": "object",
      "description": "The input query dataset(s) to be annotated",
      "properties": {
        "id": {
          "type": "string",
          "description": "ID of the sample.",
          "help_text": "Type: `string`, multiple: `False`, required, example: `\"foo\"`. "
        },
        "input": {
          "type": "string",
          "format": "path",
          "exists": true,
          "description": "Input query dataset(s) to be annotated",
          "help_text": "Type: `file`, multiple: `False`, required, direction: `input`, example: `\"input.h5mu\"`. "
        },
        "modality": {
          "type": "string",
          "description": "Modality to be processed",
          "help_text": "Type: `string`, multiple: `False`, default: `\"rna\"`. ",
          "default": "rna"
        },
        "input_layer": {
          "type": "string",
          "description": "The layer in the input data containing the raw counts, if .X is not to be used.",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "input_var_gene_names": {
          "type": "string",
          "description": "The name of the adata var column containing gene names; when no gene_name_layer is provided, the var index will be used.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "input_reference_gene_overlap": {
          "type": "integer",
          "description": "The minimum number of genes present in both the reference and query datasets.\n",
          "help_text": "Type: `integer`, multiple: `False`, default: `100`. ",
          "default": 100
        }
      }
    },
    "reference data arguments": {
      "title": "Reference data arguments",
      "type": "object",
      "description": "Dataset to be used as a reference for label transfer and to train annotation algorithms on.",
      "properties": {
        "reference": {
          "type": "string",
          "format": "path",
          "description": "The reference dataset in .h5mu format to be used as a reference mapper and to train annotation algorithms on.\n",
          "help_text": "Type: `file`, multiple: `False`, direction: `input`, example: `\"reference.h5mu\"`. "
        },
        "reference_layer_raw_counts": {
          "type": "string",
          "description": "The layer in the reference dataset containing the raw counts, if .X is not to be used.",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "reference_layer_lognormalized_counts": {
          "type": "string",
          "description": "The layer in the reference dataset containing the log-normalized counts, if .X is not to be used.",
          "help_text": "Type: `string`, multiple: `False`, default: `\"log_normalized\"`. ",
          "default": "log_normalized"
        },
        "reference_var_gene_names": {
          "type": "string",
          "description": "The name of the adata .var column containing gene names if the .var index is not to be used.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "reference_obs_batch": {
          "type": "string",
          "description": "The .obs column of the reference dataset containing the batch information.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "reference_obs_label": {
          "type": "string",
          "description": "The `.obs` key of the target labels to tranfer.",
          "help_text": "Type: `string`, multiple: `False`, example: `\"cell_type\"`. "
        },
        "reference_obs_label_unlabeled_category": {
          "type": "string",
          "description": "Value in the --reference_obs_label field that indicates unlabeled observations",
          "help_text": "Type: `string`, multiple: `False`, default: `\"Unkown\"`. ",
          "default": "Unkown"
        },
        "reference_var_input": {
          "type": "string",
          "description": ".var column containing highly variable genes",
          "help_text": "Type: `string`, multiple: `False`. "
        }
      }
    },
    "methods": {
      "title": "Methods",
      "type": "object",
      "description": "The available annotation and integration methods to integrate and/or annotate the query dataset(s) with.",
      "properties": {
        "integration_methods": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Integration methods to be executed.",
          "help_text": "Type: `string`, multiple: `True`, example: `[\"harmony;scvi\"]`, choices: ``harmony`, `scvi``. "
        },
        "annotation_methods": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Annotation methods to be executed.",
          "help_text": "Type: `string`, multiple: `True`, example: `[\"celltypist;scanvi_scarches\"]`, choices: ``celltypist`, `scanvi_scarches``. "
        }
      }
    },
    "pre-processing options: rna filtering": {
      "title": "Pre-processing options: RNA filtering",
      "type": "object",
      "description": "Pre-processing options for filtering RNA data",
      "properties": {
        "rna_min_counts": {
          "type": "integer",
          "description": "Minimum number of counts captured per cell.",
          "help_text": "Type: `integer`, multiple: `False`, example: `200`. "
        },
        "rna_max_counts": {
          "type": "integer",
          "description": "Maximum number of counts captured per cell.",
          "help_text": "Type: `integer`, multiple: `False`, example: `5000000`. "
        },
        "rna_min_genes_per_cell": {
          "type": "integer",
          "description": "Minimum of non-zero values per cell.",
          "help_text": "Type: `integer`, multiple: `False`, example: `200`. "
        },
        "rna_max_genes_per_cell": {
          "type": "integer",
          "description": "Maximum of non-zero values per cell.",
          "help_text": "Type: `integer`, multiple: `False`, example: `1500000`. "
        },
        "rna_min_cells_per_gene": {
          "type": "integer",
          "description": "Minimum of non-zero values per gene.",
          "help_text": "Type: `integer`, multiple: `False`, example: `3`. "
        },
        "rna_min_fraction_mito": {
          "type": "number",
          "description": "Minimum fraction of UMIs that are mitochondrial.",
          "help_text": "Type: `double`, multiple: `False`, example: `0.0`. "
        },
        "rna_max_fraction_mito": {
          "type": "number",
          "description": "Maximum fraction of UMIs that are mitochondrial.",
          "help_text": "Type: `double`, multiple: `False`, example: `0.2`. "
        }
      }
    },
    "pre-processing options: highly variable features detection": {
      "title": "Pre-processing options: Highly variable features detection",
      "type": "object",
      "description": "Pre-processing options for detecting highly variable features",
      "properties": {
        "n_hvg": {
          "type": "integer",
          "description": "Number of highly-variable features to keep",
          "help_text": "Type: `integer`, multiple: `False`, default: `2000`. ",
          "default": 2000
        }
      }
    },
    "pre-processing options: mitochondrial & ribosomal gene detection": {
      "title": "Pre-processing options: Mitochondrial & Ribosomal Gene Detection",
      "type": "object",
      "description": "Pre-processing options for detecting mitochondrial genes",
      "properties": {
        "var_name_mitochondrial_genes": {
          "type": "string",
          "description": "In which .var slot to store a boolean array corresponding the mitochondrial genes.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "var_name_ribosomal_genes": {
          "type": "string",
          "description": "In which .var slot to store a boolean array corresponding the ribosomal genes.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "obs_name_mitochondrial_fraction": {
          "type": "string",
          "description": "When specified, write the fraction of counts originating from mitochondrial genes \n(based on --mitochondrial_gene_regex) to an .obs column with the specified name.\nRequires --var_name_mitochondrial_genes.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "obs_name_ribosomal_fraction": {
          "type": "string",
          "description": "When specified, write the fraction of counts originating from ribosomal genes \n(based on --ribosomal_gene_regex) to an .obs column with the specified name.\nRequires --var_name_ribosomal_genes.\n",
          "help_text": "Type: `string`, multiple: `False`. "
        },
        "mitochondrial_gene_regex": {
          "type": "string",
          "description": "Regex string that identifies mitochondrial genes from --var_gene_names.\nBy default will detect human and mouse mitochondrial genes from a gene symbol.\n",
          "help_text": "Type: `string`, multiple: `False`, default: `\"^[mM][tT]-\"`. ",
          "default": "^[mM][tT]-"
        },
        "ribosomal_gene_regex": {
          "type": "string",
          "description": "Regex string that identifies ribosomal genes from --var_gene_names.\nBy default will detect human and mouse ribosomal genes from a gene symbol.\n",
          "help_text": "Type: `string`, multiple: `False`, default: `\"^[Mm]?[Rr][Pp][LlSs]\"`. ",
          "default": "^[Mm]?[Rr][Pp][LlSs]"
        }
      }
    },
    "pre-processing options: qc metrics calculation options": {
      "title": "Pre-processing options: QC metrics calculation options",
      "type": "object",
      "description": "Pre-processing options for calculating QC metrics",
      "properties": {
        "var_qc_metrics": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Keys to select a boolean (containing only True or False) column from .var.\nFor each cell, calculate the proportion of total values for genes which are labeled 'True', \ncompared to the total sum of the values for all genes",
          "help_text": "Type: `string`, multiple: `True`, example: `[\"ercc,highly_variable\"]`. "
        }
      }
    },
    "harmony integration options": {
      "title": "Harmony integration options",
      "type": "object",
      "description": "Specifications for harmony integration.",
      "properties": {
        "harmony_theta": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "Diversity clustering penalty parameter",
          "help_text": "Type: `double`, multiple: `True`, default: `[2.0]`, example: `[0.0;1.0;2.0]`. ",
          "default": [
            2.0
          ]
        },
        "harmony_obs_covariates": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The .obs field(s) that define the covariate(s) to regress out.",
          "help_text": "Type: `string`, multiple: `True`, required, default: `[\"sample_id\"]`, example: `[\"batch\";\"sample\"]`. ",
          "default": [
            "sample_id"
          ]
        }
      }
    },
    "scvi, scanvi and scarches training options": {
      "title": "scVI, scANVI and scArches training options",
      "type": "object",
      "description": "Training arguments for scVI, scANVI and scArches. Relevant for --annotation_methods 'scvi_knn' and 'scanvi_scarches'.",
      "properties": {
        "early_stopping": {
          "type": "boolean",
          "description": "Whether to perform early stopping with respect to the validation set.",
          "help_text": "Type: `boolean`, multiple: `False`. "
        },
        "early_stopping_monitor": {
          "type": "string",
          "description": "Metric logged during validation set epoch.",
          "help_text": "Type: `string`, multiple: `False`, default: `\"elbo_validation\"`, choices: ``elbo_validation`, `reconstruction_loss_validation`, `kl_local_validation``. ",
          "enum": [
            "elbo_validation",
            "reconstruction_loss_validation",
            "kl_local_validation"
          ],
          "default": "elbo_validation"
        },
        "early_stopping_patience": {
          "type": "integer",
          "description": "Number of validation epochs with no improvement after which training will be stopped.",
          "help_text": "Type: `integer`, multiple: `False`, default: `45`. ",
          "default": 45
        },
        "early_stopping_min_delta": {
          "type": "number",
          "description": "Minimum change in the monitored quantity to qualify as an improvement, i.e",
          "help_text": "Type: `double`, multiple: `False`, default: `0.0`. ",
          "default": 0.0
        },
        "max_epochs": {
          "type": "integer",
          "description": "Number of passes through the dataset, defaults to (20000 / number of cells) * 400 or 400; whichever is smallest.",
          "help_text": "Type: `integer`, multiple: `False`. "
        },
        "reduce_lr_on_plateau": {
          "type": "boolean",
          "description": "Whether to monitor validation loss and reduce learning rate when validation set `lr_scheduler_metric` plateaus.",
          "help_text": "Type: `boolean`, multiple: `False`, default: `true`. ",
          "default": true
        },
        "lr_factor": {
          "type": "number",
          "description": "Factor to reduce learning rate.",
          "help_text": "Type: `double`, multiple: `False`, default: `0.6`. ",
          "default": 0.6
        },
        "lr_patience": {
          "type": "number",
          "description": "Number of epochs with no improvement after which learning rate will be reduced.",
          "help_text": "Type: `double`, multiple: `False`, default: `30.0`. ",
          "default": 30.0
        }
      }
    },
    "celltypist reference model": {
      "title": "CellTypist reference model",
      "type": "object",
      "description": "The CellTypist reference model to use for annotation. If not provided, the reference dataset will be used for model training.",
      "properties": {
        "celltypist_model": {
          "type": "string",
          "format": "path",
          "description": "Pretrained model in pkl format",
          "help_text": "Type: `file`, multiple: `False`, direction: `input`, example: `\"pretrained_model.pkl\"`. "
        }
      }
    },
    "celltypist annotation options": {
      "title": "CellTypist annotation options",
      "type": "object",
      "description": "Specifications for CellTypist annotation.",
      "properties": {
        "celltypist_feature_selection": {
          "type": "boolean",
          "description": "Whether to perform feature selection.",
          "help_text": "Type: `boolean`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "celltypist_majority_voting": {
          "type": "boolean",
          "description": "Whether to refine the predicted labels by running the majority voting classifier after over-clustering.",
          "help_text": "Type: `boolean`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "celltypist_C": {
          "type": "number",
          "description": "Inverse of regularization strength in logistic regression.",
          "help_text": "Type: `double`, multiple: `False`, default: `1.0`. ",
          "default": 1.0
        },
        "celltypist_max_iter": {
          "type": "integer",
          "description": "Maximum number of iterations before reaching the minimum of the cost function.",
          "help_text": "Type: `integer`, multiple: `False`, default: `1000`. ",
          "default": 1000
        },
        "celltypist_use_SGD": {
          "type": "boolean",
          "description": "Whether to use the stochastic gradient descent algorithm.",
          "help_text": "Type: `boolean_true`, multiple: `False`, default: `false`. ",
          "default": false
        },
        "celltypist_min_prop": {
          "type": "number",
          "description": "\"For the dominant cell type within a subcluster, the minimum proportion of cells required to \nsupport naming of the subcluster by this cell type",
          "help_text": "Type: `double`, multiple: `False`, default: `0.0`. ",
          "default": 0.0
        }
      }
    },
    "clustering options": {
      "title": "Clustering options",
      "type": "object",
      "description": "Arguments for Leiden clustering. Only relevant for --annotation_methods `scvi_knn`, `scanvi_scarches` and `harmony_knn`.",
      "properties": {
        "leiden_resolution": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "Control the coarseness of the clustering",
          "help_text": "Type: `double`, multiple: `True`, default: `[1.0]`. ",
          "default": [
            1.0
          ]
        }
      }
    },
    "neighbor classifier arguments": {
      "title": "Neighbor classifier arguments",
      "type": "object",
      "description": "Arguments related to calculating the n nearest neighbors. Only relevant for --annotation_methods `scvi_knn`, `scanvi_scarches` and `harmony_knn`.",
      "properties": {
        "knn_weights": {
          "type": "string",
          "description": "Weight function used in prediction",
          "help_text": "Type: `string`, multiple: `False`, default: `\"uniform\"`, choices: ``uniform`, `distance``. ",
          "enum": [
            "uniform",
            "distance"
          ],
          "default": "uniform"
        },
        "knn_n_neighbors": {
          "type": "integer",
          "description": "The number of neighbors to use in k-neighbor graph structure used for fast approximate nearest neighbor search with PyNNDescent",
          "help_text": "Type: `integer`, multiple: `False`, default: `15`. ",
          "default": 15
        }
      }
    },
    "nextflow input-output arguments": {
      "title": "Nextflow input-output arguments",
      "type": "object",
      "description": "Input/output parameters for Nextflow itself. Please note that both publishDir and publish_dir are supported but at least one has to be configured.",
      "properties": {
        "publish_dir": {
          "type": "string",
          "description": "Path to an output directory.",
          "help_text": "Type: `string`, multiple: `False`, required, example: `\"output/\"`. "
        }
      }
    }
  },
  "allOf": [
    {
      "$ref": "#/$defs/outputs"
    },
    {
      "$ref": "#/$defs/input (query) data arguments"
    },
    {
      "$ref": "#/$defs/reference data arguments"
    },
    {
      "$ref": "#/$defs/methods"
    },
    {
      "$ref": "#/$defs/pre-processing options: rna filtering"
    },
    {
      "$ref": "#/$defs/pre-processing options: highly variable features detection"
    },
    {
      "$ref": "#/$defs/pre-processing options: mitochondrial & ribosomal gene detection"
    },
    {
      "$ref": "#/$defs/pre-processing options: qc metrics calculation options"
    },
    {
      "$ref": "#/$defs/harmony integration options"
    },
    {
      "$ref": "#/$defs/scvi, scanvi and scarches training options"
    },
    {
      "$ref": "#/$defs/celltypist reference model"
    },
    {
      "$ref": "#/$defs/celltypist annotation options"
    },
    {
      "$ref": "#/$defs/clustering options"
    },
    {
      "$ref": "#/$defs/neighbor classifier arguments"
    },
    {
      "$ref": "#/$defs/nextflow input-output arguments"
    }
  ]
}
