Package 'invertiforms'

Title: Invertible Transforms for Matrices
Description: Provides composable invertible transforms for (sparse) matrices.
Authors: Alex Hayes [aut, cre, cph]
Maintainer: Alex Hayes <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9000
Built: 2024-11-01 03:08:49 UTC
Source: https://github.com/rohelab/invertiforms

Help Index


Construct and use DoubleCenter transformations

Description

A convenience function to create DoubleCenter S4 objects, which are useful for simultaneously row and column centering a matrix.

Usage

DoubleCenter(A)

## S4 method for signature 'DoubleCenter,sparseMatrix'
transform(iform, A)

## S4 method for signature 'DoubleCenter,sparseLRMatrix'
inverse_transform(iform, A)

## S4 method for signature 'DoubleCenter,vsp_fa'
inverse_transform(iform, A)

Arguments

A

A matrix to transform.

iform

An Invertiform object describing the transformation.

Value

Examples

library(igraph)
library(igraphdata)

data("karate", package = "igraphdata")

A <- get.adjacency(karate)

iform <- DoubleCenter(A)

A_tilde <- transform(iform, A)
A_recovered <- inverse_transform(iform, A_tilde)

all.equal(A, A_recovered)

Row and column centering transformation

Description

Row and column centering transformation

Slots

row_means

numeric.

col_means

numeric.

overall_mean

numeric.


Apply the inverse of an invertible transformation

Description

Apply the inverse of an invertible transformation

Usage

inverse_transform(iform, A)

Arguments

iform

An Invertiform object describing the transformation.

A

A matrix to inverse transform.

Value

The inverse transformed matrix.


An abstract S4 class representing an invertible transformation

Description

An abstract S4 class representing an invertible transformation


Construct and use the Normalized Laplacian

Description

A convenience function to create NormalizedLaplacian S4 objects, which are useful for finding the normalized Laplacian of the adjacency matrix of a graph.

Usage

NormalizedLaplacian(A)

## S4 method for signature 'NormalizedLaplacian,sparseMatrix'
transform(iform, A)

## S4 method for signature 'NormalizedLaplacian,sparseMatrix'
inverse_transform(iform, A)

Arguments

A

A matrix to transform.

iform

An Invertiform object describing the transformation.

Details

We define the normalized Laplacian L(A)L(A) of an n×nn \times n graph adjacency matrix AA as

L(A)ij=AijdioutdjinL(A)_{ij} = \frac{A_{ij}}{\sqrt{d^{out}_i} \sqrt{d^{in}_j}}

where

diout=j=1nAijd^{out}_i = \sum_{j=1}^n \| A_{ij} \|

and

djin=i=1nAij.d^{in}_j = \sum_{i=1}^n \| A_{ij} \|.

When AijA_{ij} denotes the present of an edge from node ii to node jj, which is fairly standard notation, dioutd^{out}_i denotes the (absolute) out-degree of node ii and djind^{in}_j denotes the (absolute) in-degree of node jj.

Note that this documentation renders most clearly at https://rohelab.github.io/invertiforms/.

Value

  • NormalizedLaplacian() creates a NormalizedLaplacian object.

  • transform() returns the transformed matrix, typically as a Matrix.

  • inverse_transform() returns the inverse transformed matrix, typically as a Matrix.

Examples

library(igraph)
library(igraphdata)

data("karate", package = "igraphdata")

A <- get.adjacency(karate)

iform <- NormalizedLaplacian(A)

L <- transform(iform, A)
A_recovered <- inverse_transform(iform, L)

all.equal(A, A_recovered)

Normalized graph Laplacian transformation

Description

Normalized graph Laplacian transformation

Slots

rsA

numeric.

csA

numeric.


Construct and use the Perturbed Laplacian

Description

Construct and use the Perturbed Laplacian

Usage

PerturbedLaplacian(A, tau = NULL)

## S4 method for signature 'PerturbedLaplacian,sparseMatrix'
transform(iform, A)

## S4 method for signature 'PerturbedLaplacian,sparseLRMatrix'
inverse_transform(iform, A)

Arguments

A

A matrix to transform.

tau

Additive regularizer for row and column sums of abs(A). Typically this corresponds to inflating the (absolute) out-degree and the (absolute) in-degree of each node by tau. Defaults to NULL, in which case we set tau to the mean value of abs(A).

iform

An Invertiform object describing the transformation.

Details

We define the perturbed Laplacian Lτ(A)L^\tau(A) of an n×nn \times n graph adjacency matrix AA as

Lτ(A)ij=Aij+τndiout+τdjin+τL^\tau(A)_{ij} = \frac{A_{ij} + \frac{\tau}{n}}{\sqrt{d^{out}_i + \tau} \sqrt{d^{in}_j + \tau}}

