test_classifier {scClassifR} | R Documentation

## Testing process.

### Description

Testing process.

### Usage

    test_classifier(
      test_obj,
      classifier,
      target_cell_type = NULL,
      parent_clf = NULL,
      path_to_models = c("default", "."),
      zscore = TRUE,
      ...
    )

    ## S4 method for signature 'Seurat,scClassifR'
    test_classifier(
      test_obj,
      classifier,
      target_cell_type = NULL,
      parent_clf = NULL,
      path_to_models = c("default", "."),
      zscore = TRUE,
      seurat_tag_slot = "active.ident",
      seurat_parent_tag_slot = "predicted_cell_type",
      seurat_assay = "RNA",
      seurat_slot = "counts",
      ...
    )

    ## S4 method for signature 'SingleCellExperiment,scClassifR'
    test_classifier(
      test_obj,
      classifier,
      target_cell_type = NULL,
      parent_clf = NULL,
      path_to_models = c("default", "."),
      zscore = TRUE,
      sce_tag_slot = "ident",
      sce_parent_tag_slot = "predicted_cell_type",
      sce_assay = "logcounts",
      ...
    )

### Arguments

`test_obj` | xxobject that can be used for testing
`classifier` | classification model
`target_cell_type` | vector indicating other cell types than cell labels that can be considered as the main cell type in classifier, for example, c("plasma cell", "b cell", "b cells", "activating b cell"). Default as NULL.
`parent_clf` | `scClassifR` object corresponding to classification model for the parent cell type
`path_to_models` | path to the folder containing the list of models. As default, the pretrained models in the package will be used. If user has trained new models, indicate the folder containing the new_models.rda file.
`zscore` | boolean, whether gene expression is transformed to zscore
`...` | arguments passed to other methods
`seurat_tag_slot` | string, name of annotation slot indicating cell tag/label in the testing object. Strings indicating cell types are expected in this slot. For `Seurat` object, default value is "active.ident". Expected values are string (A-Z, a-z, 0-9, no special character accepted) or binary/logical, 0/"no"/F/FALSE: not being new cell type, 1/"yes"/T/TRUE: being new cell type.
`seurat_parent_tag_slot` | string, name of tag slot in cell meta data indicating pre-assigned/predicted parent cell type. Default field is "predicted_cell_type". The slot must contain only string values.
`seurat_assay` | name of assay to use in `Seurat` object, defaults to 'RNA' assay.
`seurat_slot` | type of expression data to use in `Seurat` object. Some available types are: "counts", "data" and "scale.data". Default to "counts", which contains unnormalized data.
`sce_tag_slot` | string, name of annotation slot indicating cell tag/label in the testing object. Strings indicating cell types are expected in this slot. Default value is "ident". Expected values are string (A-Z, a-z, 0-9, no special character accepted) or binary/logical, 0/"no"/F/FALSE: not being new cell type, 1/"yes"/T/TRUE: being new cell type.
`sce_parent_tag_slot` | string, name of tag slot in cell meta data indicating pre-assigned/predicted parent cell type. Default is "predicted_cell_type". The slot must contain only string values.
`sce_assay` | name of assay to use in `SingleCellExperiment` object, defaults to 'logcounts' assay.

### Value

result of testing process in form of a list, including predicted values, prediction accuracy at a probability threshold, and roc curve information.

### Note

Only one cell type is expected for each cell. Ambiguous cell type, such as: "T cells/NK cells/ILC", will be ignored. Subtypes used in testing model for parent cell types can be indicated as parent cell type, or can be indicated in target_cell_type. For example, when testing for B cells, plasma cells can be annotated as B cells, or target_cell_type is set c("plasma cells").

### Examples

    # load small example dataset
    data("tirosh_mel80_example")

    # train the classifier
    selected_features_B = c("CD19", "MS4A1", "CD79A")
    set.seed(123)
    clf_b <- train_classifier(train_obj = tirosh_mel80_example,
    features = selected_features_B, cell_type = "B cells")

    # test the classifier, target cell type can be in other formats or
    # alternative cell type that can be considered as the classified cell type
    clf_b_test <- test_classifier(test_obj = tirosh_mel80_example,
    classifier = clf_b, target_cell_type = c("B cell"))
    clf_b_test

[Package scClassifR version 1.2.0 Index]