| dr_compare | R Documentation |
Compare several dimensionality reduction methods
dr_compare(
data,
funs = list(prcomp = stats::prcomp),
dim = 1:2,
metadata = NULL,
...
)
data |
input data. It follows the same contract as |
funs |
a named list of methods to compare. Each element is either a
function, or a list with components |
dim |
the two dimensions to extract, as a numeric vector of length 2.
Defaults to |
metadata |
optional sample-level metadata. It is forwarded to
|
... |
additional arguments passed to every method in |
dr_compare() applies several dimensionality reduction (DR) methods to the
same input data and collects their results, so that the methods can be
compared side by side. Every method is evaluated independently: a method that
fails, or that returns fewer dimensions than requested, does not interrupt
the others. The outcome of every method is reported in the summary
component, which is the main purpose of this function.
A method that fails is never given placeholder coordinates. The failure is
recorded in summary$error, and the corresponding element of results is
the condition (error) object, so it can be inspected further.
A DrCompare object, a list with the following components:
resultsa named list with one element per method. For a method that
ran successfully it is a DrResult (see dr()); for a method that failed
it is the condition (error) object.
summarya data.frame with one row per method and the columns
method, status, n, k, has_eigenvalue, has_stress and error.
status is "ok" if the method ran and returned at least max(dim)
dimensions, "insufficient_dims" if it ran but returned too few
dimensions, and "failed" if it raised an error. n and k are the
number of samples and the number of extracted dimensions,
has_eigenvalue and has_stress indicate whether the method produced
those quantities, and error holds the error message of a failed method
(NA otherwise).
dim, metadata, funsthe corresponding inputs, kept so that
autoplot() can rebuild the plot.
Guangchuang Yu
dr(), available_methods()
x <- dr_compare(iris[, 1:4], list(pca = stats::prcomp))
x$summary
autoplot(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.