Understanding the dimReduction Function Input
dim-reduction.RmdOverview
This vignette describes the usage of the dimReduction
parameter in the pandemonium app and how new functions can
be written for it.
The input for dimReduction should be a named list of
functions, where each function defines a dimension reduction and needs
to be structured as follows.
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 dist object instead of a distance matrix.
This can be done by converting the distance matrix using
stats::as.dist(). An example is the implementation of
umap.