Cluster functional terms by recursively binary cutting the similarity matrix
Source:R/binary_cut.R
binary_cut.Rd
Cluster functional terms by recursively binary cutting the similarity matrix
Usage
plot_binary_cut(
mat,
value_fun = area_above_ecdf,
cutoff = 0.85,
partition_fun = partition_by_pam,
dend = NULL,
dend_width = unit(3, "cm"),
depth = NULL,
show_heatmap_legend = TRUE,
...
)
binary_cut(
mat,
value_fun = area_above_ecdf,
partition_fun = partition_by_hclust,
cutoff = 0.85,
try_all_partition_fun = TRUE,
partial = nrow(mat) > 1500
)
Arguments
- mat
A similarity matrix.
- value_fun
A function that calculates the scores for the four submatrices on a node.
- cutoff
The cutoff for splitting the dendrogram.
- partition_fun
A function to split each node into two groups. Pre-defined functions in this package are
partition_by_kmeanspp()
,partition_by_pam()
andpartition_by_hclust()
.- dend
A dendrogram object, used internally.
- dend_width
Width of the dendrogram on the plot.
- depth
Depth of the recursive binary cut process.
- show_heatmap_legend
Whether to show the heatmap legend.
- ...
Other arguments.
- try_all_partition_fun
Different
partition_fun
may give different clusterings. If the vaule oftry_all_partition_fun
is set toTRUE
, the similarity matrix is clustered by three partitioning method:partition_by_pam()
,partition_by_kmeanspp()
andpartition_by_hclust()
. The clustering with the highest difference score is finally selected as the final clustering.- partial
Whether to generate the complete clustering or the clustering stops when sub-matrices cannot be split anymore.
Details
After the functions which perform clustering are executed, such as simplifyGO()
or
binary_cut()
, the dendrogram is temporarily saved and plot_binary_cut()
directly
uses this dendrogram.
Examples
# \donttest{
mat = readRDS(system.file("extdata", "random_GO_BP_sim_mat.rds",
package = "simplifyEnrichment"))
plot_binary_cut(mat, depth = 1)
#> create a new dendrogram.
plot_binary_cut(mat, depth = 2)
#> use the cached dendrogram.
plot_binary_cut(mat)
#> use the cached dendrogram.
# }
mat = readRDS(system.file("extdata", "random_GO_BP_sim_mat.rds",
package = "simplifyEnrichment"))
binary_cut(mat)
#> [1] 1 2 3 4 5 4 4 4 1 3 3 5 1 5 1 4 1 4 5 4 5 1 4 3 6
#> [26] 3 7 4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