<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: scDHA classification</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="https://rpkg.net/assets/examples.css" />
</head><body>

<table width="100%" summary="page for scDHA.class"><tr><td>scDHA.class</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>scDHA classification</h2>

<h3>Description</h3>

<p>Perform classification of new data based on available data.
</p>


<h3>Usage</h3>

<pre>
scDHA.class(
  train = train,
  train.label = train.label,
  test = test,
  ncores = 10L,
  seed = NULL
)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>train</code></td>
<td>
<p>Expression matrix of available data, with rows represent samples and columns represent genes.</p>
</td></tr>
<tr valign="top"><td><code>train.label</code></td>
<td>
<p>A vector containing label for each sample in training data.</p>
</td></tr>
<tr valign="top"><td><code>test</code></td>
<td>
<p>Expression matrix new data for classification, with rows represent samples and columns represent genes.</p>
</td></tr>
<tr valign="top"><td><code>ncores</code></td>
<td>
<p>Number of processor cores to use.</p>
</td></tr>
<tr valign="top"><td><code>seed</code></td>
<td>
<p>Seed for reproducibility.</p>
</td></tr>
</table>


<h3>Value</h3>

<p>A vector contain classified labels for new data.
</p>


<h3>Examples</h3>

<pre>

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

</pre>


</body></html>
