sim_annotate annotates a melted similarity matrix.

sim_annotate(
  sim_df,
  row_metadata,
  annotation_cols,
  index = "both",
  sim_cols = c("id1", "id2", "sim")
)

Arguments

sim_df

data.frame with melted similarity matrix.

row_metadata

data.frame with row metadata.

annotation_cols

character vector specifying annotation columns.

index

optional character string specifying whether to annotate left index, right index, or both. This must be one of the strings "both" (default), "left", "right".

sim_cols

optional character string specifying minimal set of columns for a similarity matrix

Value

Annotated melted similarity matrix of the same class as sim_df.

Examples

suppressMessages(suppressWarnings(library(magrittr)))
population <- tibble::tibble(
  Metadata_group = sample(c("a", "b"), 4, replace = TRUE),
  Metadata_type = sample(c("x", "y"), 4, replace = TRUE),
  x = rnorm(4),
  y = x + rnorm(4) / 100,
  z = y + rnorm(4) / 1000
)
annotation_cols <- c("Metadata_group")
sim_df <- matric::sim_calculate(population, method = "pearson")
row_metadata <- attr(sim_df, "row_metadata")
matric::sim_annotate(sim_df, row_metadata, annotation_cols)
#>    id1 id2        sim Metadata_group1 Metadata_group2
#> 1    2   1 -0.8929879               b               b
#> 2    3   1 -0.9880357               a               b
#> 3    4   1  0.9917485               b               b
#> 4    1   2 -0.8929879               b               b
#> 5    3   2  0.9517178               a               b
#> 6    4   2 -0.9433193               b               b
#> 7    1   3 -0.9880357               b               a
#> 8    2   3  0.9517178               b               a
#> 9    4   3 -0.9996544               b               a
#> 10   1   4  0.9917485               b               b
#> 11   2   4 -0.9433193               b               b
#> 12   3   4 -0.9996544               a               b