Knn

Performs label transfer from reference to query using KNN classifier

Info

ID: knn
Namespace: labels_transfer

Example commands

You can run the pipeline using nextflow run.

View help

You can use --help as a parameter to get an overview of the possible parameters.

nextflow run openpipelines-bio/openpipeline \
  -r 1.0.1 -latest \
  -main-script target/nextflow/labels_transfer/knn/main.nf \
  --help

Run command

Example of params.yaml
# Learning parameters
n_neighbors: # please fill in - example: 123

# Nextflow input-output arguments
publish_dir: # please fill in - example: "output/"
# param_list: "my_params.yaml"
nextflow run openpipelines-bio/openpipeline \
  -r 1.0.1 -latest \
  -profile docker \
  -main-script target/nextflow/labels_transfer/knn/main.nf \
  -params-file params.yaml
Note

Replace -profile docker with -profile podman or -profile singularity depending on the desired backend.

Argument groups

Input dataset (query) arguments

Name Description Attributes
--input The query data to transfer the labels to. Should be a .h5mu file. file, required
--modality Which modality to use. string, default: "rna"
--input_obsm_features The .obsm key of the embedding to use for the classifier’s inference. If not provided, the .X slot will be used instead. Make sure that embedding was obtained in the same way as the reference embedding (e.g. by the same model or preprocessing). string, example: "X_integrated_scanvi"

Reference dataset arguments

Name Description Attributes
--reference The reference data to train classifiers on. file, example: "https:/zenodo.org/record/6337966/files/HLCA_emb_and_metadata.h5ad"
--reference_obsm_features The .obsm key of the embedding to use for the classifier’s training. Make sure that embedding was obtained in the same way as the query embedding (e.g. by the same model or preprocessing). string, required, default: "X_integrated_scanvi"
--reference_obs_targets The .obs key of the target labels to tranfer. List of string, default: "ann_level_1", "ann_level_2", "ann_level_3", "ann_level_4", "ann_level_5", "ann_finest_level", multiple_sep: ";"

Outputs

Name Description Attributes
--output The query data in .h5mu format with predicted labels transfered from the reference. file, required
--output_obs_predictions In which .obs slots to store the predicted information. If provided, must have the same length as --reference_obs_targets. If empty, will default to the reference_obs_targets combined with the "_pred" suffix. List of string, multiple_sep: ";"
--output_obs_uncertainty In which .obs slots to store the uncertainty of the predictions. If provided, must have the same length as --reference_obs_targets. If empty, will default to the reference_obs_targets combined with the "_uncertainty" suffix. List of string, multiple_sep: ";"
--output_uns_parameters The .uns key to store additional information about the parameters used for the label transfer. string, default: "labels_transfer"

Learning parameters

Name Description Attributes
--n_neighbors Number of nearest neighbors to use for classification integer, required

Authors

  • Vladimir Shitov (author)