For a given features data, comutes the k-nearest neighbours classifier making use of general distance.

buildClassifier(data, features, celltypes)

Arguments

data

A data.frame, containing features for gknn training. Data must be normalized into the range of 0 to 1.

features

The features used for cell type prediction.

celltypes

The cell types for each row or column of the data.

Value

An gknn model.

Examples

data(iris)
iris[, 1:4] <- apply(iris[, 1:4], 2, function(.ele){
  (.ele-min(.ele))/max(.ele)
})
classifier <- buildClassifier(iris, colnames(iris)[1:4], iris$Species)
predictCelltypes(classifier, iris[c(1, 51, 101), ])
#> $celltypes
#>          1         51        101 
#>     setosa versicolor  virginica 
#> Levels: setosa versicolor virginica
#> 
#> $prob
#> NULL
#>