classify: Distance to centroid classifier function

Description Usage Arguments Value Examples

View source: R/calculate_distance.R

Description

Given an n x m matrix of centroids, where m are the prototypic centroids with n features, classify new samples according to the distance to the centroids.

Usage

1
classify(data, centroid, method = "pearson")

Arguments

data

a data.frame of dimensions n x p with the samples to classify, were n are the same set of features as in the centroids

centroid

a data.frame of dimensions n x m, where each column is a prototypic centroid to classify the samples

method

Character string indicating which method to use to calculate distance to centroid. Options are "pearson" (default), "kendall", or "spearman"

Value

Returns a numeric vector of length p with the class assigned to each sample according to the shortest distance to centroid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
rna_luad<-use_rna_luad()

#The expression of the toy datasets are already scaled
prm <- rna_luad$TCGA$expression_matrix

#We change the rownames to be gene Symbol insted of Gene Id.
rownames(prm)<- rna_luad$TCGA$feature_data$gene

#Wilkerson's centroids
centroids<- rna_luad$WilkCentroids

#Extract features from both data.frames
inBoth<- Reduce(intersect, list(rownames(prm),rownames(centroids)))

#Classify samples
Wilk.Class<- classify(prm[inBoth,],centroids[inBoth,])
table(Wilk.Class)

## End(Not run)

harpomaxx/galgo documentation built on Aug. 11, 2020, 3:07 p.m.