R package for computing the Mapper construction from Topological Data Analysis
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
data
docs
inst/dashboard
man
pkgdown
src
tests
vignettes
.gitattributes
.gitignore
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
README.md Merge branch 'master' of https://github.com/peekxc/mapper Nov 29, 2018
appveyor.yml
index.Rmd

README.md

Mapper

Appveyor Windows Build status Travis OS X Build status Travis Linux X Build status

This package provides a set of tools written in R/Rcpp for computing the mapper construction, and other related algorithms. Mapper was originally introduced in the article

Singh, Gurjeet, Facundo Mémoli, and Gunnar E. Carlsson. "Topological methods for the analysis of high dimensional data sets and 3d object recognition." SPBG. 2007.

Installation

The current development version can be installed with the devtools package:

require("devtools")
devtools::install_gitub("peekxc/mapper")

A stable CRAN release is planned for the future.

Usage

Given a data set, define the filter function. Here is an example using the noisy points sampled from the perimeter of a circle, similar to the example given by Example 3.2 in the original paper.

## Load the circle data set 
data("noisy_circle", package = "Mapper")

## Define filter values equal to the distance from each point to the left-most point in the circle 
left_pt <- noisy_circle[which.min(noisy_circle[, 1]),]
f_x <- matrix(apply(noisy_circle, 1, function(pt) (pt - left_pt)[1]))

Visualize the data and the results of the map

layout(matrix(1:2, nrow=1))
rbw <- rainbow(100, start=0,end=4/6)[cut(f_x, breaks=99, labels=FALSE)]
plot(noisy_circle, col = rbw)
plot(cbind(f_x, 1L), pch = "|", col = rbw)

Noisy circle example You can construct a mapper with R6 method chaining

## Define the main via chaining R6 methods
m <- MapperRef$new(noisy_circle)$
  use_cover(filter_values = matrix(f_x), type="fixed rectangular", number_intervals=5L, percent_overlap=20)$
  use_clustering_algorithm(cl = "single", num_bins = 10)$
  use_distance_measure(measure = "euclidean")$
  compute_k_skeleton(k=1L)
m
Mapper construction for 1500 objects
Cover: (typename = Fixed Rectangular, number intervals = [5], percent overlap = [20]%)

The mapper is stored in a simplex tree. To get a quick overview of what the complex looks like use

print(m$simplicial_complex) 
Simplex Tree with (8, 8) (0, 1)-simplices

Or print out the full trie structure

m$simplicial_complex$print_tree() 
0 (h = 1): .( 1 2 )
1 (h = 1): .( 3 )
2 (h = 1): .( 4 )
3 (h = 1): .( 6 )
4 (h = 1): .( 5 )
5 (h = 1): .( 7 )
6 (h = 1): .( 7 )
7 (h = 0): 

You can export to your favorite graph-based representation.

## Export to graph
m$simplicial_complex$as_adjacency_matrix()
# ...or m$simplicial_complex$as_adjacency_list()
# ...or m$simplicial_complex$as_edge_list()

The vertices of the mapper are stored as a simple list

View(m$vertices)

To interactive with the graph, consider the grapher library, ported from Ayasdis grapher.js library.

library("grapher")
m$as_grapher() 

Additional Information

More comprehensive documentation is available here. There's also a vignette on using the package that is more-depth.