knn_trn: knn_trn allows assessing the final DEGs through a machine...

View source: R/knn_trn.R

knn_trnR Documentation

knn_trn allows assessing the final DEGs through a machine learning step by using k-NN in a cross validation process.

Description

knn_trn allows assessing the final DEGs through a machine learning step by using k-NN in a cross validation process. This function applies a cross validation of n folds with representation of all classes in each fold. The 80% of the data are used for training and the 20% for test. An optimization of the k neighbours is done at the start of the process.

Usage

knn_trn(data, labels, vars_selected, numFold = 10, LOOCV = FALSE)

Arguments

data

The data parameter is an expression matrix or data.frame that contains the genes in the columns and the samples in the rows.

labels

A vector or factor that contains the labels for each of the samples in the data object.

vars_selected

The genes selected to classify by using them. It can be the final DEGs extracted with the function DEGsExtraction or a custom vector of genes. Furthermore, the ranking achieved by featureSelection function can be used as input of this parameter.

numFold

The number of folds to carry out in the cross validation process.

LOOCV

Logical parameter to choose between Loo-CV and KFold-CV.

Value

A list that contains seven objects. The confusion matrix for each fold, the accuracy, the sensitivity, the specificity and the F1-Scores for each fold and each genes, the best k found for the knn algorithm after tuning, and the predictions made.

Examples

dir <- system.file("extdata", package="KnowSeq")
load(paste(dir,"/expressionExample.RData",sep = ""))

knn_trn(t(DEGsMatrix)[,1:10],labels,rownames(DEGsMatrix)[1:10],3)

CasedUgr/KnowSeq documentation built on Aug. 16, 2022, 6:19 a.m.