cola Report for recount2:ERP001908

Date: 2019-12-25 22:24:31 CET, cola version: 1.3.2

Document is loading...


Summary

All available functions which can be applied to this res_list object:

res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#>   Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#>   Number of partitions are tried for k = 2, 3, 4, 5, 6.
#>   Performed in total 30000 partitions by row resampling.
#> 
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#>  [1] "cola_report"           "collect_classes"       "collect_plots"         "collect_stats"        
#>  [5] "colnames"              "functional_enrichment" "get_anno_col"          "get_anno"             
#>  [9] "get_classes"           "get_matrix"            "get_membership"        "get_stats"            
#> [13] "is_best_k"             "is_stable_k"           "ncol"                  "nrow"                 
#> [17] "rownames"              "show"                  "suggest_best_k"        "test_to_known_factors"
#> [21] "top_rows_heatmap"      "top_rows_overlap"     
#> 
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]

The call of run_all_consensus_partition_methods() was:

#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 10269    62

Density distribution

The density distribution for each sample is visualized as in 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, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
    mc.cores = 4)

plot of chunk density-heatmap

Suggest the best k

Folowing table shows the best k (number of partitions) for each combination of top-value methods and partition methods. Clicking on the method name in the table goes to the section for a single combination of methods.

The cola vignette explains the definition of the metrics used for determining the best number of partitions.

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:kmeans 2 1.000 0.981 0.992 **
SD:skmeans 2 1.000 0.960 0.984 **
CV:hclust 2 1.000 0.969 0.982 **
CV:skmeans 2 1.000 0.970 0.987 **
MAD:kmeans 2 1.000 0.984 0.993 **
MAD:skmeans 2 1.000 0.974 0.988 **
ATC:skmeans 2 1.000 0.981 0.991 **
CV:kmeans 2 0.965 0.912 0.967 **
SD:pam 3 0.942 0.919 0.968 * 2
ATC:kmeans 3 0.935 0.953 0.971 * 2
MAD:pam 3 0.930 0.936 0.972 * 2
ATC:pam 3 0.907 0.907 0.942 *
SD:NMF 2 0.900 0.926 0.967
MAD:NMF 2 0.871 0.914 0.953
CV:pam 2 0.862 0.921 0.963
ATC:NMF 2 0.775 0.896 0.954
SD:hclust 3 0.750 0.835 0.933
MAD:hclust 5 0.738 0.810 0.925
MAD:mclust 5 0.673 0.791 0.884
CV:NMF 2 0.662 0.863 0.931
ATC:hclust 2 0.610 0.934 0.904
CV:mclust 6 0.547 0.653 0.807
ATC:mclust 2 0.528 0.887 0.923
SD:mclust 3 0.283 0.669 0.775

**: 1-PAC > 0.95, *: 1-PAC > 0.9

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

Consensus heatmaps for all methods. (What is a consensus heatmap?)

collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-1

collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-2

collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-3

collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-4

collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)

plot of chunk tab-collect-consensus-heatmap-5

Membership heatmap

Membership heatmaps for all methods. (What is a membership heatmap?)

collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-1

collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-2

collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-3

collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-4

collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)

plot of chunk tab-collect-membership-heatmap-5

Signature heatmap

Signature heatmaps for all methods. (What is a signature heatmap?)

Note in following heatmaps, rows are scaled.

collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-1

collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-2

collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-3

collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-4

collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)

plot of chunk tab-collect-get-signatures-5

Statistics table

The statistics used for measuring the stability of consensus partitioning. (How are they defined?)

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 0.900           0.926       0.967         0.4898 0.505   0.505
#> CV:NMF      2 0.662           0.863       0.931         0.4772 0.511   0.511
#> MAD:NMF     2 0.871           0.914       0.953         0.4977 0.497   0.497
#> ATC:NMF     2 0.775           0.896       0.954         0.4874 0.511   0.511
#> SD:skmeans  2 1.000           0.960       0.984         0.5010 0.497   0.497
#> CV:skmeans  2 1.000           0.970       0.987         0.5034 0.497   0.497
#> MAD:skmeans 2 1.000           0.974       0.988         0.5022 0.497   0.497
#> ATC:skmeans 2 1.000           0.981       0.991         0.5048 0.494   0.494
#> SD:mclust   2 0.492           0.737       0.866         0.3414 0.748   0.748
#> CV:mclust   2 0.903           0.944       0.980         0.0701 0.968   0.968
#> MAD:mclust  2 0.445           0.735       0.870         0.3247 0.748   0.748
#> ATC:mclust  2 0.528           0.887       0.923         0.4617 0.497   0.497
#> SD:kmeans   2 1.000           0.981       0.992         0.4846 0.518   0.518
#> CV:kmeans   2 0.965           0.912       0.967         0.4509 0.556   0.556
#> MAD:kmeans  2 1.000           0.984       0.993         0.4855 0.518   0.518
#> ATC:kmeans  2 1.000           0.978       0.989         0.4394 0.568   0.568
#> SD:pam      2 0.966           0.960       0.980         0.5011 0.500   0.500
#> CV:pam      2 0.862           0.921       0.963         0.4365 0.556   0.556
#> MAD:pam     2 0.932           0.933       0.971         0.5021 0.497   0.497
#> ATC:pam     2 0.784           0.908       0.946         0.4864 0.492   0.492
#> SD:hclust   2 0.594           0.872       0.879         0.2921 0.581   0.581
#> CV:hclust   2 1.000           0.969       0.982         0.0914 0.906   0.906
#> MAD:hclust  2 0.560           0.857       0.895         0.3502 0.568   0.568
#> ATC:hclust  2 0.610           0.934       0.904         0.3234 0.568   0.568
get_stats(res_list, k = 3)
#>             k  1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.5463           0.649       0.847          0.298 0.791   0.615
#> CV:NMF      3 0.5287           0.727       0.868          0.155 0.867   0.763
#> MAD:NMF     3 0.5348           0.679       0.844          0.261 0.856   0.718
#> ATC:NMF     3 0.5324           0.772       0.859          0.359 0.796   0.609
#> SD:skmeans  3 0.8028           0.841       0.909          0.220 0.871   0.745
#> CV:skmeans  3 0.7344           0.799       0.902          0.241 0.847   0.701
#> MAD:skmeans 3 0.7864           0.812       0.893          0.222 0.871   0.745
#> ATC:skmeans 3 0.8542           0.855       0.927          0.181 0.911   0.820
#> SD:mclust   3 0.2825           0.669       0.775          0.581 0.675   0.575
#> CV:mclust   3 0.0926           0.477       0.728          5.448 0.604   0.591
#> MAD:mclust  3 0.3122           0.616       0.778          0.594 0.689   0.592
#> ATC:mclust  3 0.6122           0.761       0.853          0.238 0.840   0.709
#> SD:kmeans   3 0.8149           0.814       0.900          0.217 0.808   0.649
#> CV:kmeans   3 0.7592           0.811       0.888          0.266 0.778   0.621
#> MAD:kmeans  3 0.7477           0.779       0.894          0.245 0.788   0.616
#> ATC:kmeans  3 0.9350           0.953       0.971          0.368 0.714   0.539
#> SD:pam      3 0.9419           0.919       0.968          0.175 0.914   0.829
#> CV:pam      3 0.7139           0.810       0.930          0.104 0.990   0.982
#> MAD:pam     3 0.9298           0.936       0.972          0.181 0.882   0.771
#> ATC:pam     3 0.9071           0.907       0.942          0.218 0.889   0.776
#> SD:hclust   3 0.7502           0.835       0.933          0.652 0.887   0.814
#> CV:hclust   3 1.0000           0.961       0.987          0.270 0.999   0.999
#> MAD:hclust  3 0.6669           0.781       0.920          0.401 0.870   0.785
#> ATC:hclust  3 0.7528           0.946       0.971          0.460 0.975   0.955
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.520           0.569       0.749         0.1270 0.753   0.466
#> CV:NMF      4 0.465           0.651       0.821         0.2158 0.723   0.481
#> MAD:NMF     4 0.500           0.666       0.794         0.1305 0.750   0.474
#> ATC:NMF     4 0.537           0.593       0.771         0.1167 0.824   0.528
#> SD:skmeans  4 0.613           0.667       0.820         0.1323 0.922   0.803
#> CV:skmeans  4 0.520           0.625       0.774         0.1382 0.943   0.849
#> MAD:skmeans 4 0.549           0.631       0.793         0.1381 0.921   0.799
#> ATC:skmeans 4 0.776           0.723       0.853         0.0739 0.976   0.940
#> SD:mclust   4 0.615           0.758       0.868         0.1162 0.883   0.769
#> CV:mclust   4 0.234           0.531       0.771         0.2223 0.677   0.543
#> MAD:mclust  4 0.579           0.771       0.869         0.1427 0.896   0.795
#> ATC:mclust  4 0.618           0.739       0.779         0.1171 0.918   0.836
#> SD:kmeans   4 0.658           0.714       0.820         0.1253 0.968   0.919
#> CV:kmeans   4 0.843           0.857       0.924         0.0712 0.959   0.897
#> MAD:kmeans  4 0.679           0.652       0.817         0.1194 0.919   0.795
#> ATC:kmeans  4 0.739           0.777       0.881         0.1106 0.906   0.773
#> SD:pam      4 0.802           0.857       0.925         0.0506 0.996   0.990
#> CV:pam      4 0.698           0.795       0.911         0.0931 0.897   0.813
#> MAD:pam     4 0.770           0.878       0.852         0.0481 0.996   0.990
#> ATC:pam     4 1.000           0.940       0.980         0.0591 0.987   0.967
#> SD:hclust   4 0.738           0.852       0.948         0.0176 0.999   0.998
#> CV:hclust   4 0.662           0.845       0.932         2.1815 0.762   0.737
#> MAD:hclust  4 0.695           0.818       0.931         0.0257 0.979   0.959
#> ATC:hclust  4 0.754           0.793       0.903         0.0691 0.971   0.946
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.626           0.668       0.797         0.0807 0.885   0.643
#> CV:NMF      5 0.547           0.457       0.761         0.0943 0.948   0.843
#> MAD:NMF     5 0.563           0.638       0.759         0.0810 0.883   0.646
#> ATC:NMF     5 0.564           0.561       0.750         0.0472 0.946   0.791
#> SD:skmeans  5 0.564           0.576       0.749         0.0775 0.969   0.909
#> CV:skmeans  5 0.522           0.388       0.687         0.0716 0.929   0.795
#> MAD:skmeans 5 0.552           0.512       0.741         0.0668 0.964   0.890
#> ATC:skmeans 5 0.699           0.628       0.801         0.0599 0.999   0.997
#> SD:mclust   5 0.696           0.798       0.876         0.1471 0.878   0.726
#> CV:mclust   5 0.283           0.572       0.746         0.2190 0.785   0.596
#> MAD:mclust  5 0.673           0.791       0.884         0.1677 0.854   0.680
#> ATC:mclust  5 0.457           0.420       0.702         0.0858 0.834   0.653
#> SD:kmeans   5 0.723           0.636       0.828         0.1032 0.815   0.541
#> CV:kmeans   5 0.846           0.848       0.924         0.0385 0.999   0.997
#> MAD:kmeans  5 0.721           0.735       0.833         0.0912 0.802   0.486
#> ATC:kmeans  5 0.738           0.606       0.752         0.1003 0.867   0.649
#> SD:pam      5 0.786           0.873       0.928         0.0202 0.983   0.959
#> CV:pam      5 0.646           0.795       0.916         0.0678 0.997   0.994
#> MAD:pam     5 0.740           0.837       0.925         0.0242 0.991   0.978
#> ATC:pam     5 0.754           0.773       0.845         0.1019 0.973   0.929
#> SD:hclust   5 0.759           0.824       0.938         0.0979 0.958   0.918
#> CV:hclust   5 0.638           0.768       0.902         0.2649 0.860   0.791
#> MAD:hclust  5 0.738           0.810       0.925         0.1022 0.949   0.897
#> ATC:hclust  5 0.757           0.831       0.876         0.0563 0.979   0.959
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.607           0.480       0.716         0.0424 0.936   0.740
#> CV:NMF      6 0.566           0.478       0.697         0.0497 0.867   0.595
#> MAD:NMF     6 0.583           0.503       0.718         0.0449 0.970   0.870
#> ATC:NMF     6 0.615           0.547       0.720         0.0318 0.968   0.859
#> SD:skmeans  6 0.580           0.486       0.717         0.0461 0.966   0.889
#> CV:skmeans  6 0.540           0.328       0.629         0.0483 0.940   0.809
#> MAD:skmeans 6 0.565           0.488       0.710         0.0484 0.997   0.989
#> ATC:skmeans 6 0.655           0.601       0.776         0.0396 0.973   0.930
#> SD:mclust   6 0.679           0.688       0.831         0.0794 0.984   0.952
#> CV:mclust   6 0.547           0.653       0.807         0.0895 0.918   0.763
#> MAD:mclust  6 0.634           0.610       0.803         0.0772 0.969   0.907
#> ATC:mclust  6 0.555           0.330       0.652         0.0526 0.888   0.685
#> SD:kmeans   6 0.679           0.698       0.813         0.0598 0.919   0.715
#> CV:kmeans   6 0.835           0.770       0.896         0.0422 0.973   0.928
#> MAD:kmeans  6 0.693           0.737       0.823         0.0573 0.948   0.800
#> ATC:kmeans  6 0.786           0.847       0.845         0.0571 0.832   0.474
#> SD:pam      6 0.710           0.822       0.907         0.0280 0.987   0.968
#> CV:pam      6 0.619           0.756       0.893         0.0417 0.992   0.981
#> MAD:pam     6 0.728           0.837       0.892         0.0956 0.854   0.641
#> ATC:pam     6 0.714           0.731       0.833         0.0683 0.840   0.586
#> SD:hclust   6 0.777           0.751       0.904         0.0463 0.992   0.982
#> CV:hclust   6 0.610           0.787       0.899         0.0740 0.948   0.902
#> MAD:hclust  6 0.738           0.765       0.898         0.0310 0.937   0.870
#> ATC:hclust  6 0.754           0.781       0.864         0.0486 1.000   1.000

Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.

collect_stats(res_list, k = 2)

plot of chunk tab-collect-stats-from-consensus-partition-list-1

collect_stats(res_list, k = 3)

plot of chunk tab-collect-stats-from-consensus-partition-list-2

collect_stats(res_list, k = 4)

plot of chunk tab-collect-stats-from-consensus-partition-list-3

collect_stats(res_list, k = 5)

plot of chunk tab-collect-stats-from-consensus-partition-list-4

collect_stats(res_list, k = 6)

plot of chunk tab-collect-stats-from-consensus-partition-list-5

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

plot of chunk tab-collect-classes-from-consensus-partition-list-1

collect_classes(res_list, k = 3)

plot of chunk tab-collect-classes-from-consensus-partition-list-2

collect_classes(res_list, k = 4)

plot of chunk tab-collect-classes-from-consensus-partition-list-3

collect_classes(res_list, k = 5)

plot of chunk tab-collect-classes-from-consensus-partition-list-4

collect_classes(res_list, k = 6)

plot of chunk tab-collect-classes-from-consensus-partition-list-5

Top rows overlap

Overlap of top rows from different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-1

top_rows_overlap(res_list, top_n = 2000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-2

top_rows_overlap(res_list, top_n = 3000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-3

top_rows_overlap(res_list, top_n = 4000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-4

top_rows_overlap(res_list, top_n = 5000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-5

Also visualize the correspondance of rankings between different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-1

top_rows_overlap(res_list, top_n = 2000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-2

top_rows_overlap(res_list, top_n = 3000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-3

top_rows_overlap(res_list, top_n = 4000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-4

top_rows_overlap(res_list, top_n = 5000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-5

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

plot of chunk tab-top-rows-heatmap-1

top_rows_heatmap(res_list, top_n = 2000)

plot of chunk tab-top-rows-heatmap-2

top_rows_heatmap(res_list, top_n = 3000)

plot of chunk tab-top-rows-heatmap-3

top_rows_heatmap(res_list, top_n = 4000)

plot of chunk tab-top-rows-heatmap-4

top_rows_heatmap(res_list, top_n = 5000)

plot of chunk tab-top-rows-heatmap-5

Results for each method


SD:hclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "hclust"]
# you can also extract it by
# res = res_list["SD:hclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-hclust-select-partition-number

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.594           0.872       0.879         0.2921 0.581   0.581
#> 3 3 0.750           0.835       0.933         0.6525 0.887   0.814
#> 4 4 0.738           0.852       0.948         0.0176 0.999   0.998
#> 5 5 0.759           0.824       0.938         0.0979 0.958   0.918
#> 6 6 0.777           0.751       0.904         0.0463 0.992   0.982

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.9775      0.833 0.588 0.412
#> ERR184093     2  0.0000      0.961 0.000 1.000
#> ERR184051     1  0.9881      0.844 0.564 0.436
#> ERR184076     1  0.9775      0.833 0.588 0.412
#> ERR184043     1  0.9881      0.844 0.564 0.436
#> ERR184037     2  0.7745      0.461 0.228 0.772
#> ERR184059     1  0.9881      0.844 0.564 0.436
#> ERR184055     2  0.6623      0.637 0.172 0.828
#> ERR184065     2  0.0000      0.961 0.000 1.000
#> ERR184069     2  0.0000      0.961 0.000 1.000
#> ERR184040     1  0.9754      0.830 0.592 0.408
#> ERR184057     2  0.0000      0.961 0.000 1.000
#> ERR184082     2  0.0000      0.961 0.000 1.000
#> ERR184083     2  0.0000      0.961 0.000 1.000
#> ERR184039     2  0.0000      0.961 0.000 1.000
#> ERR184064     1  0.9881      0.844 0.564 0.436
#> ERR184081     2  0.0000      0.961 0.000 1.000
#> ERR184095     2  0.0000      0.961 0.000 1.000
#> ERR184079     2  0.0000      0.961 0.000 1.000
#> ERR184084     1  0.9881      0.844 0.564 0.436
#> ERR184068     2  0.0000      0.961 0.000 1.000
#> ERR184067     2  0.0000      0.961 0.000 1.000
#> ERR184071     2  0.0000      0.961 0.000 1.000
#> ERR184042     1  0.0000      0.542 1.000 0.000
#> ERR184063     1  0.9881      0.844 0.564 0.436
#> ERR184091     2  0.0000      0.961 0.000 1.000
#> ERR184061     2  0.0000      0.961 0.000 1.000
#> ERR184077     2  0.0000      0.961 0.000 1.000
#> ERR184062     2  0.0376      0.956 0.004 0.996
#> ERR184053     2  0.0000      0.961 0.000 1.000
#> ERR184088     2  0.0000      0.961 0.000 1.000
#> ERR184075     2  0.0000      0.961 0.000 1.000
#> ERR184041     1  0.9881      0.844 0.564 0.436
#> ERR184060     2  0.0000      0.961 0.000 1.000
#> ERR184035     2  0.0000      0.961 0.000 1.000
#> ERR184086     2  0.0000      0.961 0.000 1.000
#> ERR184080     2  0.4562      0.818 0.096 0.904
#> ERR184050     2  0.0000      0.961 0.000 1.000
#> ERR184047     1  0.0000      0.542 1.000 0.000
#> ERR184092     2  0.0000      0.961 0.000 1.000
#> ERR184072     1  0.9896      0.837 0.560 0.440
#> ERR184073     1  0.9850      0.841 0.572 0.428
#> ERR184066     2  0.3879      0.851 0.076 0.924
#> ERR184098     2  0.0000      0.961 0.000 1.000
#> ERR184044     2  0.0672      0.951 0.008 0.992
#> ERR184054     2  0.9635     -0.336 0.388 0.612
#> ERR184085     2  0.0000      0.961 0.000 1.000
#> ERR184056     2  0.0000      0.961 0.000 1.000
#> ERR184052     2  0.0000      0.961 0.000 1.000
#> ERR184070     2  0.0000      0.961 0.000 1.000
#> ERR184096     1  0.0000      0.542 1.000 0.000
#> ERR184089     2  0.0000      0.961 0.000 1.000
#> ERR184049     2  0.0000      0.961 0.000 1.000
#> ERR184038     2  0.3431      0.870 0.064 0.936
#> ERR184087     1  0.9881      0.844 0.564 0.436
#> ERR184097     2  0.0000      0.961 0.000 1.000
#> ERR184094     1  0.9881      0.844 0.564 0.436
#> ERR184058     2  0.0000      0.961 0.000 1.000
#> ERR184036     2  0.0000      0.961 0.000 1.000
#> ERR184046     2  0.0000      0.961 0.000 1.000
#> ERR184074     1  0.9881      0.844 0.564 0.436
#> ERR184048     2  0.0000      0.961 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.1031      0.818 0.976 0.000 0.024
#> ERR184093     2  0.0747      0.936 0.016 0.984 0.000
#> ERR184051     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184076     1  0.1031      0.818 0.976 0.000 0.024
#> ERR184043     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184037     1  0.5988      0.281 0.632 0.368 0.000
#> ERR184059     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184055     1  0.6235      0.155 0.564 0.436 0.000
#> ERR184065     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184069     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184040     1  0.1411      0.804 0.964 0.000 0.036
#> ERR184057     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184082     2  0.3038      0.875 0.104 0.896 0.000
#> ERR184083     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184039     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184064     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184081     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184079     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184084     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184068     2  0.2537      0.895 0.080 0.920 0.000
#> ERR184067     2  0.0237      0.940 0.004 0.996 0.000
#> ERR184071     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184042     3  0.0000      0.528 0.000 0.000 1.000
#> ERR184063     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184091     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184061     2  0.3192      0.866 0.112 0.888 0.000
#> ERR184077     2  0.0592      0.937 0.012 0.988 0.000
#> ERR184062     2  0.5216      0.683 0.260 0.740 0.000
#> ERR184053     2  0.1860      0.913 0.052 0.948 0.000
#> ERR184088     2  0.0424      0.939 0.008 0.992 0.000
#> ERR184075     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184041     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184060     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184035     2  0.3038      0.875 0.104 0.896 0.000
#> ERR184086     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184080     2  0.6104      0.505 0.348 0.648 0.004
#> ERR184050     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184047     3  0.6274      0.625 0.456 0.000 0.544
#> ERR184092     2  0.0747      0.936 0.016 0.984 0.000
#> ERR184072     1  0.0237      0.839 0.996 0.004 0.000
#> ERR184073     1  0.0592      0.833 0.988 0.000 0.012
#> ERR184066     2  0.6008      0.460 0.372 0.628 0.000
#> ERR184098     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184044     2  0.4062      0.816 0.164 0.836 0.000
#> ERR184054     1  0.4452      0.516 0.808 0.192 0.000
#> ERR184085     2  0.3192      0.868 0.112 0.888 0.000
#> ERR184056     2  0.0424      0.938 0.008 0.992 0.000
#> ERR184052     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184070     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184096     3  0.6274      0.625 0.456 0.000 0.544
#> ERR184089     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184049     2  0.0747      0.936 0.016 0.984 0.000
#> ERR184038     2  0.5733      0.565 0.324 0.676 0.000
#> ERR184087     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184097     2  0.0592      0.938 0.012 0.988 0.000
#> ERR184094     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184058     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184036     2  0.0747      0.936 0.016 0.984 0.000
#> ERR184046     2  0.0000      0.941 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.844 1.000 0.000 0.000
#> ERR184048     2  0.0237      0.940 0.004 0.996 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR184078     1  0.0817      0.870 0.976 0.000 0.024  0
#> ERR184093     2  0.0592      0.933 0.016 0.984 0.000  0
#> ERR184051     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184076     1  0.0817      0.870 0.976 0.000 0.024  0
#> ERR184043     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184037     1  0.4920      0.372 0.628 0.368 0.004  0
#> ERR184059     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184055     1  0.4941      0.165 0.564 0.436 0.000  0
#> ERR184065     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184069     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184040     1  0.1118      0.862 0.964 0.000 0.036  0
#> ERR184057     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184082     2  0.2408      0.872 0.104 0.896 0.000  0
#> ERR184083     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184039     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184064     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184081     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184095     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184079     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184084     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184068     2  0.2011      0.892 0.080 0.920 0.000  0
#> ERR184067     2  0.0188      0.938 0.004 0.996 0.000  0
#> ERR184071     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1
#> ERR184063     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184091     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184061     2  0.2530      0.862 0.112 0.888 0.000  0
#> ERR184077     2  0.0469      0.935 0.012 0.988 0.000  0
#> ERR184062     2  0.4134      0.681 0.260 0.740 0.000  0
#> ERR184053     2  0.1474      0.910 0.052 0.948 0.000  0
#> ERR184088     2  0.0336      0.937 0.008 0.992 0.000  0
#> ERR184075     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184041     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184060     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184035     2  0.2408      0.872 0.104 0.896 0.000  0
#> ERR184086     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184080     2  0.4837      0.502 0.348 0.648 0.004  0
#> ERR184050     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184047     3  0.0000      1.000 0.000 0.000 1.000  0
#> ERR184092     2  0.0592      0.933 0.016 0.984 0.000  0
#> ERR184072     1  0.0188      0.884 0.996 0.004 0.000  0
#> ERR184073     1  0.0469      0.880 0.988 0.000 0.012  0
#> ERR184066     2  0.4761      0.456 0.372 0.628 0.000  0
#> ERR184098     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184044     2  0.3219      0.813 0.164 0.836 0.000  0
#> ERR184054     1  0.3528      0.625 0.808 0.192 0.000  0
#> ERR184085     2  0.2530      0.865 0.112 0.888 0.000  0
#> ERR184056     2  0.0336      0.936 0.008 0.992 0.000  0
#> ERR184052     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184070     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184096     3  0.0000      1.000 0.000 0.000 1.000  0
#> ERR184089     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184049     2  0.0592      0.934 0.016 0.984 0.000  0
#> ERR184038     2  0.4543      0.562 0.324 0.676 0.000  0
#> ERR184087     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184097     2  0.0469      0.935 0.012 0.988 0.000  0
#> ERR184094     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184058     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184036     2  0.0592      0.934 0.016 0.984 0.000  0
#> ERR184046     2  0.0000      0.938 0.000 1.000 0.000  0
#> ERR184074     1  0.0000      0.887 1.000 0.000 0.000  0
#> ERR184048     2  0.0188      0.938 0.004 0.996 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> ERR184078     1  0.0992      0.642 0.968 0.000 0.008  0 0.024
#> ERR184093     2  0.0510      0.933 0.016 0.984 0.000  0 0.000
#> ERR184051     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184076     1  0.0865      0.641 0.972 0.000 0.004  0 0.024
#> ERR184043     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184037     1  0.4225      0.372 0.632 0.364 0.000  0 0.004
#> ERR184059     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184055     1  0.4249      0.196 0.568 0.432 0.000  0 0.000
#> ERR184065     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184069     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184040     1  0.1661      0.631 0.940 0.000 0.024  0 0.036
#> ERR184057     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184082     2  0.2074      0.869 0.104 0.896 0.000  0 0.000
#> ERR184083     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184039     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184064     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184081     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184095     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184079     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184084     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184068     2  0.1732      0.891 0.080 0.920 0.000  0 0.000
#> ERR184067     2  0.0162      0.938 0.004 0.996 0.000  0 0.000
#> ERR184071     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000
#> ERR184063     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184091     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184061     2  0.2230      0.855 0.116 0.884 0.000  0 0.000
#> ERR184077     2  0.0404      0.935 0.012 0.988 0.000  0 0.000
#> ERR184062     2  0.3561      0.666 0.260 0.740 0.000  0 0.000
#> ERR184053     2  0.1270      0.910 0.052 0.948 0.000  0 0.000
#> ERR184088     2  0.0290      0.937 0.008 0.992 0.000  0 0.000
#> ERR184075     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184041     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184060     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184035     2  0.2074      0.869 0.104 0.896 0.000  0 0.000
#> ERR184086     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184080     2  0.4182      0.466 0.352 0.644 0.000  0 0.004
#> ERR184050     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184047     5  0.0000      1.000 0.000 0.000 0.000  0 1.000
#> ERR184092     2  0.0510      0.933 0.016 0.984 0.000  0 0.000
#> ERR184072     1  0.0000      0.645 1.000 0.000 0.000  0 0.000
#> ERR184073     1  0.1106      0.642 0.964 0.000 0.024  0 0.012
#> ERR184066     2  0.4114      0.418 0.376 0.624 0.000  0 0.000
#> ERR184098     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184044     2  0.2813      0.801 0.168 0.832 0.000  0 0.000
#> ERR184054     1  0.3282      0.516 0.804 0.188 0.008  0 0.000
#> ERR184085     2  0.2179      0.862 0.112 0.888 0.000  0 0.000
#> ERR184056     2  0.0290      0.937 0.008 0.992 0.000  0 0.000
#> ERR184052     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184070     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184096     5  0.0000      1.000 0.000 0.000 0.000  0 1.000
#> ERR184089     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184049     2  0.0510      0.935 0.016 0.984 0.000  0 0.000
#> ERR184038     2  0.3932      0.532 0.328 0.672 0.000  0 0.000
#> ERR184087     3  0.0000      1.000 0.000 0.000 1.000  0 0.000
#> ERR184097     2  0.0404      0.936 0.012 0.988 0.000  0 0.000
#> ERR184094     1  0.4305     -0.136 0.512 0.000 0.488  0 0.000
#> ERR184058     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184036     2  0.0609      0.932 0.020 0.980 0.000  0 0.000
#> ERR184046     2  0.0000      0.939 0.000 1.000 0.000  0 0.000
#> ERR184074     1  0.0404      0.647 0.988 0.000 0.012  0 0.000
#> ERR184048     2  0.0162      0.938 0.004 0.996 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.3954    0.40342 0.620 0.000 0.004  0 0.004 0.372
#> ERR184093     2  0.0603    0.88864 0.004 0.980 0.000  0 0.000 0.016
#> ERR184051     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184076     1  0.3862    0.38874 0.608 0.000 0.000  0 0.004 0.388
#> ERR184043     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184037     6  0.5190    0.82150 0.128 0.280 0.000  0 0.000 0.592
#> ERR184059     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184055     6  0.5310    0.84091 0.116 0.348 0.000  0 0.000 0.536
#> ERR184065     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184069     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184040     1  0.1949    0.57374 0.924 0.000 0.020  0 0.020 0.036
#> ERR184057     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184082     2  0.2651    0.74700 0.028 0.860 0.000  0 0.000 0.112
#> ERR184083     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184039     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184064     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184081     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184095     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184079     2  0.0146    0.89806 0.000 0.996 0.000  0 0.000 0.004
#> ERR184084     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184068     2  0.1779    0.82803 0.016 0.920 0.000  0 0.000 0.064
#> ERR184067     2  0.0146    0.89793 0.000 0.996 0.000  0 0.000 0.004
#> ERR184071     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184042     4  0.0000    0.00000 0.000 0.000 0.000  1 0.000 0.000
#> ERR184063     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184091     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184061     2  0.3134    0.64728 0.024 0.808 0.000  0 0.000 0.168
#> ERR184077     2  0.0405    0.89344 0.004 0.988 0.000  0 0.000 0.008
#> ERR184062     2  0.4565    0.31259 0.096 0.684 0.000  0 0.000 0.220
#> ERR184053     2  0.1219    0.85611 0.004 0.948 0.000  0 0.000 0.048
#> ERR184088     2  0.0260    0.89603 0.000 0.992 0.000  0 0.000 0.008
#> ERR184075     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184041     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184060     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184035     2  0.2651    0.74700 0.028 0.860 0.000  0 0.000 0.112
#> ERR184086     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184080     2  0.5437   -0.18474 0.196 0.576 0.000  0 0.000 0.228
#> ERR184050     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184047     5  0.0000    1.00000 0.000 0.000 0.000  0 1.000 0.000
#> ERR184092     2  0.0603    0.88864 0.004 0.980 0.000  0 0.000 0.016
#> ERR184072     1  0.2491    0.55458 0.836 0.000 0.000  0 0.000 0.164
#> ERR184073     1  0.1364    0.57996 0.952 0.000 0.020  0 0.012 0.016
#> ERR184066     2  0.5506   -0.26545 0.180 0.556 0.000  0 0.000 0.264
#> ERR184098     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184044     2  0.3454    0.56857 0.024 0.768 0.000  0 0.000 0.208
#> ERR184054     1  0.4342    0.25621 0.740 0.152 0.008  0 0.000 0.100
#> ERR184085     2  0.2826    0.72143 0.028 0.844 0.000  0 0.000 0.128
#> ERR184056     2  0.0260    0.89479 0.008 0.992 0.000  0 0.000 0.000
#> ERR184052     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184070     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184096     5  0.0000    1.00000 0.000 0.000 0.000  0 1.000 0.000
#> ERR184089     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184049     2  0.0603    0.88957 0.004 0.980 0.000  0 0.000 0.016
#> ERR184038     2  0.5183   -0.04971 0.140 0.604 0.000  0 0.000 0.256
#> ERR184087     3  0.0000    1.00000 0.000 0.000 1.000  0 0.000 0.000
#> ERR184097     2  0.0405    0.89419 0.004 0.988 0.000  0 0.000 0.008
#> ERR184094     1  0.3866    0.00265 0.516 0.000 0.484  0 0.000 0.000
#> ERR184058     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184036     2  0.0777    0.88247 0.004 0.972 0.000  0 0.000 0.024
#> ERR184046     2  0.0000    0.89910 0.000 1.000 0.000  0 0.000 0.000
#> ERR184074     1  0.4089    0.30819 0.524 0.000 0.008  0 0.000 0.468
#> ERR184048     2  0.0146    0.89781 0.000 0.996 0.000  0 0.000 0.004

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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.


SD:kmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-kmeans-select-partition-number

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.981       0.992         0.4846 0.518   0.518
#> 3 3 0.815           0.814       0.900         0.2165 0.808   0.649
#> 4 4 0.658           0.714       0.820         0.1253 0.968   0.919
#> 5 5 0.723           0.636       0.828         0.1032 0.815   0.541
#> 6 6 0.679           0.698       0.813         0.0598 0.919   0.715

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.995 1.000 0.000
#> ERR184093     2  0.0000      0.989 0.000 1.000
#> ERR184051     1  0.0000      0.995 1.000 0.000
#> ERR184076     1  0.0000      0.995 1.000 0.000
#> ERR184043     1  0.0000      0.995 1.000 0.000
#> ERR184037     1  0.0938      0.988 0.988 0.012
#> ERR184059     1  0.0000      0.995 1.000 0.000
#> ERR184055     1  0.2236      0.966 0.964 0.036
#> ERR184065     2  0.0000      0.989 0.000 1.000
#> ERR184069     2  0.0000      0.989 0.000 1.000
#> ERR184040     1  0.0000      0.995 1.000 0.000
#> ERR184057     2  0.0000      0.989 0.000 1.000
#> ERR184082     2  0.0000      0.989 0.000 1.000
#> ERR184083     2  0.0000      0.989 0.000 1.000
#> ERR184039     2  0.0000      0.989 0.000 1.000
#> ERR184064     1  0.0000      0.995 1.000 0.000
#> ERR184081     2  0.0000      0.989 0.000 1.000
#> ERR184095     2  0.0000      0.989 0.000 1.000
#> ERR184079     2  0.0000      0.989 0.000 1.000
#> ERR184084     1  0.0000      0.995 1.000 0.000
#> ERR184068     2  0.0000      0.989 0.000 1.000
#> ERR184067     2  0.0000      0.989 0.000 1.000
#> ERR184071     2  0.0000      0.989 0.000 1.000
#> ERR184042     1  0.0000      0.995 1.000 0.000
#> ERR184063     1  0.0000      0.995 1.000 0.000
#> ERR184091     2  0.0000      0.989 0.000 1.000
#> ERR184061     2  0.0000      0.989 0.000 1.000
#> ERR184077     2  0.0000      0.989 0.000 1.000
#> ERR184062     2  0.0000      0.989 0.000 1.000
#> ERR184053     2  0.0000      0.989 0.000 1.000
#> ERR184088     2  0.0000      0.989 0.000 1.000
#> ERR184075     2  0.0000      0.989 0.000 1.000
#> ERR184041     1  0.0000      0.995 1.000 0.000
#> ERR184060     2  0.0000      0.989 0.000 1.000
#> ERR184035     2  0.2778      0.944 0.048 0.952
#> ERR184086     2  0.0000      0.989 0.000 1.000
#> ERR184080     1  0.0938      0.988 0.988 0.012
#> ERR184050     2  0.0000      0.989 0.000 1.000
#> ERR184047     1  0.0000      0.995 1.000 0.000
#> ERR184092     2  0.0000      0.989 0.000 1.000
#> ERR184072     1  0.0000      0.995 1.000 0.000
#> ERR184073     1  0.0000      0.995 1.000 0.000
#> ERR184066     1  0.2236      0.966 0.964 0.036
#> ERR184098     2  0.0000      0.989 0.000 1.000
#> ERR184044     2  0.9000      0.536 0.316 0.684
#> ERR184054     1  0.0000      0.995 1.000 0.000
#> ERR184085     2  0.2948      0.940 0.052 0.948
#> ERR184056     2  0.0000      0.989 0.000 1.000
#> ERR184052     2  0.0000      0.989 0.000 1.000
#> ERR184070     2  0.0000      0.989 0.000 1.000
#> ERR184096     1  0.0000      0.995 1.000 0.000
#> ERR184089     2  0.0000      0.989 0.000 1.000
#> ERR184049     2  0.0000      0.989 0.000 1.000
#> ERR184038     1  0.0938      0.988 0.988 0.012
#> ERR184087     1  0.0000      0.995 1.000 0.000
#> ERR184097     2  0.0000      0.989 0.000 1.000
#> ERR184094     1  0.0000      0.995 1.000 0.000
#> ERR184058     2  0.0000      0.989 0.000 1.000
#> ERR184036     2  0.0000      0.989 0.000 1.000
#> ERR184046     2  0.0000      0.989 0.000 1.000
#> ERR184074     1  0.0000      0.995 1.000 0.000
#> ERR184048     2  0.0000      0.989 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.1964     0.6876 0.944 0.000 0.056
#> ERR184093     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184051     3  0.5138     0.7836 0.252 0.000 0.748
#> ERR184076     1  0.1643     0.7001 0.956 0.000 0.044
#> ERR184043     3  0.4702     0.8040 0.212 0.000 0.788
#> ERR184037     1  0.0237     0.7300 0.996 0.000 0.004
#> ERR184059     3  0.4555     0.8027 0.200 0.000 0.800
#> ERR184055     1  0.0592     0.7306 0.988 0.000 0.012
#> ERR184065     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184069     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184040     1  0.3879     0.5229 0.848 0.000 0.152
#> ERR184057     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184082     1  0.6244     0.2807 0.560 0.440 0.000
#> ERR184083     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184039     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184064     3  0.4702     0.8040 0.212 0.000 0.788
#> ERR184081     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184079     2  0.1289     0.9610 0.032 0.968 0.000
#> ERR184084     3  0.4654     0.8031 0.208 0.000 0.792
#> ERR184068     2  0.2165     0.9336 0.064 0.936 0.000
#> ERR184067     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184071     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184042     3  0.0424     0.6703 0.008 0.000 0.992
#> ERR184063     3  0.6079     0.6191 0.388 0.000 0.612
#> ERR184091     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184061     1  0.6309     0.0677 0.500 0.500 0.000
#> ERR184077     2  0.1643     0.9519 0.044 0.956 0.000
#> ERR184062     2  0.3482     0.8564 0.128 0.872 0.000
#> ERR184053     2  0.1643     0.9519 0.044 0.956 0.000
#> ERR184088     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184075     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184041     3  0.5785     0.7058 0.332 0.000 0.668
#> ERR184060     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184035     1  0.5397     0.5039 0.720 0.280 0.000
#> ERR184086     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184080     1  0.0237     0.7300 0.996 0.000 0.004
#> ERR184050     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184047     3  0.4974     0.6130 0.236 0.000 0.764
#> ERR184092     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184072     1  0.0592     0.7306 0.988 0.000 0.012
#> ERR184073     3  0.6305     0.5547 0.484 0.000 0.516
#> ERR184066     1  0.0592     0.7306 0.988 0.000 0.012
#> ERR184098     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184044     1  0.2866     0.6796 0.916 0.076 0.008
#> ERR184054     1  0.0747     0.7287 0.984 0.000 0.016
#> ERR184085     1  0.5465     0.4937 0.712 0.288 0.000
#> ERR184056     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184052     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184070     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184096     3  0.5216     0.5923 0.260 0.000 0.740
#> ERR184089     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184049     2  0.5216     0.6270 0.260 0.740 0.000
#> ERR184038     1  0.2796     0.6643 0.908 0.000 0.092
#> ERR184087     3  0.4702     0.8040 0.212 0.000 0.788
#> ERR184097     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184094     3  0.6244     0.6291 0.440 0.000 0.560
#> ERR184058     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184036     2  0.0592     0.9737 0.012 0.988 0.000
#> ERR184046     2  0.0000     0.9768 0.000 1.000 0.000
#> ERR184074     1  0.1289     0.7101 0.968 0.000 0.032
#> ERR184048     2  0.1643     0.9519 0.044 0.956 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.4671      0.539 0.752 0.000 0.028 0.220
#> ERR184093     2  0.4153      0.818 0.048 0.820 0.000 0.132
#> ERR184051     3  0.1284      0.852 0.024 0.000 0.964 0.012
#> ERR184076     1  0.4194      0.596 0.800 0.000 0.028 0.172
#> ERR184043     3  0.0592      0.857 0.016 0.000 0.984 0.000
#> ERR184037     1  0.0927      0.703 0.976 0.000 0.008 0.016
#> ERR184059     3  0.4356      0.465 0.000 0.000 0.708 0.292
#> ERR184055     1  0.0804      0.703 0.980 0.000 0.008 0.012
#> ERR184065     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184069     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184040     1  0.5527      0.284 0.616 0.000 0.028 0.356
#> ERR184057     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184082     1  0.6714      0.438 0.616 0.208 0.000 0.176
#> ERR184083     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184064     3  0.0592      0.857 0.016 0.000 0.984 0.000
#> ERR184081     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184095     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184079     2  0.6323      0.695 0.176 0.660 0.000 0.164
#> ERR184084     3  0.4621      0.480 0.008 0.000 0.708 0.284
#> ERR184068     2  0.6695      0.635 0.220 0.616 0.000 0.164
#> ERR184067     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184071     2  0.4898      0.791 0.072 0.772 0.000 0.156
#> ERR184042     4  0.4605      0.355 0.000 0.000 0.336 0.664
#> ERR184063     3  0.1936      0.828 0.028 0.000 0.940 0.032
#> ERR184091     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184061     1  0.6071      0.526 0.684 0.144 0.000 0.172
#> ERR184077     2  0.6279      0.696 0.180 0.664 0.000 0.156
#> ERR184062     2  0.7079      0.534 0.276 0.556 0.000 0.168
#> ERR184053     2  0.6279      0.696 0.180 0.664 0.000 0.156
#> ERR184088     2  0.5174      0.777 0.092 0.756 0.000 0.152
#> ERR184075     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184041     3  0.1510      0.847 0.028 0.000 0.956 0.016
#> ERR184060     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184035     1  0.4544      0.622 0.788 0.048 0.000 0.164
#> ERR184086     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184080     1  0.1042      0.701 0.972 0.000 0.008 0.020
#> ERR184050     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184047     4  0.4318      0.698 0.116 0.000 0.068 0.816
#> ERR184092     2  0.3793      0.828 0.044 0.844 0.000 0.112
#> ERR184072     1  0.2949      0.667 0.888 0.000 0.024 0.088
#> ERR184073     1  0.6589      0.140 0.556 0.000 0.092 0.352
#> ERR184066     1  0.0804      0.703 0.980 0.000 0.008 0.012
#> ERR184098     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184044     1  0.3311      0.647 0.828 0.000 0.000 0.172
#> ERR184054     1  0.3143      0.660 0.876 0.000 0.024 0.100
#> ERR184085     1  0.5376      0.584 0.736 0.088 0.000 0.176
#> ERR184056     2  0.3674      0.829 0.036 0.848 0.000 0.116
#> ERR184052     2  0.0469      0.866 0.000 0.988 0.000 0.012
#> ERR184070     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184096     4  0.4282      0.695 0.124 0.000 0.060 0.816
#> ERR184089     2  0.0188      0.867 0.000 0.996 0.000 0.004
#> ERR184049     2  0.7426      0.278 0.376 0.452 0.000 0.172
#> ERR184038     1  0.3958      0.658 0.816 0.000 0.024 0.160
#> ERR184087     3  0.0592      0.857 0.016 0.000 0.984 0.000
#> ERR184097     2  0.3850      0.825 0.044 0.840 0.000 0.116
#> ERR184094     4  0.7474      0.312 0.176 0.000 0.400 0.424
#> ERR184058     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184036     2  0.4740      0.801 0.080 0.788 0.000 0.132
#> ERR184046     2  0.0000      0.867 0.000 1.000 0.000 0.000
#> ERR184074     1  0.4238      0.593 0.796 0.000 0.028 0.176
#> ERR184048     2  0.6310      0.691 0.188 0.660 0.000 0.152

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.1750     0.5344 0.936 0.000 0.000 0.036 0.028
#> ERR184093     2  0.4948    -0.0561 0.000 0.536 0.000 0.436 0.028
#> ERR184051     3  0.0290     0.8413 0.000 0.000 0.992 0.008 0.000
#> ERR184076     1  0.3574     0.6528 0.804 0.000 0.000 0.168 0.028
#> ERR184043     3  0.0000     0.8422 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.4650     0.6139 0.520 0.000 0.000 0.468 0.012
#> ERR184059     3  0.6098     0.2832 0.196 0.000 0.568 0.000 0.236
#> ERR184055     1  0.4653     0.6114 0.516 0.000 0.000 0.472 0.012
#> ERR184065     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184069     2  0.0000     0.8670 0.000 1.000 0.000 0.000 0.000
#> ERR184040     1  0.1195     0.4997 0.960 0.000 0.000 0.012 0.028
#> ERR184057     2  0.0290     0.8656 0.000 0.992 0.000 0.000 0.008
#> ERR184082     4  0.0290     0.6179 0.000 0.000 0.000 0.992 0.008
#> ERR184083     2  0.0000     0.8670 0.000 1.000 0.000 0.000 0.000
#> ERR184039     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184064     3  0.0000     0.8422 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.0000     0.8670 0.000 1.000 0.000 0.000 0.000
#> ERR184095     2  0.0162     0.8665 0.000 0.996 0.000 0.000 0.004
#> ERR184079     4  0.4024     0.6589 0.000 0.220 0.000 0.752 0.028
#> ERR184084     3  0.6346     0.2553 0.212 0.000 0.548 0.004 0.236
#> ERR184068     4  0.3355     0.6805 0.000 0.184 0.000 0.804 0.012
#> ERR184067     2  0.0290     0.8656 0.000 0.992 0.000 0.000 0.008
#> ERR184071     4  0.5106     0.2421 0.000 0.456 0.000 0.508 0.036
#> ERR184042     5  0.2574     0.5966 0.012 0.000 0.112 0.000 0.876
#> ERR184063     3  0.0290     0.8413 0.000 0.000 0.992 0.008 0.000
#> ERR184091     2  0.1043     0.8622 0.000 0.960 0.000 0.000 0.040
#> ERR184061     4  0.1525     0.6200 0.012 0.004 0.000 0.948 0.036
#> ERR184077     4  0.4446     0.4346 0.000 0.400 0.000 0.592 0.008
#> ERR184062     4  0.3012     0.6741 0.000 0.124 0.000 0.852 0.024
#> ERR184053     4  0.4527     0.4489 0.000 0.392 0.000 0.596 0.012
#> ERR184088     4  0.4902     0.2431 0.000 0.468 0.000 0.508 0.024
#> ERR184075     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184041     3  0.0290     0.8413 0.000 0.000 0.992 0.008 0.000
#> ERR184060     2  0.0000     0.8670 0.000 1.000 0.000 0.000 0.000
#> ERR184035     4  0.0566     0.6168 0.004 0.000 0.000 0.984 0.012
#> ERR184086     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184080     1  0.4375     0.6397 0.576 0.000 0.000 0.420 0.004
#> ERR184050     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184047     5  0.4165     0.8201 0.320 0.000 0.008 0.000 0.672
#> ERR184092     2  0.4546     0.4014 0.000 0.668 0.000 0.304 0.028
#> ERR184072     1  0.3635     0.6815 0.748 0.000 0.000 0.248 0.004
#> ERR184073     1  0.0579     0.5159 0.984 0.000 0.008 0.008 0.000
#> ERR184066     1  0.4443     0.6158 0.524 0.000 0.000 0.472 0.004
#> ERR184098     2  0.1478     0.8578 0.000 0.936 0.000 0.000 0.064
#> ERR184044     4  0.1549     0.5709 0.040 0.000 0.000 0.944 0.016
#> ERR184054     1  0.3579     0.6824 0.756 0.000 0.000 0.240 0.004
#> ERR184085     4  0.0404     0.6162 0.000 0.000 0.000 0.988 0.012
#> ERR184056     2  0.4219     0.5009 0.000 0.716 0.000 0.260 0.024
#> ERR184052     2  0.1522     0.8363 0.000 0.944 0.000 0.044 0.012
#> ERR184070     2  0.0162     0.8665 0.000 0.996 0.000 0.000 0.004
#> ERR184096     5  0.4201     0.8164 0.328 0.000 0.008 0.000 0.664
#> ERR184089     2  0.1197     0.8616 0.000 0.952 0.000 0.000 0.048
#> ERR184049     4  0.1195     0.6386 0.000 0.028 0.000 0.960 0.012
#> ERR184038     4  0.2689     0.4763 0.084 0.000 0.016 0.888 0.012
#> ERR184087     3  0.0000     0.8422 0.000 0.000 1.000 0.000 0.000
#> ERR184097     2  0.4624     0.2974 0.000 0.636 0.000 0.340 0.024
#> ERR184094     1  0.6529    -0.4196 0.476 0.000 0.296 0.000 0.228
#> ERR184058     2  0.0404     0.8660 0.000 0.988 0.000 0.000 0.012
#> ERR184036     2  0.5296    -0.2292 0.000 0.480 0.000 0.472 0.048
#> ERR184046     2  0.0000     0.8670 0.000 1.000 0.000 0.000 0.000
#> ERR184074     1  0.2852     0.6647 0.828 0.000 0.000 0.172 0.000
#> ERR184048     4  0.4415     0.4582 0.000 0.388 0.000 0.604 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.2088     0.7182 0.904 0.000 0.000 NA 0.068 0.000
#> ERR184093     6  0.4592     0.6328 0.000 0.268 0.000 NA 0.004 0.664
#> ERR184051     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184076     1  0.2251     0.7270 0.904 0.000 0.000 NA 0.052 0.008
#> ERR184043     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184037     1  0.5522     0.5829 0.544 0.000 0.000 NA 0.000 0.168
#> ERR184059     3  0.4435     0.2442 0.004 0.000 0.576 NA 0.400 0.004
#> ERR184055     1  0.5523     0.6005 0.552 0.000 0.000 NA 0.000 0.180
#> ERR184065     2  0.2191     0.8854 0.000 0.876 0.000 NA 0.004 0.000
#> ERR184069     2  0.0000     0.9001 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184040     1  0.2667     0.6880 0.852 0.000 0.000 NA 0.128 0.000
#> ERR184057     2  0.0260     0.8978 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184082     6  0.3673     0.5845 0.016 0.004 0.000 NA 0.000 0.736
#> ERR184083     2  0.0260     0.9006 0.000 0.992 0.000 NA 0.000 0.000
#> ERR184039     2  0.2191     0.8854 0.000 0.876 0.000 NA 0.004 0.000
#> ERR184064     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184081     2  0.0146     0.8991 0.000 0.996 0.000 NA 0.000 0.004
#> ERR184095     2  0.0260     0.8978 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184079     6  0.2711     0.7054 0.000 0.068 0.000 NA 0.004 0.872
#> ERR184084     3  0.6073     0.0191 0.016 0.000 0.460 NA 0.400 0.012
#> ERR184068     6  0.2138     0.6960 0.004 0.052 0.000 NA 0.000 0.908
#> ERR184067     2  0.0622     0.8942 0.000 0.980 0.000 NA 0.000 0.012
#> ERR184071     6  0.4294     0.6896 0.000 0.188 0.000 NA 0.004 0.728
#> ERR184042     5  0.4319     0.5709 0.000 0.000 0.032 NA 0.620 0.000
#> ERR184063     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184091     2  0.2053     0.8881 0.000 0.888 0.000 NA 0.004 0.000
#> ERR184061     6  0.4111     0.6135 0.028 0.012 0.000 NA 0.000 0.716
#> ERR184077     6  0.3141     0.7068 0.000 0.200 0.000 NA 0.000 0.788
#> ERR184062     6  0.2822     0.6976 0.012 0.048 0.000 NA 0.004 0.876
#> ERR184053     6  0.3488     0.7072 0.000 0.184 0.000 NA 0.000 0.780
#> ERR184088     6  0.4145     0.6883 0.000 0.220 0.000 NA 0.004 0.724
#> ERR184075     2  0.2191     0.8854 0.000 0.876 0.000 NA 0.004 0.000
#> ERR184041     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184060     2  0.0000     0.9001 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184035     6  0.3697     0.5826 0.016 0.004 0.000 NA 0.000 0.732
#> ERR184086     2  0.2234     0.8843 0.000 0.872 0.000 NA 0.004 0.000
#> ERR184080     1  0.4465     0.7020 0.712 0.000 0.000 NA 0.000 0.144
#> ERR184050     2  0.3314     0.8595 0.000 0.820 0.000 NA 0.004 0.048
#> ERR184047     5  0.0363     0.7016 0.012 0.000 0.000 NA 0.988 0.000
#> ERR184092     6  0.4968     0.3190 0.000 0.432 0.000 NA 0.004 0.508
#> ERR184072     1  0.1572     0.7585 0.936 0.000 0.000 NA 0.000 0.028
#> ERR184073     1  0.1913     0.7205 0.908 0.000 0.000 NA 0.080 0.000
#> ERR184066     1  0.4843     0.6721 0.664 0.000 0.000 NA 0.000 0.192
#> ERR184098     2  0.3494     0.8365 0.000 0.792 0.000 NA 0.004 0.036
#> ERR184044     6  0.3830     0.5713 0.044 0.000 0.000 NA 0.000 0.744
#> ERR184054     1  0.1151     0.7591 0.956 0.000 0.000 NA 0.000 0.032
#> ERR184085     6  0.3767     0.5704 0.016 0.004 0.000 NA 0.000 0.720
#> ERR184056     2  0.4835    -0.0795 0.000 0.540 0.000 NA 0.004 0.408
#> ERR184052     2  0.3066     0.8041 0.000 0.832 0.000 NA 0.000 0.124
#> ERR184070     2  0.0000     0.9001 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184096     5  0.0547     0.7017 0.020 0.000 0.000 NA 0.980 0.000
#> ERR184089     2  0.3314     0.8595 0.000 0.820 0.000 NA 0.004 0.048
#> ERR184049     6  0.3163     0.6301 0.008 0.012 0.000 NA 0.000 0.808
#> ERR184038     6  0.4969     0.4573 0.100 0.000 0.008 NA 0.000 0.652
#> ERR184087     3  0.0000     0.8350 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184097     6  0.4829     0.4011 0.000 0.404 0.000 NA 0.004 0.544
#> ERR184094     5  0.6437     0.0730 0.220 0.000 0.344 NA 0.416 0.004
#> ERR184058     2  0.0790     0.8995 0.000 0.968 0.000 NA 0.000 0.000
#> ERR184036     6  0.5068     0.6392 0.000 0.240 0.000 NA 0.000 0.624
#> ERR184046     2  0.0260     0.9006 0.000 0.992 0.000 NA 0.000 0.000
#> ERR184074     1  0.3224     0.7430 0.824 0.000 0.000 NA 0.004 0.040
#> ERR184048     6  0.2730     0.7091 0.000 0.192 0.000 NA 0.000 0.808

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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.


SD:skmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-skmeans-select-partition-number

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.960       0.984         0.5010 0.497   0.497
#> 3 3 0.803           0.841       0.909         0.2197 0.871   0.745
#> 4 4 0.613           0.667       0.820         0.1323 0.922   0.803
#> 5 5 0.564           0.576       0.749         0.0775 0.969   0.909
#> 6 6 0.580           0.486       0.717         0.0461 0.966   0.889

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1   0.000      0.969 1.000 0.000
#> ERR184093     2   0.000      0.993 0.000 1.000
#> ERR184051     1   0.000      0.969 1.000 0.000
#> ERR184076     1   0.000      0.969 1.000 0.000
#> ERR184043     1   0.000      0.969 1.000 0.000
#> ERR184037     1   0.000      0.969 1.000 0.000
#> ERR184059     1   0.000      0.969 1.000 0.000
#> ERR184055     1   0.000      0.969 1.000 0.000
#> ERR184065     2   0.000      0.993 0.000 1.000
#> ERR184069     2   0.000      0.993 0.000 1.000
#> ERR184040     1   0.000      0.969 1.000 0.000
#> ERR184057     2   0.000      0.993 0.000 1.000
#> ERR184082     1   0.988      0.251 0.564 0.436
#> ERR184083     2   0.000      0.993 0.000 1.000
#> ERR184039     2   0.000      0.993 0.000 1.000
#> ERR184064     1   0.000      0.969 1.000 0.000
#> ERR184081     2   0.000      0.993 0.000 1.000
#> ERR184095     2   0.000      0.993 0.000 1.000
#> ERR184079     2   0.000      0.993 0.000 1.000
#> ERR184084     1   0.000      0.969 1.000 0.000
#> ERR184068     2   0.000      0.993 0.000 1.000
#> ERR184067     2   0.000      0.993 0.000 1.000
#> ERR184071     2   0.000      0.993 0.000 1.000
#> ERR184042     1   0.000      0.969 1.000 0.000
#> ERR184063     1   0.000      0.969 1.000 0.000
#> ERR184091     2   0.000      0.993 0.000 1.000
#> ERR184061     2   0.697      0.756 0.188 0.812
#> ERR184077     2   0.000      0.993 0.000 1.000
#> ERR184062     2   0.118      0.978 0.016 0.984
#> ERR184053     2   0.000      0.993 0.000 1.000
#> ERR184088     2   0.000      0.993 0.000 1.000
#> ERR184075     2   0.000      0.993 0.000 1.000
#> ERR184041     1   0.000      0.969 1.000 0.000
#> ERR184060     2   0.000      0.993 0.000 1.000
#> ERR184035     1   0.833      0.648 0.736 0.264
#> ERR184086     2   0.000      0.993 0.000 1.000
#> ERR184080     1   0.000      0.969 1.000 0.000
#> ERR184050     2   0.000      0.993 0.000 1.000
#> ERR184047     1   0.000      0.969 1.000 0.000
#> ERR184092     2   0.000      0.993 0.000 1.000
#> ERR184072     1   0.000      0.969 1.000 0.000
#> ERR184073     1   0.000      0.969 1.000 0.000
#> ERR184066     1   0.000      0.969 1.000 0.000
#> ERR184098     2   0.000      0.993 0.000 1.000
#> ERR184044     1   0.000      0.969 1.000 0.000
#> ERR184054     1   0.000      0.969 1.000 0.000
#> ERR184085     1   0.518      0.856 0.884 0.116
#> ERR184056     2   0.000      0.993 0.000 1.000
#> ERR184052     2   0.000      0.993 0.000 1.000
#> ERR184070     2   0.000      0.993 0.000 1.000
#> ERR184096     1   0.000      0.969 1.000 0.000
#> ERR184089     2   0.000      0.993 0.000 1.000
#> ERR184049     2   0.000      0.993 0.000 1.000
#> ERR184038     1   0.000      0.969 1.000 0.000
#> ERR184087     1   0.000      0.969 1.000 0.000
#> ERR184097     2   0.000      0.993 0.000 1.000
#> ERR184094     1   0.000      0.969 1.000 0.000
#> ERR184058     2   0.000      0.993 0.000 1.000
#> ERR184036     2   0.000      0.993 0.000 1.000
#> ERR184046     2   0.000      0.993 0.000 1.000
#> ERR184074     1   0.000      0.969 1.000 0.000
#> ERR184048     2   0.000      0.993 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.4654      0.808 0.792 0.000 0.208
#> ERR184093     2  0.0892      0.969 0.020 0.980 0.000
#> ERR184051     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184076     1  0.4887      0.798 0.772 0.000 0.228
#> ERR184043     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184037     1  0.1964      0.772 0.944 0.000 0.056
#> ERR184059     3  0.3816      0.767 0.148 0.000 0.852
#> ERR184055     1  0.2796      0.788 0.908 0.000 0.092
#> ERR184065     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184069     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184040     1  0.4887      0.797 0.772 0.000 0.228
#> ERR184057     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184082     3  0.8230      0.498 0.224 0.144 0.632
#> ERR184083     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184039     2  0.0237      0.973 0.004 0.996 0.000
#> ERR184064     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184081     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184079     2  0.2066      0.947 0.060 0.940 0.000
#> ERR184084     3  0.3816      0.768 0.148 0.000 0.852
#> ERR184068     2  0.3551      0.888 0.132 0.868 0.000
#> ERR184067     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184071     2  0.0237      0.973 0.004 0.996 0.000
#> ERR184042     3  0.3816      0.768 0.148 0.000 0.852
#> ERR184063     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184091     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184061     1  0.6724      0.109 0.568 0.420 0.012
#> ERR184077     2  0.1289      0.964 0.032 0.968 0.000
#> ERR184062     2  0.4465      0.796 0.176 0.820 0.004
#> ERR184053     2  0.1163      0.965 0.028 0.972 0.000
#> ERR184088     2  0.1753      0.955 0.048 0.952 0.000
#> ERR184075     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184041     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184060     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184035     1  0.1482      0.704 0.968 0.020 0.012
#> ERR184086     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184080     1  0.2356      0.784 0.928 0.000 0.072
#> ERR184050     2  0.0237      0.973 0.004 0.996 0.000
#> ERR184047     1  0.5431      0.740 0.716 0.000 0.284
#> ERR184092     2  0.0592      0.970 0.012 0.988 0.000
#> ERR184072     1  0.3752      0.815 0.856 0.000 0.144
#> ERR184073     1  0.5327      0.757 0.728 0.000 0.272
#> ERR184066     1  0.4062      0.818 0.836 0.000 0.164
#> ERR184098     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184044     1  0.6045      0.415 0.620 0.000 0.380
#> ERR184054     1  0.4121      0.818 0.832 0.000 0.168
#> ERR184085     3  0.5580      0.699 0.256 0.008 0.736
#> ERR184056     2  0.0747      0.969 0.016 0.984 0.000
#> ERR184052     2  0.0424      0.972 0.008 0.992 0.000
#> ERR184070     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184096     1  0.5098      0.781 0.752 0.000 0.248
#> ERR184089     2  0.2301      0.931 0.004 0.936 0.060
#> ERR184049     2  0.5109      0.781 0.212 0.780 0.008
#> ERR184038     3  0.3340      0.790 0.120 0.000 0.880
#> ERR184087     3  0.0000      0.831 0.000 0.000 1.000
#> ERR184097     2  0.0592      0.970 0.012 0.988 0.000
#> ERR184094     3  0.6299     -0.163 0.476 0.000 0.524
#> ERR184058     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184036     2  0.1964      0.945 0.056 0.944 0.000
#> ERR184046     2  0.0000      0.973 0.000 1.000 0.000
#> ERR184074     1  0.4062      0.818 0.836 0.000 0.164
#> ERR184048     2  0.1964      0.951 0.056 0.944 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.2334     0.8356 0.908 0.000 0.088 0.004
#> ERR184093     2  0.3668     0.7365 0.000 0.808 0.004 0.188
#> ERR184051     3  0.0469     0.8304 0.012 0.000 0.988 0.000
#> ERR184076     1  0.2593     0.8354 0.904 0.000 0.080 0.016
#> ERR184043     3  0.0469     0.8304 0.012 0.000 0.988 0.000
#> ERR184037     1  0.3311     0.7034 0.828 0.000 0.000 0.172
#> ERR184059     3  0.4277     0.6557 0.280 0.000 0.720 0.000
#> ERR184055     1  0.4289     0.7098 0.796 0.000 0.032 0.172
#> ERR184065     2  0.2081     0.8154 0.000 0.916 0.000 0.084
#> ERR184069     2  0.0188     0.8268 0.000 0.996 0.000 0.004
#> ERR184040     1  0.2654     0.8314 0.888 0.000 0.108 0.004
#> ERR184057     2  0.0469     0.8262 0.000 0.988 0.000 0.012
#> ERR184082     4  0.7609     0.3058 0.116 0.056 0.228 0.600
#> ERR184083     2  0.1211     0.8296 0.000 0.960 0.000 0.040
#> ERR184039     2  0.2281     0.8125 0.000 0.904 0.000 0.096
#> ERR184064     3  0.0469     0.8304 0.012 0.000 0.988 0.000
#> ERR184081     2  0.0336     0.8266 0.000 0.992 0.000 0.008
#> ERR184095     2  0.0817     0.8268 0.000 0.976 0.000 0.024
#> ERR184079     2  0.5653     0.1626 0.016 0.532 0.004 0.448
#> ERR184084     3  0.4836     0.5773 0.320 0.000 0.672 0.008
#> ERR184068     4  0.5937     0.1217 0.032 0.404 0.004 0.560
#> ERR184067     2  0.1022     0.8280 0.000 0.968 0.000 0.032
#> ERR184071     2  0.2999     0.8006 0.000 0.864 0.004 0.132
#> ERR184042     3  0.4331     0.6463 0.288 0.000 0.712 0.000
#> ERR184063     3  0.0336     0.8276 0.008 0.000 0.992 0.000
#> ERR184091     2  0.1867     0.8194 0.000 0.928 0.000 0.072
#> ERR184061     4  0.8010     0.3692 0.208 0.352 0.012 0.428
#> ERR184077     2  0.4655     0.5518 0.000 0.684 0.004 0.312
#> ERR184062     2  0.7660    -0.0485 0.116 0.468 0.024 0.392
#> ERR184053     2  0.4800     0.4771 0.000 0.656 0.004 0.340
#> ERR184088     2  0.3751     0.7085 0.004 0.800 0.000 0.196
#> ERR184075     2  0.2081     0.8159 0.000 0.916 0.000 0.084
#> ERR184041     3  0.0336     0.8276 0.008 0.000 0.992 0.000
#> ERR184060     2  0.0000     0.8272 0.000 1.000 0.000 0.000
#> ERR184035     4  0.5427    -0.0354 0.444 0.004 0.008 0.544
#> ERR184086     2  0.2081     0.8159 0.000 0.916 0.000 0.084
#> ERR184080     1  0.1824     0.7802 0.936 0.000 0.004 0.060
#> ERR184050     2  0.2530     0.8094 0.000 0.888 0.000 0.112
#> ERR184047     1  0.3311     0.7915 0.828 0.000 0.172 0.000
#> ERR184092     2  0.2773     0.7854 0.000 0.880 0.004 0.116
#> ERR184072     1  0.3081     0.8254 0.888 0.000 0.064 0.048
#> ERR184073     1  0.3311     0.7933 0.828 0.000 0.172 0.000
#> ERR184066     1  0.3547     0.7972 0.864 0.000 0.064 0.072
#> ERR184098     2  0.2216     0.8179 0.000 0.908 0.000 0.092
#> ERR184044     1  0.7782     0.1345 0.424 0.000 0.312 0.264
#> ERR184054     1  0.2179     0.8331 0.924 0.000 0.064 0.012
#> ERR184085     4  0.7756    -0.1677 0.236 0.000 0.364 0.400
#> ERR184056     2  0.3024     0.7677 0.000 0.852 0.000 0.148
#> ERR184052     2  0.1474     0.8271 0.000 0.948 0.000 0.052
#> ERR184070     2  0.0188     0.8275 0.000 0.996 0.000 0.004
#> ERR184096     1  0.2760     0.8229 0.872 0.000 0.128 0.000
#> ERR184089     2  0.5051     0.6825 0.000 0.768 0.100 0.132
#> ERR184049     4  0.6237     0.1527 0.044 0.448 0.004 0.504
#> ERR184038     3  0.5170     0.6968 0.228 0.000 0.724 0.048
#> ERR184087     3  0.0469     0.8304 0.012 0.000 0.988 0.000
#> ERR184097     2  0.3257     0.7568 0.000 0.844 0.004 0.152
#> ERR184094     1  0.4888     0.2942 0.588 0.000 0.412 0.000
#> ERR184058     2  0.1302     0.8283 0.000 0.956 0.000 0.044
#> ERR184036     2  0.4533     0.6412 0.012 0.764 0.008 0.216
#> ERR184046     2  0.0921     0.8292 0.000 0.972 0.000 0.028
#> ERR184074     1  0.2443     0.8296 0.916 0.000 0.060 0.024
#> ERR184048     2  0.4776     0.4021 0.000 0.624 0.000 0.376

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.1808     0.8228 0.936 0.000 0.044 0.012 0.008
#> ERR184093     2  0.5666     0.5779 0.000 0.640 0.008 0.112 0.240
#> ERR184051     3  0.0865     0.7483 0.024 0.000 0.972 0.004 0.000
#> ERR184076     1  0.2362     0.8180 0.916 0.000 0.032 0.024 0.028
#> ERR184043     3  0.0865     0.7478 0.024 0.000 0.972 0.004 0.000
#> ERR184037     1  0.5026     0.3295 0.588 0.000 0.000 0.372 0.040
#> ERR184059     3  0.4457     0.5051 0.368 0.000 0.620 0.012 0.000
#> ERR184055     1  0.5348     0.5111 0.656 0.000 0.028 0.276 0.040
#> ERR184065     2  0.3779     0.7158 0.000 0.812 0.004 0.136 0.048
#> ERR184069     2  0.1216     0.7533 0.000 0.960 0.000 0.020 0.020
#> ERR184040     1  0.1357     0.8210 0.948 0.000 0.048 0.000 0.004
#> ERR184057     2  0.1399     0.7494 0.000 0.952 0.000 0.020 0.028
#> ERR184082     5  0.8092     0.1333 0.068 0.076 0.112 0.228 0.516
#> ERR184083     2  0.1597     0.7551 0.000 0.940 0.000 0.048 0.012
#> ERR184039     2  0.3916     0.7185 0.000 0.804 0.004 0.136 0.056
#> ERR184064     3  0.0703     0.7485 0.024 0.000 0.976 0.000 0.000
#> ERR184081     2  0.1195     0.7524 0.000 0.960 0.000 0.012 0.028
#> ERR184095     2  0.2172     0.7421 0.000 0.908 0.000 0.016 0.076
#> ERR184079     2  0.7099     0.0263 0.008 0.416 0.008 0.220 0.348
#> ERR184084     3  0.5450     0.3819 0.412 0.000 0.540 0.024 0.024
#> ERR184068     5  0.5561     0.1552 0.016 0.236 0.000 0.088 0.660
#> ERR184067     2  0.2291     0.7480 0.000 0.908 0.000 0.056 0.036
#> ERR184071     2  0.5091     0.6138 0.000 0.676 0.000 0.088 0.236
#> ERR184042     3  0.4676     0.4622 0.392 0.000 0.592 0.012 0.004
#> ERR184063     3  0.1074     0.7378 0.016 0.000 0.968 0.012 0.004
#> ERR184091     2  0.3037     0.7375 0.000 0.860 0.000 0.100 0.040
#> ERR184061     4  0.6625     0.2574 0.100 0.144 0.020 0.656 0.080
#> ERR184077     2  0.5274     0.3924 0.000 0.572 0.000 0.056 0.372
#> ERR184062     5  0.7519     0.0539 0.048 0.264 0.008 0.200 0.480
#> ERR184053     2  0.5869     0.1910 0.000 0.484 0.004 0.084 0.428
#> ERR184088     2  0.5496     0.5833 0.004 0.668 0.000 0.164 0.164
#> ERR184075     2  0.4014     0.7149 0.000 0.804 0.008 0.128 0.060
#> ERR184041     3  0.0833     0.7408 0.016 0.000 0.976 0.004 0.004
#> ERR184060     2  0.0771     0.7524 0.000 0.976 0.000 0.004 0.020
#> ERR184035     5  0.7574    -0.0126 0.296 0.024 0.012 0.260 0.408
#> ERR184086     2  0.3090     0.7402 0.000 0.860 0.004 0.104 0.032
#> ERR184080     1  0.2518     0.7807 0.896 0.000 0.008 0.080 0.016
#> ERR184050     2  0.4352     0.7004 0.000 0.772 0.008 0.160 0.060
#> ERR184047     1  0.2753     0.7779 0.856 0.000 0.136 0.008 0.000
#> ERR184092     2  0.5092     0.6346 0.000 0.708 0.008 0.092 0.192
#> ERR184072     1  0.3284     0.7908 0.864 0.000 0.028 0.080 0.028
#> ERR184073     1  0.2864     0.7808 0.852 0.000 0.136 0.012 0.000
#> ERR184066     1  0.4499     0.7149 0.788 0.000 0.028 0.076 0.108
#> ERR184098     2  0.4382     0.7116 0.000 0.772 0.004 0.140 0.084
#> ERR184044     4  0.8218     0.0267 0.340 0.004 0.208 0.340 0.108
#> ERR184054     1  0.2140     0.8151 0.924 0.000 0.024 0.040 0.012
#> ERR184085     5  0.8789    -0.0355 0.172 0.012 0.248 0.260 0.308
#> ERR184056     2  0.4799     0.6269 0.000 0.716 0.008 0.056 0.220
#> ERR184052     2  0.3176     0.7426 0.000 0.856 0.000 0.080 0.064
#> ERR184070     2  0.1626     0.7485 0.000 0.940 0.000 0.016 0.044
#> ERR184096     1  0.1892     0.8128 0.916 0.000 0.080 0.004 0.000
#> ERR184089     2  0.7057     0.4600 0.000 0.576 0.144 0.180 0.100
#> ERR184049     4  0.5887     0.1702 0.012 0.220 0.000 0.632 0.136
#> ERR184038     3  0.6401     0.4889 0.328 0.000 0.552 0.052 0.068
#> ERR184087     3  0.0865     0.7484 0.024 0.000 0.972 0.004 0.000
#> ERR184097     2  0.5001     0.5993 0.000 0.680 0.008 0.052 0.260
#> ERR184094     1  0.4184     0.5218 0.700 0.000 0.284 0.016 0.000
#> ERR184058     2  0.2388     0.7486 0.000 0.900 0.000 0.072 0.028
#> ERR184036     2  0.5938     0.2518 0.000 0.512 0.000 0.376 0.112
#> ERR184046     2  0.1211     0.7549 0.000 0.960 0.000 0.024 0.016
#> ERR184074     1  0.2438     0.8185 0.900 0.000 0.040 0.060 0.000
#> ERR184048     2  0.5942     0.2943 0.000 0.524 0.000 0.116 0.360

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.2051     0.7810 0.924 0.000 0.032 0.012 0.020 0.012
#> ERR184093     2  0.5525     0.1470 0.000 0.520 0.000 0.388 0.052 0.040
#> ERR184051     3  0.0260     0.7578 0.008 0.000 0.992 0.000 0.000 0.000
#> ERR184076     1  0.3391     0.7724 0.856 0.000 0.032 0.024 0.044 0.044
#> ERR184043     3  0.0508     0.7584 0.012 0.000 0.984 0.000 0.000 0.004
#> ERR184037     1  0.5115     0.4481 0.560 0.000 0.000 0.004 0.080 0.356
#> ERR184059     3  0.4514     0.5307 0.328 0.000 0.632 0.000 0.028 0.012
#> ERR184055     1  0.6000     0.5033 0.572 0.000 0.024 0.020 0.100 0.284
#> ERR184065     2  0.4225     0.6164 0.000 0.764 0.000 0.144 0.024 0.068
#> ERR184069     2  0.1151     0.6659 0.000 0.956 0.000 0.032 0.000 0.012
#> ERR184040     1  0.1555     0.7790 0.932 0.000 0.060 0.000 0.004 0.004
#> ERR184057     2  0.2136     0.6513 0.000 0.908 0.000 0.064 0.016 0.012
#> ERR184082     5  0.6204     0.2792 0.036 0.072 0.072 0.052 0.688 0.080
#> ERR184083     2  0.1952     0.6749 0.000 0.920 0.000 0.052 0.016 0.012
#> ERR184039     2  0.4708     0.6014 0.000 0.728 0.000 0.148 0.032 0.092
#> ERR184064     3  0.0363     0.7593 0.012 0.000 0.988 0.000 0.000 0.000
#> ERR184081     2  0.1692     0.6606 0.000 0.932 0.000 0.048 0.008 0.012
#> ERR184095     2  0.2742     0.6279 0.000 0.852 0.000 0.128 0.012 0.008
#> ERR184079     4  0.7215     0.3540 0.004 0.236 0.000 0.456 0.140 0.164
#> ERR184084     3  0.5507     0.3804 0.372 0.000 0.524 0.004 0.092 0.008
#> ERR184068     5  0.7679    -0.3144 0.004 0.192 0.004 0.300 0.348 0.152
#> ERR184067     2  0.3566     0.6297 0.000 0.812 0.000 0.104 0.008 0.076
#> ERR184071     2  0.5472     0.5383 0.000 0.676 0.000 0.136 0.096 0.092
#> ERR184042     3  0.4595     0.5441 0.320 0.000 0.636 0.004 0.032 0.008
#> ERR184063     3  0.0665     0.7445 0.004 0.000 0.980 0.000 0.008 0.008
#> ERR184091     2  0.3517     0.6470 0.000 0.824 0.000 0.104 0.024 0.048
#> ERR184061     6  0.6407     0.0763 0.088 0.096 0.004 0.116 0.052 0.644
#> ERR184077     2  0.6612    -0.1172 0.000 0.460 0.000 0.324 0.152 0.064
#> ERR184062     4  0.6749     0.3401 0.032 0.140 0.004 0.596 0.100 0.128
#> ERR184053     2  0.7066    -0.2482 0.004 0.400 0.004 0.324 0.212 0.056
#> ERR184088     2  0.6346     0.2376 0.000 0.576 0.000 0.152 0.172 0.100
#> ERR184075     2  0.4683     0.6065 0.000 0.728 0.000 0.156 0.032 0.084
#> ERR184041     3  0.0717     0.7556 0.016 0.000 0.976 0.000 0.008 0.000
#> ERR184060     2  0.1411     0.6667 0.000 0.936 0.000 0.060 0.004 0.000
#> ERR184035     5  0.6586     0.2228 0.208 0.012 0.000 0.064 0.552 0.164
#> ERR184086     2  0.3864     0.6429 0.000 0.796 0.000 0.128 0.032 0.044
#> ERR184080     1  0.4084     0.7315 0.796 0.000 0.008 0.024 0.084 0.088
#> ERR184050     2  0.5542     0.5204 0.000 0.636 0.000 0.208 0.040 0.116
#> ERR184047     1  0.3002     0.7370 0.836 0.000 0.136 0.000 0.020 0.008
#> ERR184092     2  0.4379     0.3953 0.000 0.632 0.000 0.336 0.008 0.024
#> ERR184072     1  0.4528     0.7204 0.772 0.000 0.020 0.032 0.068 0.108
#> ERR184073     1  0.3277     0.7510 0.832 0.000 0.128 0.008 0.016 0.016
#> ERR184066     1  0.5983     0.5875 0.656 0.000 0.020 0.096 0.096 0.132
#> ERR184098     2  0.4930     0.5884 0.000 0.696 0.000 0.184 0.028 0.092
#> ERR184044     6  0.8760    -0.1922 0.252 0.004 0.220 0.104 0.140 0.280
#> ERR184054     1  0.3412     0.7527 0.848 0.000 0.008 0.032 0.056 0.056
#> ERR184085     5  0.8103     0.2057 0.176 0.012 0.128 0.068 0.460 0.156
#> ERR184056     2  0.4777     0.3680 0.000 0.628 0.000 0.316 0.024 0.032
#> ERR184052     2  0.3844     0.6442 0.000 0.812 0.000 0.072 0.060 0.056
#> ERR184070     2  0.2001     0.6502 0.000 0.900 0.000 0.092 0.004 0.004
#> ERR184096     1  0.1843     0.7737 0.912 0.000 0.080 0.000 0.004 0.004
#> ERR184089     2  0.7042     0.3511 0.000 0.528 0.048 0.240 0.076 0.108
#> ERR184049     6  0.7030     0.0788 0.020 0.208 0.000 0.096 0.156 0.520
#> ERR184038     3  0.6874     0.4260 0.260 0.000 0.512 0.048 0.148 0.032
#> ERR184087     3  0.0363     0.7593 0.012 0.000 0.988 0.000 0.000 0.000
#> ERR184097     2  0.4817     0.2458 0.000 0.564 0.000 0.388 0.036 0.012
#> ERR184094     1  0.4504     0.4184 0.648 0.000 0.308 0.000 0.032 0.012
#> ERR184058     2  0.2136     0.6690 0.000 0.908 0.000 0.064 0.012 0.016
#> ERR184036     6  0.6599    -0.1089 0.008 0.396 0.000 0.124 0.052 0.420
#> ERR184046     2  0.1750     0.6720 0.000 0.932 0.000 0.040 0.012 0.016
#> ERR184074     1  0.3722     0.7726 0.820 0.000 0.048 0.008 0.024 0.100
#> ERR184048     2  0.7047    -0.0968 0.000 0.468 0.004 0.196 0.236 0.096

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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.


SD:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "pam"]
# you can also extract it by
# res = res_list["SD:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-pam-select-partition-number

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.966           0.960       0.980         0.5011 0.500   0.500
#> 3 3 0.942           0.919       0.968         0.1751 0.914   0.829
#> 4 4 0.802           0.857       0.925         0.0506 0.996   0.990
#> 5 5 0.786           0.873       0.928         0.0202 0.983   0.959
#> 6 6 0.710           0.822       0.907         0.0280 0.987   0.968

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 shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.988 1.000 0.000
#> ERR184093     2  0.0000      0.972 0.000 1.000
#> ERR184051     1  0.0000      0.988 1.000 0.000
#> ERR184076     1  0.0000      0.988 1.000 0.000
#> ERR184043     1  0.0000      0.988 1.000 0.000
#> ERR184037     1  0.0000      0.988 1.000 0.000
#> ERR184059     1  0.0000      0.988 1.000 0.000
#> ERR184055     1  0.0000      0.988 1.000 0.000
#> ERR184065     2  0.0000      0.972 0.000 1.000
#> ERR184069     2  0.0000      0.972 0.000 1.000
#> ERR184040     1  0.0000      0.988 1.000 0.000
#> ERR184057     2  0.0000      0.972 0.000 1.000
#> ERR184082     2  0.1414      0.961 0.020 0.980
#> ERR184083     2  0.0000      0.972 0.000 1.000
#> ERR184039     2  0.0000      0.972 0.000 1.000
#> ERR184064     1  0.0000      0.988 1.000 0.000
#> ERR184081     2  0.0000      0.972 0.000 1.000
#> ERR184095     2  0.0000      0.972 0.000 1.000
#> ERR184079     2  0.0000      0.972 0.000 1.000
#> ERR184084     1  0.0000      0.988 1.000 0.000
#> ERR184068     2  0.7056      0.787 0.192 0.808
#> ERR184067     2  0.0000      0.972 0.000 1.000
#> ERR184071     2  0.2948      0.938 0.052 0.948
#> ERR184042     1  0.0000      0.988 1.000 0.000
#> ERR184063     1  0.1414      0.972 0.980 0.020
#> ERR184091     2  0.0000      0.972 0.000 1.000
#> ERR184061     1  0.7453      0.724 0.788 0.212
#> ERR184077     2  0.0376      0.970 0.004 0.996
#> ERR184062     2  0.8555      0.650 0.280 0.720
#> ERR184053     2  0.3879      0.919 0.076 0.924
#> ERR184088     2  0.1184      0.963 0.016 0.984
#> ERR184075     2  0.0000      0.972 0.000 1.000
#> ERR184041     1  0.0672      0.982 0.992 0.008
#> ERR184060     2  0.0000      0.972 0.000 1.000
#> ERR184035     1  0.2603      0.947 0.956 0.044
#> ERR184086     2  0.0000      0.972 0.000 1.000
#> ERR184080     1  0.0000      0.988 1.000 0.000
#> ERR184050     2  0.0000      0.972 0.000 1.000
#> ERR184047     1  0.0000      0.988 1.000 0.000
#> ERR184092     2  0.0000      0.972 0.000 1.000
#> ERR184072     1  0.0000      0.988 1.000 0.000
#> ERR184073     1  0.0000      0.988 1.000 0.000
#> ERR184066     1  0.0000      0.988 1.000 0.000
#> ERR184098     2  0.0000      0.972 0.000 1.000
#> ERR184044     1  0.0376      0.986 0.996 0.004
#> ERR184054     1  0.0000      0.988 1.000 0.000
#> ERR184085     2  0.4815      0.893 0.104 0.896
#> ERR184056     2  0.0376      0.970 0.004 0.996
#> ERR184052     2  0.0000      0.972 0.000 1.000
#> ERR184070     2  0.0000      0.972 0.000 1.000
#> ERR184096     1  0.0000      0.988 1.000 0.000
#> ERR184089     2  0.0000      0.972 0.000 1.000
#> ERR184049     2  0.5946      0.849 0.144 0.856
#> ERR184038     1  0.0000      0.988 1.000 0.000
#> ERR184087     1  0.0000      0.988 1.000 0.000
#> ERR184097     2  0.0000      0.972 0.000 1.000
#> ERR184094     1  0.0000      0.988 1.000 0.000
#> ERR184058     2  0.0000      0.972 0.000 1.000
#> ERR184036     2  0.0000      0.972 0.000 1.000
#> ERR184046     2  0.0000      0.972 0.000 1.000
#> ERR184074     1  0.0000      0.988 1.000 0.000
#> ERR184048     2  0.3879      0.918 0.076 0.924

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184093     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184051     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184076     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184043     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184037     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184059     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184055     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184065     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184069     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184040     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184057     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184082     2  0.0747     0.9631 0.016 0.984 0.000
#> ERR184083     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184039     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184064     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184081     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184079     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184084     3  0.6309    -0.0367 0.500 0.000 0.500
#> ERR184068     2  0.4452     0.7854 0.192 0.808 0.000
#> ERR184067     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184071     2  0.1860     0.9363 0.052 0.948 0.000
#> ERR184042     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184063     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184091     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184061     1  0.4346     0.6894 0.816 0.184 0.000
#> ERR184077     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184062     2  0.5016     0.7124 0.240 0.760 0.000
#> ERR184053     2  0.2448     0.9152 0.076 0.924 0.000
#> ERR184088     2  0.0592     0.9656 0.012 0.988 0.000
#> ERR184075     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184041     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184060     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184035     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184086     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184080     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184050     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184047     1  0.6140     0.2824 0.596 0.000 0.404
#> ERR184092     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184072     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184073     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184066     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184098     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184044     1  0.0237     0.9531 0.996 0.004 0.000
#> ERR184054     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184085     2  0.1964     0.9338 0.056 0.944 0.000
#> ERR184056     2  0.0237     0.9703 0.004 0.996 0.000
#> ERR184052     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184070     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184096     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184089     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184049     2  0.3686     0.8483 0.140 0.860 0.000
#> ERR184038     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184087     3  0.0000     0.9346 0.000 0.000 1.000
#> ERR184097     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184094     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184058     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184036     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184046     2  0.0000     0.9725 0.000 1.000 0.000
#> ERR184074     1  0.0000     0.9577 1.000 0.000 0.000
#> ERR184048     2  0.2448     0.9150 0.076 0.924 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184093     2  0.1637     0.9103 0.000 0.940 0.000 0.060
#> ERR184051     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184076     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184043     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184037     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184059     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184055     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184065     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184069     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184040     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184057     2  0.2589     0.9085 0.000 0.884 0.000 0.116
#> ERR184082     2  0.2053     0.9125 0.004 0.924 0.000 0.072
#> ERR184083     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184064     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184081     2  0.2589     0.9085 0.000 0.884 0.000 0.116
#> ERR184095     2  0.0817     0.9193 0.000 0.976 0.000 0.024
#> ERR184079     2  0.2281     0.9060 0.000 0.904 0.000 0.096
#> ERR184084     3  0.5000    -0.0381 0.500 0.000 0.500 0.000
#> ERR184068     2  0.4549     0.8536 0.096 0.804 0.000 0.100
#> ERR184067     2  0.2589     0.9085 0.000 0.884 0.000 0.116
#> ERR184071     2  0.3610     0.8849 0.000 0.800 0.000 0.200
#> ERR184042     4  0.3610     0.0000 0.000 0.000 0.200 0.800
#> ERR184063     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184091     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184061     1  0.6149     0.4407 0.676 0.180 0.000 0.144
#> ERR184077     2  0.3610     0.8849 0.000 0.800 0.000 0.200
#> ERR184062     2  0.5033     0.8432 0.072 0.760 0.000 0.168
#> ERR184053     2  0.3610     0.8849 0.000 0.800 0.000 0.200
#> ERR184088     2  0.3494     0.8964 0.004 0.824 0.000 0.172
#> ERR184075     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184041     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184060     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184035     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184086     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184080     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184050     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184047     1  0.4866     0.2633 0.596 0.000 0.404 0.000
#> ERR184092     2  0.3356     0.8956 0.000 0.824 0.000 0.176
#> ERR184072     1  0.0188     0.9340 0.996 0.000 0.000 0.004
#> ERR184073     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184066     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184098     2  0.0817     0.9189 0.000 0.976 0.000 0.024
#> ERR184044     1  0.2197     0.8536 0.916 0.004 0.000 0.080
#> ERR184054     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184085     2  0.3913     0.8923 0.028 0.824 0.000 0.148
#> ERR184056     2  0.3610     0.8849 0.000 0.800 0.000 0.200
#> ERR184052     2  0.2469     0.9106 0.000 0.892 0.000 0.108
#> ERR184070     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184096     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184089     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184049     2  0.4139     0.8870 0.040 0.816 0.000 0.144
#> ERR184038     1  0.0817     0.9162 0.976 0.000 0.000 0.024
#> ERR184087     3  0.0000     0.8496 0.000 0.000 1.000 0.000
#> ERR184097     2  0.3610     0.8849 0.000 0.800 0.000 0.200
#> ERR184094     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184058     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184036     2  0.1474     0.9186 0.000 0.948 0.000 0.052
#> ERR184046     2  0.0000     0.9161 0.000 1.000 0.000 0.000
#> ERR184074     1  0.0000     0.9370 1.000 0.000 0.000 0.000
#> ERR184048     2  0.3610     0.8849 0.000 0.800 0.000 0.200

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2  p3 p4    p5
#> ERR184078     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184093     2  0.1410     0.9099 0.000 0.940 0.0  0 0.060
#> ERR184051     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184076     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184043     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184037     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184059     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184055     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184065     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184069     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184040     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184057     2  0.2230     0.9081 0.000 0.884 0.0  0 0.116
#> ERR184082     2  0.1768     0.9121 0.004 0.924 0.0  0 0.072
#> ERR184083     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184039     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184064     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184081     2  0.2230     0.9081 0.000 0.884 0.0  0 0.116
#> ERR184095     2  0.0703     0.9189 0.000 0.976 0.0  0 0.024
#> ERR184079     2  0.1965     0.9055 0.000 0.904 0.0  0 0.096
#> ERR184084     3  0.4307    -0.0283 0.500 0.000 0.5  0 0.000
#> ERR184068     2  0.3918     0.8527 0.096 0.804 0.0  0 0.100
#> ERR184067     2  0.2230     0.9081 0.000 0.884 0.0  0 0.116
#> ERR184071     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200
#> ERR184042     4  0.0000     0.0000 0.000 0.000 0.0  1 0.000
#> ERR184063     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184091     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184061     1  0.5296     0.3366 0.676 0.180 0.0  0 0.144
#> ERR184077     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200
#> ERR184062     2  0.4335     0.8434 0.072 0.760 0.0  0 0.168
#> ERR184053     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200
#> ERR184088     2  0.3010     0.8960 0.004 0.824 0.0  0 0.172
#> ERR184075     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184041     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184060     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184035     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184086     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184080     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184050     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184047     5  0.3109     0.9910 0.200 0.000 0.0  0 0.800
#> ERR184092     2  0.2891     0.8951 0.000 0.824 0.0  0 0.176
#> ERR184072     1  0.0162     0.9459 0.996 0.000 0.0  0 0.004
#> ERR184073     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184066     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184098     2  0.0703     0.9186 0.000 0.976 0.0  0 0.024
#> ERR184044     1  0.1892     0.8399 0.916 0.004 0.0  0 0.080
#> ERR184054     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184085     2  0.3370     0.8918 0.028 0.824 0.0  0 0.148
#> ERR184056     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200
#> ERR184052     2  0.2127     0.9102 0.000 0.892 0.0  0 0.108
#> ERR184070     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184096     5  0.3143     0.9911 0.204 0.000 0.0  0 0.796
#> ERR184089     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184049     2  0.3565     0.8864 0.040 0.816 0.0  0 0.144
#> ERR184038     1  0.0703     0.9225 0.976 0.000 0.0  0 0.024
#> ERR184087     3  0.0000     0.8800 0.000 0.000 1.0  0 0.000
#> ERR184097     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200
#> ERR184094     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184058     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184036     2  0.1270     0.9182 0.000 0.948 0.0  0 0.052
#> ERR184046     2  0.0000     0.9158 0.000 1.000 0.0  0 0.000
#> ERR184074     1  0.0000     0.9498 1.000 0.000 0.0  0 0.000
#> ERR184048     2  0.3109     0.8844 0.000 0.800 0.0  0 0.200

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2  p3 p4    p5    p6
#> ERR184078     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184093     2  0.2300     0.8501 0.000 0.856 0.0  0 0.144 0.000
#> ERR184051     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184076     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184043     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184037     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184059     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184055     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184065     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184069     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184040     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184057     2  0.2003     0.8760 0.000 0.884 0.0  0 0.116 0.000
#> ERR184082     2  0.1757     0.8810 0.008 0.916 0.0  0 0.076 0.000
#> ERR184083     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184039     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184064     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184081     2  0.2003     0.8760 0.000 0.884 0.0  0 0.116 0.000
#> ERR184095     2  0.0632     0.8876 0.000 0.976 0.0  0 0.024 0.000
#> ERR184079     2  0.2762     0.8316 0.000 0.804 0.0  0 0.196 0.000
#> ERR184084     1  0.3869     0.0157 0.500 0.000 0.5  0 0.000 0.000
#> ERR184068     2  0.4459     0.7678 0.096 0.700 0.0  0 0.204 0.000
#> ERR184067     2  0.2003     0.8760 0.000 0.884 0.0  0 0.116 0.000
#> ERR184071     2  0.3409     0.8050 0.000 0.700 0.0  0 0.300 0.000
#> ERR184042     4  0.0000     0.0000 0.000 0.000 0.0  1 0.000 0.000
#> ERR184063     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184091     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184061     1  0.4728     0.4188 0.680 0.176 0.0  0 0.144 0.000
#> ERR184077     2  0.3428     0.8022 0.000 0.696 0.0  0 0.304 0.000
#> ERR184062     2  0.4193     0.7843 0.044 0.684 0.0  0 0.272 0.000
#> ERR184053     2  0.3428     0.8022 0.000 0.696 0.0  0 0.304 0.000
#> ERR184088     2  0.3136     0.8453 0.004 0.768 0.0  0 0.228 0.000
#> ERR184075     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184041     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184060     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184035     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184086     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184080     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184050     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184047     5  0.3428     0.0000 0.000 0.000 0.0  0 0.696 0.304
#> ERR184092     2  0.3309     0.8162 0.000 0.720 0.0  0 0.280 0.000
#> ERR184072     1  0.0146     0.9115 0.996 0.000 0.0  0 0.004 0.000
#> ERR184073     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184066     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184098     2  0.0632     0.8872 0.000 0.976 0.0  0 0.024 0.000
#> ERR184044     1  0.2805     0.6986 0.812 0.004 0.0  0 0.184 0.000
#> ERR184054     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184085     2  0.3101     0.8604 0.032 0.820 0.0  0 0.148 0.000
#> ERR184056     2  0.3428     0.8022 0.000 0.696 0.0  0 0.304 0.000
#> ERR184052     2  0.1910     0.8780 0.000 0.892 0.0  0 0.108 0.000
#> ERR184070     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184096     6  0.0713     0.0000 0.028 0.000 0.0  0 0.000 0.972
#> ERR184089     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184049     2  0.3240     0.8573 0.040 0.812 0.0  0 0.148 0.000
#> ERR184038     1  0.0632     0.8931 0.976 0.000 0.0  0 0.024 0.000
#> ERR184087     3  0.0000     1.0000 0.000 0.000 1.0  0 0.000 0.000
#> ERR184097     2  0.3428     0.8022 0.000 0.696 0.0  0 0.304 0.000
#> ERR184094     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184058     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184036     2  0.1141     0.8862 0.000 0.948 0.0  0 0.052 0.000
#> ERR184046     2  0.0000     0.8851 0.000 1.000 0.0  0 0.000 0.000
#> ERR184074     1  0.0000     0.9145 1.000 0.000 0.0  0 0.000 0.000
#> ERR184048     2  0.2823     0.8561 0.000 0.796 0.0  0 0.204 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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.


SD:mclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "mclust"]
# you can also extract it by
# res = res_list["SD:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-mclust-select-partition-number

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.492           0.737       0.866         0.3414 0.748   0.748
#> 3 3 0.283           0.669       0.775         0.5806 0.675   0.575
#> 4 4 0.615           0.758       0.868         0.1162 0.883   0.769
#> 5 5 0.696           0.798       0.876         0.1471 0.878   0.726
#> 6 6 0.679           0.688       0.831         0.0794 0.984   0.952

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.9795      0.476 0.416 0.584
#> ERR184093     2  0.0000      0.822 0.000 1.000
#> ERR184051     1  0.3114      0.904 0.944 0.056
#> ERR184076     2  0.9795      0.476 0.416 0.584
#> ERR184043     1  0.0000      0.903 1.000 0.000
#> ERR184037     2  0.9522      0.544 0.372 0.628
#> ERR184059     1  0.7056      0.736 0.808 0.192
#> ERR184055     2  0.9522      0.544 0.372 0.628
#> ERR184065     2  0.0672      0.821 0.008 0.992
#> ERR184069     2  0.0000      0.822 0.000 1.000
#> ERR184040     2  0.9795      0.476 0.416 0.584
#> ERR184057     2  0.0000      0.822 0.000 1.000
#> ERR184082     2  0.2948      0.808 0.052 0.948
#> ERR184083     2  0.0672      0.821 0.008 0.992
#> ERR184039     2  0.0672      0.821 0.008 0.992
#> ERR184064     1  0.0000      0.903 1.000 0.000
#> ERR184081     2  0.0000      0.822 0.000 1.000
#> ERR184095     2  0.0000      0.822 0.000 1.000
#> ERR184079     2  0.0000      0.822 0.000 1.000
#> ERR184084     1  0.7453      0.683 0.788 0.212
#> ERR184068     2  0.0938      0.820 0.012 0.988
#> ERR184067     2  0.0000      0.822 0.000 1.000
#> ERR184071     2  0.0672      0.821 0.008 0.992
#> ERR184042     1  0.0000      0.903 1.000 0.000
#> ERR184063     1  0.3114      0.904 0.944 0.056
#> ERR184091     2  0.0672      0.821 0.008 0.992
#> ERR184061     2  0.3431      0.801 0.064 0.936
#> ERR184077     2  0.0000      0.822 0.000 1.000
#> ERR184062     2  0.9209      0.576 0.336 0.664
#> ERR184053     2  0.2236      0.815 0.036 0.964
#> ERR184088     2  0.0000      0.822 0.000 1.000
#> ERR184075     2  0.0672      0.821 0.008 0.992
#> ERR184041     1  0.3114      0.904 0.944 0.056
#> ERR184060     2  0.0000      0.822 0.000 1.000
#> ERR184035     2  0.7299      0.711 0.204 0.796
#> ERR184086     2  0.0672      0.821 0.008 0.992
#> ERR184080     2  0.9522      0.544 0.372 0.628
#> ERR184050     2  0.0672      0.821 0.008 0.992
#> ERR184047     2  0.9795      0.476 0.416 0.584
#> ERR184092     2  0.0000      0.822 0.000 1.000
#> ERR184072     2  0.9795      0.476 0.416 0.584
#> ERR184073     2  0.9795      0.476 0.416 0.584
#> ERR184066     2  0.9795      0.476 0.416 0.584
#> ERR184098     2  0.0672      0.821 0.008 0.992
#> ERR184044     2  0.8713      0.631 0.292 0.708
#> ERR184054     2  0.9795      0.476 0.416 0.584
#> ERR184085     2  0.7674      0.700 0.224 0.776
#> ERR184056     2  0.0000      0.822 0.000 1.000
#> ERR184052     2  0.0672      0.821 0.008 0.992
#> ERR184070     2  0.0672      0.821 0.008 0.992
#> ERR184096     2  0.9795      0.476 0.416 0.584
#> ERR184089     2  0.4690      0.785 0.100 0.900
#> ERR184049     2  0.2236      0.813 0.036 0.964
#> ERR184038     2  0.9608      0.536 0.384 0.616
#> ERR184087     1  0.0000      0.903 1.000 0.000
#> ERR184097     2  0.0000      0.822 0.000 1.000
#> ERR184094     2  0.9833      0.470 0.424 0.576
#> ERR184058     2  0.0672      0.821 0.008 0.992
#> ERR184036     2  0.1414      0.818 0.020 0.980
#> ERR184046     2  0.0672      0.821 0.008 0.992
#> ERR184074     2  0.9522      0.544 0.372 0.628
#> ERR184048     2  0.0000      0.822 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.4865     0.7585 0.832 0.136 0.032
#> ERR184093     2  0.5360     0.7250 0.220 0.768 0.012
#> ERR184051     3  0.2063     0.9519 0.044 0.008 0.948
#> ERR184076     1  0.4931     0.7577 0.828 0.140 0.032
#> ERR184043     3  0.0892     0.9561 0.020 0.000 0.980
#> ERR184037     1  0.7797     0.5178 0.608 0.320 0.072
#> ERR184059     1  0.6950     0.1412 0.508 0.016 0.476
#> ERR184055     1  0.7095     0.5728 0.660 0.292 0.048
#> ERR184065     2  0.4475     0.7171 0.072 0.864 0.064
#> ERR184069     2  0.0237     0.7432 0.004 0.996 0.000
#> ERR184040     1  0.4848     0.7594 0.836 0.128 0.036
#> ERR184057     2  0.0424     0.7444 0.008 0.992 0.000
#> ERR184082     2  0.6570     0.6062 0.308 0.668 0.024
#> ERR184083     2  0.3573     0.7420 0.120 0.876 0.004
#> ERR184039     2  0.3764     0.7308 0.068 0.892 0.040
#> ERR184064     3  0.1163     0.9600 0.028 0.000 0.972
#> ERR184081     2  0.0237     0.7432 0.004 0.996 0.000
#> ERR184095     2  0.0424     0.7417 0.008 0.992 0.000
#> ERR184079     2  0.5698     0.6722 0.252 0.736 0.012
#> ERR184084     1  0.8834     0.1089 0.464 0.116 0.420
#> ERR184068     2  0.5775     0.6718 0.260 0.728 0.012
#> ERR184067     2  0.3412     0.7439 0.124 0.876 0.000
#> ERR184071     2  0.5919     0.6866 0.276 0.712 0.012
#> ERR184042     3  0.4750     0.7962 0.216 0.000 0.784
#> ERR184063     3  0.1711     0.9590 0.032 0.008 0.960
#> ERR184091     2  0.4288     0.7207 0.068 0.872 0.060
#> ERR184061     2  0.6587     0.4817 0.424 0.568 0.008
#> ERR184077     2  0.5843     0.6754 0.252 0.732 0.016
#> ERR184062     1  0.7072    -0.2032 0.504 0.476 0.020
#> ERR184053     2  0.6262     0.6401 0.284 0.696 0.020
#> ERR184088     2  0.6102     0.6541 0.320 0.672 0.008
#> ERR184075     2  0.4660     0.7113 0.072 0.856 0.072
#> ERR184041     3  0.1525     0.9607 0.032 0.004 0.964
#> ERR184060     2  0.5812     0.6944 0.264 0.724 0.012
#> ERR184035     2  0.7366     0.3329 0.400 0.564 0.036
#> ERR184086     2  0.3875     0.7292 0.068 0.888 0.044
#> ERR184080     1  0.6506     0.6754 0.720 0.236 0.044
#> ERR184050     2  0.4658     0.7137 0.076 0.856 0.068
#> ERR184047     1  0.5955     0.6390 0.772 0.048 0.180
#> ERR184092     2  0.3715     0.7451 0.128 0.868 0.004
#> ERR184072     1  0.4848     0.7590 0.836 0.128 0.036
#> ERR184073     1  0.7317     0.6790 0.696 0.096 0.208
#> ERR184066     1  0.5295     0.7517 0.808 0.156 0.036
#> ERR184098     2  0.4087     0.7253 0.068 0.880 0.052
#> ERR184044     2  0.6696     0.5688 0.348 0.632 0.020
#> ERR184054     1  0.4995     0.7560 0.824 0.144 0.032
#> ERR184085     2  0.6541     0.5925 0.304 0.672 0.024
#> ERR184056     2  0.3459     0.7539 0.096 0.892 0.012
#> ERR184052     2  0.2680     0.7426 0.068 0.924 0.008
#> ERR184070     2  0.5465     0.6705 0.288 0.712 0.000
#> ERR184096     1  0.6490     0.6817 0.752 0.076 0.172
#> ERR184089     2  0.6271     0.6276 0.088 0.772 0.140
#> ERR184049     2  0.5956     0.6504 0.324 0.672 0.004
#> ERR184038     2  0.8665     0.0417 0.384 0.508 0.108
#> ERR184087     3  0.1289     0.9605 0.032 0.000 0.968
#> ERR184097     2  0.4390     0.7422 0.148 0.840 0.012
#> ERR184094     1  0.7056     0.5246 0.656 0.044 0.300
#> ERR184058     2  0.0000     0.7423 0.000 1.000 0.000
#> ERR184036     2  0.5244     0.7181 0.240 0.756 0.004
#> ERR184046     2  0.1031     0.7503 0.024 0.976 0.000
#> ERR184074     1  0.6337     0.6943 0.736 0.220 0.044
#> ERR184048     2  0.5659     0.6759 0.248 0.740 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.1388     0.7853 0.960 0.012 0.000 0.028
#> ERR184093     2  0.1820     0.8779 0.020 0.944 0.000 0.036
#> ERR184051     3  0.0188     0.7336 0.000 0.000 0.996 0.004
#> ERR184076     1  0.1510     0.7858 0.956 0.016 0.000 0.028
#> ERR184043     3  0.0336     0.7237 0.000 0.000 0.992 0.008
#> ERR184037     1  0.6003     0.6911 0.736 0.068 0.044 0.152
#> ERR184059     3  0.4673     0.3163 0.132 0.000 0.792 0.076
#> ERR184055     1  0.5075     0.6927 0.776 0.120 0.004 0.100
#> ERR184065     2  0.4776     0.7683 0.000 0.712 0.016 0.272
#> ERR184069     2  0.2281     0.8850 0.000 0.904 0.000 0.096
#> ERR184040     1  0.0469     0.7904 0.988 0.012 0.000 0.000
#> ERR184057     2  0.2281     0.8850 0.000 0.904 0.000 0.096
#> ERR184082     2  0.0524     0.8896 0.008 0.988 0.000 0.004
#> ERR184083     2  0.2011     0.8861 0.000 0.920 0.000 0.080
#> ERR184039     2  0.4012     0.8330 0.000 0.800 0.016 0.184
#> ERR184064     3  0.0000     0.7316 0.000 0.000 1.000 0.000
#> ERR184081     2  0.2345     0.8844 0.000 0.900 0.000 0.100
#> ERR184095     2  0.2081     0.8858 0.000 0.916 0.000 0.084
#> ERR184079     2  0.1406     0.8828 0.016 0.960 0.000 0.024
#> ERR184084     2  0.8839     0.0179 0.148 0.460 0.296 0.096
#> ERR184068     2  0.1820     0.8784 0.020 0.944 0.000 0.036
#> ERR184067     2  0.2081     0.8875 0.000 0.916 0.000 0.084
#> ERR184071     2  0.0524     0.8895 0.000 0.988 0.004 0.008
#> ERR184042     4  0.6673     0.0000 0.140 0.000 0.252 0.608
#> ERR184063     3  0.0188     0.7336 0.000 0.000 0.996 0.004
#> ERR184091     2  0.4690     0.7714 0.000 0.724 0.016 0.260
#> ERR184061     1  0.6865     0.2732 0.548 0.368 0.020 0.064
#> ERR184077     2  0.0469     0.8866 0.000 0.988 0.000 0.012
#> ERR184062     2  0.3813     0.8022 0.148 0.828 0.000 0.024
#> ERR184053     2  0.0188     0.8883 0.000 0.996 0.000 0.004
#> ERR184088     2  0.1724     0.8792 0.020 0.948 0.000 0.032
#> ERR184075     2  0.4868     0.7643 0.000 0.720 0.024 0.256
#> ERR184041     3  0.0188     0.7336 0.000 0.000 0.996 0.004
#> ERR184060     2  0.2876     0.8880 0.008 0.892 0.008 0.092
#> ERR184035     2  0.4473     0.7788 0.152 0.804 0.008 0.036
#> ERR184086     2  0.4630     0.7732 0.000 0.732 0.016 0.252
#> ERR184080     1  0.3229     0.7786 0.880 0.048 0.000 0.072
#> ERR184050     2  0.4661     0.7717 0.000 0.728 0.016 0.256
#> ERR184047     1  0.4791     0.6825 0.784 0.000 0.080 0.136
#> ERR184092     2  0.1510     0.8818 0.016 0.956 0.000 0.028
#> ERR184072     1  0.1584     0.7844 0.952 0.012 0.000 0.036
#> ERR184073     1  0.3030     0.7562 0.892 0.004 0.076 0.028
#> ERR184066     1  0.3647     0.6921 0.852 0.108 0.000 0.040
#> ERR184098     2  0.4364     0.8016 0.000 0.764 0.016 0.220
#> ERR184044     2  0.2002     0.8727 0.044 0.936 0.000 0.020
#> ERR184054     1  0.1284     0.7864 0.964 0.012 0.000 0.024
#> ERR184085     2  0.0672     0.8899 0.008 0.984 0.000 0.008
#> ERR184056     2  0.1706     0.8819 0.016 0.948 0.000 0.036
#> ERR184052     2  0.2727     0.8829 0.004 0.900 0.012 0.084
#> ERR184070     2  0.2926     0.8880 0.012 0.888 0.004 0.096
#> ERR184096     1  0.4222     0.7237 0.832 0.004 0.080 0.084
#> ERR184089     3  0.7771     0.0249 0.000 0.320 0.424 0.256
#> ERR184049     2  0.1398     0.8856 0.004 0.956 0.000 0.040
#> ERR184038     2  0.5805     0.7066 0.140 0.752 0.052 0.056
#> ERR184087     3  0.1936     0.6630 0.028 0.000 0.940 0.032
#> ERR184097     2  0.1820     0.8789 0.020 0.944 0.000 0.036
#> ERR184094     1  0.5680     0.6759 0.752 0.020 0.108 0.120
#> ERR184058     2  0.2281     0.8831 0.000 0.904 0.000 0.096
#> ERR184036     2  0.1767     0.8850 0.012 0.944 0.000 0.044
#> ERR184046     2  0.2384     0.8862 0.004 0.916 0.008 0.072
#> ERR184074     1  0.3796     0.7711 0.852 0.044 0.004 0.100
#> ERR184048     2  0.1151     0.8846 0.008 0.968 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.0451      0.813 0.988 0.004 0.000 0.008 0.000
#> ERR184093     2  0.1471      0.877 0.004 0.952 0.000 0.024 0.020
#> ERR184051     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000
#> ERR184076     1  0.0451      0.813 0.988 0.004 0.000 0.008 0.000
#> ERR184043     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.5528      0.620 0.644 0.036 0.008 0.288 0.024
#> ERR184059     3  0.4471      0.422 0.020 0.004 0.684 0.292 0.000
#> ERR184055     1  0.4034      0.765 0.812 0.080 0.000 0.096 0.012
#> ERR184065     5  0.1478      0.893 0.000 0.064 0.000 0.000 0.936
#> ERR184069     2  0.3574      0.823 0.000 0.804 0.000 0.028 0.168
#> ERR184040     1  0.0671      0.817 0.980 0.004 0.000 0.016 0.000
#> ERR184057     2  0.3535      0.827 0.000 0.808 0.000 0.028 0.164
#> ERR184082     2  0.0963      0.878 0.000 0.964 0.000 0.000 0.036
#> ERR184083     2  0.3409      0.823 0.000 0.816 0.000 0.024 0.160
#> ERR184039     5  0.3969      0.581 0.000 0.304 0.000 0.004 0.692
#> ERR184064     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.3574      0.823 0.000 0.804 0.000 0.028 0.168
#> ERR184095     2  0.3368      0.826 0.000 0.820 0.000 0.024 0.156
#> ERR184079     2  0.0510      0.879 0.000 0.984 0.000 0.016 0.000
#> ERR184084     2  0.6476      0.432 0.028 0.584 0.072 0.296 0.020
#> ERR184068     2  0.0898      0.876 0.000 0.972 0.000 0.020 0.008
#> ERR184067     2  0.2674      0.856 0.000 0.868 0.000 0.012 0.120
#> ERR184071     2  0.0865      0.880 0.000 0.972 0.000 0.004 0.024
#> ERR184042     4  0.2208      0.000 0.020 0.000 0.072 0.908 0.000
#> ERR184063     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000
#> ERR184091     5  0.1478      0.893 0.000 0.064 0.000 0.000 0.936
#> ERR184061     1  0.5623      0.387 0.604 0.324 0.000 0.024 0.048
#> ERR184077     2  0.0324      0.880 0.000 0.992 0.000 0.004 0.004
#> ERR184062     2  0.2723      0.814 0.124 0.864 0.000 0.000 0.012
#> ERR184053     2  0.0880      0.878 0.000 0.968 0.000 0.000 0.032
#> ERR184088     2  0.1372      0.875 0.004 0.956 0.000 0.024 0.016
#> ERR184075     5  0.1478      0.893 0.000 0.064 0.000 0.000 0.936
#> ERR184041     3  0.0000      0.903 0.000 0.000 1.000 0.000 0.000
#> ERR184060     2  0.3566      0.827 0.004 0.812 0.000 0.024 0.160
#> ERR184035     2  0.2581      0.850 0.048 0.904 0.000 0.020 0.028
#> ERR184086     5  0.1792      0.882 0.000 0.084 0.000 0.000 0.916
#> ERR184080     1  0.2585      0.812 0.896 0.024 0.000 0.072 0.008
#> ERR184050     5  0.1478      0.893 0.000 0.064 0.000 0.000 0.936
#> ERR184047     1  0.4213      0.648 0.680 0.000 0.012 0.308 0.000
#> ERR184092     2  0.1471      0.879 0.004 0.952 0.000 0.024 0.020
#> ERR184072     1  0.0324      0.813 0.992 0.004 0.000 0.004 0.000
#> ERR184073     1  0.1651      0.817 0.944 0.008 0.012 0.036 0.000
#> ERR184066     1  0.2077      0.749 0.908 0.084 0.000 0.000 0.008
#> ERR184098     5  0.3074      0.767 0.000 0.196 0.000 0.000 0.804
#> ERR184044     2  0.1904      0.875 0.020 0.936 0.000 0.028 0.016
#> ERR184054     1  0.0162      0.814 0.996 0.004 0.000 0.000 0.000
#> ERR184085     2  0.2124      0.874 0.020 0.924 0.000 0.012 0.044
#> ERR184056     2  0.1278      0.878 0.004 0.960 0.000 0.020 0.016
#> ERR184052     2  0.2970      0.829 0.000 0.828 0.000 0.004 0.168
#> ERR184070     2  0.3691      0.826 0.004 0.804 0.000 0.028 0.164
#> ERR184096     1  0.3563      0.738 0.780 0.000 0.012 0.208 0.000
#> ERR184089     5  0.1740      0.876 0.000 0.056 0.012 0.000 0.932
#> ERR184049     2  0.1788      0.870 0.004 0.932 0.000 0.008 0.056
#> ERR184038     2  0.4918      0.776 0.088 0.780 0.012 0.080 0.040
#> ERR184087     3  0.2074      0.804 0.000 0.000 0.896 0.104 0.000
#> ERR184097     2  0.1377      0.878 0.004 0.956 0.000 0.020 0.020
#> ERR184094     1  0.5337      0.640 0.660 0.028 0.024 0.280 0.008
#> ERR184058     2  0.3602      0.807 0.000 0.796 0.000 0.024 0.180
#> ERR184036     2  0.2158      0.870 0.008 0.920 0.000 0.020 0.052
#> ERR184046     2  0.3461      0.825 0.004 0.812 0.000 0.016 0.168
#> ERR184074     1  0.2731      0.804 0.876 0.016 0.000 0.104 0.004
#> ERR184048     2  0.0566      0.880 0.000 0.984 0.000 0.012 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.0622    0.81398 0.980 0.000 0.000 0.012 0.008 0.000
#> ERR184093     2  0.0865    0.76579 0.000 0.964 0.000 0.000 0.036 0.000
#> ERR184051     3  0.0000    0.91454 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184076     1  0.0622    0.81398 0.980 0.000 0.000 0.012 0.008 0.000
#> ERR184043     3  0.0000    0.91454 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184037     1  0.5549    0.56388 0.600 0.008 0.004 0.152 0.236 0.000
#> ERR184059     3  0.4316    0.37226 0.000 0.000 0.648 0.312 0.040 0.000
#> ERR184055     1  0.3656    0.73259 0.808 0.124 0.000 0.020 0.048 0.000
#> ERR184065     6  0.0146    0.90111 0.000 0.004 0.000 0.000 0.000 0.996
#> ERR184069     2  0.4650    0.69125 0.000 0.688 0.000 0.004 0.212 0.096
#> ERR184040     1  0.0363    0.81476 0.988 0.000 0.000 0.012 0.000 0.000
#> ERR184057     2  0.4512    0.70750 0.000 0.708 0.000 0.004 0.192 0.096
#> ERR184082     2  0.4736    0.22647 0.012 0.576 0.000 0.000 0.380 0.032
#> ERR184083     2  0.4689    0.69406 0.000 0.696 0.000 0.004 0.172 0.128
#> ERR184039     6  0.3431    0.55370 0.000 0.228 0.000 0.000 0.016 0.756
#> ERR184064     3  0.0000    0.91454 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184081     2  0.4650    0.69125 0.000 0.688 0.000 0.004 0.212 0.096
#> ERR184095     2  0.4358    0.70457 0.000 0.728 0.000 0.004 0.172 0.096
#> ERR184079     2  0.0632    0.76801 0.000 0.976 0.000 0.000 0.024 0.000
#> ERR184084     5  0.6208    0.00000 0.020 0.088 0.032 0.348 0.512 0.000
#> ERR184068     2  0.1151    0.76757 0.012 0.956 0.000 0.000 0.032 0.000
#> ERR184067     2  0.3253    0.75473 0.000 0.832 0.000 0.004 0.068 0.096
#> ERR184071     2  0.1082    0.77030 0.000 0.956 0.000 0.000 0.004 0.040
#> ERR184042     4  0.1141    0.00000 0.000 0.000 0.052 0.948 0.000 0.000
#> ERR184063     3  0.0146    0.91176 0.000 0.000 0.996 0.000 0.004 0.000
#> ERR184091     6  0.0000    0.90254 0.000 0.000 0.000 0.000 0.000 1.000
#> ERR184061     1  0.4732    0.35897 0.612 0.320 0.000 0.000 0.068 0.000
#> ERR184077     2  0.0363    0.76874 0.000 0.988 0.000 0.000 0.012 0.000
#> ERR184062     2  0.2573    0.71776 0.112 0.864 0.000 0.000 0.024 0.000
#> ERR184053     2  0.4206    0.30350 0.000 0.620 0.000 0.000 0.356 0.024
#> ERR184088     2  0.0777    0.76718 0.004 0.972 0.000 0.000 0.024 0.000
#> ERR184075     6  0.0000    0.90254 0.000 0.000 0.000 0.000 0.000 1.000
#> ERR184041     3  0.0000    0.91454 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184060     2  0.4422    0.70055 0.000 0.720 0.000 0.004 0.180 0.096
#> ERR184035     2  0.5035    0.09799 0.068 0.548 0.000 0.004 0.380 0.000
#> ERR184086     6  0.0146    0.90124 0.000 0.000 0.000 0.000 0.004 0.996
#> ERR184080     1  0.2151    0.80501 0.912 0.048 0.000 0.016 0.024 0.000
#> ERR184050     6  0.0000    0.90254 0.000 0.000 0.000 0.000 0.000 1.000
#> ERR184047     1  0.5200    0.52485 0.588 0.000 0.004 0.304 0.104 0.000
#> ERR184092     2  0.1088    0.77160 0.000 0.960 0.000 0.000 0.024 0.016
#> ERR184072     1  0.0000    0.81486 1.000 0.000 0.000 0.000 0.000 0.000
#> ERR184073     1  0.1401    0.80962 0.948 0.000 0.004 0.028 0.020 0.000
#> ERR184066     1  0.1643    0.77702 0.924 0.068 0.000 0.000 0.008 0.000
#> ERR184098     6  0.2234    0.75873 0.000 0.124 0.000 0.000 0.004 0.872
#> ERR184044     2  0.2461    0.75866 0.048 0.900 0.000 0.004 0.020 0.028
#> ERR184054     1  0.0146    0.81454 0.996 0.000 0.000 0.000 0.004 0.000
#> ERR184085     2  0.4900    0.41526 0.036 0.636 0.000 0.000 0.296 0.032
#> ERR184056     2  0.0993    0.77183 0.000 0.964 0.000 0.000 0.024 0.012
#> ERR184052     2  0.2821    0.74722 0.000 0.832 0.000 0.000 0.016 0.152
#> ERR184070     2  0.4512    0.69780 0.000 0.708 0.000 0.004 0.192 0.096
#> ERR184096     1  0.4275    0.66599 0.728 0.000 0.004 0.192 0.076 0.000
#> ERR184089     6  0.0146    0.89936 0.000 0.000 0.000 0.004 0.000 0.996
#> ERR184049     2  0.1895    0.76203 0.016 0.912 0.000 0.000 0.072 0.000
#> ERR184038     2  0.6635   -0.00264 0.132 0.464 0.000 0.036 0.348 0.020
#> ERR184087     3  0.1141    0.87081 0.000 0.000 0.948 0.052 0.000 0.000
#> ERR184097     2  0.1049    0.76674 0.008 0.960 0.000 0.000 0.032 0.000
#> ERR184094     1  0.5121    0.58391 0.632 0.004 0.008 0.268 0.088 0.000
#> ERR184058     2  0.5173    0.64100 0.000 0.636 0.000 0.004 0.172 0.188
#> ERR184036     2  0.1802    0.76378 0.012 0.916 0.000 0.000 0.072 0.000
#> ERR184046     2  0.4768    0.68375 0.000 0.688 0.000 0.004 0.168 0.140
#> ERR184074     1  0.2477    0.80089 0.896 0.048 0.000 0.024 0.032 0.000
#> ERR184048     2  0.0363    0.76871 0.000 0.988 0.000 0.000 0.012 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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.


SD:NMF

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["SD", "NMF"]
# you can also extract it by
# res = res_list["SD:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk SD-NMF-select-partition-number

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.900           0.926       0.967         0.4898 0.505   0.505
#> 3 3 0.546           0.649       0.847         0.2985 0.791   0.615
#> 4 4 0.520           0.569       0.749         0.1270 0.753   0.466
#> 5 5 0.626           0.668       0.797         0.0807 0.885   0.643
#> 6 6 0.607           0.480       0.716         0.0424 0.936   0.740

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.0000      0.978 0.000 1.000
#> ERR184093     2  0.0000      0.978 0.000 1.000
#> ERR184051     1  0.0000      0.945 1.000 0.000
#> ERR184076     2  0.0000      0.978 0.000 1.000
#> ERR184043     1  0.0000      0.945 1.000 0.000
#> ERR184037     2  0.0000      0.978 0.000 1.000
#> ERR184059     1  0.0000      0.945 1.000 0.000
#> ERR184055     2  0.0000      0.978 0.000 1.000
#> ERR184065     1  0.0000      0.945 1.000 0.000
#> ERR184069     2  0.8713      0.562 0.292 0.708
#> ERR184040     2  0.0000      0.978 0.000 1.000
#> ERR184057     2  0.0000      0.978 0.000 1.000
#> ERR184082     1  0.4690      0.873 0.900 0.100
#> ERR184083     1  0.0672      0.942 0.992 0.008
#> ERR184039     1  0.0000      0.945 1.000 0.000
#> ERR184064     1  0.0000      0.945 1.000 0.000
#> ERR184081     1  0.7815      0.722 0.768 0.232
#> ERR184095     2  0.0000      0.978 0.000 1.000
#> ERR184079     2  0.0000      0.978 0.000 1.000
#> ERR184084     1  0.1414      0.935 0.980 0.020
#> ERR184068     2  0.0000      0.978 0.000 1.000
#> ERR184067     2  0.3584      0.912 0.068 0.932
#> ERR184071     1  0.8016      0.703 0.756 0.244
#> ERR184042     1  0.0376      0.943 0.996 0.004
#> ERR184063     1  0.0000      0.945 1.000 0.000
#> ERR184091     1  0.0000      0.945 1.000 0.000
#> ERR184061     2  0.0000      0.978 0.000 1.000
#> ERR184077     2  0.0000      0.978 0.000 1.000
#> ERR184062     2  0.0000      0.978 0.000 1.000
#> ERR184053     2  0.0938      0.969 0.012 0.988
#> ERR184088     2  0.0000      0.978 0.000 1.000
#> ERR184075     1  0.0000      0.945 1.000 0.000
#> ERR184041     1  0.0000      0.945 1.000 0.000
#> ERR184060     2  0.0000      0.978 0.000 1.000
#> ERR184035     2  0.0000      0.978 0.000 1.000
#> ERR184086     1  0.0000      0.945 1.000 0.000
#> ERR184080     2  0.0000      0.978 0.000 1.000
#> ERR184050     1  0.0000      0.945 1.000 0.000
#> ERR184047     2  0.0000      0.978 0.000 1.000
#> ERR184092     2  0.0000      0.978 0.000 1.000
#> ERR184072     2  0.0000      0.978 0.000 1.000
#> ERR184073     2  0.0672      0.972 0.008 0.992
#> ERR184066     2  0.0000      0.978 0.000 1.000
#> ERR184098     1  0.0000      0.945 1.000 0.000
#> ERR184044     2  0.0672      0.972 0.008 0.992
#> ERR184054     2  0.0000      0.978 0.000 1.000
#> ERR184085     1  0.9491      0.462 0.632 0.368
#> ERR184056     2  0.0000      0.978 0.000 1.000
#> ERR184052     1  0.2603      0.919 0.956 0.044
#> ERR184070     2  0.0000      0.978 0.000 1.000
#> ERR184096     2  0.0000      0.978 0.000 1.000
#> ERR184089     1  0.0000      0.945 1.000 0.000
#> ERR184049     2  0.0938      0.968 0.012 0.988
#> ERR184038     1  0.8861      0.599 0.696 0.304
#> ERR184087     1  0.0000      0.945 1.000 0.000
#> ERR184097     2  0.0000      0.978 0.000 1.000
#> ERR184094     2  0.8955      0.519 0.312 0.688
#> ERR184058     1  0.0938      0.940 0.988 0.012
#> ERR184036     2  0.0000      0.978 0.000 1.000
#> ERR184046     1  0.0000      0.945 1.000 0.000
#> ERR184074     2  0.0000      0.978 0.000 1.000
#> ERR184048     2  0.0000      0.978 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.1031     0.8466 0.976 0.000 0.024
#> ERR184093     1  0.0237     0.8520 0.996 0.004 0.000
#> ERR184051     3  0.2261     0.7431 0.000 0.068 0.932
#> ERR184076     1  0.1529     0.8404 0.960 0.000 0.040
#> ERR184043     3  0.2261     0.7433 0.000 0.068 0.932
#> ERR184037     1  0.1411     0.8497 0.964 0.036 0.000
#> ERR184059     3  0.0475     0.7216 0.004 0.004 0.992
#> ERR184055     1  0.0424     0.8523 0.992 0.008 0.000
#> ERR184065     2  0.3038     0.6896 0.000 0.896 0.104
#> ERR184069     2  0.0592     0.7501 0.012 0.988 0.000
#> ERR184040     1  0.0237     0.8509 0.996 0.000 0.004
#> ERR184057     1  0.6309     0.2299 0.504 0.496 0.000
#> ERR184082     2  0.1643     0.7421 0.000 0.956 0.044
#> ERR184083     2  0.0424     0.7556 0.000 0.992 0.008
#> ERR184039     2  0.1964     0.7333 0.000 0.944 0.056
#> ERR184064     3  0.4452     0.7159 0.000 0.192 0.808
#> ERR184081     2  0.0000     0.7546 0.000 1.000 0.000
#> ERR184095     2  0.5988     0.1860 0.368 0.632 0.000
#> ERR184079     1  0.2066     0.8437 0.940 0.060 0.000
#> ERR184084     3  0.6516     0.1970 0.004 0.480 0.516
#> ERR184068     1  0.3412     0.8147 0.876 0.124 0.000
#> ERR184067     2  0.3482     0.6409 0.128 0.872 0.000
#> ERR184071     2  0.0829     0.7537 0.012 0.984 0.004
#> ERR184042     3  0.1529     0.7060 0.040 0.000 0.960
#> ERR184063     3  0.3941     0.7318 0.000 0.156 0.844
#> ERR184091     2  0.2448     0.7170 0.000 0.924 0.076
#> ERR184061     1  0.0592     0.8532 0.988 0.012 0.000
#> ERR184077     1  0.4121     0.7831 0.832 0.168 0.000
#> ERR184062     1  0.4178     0.7459 0.828 0.000 0.172
#> ERR184053     1  0.6309     0.2218 0.500 0.500 0.000
#> ERR184088     1  0.3619     0.8067 0.864 0.136 0.000
#> ERR184075     2  0.5948     0.2336 0.000 0.640 0.360
#> ERR184041     3  0.5327     0.6390 0.000 0.272 0.728
#> ERR184060     1  0.5497     0.6450 0.708 0.292 0.000
#> ERR184035     1  0.4178     0.7780 0.828 0.172 0.000
#> ERR184086     2  0.6267    -0.0728 0.000 0.548 0.452
#> ERR184080     1  0.0424     0.8523 0.992 0.008 0.000
#> ERR184050     2  0.6111     0.1237 0.000 0.604 0.396
#> ERR184047     1  0.5363     0.6072 0.724 0.000 0.276
#> ERR184092     1  0.1753     0.8473 0.952 0.048 0.000
#> ERR184072     1  0.1163     0.8451 0.972 0.000 0.028
#> ERR184073     1  0.4931     0.6715 0.768 0.000 0.232
#> ERR184066     1  0.2261     0.8270 0.932 0.000 0.068
#> ERR184098     2  0.6308    -0.2115 0.000 0.508 0.492
#> ERR184044     1  0.4605     0.7101 0.796 0.000 0.204
#> ERR184054     1  0.1289     0.8444 0.968 0.000 0.032
#> ERR184085     2  0.0983     0.7493 0.016 0.980 0.004
#> ERR184056     1  0.0424     0.8523 0.992 0.008 0.000
#> ERR184052     2  0.0237     0.7556 0.000 0.996 0.004
#> ERR184070     1  0.2537     0.8367 0.920 0.080 0.000
#> ERR184096     1  0.2165     0.8293 0.936 0.000 0.064
#> ERR184089     3  0.6235     0.3270 0.000 0.436 0.564
#> ERR184049     2  0.6095     0.1107 0.392 0.608 0.000
#> ERR184038     3  0.3267     0.6576 0.116 0.000 0.884
#> ERR184087     3  0.4654     0.7050 0.000 0.208 0.792
#> ERR184097     1  0.0237     0.8516 0.996 0.000 0.004
#> ERR184094     3  0.6111     0.2161 0.396 0.000 0.604
#> ERR184058     2  0.0424     0.7556 0.000 0.992 0.008
#> ERR184036     1  0.6215     0.4026 0.572 0.428 0.000
#> ERR184046     2  0.0424     0.7556 0.000 0.992 0.008
#> ERR184074     1  0.0000     0.8513 1.000 0.000 0.000
#> ERR184048     1  0.5905     0.5496 0.648 0.352 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.0927      0.726 0.976 0.008 0.000 0.016
#> ERR184093     1  0.1837      0.730 0.944 0.028 0.000 0.028
#> ERR184051     3  0.2466      0.609 0.004 0.000 0.900 0.096
#> ERR184076     1  0.0992      0.726 0.976 0.008 0.004 0.012
#> ERR184043     3  0.0817      0.685 0.000 0.000 0.976 0.024
#> ERR184037     1  0.7485      0.347 0.472 0.192 0.000 0.336
#> ERR184059     3  0.4098      0.426 0.012 0.000 0.784 0.204
#> ERR184055     1  0.5272      0.604 0.680 0.032 0.000 0.288
#> ERR184065     3  0.6350      0.546 0.000 0.364 0.564 0.072
#> ERR184069     2  0.4465      0.650 0.004 0.776 0.020 0.200
#> ERR184040     1  0.1042      0.730 0.972 0.008 0.000 0.020
#> ERR184057     2  0.4692      0.630 0.032 0.756 0.000 0.212
#> ERR184082     2  0.3752      0.692 0.056 0.872 0.036 0.036
#> ERR184083     2  0.1888      0.686 0.000 0.940 0.044 0.016
#> ERR184039     3  0.6751      0.447 0.000 0.396 0.508 0.096
#> ERR184064     3  0.1042      0.708 0.000 0.020 0.972 0.008
#> ERR184081     2  0.3398      0.686 0.000 0.872 0.060 0.068
#> ERR184095     2  0.3801      0.688 0.064 0.856 0.004 0.076
#> ERR184079     1  0.6586      0.176 0.544 0.368 0.000 0.088
#> ERR184084     2  0.7381      0.479 0.064 0.620 0.228 0.088
#> ERR184068     2  0.6011      0.197 0.480 0.480 0.000 0.040
#> ERR184067     2  0.5304      0.560 0.012 0.672 0.012 0.304
#> ERR184071     2  0.2853      0.673 0.008 0.900 0.076 0.016
#> ERR184042     4  0.5643      0.092 0.024 0.000 0.428 0.548
#> ERR184063     3  0.1576      0.672 0.000 0.004 0.948 0.048
#> ERR184091     3  0.6285      0.473 0.000 0.412 0.528 0.060
#> ERR184061     1  0.6041      0.546 0.608 0.060 0.000 0.332
#> ERR184077     2  0.5953      0.542 0.268 0.656 0.000 0.076
#> ERR184062     1  0.1929      0.703 0.940 0.000 0.036 0.024
#> ERR184053     2  0.4972      0.657 0.136 0.780 0.004 0.080
#> ERR184088     1  0.7518      0.348 0.496 0.260 0.000 0.244
#> ERR184075     3  0.5257      0.697 0.000 0.212 0.728 0.060
#> ERR184041     3  0.1211      0.719 0.000 0.040 0.960 0.000
#> ERR184060     1  0.7386      0.390 0.552 0.264 0.008 0.176
#> ERR184035     2  0.5839      0.452 0.352 0.604 0.000 0.044
#> ERR184086     3  0.4701      0.723 0.000 0.164 0.780 0.056
#> ERR184080     1  0.2593      0.726 0.904 0.016 0.000 0.080
#> ERR184050     3  0.5091      0.713 0.000 0.180 0.752 0.068
#> ERR184047     1  0.5559      0.618 0.740 0.004 0.136 0.120
#> ERR184092     1  0.4352      0.693 0.816 0.080 0.000 0.104
#> ERR184072     1  0.1443      0.729 0.960 0.008 0.004 0.028
#> ERR184073     1  0.4837      0.639 0.792 0.008 0.136 0.064
#> ERR184066     1  0.0927      0.725 0.976 0.000 0.016 0.008
#> ERR184098     3  0.4022      0.734 0.000 0.096 0.836 0.068
#> ERR184044     1  0.7196      0.442 0.568 0.020 0.104 0.308
#> ERR184054     1  0.0469      0.730 0.988 0.000 0.000 0.012
#> ERR184085     2  0.2644      0.695 0.000 0.908 0.032 0.060
#> ERR184056     1  0.1406      0.728 0.960 0.024 0.000 0.016
#> ERR184052     2  0.5522      0.480 0.000 0.716 0.204 0.080
#> ERR184070     1  0.7007      0.474 0.548 0.144 0.000 0.308
#> ERR184096     1  0.2214      0.725 0.928 0.000 0.028 0.044
#> ERR184089     3  0.3858      0.735 0.000 0.100 0.844 0.056
#> ERR184049     2  0.6860      0.404 0.084 0.564 0.012 0.340
#> ERR184038     4  0.8203      0.266 0.180 0.032 0.316 0.472
#> ERR184087     3  0.1042      0.696 0.000 0.008 0.972 0.020
#> ERR184097     1  0.1297      0.720 0.964 0.020 0.000 0.016
#> ERR184094     1  0.7783      0.131 0.468 0.008 0.328 0.196
#> ERR184058     2  0.4542      0.621 0.000 0.804 0.108 0.088
#> ERR184036     4  0.8074     -0.311 0.316 0.328 0.004 0.352
#> ERR184046     2  0.4920      0.515 0.000 0.756 0.192 0.052
#> ERR184074     1  0.4936      0.622 0.700 0.020 0.000 0.280
#> ERR184048     2  0.4713      0.641 0.172 0.776 0.000 0.052

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.1186      0.841 0.964 0.020 0.000 0.008 0.008
#> ERR184093     1  0.3287      0.815 0.848 0.008 0.008 0.012 0.124
#> ERR184051     3  0.3969      0.631 0.004 0.000 0.692 0.304 0.000
#> ERR184076     1  0.1488      0.843 0.956 0.008 0.008 0.012 0.016
#> ERR184043     3  0.3010      0.754 0.004 0.000 0.824 0.172 0.000
#> ERR184037     5  0.2511      0.715 0.088 0.016 0.000 0.004 0.892
#> ERR184059     3  0.4590      0.407 0.012 0.000 0.568 0.420 0.000
#> ERR184055     5  0.3289      0.709 0.172 0.004 0.000 0.008 0.816
#> ERR184065     3  0.2727      0.733 0.000 0.116 0.868 0.000 0.016
#> ERR184069     2  0.4622      0.318 0.000 0.548 0.012 0.000 0.440
#> ERR184040     1  0.1408      0.852 0.948 0.008 0.000 0.000 0.044
#> ERR184057     2  0.4209      0.654 0.016 0.732 0.000 0.008 0.244
#> ERR184082     2  0.2438      0.737 0.032 0.916 0.032 0.012 0.008
#> ERR184083     2  0.1492      0.736 0.000 0.948 0.040 0.004 0.008
#> ERR184039     3  0.3823      0.670 0.000 0.140 0.808 0.004 0.048
#> ERR184064     3  0.2648      0.768 0.000 0.000 0.848 0.152 0.000
#> ERR184081     2  0.4451      0.658 0.000 0.712 0.040 0.000 0.248
#> ERR184095     2  0.2804      0.724 0.020 0.892 0.004 0.016 0.068
#> ERR184079     5  0.7414      0.275 0.328 0.244 0.008 0.020 0.400
#> ERR184084     2  0.3484      0.704 0.032 0.868 0.028 0.056 0.016
#> ERR184068     2  0.5534      0.308 0.360 0.580 0.000 0.020 0.040
#> ERR184067     5  0.3826      0.493 0.008 0.236 0.004 0.000 0.752
#> ERR184071     2  0.3430      0.719 0.016 0.844 0.120 0.004 0.016
#> ERR184042     4  0.1569      0.612 0.008 0.000 0.032 0.948 0.012
#> ERR184063     3  0.3534      0.693 0.000 0.000 0.744 0.256 0.000
#> ERR184091     3  0.3039      0.703 0.000 0.152 0.836 0.000 0.012
#> ERR184061     5  0.2733      0.712 0.112 0.004 0.000 0.012 0.872
#> ERR184077     2  0.3514      0.698 0.056 0.852 0.000 0.020 0.072
#> ERR184062     1  0.1913      0.827 0.936 0.000 0.020 0.024 0.020
#> ERR184053     2  0.3519      0.701 0.040 0.848 0.000 0.020 0.092
#> ERR184088     5  0.5169      0.633 0.248 0.068 0.000 0.008 0.676
#> ERR184075     3  0.1492      0.797 0.000 0.040 0.948 0.008 0.004
#> ERR184041     3  0.1965      0.788 0.000 0.000 0.904 0.096 0.000
#> ERR184060     5  0.7565      0.243 0.368 0.136 0.064 0.008 0.424
#> ERR184035     2  0.4773      0.604 0.216 0.716 0.000 0.004 0.064
#> ERR184086     3  0.0992      0.795 0.000 0.024 0.968 0.000 0.008
#> ERR184080     1  0.4083      0.625 0.728 0.008 0.000 0.008 0.256
#> ERR184050     3  0.1828      0.785 0.000 0.032 0.936 0.004 0.028
#> ERR184047     1  0.5937      0.562 0.660 0.004 0.020 0.140 0.176
#> ERR184092     1  0.5291      0.436 0.632 0.044 0.004 0.008 0.312
#> ERR184072     1  0.2812      0.828 0.876 0.004 0.000 0.024 0.096
#> ERR184073     1  0.4773      0.728 0.744 0.004 0.024 0.036 0.192
#> ERR184066     1  0.0955      0.850 0.968 0.004 0.000 0.000 0.028
#> ERR184098     3  0.1173      0.799 0.000 0.004 0.964 0.020 0.012
#> ERR184044     5  0.7237      0.250 0.344 0.000 0.044 0.168 0.444
#> ERR184054     1  0.1522      0.852 0.944 0.000 0.000 0.012 0.044
#> ERR184085     2  0.3613      0.727 0.000 0.840 0.032 0.024 0.104
#> ERR184056     1  0.1653      0.845 0.944 0.028 0.000 0.004 0.024
#> ERR184052     2  0.6124      0.260 0.000 0.460 0.412 0.000 0.128
#> ERR184070     5  0.3376      0.723 0.108 0.032 0.000 0.012 0.848
#> ERR184096     1  0.2518      0.842 0.896 0.000 0.008 0.016 0.080
#> ERR184089     3  0.0693      0.800 0.000 0.008 0.980 0.012 0.000
#> ERR184049     5  0.2452      0.667 0.016 0.084 0.004 0.000 0.896
#> ERR184038     4  0.7139      0.587 0.260 0.124 0.048 0.552 0.016
#> ERR184087     3  0.3336      0.720 0.000 0.000 0.772 0.228 0.000
#> ERR184097     1  0.1492      0.831 0.948 0.040 0.000 0.004 0.008
#> ERR184094     5  0.6437      0.505 0.108 0.000 0.080 0.176 0.636
#> ERR184058     2  0.4847      0.628 0.000 0.692 0.240 0.000 0.068
#> ERR184036     5  0.2806      0.689 0.028 0.056 0.012 0.008 0.896
#> ERR184046     2  0.4313      0.608 0.008 0.704 0.276 0.000 0.012
#> ERR184074     5  0.3596      0.683 0.200 0.000 0.000 0.016 0.784
#> ERR184048     2  0.1597      0.733 0.048 0.940 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.1554    0.64534 0.940 0.008 0.000 0.004 0.044 0.004
#> ERR184093     5  0.6280    0.04849 0.384 0.060 0.004 0.008 0.480 0.064
#> ERR184051     3  0.3894    0.62305 0.008 0.000 0.732 0.240 0.016 0.004
#> ERR184076     1  0.1296    0.63748 0.948 0.004 0.000 0.004 0.044 0.000
#> ERR184043     3  0.2908    0.71139 0.008 0.000 0.840 0.140 0.004 0.008
#> ERR184037     6  0.2157    0.62376 0.076 0.008 0.000 0.004 0.008 0.904
#> ERR184059     3  0.4461    0.43544 0.016 0.000 0.604 0.368 0.008 0.004
#> ERR184055     6  0.3827    0.55741 0.256 0.000 0.000 0.004 0.020 0.720
#> ERR184065     3  0.3578    0.65535 0.000 0.152 0.800 0.000 0.016 0.032
#> ERR184069     6  0.4954   -0.14809 0.000 0.444 0.012 0.000 0.040 0.504
#> ERR184040     1  0.1857    0.63666 0.924 0.004 0.000 0.000 0.028 0.044
#> ERR184057     2  0.6091    0.26325 0.020 0.452 0.000 0.000 0.152 0.376
#> ERR184082     2  0.3146    0.59771 0.028 0.868 0.008 0.016 0.068 0.012
#> ERR184083     2  0.2122    0.63458 0.000 0.916 0.024 0.000 0.032 0.028
#> ERR184039     3  0.6051    0.29950 0.000 0.320 0.540 0.008 0.040 0.092
#> ERR184064     3  0.2101    0.73407 0.004 0.000 0.892 0.100 0.000 0.004
#> ERR184081     2  0.6042    0.30593 0.000 0.476 0.024 0.004 0.116 0.380
#> ERR184095     2  0.5055    0.52608 0.012 0.624 0.000 0.004 0.296 0.064
#> ERR184079     5  0.7278    0.12878 0.076 0.344 0.000 0.008 0.348 0.224
#> ERR184084     2  0.4652    0.56899 0.024 0.776 0.020 0.088 0.080 0.012
#> ERR184068     2  0.5920    0.04937 0.188 0.536 0.000 0.004 0.264 0.008
#> ERR184067     6  0.3695    0.50558 0.000 0.176 0.000 0.004 0.044 0.776
#> ERR184071     2  0.5612    0.60701 0.024 0.692 0.116 0.000 0.104 0.064
#> ERR184042     4  0.0820    0.51682 0.000 0.000 0.012 0.972 0.016 0.000
#> ERR184063     3  0.3468    0.67395 0.008 0.000 0.784 0.192 0.012 0.004
#> ERR184091     3  0.3178    0.67896 0.000 0.128 0.832 0.000 0.012 0.028
#> ERR184061     6  0.3526    0.50868 0.028 0.004 0.000 0.004 0.172 0.792
#> ERR184077     2  0.5062    0.40044 0.024 0.532 0.000 0.008 0.416 0.020
#> ERR184062     1  0.3990    0.46989 0.728 0.000 0.016 0.004 0.240 0.012
#> ERR184053     2  0.5410    0.40720 0.020 0.516 0.000 0.004 0.404 0.056
#> ERR184088     6  0.6264    0.30877 0.332 0.124 0.000 0.004 0.040 0.500
#> ERR184075     3  0.1096    0.75029 0.000 0.020 0.964 0.004 0.008 0.004
#> ERR184041     3  0.1573    0.74763 0.004 0.004 0.936 0.052 0.000 0.004
#> ERR184060     1  0.7430   -0.16577 0.400 0.172 0.036 0.004 0.052 0.336
#> ERR184035     2  0.4942    0.46840 0.180 0.704 0.000 0.000 0.052 0.064
#> ERR184086     3  0.1621    0.74786 0.000 0.016 0.944 0.008 0.020 0.012
#> ERR184080     1  0.3304    0.56158 0.816 0.004 0.000 0.000 0.040 0.140
#> ERR184050     3  0.3832    0.69345 0.000 0.044 0.820 0.008 0.080 0.048
#> ERR184047     1  0.5774    0.39872 0.644 0.000 0.016 0.140 0.032 0.168
#> ERR184092     5  0.7151    0.32271 0.288 0.080 0.000 0.000 0.364 0.268
#> ERR184072     1  0.5246   -0.00801 0.496 0.008 0.000 0.004 0.432 0.060
#> ERR184073     1  0.5909   -0.05664 0.456 0.000 0.012 0.012 0.420 0.100
#> ERR184066     1  0.2537    0.63587 0.880 0.000 0.008 0.000 0.088 0.024
#> ERR184098     3  0.1490    0.75020 0.000 0.008 0.948 0.004 0.024 0.016
#> ERR184044     6  0.7175    0.16223 0.352 0.000 0.044 0.128 0.052 0.424
#> ERR184054     1  0.3593    0.58865 0.788 0.004 0.000 0.000 0.164 0.044
#> ERR184085     2  0.3897    0.57973 0.000 0.780 0.004 0.016 0.036 0.164
#> ERR184056     1  0.2002    0.63310 0.916 0.008 0.000 0.000 0.056 0.020
#> ERR184052     3  0.7186   -0.13157 0.016 0.320 0.404 0.000 0.060 0.200
#> ERR184070     6  0.3194    0.61008 0.168 0.020 0.000 0.000 0.004 0.808
#> ERR184096     1  0.4841    0.51473 0.696 0.004 0.008 0.004 0.204 0.084
#> ERR184089     3  0.0146    0.75168 0.000 0.004 0.996 0.000 0.000 0.000
#> ERR184049     6  0.2312    0.58236 0.000 0.080 0.004 0.008 0.012 0.896
#> ERR184038     4  0.7650    0.45256 0.232 0.092 0.044 0.464 0.164 0.004
#> ERR184087     3  0.2845    0.70035 0.004 0.000 0.820 0.172 0.000 0.004
#> ERR184097     1  0.1908    0.62777 0.900 0.000 0.000 0.000 0.096 0.004
#> ERR184094     6  0.6097    0.43738 0.068 0.000 0.084 0.176 0.032 0.640
#> ERR184058     2  0.5172    0.52339 0.000 0.676 0.184 0.000 0.032 0.108
#> ERR184036     6  0.2512    0.58608 0.004 0.028 0.004 0.008 0.060 0.896
#> ERR184046     2  0.4726    0.52401 0.000 0.708 0.196 0.000 0.068 0.028
#> ERR184074     6  0.4354    0.50995 0.240 0.000 0.000 0.000 0.068 0.692
#> ERR184048     2  0.2778    0.61893 0.032 0.872 0.000 0.000 0.080 0.016

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-SD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-SD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-SD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-SD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-SD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-SD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-SD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-SD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-SD-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-SD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-SD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-SD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-SD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-SD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-SD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-SD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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.


CV:hclust**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "hclust"]
# you can also extract it by
# res = res_list["CV:hclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-hclust-select-partition-number

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.969       0.982         0.0914 0.906   0.906
#> 3 3 1.000           0.961       0.987         0.2705 0.999   0.999
#> 4 4 0.662           0.845       0.932         2.1815 0.762   0.737
#> 5 5 0.638           0.768       0.902         0.2649 0.860   0.791
#> 6 6 0.610           0.787       0.899         0.0740 0.948   0.902

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.0000      0.988 0.000 1.000
#> ERR184093     2  0.0000      0.988 0.000 1.000
#> ERR184051     2  0.3114      0.938 0.056 0.944
#> ERR184076     2  0.0000      0.988 0.000 1.000
#> ERR184043     2  0.3114      0.938 0.056 0.944
#> ERR184037     2  0.0000      0.988 0.000 1.000
#> ERR184059     2  0.3431      0.929 0.064 0.936
#> ERR184055     2  0.0000      0.988 0.000 1.000
#> ERR184065     2  0.0000      0.988 0.000 1.000
#> ERR184069     2  0.0000      0.988 0.000 1.000
#> ERR184040     2  0.2778      0.945 0.048 0.952
#> ERR184057     2  0.0000      0.988 0.000 1.000
#> ERR184082     2  0.0000      0.988 0.000 1.000
#> ERR184083     2  0.0000      0.988 0.000 1.000
#> ERR184039     2  0.0000      0.988 0.000 1.000
#> ERR184064     2  0.3114      0.938 0.056 0.944
#> ERR184081     2  0.0000      0.988 0.000 1.000
#> ERR184095     2  0.0000      0.988 0.000 1.000
#> ERR184079     2  0.0000      0.988 0.000 1.000
#> ERR184084     2  0.0000      0.988 0.000 1.000
#> ERR184068     2  0.0000      0.988 0.000 1.000
#> ERR184067     2  0.0000      0.988 0.000 1.000
#> ERR184071     2  0.0000      0.988 0.000 1.000
#> ERR184042     1  0.0000      0.709 1.000 0.000
#> ERR184063     2  0.3114      0.938 0.056 0.944
#> ERR184091     2  0.0000      0.988 0.000 1.000
#> ERR184061     2  0.0000      0.988 0.000 1.000
#> ERR184077     2  0.0000      0.988 0.000 1.000
#> ERR184062     2  0.0000      0.988 0.000 1.000
#> ERR184053     2  0.0000      0.988 0.000 1.000
#> ERR184088     2  0.0000      0.988 0.000 1.000
#> ERR184075     2  0.0000      0.988 0.000 1.000
#> ERR184041     2  0.3114      0.938 0.056 0.944
#> ERR184060     2  0.0000      0.988 0.000 1.000
#> ERR184035     2  0.0000      0.988 0.000 1.000
#> ERR184086     2  0.0000      0.988 0.000 1.000
#> ERR184080     2  0.0000      0.988 0.000 1.000
#> ERR184050     2  0.0000      0.988 0.000 1.000
#> ERR184047     1  0.8555      0.799 0.720 0.280
#> ERR184092     2  0.0000      0.988 0.000 1.000
#> ERR184072     2  0.0000      0.988 0.000 1.000
#> ERR184073     2  0.2778      0.946 0.048 0.952
#> ERR184066     2  0.0000      0.988 0.000 1.000
#> ERR184098     2  0.0000      0.988 0.000 1.000
#> ERR184044     2  0.0000      0.988 0.000 1.000
#> ERR184054     2  0.0938      0.978 0.012 0.988
#> ERR184085     2  0.0000      0.988 0.000 1.000
#> ERR184056     2  0.0000      0.988 0.000 1.000
#> ERR184052     2  0.0000      0.988 0.000 1.000
#> ERR184070     2  0.0000      0.988 0.000 1.000
#> ERR184096     1  0.8555      0.799 0.720 0.280
#> ERR184089     2  0.0000      0.988 0.000 1.000
#> ERR184049     2  0.0000      0.988 0.000 1.000
#> ERR184038     2  0.0000      0.988 0.000 1.000
#> ERR184087     2  0.3114      0.938 0.056 0.944
#> ERR184097     2  0.0000      0.988 0.000 1.000
#> ERR184094     2  0.2778      0.946 0.048 0.952
#> ERR184058     2  0.0000      0.988 0.000 1.000
#> ERR184036     2  0.0000      0.988 0.000 1.000
#> ERR184046     2  0.0000      0.988 0.000 1.000
#> ERR184074     2  0.1414      0.972 0.020 0.980
#> ERR184048     2  0.0000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> ERR184078     2  0.0000      0.986 0.000 1.000  0
#> ERR184093     2  0.0000      0.986 0.000 1.000  0
#> ERR184051     2  0.2066      0.945 0.060 0.940  0
#> ERR184076     2  0.0000      0.986 0.000 1.000  0
#> ERR184043     2  0.2625      0.924 0.084 0.916  0
#> ERR184037     2  0.0000      0.986 0.000 1.000  0
#> ERR184059     2  0.2959      0.908 0.100 0.900  0
#> ERR184055     2  0.0000      0.986 0.000 1.000  0
#> ERR184065     2  0.0000      0.986 0.000 1.000  0
#> ERR184069     2  0.0000      0.986 0.000 1.000  0
#> ERR184040     2  0.2959      0.902 0.100 0.900  0
#> ERR184057     2  0.0000      0.986 0.000 1.000  0
#> ERR184082     2  0.0000      0.986 0.000 1.000  0
#> ERR184083     2  0.0000      0.986 0.000 1.000  0
#> ERR184039     2  0.0000      0.986 0.000 1.000  0
#> ERR184064     2  0.2625      0.924 0.084 0.916  0
#> ERR184081     2  0.0000      0.986 0.000 1.000  0
#> ERR184095     2  0.0000      0.986 0.000 1.000  0
#> ERR184079     2  0.0000      0.986 0.000 1.000  0
#> ERR184084     2  0.0237      0.984 0.004 0.996  0
#> ERR184068     2  0.0000      0.986 0.000 1.000  0
#> ERR184067     2  0.0000      0.986 0.000 1.000  0
#> ERR184071     2  0.0000      0.986 0.000 1.000  0
#> ERR184042     3  0.0000      0.000 0.000 0.000  1
#> ERR184063     2  0.2066      0.945 0.060 0.940  0
#> ERR184091     2  0.0000      0.986 0.000 1.000  0
#> ERR184061     2  0.0000      0.986 0.000 1.000  0
#> ERR184077     2  0.0000      0.986 0.000 1.000  0
#> ERR184062     2  0.0000      0.986 0.000 1.000  0
#> ERR184053     2  0.0000      0.986 0.000 1.000  0
#> ERR184088     2  0.0000      0.986 0.000 1.000  0
#> ERR184075     2  0.0000      0.986 0.000 1.000  0
#> ERR184041     2  0.2066      0.945 0.060 0.940  0
#> ERR184060     2  0.0000      0.986 0.000 1.000  0
#> ERR184035     2  0.0000      0.986 0.000 1.000  0
#> ERR184086     2  0.0000      0.986 0.000 1.000  0
#> ERR184080     2  0.0000      0.986 0.000 1.000  0
#> ERR184050     2  0.0000      0.986 0.000 1.000  0
#> ERR184047     1  0.0000      1.000 1.000 0.000  0
#> ERR184092     2  0.0000      0.986 0.000 1.000  0
#> ERR184072     2  0.0000      0.986 0.000 1.000  0
#> ERR184073     2  0.1860      0.951 0.052 0.948  0
#> ERR184066     2  0.0237      0.984 0.004 0.996  0
#> ERR184098     2  0.0000      0.986 0.000 1.000  0
#> ERR184044     2  0.0000      0.986 0.000 1.000  0
#> ERR184054     2  0.0747      0.976 0.016 0.984  0
#> ERR184085     2  0.0000      0.986 0.000 1.000  0
#> ERR184056     2  0.0000      0.986 0.000 1.000  0
#> ERR184052     2  0.0000      0.986 0.000 1.000  0
#> ERR184070     2  0.0000      0.986 0.000 1.000  0
#> ERR184096     1  0.0000      1.000 1.000 0.000  0
#> ERR184089     2  0.0000      0.986 0.000 1.000  0
#> ERR184049     2  0.0000      0.986 0.000 1.000  0
#> ERR184038     2  0.0000      0.986 0.000 1.000  0
#> ERR184087     2  0.2625      0.924 0.084 0.916  0
#> ERR184097     2  0.0000      0.986 0.000 1.000  0
#> ERR184094     2  0.2448      0.931 0.076 0.924  0
#> ERR184058     2  0.0000      0.986 0.000 1.000  0
#> ERR184036     2  0.0000      0.986 0.000 1.000  0
#> ERR184046     2  0.0000      0.986 0.000 1.000  0
#> ERR184074     2  0.1031      0.972 0.024 0.976  0
#> ERR184048     2  0.0000      0.986 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR184078     2  0.3024      0.833 0.000 0.852 0.148  0
#> ERR184093     2  0.0188      0.930 0.000 0.996 0.004  0
#> ERR184051     3  0.3649      0.739 0.000 0.204 0.796  0
#> ERR184076     2  0.3172      0.816 0.000 0.840 0.160  0
#> ERR184043     3  0.1792      0.857 0.000 0.068 0.932  0
#> ERR184037     2  0.2281      0.876 0.000 0.904 0.096  0
#> ERR184059     3  0.1489      0.811 0.004 0.044 0.952  0
#> ERR184055     2  0.1940      0.894 0.000 0.924 0.076  0
#> ERR184065     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184069     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184040     2  0.6396      0.239 0.076 0.564 0.360  0
#> ERR184057     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184082     2  0.4431      0.549 0.000 0.696 0.304  0
#> ERR184083     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184039     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184064     3  0.1792      0.857 0.000 0.068 0.932  0
#> ERR184081     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184095     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184079     2  0.0817      0.923 0.000 0.976 0.024  0
#> ERR184084     2  0.4855      0.315 0.000 0.600 0.400  0
#> ERR184068     2  0.1211      0.913 0.000 0.960 0.040  0
#> ERR184067     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184071     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1
#> ERR184063     3  0.2408      0.860 0.000 0.104 0.896  0
#> ERR184091     2  0.0188      0.930 0.000 0.996 0.004  0
#> ERR184061     2  0.1211      0.921 0.000 0.960 0.040  0
#> ERR184077     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184062     2  0.0336      0.929 0.000 0.992 0.008  0
#> ERR184053     2  0.1211      0.913 0.000 0.960 0.040  0
#> ERR184088     2  0.0592      0.928 0.000 0.984 0.016  0
#> ERR184075     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184041     3  0.2281      0.863 0.000 0.096 0.904  0
#> ERR184060     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184035     2  0.3356      0.786 0.000 0.824 0.176  0
#> ERR184086     2  0.0188      0.930 0.000 0.996 0.004  0
#> ERR184080     2  0.0592      0.928 0.000 0.984 0.016  0
#> ERR184050     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184047     1  0.0000      0.989 1.000 0.000 0.000  0
#> ERR184092     2  0.0188      0.930 0.000 0.996 0.004  0
#> ERR184072     2  0.1211      0.914 0.000 0.960 0.040  0
#> ERR184073     3  0.4304      0.597 0.000 0.284 0.716  0
#> ERR184066     2  0.2408      0.867 0.000 0.896 0.104  0
#> ERR184098     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184044     2  0.1557      0.902 0.000 0.944 0.056  0
#> ERR184054     2  0.4624      0.483 0.000 0.660 0.340  0
#> ERR184085     2  0.3074      0.813 0.000 0.848 0.152  0
#> ERR184056     2  0.0336      0.929 0.000 0.992 0.008  0
#> ERR184052     2  0.0592      0.928 0.000 0.984 0.016  0
#> ERR184070     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184096     1  0.0336      0.989 0.992 0.000 0.008  0
#> ERR184089     2  0.0336      0.930 0.000 0.992 0.008  0
#> ERR184049     2  0.0592      0.928 0.000 0.984 0.016  0
#> ERR184038     2  0.0336      0.929 0.000 0.992 0.008  0
#> ERR184087     3  0.1716      0.852 0.000 0.064 0.936  0
#> ERR184097     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184094     3  0.2469      0.842 0.000 0.108 0.892  0
#> ERR184058     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184036     2  0.0707      0.928 0.000 0.980 0.020  0
#> ERR184046     2  0.0000      0.930 0.000 1.000 0.000  0
#> ERR184074     2  0.4746      0.419 0.000 0.632 0.368  0
#> ERR184048     2  0.0336      0.929 0.000 0.992 0.008  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> ERR184078     1  0.2719      0.378 0.852 0.144 0.004  0 0.000
#> ERR184093     2  0.0162      0.921 0.004 0.996 0.000  0 0.000
#> ERR184051     3  0.3039      0.658 0.000 0.192 0.808  0 0.000
#> ERR184076     1  0.1877      0.138 0.924 0.064 0.012  0 0.000
#> ERR184043     3  0.1341      0.867 0.000 0.056 0.944  0 0.000
#> ERR184037     2  0.3916      0.686 0.092 0.804 0.104  0 0.000
#> ERR184059     3  0.1124      0.833 0.004 0.036 0.960  0 0.000
#> ERR184055     2  0.3169      0.777 0.060 0.856 0.084  0 0.000
#> ERR184065     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184069     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184040     1  0.7865      0.356 0.344 0.260 0.328  0 0.068
#> ERR184057     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184082     1  0.6685      0.473 0.388 0.376 0.236  0 0.000
#> ERR184083     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184039     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184064     3  0.1341      0.867 0.000 0.056 0.944  0 0.000
#> ERR184081     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184095     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184079     2  0.0798      0.909 0.008 0.976 0.016  0 0.000
#> ERR184084     1  0.6629      0.428 0.436 0.232 0.332  0 0.000
#> ERR184068     2  0.2193      0.849 0.060 0.912 0.028  0 0.000
#> ERR184067     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184071     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000
#> ERR184063     3  0.1908      0.853 0.000 0.092 0.908  0 0.000
#> ERR184091     2  0.0162      0.921 0.000 0.996 0.004  0 0.000
#> ERR184061     2  0.1364      0.898 0.012 0.952 0.036  0 0.000
#> ERR184077     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184062     2  0.0290      0.918 0.000 0.992 0.008  0 0.000
#> ERR184053     2  0.2260      0.845 0.064 0.908 0.028  0 0.000
#> ERR184088     2  0.0566      0.917 0.004 0.984 0.012  0 0.000
#> ERR184075     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184041     3  0.1792      0.861 0.000 0.084 0.916  0 0.000
#> ERR184060     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184035     1  0.5751      0.577 0.552 0.348 0.100  0 0.000
#> ERR184086     2  0.0162      0.921 0.000 0.996 0.004  0 0.000
#> ERR184080     2  0.0566      0.917 0.004 0.984 0.012  0 0.000
#> ERR184050     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184047     5  0.0000      0.983 0.000 0.000 0.000  0 1.000
#> ERR184092     2  0.0162      0.921 0.004 0.996 0.000  0 0.000
#> ERR184072     2  0.2824      0.806 0.096 0.872 0.032  0 0.000
#> ERR184073     3  0.4496      0.478 0.056 0.216 0.728  0 0.000
#> ERR184066     2  0.3035      0.775 0.032 0.856 0.112  0 0.000
#> ERR184098     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184044     2  0.1628      0.870 0.008 0.936 0.056  0 0.000
#> ERR184054     2  0.6790     -0.581 0.300 0.384 0.316  0 0.000
#> ERR184085     2  0.4808      0.498 0.136 0.728 0.136  0 0.000
#> ERR184056     2  0.0324      0.919 0.004 0.992 0.004  0 0.000
#> ERR184052     2  0.0566      0.917 0.004 0.984 0.012  0 0.000
#> ERR184070     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184096     5  0.0510      0.983 0.016 0.000 0.000  0 0.984
#> ERR184089     2  0.0290      0.920 0.000 0.992 0.008  0 0.000
#> ERR184049     2  0.0566      0.917 0.004 0.984 0.012  0 0.000
#> ERR184038     2  0.0290      0.918 0.000 0.992 0.008  0 0.000
#> ERR184087     3  0.1270      0.863 0.000 0.052 0.948  0 0.000
#> ERR184097     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184094     3  0.2344      0.842 0.032 0.064 0.904  0 0.000
#> ERR184058     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184036     2  0.0671      0.917 0.004 0.980 0.016  0 0.000
#> ERR184046     2  0.0000      0.922 0.000 1.000 0.000  0 0.000
#> ERR184074     2  0.6799     -0.601 0.296 0.372 0.332  0 0.000
#> ERR184048     2  0.0324      0.919 0.004 0.992 0.004  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.4575     -0.297 0.600 0.048 0.000  0 0.000 0.352
#> ERR184093     2  0.0146      0.948 0.000 0.996 0.000  0 0.000 0.004
#> ERR184051     3  0.2912      0.640 0.012 0.172 0.816  0 0.000 0.000
#> ERR184076     6  0.2237      0.000 0.080 0.020 0.004  0 0.000 0.896
#> ERR184043     3  0.1007      0.841 0.000 0.044 0.956  0 0.000 0.000
#> ERR184037     2  0.4410      0.608 0.176 0.740 0.056  0 0.000 0.028
#> ERR184059     3  0.2775      0.732 0.052 0.016 0.876  0 0.000 0.056
#> ERR184055     2  0.3649      0.741 0.136 0.804 0.040  0 0.000 0.020
#> ERR184065     2  0.0363      0.945 0.000 0.988 0.012  0 0.000 0.000
#> ERR184069     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184040     1  0.7039      0.362 0.484 0.132 0.292  0 0.048 0.044
#> ERR184057     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184082     1  0.5980      0.451 0.496 0.288 0.208  0 0.000 0.008
#> ERR184083     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184039     2  0.0363      0.945 0.000 0.988 0.012  0 0.000 0.000
#> ERR184064     3  0.1007      0.841 0.000 0.044 0.956  0 0.000 0.000
#> ERR184081     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184095     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184079     2  0.0951      0.932 0.020 0.968 0.008  0 0.000 0.004
#> ERR184084     1  0.5249      0.305 0.592 0.100 0.300  0 0.000 0.008
#> ERR184068     2  0.2473      0.839 0.104 0.876 0.008  0 0.000 0.012
#> ERR184067     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184071     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000 0.000
#> ERR184063     3  0.1610      0.828 0.000 0.084 0.916  0 0.000 0.000
#> ERR184091     2  0.0146      0.948 0.000 0.996 0.004  0 0.000 0.000
#> ERR184061     2  0.1642      0.914 0.032 0.936 0.028  0 0.000 0.004
#> ERR184077     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184062     2  0.0405      0.944 0.004 0.988 0.008  0 0.000 0.000
#> ERR184053     2  0.2473      0.839 0.104 0.876 0.008  0 0.000 0.012
#> ERR184088     2  0.0665      0.943 0.008 0.980 0.008  0 0.000 0.004
#> ERR184075     2  0.0363      0.945 0.000 0.988 0.012  0 0.000 0.000
#> ERR184041     3  0.1501      0.835 0.000 0.076 0.924  0 0.000 0.000
#> ERR184060     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184035     1  0.4331      0.413 0.728 0.208 0.040  0 0.000 0.024
#> ERR184086     2  0.0146      0.948 0.000 0.996 0.004  0 0.000 0.000
#> ERR184080     2  0.0665      0.943 0.008 0.980 0.008  0 0.000 0.004
#> ERR184050     2  0.0363      0.945 0.000 0.988 0.012  0 0.000 0.000
#> ERR184047     5  0.0000      0.939 0.000 0.000 0.000  0 1.000 0.000
#> ERR184092     2  0.0146      0.948 0.000 0.996 0.000  0 0.000 0.004
#> ERR184072     2  0.3515      0.702 0.192 0.780 0.012  0 0.000 0.016
#> ERR184073     3  0.4699      0.446 0.100 0.184 0.704  0 0.000 0.012
#> ERR184066     2  0.3321      0.778 0.072 0.832 0.088  0 0.000 0.008
#> ERR184098     2  0.0260      0.947 0.000 0.992 0.008  0 0.000 0.000
#> ERR184044     2  0.1657      0.893 0.016 0.928 0.056  0 0.000 0.000
#> ERR184054     1  0.6818      0.445 0.380 0.300 0.276  0 0.000 0.044
#> ERR184085     2  0.4742      0.465 0.184 0.688 0.124  0 0.000 0.004
#> ERR184056     2  0.0291      0.946 0.000 0.992 0.004  0 0.000 0.004
#> ERR184052     2  0.0551      0.945 0.004 0.984 0.008  0 0.000 0.004
#> ERR184070     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184096     5  0.1708      0.939 0.040 0.000 0.004  0 0.932 0.024
#> ERR184089     2  0.0363      0.945 0.000 0.988 0.012  0 0.000 0.000
#> ERR184049     2  0.0665      0.943 0.008 0.980 0.008  0 0.000 0.004
#> ERR184038     2  0.0405      0.944 0.004 0.988 0.008  0 0.000 0.000
#> ERR184087     3  0.0937      0.837 0.000 0.040 0.960  0 0.000 0.000
#> ERR184097     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184094     3  0.2556      0.799 0.052 0.048 0.888  0 0.000 0.012
#> ERR184058     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184036     2  0.0767      0.943 0.008 0.976 0.012  0 0.000 0.004
#> ERR184046     2  0.0000      0.949 0.000 1.000 0.000  0 0.000 0.000
#> ERR184074     1  0.6617      0.460 0.432 0.248 0.284  0 0.000 0.036
#> ERR184048     2  0.0291      0.946 0.000 0.992 0.004  0 0.000 0.004

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

plot of chunk tab-CV-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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.


CV:kmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "kmeans"]
# you can also extract it by
# res = res_list["CV:kmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-kmeans-select-partition-number

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.965           0.912       0.967         0.4509 0.556   0.556
#> 3 3 0.759           0.811       0.888         0.2657 0.778   0.621
#> 4 4 0.843           0.857       0.924         0.0712 0.959   0.897
#> 5 5 0.846           0.848       0.924         0.0385 0.999   0.997
#> 6 6 0.835           0.770       0.896         0.0422 0.973   0.928

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.965 1.000 0.000
#> ERR184093     2  0.0000      0.963 0.000 1.000
#> ERR184051     1  0.0000      0.965 1.000 0.000
#> ERR184076     1  0.0000      0.965 1.000 0.000
#> ERR184043     1  0.0000      0.965 1.000 0.000
#> ERR184037     2  0.9970      0.121 0.468 0.532
#> ERR184059     1  0.0000      0.965 1.000 0.000
#> ERR184055     2  0.2948      0.921 0.052 0.948
#> ERR184065     2  0.0000      0.963 0.000 1.000
#> ERR184069     2  0.0000      0.963 0.000 1.000
#> ERR184040     1  0.0000      0.965 1.000 0.000
#> ERR184057     2  0.0000      0.963 0.000 1.000
#> ERR184082     2  0.9970      0.120 0.468 0.532
#> ERR184083     2  0.0000      0.963 0.000 1.000
#> ERR184039     2  0.0000      0.963 0.000 1.000
#> ERR184064     1  0.0000      0.965 1.000 0.000
#> ERR184081     2  0.0000      0.963 0.000 1.000
#> ERR184095     2  0.0000      0.963 0.000 1.000
#> ERR184079     2  0.0000      0.963 0.000 1.000
#> ERR184084     1  0.0000      0.965 1.000 0.000
#> ERR184068     2  0.0000      0.963 0.000 1.000
#> ERR184067     2  0.0000      0.963 0.000 1.000
#> ERR184071     2  0.0000      0.963 0.000 1.000
#> ERR184042     1  0.0000      0.965 1.000 0.000
#> ERR184063     1  0.0000      0.965 1.000 0.000
#> ERR184091     2  0.0000      0.963 0.000 1.000
#> ERR184061     2  0.0000      0.963 0.000 1.000
#> ERR184077     2  0.0000      0.963 0.000 1.000
#> ERR184062     2  0.0000      0.963 0.000 1.000
#> ERR184053     2  0.0000      0.963 0.000 1.000
#> ERR184088     2  0.0000      0.963 0.000 1.000
#> ERR184075     2  0.0000      0.963 0.000 1.000
#> ERR184041     1  0.0000      0.965 1.000 0.000
#> ERR184060     2  0.0000      0.963 0.000 1.000
#> ERR184035     1  0.7139      0.733 0.804 0.196
#> ERR184086     2  0.0000      0.963 0.000 1.000
#> ERR184080     2  0.8081      0.665 0.248 0.752
#> ERR184050     2  0.0000      0.963 0.000 1.000
#> ERR184047     1  0.0000      0.965 1.000 0.000
#> ERR184092     2  0.0000      0.963 0.000 1.000
#> ERR184072     2  0.3584      0.905 0.068 0.932
#> ERR184073     1  0.0000      0.965 1.000 0.000
#> ERR184066     2  0.2948      0.921 0.052 0.948
#> ERR184098     2  0.0000      0.963 0.000 1.000
#> ERR184044     2  0.0000      0.963 0.000 1.000
#> ERR184054     1  0.0000      0.965 1.000 0.000
#> ERR184085     1  0.9833      0.220 0.576 0.424
#> ERR184056     2  0.0000      0.963 0.000 1.000
#> ERR184052     2  0.0000      0.963 0.000 1.000
#> ERR184070     2  0.0000      0.963 0.000 1.000
#> ERR184096     1  0.0000      0.965 1.000 0.000
#> ERR184089     2  0.0000      0.963 0.000 1.000
#> ERR184049     2  0.0000      0.963 0.000 1.000
#> ERR184038     2  0.4022      0.893 0.080 0.920
#> ERR184087     1  0.0000      0.965 1.000 0.000
#> ERR184097     2  0.0000      0.963 0.000 1.000
#> ERR184094     1  0.0000      0.965 1.000 0.000
#> ERR184058     2  0.0000      0.963 0.000 1.000
#> ERR184036     2  0.0000      0.963 0.000 1.000
#> ERR184046     2  0.0000      0.963 0.000 1.000
#> ERR184074     1  0.0376      0.961 0.996 0.004
#> ERR184048     2  0.0000      0.963 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000      0.660 1.000 0.000 0.000
#> ERR184093     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184051     3  0.6095      0.754 0.392 0.000 0.608
#> ERR184076     1  0.0000      0.660 1.000 0.000 0.000
#> ERR184043     3  0.5706      0.804 0.320 0.000 0.680
#> ERR184037     1  0.2066      0.685 0.940 0.060 0.000
#> ERR184059     3  0.5431      0.801 0.284 0.000 0.716
#> ERR184055     1  0.4346      0.644 0.816 0.184 0.000
#> ERR184065     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184069     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184040     1  0.0000      0.660 1.000 0.000 0.000
#> ERR184057     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184082     1  0.6977      0.483 0.712 0.076 0.212
#> ERR184083     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184039     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184064     3  0.5706      0.804 0.320 0.000 0.680
#> ERR184081     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184079     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184084     3  0.5926      0.792 0.356 0.000 0.644
#> ERR184068     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184067     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184071     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184042     3  0.0424      0.600 0.008 0.000 0.992
#> ERR184063     3  0.6095      0.754 0.392 0.000 0.608
#> ERR184091     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184061     1  0.6204      0.433 0.576 0.424 0.000
#> ERR184077     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184062     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184053     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184088     2  0.0592      0.965 0.012 0.988 0.000
#> ERR184075     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184041     3  0.6095      0.754 0.392 0.000 0.608
#> ERR184060     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184035     1  0.0661      0.666 0.988 0.008 0.004
#> ERR184086     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184080     1  0.2066      0.685 0.940 0.060 0.000
#> ERR184050     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184047     3  0.5760      0.502 0.328 0.000 0.672
#> ERR184092     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184072     1  0.5835      0.544 0.660 0.340 0.000
#> ERR184073     3  0.6252      0.707 0.444 0.000 0.556
#> ERR184066     1  0.5678      0.564 0.684 0.316 0.000
#> ERR184098     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184044     2  0.3412      0.818 0.124 0.876 0.000
#> ERR184054     1  0.0000      0.660 1.000 0.000 0.000
#> ERR184085     1  0.6541      0.456 0.732 0.056 0.212
#> ERR184056     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184052     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184070     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184096     3  0.5926      0.477 0.356 0.000 0.644
#> ERR184089     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184049     2  0.6286     -0.120 0.464 0.536 0.000
#> ERR184038     1  0.5956      0.553 0.672 0.324 0.004
#> ERR184087     3  0.5397      0.801 0.280 0.000 0.720
#> ERR184097     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184094     3  0.5431      0.801 0.284 0.000 0.716
#> ERR184058     2  0.0237      0.975 0.000 0.996 0.004
#> ERR184036     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184046     2  0.0000      0.977 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.660 1.000 0.000 0.000
#> ERR184048     2  0.0000      0.977 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.1489      0.684 0.952 0.000 0.004 0.044
#> ERR184093     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184051     3  0.2197      0.902 0.048 0.000 0.928 0.024
#> ERR184076     1  0.1489      0.684 0.952 0.000 0.004 0.044
#> ERR184043     3  0.1118      0.911 0.036 0.000 0.964 0.000
#> ERR184037     1  0.0469      0.711 0.988 0.000 0.012 0.000
#> ERR184059     3  0.1022      0.908 0.032 0.000 0.968 0.000
#> ERR184055     1  0.3367      0.697 0.876 0.092 0.012 0.020
#> ERR184065     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184069     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184040     1  0.1677      0.683 0.948 0.000 0.012 0.040
#> ERR184057     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184082     1  0.5876      0.490 0.660 0.012 0.288 0.040
#> ERR184083     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184064     3  0.1118      0.911 0.036 0.000 0.964 0.000
#> ERR184081     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184095     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184079     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184084     3  0.2662      0.862 0.084 0.000 0.900 0.016
#> ERR184068     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184067     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184071     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184042     4  0.2704      0.641 0.000 0.000 0.124 0.876
#> ERR184063     3  0.2399      0.900 0.048 0.000 0.920 0.032
#> ERR184091     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184061     1  0.5191      0.550 0.684 0.292 0.004 0.020
#> ERR184077     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184062     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184053     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184088     2  0.0921      0.966 0.028 0.972 0.000 0.000
#> ERR184075     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184041     3  0.2399      0.900 0.048 0.000 0.920 0.032
#> ERR184060     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184035     1  0.1284      0.706 0.964 0.000 0.012 0.024
#> ERR184086     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184080     1  0.0469      0.711 0.988 0.000 0.012 0.000
#> ERR184050     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184047     4  0.6664      0.797 0.232 0.000 0.152 0.616
#> ERR184092     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184072     1  0.4092      0.651 0.800 0.184 0.008 0.008
#> ERR184073     3  0.5217      0.375 0.380 0.000 0.608 0.012
#> ERR184066     1  0.4773      0.625 0.756 0.216 0.012 0.016
#> ERR184098     2  0.0336      0.987 0.000 0.992 0.000 0.008
#> ERR184044     2  0.3266      0.831 0.108 0.868 0.000 0.024
#> ERR184054     1  0.0469      0.711 0.988 0.000 0.012 0.000
#> ERR184085     1  0.5876      0.496 0.660 0.012 0.288 0.040
#> ERR184056     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184052     2  0.0895      0.972 0.004 0.976 0.000 0.020
#> ERR184070     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184096     4  0.6547      0.792 0.260 0.000 0.124 0.616
#> ERR184089     2  0.0817      0.976 0.000 0.976 0.000 0.024
#> ERR184049     1  0.5657      0.358 0.540 0.436 0.000 0.024
#> ERR184038     1  0.5603      0.515 0.644 0.324 0.008 0.024
#> ERR184087     3  0.1118      0.911 0.036 0.000 0.964 0.000
#> ERR184097     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184094     3  0.1118      0.911 0.036 0.000 0.964 0.000
#> ERR184058     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184036     2  0.0188      0.988 0.004 0.996 0.000 0.000
#> ERR184046     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> ERR184074     1  0.0469      0.711 0.988 0.000 0.012 0.000
#> ERR184048     2  0.0000      0.991 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.2504      0.736 0.896 0.000 0.000 0.040 0.064
#> ERR184093     2  0.0579      0.976 0.000 0.984 0.000 0.008 0.008
#> ERR184051     3  0.1195      0.866 0.012 0.000 0.960 0.000 0.028
#> ERR184076     1  0.2438      0.739 0.900 0.000 0.000 0.040 0.060
#> ERR184043     3  0.0000      0.874 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.0162      0.771 0.996 0.000 0.000 0.004 0.000
#> ERR184059     3  0.1124      0.863 0.000 0.000 0.960 0.004 0.036
#> ERR184055     1  0.2180      0.768 0.924 0.024 0.000 0.020 0.032
#> ERR184065     2  0.1195      0.969 0.000 0.960 0.000 0.012 0.028
#> ERR184069     2  0.0162      0.977 0.000 0.996 0.000 0.004 0.000
#> ERR184040     1  0.2615      0.728 0.892 0.000 0.008 0.020 0.080
#> ERR184057     2  0.0162      0.977 0.000 0.996 0.000 0.004 0.000
#> ERR184082     1  0.6560      0.509 0.588 0.004 0.252 0.120 0.036
#> ERR184083     2  0.0566      0.975 0.000 0.984 0.000 0.004 0.012
#> ERR184039     2  0.1195      0.969 0.000 0.960 0.000 0.012 0.028
#> ERR184064     3  0.0000      0.874 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.0162      0.977 0.000 0.996 0.000 0.004 0.000
#> ERR184095     2  0.0162      0.977 0.000 0.996 0.000 0.004 0.000
#> ERR184079     2  0.0451      0.976 0.000 0.988 0.000 0.008 0.004
#> ERR184084     3  0.4163      0.750 0.056 0.000 0.816 0.088 0.040
#> ERR184068     2  0.1310      0.965 0.000 0.956 0.000 0.024 0.020
#> ERR184067     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> ERR184071     2  0.0566      0.976 0.000 0.984 0.000 0.012 0.004
#> ERR184042     4  0.3081      0.000 0.000 0.000 0.012 0.832 0.156
#> ERR184063     3  0.1195      0.866 0.012 0.000 0.960 0.000 0.028
#> ERR184091     2  0.1195      0.969 0.000 0.960 0.000 0.012 0.028
#> ERR184061     1  0.4787      0.650 0.744 0.184 0.000 0.032 0.040
#> ERR184077     2  0.0290      0.975 0.000 0.992 0.000 0.008 0.000
#> ERR184062     2  0.0451      0.976 0.000 0.988 0.000 0.008 0.004
#> ERR184053     2  0.0290      0.975 0.000 0.992 0.000 0.008 0.000
#> ERR184088     2  0.1018      0.963 0.016 0.968 0.000 0.016 0.000
#> ERR184075     2  0.1195      0.969 0.000 0.960 0.000 0.012 0.028
#> ERR184041     3  0.1281      0.865 0.012 0.000 0.956 0.000 0.032
#> ERR184060     2  0.0324      0.976 0.000 0.992 0.000 0.004 0.004
#> ERR184035     1  0.2813      0.737 0.868 0.000 0.000 0.108 0.024
#> ERR184086     2  0.0992      0.971 0.000 0.968 0.000 0.008 0.024
#> ERR184080     1  0.0162      0.771 0.996 0.000 0.000 0.000 0.004
#> ERR184050     2  0.1195      0.968 0.000 0.960 0.000 0.012 0.028
#> ERR184047     5  0.2230      0.987 0.044 0.000 0.044 0.000 0.912
#> ERR184092     2  0.0290      0.975 0.000 0.992 0.000 0.008 0.000
#> ERR184072     1  0.3584      0.717 0.828 0.132 0.000 0.028 0.012
#> ERR184073     3  0.5131      0.140 0.436 0.000 0.532 0.008 0.024
#> ERR184066     1  0.3204      0.742 0.860 0.100 0.000 0.016 0.024
#> ERR184098     2  0.1082      0.969 0.000 0.964 0.000 0.008 0.028
#> ERR184044     2  0.3850      0.798 0.116 0.824 0.000 0.028 0.032
#> ERR184054     1  0.0162      0.771 0.996 0.000 0.000 0.000 0.004
#> ERR184085     1  0.6330      0.563 0.632 0.004 0.212 0.108 0.044
#> ERR184056     2  0.0404      0.976 0.000 0.988 0.000 0.012 0.000
#> ERR184052     2  0.1934      0.937 0.008 0.932 0.000 0.020 0.040
#> ERR184070     2  0.0162      0.977 0.000 0.996 0.000 0.004 0.000
#> ERR184096     5  0.2228      0.987 0.048 0.000 0.040 0.000 0.912
#> ERR184089     2  0.1522      0.958 0.000 0.944 0.000 0.012 0.044
#> ERR184049     1  0.5808      0.365 0.552 0.376 0.000 0.032 0.040
#> ERR184038     1  0.5161      0.540 0.668 0.272 0.000 0.020 0.040
#> ERR184087     3  0.0000      0.874 0.000 0.000 1.000 0.000 0.000
#> ERR184097     2  0.0290      0.975 0.000 0.992 0.000 0.008 0.000
#> ERR184094     3  0.1285      0.861 0.004 0.000 0.956 0.004 0.036
#> ERR184058     2  0.1106      0.971 0.000 0.964 0.000 0.012 0.024
#> ERR184036     2  0.0693      0.974 0.000 0.980 0.000 0.012 0.008
#> ERR184046     2  0.0566      0.975 0.000 0.984 0.000 0.004 0.012
#> ERR184074     1  0.0000      0.771 1.000 0.000 0.000 0.000 0.000
#> ERR184048     2  0.0290      0.975 0.000 0.992 0.000 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     6  0.4474     0.9510 0.360 0.000 0.000 0.012 0.020 0.608
#> ERR184093     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184051     3  0.0000     0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184076     6  0.4418     0.9510 0.368 0.000 0.000 0.012 0.016 0.604
#> ERR184043     3  0.0146     0.9127 0.000 0.000 0.996 0.000 0.004 0.000
#> ERR184037     1  0.1753     0.5278 0.912 0.000 0.004 0.000 0.000 0.084
#> ERR184059     3  0.2474     0.8560 0.000 0.000 0.880 0.000 0.080 0.040
#> ERR184055     1  0.1226     0.5491 0.952 0.004 0.004 0.000 0.000 0.040
#> ERR184065     2  0.1340     0.9456 0.000 0.948 0.000 0.008 0.004 0.040
#> ERR184069     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184040     1  0.5145    -0.4054 0.572 0.000 0.004 0.000 0.088 0.336
#> ERR184057     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184082     1  0.5478     0.2889 0.512 0.000 0.136 0.000 0.000 0.352
#> ERR184083     2  0.0260     0.9581 0.000 0.992 0.000 0.000 0.000 0.008
#> ERR184039     2  0.1872     0.9352 0.004 0.920 0.000 0.008 0.004 0.064
#> ERR184064     3  0.0146     0.9127 0.000 0.000 0.996 0.000 0.004 0.000
#> ERR184081     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184095     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184079     2  0.0260     0.9583 0.008 0.992 0.000 0.000 0.000 0.000
#> ERR184084     3  0.5186     0.4692 0.012 0.000 0.572 0.000 0.072 0.344
#> ERR184068     2  0.1564     0.9354 0.040 0.936 0.000 0.000 0.000 0.024
#> ERR184067     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184071     2  0.0551     0.9584 0.004 0.984 0.000 0.008 0.000 0.004
#> ERR184042     4  0.0547     0.0000 0.000 0.000 0.000 0.980 0.020 0.000
#> ERR184063     3  0.0000     0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184091     2  0.1268     0.9467 0.000 0.952 0.000 0.008 0.004 0.036
#> ERR184061     1  0.2776     0.5332 0.860 0.088 0.000 0.000 0.000 0.052
#> ERR184077     2  0.0146     0.9590 0.004 0.996 0.000 0.000 0.000 0.000
#> ERR184062     2  0.0547     0.9535 0.020 0.980 0.000 0.000 0.000 0.000
#> ERR184053     2  0.0146     0.9590 0.004 0.996 0.000 0.000 0.000 0.000
#> ERR184088     2  0.1913     0.9040 0.080 0.908 0.000 0.000 0.000 0.012
#> ERR184075     2  0.1554     0.9434 0.004 0.940 0.000 0.008 0.004 0.044
#> ERR184041     3  0.0146     0.9104 0.000 0.000 0.996 0.000 0.000 0.004
#> ERR184060     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184035     1  0.4126     0.1770 0.512 0.000 0.004 0.000 0.004 0.480
#> ERR184086     2  0.1268     0.9467 0.000 0.952 0.000 0.008 0.004 0.036
#> ERR184080     1  0.1788     0.5096 0.916 0.000 0.004 0.000 0.004 0.076
#> ERR184050     2  0.1985     0.9335 0.008 0.916 0.000 0.008 0.004 0.064
#> ERR184047     5  0.0291     0.9967 0.004 0.000 0.000 0.000 0.992 0.004
#> ERR184092     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184072     1  0.1686     0.5521 0.924 0.064 0.000 0.000 0.000 0.012
#> ERR184073     1  0.5360    -0.0475 0.508 0.000 0.412 0.000 0.056 0.024
#> ERR184066     1  0.1578     0.5555 0.936 0.048 0.004 0.000 0.000 0.012
#> ERR184098     2  0.1925     0.9356 0.008 0.920 0.000 0.008 0.004 0.060
#> ERR184044     2  0.4486     0.4972 0.292 0.656 0.000 0.004 0.000 0.048
#> ERR184054     1  0.1555     0.5204 0.932 0.000 0.004 0.000 0.004 0.060
#> ERR184085     1  0.5160     0.3461 0.564 0.000 0.104 0.000 0.000 0.332
#> ERR184056     2  0.0146     0.9590 0.004 0.996 0.000 0.000 0.000 0.000
#> ERR184052     2  0.2579     0.8986 0.048 0.884 0.000 0.008 0.000 0.060
#> ERR184070     2  0.0000     0.9595 0.000 1.000 0.000 0.000 0.000 0.000
#> ERR184096     5  0.0146     0.9967 0.004 0.000 0.000 0.000 0.996 0.000
#> ERR184089     2  0.2128     0.9314 0.008 0.912 0.004 0.008 0.004 0.064
#> ERR184049     1  0.4469     0.3206 0.668 0.276 0.000 0.004 0.000 0.052
#> ERR184038     1  0.3779     0.3967 0.760 0.204 0.004 0.004 0.000 0.028
#> ERR184087     3  0.0146     0.9127 0.000 0.000 0.996 0.000 0.004 0.000
#> ERR184097     2  0.0146     0.9590 0.004 0.996 0.000 0.000 0.000 0.000
#> ERR184094     3  0.2474     0.8560 0.000 0.000 0.880 0.000 0.080 0.040
#> ERR184058     2  0.1686     0.9413 0.004 0.932 0.000 0.008 0.004 0.052
#> ERR184036     2  0.1832     0.9357 0.032 0.928 0.000 0.008 0.000 0.032
#> ERR184046     2  0.0260     0.9581 0.000 0.992 0.000 0.000 0.000 0.008
#> ERR184074     1  0.1588     0.5145 0.924 0.000 0.004 0.000 0.000 0.072
#> ERR184048     2  0.0146     0.9590 0.004 0.996 0.000 0.000 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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.


CV:skmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "skmeans"]
# you can also extract it by
# res = res_list["CV:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-skmeans-select-partition-number

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.970       0.987         0.5034 0.497   0.497
#> 3 3 0.734           0.799       0.902         0.2412 0.847   0.701
#> 4 4 0.520           0.625       0.774         0.1382 0.943   0.849
#> 5 5 0.522           0.388       0.687         0.0716 0.929   0.795
#> 6 6 0.540           0.328       0.629         0.0483 0.940   0.809

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1   0.000      0.983 1.000 0.000
#> ERR184093     2   0.000      0.989 0.000 1.000
#> ERR184051     1   0.000      0.983 1.000 0.000
#> ERR184076     1   0.000      0.983 1.000 0.000
#> ERR184043     1   0.000      0.983 1.000 0.000
#> ERR184037     1   0.000      0.983 1.000 0.000
#> ERR184059     1   0.000      0.983 1.000 0.000
#> ERR184055     1   0.000      0.983 1.000 0.000
#> ERR184065     2   0.000      0.989 0.000 1.000
#> ERR184069     2   0.000      0.989 0.000 1.000
#> ERR184040     1   0.000      0.983 1.000 0.000
#> ERR184057     2   0.000      0.989 0.000 1.000
#> ERR184082     1   0.000      0.983 1.000 0.000
#> ERR184083     2   0.000      0.989 0.000 1.000
#> ERR184039     2   0.000      0.989 0.000 1.000
#> ERR184064     1   0.000      0.983 1.000 0.000
#> ERR184081     2   0.000      0.989 0.000 1.000
#> ERR184095     2   0.000      0.989 0.000 1.000
#> ERR184079     2   0.000      0.989 0.000 1.000
#> ERR184084     1   0.000      0.983 1.000 0.000
#> ERR184068     2   0.000      0.989 0.000 1.000
#> ERR184067     2   0.000      0.989 0.000 1.000
#> ERR184071     2   0.000      0.989 0.000 1.000
#> ERR184042     1   0.000      0.983 1.000 0.000
#> ERR184063     1   0.000      0.983 1.000 0.000
#> ERR184091     2   0.000      0.989 0.000 1.000
#> ERR184061     1   0.808      0.683 0.752 0.248
#> ERR184077     2   0.000      0.989 0.000 1.000
#> ERR184062     2   0.000      0.989 0.000 1.000
#> ERR184053     2   0.000      0.989 0.000 1.000
#> ERR184088     2   0.000      0.989 0.000 1.000
#> ERR184075     2   0.000      0.989 0.000 1.000
#> ERR184041     1   0.000      0.983 1.000 0.000
#> ERR184060     2   0.000      0.989 0.000 1.000
#> ERR184035     1   0.000      0.983 1.000 0.000
#> ERR184086     2   0.000      0.989 0.000 1.000
#> ERR184080     1   0.000      0.983 1.000 0.000
#> ERR184050     2   0.000      0.989 0.000 1.000
#> ERR184047     1   0.000      0.983 1.000 0.000
#> ERR184092     2   0.000      0.989 0.000 1.000
#> ERR184072     1   0.644      0.809 0.836 0.164
#> ERR184073     1   0.000      0.983 1.000 0.000
#> ERR184066     1   0.000      0.983 1.000 0.000
#> ERR184098     2   0.000      0.989 0.000 1.000
#> ERR184044     2   0.358      0.921 0.068 0.932
#> ERR184054     1   0.000      0.983 1.000 0.000
#> ERR184085     1   0.000      0.983 1.000 0.000
#> ERR184056     2   0.000      0.989 0.000 1.000
#> ERR184052     2   0.000      0.989 0.000 1.000
#> ERR184070     2   0.000      0.989 0.000 1.000
#> ERR184096     1   0.000      0.983 1.000 0.000
#> ERR184089     2   0.000      0.989 0.000 1.000
#> ERR184049     2   0.871      0.590 0.292 0.708
#> ERR184038     1   0.260      0.944 0.956 0.044
#> ERR184087     1   0.000      0.983 1.000 0.000
#> ERR184097     2   0.000      0.989 0.000 1.000
#> ERR184094     1   0.000      0.983 1.000 0.000
#> ERR184058     2   0.000      0.989 0.000 1.000
#> ERR184036     2   0.000      0.989 0.000 1.000
#> ERR184046     2   0.000      0.989 0.000 1.000
#> ERR184074     1   0.000      0.983 1.000 0.000
#> ERR184048     2   0.000      0.989 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.3816     0.7927 0.852 0.000 0.148
#> ERR184093     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184051     3  0.0000     0.7987 0.000 0.000 1.000
#> ERR184076     1  0.4062     0.7864 0.836 0.000 0.164
#> ERR184043     3  0.0000     0.7987 0.000 0.000 1.000
#> ERR184037     1  0.0747     0.7842 0.984 0.000 0.016
#> ERR184059     3  0.2878     0.7804 0.096 0.000 0.904
#> ERR184055     1  0.0661     0.7779 0.988 0.008 0.004
#> ERR184065     2  0.0237     0.9562 0.000 0.996 0.004
#> ERR184069     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184040     1  0.5098     0.7099 0.752 0.000 0.248
#> ERR184057     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184082     3  0.3879     0.7528 0.152 0.000 0.848
#> ERR184083     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184039     2  0.0848     0.9522 0.008 0.984 0.008
#> ERR184064     3  0.0000     0.7987 0.000 0.000 1.000
#> ERR184081     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184079     2  0.1411     0.9386 0.036 0.964 0.000
#> ERR184084     3  0.4346     0.7149 0.184 0.000 0.816
#> ERR184068     2  0.1267     0.9452 0.024 0.972 0.004
#> ERR184067     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184071     2  0.0237     0.9564 0.004 0.996 0.000
#> ERR184042     3  0.3267     0.7720 0.116 0.000 0.884
#> ERR184063     3  0.0237     0.7963 0.004 0.000 0.996
#> ERR184091     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184061     1  0.6363     0.6221 0.768 0.136 0.096
#> ERR184077     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184062     2  0.2625     0.8945 0.084 0.916 0.000
#> ERR184053     2  0.0237     0.9564 0.004 0.996 0.000
#> ERR184088     2  0.5656     0.6127 0.284 0.712 0.004
#> ERR184075     2  0.1964     0.9217 0.000 0.944 0.056
#> ERR184041     3  0.0000     0.7987 0.000 0.000 1.000
#> ERR184060     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184035     1  0.4178     0.7699 0.828 0.000 0.172
#> ERR184086     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184080     1  0.1031     0.7874 0.976 0.000 0.024
#> ERR184050     2  0.1529     0.9356 0.000 0.960 0.040
#> ERR184047     1  0.6280     0.2594 0.540 0.000 0.460
#> ERR184092     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184072     1  0.3134     0.7835 0.916 0.032 0.052
#> ERR184073     3  0.6140     0.1878 0.404 0.000 0.596
#> ERR184066     1  0.3826     0.7859 0.868 0.008 0.124
#> ERR184098     2  0.0892     0.9485 0.000 0.980 0.020
#> ERR184044     2  0.9129     0.0837 0.372 0.480 0.148
#> ERR184054     1  0.3551     0.7984 0.868 0.000 0.132
#> ERR184085     3  0.4750     0.7069 0.216 0.000 0.784
#> ERR184056     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184052     2  0.5471     0.7918 0.128 0.812 0.060
#> ERR184070     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184096     1  0.5650     0.6164 0.688 0.000 0.312
#> ERR184089     3  0.6521    -0.0957 0.004 0.496 0.500
#> ERR184049     1  0.7979     0.4397 0.640 0.248 0.112
#> ERR184038     3  0.5708     0.6672 0.204 0.028 0.768
#> ERR184087     3  0.0000     0.7987 0.000 0.000 1.000
#> ERR184097     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184094     3  0.4504     0.6926 0.196 0.000 0.804
#> ERR184058     2  0.0237     0.9563 0.004 0.996 0.000
#> ERR184036     2  0.1643     0.9335 0.044 0.956 0.000
#> ERR184046     2  0.0000     0.9577 0.000 1.000 0.000
#> ERR184074     1  0.3752     0.7948 0.856 0.000 0.144
#> ERR184048     2  0.0000     0.9577 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.3015     0.7568 0.884 0.000 0.092 0.024
#> ERR184093     2  0.2480     0.7775 0.008 0.904 0.000 0.088
#> ERR184051     3  0.0188     0.7894 0.000 0.000 0.996 0.004
#> ERR184076     1  0.3224     0.7564 0.864 0.000 0.120 0.016
#> ERR184043     3  0.0469     0.7875 0.000 0.000 0.988 0.012
#> ERR184037     1  0.3577     0.6790 0.832 0.000 0.012 0.156
#> ERR184059     3  0.3529     0.7508 0.152 0.000 0.836 0.012
#> ERR184055     1  0.5684     0.4948 0.664 0.016 0.024 0.296
#> ERR184065     2  0.4164     0.6773 0.000 0.736 0.000 0.264
#> ERR184069     2  0.1716     0.7800 0.000 0.936 0.000 0.064
#> ERR184040     1  0.4121     0.7196 0.796 0.000 0.184 0.020
#> ERR184057     2  0.0817     0.7777 0.000 0.976 0.000 0.024
#> ERR184082     3  0.6357     0.6013 0.184 0.000 0.656 0.160
#> ERR184083     2  0.2216     0.7795 0.000 0.908 0.000 0.092
#> ERR184039     2  0.4406     0.6505 0.000 0.700 0.000 0.300
#> ERR184064     3  0.0188     0.7890 0.000 0.000 0.996 0.004
#> ERR184081     2  0.1637     0.7816 0.000 0.940 0.000 0.060
#> ERR184095     2  0.0921     0.7765 0.000 0.972 0.000 0.028
#> ERR184079     2  0.4501     0.6902 0.024 0.764 0.000 0.212
#> ERR184084     3  0.4399     0.7018 0.212 0.000 0.768 0.020
#> ERR184068     2  0.5449     0.5172 0.032 0.676 0.004 0.288
#> ERR184067     2  0.2408     0.7684 0.000 0.896 0.000 0.104
#> ERR184071     2  0.3490     0.7653 0.004 0.836 0.004 0.156
#> ERR184042     3  0.3271     0.7623 0.132 0.000 0.856 0.012
#> ERR184063     3  0.0921     0.7835 0.000 0.000 0.972 0.028
#> ERR184091     2  0.4103     0.6854 0.000 0.744 0.000 0.256
#> ERR184061     4  0.7556    -0.0898 0.420 0.072 0.044 0.464
#> ERR184077     2  0.2814     0.7621 0.000 0.868 0.000 0.132
#> ERR184062     2  0.6117     0.4486 0.072 0.648 0.004 0.276
#> ERR184053     2  0.3257     0.7169 0.004 0.844 0.000 0.152
#> ERR184088     2  0.7427    -0.1560 0.200 0.500 0.000 0.300
#> ERR184075     2  0.5557     0.5878 0.000 0.652 0.040 0.308
#> ERR184041     3  0.1305     0.7773 0.004 0.000 0.960 0.036
#> ERR184060     2  0.0817     0.7777 0.000 0.976 0.000 0.024
#> ERR184035     1  0.5352     0.6914 0.740 0.000 0.092 0.168
#> ERR184086     2  0.3726     0.7181 0.000 0.788 0.000 0.212
#> ERR184080     1  0.3335     0.7022 0.860 0.000 0.020 0.120
#> ERR184050     2  0.5786     0.4807 0.004 0.588 0.028 0.380
#> ERR184047     1  0.5310     0.2760 0.576 0.000 0.412 0.012
#> ERR184092     2  0.2011     0.7758 0.000 0.920 0.000 0.080
#> ERR184072     1  0.6963     0.4470 0.636 0.076 0.044 0.244
#> ERR184073     3  0.5602     0.2641 0.408 0.000 0.568 0.024
#> ERR184066     1  0.6097     0.6333 0.724 0.028 0.096 0.152
#> ERR184098     2  0.5498     0.4671 0.000 0.576 0.020 0.404
#> ERR184044     4  0.9449     0.4432 0.204 0.312 0.120 0.364
#> ERR184054     1  0.3821     0.7556 0.840 0.000 0.120 0.040
#> ERR184085     3  0.6875     0.5387 0.220 0.000 0.596 0.184
#> ERR184056     2  0.0817     0.7772 0.000 0.976 0.000 0.024
#> ERR184052     4  0.7176     0.1395 0.052 0.408 0.040 0.500
#> ERR184070     2  0.1022     0.7773 0.000 0.968 0.000 0.032
#> ERR184096     1  0.4372     0.6160 0.728 0.000 0.268 0.004
#> ERR184089     4  0.8310     0.3051 0.016 0.260 0.360 0.364
#> ERR184049     4  0.8592     0.3286 0.248 0.160 0.084 0.508
#> ERR184038     3  0.8302     0.3505 0.264 0.052 0.512 0.172
#> ERR184087     3  0.0524     0.7893 0.004 0.000 0.988 0.008
#> ERR184097     2  0.2480     0.7669 0.008 0.904 0.000 0.088
#> ERR184094     3  0.4019     0.7158 0.196 0.000 0.792 0.012
#> ERR184058     2  0.4356     0.6377 0.000 0.708 0.000 0.292
#> ERR184036     2  0.5430     0.4563 0.036 0.664 0.000 0.300
#> ERR184046     2  0.2081     0.7761 0.000 0.916 0.000 0.084
#> ERR184074     1  0.4638     0.7477 0.788 0.000 0.152 0.060
#> ERR184048     2  0.2345     0.7556 0.000 0.900 0.000 0.100

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.3323     0.5791 0.864 0.000 0.056 0.020 0.060
#> ERR184093     2  0.4149     0.5091 0.004 0.768 0.000 0.188 0.040
#> ERR184051     3  0.1405     0.7268 0.008 0.000 0.956 0.016 0.020
#> ERR184076     1  0.4500     0.5810 0.784 0.000 0.100 0.020 0.096
#> ERR184043     3  0.0693     0.7263 0.008 0.000 0.980 0.012 0.000
#> ERR184037     1  0.5031     0.1914 0.656 0.000 0.012 0.036 0.296
#> ERR184059     3  0.4065     0.6378 0.212 0.000 0.760 0.008 0.020
#> ERR184055     5  0.5850     0.3294 0.396 0.024 0.004 0.040 0.536
#> ERR184065     2  0.4482     0.0926 0.000 0.612 0.000 0.376 0.012
#> ERR184069     2  0.3184     0.5490 0.000 0.852 0.000 0.100 0.048
#> ERR184040     1  0.3387     0.6004 0.836 0.000 0.132 0.008 0.024
#> ERR184057     2  0.1484     0.5711 0.000 0.944 0.000 0.048 0.008
#> ERR184082     3  0.8038     0.3569 0.192 0.004 0.464 0.144 0.196
#> ERR184083     2  0.3304     0.5206 0.000 0.816 0.000 0.168 0.016
#> ERR184039     2  0.5223    -0.1659 0.000 0.512 0.000 0.444 0.044
#> ERR184064     3  0.0451     0.7268 0.008 0.000 0.988 0.004 0.000
#> ERR184081     2  0.2770     0.5659 0.000 0.880 0.000 0.076 0.044
#> ERR184095     2  0.1877     0.5711 0.000 0.924 0.000 0.064 0.012
#> ERR184079     2  0.5847     0.3309 0.000 0.608 0.000 0.204 0.188
#> ERR184084     3  0.6220     0.4604 0.296 0.000 0.588 0.048 0.068
#> ERR184068     2  0.6607     0.2196 0.012 0.536 0.004 0.284 0.164
#> ERR184067     2  0.4210     0.5366 0.000 0.780 0.000 0.124 0.096
#> ERR184071     2  0.5390     0.3031 0.004 0.620 0.008 0.320 0.048
#> ERR184042     3  0.4173     0.6413 0.212 0.000 0.756 0.012 0.020
#> ERR184063     3  0.1399     0.7183 0.000 0.000 0.952 0.028 0.020
#> ERR184091     2  0.4540     0.1752 0.000 0.640 0.000 0.340 0.020
#> ERR184061     5  0.7323     0.5453 0.216 0.080 0.032 0.092 0.580
#> ERR184077     2  0.4179     0.5315 0.000 0.776 0.000 0.152 0.072
#> ERR184062     2  0.7475     0.1193 0.040 0.492 0.016 0.280 0.172
#> ERR184053     2  0.4045     0.5196 0.004 0.792 0.000 0.148 0.056
#> ERR184088     2  0.7830    -0.0473 0.148 0.460 0.000 0.136 0.256
#> ERR184075     2  0.5084    -0.2264 0.000 0.488 0.020 0.484 0.008
#> ERR184041     3  0.1557     0.7111 0.000 0.000 0.940 0.052 0.008
#> ERR184060     2  0.0955     0.5656 0.000 0.968 0.000 0.028 0.004
#> ERR184035     1  0.6121     0.4396 0.656 0.000 0.076 0.076 0.192
#> ERR184086     2  0.3949     0.3059 0.000 0.696 0.000 0.300 0.004
#> ERR184080     1  0.3523     0.4427 0.824 0.004 0.000 0.032 0.140
#> ERR184050     4  0.6324     0.1774 0.000 0.444 0.024 0.448 0.084
#> ERR184047     1  0.4557     0.3998 0.656 0.000 0.324 0.012 0.008
#> ERR184092     2  0.3242     0.5597 0.000 0.844 0.000 0.116 0.040
#> ERR184072     1  0.7662    -0.1934 0.448 0.048 0.032 0.116 0.356
#> ERR184073     1  0.5605    -0.0489 0.472 0.000 0.468 0.008 0.052
#> ERR184066     1  0.7859     0.0234 0.512 0.048 0.072 0.104 0.264
#> ERR184098     4  0.5161     0.0730 0.000 0.480 0.008 0.488 0.024
#> ERR184044     2  0.9124    -0.1794 0.096 0.332 0.068 0.252 0.252
#> ERR184054     1  0.3709     0.5766 0.840 0.000 0.068 0.020 0.072
#> ERR184085     3  0.7852     0.2896 0.260 0.000 0.436 0.096 0.208
#> ERR184056     2  0.2959     0.5696 0.000 0.864 0.000 0.100 0.036
#> ERR184052     4  0.8128     0.2097 0.036 0.296 0.028 0.340 0.300
#> ERR184070     2  0.2209     0.5694 0.000 0.912 0.000 0.056 0.032
#> ERR184096     1  0.4230     0.5749 0.764 0.000 0.196 0.016 0.024
#> ERR184089     4  0.7239     0.2842 0.004 0.160 0.328 0.468 0.040
#> ERR184049     5  0.7549     0.5360 0.164 0.080 0.036 0.144 0.576
#> ERR184038     3  0.8418     0.1979 0.264 0.020 0.424 0.136 0.156
#> ERR184087     3  0.0833     0.7281 0.016 0.000 0.976 0.004 0.004
#> ERR184097     2  0.3595     0.5417 0.000 0.816 0.000 0.140 0.044
#> ERR184094     3  0.4747     0.5462 0.284 0.000 0.676 0.004 0.036
#> ERR184058     2  0.5554     0.1105 0.000 0.592 0.000 0.316 0.092
#> ERR184036     2  0.6910    -0.0226 0.016 0.480 0.000 0.236 0.268
#> ERR184046     2  0.2813     0.5394 0.000 0.868 0.000 0.108 0.024
#> ERR184074     1  0.4922     0.5235 0.744 0.000 0.072 0.024 0.160
#> ERR184048     2  0.4505     0.5083 0.004 0.760 0.000 0.152 0.084

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1   0.452     0.5100 0.780 0.000 0.064 0.024 0.044 0.088
#> ERR184093     2   0.545     0.4491 0.000 0.636 0.000 0.144 0.196 0.024
#> ERR184051     3   0.249     0.6602 0.024 0.000 0.900 0.048 0.020 0.008
#> ERR184076     1   0.475     0.5200 0.748 0.000 0.100 0.008 0.040 0.104
#> ERR184043     3   0.155     0.6555 0.004 0.000 0.940 0.044 0.004 0.008
#> ERR184037     1   0.483     0.0672 0.520 0.000 0.012 0.004 0.024 0.440
#> ERR184059     3   0.394     0.5981 0.192 0.000 0.764 0.020 0.016 0.008
#> ERR184055     6   0.662     0.2391 0.328 0.016 0.028 0.032 0.080 0.516
#> ERR184065     2   0.492    -0.2412 0.000 0.508 0.000 0.436 0.052 0.004
#> ERR184069     2   0.326     0.5193 0.000 0.840 0.000 0.080 0.068 0.012
#> ERR184040     1   0.403     0.5367 0.784 0.000 0.144 0.004 0.036 0.032
#> ERR184057     2   0.271     0.5514 0.000 0.860 0.000 0.036 0.104 0.000
#> ERR184082     3   0.857     0.2187 0.172 0.016 0.408 0.148 0.096 0.160
#> ERR184083     2   0.337     0.5009 0.000 0.820 0.000 0.116 0.060 0.004
#> ERR184039     4   0.549     0.2894 0.000 0.440 0.004 0.480 0.044 0.032
#> ERR184064     3   0.137     0.6620 0.008 0.000 0.952 0.028 0.008 0.004
#> ERR184081     2   0.208     0.5365 0.000 0.916 0.000 0.036 0.036 0.012
#> ERR184095     2   0.296     0.5507 0.000 0.856 0.000 0.036 0.096 0.012
#> ERR184079     2   0.728     0.2574 0.032 0.524 0.004 0.124 0.196 0.120
#> ERR184084     3   0.650     0.3925 0.288 0.000 0.544 0.076 0.032 0.060
#> ERR184068     2   0.721     0.0106 0.036 0.444 0.004 0.088 0.344 0.084
#> ERR184067     2   0.525     0.4663 0.004 0.704 0.000 0.116 0.112 0.064
#> ERR184071     2   0.548     0.4015 0.004 0.648 0.000 0.156 0.168 0.024
#> ERR184042     3   0.439     0.5935 0.184 0.000 0.748 0.020 0.024 0.024
#> ERR184063     3   0.313     0.6321 0.008 0.000 0.860 0.080 0.024 0.028
#> ERR184091     2   0.462    -0.0954 0.000 0.572 0.000 0.388 0.036 0.004
#> ERR184061     6   0.839     0.3528 0.188 0.080 0.032 0.120 0.128 0.452
#> ERR184077     2   0.509     0.5054 0.004 0.696 0.000 0.072 0.184 0.044
#> ERR184062     2   0.756    -0.2047 0.020 0.364 0.000 0.152 0.344 0.120
#> ERR184053     2   0.596     0.3103 0.012 0.572 0.000 0.072 0.296 0.048
#> ERR184088     2   0.835    -0.3068 0.112 0.336 0.004 0.064 0.244 0.240
#> ERR184075     4   0.584     0.3672 0.000 0.408 0.028 0.492 0.052 0.020
#> ERR184041     3   0.291     0.6322 0.008 0.000 0.864 0.096 0.016 0.016
#> ERR184060     2   0.201     0.5349 0.000 0.916 0.000 0.036 0.044 0.004
#> ERR184035     1   0.669     0.2957 0.584 0.000 0.036 0.096 0.096 0.188
#> ERR184086     2   0.460     0.1190 0.000 0.628 0.000 0.320 0.048 0.004
#> ERR184080     1   0.464     0.3761 0.716 0.000 0.000 0.020 0.080 0.184
#> ERR184050     4   0.625     0.4659 0.004 0.312 0.024 0.548 0.076 0.036
#> ERR184047     1   0.463     0.1319 0.572 0.000 0.396 0.008 0.008 0.016
#> ERR184092     2   0.451     0.5160 0.000 0.740 0.000 0.068 0.160 0.032
#> ERR184072     1   0.779    -0.1760 0.404 0.040 0.032 0.028 0.240 0.256
#> ERR184073     3   0.569     0.1012 0.424 0.000 0.476 0.012 0.012 0.076
#> ERR184066     1   0.834    -0.0317 0.372 0.024 0.080 0.056 0.196 0.272
#> ERR184098     4   0.580     0.4121 0.000 0.340 0.000 0.520 0.120 0.020
#> ERR184044     5   0.922     0.0000 0.052 0.228 0.072 0.152 0.288 0.208
#> ERR184054     1   0.528     0.5037 0.712 0.000 0.100 0.012 0.064 0.112
#> ERR184085     3   0.880     0.0999 0.196 0.004 0.312 0.128 0.140 0.220
#> ERR184056     2   0.397     0.5252 0.000 0.744 0.000 0.048 0.204 0.004
#> ERR184052     4   0.889    -0.1971 0.052 0.260 0.036 0.304 0.156 0.192
#> ERR184070     2   0.248     0.5501 0.000 0.888 0.000 0.032 0.072 0.008
#> ERR184096     1   0.448     0.4753 0.720 0.000 0.220 0.016 0.024 0.020
#> ERR184089     4   0.612     0.1489 0.004 0.108 0.212 0.616 0.040 0.020
#> ERR184049     6   0.771     0.2814 0.092 0.064 0.040 0.152 0.108 0.544
#> ERR184038     3   0.892     0.1078 0.228 0.032 0.348 0.084 0.160 0.148
#> ERR184087     3   0.133     0.6627 0.020 0.000 0.948 0.032 0.000 0.000
#> ERR184097     2   0.462     0.4918 0.004 0.696 0.000 0.056 0.232 0.012
#> ERR184094     3   0.460     0.5545 0.228 0.000 0.708 0.016 0.016 0.032
#> ERR184058     2   0.567    -0.0411 0.004 0.552 0.000 0.344 0.056 0.044
#> ERR184036     2   0.748    -0.0906 0.008 0.428 0.000 0.192 0.156 0.216
#> ERR184046     2   0.282     0.5009 0.000 0.852 0.000 0.108 0.040 0.000
#> ERR184074     1   0.596     0.4488 0.616 0.000 0.128 0.012 0.040 0.204
#> ERR184048     2   0.564     0.4236 0.016 0.604 0.000 0.056 0.288 0.036

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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.


CV:pam

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "pam"]
# you can also extract it by
# res = res_list["CV:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-pam-select-partition-number

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.862           0.921       0.963         0.4365 0.556   0.556
#> 3 3 0.714           0.810       0.930         0.1043 0.990   0.982
#> 4 4 0.698           0.795       0.911         0.0931 0.897   0.813
#> 5 5 0.646           0.795       0.916         0.0678 0.997   0.994
#> 6 6 0.619           0.756       0.893         0.0417 0.992   0.981

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0376      0.926 0.996 0.004
#> ERR184093     2  0.0000      0.976 0.000 1.000
#> ERR184051     2  0.2043      0.951 0.032 0.968
#> ERR184076     1  0.0376      0.926 0.996 0.004
#> ERR184043     2  0.2043      0.951 0.032 0.968
#> ERR184037     1  0.0376      0.926 0.996 0.004
#> ERR184059     1  0.1184      0.921 0.984 0.016
#> ERR184055     1  0.1184      0.921 0.984 0.016
#> ERR184065     2  0.0000      0.976 0.000 1.000
#> ERR184069     2  0.0000      0.976 0.000 1.000
#> ERR184040     1  0.0376      0.926 0.996 0.004
#> ERR184057     2  0.0000      0.976 0.000 1.000
#> ERR184082     1  0.8763      0.630 0.704 0.296
#> ERR184083     2  0.0000      0.976 0.000 1.000
#> ERR184039     2  0.0000      0.976 0.000 1.000
#> ERR184064     2  0.2423      0.944 0.040 0.960
#> ERR184081     2  0.0000      0.976 0.000 1.000
#> ERR184095     2  0.0000      0.976 0.000 1.000
#> ERR184079     2  0.0000      0.976 0.000 1.000
#> ERR184084     1  0.1414      0.919 0.980 0.020
#> ERR184068     2  0.0000      0.976 0.000 1.000
#> ERR184067     2  0.0000      0.976 0.000 1.000
#> ERR184071     2  0.0000      0.976 0.000 1.000
#> ERR184042     1  0.4939      0.856 0.892 0.108
#> ERR184063     2  0.0376      0.973 0.004 0.996
#> ERR184091     2  0.0000      0.976 0.000 1.000
#> ERR184061     1  0.9732      0.395 0.596 0.404
#> ERR184077     2  0.0000      0.976 0.000 1.000
#> ERR184062     2  0.0000      0.976 0.000 1.000
#> ERR184053     2  0.0000      0.976 0.000 1.000
#> ERR184088     2  0.4431      0.883 0.092 0.908
#> ERR184075     2  0.0000      0.976 0.000 1.000
#> ERR184041     2  0.0376      0.973 0.004 0.996
#> ERR184060     2  0.0000      0.976 0.000 1.000
#> ERR184035     1  0.0376      0.926 0.996 0.004
#> ERR184086     2  0.0000      0.976 0.000 1.000
#> ERR184080     1  0.0376      0.926 0.996 0.004
#> ERR184050     2  0.0000      0.976 0.000 1.000
#> ERR184047     1  0.0000      0.925 1.000 0.000
#> ERR184092     2  0.0000      0.976 0.000 1.000
#> ERR184072     1  0.7950      0.713 0.760 0.240
#> ERR184073     1  0.0000      0.925 1.000 0.000
#> ERR184066     1  0.8144      0.696 0.748 0.252
#> ERR184098     2  0.0000      0.976 0.000 1.000
#> ERR184044     2  0.0000      0.976 0.000 1.000
#> ERR184054     1  0.0376      0.926 0.996 0.004
#> ERR184085     2  0.8327      0.625 0.264 0.736
#> ERR184056     2  0.0000      0.976 0.000 1.000
#> ERR184052     2  0.0000      0.976 0.000 1.000
#> ERR184070     2  0.0000      0.976 0.000 1.000
#> ERR184096     1  0.0000      0.925 1.000 0.000
#> ERR184089     2  0.0000      0.976 0.000 1.000
#> ERR184049     2  0.0376      0.973 0.004 0.996
#> ERR184038     2  0.8386      0.616 0.268 0.732
#> ERR184087     2  0.6531      0.791 0.168 0.832
#> ERR184097     2  0.0000      0.976 0.000 1.000
#> ERR184094     1  0.0000      0.925 1.000 0.000
#> ERR184058     2  0.0000      0.976 0.000 1.000
#> ERR184036     2  0.0000      0.976 0.000 1.000
#> ERR184046     2  0.0000      0.976 0.000 1.000
#> ERR184074     1  0.0376      0.926 0.996 0.004
#> ERR184048     2  0.0000      0.976 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184093     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184051     2  0.5905      0.527 0.000 0.648 0.352
#> ERR184076     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184043     2  0.5905      0.527 0.000 0.648 0.352
#> ERR184037     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184059     1  0.6427      0.383 0.640 0.012 0.348
#> ERR184055     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184065     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184069     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184040     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184057     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184082     1  0.5656      0.487 0.712 0.284 0.004
#> ERR184083     2  0.0237      0.939 0.000 0.996 0.004
#> ERR184039     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184064     2  0.5905      0.527 0.000 0.648 0.352
#> ERR184081     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184079     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184084     1  0.2743      0.787 0.928 0.020 0.052
#> ERR184068     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184067     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184071     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184042     3  0.0000      0.000 0.000 0.000 1.000
#> ERR184063     2  0.3941      0.808 0.000 0.844 0.156
#> ERR184091     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184061     1  0.6379      0.335 0.624 0.368 0.008
#> ERR184077     2  0.0237      0.939 0.000 0.996 0.004
#> ERR184062     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184053     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184088     2  0.2711      0.853 0.088 0.912 0.000
#> ERR184075     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184041     2  0.0747      0.934 0.000 0.984 0.016
#> ERR184060     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184035     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184086     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184080     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184050     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184047     1  0.5785      0.423 0.668 0.000 0.332
#> ERR184092     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184072     1  0.5335      0.549 0.760 0.232 0.008
#> ERR184073     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184066     1  0.5216      0.528 0.740 0.260 0.000
#> ERR184098     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184044     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184054     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184085     2  0.5692      0.623 0.268 0.724 0.008
#> ERR184056     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184052     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184070     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184096     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184089     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184049     2  0.0848      0.934 0.008 0.984 0.008
#> ERR184038     2  0.5692      0.624 0.268 0.724 0.008
#> ERR184087     2  0.5905      0.527 0.000 0.648 0.352
#> ERR184097     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184094     1  0.3116      0.746 0.892 0.000 0.108
#> ERR184058     2  0.0424      0.938 0.000 0.992 0.008
#> ERR184036     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184046     2  0.0000      0.939 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.825 1.000 0.000 0.000
#> ERR184048     2  0.0000      0.939 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184093     2  0.0592     0.9411 0.000 0.984 0.016 0.000
#> ERR184051     3  0.5093     0.6169 0.012 0.348 0.640 0.000
#> ERR184076     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184043     3  0.4795     0.6771 0.012 0.292 0.696 0.000
#> ERR184037     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184059     3  0.5038     0.1493 0.336 0.012 0.652 0.000
#> ERR184055     1  0.0336     0.8348 0.992 0.008 0.000 0.000
#> ERR184065     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184069     2  0.0469     0.9413 0.000 0.988 0.012 0.000
#> ERR184040     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184057     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184082     1  0.4850     0.4299 0.696 0.292 0.008 0.004
#> ERR184083     2  0.1489     0.9347 0.000 0.952 0.044 0.004
#> ERR184039     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184064     3  0.4795     0.6771 0.012 0.292 0.696 0.000
#> ERR184081     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184095     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184079     2  0.0779     0.9408 0.000 0.980 0.016 0.004
#> ERR184084     1  0.3408     0.7452 0.860 0.016 0.120 0.004
#> ERR184068     2  0.0376     0.9394 0.000 0.992 0.004 0.004
#> ERR184067     2  0.0376     0.9394 0.000 0.992 0.004 0.004
#> ERR184071     2  0.1022     0.9386 0.000 0.968 0.032 0.000
#> ERR184042     4  0.0188     0.0000 0.000 0.000 0.004 0.996
#> ERR184063     2  0.3726     0.7052 0.000 0.788 0.212 0.000
#> ERR184091     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184061     1  0.5964     0.2391 0.612 0.340 0.044 0.004
#> ERR184077     2  0.0707     0.9409 0.000 0.980 0.020 0.000
#> ERR184062     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184053     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184088     2  0.2266     0.8381 0.084 0.912 0.004 0.000
#> ERR184075     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184041     2  0.1637     0.9269 0.000 0.940 0.060 0.000
#> ERR184060     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184035     1  0.0188     0.8376 0.996 0.000 0.000 0.004
#> ERR184086     2  0.1389     0.9334 0.000 0.952 0.048 0.000
#> ERR184080     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184050     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184047     3  0.3726    -0.0645 0.212 0.000 0.788 0.000
#> ERR184092     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184072     1  0.4707     0.5346 0.760 0.204 0.036 0.000
#> ERR184073     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184066     1  0.4428     0.4852 0.720 0.276 0.004 0.000
#> ERR184098     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184044     2  0.0336     0.9402 0.000 0.992 0.008 0.000
#> ERR184054     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184085     2  0.5648     0.4632 0.268 0.680 0.048 0.004
#> ERR184056     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184052     2  0.1302     0.9351 0.000 0.956 0.044 0.000
#> ERR184070     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184096     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184089     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184049     2  0.1822     0.9343 0.008 0.944 0.044 0.004
#> ERR184038     2  0.5471     0.4654 0.268 0.684 0.048 0.000
#> ERR184087     3  0.4795     0.6771 0.012 0.292 0.696 0.000
#> ERR184097     2  0.0188     0.9392 0.000 0.996 0.004 0.000
#> ERR184094     1  0.4222     0.5526 0.728 0.000 0.272 0.000
#> ERR184058     2  0.1576     0.9328 0.000 0.948 0.048 0.004
#> ERR184036     2  0.0188     0.9406 0.000 0.996 0.000 0.004
#> ERR184046     2  0.0592     0.9411 0.000 0.984 0.016 0.000
#> ERR184074     1  0.0000     0.8395 1.000 0.000 0.000 0.000
#> ERR184048     2  0.0336     0.9404 0.000 0.992 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> ERR184078     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184093     2  0.1043      0.920 0.000 0.960 0.040  0 0.000
#> ERR184051     3  0.3607      0.446 0.004 0.244 0.752  0 0.000
#> ERR184076     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184043     3  0.0865      0.781 0.004 0.024 0.972  0 0.000
#> ERR184037     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184059     3  0.2020      0.559 0.100 0.000 0.900  0 0.000
#> ERR184055     1  0.0290      0.828 0.992 0.008 0.000  0 0.000
#> ERR184065     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184069     2  0.0963      0.920 0.000 0.964 0.036  0 0.000
#> ERR184040     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184057     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184082     1  0.4604      0.482 0.680 0.292 0.016  0 0.012
#> ERR184083     2  0.2304      0.909 0.000 0.892 0.100  0 0.008
#> ERR184039     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184064     3  0.0865      0.781 0.004 0.024 0.972  0 0.000
#> ERR184081     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184095     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184079     2  0.1205      0.920 0.000 0.956 0.040  0 0.004
#> ERR184084     1  0.3783      0.607 0.740 0.000 0.252  0 0.008
#> ERR184068     2  0.0162      0.916 0.000 0.996 0.000  0 0.004
#> ERR184067     2  0.0162      0.916 0.000 0.996 0.000  0 0.004
#> ERR184071     2  0.1894      0.915 0.000 0.920 0.072  0 0.008
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000
#> ERR184063     2  0.3980      0.694 0.000 0.708 0.284  0 0.008
#> ERR184091     2  0.2358      0.907 0.000 0.888 0.104  0 0.008
#> ERR184061     1  0.5815      0.377 0.616 0.272 0.100  0 0.012
#> ERR184077     2  0.1357      0.919 0.000 0.948 0.048  0 0.004
#> ERR184062     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184053     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184088     2  0.1732      0.846 0.080 0.920 0.000  0 0.000
#> ERR184075     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184041     2  0.2439      0.901 0.000 0.876 0.120  0 0.004
#> ERR184060     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184035     1  0.0162      0.830 0.996 0.000 0.000  0 0.004
#> ERR184086     2  0.2233      0.908 0.000 0.892 0.104  0 0.004
#> ERR184080     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184050     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184047     5  0.0404      0.000 0.012 0.000 0.000  0 0.988
#> ERR184092     2  0.0162      0.917 0.000 0.996 0.004  0 0.000
#> ERR184072     1  0.4489      0.608 0.760 0.156 0.080  0 0.004
#> ERR184073     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184066     1  0.3796      0.508 0.700 0.300 0.000  0 0.000
#> ERR184098     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184044     2  0.0162      0.917 0.000 0.996 0.004  0 0.000
#> ERR184054     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184085     2  0.5795      0.526 0.268 0.620 0.100  0 0.012
#> ERR184056     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184052     2  0.2304      0.908 0.000 0.892 0.100  0 0.008
#> ERR184070     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184096     1  0.0162      0.830 0.996 0.000 0.004  0 0.000
#> ERR184089     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184049     2  0.2414      0.911 0.008 0.900 0.080  0 0.012
#> ERR184038     2  0.5737      0.526 0.268 0.620 0.104  0 0.008
#> ERR184087     3  0.0865      0.781 0.004 0.024 0.972  0 0.000
#> ERR184097     2  0.0000      0.916 0.000 1.000 0.000  0 0.000
#> ERR184094     1  0.3684      0.552 0.720 0.000 0.280  0 0.000
#> ERR184058     2  0.2470      0.906 0.000 0.884 0.104  0 0.012
#> ERR184036     2  0.0451      0.918 0.000 0.988 0.004  0 0.008
#> ERR184046     2  0.1197      0.920 0.000 0.952 0.048  0 0.000
#> ERR184074     1  0.0000      0.832 1.000 0.000 0.000  0 0.000
#> ERR184048     2  0.0609      0.920 0.000 0.980 0.020  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4 p5    p6
#> ERR184078     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184093     2  0.1219      0.902 0.000 0.948 0.004  0  0 0.048
#> ERR184051     3  0.4091      0.391 0.000 0.224 0.720  0  0 0.056
#> ERR184076     1  0.0458      0.768 0.984 0.000 0.000  0  0 0.016
#> ERR184043     3  0.0458      0.814 0.000 0.016 0.984  0  0 0.000
#> ERR184037     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184059     3  0.0632      0.749 0.000 0.000 0.976  0  0 0.024
#> ERR184055     1  0.0405      0.770 0.988 0.008 0.000  0  0 0.004
#> ERR184065     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184069     2  0.1010      0.903 0.000 0.960 0.004  0  0 0.036
#> ERR184040     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184057     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184082     1  0.4630      0.391 0.660 0.280 0.012  0  0 0.048
#> ERR184083     2  0.2581      0.892 0.000 0.860 0.020  0  0 0.120
#> ERR184039     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184064     3  0.0458      0.814 0.000 0.016 0.984  0  0 0.000
#> ERR184081     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184095     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184079     2  0.1584      0.903 0.000 0.928 0.008  0  0 0.064
#> ERR184084     1  0.3952      0.415 0.672 0.000 0.308  0  0 0.020
#> ERR184068     2  0.0547      0.899 0.000 0.980 0.000  0  0 0.020
#> ERR184067     2  0.0632      0.898 0.000 0.976 0.000  0  0 0.024
#> ERR184071     2  0.2350      0.898 0.000 0.880 0.020  0  0 0.100
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1  0 0.000
#> ERR184063     2  0.4594      0.683 0.000 0.676 0.232  0  0 0.092
#> ERR184091     2  0.2624      0.890 0.000 0.856 0.020  0  0 0.124
#> ERR184061     1  0.5473      0.349 0.616 0.236 0.020  0  0 0.128
#> ERR184077     2  0.1895      0.903 0.000 0.912 0.016  0  0 0.072
#> ERR184062     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184053     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184088     2  0.1951      0.834 0.076 0.908 0.000  0  0 0.016
#> ERR184075     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184041     2  0.2912      0.886 0.000 0.844 0.040  0  0 0.116
#> ERR184060     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184035     1  0.0146      0.775 0.996 0.000 0.000  0  0 0.004
#> ERR184086     2  0.2581      0.891 0.000 0.860 0.020  0  0 0.120
#> ERR184080     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184050     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184047     5  0.0000      0.000 0.000 0.000 0.000  0  1 0.000
#> ERR184092     2  0.0146      0.899 0.000 0.996 0.000  0  0 0.004
#> ERR184072     1  0.4250      0.557 0.760 0.132 0.016  0  0 0.092
#> ERR184073     1  0.0146      0.775 0.996 0.000 0.000  0  0 0.004
#> ERR184066     1  0.3990      0.407 0.676 0.304 0.004  0  0 0.016
#> ERR184098     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184044     2  0.0972      0.901 0.000 0.964 0.008  0  0 0.028
#> ERR184054     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184085     2  0.5644      0.531 0.264 0.584 0.020  0  0 0.132
#> ERR184056     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184052     2  0.2581      0.892 0.000 0.860 0.020  0  0 0.120
#> ERR184070     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184096     6  0.2762      0.000 0.196 0.000 0.000  0  0 0.804
#> ERR184089     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184049     2  0.2501      0.896 0.004 0.872 0.016  0  0 0.108
#> ERR184038     2  0.5610      0.532 0.264 0.588 0.020  0  0 0.128
#> ERR184087     3  0.0458      0.814 0.000 0.016 0.984  0  0 0.000
#> ERR184097     2  0.0458      0.895 0.000 0.984 0.000  0  0 0.016
#> ERR184094     1  0.3371      0.407 0.708 0.000 0.292  0  0 0.000
#> ERR184058     2  0.2750      0.887 0.000 0.844 0.020  0  0 0.136
#> ERR184036     2  0.0935      0.901 0.000 0.964 0.004  0  0 0.032
#> ERR184046     2  0.1434      0.904 0.000 0.940 0.012  0  0 0.048
#> ERR184074     1  0.0000      0.776 1.000 0.000 0.000  0  0 0.000
#> ERR184048     2  0.1320      0.902 0.000 0.948 0.016  0  0 0.036

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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.


CV:mclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "mclust"]
# you can also extract it by
# res = res_list["CV:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-mclust-select-partition-number

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.9032           0.944       0.980         0.0701 0.968   0.968
#> 3 3 0.0926           0.477       0.728         5.4481 0.604   0.591
#> 4 4 0.2341           0.531       0.771         0.2223 0.677   0.543
#> 5 5 0.2831           0.572       0.746         0.2190 0.785   0.596
#> 6 6 0.5475           0.653       0.807         0.0895 0.918   0.763

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 6

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.1414      0.967 0.020 0.980
#> ERR184093     2  0.0000      0.979 0.000 1.000
#> ERR184051     2  0.0672      0.975 0.008 0.992
#> ERR184076     2  0.2423      0.951 0.040 0.960
#> ERR184043     2  0.5737      0.854 0.136 0.864
#> ERR184037     2  0.0376      0.977 0.004 0.996
#> ERR184059     2  0.1184      0.970 0.016 0.984
#> ERR184055     2  0.0000      0.979 0.000 1.000
#> ERR184065     2  0.0000      0.979 0.000 1.000
#> ERR184069     2  0.0000      0.979 0.000 1.000
#> ERR184040     2  0.1843      0.961 0.028 0.972
#> ERR184057     2  0.0000      0.979 0.000 1.000
#> ERR184082     2  0.0000      0.979 0.000 1.000
#> ERR184083     2  0.0000      0.979 0.000 1.000
#> ERR184039     2  0.0000      0.979 0.000 1.000
#> ERR184064     2  0.5737      0.854 0.136 0.864
#> ERR184081     2  0.0000      0.979 0.000 1.000
#> ERR184095     2  0.0000      0.979 0.000 1.000
#> ERR184079     2  0.0672      0.975 0.008 0.992
#> ERR184084     2  0.9170      0.517 0.332 0.668
#> ERR184068     2  0.0000      0.979 0.000 1.000
#> ERR184067     2  0.0000      0.979 0.000 1.000
#> ERR184071     2  0.0000      0.979 0.000 1.000
#> ERR184042     1  0.0000      0.000 1.000 0.000
#> ERR184063     2  0.2778      0.943 0.048 0.952
#> ERR184091     2  0.0000      0.979 0.000 1.000
#> ERR184061     2  0.0000      0.979 0.000 1.000
#> ERR184077     2  0.0000      0.979 0.000 1.000
#> ERR184062     2  0.0000      0.979 0.000 1.000
#> ERR184053     2  0.0938      0.972 0.012 0.988
#> ERR184088     2  0.0000      0.979 0.000 1.000
#> ERR184075     2  0.0000      0.979 0.000 1.000
#> ERR184041     2  0.2778      0.943 0.048 0.952
#> ERR184060     2  0.0000      0.979 0.000 1.000
#> ERR184035     2  0.1414      0.967 0.020 0.980
#> ERR184086     2  0.0000      0.979 0.000 1.000
#> ERR184080     2  0.0000      0.979 0.000 1.000
#> ERR184050     2  0.0000      0.979 0.000 1.000
#> ERR184047     2  0.5519      0.862 0.128 0.872
#> ERR184092     2  0.0000      0.979 0.000 1.000
#> ERR184072     2  0.0000      0.979 0.000 1.000
#> ERR184073     2  0.0000      0.979 0.000 1.000
#> ERR184066     2  0.0000      0.979 0.000 1.000
#> ERR184098     2  0.0000      0.979 0.000 1.000
#> ERR184044     2  0.0376      0.977 0.004 0.996
#> ERR184054     2  0.0376      0.977 0.004 0.996
#> ERR184085     2  0.0672      0.975 0.008 0.992
#> ERR184056     2  0.0000      0.979 0.000 1.000
#> ERR184052     2  0.0000      0.979 0.000 1.000
#> ERR184070     2  0.0000      0.979 0.000 1.000
#> ERR184096     2  0.4690      0.892 0.100 0.900
#> ERR184089     2  0.0000      0.979 0.000 1.000
#> ERR184049     2  0.0000      0.979 0.000 1.000
#> ERR184038     2  0.0000      0.979 0.000 1.000
#> ERR184087     2  0.5946      0.845 0.144 0.856
#> ERR184097     2  0.0000      0.979 0.000 1.000
#> ERR184094     2  0.0000      0.979 0.000 1.000
#> ERR184058     2  0.0000      0.979 0.000 1.000
#> ERR184036     2  0.0000      0.979 0.000 1.000
#> ERR184046     2  0.0000      0.979 0.000 1.000
#> ERR184074     2  0.0000      0.979 0.000 1.000
#> ERR184048     2  0.0000      0.979 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     2  0.6589     0.4978 0.032 0.688 0.280
#> ERR184093     2  0.1411     0.6257 0.000 0.964 0.036
#> ERR184051     3  0.4750     0.7028 0.000 0.216 0.784
#> ERR184076     2  0.7283     0.4782 0.068 0.672 0.260
#> ERR184043     3  0.6511     0.6849 0.072 0.180 0.748
#> ERR184037     2  0.5956     0.5208 0.016 0.720 0.264
#> ERR184059     3  0.6742     0.6730 0.052 0.240 0.708
#> ERR184055     2  0.5318     0.5576 0.016 0.780 0.204
#> ERR184065     2  0.5905     0.1790 0.000 0.648 0.352
#> ERR184069     2  0.4504     0.5044 0.000 0.804 0.196
#> ERR184040     2  0.6703     0.4963 0.040 0.692 0.268
#> ERR184057     2  0.3340     0.5916 0.000 0.880 0.120
#> ERR184082     3  0.6111     0.5789 0.000 0.396 0.604
#> ERR184083     2  0.4399     0.5302 0.000 0.812 0.188
#> ERR184039     2  0.5678     0.3081 0.000 0.684 0.316
#> ERR184064     3  0.5905     0.6959 0.044 0.184 0.772
#> ERR184081     2  0.3412     0.5928 0.000 0.876 0.124
#> ERR184095     2  0.4796     0.4505 0.000 0.780 0.220
#> ERR184079     2  0.6307    -0.2995 0.000 0.512 0.488
#> ERR184084     3  0.6319     0.5939 0.040 0.228 0.732
#> ERR184068     2  0.2448     0.6224 0.000 0.924 0.076
#> ERR184067     2  0.5016     0.4011 0.000 0.760 0.240
#> ERR184071     2  0.5968     0.0499 0.000 0.636 0.364
#> ERR184042     1  0.0592     0.0000 0.988 0.000 0.012
#> ERR184063     3  0.5850     0.6988 0.040 0.188 0.772
#> ERR184091     2  0.5621     0.3188 0.000 0.692 0.308
#> ERR184061     2  0.2261     0.6250 0.000 0.932 0.068
#> ERR184077     3  0.6309     0.4063 0.000 0.496 0.504
#> ERR184062     2  0.4702     0.5245 0.000 0.788 0.212
#> ERR184053     3  0.6244     0.4312 0.000 0.440 0.560
#> ERR184088     2  0.2400     0.6187 0.004 0.932 0.064
#> ERR184075     3  0.6299     0.4561 0.000 0.476 0.524
#> ERR184041     3  0.5728     0.7012 0.032 0.196 0.772
#> ERR184060     2  0.3879     0.5664 0.000 0.848 0.152
#> ERR184035     2  0.7156     0.3296 0.028 0.572 0.400
#> ERR184086     2  0.5465     0.3712 0.000 0.712 0.288
#> ERR184080     2  0.5817     0.5350 0.020 0.744 0.236
#> ERR184050     3  0.6280     0.4996 0.000 0.460 0.540
#> ERR184047     2  0.9299     0.2648 0.196 0.512 0.292
#> ERR184092     2  0.3116     0.5944 0.000 0.892 0.108
#> ERR184072     2  0.5578     0.5459 0.012 0.748 0.240
#> ERR184073     2  0.6647     0.2417 0.008 0.540 0.452
#> ERR184066     2  0.3644     0.6000 0.004 0.872 0.124
#> ERR184098     2  0.5650     0.3357 0.000 0.688 0.312
#> ERR184044     2  0.3425     0.6109 0.004 0.884 0.112
#> ERR184054     2  0.5623     0.5264 0.004 0.716 0.280
#> ERR184085     3  0.5497     0.5850 0.000 0.292 0.708
#> ERR184056     2  0.1031     0.6288 0.000 0.976 0.024
#> ERR184052     2  0.3412     0.5988 0.000 0.876 0.124
#> ERR184070     2  0.2537     0.6143 0.000 0.920 0.080
#> ERR184096     2  0.8734     0.3700 0.168 0.584 0.248
#> ERR184089     3  0.6045     0.6137 0.000 0.380 0.620
#> ERR184049     2  0.4504     0.5760 0.000 0.804 0.196
#> ERR184038     3  0.6225     0.4137 0.000 0.432 0.568
#> ERR184087     3  0.6059     0.6975 0.048 0.188 0.764
#> ERR184097     2  0.0892     0.6281 0.000 0.980 0.020
#> ERR184094     3  0.7295     0.1412 0.028 0.484 0.488
#> ERR184058     2  0.6267    -0.3678 0.000 0.548 0.452
#> ERR184036     2  0.3816     0.5793 0.000 0.852 0.148
#> ERR184046     2  0.4399     0.5312 0.000 0.812 0.188
#> ERR184074     2  0.5956     0.5180 0.016 0.720 0.264
#> ERR184048     2  0.1411     0.6284 0.000 0.964 0.036

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.4372     0.6409 0.728 0.268 0.004 0.000
#> ERR184093     2  0.1151     0.7006 0.024 0.968 0.008 0.000
#> ERR184051     3  0.1624     0.6941 0.020 0.028 0.952 0.000
#> ERR184076     1  0.4632     0.6576 0.688 0.308 0.004 0.000
#> ERR184043     3  0.1443     0.6948 0.008 0.004 0.960 0.028
#> ERR184037     1  0.5295     0.3554 0.504 0.488 0.008 0.000
#> ERR184059     3  0.7590     0.4413 0.140 0.124 0.636 0.100
#> ERR184055     2  0.5232     0.2307 0.340 0.644 0.012 0.004
#> ERR184065     2  0.6166     0.4320 0.024 0.572 0.384 0.020
#> ERR184069     2  0.2466     0.7088 0.028 0.916 0.056 0.000
#> ERR184040     1  0.3547     0.5039 0.840 0.144 0.016 0.000
#> ERR184057     2  0.0927     0.7043 0.016 0.976 0.008 0.000
#> ERR184082     2  0.6664     0.4151 0.112 0.580 0.308 0.000
#> ERR184083     2  0.2782     0.7151 0.024 0.904 0.068 0.004
#> ERR184039     2  0.6134     0.4843 0.032 0.620 0.328 0.020
#> ERR184064     3  0.1114     0.6984 0.008 0.004 0.972 0.016
#> ERR184081     2  0.0707     0.7099 0.000 0.980 0.020 0.000
#> ERR184095     2  0.2660     0.7122 0.036 0.908 0.056 0.000
#> ERR184079     2  0.6159     0.5846 0.172 0.676 0.152 0.000
#> ERR184084     3  0.8577     0.2631 0.184 0.316 0.448 0.052
#> ERR184068     2  0.2706     0.6950 0.080 0.900 0.020 0.000
#> ERR184067     2  0.2408     0.7108 0.036 0.920 0.044 0.000
#> ERR184071     2  0.4144     0.6929 0.068 0.828 0.104 0.000
#> ERR184042     4  0.0817     0.0000 0.000 0.000 0.024 0.976
#> ERR184063     3  0.1394     0.7000 0.012 0.008 0.964 0.016
#> ERR184091     2  0.6206     0.4481 0.028 0.584 0.368 0.020
#> ERR184061     2  0.3344     0.6760 0.108 0.868 0.020 0.004
#> ERR184077     2  0.5574     0.6219 0.124 0.728 0.148 0.000
#> ERR184062     2  0.3617     0.7067 0.064 0.860 0.076 0.000
#> ERR184053     2  0.6439     0.5611 0.180 0.648 0.172 0.000
#> ERR184088     2  0.3462     0.6661 0.116 0.860 0.020 0.004
#> ERR184075     2  0.6200     0.3399 0.020 0.508 0.452 0.020
#> ERR184041     3  0.1007     0.7016 0.008 0.008 0.976 0.008
#> ERR184060     2  0.1488     0.7145 0.012 0.956 0.032 0.000
#> ERR184035     1  0.6585     0.4032 0.520 0.412 0.060 0.008
#> ERR184086     2  0.6170     0.4895 0.032 0.612 0.336 0.020
#> ERR184080     2  0.5296    -0.4302 0.492 0.500 0.008 0.000
#> ERR184050     2  0.6205     0.2829 0.024 0.488 0.472 0.016
#> ERR184047     1  0.4652     0.2399 0.820 0.076 0.020 0.084
#> ERR184092     2  0.1510     0.7129 0.016 0.956 0.028 0.000
#> ERR184072     2  0.5070     0.1535 0.372 0.620 0.008 0.000
#> ERR184073     2  0.8066     0.0826 0.256 0.472 0.256 0.016
#> ERR184066     2  0.3647     0.6353 0.152 0.832 0.016 0.000
#> ERR184098     2  0.5788     0.5354 0.024 0.660 0.296 0.020
#> ERR184044     2  0.4093     0.6734 0.120 0.836 0.032 0.012
#> ERR184054     2  0.5558     0.0860 0.364 0.608 0.028 0.000
#> ERR184085     2  0.7045     0.3098 0.140 0.532 0.328 0.000
#> ERR184056     2  0.1635     0.6952 0.044 0.948 0.008 0.000
#> ERR184052     2  0.3785     0.6986 0.084 0.856 0.056 0.004
#> ERR184070     2  0.0707     0.7001 0.020 0.980 0.000 0.000
#> ERR184096     1  0.5387     0.4324 0.764 0.144 0.016 0.076
#> ERR184089     3  0.5248     0.4353 0.012 0.248 0.716 0.024
#> ERR184049     2  0.2830     0.7090 0.060 0.900 0.040 0.000
#> ERR184038     2  0.6167     0.5584 0.124 0.668 0.208 0.000
#> ERR184087     3  0.1543     0.6929 0.008 0.004 0.956 0.032
#> ERR184097     2  0.1722     0.6954 0.048 0.944 0.008 0.000
#> ERR184094     3  0.8477     0.3519 0.196 0.228 0.512 0.064
#> ERR184058     2  0.5023     0.6687 0.056 0.772 0.164 0.008
#> ERR184036     2  0.1936     0.7120 0.032 0.940 0.028 0.000
#> ERR184046     2  0.2715     0.7076 0.004 0.892 0.100 0.004
#> ERR184074     1  0.5388     0.4397 0.532 0.456 0.012 0.000
#> ERR184048     2  0.2198     0.6888 0.072 0.920 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.3688     0.6512 0.816 0.124 0.000 0.000 0.060
#> ERR184093     2  0.1399     0.7633 0.028 0.952 0.000 0.000 0.020
#> ERR184051     3  0.4270     0.6274 0.000 0.048 0.748 0.000 0.204
#> ERR184076     1  0.4350     0.6721 0.764 0.152 0.000 0.000 0.084
#> ERR184043     3  0.0000     0.7970 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.5199     0.6187 0.636 0.292 0.000 0.000 0.072
#> ERR184059     3  0.5751     0.5747 0.024 0.012 0.692 0.092 0.180
#> ERR184055     2  0.5849     0.0968 0.392 0.508 0.000 0.000 0.100
#> ERR184065     5  0.5348     0.6294 0.012 0.140 0.148 0.000 0.700
#> ERR184069     2  0.1644     0.7500 0.008 0.940 0.004 0.000 0.048
#> ERR184040     1  0.3231     0.5576 0.864 0.076 0.004 0.004 0.052
#> ERR184057     2  0.1106     0.7616 0.024 0.964 0.000 0.000 0.012
#> ERR184082     5  0.6591     0.3386 0.068 0.356 0.060 0.000 0.516
#> ERR184083     2  0.1892     0.7528 0.000 0.916 0.004 0.000 0.080
#> ERR184039     5  0.5604     0.6446 0.020 0.184 0.116 0.000 0.680
#> ERR184064     3  0.0162     0.7992 0.000 0.000 0.996 0.000 0.004
#> ERR184081     2  0.1124     0.7582 0.004 0.960 0.000 0.000 0.036
#> ERR184095     2  0.2032     0.7552 0.020 0.924 0.004 0.000 0.052
#> ERR184079     2  0.4592     0.6804 0.140 0.756 0.004 0.000 0.100
#> ERR184084     5  0.9121     0.2848 0.116 0.248 0.172 0.080 0.384
#> ERR184068     2  0.3346     0.7488 0.092 0.844 0.000 0.000 0.064
#> ERR184067     2  0.1731     0.7492 0.004 0.932 0.004 0.000 0.060
#> ERR184071     2  0.4007     0.6342 0.020 0.756 0.004 0.000 0.220
#> ERR184042     4  0.0000     0.0000 0.000 0.000 0.000 1.000 0.000
#> ERR184063     3  0.0794     0.7933 0.000 0.000 0.972 0.000 0.028
#> ERR184091     5  0.5481     0.6389 0.016 0.156 0.136 0.000 0.692
#> ERR184061     2  0.5399     0.6232 0.148 0.664 0.000 0.000 0.188
#> ERR184077     2  0.4612     0.6893 0.124 0.756 0.004 0.000 0.116
#> ERR184062     2  0.3741     0.7374 0.076 0.816 0.000 0.000 0.108
#> ERR184053     2  0.4829     0.6673 0.164 0.732 0.004 0.000 0.100
#> ERR184088     2  0.4835     0.6361 0.156 0.724 0.000 0.000 0.120
#> ERR184075     5  0.5698     0.5990 0.012 0.128 0.204 0.000 0.656
#> ERR184041     3  0.0609     0.7970 0.000 0.000 0.980 0.000 0.020
#> ERR184060     2  0.2047     0.7600 0.020 0.928 0.012 0.000 0.040
#> ERR184035     1  0.5940     0.5333 0.568 0.292 0.000 0.000 0.140
#> ERR184086     5  0.6061     0.6259 0.016 0.268 0.116 0.000 0.600
#> ERR184080     1  0.5409     0.5953 0.612 0.304 0.000 0.000 0.084
#> ERR184050     5  0.5978     0.6066 0.024 0.148 0.180 0.000 0.648
#> ERR184047     1  0.5980     0.0860 0.668 0.000 0.068 0.188 0.076
#> ERR184092     2  0.1399     0.7649 0.028 0.952 0.000 0.000 0.020
#> ERR184072     2  0.5650    -0.0916 0.456 0.468 0.000 0.000 0.076
#> ERR184073     5  0.9236     0.2849 0.188 0.264 0.160 0.056 0.332
#> ERR184066     2  0.5060     0.5914 0.224 0.684 0.000 0.000 0.092
#> ERR184098     5  0.5842     0.6393 0.024 0.204 0.116 0.000 0.656
#> ERR184044     2  0.5400     0.5666 0.096 0.632 0.000 0.000 0.272
#> ERR184054     2  0.5836    -0.1348 0.448 0.468 0.004 0.000 0.080
#> ERR184085     5  0.6782     0.3598 0.100 0.332 0.052 0.000 0.516
#> ERR184056     2  0.2153     0.7639 0.040 0.916 0.000 0.000 0.044
#> ERR184052     2  0.5988     0.3859 0.080 0.552 0.016 0.000 0.352
#> ERR184070     2  0.1310     0.7623 0.024 0.956 0.000 0.000 0.020
#> ERR184096     1  0.6056     0.3917 0.712 0.052 0.044 0.124 0.068
#> ERR184089     5  0.6011     0.4258 0.016 0.092 0.316 0.000 0.576
#> ERR184049     2  0.4735     0.6621 0.072 0.728 0.004 0.000 0.196
#> ERR184038     2  0.6109     0.1666 0.104 0.516 0.008 0.000 0.372
#> ERR184087     3  0.0162     0.7992 0.000 0.000 0.996 0.000 0.004
#> ERR184097     2  0.2438     0.7548 0.040 0.900 0.000 0.000 0.060
#> ERR184094     3  0.8255     0.1493 0.080 0.072 0.388 0.080 0.380
#> ERR184058     2  0.5361     0.2283 0.024 0.580 0.024 0.000 0.372
#> ERR184036     2  0.2209     0.7644 0.032 0.912 0.000 0.000 0.056
#> ERR184046     2  0.2102     0.7561 0.012 0.916 0.004 0.000 0.068
#> ERR184074     1  0.4960     0.6619 0.668 0.268 0.000 0.000 0.064
#> ERR184048     2  0.1942     0.7617 0.068 0.920 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.2086     0.7016 0.912 0.008 0.004 0.000 0.064 0.012
#> ERR184093     2  0.0363     0.8234 0.000 0.988 0.000 0.000 0.000 0.012
#> ERR184051     3  0.3827     0.7026 0.000 0.008 0.776 0.000 0.052 0.164
#> ERR184076     1  0.2094     0.7186 0.908 0.024 0.000 0.000 0.064 0.004
#> ERR184043     3  0.0790     0.8226 0.000 0.000 0.968 0.000 0.000 0.032
#> ERR184037     1  0.2002     0.7291 0.920 0.052 0.004 0.000 0.012 0.012
#> ERR184059     3  0.3652     0.7053 0.004 0.004 0.796 0.000 0.148 0.048
#> ERR184055     1  0.5087     0.2186 0.592 0.332 0.000 0.000 0.060 0.016
#> ERR184065     6  0.1732     0.8891 0.004 0.072 0.004 0.000 0.000 0.920
#> ERR184069     2  0.0508     0.8232 0.004 0.984 0.000 0.000 0.000 0.012
#> ERR184040     1  0.2431     0.6636 0.872 0.004 0.004 0.000 0.116 0.004
#> ERR184057     2  0.0146     0.8225 0.000 0.996 0.000 0.000 0.000 0.004
#> ERR184082     5  0.7588     0.4111 0.092 0.220 0.028 0.000 0.420 0.240
#> ERR184083     2  0.1644     0.8176 0.004 0.932 0.000 0.000 0.012 0.052
#> ERR184039     6  0.2162     0.8859 0.004 0.088 0.000 0.000 0.012 0.896
#> ERR184064     3  0.0713     0.8226 0.000 0.000 0.972 0.000 0.000 0.028
#> ERR184081     2  0.0508     0.8230 0.004 0.984 0.000 0.000 0.000 0.012
#> ERR184095     2  0.0862     0.8234 0.004 0.972 0.000 0.000 0.008 0.016
#> ERR184079     2  0.4703     0.6537 0.112 0.720 0.000 0.000 0.148 0.020
#> ERR184084     5  0.7296     0.3472 0.072 0.072 0.188 0.032 0.568 0.068
#> ERR184068     2  0.2736     0.8035 0.048 0.880 0.000 0.000 0.052 0.020
#> ERR184067     2  0.0984     0.8250 0.008 0.968 0.000 0.000 0.012 0.012
#> ERR184071     2  0.3621     0.7511 0.024 0.808 0.000 0.000 0.036 0.132
#> ERR184042     4  0.0000     0.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> ERR184063     3  0.1531     0.8136 0.000 0.000 0.928 0.000 0.004 0.068
#> ERR184091     6  0.2144     0.8868 0.004 0.092 0.004 0.000 0.004 0.896
#> ERR184061     2  0.5897     0.5690 0.124 0.632 0.000 0.000 0.148 0.096
#> ERR184077     2  0.3717     0.7493 0.084 0.808 0.000 0.000 0.092 0.016
#> ERR184062     2  0.3361     0.7827 0.068 0.848 0.004 0.000 0.040 0.040
#> ERR184053     2  0.4813     0.6437 0.116 0.708 0.000 0.000 0.156 0.020
#> ERR184088     2  0.4041     0.7335 0.076 0.788 0.000 0.000 0.108 0.028
#> ERR184075     6  0.1867     0.8613 0.000 0.036 0.036 0.000 0.004 0.924
#> ERR184041     3  0.1615     0.8157 0.000 0.004 0.928 0.000 0.004 0.064
#> ERR184060     2  0.0547     0.8230 0.000 0.980 0.000 0.000 0.000 0.020
#> ERR184035     1  0.3737     0.6257 0.772 0.036 0.000 0.000 0.184 0.008
#> ERR184086     6  0.3499     0.7318 0.008 0.196 0.004 0.000 0.012 0.780
#> ERR184080     1  0.1644     0.7292 0.932 0.052 0.000 0.000 0.004 0.012
#> ERR184050     6  0.2195     0.8612 0.008 0.052 0.020 0.000 0.008 0.912
#> ERR184047     5  0.6675    -0.2164 0.372 0.000 0.032 0.132 0.440 0.024
#> ERR184092     2  0.0146     0.8225 0.000 0.996 0.000 0.000 0.000 0.004
#> ERR184072     1  0.4239     0.5430 0.732 0.204 0.000 0.000 0.052 0.012
#> ERR184073     5  0.7999     0.4233 0.132 0.148 0.156 0.024 0.488 0.052
#> ERR184066     2  0.5623     0.3408 0.340 0.536 0.000 0.000 0.108 0.016
#> ERR184098     6  0.2425     0.8729 0.012 0.100 0.000 0.000 0.008 0.880
#> ERR184044     2  0.6059     0.4896 0.048 0.580 0.000 0.000 0.168 0.204
#> ERR184054     1  0.3725     0.6308 0.788 0.156 0.004 0.000 0.048 0.004
#> ERR184085     5  0.7459     0.4486 0.128 0.168 0.024 0.000 0.468 0.212
#> ERR184056     2  0.0551     0.8243 0.008 0.984 0.000 0.000 0.004 0.004
#> ERR184052     2  0.6182     0.2866 0.040 0.492 0.000 0.000 0.128 0.340
#> ERR184070     2  0.0547     0.8230 0.000 0.980 0.000 0.000 0.000 0.020
#> ERR184096     1  0.6655     0.1136 0.460 0.012 0.024 0.104 0.376 0.024
#> ERR184089     6  0.2868     0.7713 0.000 0.028 0.132 0.000 0.000 0.840
#> ERR184049     2  0.5028     0.6467 0.048 0.708 0.000 0.000 0.140 0.104
#> ERR184038     2  0.7236    -0.1521 0.124 0.408 0.004 0.000 0.312 0.152
#> ERR184087     3  0.0713     0.8226 0.000 0.000 0.972 0.000 0.000 0.028
#> ERR184097     2  0.1059     0.8228 0.004 0.964 0.000 0.000 0.016 0.016
#> ERR184094     3  0.6573     0.0622 0.004 0.032 0.436 0.012 0.388 0.128
#> ERR184058     2  0.3852     0.7023 0.020 0.764 0.000 0.000 0.024 0.192
#> ERR184036     2  0.0665     0.8245 0.008 0.980 0.000 0.000 0.008 0.004
#> ERR184046     2  0.1588     0.8072 0.000 0.924 0.000 0.000 0.004 0.072
#> ERR184074     1  0.1657     0.7297 0.936 0.040 0.000 0.000 0.012 0.012
#> ERR184048     2  0.1599     0.8174 0.028 0.940 0.000 0.000 0.024 0.008

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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.


CV:NMF

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "NMF"]
# you can also extract it by
# res = res_list["CV:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk CV-NMF-select-partition-number

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.662           0.863       0.931         0.4772 0.511   0.511
#> 3 3 0.529           0.727       0.868         0.1550 0.867   0.763
#> 4 4 0.465           0.651       0.821         0.2158 0.723   0.481
#> 5 5 0.547           0.457       0.761         0.0943 0.948   0.843
#> 6 6 0.566           0.478       0.697         0.0497 0.867   0.595

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.0376      0.935 0.004 0.996
#> ERR184093     2  0.2236      0.932 0.036 0.964
#> ERR184051     1  0.0376      0.905 0.996 0.004
#> ERR184076     2  0.0376      0.935 0.004 0.996
#> ERR184043     1  0.0376      0.905 0.996 0.004
#> ERR184037     2  0.0000      0.937 0.000 1.000
#> ERR184059     1  0.0938      0.906 0.988 0.012
#> ERR184055     2  0.0000      0.937 0.000 1.000
#> ERR184065     1  0.0672      0.906 0.992 0.008
#> ERR184069     2  0.4161      0.900 0.084 0.916
#> ERR184040     2  0.0376      0.938 0.004 0.996
#> ERR184057     2  0.1633      0.937 0.024 0.976
#> ERR184082     1  0.7602      0.753 0.780 0.220
#> ERR184083     2  0.9552      0.384 0.376 0.624
#> ERR184039     1  0.1414      0.904 0.980 0.020
#> ERR184064     1  0.0376      0.905 0.996 0.004
#> ERR184081     2  0.4815      0.884 0.104 0.896
#> ERR184095     2  0.1633      0.937 0.024 0.976
#> ERR184079     2  0.0000      0.937 0.000 1.000
#> ERR184084     1  0.7745      0.744 0.772 0.228
#> ERR184068     2  0.1414      0.938 0.020 0.980
#> ERR184067     2  0.5059      0.876 0.112 0.888
#> ERR184071     1  0.6623      0.810 0.828 0.172
#> ERR184042     1  0.4562      0.852 0.904 0.096
#> ERR184063     1  0.0376      0.905 0.996 0.004
#> ERR184091     1  0.0938      0.906 0.988 0.012
#> ERR184061     2  0.3274      0.920 0.060 0.940
#> ERR184077     2  0.0938      0.939 0.012 0.988
#> ERR184062     2  0.4939      0.857 0.108 0.892
#> ERR184053     2  0.0376      0.938 0.004 0.996
#> ERR184088     2  0.1414      0.938 0.020 0.980
#> ERR184075     1  0.0376      0.905 0.996 0.004
#> ERR184041     1  0.0376      0.905 0.996 0.004
#> ERR184060     2  0.2778      0.926 0.048 0.952
#> ERR184035     2  0.0938      0.939 0.012 0.988
#> ERR184086     1  0.0672      0.906 0.992 0.008
#> ERR184080     2  0.0000      0.937 0.000 1.000
#> ERR184050     1  0.0672      0.906 0.992 0.008
#> ERR184047     2  0.3733      0.899 0.072 0.928
#> ERR184092     2  0.2423      0.930 0.040 0.960
#> ERR184072     2  0.0376      0.935 0.004 0.996
#> ERR184073     2  0.9850      0.196 0.428 0.572
#> ERR184066     2  0.0000      0.937 0.000 1.000
#> ERR184098     1  0.1184      0.905 0.984 0.016
#> ERR184044     2  0.8386      0.647 0.268 0.732
#> ERR184054     2  0.0376      0.935 0.004 0.996
#> ERR184085     1  0.9323      0.523 0.652 0.348
#> ERR184056     2  0.0376      0.938 0.004 0.996
#> ERR184052     1  0.8144      0.700 0.748 0.252
#> ERR184070     2  0.0938      0.939 0.012 0.988
#> ERR184096     2  0.0376      0.935 0.004 0.996
#> ERR184089     1  0.0376      0.905 0.996 0.004
#> ERR184049     2  0.5059      0.875 0.112 0.888
#> ERR184038     1  0.9881      0.286 0.564 0.436
#> ERR184087     1  0.0376      0.905 0.996 0.004
#> ERR184097     2  0.1184      0.939 0.016 0.984
#> ERR184094     1  0.1843      0.901 0.972 0.028
#> ERR184058     1  0.5408      0.847 0.876 0.124
#> ERR184036     2  0.2603      0.930 0.044 0.956
#> ERR184046     1  0.6623      0.808 0.828 0.172
#> ERR184074     2  0.0376      0.935 0.004 0.996
#> ERR184048     2  0.0938      0.939 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0892     0.8640 0.980 0.000 0.020
#> ERR184093     1  0.1170     0.8681 0.976 0.008 0.016
#> ERR184051     2  0.1964     0.7646 0.000 0.944 0.056
#> ERR184076     1  0.1399     0.8574 0.968 0.004 0.028
#> ERR184043     2  0.2537     0.7420 0.000 0.920 0.080
#> ERR184037     1  0.1289     0.8664 0.968 0.000 0.032
#> ERR184059     2  0.1411     0.7789 0.000 0.964 0.036
#> ERR184055     1  0.1529     0.8664 0.960 0.000 0.040
#> ERR184065     2  0.1289     0.7864 0.000 0.968 0.032
#> ERR184069     2  0.9142     0.3141 0.324 0.512 0.164
#> ERR184040     1  0.0424     0.8629 0.992 0.000 0.008
#> ERR184057     1  0.3780     0.8521 0.892 0.044 0.064
#> ERR184082     2  0.3846     0.7567 0.016 0.876 0.108
#> ERR184083     2  0.5637     0.6985 0.040 0.788 0.172
#> ERR184039     2  0.0424     0.7880 0.000 0.992 0.008
#> ERR184064     2  0.1860     0.7677 0.000 0.948 0.052
#> ERR184081     2  0.9070     0.3460 0.308 0.528 0.164
#> ERR184095     1  0.6324     0.7746 0.764 0.076 0.160
#> ERR184079     1  0.4139     0.8402 0.860 0.016 0.124
#> ERR184084     2  0.5060     0.7317 0.064 0.836 0.100
#> ERR184068     1  0.7739     0.6916 0.676 0.136 0.188
#> ERR184067     2  0.9317     0.0833 0.388 0.448 0.164
#> ERR184071     2  0.5473     0.7132 0.052 0.808 0.140
#> ERR184042     3  0.4504     0.0000 0.000 0.196 0.804
#> ERR184063     2  0.1860     0.7677 0.000 0.948 0.052
#> ERR184091     2  0.0892     0.7868 0.000 0.980 0.020
#> ERR184061     1  0.3112     0.8570 0.916 0.056 0.028
#> ERR184077     1  0.5159     0.8147 0.820 0.040 0.140
#> ERR184062     1  0.2947     0.8431 0.920 0.020 0.060
#> ERR184053     1  0.5850     0.7862 0.772 0.040 0.188
#> ERR184088     1  0.1832     0.8661 0.956 0.008 0.036
#> ERR184075     2  0.0237     0.7878 0.000 0.996 0.004
#> ERR184041     2  0.1643     0.7736 0.000 0.956 0.044
#> ERR184060     1  0.7797     0.4473 0.608 0.320 0.072
#> ERR184035     1  0.3722     0.8495 0.888 0.024 0.088
#> ERR184086     2  0.0892     0.7839 0.000 0.980 0.020
#> ERR184080     1  0.0237     0.8642 0.996 0.000 0.004
#> ERR184050     2  0.0592     0.7862 0.000 0.988 0.012
#> ERR184047     1  0.1950     0.8536 0.952 0.008 0.040
#> ERR184092     1  0.6363     0.7798 0.768 0.096 0.136
#> ERR184072     1  0.1753     0.8533 0.952 0.000 0.048
#> ERR184073     1  0.6126     0.6417 0.712 0.268 0.020
#> ERR184066     1  0.1529     0.8541 0.960 0.000 0.040
#> ERR184098     2  0.0237     0.7871 0.000 0.996 0.004
#> ERR184044     1  0.5378     0.6602 0.756 0.236 0.008
#> ERR184054     1  0.1163     0.8579 0.972 0.000 0.028
#> ERR184085     2  0.5020     0.7358 0.056 0.836 0.108
#> ERR184056     1  0.0747     0.8668 0.984 0.000 0.016
#> ERR184052     2  0.5815     0.6979 0.096 0.800 0.104
#> ERR184070     1  0.3009     0.8624 0.920 0.028 0.052
#> ERR184096     1  0.1289     0.8566 0.968 0.000 0.032
#> ERR184089     2  0.1411     0.7789 0.000 0.964 0.036
#> ERR184049     1  0.9226     0.0329 0.436 0.412 0.152
#> ERR184038     2  0.7549     0.0383 0.436 0.524 0.040
#> ERR184087     2  0.1753     0.7709 0.000 0.952 0.048
#> ERR184097     1  0.0237     0.8640 0.996 0.000 0.004
#> ERR184094     2  0.1031     0.7836 0.000 0.976 0.024
#> ERR184058     2  0.4514     0.7317 0.012 0.832 0.156
#> ERR184036     1  0.7447     0.7089 0.700 0.160 0.140
#> ERR184046     2  0.4326     0.7402 0.012 0.844 0.144
#> ERR184074     1  0.0592     0.8618 0.988 0.000 0.012
#> ERR184048     1  0.2796     0.8564 0.908 0.000 0.092

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.2530     0.8361 0.896 0.100 0.000 0.004
#> ERR184093     1  0.2665     0.8382 0.900 0.088 0.008 0.004
#> ERR184051     3  0.0817     0.8643 0.000 0.000 0.976 0.024
#> ERR184076     1  0.2342     0.8446 0.912 0.080 0.000 0.008
#> ERR184043     3  0.0921     0.8621 0.000 0.000 0.972 0.028
#> ERR184037     1  0.4228     0.7192 0.760 0.232 0.000 0.008
#> ERR184059     3  0.0592     0.8688 0.000 0.000 0.984 0.016
#> ERR184055     1  0.4295     0.6988 0.752 0.240 0.000 0.008
#> ERR184065     3  0.1211     0.8500 0.000 0.040 0.960 0.000
#> ERR184069     2  0.4001     0.6652 0.048 0.840 0.108 0.004
#> ERR184040     1  0.1022     0.8508 0.968 0.032 0.000 0.000
#> ERR184057     2  0.5369     0.5370 0.296 0.676 0.016 0.012
#> ERR184082     2  0.5406     0.1842 0.000 0.508 0.480 0.012
#> ERR184083     2  0.4214     0.6095 0.000 0.780 0.204 0.016
#> ERR184039     3  0.0779     0.8647 0.000 0.016 0.980 0.004
#> ERR184064     3  0.0707     0.8665 0.000 0.000 0.980 0.020
#> ERR184081     2  0.5566     0.6700 0.080 0.744 0.164 0.012
#> ERR184095     2  0.1486     0.6264 0.024 0.960 0.008 0.008
#> ERR184079     2  0.4533     0.5815 0.232 0.752 0.004 0.012
#> ERR184084     2  0.5466     0.3012 0.000 0.548 0.436 0.016
#> ERR184068     2  0.4883     0.5855 0.128 0.800 0.048 0.024
#> ERR184067     2  0.4805     0.6712 0.068 0.796 0.128 0.008
#> ERR184071     3  0.5345     0.0495 0.000 0.428 0.560 0.012
#> ERR184042     4  0.1305     0.0000 0.004 0.000 0.036 0.960
#> ERR184063     3  0.0592     0.8688 0.000 0.000 0.984 0.016
#> ERR184091     3  0.1022     0.8563 0.000 0.032 0.968 0.000
#> ERR184061     1  0.4590     0.7759 0.804 0.144 0.040 0.012
#> ERR184077     2  0.2040     0.6259 0.048 0.936 0.004 0.012
#> ERR184062     1  0.1509     0.8408 0.960 0.008 0.020 0.012
#> ERR184053     2  0.3981     0.5999 0.100 0.848 0.012 0.040
#> ERR184088     1  0.5099     0.2531 0.612 0.380 0.000 0.008
#> ERR184075     3  0.0524     0.8678 0.000 0.008 0.988 0.004
#> ERR184041     3  0.0336     0.8702 0.000 0.000 0.992 0.008
#> ERR184060     2  0.7350     0.5000 0.336 0.508 0.152 0.004
#> ERR184035     2  0.4834     0.5886 0.252 0.728 0.012 0.008
#> ERR184086     3  0.0000     0.8700 0.000 0.000 1.000 0.000
#> ERR184080     1  0.2281     0.8404 0.904 0.096 0.000 0.000
#> ERR184050     3  0.0188     0.8704 0.000 0.000 0.996 0.004
#> ERR184047     1  0.1022     0.8514 0.968 0.032 0.000 0.000
#> ERR184092     2  0.5853     0.4821 0.332 0.628 0.028 0.012
#> ERR184072     1  0.3392     0.7922 0.856 0.124 0.000 0.020
#> ERR184073     1  0.6300     0.4417 0.636 0.072 0.284 0.008
#> ERR184066     1  0.1042     0.8514 0.972 0.020 0.000 0.008
#> ERR184098     3  0.0336     0.8686 0.000 0.008 0.992 0.000
#> ERR184044     1  0.4800     0.6752 0.760 0.044 0.196 0.000
#> ERR184054     1  0.0817     0.8510 0.976 0.024 0.000 0.000
#> ERR184085     2  0.5330     0.2207 0.004 0.516 0.476 0.004
#> ERR184056     1  0.3908     0.7408 0.784 0.212 0.000 0.004
#> ERR184052     3  0.5474     0.4263 0.024 0.280 0.684 0.012
#> ERR184070     2  0.5408     0.0621 0.488 0.500 0.000 0.012
#> ERR184096     1  0.0779     0.8501 0.980 0.016 0.000 0.004
#> ERR184089     3  0.0336     0.8702 0.000 0.000 0.992 0.008
#> ERR184049     2  0.5813     0.6598 0.088 0.716 0.188 0.008
#> ERR184038     3  0.6829     0.2801 0.332 0.084 0.572 0.012
#> ERR184087     3  0.0592     0.8688 0.000 0.000 0.984 0.016
#> ERR184097     1  0.2197     0.8484 0.916 0.080 0.000 0.004
#> ERR184094     3  0.1339     0.8519 0.024 0.004 0.964 0.008
#> ERR184058     2  0.5257     0.3099 0.000 0.548 0.444 0.008
#> ERR184036     2  0.7491     0.3728 0.352 0.500 0.136 0.012
#> ERR184046     3  0.5444     0.0423 0.000 0.424 0.560 0.016
#> ERR184074     1  0.1545     0.8472 0.952 0.040 0.000 0.008
#> ERR184048     2  0.4212     0.6145 0.216 0.772 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.4328     0.6480 0.756 0.032 0.000 0.012 0.200
#> ERR184093     1  0.5177     0.6317 0.672 0.052 0.008 0.004 0.264
#> ERR184051     3  0.0290     0.8878 0.000 0.000 0.992 0.008 0.000
#> ERR184076     1  0.3048     0.6779 0.820 0.000 0.000 0.004 0.176
#> ERR184043     3  0.0290     0.8878 0.000 0.000 0.992 0.008 0.000
#> ERR184037     1  0.5998     0.1852 0.464 0.424 0.000 0.000 0.112
#> ERR184059     3  0.0290     0.8879 0.000 0.000 0.992 0.008 0.000
#> ERR184055     1  0.6409     0.2504 0.444 0.404 0.000 0.004 0.148
#> ERR184065     3  0.1205     0.8626 0.000 0.040 0.956 0.000 0.004
#> ERR184069     2  0.1461     0.3378 0.004 0.952 0.016 0.000 0.028
#> ERR184040     1  0.1981     0.7152 0.920 0.016 0.000 0.000 0.064
#> ERR184057     2  0.5546     0.2352 0.208 0.656 0.004 0.000 0.132
#> ERR184082     2  0.6615    -0.1338 0.008 0.508 0.276 0.000 0.208
#> ERR184083     2  0.5258    -0.1734 0.004 0.636 0.064 0.000 0.296
#> ERR184039     3  0.0671     0.8827 0.000 0.016 0.980 0.000 0.004
#> ERR184064     3  0.0162     0.8888 0.000 0.000 0.996 0.004 0.000
#> ERR184081     2  0.2795     0.3706 0.024 0.892 0.060 0.000 0.024
#> ERR184095     2  0.3093     0.1795 0.008 0.824 0.000 0.000 0.168
#> ERR184079     2  0.5210     0.2571 0.132 0.684 0.000 0.000 0.184
#> ERR184084     2  0.6731    -0.1777 0.008 0.488 0.248 0.000 0.256
#> ERR184068     5  0.5903     0.0000 0.040 0.408 0.020 0.008 0.524
#> ERR184067     2  0.3138     0.3583 0.032 0.876 0.032 0.000 0.060
#> ERR184071     3  0.6271    -0.1267 0.004 0.384 0.480 0.000 0.132
#> ERR184042     4  0.0579     0.0000 0.008 0.000 0.008 0.984 0.000
#> ERR184063     3  0.0290     0.8878 0.000 0.000 0.992 0.008 0.000
#> ERR184091     3  0.0671     0.8828 0.000 0.016 0.980 0.000 0.004
#> ERR184061     1  0.6788     0.4798 0.544 0.292 0.028 0.008 0.128
#> ERR184077     2  0.4678    -0.0628 0.028 0.668 0.000 0.004 0.300
#> ERR184062     1  0.5244     0.6639 0.728 0.048 0.024 0.016 0.184
#> ERR184053     2  0.5193    -0.2563 0.032 0.484 0.000 0.004 0.480
#> ERR184088     2  0.5719     0.1668 0.416 0.508 0.000 0.004 0.072
#> ERR184075     3  0.0162     0.8889 0.000 0.000 0.996 0.000 0.004
#> ERR184041     3  0.0162     0.8888 0.000 0.000 0.996 0.004 0.000
#> ERR184060     2  0.5409     0.3094 0.260 0.664 0.040 0.000 0.036
#> ERR184035     2  0.5388     0.1267 0.152 0.680 0.004 0.000 0.164
#> ERR184086     3  0.0162     0.8889 0.000 0.000 0.996 0.000 0.004
#> ERR184080     1  0.4141     0.6951 0.800 0.104 0.000 0.008 0.088
#> ERR184050     3  0.0566     0.8853 0.000 0.012 0.984 0.000 0.004
#> ERR184047     1  0.1117     0.7196 0.964 0.016 0.000 0.000 0.020
#> ERR184092     2  0.5627     0.2378 0.184 0.652 0.000 0.004 0.160
#> ERR184072     1  0.5542     0.5006 0.560 0.032 0.000 0.024 0.384
#> ERR184073     1  0.7881     0.3638 0.472 0.156 0.260 0.008 0.104
#> ERR184066     1  0.2789     0.7178 0.880 0.020 0.000 0.008 0.092
#> ERR184098     3  0.0000     0.8893 0.000 0.000 1.000 0.000 0.000
#> ERR184044     1  0.6089     0.5505 0.652 0.084 0.204 0.000 0.060
#> ERR184054     1  0.2103     0.7182 0.920 0.020 0.000 0.004 0.056
#> ERR184085     2  0.4982     0.1559 0.000 0.692 0.220 0.000 0.088
#> ERR184056     1  0.6105     0.5307 0.568 0.148 0.000 0.004 0.280
#> ERR184052     3  0.5325    -0.0170 0.020 0.436 0.524 0.000 0.020
#> ERR184070     2  0.5878     0.2343 0.324 0.556 0.000 0.000 0.120
#> ERR184096     1  0.1364     0.7181 0.952 0.012 0.000 0.000 0.036
#> ERR184089     3  0.0000     0.8893 0.000 0.000 1.000 0.000 0.000
#> ERR184049     2  0.4345     0.3692 0.056 0.808 0.068 0.000 0.068
#> ERR184038     3  0.6502     0.2827 0.240 0.004 0.556 0.008 0.192
#> ERR184087     3  0.0324     0.8886 0.000 0.004 0.992 0.004 0.000
#> ERR184097     1  0.3292     0.6991 0.836 0.016 0.000 0.008 0.140
#> ERR184094     3  0.1569     0.8514 0.032 0.012 0.948 0.008 0.000
#> ERR184058     2  0.4547     0.1991 0.000 0.736 0.192 0.000 0.072
#> ERR184036     2  0.6307     0.2637 0.188 0.636 0.036 0.004 0.136
#> ERR184046     2  0.6728    -0.2157 0.000 0.416 0.308 0.000 0.276
#> ERR184074     1  0.4280     0.6872 0.788 0.120 0.000 0.008 0.084
#> ERR184048     2  0.5045     0.1128 0.108 0.696 0.000 0.000 0.196

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.5294    0.45375 0.688 0.048 0.000 0.004 0.160 0.100
#> ERR184093     1  0.6274    0.09274 0.456 0.028 0.004 0.004 0.388 0.120
#> ERR184051     3  0.0692    0.89584 0.004 0.000 0.976 0.000 0.020 0.000
#> ERR184076     1  0.3954    0.52450 0.764 0.008 0.000 0.000 0.172 0.056
#> ERR184043     3  0.0508    0.89765 0.004 0.000 0.984 0.000 0.012 0.000
#> ERR184037     6  0.5380    0.33283 0.304 0.080 0.000 0.000 0.024 0.592
#> ERR184059     3  0.0837    0.89582 0.004 0.004 0.972 0.000 0.020 0.000
#> ERR184055     6  0.4595    0.39808 0.264 0.040 0.000 0.000 0.020 0.676
#> ERR184065     3  0.2644    0.83306 0.000 0.072 0.884 0.004 0.012 0.028
#> ERR184069     6  0.4486    0.07692 0.000 0.464 0.008 0.000 0.016 0.512
#> ERR184040     1  0.2364    0.63253 0.892 0.000 0.000 0.004 0.032 0.072
#> ERR184057     2  0.5719    0.38523 0.148 0.620 0.000 0.000 0.040 0.192
#> ERR184082     2  0.3614    0.53099 0.000 0.812 0.120 0.000 0.048 0.020
#> ERR184083     2  0.1616    0.55902 0.000 0.940 0.028 0.000 0.012 0.020
#> ERR184039     3  0.1692    0.87339 0.000 0.048 0.932 0.000 0.008 0.012
#> ERR184064     3  0.0260    0.89938 0.000 0.000 0.992 0.000 0.008 0.000
#> ERR184081     6  0.4317    0.25507 0.000 0.408 0.016 0.000 0.004 0.572
#> ERR184095     2  0.3983    0.45145 0.000 0.736 0.000 0.000 0.056 0.208
#> ERR184079     6  0.5996    0.37192 0.048 0.288 0.000 0.004 0.096 0.564
#> ERR184084     2  0.3999    0.51237 0.004 0.800 0.120 0.004 0.036 0.036
#> ERR184068     5  0.6391   -0.12337 0.016 0.420 0.012 0.012 0.428 0.112
#> ERR184067     6  0.4716    0.35470 0.008 0.344 0.008 0.000 0.028 0.612
#> ERR184071     2  0.4780    0.33975 0.000 0.592 0.360 0.000 0.028 0.020
#> ERR184042     4  0.0146    0.00000 0.004 0.000 0.000 0.996 0.000 0.000
#> ERR184063     3  0.0777    0.89947 0.000 0.000 0.972 0.000 0.024 0.004
#> ERR184091     3  0.1483    0.88312 0.000 0.036 0.944 0.000 0.008 0.012
#> ERR184061     6  0.5757    0.35114 0.232 0.028 0.040 0.000 0.064 0.636
#> ERR184077     2  0.5246    0.37280 0.004 0.620 0.000 0.000 0.152 0.224
#> ERR184062     1  0.6306    0.40447 0.568 0.000 0.048 0.008 0.216 0.160
#> ERR184053     2  0.7069    0.00937 0.032 0.388 0.000 0.020 0.256 0.304
#> ERR184088     2  0.6718   -0.22876 0.300 0.340 0.000 0.000 0.032 0.328
#> ERR184075     3  0.0622    0.89731 0.000 0.012 0.980 0.000 0.008 0.000
#> ERR184041     3  0.0291    0.90024 0.000 0.000 0.992 0.000 0.004 0.004
#> ERR184060     2  0.6386   -0.12398 0.176 0.416 0.012 0.000 0.012 0.384
#> ERR184035     2  0.4164    0.51920 0.068 0.780 0.000 0.000 0.036 0.116
#> ERR184086     3  0.0146    0.89993 0.000 0.000 0.996 0.000 0.004 0.000
#> ERR184080     1  0.4515    0.59474 0.716 0.024 0.000 0.000 0.052 0.208
#> ERR184050     3  0.1657    0.88053 0.000 0.012 0.936 0.000 0.012 0.040
#> ERR184047     1  0.3833    0.63199 0.800 0.000 0.028 0.000 0.052 0.120
#> ERR184092     6  0.6635    0.47574 0.128 0.216 0.000 0.000 0.124 0.532
#> ERR184072     5  0.5560   -0.26063 0.360 0.016 0.000 0.000 0.528 0.096
#> ERR184073     6  0.7687   -0.14095 0.244 0.004 0.288 0.000 0.156 0.308
#> ERR184066     1  0.4176    0.62490 0.752 0.000 0.008 0.000 0.080 0.160
#> ERR184098     3  0.0520    0.89883 0.000 0.000 0.984 0.000 0.008 0.008
#> ERR184044     1  0.6720    0.33307 0.492 0.004 0.252 0.000 0.060 0.192
#> ERR184054     1  0.3261    0.63809 0.824 0.000 0.000 0.000 0.072 0.104
#> ERR184085     2  0.5599    0.45773 0.000 0.632 0.116 0.004 0.032 0.216
#> ERR184056     1  0.7363   -0.05244 0.380 0.176 0.000 0.000 0.292 0.152
#> ERR184052     3  0.6368   -0.29694 0.016 0.404 0.428 0.000 0.020 0.132
#> ERR184070     6  0.5439    0.52302 0.140 0.200 0.000 0.000 0.024 0.636
#> ERR184096     1  0.3297    0.62952 0.820 0.000 0.000 0.000 0.068 0.112
#> ERR184089     3  0.0146    0.89998 0.000 0.000 0.996 0.000 0.000 0.004
#> ERR184049     6  0.4680    0.43033 0.016 0.300 0.016 0.000 0.016 0.652
#> ERR184038     3  0.6379    0.36177 0.208 0.064 0.580 0.000 0.136 0.012
#> ERR184087     3  0.0291    0.90024 0.000 0.000 0.992 0.000 0.004 0.004
#> ERR184097     1  0.3974    0.60656 0.808 0.028 0.004 0.004 0.064 0.092
#> ERR184094     3  0.2361    0.83536 0.032 0.000 0.896 0.000 0.008 0.064
#> ERR184058     2  0.4958    0.47923 0.000 0.680 0.132 0.000 0.012 0.176
#> ERR184036     6  0.5393    0.54396 0.080 0.184 0.012 0.000 0.044 0.680
#> ERR184046     2  0.4988    0.40858 0.000 0.672 0.224 0.000 0.080 0.024
#> ERR184074     1  0.5122    0.43853 0.564 0.004 0.004 0.000 0.068 0.360
#> ERR184048     2  0.2725    0.55268 0.040 0.880 0.000 0.000 0.020 0.060

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-CV-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-CV-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-CV-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-CV-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-CV-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-CV-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-CV-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-CV-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-CV-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-CV-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-CV-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-CV-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-CV-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-CV-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-CV-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-CV-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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.


MAD:hclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "hclust"]
# you can also extract it by
# res = res_list["MAD:hclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-hclust-select-partition-number

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.560           0.857       0.895         0.3502 0.568   0.568
#> 3 3 0.667           0.781       0.920         0.4007 0.870   0.785
#> 4 4 0.695           0.818       0.931         0.0257 0.979   0.959
#> 5 5 0.738           0.810       0.925         0.1022 0.949   0.897
#> 6 6 0.738           0.765       0.898         0.0310 0.937   0.870

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 5

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.8955     0.8766 0.688 0.312
#> ERR184093     2  0.0000     0.9441 0.000 1.000
#> ERR184051     1  0.8713     0.8929 0.708 0.292
#> ERR184076     1  0.8955     0.8766 0.688 0.312
#> ERR184043     1  0.8713     0.8929 0.708 0.292
#> ERR184037     2  0.9866    -0.2368 0.432 0.568
#> ERR184059     1  0.8661     0.8922 0.712 0.288
#> ERR184055     2  0.9580     0.0135 0.380 0.620
#> ERR184065     2  0.0000     0.9441 0.000 1.000
#> ERR184069     2  0.0000     0.9441 0.000 1.000
#> ERR184040     1  0.8267     0.8763 0.740 0.260
#> ERR184057     2  0.0000     0.9441 0.000 1.000
#> ERR184082     2  0.1414     0.9284 0.020 0.980
#> ERR184083     2  0.0000     0.9441 0.000 1.000
#> ERR184039     2  0.0000     0.9441 0.000 1.000
#> ERR184064     1  0.8713     0.8929 0.708 0.292
#> ERR184081     2  0.0000     0.9441 0.000 1.000
#> ERR184095     2  0.0000     0.9441 0.000 1.000
#> ERR184079     2  0.0000     0.9441 0.000 1.000
#> ERR184084     1  0.8661     0.8922 0.712 0.288
#> ERR184068     2  0.0938     0.9354 0.012 0.988
#> ERR184067     2  0.0000     0.9441 0.000 1.000
#> ERR184071     2  0.0000     0.9441 0.000 1.000
#> ERR184042     1  0.0000     0.6791 1.000 0.000
#> ERR184063     1  0.8713     0.8929 0.708 0.292
#> ERR184091     2  0.0000     0.9441 0.000 1.000
#> ERR184061     2  0.1184     0.9317 0.016 0.984
#> ERR184077     2  0.0000     0.9441 0.000 1.000
#> ERR184062     2  0.2948     0.8934 0.052 0.948
#> ERR184053     2  0.0376     0.9412 0.004 0.996
#> ERR184088     2  0.0000     0.9441 0.000 1.000
#> ERR184075     2  0.0000     0.9441 0.000 1.000
#> ERR184041     1  0.8713     0.8929 0.708 0.292
#> ERR184060     2  0.0000     0.9441 0.000 1.000
#> ERR184035     2  0.1414     0.9284 0.020 0.980
#> ERR184086     2  0.0000     0.9441 0.000 1.000
#> ERR184080     2  0.8327     0.4789 0.264 0.736
#> ERR184050     2  0.0000     0.9441 0.000 1.000
#> ERR184047     1  0.0000     0.6791 1.000 0.000
#> ERR184092     2  0.0000     0.9441 0.000 1.000
#> ERR184072     1  0.9087     0.8632 0.676 0.324
#> ERR184073     1  0.8267     0.8763 0.740 0.260
#> ERR184066     2  0.8327     0.4761 0.264 0.736
#> ERR184098     2  0.0000     0.9441 0.000 1.000
#> ERR184044     2  0.2603     0.9024 0.044 0.956
#> ERR184054     1  0.9896     0.6294 0.560 0.440
#> ERR184085     2  0.1633     0.9244 0.024 0.976
#> ERR184056     2  0.0000     0.9441 0.000 1.000
#> ERR184052     2  0.0000     0.9441 0.000 1.000
#> ERR184070     2  0.0000     0.9441 0.000 1.000
#> ERR184096     1  0.0000     0.6791 1.000 0.000
#> ERR184089     2  0.0000     0.9441 0.000 1.000
#> ERR184049     2  0.0000     0.9441 0.000 1.000
#> ERR184038     2  0.5946     0.7505 0.144 0.856
#> ERR184087     1  0.8713     0.8929 0.708 0.292
#> ERR184097     2  0.0000     0.9441 0.000 1.000
#> ERR184094     1  0.8386     0.8809 0.732 0.268
#> ERR184058     2  0.0000     0.9441 0.000 1.000
#> ERR184036     2  0.0000     0.9441 0.000 1.000
#> ERR184046     2  0.0000     0.9441 0.000 1.000
#> ERR184074     1  0.9044     0.8685 0.680 0.320
#> ERR184048     2  0.0000     0.9441 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0829     0.7857 0.984 0.012 0.004
#> ERR184093     2  0.1163     0.9334 0.028 0.972 0.000
#> ERR184051     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184076     1  0.0829     0.7857 0.984 0.012 0.004
#> ERR184043     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184037     1  0.5254     0.5240 0.736 0.264 0.000
#> ERR184059     1  0.0747     0.7853 0.984 0.000 0.016
#> ERR184055     1  0.5678     0.4624 0.684 0.316 0.000
#> ERR184065     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184069     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184040     1  0.1964     0.7624 0.944 0.000 0.056
#> ERR184057     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184082     2  0.4399     0.7926 0.188 0.812 0.000
#> ERR184083     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184039     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184064     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184081     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184079     2  0.1031     0.9353 0.024 0.976 0.000
#> ERR184084     1  0.0747     0.7853 0.984 0.000 0.016
#> ERR184068     2  0.2959     0.8824 0.100 0.900 0.000
#> ERR184067     2  0.0237     0.9399 0.004 0.996 0.000
#> ERR184071     2  0.0237     0.9399 0.004 0.996 0.000
#> ERR184042     3  0.0000     0.0000 0.000 0.000 1.000
#> ERR184063     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184091     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184061     2  0.4002     0.8137 0.160 0.840 0.000
#> ERR184077     2  0.0892     0.9368 0.020 0.980 0.000
#> ERR184062     2  0.5216     0.6823 0.260 0.740 0.000
#> ERR184053     2  0.2537     0.8970 0.080 0.920 0.000
#> ERR184088     2  0.0424     0.9399 0.008 0.992 0.000
#> ERR184075     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184041     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184060     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184035     2  0.4399     0.7926 0.188 0.812 0.000
#> ERR184086     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184080     1  0.6521    -0.0222 0.500 0.496 0.004
#> ERR184050     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184047     1  0.6280     0.0530 0.540 0.000 0.460
#> ERR184092     2  0.1163     0.9334 0.028 0.972 0.000
#> ERR184072     1  0.0892     0.7818 0.980 0.020 0.000
#> ERR184073     1  0.1964     0.7624 0.944 0.000 0.056
#> ERR184066     1  0.6305     0.0239 0.516 0.484 0.000
#> ERR184098     2  0.0592     0.9387 0.012 0.988 0.000
#> ERR184044     2  0.4702     0.7585 0.212 0.788 0.000
#> ERR184054     1  0.3983     0.6625 0.852 0.144 0.004
#> ERR184085     2  0.4504     0.7820 0.196 0.804 0.000
#> ERR184056     2  0.1529     0.9264 0.040 0.960 0.000
#> ERR184052     2  0.0237     0.9399 0.004 0.996 0.000
#> ERR184070     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184096     1  0.6280     0.0530 0.540 0.000 0.460
#> ERR184089     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184049     2  0.0424     0.9399 0.008 0.992 0.000
#> ERR184038     2  0.6026     0.4177 0.376 0.624 0.000
#> ERR184087     1  0.0592     0.7874 0.988 0.000 0.012
#> ERR184097     2  0.1163     0.9331 0.028 0.972 0.000
#> ERR184094     1  0.1643     0.7702 0.956 0.000 0.044
#> ERR184058     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184036     2  0.1643     0.9181 0.044 0.956 0.000
#> ERR184046     2  0.0000     0.9400 0.000 1.000 0.000
#> ERR184074     1  0.0747     0.7840 0.984 0.016 0.000
#> ERR184048     2  0.0424     0.9399 0.008 0.992 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.0657    0.80938 0.984 0.012 0.004 0.000
#> ERR184093     2  0.0921    0.93378 0.028 0.972 0.000 0.000
#> ERR184051     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184076     1  0.0657    0.80938 0.984 0.012 0.004 0.000
#> ERR184043     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184037     1  0.4164    0.55160 0.736 0.264 0.000 0.000
#> ERR184059     1  0.1174    0.80624 0.968 0.000 0.020 0.012
#> ERR184055     1  0.4500    0.49036 0.684 0.316 0.000 0.000
#> ERR184065     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184069     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184040     1  0.2216    0.76391 0.908 0.000 0.092 0.000
#> ERR184057     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184082     2  0.3486    0.79087 0.188 0.812 0.000 0.000
#> ERR184083     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184064     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184081     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184095     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184079     2  0.0817    0.93557 0.024 0.976 0.000 0.000
#> ERR184084     1  0.1174    0.80624 0.968 0.000 0.020 0.012
#> ERR184068     2  0.2345    0.88228 0.100 0.900 0.000 0.000
#> ERR184067     2  0.0188    0.94020 0.004 0.996 0.000 0.000
#> ERR184071     2  0.0188    0.94020 0.004 0.996 0.000 0.000
#> ERR184042     4  0.0469    0.00000 0.000 0.000 0.012 0.988
#> ERR184063     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184091     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184061     2  0.3172    0.81049 0.160 0.840 0.000 0.000
#> ERR184077     2  0.0707    0.93715 0.020 0.980 0.000 0.000
#> ERR184062     2  0.4134    0.67827 0.260 0.740 0.000 0.000
#> ERR184053     2  0.2011    0.89770 0.080 0.920 0.000 0.000
#> ERR184088     2  0.0336    0.94019 0.008 0.992 0.000 0.000
#> ERR184075     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184041     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184060     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184035     2  0.3486    0.79087 0.188 0.812 0.000 0.000
#> ERR184086     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184080     1  0.5168    0.00069 0.500 0.496 0.004 0.000
#> ERR184050     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184047     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> ERR184092     2  0.0921    0.93378 0.028 0.972 0.000 0.000
#> ERR184072     1  0.0707    0.80663 0.980 0.020 0.000 0.000
#> ERR184073     1  0.2081    0.77018 0.916 0.000 0.084 0.000
#> ERR184066     1  0.4996    0.05033 0.516 0.484 0.000 0.000
#> ERR184098     2  0.0469    0.93905 0.012 0.988 0.000 0.000
#> ERR184044     2  0.3726    0.75719 0.212 0.788 0.000 0.000
#> ERR184054     1  0.3157    0.69069 0.852 0.144 0.004 0.000
#> ERR184085     2  0.3569    0.78043 0.196 0.804 0.000 0.000
#> ERR184056     2  0.1211    0.92674 0.040 0.960 0.000 0.000
#> ERR184052     2  0.0188    0.94020 0.004 0.996 0.000 0.000
#> ERR184070     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184096     3  0.0000    1.00000 0.000 0.000 1.000 0.000
#> ERR184089     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184049     2  0.0336    0.94012 0.008 0.992 0.000 0.000
#> ERR184038     2  0.4776    0.40768 0.376 0.624 0.000 0.000
#> ERR184087     1  0.0937    0.81011 0.976 0.000 0.012 0.012
#> ERR184097     2  0.0921    0.93340 0.028 0.972 0.000 0.000
#> ERR184094     1  0.2011    0.77424 0.920 0.000 0.080 0.000
#> ERR184058     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184036     2  0.1302    0.91794 0.044 0.956 0.000 0.000
#> ERR184046     2  0.0000    0.94034 0.000 1.000 0.000 0.000
#> ERR184074     1  0.0592    0.80837 0.984 0.016 0.000 0.000
#> ERR184048     2  0.0336    0.94018 0.008 0.992 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> ERR184078     1  0.0324      0.600 0.992 0.000 0.004  0 0.004
#> ERR184093     2  0.1043      0.923 0.040 0.960 0.000  0 0.000
#> ERR184051     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184076     1  0.0162      0.599 0.996 0.000 0.000  0 0.004
#> ERR184043     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184037     1  0.3508      0.548 0.748 0.252 0.000  0 0.000
#> ERR184059     3  0.0290      0.993 0.000 0.000 0.992  0 0.008
#> ERR184055     1  0.3816      0.515 0.696 0.304 0.000  0 0.000
#> ERR184065     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184069     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184040     1  0.3532      0.551 0.832 0.000 0.076  0 0.092
#> ERR184057     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184082     2  0.3109      0.763 0.200 0.800 0.000  0 0.000
#> ERR184083     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184039     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184064     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184081     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184095     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184079     2  0.0880      0.927 0.032 0.968 0.000  0 0.000
#> ERR184084     3  0.0290      0.993 0.000 0.000 0.992  0 0.008
#> ERR184068     2  0.2020      0.870 0.100 0.900 0.000  0 0.000
#> ERR184067     2  0.0404      0.932 0.012 0.988 0.000  0 0.000
#> ERR184071     2  0.0404      0.932 0.012 0.988 0.000  0 0.000
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000
#> ERR184063     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184091     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184061     2  0.2852      0.788 0.172 0.828 0.000  0 0.000
#> ERR184077     2  0.0794      0.929 0.028 0.972 0.000  0 0.000
#> ERR184062     2  0.3636      0.637 0.272 0.728 0.000  0 0.000
#> ERR184053     2  0.1732      0.887 0.080 0.920 0.000  0 0.000
#> ERR184088     2  0.0510      0.932 0.016 0.984 0.000  0 0.000
#> ERR184075     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184041     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184060     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184035     2  0.3109      0.763 0.200 0.800 0.000  0 0.000
#> ERR184086     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184080     1  0.4449      0.119 0.512 0.484 0.000  0 0.004
#> ERR184050     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184047     5  0.0000      1.000 0.000 0.000 0.000  0 1.000
#> ERR184092     2  0.1043      0.923 0.040 0.960 0.000  0 0.000
#> ERR184072     1  0.0290      0.604 0.992 0.008 0.000  0 0.000
#> ERR184073     1  0.3479      0.552 0.836 0.000 0.080  0 0.084
#> ERR184066     1  0.4297      0.159 0.528 0.472 0.000  0 0.000
#> ERR184098     2  0.0404      0.932 0.012 0.988 0.000  0 0.000
#> ERR184044     2  0.3305      0.725 0.224 0.776 0.000  0 0.000
#> ERR184054     1  0.3513      0.602 0.828 0.132 0.036  0 0.004
#> ERR184085     2  0.3177      0.751 0.208 0.792 0.000  0 0.000
#> ERR184056     2  0.1197      0.917 0.048 0.952 0.000  0 0.000
#> ERR184052     2  0.0404      0.932 0.012 0.988 0.000  0 0.000
#> ERR184070     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184096     5  0.0000      1.000 0.000 0.000 0.000  0 1.000
#> ERR184089     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184049     2  0.0609      0.931 0.020 0.980 0.000  0 0.000
#> ERR184038     2  0.4150      0.327 0.388 0.612 0.000  0 0.000
#> ERR184087     3  0.0000      0.998 0.000 0.000 1.000  0 0.000
#> ERR184097     2  0.0963      0.924 0.036 0.964 0.000  0 0.000
#> ERR184094     1  0.4818      0.396 0.708 0.000 0.212  0 0.080
#> ERR184058     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184036     2  0.1270      0.910 0.052 0.948 0.000  0 0.000
#> ERR184046     2  0.0000      0.933 0.000 1.000 0.000  0 0.000
#> ERR184074     1  0.1502      0.605 0.940 0.004 0.056  0 0.000
#> ERR184048     2  0.0510      0.932 0.016 0.984 0.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.0405      0.485 0.988 0.000 0.004  0 0.000 0.008
#> ERR184093     2  0.0865      0.891 0.000 0.964 0.000  0 0.000 0.036
#> ERR184051     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184076     1  0.0000      0.474 1.000 0.000 0.000  0 0.000 0.000
#> ERR184043     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184037     6  0.3494      0.604 0.012 0.252 0.000  0 0.000 0.736
#> ERR184059     3  0.0260      0.993 0.000 0.000 0.992  0 0.008 0.000
#> ERR184055     6  0.4083      0.577 0.028 0.304 0.000  0 0.000 0.668
#> ERR184065     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184069     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184040     1  0.6283      0.668 0.492 0.000 0.076  0 0.088 0.344
#> ERR184057     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184082     2  0.2793      0.727 0.000 0.800 0.000  0 0.000 0.200
#> ERR184083     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184039     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184064     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184081     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184095     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184079     2  0.0713      0.895 0.000 0.972 0.000  0 0.000 0.028
#> ERR184084     3  0.0260      0.993 0.000 0.000 0.992  0 0.008 0.000
#> ERR184068     2  0.2039      0.842 0.020 0.904 0.000  0 0.000 0.076
#> ERR184067     2  0.0260      0.899 0.000 0.992 0.000  0 0.000 0.008
#> ERR184071     2  0.0260      0.899 0.000 0.992 0.000  0 0.000 0.008
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000 0.000
#> ERR184063     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184091     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184061     2  0.2562      0.748 0.000 0.828 0.000  0 0.000 0.172
#> ERR184077     2  0.0632      0.896 0.000 0.976 0.000  0 0.000 0.024
#> ERR184062     2  0.3980      0.608 0.052 0.732 0.000  0 0.000 0.216
#> ERR184053     2  0.1501      0.856 0.000 0.924 0.000  0 0.000 0.076
#> ERR184088     2  0.0363      0.899 0.000 0.988 0.000  0 0.000 0.012
#> ERR184075     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184041     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184060     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184035     2  0.2793      0.727 0.000 0.800 0.000  0 0.000 0.200
#> ERR184086     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184080     2  0.5860     -0.243 0.248 0.484 0.000  0 0.000 0.268
#> ERR184050     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184047     5  0.0000      1.000 0.000 0.000 0.000  0 1.000 0.000
#> ERR184092     2  0.0865      0.891 0.000 0.964 0.000  0 0.000 0.036
#> ERR184072     1  0.3862      0.600 0.524 0.000 0.000  0 0.000 0.476
#> ERR184073     1  0.6209      0.672 0.512 0.000 0.080  0 0.080 0.328
#> ERR184066     2  0.5772     -0.299 0.184 0.468 0.000  0 0.000 0.348
#> ERR184098     2  0.0260      0.900 0.000 0.992 0.000  0 0.000 0.008
#> ERR184044     2  0.2969      0.691 0.000 0.776 0.000  0 0.000 0.224
#> ERR184054     1  0.6097      0.340 0.516 0.132 0.036  0 0.000 0.316
#> ERR184085     2  0.2854      0.715 0.000 0.792 0.000  0 0.000 0.208
#> ERR184056     2  0.1082      0.886 0.004 0.956 0.000  0 0.000 0.040
#> ERR184052     2  0.0260      0.899 0.000 0.992 0.000  0 0.000 0.008
#> ERR184070     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184096     5  0.0000      1.000 0.000 0.000 0.000  0 1.000 0.000
#> ERR184089     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184049     2  0.0458      0.898 0.000 0.984 0.000  0 0.000 0.016
#> ERR184038     2  0.4480      0.297 0.044 0.616 0.000  0 0.000 0.340
#> ERR184087     3  0.0000      0.998 0.000 0.000 1.000  0 0.000 0.000
#> ERR184097     2  0.0790      0.892 0.000 0.968 0.000  0 0.000 0.032
#> ERR184094     1  0.7007      0.570 0.396 0.000 0.212  0 0.076 0.316
#> ERR184058     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184036     2  0.1075      0.877 0.000 0.952 0.000  0 0.000 0.048
#> ERR184046     2  0.0146      0.900 0.000 0.996 0.000  0 0.000 0.004
#> ERR184074     6  0.2129     -0.127 0.040 0.000 0.056  0 0.000 0.904
#> ERR184048     2  0.0363      0.899 0.000 0.988 0.000  0 0.000 0.012

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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.


MAD:kmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "kmeans"]
# you can also extract it by
# res = res_list["MAD:kmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-kmeans-select-partition-number

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.993         0.4855 0.518   0.518
#> 3 3 0.748           0.779       0.894         0.2446 0.788   0.616
#> 4 4 0.679           0.652       0.817         0.1194 0.919   0.795
#> 5 5 0.721           0.735       0.833         0.0912 0.802   0.486
#> 6 6 0.693           0.737       0.823         0.0573 0.948   0.800

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.999 1.000 0.000
#> ERR184093     2  0.0000      0.988 0.000 1.000
#> ERR184051     1  0.0000      0.999 1.000 0.000
#> ERR184076     1  0.0000      0.999 1.000 0.000
#> ERR184043     1  0.0000      0.999 1.000 0.000
#> ERR184037     1  0.0000      0.999 1.000 0.000
#> ERR184059     1  0.0000      0.999 1.000 0.000
#> ERR184055     1  0.0672      0.992 0.992 0.008
#> ERR184065     2  0.0000      0.988 0.000 1.000
#> ERR184069     2  0.0000      0.988 0.000 1.000
#> ERR184040     1  0.0000      0.999 1.000 0.000
#> ERR184057     2  0.0000      0.988 0.000 1.000
#> ERR184082     2  0.0000      0.988 0.000 1.000
#> ERR184083     2  0.0000      0.988 0.000 1.000
#> ERR184039     2  0.0000      0.988 0.000 1.000
#> ERR184064     1  0.0000      0.999 1.000 0.000
#> ERR184081     2  0.0000      0.988 0.000 1.000
#> ERR184095     2  0.0000      0.988 0.000 1.000
#> ERR184079     2  0.0000      0.988 0.000 1.000
#> ERR184084     1  0.0000      0.999 1.000 0.000
#> ERR184068     2  0.0000      0.988 0.000 1.000
#> ERR184067     2  0.0000      0.988 0.000 1.000
#> ERR184071     2  0.0000      0.988 0.000 1.000
#> ERR184042     1  0.0000      0.999 1.000 0.000
#> ERR184063     1  0.0000      0.999 1.000 0.000
#> ERR184091     2  0.0000      0.988 0.000 1.000
#> ERR184061     2  0.0000      0.988 0.000 1.000
#> ERR184077     2  0.0000      0.988 0.000 1.000
#> ERR184062     2  0.0000      0.988 0.000 1.000
#> ERR184053     2  0.0000      0.988 0.000 1.000
#> ERR184088     2  0.0000      0.988 0.000 1.000
#> ERR184075     2  0.0000      0.988 0.000 1.000
#> ERR184041     1  0.0000      0.999 1.000 0.000
#> ERR184060     2  0.0000      0.988 0.000 1.000
#> ERR184035     2  0.4022      0.911 0.080 0.920
#> ERR184086     2  0.0000      0.988 0.000 1.000
#> ERR184080     1  0.0000      0.999 1.000 0.000
#> ERR184050     2  0.0000      0.988 0.000 1.000
#> ERR184047     1  0.0000      0.999 1.000 0.000
#> ERR184092     2  0.0000      0.988 0.000 1.000
#> ERR184072     1  0.0000      0.999 1.000 0.000
#> ERR184073     1  0.0000      0.999 1.000 0.000
#> ERR184066     1  0.0672      0.992 0.992 0.008
#> ERR184098     2  0.0000      0.988 0.000 1.000
#> ERR184044     2  0.8016      0.681 0.244 0.756
#> ERR184054     1  0.0000      0.999 1.000 0.000
#> ERR184085     2  0.4815      0.885 0.104 0.896
#> ERR184056     2  0.0000      0.988 0.000 1.000
#> ERR184052     2  0.0000      0.988 0.000 1.000
#> ERR184070     2  0.0000      0.988 0.000 1.000
#> ERR184096     1  0.0000      0.999 1.000 0.000
#> ERR184089     2  0.0000      0.988 0.000 1.000
#> ERR184049     2  0.0000      0.988 0.000 1.000
#> ERR184038     1  0.0000      0.999 1.000 0.000
#> ERR184087     1  0.0000      0.999 1.000 0.000
#> ERR184097     2  0.0000      0.988 0.000 1.000
#> ERR184094     1  0.0000      0.999 1.000 0.000
#> ERR184058     2  0.0000      0.988 0.000 1.000
#> ERR184036     2  0.0000      0.988 0.000 1.000
#> ERR184046     2  0.0000      0.988 0.000 1.000
#> ERR184074     1  0.0000      0.999 1.000 0.000
#> ERR184048     2  0.0000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.2878     0.6447 0.904 0.000 0.096
#> ERR184093     2  0.1031     0.9477 0.024 0.976 0.000
#> ERR184051     3  0.4605     0.8168 0.204 0.000 0.796
#> ERR184076     1  0.2878     0.6447 0.904 0.000 0.096
#> ERR184043     3  0.4346     0.8261 0.184 0.000 0.816
#> ERR184037     1  0.0237     0.7269 0.996 0.000 0.004
#> ERR184059     3  0.3619     0.8224 0.136 0.000 0.864
#> ERR184055     1  0.0000     0.7266 1.000 0.000 0.000
#> ERR184065     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184069     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184040     1  0.6111    -0.1902 0.604 0.000 0.396
#> ERR184057     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184082     1  0.5465     0.5443 0.712 0.288 0.000
#> ERR184083     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184039     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184064     3  0.4346     0.8261 0.184 0.000 0.816
#> ERR184081     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184079     2  0.2537     0.9081 0.080 0.920 0.000
#> ERR184084     3  0.3752     0.8246 0.144 0.000 0.856
#> ERR184068     2  0.4702     0.7379 0.212 0.788 0.000
#> ERR184067     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184071     2  0.1529     0.9396 0.040 0.960 0.000
#> ERR184042     3  0.0000     0.7378 0.000 0.000 1.000
#> ERR184063     3  0.6299     0.3758 0.476 0.000 0.524
#> ERR184091     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184061     1  0.6252     0.2480 0.556 0.444 0.000
#> ERR184077     2  0.2878     0.8942 0.096 0.904 0.000
#> ERR184062     2  0.6291     0.0407 0.468 0.532 0.000
#> ERR184053     2  0.2959     0.8899 0.100 0.900 0.000
#> ERR184088     2  0.1289     0.9441 0.032 0.968 0.000
#> ERR184075     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184041     3  0.6204     0.5080 0.424 0.000 0.576
#> ERR184060     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184035     1  0.4605     0.6189 0.796 0.204 0.000
#> ERR184086     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184080     1  0.0237     0.7269 0.996 0.000 0.004
#> ERR184050     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184047     3  0.4002     0.7352 0.160 0.000 0.840
#> ERR184092     2  0.1163     0.9460 0.028 0.972 0.000
#> ERR184072     1  0.0237     0.7269 0.996 0.000 0.004
#> ERR184073     3  0.5859     0.7315 0.344 0.000 0.656
#> ERR184066     1  0.0000     0.7266 1.000 0.000 0.000
#> ERR184098     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184044     1  0.2261     0.7026 0.932 0.068 0.000
#> ERR184054     1  0.0592     0.7226 0.988 0.000 0.012
#> ERR184085     1  0.4654     0.6121 0.792 0.208 0.000
#> ERR184056     2  0.1411     0.9421 0.036 0.964 0.000
#> ERR184052     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184070     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184096     3  0.4235     0.7266 0.176 0.000 0.824
#> ERR184089     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184049     1  0.6309     0.0525 0.504 0.496 0.000
#> ERR184038     1  0.2066     0.6911 0.940 0.000 0.060
#> ERR184087     3  0.4235     0.8268 0.176 0.000 0.824
#> ERR184097     2  0.1411     0.9421 0.036 0.964 0.000
#> ERR184094     3  0.5497     0.7612 0.292 0.000 0.708
#> ERR184058     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184036     2  0.0747     0.9507 0.016 0.984 0.000
#> ERR184046     2  0.0000     0.9558 0.000 1.000 0.000
#> ERR184074     1  0.1964     0.6843 0.944 0.000 0.056
#> ERR184048     2  0.2796     0.8975 0.092 0.908 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.5581      0.310 0.532 0.000 0.020 0.448
#> ERR184093     2  0.4220      0.760 0.248 0.748 0.000 0.004
#> ERR184051     3  0.1452      0.799 0.036 0.000 0.956 0.008
#> ERR184076     1  0.5414      0.458 0.604 0.000 0.020 0.376
#> ERR184043     3  0.0336      0.807 0.008 0.000 0.992 0.000
#> ERR184037     1  0.4535      0.568 0.704 0.000 0.004 0.292
#> ERR184059     3  0.4955      0.318 0.008 0.000 0.648 0.344
#> ERR184055     1  0.4535      0.570 0.704 0.000 0.004 0.292
#> ERR184065     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184069     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184040     4  0.5730      0.111 0.344 0.000 0.040 0.616
#> ERR184057     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184082     1  0.2266      0.556 0.912 0.084 0.000 0.004
#> ERR184083     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184064     3  0.0336      0.807 0.008 0.000 0.992 0.000
#> ERR184081     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184095     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184079     2  0.4936      0.612 0.372 0.624 0.000 0.004
#> ERR184084     3  0.5075      0.306 0.012 0.000 0.644 0.344
#> ERR184068     1  0.5294     -0.354 0.508 0.484 0.000 0.008
#> ERR184067     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184071     2  0.4483      0.726 0.284 0.712 0.000 0.004
#> ERR184042     4  0.4746      0.129 0.000 0.000 0.368 0.632
#> ERR184063     3  0.2450      0.762 0.072 0.000 0.912 0.016
#> ERR184091     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184061     1  0.3172      0.510 0.840 0.160 0.000 0.000
#> ERR184077     2  0.4819      0.654 0.344 0.652 0.000 0.004
#> ERR184062     1  0.5093      0.112 0.640 0.348 0.000 0.012
#> ERR184053     2  0.4837      0.648 0.348 0.648 0.000 0.004
#> ERR184088     2  0.4313      0.749 0.260 0.736 0.000 0.004
#> ERR184075     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184041     3  0.2222      0.777 0.060 0.000 0.924 0.016
#> ERR184060     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184035     1  0.1936      0.586 0.940 0.028 0.000 0.032
#> ERR184086     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184080     1  0.4584      0.566 0.696 0.000 0.004 0.300
#> ERR184050     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184047     4  0.3494      0.564 0.004 0.000 0.172 0.824
#> ERR184092     2  0.3870      0.787 0.208 0.788 0.000 0.004
#> ERR184072     1  0.5026      0.546 0.672 0.000 0.016 0.312
#> ERR184073     4  0.7290      0.449 0.168 0.000 0.328 0.504
#> ERR184066     1  0.4567      0.573 0.716 0.000 0.008 0.276
#> ERR184098     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184044     1  0.0712      0.582 0.984 0.004 0.004 0.008
#> ERR184054     1  0.5069      0.539 0.664 0.000 0.016 0.320
#> ERR184085     1  0.1489      0.574 0.952 0.044 0.000 0.004
#> ERR184056     2  0.3306      0.816 0.156 0.840 0.000 0.004
#> ERR184052     2  0.1211      0.868 0.040 0.960 0.000 0.000
#> ERR184070     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184096     4  0.3306      0.571 0.004 0.000 0.156 0.840
#> ERR184089     2  0.1109      0.869 0.028 0.968 0.000 0.004
#> ERR184049     1  0.3400      0.488 0.820 0.180 0.000 0.000
#> ERR184038     1  0.3176      0.555 0.880 0.000 0.084 0.036
#> ERR184087     3  0.0336      0.807 0.008 0.000 0.992 0.000
#> ERR184097     2  0.3945      0.783 0.216 0.780 0.000 0.004
#> ERR184094     4  0.5628      0.336 0.024 0.000 0.420 0.556
#> ERR184058     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> ERR184036     2  0.4088      0.773 0.232 0.764 0.000 0.004
#> ERR184046     2  0.0000      0.881 0.000 1.000 0.000 0.000
#> ERR184074     1  0.5253      0.494 0.624 0.000 0.016 0.360
#> ERR184048     2  0.4837      0.648 0.348 0.648 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.2189      0.771 0.904 0.000 0.000 0.084 0.012
#> ERR184093     4  0.4825      0.461 0.000 0.408 0.000 0.568 0.024
#> ERR184051     3  0.0162      0.990 0.000 0.000 0.996 0.004 0.000
#> ERR184076     1  0.2997      0.824 0.840 0.000 0.000 0.148 0.012
#> ERR184043     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.4213      0.821 0.680 0.000 0.000 0.308 0.012
#> ERR184059     5  0.6390      0.583 0.168 0.000 0.396 0.000 0.436
#> ERR184055     1  0.4213      0.821 0.680 0.000 0.000 0.308 0.012
#> ERR184065     2  0.0880      0.891 0.000 0.968 0.000 0.000 0.032
#> ERR184069     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184040     1  0.1493      0.675 0.948 0.000 0.000 0.024 0.028
#> ERR184057     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184082     4  0.1413      0.650 0.020 0.012 0.000 0.956 0.012
#> ERR184083     2  0.0579      0.896 0.000 0.984 0.000 0.008 0.008
#> ERR184039     2  0.0880      0.891 0.000 0.968 0.000 0.000 0.032
#> ERR184064     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184095     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184079     4  0.3877      0.709 0.000 0.212 0.000 0.764 0.024
#> ERR184084     5  0.6529      0.587 0.168 0.000 0.392 0.004 0.436
#> ERR184068     4  0.3340      0.729 0.004 0.156 0.000 0.824 0.016
#> ERR184067     2  0.0510      0.893 0.000 0.984 0.000 0.016 0.000
#> ERR184071     4  0.4575      0.606 0.000 0.328 0.000 0.648 0.024
#> ERR184042     5  0.2692      0.577 0.008 0.000 0.092 0.016 0.884
#> ERR184063     3  0.0451      0.985 0.000 0.000 0.988 0.008 0.004
#> ERR184091     2  0.0880      0.891 0.000 0.968 0.000 0.000 0.032
#> ERR184061     4  0.2617      0.653 0.032 0.028 0.000 0.904 0.036
#> ERR184077     4  0.4025      0.662 0.000 0.292 0.000 0.700 0.008
#> ERR184062     4  0.2995      0.709 0.008 0.088 0.000 0.872 0.032
#> ERR184053     4  0.4206      0.664 0.000 0.288 0.000 0.696 0.016
#> ERR184088     4  0.4722      0.549 0.000 0.368 0.000 0.608 0.024
#> ERR184075     2  0.0880      0.891 0.000 0.968 0.000 0.000 0.032
#> ERR184041     3  0.0451      0.985 0.000 0.000 0.988 0.008 0.004
#> ERR184060     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184035     4  0.1857      0.608 0.060 0.004 0.000 0.928 0.008
#> ERR184086     2  0.0880      0.891 0.000 0.968 0.000 0.000 0.032
#> ERR184080     1  0.3684      0.840 0.720 0.000 0.000 0.280 0.000
#> ERR184050     2  0.1661      0.882 0.000 0.940 0.000 0.024 0.036
#> ERR184047     5  0.4904      0.714 0.316 0.000 0.036 0.004 0.644
#> ERR184092     2  0.4746      0.162 0.000 0.600 0.000 0.376 0.024
#> ERR184072     1  0.3671      0.846 0.756 0.000 0.000 0.236 0.008
#> ERR184073     1  0.1981      0.595 0.920 0.000 0.064 0.000 0.016
#> ERR184066     1  0.4009      0.822 0.684 0.000 0.000 0.312 0.004
#> ERR184098     2  0.1597      0.879 0.000 0.940 0.000 0.012 0.048
#> ERR184044     4  0.1800      0.618 0.048 0.000 0.000 0.932 0.020
#> ERR184054     1  0.3242      0.850 0.784 0.000 0.000 0.216 0.000
#> ERR184085     4  0.1588      0.640 0.028 0.008 0.000 0.948 0.016
#> ERR184056     2  0.4484      0.369 0.000 0.668 0.000 0.308 0.024
#> ERR184052     2  0.2648      0.726 0.000 0.848 0.000 0.152 0.000
#> ERR184070     2  0.0290      0.896 0.000 0.992 0.000 0.008 0.000
#> ERR184096     5  0.4848      0.713 0.320 0.000 0.032 0.004 0.644
#> ERR184089     2  0.1750      0.880 0.000 0.936 0.000 0.028 0.036
#> ERR184049     4  0.1721      0.658 0.016 0.020 0.000 0.944 0.020
#> ERR184038     4  0.5087     -0.143 0.320 0.000 0.028 0.636 0.016
#> ERR184087     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> ERR184097     2  0.4882     -0.123 0.000 0.532 0.000 0.444 0.024
#> ERR184094     5  0.6678      0.666 0.312 0.000 0.256 0.000 0.432
#> ERR184058     2  0.0510      0.894 0.000 0.984 0.000 0.000 0.016
#> ERR184036     4  0.4982      0.467 0.000 0.412 0.000 0.556 0.032
#> ERR184046     2  0.0451      0.896 0.000 0.988 0.000 0.008 0.004
#> ERR184074     1  0.3086      0.842 0.816 0.000 0.000 0.180 0.004
#> ERR184048     4  0.3730      0.664 0.000 0.288 0.000 0.712 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.0914      0.728 0.968 0.000 0.000 NA 0.016 0.000
#> ERR184093     6  0.3616      0.686 0.000 0.232 0.000 NA 0.008 0.748
#> ERR184051     3  0.0291      0.993 0.000 0.000 0.992 NA 0.000 0.004
#> ERR184076     1  0.1225      0.731 0.952 0.000 0.000 NA 0.012 0.000
#> ERR184043     3  0.0146      0.993 0.000 0.000 0.996 NA 0.004 0.000
#> ERR184037     1  0.5165      0.659 0.612 0.000 0.000 NA 0.004 0.116
#> ERR184059     5  0.3878      0.599 0.004 0.000 0.348 NA 0.644 0.000
#> ERR184055     1  0.4994      0.684 0.648 0.000 0.000 NA 0.004 0.120
#> ERR184065     2  0.2355      0.871 0.000 0.876 0.000 NA 0.008 0.004
#> ERR184069     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184040     1  0.3078      0.588 0.796 0.000 0.000 NA 0.192 0.000
#> ERR184057     2  0.0547      0.882 0.000 0.980 0.000 NA 0.000 0.020
#> ERR184082     6  0.3988      0.567 0.012 0.000 0.000 NA 0.004 0.660
#> ERR184083     2  0.0520      0.886 0.000 0.984 0.000 NA 0.000 0.008
#> ERR184039     2  0.2400      0.869 0.000 0.872 0.000 NA 0.008 0.004
#> ERR184064     3  0.0146      0.993 0.000 0.000 0.996 NA 0.004 0.000
#> ERR184081     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184095     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184079     6  0.1524      0.746 0.000 0.060 0.000 NA 0.008 0.932
#> ERR184084     5  0.4979      0.627 0.004 0.000 0.300 NA 0.624 0.008
#> ERR184068     6  0.3442      0.719 0.008 0.028 0.004 NA 0.012 0.832
#> ERR184067     2  0.0632      0.880 0.000 0.976 0.000 NA 0.000 0.024
#> ERR184071     6  0.2841      0.738 0.000 0.164 0.000 NA 0.000 0.824
#> ERR184042     5  0.4491      0.535 0.000 0.000 0.036 NA 0.576 0.000
#> ERR184063     3  0.0291      0.993 0.000 0.000 0.992 NA 0.000 0.004
#> ERR184091     2  0.2308      0.871 0.000 0.880 0.000 NA 0.008 0.004
#> ERR184061     6  0.3859      0.649 0.048 0.012 0.000 NA 0.004 0.788
#> ERR184077     6  0.4247      0.748 0.004 0.164 0.000 NA 0.008 0.752
#> ERR184062     6  0.2469      0.726 0.036 0.028 0.000 NA 0.012 0.904
#> ERR184053     6  0.4539      0.747 0.004 0.148 0.004 NA 0.008 0.740
#> ERR184088     6  0.2994      0.722 0.000 0.208 0.000 NA 0.000 0.788
#> ERR184075     2  0.2355      0.871 0.000 0.876 0.000 NA 0.008 0.004
#> ERR184041     3  0.0291      0.993 0.000 0.000 0.992 NA 0.000 0.004
#> ERR184060     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184035     6  0.4579      0.532 0.052 0.000 0.000 NA 0.004 0.644
#> ERR184086     2  0.2355      0.871 0.000 0.876 0.000 NA 0.008 0.004
#> ERR184080     1  0.3693      0.733 0.788 0.000 0.000 NA 0.000 0.092
#> ERR184050     2  0.3894      0.818 0.000 0.784 0.000 NA 0.008 0.088
#> ERR184047     5  0.1296      0.720 0.044 0.000 0.004 NA 0.948 0.000
#> ERR184092     6  0.3899      0.482 0.000 0.364 0.000 NA 0.008 0.628
#> ERR184072     1  0.1922      0.751 0.924 0.000 0.000 NA 0.012 0.040
#> ERR184073     1  0.3470      0.559 0.772 0.000 0.028 NA 0.200 0.000
#> ERR184066     1  0.4387      0.708 0.720 0.000 0.000 NA 0.000 0.152
#> ERR184098     2  0.4039      0.809 0.000 0.772 0.000 NA 0.008 0.104
#> ERR184044     6  0.4448      0.595 0.052 0.000 0.000 NA 0.008 0.688
#> ERR184054     1  0.0937      0.752 0.960 0.000 0.000 NA 0.000 0.040
#> ERR184085     6  0.4317      0.544 0.028 0.000 0.000 NA 0.004 0.640
#> ERR184056     2  0.4217     -0.107 0.000 0.524 0.000 NA 0.008 0.464
#> ERR184052     2  0.3671      0.666 0.000 0.756 0.000 NA 0.000 0.208
#> ERR184070     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184096     5  0.1493      0.719 0.056 0.000 0.004 NA 0.936 0.000
#> ERR184089     2  0.3989      0.811 0.000 0.776 0.000 NA 0.008 0.096
#> ERR184049     6  0.3618      0.644 0.012 0.008 0.000 NA 0.004 0.764
#> ERR184038     1  0.6564      0.189 0.368 0.000 0.012 NA 0.008 0.356
#> ERR184087     3  0.0146      0.993 0.000 0.000 0.996 NA 0.004 0.000
#> ERR184097     6  0.3940      0.543 0.000 0.336 0.000 NA 0.008 0.652
#> ERR184094     5  0.4888      0.657 0.116 0.000 0.240 NA 0.644 0.000
#> ERR184058     2  0.1219      0.882 0.000 0.948 0.000 NA 0.000 0.004
#> ERR184036     6  0.4178      0.696 0.000 0.208 0.000 NA 0.004 0.728
#> ERR184046     2  0.0260      0.886 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184074     1  0.2883      0.745 0.860 0.000 0.000 NA 0.008 0.040
#> ERR184048     6  0.3522      0.753 0.004 0.148 0.000 NA 0.004 0.804

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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.


MAD:skmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-skmeans-select-partition-number

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.974       0.988         0.5022 0.497   0.497
#> 3 3 0.786           0.812       0.893         0.2220 0.871   0.745
#> 4 4 0.549           0.631       0.793         0.1381 0.921   0.799
#> 5 5 0.552           0.512       0.741         0.0668 0.964   0.890
#> 6 6 0.565           0.488       0.710         0.0484 0.997   0.989

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.979 1.000 0.000
#> ERR184093     2  0.0000      0.995 0.000 1.000
#> ERR184051     1  0.0000      0.979 1.000 0.000
#> ERR184076     1  0.0000      0.979 1.000 0.000
#> ERR184043     1  0.0000      0.979 1.000 0.000
#> ERR184037     1  0.0000      0.979 1.000 0.000
#> ERR184059     1  0.0000      0.979 1.000 0.000
#> ERR184055     1  0.0000      0.979 1.000 0.000
#> ERR184065     2  0.0000      0.995 0.000 1.000
#> ERR184069     2  0.0000      0.995 0.000 1.000
#> ERR184040     1  0.0000      0.979 1.000 0.000
#> ERR184057     2  0.0000      0.995 0.000 1.000
#> ERR184082     1  0.8909      0.570 0.692 0.308
#> ERR184083     2  0.0000      0.995 0.000 1.000
#> ERR184039     2  0.0000      0.995 0.000 1.000
#> ERR184064     1  0.0000      0.979 1.000 0.000
#> ERR184081     2  0.0000      0.995 0.000 1.000
#> ERR184095     2  0.0000      0.995 0.000 1.000
#> ERR184079     2  0.0000      0.995 0.000 1.000
#> ERR184084     1  0.0000      0.979 1.000 0.000
#> ERR184068     2  0.0376      0.991 0.004 0.996
#> ERR184067     2  0.0000      0.995 0.000 1.000
#> ERR184071     2  0.0000      0.995 0.000 1.000
#> ERR184042     1  0.0000      0.979 1.000 0.000
#> ERR184063     1  0.0000      0.979 1.000 0.000
#> ERR184091     2  0.0000      0.995 0.000 1.000
#> ERR184061     2  0.4431      0.896 0.092 0.908
#> ERR184077     2  0.0000      0.995 0.000 1.000
#> ERR184062     2  0.3879      0.916 0.076 0.924
#> ERR184053     2  0.0000      0.995 0.000 1.000
#> ERR184088     2  0.0000      0.995 0.000 1.000
#> ERR184075     2  0.0000      0.995 0.000 1.000
#> ERR184041     1  0.0000      0.979 1.000 0.000
#> ERR184060     2  0.0000      0.995 0.000 1.000
#> ERR184035     1  0.7602      0.726 0.780 0.220
#> ERR184086     2  0.0000      0.995 0.000 1.000
#> ERR184080     1  0.0000      0.979 1.000 0.000
#> ERR184050     2  0.0000      0.995 0.000 1.000
#> ERR184047     1  0.0000      0.979 1.000 0.000
#> ERR184092     2  0.0000      0.995 0.000 1.000
#> ERR184072     1  0.0000      0.979 1.000 0.000
#> ERR184073     1  0.0000      0.979 1.000 0.000
#> ERR184066     1  0.0000      0.979 1.000 0.000
#> ERR184098     2  0.0000      0.995 0.000 1.000
#> ERR184044     1  0.0000      0.979 1.000 0.000
#> ERR184054     1  0.0000      0.979 1.000 0.000
#> ERR184085     1  0.1843      0.955 0.972 0.028
#> ERR184056     2  0.0000      0.995 0.000 1.000
#> ERR184052     2  0.0000      0.995 0.000 1.000
#> ERR184070     2  0.0000      0.995 0.000 1.000
#> ERR184096     1  0.0000      0.979 1.000 0.000
#> ERR184089     2  0.0000      0.995 0.000 1.000
#> ERR184049     2  0.0000      0.995 0.000 1.000
#> ERR184038     1  0.0000      0.979 1.000 0.000
#> ERR184087     1  0.0000      0.979 1.000 0.000
#> ERR184097     2  0.0000      0.995 0.000 1.000
#> ERR184094     1  0.0000      0.979 1.000 0.000
#> ERR184058     2  0.0000      0.995 0.000 1.000
#> ERR184036     2  0.0000      0.995 0.000 1.000
#> ERR184046     2  0.0000      0.995 0.000 1.000
#> ERR184074     1  0.0000      0.979 1.000 0.000
#> ERR184048     2  0.0000      0.995 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.5397     0.7431 0.720 0.000 0.280
#> ERR184093     2  0.0892     0.9570 0.020 0.980 0.000
#> ERR184051     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184076     1  0.5465     0.7399 0.712 0.000 0.288
#> ERR184043     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184037     1  0.1529     0.6926 0.960 0.000 0.040
#> ERR184059     3  0.2959     0.8007 0.100 0.000 0.900
#> ERR184055     1  0.2796     0.7262 0.908 0.000 0.092
#> ERR184065     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184069     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184040     1  0.5678     0.7181 0.684 0.000 0.316
#> ERR184057     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184082     3  0.8142     0.4888 0.268 0.112 0.620
#> ERR184083     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184039     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184064     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184081     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184095     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184079     2  0.2448     0.9239 0.076 0.924 0.000
#> ERR184084     3  0.3116     0.7944 0.108 0.000 0.892
#> ERR184068     2  0.4978     0.7586 0.216 0.780 0.004
#> ERR184067     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184071     2  0.0424     0.9614 0.008 0.992 0.000
#> ERR184042     3  0.3192     0.7896 0.112 0.000 0.888
#> ERR184063     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184091     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184061     1  0.6936    -0.0843 0.524 0.460 0.016
#> ERR184077     2  0.1163     0.9535 0.028 0.972 0.000
#> ERR184062     2  0.5431     0.6269 0.284 0.716 0.000
#> ERR184053     2  0.1289     0.9521 0.032 0.968 0.000
#> ERR184088     2  0.1529     0.9462 0.040 0.960 0.000
#> ERR184075     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184041     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184060     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184035     1  0.1337     0.6561 0.972 0.012 0.016
#> ERR184086     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184080     1  0.2066     0.7088 0.940 0.000 0.060
#> ERR184050     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184047     1  0.5859     0.6849 0.656 0.000 0.344
#> ERR184092     2  0.0237     0.9622 0.004 0.996 0.000
#> ERR184072     1  0.4291     0.7590 0.820 0.000 0.180
#> ERR184073     1  0.5810     0.6963 0.664 0.000 0.336
#> ERR184066     1  0.4504     0.7608 0.804 0.000 0.196
#> ERR184098     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184044     1  0.6529     0.4050 0.620 0.012 0.368
#> ERR184054     1  0.4842     0.7606 0.776 0.000 0.224
#> ERR184085     3  0.5760     0.5808 0.328 0.000 0.672
#> ERR184056     2  0.0747     0.9585 0.016 0.984 0.000
#> ERR184052     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184070     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184096     1  0.5706     0.7144 0.680 0.000 0.320
#> ERR184089     2  0.2448     0.9075 0.000 0.924 0.076
#> ERR184049     2  0.6473     0.5905 0.312 0.668 0.020
#> ERR184038     3  0.2796     0.8073 0.092 0.000 0.908
#> ERR184087     3  0.0000     0.8376 0.000 0.000 1.000
#> ERR184097     2  0.0747     0.9585 0.016 0.984 0.000
#> ERR184094     3  0.6204    -0.0808 0.424 0.000 0.576
#> ERR184058     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184036     2  0.1860     0.9326 0.052 0.948 0.000
#> ERR184046     2  0.0000     0.9633 0.000 1.000 0.000
#> ERR184074     1  0.5016     0.7578 0.760 0.000 0.240
#> ERR184048     2  0.1529     0.9484 0.040 0.960 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.2888     0.7870 0.872 0.000 0.124 0.004
#> ERR184093     2  0.4331     0.5416 0.000 0.712 0.000 0.288
#> ERR184051     3  0.0707     0.8034 0.020 0.000 0.980 0.000
#> ERR184076     1  0.2888     0.7885 0.872 0.000 0.124 0.004
#> ERR184043     3  0.0707     0.8034 0.020 0.000 0.980 0.000
#> ERR184037     1  0.2944     0.6987 0.868 0.000 0.004 0.128
#> ERR184059     3  0.4164     0.6379 0.264 0.000 0.736 0.000
#> ERR184055     1  0.3354     0.7416 0.872 0.000 0.044 0.084
#> ERR184065     2  0.2402     0.7600 0.000 0.912 0.012 0.076
#> ERR184069     2  0.0817     0.7764 0.000 0.976 0.000 0.024
#> ERR184040     1  0.3219     0.7732 0.836 0.000 0.164 0.000
#> ERR184057     2  0.1389     0.7712 0.000 0.952 0.000 0.048
#> ERR184082     4  0.8449     0.2034 0.140 0.092 0.236 0.532
#> ERR184083     2  0.0817     0.7796 0.000 0.976 0.000 0.024
#> ERR184039     2  0.2676     0.7563 0.000 0.896 0.012 0.092
#> ERR184064     3  0.0817     0.8033 0.024 0.000 0.976 0.000
#> ERR184081     2  0.1109     0.7761 0.000 0.968 0.004 0.028
#> ERR184095     2  0.1940     0.7617 0.000 0.924 0.000 0.076
#> ERR184079     2  0.5597    -0.0889 0.020 0.516 0.000 0.464
#> ERR184084     3  0.4584     0.5722 0.300 0.000 0.696 0.004
#> ERR184068     4  0.6279     0.4275 0.060 0.348 0.004 0.588
#> ERR184067     2  0.1302     0.7770 0.000 0.956 0.000 0.044
#> ERR184071     2  0.3626     0.7041 0.004 0.812 0.000 0.184
#> ERR184042     3  0.4356     0.5959 0.292 0.000 0.708 0.000
#> ERR184063     3  0.0592     0.8020 0.016 0.000 0.984 0.000
#> ERR184091     2  0.2255     0.7623 0.000 0.920 0.012 0.068
#> ERR184061     4  0.8317     0.4931 0.224 0.324 0.024 0.428
#> ERR184077     2  0.5016     0.2660 0.004 0.600 0.000 0.396
#> ERR184062     4  0.7885     0.3930 0.148 0.352 0.024 0.476
#> ERR184053     2  0.5229     0.1293 0.008 0.564 0.000 0.428
#> ERR184088     2  0.4502     0.5819 0.016 0.748 0.000 0.236
#> ERR184075     2  0.2473     0.7610 0.000 0.908 0.012 0.080
#> ERR184041     3  0.0592     0.8020 0.016 0.000 0.984 0.000
#> ERR184060     2  0.0657     0.7775 0.000 0.984 0.004 0.012
#> ERR184035     1  0.5760     0.1245 0.520 0.020 0.004 0.456
#> ERR184086     2  0.2610     0.7576 0.000 0.900 0.012 0.088
#> ERR184080     1  0.2021     0.7568 0.936 0.000 0.024 0.040
#> ERR184050     2  0.2987     0.7518 0.000 0.880 0.016 0.104
#> ERR184047     1  0.3975     0.7111 0.760 0.000 0.240 0.000
#> ERR184092     2  0.3528     0.6670 0.000 0.808 0.000 0.192
#> ERR184072     1  0.4010     0.7789 0.836 0.000 0.100 0.064
#> ERR184073     1  0.4164     0.6824 0.736 0.000 0.264 0.000
#> ERR184066     1  0.4591     0.7483 0.800 0.000 0.116 0.084
#> ERR184098     2  0.2924     0.7519 0.000 0.884 0.016 0.100
#> ERR184044     1  0.7733     0.2032 0.476 0.004 0.292 0.228
#> ERR184054     1  0.3048     0.7890 0.876 0.000 0.108 0.016
#> ERR184085     3  0.7586     0.2931 0.200 0.000 0.436 0.364
#> ERR184056     2  0.3801     0.6329 0.000 0.780 0.000 0.220
#> ERR184052     2  0.2611     0.7557 0.000 0.896 0.008 0.096
#> ERR184070     2  0.0921     0.7745 0.000 0.972 0.000 0.028
#> ERR184096     1  0.3486     0.7582 0.812 0.000 0.188 0.000
#> ERR184089     2  0.5484     0.5410 0.000 0.736 0.132 0.132
#> ERR184049     4  0.6989     0.3909 0.100 0.412 0.004 0.484
#> ERR184038     3  0.4903     0.6496 0.248 0.000 0.724 0.028
#> ERR184087     3  0.0817     0.8033 0.024 0.000 0.976 0.000
#> ERR184097     2  0.3942     0.6029 0.000 0.764 0.000 0.236
#> ERR184094     1  0.4941     0.2776 0.564 0.000 0.436 0.000
#> ERR184058     2  0.1854     0.7695 0.000 0.940 0.012 0.048
#> ERR184036     2  0.4979     0.5583 0.032 0.740 0.004 0.224
#> ERR184046     2  0.0895     0.7797 0.000 0.976 0.004 0.020
#> ERR184074     1  0.3105     0.7884 0.868 0.000 0.120 0.012
#> ERR184048     2  0.5143     0.2834 0.012 0.628 0.000 0.360

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.1831     0.7571 0.920 0.000 0.076 0.004 0.000
#> ERR184093     2  0.4971     0.2412 0.004 0.628 0.000 0.036 0.332
#> ERR184051     3  0.0703     0.7594 0.024 0.000 0.976 0.000 0.000
#> ERR184076     1  0.2069     0.7533 0.924 0.000 0.052 0.012 0.012
#> ERR184043     3  0.0609     0.7597 0.020 0.000 0.980 0.000 0.000
#> ERR184037     1  0.4623     0.4574 0.640 0.000 0.008 0.340 0.012
#> ERR184059     3  0.4375     0.4802 0.364 0.000 0.628 0.004 0.004
#> ERR184055     1  0.4699     0.5916 0.716 0.000 0.016 0.236 0.032
#> ERR184065     2  0.3810     0.6333 0.000 0.792 0.000 0.040 0.168
#> ERR184069     2  0.1168     0.6809 0.000 0.960 0.000 0.032 0.008
#> ERR184040     1  0.2249     0.7543 0.896 0.000 0.096 0.008 0.000
#> ERR184057     2  0.2221     0.6633 0.000 0.912 0.000 0.036 0.052
#> ERR184082     4  0.8928     0.2764 0.112 0.072 0.140 0.384 0.292
#> ERR184083     2  0.1478     0.6865 0.000 0.936 0.000 0.000 0.064
#> ERR184039     2  0.3920     0.6369 0.000 0.796 0.004 0.044 0.156
#> ERR184064     3  0.0609     0.7597 0.020 0.000 0.980 0.000 0.000
#> ERR184081     2  0.1117     0.6810 0.000 0.964 0.000 0.016 0.020
#> ERR184095     2  0.2236     0.6569 0.000 0.908 0.000 0.024 0.068
#> ERR184079     5  0.6726     0.4117 0.000 0.388 0.004 0.208 0.400
#> ERR184084     3  0.4882     0.2716 0.440 0.000 0.540 0.012 0.008
#> ERR184068     5  0.7226     0.4619 0.028 0.284 0.004 0.212 0.472
#> ERR184067     2  0.2592     0.6710 0.000 0.892 0.000 0.056 0.052
#> ERR184071     2  0.5107     0.4936 0.000 0.688 0.000 0.108 0.204
#> ERR184042     3  0.4478     0.4810 0.360 0.000 0.628 0.004 0.008
#> ERR184063     3  0.0960     0.7494 0.016 0.000 0.972 0.004 0.008
#> ERR184091     2  0.3061     0.6611 0.000 0.844 0.000 0.020 0.136
#> ERR184061     4  0.7384     0.1447 0.080 0.200 0.016 0.564 0.140
#> ERR184077     2  0.5901    -0.2959 0.000 0.492 0.004 0.088 0.416
#> ERR184062     5  0.7019     0.3810 0.096 0.248 0.004 0.088 0.564
#> ERR184053     2  0.6586    -0.1750 0.004 0.524 0.012 0.148 0.312
#> ERR184088     2  0.5973     0.2567 0.008 0.632 0.004 0.204 0.152
#> ERR184075     2  0.3574     0.6490 0.000 0.804 0.000 0.028 0.168
#> ERR184041     3  0.0932     0.7562 0.020 0.000 0.972 0.004 0.004
#> ERR184060     2  0.0451     0.6809 0.000 0.988 0.000 0.004 0.008
#> ERR184035     4  0.7111     0.2904 0.316 0.008 0.016 0.464 0.196
#> ERR184086     2  0.2929     0.6620 0.000 0.840 0.000 0.008 0.152
#> ERR184080     1  0.3197     0.6778 0.836 0.000 0.000 0.140 0.024
#> ERR184050     2  0.4465     0.5880 0.000 0.732 0.000 0.056 0.212
#> ERR184047     1  0.3387     0.6756 0.796 0.000 0.196 0.004 0.004
#> ERR184092     2  0.3724     0.5416 0.000 0.788 0.000 0.028 0.184
#> ERR184072     1  0.4905     0.6767 0.768 0.000 0.052 0.096 0.084
#> ERR184073     1  0.3585     0.6511 0.772 0.000 0.220 0.004 0.004
#> ERR184066     1  0.4660     0.6527 0.772 0.000 0.028 0.068 0.132
#> ERR184098     2  0.4269     0.6120 0.000 0.756 0.000 0.056 0.188
#> ERR184044     1  0.8484    -0.0976 0.348 0.016 0.184 0.332 0.120
#> ERR184054     1  0.2684     0.7443 0.900 0.000 0.032 0.044 0.024
#> ERR184085     4  0.8547     0.2809 0.160 0.008 0.264 0.364 0.204
#> ERR184056     2  0.4347     0.4624 0.000 0.732 0.004 0.032 0.232
#> ERR184052     2  0.4094     0.6214 0.000 0.788 0.000 0.084 0.128
#> ERR184070     2  0.1117     0.6770 0.000 0.964 0.000 0.020 0.016
#> ERR184096     1  0.2660     0.7366 0.864 0.000 0.128 0.000 0.008
#> ERR184089     2  0.6917     0.3263 0.004 0.580 0.108 0.076 0.232
#> ERR184049     4  0.5876     0.0445 0.020 0.240 0.004 0.644 0.092
#> ERR184038     3  0.5781     0.5281 0.292 0.000 0.620 0.040 0.048
#> ERR184087     3  0.0609     0.7597 0.020 0.000 0.980 0.000 0.000
#> ERR184097     2  0.4086     0.3873 0.000 0.704 0.000 0.012 0.284
#> ERR184094     1  0.4530     0.2967 0.612 0.000 0.376 0.004 0.008
#> ERR184058     2  0.2464     0.6781 0.000 0.888 0.000 0.016 0.096
#> ERR184036     2  0.5759     0.2174 0.012 0.604 0.000 0.300 0.084
#> ERR184046     2  0.1124     0.6841 0.000 0.960 0.000 0.004 0.036
#> ERR184074     1  0.2795     0.7531 0.880 0.000 0.056 0.064 0.000
#> ERR184048     2  0.6403    -0.2250 0.000 0.512 0.000 0.232 0.256

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.2830      0.704 0.880 0.000 0.060 0.012 0.036 0.012
#> ERR184093     2  0.6143      0.147 0.000 0.516 0.000 0.324 0.052 0.108
#> ERR184051     3  0.0837      0.777 0.020 0.000 0.972 0.004 0.004 0.000
#> ERR184076     1  0.3954      0.697 0.820 0.000 0.068 0.052 0.036 0.024
#> ERR184043     3  0.0291      0.776 0.004 0.000 0.992 0.000 0.004 0.000
#> ERR184037     1  0.5985      0.393 0.596 0.000 0.004 0.044 0.136 0.220
#> ERR184059     3  0.3681      0.631 0.272 0.000 0.716 0.004 0.004 0.004
#> ERR184055     1  0.5839      0.513 0.648 0.000 0.012 0.088 0.072 0.180
#> ERR184065     2  0.3853      0.593 0.000 0.708 0.000 0.012 0.008 0.272
#> ERR184069     2  0.1257      0.644 0.000 0.952 0.000 0.020 0.000 0.028
#> ERR184040     1  0.2094      0.704 0.900 0.000 0.080 0.000 0.020 0.000
#> ERR184057     2  0.2151      0.623 0.000 0.904 0.000 0.072 0.008 0.016
#> ERR184082     5  0.7268      0.273 0.048 0.052 0.092 0.096 0.596 0.116
#> ERR184083     2  0.2462      0.650 0.000 0.876 0.000 0.028 0.000 0.096
#> ERR184039     2  0.4071      0.575 0.000 0.672 0.000 0.020 0.004 0.304
#> ERR184064     3  0.0260      0.779 0.008 0.000 0.992 0.000 0.000 0.000
#> ERR184081     2  0.1977      0.644 0.000 0.920 0.000 0.032 0.008 0.040
#> ERR184095     2  0.2491      0.614 0.000 0.868 0.000 0.112 0.000 0.020
#> ERR184079     4  0.7330      0.230 0.004 0.324 0.000 0.380 0.168 0.124
#> ERR184084     3  0.4832      0.513 0.324 0.000 0.612 0.000 0.056 0.008
#> ERR184068     4  0.6778      0.193 0.008 0.128 0.000 0.460 0.332 0.072
#> ERR184067     2  0.3185      0.622 0.000 0.852 0.000 0.060 0.024 0.064
#> ERR184071     2  0.6351      0.408 0.000 0.592 0.004 0.140 0.108 0.156
#> ERR184042     3  0.4088      0.571 0.308 0.000 0.668 0.000 0.020 0.004
#> ERR184063     3  0.0696      0.767 0.004 0.000 0.980 0.004 0.008 0.004
#> ERR184091     2  0.3189      0.616 0.000 0.760 0.000 0.004 0.000 0.236
#> ERR184061     6  0.8072      0.489 0.096 0.184 0.004 0.120 0.140 0.456
#> ERR184077     2  0.5951     -0.173 0.000 0.444 0.000 0.428 0.088 0.040
#> ERR184062     4  0.5727      0.258 0.044 0.156 0.000 0.680 0.068 0.052
#> ERR184053     2  0.6975     -0.181 0.000 0.412 0.000 0.340 0.128 0.120
#> ERR184088     2  0.6431      0.261 0.000 0.572 0.000 0.132 0.152 0.144
#> ERR184075     2  0.3809      0.581 0.000 0.684 0.000 0.004 0.008 0.304
#> ERR184041     3  0.0405      0.778 0.008 0.000 0.988 0.000 0.004 0.000
#> ERR184060     2  0.0291      0.641 0.000 0.992 0.000 0.004 0.000 0.004
#> ERR184035     5  0.5701      0.285 0.200 0.012 0.004 0.080 0.656 0.048
#> ERR184086     2  0.3781      0.624 0.000 0.756 0.000 0.036 0.004 0.204
#> ERR184080     1  0.3571      0.628 0.816 0.000 0.000 0.012 0.096 0.076
#> ERR184050     2  0.4871      0.500 0.000 0.592 0.000 0.040 0.016 0.352
#> ERR184047     1  0.3421      0.646 0.780 0.000 0.200 0.004 0.012 0.004
#> ERR184092     2  0.4948      0.413 0.000 0.660 0.000 0.244 0.016 0.080
#> ERR184072     1  0.5640      0.534 0.672 0.000 0.012 0.116 0.144 0.056
#> ERR184073     1  0.3686      0.632 0.756 0.000 0.220 0.008 0.008 0.008
#> ERR184066     1  0.6160      0.519 0.648 0.000 0.044 0.148 0.092 0.068
#> ERR184098     2  0.4319      0.586 0.000 0.696 0.000 0.036 0.012 0.256
#> ERR184044     1  0.9070     -0.225 0.272 0.016 0.144 0.260 0.144 0.164
#> ERR184054     1  0.3969      0.684 0.820 0.000 0.048 0.028 0.068 0.036
#> ERR184085     5  0.8127      0.328 0.124 0.008 0.204 0.100 0.452 0.112
#> ERR184056     2  0.4303      0.404 0.000 0.676 0.000 0.284 0.008 0.032
#> ERR184052     2  0.4529      0.594 0.000 0.748 0.000 0.052 0.056 0.144
#> ERR184070     2  0.1082      0.635 0.000 0.956 0.000 0.040 0.000 0.004
#> ERR184096     1  0.2386      0.694 0.876 0.000 0.112 0.004 0.004 0.004
#> ERR184089     2  0.6506      0.300 0.000 0.460 0.064 0.048 0.036 0.392
#> ERR184049     6  0.7452      0.488 0.032 0.164 0.000 0.092 0.260 0.452
#> ERR184038     3  0.6643      0.442 0.256 0.000 0.552 0.048 0.100 0.044
#> ERR184087     3  0.0363      0.779 0.012 0.000 0.988 0.000 0.000 0.000
#> ERR184097     2  0.5136      0.284 0.000 0.612 0.000 0.308 0.044 0.036
#> ERR184094     1  0.4409      0.284 0.596 0.000 0.380 0.004 0.008 0.012
#> ERR184058     2  0.2402      0.642 0.000 0.856 0.000 0.004 0.000 0.140
#> ERR184036     2  0.6801      0.114 0.016 0.496 0.000 0.104 0.084 0.300
#> ERR184046     2  0.1802      0.650 0.000 0.916 0.000 0.012 0.000 0.072
#> ERR184074     1  0.3559      0.698 0.840 0.000 0.056 0.008 0.052 0.044
#> ERR184048     2  0.7097     -0.200 0.000 0.420 0.000 0.232 0.256 0.092

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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.


MAD:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "pam"]
# you can also extract it by
# res = res_list["MAD:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-pam-select-partition-number

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.932           0.933       0.971         0.5021 0.497   0.497
#> 3 3 0.930           0.936       0.972         0.1806 0.882   0.771
#> 4 4 0.770           0.878       0.852         0.0481 0.996   0.990
#> 5 5 0.740           0.837       0.925         0.0242 0.991   0.978
#> 6 6 0.728           0.837       0.892         0.0956 0.854   0.641

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 shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000    0.96524 1.000 0.000
#> ERR184093     2  0.0000    0.97225 0.000 1.000
#> ERR184051     1  0.0000    0.96524 1.000 0.000
#> ERR184076     1  0.0000    0.96524 1.000 0.000
#> ERR184043     1  0.0000    0.96524 1.000 0.000
#> ERR184037     1  0.0000    0.96524 1.000 0.000
#> ERR184059     1  0.0000    0.96524 1.000 0.000
#> ERR184055     1  0.0000    0.96524 1.000 0.000
#> ERR184065     2  0.0000    0.97225 0.000 1.000
#> ERR184069     2  0.0000    0.97225 0.000 1.000
#> ERR184040     1  0.0000    0.96524 1.000 0.000
#> ERR184057     2  0.0000    0.97225 0.000 1.000
#> ERR184082     2  0.3584    0.92444 0.068 0.932
#> ERR184083     2  0.0000    0.97225 0.000 1.000
#> ERR184039     2  0.0000    0.97225 0.000 1.000
#> ERR184064     1  0.0000    0.96524 1.000 0.000
#> ERR184081     2  0.0000    0.97225 0.000 1.000
#> ERR184095     2  0.0000    0.97225 0.000 1.000
#> ERR184079     2  0.3274    0.93032 0.060 0.940
#> ERR184084     1  0.0000    0.96524 1.000 0.000
#> ERR184068     2  0.7602    0.73191 0.220 0.780
#> ERR184067     2  0.0000    0.97225 0.000 1.000
#> ERR184071     2  0.0672    0.96783 0.008 0.992
#> ERR184042     1  0.0000    0.96524 1.000 0.000
#> ERR184063     1  0.1843    0.94193 0.972 0.028
#> ERR184091     2  0.0000    0.97225 0.000 1.000
#> ERR184061     1  0.7950    0.67699 0.760 0.240
#> ERR184077     2  0.0000    0.97225 0.000 1.000
#> ERR184062     1  0.9993    0.00075 0.516 0.484
#> ERR184053     2  0.4815    0.88809 0.104 0.896
#> ERR184088     2  0.0672    0.96784 0.008 0.992
#> ERR184075     2  0.0000    0.97225 0.000 1.000
#> ERR184041     1  0.0376    0.96213 0.996 0.004
#> ERR184060     2  0.0000    0.97225 0.000 1.000
#> ERR184035     1  0.5629    0.82914 0.868 0.132
#> ERR184086     2  0.0000    0.97225 0.000 1.000
#> ERR184080     1  0.0000    0.96524 1.000 0.000
#> ERR184050     2  0.0000    0.97225 0.000 1.000
#> ERR184047     1  0.0000    0.96524 1.000 0.000
#> ERR184092     2  0.0000    0.97225 0.000 1.000
#> ERR184072     1  0.0000    0.96524 1.000 0.000
#> ERR184073     1  0.0000    0.96524 1.000 0.000
#> ERR184066     1  0.0000    0.96524 1.000 0.000
#> ERR184098     2  0.0000    0.97225 0.000 1.000
#> ERR184044     1  0.0000    0.96524 1.000 0.000
#> ERR184054     1  0.0000    0.96524 1.000 0.000
#> ERR184085     2  0.8144    0.67031 0.252 0.748
#> ERR184056     2  0.0000    0.97225 0.000 1.000
#> ERR184052     2  0.0000    0.97225 0.000 1.000
#> ERR184070     2  0.0000    0.97225 0.000 1.000
#> ERR184096     1  0.0000    0.96524 1.000 0.000
#> ERR184089     2  0.0000    0.97225 0.000 1.000
#> ERR184049     2  0.4161    0.90971 0.084 0.916
#> ERR184038     1  0.0000    0.96524 1.000 0.000
#> ERR184087     1  0.0000    0.96524 1.000 0.000
#> ERR184097     2  0.0376    0.97015 0.004 0.996
#> ERR184094     1  0.0000    0.96524 1.000 0.000
#> ERR184058     2  0.0000    0.97225 0.000 1.000
#> ERR184036     2  0.0000    0.97225 0.000 1.000
#> ERR184046     2  0.0000    0.97225 0.000 1.000
#> ERR184074     1  0.0000    0.96524 1.000 0.000
#> ERR184048     2  0.3879    0.91653 0.076 0.924

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184093     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184051     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184076     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184043     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184037     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184059     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184055     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184065     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184069     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184040     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184057     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184082     2  0.2261      0.918 0.068 0.932 0.000
#> ERR184083     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184039     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184064     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184081     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184079     2  0.2066      0.924 0.060 0.940 0.000
#> ERR184084     3  0.3412      0.852 0.124 0.000 0.876
#> ERR184068     2  0.4796      0.741 0.220 0.780 0.000
#> ERR184067     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184071     2  0.0424      0.959 0.008 0.992 0.000
#> ERR184042     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184063     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184091     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184061     1  0.4002      0.750 0.840 0.160 0.000
#> ERR184077     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184062     2  0.6111      0.386 0.396 0.604 0.000
#> ERR184053     2  0.3038      0.885 0.104 0.896 0.000
#> ERR184088     2  0.0424      0.959 0.008 0.992 0.000
#> ERR184075     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184041     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184060     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184035     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184086     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184080     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184050     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184047     1  0.5591      0.566 0.696 0.000 0.304
#> ERR184092     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184072     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184073     1  0.0237      0.964 0.996 0.000 0.004
#> ERR184066     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184098     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184044     1  0.0424      0.959 0.992 0.008 0.000
#> ERR184054     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184085     2  0.3482      0.855 0.128 0.872 0.000
#> ERR184056     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184052     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184070     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184096     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184089     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184049     2  0.2625      0.905 0.084 0.916 0.000
#> ERR184038     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184087     3  0.0000      0.984 0.000 0.000 1.000
#> ERR184097     2  0.0237      0.961 0.004 0.996 0.000
#> ERR184094     1  0.0424      0.961 0.992 0.000 0.008
#> ERR184058     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184036     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184046     2  0.0000      0.963 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.967 1.000 0.000 0.000
#> ERR184048     2  0.2448      0.911 0.076 0.924 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184093     2  0.2814      0.881 0.000 0.868 0.000 0.132
#> ERR184051     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184076     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184043     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184037     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184059     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184055     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184065     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184069     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184040     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184057     2  0.1022      0.914 0.000 0.968 0.000 0.032
#> ERR184082     2  0.3383      0.885 0.052 0.872 0.000 0.076
#> ERR184083     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184064     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184081     2  0.1022      0.914 0.000 0.968 0.000 0.032
#> ERR184095     2  0.0336      0.917 0.000 0.992 0.000 0.008
#> ERR184079     2  0.3790      0.861 0.016 0.820 0.000 0.164
#> ERR184084     3  0.2704      0.730 0.124 0.000 0.876 0.000
#> ERR184068     2  0.4820      0.824 0.060 0.772 0.000 0.168
#> ERR184067     2  0.1022      0.914 0.000 0.968 0.000 0.032
#> ERR184071     2  0.3610      0.857 0.000 0.800 0.000 0.200
#> ERR184042     4  0.3610      0.000 0.000 0.000 0.200 0.800
#> ERR184063     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184091     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184061     1  0.4244      0.659 0.804 0.160 0.000 0.036
#> ERR184077     2  0.3610      0.857 0.000 0.800 0.000 0.200
#> ERR184062     2  0.6790      0.567 0.228 0.604 0.000 0.168
#> ERR184053     2  0.3610      0.857 0.000 0.800 0.000 0.200
#> ERR184088     2  0.3024      0.883 0.000 0.852 0.000 0.148
#> ERR184075     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184041     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184060     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184035     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184086     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184080     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184050     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184047     1  0.4431      0.528 0.696 0.000 0.304 0.000
#> ERR184092     2  0.3172      0.876 0.000 0.840 0.000 0.160
#> ERR184072     1  0.1211      0.913 0.960 0.000 0.000 0.040
#> ERR184073     1  0.0188      0.940 0.996 0.000 0.004 0.000
#> ERR184066     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184098     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184044     1  0.3636      0.748 0.820 0.008 0.000 0.172
#> ERR184054     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184085     2  0.4374      0.806 0.120 0.812 0.000 0.068
#> ERR184056     2  0.3610      0.857 0.000 0.800 0.000 0.200
#> ERR184052     2  0.0469      0.917 0.000 0.988 0.000 0.012
#> ERR184070     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184096     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184089     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184049     2  0.3090      0.889 0.056 0.888 0.000 0.056
#> ERR184038     1  0.1118      0.916 0.964 0.000 0.000 0.036
#> ERR184087     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> ERR184097     2  0.3610      0.857 0.000 0.800 0.000 0.200
#> ERR184094     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> ERR184058     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184036     2  0.0817      0.915 0.000 0.976 0.000 0.024
#> ERR184046     2  0.0000      0.918 0.000 1.000 0.000 0.000
#> ERR184074     1  0.0000      0.942 1.000 0.000 0.000 0.000
#> ERR184048     2  0.3577      0.877 0.012 0.832 0.000 0.156

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4    p5
#> ERR184078     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184093     2  0.2929      0.844 0.000 0.820 0.000  0 0.180
#> ERR184051     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184076     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184043     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184037     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184059     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184055     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184065     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184069     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184040     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184057     2  0.0880      0.899 0.000 0.968 0.000  0 0.032
#> ERR184082     2  0.2974      0.869 0.052 0.868 0.000  0 0.080
#> ERR184083     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184039     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184064     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184081     2  0.0880      0.899 0.000 0.968 0.000  0 0.032
#> ERR184095     2  0.0290      0.903 0.000 0.992 0.000  0 0.008
#> ERR184079     2  0.3487      0.826 0.008 0.780 0.000  0 0.212
#> ERR184084     3  0.2329      0.779 0.124 0.000 0.876  0 0.000
#> ERR184068     2  0.4295      0.798 0.044 0.740 0.000  0 0.216
#> ERR184067     2  0.0880      0.899 0.000 0.968 0.000  0 0.032
#> ERR184071     2  0.3452      0.820 0.000 0.756 0.000  0 0.244
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000
#> ERR184063     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184091     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184061     1  0.3655      0.530 0.804 0.160 0.000  0 0.036
#> ERR184077     2  0.3480      0.817 0.000 0.752 0.000  0 0.248
#> ERR184062     2  0.6008      0.556 0.200 0.584 0.000  0 0.216
#> ERR184053     2  0.3480      0.817 0.000 0.752 0.000  0 0.248
#> ERR184088     2  0.2813      0.861 0.000 0.832 0.000  0 0.168
#> ERR184075     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184041     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184060     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184035     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184086     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184080     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184050     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184047     5  0.3607      0.000 0.244 0.000 0.004  0 0.752
#> ERR184092     2  0.3177      0.838 0.000 0.792 0.000  0 0.208
#> ERR184072     1  0.1043      0.875 0.960 0.000 0.000  0 0.040
#> ERR184073     1  0.0162      0.911 0.996 0.000 0.004  0 0.000
#> ERR184066     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184098     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184044     1  0.3551      0.558 0.772 0.008 0.000  0 0.220
#> ERR184054     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184085     2  0.3814      0.792 0.124 0.808 0.000  0 0.068
#> ERR184056     2  0.3480      0.817 0.000 0.752 0.000  0 0.248
#> ERR184052     2  0.0404      0.902 0.000 0.988 0.000  0 0.012
#> ERR184070     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184096     1  0.3913      0.269 0.676 0.000 0.000  0 0.324
#> ERR184089     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184049     2  0.2729      0.873 0.056 0.884 0.000  0 0.060
#> ERR184038     1  0.0963      0.880 0.964 0.000 0.000  0 0.036
#> ERR184087     3  0.0000      0.971 0.000 0.000 1.000  0 0.000
#> ERR184097     2  0.3480      0.817 0.000 0.752 0.000  0 0.248
#> ERR184094     1  0.0290      0.907 0.992 0.000 0.008  0 0.000
#> ERR184058     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184036     2  0.0703      0.901 0.000 0.976 0.000  0 0.024
#> ERR184046     2  0.0000      0.903 0.000 1.000 0.000  0 0.000
#> ERR184074     1  0.0000      0.913 1.000 0.000 0.000  0 0.000
#> ERR184048     2  0.3123      0.862 0.012 0.828 0.000  0 0.160

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184093     6  0.3747      0.836 0.000 0.396 0.000  0 0.000 0.604
#> ERR184051     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184076     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184043     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184037     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184059     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184055     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184065     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184069     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184040     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184057     2  0.0790      0.906 0.000 0.968 0.000  0 0.000 0.032
#> ERR184082     2  0.3496      0.681 0.052 0.804 0.000  0 0.004 0.140
#> ERR184083     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184039     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184064     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184081     2  0.0790      0.906 0.000 0.968 0.000  0 0.000 0.032
#> ERR184095     2  0.0260      0.922 0.000 0.992 0.000  0 0.000 0.008
#> ERR184079     6  0.3887      0.873 0.008 0.360 0.000  0 0.000 0.632
#> ERR184084     3  0.2092      0.784 0.124 0.000 0.876  0 0.000 0.000
#> ERR184068     6  0.4249      0.875 0.032 0.328 0.000  0 0.000 0.640
#> ERR184067     2  0.0935      0.904 0.000 0.964 0.000  0 0.004 0.032
#> ERR184071     6  0.3756      0.803 0.000 0.400 0.000  0 0.000 0.600
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000  1 0.000 0.000
#> ERR184063     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184091     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184061     1  0.3236      0.675 0.820 0.140 0.000  0 0.004 0.036
#> ERR184077     6  0.3531      0.885 0.000 0.328 0.000  0 0.000 0.672
#> ERR184062     6  0.4393      0.864 0.044 0.316 0.000  0 0.000 0.640
#> ERR184053     6  0.3531      0.885 0.000 0.328 0.000  0 0.000 0.672
#> ERR184088     2  0.3244      0.471 0.000 0.732 0.000  0 0.000 0.268
#> ERR184075     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184041     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184060     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184035     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184086     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184080     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184050     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184047     5  0.0146      0.000 0.004 0.000 0.000  0 0.996 0.000
#> ERR184092     6  0.3672      0.858 0.000 0.368 0.000  0 0.000 0.632
#> ERR184072     1  0.0937      0.910 0.960 0.000 0.000  0 0.000 0.040
#> ERR184073     1  0.0146      0.940 0.996 0.000 0.004  0 0.000 0.000
#> ERR184066     1  0.0363      0.934 0.988 0.000 0.000  0 0.000 0.012
#> ERR184098     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184044     6  0.3983      0.163 0.348 0.008 0.000  0 0.004 0.640
#> ERR184054     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184085     2  0.4078      0.577 0.180 0.748 0.000  0 0.004 0.068
#> ERR184056     6  0.3531      0.885 0.000 0.328 0.000  0 0.000 0.672
#> ERR184052     2  0.0363      0.920 0.000 0.988 0.000  0 0.000 0.012
#> ERR184070     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184096     1  0.5325      0.265 0.548 0.000 0.000  0 0.124 0.328
#> ERR184089     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184049     2  0.3395      0.729 0.056 0.816 0.000  0 0.004 0.124
#> ERR184038     1  0.0865      0.914 0.964 0.000 0.000  0 0.000 0.036
#> ERR184087     3  0.0000      0.971 0.000 0.000 1.000  0 0.000 0.000
#> ERR184097     6  0.3531      0.885 0.000 0.328 0.000  0 0.000 0.672
#> ERR184094     1  0.0260      0.937 0.992 0.000 0.008  0 0.000 0.000
#> ERR184058     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184036     2  0.0777      0.910 0.000 0.972 0.000  0 0.004 0.024
#> ERR184046     2  0.0000      0.925 0.000 1.000 0.000  0 0.000 0.000
#> ERR184074     1  0.0000      0.942 1.000 0.000 0.000  0 0.000 0.000
#> ERR184048     2  0.3454      0.591 0.012 0.760 0.000  0 0.004 0.224

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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.


MAD:mclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-mclust-select-partition-number

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.445           0.735       0.870         0.3247 0.748   0.748
#> 3 3 0.312           0.616       0.778         0.5944 0.689   0.592
#> 4 4 0.579           0.771       0.869         0.1427 0.896   0.795
#> 5 5 0.673           0.791       0.884         0.1677 0.854   0.680
#> 6 6 0.634           0.610       0.803         0.0772 0.969   0.907

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 5

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.9635      0.483 0.388 0.612
#> ERR184093     2  0.0000      0.823 0.000 1.000
#> ERR184051     1  0.6531      0.854 0.832 0.168
#> ERR184076     2  0.9635      0.483 0.388 0.612
#> ERR184043     1  0.2236      0.875 0.964 0.036
#> ERR184037     2  0.9427      0.527 0.360 0.640
#> ERR184059     1  0.7602      0.772 0.780 0.220
#> ERR184055     2  0.9427      0.527 0.360 0.640
#> ERR184065     2  0.0672      0.823 0.008 0.992
#> ERR184069     2  0.0000      0.823 0.000 1.000
#> ERR184040     2  0.9635      0.483 0.388 0.612
#> ERR184057     2  0.0000      0.823 0.000 1.000
#> ERR184082     2  0.1843      0.817 0.028 0.972
#> ERR184083     2  0.0672      0.823 0.008 0.992
#> ERR184039     2  0.0672      0.823 0.008 0.992
#> ERR184064     1  0.2236      0.875 0.964 0.036
#> ERR184081     2  0.0672      0.823 0.008 0.992
#> ERR184095     2  0.0000      0.823 0.000 1.000
#> ERR184079     2  0.0000      0.823 0.000 1.000
#> ERR184084     1  0.5294      0.852 0.880 0.120
#> ERR184068     2  0.3114      0.797 0.056 0.944
#> ERR184067     2  0.0000      0.823 0.000 1.000
#> ERR184071     2  0.0672      0.823 0.008 0.992
#> ERR184042     1  0.0000      0.840 1.000 0.000
#> ERR184063     1  0.6623      0.851 0.828 0.172
#> ERR184091     2  0.0672      0.823 0.008 0.992
#> ERR184061     2  0.0376      0.823 0.004 0.996
#> ERR184077     2  0.0000      0.823 0.000 1.000
#> ERR184062     2  0.9552      0.500 0.376 0.624
#> ERR184053     2  0.0672      0.823 0.008 0.992
#> ERR184088     2  0.0000      0.823 0.000 1.000
#> ERR184075     2  0.0672      0.823 0.008 0.992
#> ERR184041     1  0.6623      0.851 0.828 0.172
#> ERR184060     2  0.0000      0.823 0.000 1.000
#> ERR184035     2  0.6801      0.712 0.180 0.820
#> ERR184086     2  0.0672      0.823 0.008 0.992
#> ERR184080     2  0.9427      0.527 0.360 0.640
#> ERR184050     2  0.0672      0.823 0.008 0.992
#> ERR184047     2  0.9635      0.483 0.388 0.612
#> ERR184092     2  0.0000      0.823 0.000 1.000
#> ERR184072     2  0.9635      0.483 0.388 0.612
#> ERR184073     2  0.9635      0.483 0.388 0.612
#> ERR184066     2  0.9635      0.483 0.388 0.612
#> ERR184098     2  0.0672      0.823 0.008 0.992
#> ERR184044     2  0.8144      0.652 0.252 0.748
#> ERR184054     2  0.9635      0.483 0.388 0.612
#> ERR184085     2  0.7883      0.669 0.236 0.764
#> ERR184056     2  0.0000      0.823 0.000 1.000
#> ERR184052     2  0.0672      0.823 0.008 0.992
#> ERR184070     2  0.0672      0.823 0.008 0.992
#> ERR184096     2  0.9635      0.483 0.388 0.612
#> ERR184089     2  0.3114      0.803 0.056 0.944
#> ERR184049     2  0.0000      0.823 0.000 1.000
#> ERR184038     2  0.9552      0.512 0.376 0.624
#> ERR184087     1  0.2236      0.875 0.964 0.036
#> ERR184097     2  0.0000      0.823 0.000 1.000
#> ERR184094     2  0.9686      0.477 0.396 0.604
#> ERR184058     2  0.0672      0.823 0.008 0.992
#> ERR184036     2  0.0000      0.823 0.000 1.000
#> ERR184046     2  0.0376      0.823 0.004 0.996
#> ERR184074     2  0.9427      0.527 0.360 0.640
#> ERR184048     2  0.0000      0.823 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.6008     0.5766 0.664 0.332 0.004
#> ERR184093     2  0.4768     0.7559 0.100 0.848 0.052
#> ERR184051     3  0.3921     0.9411 0.112 0.016 0.872
#> ERR184076     1  0.6057     0.5715 0.656 0.340 0.004
#> ERR184043     3  0.2625     0.9354 0.084 0.000 0.916
#> ERR184037     2  0.7584    -0.3567 0.472 0.488 0.040
#> ERR184059     1  0.6701    -0.2321 0.576 0.012 0.412
#> ERR184055     1  0.6809     0.3439 0.524 0.464 0.012
#> ERR184065     2  0.2959     0.6986 0.000 0.900 0.100
#> ERR184069     2  0.0592     0.7613 0.012 0.988 0.000
#> ERR184040     1  0.5919     0.6134 0.724 0.260 0.016
#> ERR184057     2  0.0747     0.7621 0.016 0.984 0.000
#> ERR184082     2  0.7267     0.5678 0.268 0.668 0.064
#> ERR184083     2  0.2590     0.7671 0.072 0.924 0.004
#> ERR184039     2  0.2625     0.7108 0.000 0.916 0.084
#> ERR184064     3  0.2878     0.9499 0.096 0.000 0.904
#> ERR184081     2  0.0424     0.7605 0.008 0.992 0.000
#> ERR184095     2  0.1411     0.7623 0.036 0.964 0.000
#> ERR184079     2  0.6107     0.7031 0.184 0.764 0.052
#> ERR184084     1  0.7676    -0.0928 0.584 0.056 0.360
#> ERR184068     2  0.6703     0.6548 0.236 0.712 0.052
#> ERR184067     2  0.1647     0.7684 0.036 0.960 0.004
#> ERR184071     2  0.5442     0.7337 0.132 0.812 0.056
#> ERR184042     3  0.5254     0.7982 0.264 0.000 0.736
#> ERR184063     3  0.3539     0.9484 0.100 0.012 0.888
#> ERR184091     2  0.2796     0.7052 0.000 0.908 0.092
#> ERR184061     2  0.6578     0.6624 0.224 0.724 0.052
#> ERR184077     2  0.6678     0.6799 0.216 0.724 0.060
#> ERR184062     2  0.7430     0.0343 0.424 0.540 0.036
#> ERR184053     2  0.7308     0.5343 0.284 0.656 0.060
#> ERR184088     2  0.5891     0.7103 0.168 0.780 0.052
#> ERR184075     2  0.3193     0.6948 0.004 0.896 0.100
#> ERR184041     3  0.3375     0.9501 0.100 0.008 0.892
#> ERR184060     2  0.4634     0.7390 0.164 0.824 0.012
#> ERR184035     2  0.7537     0.4508 0.332 0.612 0.056
#> ERR184086     2  0.2625     0.7108 0.000 0.916 0.084
#> ERR184080     1  0.6641     0.3924 0.544 0.448 0.008
#> ERR184050     2  0.2959     0.6986 0.000 0.900 0.100
#> ERR184047     1  0.5931     0.4262 0.792 0.084 0.124
#> ERR184092     2  0.3589     0.7636 0.048 0.900 0.052
#> ERR184072     1  0.6104     0.5658 0.648 0.348 0.004
#> ERR184073     1  0.6696     0.3381 0.736 0.076 0.188
#> ERR184066     1  0.6111     0.5088 0.604 0.396 0.000
#> ERR184098     2  0.2625     0.7105 0.000 0.916 0.084
#> ERR184044     2  0.5558     0.7225 0.152 0.800 0.048
#> ERR184054     1  0.6298     0.5238 0.608 0.388 0.004
#> ERR184085     2  0.6897     0.5343 0.292 0.668 0.040
#> ERR184056     2  0.3694     0.7637 0.052 0.896 0.052
#> ERR184052     2  0.1765     0.7440 0.004 0.956 0.040
#> ERR184070     2  0.4062     0.7334 0.164 0.836 0.000
#> ERR184096     1  0.5576     0.4936 0.812 0.104 0.084
#> ERR184089     2  0.5667     0.6059 0.060 0.800 0.140
#> ERR184049     2  0.5408     0.7306 0.136 0.812 0.052
#> ERR184038     1  0.9189     0.3027 0.436 0.416 0.148
#> ERR184087     3  0.3192     0.9469 0.112 0.000 0.888
#> ERR184097     2  0.4768     0.7544 0.100 0.848 0.052
#> ERR184094     1  0.6927     0.1794 0.700 0.060 0.240
#> ERR184058     2  0.0983     0.7547 0.004 0.980 0.016
#> ERR184036     2  0.4845     0.7542 0.104 0.844 0.052
#> ERR184046     2  0.1453     0.7621 0.024 0.968 0.008
#> ERR184074     1  0.6769     0.5116 0.592 0.392 0.016
#> ERR184048     2  0.5947     0.7118 0.172 0.776 0.052

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.2644     0.7465 0.908 0.032 0.000 0.060
#> ERR184093     2  0.1854     0.8844 0.012 0.940 0.000 0.048
#> ERR184051     3  0.0469     0.8093 0.012 0.000 0.988 0.000
#> ERR184076     1  0.2965     0.7458 0.892 0.036 0.000 0.072
#> ERR184043     3  0.0657     0.8066 0.012 0.000 0.984 0.004
#> ERR184037     1  0.5898     0.6263 0.736 0.164 0.036 0.064
#> ERR184059     3  0.4605     0.5576 0.132 0.000 0.796 0.072
#> ERR184055     1  0.5900     0.4866 0.664 0.260 0.000 0.076
#> ERR184065     2  0.4284     0.8263 0.000 0.780 0.020 0.200
#> ERR184069     2  0.2060     0.8982 0.000 0.932 0.016 0.052
#> ERR184040     1  0.1109     0.7495 0.968 0.028 0.000 0.004
#> ERR184057     2  0.1938     0.8985 0.000 0.936 0.012 0.052
#> ERR184082     2  0.1807     0.8947 0.008 0.940 0.000 0.052
#> ERR184083     2  0.2489     0.8942 0.000 0.912 0.020 0.068
#> ERR184039     2  0.3708     0.8600 0.000 0.832 0.020 0.148
#> ERR184064     3  0.0469     0.8093 0.012 0.000 0.988 0.000
#> ERR184081     2  0.2413     0.8953 0.000 0.916 0.020 0.064
#> ERR184095     2  0.1854     0.8992 0.000 0.940 0.012 0.048
#> ERR184079     2  0.2197     0.8836 0.024 0.928 0.000 0.048
#> ERR184084     3  0.8216     0.0369 0.152 0.224 0.552 0.072
#> ERR184068     2  0.3323     0.8590 0.060 0.876 0.000 0.064
#> ERR184067     2  0.1389     0.9000 0.000 0.952 0.000 0.048
#> ERR184071     2  0.0469     0.8978 0.000 0.988 0.000 0.012
#> ERR184042     4  0.6463     0.0000 0.160 0.000 0.196 0.644
#> ERR184063     3  0.0469     0.8093 0.012 0.000 0.988 0.000
#> ERR184091     2  0.4284     0.8263 0.000 0.780 0.020 0.200
#> ERR184061     1  0.5288     0.2807 0.520 0.472 0.000 0.008
#> ERR184077     2  0.1302     0.8902 0.000 0.956 0.000 0.044
#> ERR184062     2  0.5432     0.6549 0.216 0.716 0.000 0.068
#> ERR184053     2  0.0524     0.8976 0.004 0.988 0.000 0.008
#> ERR184088     2  0.1624     0.8902 0.020 0.952 0.000 0.028
#> ERR184075     2  0.4464     0.8232 0.000 0.768 0.024 0.208
#> ERR184041     3  0.0469     0.8093 0.012 0.000 0.988 0.000
#> ERR184060     2  0.2825     0.8985 0.012 0.908 0.024 0.056
#> ERR184035     2  0.3383     0.8552 0.076 0.872 0.000 0.052
#> ERR184086     2  0.4163     0.8408 0.000 0.792 0.020 0.188
#> ERR184080     1  0.3621     0.7255 0.860 0.072 0.000 0.068
#> ERR184050     2  0.4361     0.8263 0.000 0.772 0.020 0.208
#> ERR184047     1  0.3497     0.6516 0.860 0.000 0.036 0.104
#> ERR184092     2  0.1677     0.8877 0.012 0.948 0.000 0.040
#> ERR184072     1  0.2871     0.7442 0.896 0.032 0.000 0.072
#> ERR184073     1  0.2540     0.7383 0.924 0.024 0.024 0.028
#> ERR184066     1  0.5533     0.5308 0.708 0.220 0.000 0.072
#> ERR184098     2  0.3606     0.8688 0.000 0.840 0.020 0.140
#> ERR184044     2  0.2761     0.8658 0.048 0.904 0.000 0.048
#> ERR184054     1  0.2816     0.7467 0.900 0.036 0.000 0.064
#> ERR184085     2  0.1888     0.8945 0.016 0.940 0.000 0.044
#> ERR184056     2  0.1975     0.8831 0.016 0.936 0.000 0.048
#> ERR184052     2  0.2706     0.8888 0.000 0.900 0.020 0.080
#> ERR184070     2  0.2483     0.8989 0.012 0.920 0.012 0.056
#> ERR184096     1  0.2546     0.7063 0.920 0.008 0.028 0.044
#> ERR184089     2  0.7188     0.4929 0.000 0.552 0.244 0.204
#> ERR184049     2  0.0188     0.8968 0.000 0.996 0.000 0.004
#> ERR184038     2  0.6616     0.6849 0.172 0.692 0.048 0.088
#> ERR184087     3  0.2412     0.7323 0.084 0.000 0.908 0.008
#> ERR184097     2  0.2060     0.8817 0.016 0.932 0.000 0.052
#> ERR184094     1  0.4997     0.6200 0.792 0.012 0.104 0.092
#> ERR184058     2  0.2742     0.8917 0.000 0.900 0.024 0.076
#> ERR184036     2  0.0376     0.8971 0.004 0.992 0.000 0.004
#> ERR184046     2  0.2852     0.8953 0.008 0.904 0.024 0.064
#> ERR184074     1  0.3970     0.7204 0.840 0.076 0.000 0.084
#> ERR184048     2  0.0937     0.8977 0.012 0.976 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.0510      0.792 0.984 0.000 0.000 0.016 0.000
#> ERR184093     2  0.1179      0.884 0.004 0.964 0.000 0.016 0.016
#> ERR184051     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> ERR184076     1  0.0771      0.794 0.976 0.004 0.000 0.020 0.000
#> ERR184043     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.5255      0.616 0.672 0.076 0.000 0.244 0.008
#> ERR184059     3  0.4547      0.499 0.044 0.000 0.704 0.252 0.000
#> ERR184055     1  0.4907      0.584 0.720 0.204 0.000 0.064 0.012
#> ERR184065     5  0.0609      0.893 0.000 0.020 0.000 0.000 0.980
#> ERR184069     2  0.3616      0.825 0.000 0.804 0.000 0.032 0.164
#> ERR184040     1  0.0703      0.794 0.976 0.000 0.000 0.024 0.000
#> ERR184057     2  0.3535      0.827 0.000 0.808 0.000 0.028 0.164
#> ERR184082     2  0.1124      0.881 0.000 0.960 0.000 0.004 0.036
#> ERR184083     2  0.3594      0.822 0.000 0.804 0.004 0.020 0.172
#> ERR184039     5  0.3243      0.742 0.000 0.180 0.004 0.004 0.812
#> ERR184064     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.3773      0.823 0.000 0.800 0.004 0.032 0.164
#> ERR184095     2  0.3409      0.829 0.000 0.816 0.000 0.024 0.160
#> ERR184079     2  0.0510      0.883 0.000 0.984 0.000 0.016 0.000
#> ERR184084     2  0.6375      0.466 0.048 0.604 0.080 0.264 0.004
#> ERR184068     2  0.1569      0.873 0.032 0.948 0.000 0.012 0.008
#> ERR184067     2  0.2920      0.847 0.000 0.852 0.000 0.016 0.132
#> ERR184071     2  0.0898      0.884 0.000 0.972 0.000 0.008 0.020
#> ERR184042     4  0.2770      0.000 0.044 0.000 0.076 0.880 0.000
#> ERR184063     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> ERR184091     5  0.0510      0.892 0.000 0.016 0.000 0.000 0.984
#> ERR184061     1  0.4779      0.348 0.584 0.396 0.000 0.016 0.004
#> ERR184077     2  0.0671      0.882 0.000 0.980 0.000 0.016 0.004
#> ERR184062     2  0.3770      0.718 0.188 0.788 0.000 0.016 0.008
#> ERR184053     2  0.0798      0.883 0.000 0.976 0.000 0.008 0.016
#> ERR184088     2  0.0162      0.884 0.000 0.996 0.000 0.000 0.004
#> ERR184075     5  0.0510      0.892 0.000 0.016 0.000 0.000 0.984
#> ERR184041     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> ERR184060     2  0.3566      0.827 0.000 0.812 0.004 0.024 0.160
#> ERR184035     2  0.1507      0.876 0.024 0.952 0.000 0.012 0.012
#> ERR184086     5  0.2052      0.858 0.000 0.080 0.004 0.004 0.912
#> ERR184080     1  0.2251      0.787 0.916 0.024 0.000 0.052 0.008
#> ERR184050     5  0.0671      0.890 0.000 0.016 0.004 0.000 0.980
#> ERR184047     1  0.3774      0.608 0.704 0.000 0.000 0.296 0.000
#> ERR184092     2  0.0912      0.884 0.000 0.972 0.000 0.016 0.012
#> ERR184072     1  0.0771      0.794 0.976 0.004 0.000 0.020 0.000
#> ERR184073     1  0.0404      0.795 0.988 0.000 0.000 0.012 0.000
#> ERR184066     1  0.3575      0.597 0.800 0.180 0.000 0.016 0.004
#> ERR184098     5  0.3128      0.765 0.000 0.168 0.004 0.004 0.824
#> ERR184044     2  0.1095      0.881 0.008 0.968 0.000 0.012 0.012
#> ERR184054     1  0.0798      0.793 0.976 0.008 0.000 0.016 0.000
#> ERR184085     2  0.1168      0.882 0.008 0.960 0.000 0.000 0.032
#> ERR184056     2  0.0960      0.883 0.004 0.972 0.000 0.016 0.008
#> ERR184052     2  0.3282      0.821 0.000 0.804 0.000 0.008 0.188
#> ERR184070     2  0.3454      0.831 0.000 0.816 0.000 0.028 0.156
#> ERR184096     1  0.2536      0.751 0.868 0.004 0.000 0.128 0.000
#> ERR184089     5  0.0865      0.888 0.000 0.024 0.004 0.000 0.972
#> ERR184049     2  0.0912      0.882 0.000 0.972 0.000 0.016 0.012
#> ERR184038     2  0.4629      0.750 0.172 0.764 0.008 0.036 0.020
#> ERR184087     3  0.3115      0.752 0.036 0.000 0.852 0.112 0.000
#> ERR184097     2  0.1419      0.882 0.012 0.956 0.000 0.016 0.016
#> ERR184094     1  0.4748      0.645 0.708 0.016 0.012 0.252 0.012
#> ERR184058     2  0.3812      0.802 0.000 0.780 0.004 0.020 0.196
#> ERR184036     2  0.0671      0.882 0.000 0.980 0.000 0.016 0.004
#> ERR184046     2  0.3556      0.824 0.000 0.808 0.004 0.020 0.168
#> ERR184074     1  0.2674      0.780 0.888 0.020 0.000 0.084 0.008
#> ERR184048     2  0.0693      0.882 0.000 0.980 0.000 0.008 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.0551     0.6741 0.984 0.000 0.000 0.004 0.004 0.008
#> ERR184093     2  0.2100     0.6907 0.004 0.884 0.000 0.000 0.000 0.112
#> ERR184051     3  0.0146     0.9297 0.000 0.000 0.996 0.000 0.000 0.004
#> ERR184076     1  0.0767     0.6737 0.976 0.000 0.000 0.004 0.012 0.008
#> ERR184043     3  0.0000     0.9304 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184037     1  0.6091     0.1536 0.544 0.032 0.000 0.000 0.172 0.252
#> ERR184059     3  0.3626     0.6327 0.004 0.000 0.704 0.000 0.288 0.004
#> ERR184055     1  0.4430     0.5548 0.760 0.120 0.000 0.000 0.040 0.080
#> ERR184065     4  0.0260     0.9415 0.000 0.008 0.000 0.992 0.000 0.000
#> ERR184069     2  0.4267     0.6487 0.000 0.732 0.000 0.152 0.000 0.116
#> ERR184040     1  0.1908     0.6560 0.900 0.000 0.000 0.000 0.096 0.004
#> ERR184057     2  0.4095     0.6600 0.000 0.748 0.000 0.152 0.000 0.100
#> ERR184082     2  0.4243     0.3416 0.008 0.704 0.000 0.040 0.000 0.248
#> ERR184083     2  0.4282     0.6384 0.000 0.720 0.000 0.192 0.000 0.088
#> ERR184039     4  0.2538     0.7835 0.000 0.124 0.000 0.860 0.000 0.016
#> ERR184064     3  0.0000     0.9304 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184081     2  0.4267     0.6487 0.000 0.732 0.000 0.152 0.000 0.116
#> ERR184095     2  0.4140     0.6553 0.000 0.744 0.000 0.152 0.000 0.104
#> ERR184079     2  0.1610     0.7014 0.000 0.916 0.000 0.000 0.000 0.084
#> ERR184084     6  0.7518     0.0000 0.016 0.256 0.056 0.008 0.328 0.336
#> ERR184068     2  0.2831     0.6712 0.024 0.840 0.000 0.000 0.000 0.136
#> ERR184067     2  0.3190     0.6928 0.000 0.820 0.000 0.136 0.000 0.044
#> ERR184071     2  0.1643     0.7147 0.000 0.924 0.000 0.068 0.000 0.008
#> ERR184042     5  0.4617    -0.0970 0.004 0.000 0.060 0.000 0.652 0.284
#> ERR184063     3  0.0146     0.9297 0.000 0.000 0.996 0.000 0.000 0.004
#> ERR184091     4  0.0146     0.9421 0.000 0.004 0.000 0.996 0.000 0.000
#> ERR184061     1  0.5806     0.1239 0.484 0.404 0.000 0.000 0.056 0.056
#> ERR184077     2  0.1951     0.7102 0.000 0.908 0.000 0.016 0.000 0.076
#> ERR184062     2  0.3529     0.5361 0.208 0.764 0.000 0.000 0.000 0.028
#> ERR184053     2  0.3766     0.3549 0.000 0.720 0.000 0.024 0.000 0.256
#> ERR184088     2  0.1421     0.7014 0.028 0.944 0.000 0.000 0.000 0.028
#> ERR184075     4  0.0146     0.9421 0.000 0.004 0.000 0.996 0.000 0.000
#> ERR184041     3  0.0000     0.9304 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184060     2  0.4267     0.6547 0.000 0.732 0.000 0.152 0.000 0.116
#> ERR184035     2  0.6024    -0.3010 0.268 0.492 0.000 0.000 0.008 0.232
#> ERR184086     4  0.0806     0.9319 0.000 0.020 0.000 0.972 0.000 0.008
#> ERR184080     1  0.3273     0.6339 0.848 0.036 0.000 0.000 0.044 0.072
#> ERR184050     4  0.0146     0.9421 0.000 0.004 0.000 0.996 0.000 0.000
#> ERR184047     5  0.4101     0.2296 0.408 0.000 0.000 0.000 0.580 0.012
#> ERR184092     2  0.1814     0.6977 0.000 0.900 0.000 0.000 0.000 0.100
#> ERR184072     1  0.1075     0.6644 0.952 0.000 0.000 0.000 0.048 0.000
#> ERR184073     1  0.3360     0.3651 0.732 0.004 0.000 0.000 0.264 0.000
#> ERR184066     1  0.1267     0.6473 0.940 0.060 0.000 0.000 0.000 0.000
#> ERR184098     4  0.2070     0.8474 0.000 0.100 0.000 0.892 0.000 0.008
#> ERR184044     2  0.1767     0.7085 0.012 0.932 0.000 0.020 0.000 0.036
#> ERR184054     1  0.0405     0.6765 0.988 0.004 0.000 0.000 0.008 0.000
#> ERR184085     2  0.3917     0.4570 0.012 0.752 0.000 0.032 0.000 0.204
#> ERR184056     2  0.1910     0.6938 0.000 0.892 0.000 0.000 0.000 0.108
#> ERR184052     2  0.3376     0.6568 0.000 0.764 0.000 0.220 0.000 0.016
#> ERR184070     2  0.4154     0.6591 0.000 0.744 0.000 0.144 0.000 0.112
#> ERR184096     1  0.3899    -0.0625 0.592 0.000 0.000 0.000 0.404 0.004
#> ERR184089     4  0.0291     0.9388 0.000 0.004 0.004 0.992 0.000 0.000
#> ERR184049     2  0.1296     0.7075 0.004 0.948 0.000 0.000 0.004 0.044
#> ERR184038     2  0.6827     0.0160 0.136 0.556 0.000 0.044 0.056 0.208
#> ERR184087     3  0.1610     0.8715 0.000 0.000 0.916 0.000 0.084 0.000
#> ERR184097     2  0.2450     0.6843 0.016 0.868 0.000 0.000 0.000 0.116
#> ERR184094     5  0.4910     0.2132 0.420 0.012 0.000 0.008 0.536 0.024
#> ERR184058     2  0.4475     0.6103 0.000 0.692 0.000 0.220 0.000 0.088
#> ERR184036     2  0.1155     0.7090 0.004 0.956 0.000 0.004 0.000 0.036
#> ERR184046     2  0.4141     0.6520 0.000 0.740 0.000 0.168 0.000 0.092
#> ERR184074     1  0.4151     0.6100 0.780 0.036 0.000 0.000 0.120 0.064
#> ERR184048     2  0.0363     0.7099 0.000 0.988 0.000 0.000 0.000 0.012

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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.


MAD:NMF

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk MAD-NMF-select-partition-number

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.871           0.914       0.953         0.4977 0.497   0.497
#> 3 3 0.535           0.679       0.844         0.2615 0.856   0.718
#> 4 4 0.500           0.666       0.794         0.1305 0.750   0.474
#> 5 5 0.563           0.638       0.759         0.0810 0.883   0.646
#> 6 6 0.583           0.503       0.718         0.0449 0.970   0.870

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0376      0.954 0.996 0.004
#> ERR184093     1  0.0672      0.957 0.992 0.008
#> ERR184051     2  0.1414      0.936 0.020 0.980
#> ERR184076     1  0.0672      0.952 0.992 0.008
#> ERR184043     2  0.1414      0.936 0.020 0.980
#> ERR184037     1  0.0938      0.957 0.988 0.012
#> ERR184059     2  0.2603      0.926 0.044 0.956
#> ERR184055     1  0.0672      0.957 0.992 0.008
#> ERR184065     2  0.0672      0.949 0.008 0.992
#> ERR184069     2  0.5842      0.832 0.140 0.860
#> ERR184040     1  0.0376      0.956 0.996 0.004
#> ERR184057     1  0.4022      0.923 0.920 0.080
#> ERR184082     2  0.1843      0.941 0.028 0.972
#> ERR184083     2  0.0938      0.949 0.012 0.988
#> ERR184039     2  0.0938      0.949 0.012 0.988
#> ERR184064     2  0.0000      0.946 0.000 1.000
#> ERR184081     2  0.1843      0.941 0.028 0.972
#> ERR184095     1  0.5629      0.874 0.868 0.132
#> ERR184079     1  0.0938      0.957 0.988 0.012
#> ERR184084     2  0.0938      0.949 0.012 0.988
#> ERR184068     1  0.2778      0.946 0.952 0.048
#> ERR184067     2  0.9775      0.280 0.412 0.588
#> ERR184071     2  0.1633      0.944 0.024 0.976
#> ERR184042     2  0.5946      0.835 0.144 0.856
#> ERR184063     2  0.0000      0.946 0.000 1.000
#> ERR184091     2  0.0672      0.949 0.008 0.992
#> ERR184061     1  0.0938      0.957 0.988 0.012
#> ERR184077     1  0.1633      0.955 0.976 0.024
#> ERR184062     1  0.0672      0.953 0.992 0.008
#> ERR184053     1  0.3733      0.932 0.928 0.072
#> ERR184088     1  0.2778      0.946 0.952 0.048
#> ERR184075     2  0.0672      0.949 0.008 0.992
#> ERR184041     2  0.0672      0.949 0.008 0.992
#> ERR184060     1  0.5946      0.860 0.856 0.144
#> ERR184035     1  0.2948      0.944 0.948 0.052
#> ERR184086     2  0.0672      0.949 0.008 0.992
#> ERR184080     1  0.0672      0.957 0.992 0.008
#> ERR184050     2  0.0672      0.949 0.008 0.992
#> ERR184047     1  0.0938      0.951 0.988 0.012
#> ERR184092     1  0.2236      0.951 0.964 0.036
#> ERR184072     1  0.0376      0.954 0.996 0.004
#> ERR184073     1  0.0672      0.957 0.992 0.008
#> ERR184066     1  0.0376      0.954 0.996 0.004
#> ERR184098     2  0.0672      0.949 0.008 0.992
#> ERR184044     1  0.0672      0.953 0.992 0.008
#> ERR184054     1  0.0376      0.954 0.996 0.004
#> ERR184085     2  0.4022      0.898 0.080 0.920
#> ERR184056     1  0.0938      0.957 0.988 0.012
#> ERR184052     2  0.0938      0.949 0.012 0.988
#> ERR184070     1  0.2778      0.946 0.952 0.048
#> ERR184096     1  0.0376      0.954 0.996 0.004
#> ERR184089     2  0.0672      0.949 0.008 0.992
#> ERR184049     1  0.8386      0.673 0.732 0.268
#> ERR184038     2  0.9635      0.431 0.388 0.612
#> ERR184087     2  0.0000      0.946 0.000 1.000
#> ERR184097     1  0.0938      0.957 0.988 0.012
#> ERR184094     1  0.7950      0.684 0.760 0.240
#> ERR184058     2  0.0938      0.949 0.012 0.988
#> ERR184036     1  0.3431      0.936 0.936 0.064
#> ERR184046     2  0.0938      0.949 0.012 0.988
#> ERR184074     1  0.0376      0.956 0.996 0.004
#> ERR184048     1  0.2778      0.946 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.1163      0.833 0.972 0.000 0.028
#> ERR184093     1  0.0000      0.838 1.000 0.000 0.000
#> ERR184051     3  0.3482      0.701 0.000 0.128 0.872
#> ERR184076     1  0.3267      0.790 0.884 0.000 0.116
#> ERR184043     3  0.3551      0.699 0.000 0.132 0.868
#> ERR184037     1  0.1289      0.838 0.968 0.032 0.000
#> ERR184059     3  0.1860      0.686 0.000 0.052 0.948
#> ERR184055     1  0.0000      0.838 1.000 0.000 0.000
#> ERR184065     2  0.2261      0.772 0.000 0.932 0.068
#> ERR184069     2  0.0747      0.788 0.016 0.984 0.000
#> ERR184040     1  0.0747      0.836 0.984 0.000 0.016
#> ERR184057     1  0.5621      0.649 0.692 0.308 0.000
#> ERR184082     2  0.2400      0.777 0.004 0.932 0.064
#> ERR184083     2  0.0000      0.797 0.000 1.000 0.000
#> ERR184039     2  0.1753      0.784 0.000 0.952 0.048
#> ERR184064     3  0.5650      0.598 0.000 0.312 0.688
#> ERR184081     2  0.0424      0.794 0.008 0.992 0.000
#> ERR184095     1  0.6252      0.413 0.556 0.444 0.000
#> ERR184079     1  0.1643      0.836 0.956 0.044 0.000
#> ERR184084     3  0.6683      0.199 0.008 0.492 0.500
#> ERR184068     1  0.2772      0.828 0.916 0.080 0.004
#> ERR184067     2  0.3941      0.613 0.156 0.844 0.000
#> ERR184071     2  0.0424      0.794 0.008 0.992 0.000
#> ERR184042     3  0.0892      0.657 0.020 0.000 0.980
#> ERR184063     3  0.4887      0.667 0.000 0.228 0.772
#> ERR184091     2  0.2165      0.775 0.000 0.936 0.064
#> ERR184061     1  0.1643      0.838 0.956 0.044 0.000
#> ERR184077     1  0.2066      0.833 0.940 0.060 0.000
#> ERR184062     1  0.5650      0.571 0.688 0.000 0.312
#> ERR184053     1  0.5810      0.619 0.664 0.336 0.000
#> ERR184088     1  0.4291      0.773 0.820 0.180 0.000
#> ERR184075     2  0.5058      0.564 0.000 0.756 0.244
#> ERR184041     3  0.6295      0.264 0.000 0.472 0.528
#> ERR184060     1  0.6291      0.318 0.532 0.468 0.000
#> ERR184035     1  0.4121      0.781 0.832 0.168 0.000
#> ERR184086     2  0.5497      0.472 0.000 0.708 0.292
#> ERR184080     1  0.0000      0.838 1.000 0.000 0.000
#> ERR184050     2  0.5138      0.549 0.000 0.748 0.252
#> ERR184047     1  0.5363      0.628 0.724 0.000 0.276
#> ERR184092     1  0.1031      0.839 0.976 0.024 0.000
#> ERR184072     1  0.1411      0.830 0.964 0.000 0.036
#> ERR184073     1  0.5733      0.553 0.676 0.000 0.324
#> ERR184066     1  0.3816      0.765 0.852 0.000 0.148
#> ERR184098     2  0.5621      0.436 0.000 0.692 0.308
#> ERR184044     1  0.5733      0.564 0.676 0.000 0.324
#> ERR184054     1  0.1753      0.827 0.952 0.000 0.048
#> ERR184085     2  0.1620      0.789 0.024 0.964 0.012
#> ERR184056     1  0.0000      0.838 1.000 0.000 0.000
#> ERR184052     2  0.0000      0.797 0.000 1.000 0.000
#> ERR184070     1  0.3116      0.814 0.892 0.108 0.000
#> ERR184096     1  0.3192      0.793 0.888 0.000 0.112
#> ERR184089     2  0.5905      0.317 0.000 0.648 0.352
#> ERR184049     2  0.6095      0.102 0.392 0.608 0.000
#> ERR184038     3  0.3619      0.609 0.136 0.000 0.864
#> ERR184087     3  0.5760      0.578 0.000 0.328 0.672
#> ERR184097     1  0.1031      0.834 0.976 0.000 0.024
#> ERR184094     3  0.7056      0.123 0.404 0.024 0.572
#> ERR184058     2  0.0000      0.797 0.000 1.000 0.000
#> ERR184036     1  0.5397      0.684 0.720 0.280 0.000
#> ERR184046     2  0.0000      0.797 0.000 1.000 0.000
#> ERR184074     1  0.0424      0.837 0.992 0.000 0.008
#> ERR184048     1  0.4796      0.742 0.780 0.220 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.2983     0.7678 0.892 0.040 0.000 0.068
#> ERR184093     1  0.1406     0.7850 0.960 0.016 0.000 0.024
#> ERR184051     3  0.3801     0.5713 0.000 0.000 0.780 0.220
#> ERR184076     1  0.3266     0.7597 0.880 0.032 0.004 0.084
#> ERR184043     3  0.2921     0.6637 0.000 0.000 0.860 0.140
#> ERR184037     1  0.6245     0.6729 0.668 0.168 0.000 0.164
#> ERR184059     3  0.5050     0.0834 0.004 0.000 0.588 0.408
#> ERR184055     1  0.4440     0.7526 0.804 0.060 0.000 0.136
#> ERR184065     3  0.3907     0.6558 0.000 0.232 0.768 0.000
#> ERR184069     2  0.4449     0.7273 0.012 0.824 0.104 0.060
#> ERR184040     1  0.1610     0.7862 0.952 0.016 0.000 0.032
#> ERR184057     2  0.3856     0.6823 0.032 0.832 0.000 0.136
#> ERR184082     2  0.2803     0.7370 0.012 0.900 0.080 0.008
#> ERR184083     2  0.2216     0.7339 0.000 0.908 0.092 0.000
#> ERR184039     3  0.4661     0.6225 0.000 0.256 0.728 0.016
#> ERR184064     3  0.2654     0.6989 0.000 0.004 0.888 0.108
#> ERR184081     2  0.3142     0.7300 0.000 0.860 0.132 0.008
#> ERR184095     2  0.2782     0.7249 0.068 0.904 0.004 0.024
#> ERR184079     1  0.5279     0.6482 0.716 0.232 0.000 0.052
#> ERR184084     2  0.7798     0.4400 0.060 0.592 0.140 0.208
#> ERR184068     2  0.5698     0.4391 0.356 0.608 0.000 0.036
#> ERR184067     2  0.5317     0.6910 0.028 0.776 0.060 0.136
#> ERR184071     2  0.3688     0.6828 0.000 0.792 0.208 0.000
#> ERR184042     4  0.4035     0.7549 0.020 0.000 0.176 0.804
#> ERR184063     3  0.3764     0.5823 0.000 0.000 0.784 0.216
#> ERR184091     3  0.4382     0.5720 0.000 0.296 0.704 0.000
#> ERR184061     1  0.5567     0.7172 0.740 0.088 0.008 0.164
#> ERR184077     2  0.5464     0.5931 0.228 0.708 0.000 0.064
#> ERR184062     1  0.3736     0.7335 0.860 0.012 0.032 0.096
#> ERR184053     2  0.4336     0.6881 0.132 0.816 0.004 0.048
#> ERR184088     1  0.6920     0.4727 0.552 0.316 0.000 0.132
#> ERR184075     3  0.3306     0.7199 0.000 0.156 0.840 0.004
#> ERR184041     3  0.1820     0.7420 0.000 0.020 0.944 0.036
#> ERR184060     1  0.7865     0.3893 0.544 0.300 0.080 0.076
#> ERR184035     2  0.4295     0.6476 0.240 0.752 0.000 0.008
#> ERR184086     3  0.2149     0.7449 0.000 0.088 0.912 0.000
#> ERR184080     1  0.2565     0.7859 0.912 0.032 0.000 0.056
#> ERR184050     3  0.3105     0.7307 0.000 0.120 0.868 0.012
#> ERR184047     1  0.4203     0.7351 0.824 0.000 0.068 0.108
#> ERR184092     1  0.3542     0.7771 0.864 0.076 0.000 0.060
#> ERR184072     1  0.1488     0.7787 0.956 0.012 0.000 0.032
#> ERR184073     1  0.4337     0.7088 0.824 0.004 0.072 0.100
#> ERR184066     1  0.2667     0.7733 0.912 0.008 0.020 0.060
#> ERR184098     3  0.1771     0.7504 0.004 0.036 0.948 0.012
#> ERR184044     1  0.6398     0.6286 0.660 0.032 0.052 0.256
#> ERR184054     1  0.0657     0.7869 0.984 0.004 0.000 0.012
#> ERR184085     2  0.4333     0.7298 0.008 0.812 0.148 0.032
#> ERR184056     1  0.2399     0.7857 0.920 0.048 0.000 0.032
#> ERR184052     2  0.5143     0.4415 0.000 0.628 0.360 0.012
#> ERR184070     1  0.5950     0.6964 0.696 0.156 0.000 0.148
#> ERR184096     1  0.2089     0.7809 0.932 0.000 0.020 0.048
#> ERR184089     3  0.1452     0.7515 0.000 0.036 0.956 0.008
#> ERR184049     2  0.7701     0.5466 0.156 0.616 0.072 0.156
#> ERR184038     4  0.6381     0.7718 0.148 0.020 0.136 0.696
#> ERR184087     3  0.2469     0.6944 0.000 0.000 0.892 0.108
#> ERR184097     1  0.2670     0.7709 0.908 0.052 0.000 0.040
#> ERR184094     1  0.7346     0.3346 0.552 0.004 0.220 0.224
#> ERR184058     2  0.4608     0.5639 0.000 0.692 0.304 0.004
#> ERR184036     1  0.7492     0.5249 0.556 0.268 0.016 0.160
#> ERR184046     2  0.4252     0.6233 0.000 0.744 0.252 0.004
#> ERR184074     1  0.4356     0.7463 0.812 0.044 0.004 0.140
#> ERR184048     2  0.3718     0.6811 0.168 0.820 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.2476      0.794 0.904 0.012 0.000 0.020 0.064
#> ERR184093     1  0.4326      0.755 0.780 0.008 0.008 0.040 0.164
#> ERR184051     3  0.3866      0.709 0.024 0.000 0.780 0.192 0.004
#> ERR184076     1  0.1748      0.782 0.944 0.008 0.004 0.016 0.028
#> ERR184043     3  0.3080      0.766 0.020 0.000 0.852 0.124 0.004
#> ERR184037     5  0.3276      0.668 0.132 0.032 0.000 0.000 0.836
#> ERR184059     3  0.4705      0.587 0.040 0.000 0.692 0.264 0.004
#> ERR184055     5  0.3814      0.551 0.276 0.004 0.000 0.000 0.720
#> ERR184065     3  0.3876      0.677 0.000 0.168 0.796 0.012 0.024
#> ERR184069     2  0.5191      0.437 0.000 0.552 0.036 0.004 0.408
#> ERR184040     1  0.3129      0.778 0.832 0.004 0.000 0.008 0.156
#> ERR184057     2  0.4264      0.499 0.000 0.620 0.000 0.004 0.376
#> ERR184082     2  0.2702      0.717 0.008 0.904 0.040 0.016 0.032
#> ERR184083     2  0.2067      0.721 0.000 0.924 0.044 0.004 0.028
#> ERR184039     3  0.5275      0.589 0.000 0.188 0.712 0.032 0.068
#> ERR184064     3  0.2464      0.783 0.016 0.000 0.888 0.096 0.000
#> ERR184081     2  0.4409      0.681 0.000 0.736 0.040 0.004 0.220
#> ERR184095     2  0.2463      0.697 0.008 0.888 0.000 0.004 0.100
#> ERR184079     5  0.7206      0.176 0.388 0.128 0.008 0.040 0.436
#> ERR184084     2  0.5445      0.592 0.024 0.748 0.056 0.120 0.052
#> ERR184068     2  0.5646      0.301 0.336 0.584 0.000 0.008 0.072
#> ERR184067     5  0.4675      0.134 0.000 0.336 0.020 0.004 0.640
#> ERR184071     2  0.4490      0.693 0.000 0.756 0.168 0.004 0.072
#> ERR184042     4  0.1282      0.652 0.004 0.000 0.044 0.952 0.000
#> ERR184063     3  0.3586      0.721 0.020 0.000 0.792 0.188 0.000
#> ERR184091     3  0.4268      0.589 0.000 0.244 0.728 0.004 0.024
#> ERR184061     5  0.3734      0.615 0.204 0.004 0.004 0.008 0.780
#> ERR184077     2  0.4653      0.555 0.132 0.752 0.000 0.004 0.112
#> ERR184062     1  0.1682      0.762 0.944 0.000 0.032 0.012 0.012
#> ERR184053     2  0.4072      0.637 0.048 0.792 0.000 0.008 0.152
#> ERR184088     5  0.5233      0.642 0.164 0.136 0.000 0.004 0.696
#> ERR184075     3  0.1809      0.785 0.000 0.060 0.928 0.000 0.012
#> ERR184041     3  0.2026      0.799 0.016 0.012 0.928 0.044 0.000
#> ERR184060     5  0.7301      0.531 0.184 0.188 0.068 0.008 0.552
#> ERR184035     2  0.4848      0.665 0.092 0.736 0.000 0.008 0.164
#> ERR184086     3  0.1442      0.795 0.000 0.012 0.952 0.032 0.004
#> ERR184080     1  0.4182      0.391 0.600 0.000 0.000 0.000 0.400
#> ERR184050     3  0.2450      0.781 0.000 0.028 0.912 0.028 0.032
#> ERR184047     1  0.5715      0.560 0.636 0.000 0.020 0.080 0.264
#> ERR184092     1  0.5856      0.384 0.596 0.036 0.008 0.032 0.328
#> ERR184072     1  0.2731      0.793 0.876 0.016 0.000 0.004 0.104
#> ERR184073     1  0.4933      0.730 0.756 0.000 0.056 0.048 0.140
#> ERR184066     1  0.1843      0.799 0.932 0.000 0.008 0.008 0.052
#> ERR184098     3  0.1940      0.797 0.004 0.008 0.936 0.024 0.028
#> ERR184044     5  0.7191      0.275 0.320 0.000 0.056 0.144 0.480
#> ERR184054     1  0.3437      0.771 0.808 0.000 0.004 0.012 0.176
#> ERR184085     2  0.5558      0.690 0.000 0.696 0.080 0.040 0.184
#> ERR184056     1  0.3142      0.768 0.856 0.032 0.000 0.004 0.108
#> ERR184052     2  0.6418      0.486 0.000 0.508 0.316 0.004 0.172
#> ERR184070     5  0.3821      0.668 0.148 0.052 0.000 0.000 0.800
#> ERR184096     1  0.3430      0.778 0.824 0.000 0.012 0.012 0.152
#> ERR184089     3  0.0968      0.803 0.004 0.012 0.972 0.012 0.000
#> ERR184049     5  0.3898      0.511 0.004 0.188 0.020 0.004 0.784
#> ERR184038     4  0.7318      0.614 0.260 0.064 0.072 0.560 0.044
#> ERR184087     3  0.2536      0.775 0.004 0.000 0.868 0.128 0.000
#> ERR184097     1  0.1728      0.771 0.940 0.020 0.000 0.004 0.036
#> ERR184094     5  0.7491      0.421 0.204 0.000 0.136 0.136 0.524
#> ERR184058     2  0.5738      0.641 0.000 0.644 0.228 0.012 0.116
#> ERR184036     5  0.3775      0.665 0.056 0.084 0.008 0.012 0.840
#> ERR184046     2  0.4582      0.676 0.004 0.764 0.172 0.020 0.040
#> ERR184074     5  0.4240      0.479 0.304 0.000 0.004 0.008 0.684
#> ERR184048     2  0.2538      0.691 0.048 0.900 0.000 0.004 0.048

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.2602     0.6514 0.896 0.016 0.004 0.004 0.040 0.040
#> ERR184093     1  0.6126     0.4795 0.492 0.056 0.000 0.000 0.360 0.092
#> ERR184051     3  0.3299     0.7076 0.028 0.000 0.820 0.140 0.012 0.000
#> ERR184076     1  0.2613     0.6039 0.888 0.008 0.012 0.004 0.076 0.012
#> ERR184043     3  0.1938     0.7798 0.020 0.000 0.920 0.052 0.008 0.000
#> ERR184037     6  0.1881     0.7270 0.052 0.016 0.000 0.004 0.004 0.924
#> ERR184059     3  0.4124     0.5932 0.036 0.000 0.728 0.224 0.012 0.000
#> ERR184055     6  0.2872     0.6666 0.140 0.000 0.000 0.000 0.024 0.836
#> ERR184065     3  0.4400     0.6471 0.000 0.184 0.740 0.004 0.052 0.020
#> ERR184069     2  0.5106     0.3102 0.000 0.568 0.016 0.004 0.044 0.368
#> ERR184040     1  0.3823     0.6513 0.764 0.004 0.000 0.000 0.048 0.184
#> ERR184057     2  0.5738     0.0362 0.000 0.432 0.000 0.004 0.144 0.420
#> ERR184082     2  0.1956     0.3392 0.016 0.928 0.016 0.008 0.032 0.000
#> ERR184083     2  0.2268     0.3449 0.000 0.912 0.028 0.004 0.028 0.028
#> ERR184039     3  0.6088     0.2184 0.000 0.360 0.496 0.000 0.088 0.056
#> ERR184064     3  0.1434     0.7900 0.020 0.000 0.948 0.024 0.008 0.000
#> ERR184081     2  0.5759     0.2009 0.000 0.564 0.020 0.000 0.140 0.276
#> ERR184095     2  0.4721    -0.6206 0.004 0.584 0.000 0.004 0.372 0.036
#> ERR184079     2  0.7817    -0.0576 0.208 0.276 0.000 0.004 0.240 0.272
#> ERR184084     2  0.5098     0.0746 0.040 0.740 0.040 0.084 0.096 0.000
#> ERR184068     2  0.6144    -0.1837 0.296 0.472 0.000 0.000 0.220 0.012
#> ERR184067     6  0.4424     0.4924 0.000 0.208 0.004 0.008 0.060 0.720
#> ERR184071     2  0.4785     0.3516 0.000 0.720 0.180 0.004 0.056 0.040
#> ERR184042     4  0.0363     0.4830 0.000 0.000 0.012 0.988 0.000 0.000
#> ERR184063     3  0.2556     0.7627 0.028 0.000 0.884 0.076 0.012 0.000
#> ERR184091     3  0.4499     0.5709 0.000 0.252 0.692 0.004 0.040 0.012
#> ERR184061     6  0.3265     0.6863 0.056 0.000 0.000 0.004 0.112 0.828
#> ERR184077     5  0.5400     0.8679 0.064 0.460 0.000 0.008 0.460 0.008
#> ERR184062     1  0.2573     0.6271 0.856 0.000 0.008 0.000 0.132 0.004
#> ERR184053     5  0.5318     0.8675 0.024 0.452 0.000 0.012 0.484 0.028
#> ERR184088     6  0.4924     0.6334 0.112 0.156 0.000 0.000 0.028 0.704
#> ERR184075     3  0.1826     0.7811 0.000 0.052 0.924 0.004 0.020 0.000
#> ERR184041     3  0.1223     0.7949 0.016 0.004 0.960 0.008 0.012 0.000
#> ERR184060     6  0.7213     0.3375 0.172 0.228 0.040 0.000 0.064 0.496
#> ERR184035     2  0.4637     0.3557 0.112 0.748 0.000 0.008 0.024 0.108
#> ERR184086     3  0.3017     0.7571 0.000 0.084 0.844 0.000 0.072 0.000
#> ERR184080     1  0.4653     0.1641 0.488 0.012 0.000 0.000 0.020 0.480
#> ERR184050     3  0.4063     0.7107 0.000 0.072 0.768 0.000 0.148 0.012
#> ERR184047     1  0.6861     0.3176 0.476 0.000 0.048 0.080 0.056 0.340
#> ERR184092     1  0.6472     0.2007 0.392 0.024 0.000 0.000 0.224 0.360
#> ERR184072     1  0.4929     0.5980 0.644 0.004 0.000 0.000 0.252 0.100
#> ERR184073     1  0.5970     0.5607 0.572 0.000 0.036 0.008 0.280 0.104
#> ERR184066     1  0.2781     0.6517 0.876 0.000 0.008 0.004 0.048 0.064
#> ERR184098     3  0.1453     0.7928 0.000 0.008 0.944 0.000 0.040 0.008
#> ERR184044     6  0.7070     0.2772 0.280 0.004 0.068 0.108 0.036 0.504
#> ERR184054     1  0.4886     0.6550 0.680 0.000 0.000 0.008 0.128 0.184
#> ERR184085     2  0.4761     0.4141 0.000 0.752 0.024 0.032 0.064 0.128
#> ERR184056     1  0.3720     0.6204 0.816 0.036 0.000 0.000 0.056 0.092
#> ERR184052     2  0.6759     0.2858 0.000 0.484 0.276 0.004 0.068 0.168
#> ERR184070     6  0.1832     0.7319 0.032 0.032 0.000 0.000 0.008 0.928
#> ERR184096     1  0.5231     0.6522 0.688 0.000 0.012 0.020 0.156 0.124
#> ERR184089     3  0.0291     0.7955 0.000 0.004 0.992 0.000 0.004 0.000
#> ERR184049     6  0.2776     0.6778 0.000 0.112 0.004 0.004 0.020 0.860
#> ERR184038     4  0.7624     0.4502 0.260 0.032 0.116 0.432 0.160 0.000
#> ERR184087     3  0.1841     0.7843 0.008 0.000 0.920 0.064 0.008 0.000
#> ERR184097     1  0.1888     0.6257 0.916 0.012 0.000 0.000 0.068 0.004
#> ERR184094     6  0.6235     0.5343 0.084 0.000 0.120 0.124 0.032 0.640
#> ERR184058     2  0.4752     0.4178 0.000 0.740 0.136 0.004 0.048 0.072
#> ERR184036     6  0.3315     0.7050 0.004 0.056 0.000 0.004 0.104 0.832
#> ERR184046     2  0.3767     0.3883 0.000 0.808 0.092 0.004 0.084 0.012
#> ERR184074     6  0.3444     0.6572 0.124 0.000 0.008 0.000 0.052 0.816
#> ERR184048     2  0.3121     0.1606 0.032 0.844 0.000 0.004 0.112 0.008

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

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.


ATC:hclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "hclust"]
# you can also extract it by
# res = res_list["ATC:hclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-hclust-select-partition-number

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.610           0.934       0.904         0.3234 0.568   0.568
#> 3 3 0.753           0.946       0.971         0.4596 0.975   0.955
#> 4 4 0.754           0.793       0.903         0.0691 0.971   0.946
#> 5 5 0.757           0.831       0.876         0.0563 0.979   0.959
#> 6 6 0.754           0.781       0.864         0.0486 1.000   1.000

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.9286      0.896 0.656 0.344
#> ERR184093     2  0.0000      0.981 0.000 1.000
#> ERR184051     1  0.9323      0.892 0.652 0.348
#> ERR184076     1  0.9286      0.896 0.656 0.344
#> ERR184043     1  0.9248      0.896 0.660 0.340
#> ERR184037     2  0.2778      0.943 0.048 0.952
#> ERR184059     1  0.7815      0.811 0.768 0.232
#> ERR184055     2  0.2778      0.943 0.048 0.952
#> ERR184065     2  0.0000      0.981 0.000 1.000
#> ERR184069     2  0.0000      0.981 0.000 1.000
#> ERR184040     1  0.9286      0.896 0.656 0.344
#> ERR184057     2  0.0000      0.981 0.000 1.000
#> ERR184082     2  0.2778      0.943 0.048 0.952
#> ERR184083     2  0.0000      0.981 0.000 1.000
#> ERR184039     2  0.0000      0.981 0.000 1.000
#> ERR184064     1  0.9248      0.896 0.660 0.340
#> ERR184081     2  0.0000      0.981 0.000 1.000
#> ERR184095     2  0.0000      0.981 0.000 1.000
#> ERR184079     2  0.0000      0.981 0.000 1.000
#> ERR184084     1  0.9248      0.895 0.660 0.340
#> ERR184068     2  0.0000      0.981 0.000 1.000
#> ERR184067     2  0.0000      0.981 0.000 1.000
#> ERR184071     2  0.0000      0.981 0.000 1.000
#> ERR184042     1  0.0000      0.652 1.000 0.000
#> ERR184063     1  0.9323      0.892 0.652 0.348
#> ERR184091     2  0.0000      0.981 0.000 1.000
#> ERR184061     2  0.3114      0.933 0.056 0.944
#> ERR184077     2  0.0000      0.981 0.000 1.000
#> ERR184062     2  0.2778      0.943 0.048 0.952
#> ERR184053     2  0.0000      0.981 0.000 1.000
#> ERR184088     2  0.0000      0.981 0.000 1.000
#> ERR184075     2  0.0000      0.981 0.000 1.000
#> ERR184041     1  0.9427      0.874 0.640 0.360
#> ERR184060     2  0.0000      0.981 0.000 1.000
#> ERR184035     2  0.2778      0.943 0.048 0.952
#> ERR184086     2  0.0000      0.981 0.000 1.000
#> ERR184080     2  0.2778      0.943 0.048 0.952
#> ERR184050     2  0.0000      0.981 0.000 1.000
#> ERR184047     1  0.0000      0.652 1.000 0.000
#> ERR184092     2  0.0000      0.981 0.000 1.000
#> ERR184072     1  0.9323      0.892 0.652 0.348
#> ERR184073     1  0.9248      0.896 0.660 0.340
#> ERR184066     2  0.2778      0.943 0.048 0.952
#> ERR184098     2  0.0000      0.981 0.000 1.000
#> ERR184044     2  0.2778      0.943 0.048 0.952
#> ERR184054     1  0.9286      0.896 0.656 0.344
#> ERR184085     2  0.2778      0.943 0.048 0.952
#> ERR184056     2  0.0000      0.981 0.000 1.000
#> ERR184052     2  0.0000      0.981 0.000 1.000
#> ERR184070     2  0.0000      0.981 0.000 1.000
#> ERR184096     1  0.0000      0.652 1.000 0.000
#> ERR184089     2  0.0376      0.978 0.004 0.996
#> ERR184049     2  0.0000      0.981 0.000 1.000
#> ERR184038     2  0.2778      0.943 0.048 0.952
#> ERR184087     1  0.9248      0.896 0.660 0.340
#> ERR184097     2  0.0000      0.981 0.000 1.000
#> ERR184094     1  0.9248      0.896 0.660 0.340
#> ERR184058     2  0.0000      0.981 0.000 1.000
#> ERR184036     2  0.0000      0.981 0.000 1.000
#> ERR184046     2  0.0000      0.981 0.000 1.000
#> ERR184074     1  0.9286      0.896 0.656 0.344
#> ERR184048     2  0.0000      0.981 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000      0.978 1.000 0.000 0.000
#> ERR184093     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184051     1  0.0237      0.976 0.996 0.004 0.000
#> ERR184076     1  0.0000      0.978 1.000 0.000 0.000
#> ERR184043     1  0.0424      0.977 0.992 0.000 0.008
#> ERR184037     2  0.3619      0.872 0.136 0.864 0.000
#> ERR184059     1  0.4974      0.695 0.764 0.000 0.236
#> ERR184055     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184065     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184069     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184040     1  0.0000      0.978 1.000 0.000 0.000
#> ERR184057     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184082     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184083     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184039     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184064     1  0.0424      0.977 0.992 0.000 0.008
#> ERR184081     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184079     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184084     1  0.0237      0.977 0.996 0.000 0.004
#> ERR184068     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184067     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184071     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184042     3  0.0000      1.000 0.000 0.000 1.000
#> ERR184063     1  0.0237      0.976 0.996 0.004 0.000
#> ERR184091     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184061     2  0.3879      0.855 0.152 0.848 0.000
#> ERR184077     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184062     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184053     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184088     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184075     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184041     1  0.0747      0.959 0.984 0.016 0.000
#> ERR184060     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184035     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184086     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184080     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184050     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184047     3  0.0000      1.000 0.000 0.000 1.000
#> ERR184092     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184072     1  0.0237      0.976 0.996 0.004 0.000
#> ERR184073     1  0.0237      0.978 0.996 0.000 0.004
#> ERR184066     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184098     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184044     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184054     1  0.0000      0.978 1.000 0.000 0.000
#> ERR184085     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184056     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184052     2  0.0237      0.957 0.004 0.996 0.000
#> ERR184070     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184096     3  0.0000      1.000 0.000 0.000 1.000
#> ERR184089     2  0.0424      0.955 0.008 0.992 0.000
#> ERR184049     2  0.0237      0.957 0.004 0.996 0.000
#> ERR184038     2  0.3551      0.876 0.132 0.868 0.000
#> ERR184087     1  0.0424      0.977 0.992 0.000 0.008
#> ERR184097     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184094     1  0.0237      0.978 0.996 0.000 0.004
#> ERR184058     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184036     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184046     2  0.0000      0.959 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.978 1.000 0.000 0.000
#> ERR184048     2  0.0000      0.959 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     1  0.4999      0.703 0.508 0.000 0.492 0.000
#> ERR184093     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184051     3  0.1389      0.646 0.048 0.000 0.952 0.000
#> ERR184076     1  0.4888      0.673 0.588 0.000 0.412 0.000
#> ERR184043     3  0.0000      0.650 0.000 0.000 1.000 0.000
#> ERR184037     2  0.3351      0.870 0.148 0.844 0.008 0.000
#> ERR184059     3  0.4158      0.408 0.008 0.000 0.768 0.224
#> ERR184055     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184065     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184069     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184040     3  0.4999     -0.748 0.492 0.000 0.508 0.000
#> ERR184057     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184082     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184083     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184039     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184064     3  0.0000      0.650 0.000 0.000 1.000 0.000
#> ERR184081     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184095     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184079     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184084     3  0.2011      0.618 0.080 0.000 0.920 0.000
#> ERR184068     2  0.0188      0.957 0.004 0.996 0.000 0.000
#> ERR184067     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184071     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184042     4  0.3907      0.873 0.232 0.000 0.000 0.768
#> ERR184063     3  0.1389      0.646 0.048 0.000 0.952 0.000
#> ERR184091     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184061     2  0.3545      0.855 0.164 0.828 0.008 0.000
#> ERR184077     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184062     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184053     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184088     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184075     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184041     3  0.1716      0.638 0.064 0.000 0.936 0.000
#> ERR184060     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184035     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184086     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184080     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184050     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184047     4  0.0000      0.938 0.000 0.000 0.000 1.000
#> ERR184092     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184072     1  0.4164      0.564 0.736 0.000 0.264 0.000
#> ERR184073     3  0.4998     -0.746 0.488 0.000 0.512 0.000
#> ERR184066     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184098     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184044     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184054     1  0.4998      0.714 0.512 0.000 0.488 0.000
#> ERR184085     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184056     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184052     2  0.0188      0.957 0.004 0.996 0.000 0.000
#> ERR184070     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184096     4  0.0000      0.938 0.000 0.000 0.000 1.000
#> ERR184089     2  0.0817      0.947 0.024 0.976 0.000 0.000
#> ERR184049     2  0.0188      0.957 0.004 0.996 0.000 0.000
#> ERR184038     2  0.3300      0.873 0.144 0.848 0.008 0.000
#> ERR184087     3  0.0000      0.650 0.000 0.000 1.000 0.000
#> ERR184097     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184094     3  0.4907     -0.592 0.420 0.000 0.580 0.000
#> ERR184058     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184036     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184046     2  0.0000      0.958 0.000 1.000 0.000 0.000
#> ERR184074     1  0.4981      0.727 0.536 0.000 0.464 0.000
#> ERR184048     2  0.0000      0.958 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.1357      0.776 0.948 0.000 0.004 0.000 0.048
#> ERR184093     2  0.0404      0.925 0.000 0.988 0.000 0.000 0.012
#> ERR184051     3  0.4604      0.888 0.428 0.000 0.560 0.000 0.012
#> ERR184076     1  0.4807     -0.358 0.532 0.000 0.020 0.000 0.448
#> ERR184043     3  0.4150      0.893 0.388 0.000 0.612 0.000 0.000
#> ERR184037     2  0.3912      0.780 0.020 0.752 0.000 0.000 0.228
#> ERR184059     3  0.6736      0.594 0.324 0.000 0.488 0.172 0.016
#> ERR184055     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184065     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184069     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184040     1  0.0404      0.805 0.988 0.000 0.012 0.000 0.000
#> ERR184057     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184082     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184083     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184039     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184064     3  0.4150      0.893 0.388 0.000 0.612 0.000 0.000
#> ERR184081     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184095     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184079     2  0.0880      0.919 0.000 0.968 0.000 0.000 0.032
#> ERR184084     3  0.4297      0.829 0.472 0.000 0.528 0.000 0.000
#> ERR184068     2  0.0880      0.919 0.000 0.968 0.000 0.000 0.032
#> ERR184067     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184071     2  0.0290      0.926 0.000 0.992 0.000 0.000 0.008
#> ERR184042     4  0.1608      0.606 0.000 0.000 0.000 0.928 0.072
#> ERR184063     3  0.4604      0.888 0.428 0.000 0.560 0.000 0.012
#> ERR184091     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184061     2  0.4026      0.763 0.020 0.736 0.000 0.000 0.244
#> ERR184077     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184062     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184053     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184088     2  0.0404      0.925 0.000 0.988 0.000 0.000 0.012
#> ERR184075     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184041     3  0.4937      0.877 0.428 0.000 0.544 0.000 0.028
#> ERR184060     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184035     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184086     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184080     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184050     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184047     4  0.4088      0.819 0.000 0.000 0.368 0.632 0.000
#> ERR184092     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184072     5  0.4084      0.000 0.328 0.000 0.004 0.000 0.668
#> ERR184073     1  0.0609      0.804 0.980 0.000 0.020 0.000 0.000
#> ERR184066     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184098     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184044     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184054     1  0.0703      0.806 0.976 0.000 0.000 0.000 0.024
#> ERR184085     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184056     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184052     2  0.0880      0.919 0.000 0.968 0.000 0.000 0.032
#> ERR184070     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184096     4  0.4088      0.819 0.000 0.000 0.368 0.632 0.000
#> ERR184089     2  0.1478      0.903 0.000 0.936 0.000 0.000 0.064
#> ERR184049     2  0.0963      0.917 0.000 0.964 0.000 0.000 0.036
#> ERR184038     2  0.3819      0.784 0.016 0.756 0.000 0.000 0.228
#> ERR184087     3  0.4150      0.893 0.388 0.000 0.612 0.000 0.000
#> ERR184097     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184094     1  0.2408      0.690 0.892 0.000 0.092 0.000 0.016
#> ERR184058     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184036     2  0.0404      0.925 0.000 0.988 0.000 0.000 0.012
#> ERR184046     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000
#> ERR184074     1  0.1121      0.784 0.956 0.000 0.000 0.000 0.044
#> ERR184048     2  0.0000      0.928 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3 p4    p5    p6
#> ERR184078     1  0.3969      0.763 0.668 0.000 0.312 NA 0.000 0.020
#> ERR184093     2  0.0547      0.889 0.000 0.980 0.000 NA 0.000 0.020
#> ERR184051     3  0.1390      0.854 0.032 0.000 0.948 NA 0.000 0.004
#> ERR184076     1  0.3679     -0.144 0.772 0.000 0.000 NA 0.000 0.052
#> ERR184043     3  0.0000      0.861 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184037     2  0.3769      0.652 0.000 0.640 0.000 NA 0.000 0.356
#> ERR184059     3  0.5250      0.427 0.000 0.000 0.608 NA 0.208 0.000
#> ERR184055     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184065     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184069     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184040     1  0.4022      0.776 0.628 0.000 0.360 NA 0.000 0.008
#> ERR184057     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184082     2  0.3756      0.657 0.000 0.644 0.000 NA 0.000 0.352
#> ERR184083     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184039     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184064     3  0.0000      0.861 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184081     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184095     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184079     2  0.0937      0.883 0.000 0.960 0.000 NA 0.000 0.040
#> ERR184084     3  0.3796      0.691 0.084 0.000 0.776 NA 0.000 0.000
#> ERR184068     2  0.0935      0.885 0.000 0.964 0.000 NA 0.000 0.032
#> ERR184067     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184071     2  0.0260      0.892 0.000 0.992 0.000 NA 0.000 0.008
#> ERR184042     5  0.3851      0.529 0.000 0.000 0.000 NA 0.540 0.000
#> ERR184063     3  0.1390      0.854 0.032 0.000 0.948 NA 0.000 0.004
#> ERR184091     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184061     2  0.3819      0.631 0.000 0.624 0.000 NA 0.000 0.372
#> ERR184077     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184062     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184053     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184088     2  0.0547      0.889 0.000 0.980 0.000 NA 0.000 0.020
#> ERR184075     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184041     3  0.1787      0.844 0.032 0.000 0.932 NA 0.000 0.020
#> ERR184060     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184035     2  0.3756      0.657 0.000 0.644 0.000 NA 0.000 0.352
#> ERR184086     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184080     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184050     2  0.0146      0.893 0.000 0.996 0.000 NA 0.000 0.004
#> ERR184047     5  0.0000      0.790 0.000 0.000 0.000 NA 1.000 0.000
#> ERR184092     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184072     6  0.4828      0.000 0.156 0.000 0.000 NA 0.000 0.668
#> ERR184073     1  0.4326      0.776 0.608 0.000 0.368 NA 0.000 0.008
#> ERR184066     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184098     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184044     2  0.3756      0.657 0.000 0.644 0.000 NA 0.000 0.352
#> ERR184054     1  0.4306      0.775 0.624 0.000 0.344 NA 0.000 0.032
#> ERR184085     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184056     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184052     2  0.1007      0.881 0.000 0.956 0.000 NA 0.000 0.044
#> ERR184070     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184096     5  0.0000      0.790 0.000 0.000 0.000 NA 1.000 0.000
#> ERR184089     2  0.1501      0.864 0.000 0.924 0.000 NA 0.000 0.076
#> ERR184049     2  0.1075      0.879 0.000 0.952 0.000 NA 0.000 0.048
#> ERR184038     2  0.3634      0.657 0.000 0.644 0.000 NA 0.000 0.356
#> ERR184087     3  0.0000      0.861 0.000 0.000 1.000 NA 0.000 0.000
#> ERR184097     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184094     1  0.4903      0.692 0.524 0.000 0.424 NA 0.000 0.008
#> ERR184058     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184036     2  0.0547      0.889 0.000 0.980 0.000 NA 0.000 0.020
#> ERR184046     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000
#> ERR184074     1  0.5668      0.739 0.540 0.000 0.348 NA 0.000 0.036
#> ERR184048     2  0.0000      0.894 0.000 1.000 0.000 NA 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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.


ATC:kmeans*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "kmeans"]
# you can also extract it by
# res = res_list["ATC:kmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-kmeans-select-partition-number

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.978       0.989         0.4394 0.568   0.568
#> 3 3 0.935           0.953       0.971         0.3683 0.714   0.539
#> 4 4 0.739           0.777       0.881         0.1106 0.906   0.773
#> 5 5 0.738           0.606       0.752         0.1003 0.867   0.649
#> 6 6 0.786           0.847       0.845         0.0571 0.832   0.474

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 shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1   0.000      1.000 1.000 0.000
#> ERR184093     2   0.000      0.984 0.000 1.000
#> ERR184051     1   0.000      1.000 1.000 0.000
#> ERR184076     1   0.000      1.000 1.000 0.000
#> ERR184043     1   0.000      1.000 1.000 0.000
#> ERR184037     2   0.327      0.939 0.060 0.940
#> ERR184059     1   0.000      1.000 1.000 0.000
#> ERR184055     2   0.163      0.969 0.024 0.976
#> ERR184065     2   0.000      0.984 0.000 1.000
#> ERR184069     2   0.000      0.984 0.000 1.000
#> ERR184040     1   0.000      1.000 1.000 0.000
#> ERR184057     2   0.000      0.984 0.000 1.000
#> ERR184082     2   0.163      0.969 0.024 0.976
#> ERR184083     2   0.000      0.984 0.000 1.000
#> ERR184039     2   0.000      0.984 0.000 1.000
#> ERR184064     1   0.000      1.000 1.000 0.000
#> ERR184081     2   0.000      0.984 0.000 1.000
#> ERR184095     2   0.000      0.984 0.000 1.000
#> ERR184079     2   0.000      0.984 0.000 1.000
#> ERR184084     1   0.000      1.000 1.000 0.000
#> ERR184068     2   0.000      0.984 0.000 1.000
#> ERR184067     2   0.000      0.984 0.000 1.000
#> ERR184071     2   0.000      0.984 0.000 1.000
#> ERR184042     1   0.000      1.000 1.000 0.000
#> ERR184063     1   0.000      1.000 1.000 0.000
#> ERR184091     2   0.000      0.984 0.000 1.000
#> ERR184061     2   0.163      0.969 0.024 0.976
#> ERR184077     2   0.000      0.984 0.000 1.000
#> ERR184062     2   0.000      0.984 0.000 1.000
#> ERR184053     2   0.000      0.984 0.000 1.000
#> ERR184088     2   0.000      0.984 0.000 1.000
#> ERR184075     2   0.000      0.984 0.000 1.000
#> ERR184041     1   0.000      1.000 1.000 0.000
#> ERR184060     2   0.000      0.984 0.000 1.000
#> ERR184035     2   0.327      0.939 0.060 0.940
#> ERR184086     2   0.000      0.984 0.000 1.000
#> ERR184080     2   0.833      0.666 0.264 0.736
#> ERR184050     2   0.000      0.984 0.000 1.000
#> ERR184047     1   0.000      1.000 1.000 0.000
#> ERR184092     2   0.000      0.984 0.000 1.000
#> ERR184072     1   0.000      1.000 1.000 0.000
#> ERR184073     1   0.000      1.000 1.000 0.000
#> ERR184066     2   0.163      0.969 0.024 0.976
#> ERR184098     2   0.000      0.984 0.000 1.000
#> ERR184044     2   0.000      0.984 0.000 1.000
#> ERR184054     1   0.000      1.000 1.000 0.000
#> ERR184085     2   0.327      0.939 0.060 0.940
#> ERR184056     2   0.000      0.984 0.000 1.000
#> ERR184052     2   0.000      0.984 0.000 1.000
#> ERR184070     2   0.000      0.984 0.000 1.000
#> ERR184096     1   0.000      1.000 1.000 0.000
#> ERR184089     2   0.000      0.984 0.000 1.000
#> ERR184049     2   0.000      0.984 0.000 1.000
#> ERR184038     2   0.584      0.851 0.140 0.860
#> ERR184087     1   0.000      1.000 1.000 0.000
#> ERR184097     2   0.000      0.984 0.000 1.000
#> ERR184094     1   0.000      1.000 1.000 0.000
#> ERR184058     2   0.000      0.984 0.000 1.000
#> ERR184036     2   0.000      0.984 0.000 1.000
#> ERR184046     2   0.000      0.984 0.000 1.000
#> ERR184074     1   0.000      1.000 1.000 0.000
#> ERR184048     2   0.000      0.984 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.1163      0.941 0.972 0.000 0.028
#> ERR184093     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184051     1  0.0000      0.961 1.000 0.000 0.000
#> ERR184076     1  0.0237      0.961 0.996 0.000 0.004
#> ERR184043     3  0.4399      0.875 0.188 0.000 0.812
#> ERR184037     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184059     3  0.0000      0.851 0.000 0.000 1.000
#> ERR184055     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184065     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184069     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184040     1  0.1163      0.941 0.972 0.000 0.028
#> ERR184057     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184082     1  0.0892      0.946 0.980 0.020 0.000
#> ERR184083     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184039     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184064     3  0.4504      0.871 0.196 0.000 0.804
#> ERR184081     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184095     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184079     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184084     3  0.5810      0.677 0.336 0.000 0.664
#> ERR184068     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184067     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184071     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184042     3  0.0000      0.851 0.000 0.000 1.000
#> ERR184063     1  0.0000      0.961 1.000 0.000 0.000
#> ERR184091     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184061     1  0.0592      0.955 0.988 0.012 0.000
#> ERR184077     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184062     1  0.5835      0.421 0.660 0.340 0.000
#> ERR184053     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184088     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184075     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184041     1  0.0000      0.961 1.000 0.000 0.000
#> ERR184060     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184035     1  0.0747      0.951 0.984 0.016 0.000
#> ERR184086     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184080     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184050     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184047     3  0.0000      0.851 0.000 0.000 1.000
#> ERR184092     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184072     1  0.0237      0.961 0.996 0.000 0.004
#> ERR184073     3  0.4452      0.872 0.192 0.000 0.808
#> ERR184066     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184098     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184044     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184054     1  0.0237      0.961 0.996 0.000 0.004
#> ERR184085     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184056     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184052     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184070     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184096     3  0.0000      0.851 0.000 0.000 1.000
#> ERR184089     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184049     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184038     1  0.0237      0.963 0.996 0.004 0.000
#> ERR184087     3  0.4399      0.875 0.188 0.000 0.812
#> ERR184097     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184094     3  0.4452      0.872 0.192 0.000 0.808
#> ERR184058     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184036     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184046     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184074     1  0.0237      0.961 0.996 0.000 0.004
#> ERR184048     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     3  0.4304     0.5350 0.284 0.000 0.716 0.000
#> ERR184093     2  0.2530     0.9172 0.000 0.888 0.000 0.112
#> ERR184051     3  0.3942     0.7156 0.236 0.000 0.764 0.000
#> ERR184076     1  0.4998     0.0707 0.512 0.000 0.488 0.000
#> ERR184043     3  0.2589     0.7559 0.000 0.000 0.884 0.116
#> ERR184037     1  0.0188     0.7681 0.996 0.000 0.000 0.004
#> ERR184059     3  0.3172     0.7066 0.000 0.000 0.840 0.160
#> ERR184055     1  0.0000     0.7684 1.000 0.000 0.000 0.000
#> ERR184065     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184069     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184040     3  0.4304     0.5350 0.284 0.000 0.716 0.000
#> ERR184057     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184082     1  0.0469     0.7666 0.988 0.000 0.000 0.012
#> ERR184083     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184039     2  0.0000     0.9228 0.000 1.000 0.000 0.000
#> ERR184064     3  0.2589     0.7559 0.000 0.000 0.884 0.116
#> ERR184081     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184095     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184079     2  0.3219     0.9057 0.020 0.868 0.000 0.112
#> ERR184084     3  0.3166     0.7606 0.016 0.000 0.868 0.116
#> ERR184068     2  0.6607     0.5269 0.296 0.592 0.000 0.112
#> ERR184067     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184071     2  0.2530     0.9172 0.000 0.888 0.000 0.112
#> ERR184042     4  0.2647     1.0000 0.000 0.000 0.120 0.880
#> ERR184063     3  0.4193     0.6864 0.268 0.000 0.732 0.000
#> ERR184091     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184061     1  0.0921     0.7605 0.972 0.000 0.000 0.028
#> ERR184077     2  0.2469     0.9185 0.000 0.892 0.000 0.108
#> ERR184062     1  0.5119     0.5177 0.764 0.124 0.000 0.112
#> ERR184053     2  0.2469     0.9185 0.000 0.892 0.000 0.108
#> ERR184088     2  0.2530     0.9172 0.000 0.888 0.000 0.112
#> ERR184075     2  0.1211     0.9242 0.000 0.960 0.000 0.040
#> ERR184041     3  0.4304     0.6664 0.284 0.000 0.716 0.000
#> ERR184060     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184035     1  0.0336     0.7681 0.992 0.000 0.000 0.008
#> ERR184086     2  0.2011     0.9230 0.000 0.920 0.000 0.080
#> ERR184080     1  0.1389     0.7473 0.952 0.000 0.048 0.000
#> ERR184050     2  0.2530     0.9172 0.000 0.888 0.000 0.112
#> ERR184047     4  0.2647     1.0000 0.000 0.000 0.120 0.880
#> ERR184092     2  0.2345     0.9204 0.000 0.900 0.000 0.100
#> ERR184072     1  0.5016     0.3257 0.600 0.000 0.396 0.004
#> ERR184073     3  0.0000     0.7374 0.000 0.000 1.000 0.000
#> ERR184066     1  0.0000     0.7684 1.000 0.000 0.000 0.000
#> ERR184098     2  0.2011     0.9230 0.000 0.920 0.000 0.080
#> ERR184044     1  0.1118     0.7528 0.964 0.000 0.000 0.036
#> ERR184054     1  0.4855     0.3179 0.600 0.000 0.400 0.000
#> ERR184085     1  0.0000     0.7684 1.000 0.000 0.000 0.000
#> ERR184056     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184052     2  0.3108     0.9088 0.016 0.872 0.000 0.112
#> ERR184070     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184096     4  0.2647     1.0000 0.000 0.000 0.120 0.880
#> ERR184089     2  0.6476     0.5761 0.272 0.616 0.000 0.112
#> ERR184049     1  0.6885     0.0546 0.516 0.372 0.000 0.112
#> ERR184038     1  0.0000     0.7684 1.000 0.000 0.000 0.000
#> ERR184087     3  0.2589     0.7559 0.000 0.000 0.884 0.116
#> ERR184097     2  0.2345     0.9204 0.000 0.900 0.000 0.100
#> ERR184094     3  0.2589     0.7559 0.000 0.000 0.884 0.116
#> ERR184058     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184036     2  0.2530     0.9172 0.000 0.888 0.000 0.112
#> ERR184046     2  0.0188     0.9225 0.000 0.996 0.000 0.004
#> ERR184074     1  0.5163     0.1003 0.516 0.000 0.480 0.004
#> ERR184048     2  0.2408     0.9195 0.000 0.896 0.000 0.104

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.2763      0.655 0.848 0.000 0.148 0.004 0.000
#> ERR184093     2  0.4291      0.631 0.000 0.536 0.000 0.464 0.000
#> ERR184051     3  0.4597      0.891 0.424 0.000 0.564 0.012 0.000
#> ERR184076     1  0.4025      0.714 0.700 0.000 0.292 0.008 0.000
#> ERR184043     3  0.5668      0.924 0.416 0.000 0.504 0.000 0.080
#> ERR184037     4  0.4304      0.528 0.000 0.000 0.484 0.516 0.000
#> ERR184059     3  0.5989      0.889 0.412 0.000 0.476 0.000 0.112
#> ERR184055     4  0.4300      0.531 0.000 0.000 0.476 0.524 0.000
#> ERR184065     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184069     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184040     1  0.2605      0.652 0.852 0.000 0.148 0.000 0.000
#> ERR184057     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184082     4  0.4283      0.535 0.000 0.000 0.456 0.544 0.000
#> ERR184083     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184039     2  0.0404      0.747 0.000 0.988 0.000 0.012 0.000
#> ERR184064     3  0.5668      0.924 0.416 0.000 0.504 0.000 0.080
#> ERR184081     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184095     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184079     2  0.4305      0.599 0.000 0.512 0.000 0.488 0.000
#> ERR184084     3  0.5649      0.907 0.452 0.000 0.472 0.000 0.076
#> ERR184068     4  0.2773      0.146 0.000 0.164 0.000 0.836 0.000
#> ERR184067     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184071     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000
#> ERR184042     5  0.0566      0.988 0.000 0.000 0.004 0.012 0.984
#> ERR184063     3  0.4597      0.891 0.424 0.000 0.564 0.012 0.000
#> ERR184091     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184061     4  0.4297      0.532 0.000 0.000 0.472 0.528 0.000
#> ERR184077     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000
#> ERR184062     4  0.2777      0.404 0.000 0.016 0.120 0.864 0.000
#> ERR184053     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000
#> ERR184088     4  0.4305     -0.601 0.000 0.488 0.000 0.512 0.000
#> ERR184075     2  0.3534      0.704 0.000 0.744 0.000 0.256 0.000
#> ERR184041     3  0.4582      0.881 0.416 0.000 0.572 0.012 0.000
#> ERR184060     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184035     4  0.4304      0.528 0.000 0.000 0.484 0.516 0.000
#> ERR184086     2  0.4030      0.680 0.000 0.648 0.000 0.352 0.000
#> ERR184080     4  0.4971      0.503 0.028 0.000 0.460 0.512 0.000
#> ERR184050     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000
#> ERR184047     5  0.0162      0.994 0.004 0.000 0.000 0.000 0.996
#> ERR184092     2  0.4256      0.648 0.000 0.564 0.000 0.436 0.000
#> ERR184072     1  0.4836      0.684 0.628 0.000 0.336 0.036 0.000
#> ERR184073     1  0.0404      0.367 0.988 0.000 0.000 0.000 0.012
#> ERR184066     4  0.4302      0.530 0.000 0.000 0.480 0.520 0.000
#> ERR184098     2  0.4045      0.679 0.000 0.644 0.000 0.356 0.000
#> ERR184044     4  0.4126      0.513 0.000 0.000 0.380 0.620 0.000
#> ERR184054     1  0.4763      0.685 0.632 0.000 0.336 0.032 0.000
#> ERR184085     4  0.4294      0.534 0.000 0.000 0.468 0.532 0.000
#> ERR184056     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184052     4  0.4300     -0.583 0.000 0.476 0.000 0.524 0.000
#> ERR184070     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184096     5  0.0162      0.994 0.004 0.000 0.000 0.000 0.996
#> ERR184089     4  0.4166     -0.346 0.000 0.348 0.004 0.648 0.000
#> ERR184049     4  0.0703      0.339 0.000 0.024 0.000 0.976 0.000
#> ERR184038     4  0.4302      0.530 0.000 0.000 0.480 0.520 0.000
#> ERR184087     3  0.5668      0.924 0.416 0.000 0.504 0.000 0.080
#> ERR184097     2  0.4278      0.640 0.000 0.548 0.000 0.452 0.000
#> ERR184094     1  0.5124     -0.617 0.644 0.000 0.288 0.000 0.068
#> ERR184058     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184036     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000
#> ERR184046     2  0.0000      0.748 0.000 1.000 0.000 0.000 0.000
#> ERR184074     1  0.4165      0.710 0.672 0.000 0.320 0.008 0.000
#> ERR184048     2  0.4287      0.636 0.000 0.540 0.000 0.460 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.1657      0.925 0.936 0.000 0.040 0.012 0.000 0.012
#> ERR184093     2  0.0508      0.825 0.012 0.984 0.000 0.000 0.004 0.000
#> ERR184051     3  0.2477      0.871 0.024 0.000 0.896 0.048 0.000 0.032
#> ERR184076     1  0.2819      0.911 0.880 0.000 0.024 0.056 0.004 0.036
#> ERR184043     3  0.0000      0.890 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184037     6  0.1785      0.893 0.016 0.000 0.000 0.048 0.008 0.928
#> ERR184059     3  0.1321      0.875 0.024 0.000 0.952 0.020 0.004 0.000
#> ERR184055     6  0.0508      0.907 0.012 0.000 0.000 0.004 0.000 0.984
#> ERR184065     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184069     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184040     1  0.1555      0.925 0.940 0.000 0.040 0.008 0.000 0.012
#> ERR184057     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184082     6  0.1588      0.890 0.000 0.004 0.000 0.072 0.000 0.924
#> ERR184083     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184039     4  0.4249      0.857 0.012 0.416 0.000 0.568 0.004 0.000
#> ERR184064     3  0.0000      0.890 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184081     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184095     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184079     2  0.1490      0.814 0.008 0.948 0.000 0.024 0.004 0.016
#> ERR184084     3  0.1564      0.883 0.040 0.000 0.936 0.024 0.000 0.000
#> ERR184068     2  0.4467      0.547 0.016 0.708 0.000 0.040 0.004 0.232
#> ERR184067     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184071     2  0.0291      0.823 0.004 0.992 0.000 0.004 0.000 0.000
#> ERR184042     5  0.1552      0.986 0.004 0.000 0.036 0.020 0.940 0.000
#> ERR184063     3  0.2620      0.868 0.024 0.000 0.888 0.048 0.000 0.040
#> ERR184091     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184061     6  0.2290      0.888 0.024 0.004 0.000 0.060 0.008 0.904
#> ERR184077     2  0.0551      0.824 0.008 0.984 0.000 0.004 0.004 0.000
#> ERR184062     6  0.4226      0.488 0.004 0.328 0.000 0.016 0.004 0.648
#> ERR184053     2  0.0551      0.824 0.008 0.984 0.000 0.004 0.004 0.000
#> ERR184088     2  0.2495      0.781 0.016 0.892 0.000 0.032 0.000 0.060
#> ERR184075     2  0.3875      0.157 0.016 0.700 0.000 0.280 0.004 0.000
#> ERR184041     3  0.2818      0.860 0.024 0.000 0.876 0.048 0.000 0.052
#> ERR184060     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184035     6  0.2157      0.892 0.008 0.004 0.000 0.076 0.008 0.904
#> ERR184086     2  0.2886      0.614 0.016 0.836 0.000 0.144 0.004 0.000
#> ERR184080     6  0.1806      0.894 0.044 0.000 0.000 0.020 0.008 0.928
#> ERR184050     2  0.0748      0.818 0.016 0.976 0.000 0.004 0.004 0.000
#> ERR184047     5  0.0865      0.993 0.000 0.000 0.036 0.000 0.964 0.000
#> ERR184092     2  0.0653      0.820 0.004 0.980 0.000 0.012 0.004 0.000
#> ERR184072     1  0.4279      0.843 0.784 0.000 0.020 0.120 0.024 0.052
#> ERR184073     1  0.1588      0.904 0.924 0.000 0.072 0.004 0.000 0.000
#> ERR184066     6  0.0909      0.906 0.020 0.000 0.000 0.012 0.000 0.968
#> ERR184098     2  0.2846      0.623 0.016 0.840 0.000 0.140 0.004 0.000
#> ERR184044     6  0.1575      0.894 0.000 0.032 0.000 0.032 0.000 0.936
#> ERR184054     1  0.2539      0.916 0.896 0.000 0.020 0.020 0.008 0.056
#> ERR184085     6  0.1152      0.901 0.000 0.004 0.000 0.044 0.000 0.952
#> ERR184056     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184052     2  0.3003      0.775 0.028 0.868 0.000 0.032 0.004 0.068
#> ERR184070     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184096     5  0.0865      0.993 0.000 0.000 0.036 0.000 0.964 0.000
#> ERR184089     2  0.3625      0.722 0.020 0.816 0.000 0.040 0.004 0.120
#> ERR184049     2  0.5109      0.190 0.020 0.552 0.000 0.036 0.004 0.388
#> ERR184038     6  0.0909      0.906 0.020 0.000 0.000 0.012 0.000 0.968
#> ERR184087     3  0.0000      0.890 0.000 0.000 1.000 0.000 0.000 0.000
#> ERR184097     2  0.0436      0.824 0.004 0.988 0.000 0.004 0.004 0.000
#> ERR184094     3  0.4155      0.360 0.364 0.000 0.616 0.020 0.000 0.000
#> ERR184058     4  0.3742      0.985 0.000 0.348 0.000 0.648 0.004 0.000
#> ERR184036     2  0.0922      0.821 0.024 0.968 0.000 0.000 0.004 0.004
#> ERR184046     4  0.3607      0.990 0.000 0.348 0.000 0.652 0.000 0.000
#> ERR184074     1  0.2476      0.918 0.900 0.000 0.020 0.020 0.008 0.052
#> ERR184048     2  0.0551      0.824 0.008 0.984 0.000 0.004 0.004 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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.


ATC:skmeans**

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "skmeans"]
# you can also extract it by
# res = res_list["ATC:skmeans"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-skmeans-select-partition-number

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.981       0.991         0.5048 0.494   0.494
#> 3 3 0.854           0.855       0.927         0.1810 0.911   0.820
#> 4 4 0.776           0.723       0.853         0.0739 0.976   0.940
#> 5 5 0.699           0.628       0.801         0.0599 0.999   0.997
#> 6 6 0.655           0.601       0.776         0.0396 0.973   0.930

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1   0.000      0.980 1.000 0.000
#> ERR184093     2   0.000      1.000 0.000 1.000
#> ERR184051     1   0.000      0.980 1.000 0.000
#> ERR184076     1   0.000      0.980 1.000 0.000
#> ERR184043     1   0.000      0.980 1.000 0.000
#> ERR184037     1   0.000      0.980 1.000 0.000
#> ERR184059     1   0.000      0.980 1.000 0.000
#> ERR184055     1   0.000      0.980 1.000 0.000
#> ERR184065     2   0.000      1.000 0.000 1.000
#> ERR184069     2   0.000      1.000 0.000 1.000
#> ERR184040     1   0.000      0.980 1.000 0.000
#> ERR184057     2   0.000      1.000 0.000 1.000
#> ERR184082     1   0.788      0.708 0.764 0.236
#> ERR184083     2   0.000      1.000 0.000 1.000
#> ERR184039     2   0.000      1.000 0.000 1.000
#> ERR184064     1   0.000      0.980 1.000 0.000
#> ERR184081     2   0.000      1.000 0.000 1.000
#> ERR184095     2   0.000      1.000 0.000 1.000
#> ERR184079     2   0.000      1.000 0.000 1.000
#> ERR184084     1   0.000      0.980 1.000 0.000
#> ERR184068     2   0.000      1.000 0.000 1.000
#> ERR184067     2   0.000      1.000 0.000 1.000
#> ERR184071     2   0.000      1.000 0.000 1.000
#> ERR184042     1   0.000      0.980 1.000 0.000
#> ERR184063     1   0.000      0.980 1.000 0.000
#> ERR184091     2   0.000      1.000 0.000 1.000
#> ERR184061     1   0.295      0.937 0.948 0.052
#> ERR184077     2   0.000      1.000 0.000 1.000
#> ERR184062     2   0.000      1.000 0.000 1.000
#> ERR184053     2   0.000      1.000 0.000 1.000
#> ERR184088     2   0.000      1.000 0.000 1.000
#> ERR184075     2   0.000      1.000 0.000 1.000
#> ERR184041     1   0.000      0.980 1.000 0.000
#> ERR184060     2   0.000      1.000 0.000 1.000
#> ERR184035     1   0.653      0.808 0.832 0.168
#> ERR184086     2   0.000      1.000 0.000 1.000
#> ERR184080     1   0.000      0.980 1.000 0.000
#> ERR184050     2   0.000      1.000 0.000 1.000
#> ERR184047     1   0.000      0.980 1.000 0.000
#> ERR184092     2   0.000      1.000 0.000 1.000
#> ERR184072     1   0.000      0.980 1.000 0.000
#> ERR184073     1   0.000      0.980 1.000 0.000
#> ERR184066     1   0.000      0.980 1.000 0.000
#> ERR184098     2   0.000      1.000 0.000 1.000
#> ERR184044     1   0.494      0.879 0.892 0.108
#> ERR184054     1   0.000      0.980 1.000 0.000
#> ERR184085     1   0.000      0.980 1.000 0.000
#> ERR184056     2   0.000      1.000 0.000 1.000
#> ERR184052     2   0.000      1.000 0.000 1.000
#> ERR184070     2   0.000      1.000 0.000 1.000
#> ERR184096     1   0.000      0.980 1.000 0.000
#> ERR184089     2   0.000      1.000 0.000 1.000
#> ERR184049     2   0.000      1.000 0.000 1.000
#> ERR184038     1   0.000      0.980 1.000 0.000
#> ERR184087     1   0.000      0.980 1.000 0.000
#> ERR184097     2   0.000      1.000 0.000 1.000
#> ERR184094     1   0.000      0.980 1.000 0.000
#> ERR184058     2   0.000      1.000 0.000 1.000
#> ERR184036     2   0.000      1.000 0.000 1.000
#> ERR184046     2   0.000      1.000 0.000 1.000
#> ERR184074     1   0.000      0.980 1.000 0.000
#> ERR184048     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     3  0.3267      0.833 0.116 0.000 0.884
#> ERR184093     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184051     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184076     3  0.3340      0.831 0.120 0.000 0.880
#> ERR184043     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184037     1  0.1643      0.707 0.956 0.000 0.044
#> ERR184059     3  0.0237      0.869 0.004 0.000 0.996
#> ERR184055     1  0.5291      0.663 0.732 0.000 0.268
#> ERR184065     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184069     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184040     3  0.2448      0.859 0.076 0.000 0.924
#> ERR184057     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184082     1  0.7080      0.470 0.564 0.024 0.412
#> ERR184083     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184039     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184064     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184081     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184079     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184084     3  0.0424      0.868 0.008 0.000 0.992
#> ERR184068     2  0.0592      0.977 0.012 0.988 0.000
#> ERR184067     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184071     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184042     3  0.1031      0.870 0.024 0.000 0.976
#> ERR184063     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184091     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184061     1  0.2261      0.717 0.932 0.000 0.068
#> ERR184077     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184062     2  0.5327      0.643 0.272 0.728 0.000
#> ERR184053     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184088     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184075     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184041     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184060     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184035     1  0.3619      0.724 0.864 0.000 0.136
#> ERR184086     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184080     1  0.5988      0.516 0.632 0.000 0.368
#> ERR184050     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184047     3  0.1860      0.867 0.052 0.000 0.948
#> ERR184092     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184072     3  0.5948      0.362 0.360 0.000 0.640
#> ERR184073     3  0.2356      0.861 0.072 0.000 0.928
#> ERR184066     1  0.6260      0.329 0.552 0.000 0.448
#> ERR184098     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184044     1  0.6066      0.675 0.728 0.024 0.248
#> ERR184054     3  0.5178      0.626 0.256 0.000 0.744
#> ERR184085     3  0.6295     -0.232 0.472 0.000 0.528
#> ERR184056     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184052     2  0.0424      0.980 0.008 0.992 0.000
#> ERR184070     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184096     3  0.2356      0.861 0.072 0.000 0.928
#> ERR184089     2  0.0424      0.980 0.008 0.992 0.000
#> ERR184049     2  0.3619      0.847 0.136 0.864 0.000
#> ERR184038     3  0.3038      0.821 0.104 0.000 0.896
#> ERR184087     3  0.0592      0.864 0.012 0.000 0.988
#> ERR184097     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184094     3  0.1753      0.868 0.048 0.000 0.952
#> ERR184058     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184036     2  0.0747      0.973 0.016 0.984 0.000
#> ERR184046     2  0.0000      0.986 0.000 1.000 0.000
#> ERR184074     3  0.3686      0.809 0.140 0.000 0.860
#> ERR184048     2  0.0000      0.986 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     3  0.3691     0.7308 0.076 0.000 0.856 0.068
#> ERR184093     2  0.1004     0.9450 0.004 0.972 0.000 0.024
#> ERR184051     3  0.3311     0.7542 0.000 0.000 0.828 0.172
#> ERR184076     3  0.4100     0.7274 0.076 0.000 0.832 0.092
#> ERR184043     3  0.3266     0.7560 0.000 0.000 0.832 0.168
#> ERR184037     1  0.2915     0.4682 0.892 0.000 0.080 0.028
#> ERR184059     3  0.1792     0.7874 0.000 0.000 0.932 0.068
#> ERR184055     1  0.7603     0.3235 0.476 0.000 0.244 0.280
#> ERR184065     2  0.0188     0.9570 0.000 0.996 0.000 0.004
#> ERR184069     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184040     3  0.2565     0.7660 0.056 0.000 0.912 0.032
#> ERR184057     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184082     4  0.7888    -0.3066 0.244 0.020 0.216 0.520
#> ERR184083     2  0.0188     0.9570 0.000 0.996 0.000 0.004
#> ERR184039     2  0.0336     0.9560 0.000 0.992 0.000 0.008
#> ERR184064     3  0.3266     0.7560 0.000 0.000 0.832 0.168
#> ERR184081     2  0.0188     0.9570 0.000 0.996 0.000 0.004
#> ERR184095     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184079     2  0.2111     0.9100 0.024 0.932 0.000 0.044
#> ERR184084     3  0.1867     0.7868 0.000 0.000 0.928 0.072
#> ERR184068     2  0.4920     0.6652 0.052 0.756 0.000 0.192
#> ERR184067     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184071     2  0.0188     0.9568 0.000 0.996 0.000 0.004
#> ERR184042     3  0.0469     0.7906 0.000 0.000 0.988 0.012
#> ERR184063     3  0.3486     0.7452 0.000 0.000 0.812 0.188
#> ERR184091     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184061     1  0.5151     0.4550 0.760 0.000 0.100 0.140
#> ERR184077     2  0.0707     0.9510 0.000 0.980 0.000 0.020
#> ERR184062     4  0.7695     0.0453 0.220 0.372 0.000 0.408
#> ERR184053     2  0.1042     0.9447 0.008 0.972 0.000 0.020
#> ERR184088     2  0.1151     0.9428 0.008 0.968 0.000 0.024
#> ERR184075     2  0.0188     0.9570 0.000 0.996 0.000 0.004
#> ERR184041     3  0.3444     0.7479 0.000 0.000 0.816 0.184
#> ERR184060     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184035     1  0.7293     0.3016 0.476 0.000 0.156 0.368
#> ERR184086     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184080     1  0.7558     0.2390 0.428 0.000 0.380 0.192
#> ERR184050     2  0.0592     0.9526 0.000 0.984 0.000 0.016
#> ERR184047     3  0.0804     0.7881 0.012 0.000 0.980 0.008
#> ERR184092     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184072     3  0.6566     0.2828 0.288 0.000 0.600 0.112
#> ERR184073     3  0.1936     0.7768 0.032 0.000 0.940 0.028
#> ERR184066     4  0.7816    -0.3809 0.340 0.000 0.260 0.400
#> ERR184098     2  0.0188     0.9570 0.000 0.996 0.000 0.004
#> ERR184044     1  0.6260     0.3185 0.636 0.008 0.068 0.288
#> ERR184054     3  0.5470     0.5775 0.168 0.000 0.732 0.100
#> ERR184085     3  0.7796    -0.3100 0.248 0.000 0.392 0.360
#> ERR184056     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184052     2  0.2845     0.8732 0.028 0.896 0.000 0.076
#> ERR184070     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184096     3  0.1488     0.7820 0.032 0.000 0.956 0.012
#> ERR184089     2  0.3219     0.8374 0.020 0.868 0.000 0.112
#> ERR184049     2  0.6964     0.2385 0.228 0.584 0.000 0.188
#> ERR184038     3  0.5217     0.6277 0.108 0.000 0.756 0.136
#> ERR184087     3  0.3266     0.7560 0.000 0.000 0.832 0.168
#> ERR184097     2  0.0188     0.9568 0.000 0.996 0.000 0.004
#> ERR184094     3  0.0592     0.7888 0.016 0.000 0.984 0.000
#> ERR184058     2  0.0188     0.9567 0.000 0.996 0.000 0.004
#> ERR184036     2  0.1854     0.9163 0.048 0.940 0.000 0.012
#> ERR184046     2  0.0000     0.9576 0.000 1.000 0.000 0.000
#> ERR184074     3  0.4312     0.6947 0.132 0.000 0.812 0.056
#> ERR184048     2  0.0188     0.9569 0.004 0.996 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     3  0.4032     0.6588 0.164 0.000 0.792 0.024 0.020
#> ERR184093     2  0.2972     0.8474 0.004 0.864 0.000 0.024 0.108
#> ERR184051     3  0.3300     0.6720 0.000 0.000 0.792 0.204 0.004
#> ERR184076     3  0.5544     0.5896 0.148 0.000 0.712 0.052 0.088
#> ERR184043     3  0.3039     0.6794 0.000 0.000 0.808 0.192 0.000
#> ERR184037     1  0.4219     0.2870 0.816 0.000 0.068 0.060 0.056
#> ERR184059     3  0.1043     0.7317 0.000 0.000 0.960 0.040 0.000
#> ERR184055     1  0.8039     0.1118 0.432 0.000 0.132 0.212 0.224
#> ERR184065     2  0.0290     0.9071 0.000 0.992 0.000 0.000 0.008
#> ERR184069     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184040     3  0.3357     0.6919 0.136 0.000 0.836 0.016 0.012
#> ERR184057     2  0.0162     0.9070 0.000 0.996 0.000 0.000 0.004
#> ERR184082     4  0.8124     0.0000 0.168 0.020 0.172 0.496 0.144
#> ERR184083     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184039     2  0.1281     0.9011 0.000 0.956 0.000 0.012 0.032
#> ERR184064     3  0.3039     0.6798 0.000 0.000 0.808 0.192 0.000
#> ERR184081     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184095     2  0.0162     0.9070 0.000 0.996 0.000 0.000 0.004
#> ERR184079     2  0.4791     0.7081 0.020 0.748 0.000 0.064 0.168
#> ERR184084     3  0.1484     0.7321 0.008 0.000 0.944 0.048 0.000
#> ERR184068     2  0.7151     0.1510 0.048 0.504 0.000 0.176 0.272
#> ERR184067     2  0.0290     0.9074 0.000 0.992 0.000 0.000 0.008
#> ERR184071     2  0.1862     0.8937 0.004 0.932 0.000 0.016 0.048
#> ERR184042     3  0.0693     0.7357 0.012 0.000 0.980 0.008 0.000
#> ERR184063     3  0.3961     0.6284 0.000 0.000 0.736 0.248 0.016
#> ERR184091     2  0.0162     0.9066 0.000 0.996 0.000 0.000 0.004
#> ERR184061     1  0.5520     0.2189 0.692 0.000 0.024 0.180 0.104
#> ERR184077     2  0.1331     0.8989 0.000 0.952 0.000 0.008 0.040
#> ERR184062     5  0.4426     0.0513 0.052 0.196 0.000 0.004 0.748
#> ERR184053     2  0.2260     0.8762 0.000 0.908 0.000 0.028 0.064
#> ERR184088     2  0.3725     0.7998 0.008 0.816 0.000 0.036 0.140
#> ERR184075     2  0.1106     0.9028 0.000 0.964 0.000 0.012 0.024
#> ERR184041     3  0.3696     0.6612 0.000 0.000 0.772 0.212 0.016
#> ERR184060     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184035     1  0.7640    -0.2142 0.428 0.000 0.120 0.340 0.112
#> ERR184086     2  0.0693     0.9072 0.000 0.980 0.000 0.012 0.008
#> ERR184080     1  0.6974     0.0979 0.496 0.000 0.340 0.096 0.068
#> ERR184050     2  0.1960     0.8891 0.004 0.928 0.000 0.020 0.048
#> ERR184047     3  0.0794     0.7346 0.028 0.000 0.972 0.000 0.000
#> ERR184092     2  0.0510     0.9067 0.000 0.984 0.000 0.000 0.016
#> ERR184072     3  0.6905     0.0310 0.380 0.000 0.468 0.092 0.060
#> ERR184073     3  0.2011     0.7214 0.088 0.000 0.908 0.000 0.004
#> ERR184066     5  0.8044    -0.2567 0.240 0.000 0.188 0.140 0.432
#> ERR184098     2  0.0807     0.9072 0.000 0.976 0.000 0.012 0.012
#> ERR184044     1  0.8197     0.0671 0.400 0.024 0.072 0.180 0.324
#> ERR184054     3  0.5952     0.4542 0.260 0.000 0.628 0.036 0.076
#> ERR184085     3  0.8367    -0.4480 0.184 0.000 0.344 0.292 0.180
#> ERR184056     2  0.0703     0.9056 0.000 0.976 0.000 0.000 0.024
#> ERR184052     2  0.4750     0.7294 0.016 0.760 0.000 0.104 0.120
#> ERR184070     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184096     3  0.1591     0.7291 0.052 0.000 0.940 0.004 0.004
#> ERR184089     2  0.5523     0.6007 0.016 0.688 0.000 0.152 0.144
#> ERR184049     2  0.7611     0.1036 0.108 0.496 0.000 0.228 0.168
#> ERR184038     3  0.6852     0.3715 0.084 0.000 0.596 0.156 0.164
#> ERR184087     3  0.2966     0.6823 0.000 0.000 0.816 0.184 0.000
#> ERR184097     2  0.0865     0.9057 0.000 0.972 0.000 0.004 0.024
#> ERR184094     3  0.0609     0.7357 0.020 0.000 0.980 0.000 0.000
#> ERR184058     2  0.0510     0.9071 0.000 0.984 0.000 0.000 0.016
#> ERR184036     2  0.3779     0.8153 0.040 0.836 0.000 0.032 0.092
#> ERR184046     2  0.0000     0.9070 0.000 1.000 0.000 0.000 0.000
#> ERR184074     3  0.3883     0.6399 0.216 0.000 0.764 0.016 0.004
#> ERR184048     2  0.1408     0.8967 0.000 0.948 0.000 0.008 0.044

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4    p5    p6
#> ERR184078     1  0.2898     0.6656 0.880 0.000 NA 0.016 0.016 0.048
#> ERR184093     2  0.3849     0.7981 0.000 0.812 NA 0.024 0.112 0.016
#> ERR184051     1  0.3861     0.6016 0.672 0.000 NA 0.004 0.008 0.000
#> ERR184076     1  0.4833     0.5862 0.760 0.000 NA 0.032 0.044 0.076
#> ERR184043     1  0.3446     0.6102 0.692 0.000 NA 0.000 0.000 0.000
#> ERR184037     6  0.4208     0.3081 0.076 0.000 NA 0.064 0.044 0.800
#> ERR184059     1  0.1714     0.6969 0.908 0.000 NA 0.000 0.000 0.000
#> ERR184055     6  0.8778     0.0266 0.216 0.000 NA 0.160 0.136 0.296
#> ERR184065     2  0.0951     0.8730 0.000 0.968 NA 0.000 0.020 0.004
#> ERR184069     2  0.0260     0.8731 0.000 0.992 NA 0.000 0.008 0.000
#> ERR184040     1  0.2138     0.6745 0.908 0.000 NA 0.004 0.000 0.052
#> ERR184057     2  0.0603     0.8726 0.000 0.980 NA 0.004 0.016 0.000
#> ERR184082     4  0.6059     0.3194 0.108 0.000 NA 0.668 0.088 0.052
#> ERR184083     2  0.0653     0.8735 0.000 0.980 NA 0.000 0.012 0.004
#> ERR184039     2  0.1440     0.8720 0.000 0.948 NA 0.004 0.032 0.004
#> ERR184064     1  0.3409     0.6150 0.700 0.000 NA 0.000 0.000 0.000
#> ERR184081     2  0.0291     0.8728 0.000 0.992 NA 0.000 0.004 0.000
#> ERR184095     2  0.0363     0.8739 0.000 0.988 NA 0.000 0.012 0.000
#> ERR184079     2  0.6036     0.5848 0.000 0.652 NA 0.088 0.160 0.036
#> ERR184084     1  0.2311     0.6905 0.880 0.000 NA 0.016 0.000 0.000
#> ERR184068     2  0.7408     0.1514 0.000 0.480 NA 0.164 0.232 0.044
#> ERR184067     2  0.0520     0.8750 0.000 0.984 NA 0.000 0.008 0.000
#> ERR184071     2  0.2596     0.8477 0.000 0.872 NA 0.004 0.104 0.004
#> ERR184042     1  0.1141     0.7018 0.948 0.000 NA 0.000 0.000 0.000
#> ERR184063     1  0.4552     0.5202 0.580 0.000 NA 0.016 0.016 0.000
#> ERR184091     2  0.0653     0.8722 0.000 0.980 NA 0.000 0.012 0.004
#> ERR184061     6  0.6157     0.2624 0.044 0.004 NA 0.116 0.088 0.664
#> ERR184077     2  0.3035     0.8370 0.000 0.868 NA 0.020 0.072 0.012
#> ERR184062     5  0.4246     0.0952 0.000 0.156 NA 0.024 0.764 0.052
#> ERR184053     2  0.3423     0.8263 0.000 0.848 NA 0.044 0.068 0.012
#> ERR184088     2  0.4990     0.7216 0.000 0.748 NA 0.072 0.080 0.024
#> ERR184075     2  0.1821     0.8646 0.000 0.928 NA 0.000 0.040 0.008
#> ERR184041     1  0.4371     0.5164 0.576 0.000 NA 0.008 0.008 0.004
#> ERR184060     2  0.0260     0.8728 0.000 0.992 NA 0.000 0.008 0.000
#> ERR184035     4  0.6005     0.1963 0.076 0.000 NA 0.644 0.040 0.188
#> ERR184086     2  0.1180     0.8753 0.000 0.960 NA 0.004 0.024 0.004
#> ERR184080     1  0.8173    -0.3155 0.364 0.000 NA 0.148 0.088 0.292
#> ERR184050     2  0.2881     0.8380 0.000 0.872 NA 0.012 0.064 0.004
#> ERR184047     1  0.0692     0.7011 0.976 0.000 NA 0.000 0.000 0.004
#> ERR184092     2  0.1010     0.8733 0.000 0.960 NA 0.004 0.036 0.000
#> ERR184072     1  0.7129     0.1545 0.516 0.000 NA 0.088 0.044 0.244
#> ERR184073     1  0.1080     0.6906 0.960 0.000 NA 0.004 0.000 0.032
#> ERR184066     5  0.8103    -0.1395 0.180 0.000 NA 0.092 0.436 0.144
#> ERR184098     2  0.1722     0.8680 0.000 0.936 NA 0.008 0.036 0.004
#> ERR184044     6  0.7896     0.1894 0.044 0.008 NA 0.112 0.240 0.440
#> ERR184054     1  0.6462     0.3823 0.616 0.000 NA 0.052 0.060 0.164
#> ERR184085     4  0.8362     0.1856 0.236 0.000 NA 0.368 0.092 0.132
#> ERR184056     2  0.1268     0.8730 0.000 0.952 NA 0.004 0.036 0.000
#> ERR184052     2  0.5485     0.6735 0.000 0.704 NA 0.112 0.096 0.024
#> ERR184070     2  0.0146     0.8725 0.000 0.996 NA 0.000 0.004 0.000
#> ERR184096     1  0.0508     0.6968 0.984 0.000 NA 0.000 0.000 0.012
#> ERR184089     2  0.7014     0.3692 0.000 0.552 NA 0.100 0.168 0.036
#> ERR184049     2  0.8590    -0.3138 0.000 0.340 NA 0.208 0.128 0.196
#> ERR184038     1  0.7381     0.1972 0.496 0.000 NA 0.076 0.096 0.084
#> ERR184087     1  0.3390     0.6172 0.704 0.000 NA 0.000 0.000 0.000
#> ERR184097     2  0.1442     0.8704 0.000 0.944 NA 0.004 0.040 0.000
#> ERR184094     1  0.0508     0.7010 0.984 0.000 NA 0.000 0.000 0.004
#> ERR184058     2  0.0798     0.8741 0.000 0.976 NA 0.004 0.012 0.004
#> ERR184036     2  0.4263     0.7720 0.000 0.800 NA 0.044 0.048 0.080
#> ERR184046     2  0.0508     0.8737 0.000 0.984 NA 0.000 0.012 0.000
#> ERR184074     1  0.4247     0.5926 0.784 0.000 NA 0.020 0.016 0.116
#> ERR184048     2  0.2820     0.8452 0.000 0.872 NA 0.024 0.084 0.004

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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.


ATC:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "pam"]
# you can also extract it by
# res = res_list["ATC:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-pam-select-partition-number

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.784           0.908       0.946         0.4864 0.492   0.492
#> 3 3 0.907           0.907       0.942         0.2182 0.889   0.776
#> 4 4 1.000           0.940       0.980         0.0591 0.987   0.967
#> 5 5 0.754           0.773       0.845         0.1019 0.973   0.929
#> 6 6 0.714           0.731       0.833         0.0683 0.840   0.586

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.0000      0.879 1.000 0.000
#> ERR184093     2  0.0000      1.000 0.000 1.000
#> ERR184051     1  0.0000      0.879 1.000 0.000
#> ERR184076     1  0.0000      0.879 1.000 0.000
#> ERR184043     1  0.0000      0.879 1.000 0.000
#> ERR184037     1  0.8144      0.764 0.748 0.252
#> ERR184059     1  0.0000      0.879 1.000 0.000
#> ERR184055     1  0.8144      0.764 0.748 0.252
#> ERR184065     2  0.0000      1.000 0.000 1.000
#> ERR184069     2  0.0000      1.000 0.000 1.000
#> ERR184040     1  0.0000      0.879 1.000 0.000
#> ERR184057     2  0.0000      1.000 0.000 1.000
#> ERR184082     1  0.9970      0.355 0.532 0.468
#> ERR184083     2  0.0000      1.000 0.000 1.000
#> ERR184039     2  0.0000      1.000 0.000 1.000
#> ERR184064     1  0.0000      0.879 1.000 0.000
#> ERR184081     2  0.0000      1.000 0.000 1.000
#> ERR184095     2  0.0000      1.000 0.000 1.000
#> ERR184079     2  0.0000      1.000 0.000 1.000
#> ERR184084     1  0.0000      0.879 1.000 0.000
#> ERR184068     2  0.0000      1.000 0.000 1.000
#> ERR184067     2  0.0000      1.000 0.000 1.000
#> ERR184071     2  0.0000      1.000 0.000 1.000
#> ERR184042     1  0.0000      0.879 1.000 0.000
#> ERR184063     1  0.0376      0.878 0.996 0.004
#> ERR184091     2  0.0000      1.000 0.000 1.000
#> ERR184061     1  0.8608      0.726 0.716 0.284
#> ERR184077     2  0.0000      1.000 0.000 1.000
#> ERR184062     1  0.9909      0.420 0.556 0.444
#> ERR184053     2  0.0000      1.000 0.000 1.000
#> ERR184088     2  0.0000      1.000 0.000 1.000
#> ERR184075     2  0.0000      1.000 0.000 1.000
#> ERR184041     1  0.1184      0.876 0.984 0.016
#> ERR184060     2  0.0000      1.000 0.000 1.000
#> ERR184035     1  0.8267      0.756 0.740 0.260
#> ERR184086     2  0.0000      1.000 0.000 1.000
#> ERR184080     1  0.8144      0.764 0.748 0.252
#> ERR184050     2  0.0000      1.000 0.000 1.000
#> ERR184047     1  0.0000      0.879 1.000 0.000
#> ERR184092     2  0.0000      1.000 0.000 1.000
#> ERR184072     1  0.3274      0.863 0.940 0.060
#> ERR184073     1  0.0000      0.879 1.000 0.000
#> ERR184066     1  0.8144      0.764 0.748 0.252
#> ERR184098     2  0.0000      1.000 0.000 1.000
#> ERR184044     1  0.8144      0.764 0.748 0.252
#> ERR184054     1  0.3274      0.863 0.940 0.060
#> ERR184085     1  0.8207      0.760 0.744 0.256
#> ERR184056     2  0.0000      1.000 0.000 1.000
#> ERR184052     2  0.0000      1.000 0.000 1.000
#> ERR184070     2  0.0000      1.000 0.000 1.000
#> ERR184096     1  0.0000      0.879 1.000 0.000
#> ERR184089     2  0.0000      1.000 0.000 1.000
#> ERR184049     2  0.0000      1.000 0.000 1.000
#> ERR184038     1  0.8144      0.764 0.748 0.252
#> ERR184087     1  0.0000      0.879 1.000 0.000
#> ERR184097     2  0.0000      1.000 0.000 1.000
#> ERR184094     1  0.0000      0.879 1.000 0.000
#> ERR184058     2  0.0000      1.000 0.000 1.000
#> ERR184036     2  0.0000      1.000 0.000 1.000
#> ERR184046     2  0.0000      1.000 0.000 1.000
#> ERR184074     1  0.0000      0.879 1.000 0.000
#> ERR184048     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184093     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184051     3  0.6095      0.731 0.392 0.000 0.608
#> ERR184076     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184043     3  0.6095      0.731 0.392 0.000 0.608
#> ERR184037     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184059     3  0.1411      0.669 0.036 0.000 0.964
#> ERR184055     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184065     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184069     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184040     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184057     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184082     1  0.4974      0.518 0.764 0.236 0.000
#> ERR184083     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184039     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184064     3  0.6095      0.731 0.392 0.000 0.608
#> ERR184081     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184095     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184079     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184084     3  0.6140      0.715 0.404 0.000 0.596
#> ERR184068     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184067     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184071     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184042     3  0.0000      0.654 0.000 0.000 1.000
#> ERR184063     3  0.6095      0.731 0.392 0.000 0.608
#> ERR184091     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184061     1  0.0747      0.911 0.984 0.016 0.000
#> ERR184077     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184062     1  0.5465      0.408 0.712 0.288 0.000
#> ERR184053     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184088     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184075     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184041     3  0.6154      0.708 0.408 0.000 0.592
#> ERR184060     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184035     1  0.0237      0.928 0.996 0.004 0.000
#> ERR184086     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184080     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184050     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184047     3  0.0000      0.654 0.000 0.000 1.000
#> ERR184092     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184072     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184073     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184066     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184098     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184044     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184054     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184085     1  0.0237      0.928 0.996 0.004 0.000
#> ERR184056     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184052     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184070     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184096     3  0.3941      0.596 0.156 0.000 0.844
#> ERR184089     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184049     2  0.0424      0.990 0.008 0.992 0.000
#> ERR184038     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184087     3  0.5905      0.733 0.352 0.000 0.648
#> ERR184097     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184094     1  0.2959      0.790 0.900 0.000 0.100
#> ERR184058     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184036     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184046     2  0.0000      1.000 0.000 1.000 0.000
#> ERR184074     1  0.0000      0.932 1.000 0.000 0.000
#> ERR184048     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR184078     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184093     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184051     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184076     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184043     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184037     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184059     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184055     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184065     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184069     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184040     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184057     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184082     1  0.4040      0.572 0.752 0.248 0.000  0
#> ERR184083     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184039     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184064     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184081     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184095     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184079     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184084     3  0.0592      0.930 0.016 0.000 0.984  0
#> ERR184068     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184067     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184071     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184042     4  0.0000      1.000 0.000 0.000 0.000  1
#> ERR184063     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184091     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184061     1  0.0188      0.921 0.996 0.004 0.000  0
#> ERR184077     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184062     1  0.4543      0.438 0.676 0.324 0.000  0
#> ERR184053     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184088     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184075     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184041     3  0.3873      0.617 0.228 0.000 0.772  0
#> ERR184060     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184035     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184086     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184080     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184050     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184047     4  0.0000      1.000 0.000 0.000 0.000  1
#> ERR184092     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184072     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184073     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184066     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184098     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184044     1  0.0188      0.921 0.996 0.004 0.000  0
#> ERR184054     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184085     1  0.0336      0.917 0.992 0.008 0.000  0
#> ERR184056     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184052     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184070     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184096     4  0.0000      1.000 0.000 0.000 0.000  1
#> ERR184089     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184049     2  0.0336      0.990 0.008 0.992 0.000  0
#> ERR184038     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184087     3  0.0000      0.946 0.000 0.000 1.000  0
#> ERR184097     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184094     1  0.4866      0.286 0.596 0.000 0.404  0
#> ERR184058     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184036     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184046     2  0.0000      1.000 0.000 1.000 0.000  0
#> ERR184074     1  0.0000      0.924 1.000 0.000 0.000  0
#> ERR184048     2  0.0000      1.000 0.000 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184093     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184051     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000
#> ERR184076     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184043     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000
#> ERR184037     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184059     3  0.0162      0.941 0.000 0.000 0.996 0.000 0.004
#> ERR184055     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184065     2  0.4278      0.738 0.000 0.548 0.000 0.000 0.452
#> ERR184069     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184040     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184057     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184082     1  0.4150      0.380 0.612 0.388 0.000 0.000 0.000
#> ERR184083     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184039     2  0.4161      0.745 0.000 0.608 0.000 0.000 0.392
#> ERR184064     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000
#> ERR184081     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184095     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184079     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184084     3  0.0510      0.928 0.016 0.000 0.984 0.000 0.000
#> ERR184068     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184067     2  0.4278      0.738 0.000 0.548 0.000 0.000 0.452
#> ERR184071     2  0.0703      0.730 0.000 0.976 0.000 0.000 0.024
#> ERR184042     4  0.0000      0.000 0.000 0.000 0.000 1.000 0.000
#> ERR184063     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000
#> ERR184091     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184061     1  0.2605      0.764 0.852 0.148 0.000 0.000 0.000
#> ERR184077     2  0.0290      0.723 0.000 0.992 0.000 0.000 0.008
#> ERR184062     2  0.3586      0.313 0.264 0.736 0.000 0.000 0.000
#> ERR184053     2  0.0290      0.723 0.000 0.992 0.000 0.000 0.008
#> ERR184088     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184075     2  0.4273      0.739 0.000 0.552 0.000 0.000 0.448
#> ERR184041     3  0.3336      0.597 0.228 0.000 0.772 0.000 0.000
#> ERR184060     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184035     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184086     2  0.3684      0.747 0.000 0.720 0.000 0.000 0.280
#> ERR184080     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184050     2  0.3452      0.749 0.000 0.756 0.000 0.000 0.244
#> ERR184047     5  0.4297      1.000 0.000 0.000 0.000 0.472 0.528
#> ERR184092     2  0.0609      0.728 0.000 0.980 0.000 0.000 0.020
#> ERR184072     1  0.0290      0.909 0.992 0.000 0.000 0.000 0.008
#> ERR184073     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184066     1  0.0703      0.896 0.976 0.024 0.000 0.000 0.000
#> ERR184098     2  0.3661      0.748 0.000 0.724 0.000 0.000 0.276
#> ERR184044     1  0.3003      0.722 0.812 0.188 0.000 0.000 0.000
#> ERR184054     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184085     1  0.0162      0.910 0.996 0.004 0.000 0.000 0.000
#> ERR184056     2  0.3210      0.733 0.000 0.788 0.000 0.000 0.212
#> ERR184052     2  0.0609      0.729 0.000 0.980 0.000 0.000 0.020
#> ERR184070     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184096     5  0.4297      1.000 0.000 0.000 0.000 0.472 0.528
#> ERR184089     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184049     2  0.0000      0.720 0.000 1.000 0.000 0.000 0.000
#> ERR184038     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184087     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000
#> ERR184097     2  0.2516      0.730 0.000 0.860 0.000 0.000 0.140
#> ERR184094     1  0.4192      0.332 0.596 0.000 0.404 0.000 0.000
#> ERR184058     2  0.4278      0.738 0.000 0.548 0.000 0.000 0.452
#> ERR184036     2  0.1544      0.738 0.000 0.932 0.000 0.000 0.068
#> ERR184046     2  0.4287      0.735 0.000 0.540 0.000 0.000 0.460
#> ERR184074     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> ERR184048     2  0.0880      0.732 0.000 0.968 0.000 0.000 0.032

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4   p5    p6
#> ERR184078     1  0.0146     0.8749 0.996 0.000 0.000 0.000 0.00 0.004
#> ERR184093     2  0.0000     0.7474 0.000 1.000 0.000 0.000 0.00 0.000
#> ERR184051     3  0.0000     0.9190 0.000 0.000 1.000 0.000 0.00 0.000
#> ERR184076     1  0.0146     0.8750 0.996 0.000 0.000 0.000 0.00 0.004
#> ERR184043     3  0.0000     0.9190 0.000 0.000 1.000 0.000 0.00 0.000
#> ERR184037     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184059     3  0.3278     0.7736 0.000 0.000 0.808 0.152 0.00 0.040
#> ERR184055     1  0.0146     0.8747 0.996 0.004 0.000 0.000 0.00 0.000
#> ERR184065     6  0.3023     0.9679 0.000 0.232 0.000 0.000 0.00 0.768
#> ERR184069     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184040     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184057     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184082     2  0.3843    -0.0574 0.452 0.548 0.000 0.000 0.00 0.000
#> ERR184083     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184039     6  0.3547     0.8035 0.000 0.332 0.000 0.000 0.00 0.668
#> ERR184064     3  0.0000     0.9190 0.000 0.000 1.000 0.000 0.00 0.000
#> ERR184081     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184095     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184079     2  0.0000     0.7474 0.000 1.000 0.000 0.000 0.00 0.000
#> ERR184084     3  0.0458     0.9069 0.016 0.000 0.984 0.000 0.00 0.000
#> ERR184068     2  0.0000     0.7474 0.000 1.000 0.000 0.000 0.00 0.000
#> ERR184067     6  0.3076     0.9632 0.000 0.240 0.000 0.000 0.00 0.760
#> ERR184071     2  0.2260     0.6894 0.000 0.860 0.000 0.000 0.00 0.140
#> ERR184042     4  0.3756     0.0000 0.000 0.000 0.000 0.600 0.40 0.000
#> ERR184063     3  0.0000     0.9190 0.000 0.000 1.000 0.000 0.00 0.000
#> ERR184091     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184061     1  0.3620     0.4456 0.648 0.352 0.000 0.000 0.00 0.000
#> ERR184077     2  0.0865     0.7440 0.000 0.964 0.000 0.000 0.00 0.036
#> ERR184062     2  0.1007     0.7175 0.044 0.956 0.000 0.000 0.00 0.000
#> ERR184053     2  0.2793     0.5831 0.000 0.800 0.000 0.000 0.00 0.200
#> ERR184088     2  0.0363     0.7484 0.000 0.988 0.000 0.000 0.00 0.012
#> ERR184075     6  0.3050     0.9648 0.000 0.236 0.000 0.000 0.00 0.764
#> ERR184041     3  0.2996     0.6086 0.228 0.000 0.772 0.000 0.00 0.000
#> ERR184060     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184035     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184086     2  0.3672     0.1922 0.000 0.632 0.000 0.000 0.00 0.368
#> ERR184080     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184050     2  0.3547     0.3035 0.000 0.668 0.000 0.000 0.00 0.332
#> ERR184047     5  0.0000     0.7633 0.000 0.000 0.000 0.000 1.00 0.000
#> ERR184092     2  0.2762     0.6016 0.000 0.804 0.000 0.000 0.00 0.196
#> ERR184072     1  0.3558     0.6364 0.736 0.000 0.000 0.248 0.00 0.016
#> ERR184073     1  0.0632     0.8645 0.976 0.000 0.000 0.024 0.00 0.000
#> ERR184066     1  0.0937     0.8489 0.960 0.040 0.000 0.000 0.00 0.000
#> ERR184098     2  0.3765     0.0963 0.000 0.596 0.000 0.000 0.00 0.404
#> ERR184044     1  0.3868     0.1940 0.508 0.492 0.000 0.000 0.00 0.000
#> ERR184054     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184085     1  0.0865     0.8513 0.964 0.036 0.000 0.000 0.00 0.000
#> ERR184056     2  0.3823    -0.0604 0.000 0.564 0.000 0.000 0.00 0.436
#> ERR184052     2  0.0632     0.7481 0.000 0.976 0.000 0.000 0.00 0.024
#> ERR184070     6  0.3151     0.9451 0.000 0.252 0.000 0.000 0.00 0.748
#> ERR184096     5  0.2454     0.7633 0.000 0.000 0.000 0.000 0.84 0.160
#> ERR184089     2  0.1007     0.7428 0.000 0.956 0.000 0.000 0.00 0.044
#> ERR184049     2  0.0000     0.7474 0.000 1.000 0.000 0.000 0.00 0.000
#> ERR184038     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184087     3  0.0000     0.9190 0.000 0.000 1.000 0.000 0.00 0.000
#> ERR184097     2  0.3672     0.1956 0.000 0.632 0.000 0.000 0.00 0.368
#> ERR184094     1  0.4273     0.3368 0.596 0.000 0.380 0.024 0.00 0.000
#> ERR184058     6  0.3244     0.9271 0.000 0.268 0.000 0.000 0.00 0.732
#> ERR184036     2  0.2260     0.6715 0.000 0.860 0.000 0.000 0.00 0.140
#> ERR184046     6  0.2969     0.9723 0.000 0.224 0.000 0.000 0.00 0.776
#> ERR184074     1  0.0000     0.8760 1.000 0.000 0.000 0.000 0.00 0.000
#> ERR184048     2  0.1765     0.7173 0.000 0.904 0.000 0.000 0.00 0.096

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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.


ATC:mclust

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-mclust-select-partition-number

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.528           0.887       0.923         0.4617 0.497   0.497
#> 3 3 0.612           0.761       0.853         0.2382 0.840   0.709
#> 4 4 0.618           0.739       0.779         0.1171 0.918   0.836
#> 5 5 0.457           0.420       0.702         0.0858 0.834   0.653
#> 6 6 0.555           0.330       0.652         0.0526 0.888   0.685

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     1  0.6247      0.886 0.844 0.156
#> ERR184093     2  0.0000      0.973 0.000 1.000
#> ERR184051     1  0.0000      0.838 1.000 0.000
#> ERR184076     1  0.6247      0.886 0.844 0.156
#> ERR184043     1  0.0000      0.838 1.000 0.000
#> ERR184037     1  0.6247      0.886 0.844 0.156
#> ERR184059     1  0.0938      0.844 0.988 0.012
#> ERR184055     1  0.9323      0.665 0.652 0.348
#> ERR184065     2  0.0000      0.973 0.000 1.000
#> ERR184069     2  0.0000      0.973 0.000 1.000
#> ERR184040     1  0.6247      0.886 0.844 0.156
#> ERR184057     2  0.0000      0.973 0.000 1.000
#> ERR184082     2  0.5737      0.807 0.136 0.864
#> ERR184083     2  0.0000      0.973 0.000 1.000
#> ERR184039     2  0.0000      0.973 0.000 1.000
#> ERR184064     1  0.0000      0.838 1.000 0.000
#> ERR184081     2  0.0000      0.973 0.000 1.000
#> ERR184095     2  0.0000      0.973 0.000 1.000
#> ERR184079     2  0.0000      0.973 0.000 1.000
#> ERR184084     1  0.1414      0.846 0.980 0.020
#> ERR184068     2  0.0000      0.973 0.000 1.000
#> ERR184067     2  0.0000      0.973 0.000 1.000
#> ERR184071     2  0.0000      0.973 0.000 1.000
#> ERR184042     1  0.0000      0.838 1.000 0.000
#> ERR184063     1  0.0000      0.838 1.000 0.000
#> ERR184091     2  0.0000      0.973 0.000 1.000
#> ERR184061     1  0.6247      0.886 0.844 0.156
#> ERR184077     2  0.0000      0.973 0.000 1.000
#> ERR184062     2  0.7219      0.692 0.200 0.800
#> ERR184053     2  0.0376      0.969 0.004 0.996
#> ERR184088     2  0.0000      0.973 0.000 1.000
#> ERR184075     2  0.1843      0.946 0.028 0.972
#> ERR184041     1  0.0000      0.838 1.000 0.000
#> ERR184060     2  0.0000      0.973 0.000 1.000
#> ERR184035     1  0.8813      0.734 0.700 0.300
#> ERR184086     2  0.0000      0.973 0.000 1.000
#> ERR184080     1  0.6247      0.886 0.844 0.156
#> ERR184050     2  0.0000      0.973 0.000 1.000
#> ERR184047     1  0.6247      0.886 0.844 0.156
#> ERR184092     2  0.0000      0.973 0.000 1.000
#> ERR184072     1  0.6247      0.886 0.844 0.156
#> ERR184073     1  0.6247      0.886 0.844 0.156
#> ERR184066     1  0.8555      0.767 0.720 0.280
#> ERR184098     2  0.0000      0.973 0.000 1.000
#> ERR184044     2  0.2423      0.934 0.040 0.960
#> ERR184054     1  0.6247      0.886 0.844 0.156
#> ERR184085     2  0.9087      0.383 0.324 0.676
#> ERR184056     2  0.0000      0.973 0.000 1.000
#> ERR184052     2  0.0000      0.973 0.000 1.000
#> ERR184070     2  0.0000      0.973 0.000 1.000
#> ERR184096     1  0.6247      0.886 0.844 0.156
#> ERR184089     1  0.9988      0.323 0.520 0.480
#> ERR184049     2  0.0000      0.973 0.000 1.000
#> ERR184038     1  0.7376      0.845 0.792 0.208
#> ERR184087     1  0.0000      0.838 1.000 0.000
#> ERR184097     2  0.0000      0.973 0.000 1.000
#> ERR184094     1  0.6247      0.886 0.844 0.156
#> ERR184058     2  0.0000      0.973 0.000 1.000
#> ERR184036     1  0.9580      0.609 0.620 0.380
#> ERR184046     2  0.0000      0.973 0.000 1.000
#> ERR184074     1  0.6247      0.886 0.844 0.156
#> ERR184048     2  0.0000      0.973 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     1  0.6722      0.800 0.720 0.060 0.220
#> ERR184093     2  0.4110      0.844 0.152 0.844 0.004
#> ERR184051     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184076     1  0.6853      0.798 0.712 0.064 0.224
#> ERR184043     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184037     1  0.6486      0.725 0.760 0.096 0.144
#> ERR184059     3  0.6204     -0.136 0.424 0.000 0.576
#> ERR184055     2  0.6598      0.508 0.428 0.564 0.008
#> ERR184065     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184069     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184040     1  0.6722      0.800 0.720 0.060 0.220
#> ERR184057     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184082     2  0.6984      0.518 0.420 0.560 0.020
#> ERR184083     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184039     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184064     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184081     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184095     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184079     2  0.3983      0.845 0.144 0.852 0.004
#> ERR184084     1  0.5926      0.641 0.644 0.000 0.356
#> ERR184068     2  0.5109      0.802 0.212 0.780 0.008
#> ERR184067     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184071     2  0.2400      0.873 0.064 0.932 0.004
#> ERR184042     1  0.5810      0.625 0.664 0.000 0.336
#> ERR184063     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184091     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184061     1  0.6927      0.795 0.700 0.060 0.240
#> ERR184077     2  0.3030      0.866 0.092 0.904 0.004
#> ERR184062     2  0.5541      0.771 0.252 0.740 0.008
#> ERR184053     2  0.5775      0.716 0.260 0.728 0.012
#> ERR184088     2  0.4465      0.831 0.176 0.820 0.004
#> ERR184075     2  0.2703      0.853 0.016 0.928 0.056
#> ERR184041     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184060     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184035     1  0.4099      0.536 0.852 0.140 0.008
#> ERR184086     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184080     1  0.5506      0.691 0.816 0.092 0.092
#> ERR184050     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184047     1  0.5588      0.731 0.720 0.004 0.276
#> ERR184092     2  0.1647      0.879 0.036 0.960 0.004
#> ERR184072     1  0.6335      0.784 0.724 0.036 0.240
#> ERR184073     1  0.6836      0.795 0.704 0.056 0.240
#> ERR184066     1  0.6937      0.428 0.680 0.272 0.048
#> ERR184098     2  0.0237      0.882 0.000 0.996 0.004
#> ERR184044     2  0.5247      0.793 0.224 0.768 0.008
#> ERR184054     1  0.6630      0.800 0.724 0.056 0.220
#> ERR184085     2  0.7223      0.470 0.424 0.548 0.028
#> ERR184056     2  0.1989      0.877 0.048 0.948 0.004
#> ERR184052     2  0.0237      0.883 0.004 0.996 0.000
#> ERR184070     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184096     1  0.5803      0.756 0.736 0.016 0.248
#> ERR184089     2  0.7061      0.488 0.036 0.632 0.332
#> ERR184049     2  0.4409      0.830 0.172 0.824 0.004
#> ERR184038     1  0.7012      0.338 0.652 0.308 0.040
#> ERR184087     3  0.0424      0.903 0.008 0.000 0.992
#> ERR184097     2  0.3112      0.864 0.096 0.900 0.004
#> ERR184094     1  0.6562      0.777 0.700 0.036 0.264
#> ERR184058     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184036     2  0.9400     -0.206 0.356 0.464 0.180
#> ERR184046     2  0.0000      0.883 0.000 1.000 0.000
#> ERR184074     1  0.6895      0.799 0.708 0.064 0.228
#> ERR184048     2  0.2772      0.870 0.080 0.916 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> ERR184078     1  0.1492      0.852 0.956 0.004 0.004 NA
#> ERR184093     2  0.1978      0.734 0.068 0.928 0.000 NA
#> ERR184051     3  0.1489      0.942 0.044 0.000 0.952 NA
#> ERR184076     1  0.1492      0.852 0.956 0.004 0.004 NA
#> ERR184043     3  0.1888      0.938 0.044 0.000 0.940 NA
#> ERR184037     1  0.3213      0.834 0.896 0.040 0.024 NA
#> ERR184059     3  0.5309      0.600 0.256 0.000 0.700 NA
#> ERR184055     2  0.4326      0.669 0.088 0.840 0.036 NA
#> ERR184065     2  0.5155      0.728 0.000 0.528 0.004 NA
#> ERR184069     2  0.4907      0.753 0.000 0.580 0.000 NA
#> ERR184040     1  0.1082      0.854 0.972 0.004 0.004 NA
#> ERR184057     2  0.4790      0.763 0.000 0.620 0.000 NA
#> ERR184082     2  0.3403      0.728 0.028 0.888 0.040 NA
#> ERR184083     2  0.4898      0.754 0.000 0.584 0.000 NA
#> ERR184039     2  0.4916      0.748 0.000 0.576 0.000 NA
#> ERR184064     3  0.1489      0.942 0.044 0.000 0.952 NA
#> ERR184081     2  0.4907      0.753 0.000 0.580 0.000 NA
#> ERR184095     2  0.4898      0.755 0.000 0.584 0.000 NA
#> ERR184079     2  0.0967      0.731 0.004 0.976 0.004 NA
#> ERR184084     1  0.8643      0.216 0.456 0.216 0.276 NA
#> ERR184068     2  0.0895      0.728 0.000 0.976 0.004 NA
#> ERR184067     2  0.4800      0.766 0.000 0.656 0.004 NA
#> ERR184071     2  0.2859      0.761 0.000 0.880 0.008 NA
#> ERR184042     1  0.6961      0.508 0.512 0.000 0.120 NA
#> ERR184063     3  0.1635      0.942 0.044 0.000 0.948 NA
#> ERR184091     2  0.5163      0.724 0.000 0.516 0.004 NA
#> ERR184061     1  0.1284      0.859 0.964 0.012 0.000 NA
#> ERR184077     2  0.1890      0.748 0.000 0.936 0.008 NA
#> ERR184062     2  0.3907      0.688 0.064 0.864 0.036 NA
#> ERR184053     2  0.2742      0.756 0.008 0.900 0.008 NA
#> ERR184088     2  0.1296      0.735 0.028 0.964 0.004 NA
#> ERR184075     2  0.7345      0.689 0.016 0.532 0.116 NA
#> ERR184041     3  0.2111      0.936 0.044 0.000 0.932 NA
#> ERR184060     2  0.5060      0.755 0.004 0.584 0.000 NA
#> ERR184035     2  0.6619      0.422 0.304 0.616 0.036 NA
#> ERR184086     2  0.4907      0.749 0.000 0.580 0.000 NA
#> ERR184080     1  0.2521      0.835 0.924 0.028 0.032 NA
#> ERR184050     2  0.4961      0.736 0.000 0.552 0.000 NA
#> ERR184047     1  0.4504      0.808 0.772 0.004 0.020 NA
#> ERR184092     2  0.2831      0.762 0.000 0.876 0.004 NA
#> ERR184072     1  0.2197      0.855 0.916 0.004 0.000 NA
#> ERR184073     1  0.3534      0.837 0.840 0.004 0.008 NA
#> ERR184066     2  0.6696      0.299 0.320 0.600 0.036 NA
#> ERR184098     2  0.4907      0.749 0.000 0.580 0.000 NA
#> ERR184044     2  0.2392      0.726 0.012 0.928 0.036 NA
#> ERR184054     1  0.0712      0.857 0.984 0.004 0.004 NA
#> ERR184085     2  0.4329      0.703 0.056 0.844 0.036 NA
#> ERR184056     2  0.3142      0.763 0.000 0.860 0.008 NA
#> ERR184052     2  0.4843      0.758 0.000 0.604 0.000 NA
#> ERR184070     2  0.4905      0.766 0.004 0.632 0.000 NA
#> ERR184096     1  0.3992      0.822 0.800 0.004 0.008 NA
#> ERR184089     2  0.9053      0.332 0.076 0.408 0.296 NA
#> ERR184049     2  0.0707      0.745 0.000 0.980 0.000 NA
#> ERR184038     2  0.4723      0.665 0.108 0.816 0.036 NA
#> ERR184087     3  0.1489      0.941 0.044 0.000 0.952 NA
#> ERR184097     2  0.2737      0.759 0.000 0.888 0.008 NA
#> ERR184094     1  0.4420      0.812 0.776 0.008 0.012 NA
#> ERR184058     2  0.5039      0.757 0.004 0.592 0.000 NA
#> ERR184036     2  0.6031      0.245 0.420 0.536 0.000 NA
#> ERR184046     2  0.4916      0.752 0.000 0.576 0.000 NA
#> ERR184074     1  0.1004      0.858 0.972 0.004 0.000 NA
#> ERR184048     2  0.1909      0.745 0.004 0.940 0.008 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.3437     0.5857 0.808 0.000 0.004 0.176 0.012
#> ERR184093     2  0.1911     0.4934 0.036 0.932 0.000 0.004 0.028
#> ERR184051     3  0.2605     0.8389 0.148 0.000 0.852 0.000 0.000
#> ERR184076     1  0.3696     0.5617 0.772 0.000 0.000 0.212 0.016
#> ERR184043     3  0.1341     0.8423 0.056 0.000 0.944 0.000 0.000
#> ERR184037     1  0.3694     0.5566 0.796 0.032 0.000 0.172 0.000
#> ERR184059     3  0.4378     0.5883 0.216 0.000 0.740 0.040 0.004
#> ERR184055     2  0.5564     0.3778 0.200 0.664 0.000 0.128 0.008
#> ERR184065     5  0.5964     0.5031 0.000 0.340 0.000 0.124 0.536
#> ERR184069     5  0.4192     0.8150 0.000 0.404 0.000 0.000 0.596
#> ERR184040     1  0.2439     0.6456 0.876 0.000 0.004 0.120 0.000
#> ERR184057     5  0.4302     0.7232 0.000 0.480 0.000 0.000 0.520
#> ERR184082     2  0.5385     0.4093 0.124 0.724 0.000 0.112 0.040
#> ERR184083     5  0.4350     0.8180 0.000 0.408 0.000 0.004 0.588
#> ERR184039     2  0.5630    -0.3643 0.000 0.560 0.000 0.088 0.352
#> ERR184064     3  0.1341     0.8423 0.056 0.000 0.944 0.000 0.000
#> ERR184081     5  0.4219     0.8152 0.000 0.416 0.000 0.000 0.584
#> ERR184095     5  0.4262     0.7974 0.000 0.440 0.000 0.000 0.560
#> ERR184079     2  0.0798     0.5035 0.000 0.976 0.000 0.016 0.008
#> ERR184084     1  0.8160    -0.1210 0.428 0.180 0.268 0.116 0.008
#> ERR184068     2  0.0912     0.5034 0.000 0.972 0.000 0.016 0.012
#> ERR184067     2  0.3969    -0.1599 0.000 0.692 0.000 0.004 0.304
#> ERR184071     2  0.2233     0.4465 0.000 0.904 0.000 0.016 0.080
#> ERR184042     4  0.8269     0.0000 0.320 0.000 0.136 0.332 0.212
#> ERR184063     3  0.2605     0.8389 0.148 0.000 0.852 0.000 0.000
#> ERR184091     5  0.5739     0.5539 0.000 0.280 0.000 0.124 0.596
#> ERR184061     1  0.3190     0.6344 0.840 0.008 0.000 0.140 0.012
#> ERR184077     2  0.1493     0.4961 0.000 0.948 0.000 0.024 0.028
#> ERR184062     2  0.5108     0.4113 0.156 0.716 0.000 0.120 0.008
#> ERR184053     2  0.1893     0.4953 0.000 0.928 0.000 0.024 0.048
#> ERR184088     2  0.1597     0.4997 0.024 0.948 0.000 0.008 0.020
#> ERR184075     2  0.7719    -0.2392 0.008 0.448 0.092 0.124 0.328
#> ERR184041     3  0.2806     0.8334 0.152 0.000 0.844 0.000 0.004
#> ERR184060     5  0.4262     0.8029 0.000 0.440 0.000 0.000 0.560
#> ERR184035     2  0.6643    -0.0239 0.372 0.404 0.000 0.224 0.000
#> ERR184086     2  0.5778    -0.3529 0.000 0.528 0.000 0.096 0.376
#> ERR184080     1  0.3151     0.6137 0.836 0.020 0.000 0.144 0.000
#> ERR184050     2  0.6001    -0.3572 0.000 0.456 0.000 0.112 0.432
#> ERR184047     1  0.5778     0.1709 0.680 0.000 0.040 0.180 0.100
#> ERR184092     2  0.2104     0.4714 0.000 0.916 0.000 0.024 0.060
#> ERR184072     1  0.2361     0.6597 0.892 0.000 0.000 0.096 0.012
#> ERR184073     1  0.2740     0.6475 0.876 0.000 0.000 0.096 0.028
#> ERR184066     2  0.6464     0.1549 0.360 0.484 0.000 0.148 0.008
#> ERR184098     2  0.5845    -0.3479 0.000 0.540 0.000 0.108 0.352
#> ERR184044     2  0.4605     0.4265 0.132 0.772 0.000 0.076 0.020
#> ERR184054     1  0.1478     0.6744 0.936 0.000 0.000 0.064 0.000
#> ERR184085     2  0.5231     0.4131 0.140 0.728 0.000 0.104 0.028
#> ERR184056     2  0.1701     0.4851 0.000 0.936 0.000 0.016 0.048
#> ERR184052     2  0.4956    -0.2349 0.000 0.636 0.000 0.048 0.316
#> ERR184070     2  0.4268    -0.5348 0.000 0.556 0.000 0.000 0.444
#> ERR184096     1  0.5777     0.2018 0.676 0.000 0.040 0.192 0.092
#> ERR184089     2  0.9117    -0.1783 0.076 0.360 0.152 0.124 0.288
#> ERR184049     2  0.1408     0.4880 0.000 0.948 0.000 0.008 0.044
#> ERR184038     2  0.5407     0.3887 0.196 0.680 0.000 0.116 0.008
#> ERR184087     3  0.1341     0.8423 0.056 0.000 0.944 0.000 0.000
#> ERR184097     2  0.1701     0.4890 0.000 0.936 0.000 0.016 0.048
#> ERR184094     1  0.3110     0.6365 0.876 0.020 0.000 0.060 0.044
#> ERR184058     5  0.4450     0.6808 0.000 0.488 0.000 0.004 0.508
#> ERR184036     2  0.5392     0.2990 0.256 0.664 0.000 0.060 0.020
#> ERR184046     5  0.4192     0.8167 0.000 0.404 0.000 0.000 0.596
#> ERR184074     1  0.1764     0.6726 0.928 0.000 0.000 0.064 0.008
#> ERR184048     2  0.1493     0.4955 0.000 0.948 0.000 0.024 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     6  0.3586     0.7662 0.280 0.004 0.004 0.000 0.000 0.712
#> ERR184093     2  0.2307     0.4990 0.064 0.900 0.000 0.024 0.012 0.000
#> ERR184051     3  0.1080     0.8787 0.004 0.000 0.960 0.004 0.000 0.032
#> ERR184076     6  0.4027     0.7466 0.236 0.004 0.012 0.008 0.008 0.732
#> ERR184043     3  0.0767     0.8746 0.000 0.000 0.976 0.012 0.008 0.004
#> ERR184037     1  0.5876    -0.1178 0.500 0.012 0.000 0.064 0.032 0.392
#> ERR184059     3  0.3114     0.8056 0.052 0.000 0.864 0.004 0.032 0.048
#> ERR184055     2  0.4184     0.2346 0.488 0.500 0.000 0.000 0.012 0.000
#> ERR184065     4  0.5624     0.2766 0.000 0.356 0.000 0.488 0.156 0.000
#> ERR184069     4  0.4076     0.7304 0.000 0.452 0.000 0.540 0.008 0.000
#> ERR184040     6  0.4584     0.5555 0.428 0.008 0.004 0.000 0.016 0.544
#> ERR184057     2  0.4181    -0.6920 0.012 0.512 0.000 0.476 0.000 0.000
#> ERR184082     2  0.5734     0.2482 0.372 0.524 0.000 0.056 0.004 0.044
#> ERR184083     4  0.4308     0.7393 0.012 0.468 0.000 0.516 0.004 0.000
#> ERR184039     2  0.4710     0.0312 0.004 0.668 0.000 0.244 0.084 0.000
#> ERR184064     3  0.0767     0.8769 0.000 0.000 0.976 0.008 0.012 0.004
#> ERR184081     4  0.3993     0.7359 0.004 0.476 0.000 0.520 0.000 0.000
#> ERR184095     4  0.3998     0.7069 0.004 0.492 0.000 0.504 0.000 0.000
#> ERR184079     2  0.1194     0.5090 0.032 0.956 0.000 0.004 0.008 0.000
#> ERR184084     3  0.7589     0.3054 0.088 0.144 0.476 0.020 0.024 0.248
#> ERR184068     2  0.2067     0.5016 0.064 0.912 0.000 0.016 0.004 0.004
#> ERR184067     2  0.2879     0.2751 0.004 0.816 0.000 0.176 0.004 0.000
#> ERR184071     2  0.0951     0.4937 0.008 0.968 0.000 0.020 0.004 0.000
#> ERR184042     5  0.4690     0.4162 0.056 0.004 0.080 0.000 0.752 0.108
#> ERR184063     3  0.1225     0.8785 0.004 0.000 0.956 0.004 0.004 0.032
#> ERR184091     4  0.5464     0.4299 0.004 0.268 0.000 0.576 0.152 0.000
#> ERR184061     1  0.7574    -0.0851 0.428 0.008 0.016 0.152 0.112 0.284
#> ERR184077     2  0.0748     0.4958 0.004 0.976 0.000 0.016 0.004 0.000
#> ERR184062     2  0.4292     0.2761 0.416 0.568 0.000 0.004 0.008 0.004
#> ERR184053     2  0.1553     0.5043 0.008 0.944 0.000 0.032 0.004 0.012
#> ERR184088     2  0.2326     0.5013 0.092 0.888 0.000 0.012 0.008 0.000
#> ERR184075     2  0.6709    -0.0901 0.000 0.432 0.040 0.360 0.156 0.012
#> ERR184041     3  0.1371     0.8745 0.004 0.000 0.948 0.004 0.004 0.040
#> ERR184060     4  0.3979     0.7434 0.000 0.456 0.000 0.540 0.004 0.000
#> ERR184035     1  0.6432     0.0746 0.520 0.228 0.000 0.016 0.020 0.216
#> ERR184086     2  0.4729     0.0231 0.000 0.656 0.000 0.248 0.096 0.000
#> ERR184080     1  0.4509    -0.2244 0.620 0.016 0.000 0.000 0.020 0.344
#> ERR184050     2  0.5723    -0.1272 0.000 0.460 0.004 0.392 0.144 0.000
#> ERR184047     5  0.5297     0.4867 0.384 0.004 0.000 0.000 0.520 0.092
#> ERR184092     2  0.0508     0.4962 0.004 0.984 0.000 0.012 0.000 0.000
#> ERR184072     1  0.7284    -0.0949 0.436 0.000 0.016 0.152 0.100 0.296
#> ERR184073     1  0.7282    -0.0719 0.476 0.000 0.024 0.116 0.128 0.256
#> ERR184066     1  0.4802    -0.0069 0.588 0.364 0.000 0.004 0.008 0.036
#> ERR184098     2  0.4733     0.0475 0.004 0.668 0.000 0.240 0.088 0.000
#> ERR184044     2  0.4420     0.2935 0.360 0.604 0.000 0.036 0.000 0.000
#> ERR184054     1  0.5650    -0.3119 0.572 0.008 0.020 0.024 0.036 0.340
#> ERR184085     2  0.5176     0.2629 0.388 0.544 0.000 0.052 0.004 0.012
#> ERR184056     2  0.1036     0.5047 0.004 0.964 0.000 0.024 0.008 0.000
#> ERR184052     2  0.3409     0.2578 0.000 0.780 0.000 0.192 0.028 0.000
#> ERR184070     2  0.3881    -0.4351 0.000 0.600 0.000 0.396 0.004 0.000
#> ERR184096     5  0.4925     0.4838 0.448 0.000 0.000 0.008 0.500 0.044
#> ERR184089     2  0.7219    -0.0944 0.000 0.408 0.072 0.340 0.160 0.020
#> ERR184049     2  0.2201     0.4946 0.056 0.904 0.000 0.036 0.004 0.000
#> ERR184038     2  0.4878     0.2431 0.464 0.496 0.000 0.020 0.012 0.008
#> ERR184087     3  0.0665     0.8749 0.000 0.000 0.980 0.008 0.008 0.004
#> ERR184097     2  0.0935     0.5023 0.000 0.964 0.000 0.032 0.004 0.000
#> ERR184094     1  0.7405    -0.1399 0.480 0.044 0.028 0.036 0.124 0.288
#> ERR184058     2  0.4032    -0.4595 0.000 0.572 0.000 0.420 0.008 0.000
#> ERR184036     2  0.4556     0.3976 0.100 0.768 0.000 0.060 0.064 0.008
#> ERR184046     4  0.3982     0.7455 0.004 0.460 0.000 0.536 0.000 0.000
#> ERR184074     1  0.6932    -0.1661 0.476 0.004 0.020 0.108 0.068 0.324
#> ERR184048     2  0.1007     0.5079 0.016 0.968 0.000 0.008 0.004 0.004

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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.


ATC:NMF

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["ATC", "NMF"]
# you can also extract it by
# res = res_list["ATC:NMF"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 10269 rows and 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 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_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower 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)

plot of chunk ATC-NMF-select-partition-number

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.775           0.896       0.954         0.4874 0.511   0.511
#> 3 3 0.532           0.772       0.859         0.3587 0.796   0.609
#> 4 4 0.537           0.593       0.771         0.1167 0.824   0.528
#> 5 5 0.564           0.561       0.750         0.0472 0.946   0.791
#> 6 6 0.615           0.547       0.720         0.0318 0.968   0.859

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows 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 class 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.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> ERR184078     2  0.0000     0.9509 0.000 1.000
#> ERR184093     2  0.0000     0.9509 0.000 1.000
#> ERR184051     1  0.0000     0.9470 1.000 0.000
#> ERR184076     2  0.0000     0.9509 0.000 1.000
#> ERR184043     1  0.0000     0.9470 1.000 0.000
#> ERR184037     2  0.0000     0.9509 0.000 1.000
#> ERR184059     1  0.0000     0.9470 1.000 0.000
#> ERR184055     2  0.0938     0.9474 0.012 0.988
#> ERR184065     1  0.0000     0.9470 1.000 0.000
#> ERR184069     2  0.9977     0.0827 0.472 0.528
#> ERR184040     2  0.0000     0.9509 0.000 1.000
#> ERR184057     2  0.0376     0.9499 0.004 0.996
#> ERR184082     1  0.6148     0.8258 0.848 0.152
#> ERR184083     1  0.0000     0.9470 1.000 0.000
#> ERR184039     1  0.0000     0.9470 1.000 0.000
#> ERR184064     1  0.0000     0.9470 1.000 0.000
#> ERR184081     1  0.6048     0.8298 0.852 0.148
#> ERR184095     2  0.5408     0.8587 0.124 0.876
#> ERR184079     2  0.0000     0.9509 0.000 1.000
#> ERR184084     1  0.0000     0.9470 1.000 0.000
#> ERR184068     2  0.0938     0.9472 0.012 0.988
#> ERR184067     2  0.5059     0.8681 0.112 0.888
#> ERR184071     2  0.9608     0.3747 0.384 0.616
#> ERR184042     1  0.6623     0.8008 0.828 0.172
#> ERR184063     1  0.0000     0.9470 1.000 0.000
#> ERR184091     1  0.0000     0.9470 1.000 0.000
#> ERR184061     2  0.0000     0.9509 0.000 1.000
#> ERR184077     2  0.1184     0.9452 0.016 0.984
#> ERR184062     2  0.0938     0.9473 0.012 0.988
#> ERR184053     2  0.6343     0.8145 0.160 0.840
#> ERR184088     2  0.0000     0.9509 0.000 1.000
#> ERR184075     1  0.0000     0.9470 1.000 0.000
#> ERR184041     1  0.0000     0.9470 1.000 0.000
#> ERR184060     2  0.0672     0.9488 0.008 0.992
#> ERR184035     2  0.0000     0.9509 0.000 1.000
#> ERR184086     1  0.0000     0.9470 1.000 0.000
#> ERR184080     2  0.0000     0.9509 0.000 1.000
#> ERR184050     1  0.0000     0.9470 1.000 0.000
#> ERR184047     2  0.3584     0.9109 0.068 0.932
#> ERR184092     2  0.0000     0.9509 0.000 1.000
#> ERR184072     2  0.0000     0.9509 0.000 1.000
#> ERR184073     2  0.0000     0.9509 0.000 1.000
#> ERR184066     2  0.0000     0.9509 0.000 1.000
#> ERR184098     1  0.0000     0.9470 1.000 0.000
#> ERR184044     2  0.2603     0.9282 0.044 0.956
#> ERR184054     2  0.0000     0.9509 0.000 1.000
#> ERR184085     1  0.7745     0.7112 0.772 0.228
#> ERR184056     2  0.0672     0.9488 0.008 0.992
#> ERR184052     1  0.3431     0.9049 0.936 0.064
#> ERR184070     2  0.0000     0.9509 0.000 1.000
#> ERR184096     2  0.0000     0.9509 0.000 1.000
#> ERR184089     1  0.0000     0.9470 1.000 0.000
#> ERR184049     2  0.2603     0.9285 0.044 0.956
#> ERR184038     1  0.9661     0.3368 0.608 0.392
#> ERR184087     1  0.0000     0.9470 1.000 0.000
#> ERR184097     2  0.3114     0.9206 0.056 0.944
#> ERR184094     2  0.5842     0.8379 0.140 0.860
#> ERR184058     1  0.1843     0.9308 0.972 0.028
#> ERR184036     2  0.0000     0.9509 0.000 1.000
#> ERR184046     1  0.0000     0.9470 1.000 0.000
#> ERR184074     2  0.0000     0.9509 0.000 1.000
#> ERR184048     2  0.0000     0.9509 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> ERR184078     2  0.2878      0.849 0.096 0.904 0.000
#> ERR184093     1  0.5948      0.413 0.640 0.360 0.000
#> ERR184051     3  0.0747      0.893 0.000 0.016 0.984
#> ERR184076     2  0.1753      0.843 0.048 0.952 0.000
#> ERR184043     3  0.0237      0.894 0.000 0.004 0.996
#> ERR184037     1  0.4062      0.770 0.836 0.164 0.000
#> ERR184059     3  0.0747      0.894 0.000 0.016 0.984
#> ERR184055     2  0.5497      0.662 0.292 0.708 0.000
#> ERR184065     3  0.0424      0.894 0.000 0.008 0.992
#> ERR184069     1  0.5357      0.704 0.820 0.064 0.116
#> ERR184040     2  0.3816      0.835 0.148 0.852 0.000
#> ERR184057     2  0.4702      0.735 0.212 0.788 0.000
#> ERR184082     3  0.7279      0.613 0.056 0.292 0.652
#> ERR184083     3  0.5315      0.766 0.012 0.216 0.772
#> ERR184039     3  0.2599      0.875 0.052 0.016 0.932
#> ERR184064     3  0.0424      0.894 0.000 0.008 0.992
#> ERR184081     3  0.7248      0.656 0.068 0.256 0.676
#> ERR184095     2  0.2998      0.823 0.068 0.916 0.016
#> ERR184079     2  0.4842      0.753 0.224 0.776 0.000
#> ERR184084     3  0.3682      0.847 0.008 0.116 0.876
#> ERR184068     2  0.2711      0.846 0.088 0.912 0.000
#> ERR184067     1  0.8093      0.265 0.516 0.416 0.068
#> ERR184071     2  0.3623      0.793 0.032 0.896 0.072
#> ERR184042     3  0.4174      0.849 0.036 0.092 0.872
#> ERR184063     3  0.0424      0.894 0.000 0.008 0.992
#> ERR184091     3  0.0237      0.894 0.000 0.004 0.996
#> ERR184061     1  0.1129      0.791 0.976 0.020 0.004
#> ERR184077     2  0.2165      0.849 0.064 0.936 0.000
#> ERR184062     2  0.3686      0.824 0.140 0.860 0.000
#> ERR184053     2  0.0747      0.827 0.016 0.984 0.000
#> ERR184088     1  0.4842      0.714 0.776 0.224 0.000
#> ERR184075     3  0.0747      0.894 0.000 0.016 0.984
#> ERR184041     3  0.0892      0.893 0.000 0.020 0.980
#> ERR184060     1  0.4293      0.752 0.832 0.164 0.004
#> ERR184035     1  0.6057      0.583 0.656 0.340 0.004
#> ERR184086     3  0.0424      0.893 0.008 0.000 0.992
#> ERR184080     2  0.5678      0.657 0.316 0.684 0.000
#> ERR184050     3  0.2584      0.870 0.064 0.008 0.928
#> ERR184047     1  0.7334      0.547 0.624 0.328 0.048
#> ERR184092     2  0.4796      0.776 0.220 0.780 0.000
#> ERR184072     1  0.2878      0.789 0.904 0.096 0.000
#> ERR184073     1  0.1529      0.792 0.960 0.040 0.000
#> ERR184066     2  0.3340      0.829 0.120 0.880 0.000
#> ERR184098     3  0.0829      0.894 0.004 0.012 0.984
#> ERR184044     1  0.6113      0.583 0.688 0.300 0.012
#> ERR184054     2  0.5706      0.641 0.320 0.680 0.000
#> ERR184085     3  0.8068      0.455 0.316 0.088 0.596
#> ERR184056     2  0.2356      0.851 0.072 0.928 0.000
#> ERR184052     3  0.6105      0.685 0.252 0.024 0.724
#> ERR184070     1  0.0892      0.794 0.980 0.020 0.000
#> ERR184096     1  0.3116      0.796 0.892 0.108 0.000
#> ERR184089     3  0.0000      0.893 0.000 0.000 1.000
#> ERR184049     1  0.3802      0.776 0.888 0.080 0.032
#> ERR184038     2  0.3551      0.743 0.000 0.868 0.132
#> ERR184087     3  0.0000      0.893 0.000 0.000 1.000
#> ERR184097     2  0.1964      0.843 0.056 0.944 0.000
#> ERR184094     1  0.4179      0.774 0.876 0.052 0.072
#> ERR184058     3  0.7683      0.530 0.328 0.064 0.608
#> ERR184036     1  0.0983      0.793 0.980 0.016 0.004
#> ERR184046     3  0.2066      0.882 0.000 0.060 0.940
#> ERR184074     1  0.2796      0.801 0.908 0.092 0.000
#> ERR184048     2  0.3619      0.825 0.136 0.864 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> ERR184078     4  0.2271     0.7885 0.008 0.076 0.000 0.916
#> ERR184093     1  0.5489     0.4585 0.700 0.060 0.000 0.240
#> ERR184051     3  0.0657     0.9041 0.000 0.012 0.984 0.004
#> ERR184076     4  0.1305     0.7909 0.004 0.036 0.000 0.960
#> ERR184043     3  0.0779     0.9009 0.000 0.016 0.980 0.004
#> ERR184037     1  0.6139     0.3430 0.544 0.404 0.000 0.052
#> ERR184059     3  0.0657     0.9048 0.000 0.012 0.984 0.004
#> ERR184055     4  0.6121     0.6278 0.156 0.164 0.000 0.680
#> ERR184065     3  0.1576     0.8884 0.004 0.048 0.948 0.000
#> ERR184069     2  0.6020     0.1660 0.376 0.580 0.040 0.004
#> ERR184040     4  0.3547     0.7842 0.072 0.064 0.000 0.864
#> ERR184057     2  0.5790     0.4806 0.080 0.684 0.000 0.236
#> ERR184082     2  0.4256     0.5772 0.008 0.824 0.128 0.040
#> ERR184083     2  0.5530     0.3998 0.000 0.632 0.336 0.032
#> ERR184039     3  0.5508     0.5567 0.056 0.252 0.692 0.000
#> ERR184064     3  0.0188     0.9044 0.000 0.000 0.996 0.004
#> ERR184081     2  0.5606     0.5532 0.068 0.756 0.148 0.028
#> ERR184095     2  0.3823     0.5460 0.008 0.824 0.008 0.160
#> ERR184079     2  0.6295     0.3304 0.088 0.616 0.000 0.296
#> ERR184084     2  0.5732     0.2876 0.004 0.580 0.392 0.024
#> ERR184068     2  0.6149    -0.2062 0.048 0.480 0.000 0.472
#> ERR184067     2  0.5722     0.4530 0.192 0.724 0.012 0.072
#> ERR184071     2  0.6569    -0.0323 0.008 0.476 0.056 0.460
#> ERR184042     3  0.4587     0.7656 0.020 0.140 0.808 0.032
#> ERR184063     3  0.0376     0.9050 0.000 0.004 0.992 0.004
#> ERR184091     3  0.1557     0.8830 0.000 0.056 0.944 0.000
#> ERR184061     1  0.1902     0.6701 0.932 0.064 0.000 0.004
#> ERR184077     4  0.5343     0.5353 0.028 0.316 0.000 0.656
#> ERR184062     4  0.3204     0.7680 0.064 0.028 0.016 0.892
#> ERR184053     4  0.5270     0.5393 0.012 0.320 0.008 0.660
#> ERR184088     1  0.6337     0.1566 0.472 0.468 0.000 0.060
#> ERR184075     3  0.0592     0.9030 0.000 0.016 0.984 0.000
#> ERR184041     3  0.0524     0.9032 0.000 0.004 0.988 0.008
#> ERR184060     1  0.6170     0.6143 0.700 0.084 0.020 0.196
#> ERR184035     2  0.4379     0.4890 0.172 0.792 0.000 0.036
#> ERR184086     3  0.0657     0.9034 0.004 0.012 0.984 0.000
#> ERR184080     4  0.7241     0.3748 0.196 0.264 0.000 0.540
#> ERR184050     3  0.3027     0.8340 0.088 0.020 0.888 0.004
#> ERR184047     1  0.8713     0.3386 0.444 0.236 0.052 0.268
#> ERR184092     4  0.3806     0.7297 0.156 0.020 0.000 0.824
#> ERR184072     1  0.3372     0.6357 0.868 0.036 0.000 0.096
#> ERR184073     1  0.1635     0.6602 0.948 0.008 0.000 0.044
#> ERR184066     4  0.2207     0.7860 0.056 0.012 0.004 0.928
#> ERR184098     3  0.1114     0.8994 0.008 0.016 0.972 0.004
#> ERR184044     1  0.8069     0.2188 0.468 0.064 0.092 0.376
#> ERR184054     4  0.5432     0.5365 0.316 0.032 0.000 0.652
#> ERR184085     2  0.5993     0.5104 0.144 0.712 0.136 0.008
#> ERR184056     4  0.2480     0.7820 0.008 0.088 0.000 0.904
#> ERR184052     3  0.7453     0.0231 0.192 0.324 0.484 0.000
#> ERR184070     1  0.3751     0.6247 0.800 0.196 0.000 0.004
#> ERR184096     1  0.3463     0.6752 0.864 0.040 0.000 0.096
#> ERR184089     3  0.0188     0.9052 0.000 0.004 0.996 0.000
#> ERR184049     2  0.5795    -0.1184 0.460 0.516 0.008 0.016
#> ERR184038     4  0.3771     0.7306 0.004 0.052 0.088 0.856
#> ERR184087     3  0.0336     0.9047 0.000 0.008 0.992 0.000
#> ERR184097     4  0.1452     0.7900 0.008 0.036 0.000 0.956
#> ERR184094     1  0.6429     0.4283 0.600 0.336 0.040 0.024
#> ERR184058     2  0.6878     0.4350 0.136 0.596 0.264 0.004
#> ERR184036     1  0.3024     0.6484 0.852 0.148 0.000 0.000
#> ERR184046     3  0.3647     0.8324 0.004 0.096 0.860 0.040
#> ERR184074     1  0.4234     0.6727 0.816 0.132 0.000 0.052
#> ERR184048     2  0.4706     0.4836 0.028 0.748 0.000 0.224

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> ERR184078     1  0.3409     0.6886 0.824 0.032 0.000 0.144 0.000
#> ERR184093     5  0.6261     0.3804 0.160 0.008 0.000 0.268 0.564
#> ERR184051     3  0.0324     0.9049 0.004 0.004 0.992 0.000 0.000
#> ERR184076     1  0.1830     0.7458 0.932 0.028 0.000 0.040 0.000
#> ERR184043     3  0.0613     0.9019 0.008 0.000 0.984 0.004 0.004
#> ERR184037     5  0.7079     0.1896 0.124 0.340 0.000 0.056 0.480
#> ERR184059     3  0.1186     0.9028 0.008 0.008 0.964 0.020 0.000
#> ERR184055     1  0.6479     0.4950 0.648 0.100 0.004 0.092 0.156
#> ERR184065     3  0.2068     0.8698 0.000 0.092 0.904 0.004 0.000
#> ERR184069     2  0.4625     0.4034 0.000 0.652 0.004 0.020 0.324
#> ERR184040     1  0.3224     0.7407 0.868 0.028 0.000 0.076 0.028
#> ERR184057     2  0.7129     0.2729 0.236 0.548 0.000 0.088 0.128
#> ERR184082     2  0.3317     0.4748 0.004 0.852 0.056 0.088 0.000
#> ERR184083     2  0.5249     0.3648 0.016 0.712 0.164 0.108 0.000
#> ERR184039     3  0.4905     0.4659 0.000 0.344 0.624 0.008 0.024
#> ERR184064     3  0.0162     0.9051 0.000 0.004 0.996 0.000 0.000
#> ERR184081     2  0.4075     0.5511 0.016 0.836 0.044 0.036 0.068
#> ERR184095     2  0.3575     0.4308 0.056 0.824 0.000 0.120 0.000
#> ERR184079     2  0.7018    -0.1206 0.180 0.536 0.000 0.236 0.048
#> ERR184084     2  0.5240     0.3298 0.000 0.660 0.244 0.096 0.000
#> ERR184068     4  0.7082     0.5132 0.236 0.308 0.004 0.440 0.012
#> ERR184067     2  0.6209     0.4501 0.068 0.640 0.000 0.080 0.212
#> ERR184071     2  0.6953    -0.2600 0.392 0.464 0.044 0.092 0.008
#> ERR184042     3  0.4826     0.7537 0.024 0.160 0.764 0.032 0.020
#> ERR184063     3  0.0486     0.9045 0.004 0.004 0.988 0.004 0.000
#> ERR184091     3  0.2233     0.8590 0.000 0.104 0.892 0.004 0.000
#> ERR184061     5  0.2157     0.5981 0.004 0.036 0.000 0.040 0.920
#> ERR184077     4  0.6971     0.6280 0.296 0.252 0.000 0.440 0.012
#> ERR184062     1  0.2930     0.7232 0.880 0.000 0.032 0.076 0.012
#> ERR184053     4  0.6352     0.5517 0.308 0.188 0.000 0.504 0.000
#> ERR184088     2  0.7000     0.0559 0.132 0.472 0.000 0.044 0.352
#> ERR184075     3  0.0609     0.9043 0.000 0.020 0.980 0.000 0.000
#> ERR184041     3  0.0451     0.9037 0.004 0.000 0.988 0.008 0.000
#> ERR184060     5  0.6504     0.3425 0.336 0.028 0.028 0.052 0.556
#> ERR184035     2  0.2264     0.5359 0.004 0.912 0.000 0.024 0.060
#> ERR184086     3  0.1186     0.9035 0.000 0.020 0.964 0.008 0.008
#> ERR184080     1  0.6456     0.4321 0.628 0.172 0.000 0.060 0.140
#> ERR184050     3  0.3280     0.7788 0.000 0.004 0.824 0.012 0.160
#> ERR184047     5  0.8311     0.1993 0.368 0.152 0.076 0.036 0.368
#> ERR184092     1  0.4414     0.6434 0.764 0.000 0.004 0.072 0.160
#> ERR184072     5  0.4958     0.4776 0.084 0.000 0.000 0.224 0.692
#> ERR184073     5  0.4170     0.5201 0.048 0.000 0.000 0.192 0.760
#> ERR184066     1  0.1787     0.7410 0.940 0.000 0.016 0.032 0.012
#> ERR184098     3  0.1347     0.8951 0.020 0.004 0.960 0.008 0.008
#> ERR184044     5  0.8261     0.2401 0.340 0.044 0.100 0.100 0.416
#> ERR184054     1  0.5355     0.5725 0.704 0.008 0.004 0.148 0.136
#> ERR184085     2  0.3586     0.5426 0.000 0.848 0.080 0.024 0.048
#> ERR184056     1  0.3019     0.7229 0.864 0.048 0.000 0.088 0.000
#> ERR184052     2  0.6036     0.2998 0.000 0.548 0.356 0.020 0.076
#> ERR184070     5  0.3984     0.5573 0.032 0.152 0.000 0.016 0.800
#> ERR184096     5  0.4844     0.5854 0.152 0.024 0.000 0.072 0.752
#> ERR184089     3  0.0566     0.9053 0.000 0.012 0.984 0.000 0.004
#> ERR184049     2  0.6168     0.1467 0.048 0.512 0.000 0.044 0.396
#> ERR184038     1  0.3882     0.6476 0.824 0.016 0.100 0.060 0.000
#> ERR184087     3  0.0854     0.9062 0.000 0.012 0.976 0.008 0.004
#> ERR184097     1  0.2513     0.7232 0.900 0.012 0.008 0.076 0.004
#> ERR184094     5  0.7449     0.2508 0.080 0.300 0.064 0.036 0.520
#> ERR184058     2  0.4112     0.5269 0.000 0.804 0.124 0.016 0.056
#> ERR184036     5  0.2289     0.6012 0.004 0.080 0.000 0.012 0.904
#> ERR184046     3  0.5424     0.6241 0.052 0.220 0.688 0.040 0.000
#> ERR184074     5  0.4797     0.5951 0.116 0.104 0.000 0.020 0.760
#> ERR184048     2  0.4937     0.3595 0.128 0.744 0.000 0.112 0.016

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> ERR184078     1  0.3722     0.7387 0.820 0.044 0.000 0.036 0.004 0.096
#> ERR184093     6  0.5071     0.5543 0.064 0.012 0.000 0.004 0.300 0.620
#> ERR184051     3  0.0508     0.8839 0.004 0.000 0.984 0.012 0.000 0.000
#> ERR184076     1  0.2377     0.7532 0.908 0.008 0.008 0.040 0.004 0.032
#> ERR184043     3  0.0841     0.8832 0.004 0.004 0.976 0.008 0.004 0.004
#> ERR184037     5  0.5693     0.4627 0.088 0.168 0.000 0.036 0.672 0.036
#> ERR184059     3  0.2132     0.8771 0.008 0.020 0.920 0.032 0.000 0.020
#> ERR184055     1  0.7016     0.4492 0.560 0.096 0.004 0.064 0.208 0.068
#> ERR184065     3  0.2270     0.8506 0.000 0.072 0.900 0.020 0.004 0.004
#> ERR184069     2  0.5274     0.2416 0.004 0.516 0.008 0.024 0.424 0.024
#> ERR184040     1  0.3566     0.7524 0.844 0.020 0.004 0.024 0.032 0.076
#> ERR184057     2  0.7565     0.0809 0.240 0.348 0.000 0.056 0.320 0.036
#> ERR184082     2  0.2594     0.5298 0.004 0.900 0.036 0.024 0.008 0.028
#> ERR184083     2  0.3879     0.4635 0.004 0.792 0.144 0.036 0.000 0.024
#> ERR184039     3  0.5598     0.3476 0.000 0.320 0.572 0.020 0.080 0.008
#> ERR184064     3  0.0551     0.8846 0.004 0.004 0.984 0.000 0.000 0.008
#> ERR184081     2  0.5006     0.5699 0.024 0.704 0.020 0.012 0.212 0.028
#> ERR184095     2  0.4280     0.5306 0.020 0.796 0.004 0.092 0.064 0.024
#> ERR184079     2  0.7266     0.1671 0.080 0.536 0.000 0.164 0.068 0.152
#> ERR184084     2  0.4681     0.4029 0.008 0.708 0.208 0.064 0.000 0.012
#> ERR184068     6  0.7440    -0.4865 0.104 0.248 0.000 0.320 0.004 0.324
#> ERR184067     2  0.6500     0.1948 0.064 0.456 0.000 0.032 0.396 0.052
#> ERR184071     2  0.7437    -0.0163 0.380 0.416 0.060 0.068 0.040 0.036
#> ERR184042     3  0.5405     0.7259 0.020 0.116 0.732 0.044 0.040 0.048
#> ERR184063     3  0.1129     0.8844 0.004 0.008 0.964 0.012 0.000 0.012
#> ERR184091     3  0.1555     0.8689 0.000 0.060 0.932 0.004 0.000 0.004
#> ERR184061     5  0.2915     0.2828 0.000 0.000 0.000 0.008 0.808 0.184
#> ERR184077     4  0.7268     0.5785 0.160 0.224 0.000 0.464 0.008 0.144
#> ERR184062     1  0.2587     0.7459 0.892 0.000 0.016 0.036 0.004 0.052
#> ERR184053     4  0.4827     0.5987 0.160 0.116 0.008 0.708 0.000 0.008
#> ERR184088     2  0.6975     0.2677 0.128 0.452 0.000 0.008 0.316 0.096
#> ERR184075     3  0.0665     0.8844 0.000 0.008 0.980 0.004 0.000 0.008
#> ERR184041     3  0.1312     0.8812 0.008 0.004 0.956 0.012 0.000 0.020
#> ERR184060     5  0.7728    -0.0529 0.312 0.072 0.016 0.012 0.340 0.248
#> ERR184035     2  0.3459     0.5858 0.008 0.820 0.000 0.004 0.124 0.044
#> ERR184086     3  0.1761     0.8758 0.000 0.008 0.936 0.008 0.016 0.032
#> ERR184080     1  0.5542     0.6004 0.676 0.096 0.000 0.012 0.164 0.052
#> ERR184050     3  0.5034     0.6763 0.004 0.004 0.720 0.036 0.136 0.100
#> ERR184047     5  0.6255     0.2690 0.360 0.060 0.024 0.012 0.516 0.028
#> ERR184092     1  0.5180     0.6421 0.708 0.012 0.000 0.056 0.160 0.064
#> ERR184072     6  0.4694     0.5639 0.024 0.008 0.000 0.008 0.360 0.600
#> ERR184073     6  0.4427     0.5155 0.016 0.008 0.000 0.000 0.412 0.564
#> ERR184066     1  0.1579     0.7601 0.944 0.000 0.004 0.024 0.008 0.020
#> ERR184098     3  0.2296     0.8618 0.024 0.004 0.916 0.016 0.012 0.028
#> ERR184044     5  0.7713     0.2795 0.288 0.032 0.048 0.104 0.464 0.064
#> ERR184054     1  0.5188     0.5502 0.648 0.004 0.000 0.024 0.072 0.252
#> ERR184085     2  0.4709     0.5843 0.004 0.744 0.024 0.044 0.164 0.020
#> ERR184056     1  0.3718     0.7391 0.836 0.060 0.000 0.032 0.028 0.044
#> ERR184052     2  0.5780     0.3719 0.000 0.576 0.292 0.008 0.100 0.024
#> ERR184070     5  0.2593     0.5329 0.012 0.068 0.000 0.000 0.884 0.036
#> ERR184096     5  0.4794     0.1441 0.100 0.000 0.000 0.004 0.668 0.228
#> ERR184089     3  0.1109     0.8853 0.004 0.016 0.964 0.004 0.000 0.012
#> ERR184049     5  0.4402     0.1942 0.016 0.336 0.000 0.000 0.632 0.016
#> ERR184038     1  0.4030     0.6876 0.820 0.004 0.060 0.056 0.020 0.040
#> ERR184087     3  0.1325     0.8849 0.000 0.016 0.956 0.012 0.004 0.012
#> ERR184097     1  0.2102     0.7626 0.920 0.020 0.004 0.032 0.000 0.024
#> ERR184094     5  0.4551     0.4927 0.024 0.172 0.016 0.012 0.752 0.024
#> ERR184058     2  0.4105     0.5911 0.000 0.780 0.048 0.008 0.144 0.020
#> ERR184036     5  0.2563     0.4861 0.000 0.040 0.000 0.004 0.880 0.076
#> ERR184046     3  0.6124     0.5347 0.080 0.196 0.640 0.048 0.016 0.020
#> ERR184074     5  0.3075     0.5438 0.080 0.020 0.000 0.016 0.864 0.020
#> ERR184048     2  0.5403     0.5025 0.048 0.716 0.000 0.044 0.076 0.116

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

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:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

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.

Session info

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 7 (Core)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib64/libblas.so.3.4.2
#> LAPACK: /usr/lib64/liblapack.so.3.4.2
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
#>  [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
#> [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] grid      stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] genefilter_1.66.0    ComplexHeatmap_2.3.1 markdown_1.1         knitr_1.26          
#> [5] GetoptLong_0.1.7     cola_1.3.2          
#> 
#> loaded via a namespace (and not attached):
#>  [1] circlize_0.4.8       shape_1.4.4          xfun_0.11            slam_0.1-46         
#>  [5] lattice_0.20-38      splines_3.6.0        colorspace_1.4-1     vctrs_0.2.0         
#>  [9] stats4_3.6.0         blob_1.2.0           XML_3.98-1.20        survival_2.44-1.1   
#> [13] rlang_0.4.2          pillar_1.4.2         DBI_1.0.0            BiocGenerics_0.30.0 
#> [17] bit64_0.9-7          RColorBrewer_1.1-2   matrixStats_0.55.0   stringr_1.4.0       
#> [21] GlobalOptions_0.1.1  evaluate_0.14        memoise_1.1.0        Biobase_2.44.0      
#> [25] IRanges_2.18.3       parallel_3.6.0       AnnotationDbi_1.46.1 highr_0.8           
#> [29] Rcpp_1.0.3           xtable_1.8-4         backports_1.1.5      S4Vectors_0.22.1    
#> [33] annotate_1.62.0      skmeans_0.2-11       bit_1.1-14           microbenchmark_1.4-7
#> [37] brew_1.0-6           impute_1.58.0        rjson_0.2.20         png_0.1-7           
#> [41] digest_0.6.23        stringi_1.4.3        polyclip_1.10-0      clue_0.3-57         
#> [45] tools_3.6.0          bitops_1.0-6         magrittr_1.5         eulerr_6.0.0        
#> [49] RCurl_1.95-4.12      RSQLite_2.1.4        tibble_2.1.3         cluster_2.1.0       
#> [53] crayon_1.3.4         pkgconfig_2.0.3      zeallot_0.1.0        Matrix_1.2-17       
#> [57] xml2_1.2.2           httr_1.4.1           R6_2.4.1             mclust_5.4.5        
#> [61] compiler_3.6.0