where

diout=j=1nAijd^{out}_i = \sum_{j=1}^n \|A_{ij} \|

and

djin=i=1nAij.d^{in}_j = \sum_{i=1}^n \|A_{ij} \|.

When AijA_{ij} denotes the present of an edge from node ii to node jj, which is fairly standard notation, dioutd^{out}_i denotes the (absolute) out-degree of node ii and djind^{in}_j denotes the (absolute) in-degree of node jj.

Note that this documentation renders more clearly at https://rohelab.github.io/invertiforms/.

Value

  • PerturbedLaplacian() creates a PerturbedLaplacian object.

  • transform() returns the transformed matrix, typically as a Matrix.

  • inverse_transform() returns the inverse transformed matrix, typically as a Matrix.

Examples

library(igraph)
library(igraphdata)

data("karate", package = "igraphdata")

A <- get.adjacency(karate)

iform <- PerturbedLaplacian(A)

L <- transform(iform, A)
L

## Not run: 
A_recovered <- inverse_transform(iform, L)
all.equal(A, A_recovered)

## End(Not run)

Perturbed graph Laplacian transformation

Description

Perturbed graph Laplacian transformation

Slots

tau

numeric.

rsA

numeric.

csA

numeric.

tau_choice

character.


Construct and use the Regularized Laplacian

Description

Construct and use the Regularized Laplacian

Usage

RegularizedLaplacian(A, tau_row = NULL, tau_col = NULL)

## S4 method for signature 'RegularizedLaplacian,Matrix'
transform(iform, A)

## S4 method for signature 'RegularizedLaplacian,matrix'
transform(iform, A)

## S4 method for signature 'RegularizedLaplacian,sparseLRMatrix'
transform(iform, A)

## S4 method for signature 'RegularizedLaplacian,Matrix'
inverse_transform(iform, A)

## S4 method for signature 'RegularizedLaplacian,matrix'
inverse_transform(iform, A)

## S4 method for signature 'RegularizedLaplacian,vsp_fa'
inverse_transform(iform, A)

Arguments

A

A matrix to transform.

tau_row

Additive regularizer for row sums of abs(A). Typically this corresponds to inflating the (absolute) out-degree of each node by tau_row. Defaults to NULL, in which case we set tau_row to the mean (absolute) row sum of A.

tau_col

Additive regularizer for column sums of abs(A). Typically this corresponds to inflating the (absolute) in-degree of each node by tau_col. Defaults to NULL, in which case we set tau_col to the mean (absolute) column sum of A.

iform

An Invertiform object describing the transformation.

Details

We define the regularized Laplacian Lτ(A)L^\tau(A) of an n×nn \times n graph adjacency matrix AA as

Lτ(A)ij=Aijdiout+τrowdjin+τcolL^\tau(A)_{ij} = \frac{A_{ij}}{\sqrt{d^{out}_i + \tau_{row}} \sqrt{d^{in}_j + \tau_{col}}}

where

diout=j=1nAijd^{out}_i = \sum_{j=1}^n \| A_{ij} \|

and

djin=i=1nAij.d^{in}_j = \sum_{i=1}^n \| A_{ij} \|.

When AijA_{ij} denotes the present of an edge from node ii to node jj, which is fairly standard notation, dioutd^{out}_i denotes the (absolute) out-degree of node ii and djind^{in}_j denotes the (absolute) in-degree of node jj. Then τrow\tau_{row} is an additive out-degree regularizer and τcol\tau_{col} is an additive in-degree regularizer.

Note that this documentation renders more clearly at https://rohelab.github.io/invertiforms/.

Value

  • RegularizedLaplacian() creates a RegularizedLaplacian object.

  • transform() returns the transformed matrix, typically as a Matrix.

  • inverse_transform() returns the inverse transformed matrix, typically as a Matrix.

Examples

library(igraph)
library(igraphdata)

data("karate", package = "igraphdata")

A <- get.adjacency(karate)

iform <- RegularizedLaplacian(A)

L <- transform(iform, A)
L

A_recovered <- inverse_transform(iform, L)

all.equal(A, A_recovered)

Regularized graph Laplacian transformation

Description

Regularized graph Laplacian transformation

Slots

tau_row

numeric.

tau_col

numeric.

rsA

numeric.

csA

numeric.

tau_choice_row

character.

tau_choice_col

character.


Apply an invertible transformation

Description

Apply an invertible transformation

Usage

transform(iform, A)

Arguments

iform

An Invertiform object describing the transformation.

A

A matrix to transform.

Value

The transformed matrix.