Date: 2021-07-22 16:07:29 CEST, cola version: 1.9.4
Document is loading...
First the variable is renamed to res_rh
.
res_rh = rh
The partition hierarchy and all available functions which can be applied to res_rh
object.
res_rh
#> A 'HierarchicalPartition' object with 'ATC:skmeans' method.
#> On a matrix with 11993 rows and 128 columns.
#> Performed in total 3300 partitions.
#> There are 15 groups under the following parameters:
#> - min_samples: 6
#> - mean_silhouette_cutoff: 0.9
#> - min_n_signatures: 448 (signatures are selected based on:)
#> - fdr_cutoff: 0.05
#> - group_diff (scaled values): 0.5
#>
#> Hierarchy of the partition:
#> 0, 128 cols
#> |-- 01, 58 cols, 4791 signatures
#> | |-- 011, 32 cols, 1901 signatures
#> | | |-- 0111, 9 cols (b)
#> | | |-- 0112, 9 cols (b)
#> | | |-- 0113, 8 cols (b)
#> | | `-- 0114, 6 cols (b)
#> | |-- 012, 13 cols, 1224 signatures
#> | | |-- 0121, 7 cols (b)
#> | | |-- 0122, 4 cols (b)
#> | | `-- 0123, 2 cols (b)
#> | `-- 013, 13 cols, 129 signatures (c)
#> |-- 02, 39 cols, 5639 signatures
#> | |-- 021, 14 cols, 137 signatures (c)
#> | |-- 022, 18 cols, 561 signatures
#> | | |-- 0221, 8 cols (b)
#> | | `-- 0222, 10 cols (b)
#> | `-- 023, 7 cols (b)
#> `-- 03, 31 cols, 1726 signatures
#> |-- 031, 14 cols, 4 signatures (c)
#> |-- 032, 9 cols (b)
#> `-- 033, 8 cols (b)
#> Stop reason:
#> b) Subgroup had too few columns.
#> c) There were too few signatures.
#>
#> Following methods can be applied to this 'HierarchicalPartition' object:
#> [1] "all_leaves" "all_nodes" "cola_report" "collect_classes"
#> [5] "colnames" "compare_signatures" "dimension_reduction" "functional_enrichment"
#> [9] "get_anno_col" "get_anno" "get_children_nodes" "get_classes"
#> [13] "get_matrix" "get_signatures" "is_leaf_node" "max_depth"
#> [17] "merge_node" "ncol" "node_info" "node_level"
#> [21] "nrow" "rownames" "show" "split_node"
#> [25] "suggest_best_k" "test_to_known_factors" "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single node by e.g. object["01"]
The call of hierarchical_partition()
was:
#> hierarchical_partition(data = m, anno = anno, cores = 4)
Dimension of the input matrix:
mat = get_matrix(res_rh)
dim(mat)
#> [1] 11993 128
All the methods that were tried:
res_rh@param$combination_method
#> [[1]]
#> [1] "ATC" "skmeans"
The density distribution for each sample is visualized as one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_rh),
col = get_anno_col(res_rh)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 1)
Some values about the hierarchy:
all_nodes(res_rh)
#> [1] "0" "01" "011" "0111" "0112" "0113" "0114" "012" "0121" "0122" "0123" "013" "02"
#> [14] "021" "022" "0221" "0222" "023" "03" "031" "032" "033"
all_leaves(res_rh)
#> [1] "0111" "0112" "0113" "0114" "0121" "0122" "0123" "013" "021" "0221" "0222" "023" "031"
#> [14] "032" "033"
node_info(res_rh)
#> id best_method depth best_k n_columns n_signatures p_signatures is_leaf
#> 1 0 ATC:skmeans 1 3 128 8975 0.748353 FALSE
#> 2 01 ATC:skmeans 2 3 58 4791 0.399483 FALSE
#> 3 011 ATC:skmeans 3 4 32 1901 0.158509 FALSE
#> 4 0111 not applied 4 NA 9 NA NA TRUE
#> 5 0112 not applied 4 NA 9 NA NA TRUE
#> 6 0113 not applied 4 NA 8 NA NA TRUE
#> 7 0114 not applied 4 NA 6 NA NA TRUE
#> 8 012 ATC:skmeans 3 3 13 1224 0.102060 FALSE
#> 9 0121 not applied 4 NA 7 NA NA TRUE
#> 10 0122 not applied 4 NA 4 NA NA TRUE
#> 11 0123 not applied 4 NA 2 NA NA TRUE
#> 12 013 ATC:skmeans 3 2 13 129 0.010756 TRUE
#> 13 02 ATC:skmeans 2 3 39 5639 0.470191 FALSE
#> 14 021 ATC:skmeans 3 2 14 137 0.011423 TRUE
#> 15 022 ATC:skmeans 3 2 18 561 0.046777 FALSE
#> 16 0221 not applied 4 NA 8 NA NA TRUE
#> 17 0222 not applied 4 NA 10 NA NA TRUE
#> 18 023 not applied 3 NA 7 NA NA TRUE
#> 19 03 ATC:skmeans 2 3 31 1726 0.143917 FALSE
#> 20 031 ATC:skmeans 3 2 14 4 0.000334 TRUE
#> 21 032 not applied 3 NA 9 NA NA TRUE
#> 22 033 not applied 3 NA 8 NA NA TRUE
In the output from node_info()
, there are the following columns:
id
: The node id.best_method
: The best method selected.depth
: Depth of the node in the hierarchy.best_k
: Best number of groups of the partition on that node.n_columns
: Number of columns in the submatrix.n_signatures
: Number of signatures with the best_k
.p_signatures
: Proportion of hte signatures in total number of rows in the matrix.is_leaf
: Whether the node is a leaf.Labels of nodes are encoded in a special way. The number of digits correspond to the depth of the node in the hierarchy and the value of the digits correspond to the index of the subgroup in the current node, E.g. a label of “012” means the node is the second subgroup of the partition which is the first subgroup of the root node.
Following table shows the best k
(number of partitions) for each node in the
partition hierarchy. Clicking on the node name in the table goes to the
corresponding section for the partitioning on that node.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_rh)
Node | Best method | Is leaf | Best k | 1-PAC | Mean silhouette | Concordance | #samples | |
---|---|---|---|---|---|---|---|---|
Node0 | ATC:skmeans | 3 | 1.00 | 0.95 | 0.98 | 128 | ** | |
Node01 | ATC:skmeans | 3 | 1.00 | 0.98 | 0.99 | 58 | ** | |
Node011 | ATC:skmeans | 4 | 1.00 | 0.98 | 0.98 | 32 | ** | |
Node0111-leaf | not applied | ✓ (b) | 9 | |||||
Node0112-leaf | not applied | ✓ (b) | 9 | |||||
Node0113-leaf | not applied | ✓ (b) | 8 | |||||
Node0114-leaf | not applied | ✓ (b) | 6 | |||||
Node012 | ATC:skmeans | 3 | 1.00 | 1.00 | 1.00 | 13 | ** | |
Node0121-leaf | not applied | ✓ (b) | 7 | |||||
Node0122-leaf | not applied | ✓ (b) | 4 | |||||
Node0123-leaf | not applied | ✓ (b) | 2 | |||||
Node013-leaf | ATC:skmeans | ✓ (c) | 2 | 1.00 | 1.00 | 1.00 | 13 | ** |
Node02 | ATC:skmeans | 3 | 1.00 | 1.00 | 1.00 | 39 | ** | |
Node021-leaf | ATC:skmeans | ✓ (c) | 4 | 0.92 | 0.95 | 0.97 | 14 | * |
Node022 | ATC:skmeans | 2 | 1.00 | 1.00 | 1.00 | 18 | ** | |
Node0221-leaf | not applied | ✓ (b) | 8 | |||||
Node0222-leaf | not applied | ✓ (b) | 10 | |||||
Node023-leaf | not applied | ✓ (b) | 7 | |||||
Node03 | ATC:skmeans | 3 | 1.00 | 0.99 | 0.99 | 31 | ** | |
Node031-leaf | ATC:skmeans | ✓ (c) | 2 | 1.00 | 1.00 | 1.00 | 14 | ** |
Node032-leaf | not applied | ✓ (b) | 9 | |||||
Node033-leaf | not applied | ✓ (b) | 8 |
Stop reason: b) Subgroup had too few columns. c) There were too few signatures.
**: 1-PAC > 0.95, *: 1-PAC > 0.9
The nodes of the hierarchy can be merged by setting the merge_node
parameters. Here we
control the hierarchy with the min_n_signatures
parameter. The value of min_n_signatures
is
from node_info()
.
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 561))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1224))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1726))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1901))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 4791))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 5639))
collect_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 8975))
Following shows the table of the partitions (You need to click the show/hide code output link to see it).
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 561))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024
#> "013" "021" "013" "021" "0111" "023" "021" "0111" "0222" "0114" "013" "0111" "013" "032"
#> 09008 09017 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009
#> "023" "033" "013" "032" "013" "0222" "0222" "0222" "0222" "0222" "032" "0221" "0222" "021"
#> 19005 20002 22009 22010 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019
#> "0221" "023" "033" "031" "013" "033" "0111" "0111" "0121" "0121" "0222" "021" "033" "021"
#> 24022 25003 25006 26001 26003 26005 26008 27003 27004 28001 28003 28005 28006 28007
#> "0113" "033" "021" "0222" "0113" "0222" "021" "032" "0114" "032" "031" "0114" "0121" "0114"
#> 28019 28021 28023 28024 28028 28031 28032 28035 28036 28037 28042 28043 28044 28047
#> "021" "023" "0114" "0114" "0113" "032" "0113" "023" "0113" "023" "031" "0113" "0221" "0122"
#> 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007 43012 48001 49006 57001
#> "021" "032" "0112" "023" "0221" "0111" "0221" "032" "033" "0122" "031" "0221" "013" "0112"
#> 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003 01007 02020
#> "0112" "0112" "033" "0121" "0111" "021" "0111" "021" "0113" "0111" "013" "031" "031" "0221"
#> 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "0112" "013" "0121" "0121" "033" "021" "0112" "0112" "032" "0112" "031" "0122" "031" "0122"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003
#> "0113" "031" "021" "0121" "031" "0123" "031" "013" "0112" "0123" "013" "013" "031" "031"
#> 83001 LAL4
#> "0221" "031"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1224))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024
#> "013" "021" "013" "021" "0111" "023" "021" "0111" "022" "0114" "013" "0111" "013" "032"
#> 09008 09017 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009
#> "023" "033" "013" "032" "013" "022" "022" "022" "022" "022" "032" "022" "022" "021"
#> 19005 20002 22009 22010 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019
#> "022" "023" "033" "031" "013" "033" "0111" "0111" "0121" "0121" "022" "021" "033" "021"
#> 24022 25003 25006 26001 26003 26005 26008 27003 27004 28001 28003 28005 28006 28007
#> "0113" "033" "021" "022" "0113" "022" "021" "032" "0114" "032" "031" "0114" "0121" "0114"
#> 28019 28021 28023 28024 28028 28031 28032 28035 28036 28037 28042 28043 28044 28047
#> "021" "023" "0114" "0114" "0113" "032" "0113" "023" "0113" "023" "031" "0113" "022" "0122"
#> 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007 43012 48001 49006 57001
#> "021" "032" "0112" "023" "022" "0111" "022" "032" "033" "0122" "031" "022" "013" "0112"
#> 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003 01007 02020
#> "0112" "0112" "033" "0121" "0111" "021" "0111" "021" "0113" "0111" "013" "031" "031" "022"
#> 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "0112" "013" "0121" "0121" "033" "021" "0112" "0112" "032" "0112" "031" "0122" "031" "0122"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003
#> "0113" "031" "021" "0121" "031" "0123" "031" "013" "0112" "0123" "013" "013" "031" "031"
#> 83001 LAL4
#> "022" "031"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1726))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024
#> "013" "021" "013" "021" "0111" "023" "021" "0111" "022" "0114" "013" "0111" "013" "032"
#> 09008 09017 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009
#> "023" "033" "013" "032" "013" "022" "022" "022" "022" "022" "032" "022" "022" "021"
#> 19005 20002 22009 22010 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019
#> "022" "023" "033" "031" "013" "033" "0111" "0111" "012" "012" "022" "021" "033" "021"
#> 24022 25003 25006 26001 26003 26005 26008 27003 27004 28001 28003 28005 28006 28007
#> "0113" "033" "021" "022" "0113" "022" "021" "032" "0114" "032" "031" "0114" "012" "0114"
#> 28019 28021 28023 28024 28028 28031 28032 28035 28036 28037 28042 28043 28044 28047
#> "021" "023" "0114" "0114" "0113" "032" "0113" "023" "0113" "023" "031" "0113" "022" "012"
#> 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007 43012 48001 49006 57001
#> "021" "032" "0112" "023" "022" "0111" "022" "032" "033" "012" "031" "022" "013" "0112"
#> 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003 01007 02020
#> "0112" "0112" "033" "012" "0111" "021" "0111" "021" "0113" "0111" "013" "031" "031" "022"
#> 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "0112" "013" "012" "012" "033" "021" "0112" "0112" "032" "0112" "031" "012" "031" "012"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003
#> "0113" "031" "021" "012" "031" "012" "031" "013" "0112" "012" "013" "013" "031" "031"
#> 83001 LAL4
#> "022" "031"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 1901))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024
#> "013" "021" "013" "021" "0111" "023" "021" "0111" "022" "0114" "013" "0111" "013" "03"
#> 09008 09017 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009
#> "023" "03" "013" "03" "013" "022" "022" "022" "022" "022" "03" "022" "022" "021"
#> 19005 20002 22009 22010 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019
#> "022" "023" "03" "03" "013" "03" "0111" "0111" "012" "012" "022" "021" "03" "021"
#> 24022 25003 25006 26001 26003 26005 26008 27003 27004 28001 28003 28005 28006 28007
#> "0113" "03" "021" "022" "0113" "022" "021" "03" "0114" "03" "03" "0114" "012" "0114"
#> 28019 28021 28023 28024 28028 28031 28032 28035 28036 28037 28042 28043 28044 28047
#> "021" "023" "0114" "0114" "0113" "03" "0113" "023" "0113" "023" "03" "0113" "022" "012"
#> 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007 43012 48001 49006 57001
#> "021" "03" "0112" "023" "022" "0111" "022" "03" "03" "012" "03" "022" "013" "0112"
#> 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003 01007 02020
#> "0112" "0112" "03" "012" "0111" "021" "0111" "021" "0113" "0111" "013" "03" "03" "022"
#> 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "0112" "013" "012" "012" "03" "021" "0112" "0112" "03" "0112" "03" "012" "03" "012"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003
#> "0113" "03" "021" "012" "03" "012" "03" "013" "0112" "012" "013" "013" "03" "03"
#> 83001 LAL4
#> "022" "03"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 4791))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024 09008 09017
#> "013" "021" "013" "021" "011" "023" "021" "011" "022" "011" "013" "011" "013" "03" "023" "03"
#> 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009 19005 20002 22009 22010
#> "013" "03" "013" "022" "022" "022" "022" "022" "03" "022" "022" "021" "022" "023" "03" "03"
#> 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019 24022 25003 25006 26001 26003 26005
#> "013" "03" "011" "011" "012" "012" "022" "021" "03" "021" "011" "03" "021" "022" "011" "022"
#> 26008 27003 27004 28001 28003 28005 28006 28007 28019 28021 28023 28024 28028 28031 28032 28035
#> "021" "03" "011" "03" "03" "011" "012" "011" "021" "023" "011" "011" "011" "03" "011" "023"
#> 28036 28037 28042 28043 28044 28047 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007
#> "011" "023" "03" "011" "022" "012" "021" "03" "011" "023" "022" "011" "022" "03" "03" "012"
#> 43012 48001 49006 57001 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003
#> "03" "022" "013" "011" "011" "011" "03" "012" "011" "021" "011" "021" "011" "011" "013" "03"
#> 01007 02020 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "03" "022" "011" "013" "012" "012" "03" "021" "011" "011" "03" "011" "03" "012" "03" "012"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003 83001 LAL4
#> "011" "03" "021" "012" "03" "012" "03" "013" "011" "012" "013" "013" "03" "03" "022" "03"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 5639))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024 09008 09017
#> "01" "021" "01" "021" "01" "023" "021" "01" "022" "01" "01" "01" "01" "03" "023" "03"
#> 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009 19005 20002 22009 22010
#> "01" "03" "01" "022" "022" "022" "022" "022" "03" "022" "022" "021" "022" "023" "03" "03"
#> 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019 24022 25003 25006 26001 26003 26005
#> "01" "03" "01" "01" "01" "01" "022" "021" "03" "021" "01" "03" "021" "022" "01" "022"
#> 26008 27003 27004 28001 28003 28005 28006 28007 28019 28021 28023 28024 28028 28031 28032 28035
#> "021" "03" "01" "03" "03" "01" "01" "01" "021" "023" "01" "01" "01" "03" "01" "023"
#> 28036 28037 28042 28043 28044 28047 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007
#> "01" "023" "03" "01" "022" "01" "021" "03" "01" "023" "022" "01" "022" "03" "03" "01"
#> 43012 48001 49006 57001 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003
#> "03" "022" "01" "01" "01" "01" "03" "01" "01" "021" "01" "021" "01" "01" "01" "03"
#> 01007 02020 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "03" "022" "01" "01" "01" "01" "03" "021" "01" "01" "03" "01" "03" "01" "03" "01"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003 83001 LAL4
#> "01" "03" "021" "01" "03" "01" "03" "01" "01" "01" "01" "01" "03" "03" "022" "03"
get_classes(res_rh, merge_node = merge_node_param(min_n_signatures = 8975))
#> 01005 01010 03002 04006 04007 04008 04010 04016 06002 08001 08011 08012 08018 08024 09008 09017
#> "01" "02" "01" "02" "01" "02" "02" "01" "02" "01" "01" "01" "01" "03" "02" "03"
#> 11005 12006 12007 12012 12019 12026 14016 15001 15004 15005 16004 16009 19005 20002 22009 22010
#> "01" "03" "01" "02" "02" "02" "02" "02" "03" "02" "02" "02" "02" "02" "03" "03"
#> 22011 22013 24001 24005 24008 24010 24011 24017 24018 24019 24022 25003 25006 26001 26003 26005
#> "01" "03" "01" "01" "01" "01" "02" "02" "03" "02" "01" "03" "02" "02" "01" "02"
#> 26008 27003 27004 28001 28003 28005 28006 28007 28019 28021 28023 28024 28028 28031 28032 28035
#> "02" "03" "01" "03" "03" "01" "01" "01" "02" "02" "01" "01" "01" "03" "01" "02"
#> 28036 28037 28042 28043 28044 28047 30001 31007 31011 33005 36001 36002 37013 43001 43004 43007
#> "01" "02" "03" "01" "02" "01" "02" "03" "01" "02" "02" "01" "02" "03" "03" "01"
#> 43012 48001 49006 57001 62001 62002 62003 63001 64001 64002 65005 68001 68003 84004 LAL5 01003
#> "03" "02" "01" "01" "01" "01" "03" "01" "01" "02" "01" "02" "01" "01" "01" "03"
#> 01007 02020 04018 09002 10005 11002 12008 15006 16002 16007 17003 18001 19002 19008 19014 19017
#> "03" "02" "01" "01" "01" "01" "03" "02" "01" "01" "03" "01" "03" "01" "03" "01"
#> 20005 24006 26009 28008 28009 31015 37001 43006 43015 44001 49004 56007 64005 65003 83001 LAL4
#> "01" "03" "02" "01" "03" "01" "03" "01" "01" "01" "01" "01" "03" "03" "02" "03"
Heatmaps of the top rows:
top_rows_heatmap(res_rh)
Top rows on each node:
top_rows_overlap(res_rh, method = "upset")
UMAP plot which shows how samples are separated.
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 561),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 561),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1224),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1224),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1726),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1726),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1901),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 1901),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 4791),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 4791),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 5639),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 5639),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
par(mfrow = c(1, 2))
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 8975),
method = "UMAP", top_value_method = "SD", top_n = 1200, scale_rows = FALSE)
dimension_reduction(res_rh, merge_node = merge_node_param(min_n_signatures = 8975),
method = "UMAP", top_value_method = "ATC", top_n = 1200, scale_rows = TRUE)
Signatures on the heatmap are the union of all signatures found on every node on the hierarchy. The number of k-means on rows are automatically selected by the function.
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 561))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 1224))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 1726))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 1901))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 4791))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 5639))
get_signatures(res_rh, merge_node = merge_node_param(min_n_signatures = 8975))
Compare signatures from different nodes:
compare_signatures(res_rh, verbose = FALSE)
If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs. Note it only works on every node and the final signatures
are the union of all signatures of all nodes.
# code only for demonstration
# e.g. to show the top 500 most significant rows on each node.
tb = get_signature(res_rh, top_signatures = 500)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 561))
#> sex age BT
#> class 0.969 0.0863 0.029
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 1224))
#> sex age BT
#> class 0.954 0.0767 0.0146
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 1726))
#> sex age BT
#> class 0.921 0.0199 0.00374
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 1901))
#> sex age BT
#> class 0.932 0.179 0.0552
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 4791))
#> sex age BT
#> class 0.947 0.0997 0.203
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 5639))
#> sex age BT
#> class 0.972 0.0819 0.195
test_to_known_factors(res_rh, merge_node = merge_node_param(min_n_signatures = 8975))
#> sex age BT
#> class 0.867 0.012 0.0532
Child nodes: Node01 , Node02 , Node03 .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["0"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 128 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.00 0.972 0.989 0.5031 0.497 0.497
#> 3 3 1.00 0.955 0.983 0.2836 0.800 0.619
#> 4 4 0.81 0.693 0.862 0.0809 0.954 0.869
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 01005 1 0.000 0.990 1.00 0.00
#> 01010 2 0.000 0.987 0.00 1.00
#> 03002 1 0.000 0.990 1.00 0.00
#> 04006 2 0.000 0.987 0.00 1.00
#> 04007 1 0.000 0.990 1.00 0.00
#> 04008 2 0.000 0.987 0.00 1.00
#> 04010 2 0.000 0.987 0.00 1.00
#> 04016 1 0.000 0.990 1.00 0.00
#> 06002 2 0.000 0.987 0.00 1.00
#> 08001 1 0.000 0.990 1.00 0.00
#> 08011 1 0.000 0.990 1.00 0.00
#> 08012 1 0.000 0.990 1.00 0.00
#> 08018 1 0.000 0.990 1.00 0.00
#> 08024 2 0.000 0.987 0.00 1.00
#> 09008 2 0.000 0.987 0.00 1.00
#> 09017 1 0.000 0.990 1.00 0.00
#> 11005 1 0.000 0.990 1.00 0.00
#> 12006 2 0.000 0.987 0.00 1.00
#> 12007 1 0.000 0.990 1.00 0.00
#> 12012 2 0.000 0.987 0.00 1.00
#> 12019 2 0.000 0.987 0.00 1.00
#> 12026 2 0.000 0.987 0.00 1.00
#> 14016 2 0.000 0.987 0.00 1.00
#> 15001 2 0.000 0.987 0.00 1.00
#> 15004 2 0.990 0.209 0.44 0.56
#> 15005 2 0.000 0.987 0.00 1.00
#> 16004 2 0.000 0.987 0.00 1.00
#> 16009 2 0.000 0.987 0.00 1.00
#> 19005 2 0.000 0.987 0.00 1.00
#> 20002 2 0.000 0.987 0.00 1.00
#> 22009 2 0.000 0.987 0.00 1.00
#> 22010 2 0.000 0.987 0.00 1.00
#> 22011 1 0.000 0.990 1.00 0.00
#> 22013 2 0.000 0.987 0.00 1.00
#> 24001 1 0.000 0.990 1.00 0.00
#> 24005 1 0.000 0.990 1.00 0.00
#> 24008 1 0.000 0.990 1.00 0.00
#> 24010 1 0.000 0.990 1.00 0.00
#> 24011 2 0.000 0.987 0.00 1.00
#> 24017 2 0.000 0.987 0.00 1.00
#> 24018 2 0.000 0.987 0.00 1.00
#> 24019 2 0.000 0.987 0.00 1.00
#> 24022 1 0.000 0.990 1.00 0.00
#> 25003 2 0.000 0.987 0.00 1.00
#> 25006 2 0.000 0.987 0.00 1.00
#> 26001 2 0.000 0.987 0.00 1.00
#> 26003 1 0.000 0.990 1.00 0.00
#> 26005 2 0.000 0.987 0.00 1.00
#> 26008 2 0.000 0.987 0.00 1.00
#> 27003 2 0.000 0.987 0.00 1.00
#> 27004 1 0.000 0.990 1.00 0.00
#> 28001 2 0.000 0.987 0.00 1.00
#> 28003 2 0.000 0.987 0.00 1.00
#> 28005 1 0.000 0.990 1.00 0.00
#> 28006 1 0.000 0.990 1.00 0.00
#> 28007 1 0.000 0.990 1.00 0.00
#> 28019 2 0.000 0.987 0.00 1.00
#> 28021 2 0.000 0.987 0.00 1.00
#> 28023 1 0.000 0.990 1.00 0.00
#> 28024 1 0.000 0.990 1.00 0.00
#> 28028 1 0.000 0.990 1.00 0.00
#> 28031 1 0.529 0.859 0.88 0.12
#> 28032 1 0.000 0.990 1.00 0.00
#> 28035 2 0.000 0.987 0.00 1.00
#> 28036 1 0.000 0.990 1.00 0.00
#> 28037 2 0.000 0.987 0.00 1.00
#> 28042 1 0.000 0.990 1.00 0.00
#> 28043 1 0.000 0.990 1.00 0.00
#> 28044 1 0.981 0.266 0.58 0.42
#> 28047 1 0.000 0.990 1.00 0.00
#> 30001 2 0.000 0.987 0.00 1.00
#> 31007 1 0.000 0.990 1.00 0.00
#> 31011 1 0.000 0.990 1.00 0.00
#> 33005 2 0.000 0.987 0.00 1.00
#> 36001 2 0.000 0.987 0.00 1.00
#> 36002 1 0.000 0.990 1.00 0.00
#> 37013 2 0.000 0.987 0.00 1.00
#> 43001 2 0.000 0.987 0.00 1.00
#> 43004 2 0.000 0.987 0.00 1.00
#> 43007 1 0.000 0.990 1.00 0.00
#> 43012 1 0.000 0.990 1.00 0.00
#> 48001 2 0.000 0.987 0.00 1.00
#> 49006 1 0.000 0.990 1.00 0.00
#> 57001 1 0.000 0.990 1.00 0.00
#> 62001 1 0.000 0.990 1.00 0.00
#> 62002 1 0.000 0.990 1.00 0.00
#> 62003 2 0.000 0.987 0.00 1.00
#> 63001 1 0.000 0.990 1.00 0.00
#> 64001 1 0.000 0.990 1.00 0.00
#> 64002 2 0.000 0.987 0.00 1.00
#> 65005 1 0.000 0.990 1.00 0.00
#> 68001 2 0.000 0.987 0.00 1.00
#> 68003 1 0.000 0.990 1.00 0.00
#> 84004 1 0.000 0.990 1.00 0.00
#> LAL5 1 0.000 0.990 1.00 0.00
#> 01003 1 0.000 0.990 1.00 0.00
#> 01007 2 0.000 0.987 0.00 1.00
#> 02020 2 0.000 0.987 0.00 1.00
#> 04018 1 0.000 0.990 1.00 0.00
#> 09002 1 0.000 0.990 1.00 0.00
#> 10005 1 0.000 0.990 1.00 0.00
#> 11002 1 0.000 0.990 1.00 0.00
#> 12008 2 0.000 0.987 0.00 1.00
#> 15006 2 0.000 0.987 0.00 1.00
#> 16002 1 0.000 0.990 1.00 0.00
#> 16007 1 0.000 0.990 1.00 0.00
#> 17003 2 0.000 0.987 0.00 1.00
#> 18001 1 0.000 0.990 1.00 0.00
#> 19002 2 0.000 0.987 0.00 1.00
#> 19008 1 0.000 0.990 1.00 0.00
#> 19014 1 0.242 0.951 0.96 0.04
#> 19017 1 0.000 0.990 1.00 0.00
#> 20005 1 0.000 0.990 1.00 0.00
#> 24006 2 0.000 0.987 0.00 1.00
#> 26009 2 0.000 0.987 0.00 1.00
#> 28008 1 0.000 0.990 1.00 0.00
#> 28009 2 0.000 0.987 0.00 1.00
#> 31015 1 0.000 0.990 1.00 0.00
#> 37001 2 0.000 0.987 0.00 1.00
#> 43006 1 0.000 0.990 1.00 0.00
#> 43015 1 0.000 0.990 1.00 0.00
#> 44001 1 0.000 0.990 1.00 0.00
#> 49004 1 0.000 0.990 1.00 0.00
#> 56007 1 0.000 0.990 1.00 0.00
#> 64005 2 0.000 0.987 0.00 1.00
#> 65003 2 0.881 0.567 0.30 0.70
#> 83001 2 0.000 0.987 0.00 1.00
#> LAL4 1 0.327 0.931 0.94 0.06
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 01005 1 0.0000 1.0000 1.00 0.00 0.00
#> 01010 2 0.0000 0.9801 0.00 1.00 0.00
#> 03002 1 0.0000 1.0000 1.00 0.00 0.00
#> 04006 2 0.0000 0.9801 0.00 1.00 0.00
#> 04007 1 0.0000 1.0000 1.00 0.00 0.00
#> 04008 2 0.0000 0.9801 0.00 1.00 0.00
#> 04010 2 0.0000 0.9801 0.00 1.00 0.00
#> 04016 1 0.0000 1.0000 1.00 0.00 0.00
#> 06002 2 0.0000 0.9801 0.00 1.00 0.00
#> 08001 1 0.0000 1.0000 1.00 0.00 0.00
#> 08011 1 0.0000 1.0000 1.00 0.00 0.00
#> 08012 1 0.0000 1.0000 1.00 0.00 0.00
#> 08018 1 0.0000 1.0000 1.00 0.00 0.00
#> 08024 3 0.6302 0.0748 0.00 0.48 0.52
#> 09008 2 0.0000 0.9801 0.00 1.00 0.00
#> 09017 3 0.6280 0.1358 0.46 0.00 0.54
#> 11005 1 0.0000 1.0000 1.00 0.00 0.00
#> 12006 3 0.0000 0.9480 0.00 0.00 1.00
#> 12007 1 0.0000 1.0000 1.00 0.00 0.00
#> 12012 2 0.0000 0.9801 0.00 1.00 0.00
#> 12019 2 0.6045 0.3566 0.00 0.62 0.38
#> 12026 2 0.0000 0.9801 0.00 1.00 0.00
#> 14016 2 0.0000 0.9801 0.00 1.00 0.00
#> 15001 2 0.0000 0.9801 0.00 1.00 0.00
#> 15004 3 0.0000 0.9480 0.00 0.00 1.00
#> 15005 2 0.0000 0.9801 0.00 1.00 0.00
#> 16004 2 0.0000 0.9801 0.00 1.00 0.00
#> 16009 2 0.0000 0.9801 0.00 1.00 0.00
#> 19005 2 0.0000 0.9801 0.00 1.00 0.00
#> 20002 2 0.0000 0.9801 0.00 1.00 0.00
#> 22009 3 0.0000 0.9480 0.00 0.00 1.00
#> 22010 3 0.0000 0.9480 0.00 0.00 1.00
#> 22011 1 0.0000 1.0000 1.00 0.00 0.00
#> 22013 3 0.0892 0.9327 0.00 0.02 0.98
#> 24001 1 0.0000 1.0000 1.00 0.00 0.00
#> 24005 1 0.0000 1.0000 1.00 0.00 0.00
#> 24008 1 0.0000 1.0000 1.00 0.00 0.00
#> 24010 1 0.0000 1.0000 1.00 0.00 0.00
#> 24011 2 0.3340 0.8483 0.00 0.88 0.12
#> 24017 2 0.0000 0.9801 0.00 1.00 0.00
#> 24018 3 0.0000 0.9480 0.00 0.00 1.00
#> 24019 2 0.0000 0.9801 0.00 1.00 0.00
#> 24022 1 0.0000 1.0000 1.00 0.00 0.00
#> 25003 3 0.0000 0.9480 0.00 0.00 1.00
#> 25006 2 0.0000 0.9801 0.00 1.00 0.00
#> 26001 2 0.0000 0.9801 0.00 1.00 0.00
#> 26003 1 0.0000 1.0000 1.00 0.00 0.00
#> 26005 2 0.0000 0.9801 0.00 1.00 0.00
#> 26008 2 0.0000 0.9801 0.00 1.00 0.00
#> 27003 3 0.0000 0.9480 0.00 0.00 1.00
#> 27004 1 0.0000 1.0000 1.00 0.00 0.00
#> 28001 3 0.0000 0.9480 0.00 0.00 1.00
#> 28003 3 0.0000 0.9480 0.00 0.00 1.00
#> 28005 1 0.0000 1.0000 1.00 0.00 0.00
#> 28006 1 0.0000 1.0000 1.00 0.00 0.00
#> 28007 1 0.0000 1.0000 1.00 0.00 0.00
#> 28019 2 0.0000 0.9801 0.00 1.00 0.00
#> 28021 2 0.0000 0.9801 0.00 1.00 0.00
#> 28023 1 0.0000 1.0000 1.00 0.00 0.00
#> 28024 1 0.0000 1.0000 1.00 0.00 0.00
#> 28028 1 0.0000 1.0000 1.00 0.00 0.00
#> 28031 3 0.0000 0.9480 0.00 0.00 1.00
#> 28032 1 0.0000 1.0000 1.00 0.00 0.00
#> 28035 2 0.0000 0.9801 0.00 1.00 0.00
#> 28036 1 0.0000 1.0000 1.00 0.00 0.00
#> 28037 2 0.0000 0.9801 0.00 1.00 0.00
#> 28042 3 0.0000 0.9480 0.00 0.00 1.00
#> 28043 1 0.0000 1.0000 1.00 0.00 0.00
#> 28044 2 0.4291 0.7478 0.18 0.82 0.00
#> 28047 1 0.0000 1.0000 1.00 0.00 0.00
#> 30001 2 0.0000 0.9801 0.00 1.00 0.00
#> 31007 3 0.0000 0.9480 0.00 0.00 1.00
#> 31011 1 0.0000 1.0000 1.00 0.00 0.00
#> 33005 2 0.0000 0.9801 0.00 1.00 0.00
#> 36001 2 0.0000 0.9801 0.00 1.00 0.00
#> 36002 1 0.0000 1.0000 1.00 0.00 0.00
#> 37013 2 0.0000 0.9801 0.00 1.00 0.00
#> 43001 3 0.6126 0.3258 0.00 0.40 0.60
#> 43004 3 0.0000 0.9480 0.00 0.00 1.00
#> 43007 1 0.0000 1.0000 1.00 0.00 0.00
#> 43012 3 0.0000 0.9480 0.00 0.00 1.00
#> 48001 2 0.0000 0.9801 0.00 1.00 0.00
#> 49006 1 0.0000 1.0000 1.00 0.00 0.00
#> 57001 1 0.0000 1.0000 1.00 0.00 0.00
#> 62001 1 0.0000 1.0000 1.00 0.00 0.00
#> 62002 1 0.0000 1.0000 1.00 0.00 0.00
#> 62003 3 0.0892 0.9327 0.00 0.02 0.98
#> 63001 1 0.0000 1.0000 1.00 0.00 0.00
#> 64001 1 0.0000 1.0000 1.00 0.00 0.00
#> 64002 2 0.0000 0.9801 0.00 1.00 0.00
#> 65005 1 0.0000 1.0000 1.00 0.00 0.00
#> 68001 2 0.0000 0.9801 0.00 1.00 0.00
#> 68003 1 0.0000 1.0000 1.00 0.00 0.00
#> 84004 1 0.0000 1.0000 1.00 0.00 0.00
#> LAL5 1 0.0000 1.0000 1.00 0.00 0.00
#> 01003 3 0.0000 0.9480 0.00 0.00 1.00
#> 01007 3 0.2066 0.8949 0.00 0.06 0.94
#> 02020 2 0.0000 0.9801 0.00 1.00 0.00
#> 04018 1 0.0000 1.0000 1.00 0.00 0.00
#> 09002 1 0.0000 1.0000 1.00 0.00 0.00
#> 10005 1 0.0000 1.0000 1.00 0.00 0.00
#> 11002 1 0.0000 1.0000 1.00 0.00 0.00
#> 12008 3 0.0000 0.9480 0.00 0.00 1.00
#> 15006 2 0.0000 0.9801 0.00 1.00 0.00
#> 16002 1 0.0000 1.0000 1.00 0.00 0.00
#> 16007 1 0.0000 1.0000 1.00 0.00 0.00
#> 17003 3 0.0000 0.9480 0.00 0.00 1.00
#> 18001 1 0.0000 1.0000 1.00 0.00 0.00
#> 19002 3 0.0000 0.9480 0.00 0.00 1.00
#> 19008 1 0.0000 1.0000 1.00 0.00 0.00
#> 19014 3 0.0000 0.9480 0.00 0.00 1.00
#> 19017 1 0.0000 1.0000 1.00 0.00 0.00
#> 20005 1 0.0000 1.0000 1.00 0.00 0.00
#> 24006 3 0.0000 0.9480 0.00 0.00 1.00
#> 26009 2 0.0000 0.9801 0.00 1.00 0.00
#> 28008 1 0.0000 1.0000 1.00 0.00 0.00
#> 28009 3 0.0000 0.9480 0.00 0.00 1.00
#> 31015 1 0.0000 1.0000 1.00 0.00 0.00
#> 37001 3 0.0000 0.9480 0.00 0.00 1.00
#> 43006 1 0.0000 1.0000 1.00 0.00 0.00
#> 43015 1 0.0000 1.0000 1.00 0.00 0.00
#> 44001 1 0.0000 1.0000 1.00 0.00 0.00
#> 49004 1 0.0000 1.0000 1.00 0.00 0.00
#> 56007 1 0.0000 1.0000 1.00 0.00 0.00
#> 64005 3 0.0000 0.9480 0.00 0.00 1.00
#> 65003 3 0.0000 0.9480 0.00 0.00 1.00
#> 83001 2 0.0000 0.9801 0.00 1.00 0.00
#> LAL4 3 0.0000 0.9480 0.00 0.00 1.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 01005 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 01010 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 03002 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 04006 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 04007 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 04008 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 04010 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 04016 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 06002 2 0.3172 0.7777 0.00 0.84 0.16 0.00
#> 08001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 08011 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 08012 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 08018 1 0.3975 0.6518 0.76 0.00 0.00 0.24
#> 08024 3 0.7493 0.2559 0.00 0.20 0.48 0.32
#> 09008 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 09017 4 0.6201 0.1238 0.08 0.00 0.30 0.62
#> 11005 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 12006 3 0.4624 0.2130 0.00 0.00 0.66 0.34
#> 12007 1 0.2011 0.9109 0.92 0.00 0.00 0.08
#> 12012 2 0.7198 0.3649 0.00 0.54 0.18 0.28
#> 12019 2 0.6299 0.2115 0.00 0.52 0.42 0.06
#> 12026 2 0.3610 0.7459 0.00 0.80 0.20 0.00
#> 14016 2 0.3610 0.7459 0.00 0.80 0.20 0.00
#> 15001 2 0.6320 0.5793 0.00 0.66 0.16 0.18
#> 15004 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 15005 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 16004 2 0.3610 0.7459 0.00 0.80 0.20 0.00
#> 16009 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 19005 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 20002 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 22009 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 22010 3 0.3801 0.4042 0.00 0.00 0.78 0.22
#> 22011 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 22013 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 24001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 24005 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 24008 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 24010 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 24011 2 0.7913 -0.1509 0.00 0.36 0.32 0.32
#> 24017 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 24018 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 24019 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 24022 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 25003 3 0.1637 0.5206 0.00 0.00 0.94 0.06
#> 25006 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 26001 2 0.3801 0.7266 0.00 0.78 0.22 0.00
#> 26003 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 26005 2 0.3400 0.7619 0.00 0.82 0.18 0.00
#> 26008 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 27003 3 0.5000 -0.1682 0.00 0.00 0.50 0.50
#> 27004 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28001 3 0.4790 0.1527 0.00 0.00 0.62 0.38
#> 28003 3 0.3172 0.4294 0.00 0.00 0.84 0.16
#> 28005 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28006 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28007 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28019 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 28021 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 28023 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28024 1 0.1211 0.9339 0.96 0.00 0.00 0.04
#> 28028 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 28031 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 28032 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 28035 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 28036 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 28037 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 28042 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 28043 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 28044 4 0.8103 0.0597 0.02 0.24 0.26 0.48
#> 28047 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 30001 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 31007 4 0.5000 0.0494 0.00 0.00 0.50 0.50
#> 31011 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 33005 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 36001 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 36002 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 37013 2 0.1211 0.8544 0.00 0.96 0.04 0.00
#> 43001 3 0.6941 0.2769 0.00 0.36 0.52 0.12
#> 43004 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 43007 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 43012 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 48001 2 0.2011 0.8334 0.00 0.92 0.08 0.00
#> 49006 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 57001 1 0.4994 0.2913 0.52 0.00 0.00 0.48
#> 62001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 62002 1 0.4994 0.2913 0.52 0.00 0.00 0.48
#> 62003 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 63001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 64001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 64002 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 65005 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 68001 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 68003 1 0.6011 0.1850 0.48 0.00 0.04 0.48
#> 84004 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> LAL5 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 01003 4 0.4522 0.0608 0.00 0.00 0.32 0.68
#> 01007 3 0.6766 0.2222 0.00 0.10 0.52 0.38
#> 02020 2 0.4994 0.2651 0.00 0.52 0.48 0.00
#> 04018 4 0.7382 0.1538 0.22 0.00 0.26 0.52
#> 09002 1 0.2011 0.9123 0.92 0.00 0.00 0.08
#> 10005 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 11002 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 12008 3 0.0707 0.5268 0.00 0.00 0.98 0.02
#> 15006 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 16002 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 16007 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 17003 3 0.4790 0.1505 0.00 0.00 0.62 0.38
#> 18001 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 19002 3 0.4790 0.2309 0.00 0.00 0.62 0.38
#> 19008 1 0.2011 0.9123 0.92 0.00 0.00 0.08
#> 19014 3 0.4522 0.2969 0.00 0.00 0.68 0.32
#> 19017 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 20005 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 24006 3 0.0000 0.5319 0.00 0.00 1.00 0.00
#> 26009 2 0.0000 0.8809 0.00 1.00 0.00 0.00
#> 28008 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 28009 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 31015 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 37001 3 0.3172 0.4294 0.00 0.00 0.84 0.16
#> 43006 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 43015 1 0.1637 0.9246 0.94 0.00 0.00 0.06
#> 44001 1 0.0707 0.9364 0.98 0.00 0.00 0.02
#> 49004 1 0.0000 0.9503 1.00 0.00 0.00 0.00
#> 56007 4 0.6453 0.0921 0.36 0.00 0.08 0.56
#> 64005 3 0.2647 0.5548 0.00 0.12 0.88 0.00
#> 65003 4 0.4994 0.1052 0.00 0.00 0.48 0.52
#> 83001 2 0.4907 0.3649 0.00 0.58 0.00 0.42
#> LAL4 3 0.3801 0.3658 0.00 0.00 0.78 0.22
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 126 0.370 0.3787 0.58720 2
#> ATC:skmeans 124 0.820 0.0152 0.05971 3
#> ATC:skmeans 95 0.716 0.2768 0.00522 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node0. Child nodes: Node011 , Node012 , Node013-leaf , Node021-leaf , Node022 , Node023-leaf , Node031-leaf , Node032-leaf , Node033-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["01"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 58 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.984 0.994 0.453 0.552 0.552
#> 3 3 1.000 0.980 0.991 0.348 0.792 0.639
#> 4 4 0.798 0.839 0.935 0.222 0.809 0.543
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 01005 1 0.943 0.437 0.64 0.36
#> 03002 1 0.000 0.990 1.00 0.00
#> 04007 1 0.000 0.990 1.00 0.00
#> 04016 1 0.000 0.990 1.00 0.00
#> 08001 1 0.000 0.990 1.00 0.00
#> 08011 1 0.000 0.990 1.00 0.00
#> 08012 1 0.000 0.990 1.00 0.00
#> 08018 2 0.000 1.000 0.00 1.00
#> 11005 2 0.000 1.000 0.00 1.00
#> 12007 1 0.000 0.990 1.00 0.00
#> 22011 1 0.000 0.990 1.00 0.00
#> 24001 1 0.000 0.990 1.00 0.00
#> 24005 1 0.000 0.990 1.00 0.00
#> 24008 2 0.000 1.000 0.00 1.00
#> 24010 2 0.000 1.000 0.00 1.00
#> 24022 1 0.000 0.990 1.00 0.00
#> 26003 1 0.000 0.990 1.00 0.00
#> 27004 1 0.000 0.990 1.00 0.00
#> 28005 1 0.000 0.990 1.00 0.00
#> 28006 2 0.000 1.000 0.00 1.00
#> 28007 1 0.000 0.990 1.00 0.00
#> 28023 1 0.000 0.990 1.00 0.00
#> 28024 1 0.000 0.990 1.00 0.00
#> 28028 1 0.000 0.990 1.00 0.00
#> 28032 1 0.000 0.990 1.00 0.00
#> 28036 1 0.000 0.990 1.00 0.00
#> 28043 1 0.000 0.990 1.00 0.00
#> 28047 2 0.000 1.000 0.00 1.00
#> 31011 1 0.000 0.990 1.00 0.00
#> 36002 1 0.000 0.990 1.00 0.00
#> 43007 2 0.000 1.000 0.00 1.00
#> 49006 2 0.000 1.000 0.00 1.00
#> 57001 1 0.000 0.990 1.00 0.00
#> 62001 1 0.000 0.990 1.00 0.00
#> 62002 1 0.000 0.990 1.00 0.00
#> 63001 2 0.000 1.000 0.00 1.00
#> 64001 1 0.000 0.990 1.00 0.00
#> 65005 1 0.000 0.990 1.00 0.00
#> 68003 1 0.000 0.990 1.00 0.00
#> 84004 1 0.000 0.990 1.00 0.00
#> LAL5 1 0.000 0.990 1.00 0.00
#> 04018 1 0.000 0.990 1.00 0.00
#> 09002 2 0.000 1.000 0.00 1.00
#> 10005 2 0.000 1.000 0.00 1.00
#> 11002 2 0.000 1.000 0.00 1.00
#> 16002 1 0.000 0.990 1.00 0.00
#> 16007 1 0.000 0.990 1.00 0.00
#> 18001 1 0.000 0.990 1.00 0.00
#> 19008 2 0.000 1.000 0.00 1.00
#> 19017 2 0.000 1.000 0.00 1.00
#> 20005 1 0.000 0.990 1.00 0.00
#> 28008 2 0.000 1.000 0.00 1.00
#> 31015 2 0.000 1.000 0.00 1.00
#> 43006 2 0.000 1.000 0.00 1.00
#> 43015 1 0.000 0.990 1.00 0.00
#> 44001 2 0.000 1.000 0.00 1.00
#> 49004 2 0.000 1.000 0.00 1.00
#> 56007 1 0.000 0.990 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 01005 3 0.0000 0.994 0.00 0.00 1.00
#> 03002 3 0.0000 0.994 0.00 0.00 1.00
#> 04007 1 0.0000 0.985 1.00 0.00 0.00
#> 04016 1 0.0000 0.985 1.00 0.00 0.00
#> 08001 1 0.0000 0.985 1.00 0.00 0.00
#> 08011 3 0.0892 0.976 0.02 0.00 0.98
#> 08012 1 0.0000 0.985 1.00 0.00 0.00
#> 08018 3 0.0000 0.994 0.00 0.00 1.00
#> 11005 3 0.0000 0.994 0.00 0.00 1.00
#> 12007 3 0.0000 0.994 0.00 0.00 1.00
#> 22011 3 0.0892 0.976 0.02 0.00 0.98
#> 24001 1 0.0000 0.985 1.00 0.00 0.00
#> 24005 1 0.0000 0.985 1.00 0.00 0.00
#> 24008 2 0.0000 1.000 0.00 1.00 0.00
#> 24010 2 0.0000 1.000 0.00 1.00 0.00
#> 24022 1 0.0000 0.985 1.00 0.00 0.00
#> 26003 1 0.0892 0.972 0.98 0.00 0.02
#> 27004 1 0.0000 0.985 1.00 0.00 0.00
#> 28005 1 0.0000 0.985 1.00 0.00 0.00
#> 28006 2 0.0000 1.000 0.00 1.00 0.00
#> 28007 1 0.0000 0.985 1.00 0.00 0.00
#> 28023 1 0.0000 0.985 1.00 0.00 0.00
#> 28024 1 0.0000 0.985 1.00 0.00 0.00
#> 28028 1 0.0000 0.985 1.00 0.00 0.00
#> 28032 1 0.0892 0.972 0.98 0.00 0.02
#> 28036 1 0.0892 0.972 0.98 0.00 0.02
#> 28043 1 0.0000 0.985 1.00 0.00 0.00
#> 28047 2 0.0000 1.000 0.00 1.00 0.00
#> 31011 1 0.0000 0.985 1.00 0.00 0.00
#> 36002 1 0.0000 0.985 1.00 0.00 0.00
#> 43007 2 0.0000 1.000 0.00 1.00 0.00
#> 49006 3 0.0892 0.977 0.00 0.02 0.98
#> 57001 1 0.0000 0.985 1.00 0.00 0.00
#> 62001 1 0.0000 0.985 1.00 0.00 0.00
#> 62002 1 0.0000 0.985 1.00 0.00 0.00
#> 63001 2 0.0000 1.000 0.00 1.00 0.00
#> 64001 1 0.0000 0.985 1.00 0.00 0.00
#> 65005 1 0.0000 0.985 1.00 0.00 0.00
#> 68003 1 0.0000 0.985 1.00 0.00 0.00
#> 84004 1 0.0000 0.985 1.00 0.00 0.00
#> LAL5 3 0.0000 0.994 0.00 0.00 1.00
#> 04018 1 0.0892 0.972 0.98 0.00 0.02
#> 09002 3 0.0000 0.994 0.00 0.00 1.00
#> 10005 2 0.0000 1.000 0.00 1.00 0.00
#> 11002 2 0.0000 1.000 0.00 1.00 0.00
#> 16002 1 0.0000 0.985 1.00 0.00 0.00
#> 16007 1 0.0000 0.985 1.00 0.00 0.00
#> 18001 1 0.0000 0.985 1.00 0.00 0.00
#> 19008 2 0.0000 1.000 0.00 1.00 0.00
#> 19017 2 0.0000 1.000 0.00 1.00 0.00
#> 20005 1 0.1529 0.954 0.96 0.00 0.04
#> 28008 2 0.0000 1.000 0.00 1.00 0.00
#> 31015 2 0.0000 1.000 0.00 1.00 0.00
#> 43006 3 0.0000 0.994 0.00 0.00 1.00
#> 43015 1 0.5835 0.498 0.66 0.00 0.34
#> 44001 2 0.0000 1.000 0.00 1.00 0.00
#> 49004 3 0.0000 0.994 0.00 0.00 1.00
#> 56007 3 0.0000 0.994 0.00 0.00 1.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 01005 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 03002 3 0.3610 0.7590 0.00 0.0 0.80 0.20
#> 04007 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 04016 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 08001 4 0.2921 0.8098 0.14 0.0 0.00 0.86
#> 08011 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 08012 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 08018 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 11005 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 12007 3 0.2647 0.8633 0.00 0.0 0.88 0.12
#> 22011 3 0.2647 0.8496 0.12 0.0 0.88 0.00
#> 24001 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 24005 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 24008 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 24010 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 24022 4 0.2921 0.8098 0.14 0.0 0.00 0.86
#> 26003 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 27004 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 28005 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 28006 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 28007 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 28023 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 28024 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 28028 4 0.2345 0.8418 0.10 0.0 0.00 0.90
#> 28032 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 28036 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 28043 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 28047 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 31011 1 0.4977 0.1824 0.54 0.0 0.00 0.46
#> 36002 1 0.4406 0.5603 0.70 0.0 0.00 0.30
#> 43007 2 0.3610 0.7555 0.00 0.8 0.20 0.00
#> 49006 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 57001 1 0.4994 0.0627 0.52 0.0 0.00 0.48
#> 62001 4 0.3801 0.6770 0.22 0.0 0.00 0.78
#> 62002 4 0.4994 -0.0137 0.48 0.0 0.00 0.52
#> 63001 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 64001 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 65005 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> 68003 4 0.0707 0.8867 0.02 0.0 0.00 0.98
#> 84004 1 0.0000 0.8885 1.00 0.0 0.00 0.00
#> LAL5 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 04018 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 09002 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 10005 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 11002 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 16002 1 0.4855 0.3615 0.60 0.0 0.00 0.40
#> 16007 1 0.0707 0.8760 0.98 0.0 0.02 0.00
#> 18001 1 0.2647 0.7894 0.88 0.0 0.00 0.12
#> 19008 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 19017 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 20005 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 28008 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 31015 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 43006 4 0.4134 0.5892 0.00 0.0 0.26 0.74
#> 43015 4 0.0000 0.8935 0.00 0.0 0.00 1.00
#> 44001 2 0.0000 0.9833 0.00 1.0 0.00 0.00
#> 49004 3 0.0000 0.9475 0.00 0.0 1.00 0.00
#> 56007 4 0.0000 0.8935 0.00 0.0 0.00 1.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 57 0.714 0.0649 0.215 2
#> ATC:skmeans 57 0.501 0.3076 0.227 3
#> ATC:skmeans 54 0.848 0.3282 0.370 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node01. Child nodes: Node0111-leaf , Node0112-leaf , Node0113-leaf , Node0114-leaf , Node0121-leaf , Node0122-leaf , Node0123-leaf , Node0221-leaf , Node0222-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["011"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 32 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.973 0.989 0.511 0.492 0.492
#> 3 3 1.000 0.985 0.983 0.314 0.837 0.668
#> 4 4 0.998 0.975 0.984 0.145 0.883 0.655
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 04007 1 0.000 1.000 1.00 0.00
#> 04016 1 0.000 1.000 1.00 0.00
#> 08001 1 0.000 1.000 1.00 0.00
#> 08012 1 0.000 1.000 1.00 0.00
#> 24001 1 0.000 1.000 1.00 0.00
#> 24005 1 0.000 1.000 1.00 0.00
#> 24022 2 0.000 0.980 0.00 1.00
#> 26003 2 0.000 0.980 0.00 1.00
#> 27004 2 0.925 0.485 0.34 0.66
#> 28005 1 0.000 1.000 1.00 0.00
#> 28007 1 0.000 1.000 1.00 0.00
#> 28023 1 0.000 1.000 1.00 0.00
#> 28024 1 0.000 1.000 1.00 0.00
#> 28028 2 0.000 0.980 0.00 1.00
#> 28032 2 0.000 0.980 0.00 1.00
#> 28036 2 0.000 0.980 0.00 1.00
#> 28043 2 0.000 0.980 0.00 1.00
#> 31011 2 0.000 0.980 0.00 1.00
#> 36002 1 0.000 1.000 1.00 0.00
#> 57001 2 0.000 0.980 0.00 1.00
#> 62001 2 0.000 0.980 0.00 1.00
#> 62002 2 0.000 0.980 0.00 1.00
#> 64001 1 0.000 1.000 1.00 0.00
#> 65005 1 0.000 1.000 1.00 0.00
#> 68003 2 0.000 0.980 0.00 1.00
#> 84004 1 0.000 1.000 1.00 0.00
#> 04018 2 0.000 0.980 0.00 1.00
#> 16002 2 0.000 0.980 0.00 1.00
#> 16007 2 0.000 0.980 0.00 1.00
#> 18001 2 0.000 0.980 0.00 1.00
#> 20005 2 0.000 0.980 0.00 1.00
#> 43015 2 0.000 0.980 0.00 1.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 04007 1 0.0000 0.987 1.00 0.00 0.00
#> 04016 1 0.0000 0.987 1.00 0.00 0.00
#> 08001 1 0.1529 0.976 0.96 0.00 0.04
#> 08012 1 0.0000 0.987 1.00 0.00 0.00
#> 24001 1 0.0000 0.987 1.00 0.00 0.00
#> 24005 1 0.0000 0.987 1.00 0.00 0.00
#> 24022 3 0.0892 0.978 0.00 0.02 0.98
#> 26003 3 0.1529 0.988 0.00 0.04 0.96
#> 27004 3 0.0892 0.954 0.00 0.02 0.98
#> 28005 1 0.1529 0.976 0.96 0.00 0.04
#> 28007 1 0.1529 0.976 0.96 0.00 0.04
#> 28023 1 0.1529 0.976 0.96 0.00 0.04
#> 28024 1 0.1529 0.976 0.96 0.00 0.04
#> 28028 3 0.0892 0.978 0.00 0.02 0.98
#> 28032 3 0.1529 0.988 0.00 0.04 0.96
#> 28036 3 0.1529 0.988 0.00 0.04 0.96
#> 28043 3 0.1529 0.988 0.00 0.04 0.96
#> 31011 2 0.0000 0.994 0.00 1.00 0.00
#> 36002 1 0.0000 0.987 1.00 0.00 0.00
#> 57001 2 0.0000 0.994 0.00 1.00 0.00
#> 62001 2 0.0000 0.994 0.00 1.00 0.00
#> 62002 2 0.0892 0.977 0.00 0.98 0.02
#> 64001 1 0.0000 0.987 1.00 0.00 0.00
#> 65005 1 0.0000 0.987 1.00 0.00 0.00
#> 68003 3 0.1529 0.988 0.00 0.04 0.96
#> 84004 1 0.0000 0.987 1.00 0.00 0.00
#> 04018 2 0.0000 0.994 0.00 1.00 0.00
#> 16002 2 0.0000 0.994 0.00 1.00 0.00
#> 16007 2 0.0892 0.974 0.02 0.98 0.00
#> 18001 2 0.0000 0.994 0.00 1.00 0.00
#> 20005 3 0.1529 0.988 0.00 0.04 0.96
#> 43015 2 0.0000 0.994 0.00 1.00 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 04007 1 0.1211 0.956 0.96 0.00 0.00 0.04
#> 04016 1 0.0707 0.962 0.98 0.00 0.00 0.02
#> 08001 4 0.1637 0.929 0.06 0.00 0.00 0.94
#> 08012 1 0.0000 0.956 1.00 0.00 0.00 0.00
#> 24001 1 0.0000 0.956 1.00 0.00 0.00 0.00
#> 24005 1 0.2647 0.900 0.88 0.00 0.00 0.12
#> 24022 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 26003 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 27004 4 0.0707 0.965 0.00 0.00 0.02 0.98
#> 28005 4 0.0000 0.982 0.00 0.00 0.00 1.00
#> 28007 4 0.0000 0.982 0.00 0.00 0.00 1.00
#> 28023 4 0.0000 0.982 0.00 0.00 0.00 1.00
#> 28024 4 0.0000 0.982 0.00 0.00 0.00 1.00
#> 28028 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 28032 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 28036 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 28043 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 31011 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 36002 1 0.0707 0.950 0.98 0.00 0.00 0.02
#> 57001 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 62001 2 0.1411 0.963 0.02 0.96 0.00 0.02
#> 62002 2 0.0707 0.977 0.00 0.98 0.02 0.00
#> 64001 1 0.0707 0.962 0.98 0.00 0.00 0.02
#> 65005 1 0.0707 0.962 0.98 0.00 0.00 0.02
#> 68003 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 84004 1 0.2647 0.900 0.88 0.00 0.00 0.12
#> 04018 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 16002 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 16007 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 18001 2 0.0000 0.993 0.00 1.00 0.00 0.00
#> 20005 3 0.0000 1.000 0.00 0.00 1.00 0.00
#> 43015 2 0.0000 0.993 0.00 1.00 0.00 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 31 0.724 0.153 0.0412 2
#> ATC:skmeans 32 0.408 0.311 0.0268 3
#> ATC:skmeans 32 0.594 0.617 0.0521 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node01. Child nodes: Node0111-leaf , Node0112-leaf , Node0113-leaf , Node0114-leaf , Node0121-leaf , Node0122-leaf , Node0123-leaf , Node0221-leaf , Node0222-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["012"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 13 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.539 0.462 0.462
#> 3 3 1.000 0.997 0.998 0.189 0.897 0.778
#> 4 4 0.872 0.866 0.952 0.129 0.923 0.786
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 24008 1 0 1 1 0
#> 24010 1 0 1 1 0
#> 28006 1 0 1 1 0
#> 28047 2 0 1 0 1
#> 43007 2 0 1 0 1
#> 63001 1 0 1 1 0
#> 10005 1 0 1 1 0
#> 11002 1 0 1 1 0
#> 19008 2 0 1 0 1
#> 19017 2 0 1 0 1
#> 28008 1 0 1 1 0
#> 31015 2 0 1 0 1
#> 44001 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 24008 1 0.0000 1.00 1 0.00 0.00
#> 24010 1 0.0000 1.00 1 0.00 0.00
#> 28006 1 0.0000 1.00 1 0.00 0.00
#> 28047 2 0.0000 1.00 0 1.00 0.00
#> 43007 2 0.0000 1.00 0 1.00 0.00
#> 63001 1 0.0000 1.00 1 0.00 0.00
#> 10005 1 0.0000 1.00 1 0.00 0.00
#> 11002 1 0.0000 1.00 1 0.00 0.00
#> 19008 2 0.0000 1.00 0 1.00 0.00
#> 19017 2 0.0000 1.00 0 1.00 0.00
#> 28008 1 0.0000 1.00 1 0.00 0.00
#> 31015 3 0.0892 0.98 0 0.02 0.98
#> 44001 3 0.0000 0.98 0 0.00 1.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 24008 4 0.2647 0.000 0.12 0.00 0.00 0.88
#> 24010 1 0.2011 0.924 0.92 0.00 0.00 0.08
#> 28006 1 0.0000 0.921 1.00 0.00 0.00 0.00
#> 28047 2 0.2011 0.952 0.00 0.92 0.00 0.08
#> 43007 2 0.2011 0.952 0.00 0.92 0.00 0.08
#> 63001 1 0.2011 0.924 0.92 0.00 0.00 0.08
#> 10005 1 0.2011 0.924 0.92 0.00 0.00 0.08
#> 11002 1 0.1211 0.907 0.96 0.00 0.00 0.04
#> 19008 2 0.0000 0.952 0.00 1.00 0.00 0.00
#> 19017 2 0.0000 0.952 0.00 1.00 0.00 0.00
#> 28008 1 0.1211 0.907 0.96 0.00 0.00 0.04
#> 31015 3 0.0707 0.972 0.00 0.02 0.98 0.00
#> 44001 3 0.0000 0.972 0.00 0.00 1.00 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 13 1.000 0.483 0.406 2
#> ATC:skmeans 13 0.695 0.495 0.436 3
#> ATC:skmeans 12 0.741 0.539 0.555 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node0. Child nodes: Node011 , Node012 , Node013-leaf , Node021-leaf , Node022 , Node023-leaf , Node031-leaf , Node032-leaf , Node033-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["02"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 39 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.97 0.987 0.513 0.487 0.487
#> 3 3 1.000 1.00 1.000 0.254 0.843 0.687
#> 4 4 0.896 0.97 0.975 0.123 0.924 0.789
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 01010 1 0.000 1.000 1.00 0.00
#> 04006 1 0.000 1.000 1.00 0.00
#> 04008 2 0.795 0.697 0.24 0.76
#> 04010 1 0.000 1.000 1.00 0.00
#> 06002 2 0.000 0.972 0.00 1.00
#> 09008 1 0.000 1.000 1.00 0.00
#> 12012 2 0.000 0.972 0.00 1.00
#> 12019 2 0.000 0.972 0.00 1.00
#> 12026 2 0.000 0.972 0.00 1.00
#> 14016 2 0.000 0.972 0.00 1.00
#> 15001 2 0.000 0.972 0.00 1.00
#> 15005 2 0.000 0.972 0.00 1.00
#> 16004 2 0.000 0.972 0.00 1.00
#> 16009 1 0.000 1.000 1.00 0.00
#> 19005 2 0.000 0.972 0.00 1.00
#> 20002 2 0.855 0.631 0.28 0.72
#> 24011 2 0.000 0.972 0.00 1.00
#> 24017 1 0.000 1.000 1.00 0.00
#> 24019 1 0.000 1.000 1.00 0.00
#> 25006 1 0.000 1.000 1.00 0.00
#> 26001 2 0.000 0.972 0.00 1.00
#> 26005 2 0.000 0.972 0.00 1.00
#> 26008 1 0.000 1.000 1.00 0.00
#> 28019 1 0.000 1.000 1.00 0.00
#> 28021 1 0.000 1.000 1.00 0.00
#> 28035 1 0.000 1.000 1.00 0.00
#> 28037 1 0.000 1.000 1.00 0.00
#> 28044 2 0.000 0.972 0.00 1.00
#> 30001 1 0.000 1.000 1.00 0.00
#> 33005 1 0.000 1.000 1.00 0.00
#> 36001 2 0.000 0.972 0.00 1.00
#> 37013 2 0.000 0.972 0.00 1.00
#> 48001 2 0.000 0.972 0.00 1.00
#> 64002 1 0.000 1.000 1.00 0.00
#> 68001 1 0.000 1.000 1.00 0.00
#> 02020 2 0.000 0.972 0.00 1.00
#> 15006 1 0.000 1.000 1.00 0.00
#> 26009 1 0.000 1.000 1.00 0.00
#> 83001 2 0.000 0.972 0.00 1.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 01010 1 0 1 1 0 0
#> 04006 1 0 1 1 0 0
#> 04008 3 0 1 0 0 1
#> 04010 1 0 1 1 0 0
#> 06002 2 0 1 0 1 0
#> 09008 3 0 1 0 0 1
#> 12012 2 0 1 0 1 0
#> 12019 2 0 1 0 1 0
#> 12026 2 0 1 0 1 0
#> 14016 2 0 1 0 1 0
#> 15001 2 0 1 0 1 0
#> 15005 2 0 1 0 1 0
#> 16004 2 0 1 0 1 0
#> 16009 1 0 1 1 0 0
#> 19005 2 0 1 0 1 0
#> 20002 3 0 1 0 0 1
#> 24011 2 0 1 0 1 0
#> 24017 1 0 1 1 0 0
#> 24019 1 0 1 1 0 0
#> 25006 1 0 1 1 0 0
#> 26001 2 0 1 0 1 0
#> 26005 2 0 1 0 1 0
#> 26008 1 0 1 1 0 0
#> 28019 1 0 1 1 0 0
#> 28021 3 0 1 0 0 1
#> 28035 3 0 1 0 0 1
#> 28037 3 0 1 0 0 1
#> 28044 2 0 1 0 1 0
#> 30001 1 0 1 1 0 0
#> 33005 3 0 1 0 0 1
#> 36001 2 0 1 0 1 0
#> 37013 2 0 1 0 1 0
#> 48001 2 0 1 0 1 0
#> 64002 1 0 1 1 0 0
#> 68001 1 0 1 1 0 0
#> 02020 2 0 1 0 1 0
#> 15006 1 0 1 1 0 0
#> 26009 1 0 1 1 0 0
#> 83001 2 0 1 0 1 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 01010 1 0.0000 1.000 1 0.00 0 0.00
#> 04006 1 0.0000 1.000 1 0.00 0 0.00
#> 04008 3 0.0000 1.000 0 0.00 1 0.00
#> 04010 1 0.0000 1.000 1 0.00 0 0.00
#> 06002 2 0.2921 0.915 0 0.86 0 0.14
#> 09008 3 0.0000 1.000 0 0.00 1 0.00
#> 12012 2 0.2921 0.915 0 0.86 0 0.14
#> 12019 2 0.2921 0.915 0 0.86 0 0.14
#> 12026 4 0.0000 1.000 0 0.00 0 1.00
#> 14016 4 0.0000 1.000 0 0.00 0 1.00
#> 15001 2 0.2921 0.915 0 0.86 0 0.14
#> 15005 2 0.0000 0.918 0 1.00 0 0.00
#> 16004 4 0.0000 1.000 0 0.00 0 1.00
#> 16009 1 0.0000 1.000 1 0.00 0 0.00
#> 19005 2 0.2647 0.918 0 0.88 0 0.12
#> 20002 3 0.0000 1.000 0 0.00 1 0.00
#> 24011 4 0.0000 1.000 0 0.00 0 1.00
#> 24017 1 0.0000 1.000 1 0.00 0 0.00
#> 24019 1 0.0000 1.000 1 0.00 0 0.00
#> 25006 1 0.0000 1.000 1 0.00 0 0.00
#> 26001 2 0.2921 0.915 0 0.86 0 0.14
#> 26005 2 0.2921 0.915 0 0.86 0 0.14
#> 26008 1 0.0000 1.000 1 0.00 0 0.00
#> 28019 1 0.0000 1.000 1 0.00 0 0.00
#> 28021 3 0.0000 1.000 0 0.00 1 0.00
#> 28035 3 0.0000 1.000 0 0.00 1 0.00
#> 28037 3 0.0000 1.000 0 0.00 1 0.00
#> 28044 2 0.0000 0.918 0 1.00 0 0.00
#> 30001 1 0.0000 1.000 1 0.00 0 0.00
#> 33005 3 0.0000 1.000 0 0.00 1 0.00
#> 36001 2 0.0000 0.918 0 1.00 0 0.00
#> 37013 2 0.0000 0.918 0 1.00 0 0.00
#> 48001 2 0.0000 0.918 0 1.00 0 0.00
#> 64002 1 0.0000 1.000 1 0.00 0 0.00
#> 68001 1 0.0000 1.000 1 0.00 0 0.00
#> 02020 2 0.0707 0.920 0 0.98 0 0.02
#> 15006 1 0.0000 1.000 1 0.00 0 0.00
#> 26009 1 0.0000 1.000 1 0.00 0 0.00
#> 83001 2 0.0000 0.918 0 1.00 0 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 39 1.000 0.4107 0.381 2
#> ATC:skmeans 39 0.896 0.7659 0.162 3
#> ATC:skmeans 39 0.842 0.0161 0.365 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node02. Child nodes: Node0111-leaf , Node0112-leaf , Node0113-leaf , Node0114-leaf , Node0121-leaf , Node0122-leaf , Node0123-leaf , Node0221-leaf , Node0222-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["022"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 18 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5234 0.477 0.477
#> 3 3 0.863 0.902 0.962 0.3139 0.837 0.658
#> 4 4 0.863 0.798 0.930 0.0939 0.922 0.755
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 06002 2 0 1 0 1
#> 12012 2 0 1 0 1
#> 12019 2 0 1 0 1
#> 12026 2 0 1 0 1
#> 14016 2 0 1 0 1
#> 15001 2 0 1 0 1
#> 15005 1 0 1 1 0
#> 16004 2 0 1 0 1
#> 19005 1 0 1 1 0
#> 24011 2 0 1 0 1
#> 26001 2 0 1 0 1
#> 26005 2 0 1 0 1
#> 28044 1 0 1 1 0
#> 36001 1 0 1 1 0
#> 37013 1 0 1 1 0
#> 48001 1 0 1 1 0
#> 02020 1 0 1 1 0
#> 83001 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 06002 3 0.000 0.895 0.00 0.00 1.0
#> 12012 3 0.613 0.340 0.00 0.40 0.6
#> 12019 3 0.000 0.895 0.00 0.00 1.0
#> 12026 2 0.000 1.000 0.00 1.00 0.0
#> 14016 2 0.000 1.000 0.00 1.00 0.0
#> 15001 3 0.000 0.895 0.00 0.00 1.0
#> 15005 1 0.000 0.958 1.00 0.00 0.0
#> 16004 2 0.000 1.000 0.00 1.00 0.0
#> 19005 1 0.540 0.616 0.72 0.28 0.0
#> 24011 2 0.000 1.000 0.00 1.00 0.0
#> 26001 2 0.000 1.000 0.00 1.00 0.0
#> 26005 3 0.000 0.895 0.00 0.00 1.0
#> 28044 1 0.000 0.958 1.00 0.00 0.0
#> 36001 1 0.000 0.958 1.00 0.00 0.0
#> 37013 1 0.000 0.958 1.00 0.00 0.0
#> 48001 1 0.000 0.958 1.00 0.00 0.0
#> 02020 1 0.000 0.958 1.00 0.00 0.0
#> 83001 1 0.000 0.958 1.00 0.00 0.0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 06002 3 0.0000 0.7356 0.00 0.00 1.00 0.00
#> 12012 3 0.6336 0.0742 0.00 0.46 0.48 0.06
#> 12019 4 0.5062 0.4909 0.00 0.02 0.30 0.68
#> 12026 2 0.0000 1.0000 0.00 1.00 0.00 0.00
#> 14016 2 0.0000 1.0000 0.00 1.00 0.00 0.00
#> 15001 3 0.0000 0.7356 0.00 0.00 1.00 0.00
#> 15005 1 0.0000 0.9311 1.00 0.00 0.00 0.00
#> 16004 2 0.0000 1.0000 0.00 1.00 0.00 0.00
#> 19005 4 0.0707 0.6155 0.02 0.00 0.00 0.98
#> 24011 2 0.0000 1.0000 0.00 1.00 0.00 0.00
#> 26001 2 0.0000 1.0000 0.00 1.00 0.00 0.00
#> 26005 3 0.0000 0.7356 0.00 0.00 1.00 0.00
#> 28044 1 0.0000 0.9311 1.00 0.00 0.00 0.00
#> 36001 1 0.0000 0.9311 1.00 0.00 0.00 0.00
#> 37013 1 0.0000 0.9311 1.00 0.00 0.00 0.00
#> 48001 1 0.4855 0.3938 0.60 0.00 0.00 0.40
#> 02020 1 0.0000 0.9311 1.00 0.00 0.00 0.00
#> 83001 1 0.0000 0.9311 1.00 0.00 0.00 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 18 1.000 0.260 0.312 2
#> ATC:skmeans 17 0.335 0.308 0.654 3
#> ATC:skmeans 15 0.308 0.192 0.413 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
Parent node: Node0. Child nodes: Node011 , Node012 , Node013-leaf , Node021-leaf , Node022 , Node023-leaf , Node031-leaf , Node032-leaf , Node033-leaf .
The object with results only for a single top-value method and a single partitioning method can be extracted as:
res = res_rh["03"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4.
#> On a matrix with 11393 rows and 31 columns.
#> Top rows (1139) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 150 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_partitions"
#> [7] "compare_signatures" "consensus_heatmap" "dimension_reduction"
#> [10] "functional_enrichment" "get_anno_col" "get_anno"
#> [13] "get_classes" "get_consensus" "get_matrix"
#> [16] "get_membership" "get_param" "get_signatures"
#> [19] "get_stats" "is_best_k" "is_stable_k"
#> [22] "membership_heatmap" "ncol" "nrow"
#> [25] "plot_ecdf" "predict_classes" "rownames"
#> [28] "select_partition_number" "show" "suggest_best_k"
#> [31] "test_to_known_factors" "top_rows_heatmap"
collect_plots()
function collects all the plots made from res
for all k
(number of subgroups)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, higher 1-PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.754 0.799 0.922 0.499 0.488 0.488
#> 3 3 1.000 0.986 0.994 0.340 0.781 0.579
#> 4 4 0.771 0.816 0.910 0.139 0.867 0.620
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following is the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall subgroup
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> 08024 2 0.000 0.864 0.00 1.00
#> 09017 1 0.000 0.933 1.00 0.00
#> 12006 2 0.000 0.864 0.00 1.00
#> 15004 2 0.000 0.864 0.00 1.00
#> 22009 1 0.999 -0.193 0.52 0.48
#> 22010 1 0.000 0.933 1.00 0.00
#> 22013 2 0.943 0.537 0.36 0.64
#> 24018 2 0.971 0.453 0.40 0.60
#> 25003 2 0.943 0.537 0.36 0.64
#> 27003 2 0.000 0.864 0.00 1.00
#> 28001 2 0.000 0.864 0.00 1.00
#> 28003 1 0.000 0.933 1.00 0.00
#> 28031 2 0.000 0.864 0.00 1.00
#> 28042 1 0.971 0.297 0.60 0.40
#> 31007 2 0.000 0.864 0.00 1.00
#> 43001 2 0.000 0.864 0.00 1.00
#> 43004 1 0.000 0.933 1.00 0.00
#> 43012 1 0.000 0.933 1.00 0.00
#> 62003 2 0.943 0.537 0.36 0.64
#> 01003 1 0.000 0.933 1.00 0.00
#> 01007 1 0.000 0.933 1.00 0.00
#> 12008 2 0.327 0.832 0.06 0.94
#> 17003 2 0.000 0.864 0.00 1.00
#> 19002 1 0.000 0.933 1.00 0.00
#> 19014 1 0.000 0.933 1.00 0.00
#> 24006 1 0.000 0.933 1.00 0.00
#> 28009 1 0.000 0.933 1.00 0.00
#> 37001 1 0.000 0.933 1.00 0.00
#> 64005 1 0.000 0.933 1.00 0.00
#> 65003 1 0.000 0.933 1.00 0.00
#> LAL4 1 0.000 0.933 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> 08024 2 0.000 1.000 0.00 1.00 0.00
#> 09017 3 0.000 1.000 0.00 0.00 1.00
#> 12006 2 0.000 1.000 0.00 1.00 0.00
#> 15004 2 0.000 1.000 0.00 1.00 0.00
#> 22009 3 0.000 1.000 0.00 0.00 1.00
#> 22010 1 0.000 0.984 1.00 0.00 0.00
#> 22013 3 0.000 1.000 0.00 0.00 1.00
#> 24018 3 0.000 1.000 0.00 0.00 1.00
#> 25003 3 0.000 1.000 0.00 0.00 1.00
#> 27003 2 0.000 1.000 0.00 1.00 0.00
#> 28001 2 0.000 1.000 0.00 1.00 0.00
#> 28003 1 0.000 0.984 1.00 0.00 0.00
#> 28031 2 0.000 1.000 0.00 1.00 0.00
#> 28042 1 0.369 0.838 0.86 0.14 0.00
#> 31007 2 0.000 1.000 0.00 1.00 0.00
#> 43001 2 0.000 1.000 0.00 1.00 0.00
#> 43004 3 0.000 1.000 0.00 0.00 1.00
#> 43012 1 0.000 0.984 1.00 0.00 0.00
#> 62003 3 0.000 1.000 0.00 0.00 1.00
#> 01003 1 0.000 0.984 1.00 0.00 0.00
#> 01007 1 0.000 0.984 1.00 0.00 0.00
#> 12008 3 0.000 1.000 0.00 0.00 1.00
#> 17003 2 0.000 1.000 0.00 1.00 0.00
#> 19002 1 0.000 0.984 1.00 0.00 0.00
#> 19014 1 0.000 0.984 1.00 0.00 0.00
#> 24006 1 0.000 0.984 1.00 0.00 0.00
#> 28009 1 0.000 0.984 1.00 0.00 0.00
#> 37001 1 0.000 0.984 1.00 0.00 0.00
#> 64005 1 0.207 0.930 0.94 0.00 0.06
#> 65003 1 0.000 0.984 1.00 0.00 0.00
#> LAL4 1 0.000 0.984 1.00 0.00 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> 08024 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 09017 3 0.3975 0.723 0.24 0.00 0.76 0.00
#> 12006 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 15004 4 0.4134 0.611 0.00 0.26 0.00 0.74
#> 22009 3 0.0000 0.895 0.00 0.00 1.00 0.00
#> 22010 1 0.0000 0.880 1.00 0.00 0.00 0.00
#> 22013 3 0.0000 0.895 0.00 0.00 1.00 0.00
#> 24018 3 0.0000 0.895 0.00 0.00 1.00 0.00
#> 25003 3 0.0000 0.895 0.00 0.00 1.00 0.00
#> 27003 2 0.3172 0.797 0.00 0.84 0.00 0.16
#> 28001 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 28003 1 0.0707 0.872 0.98 0.00 0.00 0.02
#> 28031 4 0.3610 0.685 0.00 0.20 0.00 0.80
#> 28042 4 0.0000 0.776 0.00 0.00 0.00 1.00
#> 31007 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 43001 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 43004 3 0.4624 0.578 0.34 0.00 0.66 0.00
#> 43012 4 0.1637 0.780 0.06 0.00 0.00 0.94
#> 62003 3 0.0000 0.895 0.00 0.00 1.00 0.00
#> 01003 1 0.0000 0.880 1.00 0.00 0.00 0.00
#> 01007 4 0.4624 0.532 0.34 0.00 0.00 0.66
#> 12008 3 0.2611 0.849 0.02 0.04 0.92 0.02
#> 17003 2 0.0000 0.971 0.00 1.00 0.00 0.00
#> 19002 1 0.0000 0.880 1.00 0.00 0.00 0.00
#> 19014 1 0.2647 0.832 0.88 0.00 0.00 0.12
#> 24006 1 0.0000 0.880 1.00 0.00 0.00 0.00
#> 28009 4 0.2921 0.709 0.14 0.00 0.00 0.86
#> 37001 1 0.3400 0.795 0.82 0.00 0.00 0.18
#> 64005 1 0.0000 0.880 1.00 0.00 0.00 0.00
#> 65003 1 0.4977 0.267 0.54 0.00 0.00 0.46
#> LAL4 1 0.4079 0.781 0.80 0.00 0.02 0.18
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
As soon as the classes for columns are determined, the signatures that are significantly different between subgroups can be looked for. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. To get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows (which is done by automatically selecting number of clusters).If there are too many signatures, top_signatures = ...
can be set to only show the
signatures with the highest FDRs:
# code only for demonstration
# e.g. to show the top 500 most significant rows
tb = get_signature(res, k = ..., top_signatures = 500)
If the signatures are defined as these which are uniquely high in current group, diff_method
argument
can be set to "uniquely_high_in_one_group"
:
# code only for demonstration
tb = get_signature(res, k = ..., diff_method = "uniquely_high_in_one_group")
UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n_sample sex(p-value) age(p-value) BT(p-value) k
#> ATC:skmeans 28 0.254 0.214 0.0216 2
#> ATC:skmeans 31 0.463 0.221 0.0167 3
#> ATC:skmeans 30 0.733 0.542 0.0985 4
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#>
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
#> [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] grid parallel stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] genefilter_1.74.0 ComplexHeatmap_2.8.0 markdown_1.1 knitr_1.33
#> [5] preprocessCore_1.54.0 ALL_1.34.0 Biobase_2.52.0 BiocGenerics_0.38.0
#> [9] cola_1.9.4
#>
#> loaded via a namespace (and not attached):
#> [1] colorspace_2.0-2 rjson_0.2.20 ellipsis_0.3.2 mclust_5.4.7
#> [5] circlize_0.4.13 XVector_0.32.0 GlobalOptions_0.1.2 clue_0.3-59
#> [9] rstudioapi_0.13 bit64_4.0.5 AnnotationDbi_1.54.1 Polychrome_1.3.1
#> [13] RSpectra_0.16-0 fansi_0.5.0 xml2_1.3.2 codetools_0.2-18
#> [17] splines_4.1.0 doParallel_1.0.16 cachem_1.0.5 impute_1.66.0
#> [21] polyclip_1.10-0 jsonlite_1.7.2 Cairo_1.5-12.2 umap_0.2.7.0
#> [25] annotate_1.70.0 cluster_2.1.2 png_0.1-7 data.tree_1.0.0
#> [29] compiler_4.1.0 httr_1.4.2 assertthat_0.2.1 Matrix_1.3-4
#> [33] fastmap_1.1.0 tools_4.1.0 gtable_0.3.0 glue_1.4.2
#> [37] GenomeInfoDbData_1.2.6 dplyr_1.0.7 Rcpp_1.0.7 slam_0.1-48
#> [41] eulerr_6.1.0 vctrs_0.3.8 Biostrings_2.60.1 iterators_1.0.13
#> [45] polylabelr_0.2.0 xfun_0.24 stringr_1.4.0 lifecycle_1.0.0
#> [49] irlba_2.3.3 XML_3.99-0.6 dendextend_1.15.1 zlibbioc_1.38.0
#> [53] scales_1.1.1 microbenchmark_1.4-7 RColorBrewer_1.1-2 memoise_2.0.0
#> [57] reticulate_1.20 gridExtra_2.3 ggplot2_3.3.5 stringi_1.7.3
#> [61] RSQLite_2.2.7 highr_0.9 S4Vectors_0.30.0 foreach_1.5.1
#> [65] shape_1.4.6 GenomeInfoDb_1.28.1 rlang_0.4.11 pkgconfig_2.0.3
#> [69] matrixStats_0.59.0 bitops_1.0-7 evaluate_0.14 lattice_0.20-44
#> [73] purrr_0.3.4 bit_4.0.4 tidyselect_1.1.1 magrittr_2.0.1
#> [77] R6_2.5.0 IRanges_2.26.0 generics_0.1.0 DBI_1.1.1
#> [81] pillar_1.6.1 survival_3.2-11 KEGGREST_1.32.0 scatterplot3d_0.3-41
#> [85] RCurl_1.98-1.3 tibble_3.1.2 crayon_1.4.1 utf8_1.2.1
#> [89] skmeans_0.2-13 viridis_0.6.1 GetoptLong_1.0.5 blob_1.2.1
#> [93] digest_0.6.27 xtable_1.8-4 brew_1.0-6 openssl_1.4.4
#> [97] stats4_4.1.0 munsell_0.5.0 viridisLite_0.4.0 askpass_1.1