LaplacianScorer: Computes and samples 0 and 1-dimensional laplacian scores.

Description Fields Examples

Description

Builds an object to compute and sample values for the combinatorial laplacian score of functions defined on the set of points underlying a given simplicial complex. Takes in data about the complex and its 0- (and possibly 1-) dimensional laplacian to build a scorer. The scorer pushes functions defined on the points underlying the complex to the 0- (or 1-) dimensional skeleton by averaging over the points associated to each complex and evaluates the Rayleigh quotient of the normalized graph laplacean on the pushed function. The scorer can also sample values from the null distribution obtained by shuffling the labels of the underlying points.

Fields

new

Constructs a scorer using data on the complex and its associated laplacian.

Use scorer <- new(LaplacianScorer, comb_laplacian, pts_in_vertex, adjacency, one_forms)

Parameters

  • comb_laplacian: output of combinatorial_laplacian

  • pts_in_vertex: list of vectors where the i-th vector contains the index of the points associated to the i-th vertex

  • adjacency: adjacency matrix for 1-skeleton as a sparse matrix

  • one_forms: boolean indicating if laplacian of one-forms will be computed

score

Pushes functions defined by rows of funcs to the dim-skeleton by averaging and computes its laplacian score.

Use scorer$score(funcs, dim)

Parameters

  • funcs: functions to be scored as a rows of a dense matrix

  • dim: dimension of the laplacian (0 or 1)

Value Scores of functions as a vector

sample_scores

Takes samples of scores by permuting point labels

Use scorer$sample_scores(funcs, n_perm, dim, n_cores)

Parameters

  • funcs: base functions as rows of a dense matrix

  • n_perm: number of permutations

  • dim: dimension of the laplacian

  • n_cores: number of cores to be used, parallelization requires code to be compiled with openmp

Value Dense matrix with sampled scores where the i-th row has samples for the i-th function

sample_with_covariate

Takes samples of scores of function in tandem with scores of covariates by applying the same permutations of labels to both. Use scorer$sample_with_covariate(funcs, cov, n_perm, dim, n_cores) Parameters

  • funcs: base functions as rows of a dense matrix

  • cov: covariates as rows of a dense matrix

  • n_perm: number of permutations

  • dim: dimension of the laplacian

  • n_cores: number of cores to be used, parallelization requires code to be compiled with openmp

Value A list out with two elements

  • out$func_scores: a dense matrix with sampled scores where the i-th row has samples for the i-th function.

  • out$cov_scores: a dense 3-dimensional array where the position (i, j, k) has the sampled score of the j-th covariate associated to the k-th sample of the i-th function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(RayleighSelection)

# Create a simplicial complex and compute the associated 0- and 1-laplacians
gy <- nerve_complex(list(c(1,4,6,10), c(1,2,7), c(2,3,8), c(3,4,9,10), c(4,5)))
lout <- combinatorial_laplacian(gy, one_forms = TRUE)

# Create an associated instance of LaplacianScorer
scorer <- new(LaplacianScorer, lout, gy$points_in_vertex, gy$adjacency, TRUE)

# Compute the 0-laplacian score of a a function
scorer$score(t(as.matrix(c(0,1,1,0,0,0,0,0,0,1))), 0)

# Sample scores by shuffling the function
scorer$sample_scores(t(as.matrix(c(0,1,1,0,0,0,0,0,0,1))), 10, 0, 1)

# Sample scores in tandem with a covariate
scorer$sample_with_covariate(t(as.matrix(c(0,1,1,0,0,0,0,0,0,1))),
                             t(as.matrix(c(0,1,0,1,0,0,0,0,0,1))), 10, 0, 1)

CamaraLab/RayleighSelection documentation built on Aug. 16, 2021, 12:01 p.m.