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:
a matrix with at least 3 columns (dimension/degree, start/birth, end/death) as returned by
ripserr::vietoris_rips()
in the form of the 'PHom' class,a list as returned by any
*Diag()
function in the TDA package.
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
|
warn |
A boolean specifying whether to issue a warning if the input
persistence data contained unordered pairs. Defaults to |
... |
Parameters passed to methods. |
birth |
A numeric value specifying the height at which to declare all
leaves were born. Defaults to |
dimension |
A non-negative integer specifying the homology dimension for which to recover a matrix of persistence pairs. |
row.names |
|
optional |
logical. If |
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:
-
pairs
: A list of 2-column matrices containing birth-death pairs. Thei
-th element of the list corresponds to the(i-1)
-th homology dimension. If there is no pairs for a given dimension but there are pairs in higher dimensions, the corresponding element(s) is/are filled with a0 \times 2
numeric matrix. -
metadata
: A list of length 6 containing information about how the data was computed:-
orderered_pairs
: A boolean indicating whether the pairs in thepairs
list are ordered (i.e. the first column is strictly less than the second column). -
data
: The name of the object containing the original data on which the persistence data was computed. -
engine
: The name of the package and the function of this package that computed the persistence data in the form"package_name::package_function"
. -
filtration
: The filtration used in the computation in a human-readable format (i.e. full names, capitals where need, etc.). -
parameters
: A list of parameters used in the computation. -
call
: The exact call that generated the persistence data.
-
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)