workflows/annotation/scanvi_scarches
Description
Cell type annotation workflow using ScanVI with scArches for reference mapping.
Query Input
Name | Type & Properties | Description |
|---|---|---|
--id | string required | ID of the sample. |
--input | file required | Input dataset consisting of the (unlabeled) query observations. The dataset is expected to be pre-processed in the same way as --reference. |
--modality | string | Which modality to process. Should match the modality of the --reference dataset. |
--layer | string | Which layer to use for integration if .X is not to be used. Should match the layer of the --reference dataset. |
--input_obs_batch_label | string required | The .obs field in the input (query) dataset containing the batch labels. |
--input_obs_size_factor | string | Key in adata.obs for size factor information. Instead of using library size as a size factor, the provided size factor column will be used as offset in the mean of the likelihood. Assumed to be on linear scale. |
--input_obs_categorical_covariate | string multiple | Keys in adata.obs that correspond to categorical data. These covariates can be added in addition to the batch covariate and are also treated as nuisance factors (i.e., the model tries to minimize their effects on the latent space). Thus, these should not be used for biologically-relevant factors that you do _not_ want to correct for. Important: the order of the categorical covariates matters and should match the order of the covariates in the reference data. |
--input_obs_continuous_covariate | string multiple | Keys in adata.obs that correspond to continuous data. These covariates can be added in addition to the batch covariate and are also treated as nuisance factors (i.e., the model tries to minimize their effects on the latent space). Thus, these should not be used for biologically-relevant factors that you do _not_ want to correct for. Important: the order of the continuous covariates matters and should match the order of the covariates in the reference data. |
--input_var_gene_names | string | .var column containing gene names. By default, use the index. |
--sanitize_ensembl_ids | boolean | Whether to sanitize ensembl ids by removing version numbers. |
Reference model
Name | Type & Properties | Description |
|---|---|---|
--reference_model | file | Path to pre-trained scANVI model. If both `--reference` and `--reference_model` are provided, the reference model will be used and the reference dataset will be ignored. |
Reference input
Name | Type & Properties | Description |
|---|---|---|
--reference | file | Reference dataset consisting of the labeled observations to train the KNN classifier on. The dataset is expected to be pre-processed in the same way as the --input query dataset. If both `--reference` and `--reference_model` are provided, the reference model will be used and the reference dataset will be ignored. |
--reference_obs_target | string | The `.obs` key containing the target labels. |
--reference_obs_batch_label | string | The .obs field in the reference dataset containing the batch labels. |
--reference_obs_size_factor | string | Key in adata.obs for size factor information. Instead of using library size as a size factor, the provided size factor column will be used as offset in the mean of the likelihood. Assumed to be on linear scale. |
--reference_obs_categorical_covariate | string multiple | Keys in adata.obs that correspond to categorical data. These covariates can be added in addition to the batch covariate and are also treated as nuisance factors (i.e., the model tries to minimize their effects on the latent space). Thus, these should not be used for biologically-relevant factors that you do _not_ want to correct for. Important: the order of the categorical covariates matters and should match the order of the covariates in the query data. |
--reference_obs_continuous_covariate | string multiple | Keys in adata.obs that correspond to continuous data. These covariates can be added in addition to the batch covariate and are also treated as nuisance factors (i.e., the model tries to minimize their effects on the latent space). Thus, these should not be used for biologically-relevant factors that you do _not_ want to correct for. Important: the order of the continuous covariates matters and should match the order of the covariates in the query data. |
--unlabeled_category | string | Value in the --reference_obs_batch_label field that indicates unlabeled observations |
--reference_var_hvg | string | .var column containing highly variable genes. If not provided, genes will not be subset. |
--reference_var_gene_names | string | .var column containing gene names. By default, use the index. |
scVI, scANVI and scArches training options
Name | Type & Properties | Description |
|---|---|---|
--early_stopping | boolean | Whether to perform early stopping with respect to the validation set. |
--early_stopping_monitor | string | Metric logged during validation set epoch. |
--early_stopping_patience | integer | Number of validation epochs with no improvement after which training will be stopped. |
--early_stopping_min_delta | double | Minimum change in the monitored quantity to qualify as an improvement, i.e. an absolute change of less than min_delta, will count as no improvement. |
--max_epochs | integer | Number of passes through the dataset, defaults to (20000 / number of cells) * 400 or 400; whichever is smallest. |
--reduce_lr_on_plateau | boolean | Whether to monitor validation loss and reduce learning rate when validation set `lr_scheduler_metric` plateaus. |
--lr_factor | double | Factor to reduce learning rate. |
--lr_patience | double | Number of epochs with no improvement after which learning rate will be reduced. |
Leiden clustering options
Name | Type & Properties | Description |
|---|---|---|
--leiden_resolution | double multiple | Control the coarseness of the clustering. Higher values lead to more clusters. |
Neighbor classifier arguments
Name | Type & Properties | Description |
|---|---|---|
--knn_weights | string | Weight function used in prediction. Possible values are: `uniform` (all points in each neighborhood are weighted equally) or `distance` (weight points by the inverse of their distance) |
--knn_n_neighbors | integer | The number of neighbors to use in k-neighbor graph structure used for fast approximate nearest neighbor search with PyNNDescent. Larger values will result in more accurate search results at the cost of computation time. |
Outputs
Name | Type & Properties | Description |
|---|---|---|
--output | file required output | The annotated output .h5mu file. |
--output_obsm_integrated | string | The .obsm field in the output h5mu object where the scANVI latent representation will be stored. |
--output_obs_predictions | string | The .obs field in the output h5mu object where the predicted labels from the scANVI classifier will be stored. |
--output_obs_probabilities | string | The .obs field in the output h5mu object where the predicted probabilities from the scANVI classifier will be stored. |
--output_compression | string | The compression format to be used on the output h5mu object. |
--output_model | file output | Path to the resulting scANVI model that was updated with query data. |
Compute
Name | Type & Properties | Description |
|---|---|---|
--device_type | string | Which implementation to use for the steps that have both a CPU and a GPU variant (normalization, log1p, scaling, highly variable features, PCA, neighbors, BBKNN, Harmony, Leiden clustering and UMAP): * `cpu` (default): the scanpy implementation. * `gpu`: the rapids-singlecell implementation from the `openpipeline_rapids` package. Selecting `gpu` requires a CUDA-capable NVIDIA GPU on every executor that runs a GPU-labelled process; there is no automatic fallback to CPU. The GPU processes also need the container runtime to be given access to the devices, which is done by adding `-c src/workflows/utils/gpu.config` to the Nextflow command. |
--managed_memory | boolean_true | Only used with `--device_type gpu`. Allocate GPU memory with RMM managed memory from the start. Managed memory lets data that does not fit in VRAM spill to host RAM, at the cost of speed. By default, each GPU step runs with regular GPU memory and only switches to managed memory, retrying once, if the GPU runs out of memory. |
Run this component
Run the following command to execute this component with Nextflow:
cat > params.yaml <<'EOM'
id: "run"
modality: [ "rna" ]
input_obs_batch_label: [ "sample_id" ]
sanitize_ensembl_ids: [ true ]
reference_obs_batch_label: [ "sample_id" ]
unlabeled_category: [ "Unknown" ]
reference_var_hvg: [ "filter_with_hvg" ]
early_stopping_monitor: [ "elbo_validation" ]
early_stopping_patience: [ 45 ]
early_stopping_min_delta: [ 0 ]
reduce_lr_on_plateau: [ true ]
lr_factor: [ 0.6 ]
lr_patience: [ 30 ]
leiden_resolution: [ 1 ]
knn_weights: [ "uniform" ]
knn_n_neighbors: [ 15 ]
output: "$id.$key.output.h5mu"
output_obsm_integrated: [ "X_integrated_scanvi" ]
output_obs_predictions: [ "scanvi_pred" ]
output_obs_probabilities: [ "scanvi_probabilities" ]
output_model: "$id.$key.output_model"
device_type: [ "cpu" ]
publish_dir: "output/"
EOM
nextflow run https://packages.viash-hub.com/vsh/openpipeline.git \
-revision v5.0.0 \
-main-script target/nextflow/workflows/annotation/scanvi_scarches/main.nf \
-params-file params.yaml Relationships
Used by
0 relationships
No components use this component.
Current component
workflows/annotation/scanvi_scarchesopenpipeline v5.0.0