scDHA.class {scDHA}R Documentation

scDHA classification

Description

Perform classification of new data based on available data.

Usage

scDHA.class(
  train = train,
  train.label = train.label,
  test = test,
  ncores = 10L,
  seed = NULL
)

Arguments

train

Expression matrix of available data, with rows represent samples and columns represent genes.

train.label

A vector containing label for each sample in training data.

test

Expression matrix new data for classification, with rows represent samples and columns represent genes.

ncores

Number of processor cores to use.

seed

Seed for reproducibility.

Value

A vector contain classified labels for new data.

Examples


library(scDHA)
#Load example data (Goolam dataset)
data('Goolam'); data <- t(Goolam$data); label <- as.character(Goolam$label)
#Log transform the data 
data <- log2(data + 1)
#Split data into training and testing sets
set.seed(1)
idx <- sample.int(nrow(data), size = round(nrow(data)*0.75))
train.x <- data[idx, ]; train.y <- label[idx]
test.x <- data[-idx, ]; test.y <- label[-idx]
if(torch::torch_is_installed()) #scDHA need libtorch installed
{
  #Predict the labels of cells in testing set
  prediction <- scDHA.class(train = train.x, train.label = train.y, test = test.x, 
                            ncores = 2, seed = 1)
  #Calculate accuracy of the predictions
  acc <- round(sum(test.y == prediction)/length(test.y), 2)
  print(paste0("Accuracy = ", acc))
}


[Package scDHA version 1.2.2 Index]