Learn R Programming

gtexture (version 1.0.0)

comat: Calculate Co-Occurrence Matrix

Description

Calculate generalized co-occurrence matrix from a variety of objects, currently including fitness landscapes stored as a FitLandDF instance from the fitscape package.

Usage

get_comatrix(x, ...)

# S3 method for default get_comatrix(x, ...)

# S3 method for FitLandDF get_comatrix( x, discrete = equal_discrete(2), neighbor = manhattan(1), normalize = normalize_glcm, ... )

# S3 method for igraph get_comatrix( x, values, nlevels = length(unique(values)), normalize = normalize_glcm, verbose = TRUE, ... )

Value

matrix (co-occurrence matrix)

Arguments

x

object upon which co-occurrence matrix will be calculated

...

additional arguments

discrete

function that discretizes object

neighbor

function that returns TRUE if two numeric vectors are within acceptable distance of one another or a single-element character vector that describes how to identify acceptable neighbors/offsets

normalize

function that normalizes the co-occurrence matrix

values

named numeric with values corresponding to the nodes in x.

nlevels

int number of levels to discretize into

verbose

bool

Examples

Run this code
# create fitness landscape as instance of FitLandDF object
a <- round(runif(64))
a <- array(a, dim = rep(4, 3))
my_landscape <- fitscape::FitLandDF(a)

# calculate co-occurrence matrix using:
#   Manhattan distance of 1
#   discretization into 2 equal-sized buckets
#   normalization: multiply all elements so that sum of matrix equals unity
comat <- get_comatrix(my_landscape,
                      discrete = equal_discrete(2),
                      neighbor = manhattan(1))

# print co-occurrence matrix
print(comat)

Run the code above in your browser using DataLab