Package 'tidydr'

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

Help Index


List dimensionality reduction methods currently available

Description

This function shows available methods that worked for dr() function.

Usage

available_methods(method = "all")

Arguments

method

one of 'data', 'distance' or 'all' (default)

Value

A character vector of available DR methods

Author(s)

Lang Zhou and Guangchuang Yu

Examples

available_methods()

dr

Description

dimensional reduction

Usage

dr(data, fun, ...)

Arguments

data

input data

fun

function to perform dimensional reduction

...

additional parameters passed to 'fun'

Details

This function call the user-provided function ('fun') to perform dimensional reduction on the input data ('data')

Value

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)

Author(s)

Guangchuang Yu

Examples

x = dr(iris[,1:4], prcomp)
autoplot(x, aes(color=.group), metadata=iris$Species)

dr_extract

Description

dr_extract generic

Usage

dr_extract(result)

Arguments

result

DrResult object

Value

a list that contains components to construct a 'DrResult' object.

Author(s)

Guangchuang Yu


element_line2

Description

element_line2 for drawing shorten axis lines

Usage

element_line2(
  colour = NULL,
  size = NULL,
  linetype = NULL,
  lineend = NULL,
  color = NULL,
  arrow = NULL,
  inherit.blank = FALSE,
  id,
  xlength = 0.3,
  ylength = 0.3,
  ...
)

Arguments

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

Value

element_line2 object, which is a tailored element_line object

Author(s)

Guangchuang Yu


nk

Description

Choose best K (number of clusters)

Usage

nk(data, k)

Arguments

data

input data (a matrix or data frame)

k

a vector of candidate number of clusters

Details

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)

Value

a silinfo object, which contains 'data' (original data), 'silinfo' (silhouette scores), and k (the input k vector)

Author(s)

Guangchuang Yu

Examples

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)

theme_dr

Description

Dimensional reduction scatter plot axis theme

Usage

theme_dr(
  xlength = 0.3,
  ylength = 0.3,
  arrow = grid::arrow(length = unit(0.15, "inches"), type = "closed")
)

Arguments

xlength

length of x axis

ylength

length of y axis

arrow

arrow specification, as created by 'grid::arrow()'

Value

a theme object with shorten axes

Author(s)

Guangchuang Yu


theme_noaxis

Description

theme that remove axis

Usage

theme_noaxis(...)

Arguments

...

additional theme setting

Value

a theme object that disable axes

Author(s)

Guangchuang Yu