TDAstats: topological data analysis in R

Travis-CI Build Status AppVeyor Build Status Coverage Status

License: GPL v3 CRAN version CRAN Downloads



TDAstats is an R pipeline for computing persistent homology in topological data analysis.


To install TDAstats, run the following R code:

# install from CRAN

# install development version from GitHub

# install development version with vignettes/tutorials
devtools::install_github("rrrlw/TDAstats", build_vignettes = TRUE)

Sample code

The following sample code creates two synthetic datasets, and calculates and visualizes their persistent homology to showcase the use of TDAstats.

# load TDAstats

# load sample datasets

# calculate persistent homology for both datasets
unif.phom <- calculate_homology(unif2d, dim = 1)
circ.phom <- calculate_homology(circle2d, dim = 1)

# visualize first dataset as persistence diagram

# visualize second dataset as topological barcode

A more detailed tutorial can be found in the package vignettes or at this Gist.


TDAstats has 3 primary goals:

  1. Calculation of persistent homology: the C++ Ripser project is a lightweight library for calculating persistent homology that outpaces all of its competitors. Given the importance of computational efficiency, TDAstats naturally uses Ripser behind the scenes for homology calculations, using the Rcpp package to integrate the C++ code into an R pipeline (Ripser for R).

  2. Statistical inference of persistent homology: persistent homology can be used in hypothesis testing to compare the topological structure of two point clouds. TDAstats uses a permutation test in conjunction with the Wasserstein metric for nonparametric statistical inference.

  3. Visualization of persistent homology: persistent homology is visualized using two types of plots - persistence diagrams and topological barcodes. TDAstats provides implementations of both plot types using the ggplot2 framework. Having ggplot2 underlying the plots confers many advantages to the user, including generation of publication-quality plots and customization using the ggplot object returned by TDAstats.


To contribute to TDAstats, you can create issues for any bugs/suggestions on the issues page. You can also fork the TDAstats repository and create pull requests to add features you think will be useful for users.

Real-world applications, use cases, and mentions

rrrlw/TDAstats documentation built on Jan. 1, 2020, 11:54 p.m.