This function runs different classification models based on user input to predict cluster assignments for test data.
Usage
RunClassifier(
algorithm,
data.test,
data.train,
cluster.data,
cluster.markers,
scale = TRUE
)Arguments
- algorithm
A character string indicating the classifier to use. Supported algorithms include: "Adaboost", "DT", "Enet", "Enrichment", "GBDT", "LASSO", "LDA", "NBayes", "NNet", "PCA", "Ridge", "StepLR", "SVD", "SVM", "XGBoost", "kNN", "RF".
- data.test
A numeric matrix or data frame of test data. Rows represent genes, and columns represent samples.
- data.train
A numeric matrix or data frame of training data. Rows represent genes, and columns represent samples.
- cluster.data
A data frame where the first column must be the sample IDs and the second column must be the cluster assignments. The sample IDs must match the column names of the training data.
- cluster.markers
A list of data frames, each containing markers for a specific cluster, with columns 'Gene' indicating gene names.
- scale
A logical value indicating whether to scale the test data. Default is TRUE.
Details
The function dynamically selects and runs a classification model based on user input. The supported classifiers include a range of machine learning models such as Random Forest, kNN, PCA, SVM, LASSO, Ridge, and others.
Examples
# Example usage:
data.test <- matrix(rnorm(1000), nrow = 100, ncol = 10)
data.train <- matrix(rnorm(1000), nrow = 100, ncol = 10)
cluster.data <- data.frame(Sample = paste0("Sample", 1:10), Cluster = rep(1:2, each = 5))
cluster.markers <- setNames(lapply(unique(cluster.data$Cluster), function(c) data.frame(Gene = paste0("Gene", sample(1:30, 10)), OR = runif(10, 0.5, 2), AUC = runif(10))), unique(cluster.data$Cluster))
result <- RunClassifier(algorithm = "RF", data.test, data.train, cluster.data, cluster.markers, scale = TRUE)