persistence {phutil}R Documentation

An S3 class for storing persistence data

Description

A collection of functions to coerce persistence data into objects of class persistence (See Value section for more details on this class). It is currently possible to coerce persistence data from the following sources:

Usage

as_persistence(x, warn = TRUE, ...)

## S3 method for class 'list'
as_persistence(x, warn = TRUE, ...)

## S3 method for class 'persistence'
as_persistence(x, warn = TRUE, ...)

## S3 method for class 'data.frame'
as_persistence(x, warn = TRUE, ...)

## S3 method for class 'matrix'
as_persistence(x, warn = TRUE, ...)

## S3 method for class 'diagram'
as_persistence(x, warn = TRUE, ...)

## S3 method for class 'PHom'
as_persistence(x, ...)

## S3 method for class 'hclust'
as_persistence(x, warn = TRUE, birth = NULL, ...)

## S3 method for class 'persistence'
print(x, ...)

## S3 method for class 'persistence'
format(x, ...)

get_pairs(x, dimension, ...)

## S3 method for class 'persistence'
as.matrix(x, ...)

## S3 method for class 'persistence'
as.data.frame(x, row.names = NULL, optional = TRUE, ...)

Arguments

x

An R object containing the persistence data to be coerced into an object of class persistence. Currently supported forms are:

  • a \geq 2-column matrix (or object coercible to one) with dimension/degree, start/birth and end/death columns; if it has only 2 columns, we assume that the dimension column is missing and we set it to 0 (i.e. we assume that the data is in the form birth and death),

  • a base::data.frame (or object coercible to one) with at least 3 columns containing the persistence data; if it has only 2 columns, we assume that the dimension column is missing and we set it to 0,

  • a list of 2-column matrices (or objects coercible to one) with the first column being the birth and the second column being the death of homological features; indexed by dimension, i.e. the i-th element of the list corresponds to the (i-1)-th homology dimension,

  • an object of class 'PHom' as returned by ripserr::vietoris_rips(),

  • (a list as returned by a ⁠*Diag()⁠ function in TDA (e.g. TDA::ripsDiag()) whose first element is) an object of class 'diagram',

  • an object of class stats::hclust in which case we use the entry height as the death of homological features and 0 as the birth of all features.

warn

A boolean specifying whether to issue a warning if the input persistence data contained unordered pairs. Defaults to TRUE.

...

Parameters passed to methods.

birth

A numeric value specifying the height at which to declare all leaves were born. Defaults to 0 if all heights are non-negative and -Inf otherwise.

dimension

A non-negative integer specifying the homology dimension for which to recover a matrix of persistence pairs.

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

logical. If TRUE, setting row names and converting column names (to syntactic names: see make.names) is optional. Note that all of R's base package as.data.frame() methods use optional only for column names treatment, basically with the meaning of data.frame(*, check.names = !optional). See also the make.names argument of the matrix method.

Details

Caution. When providing an unnamed input matrix, the matrix coercer assumes that it has at least 3 columns, with the first column being the dimension/degree, the second column being the start/birth and the third column being the end/death.

Value

An object of class persistence which is a list of 2 elements:

Examples

as_persistence(noisy_circle_ripserr)

x <- as_persistence(noisy_circle_tda_rips)
x

as_persistence(x)

get_pairs(x, dimension = 1)

as.data.frame(x)

# distances between cities
euroclust <- hclust(eurodist, method = "ward.D")
as_persistence(euroclust)

# `hclust()` can accommodate negative distances
d <- as.dist(rbind(c(0, 3, -4), c(3, 0, 5), c(-4, 5, 0)))
hc <- hclust(d, method = "single")
ph <- as_persistence(hc, birth = -10)
get_pairs(ph, 0)

[Package phutil version 0.0.1 Index]