View source: R/run.chronoclust.R
run.chronoclust | R Documentation |
Method to run ChronoClust clustering algorithm.
For this to work properly, a Python session must already be embedded within the currently running R session.
This is because ChronoClust is originally written in Python 3.
Spectre includes a function run.prepare.chronoclust
that uses Reticulate to prepare and embed Python session within R session.
run.chronoclust(dat, timepoint.col, use.cols, config=NULL, clust.name = "ChronoClust_cluster")
dat |
NO DEFAULT. Data.frame. Data to be clustered. |
timepoint.col |
NO DEFAULT. Column name which represents the time point of each cell (data point) in dat. |
timepoints |
NO DEFAULT. The time points (in order). |
use.cols |
NO DEFAULT. Vector of column names to use for clustering. |
config |
DEFAULT = NULL. A named numeric list. List containing the value of ChronoClust's hyper-parameter. The name of the element must correspond to one of ChronoClust's parameter name such as epsilon, upsilon, etc. The numeric value must correspond to the value assigned for the corresponding parameter. Only include parameters that you want to override. Those you prefer to set to default value need not be included in the list. |
clust.name |
DEFAULT = "ChronoClust_cluster". Character. Name of the resulting 'cluster' |
clean.up |
DEFAULT = FALSE. Whether to remove the files chronoclust produces |
Givanna Putri, givanna.haryonoputri@sydney.edu.au
https://github.com/ghar1821/Chronoclust for ChronoClust's Python implementation.
run.prepare.chronoclust
for how to embed Python session within R session.
# Read data
data.list <- Spectre::read.files(file.loc = PrimaryDirectory, file.type = ".csv", do.embed.file.names = TRUE)
cell.dat <- Spectre::do.merge.files(dat = data.list)
# Specify clustering column
cluster.cols <- names(cell.dat)[c(1:8,10:20)]
# Specify time point column
timepoint.col <- "Group"
timepoints <- c("Mock", "WNV-01", "WNV-02", "WNV-03", "WNV-04", "WNV-05")
# Prepare Python session
run.prepare.chronoclust(environment_name = "chronoclust-R",
create_environment = TRUE,
install_dependencies = TRUE)
# Specify the parameters that need to be overriden
config <- list(beta = 0.2,
delta = 0.05,
epsilon = 0.03,
mu = 0.01)
cell.dat <- Spectre::run.chronoclust(dat=cell.dat,
timepoint.col=timepoint.col,
timepoints=timepoints,
use.cols=cluster.cols,
config=config)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.