Skip to contents

This function performs classification using pathway enrichment analysis and a neural network to predict cluster assignments for test data based on trained models from training data and cluster markers.

Usage

Classifier.Enrichment(
  data.test,
  data.train,
  cluster.data,
  cluster.markers,
  scale = TRUE,
  nCores = 5
)

Arguments

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, 'OR' as odds ratio, and 'AUC' as area under curve.

scale

A logical value indicating whether to scale the test data. Default is TRUE.

nCores

An integer indicating the number of cores to use for pathway enrichment analysis. Default is 5.

Value

A data frame with: - ID: The sample identifier. - Cluster: The predicted cluster label for each sample. - NES: Normalized Enrichment Score (NES) for each cluster assignment.

Details

The function operates as follows: 1. Ensures that the `cluster.data` has the correct column names. 2. Adds a one-hot encoded matrix for cluster assignments. 3. Scales the test data for prediction. 4. Selects genes that are common between the test and training datasets. 5. Filters out markers with low odds ratio. 6. Performs pathway enrichment analysis using the ssMwwGST method.

Author

Zaoqu Liu; Email: liuzaoqu@163.com

Examples

cluster.data <- data.frame(
  Sample = paste0("Sample", 1:60),
  Cluster = rep(paste0("C", 1:3), each = 20)
)
data.train <- matrix(rnorm(6000),
  nrow = 100,
  dimnames = list(paste0("Gene", 1:100), cluster.data$Sample)
)
data.test <- matrix(rnorm(5000),
  nrow = 100,
  dimnames = list(paste0("Gene", 1:100), paste0("P", 1:50))
)
cluster.markers <- setNames(
  lapply(
    unique(cluster.data$Cluster),
    function(cluster) {
      data.frame(Gene = sample(rownames(data.train), 10))
    }
  ),
  unique(cluster.data$Cluster)
)
result <- Classifier.Enrichment(
  data.test = data.test, data.train = data.train,
  cluster.data, cluster.markers
)
head(result)