dimReduction
dim-reduction.Rmd
Overview
This vignette describes the usage of the dimReduction
parameter in the pandemonium
app and how new functions can
be written for it.
How to write new functions
The standard way to write a new function to be passed to
dimReduction
is as a wrapper for a common dimension
reduction algorithm. THe defined function must be able to take
mat
and dist
as parameters. If only one of
them is used it is best to write the function with space for additional
parameters with ...
as seen in the following example.
tSNE_mat <- function(mat,...) {
coord_red = list()
coord_red$Y = Rtsne::Rtsne(mat)$Y
coord_red
}
tSNE_dist <- function(dist,...) {
coord_red = list()
coord_red$Y = Rtsne::Rtsne(dist, is.dist = TRUE)$Y
coord_red
}
newPandemonium(df, dim_reduction = list(tSNE_mat = tSNE_mat, tSNE_dist = tSNE_dist))
Some algorithms may take a distances object instead of a distance
matrix. This can be done by converting the distance matrix using
stats::as.dist()
. As done with umap.