as_persistence.Rd
Transform persistence data to the format used by plt.
as_persistence(x, ...)
# S3 method for default
as_persistence(x, modulus = NULL, max_dim = NULL, threshold = NULL, ...)
# S3 method for persistence
as_persistence(x, ...)
# S3 method for list
as_persistence(x, ...)
# S3 method for diagram
as_persistence(x, ...)
# S3 method for PHom
as_persistence(x, ...)
# S3 method for persistence
print(x, ...)
# S3 method for persistence
format(x, ...)
get_pairs(x, degree, ...)
# S3 method for persistence
as.data.frame(x, row.names = NULL, optional = TRUE, ...)
Persistence data to be transformed; either a \(\geq 3\)-column
matrix (or object coercible to one) with dimension/degree, start/birth, and
end/death columns, a list whose first element is such an object, an object
of class 'PHom' as returned by [ripserr::vietoris_rips()]
, or (a list as
returned by a *Diag()
function in TDA (e.g. [TDA::ripsDiag()]
)
whose first element is) an object of class 'diagram'.
Parameters passed to methods.
Possibly missing parameters of the
calculation of the persistence data x
to be included in the 'persistence'
object.
Non-negative integer; the homology degree for which to recover a matrix of persistence pairs.
NULL
or a character vector giving the row
names for the data frame. Missing values are not allowed.
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.
Persistence data in the form of a list with named entries:
pairs
A list of 2-column matrices containing birth-death pairs in each dimension/degree, starting with zero.
modulus
The (integer) modulus of the prime field in which homology coefficientts were calculated.
max_dim
The (integer) maximum dimension of calculated features.
threshold
The (real) maximum length of an edge in the simplicial filtration.
This class and function will soon be spun off to a lower-level package that can be imported by others as needed. Refer to http://adv-r.had.co.nz/S3.html for guidance on methods to make available.
# sample from a cylinder
x <- tdaunif::sample_cylinder_elliptical(n = 60)
# calculate PH using {ripserr}
ph <- ripserr::vietoris_rips(x, dim = 1)
#> Warning: `dim` parameter has been deprecated; use `max_dim` instead.
as_persistence(ph)
#> 'persistence' data computed up to degree 1:
#>
#> * 0-degree features: 59
#> * 1-degree features: 8
# calculate PH using {TDA}
ph <- TDA::alphaComplexDiag(x, maxdimension = 1)
as_persistence(ph)
#> 'persistence' data computed up to degree 1:
#>
#> * 0-degree features: 60
#> * 1-degree features: 36
#>
#> threshold = 1.004018
# create a 'persistence' object directly from a matrix
as_persistence(unclass(ph$diagram))
#> 'persistence' data computed up to degree 2:
#>
#> * 0-degree features: 60
#> * 1-degree features: 36
#> * 2-degree features: 20