Title: | Unify Dimensionality Reduction Results |
---|---|
Description: | Dimensionality reduction (DR) is widely used in many domain for analyzing and visualizing high-dimensional data. 'tidydr' provides uniform output and is compatible with multiple methods, including 'prcomp', 'mds', 'Rtsne'. etc. |
Authors: | Guangchuang Yu [aut, cre, cph] , Shuangbin Xu [aut] , Erqiang Hu [ctb] |
Maintainer: | Guangchuang Yu <[email protected]> |
License: | Artistic-2.0 |
Version: | 0.0.5.001 |
Built: | 2024-11-01 04:40:21 UTC |
Source: | https://github.com/yulab-smu/tidydr |
This function shows available methods that worked for dr()
function.
available_methods(method = "all")
available_methods(method = "all")
method |
one of 'data', 'distance' or 'all' (default) |
A character vector of available DR methods
Lang Zhou and Guangchuang Yu
available_methods()
available_methods()
dimensional reduction
dr(data, fun, ...)
dr(data, fun, ...)
data |
input data |
fun |
function to perform dimensional reduction |
... |
additional parameters passed to 'fun' |
This function call the user-provided function ('fun') to perform dimensional reduction on the input data ('data')
a DrResult object, which contains 'data' (original data), 'drdata' (coordination after dimensionality reduction), eigenvalue (standard deviation explained by each dimension) and stress (evaluate the effect of dimensionality reduction)
Guangchuang Yu
x = dr(iris[,1:4], prcomp) autoplot(x, aes(color=.group), metadata=iris$Species)
x = dr(iris[,1:4], prcomp) autoplot(x, aes(color=.group), metadata=iris$Species)
dr_extract generic
dr_extract(result)
dr_extract(result)
result |
DrResult object |
a list that contains components to construct a 'DrResult' object.
Guangchuang Yu
element_line2 for drawing shorten axis lines
element_line2( colour = NULL, size = NULL, linetype = NULL, lineend = NULL, color = NULL, arrow = NULL, inherit.blank = FALSE, id, xlength = 0.3, ylength = 0.3, ... )
element_line2( colour = NULL, size = NULL, linetype = NULL, lineend = NULL, color = NULL, arrow = NULL, inherit.blank = FALSE, id, xlength = 0.3, ylength = 0.3, ... )
colour |
line colour |
size |
line size in pts |
linetype |
line type |
lineend |
line end style (round, butt, square) |
color |
aliase to colour |
arrow |
arrow specification, as created by 'grid::arrow()' |
inherit.blank |
whether inherit 'element_blank' |
id |
1 or 2, 1 for axis.line.x.bottom and 2 for axis.line.y.left, only these two axes supported |
xlength |
length of x axis |
ylength |
length of y axis |
... |
additional parameters |
element_line2 object, which is a tailored element_line object
Guangchuang Yu
Choose best K (number of clusters)
nk(data, k)
nk(data, k)
data |
input data (a matrix or data frame) |
k |
a vector of candidate number of clusters |
This function calculate the silhouette scores of each K (number of clusters).
The output object can be used to choose the best K (via summary()
or autoplot()
methods)
a silinfo
object, which contains 'data' (original data), 'silinfo' (silhouette scores), and k (the input k vector)
Guangchuang Yu
x <- nk(iris[,-5], 2:8) summary(x) # to visualize the average silhouete score (y axis) with k (x axis) autoplot(x) # to visualize a PCA plot color by the choosing k autoplot(x, k=3)
x <- nk(iris[,-5], 2:8) summary(x) # to visualize the average silhouete score (y axis) with k (x axis) autoplot(x) # to visualize a PCA plot color by the choosing k autoplot(x, k=3)
Dimensional reduction scatter plot axis theme
theme_dr( xlength = 0.3, ylength = 0.3, arrow = grid::arrow(length = unit(0.15, "inches"), type = "closed") )
theme_dr( xlength = 0.3, ylength = 0.3, arrow = grid::arrow(length = unit(0.15, "inches"), type = "closed") )
xlength |
length of x axis |
ylength |
length of y axis |
arrow |
arrow specification, as created by 'grid::arrow()' |
a theme object with shorten axes
Guangchuang Yu
theme that remove axis
theme_noaxis(...)
theme_noaxis(...)
... |
additional theme setting |
a theme object that disable axes
Guangchuang Yu