sim_annotate
annotates a melted similarity matrix.
sim_annotate(
sim_df,
row_metadata,
annotation_cols,
index = "both",
sim_cols = c("id1", "id2", "sim")
)
data.frame with melted similarity matrix.
data.frame with row metadata.
character vector specifying annotation columns.
optional character string specifying whether to annotate left index, right index, or both.
This must be one of the strings "both"
(default), "left"
, "right"
.
optional character string specifying minimal set of columns for a similarity matrix
Annotated melted similarity matrix of the same class as sim_df
.
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