R/gknn.R
buildClassifier.Rd
For a given features data, comutes the k-nearest neighbours classifier making use of general distance.
buildClassifier(data, features, celltypes)
A data.frame, containing features for gknn training. Data must be normalized into the range of 0 to 1.
The features used for cell type prediction.
The cell types for each row or column of the data.
An gknn model.
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
#>