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

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,
  ...
)

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

Value

co-occurrence matrix

Examples

# 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)
#>           [,1]      [,2]
#> [1,] 0.2222222 0.2606838
#> [2,] 0.2606838 0.2564103