plot_skeleton: Plots a simplicial complex.

Description Usage Arguments Examples

View source: R/plot_skeleton.R

Description

Plots the 0-, 1- and 2-simplices of a simplicial complex and colors the vertices according to the value of one or more functions with support on the underlying set of points. The complex is visualized using a force-directed graph layout acting on the 1-skeleton. Node sizes are proportional to the number of points in the corresponding open set.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plot_skeleton(
  g2,
  k,
  r,
  g,
  b,
  pushforward = mean,
  seed = 10,
  iterations = 1500,
  file = ""
)

Arguments

g2

an object of the class simplicial containing the nerve complex.

k

a numeric vector or matrix specifying one or more functions with support on the set of points that will be mapped to the rainbow palette. Each column corresponds to a point and each row specifies a different function. If more than one function is specified, the average of all rows is considered. Incompatible with the parameters r, g, and b.

r

similar to k but mapped to the red channel.

g

similar to k but mapped to the green channel.

b

similar to k but mapped to the blue channel.

pushforward

pushforward function that maps r, g, b, and k to functions with support on the simplices. By default is set to mean. Other choices may slow down the computation substantially.

seed

integer specifying the seed used to initialize the force-directed layout. By default is set to 10.

iterations

number of iterations used in the Force Atlas 2 layout. By default is set to 1500. A larger value may be required for optimal visualization of large graphs.

file

if specified, exports the 1-skeleton to graphviz DOT file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Example 1
library(RayleighSelection)
gy <- nerve_complex(list(c(1,4,6,10), c(1,2,7), c(2,3,8), c(3,4,9,10), c(4,5)))
plot_skeleton(gy,k=c(0,1,1,0,0,0,0,0,0,1))


# Example 2: MNIST dataset
data("mnist")

# Compute reduced representation using Laplacian eigenmap of pixels with high variance
library(dimRed)
leim <- LaplacianEigenmaps()
mnist_top <- mnist[apply(mnist, 1, var) > 10000,]
emb <- leim@fun(as(t(mnist_top), "dimRedData"), leim@stdpars)

# Compute Mapper representation using the Laplacian eigenmap as an auxiliary function and correlation
# distance as metric
library(TDAmapper)
mnist_distances <- (1.0 - cor(mnist_top))
m2 <- mapper2D(distance_matrix = mnist_distances,
               filter_values = list(emb@data@data[,1], emb@data@data[,2]),
               num_intervals = c(30,30),
               percent_overlap = 35,
               num_bins_when_clustering = 10);

# Compute the nerve complex
gg <- nerve_complex(m2$points_in_vertex)

# Plots simplicial complex colored by the value of the 301th pixel
plot_skeleton(gg, k=mnist[301,])

CamaraLab/RayleighSelection documentation built on Aug. 16, 2021, 12:01 p.m.