Title: | Learning Principal Graphs with DDRTree |
---|---|
Description: | Project data into a reduced dimensional space and construct a principal graph from the reduced dimension. |
Authors: | Xiaojie Qiu, Cole Trapnell, Qi Mao, Li Wang |
Maintainer: | Xiaojie Qiu <[email protected]> |
License: | Artistic License 2.0 |
Version: | 0.1.5 |
Built: | 2024-11-02 04:27:12 UTC |
Source: | https://github.com/cole-trapnell-lab/DDRTree |
Perform DDRTree construction
This is an R and C code implementation of the DDRTree algorithm from Qi Mao, Li Wang et al.
Qi Mao, Li Wang, Steve Goodison, and Yijun Sun. Dimensionality Reduction via Graph Structure Learning.
The 21st ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD'15), 2015
http://dl.acm.org/citation.cfm?id=2783309
to perform dimension reduction and principal graph
learning simultaneously. Please cite this package and KDD'15 paper if you found DDRTree is useful for your research.
DDRTree(X, dimensions = 2, initial_method = NULL, maxIter = 20, sigma = 0.001, lambda = NULL, ncenter = NULL, param.gamma = 10, tol = 0.001, verbose = F, ...)
DDRTree(X, dimensions = 2, initial_method = NULL, maxIter = 20, sigma = 0.001, lambda = NULL, ncenter = NULL, param.gamma = 10, tol = 0.001, verbose = F, ...)
X |
a matrix with |
dimensions |
reduced dimension |
initial_method |
a function to take the data transpose of X as input and then output the reduced dimension, row number should not larger than observation and column number should not be larger than variables (like isomap may only return matrix on valid sample sets). Sample names of returned reduced dimension should be preserved. |
maxIter |
maximum iterations |
sigma |
bandwidth parameter |
lambda |
regularization parameter for inverse graph embedding |
ncenter |
number of nodes allowed in the regularization graph |
param.gamma |
regularization parameter for k-means (the prefix of 'param' is used to avoid name collision with gamma) |
tol |
relative objective difference |
verbose |
emit extensive debug output |
... |
additional arguments passed to DDRTree |
a list with W, Z, stree, Y, history W is the orthogonal set of d (dimensions) linear basis vector Z is the reduced dimension space stree is the smooth tree graph embedded in the low dimension space Y represents latent points as the center of Z
The unprecedented increase in big-data causes a huge difficulty in data visualization and downstream analysis.
Conventional dimension reduction approaches (for example, PCA, ICA, Isomap, LLE, etc.) are limited in their ability
to explictly recover the intrinisic structure from the data as well as the discriminative feature representation,
both are important for scientific discovery. The DDRTree algorithm is a new algorithm to perform the following
three tasks in one setting:
1. Reduce high dimension data into a low dimension space
2. Recover an explicit smooth graph structure with local geometry only captured by distances of data
points in the low dimension space.
3. Obtain clustering structures of data points in reduced dimension
Reverse graph embedding is previously applied to learn the intrinisic graph structure in the original dimension. The optimization of graph inference can be represented as:
where
is a function to map the instrinsic data space
back to the input data space (reverse embedding)
.
is the the vertex of the instrinsic undirected graph
.
is
the edge weight associates with the edge set
.
In order to learn the intrinsic structure from a reduced dimension, we need also to consider a term which includes
the error during the learning of the instrinsic structure. This strategy is incorporated as the following:
where is a non-negative parameter which controls the tradeoff between the data
reconstruction error and the reverse graph embedding.
The general framework for reducing dimension by learning an intrinsic structure in a low dimension requires a feasible set
of graph and a mapping function
. The algorithm uses minimum spanning tree as the feasible tree
graph structure, which can be solved by Kruskal' algoritm. A linear projection model
is used as the mapping function.
Those setting results in the following specific form for the previous framework:
where is an orthogonal set of
linear basis vectors. We can group tree graph
, the orthogonal set of linear basis vectors
and projected points in reduced dimension
as two groups and apply alternative structure optimization to optimize the tree graph.
This method is defined as DRtree (Dimension Reduction tree) as discussed by the authors.
In order to avoid the issues where data points scattered into different branches (which leads to lose of cluster information) and to
incorporate the discriminative information,another set of points as the centers of
can be also introduced.
By so doing, the objective functions of K-means and the DRtree can be simulatenously minimized. The author further proposed a soft partition method
to account for the limits from K-means and proposed the following objective function:
where is the negative
entropy regularization which transforms the hard assignments used in K-means into soft assignments and
is the regulization parameter.
Alternative structure optimization is again used to solve the above problem by separately optimize each group
until convergence.
: Data matrix
, parameters
Initialize
by PCA
:
Obtain
via Kruskal's algorithm
Compute
with each element
Perform eigen-decomposition on
such that
and
is sorted in a descending order
Convergence
We implemented the algorithm mostly in Rcpp for the purpose of efficiency. It also has extensive optimization for sparse input data. This implementation is originally based on the matlab code provided from the author of DDRTree paper.
data('iris') subset_iris_mat <- as.matrix(t(iris[c(1, 2, 52, 103), 1:4])) #subset the data #run DDRTree with ncenters equal to species number DDRTree_res <- DDRTree(subset_iris_mat, dimensions = 2, maxIter = 5, sigma = 1e-2, lambda = 1, ncenter = 3, param.gamma = 10, tol = 1e-2, verbose = FALSE) Z <- DDRTree_res$Z #obatain matrix Y <- DDRTree_res$Y stree <- DDRTree_res$stree plot(Z[1, ], Z[2, ], col = iris[c(1, 2, 52, 103), 'Species']) #reduced dimension legend("center", legend = unique(iris[c(1, 2, 52, 103), 'Species']), cex=0.8, col=unique(iris[c(1, 2, 52, 103), 'Species']), pch = 1) #legend title(main="DDRTree reduced dimension", col.main="red", font.main=4) dev.off() plot(Y[1, ], Y[2, ], col = 'blue', pch = 17) #center of the Z title(main="DDRTree smooth principal curves", col.main="red", font.main=4) #run DDRTree with ncenters equal to species number DDRTree_res <- DDRTree(subset_iris_mat, dimensions = 2, maxIter = 5, sigma = 1e-3, lambda = 1, ncenter = NULL,param.gamma = 10, tol = 1e-2, verbose = FALSE) Z <- DDRTree_res$Z #obatain matrix Y <- DDRTree_res$Y stree <- DDRTree_res$stree plot(Z[1, ], Z[2, ], col = iris[c(1, 2, 52, 103), 'Species']) #reduced dimension legend("center", legend = unique(iris[c(1, 2, 52, 103), 'Species']), cex=0.8, col=unique(iris[c(1, 2, 52, 103), 'Species']), pch = 1) #legend title(main="DDRTree reduced dimension", col.main="red", font.main=4) dev.off() plot(Y[1, ], Y[2, ], col = 'blue', pch = 2) #center of the Z title(main="DDRTree smooth principal graphs", col.main="red", font.main=4)
data('iris') subset_iris_mat <- as.matrix(t(iris[c(1, 2, 52, 103), 1:4])) #subset the data #run DDRTree with ncenters equal to species number DDRTree_res <- DDRTree(subset_iris_mat, dimensions = 2, maxIter = 5, sigma = 1e-2, lambda = 1, ncenter = 3, param.gamma = 10, tol = 1e-2, verbose = FALSE) Z <- DDRTree_res$Z #obatain matrix Y <- DDRTree_res$Y stree <- DDRTree_res$stree plot(Z[1, ], Z[2, ], col = iris[c(1, 2, 52, 103), 'Species']) #reduced dimension legend("center", legend = unique(iris[c(1, 2, 52, 103), 'Species']), cex=0.8, col=unique(iris[c(1, 2, 52, 103), 'Species']), pch = 1) #legend title(main="DDRTree reduced dimension", col.main="red", font.main=4) dev.off() plot(Y[1, ], Y[2, ], col = 'blue', pch = 17) #center of the Z title(main="DDRTree smooth principal curves", col.main="red", font.main=4) #run DDRTree with ncenters equal to species number DDRTree_res <- DDRTree(subset_iris_mat, dimensions = 2, maxIter = 5, sigma = 1e-3, lambda = 1, ncenter = NULL,param.gamma = 10, tol = 1e-2, verbose = FALSE) Z <- DDRTree_res$Z #obatain matrix Y <- DDRTree_res$Y stree <- DDRTree_res$stree plot(Z[1, ], Z[2, ], col = iris[c(1, 2, 52, 103), 'Species']) #reduced dimension legend("center", legend = unique(iris[c(1, 2, 52, 103), 'Species']), cex=0.8, col=unique(iris[c(1, 2, 52, 103), 'Species']), pch = 1) #legend title(main="DDRTree reduced dimension", col.main="red", font.main=4) dev.off() plot(Y[1, ], Y[2, ], col = 'blue', pch = 2) #center of the Z title(main="DDRTree smooth principal graphs", col.main="red", font.main=4)
Get the top L eigenvalues
get_major_eigenvalue(C, L)
get_major_eigenvalue(C, L)
C |
data matrix used for eigendecomposition |
L |
number for the top eigenvalues |
Compute the PCA projection
pca_projection_R(C, L)
pca_projection_R(C, L)
C |
data matrix used for PCA projection |
L |
number for the top principal components |
calculate the square distance between a, b
sqdist_R(a, b)
sqdist_R(a, b)
a |
a matrix with |
b |
a matrix with |
a numeric value for the different between a and b