knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ripserr: Calculate Persistent Homology of Vietoris-Rips and Cubical Complexes using Ripser in R

Travis-CI Build Status AppVeyor Build Status Codecov test coverage

License: GPL v3 CRAN version CRAN Downloads

Overview

ripserr ports the Ripser and Cubical Ripser persistent homology calculation engines from C++ via Rcpp. It can be used as a convenient and rapid calculation tool in topological data analysis pipelines.

Installation

# install development version
devtools::install_github("rrrlw/ripserr")

# install from CRAN (not available yet)
# install.packages("ripserr")

Sample code

Ripser (Vietoris-Rips complex) can be used as follows for data with dimension greater than or equal to 2.

# load ripserr
library("ripserr")

set.seed(42)
SIZE <- 100

# 2-dimensional example
dataset2 <- rnorm(SIZE * 2)
dim(dataset2) <- c(SIZE, 2)
vr_phom2 <- vietoris_rips(dataset2)
head(vr_phom2)
tail(vr_phom2)

# 3-dimensional example
dataset3 <- rnorm(SIZE * 3)
dim(dataset3) <- c(SIZE, 3)
vr_phom3 <- vietoris_rips(dataset3, max_dim = 2) # default: max_dim = 1
head(vr_phom3)
tail(vr_phom3)

Cubical Ripser (cubical complex) can be used as follows for data with dimension equal to 2, 3, or 4.

# load ripserr
library("ripserr")

set.seed(42)
SIZE <- 10

# 2-dimensional example
dataset2 <- rnorm(SIZE ^ 2)
dim(dataset2) <- rep(SIZE, 2)
cub_phom2 <- cubical(dataset2)
head(cub_phom2)
tail(cub_phom2)

# 3-dimensional example
dataset3 <- rnorm(SIZE ^ 3)
dim(dataset3) <- rep(SIZE, 3)
cub_phom3 <- cubical(dataset3)
head(cub_phom3)
tail(cub_phom3)

# 4-dimensional example
dataset4 <- rnorm(SIZE ^ 4)
dim(dataset4) <- rep(SIZE, 4)
cub_phom4 <- cubical(dataset4)
head(cub_phom4)
tail(cub_phom4)

Functionality

  1. Calculation of persistent homology of Vietoris-Rips complexes using Ripser (function named vietoris_rips).
  2. Calculation of persistent homology of cubical complexes using Cubical Ripser (function named cubical).

Citation

If you use the ripserr package in your work, please consider citing the following (based on use):

Contribute

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



rrrlw/ripserr documentation built on July 12, 2022, 11:13 a.m.