Learn R Programming

topolow (version 1.0.0)

prepare_heatmap_data: Generate Distance Matrix Heatmap Data

Description

Prepares distance matrix data for heatmap visualization by handling missing values and calculating relevant statistics.

Usage

prepare_heatmap_data(
  distance_matrix,
  cluster_rows = FALSE,
  cluster_cols = FALSE
)

Value

A list of data prepared for generating a heatmap of the distance matrix:

matrix_data

The distance matrix, potentially reordered by clustering.

row_order

An integer vector of the row indices after clustering. If cluster_rows is FALSE, this is the original order.

col_order

An integer vector of the column indices after clustering. If cluster_cols is FALSE, this is the original order.

stats

A list of summary statistics for the distance matrix, including mean, sd, min, max, and completeness.

Arguments

distance_matrix

Square symmetric matrix of distances

cluster_rows

Logical; whether to cluster rows

cluster_cols

Logical; whether to cluster columns

Examples

Run this code
# Create a sample distance matrix
dist_mat <- matrix(runif(25), 5, 5)

# Prepare data for a heatmap
heatmap_data <- prepare_heatmap_data(dist_mat)
print(heatmap_data$stats$completeness)

Run the code above in your browser using DataLab