cola Report for GDS807

Date: 2019-12-25 22:17:03 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 21446 rows and 60 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, anno = anno)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 21446    60

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, top_annotation = HeatmapAnnotation(df = get_anno(res_list), 
    col = get_anno_col(res_list)), 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
ATC:kmeans 2 1.000 0.987 0.994 **
ATC:skmeans 2 1.000 0.986 0.993 **
SD:NMF 2 0.894 0.920 0.966
MAD:NMF 2 0.863 0.921 0.966
SD:mclust 5 0.806 0.884 0.897
MAD:mclust 5 0.796 0.829 0.910
SD:skmeans 2 0.758 0.876 0.944
MAD:kmeans 6 0.753 0.794 0.853
MAD:skmeans 2 0.621 0.811 0.922
ATC:pam 3 0.573 0.666 0.861
SD:kmeans 2 0.537 0.772 0.895
ATC:mclust 2 0.514 0.910 0.923
ATC:hclust 5 0.469 0.471 0.745
MAD:pam 4 0.467 0.667 0.803
MAD:hclust 5 0.423 0.568 0.714
CV:kmeans 2 0.418 0.685 0.805
CV:skmeans 2 0.383 0.691 0.847
ATC:NMF 2 0.380 0.747 0.867
CV:NMF 2 0.308 0.595 0.817
SD:hclust 3 0.285 0.622 0.716
CV:hclust 5 0.257 0.452 0.605
CV:pam 2 0.145 0.560 0.796
CV:mclust 3 0.076 0.432 0.650
SD:pam 2 0.075 0.646 0.766

**: 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.8941           0.920       0.966          0.499 0.497   0.497
#> CV:NMF      2 0.3076           0.595       0.817          0.486 0.512   0.512
#> MAD:NMF     2 0.8634           0.921       0.966          0.498 0.501   0.501
#> ATC:NMF     2 0.3797           0.747       0.867          0.500 0.492   0.492
#> SD:skmeans  2 0.7575           0.876       0.944          0.507 0.492   0.492
#> CV:skmeans  2 0.3828           0.691       0.847          0.506 0.492   0.492
#> MAD:skmeans 2 0.6209           0.811       0.922          0.507 0.492   0.492
#> ATC:skmeans 2 1.0000           0.986       0.993          0.504 0.497   0.497
#> SD:mclust   2 0.3095           0.849       0.883          0.353 0.636   0.636
#> CV:mclust   2 0.3076           0.751       0.824          0.366 0.537   0.537
#> MAD:mclust  2 0.7863           0.947       0.956          0.355 0.636   0.636
#> ATC:mclust  2 0.5138           0.910       0.923          0.387 0.587   0.587
#> SD:kmeans   2 0.5372           0.772       0.895          0.458 0.548   0.548
#> CV:kmeans   2 0.4180           0.685       0.805          0.485 0.501   0.501
#> MAD:kmeans  2 0.5238           0.727       0.886          0.470 0.506   0.506
#> ATC:kmeans  2 1.0000           0.987       0.994          0.456 0.548   0.548
#> SD:pam      2 0.0746           0.646       0.766          0.465 0.494   0.494
#> CV:pam      2 0.1447           0.560       0.796          0.473 0.512   0.512
#> MAD:pam     2 0.1103           0.422       0.726          0.382 0.587   0.587
#> ATC:pam     2 0.4599           0.886       0.923          0.385 0.619   0.619
#> SD:hclust   2 0.6523           0.881       0.924          0.268 0.790   0.790
#> CV:hclust   2 0.1228           0.412       0.754          0.406 0.560   0.560
#> MAD:hclust  2 0.3778           0.701       0.853          0.350 0.655   0.655
#> ATC:hclust  2 0.4373           0.721       0.872          0.405 0.548   0.548
get_stats(res_list, k = 3)
#>             k  1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.7168           0.792       0.901          0.348 0.731   0.506
#> CV:NMF      3 0.2519           0.482       0.717          0.360 0.692   0.461
#> MAD:NMF     3 0.5833           0.751       0.871          0.347 0.720   0.493
#> ATC:NMF     3 0.4561           0.649       0.830          0.323 0.656   0.410
#> SD:skmeans  3 0.5564           0.761       0.864          0.326 0.742   0.522
#> CV:skmeans  3 0.2769           0.314       0.636          0.321 0.790   0.614
#> MAD:skmeans 3 0.5031           0.719       0.843          0.329 0.755   0.539
#> ATC:skmeans 3 0.5551           0.580       0.804          0.300 0.780   0.585
#> SD:mclust   3 0.3647           0.675       0.811          0.637 0.579   0.439
#> CV:mclust   3 0.0764           0.432       0.650          0.512 0.789   0.643
#> MAD:mclust  3 0.3596           0.717       0.781          0.584 0.705   0.541
#> ATC:mclust  3 0.4129           0.825       0.840          0.344 0.873   0.798
#> SD:kmeans   3 0.2964           0.460       0.668          0.352 0.711   0.504
#> CV:kmeans   3 0.1986           0.407       0.638          0.328 0.815   0.647
#> MAD:kmeans  3 0.3158           0.492       0.679          0.364 0.704   0.479
#> ATC:kmeans  3 0.4273           0.581       0.740          0.400 0.746   0.562
#> SD:pam      3 0.2970           0.682       0.820          0.229 0.575   0.380
#> CV:pam      3 0.2381           0.489       0.731          0.346 0.726   0.515
#> MAD:pam     3 0.2287           0.457       0.706          0.549 0.567   0.388
#> ATC:pam     3 0.5733           0.666       0.861          0.554 0.714   0.549
#> SD:hclust   3 0.2851           0.622       0.716          0.922 0.692   0.610
#> CV:hclust   3 0.1291           0.413       0.681          0.456 0.765   0.605
#> MAD:hclust  3 0.2826           0.527       0.687          0.557 0.918   0.876
#> ATC:hclust  3 0.3014           0.488       0.718          0.472 0.734   0.543
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.498           0.524       0.685          0.101 0.821   0.531
#> CV:NMF      4 0.338           0.303       0.621          0.136 0.781   0.448
#> MAD:NMF     4 0.484           0.504       0.684          0.107 0.850   0.595
#> ATC:NMF     4 0.424           0.481       0.721          0.123 0.851   0.589
#> SD:skmeans  4 0.501           0.516       0.731          0.122 0.865   0.621
#> CV:skmeans  4 0.350           0.205       0.550          0.126 0.716   0.390
#> MAD:skmeans 4 0.493           0.485       0.713          0.123 0.858   0.603
#> ATC:skmeans 4 0.554           0.574       0.760          0.131 0.780   0.464
#> SD:mclust   4 0.580           0.479       0.770          0.130 0.753   0.491
#> CV:mclust   4 0.236           0.324       0.566          0.240 0.702   0.419
#> MAD:mclust  4 0.551           0.765       0.846          0.182 0.898   0.749
#> ATC:mclust  4 0.533           0.645       0.782          0.256 0.785   0.615
#> SD:kmeans   4 0.445           0.469       0.685          0.142 0.662   0.318
#> CV:kmeans   4 0.298           0.299       0.572          0.134 0.840   0.595
#> MAD:kmeans  4 0.409           0.419       0.649          0.116 0.684   0.314
#> ATC:kmeans  4 0.492           0.447       0.720          0.149 0.799   0.507
#> SD:pam      4 0.393           0.501       0.744          0.243 0.718   0.447
#> CV:pam      4 0.367           0.344       0.650          0.155 0.797   0.501
#> MAD:pam     4 0.467           0.667       0.803          0.206 0.746   0.448
#> ATC:pam     4 0.599           0.627       0.831          0.117 0.934   0.829
#> SD:hclust   4 0.273           0.380       0.657          0.317 0.662   0.419
#> CV:hclust   4 0.180           0.404       0.598          0.124 0.818   0.604
#> MAD:hclust  4 0.363           0.518       0.709          0.273 0.641   0.417
#> ATC:hclust  4 0.363           0.429       0.677          0.117 0.847   0.621
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.623           0.692       0.799         0.0686 0.846   0.505
#> CV:NMF      5 0.458           0.354       0.600         0.0665 0.798   0.377
#> MAD:NMF     5 0.603           0.633       0.793         0.0714 0.823   0.446
#> ATC:NMF     5 0.539           0.471       0.722         0.0711 0.808   0.393
#> SD:skmeans  5 0.505           0.410       0.666         0.0668 0.832   0.448
#> CV:skmeans  5 0.415           0.248       0.526         0.0677 0.742   0.278
#> MAD:skmeans 5 0.520           0.464       0.689         0.0666 0.864   0.527
#> ATC:skmeans 5 0.631           0.544       0.703         0.0741 0.893   0.627
#> SD:mclust   5 0.806           0.884       0.897         0.1598 0.801   0.437
#> CV:mclust   5 0.353           0.298       0.584         0.1170 0.806   0.439
#> MAD:mclust  5 0.796           0.829       0.910         0.1626 0.856   0.601
#> ATC:mclust  5 0.480           0.500       0.712         0.1364 0.747   0.416
#> SD:kmeans   5 0.588           0.622       0.769         0.0760 0.820   0.526
#> CV:kmeans   5 0.405           0.323       0.561         0.0741 0.858   0.538
#> MAD:kmeans  5 0.607           0.596       0.763         0.0839 0.803   0.442
#> ATC:kmeans  5 0.541           0.371       0.649         0.0757 0.824   0.444
#> SD:pam      5 0.534           0.596       0.746         0.0913 0.860   0.560
#> CV:pam      5 0.501           0.478       0.702         0.0713 0.776   0.343
#> MAD:pam     5 0.592           0.574       0.761         0.0960 0.899   0.651
#> ATC:pam     5 0.584           0.481       0.716         0.1361 0.805   0.480
#> SD:hclust   5 0.355           0.383       0.648         0.0871 0.895   0.704
#> CV:hclust   5 0.257           0.452       0.605         0.0723 0.872   0.662
#> MAD:hclust  5 0.423           0.568       0.714         0.0742 0.914   0.702
#> ATC:hclust  5 0.469           0.471       0.745         0.0845 0.947   0.831
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.685           0.560       0.748         0.0502 0.863   0.465
#> CV:NMF      6 0.538           0.321       0.581         0.0441 0.854   0.422
#> MAD:NMF     6 0.692           0.548       0.771         0.0480 0.905   0.581
#> ATC:NMF     6 0.567           0.426       0.665         0.0424 0.879   0.489
#> SD:skmeans  6 0.575           0.408       0.644         0.0424 0.931   0.671
#> CV:skmeans  6 0.477           0.254       0.524         0.0414 0.866   0.452
#> MAD:skmeans 6 0.576           0.422       0.668         0.0410 0.929   0.664
#> ATC:skmeans 6 0.664           0.573       0.749         0.0439 0.910   0.605
#> SD:mclust   6 0.770           0.802       0.872         0.0569 0.955   0.812
#> CV:mclust   6 0.451           0.273       0.535         0.0526 0.842   0.413
#> MAD:mclust  6 0.756           0.753       0.806         0.0465 0.962   0.832
#> ATC:mclust  6 0.611           0.643       0.755         0.0813 0.909   0.653
#> SD:kmeans   6 0.701           0.749       0.808         0.0601 0.892   0.609
#> CV:kmeans   6 0.503           0.362       0.601         0.0480 0.903   0.593
#> MAD:kmeans  6 0.753           0.794       0.853         0.0492 0.881   0.559
#> ATC:kmeans  6 0.632           0.399       0.598         0.0468 0.819   0.357
#> SD:pam      6 0.672           0.577       0.750         0.0590 0.854   0.447
#> CV:pam      6 0.517           0.228       0.606         0.0352 0.853   0.451
#> MAD:pam     6 0.841           0.794       0.909         0.0544 0.876   0.506
#> ATC:pam     6 0.658           0.600       0.795         0.0790 0.833   0.415
#> SD:hclust   6 0.444           0.392       0.649         0.0496 0.883   0.597
#> CV:hclust   6 0.350           0.364       0.588         0.0620 0.879   0.636
#> MAD:hclust  6 0.463           0.570       0.726         0.0394 0.969   0.862
#> ATC:hclust  6 0.486           0.438       0.713         0.0512 0.985   0.946

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

Test to known annotations

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res_list, k = 2)
#>              n disease.state(p) k
#> SD:NMF      58            0.205 2
#> CV:NMF      51            0.294 2
#> MAD:NMF     59            0.256 2
#> ATC:NMF     56            0.104 2
#> SD:skmeans  56            0.292 2
#> CV:skmeans  56            0.399 2
#> MAD:skmeans 51            0.125 2
#> ATC:skmeans 60            0.107 2
#> SD:mclust   59            0.954 2
#> CV:mclust   55            0.561 2
#> MAD:mclust  60            1.000 2
#> ATC:mclust  59            0.872 2
#> SD:kmeans   53            0.323 2
#> CV:kmeans   58            0.256 2
#> MAD:kmeans  50            0.421 2
#> ATC:kmeans  60            0.647 2
#> SD:pam      55            0.139 2
#> CV:pam      49            1.000 2
#> MAD:pam     38            0.558 2
#> ATC:pam     59            0.827 2
#> SD:hclust   59            0.129 2
#> CV:hclust   37            0.347 2
#> MAD:hclust  51            0.604 2
#> ATC:hclust  50            0.623 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) k
#> SD:NMF      55           0.2415 3
#> CV:NMF      40           0.9260 3
#> MAD:NMF     54           0.2636 3
#> ATC:NMF     49           0.1199 3
#> SD:skmeans  55           0.5919 3
#> CV:skmeans   5               NA 3
#> MAD:skmeans 51           0.5107 3
#> ATC:skmeans 45           0.0666 3
#> SD:mclust   47           0.4888 3
#> CV:mclust   30           0.2412 3
#> MAD:mclust  57           0.9044 3
#> ATC:mclust  59           0.7187 3
#> SD:kmeans   34           0.4639 3
#> CV:kmeans   28           0.0689 3
#> MAD:kmeans  33           0.2752 3
#> ATC:kmeans  41           0.0639 3
#> SD:pam      54           0.1299 3
#> CV:pam      33           0.5196 3
#> MAD:pam     31           0.1475 3
#> ATC:pam     47           0.7840 3
#> SD:hclust   51           0.1610 3
#> CV:hclust   27           0.1958 3
#> MAD:hclust  41           0.0657 3
#> ATC:hclust  36           0.1061 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) k
#> SD:NMF      43           0.8719 4
#> CV:NMF      12           0.0811 4
#> MAD:NMF     38           0.3167 4
#> ATC:NMF     34           0.3014 4
#> SD:skmeans  35           0.4576 4
#> CV:skmeans   2               NA 4
#> MAD:skmeans 33           0.1461 4
#> ATC:skmeans 45           0.2996 4
#> SD:mclust   33           0.1243 4
#> CV:mclust    7           1.0000 4
#> MAD:mclust  55           0.2092 4
#> ATC:mclust  53           0.3071 4
#> SD:kmeans   35           0.8798 4
#> CV:kmeans    7           1.0000 4
#> MAD:kmeans  29           0.1157 4
#> ATC:kmeans  31           0.4297 4
#> SD:pam      39           0.2968 4
#> CV:pam      21           0.3247 4
#> MAD:pam     51           0.2332 4
#> ATC:pam     47           0.6390 4
#> SD:hclust   23           0.0243 4
#> CV:hclust   27           0.8373 4
#> MAD:hclust  33           0.1008 4
#> ATC:hclust  24           0.6650 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) k
#> SD:NMF      52           0.5183 5
#> CV:NMF      21           0.2063 5
#> MAD:NMF     50           0.6425 5
#> ATC:NMF     29           0.6105 5
#> SD:skmeans  27           0.2695 5
#> CV:skmeans   0               NA 5
#> MAD:skmeans 29           0.4431 5
#> ATC:skmeans 37           0.3336 5
#> SD:mclust   59           0.0587 5
#> CV:mclust    6           0.3012 5
#> MAD:mclust  57           0.1045 5
#> ATC:mclust  39           0.6266 5
#> SD:kmeans   41           0.4512 5
#> CV:kmeans   10           0.2512 5
#> MAD:kmeans  47           0.3783 5
#> ATC:kmeans  30           0.9274 5
#> SD:pam      45           0.4365 5
#> CV:pam      34           0.4587 5
#> MAD:pam     37           0.2874 5
#> ATC:pam     37           0.7076 5
#> SD:hclust   27           0.0825 5
#> CV:hclust   26           0.0676 5
#> MAD:hclust  43           0.0943 5
#> ATC:hclust  37           0.6777 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) k
#> SD:NMF      39           0.2506 6
#> CV:NMF      12           0.3006 6
#> MAD:NMF     37           0.6133 6
#> ATC:NMF     25           0.7653 6
#> SD:skmeans  25           0.5177 6
#> CV:skmeans   6           1.0000 6
#> MAD:skmeans 26           0.6532 6
#> ATC:skmeans 44           0.5104 6
#> SD:mclust   54           0.1978 6
#> CV:mclust    7           0.4594 6
#> MAD:mclust  54           0.2801 6
#> ATC:mclust  53           0.7016 6
#> SD:kmeans   57           0.3734 6
#> CV:kmeans   12           0.0965 6
#> MAD:kmeans  55           0.4154 6
#> ATC:kmeans  24           0.7312 6
#> SD:pam      42           0.3153 6
#> CV:pam      10           0.6283 6
#> MAD:pam     53           0.1551 6
#> ATC:pam     45           0.5411 6
#> SD:hclust   26           0.0403 6
#> CV:hclust   24           0.8694 6
#> MAD:hclust  40           0.0158 6
#> ATC:hclust  31           0.4210 6

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 21446 rows and 60 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.652           0.881       0.924         0.2678 0.790   0.790
#> 3 3 0.285           0.622       0.716         0.9216 0.692   0.610
#> 4 4 0.273           0.380       0.657         0.3167 0.662   0.419
#> 5 5 0.355           0.383       0.648         0.0871 0.895   0.704
#> 6 6 0.444           0.392       0.649         0.0496 0.883   0.597

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
#> GSM22369     1  0.8016      0.777 0.756 0.244
#> GSM22374     1  0.0376      0.921 0.996 0.004
#> GSM22381     1  0.3274      0.919 0.940 0.060
#> GSM22382     1  0.8016      0.777 0.756 0.244
#> GSM22384     1  0.5519      0.882 0.872 0.128
#> GSM22385     1  0.0376      0.921 0.996 0.004
#> GSM22387     1  0.0376      0.921 0.996 0.004
#> GSM22388     1  0.0376      0.921 0.996 0.004
#> GSM22390     1  0.4161      0.912 0.916 0.084
#> GSM22392     1  0.2603      0.922 0.956 0.044
#> GSM22393     1  0.0376      0.921 0.996 0.004
#> GSM22394     1  0.3114      0.921 0.944 0.056
#> GSM22397     1  0.0376      0.921 0.996 0.004
#> GSM22400     1  0.3274      0.919 0.940 0.060
#> GSM22401     1  0.7883      0.790 0.764 0.236
#> GSM22403     1  0.0938      0.924 0.988 0.012
#> GSM22404     1  0.8016      0.777 0.756 0.244
#> GSM22405     1  0.8909      0.686 0.692 0.308
#> GSM22406     1  0.0938      0.922 0.988 0.012
#> GSM22408     1  0.1184      0.925 0.984 0.016
#> GSM22409     1  0.4022      0.913 0.920 0.080
#> GSM22410     1  0.4562      0.905 0.904 0.096
#> GSM22413     1  0.3431      0.918 0.936 0.064
#> GSM22414     1  0.3274      0.919 0.940 0.060
#> GSM22417     1  0.2423      0.923 0.960 0.040
#> GSM22418     1  0.0376      0.921 0.996 0.004
#> GSM22419     1  0.0376      0.921 0.996 0.004
#> GSM22420     1  0.0376      0.921 0.996 0.004
#> GSM22421     2  0.0376      0.923 0.004 0.996
#> GSM22422     1  0.7299      0.827 0.796 0.204
#> GSM22423     1  0.4562      0.905 0.904 0.096
#> GSM22424     1  0.0376      0.921 0.996 0.004
#> GSM22365     2  0.0376      0.923 0.004 0.996
#> GSM22366     1  0.7299      0.825 0.796 0.204
#> GSM22367     1  0.8327      0.756 0.736 0.264
#> GSM22368     1  0.3114      0.923 0.944 0.056
#> GSM22370     1  0.0938      0.924 0.988 0.012
#> GSM22371     2  0.0376      0.923 0.004 0.996
#> GSM22372     1  0.4690      0.904 0.900 0.100
#> GSM22373     1  0.1414      0.924 0.980 0.020
#> GSM22375     1  0.2423      0.922 0.960 0.040
#> GSM22376     1  0.3274      0.919 0.940 0.060
#> GSM22377     1  0.0000      0.922 1.000 0.000
#> GSM22378     2  0.0376      0.923 0.004 0.996
#> GSM22379     2  0.0376      0.923 0.004 0.996
#> GSM22380     1  0.6531      0.855 0.832 0.168
#> GSM22383     1  0.0376      0.921 0.996 0.004
#> GSM22386     2  0.9732      0.205 0.404 0.596
#> GSM22389     1  0.2603      0.922 0.956 0.044
#> GSM22391     1  0.8813      0.643 0.700 0.300
#> GSM22395     1  0.1633      0.925 0.976 0.024
#> GSM22396     1  0.3431      0.918 0.936 0.064
#> GSM22398     1  0.1184      0.922 0.984 0.016
#> GSM22399     1  0.0376      0.921 0.996 0.004
#> GSM22402     2  0.0938      0.918 0.012 0.988
#> GSM22407     1  0.3584      0.917 0.932 0.068
#> GSM22411     1  0.7674      0.790 0.776 0.224
#> GSM22412     1  0.2236      0.925 0.964 0.036
#> GSM22415     1  0.0376      0.923 0.996 0.004
#> GSM22416     1  0.0376      0.921 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3  0.4349      0.725 0.128 0.020 0.852
#> GSM22374     1  0.2879      0.682 0.924 0.024 0.052
#> GSM22381     1  0.6018      0.642 0.684 0.008 0.308
#> GSM22382     3  0.4349      0.725 0.128 0.020 0.852
#> GSM22384     3  0.6814      0.470 0.372 0.020 0.608
#> GSM22385     1  0.1031      0.680 0.976 0.000 0.024
#> GSM22387     1  0.1031      0.681 0.976 0.000 0.024
#> GSM22388     1  0.2879      0.682 0.924 0.024 0.052
#> GSM22390     1  0.6796      0.517 0.612 0.020 0.368
#> GSM22392     1  0.6404      0.554 0.644 0.012 0.344
#> GSM22393     1  0.1525      0.679 0.964 0.004 0.032
#> GSM22394     1  0.5881      0.667 0.728 0.016 0.256
#> GSM22397     1  0.6452      0.669 0.712 0.036 0.252
#> GSM22400     1  0.6075      0.637 0.676 0.008 0.316
#> GSM22401     3  0.4915      0.693 0.184 0.012 0.804
#> GSM22403     1  0.3454      0.696 0.888 0.008 0.104
#> GSM22404     3  0.4349      0.725 0.128 0.020 0.852
#> GSM22405     3  0.2680      0.598 0.008 0.068 0.924
#> GSM22406     1  0.5318      0.682 0.780 0.016 0.204
#> GSM22408     1  0.6880      0.636 0.660 0.036 0.304
#> GSM22409     1  0.6793      0.406 0.536 0.012 0.452
#> GSM22410     1  0.6410      0.415 0.576 0.004 0.420
#> GSM22413     1  0.6129      0.632 0.668 0.008 0.324
#> GSM22414     1  0.6047      0.638 0.680 0.008 0.312
#> GSM22417     3  0.6661      0.243 0.400 0.012 0.588
#> GSM22418     1  0.0592      0.667 0.988 0.000 0.012
#> GSM22419     1  0.0424      0.669 0.992 0.000 0.008
#> GSM22420     1  0.2879      0.682 0.924 0.024 0.052
#> GSM22421     2  0.2448      0.878 0.000 0.924 0.076
#> GSM22422     3  0.6698      0.592 0.280 0.036 0.684
#> GSM22423     1  0.6421      0.408 0.572 0.004 0.424
#> GSM22424     1  0.1711      0.678 0.960 0.008 0.032
#> GSM22365     2  0.1529      0.897 0.000 0.960 0.040
#> GSM22366     3  0.6307      0.418 0.328 0.012 0.660
#> GSM22367     3  0.1919      0.657 0.020 0.024 0.956
#> GSM22368     3  0.5958      0.558 0.300 0.008 0.692
#> GSM22370     1  0.3454      0.696 0.888 0.008 0.104
#> GSM22371     2  0.1529      0.897 0.000 0.960 0.040
#> GSM22372     1  0.6683      0.252 0.500 0.008 0.492
#> GSM22373     1  0.5816      0.686 0.752 0.024 0.224
#> GSM22375     1  0.6404      0.570 0.644 0.012 0.344
#> GSM22376     1  0.5988      0.643 0.688 0.008 0.304
#> GSM22377     1  0.5708      0.683 0.768 0.028 0.204
#> GSM22378     2  0.1529      0.897 0.000 0.960 0.040
#> GSM22379     2  0.1529      0.897 0.000 0.960 0.040
#> GSM22380     3  0.6448      0.545 0.328 0.016 0.656
#> GSM22383     1  0.1525      0.679 0.964 0.004 0.032
#> GSM22386     2  0.9243      0.052 0.264 0.528 0.208
#> GSM22389     1  0.6427      0.546 0.640 0.012 0.348
#> GSM22391     1  0.9502      0.216 0.492 0.236 0.272
#> GSM22395     1  0.6543      0.580 0.640 0.016 0.344
#> GSM22396     1  0.6229      0.616 0.652 0.008 0.340
#> GSM22398     3  0.5873      0.536 0.312 0.004 0.684
#> GSM22399     1  0.2879      0.682 0.924 0.024 0.052
#> GSM22402     2  0.1964      0.888 0.000 0.944 0.056
#> GSM22407     1  0.6318      0.598 0.636 0.008 0.356
#> GSM22411     3  0.3406      0.678 0.068 0.028 0.904
#> GSM22412     1  0.5618      0.687 0.732 0.008 0.260
#> GSM22415     1  0.6632      0.658 0.692 0.036 0.272
#> GSM22416     1  0.1267      0.679 0.972 0.004 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.5590    -0.1881 0.008 0.008 0.480 0.504
#> GSM22374     1  0.6376     0.6295 0.680 0.012 0.120 0.188
#> GSM22381     4  0.4372     0.2981 0.268 0.004 0.000 0.728
#> GSM22382     4  0.5590    -0.1881 0.008 0.008 0.480 0.504
#> GSM22384     4  0.7081    -0.0534 0.136 0.000 0.352 0.512
#> GSM22385     1  0.4770     0.5958 0.700 0.000 0.012 0.288
#> GSM22387     1  0.3583     0.6579 0.816 0.000 0.004 0.180
#> GSM22388     1  0.6376     0.6295 0.680 0.012 0.120 0.188
#> GSM22390     4  0.7481     0.0977 0.316 0.000 0.200 0.484
#> GSM22392     4  0.7458     0.0999 0.380 0.000 0.176 0.444
#> GSM22393     1  0.1938     0.6133 0.936 0.000 0.012 0.052
#> GSM22394     4  0.5864    -0.1642 0.484 0.004 0.024 0.488
#> GSM22397     4  0.7085     0.2465 0.300 0.000 0.156 0.544
#> GSM22400     4  0.4283     0.3132 0.256 0.004 0.000 0.740
#> GSM22401     4  0.4790     0.0370 0.000 0.000 0.380 0.620
#> GSM22403     1  0.5447     0.3193 0.528 0.004 0.008 0.460
#> GSM22404     4  0.5590    -0.1881 0.008 0.008 0.480 0.504
#> GSM22405     3  0.4556     0.6322 0.004 0.068 0.808 0.120
#> GSM22406     1  0.6729     0.2236 0.572 0.000 0.116 0.312
#> GSM22408     4  0.6422     0.3241 0.248 0.000 0.120 0.632
#> GSM22409     4  0.1124     0.4501 0.012 0.004 0.012 0.972
#> GSM22410     4  0.5332     0.4073 0.184 0.000 0.080 0.736
#> GSM22413     4  0.4252     0.3147 0.252 0.004 0.000 0.744
#> GSM22414     4  0.4343     0.3055 0.264 0.004 0.000 0.732
#> GSM22417     3  0.7681     0.2317 0.216 0.000 0.404 0.380
#> GSM22418     1  0.2101     0.6049 0.928 0.000 0.012 0.060
#> GSM22419     1  0.3718     0.6662 0.820 0.000 0.012 0.168
#> GSM22420     1  0.6376     0.6295 0.680 0.012 0.120 0.188
#> GSM22421     2  0.1677     0.8766 0.000 0.948 0.040 0.012
#> GSM22422     4  0.5809     0.1753 0.020 0.028 0.284 0.668
#> GSM22423     4  0.5291     0.4103 0.180 0.000 0.080 0.740
#> GSM22424     1  0.2300     0.6160 0.920 0.000 0.016 0.064
#> GSM22365     2  0.0469     0.8976 0.000 0.988 0.000 0.012
#> GSM22366     4  0.4053     0.3004 0.000 0.004 0.228 0.768
#> GSM22367     3  0.4132     0.6343 0.012 0.008 0.804 0.176
#> GSM22368     3  0.7347     0.5335 0.252 0.004 0.548 0.196
#> GSM22370     1  0.5447     0.3193 0.528 0.004 0.008 0.460
#> GSM22371     2  0.0707     0.8953 0.000 0.980 0.000 0.020
#> GSM22372     4  0.5102     0.4213 0.136 0.000 0.100 0.764
#> GSM22373     1  0.6945     0.1790 0.552 0.000 0.136 0.312
#> GSM22375     1  0.7475    -0.1699 0.420 0.000 0.176 0.404
#> GSM22376     4  0.4401     0.2936 0.272 0.004 0.000 0.724
#> GSM22377     4  0.7492     0.1353 0.340 0.004 0.168 0.488
#> GSM22378     2  0.0469     0.8976 0.000 0.988 0.000 0.012
#> GSM22379     2  0.0469     0.8976 0.000 0.988 0.000 0.012
#> GSM22380     4  0.6126     0.1685 0.064 0.004 0.300 0.632
#> GSM22383     1  0.3249     0.6588 0.852 0.000 0.008 0.140
#> GSM22386     2  0.7932     0.2672 0.092 0.544 0.072 0.292
#> GSM22389     4  0.7458     0.0933 0.380 0.000 0.176 0.444
#> GSM22391     4  0.9269     0.0411 0.232 0.248 0.104 0.416
#> GSM22395     4  0.6835     0.2795 0.316 0.000 0.124 0.560
#> GSM22396     4  0.4053     0.3413 0.228 0.004 0.000 0.768
#> GSM22398     3  0.6664     0.5554 0.308 0.000 0.580 0.112
#> GSM22399     1  0.6376     0.6295 0.680 0.012 0.120 0.188
#> GSM22402     2  0.1256     0.8846 0.000 0.964 0.008 0.028
#> GSM22407     4  0.4722     0.3494 0.228 0.004 0.020 0.748
#> GSM22411     3  0.4285     0.6515 0.040 0.000 0.804 0.156
#> GSM22412     4  0.6197     0.0587 0.400 0.000 0.056 0.544
#> GSM22415     4  0.6890     0.2790 0.268 0.000 0.152 0.580
#> GSM22416     1  0.3300     0.6561 0.848 0.000 0.008 0.144

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     4  0.4846    -0.0382 0.004 0.008 0.004 0.512 0.472
#> GSM22374     1  0.5531     0.5786 0.704 0.000 0.160 0.036 0.100
#> GSM22381     4  0.3928     0.3521 0.296 0.000 0.004 0.700 0.000
#> GSM22382     4  0.4846    -0.0382 0.004 0.008 0.004 0.512 0.472
#> GSM22384     4  0.7489    -0.1041 0.128 0.000 0.088 0.440 0.344
#> GSM22385     1  0.5245     0.5647 0.704 0.000 0.104 0.180 0.012
#> GSM22387     1  0.3395     0.6032 0.844 0.000 0.104 0.048 0.004
#> GSM22388     1  0.5531     0.5786 0.704 0.000 0.160 0.036 0.100
#> GSM22390     4  0.8344    -0.4081 0.140 0.000 0.292 0.328 0.240
#> GSM22392     4  0.8433    -0.3926 0.192 0.000 0.308 0.312 0.188
#> GSM22393     1  0.3792     0.5313 0.792 0.000 0.180 0.020 0.008
#> GSM22394     1  0.5762     0.2451 0.564 0.004 0.056 0.364 0.012
#> GSM22397     3  0.4927     0.7141 0.040 0.000 0.696 0.248 0.016
#> GSM22400     4  0.3838     0.3691 0.280 0.000 0.004 0.716 0.000
#> GSM22401     4  0.4375     0.1647 0.004 0.000 0.004 0.628 0.364
#> GSM22403     1  0.4752     0.2507 0.568 0.000 0.020 0.412 0.000
#> GSM22404     4  0.4846    -0.0382 0.004 0.008 0.004 0.512 0.472
#> GSM22405     5  0.3582     0.6410 0.000 0.080 0.008 0.072 0.840
#> GSM22406     1  0.8035    -0.1601 0.376 0.000 0.312 0.208 0.104
#> GSM22408     3  0.4739     0.6899 0.012 0.000 0.652 0.320 0.016
#> GSM22409     4  0.1471     0.3979 0.024 0.000 0.020 0.952 0.004
#> GSM22410     4  0.5462     0.4028 0.212 0.000 0.032 0.688 0.068
#> GSM22413     4  0.3838     0.3668 0.280 0.000 0.004 0.716 0.000
#> GSM22414     4  0.3906     0.3582 0.292 0.000 0.004 0.704 0.000
#> GSM22417     5  0.8009     0.2139 0.136 0.000 0.168 0.272 0.424
#> GSM22418     1  0.4478     0.4938 0.724 0.000 0.240 0.020 0.016
#> GSM22419     1  0.3439     0.6256 0.848 0.000 0.104 0.028 0.020
#> GSM22420     1  0.5531     0.5786 0.704 0.000 0.160 0.036 0.100
#> GSM22421     2  0.5354     0.7163 0.024 0.724 0.184 0.024 0.044
#> GSM22422     4  0.4870     0.2637 0.016 0.028 0.000 0.680 0.276
#> GSM22423     4  0.5432     0.4038 0.208 0.000 0.032 0.692 0.068
#> GSM22424     1  0.3881     0.5352 0.788 0.000 0.180 0.024 0.008
#> GSM22365     2  0.0000     0.8724 0.000 1.000 0.000 0.000 0.000
#> GSM22366     4  0.3883     0.3561 0.016 0.000 0.004 0.764 0.216
#> GSM22367     5  0.3023     0.6368 0.004 0.008 0.004 0.132 0.852
#> GSM22368     5  0.7107     0.5640 0.216 0.008 0.056 0.156 0.564
#> GSM22370     1  0.4752     0.2507 0.568 0.000 0.020 0.412 0.000
#> GSM22371     2  0.0290     0.8696 0.000 0.992 0.000 0.008 0.000
#> GSM22372     4  0.5001     0.3789 0.088 0.000 0.076 0.764 0.072
#> GSM22373     1  0.7979    -0.2020 0.352 0.000 0.348 0.204 0.096
#> GSM22375     3  0.8359     0.3034 0.204 0.000 0.368 0.252 0.176
#> GSM22376     4  0.3949     0.3478 0.300 0.000 0.004 0.696 0.000
#> GSM22377     3  0.5651     0.6528 0.084 0.000 0.676 0.208 0.032
#> GSM22378     2  0.0000     0.8724 0.000 1.000 0.000 0.000 0.000
#> GSM22379     2  0.0000     0.8724 0.000 1.000 0.000 0.000 0.000
#> GSM22380     4  0.5777     0.2349 0.056 0.004 0.024 0.620 0.296
#> GSM22383     1  0.1764     0.6308 0.940 0.000 0.012 0.036 0.012
#> GSM22386     2  0.7637     0.2841 0.036 0.556 0.120 0.208 0.080
#> GSM22389     4  0.8433    -0.3916 0.192 0.000 0.308 0.312 0.188
#> GSM22391     4  0.9395    -0.3374 0.088 0.260 0.236 0.304 0.112
#> GSM22395     3  0.7439     0.5150 0.108 0.000 0.464 0.324 0.104
#> GSM22396     4  0.3662     0.3921 0.252 0.000 0.004 0.744 0.000
#> GSM22398     5  0.6367     0.5834 0.268 0.000 0.056 0.080 0.596
#> GSM22399     1  0.5531     0.5786 0.704 0.000 0.160 0.036 0.100
#> GSM22402     2  0.0807     0.8597 0.000 0.976 0.000 0.012 0.012
#> GSM22407     4  0.4181     0.4036 0.244 0.000 0.004 0.732 0.020
#> GSM22411     5  0.3613     0.6634 0.024 0.000 0.032 0.104 0.840
#> GSM22412     4  0.7483    -0.0473 0.280 0.000 0.200 0.460 0.060
#> GSM22415     3  0.4657     0.7158 0.020 0.000 0.696 0.268 0.016
#> GSM22416     1  0.1124     0.6307 0.960 0.000 0.004 0.036 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
#> GSM22369     5  0.4487     0.2275 0.004 0.008 0.004 0.484 0.496 0.004
#> GSM22374     1  0.4636     0.6041 0.716 0.000 0.112 0.012 0.000 0.160
#> GSM22381     4  0.3512     0.5623 0.272 0.000 0.008 0.720 0.000 0.000
#> GSM22382     5  0.4487     0.2275 0.004 0.008 0.004 0.484 0.496 0.004
#> GSM22384     4  0.7106    -0.2176 0.116 0.000 0.104 0.392 0.376 0.012
#> GSM22385     1  0.5003     0.5612 0.700 0.000 0.104 0.168 0.004 0.024
#> GSM22387     1  0.2748     0.5964 0.872 0.000 0.092 0.004 0.012 0.020
#> GSM22388     1  0.4636     0.6041 0.716 0.000 0.112 0.012 0.000 0.160
#> GSM22390     3  0.8110     0.4093 0.092 0.000 0.320 0.236 0.292 0.060
#> GSM22392     3  0.8607     0.4551 0.144 0.000 0.300 0.180 0.268 0.108
#> GSM22393     1  0.3762     0.4993 0.760 0.000 0.208 0.004 0.008 0.020
#> GSM22394     1  0.5845     0.2680 0.572 0.004 0.060 0.316 0.036 0.012
#> GSM22397     3  0.2011     0.4369 0.020 0.000 0.912 0.064 0.000 0.004
#> GSM22400     4  0.3421     0.5758 0.256 0.000 0.008 0.736 0.000 0.000
#> GSM22401     4  0.3996    -0.0323 0.000 0.000 0.004 0.604 0.388 0.004
#> GSM22403     1  0.4493     0.0833 0.548 0.000 0.024 0.424 0.004 0.000
#> GSM22404     5  0.4487     0.2275 0.004 0.008 0.004 0.484 0.496 0.004
#> GSM22405     5  0.2094     0.4500 0.000 0.080 0.000 0.020 0.900 0.000
#> GSM22406     1  0.8188    -0.2495 0.344 0.000 0.296 0.132 0.164 0.064
#> GSM22408     3  0.2765     0.4388 0.000 0.000 0.848 0.132 0.004 0.016
#> GSM22409     4  0.0622     0.5158 0.000 0.000 0.008 0.980 0.000 0.012
#> GSM22410     4  0.5189     0.4912 0.208 0.000 0.036 0.668 0.088 0.000
#> GSM22413     4  0.3421     0.5743 0.256 0.000 0.008 0.736 0.000 0.000
#> GSM22414     4  0.3490     0.5672 0.268 0.000 0.008 0.724 0.000 0.000
#> GSM22417     5  0.7674    -0.0665 0.088 0.000 0.132 0.176 0.496 0.108
#> GSM22418     1  0.4428     0.4456 0.688 0.000 0.260 0.000 0.016 0.036
#> GSM22419     1  0.2976     0.6318 0.856 0.000 0.104 0.004 0.012 0.024
#> GSM22420     1  0.4636     0.6041 0.716 0.000 0.112 0.012 0.000 0.160
#> GSM22421     6  0.3840     0.0000 0.000 0.284 0.000 0.000 0.020 0.696
#> GSM22422     4  0.4436     0.1549 0.012 0.028 0.000 0.652 0.308 0.000
#> GSM22423     4  0.5162     0.4907 0.204 0.000 0.036 0.672 0.088 0.000
#> GSM22424     1  0.3679     0.5101 0.764 0.000 0.208 0.004 0.008 0.016
#> GSM22365     2  0.0000     0.6056 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22366     4  0.3189     0.3511 0.000 0.000 0.004 0.760 0.236 0.000
#> GSM22367     5  0.1901     0.5224 0.000 0.008 0.004 0.076 0.912 0.000
#> GSM22368     5  0.6249     0.4050 0.172 0.008 0.024 0.096 0.636 0.064
#> GSM22370     1  0.4493     0.0833 0.548 0.000 0.024 0.424 0.004 0.000
#> GSM22371     2  0.0260     0.6018 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM22372     4  0.4736     0.4717 0.068 0.000 0.080 0.760 0.080 0.012
#> GSM22373     3  0.7893     0.2053 0.324 0.000 0.372 0.112 0.132 0.060
#> GSM22375     3  0.8349     0.4946 0.152 0.000 0.372 0.132 0.244 0.100
#> GSM22376     4  0.3534     0.5583 0.276 0.000 0.008 0.716 0.000 0.000
#> GSM22377     3  0.3357     0.4099 0.064 0.000 0.844 0.040 0.000 0.052
#> GSM22378     2  0.0000     0.6056 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22379     2  0.0000     0.6056 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     4  0.5505     0.0935 0.044 0.004 0.020 0.580 0.336 0.016
#> GSM22383     1  0.1007     0.6377 0.968 0.000 0.004 0.004 0.008 0.016
#> GSM22386     2  0.7293     0.1543 0.008 0.556 0.116 0.164 0.092 0.064
#> GSM22389     3  0.8612     0.4505 0.140 0.000 0.296 0.188 0.268 0.108
#> GSM22391     2  0.9102    -0.3100 0.048 0.260 0.252 0.248 0.124 0.068
#> GSM22395     3  0.7102     0.5347 0.064 0.000 0.540 0.168 0.172 0.056
#> GSM22396     4  0.3245     0.5899 0.228 0.000 0.008 0.764 0.000 0.000
#> GSM22398     5  0.5201     0.3428 0.228 0.000 0.024 0.012 0.668 0.068
#> GSM22399     1  0.4636     0.6041 0.716 0.000 0.112 0.012 0.000 0.160
#> GSM22402     2  0.0692     0.5870 0.000 0.976 0.000 0.004 0.020 0.000
#> GSM22407     4  0.3933     0.5964 0.220 0.000 0.008 0.740 0.032 0.000
#> GSM22411     5  0.2157     0.5009 0.008 0.000 0.028 0.040 0.916 0.008
#> GSM22412     4  0.7562     0.0944 0.260 0.000 0.188 0.436 0.068 0.048
#> GSM22415     3  0.1700     0.4304 0.000 0.000 0.916 0.080 0.000 0.004
#> GSM22416     1  0.0405     0.6401 0.988 0.000 0.000 0.008 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:hclust 59           0.1293 2
#> SD:hclust 51           0.1610 3
#> SD:hclust 23           0.0243 4
#> SD:hclust 27           0.0825 5
#> SD:hclust 26           0.0403 6

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 21446 rows and 60 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 0.537           0.772       0.895         0.4578 0.548   0.548
#> 3 3 0.296           0.460       0.668         0.3520 0.711   0.504
#> 4 4 0.445           0.469       0.685         0.1420 0.662   0.318
#> 5 5 0.588           0.622       0.769         0.0760 0.820   0.526
#> 6 6 0.701           0.749       0.808         0.0601 0.892   0.609

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
#> GSM22369     2  0.2043      0.920 0.032 0.968
#> GSM22374     1  0.0672      0.849 0.992 0.008
#> GSM22381     1  0.0376      0.854 0.996 0.004
#> GSM22382     2  0.2043      0.920 0.032 0.968
#> GSM22384     1  0.7950      0.722 0.760 0.240
#> GSM22385     1  0.2043      0.849 0.968 0.032
#> GSM22387     1  0.0376      0.851 0.996 0.004
#> GSM22388     1  0.0672      0.849 0.992 0.008
#> GSM22390     1  0.7883      0.721 0.764 0.236
#> GSM22392     1  0.0376      0.854 0.996 0.004
#> GSM22393     1  0.0376      0.854 0.996 0.004
#> GSM22394     1  0.9460      0.541 0.636 0.364
#> GSM22397     1  0.0000      0.853 1.000 0.000
#> GSM22400     1  0.1843      0.850 0.972 0.028
#> GSM22401     2  0.2043      0.920 0.032 0.968
#> GSM22403     1  0.2043      0.849 0.968 0.032
#> GSM22404     2  0.2043      0.920 0.032 0.968
#> GSM22405     2  0.0376      0.922 0.004 0.996
#> GSM22406     1  0.0376      0.854 0.996 0.004
#> GSM22408     1  0.6973      0.765 0.812 0.188
#> GSM22409     1  0.9970      0.303 0.532 0.468
#> GSM22410     1  0.5842      0.803 0.860 0.140
#> GSM22413     1  0.2043      0.849 0.968 0.032
#> GSM22414     2  0.2043      0.920 0.032 0.968
#> GSM22417     1  0.8763      0.650 0.704 0.296
#> GSM22418     1  0.0376      0.854 0.996 0.004
#> GSM22419     1  0.0376      0.854 0.996 0.004
#> GSM22420     1  0.0672      0.849 0.992 0.008
#> GSM22421     2  0.0376      0.922 0.004 0.996
#> GSM22422     2  0.0672      0.922 0.008 0.992
#> GSM22423     1  0.9922      0.353 0.552 0.448
#> GSM22424     1  0.0000      0.853 1.000 0.000
#> GSM22365     2  0.0376      0.922 0.004 0.996
#> GSM22366     2  0.4022      0.870 0.080 0.920
#> GSM22367     2  0.0672      0.922 0.008 0.992
#> GSM22368     2  0.2043      0.920 0.032 0.968
#> GSM22370     1  0.2043      0.849 0.968 0.032
#> GSM22371     2  0.0376      0.922 0.004 0.996
#> GSM22372     1  0.9970      0.303 0.532 0.468
#> GSM22373     1  0.0376      0.854 0.996 0.004
#> GSM22375     1  0.5946      0.794 0.856 0.144
#> GSM22376     1  0.8813      0.595 0.700 0.300
#> GSM22377     1  0.0672      0.849 0.992 0.008
#> GSM22378     2  0.0376      0.922 0.004 0.996
#> GSM22379     2  0.0376      0.922 0.004 0.996
#> GSM22380     2  0.9661      0.174 0.392 0.608
#> GSM22383     1  0.0376      0.854 0.996 0.004
#> GSM22386     2  0.0672      0.922 0.008 0.992
#> GSM22389     1  0.7139      0.758 0.804 0.196
#> GSM22391     2  0.9998     -0.227 0.492 0.508
#> GSM22395     1  0.7139      0.758 0.804 0.196
#> GSM22396     1  0.9970      0.303 0.532 0.468
#> GSM22398     1  0.0938      0.853 0.988 0.012
#> GSM22399     1  0.0672      0.849 0.992 0.008
#> GSM22402     2  0.0376      0.922 0.004 0.996
#> GSM22407     1  0.9970      0.303 0.532 0.468
#> GSM22411     2  0.2603      0.911 0.044 0.956
#> GSM22412     1  0.0376      0.854 0.996 0.004
#> GSM22415     1  0.6887      0.770 0.816 0.184
#> GSM22416     1  0.0376      0.854 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.8069     0.6920 0.244 0.636 0.120
#> GSM22374     1  0.5327     0.5457 0.728 0.000 0.272
#> GSM22381     1  0.5623     0.6156 0.716 0.004 0.280
#> GSM22382     2  0.8129     0.6889 0.244 0.632 0.124
#> GSM22384     3  0.7124     0.4208 0.272 0.056 0.672
#> GSM22385     1  0.5902     0.5258 0.680 0.004 0.316
#> GSM22387     1  0.6252     0.5633 0.556 0.000 0.444
#> GSM22388     1  0.5327     0.5457 0.728 0.000 0.272
#> GSM22390     3  0.2492     0.5118 0.048 0.016 0.936
#> GSM22392     3  0.3267     0.3810 0.116 0.000 0.884
#> GSM22393     1  0.6192     0.5827 0.580 0.000 0.420
#> GSM22394     3  0.7328     0.3206 0.344 0.044 0.612
#> GSM22397     3  0.4178     0.2980 0.172 0.000 0.828
#> GSM22400     1  0.5831     0.5505 0.708 0.008 0.284
#> GSM22401     2  0.8129     0.6889 0.244 0.632 0.124
#> GSM22403     1  0.5578     0.5789 0.748 0.012 0.240
#> GSM22404     2  0.8069     0.6920 0.244 0.636 0.120
#> GSM22405     2  0.4357     0.7440 0.080 0.868 0.052
#> GSM22406     3  0.5254     0.0591 0.264 0.000 0.736
#> GSM22408     3  0.2152     0.4990 0.036 0.016 0.948
#> GSM22409     3  0.9641     0.2321 0.356 0.212 0.432
#> GSM22410     3  0.7278     0.0958 0.456 0.028 0.516
#> GSM22413     1  0.5763     0.5719 0.740 0.016 0.244
#> GSM22414     2  0.8339     0.6152 0.204 0.628 0.168
#> GSM22417     3  0.3356     0.5091 0.056 0.036 0.908
#> GSM22418     3  0.5905    -0.2154 0.352 0.000 0.648
#> GSM22419     3  0.6235    -0.4273 0.436 0.000 0.564
#> GSM22420     1  0.5327     0.5457 0.728 0.000 0.272
#> GSM22421     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22422     2  0.4194     0.7548 0.064 0.876 0.060
#> GSM22423     3  0.9544     0.1904 0.388 0.192 0.420
#> GSM22424     1  0.6260     0.5560 0.552 0.000 0.448
#> GSM22365     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22366     2  0.9795     0.3195 0.316 0.428 0.256
#> GSM22367     2  0.6322     0.7369 0.120 0.772 0.108
#> GSM22368     2  0.8094     0.6932 0.240 0.636 0.124
#> GSM22370     1  0.5945     0.5400 0.740 0.024 0.236
#> GSM22371     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22372     3  0.9334     0.3287 0.292 0.200 0.508
#> GSM22373     3  0.3816     0.3404 0.148 0.000 0.852
#> GSM22375     3  0.1525     0.4893 0.032 0.004 0.964
#> GSM22376     1  0.8148     0.3769 0.644 0.156 0.200
#> GSM22377     1  0.6079     0.4512 0.612 0.000 0.388
#> GSM22378     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22379     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22380     3  0.9825     0.1811 0.308 0.268 0.424
#> GSM22383     1  0.6298     0.5832 0.608 0.004 0.388
#> GSM22386     2  0.6451     0.3080 0.004 0.560 0.436
#> GSM22389     3  0.1905     0.5009 0.028 0.016 0.956
#> GSM22391     3  0.6297     0.4685 0.184 0.060 0.756
#> GSM22395     3  0.0983     0.5069 0.004 0.016 0.980
#> GSM22396     3  0.9168     0.3436 0.288 0.184 0.528
#> GSM22398     1  0.7561     0.3386 0.516 0.040 0.444
#> GSM22399     1  0.5327     0.5457 0.728 0.000 0.272
#> GSM22402     2  0.1643     0.7439 0.000 0.956 0.044
#> GSM22407     1  0.9737    -0.2102 0.392 0.224 0.384
#> GSM22411     3  0.9417    -0.2606 0.176 0.384 0.440
#> GSM22412     1  0.6483     0.4918 0.544 0.004 0.452
#> GSM22415     3  0.2492     0.4955 0.048 0.016 0.936
#> GSM22416     1  0.6033     0.6186 0.660 0.004 0.336

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.8078   -0.07650 0.172 0.320 0.028 0.480
#> GSM22374     1  0.4888    0.93143 0.780 0.000 0.124 0.096
#> GSM22381     4  0.5464    0.41602 0.228 0.000 0.064 0.708
#> GSM22382     4  0.8078   -0.07650 0.172 0.320 0.028 0.480
#> GSM22384     4  0.5022    0.47172 0.012 0.004 0.300 0.684
#> GSM22385     4  0.4824    0.50872 0.144 0.000 0.076 0.780
#> GSM22387     3  0.7924   -0.20425 0.332 0.000 0.340 0.328
#> GSM22388     1  0.4780    0.92371 0.788 0.000 0.116 0.096
#> GSM22390     3  0.1624    0.68253 0.020 0.000 0.952 0.028
#> GSM22392     3  0.1406    0.68197 0.016 0.000 0.960 0.024
#> GSM22393     4  0.7802   -0.10704 0.304 0.000 0.276 0.420
#> GSM22394     4  0.4957    0.45440 0.016 0.000 0.300 0.684
#> GSM22397     3  0.2830    0.66482 0.060 0.000 0.900 0.040
#> GSM22400     4  0.5097    0.49293 0.164 0.008 0.060 0.768
#> GSM22401     4  0.8078   -0.07650 0.172 0.320 0.028 0.480
#> GSM22403     4  0.4980    0.47371 0.196 0.004 0.044 0.756
#> GSM22404     4  0.8078   -0.07650 0.172 0.320 0.028 0.480
#> GSM22405     2  0.7369    0.61365 0.168 0.620 0.036 0.176
#> GSM22406     3  0.3833    0.60419 0.080 0.000 0.848 0.072
#> GSM22408     3  0.1733    0.68692 0.028 0.000 0.948 0.024
#> GSM22409     4  0.5080    0.57930 0.016 0.064 0.136 0.784
#> GSM22410     4  0.3573    0.57688 0.016 0.004 0.132 0.848
#> GSM22413     4  0.4598    0.50301 0.160 0.004 0.044 0.792
#> GSM22414     4  0.6214    0.16496 0.000 0.408 0.056 0.536
#> GSM22417     3  0.1724    0.67842 0.020 0.000 0.948 0.032
#> GSM22418     3  0.6885    0.28414 0.196 0.000 0.596 0.208
#> GSM22419     3  0.7719   -0.00481 0.268 0.000 0.448 0.284
#> GSM22420     1  0.4888    0.93143 0.780 0.000 0.124 0.096
#> GSM22421     2  0.0657    0.83741 0.004 0.984 0.012 0.000
#> GSM22422     2  0.5720    0.61778 0.052 0.692 0.008 0.248
#> GSM22423     4  0.4795    0.57942 0.016 0.060 0.120 0.804
#> GSM22424     3  0.7918   -0.18303 0.316 0.000 0.352 0.332
#> GSM22365     2  0.0469    0.83860 0.000 0.988 0.012 0.000
#> GSM22366     4  0.6629    0.41988 0.088 0.140 0.068 0.704
#> GSM22367     2  0.8148    0.47146 0.172 0.512 0.040 0.276
#> GSM22368     4  0.8306   -0.09682 0.172 0.320 0.040 0.468
#> GSM22370     4  0.4800    0.47356 0.196 0.000 0.044 0.760
#> GSM22371     2  0.0469    0.83860 0.000 0.988 0.012 0.000
#> GSM22372     4  0.5363    0.54199 0.000 0.064 0.216 0.720
#> GSM22373     3  0.2319    0.66632 0.040 0.000 0.924 0.036
#> GSM22375     3  0.0188    0.68760 0.000 0.000 0.996 0.004
#> GSM22376     4  0.5339    0.51448 0.156 0.032 0.044 0.768
#> GSM22377     1  0.5742    0.67943 0.648 0.000 0.300 0.052
#> GSM22378     2  0.0469    0.83860 0.000 0.988 0.012 0.000
#> GSM22379     2  0.0469    0.83860 0.000 0.988 0.012 0.000
#> GSM22380     4  0.6455    0.50227 0.056 0.104 0.124 0.716
#> GSM22383     4  0.7486    0.10758 0.272 0.000 0.228 0.500
#> GSM22386     3  0.5906    0.18796 0.008 0.376 0.588 0.028
#> GSM22389     3  0.1284    0.68972 0.012 0.000 0.964 0.024
#> GSM22391     3  0.3962    0.58075 0.028 0.000 0.820 0.152
#> GSM22395     3  0.0592    0.68673 0.000 0.000 0.984 0.016
#> GSM22396     4  0.5321    0.53498 0.000 0.056 0.228 0.716
#> GSM22398     4  0.8084    0.01095 0.260 0.008 0.328 0.404
#> GSM22399     1  0.4888    0.93143 0.780 0.000 0.124 0.096
#> GSM22402     2  0.0469    0.83860 0.000 0.988 0.012 0.000
#> GSM22407     4  0.4416    0.58045 0.020 0.056 0.092 0.832
#> GSM22411     3  0.8764    0.16963 0.172 0.112 0.512 0.204
#> GSM22412     4  0.7241    0.23846 0.196 0.000 0.264 0.540
#> GSM22415     3  0.1929    0.68361 0.036 0.000 0.940 0.024
#> GSM22416     4  0.7357    0.10570 0.296 0.000 0.192 0.512

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.3389     0.7138 0.000 0.116 0.000 0.048 0.836
#> GSM22374     1  0.2351     0.9402 0.896 0.000 0.016 0.088 0.000
#> GSM22381     4  0.1934     0.6107 0.040 0.000 0.008 0.932 0.020
#> GSM22382     5  0.3389     0.7138 0.000 0.116 0.000 0.048 0.836
#> GSM22384     4  0.5883     0.3916 0.000 0.000 0.104 0.508 0.388
#> GSM22385     4  0.3759     0.6289 0.020 0.004 0.024 0.828 0.124
#> GSM22387     4  0.6585     0.2860 0.180 0.000 0.124 0.620 0.076
#> GSM22388     1  0.2351     0.9402 0.896 0.000 0.016 0.088 0.000
#> GSM22390     3  0.0992     0.8556 0.000 0.000 0.968 0.024 0.008
#> GSM22392     3  0.0992     0.8520 0.008 0.000 0.968 0.024 0.000
#> GSM22393     4  0.4885     0.4660 0.108 0.000 0.052 0.768 0.072
#> GSM22394     4  0.5980     0.5207 0.016 0.000 0.092 0.584 0.308
#> GSM22397     3  0.4020     0.8083 0.052 0.004 0.832 0.040 0.072
#> GSM22400     4  0.3554     0.6295 0.020 0.000 0.016 0.828 0.136
#> GSM22401     5  0.3389     0.7138 0.000 0.116 0.000 0.048 0.836
#> GSM22403     4  0.3002     0.6262 0.028 0.000 0.000 0.856 0.116
#> GSM22404     5  0.3389     0.7138 0.000 0.116 0.000 0.048 0.836
#> GSM22405     5  0.4581     0.3208 0.004 0.360 0.012 0.000 0.624
#> GSM22406     3  0.5190     0.6814 0.036 0.004 0.728 0.180 0.052
#> GSM22408     3  0.2760     0.8350 0.028 0.000 0.892 0.016 0.064
#> GSM22409     4  0.5191     0.4908 0.004 0.004 0.040 0.620 0.332
#> GSM22410     4  0.5244     0.4649 0.004 0.004 0.036 0.588 0.368
#> GSM22413     4  0.3602     0.6135 0.024 0.000 0.000 0.796 0.180
#> GSM22414     4  0.7018     0.1593 0.000 0.224 0.016 0.432 0.328
#> GSM22417     3  0.0798     0.8551 0.000 0.000 0.976 0.016 0.008
#> GSM22418     3  0.7427     0.2225 0.108 0.004 0.428 0.380 0.080
#> GSM22419     4  0.6962     0.2953 0.112 0.004 0.216 0.584 0.084
#> GSM22420     1  0.2351     0.9402 0.896 0.000 0.016 0.088 0.000
#> GSM22421     2  0.1530     0.9686 0.028 0.952 0.008 0.004 0.008
#> GSM22422     5  0.5303     0.3173 0.004 0.440 0.000 0.040 0.516
#> GSM22423     4  0.5175     0.4500 0.004 0.000 0.040 0.584 0.372
#> GSM22424     4  0.5971     0.3720 0.104 0.000 0.120 0.688 0.088
#> GSM22365     2  0.0290     0.9903 0.000 0.992 0.000 0.000 0.008
#> GSM22366     5  0.5062    -0.0871 0.004 0.004 0.020 0.420 0.552
#> GSM22367     5  0.3718     0.6129 0.004 0.196 0.016 0.000 0.784
#> GSM22368     5  0.3268     0.7003 0.004 0.112 0.004 0.028 0.852
#> GSM22370     4  0.3193     0.6239 0.028 0.000 0.000 0.840 0.132
#> GSM22371     2  0.0693     0.9866 0.008 0.980 0.000 0.000 0.012
#> GSM22372     4  0.5424     0.4847 0.000 0.004 0.064 0.596 0.336
#> GSM22373     3  0.3684     0.7939 0.028 0.000 0.844 0.076 0.052
#> GSM22375     3  0.0703     0.8562 0.000 0.000 0.976 0.024 0.000
#> GSM22376     4  0.3527     0.6157 0.024 0.000 0.000 0.804 0.172
#> GSM22377     1  0.5544     0.7372 0.720 0.004 0.148 0.072 0.056
#> GSM22378     2  0.0290     0.9903 0.000 0.992 0.000 0.000 0.008
#> GSM22379     2  0.0290     0.9903 0.000 0.992 0.000 0.000 0.008
#> GSM22380     5  0.5238    -0.1914 0.000 0.004 0.036 0.440 0.520
#> GSM22383     4  0.4700     0.5083 0.096 0.004 0.048 0.788 0.064
#> GSM22386     3  0.4323     0.6839 0.008 0.180 0.772 0.008 0.032
#> GSM22389     3  0.0609     0.8556 0.000 0.000 0.980 0.020 0.000
#> GSM22391     3  0.2728     0.8035 0.004 0.004 0.892 0.032 0.068
#> GSM22395     3  0.0671     0.8547 0.000 0.000 0.980 0.016 0.004
#> GSM22396     4  0.5409     0.4851 0.000 0.004 0.064 0.600 0.332
#> GSM22398     4  0.6893     0.0178 0.028 0.000 0.144 0.416 0.412
#> GSM22399     1  0.2351     0.9402 0.896 0.000 0.016 0.088 0.000
#> GSM22402     2  0.0566     0.9883 0.004 0.984 0.000 0.000 0.012
#> GSM22407     4  0.4675     0.4996 0.000 0.004 0.020 0.640 0.336
#> GSM22411     5  0.4251     0.2622 0.004 0.000 0.372 0.000 0.624
#> GSM22412     4  0.2970     0.5968 0.012 0.004 0.100 0.872 0.012
#> GSM22415     3  0.3181     0.8288 0.036 0.004 0.876 0.020 0.064
#> GSM22416     4  0.4129     0.5022 0.112 0.000 0.020 0.808 0.060

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5  0.4567      0.814 0.004 0.048 0.000 0.280 0.664 0.004
#> GSM22374     6  0.1082      0.919 0.040 0.000 0.000 0.004 0.000 0.956
#> GSM22381     4  0.4876      0.482 0.348 0.000 0.000 0.596 0.036 0.020
#> GSM22382     5  0.4567      0.814 0.004 0.048 0.000 0.280 0.664 0.004
#> GSM22384     4  0.2594      0.716 0.040 0.000 0.016 0.892 0.048 0.004
#> GSM22385     4  0.4757      0.557 0.280 0.000 0.000 0.636 0.084 0.000
#> GSM22387     1  0.3672      0.804 0.832 0.000 0.032 0.076 0.012 0.048
#> GSM22388     6  0.1082      0.919 0.040 0.000 0.000 0.004 0.000 0.956
#> GSM22390     3  0.1350      0.857 0.020 0.000 0.952 0.008 0.020 0.000
#> GSM22392     3  0.1036      0.857 0.024 0.000 0.964 0.008 0.004 0.000
#> GSM22393     1  0.3214      0.793 0.820 0.000 0.008 0.152 0.016 0.004
#> GSM22394     4  0.4521      0.537 0.252 0.000 0.016 0.692 0.036 0.004
#> GSM22397     3  0.5834      0.689 0.136 0.008 0.660 0.028 0.148 0.020
#> GSM22400     4  0.4046      0.675 0.200 0.000 0.000 0.748 0.036 0.016
#> GSM22401     5  0.4745      0.801 0.008 0.048 0.000 0.296 0.644 0.004
#> GSM22403     4  0.4694      0.585 0.284 0.000 0.000 0.656 0.040 0.020
#> GSM22404     5  0.4567      0.814 0.004 0.048 0.000 0.280 0.664 0.004
#> GSM22405     5  0.3712      0.581 0.000 0.232 0.012 0.012 0.744 0.000
#> GSM22406     3  0.4630      0.599 0.280 0.000 0.660 0.012 0.048 0.000
#> GSM22408     3  0.4623      0.758 0.080 0.000 0.760 0.024 0.116 0.020
#> GSM22409     4  0.1457      0.750 0.028 0.004 0.004 0.948 0.016 0.000
#> GSM22410     4  0.2389      0.743 0.060 0.000 0.000 0.888 0.052 0.000
#> GSM22413     4  0.3908      0.710 0.164 0.000 0.000 0.776 0.040 0.020
#> GSM22414     4  0.3593      0.608 0.024 0.176 0.000 0.788 0.008 0.004
#> GSM22417     3  0.1478      0.851 0.032 0.000 0.944 0.004 0.020 0.000
#> GSM22418     1  0.3931      0.689 0.768 0.000 0.172 0.012 0.048 0.000
#> GSM22419     1  0.3785      0.790 0.816 0.000 0.056 0.072 0.056 0.000
#> GSM22420     6  0.1082      0.919 0.040 0.000 0.000 0.004 0.000 0.956
#> GSM22421     2  0.0964      0.960 0.012 0.968 0.000 0.000 0.004 0.016
#> GSM22422     5  0.6696      0.518 0.020 0.256 0.000 0.336 0.380 0.008
#> GSM22423     4  0.1633      0.738 0.044 0.000 0.000 0.932 0.024 0.000
#> GSM22424     1  0.3216      0.788 0.852 0.000 0.012 0.088 0.036 0.012
#> GSM22365     2  0.0405      0.979 0.004 0.988 0.000 0.008 0.000 0.000
#> GSM22366     4  0.2747      0.640 0.028 0.004 0.000 0.860 0.108 0.000
#> GSM22367     5  0.4017      0.787 0.000 0.076 0.004 0.160 0.760 0.000
#> GSM22368     5  0.4396      0.794 0.016 0.048 0.008 0.188 0.740 0.000
#> GSM22370     4  0.4815      0.593 0.272 0.000 0.000 0.656 0.052 0.020
#> GSM22371     2  0.1294      0.970 0.024 0.956 0.000 0.008 0.008 0.004
#> GSM22372     4  0.1534      0.751 0.032 0.004 0.004 0.944 0.016 0.000
#> GSM22373     3  0.4108      0.689 0.232 0.000 0.724 0.012 0.032 0.000
#> GSM22375     3  0.0837      0.857 0.020 0.000 0.972 0.004 0.004 0.000
#> GSM22376     4  0.3958      0.696 0.180 0.000 0.000 0.764 0.040 0.016
#> GSM22377     6  0.6028      0.629 0.144 0.000 0.092 0.004 0.132 0.628
#> GSM22378     2  0.0260      0.979 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM22379     2  0.0260      0.979 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM22380     4  0.3266      0.609 0.032 0.004 0.004 0.824 0.136 0.000
#> GSM22383     1  0.3166      0.781 0.816 0.000 0.004 0.156 0.024 0.000
#> GSM22386     3  0.3085      0.809 0.028 0.040 0.876 0.016 0.036 0.004
#> GSM22389     3  0.0692      0.857 0.020 0.000 0.976 0.004 0.000 0.000
#> GSM22391     3  0.2550      0.822 0.024 0.000 0.892 0.048 0.036 0.000
#> GSM22395     3  0.0291      0.854 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM22396     4  0.1313      0.753 0.028 0.000 0.004 0.952 0.016 0.000
#> GSM22398     1  0.5622      0.375 0.528 0.000 0.080 0.028 0.364 0.000
#> GSM22399     6  0.1082      0.919 0.040 0.000 0.000 0.004 0.000 0.956
#> GSM22402     2  0.1579      0.963 0.024 0.944 0.000 0.008 0.020 0.004
#> GSM22407     4  0.1889      0.754 0.056 0.000 0.000 0.920 0.020 0.004
#> GSM22411     5  0.3541      0.530 0.000 0.000 0.260 0.012 0.728 0.000
#> GSM22412     4  0.5356      0.456 0.304 0.000 0.052 0.600 0.044 0.000
#> GSM22415     3  0.5201      0.732 0.088 0.008 0.724 0.028 0.132 0.020
#> GSM22416     1  0.3194      0.771 0.808 0.000 0.004 0.172 0.012 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:kmeans 53            0.323 2
#> SD:kmeans 34            0.464 3
#> SD:kmeans 35            0.880 4
#> SD:kmeans 41            0.451 5
#> SD:kmeans 57            0.373 6

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 21446 rows and 60 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 0.758           0.876       0.944         0.5071 0.492   0.492
#> 3 3 0.556           0.761       0.864         0.3263 0.742   0.522
#> 4 4 0.501           0.516       0.731         0.1219 0.865   0.621
#> 5 5 0.505           0.410       0.666         0.0668 0.832   0.448
#> 6 6 0.575           0.408       0.644         0.0424 0.931   0.671

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
#> GSM22369     2  0.0000      0.920 0.000 1.000
#> GSM22374     1  0.0000      0.955 1.000 0.000
#> GSM22381     1  0.0000      0.955 1.000 0.000
#> GSM22382     2  0.0000      0.920 0.000 1.000
#> GSM22384     2  0.9323      0.492 0.348 0.652
#> GSM22385     1  0.0000      0.955 1.000 0.000
#> GSM22387     1  0.0000      0.955 1.000 0.000
#> GSM22388     1  0.0000      0.955 1.000 0.000
#> GSM22390     2  0.9775      0.313 0.412 0.588
#> GSM22392     1  0.1184      0.947 0.984 0.016
#> GSM22393     1  0.0000      0.955 1.000 0.000
#> GSM22394     2  0.7815      0.715 0.232 0.768
#> GSM22397     1  0.0000      0.955 1.000 0.000
#> GSM22400     1  0.3733      0.903 0.928 0.072
#> GSM22401     2  0.0000      0.920 0.000 1.000
#> GSM22403     1  0.0000      0.955 1.000 0.000
#> GSM22404     2  0.0000      0.920 0.000 1.000
#> GSM22405     2  0.0000      0.920 0.000 1.000
#> GSM22406     1  0.0000      0.955 1.000 0.000
#> GSM22408     1  0.4161      0.899 0.916 0.084
#> GSM22409     2  0.4161      0.866 0.084 0.916
#> GSM22410     1  0.7219      0.748 0.800 0.200
#> GSM22413     1  0.2603      0.927 0.956 0.044
#> GSM22414     2  0.0000      0.920 0.000 1.000
#> GSM22417     2  0.9710      0.329 0.400 0.600
#> GSM22418     1  0.0000      0.955 1.000 0.000
#> GSM22419     1  0.0000      0.955 1.000 0.000
#> GSM22420     1  0.0000      0.955 1.000 0.000
#> GSM22421     2  0.0000      0.920 0.000 1.000
#> GSM22422     2  0.0000      0.920 0.000 1.000
#> GSM22423     2  0.7219      0.752 0.200 0.800
#> GSM22424     1  0.0000      0.955 1.000 0.000
#> GSM22365     2  0.0000      0.920 0.000 1.000
#> GSM22366     2  0.1414      0.911 0.020 0.980
#> GSM22367     2  0.0000      0.920 0.000 1.000
#> GSM22368     2  0.0000      0.920 0.000 1.000
#> GSM22370     1  0.0376      0.953 0.996 0.004
#> GSM22371     2  0.0000      0.920 0.000 1.000
#> GSM22372     2  0.1184      0.913 0.016 0.984
#> GSM22373     1  0.0000      0.955 1.000 0.000
#> GSM22375     1  0.6048      0.834 0.852 0.148
#> GSM22376     2  0.9775      0.373 0.412 0.588
#> GSM22377     1  0.0000      0.955 1.000 0.000
#> GSM22378     2  0.0000      0.920 0.000 1.000
#> GSM22379     2  0.0000      0.920 0.000 1.000
#> GSM22380     2  0.0000      0.920 0.000 1.000
#> GSM22383     1  0.0000      0.955 1.000 0.000
#> GSM22386     2  0.0000      0.920 0.000 1.000
#> GSM22389     1  0.7528      0.744 0.784 0.216
#> GSM22391     2  0.0000      0.920 0.000 1.000
#> GSM22395     1  0.8207      0.678 0.744 0.256
#> GSM22396     2  0.1633      0.909 0.024 0.976
#> GSM22398     1  0.3274      0.921 0.940 0.060
#> GSM22399     1  0.0000      0.955 1.000 0.000
#> GSM22402     2  0.0000      0.920 0.000 1.000
#> GSM22407     2  0.2423      0.898 0.040 0.960
#> GSM22411     2  0.0000      0.920 0.000 1.000
#> GSM22412     1  0.0000      0.955 1.000 0.000
#> GSM22415     1  0.4431      0.892 0.908 0.092
#> GSM22416     1  0.0000      0.955 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.2384      0.886 0.008 0.936 0.056
#> GSM22374     1  0.2711      0.836 0.912 0.000 0.088
#> GSM22381     1  0.0000      0.830 1.000 0.000 0.000
#> GSM22382     2  0.2301      0.885 0.004 0.936 0.060
#> GSM22384     3  0.4339      0.776 0.084 0.048 0.868
#> GSM22385     1  0.3193      0.813 0.896 0.004 0.100
#> GSM22387     1  0.3038      0.833 0.896 0.000 0.104
#> GSM22388     1  0.2711      0.836 0.912 0.000 0.088
#> GSM22390     3  0.2903      0.816 0.028 0.048 0.924
#> GSM22392     3  0.2356      0.799 0.072 0.000 0.928
#> GSM22393     1  0.2878      0.836 0.904 0.000 0.096
#> GSM22394     3  0.8834      0.558 0.196 0.224 0.580
#> GSM22397     3  0.4796      0.642 0.220 0.000 0.780
#> GSM22400     1  0.1989      0.813 0.948 0.048 0.004
#> GSM22401     2  0.1647      0.891 0.004 0.960 0.036
#> GSM22403     1  0.0983      0.824 0.980 0.016 0.004
#> GSM22404     2  0.2301      0.885 0.004 0.936 0.060
#> GSM22405     2  0.2066      0.886 0.000 0.940 0.060
#> GSM22406     3  0.6215      0.113 0.428 0.000 0.572
#> GSM22408     3  0.1647      0.817 0.036 0.004 0.960
#> GSM22409     2  0.6495      0.722 0.200 0.740 0.060
#> GSM22410     1  0.7824      0.368 0.580 0.064 0.356
#> GSM22413     1  0.1453      0.822 0.968 0.024 0.008
#> GSM22414     2  0.1491      0.889 0.016 0.968 0.016
#> GSM22417     3  0.1643      0.810 0.000 0.044 0.956
#> GSM22418     1  0.6291      0.220 0.532 0.000 0.468
#> GSM22419     1  0.5810      0.587 0.664 0.000 0.336
#> GSM22420     1  0.2711      0.836 0.912 0.000 0.088
#> GSM22421     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22422     2  0.0237      0.890 0.000 0.996 0.004
#> GSM22423     2  0.8937      0.465 0.308 0.540 0.152
#> GSM22424     1  0.3116      0.831 0.892 0.000 0.108
#> GSM22365     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22366     2  0.3583      0.871 0.056 0.900 0.044
#> GSM22367     2  0.2066      0.886 0.000 0.940 0.060
#> GSM22368     2  0.2200      0.886 0.004 0.940 0.056
#> GSM22370     1  0.2434      0.814 0.940 0.024 0.036
#> GSM22371     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22372     2  0.6295      0.741 0.072 0.764 0.164
#> GSM22373     3  0.3619      0.752 0.136 0.000 0.864
#> GSM22375     3  0.1289      0.816 0.032 0.000 0.968
#> GSM22376     1  0.5291      0.566 0.732 0.268 0.000
#> GSM22377     1  0.5560      0.641 0.700 0.000 0.300
#> GSM22378     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22379     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22380     2  0.5180      0.801 0.032 0.812 0.156
#> GSM22383     1  0.2066      0.839 0.940 0.000 0.060
#> GSM22386     3  0.5733      0.530 0.000 0.324 0.676
#> GSM22389     3  0.1905      0.816 0.028 0.016 0.956
#> GSM22391     3  0.3192      0.777 0.000 0.112 0.888
#> GSM22395     3  0.0592      0.817 0.012 0.000 0.988
#> GSM22396     2  0.7764      0.461 0.068 0.604 0.328
#> GSM22398     1  0.7248      0.645 0.676 0.068 0.256
#> GSM22399     1  0.2711      0.836 0.912 0.000 0.088
#> GSM22402     2  0.0892      0.890 0.000 0.980 0.020
#> GSM22407     2  0.4514      0.799 0.156 0.832 0.012
#> GSM22411     3  0.5529      0.573 0.000 0.296 0.704
#> GSM22412     1  0.3686      0.791 0.860 0.000 0.140
#> GSM22415     3  0.3502      0.800 0.084 0.020 0.896
#> GSM22416     1  0.1525      0.837 0.964 0.004 0.032

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.5055    0.40405 0.000 0.368 0.008 0.624
#> GSM22374     1  0.1913    0.72452 0.940 0.000 0.040 0.020
#> GSM22381     1  0.3982    0.70093 0.776 0.000 0.004 0.220
#> GSM22382     4  0.5024    0.41060 0.000 0.360 0.008 0.632
#> GSM22384     4  0.4973    0.34966 0.012 0.004 0.292 0.692
#> GSM22385     1  0.6741    0.43244 0.476 0.008 0.068 0.448
#> GSM22387     1  0.2546    0.72588 0.912 0.000 0.060 0.028
#> GSM22388     1  0.1913    0.72452 0.940 0.000 0.040 0.020
#> GSM22390     3  0.4116    0.71072 0.016 0.060 0.848 0.076
#> GSM22392     3  0.1975    0.74569 0.048 0.000 0.936 0.016
#> GSM22393     1  0.4300    0.72101 0.820 0.000 0.092 0.088
#> GSM22394     4  0.9688    0.05438 0.144 0.232 0.288 0.336
#> GSM22397     3  0.5560    0.51008 0.292 0.004 0.668 0.036
#> GSM22400     1  0.7034    0.51326 0.552 0.088 0.016 0.344
#> GSM22401     4  0.4843    0.37587 0.000 0.396 0.000 0.604
#> GSM22403     1  0.4609    0.67962 0.752 0.024 0.000 0.224
#> GSM22404     4  0.5070    0.40286 0.000 0.372 0.008 0.620
#> GSM22405     2  0.4955    0.18550 0.000 0.648 0.008 0.344
#> GSM22406     3  0.5904    0.38493 0.344 0.004 0.612 0.040
#> GSM22408     3  0.1411    0.74744 0.020 0.000 0.960 0.020
#> GSM22409     4  0.7255    0.26839 0.108 0.336 0.016 0.540
#> GSM22410     4  0.4814    0.41727 0.140 0.008 0.060 0.792
#> GSM22413     1  0.5203    0.50927 0.576 0.008 0.000 0.416
#> GSM22414     2  0.2466    0.66561 0.004 0.900 0.000 0.096
#> GSM22417     3  0.1820    0.73530 0.000 0.036 0.944 0.020
#> GSM22418     3  0.6610   -0.08670 0.452 0.000 0.468 0.080
#> GSM22419     1  0.6660    0.48561 0.620 0.008 0.268 0.104
#> GSM22420     1  0.1913    0.72452 0.940 0.000 0.040 0.020
#> GSM22421     2  0.0336    0.75820 0.000 0.992 0.000 0.008
#> GSM22422     2  0.2589    0.66187 0.000 0.884 0.000 0.116
#> GSM22423     4  0.5799    0.48169 0.096 0.120 0.032 0.752
#> GSM22424     1  0.3550    0.70946 0.860 0.000 0.096 0.044
#> GSM22365     2  0.0000    0.76225 0.000 1.000 0.000 0.000
#> GSM22366     4  0.5551    0.47511 0.032 0.264 0.012 0.692
#> GSM22367     2  0.5320   -0.02455 0.000 0.572 0.012 0.416
#> GSM22368     4  0.5290    0.18453 0.000 0.476 0.008 0.516
#> GSM22370     1  0.4889    0.56071 0.636 0.004 0.000 0.360
#> GSM22371     2  0.0188    0.75933 0.000 0.996 0.004 0.000
#> GSM22372     2  0.7735   -0.00797 0.040 0.516 0.104 0.340
#> GSM22373     3  0.3969    0.66239 0.180 0.000 0.804 0.016
#> GSM22375     3  0.0524    0.74888 0.004 0.000 0.988 0.008
#> GSM22376     1  0.7885    0.28289 0.424 0.236 0.004 0.336
#> GSM22377     1  0.4838    0.50942 0.724 0.000 0.252 0.024
#> GSM22378     2  0.0000    0.76225 0.000 1.000 0.000 0.000
#> GSM22379     2  0.0000    0.76225 0.000 1.000 0.000 0.000
#> GSM22380     4  0.6682    0.31630 0.016 0.384 0.056 0.544
#> GSM22383     1  0.5011    0.71440 0.764 0.000 0.076 0.160
#> GSM22386     3  0.5279    0.31036 0.000 0.400 0.588 0.012
#> GSM22389     3  0.0895    0.74767 0.004 0.020 0.976 0.000
#> GSM22391     3  0.3903    0.67257 0.000 0.080 0.844 0.076
#> GSM22395     3  0.0524    0.74605 0.000 0.008 0.988 0.004
#> GSM22396     4  0.8235    0.23849 0.032 0.328 0.180 0.460
#> GSM22398     1  0.8297    0.21996 0.392 0.020 0.228 0.360
#> GSM22399     1  0.1913    0.72452 0.940 0.000 0.040 0.020
#> GSM22402     2  0.0000    0.76225 0.000 1.000 0.000 0.000
#> GSM22407     4  0.6497    0.27909 0.068 0.376 0.004 0.552
#> GSM22411     3  0.7325   -0.07505 0.000 0.160 0.472 0.368
#> GSM22412     1  0.6523    0.64030 0.628 0.000 0.136 0.236
#> GSM22415     3  0.5774    0.67518 0.132 0.048 0.756 0.064
#> GSM22416     1  0.3292    0.73377 0.868 0.004 0.016 0.112

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.2304    0.62981 0.000 0.100 0.000 0.008 0.892
#> GSM22374     1  0.0290    0.61876 0.992 0.000 0.008 0.000 0.000
#> GSM22381     4  0.5107   -0.04610 0.448 0.004 0.000 0.520 0.028
#> GSM22382     5  0.2411    0.63137 0.000 0.108 0.000 0.008 0.884
#> GSM22384     5  0.6314    0.38569 0.016 0.008 0.208 0.152 0.616
#> GSM22385     4  0.7597    0.15698 0.248 0.008 0.060 0.488 0.196
#> GSM22387     1  0.4181    0.54868 0.784 0.000 0.052 0.156 0.008
#> GSM22388     1  0.0579    0.61544 0.984 0.000 0.008 0.008 0.000
#> GSM22390     3  0.6239    0.54717 0.012 0.076 0.680 0.088 0.144
#> GSM22392     3  0.3474    0.68476 0.056 0.012 0.856 0.072 0.004
#> GSM22393     1  0.5776    0.31478 0.540 0.004 0.060 0.388 0.008
#> GSM22394     4  0.9524    0.10755 0.092 0.132 0.248 0.292 0.236
#> GSM22397     3  0.6477    0.20234 0.424 0.000 0.452 0.100 0.024
#> GSM22400     4  0.6328    0.30668 0.232 0.056 0.008 0.632 0.072
#> GSM22401     5  0.4162    0.60836 0.000 0.176 0.000 0.056 0.768
#> GSM22403     1  0.5673   -0.08591 0.480 0.016 0.000 0.460 0.044
#> GSM22404     5  0.2624    0.63286 0.000 0.116 0.000 0.012 0.872
#> GSM22405     5  0.4796    0.25071 0.000 0.468 0.004 0.012 0.516
#> GSM22406     3  0.6469    0.26527 0.360 0.000 0.492 0.136 0.012
#> GSM22408     3  0.3270    0.68213 0.056 0.008 0.876 0.032 0.028
#> GSM22409     4  0.7945    0.22346 0.044 0.160 0.040 0.456 0.300
#> GSM22410     5  0.7095    0.20248 0.068 0.004 0.100 0.316 0.512
#> GSM22413     4  0.6305    0.17013 0.376 0.016 0.000 0.504 0.104
#> GSM22414     2  0.4194    0.66527 0.000 0.780 0.000 0.132 0.088
#> GSM22417     3  0.3013    0.66695 0.000 0.044 0.880 0.016 0.060
#> GSM22418     3  0.7341   -0.06930 0.312 0.004 0.364 0.304 0.016
#> GSM22419     1  0.7503    0.21353 0.420 0.008 0.240 0.304 0.028
#> GSM22420     1  0.0290    0.61876 0.992 0.000 0.008 0.000 0.000
#> GSM22421     2  0.1121    0.82782 0.000 0.956 0.000 0.000 0.044
#> GSM22422     2  0.3752    0.63691 0.000 0.780 0.004 0.016 0.200
#> GSM22423     5  0.7885    0.11877 0.084 0.068 0.060 0.296 0.492
#> GSM22424     1  0.5100    0.48345 0.672 0.000 0.068 0.256 0.004
#> GSM22365     2  0.0162    0.85173 0.000 0.996 0.004 0.000 0.000
#> GSM22366     5  0.5295    0.49948 0.000 0.092 0.016 0.192 0.700
#> GSM22367     5  0.4491    0.48014 0.000 0.336 0.004 0.012 0.648
#> GSM22368     5  0.4714    0.58399 0.000 0.236 0.008 0.044 0.712
#> GSM22370     1  0.6767   -0.07324 0.428 0.000 0.004 0.340 0.228
#> GSM22371     2  0.0451    0.84814 0.004 0.988 0.008 0.000 0.000
#> GSM22372     4  0.8101    0.11174 0.008 0.336 0.080 0.364 0.212
#> GSM22373     3  0.5404    0.59772 0.188 0.004 0.704 0.084 0.020
#> GSM22375     3  0.1220    0.69354 0.004 0.008 0.964 0.020 0.004
#> GSM22376     4  0.6927    0.34870 0.184 0.172 0.000 0.576 0.068
#> GSM22377     1  0.4300    0.48660 0.776 0.000 0.164 0.048 0.012
#> GSM22378     2  0.0324    0.85037 0.000 0.992 0.000 0.004 0.004
#> GSM22379     2  0.0162    0.85173 0.000 0.996 0.004 0.000 0.000
#> GSM22380     5  0.7384    0.44041 0.020 0.232 0.064 0.132 0.552
#> GSM22383     4  0.6581   -0.20655 0.388 0.004 0.092 0.488 0.028
#> GSM22386     2  0.4928    0.26757 0.000 0.568 0.408 0.012 0.012
#> GSM22389     3  0.1278    0.69133 0.000 0.016 0.960 0.020 0.004
#> GSM22391     3  0.5477    0.54013 0.000 0.108 0.720 0.048 0.124
#> GSM22395     3  0.1256    0.69215 0.004 0.012 0.964 0.008 0.012
#> GSM22396     4  0.8642    0.16508 0.012 0.176 0.192 0.368 0.252
#> GSM22398     5  0.8599    0.00909 0.184 0.012 0.172 0.256 0.376
#> GSM22399     1  0.0290    0.61876 0.992 0.000 0.008 0.000 0.000
#> GSM22402     2  0.0566    0.84932 0.000 0.984 0.004 0.000 0.012
#> GSM22407     4  0.7026    0.08862 0.012 0.172 0.012 0.468 0.336
#> GSM22411     5  0.5776    0.44258 0.000 0.084 0.304 0.012 0.600
#> GSM22412     4  0.6835   -0.10880 0.360 0.004 0.124 0.484 0.028
#> GSM22415     3  0.7490    0.40613 0.296 0.044 0.520 0.088 0.052
#> GSM22416     4  0.5572   -0.23627 0.460 0.004 0.040 0.488 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
#> GSM22369     5  0.2632    0.59543 0.032 0.076 0.000 0.012 0.880 0.000
#> GSM22374     6  0.0000    0.60522 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22381     4  0.6143    0.12912 0.248 0.004 0.000 0.468 0.004 0.276
#> GSM22382     5  0.2762    0.59242 0.008 0.072 0.004 0.040 0.876 0.000
#> GSM22384     5  0.7142    0.31650 0.156 0.000 0.196 0.148 0.492 0.008
#> GSM22385     1  0.7883    0.03080 0.456 0.012 0.048 0.240 0.128 0.116
#> GSM22387     6  0.4812    0.27277 0.240 0.000 0.040 0.040 0.000 0.680
#> GSM22388     6  0.0603    0.60034 0.016 0.000 0.000 0.004 0.000 0.980
#> GSM22390     3  0.6679    0.48609 0.164 0.040 0.608 0.056 0.120 0.012
#> GSM22392     3  0.3946    0.63965 0.148 0.008 0.788 0.020 0.000 0.036
#> GSM22393     1  0.6876    0.25356 0.412 0.000 0.060 0.180 0.004 0.344
#> GSM22394     1  0.9001    0.00679 0.324 0.096 0.132 0.216 0.204 0.028
#> GSM22397     6  0.7209   -0.12849 0.200 0.000 0.352 0.076 0.008 0.364
#> GSM22400     4  0.5892    0.33150 0.180 0.020 0.000 0.640 0.040 0.120
#> GSM22401     5  0.4351    0.55107 0.020 0.104 0.000 0.120 0.756 0.000
#> GSM22403     4  0.6465    0.16146 0.204 0.016 0.000 0.432 0.008 0.340
#> GSM22404     5  0.3142    0.59189 0.016 0.092 0.000 0.044 0.848 0.000
#> GSM22405     5  0.4376    0.34785 0.012 0.384 0.012 0.000 0.592 0.000
#> GSM22406     3  0.7182    0.10619 0.208 0.008 0.412 0.076 0.000 0.296
#> GSM22408     3  0.4362    0.63114 0.064 0.000 0.780 0.064 0.004 0.088
#> GSM22409     4  0.5995    0.36726 0.088 0.056 0.024 0.660 0.164 0.008
#> GSM22410     5  0.7970    0.11398 0.324 0.008 0.064 0.196 0.352 0.056
#> GSM22413     4  0.6575    0.26862 0.208 0.004 0.004 0.516 0.040 0.228
#> GSM22414     2  0.4402    0.64750 0.028 0.756 0.000 0.152 0.060 0.004
#> GSM22417     3  0.3177    0.67491 0.036 0.040 0.868 0.020 0.036 0.000
#> GSM22418     1  0.6779    0.30800 0.472 0.000 0.260 0.056 0.004 0.208
#> GSM22419     1  0.6733    0.26608 0.508 0.008 0.116 0.048 0.016 0.304
#> GSM22420     6  0.0000    0.60522 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22421     2  0.1542    0.82712 0.008 0.936 0.000 0.004 0.052 0.000
#> GSM22422     2  0.3974    0.61229 0.012 0.744 0.000 0.032 0.212 0.000
#> GSM22423     5  0.8099    0.03012 0.208 0.036 0.076 0.312 0.348 0.020
#> GSM22424     6  0.6276    0.12038 0.268 0.000 0.056 0.112 0.008 0.556
#> GSM22365     2  0.0146    0.84407 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM22366     5  0.7003    0.32160 0.112 0.068 0.020 0.272 0.516 0.012
#> GSM22367     5  0.3627    0.53811 0.008 0.244 0.004 0.004 0.740 0.000
#> GSM22368     5  0.4057    0.57740 0.052 0.144 0.004 0.020 0.780 0.000
#> GSM22370     6  0.7758   -0.19541 0.260 0.000 0.008 0.248 0.156 0.328
#> GSM22371     2  0.1088    0.83243 0.016 0.960 0.024 0.000 0.000 0.000
#> GSM22372     4  0.7700    0.25773 0.096 0.240 0.056 0.476 0.124 0.008
#> GSM22373     3  0.6323    0.40812 0.224 0.000 0.548 0.044 0.004 0.180
#> GSM22375     3  0.2483    0.68290 0.060 0.004 0.900 0.012 0.012 0.012
#> GSM22376     4  0.6488    0.36121 0.156 0.160 0.000 0.580 0.008 0.096
#> GSM22377     6  0.4302    0.47152 0.100 0.000 0.076 0.040 0.004 0.780
#> GSM22378     2  0.0291    0.84318 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM22379     2  0.0508    0.84364 0.000 0.984 0.004 0.000 0.012 0.000
#> GSM22380     5  0.8297    0.24345 0.076 0.212 0.060 0.228 0.400 0.024
#> GSM22383     1  0.5871    0.39176 0.644 0.000 0.048 0.100 0.020 0.188
#> GSM22386     2  0.5156    0.24081 0.020 0.560 0.380 0.012 0.028 0.000
#> GSM22389     3  0.2633    0.68087 0.044 0.032 0.892 0.028 0.000 0.004
#> GSM22391     3  0.6030    0.54035 0.052 0.100 0.664 0.056 0.128 0.000
#> GSM22395     3  0.1368    0.68347 0.016 0.004 0.956 0.008 0.004 0.012
#> GSM22396     4  0.7313    0.26901 0.100 0.084 0.120 0.544 0.152 0.000
#> GSM22398     5  0.8529   -0.11819 0.308 0.012 0.132 0.084 0.328 0.136
#> GSM22399     6  0.0146    0.60438 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22402     2  0.0858    0.84058 0.000 0.968 0.000 0.004 0.028 0.000
#> GSM22407     4  0.6600    0.25088 0.128 0.076 0.000 0.508 0.284 0.004
#> GSM22411     5  0.5160    0.43217 0.040 0.044 0.268 0.004 0.644 0.000
#> GSM22412     1  0.7156    0.18895 0.380 0.000 0.072 0.344 0.008 0.196
#> GSM22415     3  0.8400    0.21056 0.112 0.068 0.400 0.112 0.032 0.276
#> GSM22416     1  0.6329    0.28179 0.452 0.000 0.008 0.224 0.008 0.308

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> SD:skmeans 56            0.292 2
#> SD:skmeans 55            0.592 3
#> SD:skmeans 35            0.458 4
#> SD:skmeans 27            0.270 5
#> SD:skmeans 25            0.518 6

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 21446 rows and 60 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 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-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.0746           0.646       0.766         0.4651 0.494   0.494
#> 3 3 0.2970           0.682       0.820         0.2287 0.575   0.380
#> 4 4 0.3929           0.501       0.744         0.2430 0.718   0.447
#> 5 5 0.5338           0.596       0.746         0.0913 0.860   0.560
#> 6 6 0.6723           0.577       0.750         0.0590 0.854   0.447

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
#> GSM22369     1  0.9393      0.666 0.644 0.356
#> GSM22374     1  0.3879      0.682 0.924 0.076
#> GSM22381     1  0.7528      0.721 0.784 0.216
#> GSM22382     1  0.9209      0.670 0.664 0.336
#> GSM22384     1  0.7745      0.736 0.772 0.228
#> GSM22385     1  0.5294      0.757 0.880 0.120
#> GSM22387     1  0.2423      0.683 0.960 0.040
#> GSM22388     2  0.9954      0.478 0.460 0.540
#> GSM22390     2  0.4161      0.741 0.084 0.916
#> GSM22392     1  0.9996     -0.125 0.512 0.488
#> GSM22393     2  0.7602      0.700 0.220 0.780
#> GSM22394     1  0.9552      0.513 0.624 0.376
#> GSM22397     1  0.6148      0.749 0.848 0.152
#> GSM22400     2  0.7674      0.699 0.224 0.776
#> GSM22401     2  0.7883      0.529 0.236 0.764
#> GSM22403     1  0.7950      0.697 0.760 0.240
#> GSM22404     1  0.9460      0.655 0.636 0.364
#> GSM22405     1  0.9993      0.529 0.516 0.484
#> GSM22406     2  0.8144      0.700 0.252 0.748
#> GSM22408     2  0.8763      0.674 0.296 0.704
#> GSM22409     2  0.6801      0.714 0.180 0.820
#> GSM22410     1  0.7674      0.735 0.776 0.224
#> GSM22413     1  0.6712      0.740 0.824 0.176
#> GSM22414     2  0.5629      0.725 0.132 0.868
#> GSM22417     1  0.8499      0.713 0.724 0.276
#> GSM22418     2  0.9000      0.655 0.316 0.684
#> GSM22419     1  0.5737      0.752 0.864 0.136
#> GSM22420     1  0.6712      0.587 0.824 0.176
#> GSM22421     2  1.0000     -0.541 0.500 0.500
#> GSM22422     2  0.6623      0.655 0.172 0.828
#> GSM22423     1  0.8081      0.735 0.752 0.248
#> GSM22424     1  0.8813      0.494 0.700 0.300
#> GSM22365     2  0.3733      0.738 0.072 0.928
#> GSM22366     2  0.7883      0.695 0.236 0.764
#> GSM22367     1  0.9087      0.678 0.676 0.324
#> GSM22368     1  0.9754      0.624 0.592 0.408
#> GSM22370     1  0.5946      0.749 0.856 0.144
#> GSM22371     2  0.1184      0.732 0.016 0.984
#> GSM22372     2  0.3584      0.728 0.068 0.932
#> GSM22373     2  0.9522      0.599 0.372 0.628
#> GSM22375     2  0.9129      0.517 0.328 0.672
#> GSM22376     2  0.8267      0.669 0.260 0.740
#> GSM22377     1  0.3274      0.713 0.940 0.060
#> GSM22378     2  0.0938      0.726 0.012 0.988
#> GSM22379     2  0.2043      0.723 0.032 0.968
#> GSM22380     2  0.4022      0.727 0.080 0.920
#> GSM22383     1  0.5842      0.752 0.860 0.140
#> GSM22386     1  0.9710      0.630 0.600 0.400
#> GSM22389     2  0.7219      0.706 0.200 0.800
#> GSM22391     2  0.7602      0.688 0.220 0.780
#> GSM22395     1  0.8909      0.692 0.692 0.308
#> GSM22396     2  0.5294      0.741 0.120 0.880
#> GSM22398     1  0.5408      0.756 0.876 0.124
#> GSM22399     1  0.3879      0.679 0.924 0.076
#> GSM22402     2  0.1184      0.727 0.016 0.984
#> GSM22407     2  0.7056      0.725 0.192 0.808
#> GSM22411     1  0.8861      0.691 0.696 0.304
#> GSM22412     1  0.5842      0.752 0.860 0.140
#> GSM22415     1  0.9933      0.457 0.548 0.452
#> GSM22416     2  0.7815      0.700 0.232 0.768

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.0424      0.778 0.000 0.992 0.008
#> GSM22374     1  0.0000      0.965 1.000 0.000 0.000
#> GSM22381     3  0.6295      0.285 0.000 0.472 0.528
#> GSM22382     2  0.1753      0.787 0.000 0.952 0.048
#> GSM22384     2  0.5810      0.538 0.000 0.664 0.336
#> GSM22385     2  0.4702      0.730 0.000 0.788 0.212
#> GSM22387     1  0.0592      0.958 0.988 0.000 0.012
#> GSM22388     1  0.0000      0.965 1.000 0.000 0.000
#> GSM22390     3  0.4504      0.700 0.000 0.196 0.804
#> GSM22392     3  0.2625      0.750 0.000 0.084 0.916
#> GSM22393     3  0.1860      0.759 0.000 0.052 0.948
#> GSM22394     3  0.6307      0.090 0.000 0.488 0.512
#> GSM22397     3  0.4291      0.700 0.000 0.180 0.820
#> GSM22400     3  0.2066      0.758 0.000 0.060 0.940
#> GSM22401     2  0.2261      0.754 0.000 0.932 0.068
#> GSM22403     2  0.8505      0.521 0.256 0.600 0.144
#> GSM22404     2  0.1529      0.785 0.000 0.960 0.040
#> GSM22405     2  0.2066      0.765 0.000 0.940 0.060
#> GSM22406     3  0.0000      0.761 0.000 0.000 1.000
#> GSM22408     3  0.1411      0.762 0.000 0.036 0.964
#> GSM22409     3  0.5810      0.583 0.000 0.336 0.664
#> GSM22410     2  0.3941      0.761 0.000 0.844 0.156
#> GSM22413     2  0.3879      0.751 0.000 0.848 0.152
#> GSM22414     3  0.6008      0.533 0.000 0.372 0.628
#> GSM22417     3  0.3941      0.714 0.000 0.156 0.844
#> GSM22418     3  0.1031      0.760 0.000 0.024 0.976
#> GSM22419     3  0.4291      0.704 0.000 0.180 0.820
#> GSM22420     1  0.0000      0.965 1.000 0.000 0.000
#> GSM22421     2  0.4291      0.696 0.000 0.820 0.180
#> GSM22422     2  0.3412      0.706 0.000 0.876 0.124
#> GSM22423     2  0.6302     -0.141 0.000 0.520 0.480
#> GSM22424     3  0.7248      0.662 0.108 0.184 0.708
#> GSM22365     3  0.3816      0.725 0.000 0.148 0.852
#> GSM22366     3  0.5621      0.606 0.000 0.308 0.692
#> GSM22367     2  0.2165      0.786 0.000 0.936 0.064
#> GSM22368     2  0.3340      0.787 0.000 0.880 0.120
#> GSM22370     2  0.3116      0.771 0.000 0.892 0.108
#> GSM22371     3  0.3941      0.724 0.000 0.156 0.844
#> GSM22372     3  0.3116      0.738 0.000 0.108 0.892
#> GSM22373     3  0.1753      0.760 0.000 0.048 0.952
#> GSM22375     3  0.3116      0.749 0.000 0.108 0.892
#> GSM22376     3  0.5529      0.596 0.000 0.296 0.704
#> GSM22377     1  0.4475      0.817 0.864 0.072 0.064
#> GSM22378     3  0.6180      0.401 0.000 0.416 0.584
#> GSM22379     3  0.6204      0.374 0.000 0.424 0.576
#> GSM22380     3  0.4750      0.699 0.000 0.216 0.784
#> GSM22383     3  0.4399      0.701 0.000 0.188 0.812
#> GSM22386     3  0.5058      0.698 0.000 0.244 0.756
#> GSM22389     3  0.0892      0.762 0.000 0.020 0.980
#> GSM22391     3  0.1860      0.762 0.000 0.052 0.948
#> GSM22395     3  0.4452      0.694 0.000 0.192 0.808
#> GSM22396     3  0.2261      0.761 0.000 0.068 0.932
#> GSM22398     2  0.5859      0.563 0.000 0.656 0.344
#> GSM22399     1  0.0000      0.965 1.000 0.000 0.000
#> GSM22402     3  0.6299      0.272 0.000 0.476 0.524
#> GSM22407     3  0.5327      0.646 0.000 0.272 0.728
#> GSM22411     2  0.5859      0.552 0.000 0.656 0.344
#> GSM22412     3  0.4399      0.701 0.000 0.188 0.812
#> GSM22415     3  0.4605      0.715 0.000 0.204 0.796
#> GSM22416     3  0.1529      0.763 0.000 0.040 0.960

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     2  0.1388     0.6413 0.000 0.960 0.012 0.028
#> GSM22374     1  0.0000     0.9389 1.000 0.000 0.000 0.000
#> GSM22381     4  0.2124     0.6932 0.000 0.068 0.008 0.924
#> GSM22382     2  0.1297     0.6424 0.000 0.964 0.016 0.020
#> GSM22384     2  0.7373     0.3273 0.000 0.516 0.204 0.280
#> GSM22385     2  0.5933     0.1528 0.000 0.500 0.036 0.464
#> GSM22387     1  0.3090     0.8723 0.888 0.000 0.056 0.056
#> GSM22388     1  0.0000     0.9389 1.000 0.000 0.000 0.000
#> GSM22390     3  0.2797     0.6390 0.000 0.068 0.900 0.032
#> GSM22392     3  0.2530     0.6193 0.000 0.000 0.888 0.112
#> GSM22393     4  0.5013     0.5080 0.000 0.020 0.292 0.688
#> GSM22394     3  0.7900     0.0385 0.000 0.332 0.368 0.300
#> GSM22397     3  0.4477     0.4758 0.000 0.000 0.688 0.312
#> GSM22400     3  0.5606     0.0199 0.000 0.020 0.500 0.480
#> GSM22401     2  0.0469     0.6358 0.000 0.988 0.000 0.012
#> GSM22403     4  0.3300     0.6557 0.008 0.144 0.000 0.848
#> GSM22404     2  0.1182     0.6424 0.000 0.968 0.016 0.016
#> GSM22405     2  0.1629     0.6350 0.000 0.952 0.024 0.024
#> GSM22406     3  0.4406     0.2798 0.000 0.000 0.700 0.300
#> GSM22408     3  0.1940     0.6447 0.000 0.000 0.924 0.076
#> GSM22409     4  0.7806    -0.0815 0.000 0.252 0.356 0.392
#> GSM22410     2  0.5359     0.4607 0.000 0.676 0.036 0.288
#> GSM22413     4  0.2773     0.6745 0.000 0.116 0.004 0.880
#> GSM22414     2  0.7849    -0.0686 0.000 0.380 0.352 0.268
#> GSM22417     3  0.2530     0.6188 0.000 0.000 0.888 0.112
#> GSM22418     3  0.3311     0.5630 0.000 0.000 0.828 0.172
#> GSM22419     4  0.4283     0.5836 0.000 0.004 0.256 0.740
#> GSM22420     1  0.0000     0.9389 1.000 0.000 0.000 0.000
#> GSM22421     2  0.6095     0.4506 0.000 0.668 0.108 0.224
#> GSM22422     2  0.0336     0.6364 0.000 0.992 0.000 0.008
#> GSM22423     2  0.7730     0.2455 0.000 0.444 0.264 0.292
#> GSM22424     4  0.2546     0.7054 0.028 0.008 0.044 0.920
#> GSM22365     3  0.7180     0.4176 0.000 0.188 0.548 0.264
#> GSM22366     2  0.7545     0.1531 0.000 0.440 0.368 0.192
#> GSM22367     2  0.2002     0.6360 0.000 0.936 0.020 0.044
#> GSM22368     2  0.2813     0.6091 0.000 0.896 0.080 0.024
#> GSM22370     2  0.5570     0.2132 0.000 0.540 0.020 0.440
#> GSM22371     3  0.6159     0.5156 0.000 0.196 0.672 0.132
#> GSM22372     3  0.4491     0.6061 0.000 0.140 0.800 0.060
#> GSM22373     3  0.4817     0.1876 0.000 0.000 0.612 0.388
#> GSM22375     3  0.1743     0.6431 0.000 0.004 0.940 0.056
#> GSM22376     4  0.5174     0.6106 0.000 0.124 0.116 0.760
#> GSM22377     1  0.3632     0.7766 0.832 0.004 0.008 0.156
#> GSM22378     2  0.7608     0.0322 0.000 0.456 0.328 0.216
#> GSM22379     3  0.7459     0.2386 0.000 0.336 0.476 0.188
#> GSM22380     3  0.6243     0.2539 0.000 0.392 0.548 0.060
#> GSM22383     4  0.4466     0.6521 0.000 0.036 0.180 0.784
#> GSM22386     3  0.3612     0.6328 0.000 0.044 0.856 0.100
#> GSM22389     3  0.0000     0.6389 0.000 0.000 1.000 0.000
#> GSM22391     3  0.1820     0.6471 0.000 0.020 0.944 0.036
#> GSM22395     3  0.2589     0.6140 0.000 0.000 0.884 0.116
#> GSM22396     3  0.3885     0.6222 0.000 0.064 0.844 0.092
#> GSM22398     4  0.4880     0.6449 0.000 0.052 0.188 0.760
#> GSM22399     1  0.0000     0.9389 1.000 0.000 0.000 0.000
#> GSM22402     2  0.7192    -0.0290 0.000 0.472 0.388 0.140
#> GSM22407     3  0.7836     0.0996 0.000 0.264 0.388 0.348
#> GSM22411     3  0.5143     0.2547 0.000 0.360 0.628 0.012
#> GSM22412     4  0.3355     0.6754 0.000 0.004 0.160 0.836
#> GSM22415     3  0.4313     0.5582 0.000 0.004 0.736 0.260
#> GSM22416     4  0.5184     0.5119 0.000 0.024 0.304 0.672

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5   0.213     0.7230 0.000 0.108 0.000 0.000 0.892
#> GSM22374     1   0.000     0.9193 1.000 0.000 0.000 0.000 0.000
#> GSM22381     4   0.144     0.7390 0.000 0.040 0.000 0.948 0.012
#> GSM22382     5   0.207     0.7237 0.000 0.104 0.000 0.000 0.896
#> GSM22384     5   0.603     0.5079 0.000 0.048 0.172 0.116 0.664
#> GSM22385     5   0.554     0.5213 0.000 0.056 0.028 0.264 0.652
#> GSM22387     1   0.346     0.8228 0.844 0.000 0.036 0.108 0.012
#> GSM22388     1   0.000     0.9193 1.000 0.000 0.000 0.000 0.000
#> GSM22390     3   0.165     0.6754 0.000 0.004 0.944 0.020 0.032
#> GSM22392     3   0.120     0.6853 0.000 0.004 0.956 0.040 0.000
#> GSM22393     4   0.374     0.6945 0.000 0.072 0.100 0.824 0.004
#> GSM22394     2   0.757     0.3997 0.000 0.508 0.212 0.112 0.168
#> GSM22397     3   0.727     0.3113 0.000 0.200 0.536 0.184 0.080
#> GSM22400     4   0.520     0.5696 0.000 0.120 0.180 0.696 0.004
#> GSM22401     5   0.272     0.6989 0.000 0.144 0.000 0.004 0.852
#> GSM22403     4   0.391     0.6758 0.000 0.060 0.000 0.796 0.144
#> GSM22404     5   0.213     0.7230 0.000 0.108 0.000 0.000 0.892
#> GSM22405     5   0.252     0.7097 0.000 0.140 0.000 0.000 0.860
#> GSM22406     3   0.413     0.2834 0.000 0.000 0.620 0.380 0.000
#> GSM22408     3   0.356     0.6339 0.000 0.088 0.848 0.028 0.036
#> GSM22409     2   0.800     0.2490 0.000 0.388 0.144 0.328 0.140
#> GSM22410     5   0.479     0.6044 0.000 0.056 0.024 0.172 0.748
#> GSM22413     4   0.136     0.7350 0.000 0.012 0.000 0.952 0.036
#> GSM22414     2   0.707     0.5232 0.000 0.536 0.144 0.064 0.256
#> GSM22417     3   0.176     0.6764 0.000 0.008 0.928 0.064 0.000
#> GSM22418     3   0.441     0.2545 0.000 0.008 0.604 0.388 0.000
#> GSM22419     4   0.615     0.5682 0.000 0.060 0.180 0.656 0.104
#> GSM22420     1   0.000     0.9193 1.000 0.000 0.000 0.000 0.000
#> GSM22421     2   0.189     0.6090 0.000 0.928 0.024 0.000 0.048
#> GSM22422     5   0.256     0.7008 0.000 0.144 0.000 0.000 0.856
#> GSM22423     5   0.681     0.4186 0.000 0.096 0.096 0.220 0.588
#> GSM22424     4   0.163     0.7365 0.000 0.056 0.008 0.936 0.000
#> GSM22365     2   0.192     0.6256 0.000 0.924 0.064 0.004 0.008
#> GSM22366     5   0.605     0.4379 0.000 0.096 0.148 0.080 0.676
#> GSM22367     5   0.257     0.7266 0.000 0.112 0.000 0.012 0.876
#> GSM22368     5   0.280     0.7058 0.000 0.044 0.060 0.008 0.888
#> GSM22370     5   0.438     0.5981 0.000 0.040 0.004 0.216 0.740
#> GSM22371     2   0.514     0.3110 0.000 0.548 0.416 0.004 0.032
#> GSM22372     3   0.544     0.1713 0.000 0.372 0.576 0.024 0.028
#> GSM22373     4   0.592     0.3864 0.000 0.052 0.348 0.568 0.032
#> GSM22375     3   0.088     0.6843 0.000 0.000 0.968 0.032 0.000
#> GSM22376     4   0.406     0.6978 0.000 0.076 0.060 0.824 0.040
#> GSM22377     1   0.439     0.7306 0.792 0.024 0.000 0.116 0.068
#> GSM22378     2   0.184     0.6301 0.000 0.936 0.016 0.008 0.040
#> GSM22379     2   0.219     0.6081 0.000 0.900 0.092 0.000 0.008
#> GSM22380     3   0.787     0.0241 0.000 0.204 0.428 0.096 0.272
#> GSM22383     4   0.528     0.6594 0.000 0.056 0.096 0.740 0.108
#> GSM22386     3   0.339     0.6518 0.000 0.084 0.848 0.064 0.004
#> GSM22389     3   0.029     0.6742 0.000 0.008 0.992 0.000 0.000
#> GSM22391     3   0.223     0.6715 0.000 0.016 0.920 0.020 0.044
#> GSM22395     3   0.192     0.6739 0.000 0.008 0.924 0.064 0.004
#> GSM22396     3   0.578     0.3031 0.000 0.300 0.612 0.028 0.060
#> GSM22398     4   0.522     0.6684 0.000 0.056 0.088 0.744 0.112
#> GSM22399     1   0.000     0.9193 1.000 0.000 0.000 0.000 0.000
#> GSM22402     2   0.632     0.5668 0.000 0.580 0.192 0.012 0.216
#> GSM22407     2   0.731     0.4829 0.000 0.516 0.172 0.072 0.240
#> GSM22411     3   0.448     0.3956 0.000 0.000 0.636 0.016 0.348
#> GSM22412     4   0.523     0.6632 0.000 0.056 0.096 0.744 0.104
#> GSM22415     3   0.638     0.4342 0.000 0.188 0.632 0.120 0.060
#> GSM22416     4   0.345     0.6992 0.000 0.064 0.100 0.836 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
#> GSM22369     5  0.0146    0.79614 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM22374     6  0.0000    0.88538 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22381     1  0.0458    0.81225 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM22382     5  0.0146    0.79614 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM22384     5  0.5547    0.03669 0.004 0.000 0.120 0.388 0.488 0.000
#> GSM22385     4  0.4124    0.34358 0.024 0.000 0.000 0.644 0.332 0.000
#> GSM22387     6  0.3436    0.76963 0.104 0.000 0.048 0.020 0.000 0.828
#> GSM22388     6  0.0000    0.88538 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22390     3  0.1370    0.74687 0.004 0.000 0.948 0.036 0.012 0.000
#> GSM22392     3  0.1007    0.75044 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM22393     1  0.0000    0.81411 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM22394     4  0.6239    0.42086 0.008 0.196 0.084 0.600 0.112 0.000
#> GSM22397     4  0.2969    0.51080 0.000 0.000 0.224 0.776 0.000 0.000
#> GSM22400     1  0.4107    0.49397 0.700 0.000 0.044 0.256 0.000 0.000
#> GSM22401     5  0.1059    0.78615 0.004 0.016 0.000 0.016 0.964 0.000
#> GSM22403     1  0.3139    0.65680 0.816 0.000 0.000 0.032 0.152 0.000
#> GSM22404     5  0.0146    0.79614 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM22405     5  0.1204    0.76938 0.000 0.056 0.000 0.000 0.944 0.000
#> GSM22406     3  0.3982    0.65759 0.200 0.000 0.740 0.060 0.000 0.000
#> GSM22408     3  0.4262   -0.00641 0.016 0.000 0.508 0.476 0.000 0.000
#> GSM22409     1  0.7844    0.03490 0.360 0.088 0.044 0.304 0.204 0.000
#> GSM22410     4  0.3769    0.30954 0.004 0.000 0.000 0.640 0.356 0.000
#> GSM22413     1  0.0458    0.81196 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM22414     5  0.7382    0.05426 0.060 0.196 0.044 0.236 0.464 0.000
#> GSM22417     3  0.1387    0.74669 0.000 0.000 0.932 0.068 0.000 0.000
#> GSM22418     3  0.4764    0.60255 0.232 0.000 0.660 0.108 0.000 0.000
#> GSM22419     4  0.4582    0.52048 0.216 0.000 0.100 0.684 0.000 0.000
#> GSM22420     6  0.0000    0.88538 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22421     2  0.0000    0.81653 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22422     5  0.0713    0.79059 0.000 0.028 0.000 0.000 0.972 0.000
#> GSM22423     4  0.2146    0.53475 0.000 0.000 0.004 0.880 0.116 0.000
#> GSM22424     1  0.0458    0.81225 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM22365     2  0.0000    0.81653 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22366     4  0.4943    0.11583 0.012 0.000 0.044 0.552 0.392 0.000
#> GSM22367     5  0.1297    0.77247 0.000 0.012 0.000 0.040 0.948 0.000
#> GSM22368     5  0.0260    0.79345 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM22370     5  0.3971    0.04129 0.004 0.000 0.000 0.448 0.548 0.000
#> GSM22371     3  0.6337    0.43610 0.000 0.228 0.532 0.192 0.048 0.000
#> GSM22372     3  0.5180    0.54535 0.012 0.028 0.596 0.336 0.028 0.000
#> GSM22373     4  0.5803   -0.13998 0.408 0.000 0.180 0.412 0.000 0.000
#> GSM22375     3  0.1075    0.74886 0.000 0.000 0.952 0.048 0.000 0.000
#> GSM22376     1  0.0146    0.81448 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM22377     6  0.3371    0.51453 0.000 0.000 0.000 0.292 0.000 0.708
#> GSM22378     2  0.0000    0.81653 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22379     2  0.0000    0.81653 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     4  0.7345   -0.25349 0.060 0.028 0.360 0.368 0.184 0.000
#> GSM22383     4  0.4023    0.49341 0.264 0.000 0.028 0.704 0.004 0.000
#> GSM22386     3  0.2868    0.73495 0.000 0.028 0.840 0.132 0.000 0.000
#> GSM22389     3  0.0547    0.75573 0.000 0.000 0.980 0.020 0.000 0.000
#> GSM22391     3  0.3103    0.69464 0.000 0.000 0.784 0.208 0.008 0.000
#> GSM22395     3  0.1644    0.73526 0.004 0.000 0.920 0.076 0.000 0.000
#> GSM22396     3  0.5163    0.53609 0.012 0.016 0.592 0.340 0.040 0.000
#> GSM22398     4  0.3952    0.46194 0.308 0.000 0.020 0.672 0.000 0.000
#> GSM22399     6  0.0000    0.88538 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22402     2  0.7470    0.01259 0.012 0.336 0.088 0.232 0.332 0.000
#> GSM22407     4  0.5420    0.36714 0.012 0.192 0.052 0.676 0.068 0.000
#> GSM22411     3  0.3204    0.69109 0.004 0.000 0.820 0.032 0.144 0.000
#> GSM22412     4  0.3791    0.51101 0.236 0.000 0.032 0.732 0.000 0.000
#> GSM22415     4  0.3348    0.47226 0.016 0.000 0.216 0.768 0.000 0.000
#> GSM22416     1  0.0653    0.80975 0.980 0.000 0.004 0.012 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n disease.state(p) k
#> SD:pam 55            0.139 2
#> SD:pam 54            0.130 3
#> SD:pam 39            0.297 4
#> SD:pam 45            0.437 5
#> SD:pam 42            0.315 6

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 21446 rows and 60 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 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 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.310           0.849       0.883         0.3531 0.636   0.636
#> 3 3 0.365           0.675       0.811         0.6370 0.579   0.439
#> 4 4 0.580           0.479       0.770         0.1297 0.753   0.491
#> 5 5 0.806           0.884       0.897         0.1598 0.801   0.437
#> 6 6 0.770           0.802       0.872         0.0569 0.955   0.812

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
#> GSM22369     2  0.9491      0.771 0.368 0.632
#> GSM22374     1  0.7299      0.815 0.796 0.204
#> GSM22381     1  0.0000      0.892 1.000 0.000
#> GSM22382     2  0.9522      0.768 0.372 0.628
#> GSM22384     1  0.0376      0.891 0.996 0.004
#> GSM22385     1  0.0000      0.892 1.000 0.000
#> GSM22387     1  0.4690      0.892 0.900 0.100
#> GSM22388     1  0.7299      0.815 0.796 0.204
#> GSM22390     1  0.5842      0.880 0.860 0.140
#> GSM22392     1  0.5737      0.881 0.864 0.136
#> GSM22393     1  0.4690      0.892 0.900 0.100
#> GSM22394     1  0.0672      0.895 0.992 0.008
#> GSM22397     1  0.5294      0.887 0.880 0.120
#> GSM22400     1  0.0000      0.892 1.000 0.000
#> GSM22401     2  0.9491      0.771 0.368 0.632
#> GSM22403     1  0.0000      0.892 1.000 0.000
#> GSM22404     2  0.9491      0.771 0.368 0.632
#> GSM22405     2  0.5946      0.802 0.144 0.856
#> GSM22406     1  0.5178      0.888 0.884 0.116
#> GSM22408     1  0.5737      0.881 0.864 0.136
#> GSM22409     1  0.0000      0.892 1.000 0.000
#> GSM22410     1  0.0376      0.891 0.996 0.004
#> GSM22413     1  0.0000      0.892 1.000 0.000
#> GSM22414     1  0.5178      0.861 0.884 0.116
#> GSM22417     1  0.5842      0.880 0.860 0.140
#> GSM22418     1  0.4815      0.892 0.896 0.104
#> GSM22419     1  0.4815      0.892 0.896 0.104
#> GSM22420     1  0.7299      0.815 0.796 0.204
#> GSM22421     2  0.2236      0.792 0.036 0.964
#> GSM22422     2  0.9129      0.792 0.328 0.672
#> GSM22423     1  0.0000      0.892 1.000 0.000
#> GSM22424     1  0.4939      0.890 0.892 0.108
#> GSM22365     2  0.2236      0.792 0.036 0.964
#> GSM22366     1  0.0672      0.890 0.992 0.008
#> GSM22367     2  0.8499      0.755 0.276 0.724
#> GSM22368     2  0.9608      0.755 0.384 0.616
#> GSM22370     1  0.0000      0.892 1.000 0.000
#> GSM22371     2  0.5629      0.813 0.132 0.868
#> GSM22372     1  0.0672      0.894 0.992 0.008
#> GSM22373     1  0.5629      0.881 0.868 0.132
#> GSM22375     1  0.5842      0.880 0.860 0.140
#> GSM22376     1  0.1184      0.892 0.984 0.016
#> GSM22377     1  0.7453      0.809 0.788 0.212
#> GSM22378     2  0.2603      0.795 0.044 0.956
#> GSM22379     2  0.2236      0.792 0.036 0.964
#> GSM22380     1  0.0938      0.895 0.988 0.012
#> GSM22383     1  0.0000      0.892 1.000 0.000
#> GSM22386     1  0.7815      0.785 0.768 0.232
#> GSM22389     1  0.5842      0.880 0.860 0.140
#> GSM22391     1  0.4939      0.892 0.892 0.108
#> GSM22395     1  0.5842      0.880 0.860 0.140
#> GSM22396     1  0.0000      0.892 1.000 0.000
#> GSM22398     1  0.0376      0.891 0.996 0.004
#> GSM22399     1  0.7299      0.815 0.796 0.204
#> GSM22402     2  0.5737      0.813 0.136 0.864
#> GSM22407     1  0.0672      0.890 0.992 0.008
#> GSM22411     1  0.9393      0.482 0.644 0.356
#> GSM22412     1  0.1633      0.897 0.976 0.024
#> GSM22415     1  0.6801      0.852 0.820 0.180
#> GSM22416     1  0.0672      0.895 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     1  0.8159      0.410 0.588 0.320 0.092
#> GSM22374     1  0.8260      0.443 0.636 0.192 0.172
#> GSM22381     1  0.0237      0.779 0.996 0.000 0.004
#> GSM22382     1  0.8159      0.410 0.588 0.320 0.092
#> GSM22384     1  0.2590      0.754 0.924 0.072 0.004
#> GSM22385     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22387     1  0.3686      0.694 0.860 0.000 0.140
#> GSM22388     1  0.8353      0.430 0.628 0.192 0.180
#> GSM22390     3  0.3879      0.775 0.152 0.000 0.848
#> GSM22392     3  0.2796      0.794 0.092 0.000 0.908
#> GSM22393     1  0.6506      0.532 0.720 0.044 0.236
#> GSM22394     1  0.0892      0.775 0.980 0.000 0.020
#> GSM22397     3  0.4682      0.789 0.192 0.004 0.804
#> GSM22400     1  0.0747      0.775 0.984 0.000 0.016
#> GSM22401     1  0.8159      0.410 0.588 0.320 0.092
#> GSM22403     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22404     1  0.8159      0.410 0.588 0.320 0.092
#> GSM22405     2  0.8441      0.558 0.144 0.608 0.248
#> GSM22406     3  0.5977      0.758 0.252 0.020 0.728
#> GSM22408     3  0.2796      0.794 0.092 0.000 0.908
#> GSM22409     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22410     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22413     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22414     1  0.5526      0.681 0.792 0.172 0.036
#> GSM22417     3  0.3267      0.794 0.116 0.000 0.884
#> GSM22418     3  0.6111      0.580 0.396 0.000 0.604
#> GSM22419     3  0.6008      0.622 0.372 0.000 0.628
#> GSM22420     1  0.8485      0.405 0.616 0.192 0.192
#> GSM22421     2  0.0237      0.912 0.000 0.996 0.004
#> GSM22422     1  0.8644      0.219 0.496 0.400 0.104
#> GSM22423     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22424     1  0.8430      0.344 0.604 0.136 0.260
#> GSM22365     2  0.0237      0.912 0.000 0.996 0.004
#> GSM22366     1  0.3879      0.701 0.848 0.152 0.000
#> GSM22367     1  0.9004      0.214 0.488 0.376 0.136
#> GSM22368     1  0.8065      0.435 0.604 0.304 0.092
#> GSM22370     1  0.0000      0.779 1.000 0.000 0.000
#> GSM22371     2  0.1015      0.910 0.012 0.980 0.008
#> GSM22372     1  0.1529      0.764 0.960 0.000 0.040
#> GSM22373     3  0.4974      0.772 0.236 0.000 0.764
#> GSM22375     3  0.2796      0.794 0.092 0.000 0.908
#> GSM22376     1  0.0475      0.780 0.992 0.004 0.004
#> GSM22377     3  0.8948      0.631 0.248 0.188 0.564
#> GSM22378     2  0.1765      0.901 0.040 0.956 0.004
#> GSM22379     2  0.0237      0.912 0.000 0.996 0.004
#> GSM22380     1  0.1647      0.773 0.960 0.036 0.004
#> GSM22383     1  0.2261      0.753 0.932 0.000 0.068
#> GSM22386     3  0.8371      0.599 0.164 0.212 0.624
#> GSM22389     3  0.2878      0.795 0.096 0.000 0.904
#> GSM22391     3  0.5882      0.625 0.348 0.000 0.652
#> GSM22395     3  0.2796      0.794 0.092 0.000 0.908
#> GSM22396     1  0.1643      0.762 0.956 0.000 0.044
#> GSM22398     1  0.2050      0.775 0.952 0.028 0.020
#> GSM22399     1  0.8162      0.456 0.644 0.192 0.164
#> GSM22402     2  0.1950      0.902 0.040 0.952 0.008
#> GSM22407     1  0.0237      0.780 0.996 0.004 0.000
#> GSM22411     3  0.8518      0.268 0.180 0.208 0.612
#> GSM22412     1  0.2448      0.748 0.924 0.000 0.076
#> GSM22415     3  0.7011      0.675 0.092 0.188 0.720
#> GSM22416     1  0.2165      0.755 0.936 0.000 0.064

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.0188     0.5298 0.000 0.004 0.000 0.996
#> GSM22374     1  0.0000     0.3879 1.000 0.000 0.000 0.000
#> GSM22381     1  0.4933     0.5368 0.568 0.000 0.000 0.432
#> GSM22382     4  0.0188     0.5298 0.000 0.004 0.000 0.996
#> GSM22384     4  0.4837    -0.0116 0.348 0.000 0.004 0.648
#> GSM22385     1  0.4989     0.4824 0.528 0.000 0.000 0.472
#> GSM22387     1  0.6078     0.5080 0.620 0.000 0.068 0.312
#> GSM22388     1  0.0000     0.3879 1.000 0.000 0.000 0.000
#> GSM22390     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22392     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22393     1  0.5572     0.4708 0.716 0.000 0.088 0.196
#> GSM22394     4  0.5296    -0.4541 0.492 0.000 0.008 0.500
#> GSM22397     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22400     1  0.4933     0.5368 0.568 0.000 0.000 0.432
#> GSM22401     4  0.0188     0.5298 0.000 0.004 0.000 0.996
#> GSM22403     1  0.4933     0.5368 0.568 0.000 0.000 0.432
#> GSM22404     4  0.0188     0.5298 0.000 0.004 0.000 0.996
#> GSM22405     4  0.4711     0.1669 0.000 0.236 0.024 0.740
#> GSM22406     3  0.4985    -0.0311 0.468 0.000 0.532 0.000
#> GSM22408     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22409     1  0.4989     0.4836 0.528 0.000 0.000 0.472
#> GSM22410     4  0.4994    -0.4101 0.480 0.000 0.000 0.520
#> GSM22413     1  0.4981     0.4984 0.536 0.000 0.000 0.464
#> GSM22414     1  0.4977     0.5037 0.540 0.000 0.000 0.460
#> GSM22417     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22418     3  0.5549     0.4714 0.280 0.000 0.672 0.048
#> GSM22419     1  0.5862     0.0823 0.484 0.000 0.484 0.032
#> GSM22420     1  0.0000     0.3879 1.000 0.000 0.000 0.000
#> GSM22421     2  0.0000     0.9586 0.000 1.000 0.000 0.000
#> GSM22422     4  0.0188     0.5298 0.000 0.004 0.000 0.996
#> GSM22423     4  0.4998    -0.4302 0.488 0.000 0.000 0.512
#> GSM22424     1  0.5052     0.3732 0.720 0.000 0.244 0.036
#> GSM22365     2  0.0000     0.9586 0.000 1.000 0.000 0.000
#> GSM22366     4  0.4193     0.2049 0.268 0.000 0.000 0.732
#> GSM22367     4  0.2944     0.4447 0.000 0.004 0.128 0.868
#> GSM22368     4  0.0000     0.5280 0.000 0.000 0.000 1.000
#> GSM22370     4  0.5000    -0.4506 0.496 0.000 0.000 0.504
#> GSM22371     2  0.0376     0.9546 0.000 0.992 0.004 0.004
#> GSM22372     1  0.4985     0.4913 0.532 0.000 0.000 0.468
#> GSM22373     3  0.1557     0.8479 0.056 0.000 0.944 0.000
#> GSM22375     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22376     1  0.4941     0.5330 0.564 0.000 0.000 0.436
#> GSM22377     1  0.4866     0.0639 0.596 0.000 0.404 0.000
#> GSM22378     2  0.0000     0.9586 0.000 1.000 0.000 0.000
#> GSM22379     2  0.0000     0.9586 0.000 1.000 0.000 0.000
#> GSM22380     4  0.4804    -0.1245 0.384 0.000 0.000 0.616
#> GSM22383     1  0.5337     0.5369 0.564 0.000 0.012 0.424
#> GSM22386     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22389     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22391     3  0.2081     0.8117 0.000 0.000 0.916 0.084
#> GSM22395     3  0.0000     0.8943 0.000 0.000 1.000 0.000
#> GSM22396     1  0.4989     0.4834 0.528 0.000 0.000 0.472
#> GSM22398     4  0.5398    -0.2098 0.404 0.000 0.016 0.580
#> GSM22399     1  0.0000     0.3879 1.000 0.000 0.000 0.000
#> GSM22402     2  0.2921     0.7810 0.000 0.860 0.000 0.140
#> GSM22407     1  0.5000     0.4174 0.504 0.000 0.000 0.496
#> GSM22411     4  0.4624     0.0728 0.000 0.000 0.340 0.660
#> GSM22412     1  0.6264     0.5157 0.560 0.000 0.064 0.376
#> GSM22415     3  0.0524     0.8876 0.004 0.008 0.988 0.000
#> GSM22416     1  0.4907     0.5387 0.580 0.000 0.000 0.420

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.2966      0.888 0.000 0.000 0.000 0.184 0.816
#> GSM22374     1  0.2471      0.797 0.864 0.000 0.000 0.000 0.136
#> GSM22381     4  0.1205      0.923 0.004 0.000 0.000 0.956 0.040
#> GSM22382     5  0.2966      0.888 0.000 0.000 0.000 0.184 0.816
#> GSM22384     4  0.0794      0.931 0.000 0.000 0.028 0.972 0.000
#> GSM22385     4  0.0703      0.933 0.000 0.000 0.024 0.976 0.000
#> GSM22387     1  0.2790      0.838 0.880 0.000 0.068 0.052 0.000
#> GSM22388     1  0.2471      0.797 0.864 0.000 0.000 0.000 0.136
#> GSM22390     3  0.0000      0.953 0.000 0.000 1.000 0.000 0.000
#> GSM22392     3  0.0000      0.953 0.000 0.000 1.000 0.000 0.000
#> GSM22393     1  0.2569      0.843 0.892 0.000 0.068 0.040 0.000
#> GSM22394     4  0.1493      0.930 0.000 0.000 0.028 0.948 0.024
#> GSM22397     3  0.3044      0.827 0.148 0.000 0.840 0.008 0.004
#> GSM22400     4  0.1043      0.924 0.000 0.000 0.000 0.960 0.040
#> GSM22401     5  0.2966      0.888 0.000 0.000 0.000 0.184 0.816
#> GSM22403     4  0.1124      0.925 0.000 0.000 0.004 0.960 0.036
#> GSM22404     5  0.2966      0.888 0.000 0.000 0.000 0.184 0.816
#> GSM22405     5  0.4220      0.654 0.000 0.200 0.008 0.032 0.760
#> GSM22406     1  0.3963      0.713 0.732 0.000 0.256 0.008 0.004
#> GSM22408     3  0.0000      0.953 0.000 0.000 1.000 0.000 0.000
#> GSM22409     4  0.1121      0.928 0.000 0.000 0.000 0.956 0.044
#> GSM22410     4  0.0703      0.933 0.000 0.000 0.024 0.976 0.000
#> GSM22413     4  0.1043      0.924 0.000 0.000 0.000 0.960 0.040
#> GSM22414     4  0.1331      0.932 0.000 0.000 0.008 0.952 0.040
#> GSM22417     3  0.0162      0.952 0.000 0.000 0.996 0.004 0.000
#> GSM22418     1  0.3452      0.820 0.820 0.000 0.148 0.032 0.000
#> GSM22419     1  0.3944      0.776 0.768 0.000 0.200 0.032 0.000
#> GSM22420     1  0.2471      0.797 0.864 0.000 0.000 0.000 0.136
#> GSM22421     2  0.0162      0.977 0.000 0.996 0.000 0.000 0.004
#> GSM22422     5  0.3972      0.871 0.000 0.032 0.008 0.172 0.788
#> GSM22423     4  0.1043      0.930 0.000 0.000 0.000 0.960 0.040
#> GSM22424     1  0.2548      0.845 0.896 0.000 0.072 0.028 0.004
#> GSM22365     2  0.0162      0.977 0.000 0.996 0.000 0.000 0.004
#> GSM22366     4  0.1121      0.928 0.000 0.000 0.000 0.956 0.044
#> GSM22367     5  0.4396      0.846 0.000 0.036 0.040 0.136 0.788
#> GSM22368     5  0.3003      0.885 0.000 0.000 0.000 0.188 0.812
#> GSM22370     4  0.1043      0.924 0.000 0.000 0.000 0.960 0.040
#> GSM22371     2  0.0854      0.968 0.000 0.976 0.008 0.004 0.012
#> GSM22372     4  0.1331      0.932 0.000 0.000 0.008 0.952 0.040
#> GSM22373     3  0.1043      0.931 0.040 0.000 0.960 0.000 0.000
#> GSM22375     3  0.0000      0.953 0.000 0.000 1.000 0.000 0.000
#> GSM22376     4  0.0955      0.934 0.000 0.000 0.004 0.968 0.028
#> GSM22377     1  0.3564      0.827 0.820 0.000 0.148 0.008 0.024
#> GSM22378     2  0.0324      0.975 0.000 0.992 0.004 0.000 0.004
#> GSM22379     2  0.0162      0.977 0.000 0.996 0.000 0.000 0.004
#> GSM22380     4  0.1331      0.932 0.000 0.000 0.008 0.952 0.040
#> GSM22383     4  0.2139      0.892 0.032 0.000 0.052 0.916 0.000
#> GSM22386     3  0.1653      0.926 0.000 0.024 0.944 0.028 0.004
#> GSM22389     3  0.0162      0.952 0.000 0.000 0.996 0.004 0.000
#> GSM22391     3  0.2110      0.876 0.000 0.000 0.912 0.072 0.016
#> GSM22395     3  0.0000      0.953 0.000 0.000 1.000 0.000 0.000
#> GSM22396     4  0.1043      0.930 0.000 0.000 0.000 0.960 0.040
#> GSM22398     4  0.1764      0.901 0.008 0.000 0.064 0.928 0.000
#> GSM22399     1  0.2471      0.797 0.864 0.000 0.000 0.000 0.136
#> GSM22402     2  0.1651      0.927 0.000 0.944 0.008 0.036 0.012
#> GSM22407     4  0.1121      0.928 0.000 0.000 0.000 0.956 0.044
#> GSM22411     5  0.4682      0.449 0.000 0.000 0.356 0.024 0.620
#> GSM22412     4  0.3780      0.772 0.132 0.000 0.060 0.808 0.000
#> GSM22415     3  0.2477      0.885 0.092 0.000 0.892 0.008 0.008
#> GSM22416     4  0.4187      0.708 0.196 0.000 0.008 0.764 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
#> GSM22369     5  0.0146     0.9461 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22374     6  0.0146     0.8912 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22381     4  0.1663     0.8214 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM22382     5  0.0146     0.9461 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22384     4  0.3053     0.8726 0.024 0.000 0.000 0.828 0.144 0.004
#> GSM22385     4  0.1528     0.8657 0.016 0.000 0.000 0.936 0.048 0.000
#> GSM22387     6  0.3938     0.3458 0.324 0.000 0.000 0.016 0.000 0.660
#> GSM22388     6  0.0146     0.8912 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22390     3  0.0000     0.8297 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22392     3  0.2378     0.7791 0.152 0.000 0.848 0.000 0.000 0.000
#> GSM22393     1  0.4306     0.4752 0.624 0.000 0.000 0.032 0.000 0.344
#> GSM22394     4  0.3078     0.8600 0.012 0.000 0.000 0.796 0.192 0.000
#> GSM22397     1  0.2300     0.6916 0.856 0.000 0.144 0.000 0.000 0.000
#> GSM22400     4  0.1444     0.8294 0.072 0.000 0.000 0.928 0.000 0.000
#> GSM22401     5  0.0146     0.9461 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22403     4  0.1765     0.8168 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM22404     5  0.0146     0.9461 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22405     5  0.3660     0.6777 0.036 0.188 0.004 0.000 0.772 0.000
#> GSM22406     1  0.2586     0.7621 0.868 0.000 0.032 0.000 0.000 0.100
#> GSM22408     3  0.2340     0.7823 0.148 0.000 0.852 0.000 0.000 0.000
#> GSM22409     4  0.3776     0.8616 0.052 0.000 0.000 0.760 0.188 0.000
#> GSM22410     4  0.2831     0.8736 0.024 0.000 0.000 0.840 0.136 0.000
#> GSM22413     4  0.1141     0.8370 0.052 0.000 0.000 0.948 0.000 0.000
#> GSM22414     4  0.3992     0.8559 0.072 0.000 0.000 0.748 0.180 0.000
#> GSM22417     3  0.0000     0.8297 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22418     1  0.3066     0.7476 0.836 0.000 0.016 0.000 0.016 0.132
#> GSM22419     1  0.3207     0.7598 0.844 0.000 0.048 0.000 0.016 0.092
#> GSM22420     6  0.0146     0.8912 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22421     2  0.0000     0.9842 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22422     5  0.0964     0.9333 0.016 0.012 0.000 0.004 0.968 0.000
#> GSM22423     4  0.2558     0.8729 0.004 0.000 0.000 0.840 0.156 0.000
#> GSM22424     1  0.4004     0.4416 0.620 0.000 0.000 0.012 0.000 0.368
#> GSM22365     2  0.0000     0.9842 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22366     4  0.2871     0.8619 0.004 0.000 0.000 0.804 0.192 0.000
#> GSM22367     5  0.1434     0.9133 0.012 0.012 0.028 0.000 0.948 0.000
#> GSM22368     5  0.0260     0.9430 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM22370     4  0.0363     0.8454 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM22371     2  0.0717     0.9806 0.016 0.976 0.000 0.000 0.008 0.000
#> GSM22372     4  0.3253     0.8626 0.020 0.000 0.000 0.788 0.192 0.000
#> GSM22373     1  0.3737     0.2259 0.608 0.000 0.392 0.000 0.000 0.000
#> GSM22375     3  0.0547     0.8319 0.020 0.000 0.980 0.000 0.000 0.000
#> GSM22376     4  0.2462     0.8317 0.096 0.000 0.000 0.876 0.028 0.000
#> GSM22377     1  0.2901     0.7573 0.840 0.000 0.032 0.000 0.000 0.128
#> GSM22378     2  0.0458     0.9819 0.016 0.984 0.000 0.000 0.000 0.000
#> GSM22379     2  0.0000     0.9842 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     4  0.3168     0.8590 0.016 0.000 0.000 0.792 0.192 0.000
#> GSM22383     4  0.3417     0.8324 0.132 0.000 0.000 0.812 0.052 0.004
#> GSM22386     3  0.1180     0.8183 0.016 0.012 0.960 0.000 0.012 0.000
#> GSM22389     3  0.2003     0.8018 0.116 0.000 0.884 0.000 0.000 0.000
#> GSM22391     3  0.2009     0.7636 0.008 0.000 0.904 0.004 0.084 0.000
#> GSM22395     3  0.0547     0.8319 0.020 0.000 0.980 0.000 0.000 0.000
#> GSM22396     4  0.2664     0.8660 0.000 0.000 0.000 0.816 0.184 0.000
#> GSM22398     4  0.3361     0.8517 0.108 0.000 0.004 0.828 0.056 0.004
#> GSM22399     6  0.0146     0.8912 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22402     2  0.0993     0.9735 0.024 0.964 0.000 0.000 0.012 0.000
#> GSM22407     4  0.2948     0.8655 0.008 0.000 0.000 0.804 0.188 0.000
#> GSM22411     3  0.4335    -0.0119 0.020 0.000 0.508 0.000 0.472 0.000
#> GSM22412     4  0.3577     0.7760 0.200 0.000 0.000 0.772 0.016 0.012
#> GSM22415     3  0.3647     0.4612 0.360 0.000 0.640 0.000 0.000 0.000
#> GSM22416     4  0.3681     0.6826 0.064 0.000 0.000 0.780 0.000 0.156

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:mclust 59           0.9543 2
#> SD:mclust 47           0.4888 3
#> SD:mclust 33           0.1243 4
#> SD:mclust 59           0.0587 5
#> SD:mclust 54           0.1978 6

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 21446 rows and 60 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.894           0.920       0.966         0.4987 0.497   0.497
#> 3 3 0.717           0.792       0.901         0.3484 0.731   0.506
#> 4 4 0.498           0.524       0.685         0.1007 0.821   0.531
#> 5 5 0.623           0.692       0.799         0.0686 0.846   0.505
#> 6 6 0.685           0.560       0.748         0.0502 0.863   0.465

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
#> GSM22369     2  0.0000      0.949 0.000 1.000
#> GSM22374     1  0.0000      0.975 1.000 0.000
#> GSM22381     1  0.0000      0.975 1.000 0.000
#> GSM22382     2  0.0000      0.949 0.000 1.000
#> GSM22384     1  0.0000      0.975 1.000 0.000
#> GSM22385     1  0.0000      0.975 1.000 0.000
#> GSM22387     1  0.0000      0.975 1.000 0.000
#> GSM22388     1  0.0000      0.975 1.000 0.000
#> GSM22390     2  0.8016      0.701 0.244 0.756
#> GSM22392     1  0.0000      0.975 1.000 0.000
#> GSM22393     1  0.0000      0.975 1.000 0.000
#> GSM22394     1  0.9552      0.358 0.624 0.376
#> GSM22397     1  0.0000      0.975 1.000 0.000
#> GSM22400     1  0.0000      0.975 1.000 0.000
#> GSM22401     2  0.0000      0.949 0.000 1.000
#> GSM22403     1  0.0000      0.975 1.000 0.000
#> GSM22404     2  0.0000      0.949 0.000 1.000
#> GSM22405     2  0.0000      0.949 0.000 1.000
#> GSM22406     1  0.0000      0.975 1.000 0.000
#> GSM22408     1  0.0000      0.975 1.000 0.000
#> GSM22409     2  0.7950      0.708 0.240 0.760
#> GSM22410     1  0.0000      0.975 1.000 0.000
#> GSM22413     1  0.0000      0.975 1.000 0.000
#> GSM22414     2  0.0000      0.949 0.000 1.000
#> GSM22417     2  0.2948      0.917 0.052 0.948
#> GSM22418     1  0.0000      0.975 1.000 0.000
#> GSM22419     1  0.0000      0.975 1.000 0.000
#> GSM22420     1  0.0000      0.975 1.000 0.000
#> GSM22421     2  0.0000      0.949 0.000 1.000
#> GSM22422     2  0.0000      0.949 0.000 1.000
#> GSM22423     1  0.8443      0.603 0.728 0.272
#> GSM22424     1  0.0000      0.975 1.000 0.000
#> GSM22365     2  0.0000      0.949 0.000 1.000
#> GSM22366     2  0.0000      0.949 0.000 1.000
#> GSM22367     2  0.0000      0.949 0.000 1.000
#> GSM22368     2  0.0000      0.949 0.000 1.000
#> GSM22370     1  0.0000      0.975 1.000 0.000
#> GSM22371     2  0.0000      0.949 0.000 1.000
#> GSM22372     2  0.2948      0.917 0.052 0.948
#> GSM22373     1  0.0000      0.975 1.000 0.000
#> GSM22375     1  0.0000      0.975 1.000 0.000
#> GSM22376     2  0.9896      0.244 0.440 0.560
#> GSM22377     1  0.0000      0.975 1.000 0.000
#> GSM22378     2  0.0000      0.949 0.000 1.000
#> GSM22379     2  0.0000      0.949 0.000 1.000
#> GSM22380     2  0.2043      0.931 0.032 0.968
#> GSM22383     1  0.0000      0.975 1.000 0.000
#> GSM22386     2  0.0000      0.949 0.000 1.000
#> GSM22389     1  0.4022      0.894 0.920 0.080
#> GSM22391     2  0.0000      0.949 0.000 1.000
#> GSM22395     1  0.1414      0.957 0.980 0.020
#> GSM22396     2  0.7056      0.777 0.192 0.808
#> GSM22398     1  0.0000      0.975 1.000 0.000
#> GSM22399     1  0.0000      0.975 1.000 0.000
#> GSM22402     2  0.0000      0.949 0.000 1.000
#> GSM22407     2  0.2423      0.926 0.040 0.960
#> GSM22411     2  0.0000      0.949 0.000 1.000
#> GSM22412     1  0.0000      0.975 1.000 0.000
#> GSM22415     1  0.0376      0.971 0.996 0.004
#> GSM22416     1  0.0000      0.975 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.1315     0.8910 0.008 0.972 0.020
#> GSM22374     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22381     1  0.0592     0.9037 0.988 0.012 0.000
#> GSM22382     3  0.6451     0.0334 0.004 0.436 0.560
#> GSM22384     3  0.1647     0.8737 0.036 0.004 0.960
#> GSM22385     1  0.0661     0.9052 0.988 0.008 0.004
#> GSM22387     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22388     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22390     3  0.0424     0.8688 0.000 0.008 0.992
#> GSM22392     3  0.1860     0.8685 0.052 0.000 0.948
#> GSM22393     1  0.0424     0.9068 0.992 0.000 0.008
#> GSM22394     3  0.3293     0.8516 0.088 0.012 0.900
#> GSM22397     3  0.3192     0.8335 0.112 0.000 0.888
#> GSM22400     1  0.1753     0.8846 0.952 0.048 0.000
#> GSM22401     2  0.0829     0.8918 0.004 0.984 0.012
#> GSM22403     1  0.1964     0.8780 0.944 0.056 0.000
#> GSM22404     2  0.3349     0.8502 0.004 0.888 0.108
#> GSM22405     2  0.4750     0.7582 0.000 0.784 0.216
#> GSM22406     3  0.6291     0.1305 0.468 0.000 0.532
#> GSM22408     3  0.1289     0.8734 0.032 0.000 0.968
#> GSM22409     2  0.3038     0.8301 0.104 0.896 0.000
#> GSM22410     3  0.3918     0.8146 0.140 0.004 0.856
#> GSM22413     1  0.1411     0.8924 0.964 0.036 0.000
#> GSM22414     2  0.0592     0.8898 0.012 0.988 0.000
#> GSM22417     3  0.0592     0.8670 0.000 0.012 0.988
#> GSM22418     3  0.6252     0.2086 0.444 0.000 0.556
#> GSM22419     1  0.5591     0.5494 0.696 0.000 0.304
#> GSM22420     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22421     2  0.1753     0.8822 0.000 0.952 0.048
#> GSM22422     2  0.0000     0.8915 0.000 1.000 0.000
#> GSM22423     1  0.6229     0.4481 0.652 0.340 0.008
#> GSM22424     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22365     2  0.0424     0.8914 0.000 0.992 0.008
#> GSM22366     2  0.2845     0.8724 0.012 0.920 0.068
#> GSM22367     2  0.5529     0.6544 0.000 0.704 0.296
#> GSM22368     2  0.2301     0.8786 0.004 0.936 0.060
#> GSM22370     1  0.0747     0.9022 0.984 0.016 0.000
#> GSM22371     2  0.0747     0.8906 0.000 0.984 0.016
#> GSM22372     2  0.1015     0.8908 0.012 0.980 0.008
#> GSM22373     3  0.3879     0.7945 0.152 0.000 0.848
#> GSM22375     3  0.0592     0.8724 0.012 0.000 0.988
#> GSM22376     2  0.6299     0.0638 0.476 0.524 0.000
#> GSM22377     1  0.1163     0.9006 0.972 0.000 0.028
#> GSM22378     2  0.0000     0.8915 0.000 1.000 0.000
#> GSM22379     2  0.0892     0.8898 0.000 0.980 0.020
#> GSM22380     2  0.6341     0.5846 0.016 0.672 0.312
#> GSM22383     1  0.5254     0.6122 0.736 0.000 0.264
#> GSM22386     3  0.2796     0.8014 0.000 0.092 0.908
#> GSM22389     3  0.0892     0.8733 0.020 0.000 0.980
#> GSM22391     3  0.0747     0.8650 0.000 0.016 0.984
#> GSM22395     3  0.0000     0.8707 0.000 0.000 1.000
#> GSM22396     2  0.6796     0.6489 0.056 0.708 0.236
#> GSM22398     3  0.2486     0.8653 0.060 0.008 0.932
#> GSM22399     1  0.0747     0.9070 0.984 0.000 0.016
#> GSM22402     2  0.0424     0.8914 0.000 0.992 0.008
#> GSM22407     2  0.0892     0.8878 0.020 0.980 0.000
#> GSM22411     3  0.0747     0.8650 0.000 0.016 0.984
#> GSM22412     1  0.5058     0.6438 0.756 0.000 0.244
#> GSM22415     3  0.1643     0.8715 0.044 0.000 0.956
#> GSM22416     1  0.0424     0.9047 0.992 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     2  0.3836     0.5641 0.000 0.816 0.016 0.168
#> GSM22374     1  0.4697     0.7941 0.644 0.000 0.000 0.356
#> GSM22381     4  0.1545     0.5797 0.040 0.008 0.000 0.952
#> GSM22382     2  0.6567     0.1595 0.008 0.552 0.376 0.064
#> GSM22384     3  0.6357     0.5137 0.004 0.276 0.632 0.088
#> GSM22385     4  0.2328     0.6141 0.004 0.056 0.016 0.924
#> GSM22387     1  0.4998     0.5668 0.512 0.000 0.000 0.488
#> GSM22388     1  0.4697     0.7941 0.644 0.000 0.000 0.356
#> GSM22390     3  0.0992     0.7604 0.008 0.004 0.976 0.012
#> GSM22392     3  0.3071     0.7368 0.044 0.000 0.888 0.068
#> GSM22393     4  0.4171     0.4565 0.116 0.000 0.060 0.824
#> GSM22394     4  0.7897    -0.0120 0.004 0.236 0.344 0.416
#> GSM22397     3  0.4535     0.5598 0.240 0.000 0.744 0.016
#> GSM22400     4  0.1520     0.5986 0.020 0.024 0.000 0.956
#> GSM22401     2  0.4005     0.5635 0.008 0.808 0.008 0.176
#> GSM22403     4  0.3224     0.5117 0.120 0.016 0.000 0.864
#> GSM22404     2  0.4726     0.5585 0.004 0.784 0.048 0.164
#> GSM22405     2  0.4511     0.5306 0.040 0.784 0.176 0.000
#> GSM22406     3  0.6298     0.4755 0.100 0.000 0.632 0.268
#> GSM22408     3  0.0927     0.7572 0.016 0.000 0.976 0.008
#> GSM22409     4  0.6179     0.4969 0.068 0.256 0.012 0.664
#> GSM22410     3  0.7754     0.3456 0.004 0.320 0.460 0.216
#> GSM22413     4  0.3863     0.5992 0.028 0.144 0.000 0.828
#> GSM22414     2  0.7346     0.5287 0.280 0.520 0.000 0.200
#> GSM22417     3  0.1262     0.7609 0.008 0.008 0.968 0.016
#> GSM22418     3  0.6504     0.0642 0.072 0.000 0.476 0.452
#> GSM22419     4  0.7042     0.1205 0.132 0.000 0.352 0.516
#> GSM22420     1  0.4697     0.7941 0.644 0.000 0.000 0.356
#> GSM22421     2  0.5460     0.6327 0.340 0.632 0.028 0.000
#> GSM22422     2  0.5105     0.6402 0.276 0.696 0.000 0.028
#> GSM22423     4  0.4514     0.5751 0.008 0.228 0.008 0.756
#> GSM22424     4  0.4855    -0.3440 0.400 0.000 0.000 0.600
#> GSM22365     2  0.4936     0.6375 0.340 0.652 0.000 0.008
#> GSM22366     2  0.5928     0.4959 0.004 0.692 0.088 0.216
#> GSM22367     2  0.4891     0.3163 0.012 0.680 0.308 0.000
#> GSM22368     2  0.5479     0.5525 0.008 0.748 0.088 0.156
#> GSM22370     4  0.3991     0.5410 0.120 0.048 0.000 0.832
#> GSM22371     2  0.4936     0.6375 0.340 0.652 0.000 0.008
#> GSM22372     4  0.8696    -0.0617 0.240 0.276 0.048 0.436
#> GSM22373     3  0.2996     0.7291 0.044 0.000 0.892 0.064
#> GSM22375     3  0.0657     0.7604 0.004 0.000 0.984 0.012
#> GSM22376     4  0.4888     0.5257 0.036 0.224 0.000 0.740
#> GSM22377     1  0.6065     0.7260 0.644 0.000 0.080 0.276
#> GSM22378     2  0.5252     0.6388 0.336 0.644 0.000 0.020
#> GSM22379     2  0.4936     0.6375 0.340 0.652 0.008 0.000
#> GSM22380     2  0.6369     0.3972 0.004 0.640 0.096 0.260
#> GSM22383     4  0.2892     0.5520 0.036 0.000 0.068 0.896
#> GSM22386     3  0.5669     0.5062 0.092 0.200 0.708 0.000
#> GSM22389     3  0.1674     0.7526 0.032 0.004 0.952 0.012
#> GSM22391     3  0.1229     0.7616 0.004 0.008 0.968 0.020
#> GSM22395     3  0.0376     0.7564 0.004 0.004 0.992 0.000
#> GSM22396     4  0.7115     0.4117 0.048 0.068 0.276 0.608
#> GSM22398     3  0.7900     0.3936 0.012 0.312 0.472 0.204
#> GSM22399     1  0.4697     0.7941 0.644 0.000 0.000 0.356
#> GSM22402     2  0.5252     0.6390 0.336 0.644 0.000 0.020
#> GSM22407     4  0.5460     0.4024 0.028 0.340 0.000 0.632
#> GSM22411     3  0.4850     0.5146 0.008 0.292 0.696 0.004
#> GSM22412     4  0.3505     0.5196 0.048 0.000 0.088 0.864
#> GSM22415     1  0.5636     0.0151 0.544 0.016 0.436 0.004
#> GSM22416     4  0.1706     0.5780 0.036 0.000 0.016 0.948

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.4496      0.711 0.000 0.056 0.000 0.216 0.728
#> GSM22374     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM22381     4  0.2162      0.742 0.064 0.000 0.012 0.916 0.008
#> GSM22382     5  0.2766      0.757 0.000 0.008 0.024 0.084 0.884
#> GSM22384     5  0.4630      0.659 0.000 0.000 0.176 0.088 0.736
#> GSM22385     4  0.3327      0.722 0.004 0.000 0.084 0.852 0.060
#> GSM22387     1  0.3846      0.809 0.836 0.000 0.076 0.052 0.036
#> GSM22388     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM22390     3  0.3399      0.809 0.000 0.004 0.812 0.012 0.172
#> GSM22392     3  0.1800      0.809 0.000 0.000 0.932 0.020 0.048
#> GSM22393     4  0.6152      0.347 0.044 0.000 0.360 0.544 0.052
#> GSM22394     4  0.6273      0.069 0.004 0.000 0.428 0.440 0.128
#> GSM22397     3  0.4331      0.772 0.140 0.000 0.780 0.008 0.072
#> GSM22400     4  0.1334      0.742 0.020 0.004 0.004 0.960 0.012
#> GSM22401     5  0.5215      0.548 0.000 0.056 0.000 0.352 0.592
#> GSM22403     4  0.2911      0.717 0.136 0.004 0.000 0.852 0.008
#> GSM22404     5  0.4800      0.671 0.000 0.052 0.000 0.272 0.676
#> GSM22405     5  0.3562      0.643 0.000 0.196 0.016 0.000 0.788
#> GSM22406     3  0.2983      0.791 0.012 0.000 0.880 0.048 0.060
#> GSM22408     3  0.3437      0.800 0.004 0.004 0.804 0.004 0.184
#> GSM22409     4  0.3234      0.701 0.008 0.036 0.004 0.864 0.088
#> GSM22410     5  0.4871      0.649 0.000 0.000 0.084 0.212 0.704
#> GSM22413     4  0.2036      0.729 0.028 0.008 0.000 0.928 0.036
#> GSM22414     2  0.4898      0.266 0.000 0.592 0.000 0.376 0.032
#> GSM22417     3  0.3170      0.817 0.000 0.008 0.828 0.004 0.160
#> GSM22418     3  0.4203      0.653 0.000 0.000 0.760 0.188 0.052
#> GSM22419     3  0.4380      0.706 0.028 0.000 0.788 0.136 0.048
#> GSM22420     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM22421     2  0.0798      0.855 0.000 0.976 0.008 0.000 0.016
#> GSM22422     2  0.1364      0.838 0.000 0.952 0.000 0.036 0.012
#> GSM22423     4  0.3106      0.690 0.008 0.020 0.000 0.856 0.116
#> GSM22424     1  0.6557      0.478 0.588 0.000 0.128 0.240 0.044
#> GSM22365     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000
#> GSM22366     5  0.4970      0.471 0.000 0.008 0.020 0.392 0.580
#> GSM22367     5  0.2804      0.726 0.000 0.068 0.044 0.004 0.884
#> GSM22368     5  0.4649      0.738 0.000 0.080 0.008 0.160 0.752
#> GSM22370     4  0.4666      0.588 0.240 0.000 0.000 0.704 0.056
#> GSM22371     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000
#> GSM22372     4  0.5113      0.629 0.000 0.180 0.048 0.728 0.044
#> GSM22373     3  0.2550      0.838 0.004 0.000 0.892 0.020 0.084
#> GSM22375     3  0.2583      0.832 0.000 0.000 0.864 0.004 0.132
#> GSM22376     4  0.2052      0.726 0.004 0.080 0.000 0.912 0.004
#> GSM22377     1  0.0404      0.891 0.988 0.000 0.012 0.000 0.000
#> GSM22378     2  0.0566      0.859 0.000 0.984 0.000 0.012 0.004
#> GSM22379     2  0.0162      0.861 0.000 0.996 0.000 0.000 0.004
#> GSM22380     4  0.5262     -0.114 0.000 0.032 0.008 0.536 0.424
#> GSM22383     4  0.5534      0.577 0.032 0.000 0.260 0.656 0.052
#> GSM22386     2  0.4620      0.253 0.000 0.592 0.392 0.000 0.016
#> GSM22389     3  0.1195      0.832 0.000 0.012 0.960 0.000 0.028
#> GSM22391     3  0.2621      0.834 0.000 0.004 0.876 0.008 0.112
#> GSM22395     3  0.3035      0.820 0.004 0.004 0.844 0.004 0.144
#> GSM22396     4  0.4267      0.698 0.000 0.024 0.116 0.800 0.060
#> GSM22398     5  0.3409      0.663 0.000 0.000 0.160 0.024 0.816
#> GSM22399     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM22402     2  0.0162      0.862 0.000 0.996 0.000 0.004 0.000
#> GSM22407     4  0.1444      0.734 0.000 0.012 0.000 0.948 0.040
#> GSM22411     5  0.2833      0.667 0.004 0.004 0.140 0.000 0.852
#> GSM22412     4  0.4077      0.703 0.012 0.000 0.124 0.804 0.060
#> GSM22415     3  0.6754      0.317 0.364 0.016 0.484 0.008 0.128
#> GSM22416     4  0.4755      0.675 0.044 0.000 0.136 0.768 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5  0.3517     0.7113 0.000 0.004 0.028 0.188 0.780 0.000
#> GSM22374     6  0.0146     0.8056 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM22381     4  0.3046     0.6196 0.112 0.000 0.028 0.848 0.004 0.008
#> GSM22382     5  0.3352     0.7371 0.000 0.000 0.112 0.072 0.816 0.000
#> GSM22384     3  0.5015     0.4608 0.024 0.000 0.692 0.140 0.144 0.000
#> GSM22385     4  0.3328     0.6336 0.112 0.000 0.044 0.832 0.008 0.004
#> GSM22387     6  0.3394     0.7101 0.172 0.000 0.016 0.008 0.004 0.800
#> GSM22388     6  0.0000     0.8060 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22390     1  0.4693     0.5648 0.684 0.000 0.140 0.000 0.176 0.000
#> GSM22392     1  0.3062     0.6021 0.816 0.000 0.160 0.000 0.024 0.000
#> GSM22393     1  0.4204     0.4419 0.716 0.000 0.020 0.244 0.008 0.012
#> GSM22394     1  0.6174     0.0728 0.416 0.000 0.352 0.224 0.008 0.000
#> GSM22397     3  0.3845     0.4574 0.172 0.000 0.768 0.000 0.004 0.056
#> GSM22400     4  0.0790     0.6671 0.000 0.000 0.032 0.968 0.000 0.000
#> GSM22401     4  0.5989     0.2664 0.000 0.012 0.184 0.500 0.304 0.000
#> GSM22403     4  0.3823     0.6053 0.068 0.000 0.024 0.816 0.008 0.084
#> GSM22404     5  0.5034     0.2003 0.000 0.008 0.056 0.404 0.532 0.000
#> GSM22405     5  0.1124     0.8067 0.008 0.036 0.000 0.000 0.956 0.000
#> GSM22406     1  0.3972     0.5754 0.724 0.000 0.244 0.004 0.024 0.004
#> GSM22408     3  0.2932     0.4811 0.164 0.000 0.820 0.000 0.016 0.000
#> GSM22409     4  0.3945     0.4063 0.000 0.000 0.380 0.612 0.008 0.000
#> GSM22410     3  0.6367     0.0861 0.068 0.000 0.504 0.328 0.096 0.004
#> GSM22413     4  0.0862     0.6691 0.004 0.000 0.016 0.972 0.000 0.008
#> GSM22414     2  0.4566    -0.0242 0.000 0.488 0.020 0.484 0.008 0.000
#> GSM22417     1  0.5416     0.5212 0.596 0.004 0.228 0.000 0.172 0.000
#> GSM22418     1  0.1511     0.5765 0.940 0.000 0.012 0.044 0.004 0.000
#> GSM22419     1  0.2512     0.5764 0.900 0.004 0.048 0.032 0.008 0.008
#> GSM22420     6  0.0000     0.8060 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22421     2  0.2070     0.8364 0.000 0.896 0.092 0.000 0.012 0.000
#> GSM22422     2  0.1577     0.8593 0.000 0.940 0.016 0.036 0.008 0.000
#> GSM22423     4  0.3575     0.5346 0.000 0.000 0.284 0.708 0.008 0.000
#> GSM22424     6  0.6217     0.3329 0.364 0.000 0.044 0.104 0.004 0.484
#> GSM22365     2  0.0363     0.8764 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM22366     4  0.5674     0.3556 0.000 0.004 0.320 0.520 0.156 0.000
#> GSM22367     5  0.0984     0.8105 0.008 0.012 0.012 0.000 0.968 0.000
#> GSM22368     5  0.1639     0.8117 0.008 0.008 0.008 0.036 0.940 0.000
#> GSM22370     6  0.6200     0.1486 0.084 0.000 0.024 0.416 0.024 0.452
#> GSM22371     2  0.0363     0.8735 0.012 0.988 0.000 0.000 0.000 0.000
#> GSM22372     4  0.4580     0.4022 0.000 0.040 0.348 0.608 0.004 0.000
#> GSM22373     1  0.4211     0.5264 0.660 0.000 0.312 0.000 0.020 0.008
#> GSM22375     1  0.5117     0.5162 0.596 0.000 0.288 0.000 0.116 0.000
#> GSM22376     4  0.1760     0.6661 0.020 0.028 0.012 0.936 0.004 0.000
#> GSM22377     6  0.0777     0.7928 0.004 0.000 0.024 0.000 0.000 0.972
#> GSM22378     2  0.0520     0.8766 0.000 0.984 0.000 0.008 0.008 0.000
#> GSM22379     2  0.0291     0.8757 0.004 0.992 0.000 0.000 0.004 0.000
#> GSM22380     4  0.5122     0.4922 0.000 0.000 0.192 0.628 0.180 0.000
#> GSM22383     1  0.4149     0.4273 0.712 0.000 0.024 0.248 0.000 0.016
#> GSM22386     2  0.3571     0.7177 0.096 0.816 0.076 0.000 0.012 0.000
#> GSM22389     1  0.4573     0.5423 0.656 0.008 0.288 0.000 0.048 0.000
#> GSM22391     1  0.5268     0.4629 0.568 0.016 0.344 0.000 0.072 0.000
#> GSM22395     3  0.4265     0.1697 0.300 0.000 0.660 0.000 0.040 0.000
#> GSM22396     3  0.4496    -0.0293 0.012 0.004 0.552 0.424 0.008 0.000
#> GSM22398     5  0.2755     0.7486 0.120 0.000 0.012 0.012 0.856 0.000
#> GSM22399     6  0.0000     0.8060 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22402     2  0.0405     0.8764 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM22407     4  0.2755     0.6340 0.108 0.004 0.008 0.864 0.016 0.000
#> GSM22411     5  0.0993     0.8019 0.024 0.000 0.012 0.000 0.964 0.000
#> GSM22412     4  0.5196     0.2932 0.340 0.000 0.036 0.588 0.032 0.004
#> GSM22415     3  0.2529     0.5494 0.028 0.000 0.892 0.004 0.012 0.064
#> GSM22416     1  0.4953     0.1677 0.556 0.000 0.024 0.396 0.008 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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n disease.state(p) k
#> SD:NMF 58            0.205 2
#> SD:NMF 55            0.242 3
#> SD:NMF 43            0.872 4
#> SD:NMF 52            0.518 5
#> SD:NMF 39            0.251 6

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 21446 rows and 60 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 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 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 0.123           0.412       0.754         0.4065 0.560   0.560
#> 3 3 0.129           0.413       0.681         0.4564 0.765   0.605
#> 4 4 0.180           0.404       0.598         0.1236 0.818   0.604
#> 5 5 0.257           0.452       0.605         0.0723 0.872   0.662
#> 6 6 0.350           0.364       0.588         0.0620 0.879   0.636

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
#> GSM22369     1  0.4939     0.6013 0.892 0.108
#> GSM22374     1  0.7219     0.4999 0.800 0.200
#> GSM22381     1  0.9954    -0.2533 0.540 0.460
#> GSM22382     2  0.9933     0.2643 0.452 0.548
#> GSM22384     1  0.7219     0.5185 0.800 0.200
#> GSM22385     2  0.9580     0.6121 0.380 0.620
#> GSM22387     1  0.2603     0.6430 0.956 0.044
#> GSM22388     2  0.9522     0.6212 0.372 0.628
#> GSM22390     1  0.2043     0.6548 0.968 0.032
#> GSM22392     1  0.8713     0.3669 0.708 0.292
#> GSM22393     1  1.0000    -0.4064 0.504 0.496
#> GSM22394     2  0.9358     0.6344 0.352 0.648
#> GSM22397     2  0.9323     0.6340 0.348 0.652
#> GSM22400     1  0.9983    -0.3208 0.524 0.476
#> GSM22401     2  0.9933     0.2643 0.452 0.548
#> GSM22403     1  0.9909    -0.2084 0.556 0.444
#> GSM22404     1  0.4939     0.6013 0.892 0.108
#> GSM22405     1  0.7674     0.5092 0.776 0.224
#> GSM22406     2  0.9358     0.6344 0.352 0.648
#> GSM22408     1  0.1184     0.6559 0.984 0.016
#> GSM22409     1  0.9909    -0.2155 0.556 0.444
#> GSM22410     1  0.0938     0.6540 0.988 0.012
#> GSM22413     1  0.3431     0.6459 0.936 0.064
#> GSM22414     2  0.7674     0.6068 0.224 0.776
#> GSM22417     1  0.2423     0.6532 0.960 0.040
#> GSM22418     2  0.9909     0.5048 0.444 0.556
#> GSM22419     2  0.9358     0.6344 0.352 0.648
#> GSM22420     1  0.7219     0.4999 0.800 0.200
#> GSM22421     2  0.9000     0.2744 0.316 0.684
#> GSM22422     1  0.9998    -0.1908 0.508 0.492
#> GSM22423     1  0.1184     0.6535 0.984 0.016
#> GSM22424     1  0.9866    -0.1755 0.568 0.432
#> GSM22365     2  0.7674     0.4133 0.224 0.776
#> GSM22366     2  0.9661     0.5940 0.392 0.608
#> GSM22367     1  0.6801     0.5226 0.820 0.180
#> GSM22368     1  0.5629     0.5813 0.868 0.132
#> GSM22370     1  0.2778     0.6448 0.952 0.048
#> GSM22371     2  0.5737     0.5009 0.136 0.864
#> GSM22372     1  0.9754    -0.0852 0.592 0.408
#> GSM22373     1  0.9775    -0.0822 0.588 0.412
#> GSM22375     1  0.2778     0.6555 0.952 0.048
#> GSM22376     1  0.9933    -0.2473 0.548 0.452
#> GSM22377     1  0.5408     0.5918 0.876 0.124
#> GSM22378     2  0.4815     0.4772 0.104 0.896
#> GSM22379     1  0.9323     0.2954 0.652 0.348
#> GSM22380     1  0.2423     0.6574 0.960 0.040
#> GSM22383     1  0.5408     0.5931 0.876 0.124
#> GSM22386     1  0.6887     0.5182 0.816 0.184
#> GSM22389     1  0.1184     0.6567 0.984 0.016
#> GSM22391     1  0.1633     0.6563 0.976 0.024
#> GSM22395     1  0.1184     0.6567 0.984 0.016
#> GSM22396     2  0.9983     0.4217 0.476 0.524
#> GSM22398     1  0.2603     0.6517 0.956 0.044
#> GSM22399     1  0.9393     0.1260 0.644 0.356
#> GSM22402     2  0.7815     0.4105 0.232 0.768
#> GSM22407     2  0.8499     0.6031 0.276 0.724
#> GSM22411     1  0.2778     0.6491 0.952 0.048
#> GSM22412     1  0.9754    -0.0852 0.592 0.408
#> GSM22415     1  0.1184     0.6559 0.984 0.016
#> GSM22416     2  0.9358     0.6344 0.352 0.648

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3   0.538     0.6272 0.024 0.188 0.788
#> GSM22374     3   0.822     0.4396 0.172 0.188 0.640
#> GSM22381     2   0.997     0.0882 0.348 0.356 0.296
#> GSM22382     2   0.845     0.3483 0.304 0.580 0.116
#> GSM22384     3   0.826     0.3773 0.152 0.216 0.632
#> GSM22385     1   0.855     0.5093 0.568 0.120 0.312
#> GSM22387     3   0.334     0.6557 0.120 0.000 0.880
#> GSM22388     1   0.941     0.3599 0.508 0.240 0.252
#> GSM22390     3   0.398     0.6805 0.068 0.048 0.884
#> GSM22392     3   0.890     0.3960 0.196 0.232 0.572
#> GSM22393     1   0.992     0.2261 0.368 0.272 0.360
#> GSM22394     1   0.241     0.4726 0.940 0.040 0.020
#> GSM22397     1   0.742     0.5381 0.640 0.060 0.300
#> GSM22400     3   0.991    -0.3494 0.324 0.280 0.396
#> GSM22401     2   0.842     0.3511 0.300 0.584 0.116
#> GSM22403     2   0.980     0.2514 0.324 0.424 0.252
#> GSM22404     3   0.493     0.6412 0.024 0.156 0.820
#> GSM22405     3   0.700     0.5371 0.060 0.248 0.692
#> GSM22406     1   0.703     0.5473 0.676 0.052 0.272
#> GSM22408     3   0.145     0.6847 0.008 0.024 0.968
#> GSM22409     2   0.970     0.2910 0.328 0.440 0.232
#> GSM22410     3   0.313     0.6844 0.052 0.032 0.916
#> GSM22413     3   0.723     0.5649 0.188 0.104 0.708
#> GSM22414     1   0.742     0.2666 0.648 0.288 0.064
#> GSM22417     3   0.438     0.6790 0.064 0.068 0.868
#> GSM22418     1   0.658     0.4371 0.756 0.136 0.108
#> GSM22419     1   0.293     0.4865 0.924 0.040 0.036
#> GSM22420     3   0.822     0.4396 0.172 0.188 0.640
#> GSM22421     2   0.321     0.3423 0.060 0.912 0.028
#> GSM22422     2   0.905     0.3818 0.288 0.540 0.172
#> GSM22423     3   0.347     0.6791 0.056 0.040 0.904
#> GSM22424     3   0.977    -0.2653 0.328 0.244 0.428
#> GSM22365     2   0.487     0.3203 0.144 0.828 0.028
#> GSM22366     1   0.930     0.4590 0.508 0.192 0.300
#> GSM22367     3   0.654     0.5606 0.056 0.212 0.732
#> GSM22368     3   0.689     0.5794 0.076 0.204 0.720
#> GSM22370     3   0.350     0.6599 0.116 0.004 0.880
#> GSM22371     2   0.656     0.2393 0.276 0.692 0.032
#> GSM22372     2   0.977     0.3156 0.308 0.436 0.256
#> GSM22373     3   0.911    -0.1655 0.416 0.140 0.444
#> GSM22375     3   0.500     0.6677 0.072 0.088 0.840
#> GSM22376     3   0.997    -0.3457 0.296 0.340 0.364
#> GSM22377     3   0.676     0.5825 0.108 0.148 0.744
#> GSM22378     2   0.574     0.2383 0.256 0.732 0.012
#> GSM22379     2   0.630    -0.2226 0.000 0.524 0.476
#> GSM22380     3   0.618     0.6377 0.120 0.100 0.780
#> GSM22383     3   0.632     0.6016 0.120 0.108 0.772
#> GSM22386     3   0.685     0.5454 0.072 0.208 0.720
#> GSM22389     3   0.290     0.6843 0.048 0.028 0.924
#> GSM22391     3   0.358     0.6908 0.044 0.056 0.900
#> GSM22395     3   0.290     0.6843 0.048 0.028 0.924
#> GSM22396     1   0.934     0.3586 0.468 0.172 0.360
#> GSM22398     3   0.466     0.6764 0.076 0.068 0.856
#> GSM22399     3   0.951     0.0407 0.264 0.244 0.492
#> GSM22402     2   0.696     0.2597 0.184 0.724 0.092
#> GSM22407     1   0.771     0.1965 0.604 0.332 0.064
#> GSM22411     3   0.398     0.6799 0.048 0.068 0.884
#> GSM22412     2   0.977     0.3156 0.308 0.436 0.256
#> GSM22415     3   0.145     0.6847 0.008 0.024 0.968
#> GSM22416     1   0.227     0.4698 0.944 0.040 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3   0.619     0.6592 0.024 0.140 0.716 0.120
#> GSM22374     3   0.712     0.2709 0.044 0.044 0.496 0.416
#> GSM22381     4   0.795     0.3695 0.112 0.112 0.176 0.600
#> GSM22382     2   0.878     0.2125 0.228 0.492 0.088 0.192
#> GSM22384     3   0.760     0.3839 0.084 0.108 0.624 0.184
#> GSM22385     4   0.741     0.2319 0.268 0.024 0.132 0.576
#> GSM22387     3   0.498     0.6221 0.012 0.008 0.708 0.272
#> GSM22388     4   0.593     0.3217 0.140 0.016 0.116 0.728
#> GSM22390     3   0.273     0.7113 0.032 0.020 0.916 0.032
#> GSM22392     3   0.676     0.3145 0.048 0.032 0.584 0.336
#> GSM22393     4   0.764     0.3667 0.152 0.044 0.208 0.596
#> GSM22394     1   0.454     0.6506 0.752 0.000 0.020 0.228
#> GSM22397     4   0.732     0.1073 0.356 0.016 0.108 0.520
#> GSM22400     4   0.686     0.4093 0.060 0.048 0.256 0.636
#> GSM22401     2   0.880     0.2117 0.228 0.488 0.088 0.196
#> GSM22403     4   0.871     0.2974 0.172 0.164 0.136 0.528
#> GSM22404     3   0.599     0.6738 0.020 0.116 0.728 0.136
#> GSM22405     3   0.601     0.5339 0.036 0.156 0.732 0.076
#> GSM22406     4   0.762     0.0884 0.360 0.012 0.148 0.480
#> GSM22408     3   0.420     0.7003 0.012 0.016 0.812 0.160
#> GSM22409     4   0.889     0.2384 0.188 0.176 0.132 0.504
#> GSM22410     3   0.462     0.6976 0.020 0.020 0.792 0.168
#> GSM22413     3   0.759     0.5230 0.124 0.064 0.616 0.196
#> GSM22414     1   0.889     0.2770 0.428 0.284 0.064 0.224
#> GSM22417     3   0.321     0.7053 0.028 0.028 0.896 0.048
#> GSM22418     1   0.698     0.4680 0.592 0.028 0.076 0.304
#> GSM22419     1   0.478     0.6342 0.732 0.000 0.024 0.244
#> GSM22420     3   0.712     0.2709 0.044 0.044 0.496 0.416
#> GSM22421     2   0.403     0.3237 0.020 0.824 0.008 0.148
#> GSM22422     4   0.958    -0.1282 0.220 0.292 0.132 0.356
#> GSM22423     3   0.495     0.6821 0.016 0.024 0.760 0.200
#> GSM22424     4   0.666     0.3385 0.036 0.056 0.272 0.636
#> GSM22365     2   0.693     0.2348 0.044 0.480 0.032 0.444
#> GSM22366     4   0.651     0.2897 0.196 0.016 0.116 0.672
#> GSM22367     3   0.539     0.5603 0.040 0.160 0.764 0.036
#> GSM22368     3   0.579     0.5962 0.044 0.152 0.748 0.056
#> GSM22370     3   0.488     0.6262 0.008 0.008 0.708 0.276
#> GSM22371     4   0.803    -0.2853 0.092 0.356 0.064 0.488
#> GSM22372     4   0.921     0.2249 0.192 0.204 0.144 0.460
#> GSM22373     3   0.847    -0.1330 0.220 0.032 0.416 0.332
#> GSM22375     3   0.364     0.6938 0.036 0.028 0.876 0.060
#> GSM22376     4   0.697     0.4258 0.044 0.108 0.188 0.660
#> GSM22377     3   0.647     0.5166 0.044 0.028 0.620 0.308
#> GSM22378     4   0.751    -0.3038 0.088 0.392 0.032 0.488
#> GSM22379     2   0.745    -0.1237 0.044 0.456 0.436 0.064
#> GSM22380     3   0.668     0.6345 0.088 0.068 0.700 0.144
#> GSM22383     3   0.593     0.5400 0.028 0.016 0.632 0.324
#> GSM22386     3   0.559     0.5597 0.052 0.156 0.756 0.036
#> GSM22389     3   0.256     0.7139 0.016 0.016 0.920 0.048
#> GSM22391     3   0.463     0.7145 0.036 0.044 0.824 0.096
#> GSM22395     3   0.256     0.7139 0.016 0.016 0.920 0.048
#> GSM22396     4   0.844     0.2977 0.220 0.052 0.228 0.500
#> GSM22398     3   0.329     0.7072 0.028 0.028 0.892 0.052
#> GSM22399     4   0.698     0.1652 0.068 0.024 0.356 0.552
#> GSM22402     2   0.823     0.2007 0.064 0.432 0.104 0.400
#> GSM22407     1   0.869     0.2295 0.420 0.352 0.064 0.164
#> GSM22411     3   0.283     0.7054 0.024 0.040 0.912 0.024
#> GSM22412     4   0.921     0.2249 0.192 0.204 0.144 0.460
#> GSM22415     3   0.420     0.7003 0.012 0.016 0.812 0.160
#> GSM22416     1   0.443     0.6503 0.756 0.000 0.016 0.228

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     3   0.635    0.60575 0.008 0.052 0.644 0.096 0.200
#> GSM22374     4   0.728    0.16872 0.028 0.116 0.352 0.476 0.028
#> GSM22381     4   0.648   -0.05588 0.004 0.008 0.140 0.516 0.332
#> GSM22382     5   0.257    0.40360 0.028 0.004 0.044 0.016 0.908
#> GSM22384     3   0.630    0.38084 0.024 0.008 0.620 0.116 0.232
#> GSM22385     4   0.677    0.38960 0.232 0.044 0.052 0.616 0.056
#> GSM22387     3   0.477    0.47415 0.016 0.004 0.656 0.316 0.008
#> GSM22388     4   0.405    0.46050 0.080 0.008 0.064 0.828 0.020
#> GSM22390     3   0.216    0.65678 0.016 0.004 0.928 0.028 0.024
#> GSM22392     3   0.686    0.09617 0.028 0.068 0.532 0.336 0.036
#> GSM22393     4   0.766    0.37509 0.144 0.008 0.180 0.532 0.136
#> GSM22394     1   0.548    0.88082 0.704 0.000 0.028 0.156 0.112
#> GSM22397     4   0.620    0.28890 0.276 0.072 0.028 0.612 0.012
#> GSM22400     4   0.635    0.51241 0.028 0.028 0.188 0.656 0.100
#> GSM22401     5   0.267    0.40502 0.028 0.004 0.044 0.020 0.904
#> GSM22403     5   0.635    0.26937 0.008 0.008 0.096 0.424 0.464
#> GSM22404     3   0.553    0.61594 0.012 0.004 0.684 0.104 0.196
#> GSM22405     3   0.685    0.46404 0.028 0.220 0.604 0.036 0.112
#> GSM22406     4   0.747    0.32246 0.260 0.072 0.124 0.528 0.016
#> GSM22408     3   0.442    0.63138 0.016 0.008 0.780 0.160 0.036
#> GSM22409     5   0.626    0.37757 0.008 0.008 0.092 0.380 0.512
#> GSM22410     3   0.520    0.61672 0.012 0.056 0.720 0.196 0.016
#> GSM22413     3   0.695    0.43081 0.000 0.052 0.548 0.160 0.240
#> GSM22414     5   0.892    0.13794 0.200 0.240 0.032 0.160 0.368
#> GSM22417     3   0.358    0.65470 0.008 0.060 0.860 0.036 0.036
#> GSM22418     1   0.714    0.68251 0.564 0.004 0.076 0.212 0.144
#> GSM22419     1   0.539    0.87274 0.700 0.000 0.020 0.180 0.100
#> GSM22420     4   0.728    0.16872 0.028 0.116 0.352 0.476 0.028
#> GSM22421     5   0.604   -0.00796 0.080 0.240 0.004 0.036 0.640
#> GSM22422     5   0.666    0.40737 0.016 0.052 0.096 0.216 0.620
#> GSM22423     3   0.519    0.59887 0.016 0.004 0.712 0.200 0.068
#> GSM22424     4   0.622    0.53095 0.024 0.060 0.180 0.676 0.060
#> GSM22365     2   0.634    0.62429 0.040 0.560 0.000 0.320 0.080
#> GSM22366     4   0.563    0.40553 0.204 0.004 0.036 0.688 0.068
#> GSM22367     3   0.636    0.47512 0.028 0.268 0.600 0.008 0.096
#> GSM22368     3   0.530    0.58960 0.008 0.052 0.692 0.016 0.232
#> GSM22370     3   0.500    0.47923 0.016 0.004 0.656 0.304 0.020
#> GSM22371     2   0.843    0.61091 0.112 0.388 0.028 0.328 0.144
#> GSM22372     5   0.628    0.39877 0.008 0.008 0.104 0.336 0.544
#> GSM22373     3   0.818   -0.23145 0.156 0.040 0.420 0.324 0.060
#> GSM22375     3   0.323    0.64457 0.016 0.008 0.876 0.044 0.056
#> GSM22376     4   0.589    0.31182 0.004 0.008 0.124 0.632 0.232
#> GSM22377     3   0.704    0.18146 0.024 0.132 0.468 0.364 0.012
#> GSM22378     2   0.768    0.62572 0.108 0.432 0.000 0.328 0.132
#> GSM22379     2   0.452    0.26726 0.020 0.748 0.208 0.012 0.012
#> GSM22380     3   0.628    0.57086 0.004 0.052 0.644 0.100 0.200
#> GSM22383     3   0.652    0.28232 0.020 0.092 0.504 0.376 0.008
#> GSM22386     3   0.618    0.39464 0.044 0.340 0.564 0.004 0.048
#> GSM22389     3   0.223    0.65822 0.012 0.004 0.920 0.052 0.012
#> GSM22391     3   0.610    0.60250 0.012 0.164 0.680 0.096 0.048
#> GSM22395     3   0.223    0.65822 0.012 0.004 0.920 0.052 0.012
#> GSM22396     4   0.840    0.45161 0.124 0.056 0.176 0.500 0.144
#> GSM22398     3   0.294    0.65830 0.016 0.024 0.896 0.028 0.036
#> GSM22399     4   0.638    0.39272 0.044 0.052 0.276 0.608 0.020
#> GSM22402     2   0.806    0.57346 0.064 0.484 0.060 0.280 0.112
#> GSM22407     5   0.862    0.12573 0.232 0.192 0.028 0.132 0.416
#> GSM22411     3   0.390    0.64326 0.012 0.096 0.836 0.024 0.032
#> GSM22412     5   0.628    0.39877 0.008 0.008 0.104 0.336 0.544
#> GSM22415     3   0.442    0.63138 0.016 0.008 0.780 0.160 0.036
#> GSM22416     1   0.531    0.87827 0.712 0.000 0.020 0.156 0.112

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     3   0.689     0.5313 0.004 0.092 0.580 0.048 0.184 0.092
#> GSM22374     3   0.885    -0.0765 0.060 0.144 0.268 0.256 0.248 0.024
#> GSM22381     5   0.445     0.2864 0.004 0.004 0.080 0.172 0.736 0.004
#> GSM22382     5   0.547    -0.3181 0.028 0.000 0.024 0.020 0.488 0.440
#> GSM22384     3   0.459     0.3345 0.024 0.000 0.628 0.004 0.332 0.012
#> GSM22385     4   0.598     0.5375 0.172 0.000 0.020 0.632 0.136 0.040
#> GSM22387     3   0.595     0.4660 0.028 0.012 0.624 0.164 0.168 0.004
#> GSM22388     4   0.668     0.3618 0.136 0.000 0.040 0.432 0.376 0.016
#> GSM22390     3   0.177     0.5853 0.016 0.004 0.940 0.008 0.012 0.020
#> GSM22392     3   0.776     0.1157 0.048 0.072 0.468 0.272 0.112 0.028
#> GSM22393     5   0.791    -0.2212 0.200 0.000 0.168 0.212 0.392 0.028
#> GSM22394     1   0.174     0.8723 0.920 0.000 0.012 0.000 0.068 0.000
#> GSM22397     4   0.516     0.4165 0.200 0.000 0.004 0.684 0.048 0.064
#> GSM22400     4   0.685     0.3412 0.028 0.008 0.136 0.444 0.360 0.024
#> GSM22401     5   0.546    -0.3125 0.028 0.000 0.024 0.020 0.492 0.436
#> GSM22403     5   0.277     0.4736 0.024 0.004 0.044 0.036 0.888 0.004
#> GSM22404     3   0.524     0.5589 0.000 0.000 0.676 0.048 0.188 0.088
#> GSM22405     3   0.717    -0.0108 0.012 0.344 0.456 0.032 0.064 0.092
#> GSM22406     4   0.686     0.4927 0.228 0.000 0.096 0.552 0.080 0.044
#> GSM22408     3   0.388     0.5972 0.000 0.004 0.788 0.088 0.116 0.004
#> GSM22409     5   0.228     0.5053 0.024 0.004 0.044 0.012 0.912 0.004
#> GSM22410     3   0.620     0.5791 0.004 0.108 0.628 0.104 0.148 0.008
#> GSM22413     3   0.613     0.3277 0.008 0.088 0.452 0.028 0.420 0.004
#> GSM22414     6   0.818     0.5783 0.104 0.020 0.024 0.304 0.224 0.324
#> GSM22417     3   0.454     0.5544 0.008 0.104 0.784 0.040 0.028 0.036
#> GSM22418     1   0.525     0.6771 0.704 0.000 0.080 0.036 0.160 0.020
#> GSM22419     1   0.209     0.8663 0.904 0.000 0.004 0.016 0.076 0.000
#> GSM22420     3   0.885    -0.0765 0.060 0.144 0.268 0.256 0.248 0.024
#> GSM22421     6   0.500     0.3057 0.004 0.072 0.000 0.040 0.180 0.704
#> GSM22422     5   0.464     0.2732 0.012 0.060 0.060 0.004 0.772 0.092
#> GSM22423     3   0.462     0.5691 0.000 0.000 0.692 0.096 0.208 0.004
#> GSM22424     4   0.715     0.3926 0.020 0.036 0.136 0.500 0.276 0.032
#> GSM22365     2   0.710     0.3536 0.052 0.516 0.000 0.092 0.256 0.084
#> GSM22366     4   0.600     0.5358 0.188 0.004 0.000 0.572 0.212 0.024
#> GSM22367     2   0.662    -0.0871 0.016 0.436 0.404 0.004 0.056 0.084
#> GSM22368     3   0.635     0.4886 0.004 0.100 0.624 0.016 0.136 0.120
#> GSM22370     3   0.593     0.4691 0.024 0.012 0.620 0.160 0.180 0.004
#> GSM22371     2   0.856     0.3493 0.148 0.352 0.024 0.096 0.296 0.084
#> GSM22372     5   0.161     0.5174 0.008 0.000 0.056 0.004 0.932 0.000
#> GSM22373     3   0.770    -0.2072 0.164 0.012 0.376 0.332 0.100 0.016
#> GSM22375     3   0.266     0.5719 0.016 0.004 0.888 0.004 0.068 0.020
#> GSM22376     5   0.517    -0.0516 0.012 0.004 0.068 0.280 0.632 0.004
#> GSM22377     3   0.838     0.2301 0.044 0.172 0.392 0.196 0.180 0.016
#> GSM22378     2   0.793     0.3543 0.140 0.400 0.000 0.096 0.288 0.076
#> GSM22379     2   0.146     0.1883 0.000 0.948 0.016 0.000 0.016 0.020
#> GSM22380     3   0.619     0.4825 0.008 0.092 0.560 0.028 0.296 0.016
#> GSM22383     3   0.811     0.3348 0.044 0.120 0.436 0.192 0.192 0.016
#> GSM22386     2   0.584     0.0678 0.016 0.540 0.344 0.000 0.020 0.080
#> GSM22389     3   0.223     0.5981 0.012 0.016 0.916 0.032 0.024 0.000
#> GSM22391     3   0.669     0.2996 0.012 0.364 0.448 0.040 0.132 0.004
#> GSM22395     3   0.213     0.5980 0.012 0.012 0.920 0.032 0.024 0.000
#> GSM22396     4   0.704     0.4341 0.076 0.004 0.120 0.484 0.296 0.020
#> GSM22398     3   0.373     0.5752 0.008 0.044 0.844 0.028 0.040 0.036
#> GSM22399     5   0.816    -0.2384 0.096 0.060 0.224 0.240 0.376 0.004
#> GSM22402     2   0.844     0.3070 0.064 0.440 0.052 0.168 0.196 0.080
#> GSM22407     6   0.819     0.5718 0.192 0.012 0.016 0.240 0.200 0.340
#> GSM22411     3   0.388     0.5149 0.004 0.176 0.776 0.008 0.004 0.032
#> GSM22412     5   0.161     0.5174 0.008 0.000 0.056 0.004 0.932 0.000
#> GSM22415     3   0.388     0.5972 0.000 0.004 0.788 0.088 0.116 0.004
#> GSM22416     1   0.153     0.8723 0.928 0.000 0.004 0.000 0.068 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-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)

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:hclust 37           0.3472 2
#> CV:hclust 27           0.1958 3
#> CV:hclust 27           0.8373 4
#> CV:hclust 26           0.0676 5
#> CV:hclust 24           0.8694 6

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 21446 rows and 60 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.418           0.685       0.805         0.4852 0.501   0.501
#> 3 3 0.199           0.407       0.638         0.3280 0.815   0.647
#> 4 4 0.298           0.299       0.572         0.1339 0.840   0.595
#> 5 5 0.405           0.323       0.561         0.0741 0.858   0.538
#> 6 6 0.503           0.362       0.601         0.0480 0.903   0.593

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
#> GSM22369     1  0.0672      0.671 0.992 0.008
#> GSM22374     1  0.9661      0.717 0.608 0.392
#> GSM22381     2  0.2948      0.807 0.052 0.948
#> GSM22382     1  0.0672      0.671 0.992 0.008
#> GSM22384     1  0.9522      0.725 0.628 0.372
#> GSM22385     2  0.2043      0.807 0.032 0.968
#> GSM22387     1  0.9608      0.718 0.616 0.384
#> GSM22388     2  0.0000      0.806 0.000 1.000
#> GSM22390     1  0.9044      0.750 0.680 0.320
#> GSM22392     2  0.1843      0.799 0.028 0.972
#> GSM22393     2  0.0672      0.805 0.008 0.992
#> GSM22394     2  0.1843      0.806 0.028 0.972
#> GSM22397     2  0.1414      0.807 0.020 0.980
#> GSM22400     2  0.3114      0.806 0.056 0.944
#> GSM22401     2  0.9635      0.568 0.388 0.612
#> GSM22403     2  0.3114      0.806 0.056 0.944
#> GSM22404     1  0.0672      0.671 0.992 0.008
#> GSM22405     1  0.0672      0.667 0.992 0.008
#> GSM22406     2  0.0938      0.809 0.012 0.988
#> GSM22408     1  0.9358      0.738 0.648 0.352
#> GSM22409     2  0.3431      0.804 0.064 0.936
#> GSM22410     1  0.8861      0.745 0.696 0.304
#> GSM22413     1  0.9209      0.731 0.664 0.336
#> GSM22414     2  0.9286      0.599 0.344 0.656
#> GSM22417     1  0.0376      0.672 0.996 0.004
#> GSM22418     2  0.0938      0.803 0.012 0.988
#> GSM22419     2  0.0672      0.805 0.008 0.992
#> GSM22420     1  0.9661      0.717 0.608 0.392
#> GSM22421     1  0.9970     -0.368 0.532 0.468
#> GSM22422     1  0.3879      0.612 0.924 0.076
#> GSM22423     1  0.9248      0.742 0.660 0.340
#> GSM22424     2  0.0672      0.807 0.008 0.992
#> GSM22365     2  0.9635      0.566 0.388 0.612
#> GSM22366     2  0.3733      0.801 0.072 0.928
#> GSM22367     1  0.0672      0.667 0.992 0.008
#> GSM22368     1  0.0938      0.670 0.988 0.012
#> GSM22370     1  0.9460      0.726 0.636 0.364
#> GSM22371     2  0.9661      0.564 0.392 0.608
#> GSM22372     1  0.9552      0.678 0.624 0.376
#> GSM22373     2  0.0938      0.803 0.012 0.988
#> GSM22375     1  0.9044      0.750 0.680 0.320
#> GSM22376     1  0.9661      0.675 0.608 0.392
#> GSM22377     1  0.9661      0.717 0.608 0.392
#> GSM22378     2  0.9608      0.567 0.384 0.616
#> GSM22379     1  0.0672      0.667 0.992 0.008
#> GSM22380     1  0.8443      0.747 0.728 0.272
#> GSM22383     1  0.9608      0.718 0.616 0.384
#> GSM22386     1  0.0376      0.668 0.996 0.004
#> GSM22389     1  0.9044      0.750 0.680 0.320
#> GSM22391     1  0.0938      0.673 0.988 0.012
#> GSM22395     1  0.9044      0.749 0.680 0.320
#> GSM22396     2  0.3114      0.806 0.056 0.944
#> GSM22398     1  0.9248      0.743 0.660 0.340
#> GSM22399     1  0.9963      0.625 0.536 0.464
#> GSM22402     2  0.9661      0.564 0.392 0.608
#> GSM22407     2  0.7815      0.691 0.232 0.768
#> GSM22411     1  0.2948      0.672 0.948 0.052
#> GSM22412     2  0.9795     -0.342 0.416 0.584
#> GSM22415     1  0.8443      0.748 0.728 0.272
#> GSM22416     2  0.0000      0.806 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
#> GSM22369     3   0.615     0.3267 0.008 0.328 0.664
#> GSM22374     3   0.873     0.3888 0.352 0.120 0.528
#> GSM22381     1   0.812     0.5856 0.648 0.180 0.172
#> GSM22382     2   0.708    -0.1675 0.020 0.492 0.488
#> GSM22384     3   0.887     0.4155 0.156 0.288 0.556
#> GSM22385     1   0.639     0.6221 0.752 0.064 0.184
#> GSM22387     3   0.608     0.5237 0.296 0.012 0.692
#> GSM22388     1   0.348     0.6167 0.904 0.048 0.048
#> GSM22390     3   0.399     0.5698 0.124 0.012 0.864
#> GSM22392     1   0.924     0.3669 0.500 0.172 0.328
#> GSM22393     1   0.609     0.6068 0.780 0.144 0.076
#> GSM22394     1   0.448     0.5540 0.864 0.064 0.072
#> GSM22397     1   0.614     0.6103 0.748 0.040 0.212
#> GSM22400     1   0.897     0.5691 0.564 0.196 0.240
#> GSM22401     2   0.937    -0.0981 0.412 0.420 0.168
#> GSM22403     1   0.869     0.5350 0.588 0.248 0.164
#> GSM22404     3   0.650     0.2682 0.008 0.396 0.596
#> GSM22405     2   0.627     0.2436 0.000 0.548 0.452
#> GSM22406     1   0.506     0.6234 0.800 0.016 0.184
#> GSM22408     3   0.398     0.6068 0.068 0.048 0.884
#> GSM22409     1   0.941     0.4720 0.508 0.256 0.236
#> GSM22410     3   0.389     0.5947 0.064 0.048 0.888
#> GSM22413     3   0.795     0.4736 0.104 0.260 0.636
#> GSM22414     1   0.777     0.2262 0.560 0.384 0.056
#> GSM22417     3   0.475     0.4406 0.008 0.184 0.808
#> GSM22418     1   0.333     0.5791 0.904 0.020 0.076
#> GSM22419     1   0.314     0.5793 0.912 0.020 0.068
#> GSM22420     3   0.856     0.4008 0.352 0.108 0.540
#> GSM22421     2   0.417     0.4107 0.104 0.868 0.028
#> GSM22422     2   0.535     0.3970 0.036 0.804 0.160
#> GSM22423     3   0.735     0.4726 0.068 0.268 0.664
#> GSM22424     1   0.932     0.5410 0.516 0.212 0.272
#> GSM22365     2   0.658    -0.0143 0.420 0.572 0.008
#> GSM22366     1   0.778     0.5988 0.668 0.124 0.208
#> GSM22367     2   0.613     0.2732 0.000 0.600 0.400
#> GSM22368     3   0.697     0.1601 0.020 0.416 0.564
#> GSM22370     3   0.535     0.5627 0.176 0.028 0.796
#> GSM22371     1   0.665     0.0995 0.536 0.456 0.008
#> GSM22372     3   0.902     0.2817 0.140 0.364 0.496
#> GSM22373     1   0.754     0.5332 0.688 0.120 0.192
#> GSM22375     3   0.732     0.5233 0.104 0.196 0.700
#> GSM22376     3   0.921     0.2345 0.276 0.196 0.528
#> GSM22377     3   0.824     0.4883 0.300 0.104 0.596
#> GSM22378     1   0.662     0.1335 0.556 0.436 0.008
#> GSM22379     2   0.575     0.3914 0.004 0.700 0.296
#> GSM22380     3   0.554     0.5601 0.052 0.144 0.804
#> GSM22383     3   0.706     0.5143 0.300 0.044 0.656
#> GSM22386     2   0.628     0.1853 0.000 0.540 0.460
#> GSM22389     3   0.497     0.5822 0.100 0.060 0.840
#> GSM22391     3   0.702     0.1479 0.024 0.392 0.584
#> GSM22395     3   0.375     0.5771 0.096 0.020 0.884
#> GSM22396     1   0.883     0.5618 0.560 0.152 0.288
#> GSM22398     3   0.274     0.5980 0.052 0.020 0.928
#> GSM22399     1   0.986    -0.1415 0.416 0.296 0.288
#> GSM22402     2   0.645     0.2237 0.264 0.704 0.032
#> GSM22407     1   0.875     0.3303 0.492 0.396 0.112
#> GSM22411     3   0.660     0.3733 0.036 0.268 0.696
#> GSM22412     1   0.999     0.1112 0.348 0.312 0.340
#> GSM22415     3   0.501     0.5945 0.076 0.084 0.840
#> GSM22416     1   0.347     0.5702 0.904 0.040 0.056

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3   0.815     0.3172 0.048 0.332 0.488 0.132
#> GSM22374     4   0.812     0.1534 0.212 0.016 0.348 0.424
#> GSM22381     4   0.520     0.3214 0.188 0.052 0.008 0.752
#> GSM22382     2   0.876    -0.1954 0.092 0.420 0.360 0.128
#> GSM22384     3   0.895     0.2802 0.204 0.288 0.432 0.076
#> GSM22385     4   0.639     0.1565 0.264 0.044 0.036 0.656
#> GSM22387     3   0.696     0.3079 0.228 0.004 0.600 0.168
#> GSM22388     1   0.601     0.2085 0.588 0.012 0.028 0.372
#> GSM22390     3   0.350     0.5066 0.060 0.016 0.880 0.044
#> GSM22392     4   0.838     0.2290 0.188 0.036 0.336 0.440
#> GSM22393     4   0.703     0.1771 0.364 0.028 0.064 0.544
#> GSM22394     1   0.344     0.4906 0.884 0.020 0.040 0.056
#> GSM22397     1   0.744     0.1508 0.452 0.040 0.068 0.440
#> GSM22400     4   0.391     0.4236 0.080 0.012 0.052 0.856
#> GSM22401     2   0.943     0.0672 0.340 0.356 0.148 0.156
#> GSM22403     4   0.631     0.3046 0.176 0.124 0.012 0.688
#> GSM22404     3   0.854     0.2653 0.052 0.348 0.432 0.168
#> GSM22405     2   0.659     0.3072 0.004 0.552 0.368 0.076
#> GSM22406     1   0.733     0.1810 0.476 0.024 0.084 0.416
#> GSM22408     3   0.530     0.5037 0.028 0.036 0.760 0.176
#> GSM22409     4   0.779     0.2658 0.212 0.136 0.060 0.592
#> GSM22410     3   0.585     0.5251 0.008 0.076 0.704 0.212
#> GSM22413     3   0.902     0.3146 0.060 0.300 0.372 0.268
#> GSM22414     1   0.853     0.2928 0.412 0.240 0.032 0.316
#> GSM22417     3   0.473     0.4747 0.008 0.128 0.800 0.064
#> GSM22418     1   0.415     0.4709 0.828 0.000 0.072 0.100
#> GSM22419     1   0.407     0.4696 0.832 0.000 0.064 0.104
#> GSM22420     4   0.812     0.1347 0.208 0.016 0.364 0.412
#> GSM22421     2   0.475     0.4170 0.052 0.804 0.016 0.128
#> GSM22422     2   0.597     0.4082 0.092 0.752 0.060 0.096
#> GSM22423     3   0.824     0.3470 0.020 0.280 0.448 0.252
#> GSM22424     4   0.483     0.3982 0.084 0.036 0.064 0.816
#> GSM22365     2   0.738    -0.0358 0.252 0.544 0.004 0.200
#> GSM22366     4   0.644     0.2331 0.252 0.032 0.056 0.660
#> GSM22367     2   0.474     0.3523 0.004 0.696 0.296 0.004
#> GSM22368     3   0.832     0.2332 0.068 0.364 0.456 0.112
#> GSM22370     3   0.521     0.4024 0.008 0.004 0.624 0.364
#> GSM22371     1   0.709     0.2275 0.448 0.440 0.004 0.108
#> GSM22372     4   0.908    -0.1086 0.076 0.340 0.212 0.372
#> GSM22373     4   0.839     0.1179 0.360 0.032 0.196 0.412
#> GSM22375     3   0.604     0.4445 0.064 0.196 0.712 0.028
#> GSM22376     4   0.553     0.4076 0.004 0.084 0.180 0.732
#> GSM22377     3   0.909     0.0167 0.216 0.080 0.404 0.300
#> GSM22378     1   0.666     0.2421 0.472 0.444 0.000 0.084
#> GSM22379     2   0.531     0.4419 0.012 0.736 0.212 0.040
#> GSM22380     3   0.733     0.4499 0.012 0.240 0.576 0.172
#> GSM22383     3   0.843     0.3110 0.220 0.068 0.524 0.188
#> GSM22386     2   0.521     0.1972 0.004 0.588 0.404 0.004
#> GSM22389     3   0.500     0.4882 0.040 0.052 0.804 0.104
#> GSM22391     3   0.594     0.1256 0.008 0.428 0.540 0.024
#> GSM22395     3   0.287     0.5101 0.036 0.012 0.908 0.044
#> GSM22396     4   0.599     0.3557 0.128 0.048 0.080 0.744
#> GSM22398     3   0.551     0.5325 0.020 0.052 0.744 0.184
#> GSM22399     4   0.870     0.3008 0.224 0.144 0.116 0.516
#> GSM22402     2   0.680     0.3125 0.080 0.656 0.040 0.224
#> GSM22407     4   0.872    -0.1014 0.320 0.208 0.052 0.420
#> GSM22411     3   0.509     0.4124 0.044 0.228 0.728 0.000
#> GSM22412     4   0.722     0.3739 0.100 0.188 0.064 0.648
#> GSM22415     3   0.518     0.5268 0.000 0.052 0.728 0.220
#> GSM22416     1   0.370     0.5027 0.868 0.020 0.032 0.080

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5   0.693     0.2771 0.000 0.180 0.292 0.028 0.500
#> GSM22374     4   0.822     0.1181 0.188 0.064 0.324 0.396 0.028
#> GSM22381     4   0.600     0.3446 0.136 0.008 0.000 0.600 0.256
#> GSM22382     5   0.466     0.5142 0.000 0.072 0.152 0.016 0.760
#> GSM22384     5   0.611     0.3551 0.112 0.004 0.276 0.012 0.596
#> GSM22385     4   0.657     0.2401 0.152 0.048 0.032 0.660 0.108
#> GSM22387     3   0.568     0.4332 0.220 0.004 0.672 0.080 0.024
#> GSM22388     1   0.642     0.3367 0.584 0.016 0.048 0.304 0.048
#> GSM22390     3   0.285     0.5449 0.016 0.016 0.896 0.016 0.056
#> GSM22392     4   0.705     0.1709 0.072 0.076 0.412 0.436 0.004
#> GSM22393     4   0.763     0.2267 0.276 0.032 0.056 0.512 0.124
#> GSM22394     1   0.298     0.6320 0.888 0.008 0.044 0.012 0.048
#> GSM22397     1   0.750     0.2062 0.428 0.044 0.036 0.400 0.092
#> GSM22400     4   0.478     0.4299 0.048 0.040 0.036 0.800 0.076
#> GSM22401     5   0.643     0.4212 0.128 0.104 0.044 0.044 0.680
#> GSM22403     4   0.619     0.1655 0.120 0.004 0.000 0.476 0.400
#> GSM22404     5   0.438     0.5008 0.000 0.024 0.192 0.024 0.760
#> GSM22405     2   0.506     0.4564 0.000 0.700 0.224 0.064 0.012
#> GSM22406     1   0.729     0.2758 0.484 0.036 0.048 0.360 0.072
#> GSM22408     3   0.578     0.4745 0.020 0.020 0.704 0.132 0.124
#> GSM22409     5   0.642    -0.1396 0.108 0.004 0.012 0.388 0.488
#> GSM22410     3   0.714     0.2762 0.000 0.092 0.552 0.132 0.224
#> GSM22413     5   0.735     0.4405 0.008 0.108 0.204 0.120 0.560
#> GSM22414     4   0.865    -0.0893 0.272 0.180 0.008 0.336 0.204
#> GSM22417     3   0.500     0.4646 0.000 0.148 0.732 0.012 0.108
#> GSM22418     1   0.267     0.6467 0.892 0.000 0.060 0.044 0.004
#> GSM22419     1   0.275     0.6476 0.888 0.000 0.060 0.048 0.004
#> GSM22420     4   0.823     0.0890 0.188 0.064 0.344 0.376 0.028
#> GSM22421     2   0.561     0.4824 0.012 0.676 0.004 0.108 0.200
#> GSM22422     5   0.512     0.2250 0.016 0.284 0.012 0.020 0.668
#> GSM22423     5   0.623     0.4092 0.012 0.004 0.228 0.152 0.604
#> GSM22424     4   0.423     0.4100 0.032 0.060 0.040 0.832 0.036
#> GSM22365     2   0.603     0.4535 0.164 0.656 0.004 0.152 0.024
#> GSM22366     4   0.686     0.2163 0.192 0.028 0.012 0.576 0.192
#> GSM22367     2   0.561     0.3139 0.000 0.632 0.228 0.000 0.140
#> GSM22368     5   0.639     0.3401 0.000 0.164 0.268 0.012 0.556
#> GSM22370     3   0.630     0.3662 0.004 0.020 0.612 0.216 0.148
#> GSM22371     2   0.692     0.1087 0.404 0.444 0.004 0.112 0.036
#> GSM22372     5   0.487     0.3676 0.008 0.008 0.044 0.220 0.720
#> GSM22373     4   0.750     0.0944 0.312 0.052 0.180 0.452 0.004
#> GSM22375     3   0.484     0.2833 0.016 0.012 0.660 0.004 0.308
#> GSM22376     4   0.614     0.3002 0.000 0.004 0.144 0.556 0.296
#> GSM22377     3   0.862     0.0728 0.180 0.144 0.384 0.272 0.020
#> GSM22378     2   0.655     0.0737 0.420 0.452 0.000 0.100 0.028
#> GSM22379     2   0.361     0.5323 0.004 0.852 0.076 0.024 0.044
#> GSM22380     5   0.791     0.1166 0.000 0.172 0.344 0.104 0.380
#> GSM22383     3   0.726     0.4247 0.208 0.080 0.584 0.104 0.024
#> GSM22386     2   0.596     0.1282 0.000 0.528 0.352 0.000 0.120
#> GSM22389     3   0.444     0.5113 0.012 0.032 0.808 0.052 0.096
#> GSM22391     3   0.645     0.1229 0.000 0.380 0.440 0.000 0.180
#> GSM22395     3   0.166     0.5488 0.008 0.008 0.948 0.008 0.028
#> GSM22396     4   0.580     0.3967 0.052 0.068 0.040 0.732 0.108
#> GSM22398     3   0.639     0.3152 0.000 0.080 0.592 0.056 0.272
#> GSM22399     4   0.929     0.2215 0.208 0.120 0.108 0.388 0.176
#> GSM22402     2   0.543     0.4853 0.040 0.700 0.008 0.212 0.040
#> GSM22407     4   0.821     0.1297 0.152 0.128 0.008 0.384 0.328
#> GSM22411     3   0.601     0.3205 0.000 0.220 0.600 0.004 0.176
#> GSM22412     4   0.564     0.1236 0.032 0.000 0.024 0.484 0.460
#> GSM22415     3   0.649     0.3731 0.008 0.024 0.608 0.156 0.204
#> GSM22416     1   0.257     0.6430 0.908 0.008 0.040 0.008 0.036

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5   0.525    0.39123 0.000 0.140 0.188 0.004 0.656 0.012
#> GSM22374     6   0.409    0.47803 0.000 0.004 0.196 0.032 0.016 0.752
#> GSM22381     4   0.469    0.45204 0.048 0.008 0.000 0.752 0.068 0.124
#> GSM22382     5   0.284    0.54178 0.004 0.032 0.064 0.016 0.880 0.004
#> GSM22384     5   0.629    0.38415 0.164 0.000 0.164 0.036 0.604 0.032
#> GSM22385     4   0.703    0.32020 0.132 0.052 0.012 0.524 0.028 0.252
#> GSM22387     3   0.641    0.21787 0.172 0.004 0.536 0.012 0.024 0.252
#> GSM22388     6   0.662    0.07304 0.204 0.024 0.004 0.328 0.004 0.436
#> GSM22390     3   0.252    0.51371 0.008 0.008 0.888 0.000 0.016 0.080
#> GSM22392     6   0.625    0.17878 0.024 0.028 0.400 0.084 0.000 0.464
#> GSM22393     4   0.718    0.11707 0.100 0.028 0.024 0.472 0.048 0.328
#> GSM22394     1   0.253    0.91612 0.884 0.000 0.000 0.012 0.024 0.080
#> GSM22397     4   0.700    0.28159 0.312 0.048 0.020 0.488 0.016 0.116
#> GSM22400     4   0.571    0.23823 0.016 0.024 0.004 0.516 0.044 0.396
#> GSM22401     5   0.503    0.44152 0.076 0.072 0.004 0.072 0.752 0.024
#> GSM22403     4   0.503    0.45671 0.056 0.004 0.000 0.696 0.196 0.048
#> GSM22404     5   0.365    0.49889 0.004 0.008 0.176 0.020 0.788 0.004
#> GSM22405     2   0.534    0.49773 0.020 0.708 0.156 0.012 0.024 0.080
#> GSM22406     4   0.610    0.31181 0.312 0.044 0.012 0.560 0.008 0.064
#> GSM22408     3   0.557    0.47932 0.028 0.020 0.720 0.104 0.080 0.048
#> GSM22409     4   0.466    0.38027 0.056 0.008 0.000 0.676 0.256 0.004
#> GSM22410     3   0.762    0.16808 0.008 0.064 0.440 0.164 0.280 0.044
#> GSM22413     5   0.612    0.50192 0.004 0.072 0.104 0.116 0.664 0.040
#> GSM22414     4   0.896    0.11044 0.184 0.136 0.004 0.256 0.240 0.180
#> GSM22417     3   0.542    0.45973 0.020 0.136 0.716 0.016 0.076 0.036
#> GSM22418     1   0.354    0.90137 0.828 0.000 0.032 0.024 0.008 0.108
#> GSM22419     1   0.318    0.90504 0.832 0.000 0.004 0.024 0.008 0.132
#> GSM22420     6   0.412    0.47501 0.000 0.004 0.200 0.032 0.016 0.748
#> GSM22421     2   0.492    0.49849 0.012 0.696 0.004 0.024 0.224 0.040
#> GSM22422     5   0.620    0.35199 0.028 0.204 0.008 0.180 0.576 0.004
#> GSM22423     5   0.628    0.37843 0.020 0.008 0.188 0.200 0.572 0.012
#> GSM22424     6   0.564   -0.24480 0.012 0.028 0.008 0.412 0.032 0.508
#> GSM22365     2   0.495    0.53289 0.084 0.732 0.000 0.112 0.004 0.068
#> GSM22366     4   0.410    0.45603 0.100 0.032 0.000 0.804 0.024 0.040
#> GSM22367     2   0.645    0.36052 0.020 0.608 0.160 0.032 0.160 0.020
#> GSM22368     5   0.550    0.40435 0.004 0.132 0.176 0.008 0.660 0.020
#> GSM22370     3   0.741    0.27556 0.004 0.016 0.484 0.148 0.196 0.152
#> GSM22371     2   0.690    0.30163 0.276 0.512 0.000 0.084 0.028 0.100
#> GSM22372     5   0.525    0.19397 0.016 0.012 0.024 0.384 0.556 0.008
#> GSM22373     6   0.729    0.14376 0.260 0.032 0.112 0.100 0.004 0.492
#> GSM22375     3   0.468    0.35617 0.012 0.012 0.680 0.000 0.260 0.036
#> GSM22376     4   0.615    0.38401 0.008 0.012 0.100 0.648 0.112 0.120
#> GSM22377     6   0.575    0.33836 0.000 0.068 0.212 0.028 0.044 0.648
#> GSM22378     2   0.696    0.25756 0.284 0.492 0.000 0.136 0.028 0.060
#> GSM22379     2   0.319    0.55443 0.000 0.860 0.052 0.004 0.044 0.040
#> GSM22380     5   0.745    0.28798 0.000 0.132 0.228 0.116 0.484 0.040
#> GSM22383     3   0.811    0.12867 0.156 0.056 0.392 0.020 0.076 0.300
#> GSM22386     2   0.671   -0.04939 0.020 0.432 0.412 0.032 0.084 0.020
#> GSM22389     3   0.338    0.50332 0.008 0.016 0.844 0.000 0.056 0.076
#> GSM22391     3   0.684   -0.00635 0.020 0.368 0.460 0.036 0.096 0.020
#> GSM22395     3   0.153    0.52349 0.008 0.008 0.944 0.000 0.004 0.036
#> GSM22396     4   0.664    0.22777 0.040 0.040 0.004 0.440 0.068 0.408
#> GSM22398     3   0.691    0.19331 0.008 0.056 0.492 0.060 0.332 0.052
#> GSM22399     6   0.555    0.30067 0.008 0.016 0.020 0.276 0.056 0.624
#> GSM22402     2   0.507    0.52895 0.020 0.712 0.000 0.040 0.052 0.176
#> GSM22407     5   0.829   -0.16707 0.124 0.060 0.004 0.204 0.364 0.244
#> GSM22411     3   0.665    0.31955 0.020 0.176 0.568 0.012 0.188 0.036
#> GSM22412     4   0.559    0.40400 0.028 0.008 0.000 0.616 0.260 0.088
#> GSM22415     3   0.660    0.38173 0.020 0.020 0.596 0.176 0.148 0.040
#> GSM22416     1   0.232    0.91120 0.892 0.000 0.000 0.004 0.024 0.080

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:kmeans 58           0.2558 2
#> CV:kmeans 28           0.0689 3
#> CV:kmeans  7           1.0000 4
#> CV:kmeans 10           0.2512 5
#> CV:kmeans 12           0.0965 6

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 21446 rows and 60 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 0.383           0.691       0.847         0.5055 0.492   0.492
#> 3 3 0.277           0.314       0.636         0.3210 0.790   0.614
#> 4 4 0.350           0.205       0.550         0.1256 0.716   0.390
#> 5 5 0.415           0.248       0.526         0.0677 0.742   0.278
#> 6 6 0.477           0.254       0.524         0.0414 0.866   0.452

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
#> GSM22369     1  0.0000      0.804 1.000 0.000
#> GSM22374     1  0.9922      0.481 0.552 0.448
#> GSM22381     2  0.0000      0.793 0.000 1.000
#> GSM22382     1  0.0000      0.804 1.000 0.000
#> GSM22384     1  0.8813      0.681 0.700 0.300
#> GSM22385     2  0.0000      0.793 0.000 1.000
#> GSM22387     1  0.9710      0.569 0.600 0.400
#> GSM22388     2  0.0000      0.793 0.000 1.000
#> GSM22390     1  0.2043      0.806 0.968 0.032
#> GSM22392     2  0.5946      0.749 0.144 0.856
#> GSM22393     2  0.0000      0.793 0.000 1.000
#> GSM22394     2  0.6712      0.735 0.176 0.824
#> GSM22397     2  0.0000      0.793 0.000 1.000
#> GSM22400     2  0.0000      0.793 0.000 1.000
#> GSM22401     2  0.9710      0.535 0.400 0.600
#> GSM22403     2  0.0000      0.793 0.000 1.000
#> GSM22404     1  0.0000      0.804 1.000 0.000
#> GSM22405     1  0.0000      0.804 1.000 0.000
#> GSM22406     2  0.0000      0.793 0.000 1.000
#> GSM22408     1  0.8016      0.728 0.756 0.244
#> GSM22409     2  0.6623      0.740 0.172 0.828
#> GSM22410     1  0.7376      0.749 0.792 0.208
#> GSM22413     1  0.9522      0.601 0.628 0.372
#> GSM22414     2  0.7950      0.694 0.240 0.760
#> GSM22417     1  0.0000      0.804 1.000 0.000
#> GSM22418     2  0.0000      0.793 0.000 1.000
#> GSM22419     2  0.0000      0.793 0.000 1.000
#> GSM22420     1  0.9833      0.529 0.576 0.424
#> GSM22421     2  0.9993      0.385 0.484 0.516
#> GSM22422     1  0.3274      0.757 0.940 0.060
#> GSM22423     1  0.8081      0.726 0.752 0.248
#> GSM22424     2  0.0000      0.793 0.000 1.000
#> GSM22365     2  0.9580      0.561 0.380 0.620
#> GSM22366     2  0.4562      0.769 0.096 0.904
#> GSM22367     1  0.0000      0.804 1.000 0.000
#> GSM22368     1  0.0000      0.804 1.000 0.000
#> GSM22370     1  0.9710      0.569 0.600 0.400
#> GSM22371     2  0.9710      0.535 0.400 0.600
#> GSM22372     1  0.6623      0.738 0.828 0.172
#> GSM22373     2  0.0000      0.793 0.000 1.000
#> GSM22375     1  0.2423      0.805 0.960 0.040
#> GSM22376     2  0.9933     -0.261 0.452 0.548
#> GSM22377     1  0.9710      0.569 0.600 0.400
#> GSM22378     2  0.9522      0.571 0.372 0.628
#> GSM22379     1  0.0000      0.804 1.000 0.000
#> GSM22380     1  0.2948      0.802 0.948 0.052
#> GSM22383     1  0.9710      0.569 0.600 0.400
#> GSM22386     1  0.0000      0.804 1.000 0.000
#> GSM22389     1  0.0938      0.805 0.988 0.012
#> GSM22391     1  0.0000      0.804 1.000 0.000
#> GSM22395     1  0.3274      0.802 0.940 0.060
#> GSM22396     2  0.3274      0.782 0.060 0.940
#> GSM22398     1  0.6712      0.766 0.824 0.176
#> GSM22399     2  0.9963     -0.299 0.464 0.536
#> GSM22402     2  0.9710      0.535 0.400 0.600
#> GSM22407     2  0.7376      0.716 0.208 0.792
#> GSM22411     1  0.0000      0.804 1.000 0.000
#> GSM22412     2  0.3733      0.732 0.072 0.928
#> GSM22415     1  0.7219      0.754 0.800 0.200
#> GSM22416     2  0.0376      0.792 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3  0.4654    0.36553 0.208 0.000 0.792
#> GSM22374     2  0.9730   -0.31725 0.228 0.420 0.352
#> GSM22381     2  0.6286    0.18829 0.464 0.536 0.000
#> GSM22382     3  0.6460    0.00923 0.440 0.004 0.556
#> GSM22384     1  0.9528    0.08925 0.484 0.288 0.228
#> GSM22385     2  0.5678    0.44290 0.316 0.684 0.000
#> GSM22387     3  0.9364    0.34892 0.172 0.372 0.456
#> GSM22388     2  0.2711    0.51786 0.088 0.912 0.000
#> GSM22390     3  0.9026    0.43427 0.196 0.248 0.556
#> GSM22392     2  0.7458    0.31701 0.196 0.692 0.112
#> GSM22393     2  0.4209    0.51881 0.128 0.856 0.016
#> GSM22394     2  0.4994    0.45345 0.112 0.836 0.052
#> GSM22397     2  0.5291    0.47298 0.268 0.732 0.000
#> GSM22400     2  0.6192    0.39149 0.420 0.580 0.000
#> GSM22401     3  0.9989   -0.23777 0.336 0.312 0.352
#> GSM22403     1  0.6180    0.07798 0.584 0.416 0.000
#> GSM22404     3  0.6280   -0.01955 0.460 0.000 0.540
#> GSM22405     3  0.4371    0.43214 0.108 0.032 0.860
#> GSM22406     2  0.4974    0.49394 0.236 0.764 0.000
#> GSM22408     3  0.9560    0.39031 0.324 0.212 0.464
#> GSM22409     1  0.7728    0.27356 0.640 0.276 0.084
#> GSM22410     3  0.6460    0.29390 0.440 0.004 0.556
#> GSM22413     1  0.7571    0.29004 0.592 0.052 0.356
#> GSM22414     2  0.8173    0.41945 0.100 0.600 0.300
#> GSM22417     3  0.4915    0.46567 0.184 0.012 0.804
#> GSM22418     2  0.1289    0.51802 0.032 0.968 0.000
#> GSM22419     2  0.0892    0.52020 0.020 0.980 0.000
#> GSM22420     3  0.9755    0.28215 0.228 0.376 0.396
#> GSM22421     3  0.9391   -0.11467 0.304 0.200 0.496
#> GSM22422     3  0.6735   -0.08742 0.424 0.012 0.564
#> GSM22423     1  0.6659    0.28997 0.668 0.028 0.304
#> GSM22424     2  0.6451    0.36973 0.436 0.560 0.004
#> GSM22365     2  0.7424    0.39153 0.044 0.592 0.364
#> GSM22366     2  0.7693    0.38908 0.364 0.580 0.056
#> GSM22367     3  0.2537    0.39910 0.080 0.000 0.920
#> GSM22368     3  0.5138    0.26244 0.252 0.000 0.748
#> GSM22370     3  0.8972    0.23032 0.412 0.128 0.460
#> GSM22371     2  0.6832    0.38402 0.020 0.604 0.376
#> GSM22372     1  0.6129    0.41008 0.700 0.016 0.284
#> GSM22373     2  0.3682    0.46971 0.116 0.876 0.008
#> GSM22375     3  0.9582    0.28534 0.264 0.256 0.480
#> GSM22376     1  0.8077    0.35964 0.652 0.176 0.172
#> GSM22377     3  0.9612    0.31164 0.204 0.372 0.424
#> GSM22378     2  0.7533    0.39654 0.052 0.600 0.348
#> GSM22379     3  0.2400    0.41457 0.064 0.004 0.932
#> GSM22380     3  0.6665    0.35855 0.276 0.036 0.688
#> GSM22383     3  0.9260    0.34826 0.160 0.376 0.464
#> GSM22386     3  0.3091    0.42860 0.072 0.016 0.912
#> GSM22389     3  0.9141    0.43861 0.244 0.212 0.544
#> GSM22391     3  0.4411    0.39186 0.140 0.016 0.844
#> GSM22395     3  0.9325    0.42143 0.228 0.252 0.520
#> GSM22396     2  0.7263    0.41782 0.400 0.568 0.032
#> GSM22398     3  0.7401    0.41046 0.340 0.048 0.612
#> GSM22399     2  0.9633   -0.13842 0.300 0.464 0.236
#> GSM22402     2  0.7699    0.32110 0.048 0.532 0.420
#> GSM22407     2  0.9573    0.21006 0.328 0.460 0.212
#> GSM22411     3  0.4902    0.46303 0.092 0.064 0.844
#> GSM22412     1  0.7124    0.36092 0.656 0.296 0.048
#> GSM22415     3  0.6180    0.30690 0.416 0.000 0.584
#> GSM22416     2  0.0747    0.52092 0.016 0.984 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3   0.657    0.01695 0.016 0.044 0.508 0.432
#> GSM22374     1   0.468    0.51524 0.824 0.044 0.088 0.044
#> GSM22381     2   0.629    0.38445 0.160 0.716 0.044 0.080
#> GSM22382     4   0.525    0.17702 0.016 0.032 0.212 0.740
#> GSM22384     4   0.525    0.27006 0.200 0.020 0.032 0.748
#> GSM22385     2   0.514    0.38996 0.188 0.752 0.004 0.056
#> GSM22387     1   0.752    0.24198 0.536 0.012 0.288 0.164
#> GSM22388     2   0.558    0.21307 0.468 0.516 0.008 0.008
#> GSM22390     3   0.777   -0.14144 0.240 0.000 0.384 0.376
#> GSM22392     1   0.794    0.30442 0.600 0.176 0.100 0.124
#> GSM22393     2   0.724    0.21647 0.432 0.472 0.064 0.032
#> GSM22394     2   0.796    0.27108 0.392 0.456 0.044 0.108
#> GSM22397     2   0.410    0.44768 0.088 0.832 0.000 0.080
#> GSM22400     2   0.531    0.18902 0.392 0.596 0.004 0.008
#> GSM22401     4   0.880   -0.19566 0.048 0.328 0.236 0.388
#> GSM22403     2   0.663    0.37768 0.136 0.672 0.020 0.172
#> GSM22404     4   0.569    0.25940 0.012 0.080 0.176 0.732
#> GSM22405     3   0.482    0.31140 0.112 0.024 0.808 0.056
#> GSM22406     2   0.388    0.44900 0.068 0.852 0.004 0.076
#> GSM22408     4   0.850    0.18738 0.224 0.060 0.212 0.504
#> GSM22409     2   0.766    0.33313 0.088 0.576 0.064 0.272
#> GSM22410     3   0.906   -0.13348 0.092 0.172 0.392 0.344
#> GSM22413     4   0.863    0.18588 0.072 0.208 0.220 0.500
#> GSM22414     2   0.821    0.36682 0.176 0.512 0.268 0.044
#> GSM22417     3   0.698    0.08868 0.088 0.016 0.568 0.328
#> GSM22418     2   0.624    0.24116 0.448 0.504 0.004 0.044
#> GSM22419     2   0.604    0.26090 0.436 0.528 0.008 0.028
#> GSM22420     1   0.574    0.51860 0.760 0.040 0.116 0.084
#> GSM22421     3   0.889    0.03615 0.136 0.164 0.504 0.196
#> GSM22422     3   0.687    0.03865 0.040 0.036 0.528 0.396
#> GSM22423     4   0.627    0.30760 0.040 0.200 0.060 0.700
#> GSM22424     1   0.546   -0.13395 0.504 0.484 0.008 0.004
#> GSM22365     2   0.668    0.29550 0.056 0.484 0.448 0.012
#> GSM22366     2   0.347    0.45660 0.048 0.884 0.024 0.044
#> GSM22367     3   0.240    0.33080 0.004 0.000 0.904 0.092
#> GSM22368     3   0.655    0.15774 0.048 0.024 0.600 0.328
#> GSM22370     3   0.986   -0.14258 0.256 0.180 0.316 0.248
#> GSM22371     2   0.686    0.33826 0.064 0.512 0.408 0.016
#> GSM22372     4   0.832    0.12871 0.048 0.240 0.200 0.512
#> GSM22373     1   0.613    0.03206 0.600 0.344 0.004 0.052
#> GSM22375     4   0.635    0.21995 0.136 0.004 0.192 0.668
#> GSM22376     2   0.925    0.00841 0.220 0.452 0.184 0.144
#> GSM22377     1   0.696    0.41341 0.576 0.036 0.332 0.056
#> GSM22378     2   0.665    0.37500 0.040 0.560 0.372 0.028
#> GSM22379     3   0.368    0.32382 0.084 0.008 0.864 0.044
#> GSM22380     3   0.781    0.00524 0.052 0.084 0.472 0.392
#> GSM22383     1   0.695    0.30637 0.524 0.024 0.392 0.060
#> GSM22386     3   0.398    0.29134 0.004 0.000 0.776 0.220
#> GSM22389     4   0.786    0.06026 0.232 0.004 0.332 0.432
#> GSM22391     3   0.524    0.23870 0.024 0.004 0.688 0.284
#> GSM22395     4   0.770    0.06104 0.192 0.004 0.360 0.444
#> GSM22396     2   0.621    0.27545 0.292 0.632 0.004 0.072
#> GSM22398     4   0.883    0.01123 0.152 0.080 0.380 0.388
#> GSM22399     1   0.747    0.29493 0.636 0.160 0.136 0.068
#> GSM22402     3   0.843   -0.18560 0.184 0.288 0.480 0.048
#> GSM22407     2   0.933    0.30947 0.232 0.440 0.172 0.156
#> GSM22411     3   0.633    0.06489 0.052 0.004 0.532 0.412
#> GSM22412     2   0.888    0.20647 0.204 0.428 0.068 0.300
#> GSM22415     4   0.909    0.14460 0.108 0.156 0.324 0.412
#> GSM22416     2   0.636    0.27311 0.412 0.536 0.012 0.040

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5   0.731    0.08322 0.000 0.312 0.232 0.032 0.424
#> GSM22374     1   0.894   -0.07302 0.304 0.080 0.280 0.280 0.056
#> GSM22381     4   0.668    0.33432 0.204 0.032 0.008 0.596 0.160
#> GSM22382     5   0.569    0.48340 0.032 0.144 0.120 0.004 0.700
#> GSM22384     5   0.650    0.30109 0.236 0.016 0.188 0.000 0.560
#> GSM22385     4   0.717    0.18643 0.340 0.028 0.032 0.500 0.100
#> GSM22387     3   0.661    0.37300 0.304 0.052 0.576 0.032 0.036
#> GSM22388     1   0.572    0.34626 0.684 0.016 0.032 0.216 0.052
#> GSM22390     3   0.574    0.43564 0.076 0.076 0.728 0.016 0.104
#> GSM22392     4   0.793   -0.05961 0.168 0.092 0.356 0.380 0.004
#> GSM22393     1   0.708    0.31958 0.600 0.092 0.052 0.216 0.040
#> GSM22394     1   0.290    0.46989 0.888 0.024 0.016 0.004 0.068
#> GSM22397     1   0.721   -0.11820 0.472 0.028 0.060 0.380 0.060
#> GSM22400     4   0.323    0.37615 0.080 0.012 0.004 0.868 0.036
#> GSM22401     5   0.786    0.10037 0.248 0.248 0.016 0.048 0.440
#> GSM22403     4   0.728    0.27840 0.260 0.020 0.008 0.460 0.252
#> GSM22404     5   0.573    0.41555 0.000 0.104 0.196 0.028 0.672
#> GSM22405     2   0.531    0.34221 0.012 0.684 0.240 0.056 0.008
#> GSM22406     1   0.685   -0.10547 0.476 0.020 0.064 0.400 0.040
#> GSM22408     3   0.631    0.33054 0.040 0.068 0.684 0.052 0.156
#> GSM22409     4   0.799    0.27664 0.180 0.064 0.016 0.372 0.368
#> GSM22410     3   0.778    0.27263 0.000 0.164 0.484 0.140 0.212
#> GSM22413     5   0.779    0.28631 0.032 0.140 0.144 0.128 0.556
#> GSM22414     4   0.812    0.08969 0.300 0.276 0.000 0.328 0.096
#> GSM22417     3   0.556    0.35331 0.000 0.300 0.624 0.020 0.056
#> GSM22418     1   0.277    0.48694 0.896 0.000 0.044 0.028 0.032
#> GSM22419     1   0.143    0.49245 0.956 0.004 0.012 0.004 0.024
#> GSM22420     3   0.883   -0.00129 0.296 0.080 0.324 0.252 0.048
#> GSM22421     2   0.647    0.31380 0.096 0.652 0.008 0.080 0.164
#> GSM22422     5   0.607    0.15104 0.048 0.412 0.004 0.028 0.508
#> GSM22423     5   0.661    0.28492 0.012 0.020 0.256 0.132 0.580
#> GSM22424     4   0.535    0.30038 0.092 0.056 0.048 0.764 0.040
#> GSM22365     2   0.596    0.27471 0.328 0.544 0.000 0.128 0.000
#> GSM22366     4   0.690    0.28278 0.276 0.048 0.008 0.556 0.112
#> GSM22367     2   0.518    0.28373 0.000 0.684 0.220 0.004 0.092
#> GSM22368     2   0.712   -0.18984 0.004 0.444 0.176 0.024 0.352
#> GSM22370     3   0.821    0.33959 0.052 0.100 0.512 0.196 0.140
#> GSM22371     2   0.586    0.16998 0.452 0.468 0.000 0.072 0.008
#> GSM22372     5   0.643    0.32402 0.044 0.108 0.032 0.144 0.672
#> GSM22373     1   0.694    0.16561 0.512 0.020 0.164 0.296 0.008
#> GSM22375     3   0.673    0.13277 0.076 0.076 0.548 0.000 0.300
#> GSM22376     4   0.738    0.27762 0.008 0.072 0.160 0.540 0.220
#> GSM22377     3   0.919    0.26199 0.224 0.184 0.364 0.172 0.056
#> GSM22378     2   0.611    0.11443 0.448 0.448 0.000 0.096 0.008
#> GSM22379     2   0.383    0.37265 0.012 0.840 0.088 0.044 0.016
#> GSM22380     3   0.815    0.11377 0.024 0.292 0.352 0.044 0.288
#> GSM22383     3   0.853    0.35068 0.288 0.156 0.420 0.088 0.048
#> GSM22386     2   0.553    0.05802 0.000 0.556 0.368 0.000 0.076
#> GSM22389     3   0.625    0.38507 0.048 0.136 0.696 0.064 0.056
#> GSM22391     2   0.631   -0.08431 0.000 0.444 0.436 0.012 0.108
#> GSM22395     3   0.368    0.44987 0.020 0.104 0.840 0.004 0.032
#> GSM22396     4   0.732    0.31893 0.148 0.092 0.080 0.616 0.064
#> GSM22398     3   0.766    0.33680 0.032 0.156 0.532 0.056 0.224
#> GSM22399     1   0.916    0.12678 0.348 0.128 0.108 0.308 0.108
#> GSM22402     2   0.618    0.33932 0.172 0.624 0.000 0.180 0.024
#> GSM22407     4   0.830    0.20767 0.248 0.152 0.000 0.376 0.224
#> GSM22411     3   0.628    0.33221 0.012 0.304 0.552 0.000 0.132
#> GSM22412     4   0.761    0.26918 0.120 0.040 0.032 0.428 0.380
#> GSM22415     3   0.762    0.22928 0.000 0.128 0.500 0.144 0.228
#> GSM22416     1   0.227    0.48200 0.924 0.012 0.012 0.016 0.036

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5   0.628    0.17170 0.012 0.080 0.336 0.028 0.528 0.016
#> GSM22374     6   0.281    0.51455 0.044 0.024 0.032 0.004 0.008 0.888
#> GSM22381     4   0.526    0.43417 0.132 0.024 0.000 0.704 0.024 0.116
#> GSM22382     5   0.540    0.44173 0.048 0.096 0.056 0.060 0.732 0.008
#> GSM22384     5   0.768    0.26481 0.240 0.016 0.108 0.072 0.492 0.072
#> GSM22385     1   0.806   -0.03314 0.384 0.112 0.012 0.324 0.100 0.068
#> GSM22387     6   0.680    0.12700 0.104 0.016 0.324 0.016 0.044 0.496
#> GSM22388     6   0.642   -0.19580 0.380 0.028 0.000 0.148 0.008 0.436
#> GSM22390     3   0.692    0.32148 0.052 0.068 0.536 0.004 0.076 0.264
#> GSM22392     3   0.858    0.00243 0.124 0.192 0.332 0.056 0.020 0.276
#> GSM22393     1   0.860    0.19472 0.392 0.156 0.044 0.152 0.040 0.216
#> GSM22394     1   0.389    0.53203 0.816 0.016 0.012 0.028 0.016 0.112
#> GSM22397     1   0.759    0.12386 0.464 0.068 0.044 0.312 0.068 0.044
#> GSM22400     4   0.742    0.35899 0.084 0.168 0.012 0.520 0.036 0.180
#> GSM22401     5   0.752    0.09195 0.232 0.212 0.004 0.100 0.436 0.016
#> GSM22403     4   0.647    0.39300 0.188 0.012 0.004 0.592 0.128 0.076
#> GSM22404     5   0.372    0.40247 0.008 0.032 0.104 0.028 0.824 0.004
#> GSM22405     2   0.514    0.23147 0.004 0.644 0.280 0.008 0.036 0.028
#> GSM22406     1   0.669    0.09103 0.472 0.052 0.044 0.380 0.016 0.036
#> GSM22408     3   0.817    0.29314 0.072 0.040 0.464 0.072 0.220 0.132
#> GSM22409     4   0.582    0.42150 0.164 0.028 0.012 0.656 0.128 0.012
#> GSM22410     3   0.762    0.16516 0.032 0.020 0.464 0.112 0.280 0.092
#> GSM22413     5   0.783    0.30145 0.040 0.016 0.180 0.156 0.484 0.124
#> GSM22414     2   0.785   -0.00677 0.288 0.392 0.004 0.192 0.076 0.048
#> GSM22417     3   0.491    0.35625 0.012 0.096 0.744 0.012 0.116 0.020
#> GSM22418     1   0.395    0.53030 0.796 0.004 0.040 0.016 0.008 0.136
#> GSM22419     1   0.324    0.52398 0.804 0.004 0.008 0.008 0.000 0.176
#> GSM22420     6   0.230    0.50518 0.032 0.008 0.044 0.000 0.008 0.908
#> GSM22421     2   0.568    0.41716 0.072 0.696 0.020 0.076 0.128 0.008
#> GSM22422     2   0.778    0.00434 0.080 0.372 0.040 0.240 0.268 0.000
#> GSM22423     5   0.689    0.25031 0.080 0.008 0.132 0.152 0.588 0.040
#> GSM22424     6   0.763   -0.29125 0.044 0.208 0.020 0.348 0.024 0.356
#> GSM22365     2   0.473    0.39892 0.280 0.656 0.000 0.052 0.004 0.008
#> GSM22366     4   0.609    0.27618 0.240 0.052 0.008 0.612 0.072 0.016
#> GSM22367     2   0.671    0.01173 0.004 0.432 0.364 0.048 0.148 0.004
#> GSM22368     5   0.775    0.16417 0.036 0.184 0.304 0.032 0.408 0.036
#> GSM22370     3   0.823    0.08626 0.028 0.024 0.344 0.120 0.168 0.316
#> GSM22371     2   0.489    0.24429 0.420 0.540 0.004 0.016 0.008 0.012
#> GSM22372     5   0.726    0.17331 0.076 0.064 0.064 0.360 0.432 0.004
#> GSM22373     1   0.809    0.28117 0.440 0.144 0.092 0.076 0.012 0.236
#> GSM22375     3   0.745    0.22565 0.104 0.032 0.468 0.016 0.296 0.084
#> GSM22376     4   0.617    0.37191 0.028 0.012 0.124 0.664 0.084 0.088
#> GSM22377     6   0.503    0.39867 0.020 0.028 0.228 0.020 0.012 0.692
#> GSM22378     2   0.570    0.20755 0.396 0.500 0.000 0.080 0.012 0.012
#> GSM22379     2   0.563    0.32554 0.004 0.676 0.184 0.024 0.048 0.064
#> GSM22380     3   0.857    0.00630 0.044 0.104 0.364 0.068 0.304 0.116
#> GSM22383     6   0.757    0.11161 0.128 0.020 0.344 0.028 0.068 0.412
#> GSM22386     3   0.618    0.15271 0.008 0.352 0.512 0.040 0.084 0.004
#> GSM22389     3   0.687    0.38794 0.044 0.068 0.596 0.012 0.132 0.148
#> GSM22391     3   0.653    0.24299 0.004 0.264 0.552 0.092 0.076 0.012
#> GSM22395     3   0.486    0.42828 0.036 0.016 0.748 0.004 0.068 0.128
#> GSM22396     4   0.887    0.17494 0.160 0.268 0.072 0.344 0.048 0.108
#> GSM22398     3   0.768    0.18585 0.052 0.028 0.480 0.060 0.264 0.116
#> GSM22399     6   0.591    0.42118 0.088 0.032 0.044 0.136 0.016 0.684
#> GSM22402     2   0.400    0.45657 0.108 0.812 0.008 0.028 0.020 0.024
#> GSM22407     4   0.863    0.10796 0.252 0.248 0.004 0.252 0.180 0.064
#> GSM22411     3   0.520    0.30230 0.016 0.084 0.696 0.000 0.176 0.028
#> GSM22412     4   0.652    0.36215 0.204 0.020 0.024 0.608 0.092 0.052
#> GSM22415     3   0.828    0.22270 0.036 0.060 0.416 0.096 0.276 0.116
#> GSM22416     1   0.336    0.54389 0.828 0.028 0.004 0.008 0.004 0.128

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> CV:skmeans 56            0.399 2
#> CV:skmeans  5               NA 3
#> CV:skmeans  2               NA 4
#> CV:skmeans  0               NA 5
#> CV:skmeans  6            1.000 6

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 21446 rows and 60 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.145           0.560       0.796         0.4735 0.512   0.512
#> 3 3 0.238           0.489       0.731         0.3459 0.726   0.515
#> 4 4 0.367           0.344       0.650         0.1549 0.797   0.501
#> 5 5 0.501           0.478       0.702         0.0713 0.776   0.343
#> 6 6 0.517           0.228       0.606         0.0352 0.853   0.451

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
#> GSM22369     2  0.8608      0.590 0.284 0.716
#> GSM22374     1  0.3114      0.755 0.944 0.056
#> GSM22381     1  0.1414      0.763 0.980 0.020
#> GSM22382     2  0.0672      0.625 0.008 0.992
#> GSM22384     2  0.6623      0.637 0.172 0.828
#> GSM22385     1  0.6148      0.713 0.848 0.152
#> GSM22387     2  0.9833      0.496 0.424 0.576
#> GSM22388     1  0.0000      0.760 1.000 0.000
#> GSM22390     1  0.8713      0.607 0.708 0.292
#> GSM22392     1  0.8763      0.505 0.704 0.296
#> GSM22393     1  0.0000      0.760 1.000 0.000
#> GSM22394     2  0.9460      0.560 0.364 0.636
#> GSM22397     1  0.1184      0.765 0.984 0.016
#> GSM22400     1  0.0000      0.760 1.000 0.000
#> GSM22401     2  0.8386      0.605 0.268 0.732
#> GSM22403     1  0.0376      0.761 0.996 0.004
#> GSM22404     2  0.8016      0.610 0.244 0.756
#> GSM22405     2  0.9970     -0.265 0.468 0.532
#> GSM22406     1  0.1414      0.762 0.980 0.020
#> GSM22408     2  0.9661      0.538 0.392 0.608
#> GSM22409     1  0.4815      0.693 0.896 0.104
#> GSM22410     1  0.8661      0.623 0.712 0.288
#> GSM22413     2  0.9909      0.479 0.444 0.556
#> GSM22414     1  0.6623      0.700 0.828 0.172
#> GSM22417     2  0.9993     -0.293 0.484 0.516
#> GSM22418     2  0.9922      0.472 0.448 0.552
#> GSM22419     1  0.9993     -0.428 0.516 0.484
#> GSM22420     1  0.2236      0.760 0.964 0.036
#> GSM22421     2  0.7219      0.433 0.200 0.800
#> GSM22422     2  0.2043      0.626 0.032 0.968
#> GSM22423     2  0.9427      0.560 0.360 0.640
#> GSM22424     1  0.1414      0.763 0.980 0.020
#> GSM22365     1  0.8861      0.583 0.696 0.304
#> GSM22366     1  0.4562      0.750 0.904 0.096
#> GSM22367     2  0.2043      0.625 0.032 0.968
#> GSM22368     1  0.8081      0.633 0.752 0.248
#> GSM22370     1  0.5842      0.729 0.860 0.140
#> GSM22371     1  0.9358      0.528 0.648 0.352
#> GSM22372     2  0.9754      0.527 0.408 0.592
#> GSM22373     1  0.2948      0.755 0.948 0.052
#> GSM22375     2  0.5946      0.619 0.144 0.856
#> GSM22376     1  0.1633      0.763 0.976 0.024
#> GSM22377     1  0.9248      0.514 0.660 0.340
#> GSM22378     1  0.5519      0.730 0.872 0.128
#> GSM22379     2  0.9970     -0.265 0.468 0.532
#> GSM22380     1  0.8861      0.610 0.696 0.304
#> GSM22383     1  0.5629      0.736 0.868 0.132
#> GSM22386     2  0.6148      0.619 0.152 0.848
#> GSM22389     1  0.9850      0.386 0.572 0.428
#> GSM22391     2  0.8016      0.573 0.244 0.756
#> GSM22395     2  0.1414      0.622 0.020 0.980
#> GSM22396     1  0.5737      0.720 0.864 0.136
#> GSM22398     2  0.8081      0.608 0.248 0.752
#> GSM22399     1  0.0376      0.761 0.996 0.004
#> GSM22402     1  0.9754      0.445 0.592 0.408
#> GSM22407     1  0.5629      0.751 0.868 0.132
#> GSM22411     2  0.0000      0.621 0.000 1.000
#> GSM22412     1  0.1414      0.762 0.980 0.020
#> GSM22415     1  0.6887      0.645 0.816 0.184
#> GSM22416     1  1.0000     -0.442 0.500 0.500

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.5247      0.554 0.224 0.768 0.008
#> GSM22374     3  0.2356      0.624 0.072 0.000 0.928
#> GSM22381     1  0.0424      0.730 0.992 0.000 0.008
#> GSM22382     2  0.1751      0.533 0.028 0.960 0.012
#> GSM22384     2  0.4915      0.568 0.184 0.804 0.012
#> GSM22385     1  0.4233      0.679 0.836 0.160 0.004
#> GSM22387     3  0.3148      0.606 0.048 0.036 0.916
#> GSM22388     1  0.6026      0.317 0.624 0.000 0.376
#> GSM22390     3  0.6012      0.593 0.088 0.124 0.788
#> GSM22392     1  0.7741      0.485 0.660 0.236 0.104
#> GSM22393     1  0.0892      0.727 0.980 0.000 0.020
#> GSM22394     2  0.8268      0.364 0.096 0.576 0.328
#> GSM22397     1  0.1315      0.733 0.972 0.008 0.020
#> GSM22400     1  0.0892      0.727 0.980 0.000 0.020
#> GSM22401     2  0.5156      0.558 0.216 0.776 0.008
#> GSM22403     1  0.0424      0.731 0.992 0.000 0.008
#> GSM22404     2  0.5643      0.553 0.220 0.760 0.020
#> GSM22405     2  0.7757     -0.309 0.464 0.488 0.048
#> GSM22406     1  0.0892      0.727 0.980 0.020 0.000
#> GSM22408     2  0.8372      0.499 0.336 0.564 0.100
#> GSM22409     1  0.3038      0.650 0.896 0.104 0.000
#> GSM22410     1  0.8322      0.476 0.608 0.268 0.124
#> GSM22413     2  0.6140      0.496 0.404 0.596 0.000
#> GSM22414     1  0.4682      0.658 0.804 0.192 0.004
#> GSM22417     1  0.8405      0.268 0.460 0.456 0.084
#> GSM22418     2  0.8890      0.456 0.328 0.532 0.140
#> GSM22419     2  0.9423      0.311 0.196 0.484 0.320
#> GSM22420     3  0.2625      0.623 0.084 0.000 0.916
#> GSM22421     2  0.7865      0.291 0.216 0.660 0.124
#> GSM22422     2  0.1781      0.530 0.020 0.960 0.020
#> GSM22423     2  0.7970      0.501 0.324 0.596 0.080
#> GSM22424     1  0.2448      0.711 0.924 0.000 0.076
#> GSM22365     1  0.5873      0.572 0.684 0.312 0.004
#> GSM22366     1  0.2448      0.721 0.924 0.076 0.000
#> GSM22367     2  0.3356      0.500 0.036 0.908 0.056
#> GSM22368     1  0.5797      0.566 0.712 0.280 0.008
#> GSM22370     3  0.8772      0.468 0.364 0.120 0.516
#> GSM22371     1  0.7424      0.531 0.640 0.300 0.060
#> GSM22372     2  0.7636      0.483 0.396 0.556 0.048
#> GSM22373     1  0.6209      0.162 0.628 0.004 0.368
#> GSM22375     2  0.7022      0.422 0.068 0.700 0.232
#> GSM22376     1  0.0000      0.730 1.000 0.000 0.000
#> GSM22377     3  0.1525      0.611 0.032 0.004 0.964
#> GSM22378     1  0.3340      0.703 0.880 0.120 0.000
#> GSM22379     2  0.7915     -0.299 0.456 0.488 0.056
#> GSM22380     3  0.9417      0.417 0.224 0.272 0.504
#> GSM22383     3  0.8507      0.398 0.424 0.092 0.484
#> GSM22386     2  0.9296     -0.190 0.160 0.436 0.404
#> GSM22389     3  0.9724      0.202 0.252 0.300 0.448
#> GSM22391     2  0.7015      0.478 0.240 0.696 0.064
#> GSM22395     3  0.6062      0.380 0.000 0.384 0.616
#> GSM22396     1  0.5588      0.671 0.808 0.068 0.124
#> GSM22398     3  0.9599      0.341 0.236 0.292 0.472
#> GSM22399     3  0.2878      0.619 0.096 0.000 0.904
#> GSM22402     1  0.8800      0.342 0.488 0.396 0.116
#> GSM22407     1  0.8017      0.444 0.652 0.140 0.208
#> GSM22411     2  0.1411      0.521 0.000 0.964 0.036
#> GSM22412     1  0.0892      0.727 0.980 0.020 0.000
#> GSM22415     3  0.7542      0.400 0.432 0.040 0.528
#> GSM22416     2  0.8806      0.467 0.344 0.528 0.128

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4   0.448     0.1120 0.284 0.004 0.000 0.712
#> GSM22374     3   0.492     0.4863 0.428 0.000 0.572 0.000
#> GSM22381     2   0.365     0.6270 0.204 0.796 0.000 0.000
#> GSM22382     4   0.121     0.5301 0.032 0.004 0.000 0.964
#> GSM22384     4   0.381     0.5291 0.000 0.156 0.020 0.824
#> GSM22385     2   0.445     0.4536 0.000 0.776 0.028 0.196
#> GSM22387     3   0.537     0.4849 0.416 0.008 0.572 0.004
#> GSM22388     1   0.480    -0.2825 0.616 0.384 0.000 0.000
#> GSM22390     3   0.649     0.3376 0.096 0.012 0.652 0.240
#> GSM22392     3   0.716    -0.2155 0.140 0.368 0.492 0.000
#> GSM22393     2   0.369     0.6260 0.208 0.792 0.000 0.000
#> GSM22394     4   0.619     0.4531 0.344 0.036 0.016 0.604
#> GSM22397     2   0.194     0.5728 0.000 0.936 0.052 0.012
#> GSM22400     2   0.307     0.6257 0.152 0.848 0.000 0.000
#> GSM22401     4   0.174     0.5111 0.056 0.004 0.000 0.940
#> GSM22403     2   0.365     0.6270 0.204 0.796 0.000 0.000
#> GSM22404     4   0.304     0.4503 0.112 0.004 0.008 0.876
#> GSM22405     1   0.984     0.4885 0.340 0.236 0.200 0.224
#> GSM22406     2   0.383     0.6261 0.204 0.792 0.004 0.000
#> GSM22408     4   0.655     0.5556 0.000 0.212 0.156 0.632
#> GSM22409     2   0.540     0.5898 0.216 0.724 0.004 0.056
#> GSM22410     1   0.807     0.3548 0.444 0.072 0.080 0.404
#> GSM22413     2   0.779    -0.2150 0.248 0.400 0.000 0.352
#> GSM22414     2   0.563     0.3563 0.092 0.712 0.000 0.196
#> GSM22417     1   0.586     0.3521 0.500 0.004 0.472 0.024
#> GSM22418     4   0.708     0.5039 0.012 0.296 0.116 0.576
#> GSM22419     4   0.692     0.4541 0.316 0.116 0.004 0.564
#> GSM22420     3   0.492     0.4863 0.428 0.000 0.572 0.000
#> GSM22421     1   0.983     0.4841 0.336 0.204 0.260 0.200
#> GSM22422     4   0.416     0.4720 0.000 0.000 0.264 0.736
#> GSM22423     4   0.330     0.5729 0.000 0.144 0.008 0.848
#> GSM22424     2   0.513     0.5867 0.148 0.760 0.092 0.000
#> GSM22365     2   0.884     0.2712 0.216 0.504 0.128 0.152
#> GSM22366     2   0.582     0.5863 0.204 0.696 0.000 0.100
#> GSM22367     1   0.797     0.3625 0.428 0.008 0.228 0.336
#> GSM22368     4   0.738    -0.3712 0.420 0.140 0.004 0.436
#> GSM22370     3   0.723     0.2297 0.020 0.316 0.560 0.104
#> GSM22371     2   0.751     0.1436 0.064 0.596 0.256 0.084
#> GSM22372     4   0.682     0.5577 0.008 0.188 0.172 0.632
#> GSM22373     2   0.460     0.3899 0.008 0.732 0.256 0.004
#> GSM22375     4   0.430     0.5226 0.000 0.000 0.284 0.716
#> GSM22376     2   0.365     0.6270 0.204 0.796 0.000 0.000
#> GSM22377     3   0.492     0.4863 0.428 0.000 0.572 0.000
#> GSM22378     2   0.340     0.5108 0.008 0.840 0.000 0.152
#> GSM22379     1   0.762     0.5032 0.500 0.004 0.280 0.216
#> GSM22380     1   0.930     0.2578 0.364 0.216 0.324 0.096
#> GSM22383     2   0.781    -0.0183 0.188 0.432 0.372 0.008
#> GSM22386     3   0.765    -0.2602 0.320 0.116 0.532 0.032
#> GSM22389     3   0.496     0.0287 0.204 0.048 0.748 0.000
#> GSM22391     3   0.943    -0.2192 0.156 0.160 0.400 0.284
#> GSM22395     3   0.227     0.1992 0.084 0.000 0.912 0.004
#> GSM22396     2   0.463     0.3899 0.000 0.688 0.308 0.004
#> GSM22398     3   0.991    -0.3075 0.276 0.192 0.292 0.240
#> GSM22399     3   0.492     0.4863 0.428 0.000 0.572 0.000
#> GSM22402     2   0.960    -0.3375 0.200 0.400 0.184 0.216
#> GSM22407     2   0.661     0.1818 0.276 0.628 0.016 0.080
#> GSM22411     4   0.570     0.4261 0.032 0.000 0.380 0.588
#> GSM22412     2   0.383     0.6261 0.204 0.792 0.004 0.000
#> GSM22415     3   0.690     0.3175 0.000 0.244 0.588 0.168
#> GSM22416     4   0.658     0.4550 0.096 0.336 0.000 0.568

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.1270     0.5918 0.000 0.000 0.052 0.000 0.948
#> GSM22374     1  0.4182     0.6488 0.600 0.000 0.000 0.400 0.000
#> GSM22381     4  0.5095     0.8034 0.400 0.040 0.000 0.560 0.000
#> GSM22382     3  0.4242     0.5746 0.000 0.000 0.572 0.000 0.428
#> GSM22384     3  0.3039     0.6788 0.000 0.000 0.808 0.000 0.192
#> GSM22385     2  0.7694     0.3820 0.212 0.488 0.000 0.112 0.188
#> GSM22387     1  0.5203     0.6377 0.608 0.000 0.060 0.332 0.000
#> GSM22388     4  0.0290     0.2179 0.008 0.000 0.000 0.992 0.000
#> GSM22390     1  0.7410     0.5227 0.588 0.088 0.036 0.104 0.184
#> GSM22392     2  0.3474     0.4356 0.032 0.844 0.004 0.112 0.008
#> GSM22393     4  0.5118     0.7982 0.412 0.040 0.000 0.548 0.000
#> GSM22394     3  0.0162     0.6952 0.000 0.000 0.996 0.004 0.000
#> GSM22397     2  0.6551     0.3686 0.252 0.592 0.068 0.088 0.000
#> GSM22400     1  0.6618    -0.5137 0.400 0.384 0.000 0.216 0.000
#> GSM22401     3  0.4383     0.5770 0.000 0.000 0.572 0.004 0.424
#> GSM22403     4  0.5095     0.8034 0.400 0.040 0.000 0.560 0.000
#> GSM22404     5  0.2329     0.5066 0.000 0.000 0.124 0.000 0.876
#> GSM22405     2  0.4235     0.2680 0.000 0.656 0.000 0.008 0.336
#> GSM22406     4  0.5338     0.7385 0.400 0.056 0.000 0.544 0.000
#> GSM22408     3  0.6234     0.6186 0.172 0.136 0.644 0.000 0.048
#> GSM22409     4  0.5710     0.7864 0.400 0.040 0.024 0.536 0.000
#> GSM22410     5  0.1518     0.6296 0.016 0.020 0.000 0.012 0.952
#> GSM22413     5  0.5598     0.3150 0.400 0.000 0.076 0.000 0.524
#> GSM22414     2  0.7272     0.4061 0.200 0.528 0.000 0.072 0.200
#> GSM22417     5  0.4658     0.4613 0.000 0.432 0.004 0.008 0.556
#> GSM22418     3  0.2411     0.6904 0.108 0.008 0.884 0.000 0.000
#> GSM22419     3  0.3037     0.6832 0.032 0.004 0.864 0.100 0.000
#> GSM22420     1  0.4182     0.6488 0.600 0.000 0.000 0.400 0.000
#> GSM22421     2  0.5887     0.2173 0.004 0.600 0.132 0.000 0.264
#> GSM22422     3  0.5004     0.5616 0.000 0.224 0.696 0.004 0.076
#> GSM22423     3  0.6139     0.6081 0.148 0.000 0.560 0.004 0.288
#> GSM22424     2  0.5968     0.1375 0.444 0.448 0.000 0.108 0.000
#> GSM22365     2  0.8408     0.3583 0.100 0.492 0.096 0.224 0.088
#> GSM22366     4  0.6519     0.6935 0.296 0.040 0.000 0.560 0.104
#> GSM22367     5  0.3508     0.5733 0.000 0.252 0.000 0.000 0.748
#> GSM22368     5  0.2591     0.6254 0.044 0.020 0.000 0.032 0.904
#> GSM22370     1  0.2913     0.4137 0.876 0.000 0.040 0.004 0.080
#> GSM22371     2  0.5590     0.5068 0.076 0.744 0.104 0.036 0.040
#> GSM22372     3  0.6017     0.6454 0.128 0.116 0.688 0.004 0.064
#> GSM22373     2  0.6600     0.2978 0.388 0.488 0.060 0.064 0.000
#> GSM22375     3  0.5952     0.6160 0.000 0.252 0.584 0.000 0.164
#> GSM22376     4  0.5159     0.8015 0.400 0.044 0.000 0.556 0.000
#> GSM22377     1  0.4182     0.6488 0.600 0.000 0.000 0.400 0.000
#> GSM22378     4  0.8437     0.0114 0.244 0.280 0.000 0.316 0.160
#> GSM22379     5  0.5384     0.5361 0.000 0.228 0.104 0.004 0.664
#> GSM22380     5  0.5303     0.5245 0.232 0.108 0.000 0.000 0.660
#> GSM22383     1  0.4531     0.2476 0.780 0.004 0.064 0.016 0.136
#> GSM22386     2  0.7829    -0.0449 0.000 0.376 0.084 0.348 0.192
#> GSM22389     2  0.5748    -0.1523 0.360 0.572 0.004 0.020 0.044
#> GSM22391     2  0.6712    -0.0354 0.000 0.440 0.080 0.428 0.052
#> GSM22395     1  0.5491     0.2590 0.492 0.452 0.004 0.000 0.052
#> GSM22396     2  0.5532     0.3687 0.260 0.636 0.000 0.100 0.004
#> GSM22398     5  0.3983     0.4486 0.340 0.000 0.000 0.000 0.660
#> GSM22399     1  0.4182     0.6488 0.600 0.000 0.000 0.400 0.000
#> GSM22402     2  0.6297     0.4381 0.028 0.644 0.032 0.068 0.228
#> GSM22407     2  0.8261     0.4072 0.276 0.464 0.112 0.044 0.104
#> GSM22411     5  0.6456     0.3975 0.000 0.368 0.184 0.000 0.448
#> GSM22412     4  0.5242     0.8027 0.400 0.040 0.004 0.556 0.000
#> GSM22415     1  0.3732     0.4781 0.796 0.016 0.004 0.004 0.180
#> GSM22416     3  0.2504     0.6605 0.004 0.064 0.900 0.032 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
#> GSM22369     3  0.4168    0.41190 0.000 0.016 0.584 0.000 0.400 0.000
#> GSM22374     6  0.0000    0.67160 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22381     4  0.3810    0.18441 0.000 0.000 0.000 0.572 0.428 0.000
#> GSM22382     5  0.7039   -0.39102 0.340 0.148 0.112 0.000 0.400 0.000
#> GSM22384     1  0.5572    0.51735 0.612 0.228 0.024 0.000 0.136 0.000
#> GSM22385     4  0.2697    0.33375 0.000 0.000 0.000 0.812 0.188 0.000
#> GSM22387     6  0.2942    0.63454 0.132 0.032 0.000 0.000 0.000 0.836
#> GSM22388     6  0.7375    0.00902 0.080 0.056 0.000 0.096 0.356 0.412
#> GSM22390     6  0.6065    0.54612 0.072 0.044 0.056 0.004 0.168 0.656
#> GSM22392     4  0.6569   -0.20979 0.000 0.108 0.408 0.424 0.020 0.040
#> GSM22393     4  0.4861    0.18483 0.000 0.056 0.000 0.572 0.368 0.004
#> GSM22394     1  0.2562    0.57700 0.828 0.172 0.000 0.000 0.000 0.000
#> GSM22397     4  0.5529    0.23924 0.116 0.000 0.056 0.656 0.172 0.000
#> GSM22400     4  0.3123    0.34647 0.000 0.056 0.000 0.832 0.112 0.000
#> GSM22401     5  0.6304   -0.43792 0.336 0.244 0.012 0.000 0.408 0.000
#> GSM22403     4  0.3810    0.18441 0.000 0.000 0.000 0.572 0.428 0.000
#> GSM22404     3  0.5870    0.32013 0.108 0.024 0.468 0.000 0.400 0.000
#> GSM22405     4  0.7361   -0.26517 0.000 0.128 0.316 0.352 0.204 0.000
#> GSM22406     5  0.3756   -0.23832 0.000 0.000 0.000 0.400 0.600 0.000
#> GSM22408     1  0.8313    0.38105 0.460 0.136 0.084 0.204 0.068 0.048
#> GSM22409     4  0.5068    0.12674 0.044 0.016 0.000 0.520 0.420 0.000
#> GSM22410     3  0.4533    0.41555 0.000 0.016 0.588 0.016 0.380 0.000
#> GSM22413     3  0.4727    0.17508 0.016 0.024 0.560 0.400 0.000 0.000
#> GSM22414     4  0.3482    0.26792 0.000 0.000 0.000 0.684 0.316 0.000
#> GSM22417     3  0.2907    0.17124 0.000 0.152 0.828 0.000 0.020 0.000
#> GSM22418     1  0.0458    0.55404 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM22419     1  0.0665    0.54810 0.980 0.000 0.000 0.004 0.008 0.008
#> GSM22420     6  0.0000    0.67160 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22421     2  0.6543    0.22037 0.004 0.596 0.124 0.192 0.044 0.040
#> GSM22422     1  0.7286    0.41569 0.368 0.280 0.248 0.000 0.104 0.000
#> GSM22423     1  0.8013    0.32685 0.336 0.232 0.016 0.136 0.272 0.008
#> GSM22424     4  0.2649    0.37641 0.000 0.052 0.000 0.884 0.016 0.048
#> GSM22365     2  0.6190   -0.00313 0.020 0.456 0.004 0.372 0.148 0.000
#> GSM22366     5  0.4856   -0.30358 0.000 0.056 0.000 0.468 0.476 0.000
#> GSM22367     3  0.5330    0.25482 0.000 0.232 0.592 0.000 0.176 0.000
#> GSM22368     3  0.5699    0.39965 0.000 0.060 0.524 0.048 0.368 0.000
#> GSM22370     6  0.6749    0.42521 0.060 0.032 0.024 0.284 0.052 0.548
#> GSM22371     4  0.6548    0.01622 0.012 0.104 0.176 0.580 0.128 0.000
#> GSM22372     1  0.8198    0.40929 0.352 0.296 0.124 0.152 0.076 0.000
#> GSM22373     4  0.3649    0.32821 0.132 0.000 0.004 0.796 0.000 0.068
#> GSM22375     1  0.7677    0.43752 0.336 0.264 0.232 0.004 0.164 0.000
#> GSM22376     4  0.3797    0.19002 0.000 0.000 0.000 0.580 0.420 0.000
#> GSM22377     6  0.0000    0.67160 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22378     5  0.5184   -0.30436 0.000 0.088 0.000 0.432 0.480 0.000
#> GSM22379     3  0.3838    0.13680 0.000 0.448 0.552 0.000 0.000 0.000
#> GSM22380     3  0.4523    0.34519 0.000 0.008 0.704 0.212 0.076 0.000
#> GSM22383     6  0.7637    0.32042 0.136 0.036 0.124 0.276 0.000 0.428
#> GSM22386     2  0.6231   -0.00726 0.008 0.400 0.388 0.004 0.200 0.000
#> GSM22389     3  0.7135   -0.15926 0.000 0.204 0.416 0.072 0.008 0.300
#> GSM22391     3  0.6228   -0.29274 0.008 0.252 0.416 0.000 0.324 0.000
#> GSM22395     3  0.6166   -0.11402 0.000 0.284 0.416 0.004 0.000 0.296
#> GSM22396     4  0.2632    0.31554 0.000 0.000 0.164 0.832 0.004 0.000
#> GSM22398     3  0.7837    0.29342 0.004 0.048 0.448 0.196 0.200 0.104
#> GSM22399     6  0.0000    0.67160 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22402     4  0.6237   -0.17754 0.004 0.296 0.092 0.540 0.068 0.000
#> GSM22407     4  0.5337    0.26592 0.056 0.048 0.112 0.736 0.028 0.020
#> GSM22411     3  0.3351    0.25234 0.168 0.004 0.800 0.000 0.028 0.000
#> GSM22412     4  0.5366    0.16099 0.000 0.148 0.000 0.568 0.284 0.000
#> GSM22415     6  0.6938    0.42064 0.024 0.044 0.004 0.228 0.188 0.512
#> GSM22416     1  0.2191    0.44214 0.876 0.000 0.000 0.004 0.120 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n disease.state(p) k
#> CV:pam 49            1.000 2
#> CV:pam 33            0.520 3
#> CV:pam 21            0.325 4
#> CV:pam 34            0.459 5
#> CV:pam 10            0.628 6

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 21446 rows and 60 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 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 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.3076           0.751       0.824         0.3661 0.537   0.537
#> 3 3 0.0764           0.432       0.650         0.5120 0.789   0.643
#> 4 4 0.2362           0.324       0.566         0.2400 0.702   0.419
#> 5 5 0.3528           0.298       0.584         0.1170 0.806   0.439
#> 6 6 0.4511           0.273       0.535         0.0526 0.842   0.413

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
#> GSM22369     1  0.9710      0.895 0.600 0.400
#> GSM22374     1  0.9754      0.887 0.592 0.408
#> GSM22381     2  1.0000      0.215 0.500 0.500
#> GSM22382     1  0.9580      0.884 0.620 0.380
#> GSM22384     1  0.9710      0.895 0.600 0.400
#> GSM22385     2  0.6801      0.696 0.180 0.820
#> GSM22387     1  0.9754      0.892 0.592 0.408
#> GSM22388     2  0.0376      0.778 0.004 0.996
#> GSM22390     1  0.9686      0.895 0.604 0.396
#> GSM22392     1  0.9710      0.895 0.600 0.400
#> GSM22393     2  0.9710     -0.461 0.400 0.600
#> GSM22394     2  0.1184      0.776 0.016 0.984
#> GSM22397     2  0.6531      0.705 0.168 0.832
#> GSM22400     1  0.9460      0.810 0.636 0.364
#> GSM22401     2  0.6438      0.723 0.164 0.836
#> GSM22403     2  0.7299      0.687 0.204 0.796
#> GSM22404     1  0.9661      0.892 0.608 0.392
#> GSM22405     1  0.7219      0.675 0.800 0.200
#> GSM22406     2  0.1184      0.776 0.016 0.984
#> GSM22408     1  0.9686      0.895 0.604 0.396
#> GSM22409     2  0.2423      0.766 0.040 0.960
#> GSM22410     1  0.9686      0.895 0.604 0.396
#> GSM22413     1  0.9661      0.892 0.608 0.392
#> GSM22414     2  0.6247      0.727 0.156 0.844
#> GSM22417     1  0.9710      0.895 0.600 0.400
#> GSM22418     2  0.0672      0.778 0.008 0.992
#> GSM22419     2  0.0672      0.778 0.008 0.992
#> GSM22420     1  0.9754      0.887 0.592 0.408
#> GSM22421     1  0.7453      0.661 0.788 0.212
#> GSM22422     1  0.7883      0.721 0.764 0.236
#> GSM22423     1  0.9710      0.895 0.600 0.400
#> GSM22424     1  0.9732      0.173 0.596 0.404
#> GSM22365     2  0.7602      0.686 0.220 0.780
#> GSM22366     2  0.1414      0.773 0.020 0.980
#> GSM22367     1  0.7056      0.666 0.808 0.192
#> GSM22368     1  0.8499      0.771 0.724 0.276
#> GSM22370     1  0.9608      0.888 0.616 0.384
#> GSM22371     2  0.7219      0.698 0.200 0.800
#> GSM22372     1  0.9710      0.895 0.600 0.400
#> GSM22373     2  0.7453      0.371 0.212 0.788
#> GSM22375     1  0.9710      0.895 0.600 0.400
#> GSM22376     1  0.7674      0.634 0.776 0.224
#> GSM22377     1  0.9710      0.895 0.600 0.400
#> GSM22378     2  0.7528      0.685 0.216 0.784
#> GSM22379     1  0.7219      0.675 0.800 0.200
#> GSM22380     1  0.9710      0.895 0.600 0.400
#> GSM22383     1  0.9686      0.895 0.604 0.396
#> GSM22386     1  0.8327      0.765 0.736 0.264
#> GSM22389     1  0.9710      0.895 0.600 0.400
#> GSM22391     1  0.9635      0.891 0.612 0.388
#> GSM22395     1  0.9686      0.895 0.604 0.396
#> GSM22396     2  0.7602      0.503 0.220 0.780
#> GSM22398     1  0.9686      0.895 0.604 0.396
#> GSM22399     1  0.9754      0.887 0.592 0.408
#> GSM22402     1  0.9427      0.330 0.640 0.360
#> GSM22407     2  0.1184      0.776 0.016 0.984
#> GSM22411     1  0.9710      0.895 0.600 0.400
#> GSM22412     1  0.9686      0.884 0.604 0.396
#> GSM22415     1  0.9710      0.895 0.600 0.400
#> GSM22416     2  0.0938      0.777 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
#> GSM22369     3   0.754      0.288 0.068 0.292 0.640
#> GSM22374     3   0.599      0.407 0.240 0.024 0.736
#> GSM22381     3   0.870     -0.229 0.400 0.108 0.492
#> GSM22382     3   0.814      0.151 0.080 0.360 0.560
#> GSM22384     3   0.855      0.331 0.132 0.284 0.584
#> GSM22385     1   0.730      0.516 0.584 0.036 0.380
#> GSM22387     3   0.614      0.412 0.232 0.032 0.736
#> GSM22388     1   0.558      0.602 0.736 0.008 0.256
#> GSM22390     3   0.556      0.534 0.064 0.128 0.808
#> GSM22392     3   0.596      0.517 0.136 0.076 0.788
#> GSM22393     3   0.735      0.244 0.316 0.052 0.632
#> GSM22394     1   0.746      0.564 0.692 0.112 0.196
#> GSM22397     1   0.619      0.540 0.632 0.004 0.364
#> GSM22400     3   0.667      0.353 0.200 0.068 0.732
#> GSM22401     1   0.965      0.505 0.456 0.232 0.312
#> GSM22403     1   0.859      0.476 0.552 0.116 0.332
#> GSM22404     3   0.780      0.216 0.072 0.320 0.608
#> GSM22405     2   0.668      0.559 0.008 0.500 0.492
#> GSM22406     1   0.667      0.512 0.520 0.008 0.472
#> GSM22408     3   0.227      0.581 0.016 0.040 0.944
#> GSM22409     1   0.903      0.406 0.436 0.132 0.432
#> GSM22410     3   0.186      0.575 0.000 0.052 0.948
#> GSM22413     3   0.700      0.416 0.084 0.200 0.716
#> GSM22414     1   0.929      0.454 0.504 0.312 0.184
#> GSM22417     3   0.245      0.572 0.000 0.076 0.924
#> GSM22418     1   0.568      0.602 0.748 0.016 0.236
#> GSM22419     1   0.546      0.599 0.768 0.016 0.216
#> GSM22420     3   0.497      0.424 0.236 0.000 0.764
#> GSM22421     2   0.694      0.684 0.048 0.680 0.272
#> GSM22422     2   0.814      0.511 0.084 0.572 0.344
#> GSM22423     3   0.657      0.485 0.088 0.160 0.752
#> GSM22424     3   0.792     -0.122 0.380 0.064 0.556
#> GSM22365     1   0.814      0.303 0.476 0.456 0.068
#> GSM22366     1   0.749      0.501 0.488 0.036 0.476
#> GSM22367     2   0.599      0.694 0.000 0.632 0.368
#> GSM22368     3   0.767      0.118 0.068 0.312 0.620
#> GSM22370     3   0.455      0.534 0.020 0.140 0.840
#> GSM22371     1   0.904      0.434 0.524 0.320 0.156
#> GSM22372     3   0.800      0.303 0.088 0.304 0.608
#> GSM22373     1   0.728      0.433 0.588 0.036 0.376
#> GSM22375     3   0.762      0.426 0.128 0.188 0.684
#> GSM22376     3   0.524      0.499 0.132 0.048 0.820
#> GSM22377     3   0.318      0.568 0.064 0.024 0.912
#> GSM22378     1   0.854      0.344 0.500 0.404 0.096
#> GSM22379     2   0.638      0.704 0.008 0.624 0.368
#> GSM22380     3   0.535      0.505 0.036 0.160 0.804
#> GSM22383     3   0.454      0.563 0.084 0.056 0.860
#> GSM22386     2   0.627      0.571 0.000 0.544 0.456
#> GSM22389     3   0.288      0.569 0.052 0.024 0.924
#> GSM22391     3   0.676      0.346 0.036 0.288 0.676
#> GSM22395     3   0.543      0.538 0.064 0.120 0.816
#> GSM22396     3   0.760     -0.402 0.416 0.044 0.540
#> GSM22398     3   0.460      0.522 0.016 0.152 0.832
#> GSM22399     3   0.812      0.369 0.236 0.128 0.636
#> GSM22402     2   0.888      0.271 0.244 0.572 0.184
#> GSM22407     1   0.775      0.510 0.544 0.052 0.404
#> GSM22411     3   0.768      0.395 0.120 0.204 0.676
#> GSM22412     3   0.679      0.487 0.128 0.128 0.744
#> GSM22415     3   0.327      0.564 0.000 0.116 0.884
#> GSM22416     1   0.475      0.575 0.832 0.024 0.144

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3  0.6390    0.48476 0.060 0.036 0.680 0.224
#> GSM22374     1  0.8068    0.00998 0.360 0.004 0.324 0.312
#> GSM22381     4  0.5689    0.47236 0.068 0.120 0.048 0.764
#> GSM22382     3  0.8203    0.29357 0.380 0.024 0.408 0.188
#> GSM22384     3  0.6905    0.31419 0.396 0.012 0.516 0.076
#> GSM22385     4  0.0707    0.47738 0.000 0.000 0.020 0.980
#> GSM22387     1  0.9062   -0.09413 0.380 0.080 0.344 0.196
#> GSM22388     4  0.7931   -0.29129 0.360 0.176 0.016 0.448
#> GSM22390     3  0.6528    0.46742 0.020 0.112 0.676 0.192
#> GSM22392     4  0.8128   -0.08555 0.192 0.020 0.364 0.424
#> GSM22393     4  0.9059   -0.07870 0.296 0.108 0.160 0.436
#> GSM22394     1  0.6721    0.27997 0.664 0.028 0.104 0.204
#> GSM22397     4  0.3591    0.43657 0.008 0.168 0.000 0.824
#> GSM22400     4  0.3910    0.44587 0.020 0.016 0.120 0.844
#> GSM22401     1  0.9833   -0.19151 0.344 0.228 0.200 0.228
#> GSM22403     4  0.7064    0.38709 0.168 0.080 0.084 0.668
#> GSM22404     3  0.7866    0.39979 0.260 0.020 0.520 0.200
#> GSM22405     2  0.6945    0.35063 0.004 0.584 0.276 0.136
#> GSM22406     4  0.4132    0.43389 0.012 0.176 0.008 0.804
#> GSM22408     3  0.4372    0.53029 0.000 0.004 0.728 0.268
#> GSM22409     4  0.7400    0.29478 0.244 0.032 0.128 0.596
#> GSM22410     3  0.5290    0.45514 0.012 0.000 0.584 0.404
#> GSM22413     3  0.7629    0.37233 0.184 0.016 0.544 0.256
#> GSM22414     2  0.5074    0.48514 0.008 0.656 0.004 0.332
#> GSM22417     3  0.5215    0.53138 0.016 0.016 0.712 0.256
#> GSM22418     1  0.7762    0.34444 0.528 0.156 0.024 0.292
#> GSM22419     1  0.7937    0.25669 0.440 0.160 0.020 0.380
#> GSM22420     3  0.7752   -0.01164 0.360 0.000 0.404 0.236
#> GSM22421     2  0.7078    0.55719 0.032 0.644 0.180 0.144
#> GSM22422     2  0.8597    0.28701 0.344 0.412 0.200 0.044
#> GSM22423     3  0.7697    0.41171 0.228 0.016 0.540 0.216
#> GSM22424     4  0.3659    0.44820 0.032 0.016 0.084 0.868
#> GSM22365     2  0.4814    0.52607 0.008 0.676 0.000 0.316
#> GSM22366     4  0.4359    0.44341 0.020 0.176 0.008 0.796
#> GSM22367     2  0.5443    0.43864 0.020 0.660 0.312 0.008
#> GSM22368     3  0.6886    0.35233 0.048 0.208 0.660 0.084
#> GSM22370     3  0.7455    0.40915 0.020 0.104 0.476 0.400
#> GSM22371     2  0.5733    0.46632 0.008 0.632 0.028 0.332
#> GSM22372     4  0.8377   -0.05754 0.340 0.016 0.300 0.344
#> GSM22373     4  0.7053   -0.19810 0.356 0.000 0.132 0.512
#> GSM22375     3  0.4502    0.45044 0.236 0.016 0.748 0.000
#> GSM22376     4  0.5085   -0.11907 0.000 0.008 0.376 0.616
#> GSM22377     3  0.8123    0.25685 0.228 0.020 0.472 0.280
#> GSM22378     2  0.4991    0.49133 0.008 0.672 0.004 0.316
#> GSM22379     2  0.6166    0.48218 0.016 0.644 0.292 0.048
#> GSM22380     3  0.5166    0.48944 0.004 0.020 0.688 0.288
#> GSM22383     3  0.7756    0.37482 0.212 0.024 0.552 0.212
#> GSM22386     3  0.5085    0.26385 0.012 0.288 0.692 0.008
#> GSM22389     3  0.3791    0.52863 0.000 0.004 0.796 0.200
#> GSM22391     3  0.4168    0.47158 0.016 0.148 0.820 0.016
#> GSM22395     3  0.6491    0.46456 0.020 0.112 0.680 0.188
#> GSM22396     4  0.2376    0.47198 0.020 0.012 0.040 0.928
#> GSM22398     3  0.7444    0.41914 0.020 0.104 0.484 0.392
#> GSM22399     3  0.8379   -0.03588 0.372 0.036 0.412 0.180
#> GSM22402     2  0.6141    0.55568 0.000 0.624 0.076 0.300
#> GSM22407     4  0.6199    0.32851 0.008 0.172 0.128 0.692
#> GSM22411     3  0.2929    0.52556 0.040 0.028 0.908 0.024
#> GSM22412     4  0.6353    0.34356 0.056 0.028 0.252 0.664
#> GSM22415     3  0.5214    0.47470 0.012 0.004 0.648 0.336
#> GSM22416     1  0.7528    0.35248 0.552 0.164 0.016 0.268

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     3   0.619     0.2884 0.012 0.212 0.640 0.020 0.116
#> GSM22374     1   0.712     0.1804 0.440 0.008 0.256 0.288 0.008
#> GSM22381     4   0.649     0.4413 0.136 0.128 0.040 0.664 0.032
#> GSM22382     5   0.465     0.6072 0.012 0.008 0.348 0.000 0.632
#> GSM22384     5   0.612     0.5566 0.096 0.004 0.260 0.024 0.616
#> GSM22385     4   0.361     0.4840 0.112 0.000 0.064 0.824 0.000
#> GSM22387     3   0.568     0.1520 0.464 0.020 0.484 0.024 0.008
#> GSM22388     1   0.491     0.3162 0.716 0.120 0.000 0.164 0.000
#> GSM22390     3   0.563     0.4331 0.084 0.020 0.704 0.016 0.176
#> GSM22392     4   0.739    -0.0209 0.200 0.000 0.148 0.536 0.116
#> GSM22393     1   0.728     0.2242 0.524 0.060 0.096 0.300 0.020
#> GSM22394     1   0.506     0.2352 0.548 0.000 0.000 0.036 0.416
#> GSM22397     4   0.671     0.2276 0.388 0.012 0.144 0.452 0.004
#> GSM22400     4   0.307     0.5030 0.024 0.004 0.116 0.856 0.000
#> GSM22401     5   0.804     0.3924 0.116 0.148 0.156 0.044 0.536
#> GSM22403     4   0.822     0.3511 0.228 0.072 0.056 0.492 0.152
#> GSM22404     5   0.510     0.5471 0.012 0.012 0.420 0.004 0.552
#> GSM22405     2   0.713     0.4205 0.008 0.556 0.220 0.164 0.052
#> GSM22406     1   0.729    -0.2430 0.428 0.092 0.080 0.396 0.004
#> GSM22408     3   0.305     0.4928 0.012 0.016 0.888 0.036 0.048
#> GSM22409     4   0.916     0.1967 0.192 0.092 0.088 0.348 0.280
#> GSM22410     3   0.364     0.4400 0.012 0.048 0.848 0.084 0.008
#> GSM22413     3   0.842    -0.3589 0.016 0.108 0.372 0.192 0.312
#> GSM22414     2   0.689     0.2153 0.328 0.396 0.000 0.272 0.004
#> GSM22417     3   0.490     0.4331 0.008 0.048 0.772 0.124 0.048
#> GSM22418     1   0.417     0.3974 0.792 0.000 0.004 0.112 0.092
#> GSM22419     1   0.419     0.4033 0.796 0.000 0.008 0.092 0.104
#> GSM22420     1   0.683     0.0946 0.440 0.004 0.368 0.180 0.008
#> GSM22421     2   0.591     0.5374 0.060 0.732 0.068 0.064 0.076
#> GSM22422     2   0.594     0.0659 0.020 0.492 0.040 0.008 0.440
#> GSM22423     5   0.823     0.4989 0.068 0.072 0.360 0.092 0.408
#> GSM22424     4   0.167     0.4916 0.012 0.000 0.052 0.936 0.000
#> GSM22365     2   0.541     0.4460 0.172 0.696 0.008 0.120 0.004
#> GSM22366     4   0.727     0.4019 0.188 0.116 0.096 0.584 0.016
#> GSM22367     2   0.376     0.4780 0.008 0.828 0.084 0.000 0.080
#> GSM22368     3   0.788    -0.1998 0.036 0.316 0.372 0.016 0.260
#> GSM22370     3   0.570     0.4100 0.060 0.012 0.680 0.220 0.028
#> GSM22371     1   0.641    -0.3381 0.448 0.444 0.040 0.068 0.000
#> GSM22372     5   0.722     0.4777 0.008 0.024 0.284 0.204 0.480
#> GSM22373     1   0.573     0.1464 0.496 0.000 0.072 0.428 0.004
#> GSM22375     5   0.571     0.2740 0.032 0.048 0.308 0.000 0.612
#> GSM22376     4   0.571     0.3589 0.020 0.056 0.336 0.588 0.000
#> GSM22377     3   0.799     0.1252 0.340 0.044 0.388 0.204 0.024
#> GSM22378     2   0.599     0.2235 0.424 0.476 0.004 0.096 0.000
#> GSM22379     2   0.356     0.5378 0.032 0.860 0.072 0.020 0.016
#> GSM22380     3   0.581     0.3533 0.032 0.200 0.680 0.080 0.008
#> GSM22383     3   0.501     0.3114 0.344 0.012 0.624 0.012 0.008
#> GSM22386     2   0.694    -0.2726 0.008 0.392 0.356 0.000 0.244
#> GSM22389     3   0.395     0.4778 0.040 0.008 0.816 0.008 0.128
#> GSM22391     3   0.653     0.3159 0.012 0.304 0.536 0.004 0.144
#> GSM22395     3   0.514     0.4431 0.072 0.012 0.744 0.020 0.152
#> GSM22396     4   0.464     0.4906 0.104 0.000 0.140 0.752 0.004
#> GSM22398     3   0.452     0.4199 0.060 0.012 0.804 0.092 0.032
#> GSM22399     1   0.788     0.2062 0.468 0.232 0.084 0.208 0.008
#> GSM22402     2   0.674     0.4618 0.148 0.612 0.092 0.148 0.000
#> GSM22407     1   0.729    -0.1898 0.400 0.156 0.040 0.400 0.004
#> GSM22411     3   0.675     0.3158 0.020 0.164 0.536 0.004 0.276
#> GSM22412     4   0.834     0.4213 0.120 0.104 0.188 0.512 0.076
#> GSM22415     3   0.529     0.3979 0.032 0.136 0.740 0.084 0.008
#> GSM22416     1   0.345     0.3835 0.820 0.000 0.000 0.032 0.148

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     3   0.511     0.2512 0.160 0.004 0.688 0.012 0.132 0.004
#> GSM22374     6   0.345     0.2978 0.000 0.092 0.028 0.048 0.000 0.832
#> GSM22381     4   0.419     0.4586 0.012 0.008 0.036 0.776 0.012 0.156
#> GSM22382     5   0.565     0.5219 0.208 0.008 0.188 0.000 0.592 0.004
#> GSM22384     5   0.459     0.3656 0.040 0.000 0.044 0.000 0.720 0.196
#> GSM22385     4   0.609     0.4170 0.012 0.284 0.000 0.488 0.000 0.216
#> GSM22387     6   0.368     0.2992 0.012 0.004 0.184 0.020 0.000 0.780
#> GSM22388     4   0.536    -0.1937 0.096 0.000 0.012 0.576 0.000 0.316
#> GSM22390     6   0.532    -0.1795 0.000 0.000 0.428 0.000 0.104 0.468
#> GSM22392     6   0.724     0.0485 0.000 0.340 0.220 0.084 0.004 0.352
#> GSM22393     6   0.590    -0.0224 0.024 0.008 0.072 0.348 0.008 0.540
#> GSM22394     1   0.691     0.4509 0.416 0.000 0.000 0.072 0.316 0.196
#> GSM22397     4   0.768     0.2789 0.176 0.112 0.000 0.468 0.192 0.052
#> GSM22400     4   0.607     0.4127 0.000 0.296 0.012 0.488 0.000 0.204
#> GSM22401     5   0.755     0.4930 0.252 0.084 0.120 0.060 0.480 0.004
#> GSM22403     4   0.706     0.3246 0.164 0.004 0.076 0.572 0.120 0.064
#> GSM22404     5   0.660     0.4440 0.204 0.000 0.228 0.000 0.504 0.064
#> GSM22405     2   0.553     0.4184 0.092 0.712 0.096 0.028 0.004 0.068
#> GSM22406     4   0.535     0.2692 0.148 0.004 0.012 0.668 0.160 0.008
#> GSM22408     3   0.696     0.2432 0.016 0.012 0.416 0.020 0.192 0.344
#> GSM22409     4   0.587     0.0290 0.064 0.016 0.008 0.460 0.440 0.012
#> GSM22410     3   0.671     0.2590 0.004 0.004 0.420 0.028 0.208 0.336
#> GSM22413     3   0.650    -0.2292 0.004 0.000 0.420 0.168 0.376 0.032
#> GSM22414     2   0.570     0.3608 0.172 0.484 0.000 0.344 0.000 0.000
#> GSM22417     3   0.775     0.3043 0.084 0.204 0.508 0.020 0.112 0.072
#> GSM22418     1   0.658     0.5982 0.424 0.000 0.004 0.116 0.064 0.392
#> GSM22419     1   0.525     0.7172 0.608 0.000 0.000 0.112 0.008 0.272
#> GSM22420     6   0.287     0.3706 0.000 0.024 0.092 0.020 0.000 0.864
#> GSM22421     2   0.698     0.5334 0.104 0.504 0.232 0.152 0.004 0.004
#> GSM22422     5   0.538     0.0954 0.024 0.416 0.020 0.024 0.516 0.000
#> GSM22423     5   0.637     0.3508 0.128 0.000 0.236 0.040 0.572 0.024
#> GSM22424     4   0.598     0.4217 0.000 0.344 0.008 0.484 0.004 0.160
#> GSM22365     2   0.509     0.4837 0.040 0.492 0.012 0.452 0.000 0.004
#> GSM22366     4   0.431     0.4401 0.024 0.016 0.016 0.780 0.020 0.144
#> GSM22367     2   0.635     0.3799 0.124 0.460 0.380 0.020 0.012 0.004
#> GSM22368     3   0.878    -0.0579 0.172 0.096 0.396 0.112 0.188 0.036
#> GSM22370     6   0.651    -0.2232 0.000 0.000 0.348 0.168 0.044 0.440
#> GSM22371     2   0.670     0.3916 0.176 0.396 0.044 0.380 0.000 0.004
#> GSM22372     5   0.580     0.4396 0.024 0.012 0.128 0.184 0.644 0.008
#> GSM22373     6   0.524     0.0971 0.012 0.284 0.004 0.084 0.000 0.616
#> GSM22375     5   0.632     0.2555 0.104 0.000 0.280 0.016 0.552 0.048
#> GSM22376     4   0.617     0.2485 0.012 0.016 0.132 0.484 0.000 0.356
#> GSM22377     6   0.780     0.2472 0.004 0.232 0.272 0.052 0.056 0.384
#> GSM22378     4   0.590    -0.4747 0.144 0.388 0.012 0.456 0.000 0.000
#> GSM22379     2   0.546     0.5531 0.016 0.600 0.264 0.120 0.000 0.000
#> GSM22380     3   0.551     0.3951 0.004 0.008 0.660 0.100 0.200 0.028
#> GSM22383     6   0.409     0.2671 0.004 0.012 0.248 0.012 0.004 0.720
#> GSM22386     3   0.556     0.1255 0.008 0.132 0.652 0.020 0.184 0.004
#> GSM22389     3   0.440     0.1690 0.000 0.012 0.580 0.012 0.000 0.396
#> GSM22391     3   0.289     0.3777 0.000 0.048 0.880 0.020 0.012 0.040
#> GSM22395     3   0.418     0.1196 0.000 0.000 0.520 0.000 0.012 0.468
#> GSM22396     4   0.759     0.3937 0.004 0.308 0.000 0.336 0.152 0.200
#> GSM22398     6   0.612    -0.2897 0.004 0.000 0.348 0.004 0.204 0.440
#> GSM22399     6   0.624     0.0976 0.016 0.012 0.216 0.196 0.004 0.556
#> GSM22402     2   0.505     0.5319 0.004 0.668 0.068 0.236 0.000 0.024
#> GSM22407     4   0.769     0.2535 0.160 0.208 0.024 0.496 0.044 0.068
#> GSM22411     3   0.470     0.2994 0.000 0.004 0.704 0.012 0.204 0.076
#> GSM22412     4   0.836     0.3740 0.060 0.008 0.152 0.384 0.228 0.168
#> GSM22415     3   0.664     0.3764 0.000 0.004 0.544 0.108 0.212 0.132
#> GSM22416     1   0.478     0.6983 0.688 0.000 0.000 0.108 0.008 0.196

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:mclust 55            0.561 2
#> CV:mclust 30            0.241 3
#> CV:mclust  7            1.000 4
#> CV:mclust  6            0.301 5
#> CV:mclust  7            0.459 6

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 21446 rows and 60 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.308           0.595       0.817         0.4859 0.512   0.512
#> 3 3 0.252           0.482       0.717         0.3599 0.692   0.461
#> 4 4 0.338           0.303       0.621         0.1360 0.781   0.448
#> 5 5 0.458           0.354       0.600         0.0665 0.798   0.377
#> 6 6 0.538           0.321       0.581         0.0441 0.854   0.422

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
#> GSM22369     1  0.8661      0.610 0.712 0.288
#> GSM22374     1  0.2043      0.754 0.968 0.032
#> GSM22381     2  0.9775      0.567 0.412 0.588
#> GSM22382     1  0.9850      0.453 0.572 0.428
#> GSM22384     1  0.0938      0.766 0.988 0.012
#> GSM22385     2  0.9686      0.592 0.396 0.604
#> GSM22387     1  0.0376      0.768 0.996 0.004
#> GSM22388     2  0.9491      0.614 0.368 0.632
#> GSM22390     1  0.4298      0.753 0.912 0.088
#> GSM22392     1  0.4939      0.675 0.892 0.108
#> GSM22393     2  0.9635      0.600 0.388 0.612
#> GSM22394     2  0.6148      0.680 0.152 0.848
#> GSM22397     2  0.9686      0.592 0.396 0.604
#> GSM22400     1  0.9977     -0.313 0.528 0.472
#> GSM22401     2  0.0672      0.683 0.008 0.992
#> GSM22403     2  0.9661      0.595 0.392 0.608
#> GSM22404     1  0.8386      0.630 0.732 0.268
#> GSM22405     1  0.9815      0.457 0.580 0.420
#> GSM22406     2  0.8813      0.645 0.300 0.700
#> GSM22408     1  0.0376      0.769 0.996 0.004
#> GSM22409     2  0.1843      0.687 0.028 0.972
#> GSM22410     1  0.0000      0.769 1.000 0.000
#> GSM22413     1  0.2043      0.769 0.968 0.032
#> GSM22414     2  0.0000      0.686 0.000 1.000
#> GSM22417     1  0.8081      0.649 0.752 0.248
#> GSM22418     2  0.9686      0.592 0.396 0.604
#> GSM22419     2  0.9661      0.596 0.392 0.608
#> GSM22420     1  0.0376      0.768 0.996 0.004
#> GSM22421     2  0.0376      0.684 0.004 0.996
#> GSM22422     2  0.9850     -0.184 0.428 0.572
#> GSM22423     1  0.2603      0.754 0.956 0.044
#> GSM22424     1  0.9988     -0.354 0.520 0.480
#> GSM22365     2  0.0000      0.686 0.000 1.000
#> GSM22366     2  0.2948      0.689 0.052 0.948
#> GSM22367     1  0.9661      0.484 0.608 0.392
#> GSM22368     1  0.9661      0.484 0.608 0.392
#> GSM22370     1  0.0000      0.769 1.000 0.000
#> GSM22371     2  0.0376      0.684 0.004 0.996
#> GSM22372     1  0.9000      0.564 0.684 0.316
#> GSM22373     1  0.9833     -0.205 0.576 0.424
#> GSM22375     1  0.0376      0.770 0.996 0.004
#> GSM22376     1  0.3431      0.765 0.936 0.064
#> GSM22377     1  0.0376      0.768 0.996 0.004
#> GSM22378     2  0.0376      0.684 0.004 0.996
#> GSM22379     2  0.9881     -0.200 0.436 0.564
#> GSM22380     1  0.5737      0.729 0.864 0.136
#> GSM22383     1  0.0376      0.768 0.996 0.004
#> GSM22386     1  0.9323      0.543 0.652 0.348
#> GSM22389     1  0.0376      0.770 0.996 0.004
#> GSM22391     1  0.7056      0.694 0.808 0.192
#> GSM22395     1  0.0000      0.769 1.000 0.000
#> GSM22396     2  0.9522      0.611 0.372 0.628
#> GSM22398     1  0.3114      0.764 0.944 0.056
#> GSM22399     1  0.5059      0.678 0.888 0.112
#> GSM22402     2  0.0376      0.684 0.004 0.996
#> GSM22407     2  0.0000      0.686 0.000 1.000
#> GSM22411     1  0.7602      0.673 0.780 0.220
#> GSM22412     1  0.4939      0.685 0.892 0.108
#> GSM22415     1  0.0000      0.769 1.000 0.000
#> GSM22416     2  0.8555      0.652 0.280 0.720

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3   0.429     0.6514 0.068 0.060 0.872
#> GSM22374     1   0.206     0.6586 0.948 0.008 0.044
#> GSM22381     2   0.922     0.3808 0.408 0.440 0.152
#> GSM22382     3   0.444     0.6466 0.052 0.084 0.864
#> GSM22384     3   0.634     0.3527 0.312 0.016 0.672
#> GSM22385     1   0.764     0.2797 0.660 0.248 0.092
#> GSM22387     1   0.394     0.6215 0.844 0.000 0.156
#> GSM22388     2   0.610     0.5597 0.392 0.608 0.000
#> GSM22390     1   0.831     0.2516 0.556 0.092 0.352
#> GSM22392     1   0.438     0.6224 0.868 0.060 0.072
#> GSM22393     2   0.639     0.5269 0.412 0.584 0.004
#> GSM22394     2   0.617     0.5972 0.064 0.768 0.168
#> GSM22397     2   0.868     0.5149 0.340 0.540 0.120
#> GSM22400     1   0.492     0.5026 0.816 0.164 0.020
#> GSM22401     3   0.629     0.0531 0.000 0.468 0.532
#> GSM22403     2   0.962     0.4491 0.336 0.448 0.216
#> GSM22404     3   0.359     0.6480 0.048 0.052 0.900
#> GSM22405     1   0.967    -0.1316 0.456 0.240 0.304
#> GSM22406     2   0.617     0.6158 0.308 0.680 0.012
#> GSM22408     1   0.525     0.5519 0.736 0.000 0.264
#> GSM22409     3   0.681     0.2942 0.020 0.372 0.608
#> GSM22410     3   0.629     0.0733 0.464 0.000 0.536
#> GSM22413     3   0.490     0.5941 0.172 0.016 0.812
#> GSM22414     2   0.474     0.6501 0.084 0.852 0.064
#> GSM22417     3   0.727     0.0498 0.452 0.028 0.520
#> GSM22418     2   0.765     0.4204 0.440 0.516 0.044
#> GSM22419     2   0.685     0.5047 0.416 0.568 0.016
#> GSM22420     1   0.175     0.6584 0.952 0.000 0.048
#> GSM22421     2   0.590     0.3962 0.008 0.700 0.292
#> GSM22422     3   0.576     0.5397 0.000 0.328 0.672
#> GSM22423     3   0.480     0.5469 0.220 0.000 0.780
#> GSM22424     1   0.361     0.5634 0.888 0.096 0.016
#> GSM22365     2   0.245     0.6404 0.052 0.936 0.012
#> GSM22366     2   0.621     0.6189 0.052 0.756 0.192
#> GSM22367     3   0.582     0.6367 0.064 0.144 0.792
#> GSM22368     3   0.692     0.6262 0.128 0.136 0.736
#> GSM22370     1   0.341     0.6469 0.876 0.000 0.124
#> GSM22371     2   0.101     0.6477 0.008 0.980 0.012
#> GSM22372     3   0.618     0.6271 0.116 0.104 0.780
#> GSM22373     1   0.534     0.5508 0.816 0.132 0.052
#> GSM22375     3   0.645     0.4706 0.264 0.032 0.704
#> GSM22376     1   0.802     0.3135 0.576 0.076 0.348
#> GSM22377     1   0.207     0.6501 0.940 0.000 0.060
#> GSM22378     2   0.162     0.6478 0.012 0.964 0.024
#> GSM22379     3   0.896     0.4169 0.128 0.400 0.472
#> GSM22380     3   0.545     0.5583 0.228 0.012 0.760
#> GSM22383     1   0.406     0.6258 0.836 0.000 0.164
#> GSM22386     3   0.591     0.6225 0.068 0.144 0.788
#> GSM22389     1   0.607     0.5519 0.736 0.028 0.236
#> GSM22391     3   0.560     0.6184 0.136 0.060 0.804
#> GSM22395     1   0.562     0.5352 0.716 0.004 0.280
#> GSM22396     1   0.869    -0.0286 0.528 0.356 0.116
#> GSM22398     1   0.630     0.1231 0.528 0.000 0.472
#> GSM22399     1   0.796     0.3297 0.576 0.072 0.352
#> GSM22402     2   0.451     0.6240 0.092 0.860 0.048
#> GSM22407     2   0.572     0.6195 0.132 0.800 0.068
#> GSM22411     3   0.617     0.6047 0.144 0.080 0.776
#> GSM22412     1   0.804     0.2921 0.556 0.072 0.372
#> GSM22415     3   0.629     0.0803 0.464 0.000 0.536
#> GSM22416     2   0.594     0.6515 0.204 0.760 0.036

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4   0.548     0.1776 0.004 0.028 0.308 0.660
#> GSM22374     1   0.263     0.5204 0.912 0.060 0.024 0.004
#> GSM22381     4   0.936    -0.2825 0.228 0.308 0.100 0.364
#> GSM22382     4   0.464     0.3912 0.040 0.012 0.148 0.800
#> GSM22384     4   0.775     0.0953 0.200 0.016 0.256 0.528
#> GSM22385     1   0.850     0.2103 0.432 0.256 0.032 0.280
#> GSM22387     1   0.203     0.5384 0.936 0.000 0.036 0.028
#> GSM22388     2   0.709     0.4875 0.300 0.544 0.000 0.156
#> GSM22390     1   0.592     0.4175 0.688 0.052 0.244 0.016
#> GSM22392     3   0.765    -0.1841 0.360 0.212 0.428 0.000
#> GSM22393     2   0.719     0.4794 0.328 0.516 0.000 0.156
#> GSM22394     2   0.857     0.1837 0.108 0.444 0.092 0.356
#> GSM22397     2   0.821     0.3657 0.164 0.516 0.048 0.272
#> GSM22400     1   0.944     0.0658 0.404 0.272 0.176 0.148
#> GSM22401     4   0.477     0.4386 0.000 0.140 0.076 0.784
#> GSM22403     4   0.695     0.0755 0.180 0.212 0.004 0.604
#> GSM22404     4   0.599     0.3653 0.116 0.020 0.136 0.728
#> GSM22405     3   0.607     0.3455 0.028 0.332 0.620 0.020
#> GSM22406     2   0.741     0.4978 0.220 0.580 0.016 0.184
#> GSM22408     1   0.603     0.4668 0.676 0.000 0.216 0.108
#> GSM22409     4   0.248     0.4676 0.000 0.088 0.008 0.904
#> GSM22410     4   0.715    -0.1998 0.424 0.000 0.132 0.444
#> GSM22413     4   0.465     0.3598 0.040 0.004 0.172 0.784
#> GSM22414     2   0.360     0.5287 0.024 0.876 0.032 0.068
#> GSM22417     3   0.484     0.4795 0.116 0.004 0.792 0.088
#> GSM22418     1   0.854    -0.2253 0.468 0.308 0.060 0.164
#> GSM22419     2   0.803     0.4312 0.360 0.464 0.032 0.144
#> GSM22420     1   0.192     0.5380 0.944 0.024 0.004 0.028
#> GSM22421     2   0.754     0.0508 0.008 0.480 0.152 0.360
#> GSM22422     4   0.742     0.0350 0.000 0.244 0.240 0.516
#> GSM22423     4   0.538     0.2914 0.292 0.000 0.036 0.672
#> GSM22424     1   0.895     0.1898 0.492 0.216 0.156 0.136
#> GSM22365     2   0.496     0.2558 0.000 0.696 0.284 0.020
#> GSM22366     4   0.670    -0.2630 0.000 0.436 0.088 0.476
#> GSM22367     3   0.459     0.5559 0.000 0.048 0.784 0.168
#> GSM22368     3   0.666     0.1170 0.000 0.084 0.468 0.448
#> GSM22370     1   0.410     0.4706 0.792 0.000 0.016 0.192
#> GSM22371     2   0.340     0.5405 0.000 0.864 0.032 0.104
#> GSM22372     4   0.434     0.4323 0.012 0.092 0.064 0.832
#> GSM22373     1   0.631     0.4410 0.660 0.188 0.152 0.000
#> GSM22375     1   0.803     0.0447 0.388 0.004 0.304 0.304
#> GSM22376     1   0.744     0.2082 0.488 0.024 0.096 0.392
#> GSM22377     1   0.687     0.0954 0.480 0.056 0.444 0.020
#> GSM22378     2   0.265     0.5428 0.000 0.888 0.004 0.108
#> GSM22379     3   0.643     0.3709 0.000 0.352 0.568 0.080
#> GSM22380     3   0.537     0.4913 0.052 0.000 0.704 0.244
#> GSM22383     1   0.222     0.5365 0.908 0.000 0.092 0.000
#> GSM22386     3   0.464     0.5654 0.020 0.044 0.812 0.124
#> GSM22389     1   0.492     0.4104 0.684 0.008 0.304 0.004
#> GSM22391     3   0.388     0.5491 0.016 0.000 0.812 0.172
#> GSM22395     1   0.504     0.4201 0.684 0.000 0.296 0.020
#> GSM22396     2   0.921     0.1308 0.212 0.392 0.092 0.304
#> GSM22398     1   0.696     0.3916 0.584 0.000 0.184 0.232
#> GSM22399     1   0.850     0.0239 0.452 0.116 0.352 0.080
#> GSM22402     2   0.434     0.5077 0.024 0.836 0.096 0.044
#> GSM22407     2   0.584     0.4583 0.052 0.728 0.032 0.188
#> GSM22411     3   0.687     0.3291 0.132 0.000 0.564 0.304
#> GSM22412     4   0.805     0.1748 0.348 0.100 0.060 0.492
#> GSM22415     1   0.605     0.2762 0.556 0.000 0.048 0.396
#> GSM22416     2   0.685     0.5218 0.168 0.652 0.020 0.160

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5   0.322    0.59210 0.000 0.096 0.004 0.044 0.856
#> GSM22374     3   0.683    0.26579 0.320 0.000 0.420 0.256 0.004
#> GSM22381     1   0.611    0.25180 0.640 0.052 0.008 0.244 0.056
#> GSM22382     5   0.181    0.61652 0.020 0.016 0.008 0.012 0.944
#> GSM22384     5   0.695    0.37632 0.104 0.004 0.256 0.072 0.564
#> GSM22385     4   0.643    0.42310 0.120 0.000 0.088 0.644 0.148
#> GSM22387     3   0.486    0.54060 0.292 0.000 0.664 0.040 0.004
#> GSM22388     1   0.318    0.41716 0.872 0.020 0.044 0.064 0.000
#> GSM22390     3   0.228    0.54731 0.004 0.076 0.908 0.004 0.008
#> GSM22392     3   0.668    0.11025 0.020 0.148 0.496 0.336 0.000
#> GSM22393     1   0.462    0.43489 0.772 0.048 0.152 0.024 0.004
#> GSM22394     1   0.786    0.35015 0.552 0.036 0.132 0.128 0.152
#> GSM22397     4   0.667    0.31762 0.292 0.000 0.048 0.552 0.108
#> GSM22400     4   0.813    0.00595 0.244 0.044 0.244 0.432 0.036
#> GSM22401     5   0.228    0.60856 0.056 0.028 0.000 0.004 0.912
#> GSM22403     1   0.601    0.23453 0.580 0.004 0.004 0.112 0.300
#> GSM22404     5   0.203    0.61611 0.000 0.040 0.008 0.024 0.928
#> GSM22405     2   0.598    0.20398 0.000 0.584 0.048 0.324 0.044
#> GSM22406     1   0.540    0.29876 0.668 0.008 0.036 0.264 0.024
#> GSM22408     3   0.478    0.57738 0.048 0.016 0.780 0.128 0.028
#> GSM22409     5   0.651    0.18390 0.332 0.060 0.004 0.056 0.548
#> GSM22410     5   0.784   -0.17899 0.012 0.044 0.360 0.224 0.360
#> GSM22413     5   0.268    0.60669 0.080 0.016 0.008 0.004 0.892
#> GSM22414     4   0.663    0.29339 0.184 0.120 0.000 0.616 0.080
#> GSM22417     2   0.619    0.55690 0.000 0.644 0.196 0.108 0.052
#> GSM22418     1   0.619    0.33573 0.504 0.000 0.376 0.112 0.008
#> GSM22419     1   0.556    0.43925 0.648 0.004 0.228 0.120 0.000
#> GSM22420     3   0.516    0.51814 0.308 0.000 0.628 0.064 0.000
#> GSM22421     5   0.778   -0.06400 0.108 0.156 0.000 0.296 0.440
#> GSM22422     5   0.676    0.42701 0.052 0.172 0.016 0.136 0.624
#> GSM22423     5   0.547    0.48048 0.016 0.004 0.120 0.156 0.704
#> GSM22424     4   0.494    0.36477 0.236 0.004 0.048 0.704 0.008
#> GSM22365     2   0.587   -0.00286 0.276 0.596 0.000 0.124 0.004
#> GSM22366     1   0.717    0.09908 0.440 0.032 0.000 0.336 0.192
#> GSM22367     2   0.611    0.51608 0.000 0.604 0.152 0.012 0.232
#> GSM22368     5   0.321    0.60224 0.000 0.092 0.008 0.040 0.860
#> GSM22370     3   0.773    0.37571 0.256 0.004 0.460 0.208 0.072
#> GSM22371     1   0.675    0.16333 0.508 0.304 0.008 0.172 0.008
#> GSM22372     5   0.306    0.60678 0.052 0.044 0.000 0.024 0.880
#> GSM22373     3   0.473    0.50609 0.080 0.000 0.720 0.200 0.000
#> GSM22375     3   0.327    0.51043 0.028 0.032 0.876 0.008 0.056
#> GSM22376     5   0.892   -0.17967 0.064 0.068 0.292 0.284 0.292
#> GSM22377     2   0.813    0.05166 0.260 0.392 0.120 0.228 0.000
#> GSM22378     1   0.659    0.19198 0.504 0.296 0.000 0.192 0.008
#> GSM22379     2   0.227    0.45689 0.020 0.916 0.000 0.052 0.012
#> GSM22380     2   0.654    0.52868 0.000 0.580 0.176 0.028 0.216
#> GSM22383     3   0.667    0.53197 0.220 0.036 0.604 0.128 0.012
#> GSM22386     2   0.430    0.57551 0.004 0.712 0.268 0.004 0.012
#> GSM22389     3   0.141    0.56168 0.004 0.036 0.952 0.008 0.000
#> GSM22391     2   0.529    0.57320 0.020 0.660 0.280 0.004 0.036
#> GSM22395     3   0.313    0.55544 0.004 0.064 0.876 0.044 0.012
#> GSM22396     4   0.494    0.45797 0.064 0.012 0.020 0.760 0.144
#> GSM22398     3   0.710    0.37373 0.008 0.048 0.544 0.144 0.256
#> GSM22399     1   0.773   -0.05542 0.416 0.360 0.160 0.040 0.024
#> GSM22402     4   0.734    0.20545 0.184 0.356 0.000 0.416 0.044
#> GSM22407     4   0.744    0.01595 0.168 0.040 0.008 0.428 0.356
#> GSM22411     2   0.726    0.30995 0.004 0.352 0.340 0.012 0.292
#> GSM22412     5   0.737    0.24751 0.196 0.004 0.048 0.260 0.492
#> GSM22415     3   0.819    0.27192 0.024 0.072 0.440 0.236 0.228
#> GSM22416     1   0.549    0.42386 0.736 0.032 0.060 0.144 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
#> GSM22369     5   0.355     0.6112 0.000 0.080 0.020 0.036 0.840 0.024
#> GSM22374     6   0.476     0.4151 0.008 0.004 0.264 0.060 0.000 0.664
#> GSM22381     6   0.645     0.2730 0.196 0.120 0.000 0.052 0.036 0.596
#> GSM22382     5   0.162     0.6438 0.020 0.000 0.028 0.012 0.940 0.000
#> GSM22384     5   0.614     0.3623 0.192 0.000 0.252 0.004 0.532 0.020
#> GSM22385     4   0.507     0.3829 0.004 0.000 0.080 0.700 0.040 0.176
#> GSM22387     6   0.458     0.2497 0.004 0.004 0.452 0.020 0.000 0.520
#> GSM22388     6   0.423     0.1345 0.372 0.016 0.004 0.000 0.000 0.608
#> GSM22390     3   0.289     0.5444 0.012 0.064 0.876 0.004 0.004 0.040
#> GSM22392     3   0.703     0.2816 0.032 0.128 0.528 0.224 0.000 0.088
#> GSM22393     1   0.558     0.1835 0.568 0.044 0.052 0.004 0.000 0.332
#> GSM22394     1   0.466     0.4431 0.716 0.000 0.140 0.000 0.132 0.012
#> GSM22397     4   0.465     0.3725 0.204 0.000 0.036 0.716 0.004 0.040
#> GSM22400     6   0.709    -0.0523 0.056 0.016 0.096 0.360 0.024 0.448
#> GSM22401     5   0.117     0.6456 0.012 0.008 0.000 0.020 0.960 0.000
#> GSM22403     6   0.683     0.1615 0.240 0.004 0.000 0.068 0.204 0.484
#> GSM22404     5   0.314     0.6299 0.000 0.020 0.032 0.056 0.868 0.024
#> GSM22405     2   0.550     0.4858 0.004 0.676 0.116 0.164 0.028 0.012
#> GSM22406     1   0.623    -0.0392 0.508 0.024 0.032 0.364 0.004 0.068
#> GSM22408     3   0.615     0.3043 0.008 0.016 0.536 0.244 0.000 0.196
#> GSM22409     5   0.755     0.2521 0.256 0.064 0.000 0.124 0.468 0.088
#> GSM22410     6   0.794    -0.1106 0.000 0.016 0.192 0.280 0.196 0.316
#> GSM22413     5   0.325     0.6331 0.012 0.012 0.004 0.020 0.848 0.104
#> GSM22414     4   0.591     0.0973 0.340 0.020 0.000 0.532 0.096 0.012
#> GSM22417     2   0.677     0.3492 0.004 0.524 0.292 0.088 0.032 0.060
#> GSM22418     1   0.494     0.1640 0.508 0.008 0.444 0.000 0.004 0.036
#> GSM22419     1   0.466     0.4538 0.688 0.004 0.228 0.004 0.000 0.076
#> GSM22420     6   0.411     0.3724 0.012 0.004 0.360 0.000 0.000 0.624
#> GSM22421     5   0.686     0.2091 0.056 0.164 0.000 0.304 0.464 0.012
#> GSM22422     5   0.555     0.5206 0.240 0.068 0.032 0.004 0.644 0.012
#> GSM22423     5   0.723     0.0991 0.000 0.008 0.132 0.292 0.436 0.132
#> GSM22424     4   0.416     0.0452 0.004 0.000 0.004 0.588 0.004 0.400
#> GSM22365     2   0.400     0.2896 0.248 0.712 0.000 0.040 0.000 0.000
#> GSM22366     4   0.710     0.1985 0.280 0.052 0.000 0.492 0.052 0.124
#> GSM22367     2   0.639     0.4319 0.004 0.580 0.144 0.012 0.212 0.048
#> GSM22368     5   0.342     0.6230 0.016 0.072 0.012 0.040 0.852 0.008
#> GSM22370     6   0.573     0.2723 0.000 0.004 0.276 0.120 0.020 0.580
#> GSM22371     1   0.551     0.2657 0.540 0.300 0.000 0.160 0.000 0.000
#> GSM22372     5   0.468     0.6242 0.076 0.032 0.008 0.072 0.780 0.032
#> GSM22373     3   0.559     0.4032 0.112 0.000 0.600 0.260 0.000 0.028
#> GSM22375     3   0.248     0.5545 0.060 0.012 0.900 0.008 0.016 0.004
#> GSM22376     6   0.819    -0.1511 0.004 0.084 0.080 0.304 0.176 0.352
#> GSM22377     6   0.550     0.3561 0.000 0.208 0.060 0.084 0.000 0.648
#> GSM22378     1   0.636     0.2644 0.528 0.284 0.000 0.144 0.028 0.016
#> GSM22379     2   0.351     0.4724 0.048 0.836 0.012 0.008 0.004 0.092
#> GSM22380     2   0.791     0.3089 0.000 0.416 0.164 0.040 0.220 0.160
#> GSM22383     6   0.568     0.3624 0.100 0.032 0.260 0.004 0.000 0.604
#> GSM22386     2   0.437     0.3823 0.004 0.620 0.356 0.004 0.004 0.012
#> GSM22389     3   0.272     0.5778 0.024 0.024 0.892 0.040 0.000 0.020
#> GSM22391     2   0.548     0.3310 0.000 0.540 0.380 0.020 0.016 0.044
#> GSM22395     3   0.409     0.5580 0.000 0.028 0.792 0.100 0.004 0.076
#> GSM22396     4   0.274     0.4552 0.060 0.004 0.020 0.888 0.020 0.008
#> GSM22398     3   0.809     0.2188 0.008 0.064 0.444 0.140 0.140 0.204
#> GSM22399     6   0.541     0.3834 0.052 0.192 0.064 0.004 0.008 0.680
#> GSM22402     2   0.672     0.0178 0.148 0.416 0.004 0.384 0.040 0.008
#> GSM22407     5   0.645     0.1466 0.304 0.000 0.004 0.320 0.364 0.008
#> GSM22411     3   0.625     0.0135 0.008 0.188 0.524 0.008 0.264 0.008
#> GSM22412     5   0.798     0.2465 0.148 0.020 0.012 0.196 0.408 0.216
#> GSM22415     4   0.803     0.0585 0.004 0.068 0.228 0.368 0.064 0.268
#> GSM22416     1   0.331     0.4834 0.856 0.000 0.060 0.012 0.032 0.040

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>         n disease.state(p) k
#> CV:NMF 51           0.2939 2
#> CV:NMF 40           0.9260 3
#> CV:NMF 12           0.0811 4
#> CV:NMF 21           0.2063 5
#> CV:NMF 12           0.3006 6

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 21446 rows and 60 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.378           0.701       0.853         0.3505 0.655   0.655
#> 3 3 0.283           0.527       0.687         0.5571 0.918   0.876
#> 4 4 0.363           0.518       0.709         0.2727 0.641   0.417
#> 5 5 0.423           0.568       0.714         0.0742 0.914   0.702
#> 6 6 0.463           0.570       0.726         0.0394 0.969   0.862

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
#> GSM22369     2  0.9686     0.5238 0.396 0.604
#> GSM22374     1  0.0672     0.8369 0.992 0.008
#> GSM22381     1  0.2948     0.8451 0.948 0.052
#> GSM22382     2  0.9686     0.5238 0.396 0.604
#> GSM22384     1  0.9944    -0.0562 0.544 0.456
#> GSM22385     1  0.0938     0.8426 0.988 0.012
#> GSM22387     1  0.0672     0.8369 0.992 0.008
#> GSM22388     1  0.0672     0.8369 0.992 0.008
#> GSM22390     1  0.6712     0.7757 0.824 0.176
#> GSM22392     1  0.5294     0.8172 0.880 0.120
#> GSM22393     1  0.0672     0.8369 0.992 0.008
#> GSM22394     1  0.3431     0.8468 0.936 0.064
#> GSM22397     1  0.2423     0.8473 0.960 0.040
#> GSM22400     1  0.3584     0.8429 0.932 0.068
#> GSM22401     2  0.9754     0.4939 0.408 0.592
#> GSM22403     1  0.2236     0.8462 0.964 0.036
#> GSM22404     2  0.9686     0.5238 0.396 0.604
#> GSM22405     2  0.9522     0.5530 0.372 0.628
#> GSM22406     1  0.1633     0.8432 0.976 0.024
#> GSM22408     1  0.4161     0.8392 0.916 0.084
#> GSM22409     1  0.4939     0.8303 0.892 0.108
#> GSM22410     1  0.6973     0.7494 0.812 0.188
#> GSM22413     1  0.2948     0.8451 0.948 0.052
#> GSM22414     1  0.5629     0.8071 0.868 0.132
#> GSM22417     1  0.7528     0.7197 0.784 0.216
#> GSM22418     1  0.0672     0.8369 0.992 0.008
#> GSM22419     1  0.0672     0.8369 0.992 0.008
#> GSM22420     1  0.0672     0.8369 0.992 0.008
#> GSM22421     2  0.0672     0.6855 0.008 0.992
#> GSM22422     1  0.9954    -0.0114 0.540 0.460
#> GSM22423     1  0.6973     0.7494 0.812 0.188
#> GSM22424     1  0.0938     0.8382 0.988 0.012
#> GSM22365     2  0.0672     0.6855 0.008 0.992
#> GSM22366     1  0.9323     0.4307 0.652 0.348
#> GSM22367     2  0.9522     0.5530 0.372 0.628
#> GSM22368     1  0.9000     0.4920 0.684 0.316
#> GSM22370     1  0.2236     0.8462 0.964 0.036
#> GSM22371     2  0.1633     0.6873 0.024 0.976
#> GSM22372     1  0.7674     0.7053 0.776 0.224
#> GSM22373     1  0.2603     0.8475 0.956 0.044
#> GSM22375     1  0.5946     0.7993 0.856 0.144
#> GSM22376     1  0.3114     0.8445 0.944 0.056
#> GSM22377     1  0.2043     0.8435 0.968 0.032
#> GSM22378     2  0.0672     0.6855 0.008 0.992
#> GSM22379     2  0.0672     0.6855 0.008 0.992
#> GSM22380     1  0.9795     0.1825 0.584 0.416
#> GSM22383     1  0.0672     0.8369 0.992 0.008
#> GSM22386     1  0.9815     0.2706 0.580 0.420
#> GSM22389     1  0.5408     0.8145 0.876 0.124
#> GSM22391     1  0.9635     0.3665 0.612 0.388
#> GSM22395     1  0.4690     0.8319 0.900 0.100
#> GSM22396     1  0.4298     0.8377 0.912 0.088
#> GSM22398     1  0.7745     0.6360 0.772 0.228
#> GSM22399     1  0.0672     0.8369 0.992 0.008
#> GSM22402     2  0.1633     0.6879 0.024 0.976
#> GSM22407     1  0.7139     0.7449 0.804 0.196
#> GSM22411     2  0.9896     0.3906 0.440 0.560
#> GSM22412     1  0.2948     0.8485 0.948 0.052
#> GSM22415     1  0.3584     0.8449 0.932 0.068
#> GSM22416     1  0.0672     0.8369 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3  0.9268      0.847 0.336 0.172 0.492
#> GSM22374     1  0.6180      0.579 0.584 0.000 0.416
#> GSM22381     1  0.1411      0.564 0.964 0.000 0.036
#> GSM22382     3  0.9268      0.847 0.336 0.172 0.492
#> GSM22384     3  0.8341      0.647 0.452 0.080 0.468
#> GSM22385     1  0.4974      0.587 0.764 0.000 0.236
#> GSM22387     1  0.6225      0.571 0.568 0.000 0.432
#> GSM22388     1  0.6180      0.579 0.584 0.000 0.416
#> GSM22390     1  0.7023      0.443 0.624 0.032 0.344
#> GSM22392     1  0.6579      0.547 0.652 0.020 0.328
#> GSM22393     1  0.6192      0.573 0.580 0.000 0.420
#> GSM22394     1  0.5785      0.598 0.668 0.000 0.332
#> GSM22397     1  0.4605      0.511 0.796 0.000 0.204
#> GSM22400     1  0.1832      0.557 0.956 0.008 0.036
#> GSM22401     3  0.9306      0.837 0.348 0.172 0.480
#> GSM22403     1  0.3038      0.582 0.896 0.000 0.104
#> GSM22404     3  0.9268      0.847 0.336 0.172 0.492
#> GSM22405     3  0.9338      0.824 0.300 0.196 0.504
#> GSM22406     1  0.6062      0.594 0.616 0.000 0.384
#> GSM22408     1  0.4346      0.466 0.816 0.000 0.184
#> GSM22409     1  0.4291      0.446 0.840 0.008 0.152
#> GSM22410     1  0.5403      0.423 0.816 0.060 0.124
#> GSM22413     1  0.1411      0.564 0.964 0.000 0.036
#> GSM22414     1  0.3995      0.481 0.868 0.016 0.116
#> GSM22417     1  0.6570      0.292 0.680 0.028 0.292
#> GSM22418     1  0.6244      0.567 0.560 0.000 0.440
#> GSM22419     1  0.6252      0.567 0.556 0.000 0.444
#> GSM22420     1  0.6180      0.579 0.584 0.000 0.416
#> GSM22421     2  0.2356      0.925 0.000 0.928 0.072
#> GSM22422     1  0.9217     -0.585 0.492 0.164 0.344
#> GSM22423     1  0.5403      0.423 0.816 0.060 0.124
#> GSM22424     1  0.6154      0.578 0.592 0.000 0.408
#> GSM22365     2  0.0000      0.976 0.000 1.000 0.000
#> GSM22366     1  0.8196     -0.208 0.624 0.124 0.252
#> GSM22367     3  0.9338      0.824 0.300 0.196 0.504
#> GSM22368     1  0.8117     -0.201 0.552 0.076 0.372
#> GSM22370     1  0.3038      0.582 0.896 0.000 0.104
#> GSM22371     2  0.1031      0.967 0.000 0.976 0.024
#> GSM22372     1  0.6335      0.304 0.724 0.036 0.240
#> GSM22373     1  0.5882      0.601 0.652 0.000 0.348
#> GSM22375     1  0.6677      0.497 0.652 0.024 0.324
#> GSM22376     1  0.1163      0.561 0.972 0.000 0.028
#> GSM22377     1  0.6062      0.591 0.616 0.000 0.384
#> GSM22378     2  0.0000      0.976 0.000 1.000 0.000
#> GSM22379     2  0.0000      0.976 0.000 1.000 0.000
#> GSM22380     1  0.8930     -0.396 0.536 0.148 0.316
#> GSM22383     1  0.6204      0.576 0.576 0.000 0.424
#> GSM22386     1  0.9487      0.174 0.476 0.320 0.204
#> GSM22389     1  0.6627      0.540 0.644 0.020 0.336
#> GSM22391     1  0.9399      0.230 0.500 0.292 0.208
#> GSM22395     1  0.5020      0.450 0.796 0.012 0.192
#> GSM22396     1  0.2492      0.548 0.936 0.016 0.048
#> GSM22398     3  0.6676     -0.180 0.476 0.008 0.516
#> GSM22399     1  0.6180      0.579 0.584 0.000 0.416
#> GSM22402     2  0.0983      0.970 0.004 0.980 0.016
#> GSM22407     1  0.5536      0.366 0.804 0.052 0.144
#> GSM22411     3  0.9217      0.806 0.344 0.164 0.492
#> GSM22412     1  0.5201      0.602 0.760 0.004 0.236
#> GSM22415     1  0.4504      0.475 0.804 0.000 0.196
#> GSM22416     1  0.6168      0.581 0.588 0.000 0.412

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.2888     0.7053 0.004 0.000 0.124 0.872
#> GSM22374     1  0.2310     0.7392 0.920 0.008 0.068 0.004
#> GSM22381     3  0.5383     0.5336 0.292 0.000 0.672 0.036
#> GSM22382     4  0.2888     0.7053 0.004 0.000 0.124 0.872
#> GSM22384     4  0.6206     0.5538 0.056 0.028 0.232 0.684
#> GSM22385     1  0.5230     0.1389 0.620 0.004 0.368 0.008
#> GSM22387     1  0.0895     0.7423 0.976 0.004 0.020 0.000
#> GSM22388     1  0.2310     0.7392 0.920 0.008 0.068 0.004
#> GSM22390     3  0.8547     0.1812 0.208 0.040 0.424 0.328
#> GSM22392     1  0.8579    -0.1086 0.392 0.036 0.348 0.224
#> GSM22393     1  0.2053     0.7343 0.924 0.004 0.072 0.000
#> GSM22394     1  0.6175     0.5401 0.704 0.028 0.196 0.072
#> GSM22397     3  0.5577     0.4857 0.124 0.040 0.768 0.068
#> GSM22400     3  0.5599     0.5451 0.276 0.000 0.672 0.052
#> GSM22401     4  0.3725     0.6760 0.008 0.000 0.180 0.812
#> GSM22403     3  0.5847     0.4046 0.404 0.000 0.560 0.036
#> GSM22404     4  0.2888     0.7053 0.004 0.000 0.124 0.872
#> GSM22405     4  0.0592     0.6733 0.000 0.016 0.000 0.984
#> GSM22406     1  0.4914     0.6246 0.772 0.012 0.180 0.036
#> GSM22408     3  0.4633     0.4780 0.056 0.040 0.828 0.076
#> GSM22409     3  0.3146     0.4934 0.032 0.016 0.896 0.056
#> GSM22410     3  0.7085     0.4812 0.232 0.000 0.568 0.200
#> GSM22413     3  0.5383     0.5336 0.292 0.000 0.672 0.036
#> GSM22414     3  0.7362     0.4967 0.248 0.008 0.560 0.184
#> GSM22417     4  0.8297     0.0214 0.192 0.036 0.296 0.476
#> GSM22418     1  0.1256     0.7324 0.964 0.008 0.028 0.000
#> GSM22419     1  0.0376     0.7391 0.992 0.004 0.004 0.000
#> GSM22420     1  0.2310     0.7392 0.920 0.008 0.068 0.004
#> GSM22421     2  0.2973     0.9090 0.000 0.856 0.000 0.144
#> GSM22422     4  0.5986     0.4045 0.040 0.008 0.332 0.620
#> GSM22423     3  0.7085     0.4812 0.232 0.000 0.568 0.200
#> GSM22424     1  0.1722     0.7446 0.944 0.008 0.048 0.000
#> GSM22365     2  0.1637     0.9717 0.000 0.940 0.000 0.060
#> GSM22366     3  0.5708     0.0263 0.028 0.000 0.556 0.416
#> GSM22367     4  0.0592     0.6733 0.000 0.016 0.000 0.984
#> GSM22368     4  0.7434     0.2187 0.232 0.000 0.256 0.512
#> GSM22370     3  0.5847     0.4046 0.404 0.000 0.560 0.036
#> GSM22371     2  0.2376     0.9628 0.016 0.916 0.000 0.068
#> GSM22372     3  0.7251     0.3840 0.196 0.004 0.564 0.236
#> GSM22373     1  0.6071     0.5684 0.708 0.020 0.192 0.080
#> GSM22375     3  0.8636     0.2086 0.276 0.036 0.408 0.280
#> GSM22376     3  0.5334     0.5380 0.284 0.000 0.680 0.036
#> GSM22377     1  0.7043     0.2904 0.556 0.040 0.352 0.052
#> GSM22378     2  0.1637     0.9717 0.000 0.940 0.000 0.060
#> GSM22379     2  0.1637     0.9717 0.000 0.940 0.000 0.060
#> GSM22380     4  0.6865     0.1876 0.112 0.000 0.364 0.524
#> GSM22383     1  0.1443     0.7438 0.960 0.008 0.028 0.004
#> GSM22386     3  0.9333     0.1138 0.104 0.336 0.356 0.204
#> GSM22389     3  0.8582     0.1235 0.352 0.036 0.388 0.224
#> GSM22391     3  0.9465     0.1515 0.124 0.300 0.372 0.204
#> GSM22395     3  0.5680     0.4464 0.068 0.040 0.760 0.132
#> GSM22396     3  0.5986     0.5632 0.256 0.004 0.668 0.072
#> GSM22398     1  0.5774     0.0370 0.492 0.004 0.020 0.484
#> GSM22399     1  0.2310     0.7392 0.920 0.008 0.068 0.004
#> GSM22402     2  0.2329     0.9641 0.012 0.916 0.000 0.072
#> GSM22407     3  0.7235     0.3783 0.180 0.000 0.532 0.288
#> GSM22411     4  0.3304     0.6554 0.028 0.012 0.076 0.884
#> GSM22412     1  0.6348     0.0193 0.516 0.008 0.432 0.044
#> GSM22415     3  0.4563     0.4754 0.056 0.040 0.832 0.072
#> GSM22416     1  0.1124     0.7408 0.972 0.004 0.012 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
#> GSM22369     5  0.2583    0.69325 0.000 0.000 0.004 0.132 0.864
#> GSM22374     1  0.2409    0.75268 0.908 0.008 0.028 0.056 0.000
#> GSM22381     4  0.4080    0.74416 0.252 0.000 0.000 0.728 0.020
#> GSM22382     5  0.2583    0.69325 0.000 0.000 0.004 0.132 0.864
#> GSM22384     5  0.6505    0.42512 0.028 0.004 0.184 0.180 0.604
#> GSM22385     1  0.4707   -0.07641 0.588 0.000 0.020 0.392 0.000
#> GSM22387     1  0.0693    0.75796 0.980 0.000 0.008 0.012 0.000
#> GSM22388     1  0.2409    0.75268 0.908 0.008 0.028 0.056 0.000
#> GSM22390     3  0.7364    0.54106 0.152 0.004 0.520 0.072 0.252
#> GSM22392     3  0.7256    0.43947 0.328 0.000 0.452 0.044 0.176
#> GSM22393     1  0.2570    0.73968 0.888 0.000 0.084 0.028 0.000
#> GSM22394     1  0.5377    0.56672 0.684 0.004 0.088 0.216 0.008
#> GSM22397     3  0.5682    0.46825 0.052 0.008 0.580 0.352 0.008
#> GSM22400     4  0.4297    0.74838 0.236 0.000 0.000 0.728 0.036
#> GSM22401     5  0.3196    0.66763 0.000 0.000 0.004 0.192 0.804
#> GSM22403     4  0.4776    0.62996 0.364 0.000 0.004 0.612 0.020
#> GSM22404     5  0.2583    0.69325 0.000 0.000 0.004 0.132 0.864
#> GSM22405     5  0.0566    0.64553 0.000 0.004 0.012 0.000 0.984
#> GSM22406     1  0.4972    0.59638 0.736 0.000 0.176 0.060 0.028
#> GSM22408     3  0.4792    0.44483 0.008 0.000 0.536 0.448 0.008
#> GSM22409     4  0.1329    0.51760 0.000 0.008 0.032 0.956 0.004
#> GSM22410     4  0.5696    0.66675 0.200 0.000 0.000 0.628 0.172
#> GSM22413     4  0.4080    0.74416 0.252 0.000 0.000 0.728 0.020
#> GSM22414     4  0.6012    0.66805 0.212 0.008 0.000 0.612 0.168
#> GSM22417     5  0.7152   -0.31408 0.148 0.000 0.380 0.044 0.428
#> GSM22418     1  0.1671    0.74386 0.924 0.000 0.076 0.000 0.000
#> GSM22419     1  0.0992    0.75739 0.968 0.000 0.024 0.008 0.000
#> GSM22420     1  0.2409    0.75268 0.908 0.008 0.028 0.056 0.000
#> GSM22421     2  0.5935    0.67909 0.000 0.624 0.252 0.020 0.104
#> GSM22422     5  0.5084    0.38693 0.024 0.008 0.004 0.352 0.612
#> GSM22423     4  0.5696    0.66675 0.200 0.000 0.000 0.628 0.172
#> GSM22424     1  0.2139    0.75925 0.916 0.000 0.052 0.032 0.000
#> GSM22365     2  0.0671    0.93005 0.000 0.980 0.004 0.000 0.016
#> GSM22366     4  0.4557    0.07040 0.000 0.000 0.012 0.584 0.404
#> GSM22367     5  0.0566    0.64553 0.000 0.004 0.012 0.000 0.984
#> GSM22368     5  0.6602    0.18719 0.224 0.000 0.008 0.252 0.516
#> GSM22370     4  0.4776    0.62996 0.364 0.000 0.004 0.612 0.020
#> GSM22371     2  0.1377    0.92167 0.004 0.956 0.020 0.000 0.020
#> GSM22372     4  0.6215    0.51272 0.168 0.000 0.020 0.612 0.200
#> GSM22373     1  0.5504    0.52505 0.680 0.000 0.224 0.060 0.036
#> GSM22375     3  0.7379    0.54791 0.204 0.000 0.504 0.068 0.224
#> GSM22376     4  0.4026    0.74597 0.244 0.000 0.000 0.736 0.020
#> GSM22377     1  0.5786    0.04020 0.500 0.008 0.432 0.056 0.004
#> GSM22378     2  0.0671    0.93005 0.000 0.980 0.004 0.000 0.016
#> GSM22379     2  0.0510    0.92978 0.000 0.984 0.000 0.000 0.016
#> GSM22380     5  0.6085    0.12962 0.100 0.000 0.008 0.380 0.512
#> GSM22383     1  0.1267    0.75928 0.960 0.000 0.012 0.024 0.004
#> GSM22386     3  0.8081    0.44060 0.048 0.296 0.452 0.048 0.156
#> GSM22389     3  0.7319    0.50711 0.288 0.000 0.480 0.056 0.176
#> GSM22391     3  0.8599    0.48884 0.068 0.260 0.436 0.076 0.160
#> GSM22395     3  0.5941    0.50491 0.020 0.000 0.536 0.380 0.064
#> GSM22396     4  0.5340    0.73313 0.208 0.000 0.044 0.700 0.048
#> GSM22398     1  0.5407   -0.00724 0.472 0.000 0.056 0.000 0.472
#> GSM22399     1  0.2409    0.75268 0.908 0.008 0.028 0.056 0.000
#> GSM22402     2  0.1329    0.91983 0.004 0.956 0.008 0.000 0.032
#> GSM22407     4  0.6204    0.49947 0.156 0.000 0.004 0.552 0.288
#> GSM22411     5  0.2536    0.57627 0.004 0.000 0.128 0.000 0.868
#> GSM22412     1  0.6649   -0.03088 0.480 0.000 0.116 0.376 0.028
#> GSM22415     3  0.5033    0.46960 0.008 0.008 0.588 0.384 0.012
#> GSM22416     1  0.1612    0.75311 0.948 0.000 0.016 0.024 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
#> GSM22369     5  0.2146     0.6785 0.000 0.000 0.004 0.116 0.880 0.000
#> GSM22374     1  0.2733     0.7487 0.864 0.000 0.000 0.056 0.000 0.080
#> GSM22381     4  0.3376     0.7449 0.220 0.000 0.000 0.764 0.016 0.000
#> GSM22382     5  0.2146     0.6785 0.000 0.000 0.004 0.116 0.880 0.000
#> GSM22384     5  0.6435     0.3945 0.024 0.000 0.208 0.140 0.580 0.048
#> GSM22385     1  0.4701    -0.0826 0.560 0.000 0.004 0.396 0.000 0.040
#> GSM22387     1  0.0891     0.7587 0.968 0.000 0.024 0.000 0.000 0.008
#> GSM22388     1  0.2733     0.7487 0.864 0.000 0.000 0.056 0.000 0.080
#> GSM22390     3  0.5477     0.5683 0.112 0.000 0.672 0.028 0.172 0.016
#> GSM22392     3  0.5003     0.4703 0.288 0.000 0.608 0.000 0.104 0.000
#> GSM22393     1  0.3323     0.7299 0.824 0.000 0.128 0.036 0.000 0.012
#> GSM22394     1  0.5553     0.5971 0.668 0.000 0.100 0.172 0.008 0.052
#> GSM22397     3  0.6055     0.4342 0.044 0.000 0.592 0.160 0.004 0.200
#> GSM22400     4  0.3849     0.7483 0.208 0.000 0.008 0.752 0.032 0.000
#> GSM22401     5  0.2738     0.6582 0.000 0.000 0.004 0.176 0.820 0.000
#> GSM22403     4  0.4343     0.6487 0.320 0.000 0.000 0.648 0.016 0.016
#> GSM22404     5  0.2146     0.6785 0.000 0.000 0.004 0.116 0.880 0.000
#> GSM22405     5  0.1138     0.6163 0.000 0.004 0.024 0.000 0.960 0.012
#> GSM22406     1  0.5053     0.5685 0.688 0.000 0.216 0.056 0.016 0.024
#> GSM22408     3  0.5376     0.4453 0.016 0.000 0.644 0.204 0.004 0.132
#> GSM22409     4  0.2089     0.5488 0.000 0.000 0.020 0.916 0.020 0.044
#> GSM22410     4  0.5200     0.6567 0.192 0.000 0.000 0.632 0.172 0.004
#> GSM22413     4  0.3460     0.7459 0.220 0.000 0.000 0.760 0.020 0.000
#> GSM22414     4  0.5328     0.6653 0.180 0.008 0.004 0.640 0.168 0.000
#> GSM22417     3  0.6057     0.3590 0.108 0.000 0.492 0.008 0.368 0.024
#> GSM22418     1  0.2313     0.7386 0.884 0.000 0.100 0.004 0.000 0.012
#> GSM22419     1  0.1777     0.7572 0.932 0.000 0.024 0.012 0.000 0.032
#> GSM22420     1  0.2733     0.7487 0.864 0.000 0.000 0.056 0.000 0.080
#> GSM22421     6  0.4606     0.0000 0.000 0.268 0.000 0.000 0.076 0.656
#> GSM22422     5  0.4604     0.3923 0.024 0.008 0.008 0.332 0.628 0.000
#> GSM22423     4  0.5200     0.6567 0.192 0.000 0.000 0.632 0.172 0.004
#> GSM22424     1  0.2683     0.7589 0.884 0.000 0.056 0.032 0.000 0.028
#> GSM22365     2  0.0146     0.9728 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM22366     4  0.4151     0.0740 0.000 0.000 0.008 0.576 0.412 0.004
#> GSM22367     5  0.1138     0.6163 0.000 0.004 0.024 0.000 0.960 0.012
#> GSM22368     5  0.6985     0.2434 0.164 0.000 0.036 0.260 0.496 0.044
#> GSM22370     4  0.4343     0.6487 0.320 0.000 0.000 0.648 0.016 0.016
#> GSM22371     2  0.0891     0.9500 0.000 0.968 0.024 0.000 0.000 0.008
#> GSM22372     4  0.6482     0.4995 0.144 0.000 0.060 0.580 0.196 0.020
#> GSM22373     1  0.5314     0.4944 0.644 0.000 0.264 0.032 0.020 0.040
#> GSM22375     3  0.5023     0.5788 0.148 0.000 0.688 0.008 0.148 0.008
#> GSM22376     4  0.3320     0.7468 0.212 0.000 0.000 0.772 0.016 0.000
#> GSM22377     1  0.5890     0.0763 0.488 0.000 0.360 0.016 0.000 0.136
#> GSM22378     2  0.0146     0.9728 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM22379     2  0.0000     0.9724 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     5  0.5763     0.1181 0.100 0.000 0.012 0.368 0.512 0.008
#> GSM22383     1  0.1642     0.7622 0.936 0.000 0.032 0.028 0.000 0.004
#> GSM22386     3  0.5605     0.4026 0.016 0.296 0.584 0.000 0.096 0.008
#> GSM22389     3  0.4813     0.5313 0.248 0.000 0.648 0.000 0.104 0.000
#> GSM22391     3  0.6551     0.4310 0.036 0.260 0.560 0.028 0.108 0.008
#> GSM22395     3  0.5453     0.5100 0.020 0.000 0.688 0.160 0.040 0.092
#> GSM22396     4  0.4797     0.7402 0.184 0.000 0.060 0.712 0.044 0.000
#> GSM22398     5  0.6386     0.0901 0.408 0.000 0.076 0.008 0.440 0.068
#> GSM22399     1  0.2733     0.7487 0.864 0.000 0.000 0.056 0.000 0.080
#> GSM22402     2  0.0914     0.9463 0.000 0.968 0.016 0.000 0.016 0.000
#> GSM22407     4  0.5615     0.4978 0.140 0.000 0.004 0.556 0.296 0.004
#> GSM22411     5  0.2669     0.5482 0.000 0.000 0.156 0.000 0.836 0.008
#> GSM22412     1  0.6428    -0.0113 0.444 0.000 0.144 0.376 0.020 0.016
#> GSM22415     3  0.5478     0.4486 0.016 0.000 0.636 0.172 0.004 0.172
#> GSM22416     1  0.2557     0.7498 0.892 0.000 0.032 0.060 0.008 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:hclust 51           0.6038 2
#> MAD:hclust 41           0.0657 3
#> MAD:hclust 33           0.1008 4
#> MAD:hclust 43           0.0943 5
#> MAD:hclust 40           0.0158 6

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 21446 rows and 60 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 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 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 0.524           0.727       0.886         0.4698 0.506   0.506
#> 3 3 0.316           0.492       0.679         0.3641 0.704   0.479
#> 4 4 0.409           0.419       0.649         0.1156 0.684   0.314
#> 5 5 0.607           0.596       0.763         0.0839 0.803   0.442
#> 6 6 0.753           0.794       0.853         0.0492 0.881   0.559

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
#> GSM22369     2  0.1414     0.8423 0.020 0.980
#> GSM22374     1  0.0000     0.8588 1.000 0.000
#> GSM22381     1  0.0000     0.8588 1.000 0.000
#> GSM22382     2  0.1414     0.8423 0.020 0.980
#> GSM22384     1  0.9580     0.4304 0.620 0.380
#> GSM22385     1  0.1414     0.8522 0.980 0.020
#> GSM22387     1  0.0000     0.8588 1.000 0.000
#> GSM22388     1  0.0000     0.8588 1.000 0.000
#> GSM22390     1  0.9358     0.4917 0.648 0.352
#> GSM22392     1  0.0376     0.8585 0.996 0.004
#> GSM22393     1  0.0376     0.8585 0.996 0.004
#> GSM22394     1  0.9460     0.4608 0.636 0.364
#> GSM22397     1  0.0376     0.8585 0.996 0.004
#> GSM22400     1  0.4298     0.8142 0.912 0.088
#> GSM22401     2  0.1414     0.8423 0.020 0.980
#> GSM22403     1  0.4431     0.8118 0.908 0.092
#> GSM22404     2  0.1414     0.8423 0.020 0.980
#> GSM22405     2  0.0000     0.8411 0.000 1.000
#> GSM22406     1  0.0376     0.8585 0.996 0.004
#> GSM22408     1  0.8443     0.6273 0.728 0.272
#> GSM22409     2  0.9933     0.1572 0.452 0.548
#> GSM22410     1  0.8267     0.6565 0.740 0.260
#> GSM22413     1  0.4562     0.8086 0.904 0.096
#> GSM22414     2  0.1414     0.8423 0.020 0.980
#> GSM22417     1  0.9522     0.4377 0.628 0.372
#> GSM22418     1  0.0376     0.8585 0.996 0.004
#> GSM22419     1  0.0376     0.8585 0.996 0.004
#> GSM22420     1  0.0000     0.8588 1.000 0.000
#> GSM22421     2  0.0000     0.8411 0.000 1.000
#> GSM22422     2  0.0376     0.8410 0.004 0.996
#> GSM22423     2  0.9993     0.0274 0.484 0.516
#> GSM22424     1  0.0376     0.8585 0.996 0.004
#> GSM22365     2  0.0000     0.8411 0.000 1.000
#> GSM22366     2  0.3584     0.8100 0.068 0.932
#> GSM22367     2  0.0376     0.8410 0.004 0.996
#> GSM22368     2  0.1414     0.8423 0.020 0.980
#> GSM22370     1  0.4431     0.8118 0.908 0.092
#> GSM22371     2  0.0000     0.8411 0.000 1.000
#> GSM22372     2  0.9909     0.1837 0.444 0.556
#> GSM22373     1  0.0376     0.8585 0.996 0.004
#> GSM22375     1  0.8608     0.6113 0.716 0.284
#> GSM22376     1  0.7299     0.6876 0.796 0.204
#> GSM22377     1  0.0376     0.8585 0.996 0.004
#> GSM22378     2  0.0376     0.8410 0.004 0.996
#> GSM22379     2  0.0000     0.8411 0.000 1.000
#> GSM22380     2  0.9323     0.4375 0.348 0.652
#> GSM22383     1  0.0000     0.8588 1.000 0.000
#> GSM22386     2  0.0000     0.8411 0.000 1.000
#> GSM22389     1  0.8713     0.5967 0.708 0.292
#> GSM22391     2  0.9552     0.3600 0.376 0.624
#> GSM22395     1  0.8763     0.5909 0.704 0.296
#> GSM22396     2  0.9922     0.1700 0.448 0.552
#> GSM22398     1  0.1184     0.8545 0.984 0.016
#> GSM22399     1  0.0000     0.8588 1.000 0.000
#> GSM22402     2  0.0000     0.8411 0.000 1.000
#> GSM22407     2  0.8386     0.5803 0.268 0.732
#> GSM22411     2  0.1184     0.8418 0.016 0.984
#> GSM22412     1  0.0000     0.8588 1.000 0.000
#> GSM22415     1  0.8555     0.6162 0.720 0.280
#> GSM22416     1  0.0000     0.8588 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.6081     0.6962 0.004 0.652 0.344
#> GSM22374     1  0.0237     0.6618 0.996 0.000 0.004
#> GSM22381     1  0.5763     0.6194 0.740 0.016 0.244
#> GSM22382     2  0.6081     0.6962 0.004 0.652 0.344
#> GSM22384     3  0.4642     0.4561 0.084 0.060 0.856
#> GSM22385     1  0.6577     0.4946 0.572 0.008 0.420
#> GSM22387     1  0.1860     0.6729 0.948 0.000 0.052
#> GSM22388     1  0.0237     0.6618 0.996 0.000 0.004
#> GSM22390     3  0.6805     0.4301 0.268 0.044 0.688
#> GSM22392     3  0.6888     0.1072 0.432 0.016 0.552
#> GSM22393     1  0.3425     0.6785 0.884 0.004 0.112
#> GSM22394     3  0.6172     0.1691 0.308 0.012 0.680
#> GSM22397     1  0.6307     0.0142 0.512 0.000 0.488
#> GSM22400     1  0.7001     0.5276 0.628 0.032 0.340
#> GSM22401     2  0.6057     0.6938 0.004 0.656 0.340
#> GSM22403     1  0.6955     0.5206 0.636 0.032 0.332
#> GSM22404     2  0.6081     0.6962 0.004 0.652 0.344
#> GSM22405     2  0.3752     0.7438 0.000 0.856 0.144
#> GSM22406     1  0.5905     0.4050 0.648 0.000 0.352
#> GSM22408     3  0.6984     0.4005 0.304 0.040 0.656
#> GSM22409     3  0.8787     0.3508 0.188 0.228 0.584
#> GSM22410     3  0.5719     0.3830 0.156 0.052 0.792
#> GSM22413     1  0.6912     0.5116 0.628 0.028 0.344
#> GSM22414     2  0.5517     0.6974 0.004 0.728 0.268
#> GSM22417     3  0.7106     0.4526 0.232 0.072 0.696
#> GSM22418     1  0.5216     0.5288 0.740 0.000 0.260
#> GSM22419     1  0.4452     0.6064 0.808 0.000 0.192
#> GSM22420     1  0.0237     0.6618 0.996 0.000 0.004
#> GSM22421     2  0.2066     0.7412 0.000 0.940 0.060
#> GSM22422     2  0.4796     0.7503 0.000 0.780 0.220
#> GSM22423     3  0.8331     0.3668 0.164 0.208 0.628
#> GSM22424     1  0.2165     0.6742 0.936 0.000 0.064
#> GSM22365     2  0.1964     0.7422 0.000 0.944 0.056
#> GSM22366     3  0.7583    -0.3645 0.040 0.468 0.492
#> GSM22367     2  0.5058     0.7333 0.000 0.756 0.244
#> GSM22368     2  0.6081     0.6962 0.004 0.652 0.344
#> GSM22370     1  0.7624     0.4491 0.580 0.052 0.368
#> GSM22371     2  0.1964     0.7422 0.000 0.944 0.056
#> GSM22372     3  0.7633     0.4179 0.120 0.200 0.680
#> GSM22373     1  0.6192     0.2188 0.580 0.000 0.420
#> GSM22375     3  0.6956     0.4088 0.300 0.040 0.660
#> GSM22376     1  0.7940     0.4667 0.592 0.076 0.332
#> GSM22377     1  0.4002     0.5771 0.840 0.000 0.160
#> GSM22378     2  0.2066     0.7439 0.000 0.940 0.060
#> GSM22379     2  0.1964     0.7422 0.000 0.944 0.056
#> GSM22380     3  0.8222     0.1229 0.100 0.308 0.592
#> GSM22383     1  0.4834     0.6670 0.792 0.004 0.204
#> GSM22386     3  0.6280     0.0996 0.000 0.460 0.540
#> GSM22389     3  0.6984     0.4045 0.304 0.040 0.656
#> GSM22391     3  0.5695     0.5013 0.076 0.120 0.804
#> GSM22395     3  0.6897     0.4169 0.292 0.040 0.668
#> GSM22396     3  0.6968     0.4497 0.120 0.148 0.732
#> GSM22398     1  0.7065     0.5220 0.616 0.032 0.352
#> GSM22399     1  0.0237     0.6618 0.996 0.000 0.004
#> GSM22402     2  0.1860     0.7434 0.000 0.948 0.052
#> GSM22407     3  0.8744    -0.1329 0.108 0.444 0.448
#> GSM22411     3  0.6244    -0.1306 0.000 0.440 0.560
#> GSM22412     1  0.6154     0.4875 0.592 0.000 0.408
#> GSM22415     3  0.7186     0.3841 0.336 0.040 0.624
#> GSM22416     1  0.4755     0.6657 0.808 0.008 0.184

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.6076   -0.03012 0.036 0.344 0.012 0.608
#> GSM22374     1  0.2773    0.60490 0.900 0.000 0.072 0.028
#> GSM22381     1  0.7327    0.32720 0.488 0.012 0.112 0.388
#> GSM22382     4  0.6076   -0.03012 0.036 0.344 0.012 0.608
#> GSM22384     4  0.5718    0.33129 0.020 0.012 0.344 0.624
#> GSM22385     4  0.6882   -0.08711 0.328 0.000 0.124 0.548
#> GSM22387     1  0.6612    0.65060 0.612 0.000 0.256 0.132
#> GSM22388     1  0.2623    0.60469 0.908 0.000 0.064 0.028
#> GSM22390     3  0.1909    0.81617 0.004 0.008 0.940 0.048
#> GSM22392     3  0.1174    0.79461 0.020 0.000 0.968 0.012
#> GSM22393     1  0.7408    0.63257 0.512 0.000 0.276 0.212
#> GSM22394     4  0.7657    0.11780 0.156 0.012 0.348 0.484
#> GSM22397     3  0.4130    0.73256 0.108 0.000 0.828 0.064
#> GSM22400     4  0.7952   -0.14299 0.388 0.044 0.108 0.460
#> GSM22401     4  0.6060   -0.02403 0.036 0.340 0.012 0.612
#> GSM22403     4  0.7377   -0.14593 0.416 0.024 0.088 0.472
#> GSM22404     4  0.6076   -0.03012 0.036 0.344 0.012 0.608
#> GSM22405     2  0.6309    0.29739 0.036 0.524 0.012 0.428
#> GSM22406     3  0.4955    0.59850 0.144 0.000 0.772 0.084
#> GSM22408     3  0.2392    0.82044 0.008 0.016 0.924 0.052
#> GSM22409     4  0.7967    0.39109 0.132 0.116 0.148 0.604
#> GSM22410     4  0.4920    0.42568 0.068 0.000 0.164 0.768
#> GSM22413     4  0.7048   -0.06595 0.388 0.012 0.088 0.512
#> GSM22414     2  0.5658    0.42897 0.012 0.676 0.032 0.280
#> GSM22417     3  0.1888    0.82198 0.000 0.016 0.940 0.044
#> GSM22418     3  0.7216   -0.22217 0.336 0.000 0.508 0.156
#> GSM22419     1  0.7414    0.52506 0.460 0.000 0.368 0.172
#> GSM22420     1  0.2773    0.60490 0.900 0.000 0.072 0.028
#> GSM22421     2  0.1388    0.78657 0.012 0.960 0.028 0.000
#> GSM22422     2  0.5571    0.18522 0.004 0.512 0.012 0.472
#> GSM22423     4  0.6791    0.45145 0.084 0.088 0.132 0.696
#> GSM22424     1  0.7074    0.64615 0.568 0.000 0.240 0.192
#> GSM22365     2  0.0895    0.79506 0.000 0.976 0.020 0.004
#> GSM22366     4  0.5756    0.39744 0.052 0.136 0.056 0.756
#> GSM22367     4  0.6215   -0.12844 0.036 0.384 0.012 0.568
#> GSM22368     4  0.6060   -0.02677 0.036 0.340 0.012 0.612
#> GSM22370     4  0.6499   -0.09166 0.400 0.000 0.076 0.524
#> GSM22371     2  0.0895    0.79506 0.000 0.976 0.020 0.004
#> GSM22372     4  0.7900    0.38307 0.056 0.120 0.268 0.556
#> GSM22373     3  0.4336    0.65089 0.128 0.000 0.812 0.060
#> GSM22375     3  0.1256    0.82136 0.000 0.008 0.964 0.028
#> GSM22376     4  0.7749   -0.09449 0.392 0.048 0.084 0.476
#> GSM22377     1  0.5141    0.45407 0.700 0.000 0.268 0.032
#> GSM22378     2  0.0895    0.79506 0.000 0.976 0.020 0.004
#> GSM22379     2  0.0895    0.79506 0.000 0.976 0.020 0.004
#> GSM22380     4  0.5918    0.44658 0.048 0.104 0.096 0.752
#> GSM22383     1  0.7575    0.59831 0.484 0.000 0.252 0.264
#> GSM22386     3  0.5446    0.51644 0.000 0.276 0.680 0.044
#> GSM22389     3  0.1796    0.82300 0.004 0.016 0.948 0.032
#> GSM22391     3  0.2960    0.78757 0.004 0.020 0.892 0.084
#> GSM22395     3  0.1798    0.82216 0.000 0.016 0.944 0.040
#> GSM22396     4  0.7926    0.35927 0.056 0.112 0.292 0.540
#> GSM22398     4  0.8007   -0.16115 0.280 0.016 0.224 0.480
#> GSM22399     1  0.2773    0.60490 0.900 0.000 0.072 0.028
#> GSM22402     2  0.0895    0.79506 0.000 0.976 0.020 0.004
#> GSM22407     4  0.6583    0.45460 0.056 0.144 0.096 0.704
#> GSM22411     4  0.8154   -0.00121 0.036 0.160 0.324 0.480
#> GSM22412     1  0.7924    0.38284 0.336 0.000 0.336 0.328
#> GSM22415     3  0.3909    0.77185 0.088 0.016 0.856 0.040
#> GSM22416     1  0.7599    0.60077 0.508 0.004 0.228 0.260

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.0794     0.7748 0.000 0.000 0.000 0.028 0.972
#> GSM22374     1  0.2959     0.8314 0.864 0.000 0.036 0.100 0.000
#> GSM22381     4  0.2570     0.5342 0.084 0.028 0.000 0.888 0.000
#> GSM22382     5  0.0794     0.7748 0.000 0.000 0.000 0.028 0.972
#> GSM22384     5  0.7036    -0.0631 0.012 0.016 0.152 0.368 0.452
#> GSM22385     4  0.3045     0.6103 0.036 0.012 0.016 0.888 0.048
#> GSM22387     1  0.7468     0.3014 0.500 0.108 0.104 0.284 0.004
#> GSM22388     1  0.2959     0.8314 0.864 0.000 0.036 0.100 0.000
#> GSM22390     3  0.1405     0.8877 0.016 0.000 0.956 0.008 0.020
#> GSM22392     3  0.1059     0.8890 0.008 0.004 0.968 0.020 0.000
#> GSM22393     4  0.7448    -0.0300 0.332 0.100 0.096 0.468 0.004
#> GSM22394     4  0.8501     0.3975 0.116 0.072 0.120 0.488 0.204
#> GSM22397     3  0.3437     0.8501 0.048 0.028 0.868 0.048 0.008
#> GSM22400     4  0.3105     0.6164 0.036 0.012 0.008 0.880 0.064
#> GSM22401     5  0.1168     0.7717 0.008 0.000 0.000 0.032 0.960
#> GSM22403     4  0.3619     0.5999 0.076 0.008 0.004 0.844 0.068
#> GSM22404     5  0.0794     0.7748 0.000 0.000 0.000 0.028 0.972
#> GSM22405     5  0.2719     0.6085 0.000 0.144 0.004 0.000 0.852
#> GSM22406     3  0.4452     0.7415 0.052 0.048 0.804 0.092 0.004
#> GSM22408     3  0.1898     0.8867 0.016 0.024 0.940 0.012 0.008
#> GSM22409     4  0.4902     0.5726 0.012 0.012 0.048 0.740 0.188
#> GSM22410     4  0.4818     0.5209 0.000 0.004 0.048 0.688 0.260
#> GSM22413     4  0.3480     0.6208 0.044 0.004 0.004 0.844 0.104
#> GSM22414     2  0.6789     0.2043 0.000 0.440 0.004 0.304 0.252
#> GSM22417     3  0.0613     0.8962 0.000 0.008 0.984 0.004 0.004
#> GSM22418     4  0.8371    -0.2292 0.288 0.112 0.292 0.304 0.004
#> GSM22419     4  0.8243    -0.1856 0.308 0.112 0.212 0.364 0.004
#> GSM22420     1  0.2959     0.8314 0.864 0.000 0.036 0.100 0.000
#> GSM22421     2  0.3264     0.8722 0.024 0.840 0.004 0.000 0.132
#> GSM22422     5  0.3857     0.6420 0.008 0.132 0.000 0.048 0.812
#> GSM22423     4  0.4745     0.5532 0.000 0.012 0.048 0.724 0.216
#> GSM22424     4  0.7661    -0.1510 0.332 0.092 0.116 0.452 0.008
#> GSM22365     2  0.2770     0.8908 0.000 0.864 0.004 0.008 0.124
#> GSM22366     4  0.5033     0.3286 0.008 0.012 0.008 0.588 0.384
#> GSM22367     5  0.1200     0.7581 0.000 0.016 0.012 0.008 0.964
#> GSM22368     5  0.0771     0.7717 0.000 0.004 0.000 0.020 0.976
#> GSM22370     4  0.3839     0.6008 0.072 0.004 0.000 0.816 0.108
#> GSM22371     2  0.2929     0.8900 0.004 0.860 0.004 0.008 0.124
#> GSM22372     4  0.5127     0.5671 0.004 0.012 0.080 0.720 0.184
#> GSM22373     3  0.6322     0.5161 0.144 0.096 0.664 0.092 0.004
#> GSM22375     3  0.0579     0.8931 0.008 0.000 0.984 0.008 0.000
#> GSM22376     4  0.2964     0.6169 0.032 0.012 0.004 0.884 0.068
#> GSM22377     1  0.5265     0.6226 0.688 0.012 0.232 0.064 0.004
#> GSM22378     2  0.2770     0.8908 0.000 0.864 0.004 0.008 0.124
#> GSM22379     2  0.2770     0.8908 0.000 0.864 0.004 0.008 0.124
#> GSM22380     4  0.5281     0.2836 0.008 0.012 0.016 0.556 0.408
#> GSM22383     4  0.7019     0.1103 0.300 0.108 0.060 0.528 0.004
#> GSM22386     3  0.3586     0.7990 0.008 0.092 0.844 0.004 0.052
#> GSM22389     3  0.0566     0.8960 0.000 0.012 0.984 0.004 0.000
#> GSM22391     3  0.1982     0.8716 0.008 0.008 0.932 0.008 0.044
#> GSM22395     3  0.0727     0.8950 0.004 0.012 0.980 0.004 0.000
#> GSM22396     4  0.5217     0.5610 0.004 0.012 0.092 0.716 0.176
#> GSM22398     5  0.8556     0.1230 0.096 0.088 0.092 0.284 0.440
#> GSM22399     1  0.2959     0.8314 0.864 0.000 0.036 0.100 0.000
#> GSM22402     2  0.2976     0.8877 0.004 0.856 0.004 0.008 0.128
#> GSM22407     4  0.4949     0.5027 0.008 0.016 0.016 0.672 0.288
#> GSM22411     5  0.3452     0.5693 0.000 0.000 0.244 0.000 0.756
#> GSM22412     4  0.4162     0.5261 0.036 0.024 0.144 0.796 0.000
#> GSM22415     3  0.2763     0.8704 0.028 0.028 0.904 0.028 0.012
#> GSM22416     4  0.6995     0.0658 0.328 0.108 0.052 0.508 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
#> GSM22369     5  0.1556      0.924 0.000 0.000 0.000 0.080 0.920 0.000
#> GSM22374     6  0.2839      0.912 0.092 0.000 0.004 0.044 0.000 0.860
#> GSM22381     4  0.2941      0.649 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM22382     5  0.1556      0.924 0.000 0.000 0.000 0.080 0.920 0.000
#> GSM22384     4  0.5944      0.247 0.068 0.004 0.040 0.516 0.368 0.004
#> GSM22385     4  0.2879      0.803 0.100 0.012 0.000 0.864 0.012 0.012
#> GSM22387     1  0.2731      0.703 0.876 0.000 0.012 0.044 0.000 0.068
#> GSM22388     6  0.2839      0.912 0.092 0.000 0.004 0.044 0.000 0.860
#> GSM22390     3  0.1431      0.894 0.016 0.008 0.952 0.000 0.016 0.008
#> GSM22392     3  0.1406      0.895 0.020 0.008 0.952 0.000 0.004 0.016
#> GSM22393     1  0.2755      0.739 0.864 0.008 0.016 0.108 0.004 0.000
#> GSM22394     1  0.5810      0.255 0.516 0.004 0.036 0.388 0.044 0.012
#> GSM22397     3  0.5661      0.757 0.104 0.044 0.712 0.016 0.036 0.088
#> GSM22400     4  0.1555      0.819 0.060 0.004 0.000 0.932 0.000 0.004
#> GSM22401     5  0.1987      0.921 0.004 0.004 0.004 0.080 0.908 0.000
#> GSM22403     4  0.1701      0.812 0.072 0.008 0.000 0.920 0.000 0.000
#> GSM22404     5  0.1556      0.924 0.000 0.000 0.000 0.080 0.920 0.000
#> GSM22405     5  0.2220      0.855 0.012 0.060 0.016 0.000 0.908 0.004
#> GSM22406     3  0.4639      0.682 0.216 0.012 0.716 0.004 0.016 0.036
#> GSM22408     3  0.4353      0.824 0.048 0.044 0.808 0.016 0.024 0.060
#> GSM22409     4  0.2314      0.832 0.016 0.012 0.016 0.916 0.032 0.008
#> GSM22410     4  0.2740      0.826 0.016 0.016 0.008 0.888 0.064 0.008
#> GSM22413     4  0.0935      0.830 0.032 0.000 0.000 0.964 0.004 0.000
#> GSM22414     4  0.5566      0.366 0.008 0.324 0.000 0.560 0.100 0.008
#> GSM22417     3  0.1198      0.898 0.020 0.000 0.960 0.004 0.004 0.012
#> GSM22418     1  0.2739      0.711 0.868 0.004 0.104 0.016 0.004 0.004
#> GSM22419     1  0.2842      0.730 0.884 0.008 0.052 0.036 0.004 0.016
#> GSM22420     6  0.2839      0.912 0.092 0.000 0.004 0.044 0.000 0.860
#> GSM22421     2  0.2793      0.961 0.024 0.872 0.000 0.000 0.080 0.024
#> GSM22422     5  0.3395      0.853 0.004 0.068 0.000 0.096 0.828 0.004
#> GSM22423     4  0.1994      0.830 0.000 0.016 0.004 0.920 0.052 0.008
#> GSM22424     1  0.4463      0.605 0.732 0.020 0.016 0.208 0.004 0.020
#> GSM22365     2  0.1501      0.990 0.000 0.924 0.000 0.000 0.076 0.000
#> GSM22366     4  0.3260      0.794 0.004 0.020 0.004 0.836 0.124 0.012
#> GSM22367     5  0.1893      0.908 0.012 0.004 0.016 0.032 0.932 0.004
#> GSM22368     5  0.1994      0.916 0.016 0.000 0.004 0.052 0.920 0.008
#> GSM22370     4  0.2677      0.814 0.072 0.012 0.000 0.884 0.024 0.008
#> GSM22371     2  0.1843      0.986 0.004 0.912 0.000 0.000 0.080 0.004
#> GSM22372     4  0.2293      0.830 0.012 0.008 0.028 0.916 0.028 0.008
#> GSM22373     1  0.4898      0.349 0.592 0.008 0.360 0.004 0.008 0.028
#> GSM22375     3  0.0508      0.901 0.012 0.000 0.984 0.000 0.000 0.004
#> GSM22376     4  0.1349      0.820 0.056 0.004 0.000 0.940 0.000 0.000
#> GSM22377     6  0.6354      0.607 0.124 0.044 0.128 0.020 0.036 0.648
#> GSM22378     2  0.1501      0.990 0.000 0.924 0.000 0.000 0.076 0.000
#> GSM22379     2  0.1501      0.990 0.000 0.924 0.000 0.000 0.076 0.000
#> GSM22380     4  0.3147      0.774 0.000 0.016 0.000 0.816 0.160 0.008
#> GSM22383     1  0.2308      0.741 0.880 0.000 0.004 0.108 0.000 0.008
#> GSM22386     3  0.1121      0.892 0.008 0.016 0.964 0.000 0.008 0.004
#> GSM22389     3  0.0551      0.901 0.008 0.000 0.984 0.004 0.000 0.004
#> GSM22391     3  0.0779      0.898 0.008 0.000 0.976 0.008 0.008 0.000
#> GSM22395     3  0.0508      0.900 0.012 0.000 0.984 0.004 0.000 0.000
#> GSM22396     4  0.2315      0.831 0.012 0.008 0.028 0.916 0.024 0.012
#> GSM22398     1  0.6273      0.384 0.544 0.008 0.052 0.048 0.324 0.024
#> GSM22399     6  0.2839      0.912 0.092 0.000 0.004 0.044 0.000 0.860
#> GSM22402     2  0.1644      0.989 0.000 0.920 0.000 0.000 0.076 0.004
#> GSM22407     4  0.2890      0.824 0.036 0.004 0.008 0.876 0.068 0.008
#> GSM22411     5  0.2714      0.797 0.012 0.000 0.136 0.000 0.848 0.004
#> GSM22412     4  0.5315      0.584 0.200 0.008 0.072 0.684 0.012 0.024
#> GSM22415     3  0.5085      0.792 0.060 0.048 0.760 0.016 0.036 0.080
#> GSM22416     1  0.2355      0.738 0.876 0.000 0.004 0.112 0.000 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:kmeans 50            0.421 2
#> MAD:kmeans 33            0.275 3
#> MAD:kmeans 29            0.116 4
#> MAD:kmeans 47            0.378 5
#> MAD:kmeans 55            0.415 6

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 21446 rows and 60 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 0.621           0.811       0.922         0.5066 0.492   0.492
#> 3 3 0.503           0.719       0.843         0.3287 0.755   0.539
#> 4 4 0.493           0.485       0.713         0.1226 0.858   0.603
#> 5 5 0.520           0.464       0.689         0.0666 0.864   0.527
#> 6 6 0.576           0.422       0.668         0.0410 0.929   0.664

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
#> GSM22369     2  0.0000      0.924 0.000 1.000
#> GSM22374     1  0.0000      0.895 1.000 0.000
#> GSM22381     1  0.0000      0.895 1.000 0.000
#> GSM22382     2  0.0000      0.924 0.000 1.000
#> GSM22384     2  0.9248      0.466 0.340 0.660
#> GSM22385     1  0.0938      0.890 0.988 0.012
#> GSM22387     1  0.0000      0.895 1.000 0.000
#> GSM22388     1  0.0000      0.895 1.000 0.000
#> GSM22390     2  0.9209      0.472 0.336 0.664
#> GSM22392     1  0.0938      0.890 0.988 0.012
#> GSM22393     1  0.0000      0.895 1.000 0.000
#> GSM22394     2  0.9850      0.222 0.428 0.572
#> GSM22397     1  0.0000      0.895 1.000 0.000
#> GSM22400     1  0.5178      0.811 0.884 0.116
#> GSM22401     2  0.0000      0.924 0.000 1.000
#> GSM22403     1  0.2043      0.880 0.968 0.032
#> GSM22404     2  0.0000      0.924 0.000 1.000
#> GSM22405     2  0.0000      0.924 0.000 1.000
#> GSM22406     1  0.0000      0.895 1.000 0.000
#> GSM22408     1  0.6887      0.741 0.816 0.184
#> GSM22409     2  0.5842      0.804 0.140 0.860
#> GSM22410     1  0.9393      0.462 0.644 0.356
#> GSM22413     1  0.2778      0.869 0.952 0.048
#> GSM22414     2  0.0000      0.924 0.000 1.000
#> GSM22417     2  0.9209      0.443 0.336 0.664
#> GSM22418     1  0.0000      0.895 1.000 0.000
#> GSM22419     1  0.0000      0.895 1.000 0.000
#> GSM22420     1  0.0000      0.895 1.000 0.000
#> GSM22421     2  0.0000      0.924 0.000 1.000
#> GSM22422     2  0.0000      0.924 0.000 1.000
#> GSM22423     2  0.6438      0.769 0.164 0.836
#> GSM22424     1  0.0000      0.895 1.000 0.000
#> GSM22365     2  0.0000      0.924 0.000 1.000
#> GSM22366     2  0.2948      0.887 0.052 0.948
#> GSM22367     2  0.0000      0.924 0.000 1.000
#> GSM22368     2  0.0000      0.924 0.000 1.000
#> GSM22370     1  0.1414      0.886 0.980 0.020
#> GSM22371     2  0.0000      0.924 0.000 1.000
#> GSM22372     2  0.0376      0.922 0.004 0.996
#> GSM22373     1  0.0000      0.895 1.000 0.000
#> GSM22375     1  0.9286      0.495 0.656 0.344
#> GSM22376     1  0.9661      0.342 0.608 0.392
#> GSM22377     1  0.0000      0.895 1.000 0.000
#> GSM22378     2  0.0000      0.924 0.000 1.000
#> GSM22379     2  0.0000      0.924 0.000 1.000
#> GSM22380     2  0.1184      0.916 0.016 0.984
#> GSM22383     1  0.0000      0.895 1.000 0.000
#> GSM22386     2  0.0000      0.924 0.000 1.000
#> GSM22389     1  0.9850      0.292 0.572 0.428
#> GSM22391     2  0.0000      0.924 0.000 1.000
#> GSM22395     1  0.9988      0.125 0.520 0.480
#> GSM22396     2  0.1184      0.916 0.016 0.984
#> GSM22398     1  0.5178      0.819 0.884 0.116
#> GSM22399     1  0.0000      0.895 1.000 0.000
#> GSM22402     2  0.0000      0.924 0.000 1.000
#> GSM22407     2  0.1633      0.909 0.024 0.976
#> GSM22411     2  0.0376      0.922 0.004 0.996
#> GSM22412     1  0.0000      0.895 1.000 0.000
#> GSM22415     1  0.8713      0.590 0.708 0.292
#> GSM22416     1  0.0000      0.895 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.1878     0.8601 0.004 0.952 0.044
#> GSM22374     1  0.2959     0.8358 0.900 0.000 0.100
#> GSM22381     1  0.0424     0.8222 0.992 0.008 0.000
#> GSM22382     2  0.1878     0.8601 0.004 0.952 0.044
#> GSM22384     3  0.5764     0.7098 0.076 0.124 0.800
#> GSM22385     1  0.3637     0.7931 0.892 0.024 0.084
#> GSM22387     1  0.3116     0.8332 0.892 0.000 0.108
#> GSM22388     1  0.2959     0.8358 0.900 0.000 0.100
#> GSM22390     3  0.2584     0.7691 0.008 0.064 0.928
#> GSM22392     3  0.2878     0.7355 0.096 0.000 0.904
#> GSM22393     1  0.3482     0.8239 0.872 0.000 0.128
#> GSM22394     3  0.9741     0.3430 0.284 0.268 0.448
#> GSM22397     3  0.4399     0.6575 0.188 0.000 0.812
#> GSM22400     1  0.2749     0.7958 0.924 0.064 0.012
#> GSM22401     2  0.1647     0.8617 0.004 0.960 0.036
#> GSM22403     1  0.1950     0.8090 0.952 0.040 0.008
#> GSM22404     2  0.1878     0.8601 0.004 0.952 0.044
#> GSM22405     2  0.2625     0.8568 0.000 0.916 0.084
#> GSM22406     3  0.6302    -0.0964 0.480 0.000 0.520
#> GSM22408     3  0.1765     0.7674 0.040 0.004 0.956
#> GSM22409     2  0.7101     0.6598 0.216 0.704 0.080
#> GSM22410     3  0.9075     0.2515 0.388 0.140 0.472
#> GSM22413     1  0.2749     0.7959 0.924 0.064 0.012
#> GSM22414     2  0.2229     0.8616 0.012 0.944 0.044
#> GSM22417     3  0.2096     0.7648 0.004 0.052 0.944
#> GSM22418     1  0.6126     0.4347 0.600 0.000 0.400
#> GSM22419     1  0.5529     0.6486 0.704 0.000 0.296
#> GSM22420     1  0.2959     0.8358 0.900 0.000 0.100
#> GSM22421     2  0.2496     0.8596 0.004 0.928 0.068
#> GSM22422     2  0.0424     0.8621 0.000 0.992 0.008
#> GSM22423     2  0.9070     0.4120 0.292 0.536 0.172
#> GSM22424     1  0.2796     0.8372 0.908 0.000 0.092
#> GSM22365     2  0.2682     0.8559 0.004 0.920 0.076
#> GSM22366     2  0.4527     0.8157 0.088 0.860 0.052
#> GSM22367     2  0.2356     0.8555 0.000 0.928 0.072
#> GSM22368     2  0.1411     0.8612 0.000 0.964 0.036
#> GSM22370     1  0.2636     0.8021 0.932 0.048 0.020
#> GSM22371     2  0.2860     0.8531 0.004 0.912 0.084
#> GSM22372     2  0.7821     0.6190 0.116 0.660 0.224
#> GSM22373     3  0.5591     0.4669 0.304 0.000 0.696
#> GSM22375     3  0.1129     0.7706 0.020 0.004 0.976
#> GSM22376     1  0.4164     0.7188 0.848 0.144 0.008
#> GSM22377     1  0.6111     0.4192 0.604 0.000 0.396
#> GSM22378     2  0.2590     0.8575 0.004 0.924 0.072
#> GSM22379     2  0.2772     0.8548 0.004 0.916 0.080
#> GSM22380     2  0.6271     0.7536 0.088 0.772 0.140
#> GSM22383     1  0.2537     0.8366 0.920 0.000 0.080
#> GSM22386     3  0.4750     0.6201 0.000 0.216 0.784
#> GSM22389     3  0.1525     0.7681 0.032 0.004 0.964
#> GSM22391     3  0.3267     0.7188 0.000 0.116 0.884
#> GSM22395     3  0.0983     0.7707 0.016 0.004 0.980
#> GSM22396     2  0.8566     0.1804 0.096 0.480 0.424
#> GSM22398     1  0.7695     0.6307 0.676 0.124 0.200
#> GSM22399     1  0.2959     0.8358 0.900 0.000 0.100
#> GSM22402     2  0.2590     0.8581 0.004 0.924 0.072
#> GSM22407     2  0.3183     0.8361 0.076 0.908 0.016
#> GSM22411     3  0.6111     0.3366 0.000 0.396 0.604
#> GSM22412     1  0.4796     0.6905 0.780 0.000 0.220
#> GSM22415     3  0.2599     0.7666 0.052 0.016 0.932
#> GSM22416     1  0.1753     0.8357 0.952 0.000 0.048

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.0672    0.61997 0.000 0.008 0.008 0.984
#> GSM22374     1  0.2266    0.68027 0.912 0.004 0.084 0.000
#> GSM22381     1  0.4579    0.63095 0.756 0.224 0.016 0.004
#> GSM22382     4  0.0469    0.61878 0.000 0.000 0.012 0.988
#> GSM22384     4  0.7390    0.39239 0.044 0.092 0.276 0.588
#> GSM22385     1  0.8848    0.39808 0.472 0.252 0.084 0.192
#> GSM22387     1  0.2773    0.68215 0.900 0.028 0.072 0.000
#> GSM22388     1  0.2198    0.68426 0.920 0.008 0.072 0.000
#> GSM22390     3  0.5360    0.70546 0.032 0.060 0.776 0.132
#> GSM22392     3  0.2329    0.75505 0.072 0.012 0.916 0.000
#> GSM22393     1  0.4948    0.66108 0.776 0.100 0.124 0.000
#> GSM22394     2  0.9926   -0.00936 0.200 0.300 0.256 0.244
#> GSM22397     3  0.5282    0.52107 0.276 0.036 0.688 0.000
#> GSM22400     1  0.6464    0.32664 0.476 0.472 0.020 0.032
#> GSM22401     4  0.0707    0.61333 0.000 0.020 0.000 0.980
#> GSM22403     1  0.5689    0.54622 0.660 0.300 0.012 0.028
#> GSM22404     4  0.0672    0.61994 0.000 0.008 0.008 0.984
#> GSM22405     4  0.4136    0.43588 0.000 0.196 0.016 0.788
#> GSM22406     3  0.5548    0.38715 0.340 0.032 0.628 0.000
#> GSM22408     3  0.1610    0.76563 0.032 0.016 0.952 0.000
#> GSM22409     2  0.7408    0.06424 0.116 0.584 0.032 0.268
#> GSM22410     4  0.7993    0.43282 0.092 0.200 0.120 0.588
#> GSM22413     1  0.7481    0.47596 0.552 0.260 0.012 0.176
#> GSM22414     2  0.5270    0.51970 0.008 0.660 0.012 0.320
#> GSM22417     3  0.3411    0.74792 0.008 0.064 0.880 0.048
#> GSM22418     1  0.6207    0.10892 0.496 0.052 0.452 0.000
#> GSM22419     1  0.5649    0.47180 0.664 0.052 0.284 0.000
#> GSM22420     1  0.2266    0.68027 0.912 0.004 0.084 0.000
#> GSM22421     2  0.5428    0.49360 0.000 0.600 0.020 0.380
#> GSM22422     4  0.5055   -0.06498 0.000 0.368 0.008 0.624
#> GSM22423     4  0.8105    0.29741 0.120 0.336 0.052 0.492
#> GSM22424     1  0.3243    0.68342 0.876 0.036 0.088 0.000
#> GSM22365     2  0.5349    0.53821 0.000 0.640 0.024 0.336
#> GSM22366     4  0.6682    0.39921 0.052 0.304 0.032 0.612
#> GSM22367     4  0.2662    0.57088 0.000 0.084 0.016 0.900
#> GSM22368     4  0.2048    0.59129 0.000 0.064 0.008 0.928
#> GSM22370     1  0.7492    0.41895 0.552 0.180 0.012 0.256
#> GSM22371     2  0.5658    0.53497 0.000 0.632 0.040 0.328
#> GSM22372     2  0.7259    0.25996 0.040 0.628 0.124 0.208
#> GSM22373     3  0.5530    0.41012 0.336 0.032 0.632 0.000
#> GSM22375     3  0.1394    0.76949 0.016 0.012 0.964 0.008
#> GSM22376     2  0.6182   -0.30668 0.440 0.520 0.016 0.024
#> GSM22377     1  0.5110    0.33291 0.636 0.012 0.352 0.000
#> GSM22378     2  0.5203    0.53045 0.000 0.636 0.016 0.348
#> GSM22379     2  0.5478    0.53379 0.000 0.628 0.028 0.344
#> GSM22380     4  0.6808    0.42786 0.048 0.248 0.060 0.644
#> GSM22383     1  0.4444    0.67922 0.808 0.120 0.072 0.000
#> GSM22386     3  0.6121    0.30215 0.000 0.352 0.588 0.060
#> GSM22389     3  0.1978    0.76695 0.004 0.068 0.928 0.000
#> GSM22391     3  0.4985    0.64533 0.000 0.152 0.768 0.080
#> GSM22395     3  0.1256    0.76910 0.000 0.008 0.964 0.028
#> GSM22396     2  0.8311    0.16792 0.052 0.520 0.232 0.196
#> GSM22398     1  0.8413    0.29782 0.464 0.048 0.168 0.320
#> GSM22399     1  0.2266    0.68027 0.912 0.004 0.084 0.000
#> GSM22402     2  0.5386    0.53434 0.000 0.632 0.024 0.344
#> GSM22407     4  0.6361    0.01441 0.052 0.436 0.004 0.508
#> GSM22411     4  0.5069    0.41613 0.000 0.016 0.320 0.664
#> GSM22412     1  0.7264    0.49065 0.564 0.220 0.212 0.004
#> GSM22415     3  0.5574    0.69829 0.112 0.116 0.756 0.016
#> GSM22416     1  0.3606    0.68591 0.856 0.116 0.020 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.2439     0.6953 0.000 0.120 0.000 0.004 0.876
#> GSM22374     1  0.0693     0.6126 0.980 0.000 0.008 0.012 0.000
#> GSM22381     4  0.4886     0.0111 0.420 0.004 0.004 0.560 0.012
#> GSM22382     5  0.2179     0.6936 0.000 0.100 0.000 0.004 0.896
#> GSM22384     5  0.5427     0.4704 0.004 0.004 0.200 0.112 0.680
#> GSM22385     4  0.7256     0.1920 0.268 0.000 0.072 0.512 0.148
#> GSM22387     1  0.3994     0.6011 0.804 0.000 0.032 0.144 0.020
#> GSM22388     1  0.0898     0.6090 0.972 0.000 0.008 0.020 0.000
#> GSM22390     3  0.7065     0.5356 0.064 0.080 0.640 0.080 0.136
#> GSM22392     3  0.3289     0.6766 0.072 0.016 0.868 0.040 0.004
#> GSM22393     1  0.6404     0.4522 0.540 0.012 0.096 0.340 0.012
#> GSM22394     4  0.9628     0.1470 0.120 0.152 0.164 0.304 0.260
#> GSM22397     3  0.6806     0.2723 0.360 0.000 0.468 0.148 0.024
#> GSM22400     4  0.5573     0.4075 0.196 0.056 0.000 0.692 0.056
#> GSM22401     5  0.3844     0.6752 0.000 0.180 0.004 0.028 0.788
#> GSM22403     4  0.5719     0.1756 0.416 0.016 0.004 0.524 0.040
#> GSM22404     5  0.2464     0.6910 0.000 0.096 0.000 0.016 0.888
#> GSM22405     5  0.4211     0.4806 0.000 0.360 0.004 0.000 0.636
#> GSM22406     3  0.6673     0.1351 0.352 0.008 0.488 0.144 0.008
#> GSM22408     3  0.4017     0.6518 0.068 0.004 0.828 0.076 0.024
#> GSM22409     4  0.7342     0.3778 0.036 0.156 0.028 0.544 0.236
#> GSM22410     5  0.6302     0.3699 0.036 0.004 0.104 0.236 0.620
#> GSM22413     4  0.6615     0.2601 0.328 0.008 0.008 0.512 0.144
#> GSM22414     2  0.2597     0.8132 0.000 0.896 0.004 0.060 0.040
#> GSM22417     3  0.2705     0.6778 0.004 0.048 0.900 0.012 0.036
#> GSM22418     1  0.7321     0.2077 0.364 0.000 0.340 0.272 0.024
#> GSM22419     1  0.7065     0.4585 0.504 0.004 0.188 0.276 0.028
#> GSM22420     1  0.0451     0.6123 0.988 0.000 0.008 0.004 0.000
#> GSM22421     2  0.1597     0.8716 0.000 0.940 0.012 0.000 0.048
#> GSM22422     2  0.4367     0.2679 0.000 0.620 0.000 0.008 0.372
#> GSM22423     4  0.6969     0.1533 0.052 0.036 0.040 0.480 0.392
#> GSM22424     1  0.4866     0.5715 0.720 0.004 0.064 0.208 0.004
#> GSM22365     2  0.0162     0.8962 0.000 0.996 0.004 0.000 0.000
#> GSM22366     5  0.6261     0.2501 0.016 0.080 0.012 0.324 0.568
#> GSM22367     5  0.3196     0.6795 0.000 0.192 0.004 0.000 0.804
#> GSM22368     5  0.3569     0.6866 0.000 0.152 0.004 0.028 0.816
#> GSM22370     1  0.6852    -0.1720 0.412 0.000 0.004 0.324 0.260
#> GSM22371     2  0.0451     0.8948 0.000 0.988 0.008 0.004 0.000
#> GSM22372     4  0.8041     0.2963 0.012 0.296 0.108 0.440 0.144
#> GSM22373     3  0.7161     0.0395 0.356 0.000 0.428 0.184 0.032
#> GSM22375     3  0.1483     0.6845 0.008 0.000 0.952 0.028 0.012
#> GSM22376     4  0.6074     0.4297 0.156 0.164 0.000 0.648 0.032
#> GSM22377     1  0.4031     0.5378 0.788 0.000 0.160 0.048 0.004
#> GSM22378     2  0.0451     0.8937 0.000 0.988 0.000 0.008 0.004
#> GSM22379     2  0.0566     0.8958 0.000 0.984 0.012 0.000 0.004
#> GSM22380     5  0.7811     0.3250 0.040 0.172 0.048 0.228 0.512
#> GSM22383     1  0.6617     0.3969 0.436 0.000 0.100 0.432 0.032
#> GSM22386     3  0.5162     0.2005 0.000 0.440 0.528 0.016 0.016
#> GSM22389     3  0.2347     0.6875 0.012 0.040 0.920 0.016 0.012
#> GSM22391     3  0.4474     0.6290 0.004 0.108 0.796 0.028 0.064
#> GSM22395     3  0.1173     0.6841 0.012 0.000 0.964 0.004 0.020
#> GSM22396     4  0.8056     0.3567 0.008 0.192 0.180 0.476 0.144
#> GSM22398     5  0.8601    -0.0465 0.232 0.012 0.172 0.200 0.384
#> GSM22399     1  0.0693     0.6126 0.980 0.000 0.008 0.012 0.000
#> GSM22402     2  0.0579     0.8962 0.000 0.984 0.008 0.000 0.008
#> GSM22407     4  0.7581     0.0161 0.012 0.272 0.020 0.348 0.348
#> GSM22411     5  0.4847     0.6021 0.000 0.080 0.196 0.004 0.720
#> GSM22412     4  0.6722    -0.0962 0.312 0.000 0.112 0.532 0.044
#> GSM22415     3  0.7819     0.3978 0.288 0.104 0.488 0.096 0.024
#> GSM22416     1  0.6380     0.3466 0.468 0.012 0.044 0.440 0.036

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5  0.1312    0.65424 0.012 0.020 0.004 0.008 0.956 0.000
#> GSM22374     6  0.0146    0.67919 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM22381     4  0.6075    0.16758 0.188 0.008 0.004 0.488 0.000 0.312
#> GSM22382     5  0.0914    0.65395 0.016 0.016 0.000 0.000 0.968 0.000
#> GSM22384     5  0.6773    0.40923 0.160 0.000 0.172 0.096 0.556 0.016
#> GSM22385     1  0.7484   -0.04729 0.424 0.004 0.028 0.320 0.112 0.112
#> GSM22387     6  0.4700    0.35744 0.232 0.000 0.028 0.040 0.004 0.696
#> GSM22388     6  0.0725    0.67040 0.012 0.000 0.000 0.012 0.000 0.976
#> GSM22390     3  0.7255    0.35159 0.208 0.032 0.532 0.044 0.156 0.028
#> GSM22392     3  0.3314    0.56431 0.128 0.000 0.820 0.004 0.000 0.048
#> GSM22393     1  0.7253    0.21740 0.392 0.016 0.104 0.128 0.000 0.360
#> GSM22394     1  0.8607    0.23789 0.448 0.064 0.120 0.104 0.180 0.084
#> GSM22397     3  0.7790    0.06092 0.224 0.008 0.340 0.096 0.016 0.316
#> GSM22400     4  0.5278    0.40319 0.140 0.036 0.004 0.696 0.004 0.120
#> GSM22401     5  0.2910    0.63819 0.020 0.068 0.000 0.044 0.868 0.000
#> GSM22403     4  0.6448    0.25166 0.136 0.024 0.000 0.488 0.020 0.332
#> GSM22404     5  0.1364    0.65271 0.016 0.020 0.000 0.012 0.952 0.000
#> GSM22405     5  0.4686    0.44583 0.020 0.324 0.012 0.012 0.632 0.000
#> GSM22406     3  0.7168   -0.00874 0.196 0.000 0.404 0.088 0.004 0.308
#> GSM22408     3  0.4263    0.56687 0.064 0.000 0.792 0.076 0.008 0.060
#> GSM22409     4  0.5727    0.43452 0.076 0.092 0.012 0.692 0.116 0.012
#> GSM22410     5  0.7528    0.17271 0.240 0.000 0.076 0.212 0.436 0.036
#> GSM22413     4  0.6992    0.31676 0.168 0.012 0.000 0.508 0.096 0.216
#> GSM22414     2  0.3092    0.78448 0.024 0.864 0.000 0.072 0.032 0.008
#> GSM22417     3  0.2982    0.59864 0.064 0.028 0.872 0.008 0.028 0.000
#> GSM22418     1  0.6141    0.38332 0.532 0.000 0.240 0.028 0.000 0.200
#> GSM22419     1  0.6218    0.33670 0.532 0.008 0.124 0.036 0.000 0.300
#> GSM22420     6  0.0146    0.67919 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM22421     2  0.1644    0.86372 0.004 0.932 0.000 0.012 0.052 0.000
#> GSM22422     2  0.4922    0.19416 0.020 0.556 0.000 0.032 0.392 0.000
#> GSM22423     4  0.7387    0.04335 0.160 0.036 0.028 0.412 0.344 0.020
#> GSM22424     6  0.5712    0.17221 0.276 0.000 0.016 0.144 0.000 0.564
#> GSM22365     2  0.0260    0.88378 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM22366     5  0.6936    0.16266 0.068 0.092 0.008 0.348 0.464 0.020
#> GSM22367     5  0.3011    0.64597 0.016 0.112 0.008 0.012 0.852 0.000
#> GSM22368     5  0.4181    0.62465 0.072 0.100 0.004 0.036 0.788 0.000
#> GSM22370     6  0.7687   -0.18978 0.172 0.004 0.000 0.268 0.220 0.336
#> GSM22371     2  0.1242    0.87595 0.012 0.960 0.012 0.008 0.008 0.000
#> GSM22372     4  0.8015    0.28210 0.116 0.240 0.096 0.440 0.104 0.004
#> GSM22373     3  0.6441    0.14306 0.284 0.000 0.468 0.032 0.000 0.216
#> GSM22375     3  0.1707    0.60650 0.056 0.000 0.928 0.012 0.000 0.004
#> GSM22376     4  0.5858    0.41397 0.112 0.168 0.000 0.644 0.008 0.068
#> GSM22377     6  0.3742    0.51754 0.068 0.000 0.080 0.036 0.000 0.816
#> GSM22378     2  0.0508    0.87910 0.000 0.984 0.000 0.012 0.004 0.000
#> GSM22379     2  0.0405    0.88366 0.000 0.988 0.004 0.000 0.008 0.000
#> GSM22380     5  0.8275    0.17202 0.092 0.124 0.084 0.244 0.432 0.024
#> GSM22383     1  0.5762    0.36716 0.584 0.000 0.052 0.084 0.000 0.280
#> GSM22386     3  0.5302    0.21581 0.020 0.412 0.524 0.020 0.024 0.000
#> GSM22389     3  0.2208    0.60876 0.052 0.008 0.912 0.016 0.000 0.012
#> GSM22391     3  0.5687    0.52308 0.072 0.076 0.700 0.052 0.100 0.000
#> GSM22395     3  0.0748    0.60903 0.004 0.000 0.976 0.016 0.004 0.000
#> GSM22396     4  0.7726    0.31324 0.116 0.108 0.148 0.524 0.092 0.012
#> GSM22398     1  0.8676    0.17631 0.304 0.004 0.132 0.108 0.272 0.180
#> GSM22399     6  0.0146    0.67919 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM22402     2  0.0692    0.88220 0.000 0.976 0.000 0.004 0.020 0.000
#> GSM22407     5  0.7826   -0.09396 0.196 0.204 0.000 0.280 0.312 0.008
#> GSM22411     5  0.4360    0.57644 0.036 0.016 0.196 0.012 0.740 0.000
#> GSM22412     1  0.7019    0.13190 0.376 0.000 0.084 0.352 0.000 0.188
#> GSM22415     3  0.8430    0.20624 0.080 0.084 0.384 0.140 0.028 0.284
#> GSM22416     1  0.5832    0.29746 0.548 0.004 0.016 0.108 0.004 0.320

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n disease.state(p) k
#> MAD:skmeans 51            0.125 2
#> MAD:skmeans 51            0.511 3
#> MAD:skmeans 33            0.146 4
#> MAD:skmeans 29            0.443 5
#> MAD:skmeans 26            0.653 6

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 21446 rows and 60 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 4.
#> 
#> 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.110           0.422       0.726         0.3821 0.587   0.587
#> 3 3 0.229           0.457       0.706         0.5495 0.567   0.388
#> 4 4 0.467           0.667       0.803         0.2061 0.746   0.448
#> 5 5 0.592           0.574       0.761         0.0960 0.899   0.651
#> 6 6 0.841           0.794       0.909         0.0544 0.876   0.506

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

suggest_best_k(res)
#> [1] 4

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
#> GSM22369     2   0.584    0.63800 0.140 0.860
#> GSM22374     1   0.343    0.52261 0.936 0.064
#> GSM22381     1   0.978    0.31521 0.588 0.412
#> GSM22382     2   0.584    0.63800 0.140 0.860
#> GSM22384     2   0.722    0.61971 0.200 0.800
#> GSM22385     2   0.999   -0.22741 0.484 0.516
#> GSM22387     1   0.278    0.52390 0.952 0.048
#> GSM22388     1   0.224    0.49270 0.964 0.036
#> GSM22390     2   0.388    0.65028 0.076 0.924
#> GSM22392     2   0.980   -0.06196 0.416 0.584
#> GSM22393     2   0.998   -0.16907 0.476 0.524
#> GSM22394     2   0.987   -0.00653 0.432 0.568
#> GSM22397     1   0.999    0.21247 0.516 0.484
#> GSM22400     1   0.999    0.17994 0.516 0.484
#> GSM22401     2   0.605    0.63950 0.148 0.852
#> GSM22403     1   0.891    0.46820 0.692 0.308
#> GSM22404     2   0.574    0.64096 0.136 0.864
#> GSM22405     2   0.443    0.64473 0.092 0.908
#> GSM22406     2   0.998   -0.15613 0.476 0.524
#> GSM22408     2   0.714    0.62631 0.196 0.804
#> GSM22409     2   0.993   -0.07437 0.452 0.548
#> GSM22410     2   0.730    0.61512 0.204 0.796
#> GSM22413     2   1.000   -0.28355 0.496 0.504
#> GSM22414     2   0.781    0.57899 0.232 0.768
#> GSM22417     2   0.689    0.62955 0.184 0.816
#> GSM22418     2   0.985   -0.17513 0.428 0.572
#> GSM22419     1   1.000    0.19380 0.508 0.492
#> GSM22420     1   0.358    0.51926 0.932 0.068
#> GSM22421     2   0.482    0.64788 0.104 0.896
#> GSM22422     2   0.529    0.65675 0.120 0.880
#> GSM22423     2   0.775    0.61540 0.228 0.772
#> GSM22424     1   0.814    0.50313 0.748 0.252
#> GSM22365     2   0.978   -0.03978 0.412 0.588
#> GSM22366     2   0.689    0.63553 0.184 0.816
#> GSM22367     2   0.680    0.62871 0.180 0.820
#> GSM22368     2   0.644    0.64358 0.164 0.836
#> GSM22370     2   0.999   -0.23151 0.484 0.516
#> GSM22371     2   0.506    0.61370 0.112 0.888
#> GSM22372     2   0.402    0.63383 0.080 0.920
#> GSM22373     1   1.000    0.28734 0.512 0.488
#> GSM22375     2   0.529    0.65991 0.120 0.880
#> GSM22376     1   0.990    0.27059 0.560 0.440
#> GSM22377     1   0.781    0.50743 0.768 0.232
#> GSM22378     2   0.595    0.58392 0.144 0.856
#> GSM22379     2   0.402    0.63383 0.080 0.920
#> GSM22380     2   0.242    0.66212 0.040 0.960
#> GSM22383     1   1.000    0.19527 0.508 0.492
#> GSM22386     2   0.529    0.66522 0.120 0.880
#> GSM22389     2   0.456    0.65484 0.096 0.904
#> GSM22391     2   0.456    0.65484 0.096 0.904
#> GSM22395     2   0.584    0.65798 0.140 0.860
#> GSM22396     2   0.494    0.64370 0.108 0.892
#> GSM22398     2   0.981    0.06593 0.420 0.580
#> GSM22399     1   0.278    0.52390 0.952 0.048
#> GSM22402     2   0.541    0.59501 0.124 0.876
#> GSM22407     2   0.767    0.64204 0.224 0.776
#> GSM22411     2   0.373    0.66219 0.072 0.928
#> GSM22412     1   1.000    0.19527 0.508 0.492
#> GSM22415     2   0.781    0.63981 0.232 0.768
#> GSM22416     1   0.921    0.42142 0.664 0.336

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.0000     0.6000 0.000 1.000 0.000
#> GSM22374     1  0.0000     0.8315 1.000 0.000 0.000
#> GSM22381     2  0.8261     0.3357 0.080 0.524 0.396
#> GSM22382     2  0.0000     0.6000 0.000 1.000 0.000
#> GSM22384     2  0.5098     0.5056 0.000 0.752 0.248
#> GSM22385     2  0.6225     0.2597 0.000 0.568 0.432
#> GSM22387     1  0.0000     0.8315 1.000 0.000 0.000
#> GSM22388     1  0.0000     0.8315 1.000 0.000 0.000
#> GSM22390     3  0.5988     0.3524 0.000 0.368 0.632
#> GSM22392     3  0.2625     0.6133 0.000 0.084 0.916
#> GSM22393     3  0.3213     0.5856 0.092 0.008 0.900
#> GSM22394     2  0.5982     0.4684 0.004 0.668 0.328
#> GSM22397     3  0.7451     0.3097 0.060 0.304 0.636
#> GSM22400     3  0.6625     0.4161 0.080 0.176 0.744
#> GSM22401     2  0.0000     0.6000 0.000 1.000 0.000
#> GSM22403     2  0.9502     0.1599 0.376 0.436 0.188
#> GSM22404     2  0.0000     0.6000 0.000 1.000 0.000
#> GSM22405     2  0.4796     0.3799 0.000 0.780 0.220
#> GSM22406     3  0.0424     0.6221 0.008 0.000 0.992
#> GSM22408     3  0.5591     0.4352 0.000 0.304 0.696
#> GSM22409     2  0.8261     0.2409 0.080 0.524 0.396
#> GSM22410     2  0.5058     0.5142 0.000 0.756 0.244
#> GSM22413     2  0.5915     0.5684 0.080 0.792 0.128
#> GSM22414     2  0.5178     0.4503 0.000 0.744 0.256
#> GSM22417     3  0.3879     0.6212 0.000 0.152 0.848
#> GSM22418     3  0.1031     0.6266 0.000 0.024 0.976
#> GSM22419     3  0.8962     0.1705 0.156 0.304 0.540
#> GSM22420     1  0.0000     0.8315 1.000 0.000 0.000
#> GSM22421     2  0.6291    -0.1282 0.000 0.532 0.468
#> GSM22422     2  0.3340     0.5162 0.000 0.880 0.120
#> GSM22423     2  0.5588     0.4936 0.004 0.720 0.276
#> GSM22424     1  0.9946    -0.2584 0.368 0.284 0.348
#> GSM22365     3  0.4930     0.5706 0.044 0.120 0.836
#> GSM22366     2  0.5810     0.4492 0.000 0.664 0.336
#> GSM22367     2  0.2261     0.6051 0.000 0.932 0.068
#> GSM22368     2  0.1753     0.6058 0.000 0.952 0.048
#> GSM22370     2  0.4452     0.5760 0.000 0.808 0.192
#> GSM22371     3  0.4555     0.5596 0.000 0.200 0.800
#> GSM22372     3  0.4452     0.5636 0.000 0.192 0.808
#> GSM22373     3  0.7781     0.3406 0.116 0.220 0.664
#> GSM22375     3  0.3941     0.6282 0.000 0.156 0.844
#> GSM22376     2  0.8341     0.3019 0.080 0.468 0.452
#> GSM22377     1  0.6171     0.6145 0.776 0.080 0.144
#> GSM22378     3  0.6849     0.3409 0.020 0.380 0.600
#> GSM22379     3  0.5529     0.4462 0.000 0.296 0.704
#> GSM22380     2  0.6683    -0.1635 0.008 0.500 0.492
#> GSM22383     3  0.7851     0.2671 0.080 0.304 0.616
#> GSM22386     3  0.4504     0.6122 0.000 0.196 0.804
#> GSM22389     3  0.3116     0.6319 0.000 0.108 0.892
#> GSM22391     3  0.2878     0.6322 0.000 0.096 0.904
#> GSM22395     3  0.4002     0.6185 0.000 0.160 0.840
#> GSM22396     3  0.3267     0.6167 0.000 0.116 0.884
#> GSM22398     2  0.8310     0.1008 0.080 0.500 0.420
#> GSM22399     1  0.0000     0.8315 1.000 0.000 0.000
#> GSM22402     3  0.6309     0.0129 0.000 0.496 0.504
#> GSM22407     2  0.8191     0.3154 0.076 0.528 0.396
#> GSM22411     3  0.6168     0.3174 0.000 0.412 0.588
#> GSM22412     3  0.7851     0.2671 0.080 0.304 0.616
#> GSM22415     3  0.6169     0.3561 0.004 0.360 0.636
#> GSM22416     3  0.6357     0.4141 0.296 0.020 0.684

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     2  0.0188     0.7433 0.000 0.996 0.004 0.000
#> GSM22374     1  0.0000     0.9712 1.000 0.000 0.000 0.000
#> GSM22381     4  0.1722     0.7208 0.000 0.048 0.008 0.944
#> GSM22382     2  0.0000     0.7421 0.000 1.000 0.000 0.000
#> GSM22384     2  0.5464     0.6673 0.000 0.716 0.212 0.072
#> GSM22385     2  0.7429     0.4083 0.000 0.492 0.316 0.192
#> GSM22387     1  0.0000     0.9712 1.000 0.000 0.000 0.000
#> GSM22388     1  0.0000     0.9712 1.000 0.000 0.000 0.000
#> GSM22390     3  0.4642     0.6798 0.000 0.240 0.740 0.020
#> GSM22392     3  0.1940     0.7526 0.000 0.000 0.924 0.076
#> GSM22393     4  0.3306     0.7171 0.000 0.004 0.156 0.840
#> GSM22394     2  0.7058     0.5349 0.000 0.560 0.272 0.168
#> GSM22397     3  0.4426     0.6497 0.032 0.004 0.796 0.168
#> GSM22400     4  0.3172     0.7108 0.000 0.000 0.160 0.840
#> GSM22401     2  0.0188     0.7412 0.000 0.996 0.000 0.004
#> GSM22403     4  0.3543     0.6987 0.032 0.092 0.008 0.868
#> GSM22404     2  0.0188     0.7433 0.000 0.996 0.004 0.000
#> GSM22405     2  0.0376     0.7415 0.000 0.992 0.004 0.004
#> GSM22406     3  0.3610     0.6604 0.000 0.000 0.800 0.200
#> GSM22408     3  0.0779     0.7671 0.000 0.004 0.980 0.016
#> GSM22409     4  0.6310     0.6117 0.000 0.188 0.152 0.660
#> GSM22410     2  0.6378     0.6010 0.000 0.628 0.264 0.108
#> GSM22413     4  0.2988     0.6953 0.000 0.112 0.012 0.876
#> GSM22414     2  0.5174     0.6413 0.000 0.756 0.092 0.152
#> GSM22417     3  0.1792     0.7552 0.000 0.000 0.932 0.068
#> GSM22418     3  0.3400     0.6683 0.000 0.000 0.820 0.180
#> GSM22419     4  0.5615     0.4312 0.016 0.004 0.424 0.556
#> GSM22420     1  0.0000     0.9712 1.000 0.000 0.000 0.000
#> GSM22421     3  0.7448     0.3127 0.000 0.372 0.452 0.176
#> GSM22422     2  0.0188     0.7412 0.000 0.996 0.000 0.004
#> GSM22423     2  0.5594     0.6701 0.000 0.724 0.164 0.112
#> GSM22424     4  0.2334     0.6836 0.088 0.004 0.000 0.908
#> GSM22365     3  0.6055     0.3812 0.000 0.052 0.576 0.372
#> GSM22366     2  0.5041     0.6849 0.000 0.728 0.232 0.040
#> GSM22367     2  0.2266     0.7342 0.000 0.912 0.084 0.004
#> GSM22368     2  0.1398     0.7407 0.000 0.956 0.040 0.004
#> GSM22370     2  0.5724     0.6428 0.000 0.716 0.140 0.144
#> GSM22371     3  0.5540     0.6688 0.000 0.164 0.728 0.108
#> GSM22372     3  0.3790     0.7254 0.000 0.164 0.820 0.016
#> GSM22373     4  0.4991     0.6081 0.000 0.004 0.388 0.608
#> GSM22375     3  0.2751     0.7766 0.000 0.040 0.904 0.056
#> GSM22376     4  0.3398     0.7073 0.000 0.060 0.068 0.872
#> GSM22377     1  0.3341     0.8415 0.880 0.004 0.068 0.048
#> GSM22378     2  0.7412     0.2586 0.000 0.504 0.296 0.200
#> GSM22379     3  0.6308     0.5798 0.000 0.232 0.648 0.120
#> GSM22380     2  0.5403     0.4161 0.000 0.628 0.348 0.024
#> GSM22383     4  0.4655     0.6104 0.000 0.004 0.312 0.684
#> GSM22386     3  0.2797     0.7680 0.000 0.032 0.900 0.068
#> GSM22389     3  0.0707     0.7756 0.000 0.020 0.980 0.000
#> GSM22391     3  0.0000     0.7706 0.000 0.000 1.000 0.000
#> GSM22395     3  0.1867     0.7536 0.000 0.000 0.928 0.072
#> GSM22396     3  0.2255     0.7698 0.000 0.068 0.920 0.012
#> GSM22398     4  0.5700     0.4214 0.000 0.028 0.412 0.560
#> GSM22399     1  0.0000     0.9712 1.000 0.000 0.000 0.000
#> GSM22402     2  0.6837     0.0791 0.000 0.504 0.392 0.104
#> GSM22407     4  0.7568     0.2500 0.000 0.192 0.400 0.408
#> GSM22411     3  0.4252     0.6823 0.000 0.252 0.744 0.004
#> GSM22412     4  0.4855     0.5669 0.000 0.004 0.352 0.644
#> GSM22415     3  0.4033     0.7364 0.020 0.008 0.824 0.148
#> GSM22416     4  0.3428     0.7264 0.012 0.000 0.144 0.844

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.0000    0.70598 0.000 0.000 0.000 0.000 1.000
#> GSM22374     1  0.0000    0.95639 1.000 0.000 0.000 0.000 0.000
#> GSM22381     4  0.0854    0.68460 0.000 0.012 0.008 0.976 0.004
#> GSM22382     5  0.0000    0.70598 0.000 0.000 0.000 0.000 1.000
#> GSM22384     5  0.5142    0.55452 0.000 0.236 0.052 0.020 0.692
#> GSM22385     2  0.7522   -0.29150 0.000 0.408 0.128 0.088 0.376
#> GSM22387     1  0.0000    0.95639 1.000 0.000 0.000 0.000 0.000
#> GSM22388     1  0.0000    0.95639 1.000 0.000 0.000 0.000 0.000
#> GSM22390     3  0.2818    0.69323 0.000 0.000 0.856 0.012 0.132
#> GSM22392     3  0.0404    0.80063 0.000 0.000 0.988 0.012 0.000
#> GSM22393     4  0.1638    0.66474 0.000 0.004 0.064 0.932 0.000
#> GSM22394     2  0.6894    0.21559 0.000 0.552 0.136 0.056 0.256
#> GSM22397     2  0.5409    0.08169 0.004 0.588 0.348 0.060 0.000
#> GSM22400     4  0.2370    0.65000 0.000 0.040 0.056 0.904 0.000
#> GSM22401     5  0.0000    0.70598 0.000 0.000 0.000 0.000 1.000
#> GSM22403     4  0.1914    0.67357 0.008 0.008 0.000 0.928 0.056
#> GSM22404     5  0.0000    0.70598 0.000 0.000 0.000 0.000 1.000
#> GSM22405     5  0.0162    0.70429 0.000 0.004 0.000 0.000 0.996
#> GSM22406     3  0.2561    0.71554 0.000 0.000 0.856 0.144 0.000
#> GSM22408     3  0.4341    0.32405 0.000 0.364 0.628 0.008 0.000
#> GSM22409     4  0.6181    0.47461 0.000 0.116 0.084 0.668 0.132
#> GSM22410     5  0.7141    0.23377 0.000 0.408 0.116 0.060 0.416
#> GSM22413     4  0.1717    0.67882 0.000 0.052 0.008 0.936 0.004
#> GSM22414     5  0.6236    0.00557 0.000 0.336 0.012 0.116 0.536
#> GSM22417     3  0.0404    0.80063 0.000 0.000 0.988 0.012 0.000
#> GSM22418     3  0.2732    0.69759 0.000 0.000 0.840 0.160 0.000
#> GSM22419     4  0.6846    0.31895 0.008 0.384 0.212 0.396 0.000
#> GSM22420     1  0.0000    0.95639 1.000 0.000 0.000 0.000 0.000
#> GSM22421     2  0.6769    0.49926 0.000 0.576 0.224 0.052 0.148
#> GSM22422     5  0.0000    0.70598 0.000 0.000 0.000 0.000 1.000
#> GSM22423     5  0.6301    0.31421 0.000 0.444 0.036 0.064 0.456
#> GSM22424     4  0.2050    0.66994 0.064 0.008 0.008 0.920 0.000
#> GSM22365     2  0.5868    0.41835 0.000 0.592 0.284 0.120 0.004
#> GSM22366     5  0.5995    0.46507 0.000 0.332 0.036 0.056 0.576
#> GSM22367     5  0.2110    0.67956 0.000 0.072 0.016 0.000 0.912
#> GSM22368     5  0.0162    0.70579 0.000 0.004 0.000 0.000 0.996
#> GSM22370     5  0.5335    0.55385 0.000 0.240 0.028 0.052 0.680
#> GSM22371     2  0.5479    0.23238 0.000 0.508 0.436 0.052 0.004
#> GSM22372     3  0.3824    0.69465 0.000 0.128 0.820 0.028 0.024
#> GSM22373     4  0.6145    0.47319 0.000 0.312 0.156 0.532 0.000
#> GSM22375     3  0.0162    0.80074 0.000 0.000 0.996 0.004 0.000
#> GSM22376     4  0.1605    0.66635 0.000 0.004 0.012 0.944 0.040
#> GSM22377     1  0.3758    0.75784 0.824 0.112 0.008 0.056 0.000
#> GSM22378     2  0.6930    0.46817 0.000 0.580 0.108 0.100 0.212
#> GSM22379     2  0.6561    0.43571 0.000 0.556 0.304 0.052 0.088
#> GSM22380     5  0.6017    0.26462 0.000 0.088 0.288 0.024 0.600
#> GSM22383     4  0.6121    0.41213 0.000 0.408 0.128 0.464 0.000
#> GSM22386     3  0.0404    0.80063 0.000 0.000 0.988 0.012 0.000
#> GSM22389     3  0.0579    0.79675 0.000 0.008 0.984 0.008 0.000
#> GSM22391     3  0.0451    0.79889 0.000 0.004 0.988 0.008 0.000
#> GSM22395     3  0.0898    0.79435 0.000 0.008 0.972 0.020 0.000
#> GSM22396     3  0.3357    0.70192 0.000 0.136 0.836 0.016 0.012
#> GSM22398     4  0.6242    0.38878 0.000 0.408 0.144 0.448 0.000
#> GSM22399     1  0.0000    0.95639 1.000 0.000 0.000 0.000 0.000
#> GSM22402     2  0.7330    0.48424 0.000 0.500 0.200 0.060 0.240
#> GSM22407     2  0.5834    0.30772 0.000 0.700 0.112 0.088 0.100
#> GSM22411     3  0.2891    0.66437 0.000 0.000 0.824 0.000 0.176
#> GSM22412     4  0.6315    0.41369 0.000 0.372 0.160 0.468 0.000
#> GSM22415     3  0.6115    0.09814 0.032 0.416 0.496 0.056 0.000
#> GSM22416     4  0.1386    0.68543 0.000 0.016 0.032 0.952 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
#> GSM22369     5  0.0000     0.8372 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM22374     6  0.0000     0.9316 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22381     4  0.0000     0.9604 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM22382     5  0.0000     0.8372 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM22384     5  0.3965     0.2532 0.388 0.000 0.008 0.000 0.604 0.000
#> GSM22385     1  0.0458     0.7875 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM22387     6  0.0000     0.9316 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22388     6  0.0000     0.9316 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22390     3  0.1910     0.8487 0.000 0.000 0.892 0.000 0.108 0.000
#> GSM22392     3  0.0000     0.9390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22393     4  0.0000     0.9604 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM22394     1  0.6698     0.0849 0.412 0.176 0.056 0.000 0.356 0.000
#> GSM22397     1  0.0146     0.7868 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM22400     4  0.0363     0.9521 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM22401     5  0.0146     0.8361 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM22403     4  0.1074     0.9344 0.012 0.000 0.000 0.960 0.028 0.000
#> GSM22404     5  0.0000     0.8372 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM22405     5  0.0146     0.8358 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM22406     3  0.0363     0.9373 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM22408     1  0.3198     0.6061 0.740 0.000 0.260 0.000 0.000 0.000
#> GSM22409     4  0.5055     0.7171 0.076 0.028 0.088 0.744 0.064 0.000
#> GSM22410     1  0.0458     0.7875 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM22413     4  0.0000     0.9604 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM22414     5  0.3526     0.6472 0.016 0.172 0.000 0.020 0.792 0.000
#> GSM22417     3  0.0000     0.9390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22418     3  0.1007     0.9166 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM22419     1  0.2632     0.7335 0.832 0.000 0.000 0.164 0.000 0.004
#> GSM22420     6  0.0000     0.9316 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22421     2  0.0000     0.9767 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22422     5  0.0146     0.8357 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM22423     1  0.0363     0.7875 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM22424     4  0.0000     0.9604 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM22365     2  0.0000     0.9767 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22366     1  0.3747     0.2762 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM22367     5  0.0000     0.8372 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM22368     5  0.0146     0.8361 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM22370     5  0.3828     0.1397 0.440 0.000 0.000 0.000 0.560 0.000
#> GSM22371     3  0.4147     0.2215 0.012 0.436 0.552 0.000 0.000 0.000
#> GSM22372     3  0.0717     0.9347 0.016 0.008 0.976 0.000 0.000 0.000
#> GSM22373     1  0.3852     0.3986 0.612 0.000 0.004 0.384 0.000 0.000
#> GSM22375     3  0.0000     0.9390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22376     4  0.0000     0.9604 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM22377     6  0.3221     0.6015 0.264 0.000 0.000 0.000 0.000 0.736
#> GSM22378     2  0.0000     0.9767 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22379     2  0.0000     0.9767 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     5  0.5968     0.3461 0.144 0.004 0.312 0.016 0.524 0.000
#> GSM22383     1  0.0547     0.7876 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM22386     3  0.0146     0.9390 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM22389     3  0.0260     0.9383 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM22391     3  0.0260     0.9387 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM22395     3  0.0458     0.9342 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM22396     3  0.0692     0.9351 0.020 0.004 0.976 0.000 0.000 0.000
#> GSM22398     1  0.0458     0.7875 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM22399     6  0.0000     0.9316 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM22402     2  0.1888     0.9049 0.012 0.916 0.004 0.000 0.068 0.000
#> GSM22407     1  0.3834     0.6611 0.772 0.172 0.008 0.000 0.048 0.000
#> GSM22411     3  0.1204     0.9046 0.000 0.000 0.944 0.000 0.056 0.000
#> GSM22412     1  0.2597     0.7250 0.824 0.000 0.000 0.176 0.000 0.000
#> GSM22415     1  0.3212     0.6745 0.800 0.004 0.180 0.000 0.000 0.016
#> GSM22416     4  0.0146     0.9582 0.004 0.000 0.000 0.996 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> MAD:pam 38            0.558 2
#> MAD:pam 31            0.148 3
#> MAD:pam 51            0.233 4
#> MAD:pam 37            0.287 5
#> MAD:pam 53            0.155 6

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 21446 rows and 60 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.786           0.947       0.956         0.3553 0.636   0.636
#> 3 3 0.360           0.717       0.781         0.5843 0.705   0.541
#> 4 4 0.551           0.765       0.846         0.1825 0.898   0.749
#> 5 5 0.796           0.829       0.910         0.1626 0.856   0.601
#> 6 6 0.756           0.753       0.806         0.0465 0.962   0.832

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
#> GSM22369     2  0.4022      0.938 0.080 0.920
#> GSM22374     1  0.0376      0.970 0.996 0.004
#> GSM22381     1  0.0376      0.969 0.996 0.004
#> GSM22382     2  0.4298      0.941 0.088 0.912
#> GSM22384     1  0.2423      0.950 0.960 0.040
#> GSM22385     1  0.0376      0.969 0.996 0.004
#> GSM22387     1  0.0000      0.970 1.000 0.000
#> GSM22388     1  0.0376      0.970 0.996 0.004
#> GSM22390     1  0.0938      0.969 0.988 0.012
#> GSM22392     1  0.0938      0.969 0.988 0.012
#> GSM22393     1  0.0000      0.970 1.000 0.000
#> GSM22394     1  0.0376      0.969 0.996 0.004
#> GSM22397     1  0.0672      0.969 0.992 0.008
#> GSM22400     1  0.0376      0.969 0.996 0.004
#> GSM22401     2  0.4022      0.938 0.080 0.920
#> GSM22403     1  0.0376      0.969 0.996 0.004
#> GSM22404     2  0.4022      0.938 0.080 0.920
#> GSM22405     2  0.4562      0.954 0.096 0.904
#> GSM22406     1  0.0376      0.970 0.996 0.004
#> GSM22408     1  0.0938      0.969 0.988 0.012
#> GSM22409     1  0.4022      0.910 0.920 0.080
#> GSM22410     1  0.0938      0.968 0.988 0.012
#> GSM22413     1  0.0376      0.969 0.996 0.004
#> GSM22414     1  0.7056      0.781 0.808 0.192
#> GSM22417     1  0.1184      0.967 0.984 0.016
#> GSM22418     1  0.0376      0.970 0.996 0.004
#> GSM22419     1  0.0376      0.970 0.996 0.004
#> GSM22420     1  0.0376      0.970 0.996 0.004
#> GSM22421     2  0.4022      0.956 0.080 0.920
#> GSM22422     2  0.5178      0.948 0.116 0.884
#> GSM22423     1  0.0376      0.969 0.996 0.004
#> GSM22424     1  0.0376      0.970 0.996 0.004
#> GSM22365     2  0.4022      0.956 0.080 0.920
#> GSM22366     1  0.5408      0.860 0.876 0.124
#> GSM22367     2  0.6048      0.924 0.148 0.852
#> GSM22368     2  0.5408      0.930 0.124 0.876
#> GSM22370     1  0.5059      0.870 0.888 0.112
#> GSM22371     2  0.4161      0.956 0.084 0.916
#> GSM22372     1  0.0672      0.969 0.992 0.008
#> GSM22373     1  0.0376      0.970 0.996 0.004
#> GSM22375     1  0.0938      0.969 0.988 0.012
#> GSM22376     1  0.3879      0.911 0.924 0.076
#> GSM22377     1  0.0376      0.970 0.996 0.004
#> GSM22378     2  0.4022      0.956 0.080 0.920
#> GSM22379     2  0.4022      0.956 0.080 0.920
#> GSM22380     1  0.1633      0.961 0.976 0.024
#> GSM22383     1  0.0376      0.969 0.996 0.004
#> GSM22386     1  0.5519      0.857 0.872 0.128
#> GSM22389     1  0.0938      0.969 0.988 0.012
#> GSM22391     1  0.1184      0.967 0.984 0.016
#> GSM22395     1  0.1184      0.967 0.984 0.016
#> GSM22396     1  0.0376      0.969 0.996 0.004
#> GSM22398     1  0.0672      0.969 0.992 0.008
#> GSM22399     1  0.0376      0.970 0.996 0.004
#> GSM22402     2  0.4161      0.957 0.084 0.916
#> GSM22407     1  0.1414      0.964 0.980 0.020
#> GSM22411     1  0.8327      0.611 0.736 0.264
#> GSM22412     1  0.0376      0.970 0.996 0.004
#> GSM22415     1  0.0938      0.969 0.988 0.012
#> GSM22416     1  0.0376      0.969 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.6345      0.598 0.400 0.596 0.004
#> GSM22374     1  0.5778      0.651 0.768 0.032 0.200
#> GSM22381     1  0.0424      0.838 0.992 0.000 0.008
#> GSM22382     2  0.6345      0.598 0.400 0.596 0.004
#> GSM22384     1  0.4615      0.688 0.836 0.144 0.020
#> GSM22385     1  0.0000      0.838 1.000 0.000 0.000
#> GSM22387     1  0.4291      0.706 0.820 0.000 0.180
#> GSM22388     1  0.5574      0.682 0.784 0.032 0.184
#> GSM22390     3  0.5058      0.833 0.244 0.000 0.756
#> GSM22392     3  0.4702      0.837 0.212 0.000 0.788
#> GSM22393     1  0.5977      0.538 0.728 0.020 0.252
#> GSM22394     1  0.1765      0.831 0.956 0.004 0.040
#> GSM22397     3  0.5948      0.775 0.360 0.000 0.640
#> GSM22400     1  0.0424      0.838 0.992 0.000 0.008
#> GSM22401     2  0.6345      0.598 0.400 0.596 0.004
#> GSM22403     1  0.0475      0.838 0.992 0.004 0.004
#> GSM22404     2  0.6345      0.598 0.400 0.596 0.004
#> GSM22405     2  0.5778      0.653 0.200 0.768 0.032
#> GSM22406     3  0.7181      0.700 0.408 0.028 0.564
#> GSM22408     3  0.4750      0.838 0.216 0.000 0.784
#> GSM22409     1  0.0892      0.833 0.980 0.020 0.000
#> GSM22410     1  0.1129      0.834 0.976 0.020 0.004
#> GSM22413     1  0.0237      0.838 0.996 0.004 0.000
#> GSM22414     1  0.5860      0.601 0.748 0.228 0.024
#> GSM22417     3  0.5016      0.834 0.240 0.000 0.760
#> GSM22418     3  0.6168      0.717 0.412 0.000 0.588
#> GSM22419     3  0.6180      0.711 0.416 0.000 0.584
#> GSM22420     1  0.5826      0.645 0.764 0.032 0.204
#> GSM22421     2  0.4452      0.624 0.000 0.808 0.192
#> GSM22422     2  0.6062      0.608 0.384 0.616 0.000
#> GSM22423     1  0.0592      0.836 0.988 0.012 0.000
#> GSM22424     1  0.6522      0.460 0.696 0.032 0.272
#> GSM22365     2  0.4452      0.624 0.000 0.808 0.192
#> GSM22366     1  0.4504      0.598 0.804 0.196 0.000
#> GSM22367     2  0.6917      0.609 0.368 0.608 0.024
#> GSM22368     2  0.6386      0.579 0.412 0.584 0.004
#> GSM22370     1  0.0237      0.838 0.996 0.004 0.000
#> GSM22371     2  0.4784      0.624 0.004 0.796 0.200
#> GSM22372     1  0.2116      0.828 0.948 0.040 0.012
#> GSM22373     3  0.6168      0.717 0.412 0.000 0.588
#> GSM22375     3  0.4750      0.838 0.216 0.000 0.784
#> GSM22376     1  0.1711      0.837 0.960 0.032 0.008
#> GSM22377     3  0.7250      0.716 0.396 0.032 0.572
#> GSM22378     2  0.4861      0.629 0.008 0.800 0.192
#> GSM22379     2  0.4452      0.624 0.000 0.808 0.192
#> GSM22380     1  0.2878      0.773 0.904 0.096 0.000
#> GSM22383     1  0.2537      0.809 0.920 0.000 0.080
#> GSM22386     3  0.8042      0.464 0.136 0.216 0.648
#> GSM22389     3  0.4842      0.839 0.224 0.000 0.776
#> GSM22391     3  0.5291      0.818 0.268 0.000 0.732
#> GSM22395     3  0.4796      0.838 0.220 0.000 0.780
#> GSM22396     1  0.1170      0.839 0.976 0.008 0.016
#> GSM22398     1  0.3769      0.782 0.880 0.016 0.104
#> GSM22399     1  0.5521      0.686 0.788 0.032 0.180
#> GSM22402     2  0.5940      0.631 0.036 0.760 0.204
#> GSM22407     1  0.3116      0.756 0.892 0.108 0.000
#> GSM22411     2  0.9002      0.329 0.156 0.532 0.312
#> GSM22412     1  0.3816      0.737 0.852 0.000 0.148
#> GSM22415     3  0.6303      0.826 0.248 0.032 0.720
#> GSM22416     1  0.1964      0.823 0.944 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.3324      0.916 0.136 0.012 0.000 0.852
#> GSM22374     1  0.2973      0.714 0.856 0.000 0.000 0.144
#> GSM22381     1  0.1022      0.781 0.968 0.000 0.000 0.032
#> GSM22382     4  0.3324      0.916 0.136 0.012 0.000 0.852
#> GSM22384     1  0.5663      0.310 0.536 0.000 0.024 0.440
#> GSM22385     1  0.3306      0.767 0.840 0.000 0.004 0.156
#> GSM22387     1  0.1576      0.764 0.948 0.000 0.004 0.048
#> GSM22388     1  0.2973      0.714 0.856 0.000 0.000 0.144
#> GSM22390     3  0.0336      0.885 0.008 0.000 0.992 0.000
#> GSM22392     3  0.0000      0.886 0.000 0.000 1.000 0.000
#> GSM22393     1  0.2593      0.735 0.892 0.000 0.004 0.104
#> GSM22394     1  0.5383      0.736 0.744 0.000 0.128 0.128
#> GSM22397     3  0.3448      0.727 0.168 0.000 0.828 0.004
#> GSM22400     1  0.1489      0.782 0.952 0.000 0.004 0.044
#> GSM22401     4  0.3324      0.916 0.136 0.012 0.000 0.852
#> GSM22403     1  0.1576      0.782 0.948 0.000 0.004 0.048
#> GSM22404     4  0.3324      0.916 0.136 0.012 0.000 0.852
#> GSM22405     4  0.5154      0.753 0.040 0.104 0.060 0.796
#> GSM22406     1  0.5619      0.516 0.640 0.000 0.320 0.040
#> GSM22408     3  0.0000      0.886 0.000 0.000 1.000 0.000
#> GSM22409     1  0.4053      0.731 0.768 0.000 0.004 0.228
#> GSM22410     1  0.4372      0.695 0.728 0.000 0.004 0.268
#> GSM22413     1  0.3157      0.771 0.852 0.000 0.004 0.144
#> GSM22414     1  0.3831      0.776 0.836 0.012 0.012 0.140
#> GSM22417     3  0.0188      0.887 0.004 0.000 0.996 0.000
#> GSM22418     3  0.5524      0.556 0.276 0.000 0.676 0.048
#> GSM22419     1  0.5093      0.495 0.640 0.000 0.348 0.012
#> GSM22420     1  0.2973      0.714 0.856 0.000 0.000 0.144
#> GSM22421     2  0.0000      0.981 0.000 1.000 0.000 0.000
#> GSM22422     4  0.3324      0.916 0.136 0.012 0.000 0.852
#> GSM22423     1  0.4313      0.704 0.736 0.000 0.004 0.260
#> GSM22424     1  0.3271      0.718 0.856 0.000 0.012 0.132
#> GSM22365     2  0.0000      0.981 0.000 1.000 0.000 0.000
#> GSM22366     1  0.5112      0.375 0.560 0.000 0.004 0.436
#> GSM22367     4  0.3782      0.899 0.112 0.012 0.024 0.852
#> GSM22368     4  0.2973      0.905 0.144 0.000 0.000 0.856
#> GSM22370     1  0.3945      0.737 0.780 0.000 0.004 0.216
#> GSM22371     2  0.0895      0.966 0.020 0.976 0.004 0.000
#> GSM22372     1  0.3764      0.762 0.816 0.000 0.012 0.172
#> GSM22373     3  0.4817      0.234 0.388 0.000 0.612 0.000
#> GSM22375     3  0.0000      0.886 0.000 0.000 1.000 0.000
#> GSM22376     1  0.1661      0.781 0.944 0.000 0.004 0.052
#> GSM22377     1  0.5837      0.333 0.564 0.000 0.400 0.036
#> GSM22378     2  0.0000      0.981 0.000 1.000 0.000 0.000
#> GSM22379     2  0.0000      0.981 0.000 1.000 0.000 0.000
#> GSM22380     1  0.4560      0.664 0.700 0.000 0.004 0.296
#> GSM22383     1  0.2596      0.786 0.908 0.000 0.024 0.068
#> GSM22386     3  0.0779      0.879 0.016 0.004 0.980 0.000
#> GSM22389     3  0.0000      0.886 0.000 0.000 1.000 0.000
#> GSM22391     3  0.0895      0.874 0.020 0.000 0.976 0.004
#> GSM22395     3  0.0188      0.887 0.004 0.000 0.996 0.000
#> GSM22396     1  0.4123      0.773 0.820 0.000 0.044 0.136
#> GSM22398     1  0.5705      0.717 0.712 0.000 0.108 0.180
#> GSM22399     1  0.2973      0.714 0.856 0.000 0.000 0.144
#> GSM22402     2  0.1452      0.944 0.036 0.956 0.008 0.000
#> GSM22407     1  0.4372      0.697 0.728 0.000 0.004 0.268
#> GSM22411     4  0.5256      0.540 0.036 0.000 0.272 0.692
#> GSM22412     1  0.3958      0.738 0.816 0.000 0.160 0.024
#> GSM22415     3  0.0188      0.885 0.000 0.000 0.996 0.004
#> GSM22416     1  0.0707      0.772 0.980 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.0609     0.9309 0.000 0.000 0.000 0.020 0.980
#> GSM22374     1  0.0451     0.8413 0.988 0.000 0.000 0.004 0.008
#> GSM22381     4  0.2249     0.8163 0.096 0.000 0.000 0.896 0.008
#> GSM22382     5  0.0609     0.9309 0.000 0.000 0.000 0.020 0.980
#> GSM22384     4  0.2439     0.8810 0.000 0.000 0.004 0.876 0.120
#> GSM22385     4  0.0000     0.8814 0.000 0.000 0.000 1.000 0.000
#> GSM22387     1  0.1251     0.8340 0.956 0.000 0.008 0.036 0.000
#> GSM22388     1  0.0451     0.8413 0.988 0.000 0.000 0.004 0.008
#> GSM22390     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22392     3  0.0162     0.9140 0.000 0.000 0.996 0.000 0.004
#> GSM22393     1  0.1106     0.8444 0.964 0.000 0.024 0.012 0.000
#> GSM22394     4  0.3526     0.8529 0.000 0.000 0.072 0.832 0.096
#> GSM22397     3  0.3366     0.6600 0.212 0.000 0.784 0.000 0.004
#> GSM22400     4  0.0290     0.8795 0.000 0.000 0.000 0.992 0.008
#> GSM22401     5  0.0880     0.9308 0.000 0.000 0.000 0.032 0.968
#> GSM22403     4  0.0290     0.8795 0.000 0.000 0.000 0.992 0.008
#> GSM22404     5  0.0609     0.9309 0.000 0.000 0.000 0.020 0.980
#> GSM22405     5  0.3424     0.8476 0.000 0.096 0.028 0.024 0.852
#> GSM22406     1  0.3521     0.7115 0.764 0.000 0.232 0.000 0.004
#> GSM22408     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22409     4  0.2179     0.8850 0.000 0.000 0.000 0.888 0.112
#> GSM22410     4  0.1965     0.8898 0.000 0.000 0.000 0.904 0.096
#> GSM22413     4  0.0000     0.8814 0.000 0.000 0.000 1.000 0.000
#> GSM22414     4  0.2570     0.8848 0.000 0.000 0.028 0.888 0.084
#> GSM22417     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22418     1  0.2719     0.7886 0.852 0.000 0.144 0.000 0.004
#> GSM22419     1  0.3884     0.6359 0.708 0.000 0.288 0.000 0.004
#> GSM22420     1  0.0451     0.8413 0.988 0.000 0.000 0.004 0.008
#> GSM22421     2  0.0000     0.9807 0.000 1.000 0.000 0.000 0.000
#> GSM22422     5  0.1357     0.9233 0.000 0.000 0.004 0.048 0.948
#> GSM22423     4  0.1851     0.8911 0.000 0.000 0.000 0.912 0.088
#> GSM22424     1  0.0609     0.8445 0.980 0.000 0.020 0.000 0.000
#> GSM22365     2  0.0000     0.9807 0.000 1.000 0.000 0.000 0.000
#> GSM22366     4  0.2179     0.8850 0.000 0.000 0.000 0.888 0.112
#> GSM22367     5  0.1493     0.9228 0.000 0.000 0.024 0.028 0.948
#> GSM22368     5  0.1270     0.9214 0.000 0.000 0.000 0.052 0.948
#> GSM22370     4  0.0162     0.8824 0.000 0.000 0.000 0.996 0.004
#> GSM22371     2  0.0955     0.9615 0.000 0.968 0.028 0.004 0.000
#> GSM22372     4  0.1952     0.8919 0.000 0.000 0.004 0.912 0.084
#> GSM22373     3  0.4449    -0.1285 0.484 0.000 0.512 0.000 0.004
#> GSM22375     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22376     4  0.0290     0.8795 0.000 0.000 0.000 0.992 0.008
#> GSM22377     1  0.3814     0.6542 0.720 0.000 0.276 0.000 0.004
#> GSM22378     2  0.0000     0.9807 0.000 1.000 0.000 0.000 0.000
#> GSM22379     2  0.0000     0.9807 0.000 1.000 0.000 0.000 0.000
#> GSM22380     4  0.2329     0.8790 0.000 0.000 0.000 0.876 0.124
#> GSM22383     4  0.4650    -0.0847 0.468 0.000 0.012 0.520 0.000
#> GSM22386     3  0.1300     0.8896 0.000 0.028 0.956 0.000 0.016
#> GSM22389     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22391     3  0.0771     0.8961 0.000 0.000 0.976 0.004 0.020
#> GSM22395     3  0.0000     0.9153 0.000 0.000 1.000 0.000 0.000
#> GSM22396     4  0.2249     0.8902 0.000 0.000 0.008 0.896 0.096
#> GSM22398     4  0.2193     0.8480 0.008 0.000 0.092 0.900 0.000
#> GSM22399     1  0.0451     0.8413 0.988 0.000 0.000 0.004 0.008
#> GSM22402     2  0.1300     0.9522 0.000 0.956 0.028 0.016 0.000
#> GSM22407     4  0.2179     0.8850 0.000 0.000 0.000 0.888 0.112
#> GSM22411     5  0.3628     0.7101 0.000 0.000 0.216 0.012 0.772
#> GSM22412     4  0.5478     0.5614 0.180 0.000 0.164 0.656 0.000
#> GSM22415     3  0.0451     0.9100 0.008 0.000 0.988 0.000 0.004
#> GSM22416     1  0.4182     0.3787 0.600 0.000 0.000 0.400 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
#> GSM22369     5  0.0146      0.922 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22374     6  0.3684      0.784 0.372 0.000 0.000 0.000 0.000 0.628
#> GSM22381     4  0.3947      0.664 0.048 0.000 0.000 0.732 0.000 0.220
#> GSM22382     5  0.0260      0.922 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM22384     4  0.4907      0.733 0.000 0.000 0.012 0.668 0.092 0.228
#> GSM22385     4  0.1340      0.810 0.004 0.000 0.008 0.948 0.000 0.040
#> GSM22387     6  0.4721      0.605 0.472 0.000 0.012 0.024 0.000 0.492
#> GSM22388     6  0.3695      0.778 0.376 0.000 0.000 0.000 0.000 0.624
#> GSM22390     3  0.0260      0.919 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM22392     3  0.2340      0.856 0.148 0.000 0.852 0.000 0.000 0.000
#> GSM22393     1  0.4712     -0.138 0.648 0.000 0.016 0.044 0.000 0.292
#> GSM22394     4  0.5150      0.730 0.000 0.000 0.044 0.672 0.072 0.212
#> GSM22397     1  0.3684      0.477 0.692 0.000 0.300 0.004 0.000 0.004
#> GSM22400     4  0.2826      0.766 0.028 0.000 0.000 0.844 0.000 0.128
#> GSM22401     5  0.0146      0.922 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22403     4  0.2748      0.768 0.024 0.000 0.000 0.848 0.000 0.128
#> GSM22404     5  0.0146      0.922 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM22405     5  0.3309      0.812 0.016 0.116 0.012 0.008 0.840 0.008
#> GSM22406     1  0.1700      0.684 0.916 0.000 0.080 0.004 0.000 0.000
#> GSM22408     3  0.2260      0.865 0.140 0.000 0.860 0.000 0.000 0.000
#> GSM22409     4  0.3420      0.813 0.004 0.000 0.004 0.824 0.108 0.060
#> GSM22410     4  0.4736      0.744 0.004 0.000 0.008 0.692 0.080 0.216
#> GSM22413     4  0.1745      0.797 0.012 0.000 0.000 0.920 0.000 0.068
#> GSM22414     4  0.4000      0.809 0.008 0.008 0.024 0.812 0.092 0.056
#> GSM22417     3  0.0260      0.923 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM22418     1  0.1578      0.643 0.936 0.000 0.048 0.004 0.000 0.012
#> GSM22419     1  0.2070      0.686 0.892 0.000 0.100 0.008 0.000 0.000
#> GSM22420     6  0.3684      0.784 0.372 0.000 0.000 0.000 0.000 0.628
#> GSM22421     2  0.0146      0.989 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM22422     5  0.1254      0.916 0.004 0.004 0.012 0.016 0.960 0.004
#> GSM22423     4  0.2306      0.819 0.000 0.000 0.004 0.888 0.092 0.016
#> GSM22424     1  0.4152     -0.503 0.548 0.000 0.012 0.000 0.000 0.440
#> GSM22365     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22366     4  0.2288      0.816 0.000 0.000 0.004 0.876 0.116 0.004
#> GSM22367     5  0.1470      0.913 0.012 0.004 0.016 0.012 0.952 0.004
#> GSM22368     5  0.0603      0.919 0.000 0.000 0.004 0.016 0.980 0.000
#> GSM22370     4  0.1913      0.800 0.012 0.000 0.000 0.908 0.000 0.080
#> GSM22371     2  0.0653      0.984 0.004 0.980 0.012 0.000 0.004 0.000
#> GSM22372     4  0.2170      0.820 0.000 0.000 0.012 0.888 0.100 0.000
#> GSM22373     1  0.2697      0.639 0.812 0.000 0.188 0.000 0.000 0.000
#> GSM22375     3  0.0363      0.924 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM22376     4  0.2636      0.775 0.016 0.000 0.004 0.860 0.000 0.120
#> GSM22377     1  0.1806      0.688 0.908 0.000 0.088 0.004 0.000 0.000
#> GSM22378     2  0.0146      0.990 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM22379     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22380     4  0.3402      0.808 0.000 0.000 0.008 0.820 0.120 0.052
#> GSM22383     4  0.5398      0.217 0.360 0.000 0.016 0.544 0.000 0.080
#> GSM22386     3  0.1885      0.885 0.012 0.036 0.932 0.004 0.008 0.008
#> GSM22389     3  0.1141      0.915 0.052 0.000 0.948 0.000 0.000 0.000
#> GSM22391     3  0.0881      0.908 0.000 0.000 0.972 0.012 0.008 0.008
#> GSM22395     3  0.0363      0.924 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM22396     4  0.2326      0.820 0.000 0.000 0.012 0.888 0.092 0.008
#> GSM22398     4  0.4777      0.701 0.056 0.000 0.028 0.688 0.000 0.228
#> GSM22399     6  0.3684      0.784 0.372 0.000 0.000 0.000 0.000 0.628
#> GSM22402     2  0.0912      0.978 0.008 0.972 0.012 0.004 0.004 0.000
#> GSM22407     4  0.2196      0.817 0.000 0.000 0.004 0.884 0.108 0.004
#> GSM22411     5  0.5195      0.529 0.012 0.000 0.308 0.012 0.612 0.056
#> GSM22412     4  0.5100      0.350 0.384 0.000 0.040 0.552 0.000 0.024
#> GSM22415     3  0.2703      0.828 0.172 0.000 0.824 0.004 0.000 0.000
#> GSM22416     6  0.6224      0.278 0.304 0.000 0.004 0.312 0.000 0.380

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:mclust 60            1.000 2
#> MAD:mclust 57            0.904 3
#> MAD:mclust 55            0.209 4
#> MAD:mclust 57            0.105 5
#> MAD:mclust 54            0.280 6

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 21446 rows and 60 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.863           0.921       0.966         0.4985 0.501   0.501
#> 3 3 0.583           0.751       0.871         0.3471 0.720   0.493
#> 4 4 0.484           0.504       0.684         0.1072 0.850   0.595
#> 5 5 0.603           0.633       0.793         0.0714 0.823   0.446
#> 6 6 0.692           0.548       0.771         0.0480 0.905   0.581

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
#> GSM22369     2  0.0000      0.963 0.000 1.000
#> GSM22374     1  0.0000      0.963 1.000 0.000
#> GSM22381     1  0.0000      0.963 1.000 0.000
#> GSM22382     2  0.0000      0.963 0.000 1.000
#> GSM22384     1  0.0376      0.960 0.996 0.004
#> GSM22385     1  0.0000      0.963 1.000 0.000
#> GSM22387     1  0.0000      0.963 1.000 0.000
#> GSM22388     1  0.0000      0.963 1.000 0.000
#> GSM22390     2  0.8207      0.669 0.256 0.744
#> GSM22392     1  0.0000      0.963 1.000 0.000
#> GSM22393     1  0.0000      0.963 1.000 0.000
#> GSM22394     1  0.9129      0.514 0.672 0.328
#> GSM22397     1  0.0000      0.963 1.000 0.000
#> GSM22400     1  0.0000      0.963 1.000 0.000
#> GSM22401     2  0.0000      0.963 0.000 1.000
#> GSM22403     1  0.0000      0.963 1.000 0.000
#> GSM22404     2  0.0000      0.963 0.000 1.000
#> GSM22405     2  0.0000      0.963 0.000 1.000
#> GSM22406     1  0.0000      0.963 1.000 0.000
#> GSM22408     1  0.0000      0.963 1.000 0.000
#> GSM22409     2  0.6531      0.807 0.168 0.832
#> GSM22410     1  0.1414      0.949 0.980 0.020
#> GSM22413     1  0.0000      0.963 1.000 0.000
#> GSM22414     2  0.0000      0.963 0.000 1.000
#> GSM22417     2  0.7139      0.764 0.196 0.804
#> GSM22418     1  0.0000      0.963 1.000 0.000
#> GSM22419     1  0.0000      0.963 1.000 0.000
#> GSM22420     1  0.0000      0.963 1.000 0.000
#> GSM22421     2  0.0000      0.963 0.000 1.000
#> GSM22422     2  0.0000      0.963 0.000 1.000
#> GSM22423     1  0.9833      0.249 0.576 0.424
#> GSM22424     1  0.0000      0.963 1.000 0.000
#> GSM22365     2  0.0000      0.963 0.000 1.000
#> GSM22366     2  0.0000      0.963 0.000 1.000
#> GSM22367     2  0.0000      0.963 0.000 1.000
#> GSM22368     2  0.0000      0.963 0.000 1.000
#> GSM22370     1  0.0000      0.963 1.000 0.000
#> GSM22371     2  0.0000      0.963 0.000 1.000
#> GSM22372     2  0.1843      0.944 0.028 0.972
#> GSM22373     1  0.0000      0.963 1.000 0.000
#> GSM22375     1  0.0000      0.963 1.000 0.000
#> GSM22376     1  0.8608      0.601 0.716 0.284
#> GSM22377     1  0.0000      0.963 1.000 0.000
#> GSM22378     2  0.0000      0.963 0.000 1.000
#> GSM22379     2  0.0000      0.963 0.000 1.000
#> GSM22380     2  0.2603      0.932 0.044 0.956
#> GSM22383     1  0.0000      0.963 1.000 0.000
#> GSM22386     2  0.0000      0.963 0.000 1.000
#> GSM22389     1  0.2043      0.939 0.968 0.032
#> GSM22391     2  0.0000      0.963 0.000 1.000
#> GSM22395     1  0.2948      0.920 0.948 0.052
#> GSM22396     2  0.6887      0.786 0.184 0.816
#> GSM22398     1  0.0000      0.963 1.000 0.000
#> GSM22399     1  0.0000      0.963 1.000 0.000
#> GSM22402     2  0.0000      0.963 0.000 1.000
#> GSM22407     2  0.0376      0.961 0.004 0.996
#> GSM22411     2  0.0000      0.963 0.000 1.000
#> GSM22412     1  0.0000      0.963 1.000 0.000
#> GSM22415     1  0.1633      0.946 0.976 0.024
#> GSM22416     1  0.0000      0.963 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     2  0.1620     0.8825 0.012 0.964 0.024
#> GSM22374     1  0.1031     0.8352 0.976 0.000 0.024
#> GSM22381     1  0.0747     0.8327 0.984 0.016 0.000
#> GSM22382     2  0.5397     0.6419 0.000 0.720 0.280
#> GSM22384     3  0.4384     0.8284 0.068 0.064 0.868
#> GSM22385     1  0.1765     0.8270 0.956 0.040 0.004
#> GSM22387     1  0.1529     0.8290 0.960 0.000 0.040
#> GSM22388     1  0.0747     0.8364 0.984 0.000 0.016
#> GSM22390     3  0.1774     0.8415 0.024 0.016 0.960
#> GSM22392     3  0.2959     0.8374 0.100 0.000 0.900
#> GSM22393     1  0.1860     0.8214 0.948 0.000 0.052
#> GSM22394     3  0.6737     0.7590 0.156 0.100 0.744
#> GSM22397     3  0.4121     0.8012 0.168 0.000 0.832
#> GSM22400     1  0.2066     0.8157 0.940 0.060 0.000
#> GSM22401     2  0.1482     0.8825 0.012 0.968 0.020
#> GSM22403     1  0.2711     0.8018 0.912 0.088 0.000
#> GSM22404     2  0.2301     0.8752 0.004 0.936 0.060
#> GSM22405     2  0.4555     0.8049 0.000 0.800 0.200
#> GSM22406     3  0.6180     0.3843 0.416 0.000 0.584
#> GSM22408     3  0.3192     0.8325 0.112 0.000 0.888
#> GSM22409     2  0.5678     0.5190 0.316 0.684 0.000
#> GSM22410     3  0.6231     0.7756 0.148 0.080 0.772
#> GSM22413     1  0.2959     0.7907 0.900 0.100 0.000
#> GSM22414     2  0.1636     0.8810 0.020 0.964 0.016
#> GSM22417     3  0.1031     0.8322 0.000 0.024 0.976
#> GSM22418     3  0.6079     0.4668 0.388 0.000 0.612
#> GSM22419     1  0.6302    -0.1016 0.520 0.000 0.480
#> GSM22420     1  0.0892     0.8364 0.980 0.000 0.020
#> GSM22421     2  0.3482     0.8534 0.000 0.872 0.128
#> GSM22422     2  0.0424     0.8838 0.000 0.992 0.008
#> GSM22423     2  0.6302     0.0763 0.480 0.520 0.000
#> GSM22424     1  0.1031     0.8356 0.976 0.000 0.024
#> GSM22365     2  0.2711     0.8685 0.000 0.912 0.088
#> GSM22366     2  0.1267     0.8809 0.024 0.972 0.004
#> GSM22367     2  0.4399     0.7789 0.000 0.812 0.188
#> GSM22368     2  0.1711     0.8819 0.008 0.960 0.032
#> GSM22370     1  0.2537     0.8054 0.920 0.080 0.000
#> GSM22371     2  0.3038     0.8634 0.000 0.896 0.104
#> GSM22372     2  0.2187     0.8825 0.024 0.948 0.028
#> GSM22373     3  0.5216     0.7019 0.260 0.000 0.740
#> GSM22375     3  0.2066     0.8461 0.060 0.000 0.940
#> GSM22376     1  0.5621     0.5024 0.692 0.308 0.000
#> GSM22377     1  0.6299    -0.0911 0.524 0.000 0.476
#> GSM22378     2  0.2116     0.8808 0.012 0.948 0.040
#> GSM22379     2  0.2959     0.8645 0.000 0.900 0.100
#> GSM22380     2  0.2681     0.8760 0.040 0.932 0.028
#> GSM22383     1  0.4399     0.6762 0.812 0.000 0.188
#> GSM22386     3  0.3551     0.7363 0.000 0.132 0.868
#> GSM22389     3  0.1163     0.8450 0.028 0.000 0.972
#> GSM22391     3  0.1163     0.8275 0.000 0.028 0.972
#> GSM22395     3  0.0983     0.8429 0.016 0.004 0.980
#> GSM22396     2  0.5416     0.8246 0.100 0.820 0.080
#> GSM22398     3  0.6208     0.7704 0.164 0.068 0.768
#> GSM22399     1  0.0892     0.8364 0.980 0.000 0.020
#> GSM22402     2  0.2711     0.8685 0.000 0.912 0.088
#> GSM22407     2  0.2031     0.8787 0.032 0.952 0.016
#> GSM22411     3  0.2537     0.8193 0.000 0.080 0.920
#> GSM22412     1  0.5968     0.3183 0.636 0.000 0.364
#> GSM22415     3  0.1647     0.8463 0.036 0.004 0.960
#> GSM22416     1  0.0000     0.8353 1.000 0.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
#> GSM22369     4  0.6384    0.59340 0.068 0.400 0.000 0.532
#> GSM22374     1  0.5920    0.56865 0.612 0.000 0.052 0.336
#> GSM22381     1  0.2089    0.64081 0.940 0.028 0.012 0.020
#> GSM22382     4  0.6473    0.49381 0.004 0.268 0.100 0.628
#> GSM22384     3  0.5408    0.31855 0.016 0.000 0.576 0.408
#> GSM22385     1  0.4222    0.61124 0.832 0.004 0.084 0.080
#> GSM22387     1  0.6042    0.58382 0.672 0.000 0.104 0.224
#> GSM22388     1  0.5511    0.58082 0.636 0.000 0.032 0.332
#> GSM22390     3  0.2737    0.71916 0.000 0.008 0.888 0.104
#> GSM22392     3  0.1443    0.71464 0.028 0.008 0.960 0.004
#> GSM22393     1  0.5228    0.51006 0.700 0.004 0.268 0.028
#> GSM22394     3  0.7249    0.23518 0.156 0.000 0.496 0.348
#> GSM22397     3  0.3399    0.70019 0.040 0.000 0.868 0.092
#> GSM22400     1  0.3858    0.59003 0.844 0.116 0.004 0.036
#> GSM22401     4  0.6192    0.56645 0.052 0.436 0.000 0.512
#> GSM22403     1  0.2845    0.64306 0.896 0.028 0.000 0.076
#> GSM22404     4  0.6315    0.59710 0.064 0.396 0.000 0.540
#> GSM22405     4  0.6275    0.28455 0.000 0.460 0.056 0.484
#> GSM22406     3  0.5203    0.50835 0.232 0.000 0.720 0.048
#> GSM22408     3  0.2457    0.72768 0.004 0.008 0.912 0.076
#> GSM22409     1  0.7396    0.00157 0.516 0.216 0.000 0.268
#> GSM22410     4  0.6327   -0.10200 0.060 0.000 0.444 0.496
#> GSM22413     1  0.5292    0.47413 0.728 0.064 0.000 0.208
#> GSM22414     2  0.5171    0.51449 0.112 0.760 0.000 0.128
#> GSM22417     3  0.2542    0.72329 0.000 0.012 0.904 0.084
#> GSM22418     3  0.4327    0.56628 0.216 0.000 0.768 0.016
#> GSM22419     3  0.5420    0.31350 0.352 0.000 0.624 0.024
#> GSM22420     1  0.5848    0.57165 0.616 0.000 0.048 0.336
#> GSM22421     2  0.3342    0.60504 0.000 0.868 0.032 0.100
#> GSM22422     2  0.4988    0.09538 0.020 0.692 0.000 0.288
#> GSM22423     1  0.6545    0.28243 0.632 0.152 0.000 0.216
#> GSM22424     1  0.5508    0.60261 0.692 0.000 0.056 0.252
#> GSM22365     2  0.0188    0.73858 0.000 0.996 0.004 0.000
#> GSM22366     4  0.7328    0.48938 0.156 0.392 0.000 0.452
#> GSM22367     4  0.6316    0.46279 0.000 0.324 0.080 0.596
#> GSM22368     4  0.6660    0.59846 0.060 0.392 0.012 0.536
#> GSM22370     1  0.2704    0.64807 0.876 0.000 0.000 0.124
#> GSM22371     2  0.0657    0.73830 0.000 0.984 0.012 0.004
#> GSM22372     2  0.7196    0.26980 0.272 0.584 0.016 0.128
#> GSM22373     3  0.3015    0.67741 0.092 0.000 0.884 0.024
#> GSM22375     3  0.1716    0.73024 0.000 0.000 0.936 0.064
#> GSM22376     1  0.5384    0.48547 0.728 0.196 0.000 0.076
#> GSM22377     1  0.7662    0.35899 0.436 0.000 0.220 0.344
#> GSM22378     2  0.1520    0.72486 0.020 0.956 0.000 0.024
#> GSM22379     2  0.1722    0.69921 0.000 0.944 0.008 0.048
#> GSM22380     4  0.7407    0.54229 0.132 0.384 0.008 0.476
#> GSM22383     1  0.5022    0.50982 0.708 0.000 0.264 0.028
#> GSM22386     3  0.6714    0.32468 0.000 0.360 0.540 0.100
#> GSM22389     3  0.2124    0.73021 0.000 0.028 0.932 0.040
#> GSM22391     3  0.2845    0.71958 0.000 0.028 0.896 0.076
#> GSM22395     3  0.2654    0.72156 0.000 0.004 0.888 0.108
#> GSM22396     1  0.9028   -0.07264 0.388 0.352 0.172 0.088
#> GSM22398     3  0.6252    0.24981 0.056 0.000 0.512 0.432
#> GSM22399     1  0.5695    0.57613 0.624 0.000 0.040 0.336
#> GSM22402     2  0.0859    0.73830 0.008 0.980 0.004 0.008
#> GSM22407     4  0.8099    0.27931 0.348 0.228 0.012 0.412
#> GSM22411     3  0.6653    0.21810 0.000 0.084 0.480 0.436
#> GSM22412     1  0.5465    0.27779 0.588 0.000 0.392 0.020
#> GSM22415     3  0.8011    0.33643 0.044 0.116 0.468 0.372
#> GSM22416     1  0.3877    0.62067 0.840 0.004 0.124 0.032

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.3760    0.74267 0.000 0.028 0.000 0.188 0.784
#> GSM22374     1  0.0693    0.80052 0.980 0.000 0.008 0.012 0.000
#> GSM22381     4  0.3840    0.63383 0.208 0.008 0.012 0.772 0.000
#> GSM22382     5  0.1928    0.77688 0.000 0.004 0.004 0.072 0.920
#> GSM22384     5  0.3788    0.75026 0.004 0.000 0.104 0.072 0.820
#> GSM22385     4  0.4002    0.68603 0.144 0.000 0.028 0.804 0.024
#> GSM22387     1  0.4531    0.68344 0.760 0.000 0.144 0.092 0.004
#> GSM22388     1  0.0703    0.79789 0.976 0.000 0.000 0.024 0.000
#> GSM22390     3  0.3670    0.73314 0.000 0.004 0.796 0.020 0.180
#> GSM22392     3  0.0981    0.77687 0.000 0.008 0.972 0.012 0.008
#> GSM22393     3  0.5850    0.11305 0.060 0.008 0.480 0.448 0.004
#> GSM22394     3  0.6202    0.15202 0.016 0.000 0.472 0.424 0.088
#> GSM22397     3  0.5774    0.56352 0.208 0.004 0.652 0.008 0.128
#> GSM22400     4  0.3401    0.70531 0.116 0.032 0.004 0.844 0.004
#> GSM22401     5  0.4573    0.68204 0.000 0.044 0.000 0.256 0.700
#> GSM22403     4  0.4249    0.54336 0.296 0.016 0.000 0.688 0.000
#> GSM22404     5  0.4378    0.69654 0.000 0.036 0.000 0.248 0.716
#> GSM22405     5  0.2669    0.72637 0.000 0.104 0.020 0.000 0.876
#> GSM22406     3  0.3344    0.73781 0.112 0.000 0.848 0.028 0.012
#> GSM22408     3  0.4412    0.72254 0.060 0.004 0.784 0.012 0.140
#> GSM22409     4  0.4206    0.68458 0.052 0.032 0.004 0.816 0.096
#> GSM22410     5  0.4288    0.75070 0.008 0.000 0.072 0.136 0.784
#> GSM22413     4  0.3337    0.70918 0.064 0.008 0.000 0.856 0.072
#> GSM22414     2  0.4326    0.54352 0.000 0.708 0.000 0.264 0.028
#> GSM22417     3  0.2865    0.76470 0.004 0.008 0.856 0.000 0.132
#> GSM22418     3  0.3660    0.70828 0.016 0.000 0.800 0.176 0.008
#> GSM22419     3  0.5004    0.65923 0.084 0.004 0.736 0.164 0.012
#> GSM22420     1  0.0566    0.80069 0.984 0.000 0.004 0.012 0.000
#> GSM22421     2  0.1569    0.84144 0.000 0.944 0.008 0.004 0.044
#> GSM22422     2  0.3727    0.75172 0.004 0.824 0.000 0.104 0.068
#> GSM22423     4  0.4411    0.69256 0.120 0.020 0.000 0.788 0.072
#> GSM22424     1  0.4368    0.69677 0.772 0.000 0.080 0.144 0.004
#> GSM22365     2  0.0290    0.85499 0.000 0.992 0.000 0.008 0.000
#> GSM22366     5  0.5767    0.29490 0.032 0.032 0.000 0.432 0.504
#> GSM22367     5  0.1569    0.76200 0.000 0.044 0.008 0.004 0.944
#> GSM22368     5  0.4393    0.74103 0.000 0.052 0.004 0.192 0.752
#> GSM22370     1  0.4659   -0.11104 0.500 0.000 0.000 0.488 0.012
#> GSM22371     2  0.0671    0.85402 0.000 0.980 0.016 0.004 0.000
#> GSM22372     4  0.4645    0.52462 0.004 0.260 0.008 0.704 0.024
#> GSM22373     3  0.3067    0.75347 0.040 0.000 0.876 0.068 0.016
#> GSM22375     3  0.1768    0.78127 0.000 0.000 0.924 0.004 0.072
#> GSM22376     4  0.3758    0.70985 0.060 0.084 0.000 0.836 0.020
#> GSM22377     1  0.1408    0.78057 0.948 0.000 0.044 0.000 0.008
#> GSM22378     2  0.0898    0.85050 0.000 0.972 0.000 0.020 0.008
#> GSM22379     2  0.1117    0.84892 0.000 0.964 0.016 0.000 0.020
#> GSM22380     4  0.5144   -0.16120 0.008 0.024 0.000 0.520 0.448
#> GSM22383     4  0.6049    0.00302 0.092 0.000 0.412 0.488 0.008
#> GSM22386     2  0.5447    0.19714 0.000 0.536 0.400 0.000 0.064
#> GSM22389     3  0.1597    0.77944 0.000 0.024 0.948 0.008 0.020
#> GSM22391     3  0.2645    0.77899 0.000 0.012 0.884 0.008 0.096
#> GSM22395     3  0.3320    0.74782 0.012 0.008 0.828 0.000 0.152
#> GSM22396     4  0.4521    0.70597 0.028 0.072 0.060 0.812 0.028
#> GSM22398     5  0.5083    0.48126 0.000 0.000 0.280 0.068 0.652
#> GSM22399     1  0.0566    0.80069 0.984 0.000 0.004 0.012 0.000
#> GSM22402     2  0.0740    0.85587 0.000 0.980 0.008 0.008 0.004
#> GSM22407     4  0.3376    0.67593 0.012 0.032 0.004 0.856 0.096
#> GSM22411     5  0.2520    0.71956 0.000 0.012 0.096 0.004 0.888
#> GSM22412     4  0.5819    0.27233 0.048 0.000 0.336 0.584 0.032
#> GSM22415     1  0.6146    0.35216 0.584 0.004 0.292 0.012 0.108
#> GSM22416     4  0.5235    0.52523 0.108 0.004 0.168 0.712 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
#> GSM22369     5  0.2070     0.7617 0.000 0.000 0.012 0.092 0.896 0.000
#> GSM22374     6  0.0291     0.8742 0.004 0.000 0.004 0.000 0.000 0.992
#> GSM22381     4  0.3850     0.6708 0.108 0.000 0.004 0.800 0.012 0.076
#> GSM22382     5  0.1938     0.7713 0.004 0.000 0.040 0.036 0.920 0.000
#> GSM22384     3  0.6502    -0.1788 0.124 0.000 0.432 0.064 0.380 0.000
#> GSM22385     4  0.2384     0.7364 0.064 0.000 0.048 0.888 0.000 0.000
#> GSM22387     6  0.3669     0.7579 0.180 0.000 0.008 0.012 0.016 0.784
#> GSM22388     6  0.0405     0.8730 0.008 0.000 0.000 0.004 0.000 0.988
#> GSM22390     1  0.5695     0.2178 0.540 0.000 0.272 0.000 0.184 0.004
#> GSM22392     1  0.3819     0.2607 0.652 0.008 0.340 0.000 0.000 0.000
#> GSM22393     1  0.4880     0.4377 0.716 0.004 0.052 0.192 0.012 0.024
#> GSM22394     1  0.4612     0.4022 0.704 0.000 0.172 0.120 0.004 0.000
#> GSM22397     3  0.3239     0.4936 0.052 0.000 0.852 0.040 0.000 0.056
#> GSM22400     4  0.1121     0.7387 0.004 0.008 0.016 0.964 0.000 0.008
#> GSM22401     5  0.5095     0.2777 0.004 0.004 0.060 0.392 0.540 0.000
#> GSM22403     4  0.3999     0.5827 0.036 0.004 0.000 0.752 0.008 0.200
#> GSM22404     5  0.4211     0.5400 0.004 0.004 0.024 0.288 0.680 0.000
#> GSM22405     5  0.1716     0.7552 0.000 0.036 0.028 0.000 0.932 0.004
#> GSM22406     1  0.4702     0.0512 0.532 0.000 0.436 0.012 0.008 0.012
#> GSM22408     3  0.2313     0.4987 0.060 0.000 0.904 0.016 0.004 0.016
#> GSM22409     4  0.3778     0.6518 0.000 0.000 0.288 0.696 0.016 0.000
#> GSM22410     5  0.6794    -0.0241 0.040 0.000 0.276 0.328 0.356 0.000
#> GSM22413     4  0.2458     0.7166 0.084 0.004 0.000 0.888 0.016 0.008
#> GSM22414     2  0.3601     0.5080 0.000 0.684 0.000 0.312 0.004 0.000
#> GSM22417     3  0.4925    -0.0606 0.440 0.004 0.504 0.000 0.052 0.000
#> GSM22418     1  0.1753     0.4929 0.912 0.000 0.084 0.004 0.000 0.000
#> GSM22419     1  0.1820     0.4958 0.924 0.000 0.056 0.008 0.000 0.012
#> GSM22420     6  0.0291     0.8742 0.004 0.000 0.004 0.000 0.000 0.992
#> GSM22421     2  0.1851     0.8602 0.004 0.924 0.056 0.000 0.012 0.004
#> GSM22422     2  0.2495     0.8435 0.012 0.896 0.004 0.052 0.036 0.000
#> GSM22423     4  0.2320     0.7275 0.000 0.000 0.132 0.864 0.004 0.000
#> GSM22424     6  0.4877     0.7548 0.084 0.000 0.064 0.092 0.012 0.748
#> GSM22365     2  0.0146     0.8858 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM22366     4  0.5272     0.5073 0.000 0.008 0.148 0.628 0.216 0.000
#> GSM22367     5  0.0806     0.7699 0.000 0.008 0.020 0.000 0.972 0.000
#> GSM22368     5  0.1409     0.7701 0.012 0.000 0.008 0.032 0.948 0.000
#> GSM22370     6  0.4639     0.5601 0.032 0.000 0.004 0.288 0.016 0.660
#> GSM22371     2  0.0000     0.8854 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22372     4  0.5224     0.6193 0.060 0.016 0.304 0.612 0.008 0.000
#> GSM22373     1  0.3511     0.4138 0.760 0.000 0.216 0.000 0.000 0.024
#> GSM22375     1  0.4620     0.0821 0.532 0.000 0.428 0.000 0.040 0.000
#> GSM22376     4  0.1608     0.7320 0.016 0.036 0.000 0.940 0.004 0.004
#> GSM22377     6  0.1387     0.8378 0.000 0.000 0.068 0.000 0.000 0.932
#> GSM22378     2  0.0458     0.8854 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM22379     2  0.0146     0.8848 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM22380     4  0.4566     0.4442 0.000 0.000 0.068 0.652 0.280 0.000
#> GSM22383     1  0.2313     0.4795 0.884 0.000 0.000 0.100 0.004 0.012
#> GSM22386     2  0.4361     0.5101 0.040 0.696 0.252 0.000 0.012 0.000
#> GSM22389     1  0.4407    -0.0530 0.496 0.024 0.480 0.000 0.000 0.000
#> GSM22391     3  0.4577    -0.0968 0.472 0.012 0.500 0.000 0.016 0.000
#> GSM22395     3  0.3653     0.3659 0.228 0.004 0.748 0.000 0.020 0.000
#> GSM22396     4  0.4145     0.5894 0.004 0.004 0.356 0.628 0.008 0.000
#> GSM22398     5  0.3194     0.6720 0.132 0.000 0.032 0.000 0.828 0.008
#> GSM22399     6  0.0146     0.8729 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM22402     2  0.0363     0.8859 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM22407     4  0.4122     0.5074 0.292 0.008 0.000 0.680 0.020 0.000
#> GSM22411     5  0.1219     0.7613 0.000 0.000 0.048 0.000 0.948 0.004
#> GSM22412     1  0.5791     0.0113 0.456 0.000 0.156 0.384 0.004 0.000
#> GSM22415     3  0.2772     0.4625 0.000 0.000 0.864 0.040 0.004 0.092
#> GSM22416     1  0.4989     0.2462 0.620 0.000 0.008 0.316 0.016 0.040

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> MAD:NMF 59            0.256 2
#> MAD:NMF 54            0.264 3
#> MAD:NMF 38            0.317 4
#> MAD:NMF 50            0.643 5
#> MAD:NMF 37            0.613 6

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 21446 rows and 60 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 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 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.437           0.721       0.872         0.4051 0.548   0.548
#> 3 3 0.301           0.488       0.718         0.4718 0.734   0.543
#> 4 4 0.363           0.429       0.677         0.1173 0.847   0.621
#> 5 5 0.469           0.471       0.745         0.0845 0.947   0.831
#> 6 6 0.486           0.438       0.713         0.0512 0.985   0.946

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
#> GSM22369     1  0.0000      0.881 1.000 0.000
#> GSM22374     1  0.9129      0.411 0.672 0.328
#> GSM22381     1  0.5178      0.803 0.884 0.116
#> GSM22382     2  0.9795      0.484 0.416 0.584
#> GSM22384     1  0.0000      0.881 1.000 0.000
#> GSM22385     2  0.0000      0.723 0.000 1.000
#> GSM22387     1  0.1414      0.880 0.980 0.020
#> GSM22388     1  0.9754      0.162 0.592 0.408
#> GSM22390     1  0.3274      0.858 0.940 0.060
#> GSM22392     2  1.0000      0.222 0.500 0.500
#> GSM22393     1  0.6801      0.729 0.820 0.180
#> GSM22394     2  0.1414      0.730 0.020 0.980
#> GSM22397     2  0.0000      0.723 0.000 1.000
#> GSM22400     1  0.8763      0.500 0.704 0.296
#> GSM22401     2  0.9393      0.575 0.356 0.644
#> GSM22403     1  0.5519      0.793 0.872 0.128
#> GSM22404     1  0.0000      0.881 1.000 0.000
#> GSM22405     1  0.7139      0.693 0.804 0.196
#> GSM22406     1  0.9754      0.162 0.592 0.408
#> GSM22408     1  0.0000      0.881 1.000 0.000
#> GSM22409     1  0.7219      0.696 0.800 0.200
#> GSM22410     1  0.0000      0.881 1.000 0.000
#> GSM22413     1  0.0000      0.881 1.000 0.000
#> GSM22414     2  0.0000      0.723 0.000 1.000
#> GSM22417     1  0.0000      0.881 1.000 0.000
#> GSM22418     2  0.1633      0.730 0.024 0.976
#> GSM22419     2  0.1633      0.730 0.024 0.976
#> GSM22420     1  0.9129      0.411 0.672 0.328
#> GSM22421     2  0.9393      0.576 0.356 0.644
#> GSM22422     1  0.0376      0.881 0.996 0.004
#> GSM22423     2  0.9850      0.459 0.428 0.572
#> GSM22424     2  0.9833      0.469 0.424 0.576
#> GSM22365     2  0.8327      0.647 0.264 0.736
#> GSM22366     1  0.7950      0.630 0.760 0.240
#> GSM22367     1  0.0000      0.881 1.000 0.000
#> GSM22368     1  0.2236      0.872 0.964 0.036
#> GSM22370     1  0.1184      0.880 0.984 0.016
#> GSM22371     2  0.4022      0.728 0.080 0.920
#> GSM22372     1  0.1184      0.881 0.984 0.016
#> GSM22373     2  0.9944      0.354 0.456 0.544
#> GSM22375     1  0.1843      0.877 0.972 0.028
#> GSM22376     1  0.1184      0.881 0.984 0.016
#> GSM22377     1  0.1414      0.880 0.980 0.020
#> GSM22378     2  0.4022      0.728 0.080 0.920
#> GSM22379     1  0.0000      0.881 1.000 0.000
#> GSM22380     1  0.0000      0.881 1.000 0.000
#> GSM22383     1  0.1414      0.880 0.980 0.020
#> GSM22386     1  0.0000      0.881 1.000 0.000
#> GSM22389     1  0.8144      0.602 0.748 0.252
#> GSM22391     1  0.0000      0.881 1.000 0.000
#> GSM22395     1  0.0000      0.881 1.000 0.000
#> GSM22396     2  0.9608      0.531 0.384 0.616
#> GSM22398     1  0.1843      0.876 0.972 0.028
#> GSM22399     1  0.2423      0.870 0.960 0.040
#> GSM22402     2  0.9833      0.469 0.424 0.576
#> GSM22407     2  0.1184      0.729 0.016 0.984
#> GSM22411     1  0.0000      0.881 1.000 0.000
#> GSM22412     1  0.1184      0.881 0.984 0.016
#> GSM22415     1  0.0000      0.881 1.000 0.000
#> GSM22416     2  0.0000      0.723 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
#> GSM22369     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22374     1  0.9302     0.5317 0.524 0.240 0.236
#> GSM22381     1  0.5810     0.1637 0.664 0.000 0.336
#> GSM22382     2  0.8206    -0.0369 0.448 0.480 0.072
#> GSM22384     3  0.4555     0.6381 0.200 0.000 0.800
#> GSM22385     2  0.2625     0.7100 0.084 0.916 0.000
#> GSM22387     3  0.5968     0.5061 0.364 0.000 0.636
#> GSM22388     1  0.6044     0.4525 0.772 0.172 0.056
#> GSM22390     3  0.6888     0.3248 0.432 0.016 0.552
#> GSM22392     1  0.8403     0.2879 0.512 0.400 0.088
#> GSM22393     1  0.8104     0.3879 0.616 0.104 0.280
#> GSM22394     2  0.3192     0.6775 0.112 0.888 0.000
#> GSM22397     2  0.2066     0.7134 0.060 0.940 0.000
#> GSM22400     1  0.9429     0.5162 0.504 0.232 0.264
#> GSM22401     2  0.6919     0.1787 0.448 0.536 0.016
#> GSM22403     1  0.5465     0.2683 0.712 0.000 0.288
#> GSM22404     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22405     3  0.8925     0.0808 0.364 0.132 0.504
#> GSM22406     1  0.6044     0.4525 0.772 0.172 0.056
#> GSM22408     3  0.4750     0.6722 0.216 0.000 0.784
#> GSM22409     1  0.4235     0.4216 0.824 0.000 0.176
#> GSM22410     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22413     3  0.0592     0.6985 0.012 0.000 0.988
#> GSM22414     2  0.1964     0.7134 0.056 0.944 0.000
#> GSM22417     3  0.2625     0.7035 0.084 0.000 0.916
#> GSM22418     2  0.3340     0.6774 0.120 0.880 0.000
#> GSM22419     2  0.3340     0.6774 0.120 0.880 0.000
#> GSM22420     1  0.9302     0.5317 0.524 0.240 0.236
#> GSM22421     2  0.7152     0.1369 0.444 0.532 0.024
#> GSM22422     3  0.6095     0.5182 0.392 0.000 0.608
#> GSM22423     1  0.7178     0.0634 0.512 0.464 0.024
#> GSM22424     1  0.7181     0.0516 0.508 0.468 0.024
#> GSM22365     2  0.6062     0.4229 0.384 0.616 0.000
#> GSM22366     1  0.3116     0.4917 0.892 0.000 0.108
#> GSM22367     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22368     3  0.6529     0.5138 0.368 0.012 0.620
#> GSM22370     3  0.5431     0.6117 0.284 0.000 0.716
#> GSM22371     2  0.3267     0.6890 0.116 0.884 0.000
#> GSM22372     3  0.6225     0.4278 0.432 0.000 0.568
#> GSM22373     1  0.8070     0.1564 0.472 0.464 0.064
#> GSM22375     3  0.6398     0.4599 0.416 0.004 0.580
#> GSM22376     3  0.5859     0.5670 0.344 0.000 0.656
#> GSM22377     3  0.5968     0.5061 0.364 0.000 0.636
#> GSM22378     2  0.3267     0.6890 0.116 0.884 0.000
#> GSM22379     3  0.4702     0.6705 0.212 0.000 0.788
#> GSM22380     3  0.0892     0.7009 0.020 0.000 0.980
#> GSM22383     3  0.5968     0.5061 0.364 0.000 0.636
#> GSM22386     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22389     1  0.9323     0.4281 0.500 0.188 0.312
#> GSM22391     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22395     3  0.4346     0.6843 0.184 0.000 0.816
#> GSM22396     2  0.6505     0.0183 0.468 0.528 0.004
#> GSM22398     3  0.6018     0.5712 0.308 0.008 0.684
#> GSM22399     1  0.6079     0.0058 0.612 0.000 0.388
#> GSM22402     1  0.7181     0.0516 0.508 0.468 0.024
#> GSM22407     2  0.3267     0.7020 0.116 0.884 0.000
#> GSM22411     3  0.0000     0.6970 0.000 0.000 1.000
#> GSM22412     3  0.6225     0.4278 0.432 0.000 0.568
#> GSM22415     3  0.4235     0.6916 0.176 0.000 0.824
#> GSM22416     2  0.1753     0.6892 0.048 0.952 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22374     1  0.3400     0.3900 0.820 0.000 0.180 0.000
#> GSM22381     4  0.7715     0.3240 0.324 0.000 0.240 0.436
#> GSM22382     1  0.4716     0.4386 0.764 0.000 0.040 0.196
#> GSM22384     3  0.4501     0.5769 0.024 0.000 0.764 0.212
#> GSM22385     4  0.7745    -0.5588 0.236 0.352 0.000 0.412
#> GSM22387     3  0.4933     0.4345 0.432 0.000 0.568 0.000
#> GSM22388     4  0.7472     0.4144 0.396 0.176 0.000 0.428
#> GSM22390     1  0.4992    -0.2923 0.524 0.000 0.476 0.000
#> GSM22392     1  0.1975     0.4494 0.944 0.028 0.012 0.016
#> GSM22393     1  0.7697    -0.3346 0.468 0.008 0.176 0.348
#> GSM22394     2  0.2124     0.6686 0.008 0.924 0.000 0.068
#> GSM22397     2  0.6911     0.5756 0.108 0.480 0.000 0.412
#> GSM22400     1  0.6187     0.1432 0.672 0.000 0.184 0.144
#> GSM22401     1  0.5590     0.3469 0.692 0.064 0.000 0.244
#> GSM22403     4  0.7480     0.3426 0.376 0.000 0.180 0.444
#> GSM22404     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22405     1  0.5112    -0.0748 0.560 0.000 0.436 0.004
#> GSM22406     4  0.7472     0.4144 0.396 0.176 0.000 0.428
#> GSM22408     3  0.5462     0.6311 0.112 0.000 0.736 0.152
#> GSM22409     4  0.6384     0.4426 0.400 0.000 0.068 0.532
#> GSM22410     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22413     3  0.0469     0.6856 0.000 0.000 0.988 0.012
#> GSM22414     2  0.6871     0.5759 0.104 0.480 0.000 0.416
#> GSM22417     3  0.2281     0.6889 0.096 0.000 0.904 0.000
#> GSM22418     2  0.2142     0.6778 0.016 0.928 0.000 0.056
#> GSM22419     2  0.2142     0.6778 0.016 0.928 0.000 0.056
#> GSM22420     1  0.3400     0.3900 0.820 0.000 0.180 0.000
#> GSM22421     1  0.4268     0.4286 0.760 0.004 0.004 0.232
#> GSM22422     3  0.7408     0.3743 0.212 0.000 0.512 0.276
#> GSM22423     1  0.2654     0.4882 0.888 0.000 0.004 0.108
#> GSM22424     1  0.2714     0.4882 0.884 0.000 0.004 0.112
#> GSM22365     2  0.7852     0.1390 0.360 0.372 0.000 0.268
#> GSM22366     4  0.4941     0.4328 0.436 0.000 0.000 0.564
#> GSM22367     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22368     3  0.6499     0.4027 0.400 0.000 0.524 0.076
#> GSM22370     3  0.4713     0.5334 0.360 0.000 0.640 0.000
#> GSM22371     2  0.6198     0.6330 0.176 0.672 0.000 0.152
#> GSM22372     3  0.7613     0.2940 0.288 0.000 0.472 0.240
#> GSM22373     1  0.3236     0.4229 0.880 0.088 0.004 0.028
#> GSM22375     3  0.7354     0.3498 0.352 0.000 0.480 0.168
#> GSM22376     3  0.6619     0.4982 0.332 0.000 0.568 0.100
#> GSM22377     3  0.4925     0.4405 0.428 0.000 0.572 0.000
#> GSM22378     2  0.6198     0.6330 0.176 0.672 0.000 0.152
#> GSM22379     3  0.4964     0.6512 0.168 0.000 0.764 0.068
#> GSM22380     3  0.1174     0.6903 0.020 0.000 0.968 0.012
#> GSM22383     3  0.4925     0.4405 0.428 0.000 0.572 0.000
#> GSM22386     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22389     1  0.5631     0.2236 0.696 0.000 0.232 0.072
#> GSM22391     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22395     3  0.4040     0.6393 0.248 0.000 0.752 0.000
#> GSM22396     1  0.4282     0.4446 0.816 0.060 0.000 0.124
#> GSM22398     3  0.4964     0.4873 0.380 0.000 0.616 0.004
#> GSM22399     1  0.7867    -0.2154 0.392 0.000 0.316 0.292
#> GSM22402     1  0.2714     0.4882 0.884 0.000 0.004 0.112
#> GSM22407     1  0.6918    -0.1455 0.472 0.108 0.000 0.420
#> GSM22411     3  0.0000     0.6871 0.000 0.000 1.000 0.000
#> GSM22412     3  0.7613     0.2940 0.288 0.000 0.472 0.240
#> GSM22415     3  0.4956     0.6593 0.116 0.000 0.776 0.108
#> GSM22416     2  0.0921     0.6746 0.000 0.972 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.0404     0.6757 0.000 0.012 0.000 0.000 0.988
#> GSM22374     3  0.3242     0.5494 0.000 0.000 0.816 0.012 0.172
#> GSM22381     4  0.5644     0.5014 0.000 0.000 0.144 0.628 0.228
#> GSM22382     3  0.6034     0.3550 0.000 0.140 0.656 0.168 0.036
#> GSM22384     5  0.3676     0.5103 0.000 0.004 0.004 0.232 0.760
#> GSM22385     2  0.3067     0.6384 0.012 0.844 0.140 0.004 0.000
#> GSM22387     5  0.4604     0.4175 0.000 0.000 0.428 0.012 0.560
#> GSM22388     4  0.4086     0.3387 0.240 0.000 0.024 0.736 0.000
#> GSM22390     3  0.4650    -0.2839 0.000 0.000 0.520 0.012 0.468
#> GSM22392     3  0.1757     0.5937 0.000 0.048 0.936 0.012 0.004
#> GSM22393     4  0.6624     0.4291 0.016 0.000 0.304 0.516 0.164
#> GSM22394     1  0.0162     0.7257 0.996 0.004 0.000 0.000 0.000
#> GSM22397     2  0.1653     0.6779 0.028 0.944 0.024 0.004 0.000
#> GSM22400     3  0.6220    -0.0193 0.000 0.000 0.524 0.308 0.168
#> GSM22401     3  0.7189     0.1765 0.092 0.184 0.556 0.168 0.000
#> GSM22403     4  0.5271     0.5655 0.000 0.000 0.152 0.680 0.168
#> GSM22404     5  0.0404     0.6757 0.000 0.012 0.000 0.000 0.988
#> GSM22405     3  0.4390    -0.0613 0.000 0.000 0.568 0.004 0.428
#> GSM22406     4  0.4086     0.3387 0.240 0.000 0.024 0.736 0.000
#> GSM22408     5  0.4698     0.5988 0.000 0.000 0.096 0.172 0.732
#> GSM22409     4  0.1774     0.5546 0.000 0.000 0.016 0.932 0.052
#> GSM22410     5  0.0404     0.6757 0.000 0.012 0.000 0.000 0.988
#> GSM22413     5  0.0912     0.6731 0.000 0.012 0.000 0.016 0.972
#> GSM22414     2  0.1493     0.6774 0.028 0.948 0.024 0.000 0.000
#> GSM22417     5  0.2068     0.6791 0.000 0.000 0.092 0.004 0.904
#> GSM22418     1  0.1251     0.7389 0.956 0.036 0.008 0.000 0.000
#> GSM22419     1  0.1251     0.7389 0.956 0.036 0.008 0.000 0.000
#> GSM22420     3  0.3242     0.5494 0.000 0.000 0.816 0.012 0.172
#> GSM22421     3  0.5478     0.3165 0.000 0.180 0.656 0.164 0.000
#> GSM22422     5  0.4562     0.0525 0.000 0.000 0.008 0.496 0.496
#> GSM22423     3  0.2674     0.5779 0.000 0.120 0.868 0.012 0.000
#> GSM22424     3  0.2612     0.5770 0.000 0.124 0.868 0.008 0.000
#> GSM22365     1  0.8085     0.0263 0.408 0.128 0.268 0.196 0.000
#> GSM22366     4  0.1502     0.5448 0.004 0.000 0.056 0.940 0.000
#> GSM22367     5  0.0404     0.6757 0.000 0.012 0.000 0.000 0.988
#> GSM22368     5  0.5611     0.4002 0.000 0.000 0.408 0.076 0.516
#> GSM22370     5  0.4327     0.5145 0.000 0.000 0.360 0.008 0.632
#> GSM22371     2  0.5830     0.5056 0.228 0.656 0.040 0.076 0.000
#> GSM22372     5  0.6215     0.0678 0.000 0.000 0.140 0.412 0.448
#> GSM22373     3  0.2818     0.5460 0.000 0.132 0.856 0.012 0.000
#> GSM22375     5  0.6576     0.3685 0.000 0.004 0.340 0.188 0.468
#> GSM22376     5  0.6147     0.4205 0.000 0.000 0.188 0.256 0.556
#> GSM22377     5  0.4597     0.4237 0.000 0.000 0.424 0.012 0.564
#> GSM22378     2  0.5830     0.5056 0.228 0.656 0.040 0.076 0.000
#> GSM22379     5  0.4521     0.6341 0.000 0.000 0.164 0.088 0.748
#> GSM22380     5  0.1612     0.6799 0.000 0.012 0.024 0.016 0.948
#> GSM22383     5  0.4597     0.4237 0.000 0.000 0.424 0.012 0.564
#> GSM22386     5  0.0290     0.6782 0.000 0.000 0.000 0.008 0.992
#> GSM22389     3  0.4930     0.3914 0.000 0.000 0.696 0.084 0.220
#> GSM22391     5  0.0290     0.6782 0.000 0.000 0.000 0.008 0.992
#> GSM22395     5  0.3756     0.6285 0.000 0.000 0.248 0.008 0.744
#> GSM22396     3  0.3455     0.5024 0.000 0.208 0.784 0.008 0.000
#> GSM22398     5  0.4299     0.4695 0.000 0.000 0.388 0.004 0.608
#> GSM22399     4  0.6465     0.1362 0.000 0.000 0.208 0.484 0.308
#> GSM22402     3  0.2612     0.5770 0.000 0.124 0.868 0.008 0.000
#> GSM22407     2  0.4161     0.3299 0.000 0.608 0.392 0.000 0.000
#> GSM22411     5  0.0510     0.6736 0.000 0.016 0.000 0.000 0.984
#> GSM22412     5  0.6215     0.0678 0.000 0.000 0.140 0.412 0.448
#> GSM22415     5  0.4357     0.6323 0.000 0.000 0.104 0.128 0.768
#> GSM22416     1  0.3003     0.5605 0.812 0.188 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
#> GSM22369     3  0.0790     0.6318 0.000 0.000 0.968 0.000 0.032 0.000
#> GSM22374     6  0.3300     0.5561 0.000 0.016 0.156 0.000 0.016 0.812
#> GSM22381     4  0.6340     0.4977 0.000 0.000 0.156 0.580 0.108 0.156
#> GSM22382     5  0.3680     0.8279 0.000 0.008 0.020 0.000 0.756 0.216
#> GSM22384     3  0.5319     0.4376 0.000 0.000 0.660 0.168 0.144 0.028
#> GSM22385     2  0.3088     0.5960 0.000 0.832 0.000 0.000 0.048 0.120
#> GSM22387     3  0.3995     0.2982 0.000 0.000 0.516 0.000 0.004 0.480
#> GSM22388     4  0.3483     0.2823 0.236 0.000 0.000 0.748 0.016 0.000
#> GSM22390     6  0.3937    -0.1783 0.000 0.000 0.424 0.000 0.004 0.572
#> GSM22392     6  0.2034     0.5295 0.004 0.060 0.000 0.000 0.024 0.912
#> GSM22393     4  0.7022     0.3748 0.016 0.000 0.092 0.456 0.116 0.320
#> GSM22394     1  0.0146     0.7343 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM22397     2  0.0146     0.7012 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM22400     6  0.6323     0.0102 0.000 0.000 0.112 0.268 0.080 0.540
#> GSM22401     5  0.5040     0.8198 0.092 0.044 0.000 0.000 0.700 0.164
#> GSM22403     4  0.5777     0.5470 0.000 0.000 0.096 0.644 0.108 0.152
#> GSM22404     3  0.0790     0.6318 0.000 0.000 0.968 0.000 0.032 0.000
#> GSM22405     6  0.4519     0.0195 0.000 0.000 0.384 0.024 0.008 0.584
#> GSM22406     4  0.3483     0.2823 0.236 0.000 0.000 0.748 0.016 0.000
#> GSM22408     3  0.5537     0.5472 0.000 0.000 0.656 0.168 0.056 0.120
#> GSM22409     4  0.3157     0.4417 0.000 0.004 0.016 0.832 0.136 0.012
#> GSM22410     3  0.0790     0.6318 0.000 0.000 0.968 0.000 0.032 0.000
#> GSM22413     3  0.1732     0.6230 0.000 0.000 0.920 0.004 0.072 0.004
#> GSM22414     2  0.0291     0.7007 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM22417     3  0.2936     0.6291 0.000 0.000 0.852 0.016 0.020 0.112
#> GSM22418     1  0.1003     0.7472 0.964 0.028 0.000 0.000 0.004 0.004
#> GSM22419     1  0.1003     0.7472 0.964 0.028 0.000 0.000 0.004 0.004
#> GSM22420     6  0.3300     0.5561 0.000 0.016 0.156 0.000 0.016 0.812
#> GSM22421     6  0.5607    -0.4621 0.000 0.124 0.000 0.004 0.428 0.444
#> GSM22422     3  0.6686    -0.0285 0.000 0.004 0.380 0.320 0.272 0.024
#> GSM22423     6  0.4208     0.4899 0.000 0.140 0.000 0.028 0.064 0.768
#> GSM22424     6  0.3595     0.5150 0.000 0.144 0.000 0.028 0.024 0.804
#> GSM22365     1  0.8056     0.1056 0.408 0.140 0.000 0.164 0.060 0.228
#> GSM22366     4  0.0603     0.4692 0.000 0.004 0.000 0.980 0.016 0.000
#> GSM22367     3  0.0790     0.6318 0.000 0.000 0.968 0.000 0.032 0.000
#> GSM22368     3  0.5565     0.3094 0.000 0.000 0.468 0.096 0.012 0.424
#> GSM22370     3  0.4209     0.4286 0.000 0.000 0.588 0.012 0.004 0.396
#> GSM22371     2  0.4782     0.5371 0.200 0.700 0.000 0.084 0.008 0.008
#> GSM22372     3  0.7483    -0.0425 0.000 0.004 0.356 0.320 0.156 0.164
#> GSM22373     6  0.3362     0.4849 0.004 0.096 0.000 0.000 0.076 0.824
#> GSM22375     3  0.6836     0.2864 0.000 0.000 0.396 0.112 0.112 0.380
#> GSM22376     3  0.6023     0.3690 0.000 0.000 0.504 0.280 0.012 0.204
#> GSM22377     3  0.3993     0.3056 0.000 0.000 0.520 0.000 0.004 0.476
#> GSM22378     2  0.4782     0.5371 0.200 0.700 0.000 0.084 0.008 0.008
#> GSM22379     3  0.5456     0.5781 0.000 0.004 0.668 0.064 0.076 0.188
#> GSM22380     3  0.2344     0.6320 0.000 0.000 0.892 0.004 0.076 0.028
#> GSM22383     3  0.3993     0.3056 0.000 0.000 0.520 0.000 0.004 0.476
#> GSM22386     3  0.1608     0.6373 0.000 0.004 0.940 0.004 0.036 0.016
#> GSM22389     6  0.4518     0.4421 0.000 0.000 0.164 0.040 0.056 0.740
#> GSM22391     3  0.1608     0.6373 0.000 0.004 0.940 0.004 0.036 0.016
#> GSM22395     3  0.3634     0.5466 0.000 0.000 0.696 0.000 0.008 0.296
#> GSM22396     6  0.4659     0.4495 0.000 0.180 0.000 0.028 0.072 0.720
#> GSM22398     3  0.4561     0.3873 0.000 0.000 0.564 0.024 0.008 0.404
#> GSM22399     4  0.7260     0.1127 0.000 0.000 0.248 0.404 0.116 0.232
#> GSM22402     6  0.3595     0.5150 0.000 0.144 0.000 0.028 0.024 0.804
#> GSM22407     2  0.5057     0.1643 0.000 0.560 0.000 0.000 0.352 0.088
#> GSM22411     3  0.1082     0.6277 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM22412     3  0.7483    -0.0425 0.000 0.004 0.356 0.320 0.156 0.164
#> GSM22415     3  0.5291     0.5820 0.000 0.000 0.688 0.124 0.060 0.128
#> GSM22416     1  0.2933     0.5490 0.796 0.200 0.000 0.000 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:hclust 50            0.623 2
#> ATC:hclust 36            0.106 3
#> ATC:hclust 24            0.665 4
#> ATC:hclust 37            0.678 5
#> ATC:hclust 31            0.421 6

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 21446 rows and 60 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 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-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.987       0.994         0.4561 0.548   0.548
#> 3 3 0.427           0.581       0.740         0.4002 0.746   0.562
#> 4 4 0.492           0.447       0.720         0.1491 0.799   0.507
#> 5 5 0.541           0.371       0.649         0.0757 0.824   0.444
#> 6 6 0.632           0.399       0.598         0.0468 0.819   0.357

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
#> GSM22369     1   0.000      0.991 1.000 0.000
#> GSM22374     1   0.373      0.921 0.928 0.072
#> GSM22381     1   0.000      0.991 1.000 0.000
#> GSM22382     1   0.000      0.991 1.000 0.000
#> GSM22384     1   0.000      0.991 1.000 0.000
#> GSM22385     2   0.000      1.000 0.000 1.000
#> GSM22387     1   0.000      0.991 1.000 0.000
#> GSM22388     2   0.000      1.000 0.000 1.000
#> GSM22390     1   0.000      0.991 1.000 0.000
#> GSM22392     2   0.000      1.000 0.000 1.000
#> GSM22393     1   0.000      0.991 1.000 0.000
#> GSM22394     2   0.000      1.000 0.000 1.000
#> GSM22397     2   0.000      1.000 0.000 1.000
#> GSM22400     1   0.000      0.991 1.000 0.000
#> GSM22401     2   0.000      1.000 0.000 1.000
#> GSM22403     1   0.000      0.991 1.000 0.000
#> GSM22404     1   0.000      0.991 1.000 0.000
#> GSM22405     1   0.000      0.991 1.000 0.000
#> GSM22406     2   0.000      1.000 0.000 1.000
#> GSM22408     1   0.000      0.991 1.000 0.000
#> GSM22409     1   0.000      0.991 1.000 0.000
#> GSM22410     1   0.000      0.991 1.000 0.000
#> GSM22413     1   0.000      0.991 1.000 0.000
#> GSM22414     2   0.000      1.000 0.000 1.000
#> GSM22417     1   0.000      0.991 1.000 0.000
#> GSM22418     2   0.000      1.000 0.000 1.000
#> GSM22419     2   0.000      1.000 0.000 1.000
#> GSM22420     1   0.260      0.950 0.956 0.044
#> GSM22421     2   0.000      1.000 0.000 1.000
#> GSM22422     1   0.000      0.991 1.000 0.000
#> GSM22423     1   0.000      0.991 1.000 0.000
#> GSM22424     2   0.000      1.000 0.000 1.000
#> GSM22365     2   0.000      1.000 0.000 1.000
#> GSM22366     1   0.775      0.707 0.772 0.228
#> GSM22367     1   0.000      0.991 1.000 0.000
#> GSM22368     1   0.000      0.991 1.000 0.000
#> GSM22370     1   0.000      0.991 1.000 0.000
#> GSM22371     2   0.000      1.000 0.000 1.000
#> GSM22372     1   0.000      0.991 1.000 0.000
#> GSM22373     2   0.000      1.000 0.000 1.000
#> GSM22375     1   0.000      0.991 1.000 0.000
#> GSM22376     1   0.000      0.991 1.000 0.000
#> GSM22377     1   0.000      0.991 1.000 0.000
#> GSM22378     2   0.000      1.000 0.000 1.000
#> GSM22379     1   0.000      0.991 1.000 0.000
#> GSM22380     1   0.000      0.991 1.000 0.000
#> GSM22383     1   0.000      0.991 1.000 0.000
#> GSM22386     1   0.000      0.991 1.000 0.000
#> GSM22389     1   0.000      0.991 1.000 0.000
#> GSM22391     1   0.000      0.991 1.000 0.000
#> GSM22395     1   0.000      0.991 1.000 0.000
#> GSM22396     2   0.000      1.000 0.000 1.000
#> GSM22398     1   0.000      0.991 1.000 0.000
#> GSM22399     1   0.000      0.991 1.000 0.000
#> GSM22402     2   0.000      1.000 0.000 1.000
#> GSM22407     2   0.000      1.000 0.000 1.000
#> GSM22411     1   0.000      0.991 1.000 0.000
#> GSM22412     1   0.000      0.991 1.000 0.000
#> GSM22415     1   0.000      0.991 1.000 0.000
#> GSM22416     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
#> GSM22369     3  0.0237     0.6939 0.004 0.000 0.996
#> GSM22374     1  0.5595     0.5389 0.756 0.016 0.228
#> GSM22381     3  0.5733     0.5140 0.324 0.000 0.676
#> GSM22382     3  0.5706     0.4886 0.320 0.000 0.680
#> GSM22384     3  0.4504     0.6441 0.196 0.000 0.804
#> GSM22385     2  0.2537     0.8845 0.080 0.920 0.000
#> GSM22387     3  0.6192     0.2743 0.420 0.000 0.580
#> GSM22388     2  0.5254     0.7129 0.264 0.736 0.000
#> GSM22390     1  0.6215     0.2256 0.572 0.000 0.428
#> GSM22392     1  0.5560     0.4429 0.700 0.300 0.000
#> GSM22393     1  0.5201     0.3010 0.760 0.004 0.236
#> GSM22394     2  0.2537     0.8662 0.080 0.920 0.000
#> GSM22397     2  0.1860     0.8938 0.052 0.948 0.000
#> GSM22400     1  0.3619     0.5324 0.864 0.000 0.136
#> GSM22401     2  0.2066     0.8931 0.060 0.940 0.000
#> GSM22403     1  0.6345    -0.0596 0.596 0.004 0.400
#> GSM22404     3  0.0237     0.6939 0.004 0.000 0.996
#> GSM22405     1  0.5431     0.5101 0.716 0.000 0.284
#> GSM22406     2  0.4002     0.8525 0.160 0.840 0.000
#> GSM22408     3  0.5835     0.5437 0.340 0.000 0.660
#> GSM22409     3  0.6081     0.4851 0.344 0.004 0.652
#> GSM22410     3  0.0237     0.6939 0.004 0.000 0.996
#> GSM22413     3  0.1163     0.6922 0.028 0.000 0.972
#> GSM22414     2  0.1964     0.8931 0.056 0.944 0.000
#> GSM22417     3  0.4654     0.5809 0.208 0.000 0.792
#> GSM22418     2  0.1643     0.8768 0.044 0.956 0.000
#> GSM22419     2  0.2537     0.8662 0.080 0.920 0.000
#> GSM22420     1  0.5595     0.5389 0.756 0.016 0.228
#> GSM22421     1  0.5859     0.4007 0.656 0.344 0.000
#> GSM22422     3  0.4974     0.6179 0.236 0.000 0.764
#> GSM22423     1  0.5843     0.5384 0.732 0.016 0.252
#> GSM22424     1  0.5835     0.4147 0.660 0.340 0.000
#> GSM22365     2  0.6045     0.6004 0.380 0.620 0.000
#> GSM22366     1  0.6807     0.3891 0.736 0.092 0.172
#> GSM22367     3  0.0424     0.6938 0.008 0.000 0.992
#> GSM22368     3  0.5497     0.5660 0.292 0.000 0.708
#> GSM22370     1  0.6305     0.1228 0.516 0.000 0.484
#> GSM22371     2  0.1753     0.8940 0.048 0.952 0.000
#> GSM22372     3  0.5178     0.6102 0.256 0.000 0.744
#> GSM22373     2  0.3941     0.8517 0.156 0.844 0.000
#> GSM22375     3  0.3551     0.6741 0.132 0.000 0.868
#> GSM22376     3  0.5497     0.5715 0.292 0.000 0.708
#> GSM22377     3  0.6192     0.2743 0.420 0.000 0.580
#> GSM22378     2  0.1860     0.8938 0.052 0.948 0.000
#> GSM22379     3  0.5859     0.4768 0.344 0.000 0.656
#> GSM22380     3  0.4702     0.5780 0.212 0.000 0.788
#> GSM22383     3  0.5859     0.4466 0.344 0.000 0.656
#> GSM22386     3  0.0424     0.6945 0.008 0.000 0.992
#> GSM22389     1  0.5560     0.4273 0.700 0.000 0.300
#> GSM22391     3  0.0424     0.6945 0.008 0.000 0.992
#> GSM22395     3  0.5968     0.3173 0.364 0.000 0.636
#> GSM22396     1  0.6235     0.1766 0.564 0.436 0.000
#> GSM22398     3  0.6079     0.3092 0.388 0.000 0.612
#> GSM22399     3  0.5363     0.5933 0.276 0.000 0.724
#> GSM22402     1  0.5785     0.4271 0.668 0.332 0.000
#> GSM22407     2  0.4452     0.7761 0.192 0.808 0.000
#> GSM22411     3  0.0892     0.6924 0.020 0.000 0.980
#> GSM22412     3  0.5254     0.6075 0.264 0.000 0.736
#> GSM22415     3  0.4702     0.5805 0.212 0.000 0.788
#> GSM22416     2  0.1163     0.8804 0.028 0.972 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3  0.0188     0.6186 0.000 0.000 0.996 0.004
#> GSM22374     1  0.1174     0.6210 0.968 0.000 0.020 0.012
#> GSM22381     4  0.5359     0.5389 0.036 0.000 0.288 0.676
#> GSM22382     3  0.6646     0.1287 0.428 0.000 0.488 0.084
#> GSM22384     3  0.5873    -0.0322 0.036 0.000 0.548 0.416
#> GSM22385     2  0.3818     0.7334 0.108 0.844 0.000 0.048
#> GSM22387     1  0.5924     0.2001 0.556 0.000 0.404 0.040
#> GSM22388     4  0.6083    -0.0517 0.056 0.360 0.000 0.584
#> GSM22390     1  0.3708     0.5558 0.832 0.000 0.148 0.020
#> GSM22392     1  0.2032     0.6173 0.936 0.036 0.000 0.028
#> GSM22393     4  0.4955     0.4911 0.268 0.000 0.024 0.708
#> GSM22394     2  0.4635     0.6956 0.028 0.756 0.000 0.216
#> GSM22397     2  0.1004     0.7890 0.024 0.972 0.000 0.004
#> GSM22400     1  0.2928     0.5903 0.880 0.000 0.012 0.108
#> GSM22401     2  0.2124     0.7821 0.028 0.932 0.000 0.040
#> GSM22403     4  0.5517     0.5835 0.092 0.000 0.184 0.724
#> GSM22404     3  0.0188     0.6186 0.000 0.000 0.996 0.004
#> GSM22405     1  0.3237     0.6166 0.888 0.008 0.064 0.040
#> GSM22406     2  0.4500     0.4999 0.000 0.684 0.000 0.316
#> GSM22408     3  0.7916     0.2035 0.316 0.000 0.356 0.328
#> GSM22409     4  0.4956     0.5656 0.036 0.000 0.232 0.732
#> GSM22410     3  0.1151     0.6166 0.008 0.000 0.968 0.024
#> GSM22413     3  0.1798     0.6084 0.016 0.000 0.944 0.040
#> GSM22414     2  0.1820     0.7843 0.036 0.944 0.000 0.020
#> GSM22417     3  0.5430     0.3282 0.300 0.000 0.664 0.036
#> GSM22418     2  0.4375     0.7152 0.032 0.788 0.000 0.180
#> GSM22419     2  0.4655     0.6984 0.032 0.760 0.000 0.208
#> GSM22420     1  0.1174     0.6210 0.968 0.000 0.020 0.012
#> GSM22421     1  0.6141     0.2871 0.624 0.300 0.000 0.076
#> GSM22422     4  0.5778     0.1424 0.028 0.000 0.472 0.500
#> GSM22423     1  0.5297     0.5794 0.788 0.108 0.044 0.060
#> GSM22424     1  0.5213     0.4549 0.724 0.224 0.000 0.052
#> GSM22365     4  0.7325    -0.0618 0.168 0.340 0.000 0.492
#> GSM22366     4  0.6168     0.5604 0.104 0.108 0.052 0.736
#> GSM22367     3  0.0921     0.6147 0.000 0.000 0.972 0.028
#> GSM22368     3  0.5745     0.4231 0.288 0.000 0.656 0.056
#> GSM22370     1  0.5496     0.3141 0.604 0.000 0.372 0.024
#> GSM22371     2  0.0817     0.7889 0.024 0.976 0.000 0.000
#> GSM22372     3  0.6276    -0.1556 0.056 0.000 0.480 0.464
#> GSM22373     2  0.5093     0.5149 0.348 0.640 0.000 0.012
#> GSM22375     3  0.7437     0.3503 0.240 0.000 0.512 0.248
#> GSM22376     3  0.6675     0.4675 0.228 0.000 0.616 0.156
#> GSM22377     1  0.5837     0.2130 0.564 0.000 0.400 0.036
#> GSM22378     2  0.1151     0.7885 0.024 0.968 0.000 0.008
#> GSM22379     3  0.7060     0.2087 0.376 0.000 0.496 0.128
#> GSM22380     3  0.5256     0.3826 0.272 0.000 0.692 0.036
#> GSM22383     1  0.6145     0.0106 0.492 0.000 0.460 0.048
#> GSM22386     3  0.1389     0.6055 0.000 0.000 0.952 0.048
#> GSM22389     1  0.3048     0.5829 0.876 0.000 0.108 0.016
#> GSM22391     3  0.1389     0.6055 0.000 0.000 0.952 0.048
#> GSM22395     1  0.5606     0.1128 0.500 0.000 0.480 0.020
#> GSM22396     1  0.5970     0.1996 0.600 0.348 0.000 0.052
#> GSM22398     1  0.5774     0.1152 0.508 0.000 0.464 0.028
#> GSM22399     4  0.6005     0.4468 0.060 0.000 0.324 0.616
#> GSM22402     1  0.5321     0.4445 0.716 0.228 0.000 0.056
#> GSM22407     2  0.5349     0.4890 0.336 0.640 0.000 0.024
#> GSM22411     3  0.1767     0.6104 0.012 0.000 0.944 0.044
#> GSM22412     3  0.6799    -0.1161 0.096 0.000 0.464 0.440
#> GSM22415     3  0.5392     0.3559 0.280 0.000 0.680 0.040
#> GSM22416     2  0.4182     0.7188 0.024 0.796 0.000 0.180

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.1357     0.6528 0.000 0.000 0.048 0.004 0.948
#> GSM22374     3  0.5599     0.1070 0.008 0.448 0.492 0.052 0.000
#> GSM22381     4  0.2020     0.6445 0.000 0.000 0.000 0.900 0.100
#> GSM22382     5  0.7500     0.0725 0.000 0.164 0.376 0.064 0.396
#> GSM22384     5  0.6928    -0.1255 0.000 0.020 0.180 0.356 0.444
#> GSM22385     2  0.5728    -0.1768 0.336 0.588 0.052 0.024 0.000
#> GSM22387     3  0.5042     0.5539 0.008 0.064 0.756 0.032 0.140
#> GSM22388     4  0.5088     0.1884 0.392 0.032 0.004 0.572 0.000
#> GSM22390     3  0.4610     0.5529 0.008 0.160 0.772 0.032 0.028
#> GSM22392     2  0.5742    -0.1182 0.012 0.496 0.436 0.056 0.000
#> GSM22393     4  0.3511     0.5884 0.008 0.044 0.088 0.852 0.008
#> GSM22394     1  0.0486     0.6324 0.988 0.004 0.000 0.004 0.004
#> GSM22397     1  0.5794     0.5373 0.548 0.380 0.048 0.024 0.000
#> GSM22400     3  0.6386     0.2936 0.004 0.324 0.508 0.164 0.000
#> GSM22401     2  0.6129    -0.4806 0.460 0.464 0.028 0.036 0.012
#> GSM22403     4  0.2359     0.6433 0.000 0.008 0.036 0.912 0.044
#> GSM22404     5  0.1205     0.6544 0.000 0.000 0.040 0.004 0.956
#> GSM22405     3  0.5111     0.2950 0.000 0.376 0.588 0.024 0.012
#> GSM22406     1  0.6862     0.2542 0.436 0.164 0.020 0.380 0.000
#> GSM22408     3  0.6928     0.0156 0.000 0.004 0.376 0.328 0.292
#> GSM22409     4  0.1908     0.6460 0.000 0.000 0.000 0.908 0.092
#> GSM22410     5  0.2522     0.6137 0.000 0.000 0.108 0.012 0.880
#> GSM22413     5  0.3801     0.5539 0.000 0.008 0.140 0.040 0.812
#> GSM22414     1  0.5908     0.4936 0.524 0.404 0.048 0.020 0.004
#> GSM22417     5  0.4764     0.1146 0.000 0.004 0.436 0.012 0.548
#> GSM22418     1  0.0404     0.6366 0.988 0.012 0.000 0.000 0.000
#> GSM22419     1  0.0324     0.6337 0.992 0.004 0.000 0.004 0.000
#> GSM22420     3  0.5651     0.1120 0.008 0.444 0.492 0.056 0.000
#> GSM22421     2  0.2636     0.5474 0.028 0.908 0.036 0.020 0.008
#> GSM22422     4  0.6499     0.2569 0.000 0.020 0.116 0.488 0.376
#> GSM22423     2  0.5219     0.0301 0.000 0.560 0.400 0.032 0.008
#> GSM22424     2  0.3218     0.5860 0.004 0.844 0.128 0.024 0.000
#> GSM22365     4  0.6315     0.2199 0.320 0.120 0.016 0.544 0.000
#> GSM22366     4  0.3569     0.6183 0.012 0.064 0.044 0.860 0.020
#> GSM22367     5  0.1216     0.6536 0.000 0.000 0.020 0.020 0.960
#> GSM22368     3  0.5638    -0.0494 0.000 0.020 0.536 0.040 0.404
#> GSM22370     3  0.4749     0.5616 0.000 0.116 0.756 0.012 0.116
#> GSM22371     1  0.5794     0.5373 0.548 0.380 0.048 0.024 0.000
#> GSM22372     4  0.6945     0.2404 0.000 0.024 0.172 0.456 0.348
#> GSM22373     2  0.5115     0.4391 0.216 0.700 0.072 0.012 0.000
#> GSM22375     3  0.6890    -0.0824 0.004 0.024 0.484 0.144 0.344
#> GSM22376     3  0.6829     0.1302 0.000 0.008 0.460 0.248 0.284
#> GSM22377     3  0.5076     0.5557 0.008 0.064 0.756 0.036 0.136
#> GSM22378     1  0.5794     0.5373 0.548 0.380 0.048 0.024 0.000
#> GSM22379     3  0.7056     0.1221 0.000 0.024 0.436 0.192 0.348
#> GSM22380     5  0.4997     0.0424 0.000 0.008 0.468 0.016 0.508
#> GSM22383     3  0.4432     0.4811 0.008 0.012 0.768 0.032 0.180
#> GSM22386     5  0.2362     0.6322 0.000 0.000 0.024 0.076 0.900
#> GSM22389     3  0.4799     0.5215 0.004 0.200 0.732 0.056 0.008
#> GSM22391     5  0.2331     0.6297 0.000 0.000 0.020 0.080 0.900
#> GSM22395     3  0.4347     0.4954 0.000 0.040 0.744 0.004 0.212
#> GSM22396     2  0.3321     0.5808 0.040 0.856 0.092 0.012 0.000
#> GSM22398     3  0.4643     0.4804 0.000 0.052 0.732 0.008 0.208
#> GSM22399     4  0.4794     0.5798 0.000 0.020 0.100 0.760 0.120
#> GSM22402     2  0.3478     0.5870 0.004 0.828 0.136 0.032 0.000
#> GSM22407     2  0.4448     0.2816 0.224 0.740 0.008 0.016 0.012
#> GSM22411     5  0.3011     0.6051 0.000 0.000 0.140 0.016 0.844
#> GSM22412     4  0.7260     0.1690 0.000 0.024 0.256 0.404 0.316
#> GSM22415     5  0.5590     0.0535 0.000 0.008 0.436 0.052 0.504
#> GSM22416     1  0.1399     0.6360 0.952 0.020 0.028 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
#> GSM22369     5  0.0632     0.8164 0.000 0.000 0.024 0.000 0.976 0.000
#> GSM22374     6  0.2504     0.4992 0.004 0.012 0.104 0.004 0.000 0.876
#> GSM22381     4  0.1605     0.6842 0.012 0.000 0.016 0.940 0.032 0.000
#> GSM22382     3  0.8261     0.0132 0.108 0.084 0.452 0.020 0.196 0.140
#> GSM22384     3  0.7367    -0.1373 0.088 0.004 0.324 0.288 0.296 0.000
#> GSM22385     2  0.3158     0.5973 0.020 0.812 0.004 0.000 0.000 0.164
#> GSM22387     3  0.6057     0.2083 0.064 0.000 0.480 0.000 0.072 0.384
#> GSM22388     4  0.5794     0.4123 0.280 0.044 0.012 0.596 0.000 0.068
#> GSM22390     6  0.5076    -0.1476 0.064 0.000 0.456 0.000 0.004 0.476
#> GSM22392     6  0.1931     0.5138 0.004 0.008 0.068 0.004 0.000 0.916
#> GSM22393     4  0.2748     0.6624 0.008 0.000 0.016 0.856 0.000 0.120
#> GSM22394     1  0.2838     0.9310 0.808 0.188 0.000 0.004 0.000 0.000
#> GSM22397     2  0.2340     0.5875 0.148 0.852 0.000 0.000 0.000 0.000
#> GSM22400     6  0.5263     0.2955 0.008 0.000 0.220 0.144 0.000 0.628
#> GSM22401     2  0.4763     0.5032 0.096 0.760 0.048 0.020 0.000 0.076
#> GSM22403     4  0.1036     0.6897 0.000 0.000 0.024 0.964 0.004 0.008
#> GSM22404     5  0.0713     0.8176 0.000 0.000 0.028 0.000 0.972 0.000
#> GSM22405     6  0.4828     0.3266 0.000 0.024 0.312 0.004 0.028 0.632
#> GSM22406     4  0.6002     0.1834 0.248 0.224 0.000 0.516 0.000 0.012
#> GSM22408     3  0.7120     0.2099 0.012 0.000 0.408 0.268 0.260 0.052
#> GSM22409     4  0.1321     0.6873 0.004 0.000 0.020 0.952 0.024 0.000
#> GSM22410     5  0.2520     0.6721 0.000 0.000 0.152 0.004 0.844 0.000
#> GSM22413     5  0.4082     0.5823 0.032 0.000 0.228 0.012 0.728 0.000
#> GSM22414     2  0.2118     0.6107 0.104 0.888 0.000 0.000 0.000 0.008
#> GSM22417     3  0.5901     0.1769 0.060 0.000 0.456 0.004 0.432 0.048
#> GSM22418     1  0.2933     0.9332 0.796 0.200 0.000 0.000 0.000 0.004
#> GSM22419     1  0.3011     0.9328 0.800 0.192 0.000 0.004 0.000 0.004
#> GSM22420     6  0.2196     0.4976 0.004 0.000 0.108 0.004 0.000 0.884
#> GSM22421     2  0.5687     0.1795 0.012 0.484 0.056 0.024 0.000 0.424
#> GSM22422     4  0.7364     0.0868 0.100 0.004 0.296 0.368 0.232 0.000
#> GSM22423     6  0.6066     0.3858 0.004 0.156 0.160 0.024 0.028 0.628
#> GSM22424     6  0.4428     0.0827 0.004 0.388 0.012 0.008 0.000 0.588
#> GSM22365     4  0.6170     0.4243 0.248 0.032 0.012 0.568 0.000 0.140
#> GSM22366     4  0.1844     0.6832 0.012 0.004 0.028 0.932 0.000 0.024
#> GSM22367     5  0.0551     0.8178 0.004 0.000 0.004 0.008 0.984 0.000
#> GSM22368     3  0.6353     0.1448 0.096 0.008 0.588 0.016 0.240 0.052
#> GSM22370     3  0.6086     0.2325 0.056 0.000 0.536 0.004 0.084 0.320
#> GSM22371     2  0.2558     0.5795 0.156 0.840 0.000 0.000 0.000 0.004
#> GSM22372     3  0.7224    -0.1789 0.104 0.004 0.376 0.368 0.144 0.004
#> GSM22373     6  0.4491     0.0159 0.036 0.388 0.000 0.000 0.000 0.576
#> GSM22375     3  0.7384     0.2163 0.100 0.004 0.552 0.100 0.132 0.112
#> GSM22376     3  0.6452     0.3443 0.012 0.000 0.552 0.180 0.212 0.044
#> GSM22377     3  0.6020     0.2003 0.060 0.000 0.476 0.000 0.072 0.392
#> GSM22378     2  0.2416     0.5768 0.156 0.844 0.000 0.000 0.000 0.000
#> GSM22379     3  0.6818     0.3153 0.020 0.000 0.512 0.088 0.280 0.100
#> GSM22380     3  0.5224     0.2559 0.012 0.000 0.544 0.008 0.388 0.048
#> GSM22383     3  0.6076     0.2253 0.064 0.000 0.492 0.000 0.076 0.368
#> GSM22386     5  0.2519     0.7964 0.016 0.000 0.048 0.044 0.892 0.000
#> GSM22389     6  0.4315    -0.1221 0.012 0.000 0.492 0.004 0.000 0.492
#> GSM22391     5  0.2519     0.7964 0.016 0.000 0.048 0.044 0.892 0.000
#> GSM22395     3  0.6302     0.2985 0.056 0.000 0.528 0.000 0.140 0.276
#> GSM22396     6  0.4406     0.0112 0.004 0.432 0.012 0.004 0.000 0.548
#> GSM22398     3  0.6146     0.2983 0.060 0.000 0.556 0.000 0.120 0.264
#> GSM22399     4  0.6152     0.4789 0.092 0.000 0.160 0.644 0.060 0.044
#> GSM22402     6  0.4657     0.0927 0.004 0.376 0.016 0.016 0.000 0.588
#> GSM22407     2  0.5709     0.3761 0.040 0.552 0.048 0.012 0.000 0.348
#> GSM22411     5  0.2730     0.6698 0.000 0.000 0.192 0.000 0.808 0.000
#> GSM22412     3  0.7292    -0.1337 0.104 0.004 0.408 0.344 0.128 0.012
#> GSM22415     3  0.5445     0.2416 0.008 0.000 0.536 0.024 0.384 0.048
#> GSM22416     1  0.3464     0.8083 0.688 0.312 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:kmeans 60           0.6473 2
#> ATC:kmeans 41           0.0639 3
#> ATC:kmeans 31           0.4297 4
#> ATC:kmeans 30           0.9274 5
#> ATC:kmeans 24           0.7312 6

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 21446 rows and 60 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.986       0.993         0.5039 0.497   0.497
#> 3 3 0.555           0.580       0.804         0.3004 0.780   0.585
#> 4 4 0.554           0.574       0.760         0.1315 0.780   0.464
#> 5 5 0.631           0.544       0.703         0.0741 0.893   0.627
#> 6 6 0.664           0.573       0.749         0.0439 0.910   0.605

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
#> GSM22369     1   0.000      0.993 1.000 0.000
#> GSM22374     2   0.118      0.980 0.016 0.984
#> GSM22381     1   0.000      0.993 1.000 0.000
#> GSM22382     1   0.000      0.993 1.000 0.000
#> GSM22384     1   0.000      0.993 1.000 0.000
#> GSM22385     2   0.000      0.993 0.000 1.000
#> GSM22387     1   0.000      0.993 1.000 0.000
#> GSM22388     2   0.000      0.993 0.000 1.000
#> GSM22390     1   0.000      0.993 1.000 0.000
#> GSM22392     2   0.000      0.993 0.000 1.000
#> GSM22393     2   0.000      0.993 0.000 1.000
#> GSM22394     2   0.000      0.993 0.000 1.000
#> GSM22397     2   0.000      0.993 0.000 1.000
#> GSM22400     2   0.000      0.993 0.000 1.000
#> GSM22401     2   0.000      0.993 0.000 1.000
#> GSM22403     1   0.653      0.804 0.832 0.168
#> GSM22404     1   0.000      0.993 1.000 0.000
#> GSM22405     2   0.443      0.904 0.092 0.908
#> GSM22406     2   0.000      0.993 0.000 1.000
#> GSM22408     1   0.000      0.993 1.000 0.000
#> GSM22409     1   0.311      0.939 0.944 0.056
#> GSM22410     1   0.000      0.993 1.000 0.000
#> GSM22413     1   0.000      0.993 1.000 0.000
#> GSM22414     2   0.000      0.993 0.000 1.000
#> GSM22417     1   0.000      0.993 1.000 0.000
#> GSM22418     2   0.000      0.993 0.000 1.000
#> GSM22419     2   0.000      0.993 0.000 1.000
#> GSM22420     2   0.311      0.943 0.056 0.944
#> GSM22421     2   0.000      0.993 0.000 1.000
#> GSM22422     1   0.000      0.993 1.000 0.000
#> GSM22423     2   0.184      0.971 0.028 0.972
#> GSM22424     2   0.000      0.993 0.000 1.000
#> GSM22365     2   0.000      0.993 0.000 1.000
#> GSM22366     2   0.000      0.993 0.000 1.000
#> GSM22367     1   0.000      0.993 1.000 0.000
#> GSM22368     1   0.000      0.993 1.000 0.000
#> GSM22370     1   0.000      0.993 1.000 0.000
#> GSM22371     2   0.000      0.993 0.000 1.000
#> GSM22372     1   0.000      0.993 1.000 0.000
#> GSM22373     2   0.000      0.993 0.000 1.000
#> GSM22375     1   0.000      0.993 1.000 0.000
#> GSM22376     1   0.000      0.993 1.000 0.000
#> GSM22377     1   0.000      0.993 1.000 0.000
#> GSM22378     2   0.000      0.993 0.000 1.000
#> GSM22379     1   0.000      0.993 1.000 0.000
#> GSM22380     1   0.000      0.993 1.000 0.000
#> GSM22383     1   0.000      0.993 1.000 0.000
#> GSM22386     1   0.000      0.993 1.000 0.000
#> GSM22389     1   0.000      0.993 1.000 0.000
#> GSM22391     1   0.000      0.993 1.000 0.000
#> GSM22395     1   0.000      0.993 1.000 0.000
#> GSM22396     2   0.000      0.993 0.000 1.000
#> GSM22398     1   0.000      0.993 1.000 0.000
#> GSM22399     1   0.000      0.993 1.000 0.000
#> GSM22402     2   0.000      0.993 0.000 1.000
#> GSM22407     2   0.000      0.993 0.000 1.000
#> GSM22411     1   0.000      0.993 1.000 0.000
#> GSM22412     1   0.000      0.993 1.000 0.000
#> GSM22415     1   0.000      0.993 1.000 0.000
#> GSM22416     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
#> GSM22369     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22374     2  0.6225     0.4394 0.000 0.568 0.432
#> GSM22381     1  0.0424     0.5297 0.992 0.000 0.008
#> GSM22382     3  0.6451     0.5433 0.436 0.004 0.560
#> GSM22384     1  0.5497     0.1406 0.708 0.000 0.292
#> GSM22385     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22387     3  0.0000     0.6108 0.000 0.000 1.000
#> GSM22388     1  0.6244    -0.0462 0.560 0.440 0.000
#> GSM22390     3  0.0000     0.6108 0.000 0.000 1.000
#> GSM22392     2  0.5591     0.5959 0.000 0.696 0.304
#> GSM22393     1  0.8853     0.3082 0.568 0.168 0.264
#> GSM22394     2  0.3267     0.8216 0.116 0.884 0.000
#> GSM22397     2  0.0747     0.8827 0.016 0.984 0.000
#> GSM22400     1  0.8578     0.2519 0.504 0.100 0.396
#> GSM22401     2  0.0747     0.8827 0.016 0.984 0.000
#> GSM22403     1  0.0000     0.5316 1.000 0.000 0.000
#> GSM22404     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22405     3  0.5517     0.2723 0.004 0.268 0.728
#> GSM22406     2  0.4842     0.7020 0.224 0.776 0.000
#> GSM22408     3  0.4974     0.4257 0.236 0.000 0.764
#> GSM22409     1  0.0000     0.5316 1.000 0.000 0.000
#> GSM22410     3  0.6126     0.5697 0.400 0.000 0.600
#> GSM22413     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22414     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22417     3  0.0747     0.6159 0.016 0.000 0.984
#> GSM22418     2  0.0747     0.8827 0.016 0.984 0.000
#> GSM22419     2  0.3267     0.8216 0.116 0.884 0.000
#> GSM22420     2  0.6244     0.4266 0.000 0.560 0.440
#> GSM22421     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22422     1  0.3752     0.4382 0.856 0.000 0.144
#> GSM22423     2  0.5406     0.6937 0.020 0.780 0.200
#> GSM22424     2  0.1964     0.8526 0.000 0.944 0.056
#> GSM22365     2  0.3482     0.8115 0.128 0.872 0.000
#> GSM22366     1  0.6225    -0.0251 0.568 0.432 0.000
#> GSM22367     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22368     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22370     3  0.0237     0.6121 0.004 0.000 0.996
#> GSM22371     2  0.0747     0.8827 0.016 0.984 0.000
#> GSM22372     1  0.5327     0.2232 0.728 0.000 0.272
#> GSM22373     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22375     3  0.5810     0.5780 0.336 0.000 0.664
#> GSM22376     1  0.6308    -0.4578 0.508 0.000 0.492
#> GSM22377     3  0.0000     0.6108 0.000 0.000 1.000
#> GSM22378     2  0.0747     0.8827 0.016 0.984 0.000
#> GSM22379     3  0.5948     0.4972 0.360 0.000 0.640
#> GSM22380     3  0.5859     0.5893 0.344 0.000 0.656
#> GSM22383     3  0.0424     0.6138 0.008 0.000 0.992
#> GSM22386     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22389     3  0.0000     0.6108 0.000 0.000 1.000
#> GSM22391     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22395     3  0.0000     0.6108 0.000 0.000 1.000
#> GSM22396     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22398     3  0.2356     0.6211 0.072 0.000 0.928
#> GSM22399     1  0.3412     0.4664 0.876 0.000 0.124
#> GSM22402     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22407     2  0.0000     0.8831 0.000 1.000 0.000
#> GSM22411     3  0.6225     0.5538 0.432 0.000 0.568
#> GSM22412     1  0.5327     0.2232 0.728 0.000 0.272
#> GSM22415     3  0.4002     0.6215 0.160 0.000 0.840
#> GSM22416     2  0.0747     0.8827 0.016 0.984 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     4  0.1356     0.7497 0.032 0.000 0.008 0.960
#> GSM22374     3  0.4482     0.4100 0.128 0.068 0.804 0.000
#> GSM22381     1  0.4040     0.5576 0.752 0.000 0.000 0.248
#> GSM22382     4  0.4894     0.6455 0.068 0.064 0.052 0.816
#> GSM22384     4  0.3873     0.5517 0.228 0.000 0.000 0.772
#> GSM22385     2  0.4171     0.7823 0.084 0.828 0.088 0.000
#> GSM22387     3  0.3975     0.6103 0.000 0.000 0.760 0.240
#> GSM22388     1  0.5649     0.2001 0.580 0.392 0.028 0.000
#> GSM22390     3  0.3764     0.6221 0.000 0.000 0.784 0.216
#> GSM22392     3  0.7254    -0.3274 0.148 0.384 0.468 0.000
#> GSM22393     1  0.5434     0.5426 0.740 0.128 0.132 0.000
#> GSM22394     2  0.3266     0.7674 0.108 0.868 0.024 0.000
#> GSM22397     2  0.0000     0.7991 0.000 1.000 0.000 0.000
#> GSM22400     1  0.5252     0.2932 0.644 0.020 0.336 0.000
#> GSM22401     2  0.0188     0.7984 0.004 0.996 0.000 0.000
#> GSM22403     1  0.3831     0.5794 0.792 0.004 0.000 0.204
#> GSM22404     4  0.1452     0.7488 0.036 0.000 0.008 0.956
#> GSM22405     3  0.5932     0.4559 0.128 0.092 0.744 0.036
#> GSM22406     2  0.3172     0.6788 0.160 0.840 0.000 0.000
#> GSM22408     1  0.7707    -0.0439 0.452 0.000 0.276 0.272
#> GSM22409     1  0.4008     0.5541 0.756 0.000 0.000 0.244
#> GSM22410     4  0.4758     0.6097 0.064 0.000 0.156 0.780
#> GSM22413     4  0.1022     0.7426 0.032 0.000 0.000 0.968
#> GSM22414     2  0.3547     0.7910 0.072 0.864 0.064 0.000
#> GSM22417     4  0.6367     0.0787 0.068 0.000 0.392 0.540
#> GSM22418     2  0.3245     0.7694 0.100 0.872 0.028 0.000
#> GSM22419     2  0.3307     0.7672 0.104 0.868 0.028 0.000
#> GSM22420     3  0.4181     0.4221 0.128 0.052 0.820 0.000
#> GSM22421     2  0.5122     0.7494 0.080 0.756 0.164 0.000
#> GSM22422     4  0.4522     0.3974 0.320 0.000 0.000 0.680
#> GSM22423     3  0.8187     0.2034 0.180 0.256 0.520 0.044
#> GSM22424     2  0.6570     0.5526 0.100 0.580 0.320 0.000
#> GSM22365     2  0.4225     0.6950 0.184 0.792 0.024 0.000
#> GSM22366     1  0.4220     0.5498 0.748 0.248 0.000 0.004
#> GSM22367     4  0.0779     0.7513 0.016 0.000 0.004 0.980
#> GSM22368     4  0.1209     0.7476 0.032 0.000 0.004 0.964
#> GSM22370     3  0.5489     0.5938 0.060 0.000 0.700 0.240
#> GSM22371     2  0.0592     0.7987 0.016 0.984 0.000 0.000
#> GSM22372     4  0.4103     0.5274 0.256 0.000 0.000 0.744
#> GSM22373     2  0.5859     0.7602 0.156 0.704 0.140 0.000
#> GSM22375     4  0.4171     0.6958 0.060 0.000 0.116 0.824
#> GSM22376     4  0.6229     0.5834 0.204 0.000 0.132 0.664
#> GSM22377     3  0.3975     0.6103 0.000 0.000 0.760 0.240
#> GSM22378     2  0.0188     0.7984 0.004 0.996 0.000 0.000
#> GSM22379     4  0.6879     0.4721 0.216 0.000 0.188 0.596
#> GSM22380     4  0.5091     0.5780 0.068 0.000 0.180 0.752
#> GSM22383     3  0.5112     0.2423 0.004 0.000 0.560 0.436
#> GSM22386     4  0.1406     0.7521 0.024 0.000 0.016 0.960
#> GSM22389     3  0.3870     0.6240 0.004 0.000 0.788 0.208
#> GSM22391     4  0.1388     0.7515 0.028 0.000 0.012 0.960
#> GSM22395     3  0.5282     0.5682 0.036 0.000 0.688 0.276
#> GSM22396     2  0.5783     0.6987 0.088 0.692 0.220 0.000
#> GSM22398     3  0.5969     0.3881 0.044 0.000 0.564 0.392
#> GSM22399     1  0.5279     0.2885 0.588 0.000 0.012 0.400
#> GSM22402     2  0.5833     0.7003 0.096 0.692 0.212 0.000
#> GSM22407     2  0.5077     0.7571 0.080 0.760 0.160 0.000
#> GSM22411     4  0.1182     0.7501 0.016 0.000 0.016 0.968
#> GSM22412     4  0.4164     0.5195 0.264 0.000 0.000 0.736
#> GSM22415     4  0.6488     0.4074 0.128 0.000 0.244 0.628
#> GSM22416     2  0.3143     0.7711 0.100 0.876 0.024 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
#> GSM22369     5  0.3010     0.6762 0.000 0.008 0.116 0.016 0.860
#> GSM22374     2  0.5776     0.2998 0.064 0.592 0.324 0.020 0.000
#> GSM22381     4  0.1270     0.7168 0.000 0.000 0.000 0.948 0.052
#> GSM22382     5  0.5730     0.4526 0.012 0.240 0.036 0.044 0.668
#> GSM22384     5  0.4268     0.5973 0.016 0.024 0.028 0.124 0.808
#> GSM22385     2  0.4291    -0.1151 0.464 0.536 0.000 0.000 0.000
#> GSM22387     3  0.2943     0.7690 0.004 0.072 0.884 0.012 0.028
#> GSM22388     1  0.3861     0.4405 0.712 0.004 0.000 0.284 0.000
#> GSM22390     3  0.2789     0.7674 0.004 0.080 0.888 0.012 0.016
#> GSM22392     2  0.6954     0.3122 0.328 0.468 0.180 0.024 0.000
#> GSM22393     4  0.4796     0.6039 0.196 0.024 0.044 0.736 0.000
#> GSM22394     1  0.0000     0.7436 1.000 0.000 0.000 0.000 0.000
#> GSM22397     1  0.3534     0.6469 0.744 0.256 0.000 0.000 0.000
#> GSM22400     4  0.6621     0.4216 0.056 0.192 0.148 0.604 0.000
#> GSM22401     1  0.4181     0.5626 0.676 0.316 0.004 0.004 0.000
#> GSM22403     4  0.1329     0.7211 0.008 0.004 0.000 0.956 0.032
#> GSM22404     5  0.2732     0.6867 0.000 0.008 0.088 0.020 0.884
#> GSM22405     2  0.5482     0.1251 0.000 0.512 0.440 0.020 0.028
#> GSM22406     1  0.4428     0.6643 0.760 0.096 0.000 0.144 0.000
#> GSM22408     4  0.6925     0.0347 0.000 0.012 0.308 0.448 0.232
#> GSM22409     4  0.1331     0.7185 0.008 0.000 0.000 0.952 0.040
#> GSM22410     5  0.5325     0.4113 0.000 0.012 0.332 0.044 0.612
#> GSM22413     5  0.2417     0.6691 0.000 0.016 0.040 0.032 0.912
#> GSM22414     1  0.4182     0.3972 0.600 0.400 0.000 0.000 0.000
#> GSM22417     3  0.5189     0.4261 0.000 0.012 0.644 0.044 0.300
#> GSM22418     1  0.0162     0.7441 0.996 0.004 0.000 0.000 0.000
#> GSM22419     1  0.0000     0.7436 1.000 0.000 0.000 0.000 0.000
#> GSM22420     2  0.5948     0.1602 0.060 0.504 0.416 0.020 0.000
#> GSM22421     2  0.3647     0.4695 0.228 0.764 0.004 0.004 0.000
#> GSM22422     5  0.4315     0.4952 0.000 0.024 0.000 0.276 0.700
#> GSM22423     2  0.3264     0.5512 0.004 0.852 0.116 0.020 0.008
#> GSM22424     2  0.2177     0.5697 0.080 0.908 0.004 0.008 0.000
#> GSM22365     1  0.1168     0.7331 0.960 0.008 0.000 0.032 0.000
#> GSM22366     4  0.2989     0.6746 0.044 0.080 0.004 0.872 0.000
#> GSM22367     5  0.2766     0.6892 0.000 0.008 0.084 0.024 0.884
#> GSM22368     5  0.2849     0.6695 0.008 0.020 0.052 0.024 0.896
#> GSM22370     3  0.3758     0.7381 0.000 0.056 0.824 0.008 0.112
#> GSM22371     1  0.2732     0.7148 0.840 0.160 0.000 0.000 0.000
#> GSM22372     5  0.4360     0.4945 0.000 0.024 0.000 0.284 0.692
#> GSM22373     1  0.4299     0.3547 0.672 0.316 0.004 0.008 0.000
#> GSM22375     5  0.4192     0.6184 0.000 0.028 0.132 0.040 0.800
#> GSM22376     5  0.7027     0.3097 0.000 0.012 0.304 0.264 0.420
#> GSM22377     3  0.2806     0.7741 0.004 0.076 0.888 0.008 0.024
#> GSM22378     1  0.3366     0.6691 0.768 0.232 0.000 0.000 0.000
#> GSM22379     5  0.7082     0.3052 0.000 0.024 0.272 0.236 0.468
#> GSM22380     5  0.5354     0.3467 0.000 0.008 0.372 0.044 0.576
#> GSM22383     3  0.3944     0.7715 0.004 0.052 0.816 0.008 0.120
#> GSM22386     5  0.3857     0.6703 0.000 0.008 0.132 0.048 0.812
#> GSM22389     3  0.3345     0.7697 0.004 0.088 0.860 0.012 0.036
#> GSM22391     5  0.3627     0.6822 0.000 0.008 0.092 0.064 0.836
#> GSM22395     3  0.2646     0.7534 0.000 0.004 0.868 0.004 0.124
#> GSM22396     2  0.3318     0.5267 0.192 0.800 0.000 0.008 0.000
#> GSM22398     3  0.3740     0.6572 0.000 0.008 0.784 0.012 0.196
#> GSM22399     4  0.4609     0.2506 0.004 0.012 0.004 0.652 0.328
#> GSM22402     2  0.3242     0.5004 0.216 0.784 0.000 0.000 0.000
#> GSM22407     2  0.4081     0.3926 0.296 0.696 0.004 0.004 0.000
#> GSM22411     5  0.2733     0.6813 0.000 0.016 0.080 0.016 0.888
#> GSM22412     5  0.4338     0.4972 0.000 0.024 0.000 0.280 0.696
#> GSM22415     5  0.6229     0.1487 0.000 0.012 0.416 0.100 0.472
#> GSM22416     1  0.0404     0.7451 0.988 0.012 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
#> GSM22369     3  0.2778      0.675 0.000 0.000 0.824 0.008 0.168 0.000
#> GSM22374     6  0.5405      0.301 0.016 0.252 0.000 0.000 0.120 0.612
#> GSM22381     4  0.1934      0.743 0.000 0.000 0.040 0.916 0.044 0.000
#> GSM22382     5  0.3291      0.511 0.012 0.080 0.044 0.004 0.852 0.008
#> GSM22384     5  0.4561      0.660 0.012 0.000 0.136 0.112 0.736 0.004
#> GSM22385     2  0.3670      0.343 0.284 0.704 0.000 0.000 0.012 0.000
#> GSM22387     6  0.1700      0.712 0.000 0.000 0.048 0.000 0.024 0.928
#> GSM22388     1  0.3703      0.441 0.712 0.004 0.000 0.276 0.004 0.004
#> GSM22390     6  0.1405      0.698 0.000 0.000 0.024 0.004 0.024 0.948
#> GSM22392     2  0.6959      0.109 0.256 0.356 0.000 0.012 0.032 0.344
#> GSM22393     4  0.4566      0.665 0.164 0.012 0.008 0.752 0.020 0.044
#> GSM22394     1  0.0146      0.712 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM22397     1  0.3905      0.550 0.668 0.316 0.000 0.000 0.016 0.000
#> GSM22400     4  0.7124      0.352 0.028 0.220 0.012 0.492 0.032 0.216
#> GSM22401     1  0.5251      0.321 0.528 0.380 0.000 0.004 0.088 0.000
#> GSM22403     4  0.0767      0.759 0.000 0.004 0.008 0.976 0.012 0.000
#> GSM22404     3  0.2778      0.675 0.000 0.000 0.824 0.008 0.168 0.000
#> GSM22405     2  0.5858      0.105 0.000 0.540 0.168 0.004 0.008 0.280
#> GSM22406     1  0.4574      0.623 0.716 0.112 0.000 0.164 0.008 0.000
#> GSM22408     3  0.4737      0.399 0.000 0.004 0.640 0.308 0.020 0.028
#> GSM22409     4  0.1528      0.748 0.000 0.000 0.016 0.936 0.048 0.000
#> GSM22410     3  0.1074      0.738 0.000 0.000 0.960 0.000 0.028 0.012
#> GSM22413     5  0.4452      0.457 0.000 0.000 0.428 0.016 0.548 0.008
#> GSM22414     1  0.4305      0.328 0.544 0.436 0.000 0.000 0.020 0.000
#> GSM22417     3  0.3096      0.584 0.000 0.004 0.812 0.004 0.008 0.172
#> GSM22418     1  0.0146      0.713 0.996 0.004 0.000 0.000 0.000 0.000
#> GSM22419     1  0.0000      0.712 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM22420     6  0.3974      0.476 0.012 0.212 0.000 0.000 0.032 0.744
#> GSM22421     2  0.4437      0.570 0.092 0.716 0.000 0.004 0.188 0.000
#> GSM22422     5  0.5063      0.549 0.000 0.000 0.112 0.284 0.604 0.000
#> GSM22423     2  0.4203      0.609 0.000 0.764 0.072 0.004 0.148 0.012
#> GSM22424     2  0.1982      0.641 0.020 0.924 0.000 0.004 0.012 0.040
#> GSM22365     1  0.2067      0.687 0.916 0.028 0.000 0.048 0.004 0.004
#> GSM22366     4  0.2339      0.738 0.020 0.072 0.012 0.896 0.000 0.000
#> GSM22367     3  0.3619      0.551 0.000 0.000 0.744 0.024 0.232 0.000
#> GSM22368     5  0.4346      0.527 0.004 0.004 0.364 0.000 0.612 0.016
#> GSM22370     6  0.5051      0.572 0.000 0.076 0.316 0.000 0.008 0.600
#> GSM22371     1  0.2980      0.666 0.808 0.180 0.000 0.000 0.012 0.000
#> GSM22372     5  0.5372      0.581 0.000 0.000 0.160 0.264 0.576 0.000
#> GSM22373     1  0.4736      0.368 0.636 0.304 0.000 0.000 0.012 0.048
#> GSM22375     5  0.4992      0.614 0.000 0.000 0.252 0.016 0.652 0.080
#> GSM22376     3  0.4054      0.646 0.000 0.000 0.760 0.180 0.024 0.036
#> GSM22377     6  0.1867      0.714 0.000 0.000 0.064 0.000 0.020 0.916
#> GSM22378     1  0.3758      0.588 0.700 0.284 0.000 0.000 0.016 0.000
#> GSM22379     3  0.3865      0.684 0.000 0.016 0.808 0.120 0.032 0.024
#> GSM22380     3  0.0964      0.738 0.000 0.000 0.968 0.004 0.012 0.016
#> GSM22383     6  0.4159      0.653 0.000 0.000 0.140 0.000 0.116 0.744
#> GSM22386     3  0.3168      0.700 0.000 0.000 0.828 0.056 0.116 0.000
#> GSM22389     6  0.3966      0.689 0.000 0.020 0.108 0.028 0.036 0.808
#> GSM22391     3  0.3608      0.659 0.000 0.000 0.788 0.064 0.148 0.000
#> GSM22395     6  0.4114      0.556 0.000 0.008 0.356 0.000 0.008 0.628
#> GSM22396     2  0.1643      0.638 0.068 0.924 0.000 0.000 0.000 0.008
#> GSM22398     6  0.5308      0.454 0.000 0.012 0.376 0.000 0.076 0.536
#> GSM22399     4  0.5570      0.434 0.000 0.000 0.136 0.644 0.176 0.044
#> GSM22402     2  0.1932      0.629 0.076 0.912 0.004 0.004 0.000 0.004
#> GSM22407     2  0.5582      0.386 0.240 0.568 0.000 0.004 0.188 0.000
#> GSM22411     5  0.4242      0.402 0.000 0.000 0.448 0.000 0.536 0.016
#> GSM22412     5  0.5229      0.605 0.000 0.000 0.156 0.240 0.604 0.000
#> GSM22415     3  0.1976      0.718 0.000 0.004 0.924 0.032 0.008 0.032
#> GSM22416     1  0.0291      0.713 0.992 0.004 0.000 0.000 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n disease.state(p) k
#> ATC:skmeans 60           0.1069 2
#> ATC:skmeans 45           0.0666 3
#> ATC:skmeans 45           0.2996 4
#> ATC:skmeans 37           0.3336 5
#> ATC:skmeans 44           0.5104 6

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 21446 rows and 60 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.460           0.886       0.923          0.385 0.619   0.619
#> 3 3 0.573           0.666       0.861          0.554 0.714   0.549
#> 4 4 0.599           0.627       0.831          0.117 0.934   0.829
#> 5 5 0.584           0.481       0.716          0.136 0.805   0.480
#> 6 6 0.658           0.600       0.795          0.079 0.833   0.415

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
#> GSM22369     1  0.5408      0.898 0.876 0.124
#> GSM22374     1  0.0376      0.917 0.996 0.004
#> GSM22381     1  0.0376      0.917 0.996 0.004
#> GSM22382     1  0.5408      0.898 0.876 0.124
#> GSM22384     1  0.5408      0.898 0.876 0.124
#> GSM22385     2  0.5408      0.935 0.124 0.876
#> GSM22387     1  0.0376      0.916 0.996 0.004
#> GSM22388     2  0.8267      0.839 0.260 0.740
#> GSM22390     1  0.0376      0.917 0.996 0.004
#> GSM22392     1  0.0376      0.917 0.996 0.004
#> GSM22393     1  0.0376      0.917 0.996 0.004
#> GSM22394     2  0.4815      0.922 0.104 0.896
#> GSM22397     2  0.5408      0.935 0.124 0.876
#> GSM22400     1  0.0376      0.917 0.996 0.004
#> GSM22401     2  0.5408      0.935 0.124 0.876
#> GSM22403     1  0.0376      0.917 0.996 0.004
#> GSM22404     1  0.5408      0.898 0.876 0.124
#> GSM22405     1  0.0376      0.917 0.996 0.004
#> GSM22406     2  0.5408      0.935 0.124 0.876
#> GSM22408     1  0.0376      0.917 0.996 0.004
#> GSM22409     1  0.0376      0.917 0.996 0.004
#> GSM22410     1  0.5408      0.898 0.876 0.124
#> GSM22413     1  0.5408      0.898 0.876 0.124
#> GSM22414     2  0.5408      0.935 0.124 0.876
#> GSM22417     1  0.0376      0.917 0.996 0.004
#> GSM22418     2  0.7815      0.871 0.232 0.768
#> GSM22419     2  0.6438      0.920 0.164 0.836
#> GSM22420     1  0.0376      0.917 0.996 0.004
#> GSM22421     1  0.0376      0.917 0.996 0.004
#> GSM22422     1  0.5408      0.898 0.876 0.124
#> GSM22423     1  0.0376      0.917 0.996 0.004
#> GSM22424     1  0.0376      0.917 0.996 0.004
#> GSM22365     2  0.9087      0.739 0.324 0.676
#> GSM22366     1  0.3733      0.851 0.928 0.072
#> GSM22367     1  0.5408      0.898 0.876 0.124
#> GSM22368     1  0.5408      0.898 0.876 0.124
#> GSM22370     1  0.0376      0.917 0.996 0.004
#> GSM22371     2  0.5408      0.935 0.124 0.876
#> GSM22372     1  0.5408      0.898 0.876 0.124
#> GSM22373     2  0.8909      0.778 0.308 0.692
#> GSM22375     1  0.5408      0.898 0.876 0.124
#> GSM22376     1  0.0376      0.917 0.996 0.004
#> GSM22377     1  0.0376      0.917 0.996 0.004
#> GSM22378     2  0.5408      0.935 0.124 0.876
#> GSM22379     1  0.0376      0.917 0.996 0.004
#> GSM22380     1  0.5408      0.898 0.876 0.124
#> GSM22383     1  0.5408      0.898 0.876 0.124
#> GSM22386     1  0.5408      0.898 0.876 0.124
#> GSM22389     1  0.0376      0.917 0.996 0.004
#> GSM22391     1  0.5408      0.898 0.876 0.124
#> GSM22395     1  0.0376      0.917 0.996 0.004
#> GSM22396     1  0.9922     -0.182 0.552 0.448
#> GSM22398     1  0.5178      0.900 0.884 0.116
#> GSM22399     1  0.5408      0.898 0.876 0.124
#> GSM22402     1  0.0376      0.917 0.996 0.004
#> GSM22407     2  0.7453      0.886 0.212 0.788
#> GSM22411     1  0.5408      0.898 0.876 0.124
#> GSM22412     1  0.5408      0.898 0.876 0.124
#> GSM22415     1  0.0376      0.917 0.996 0.004
#> GSM22416     2  0.5408      0.935 0.124 0.876

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22374     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22381     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22382     3  0.6286     0.4692 0.464 0.000 0.536
#> GSM22384     3  0.6280     0.4745 0.460 0.000 0.540
#> GSM22385     2  0.4605     0.8107 0.204 0.796 0.000
#> GSM22387     1  0.2066     0.7944 0.940 0.000 0.060
#> GSM22388     2  0.6192     0.4951 0.420 0.580 0.000
#> GSM22390     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22392     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22393     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22394     2  0.0000     0.8076 0.000 1.000 0.000
#> GSM22397     2  0.0000     0.8076 0.000 1.000 0.000
#> GSM22400     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22401     2  0.4605     0.8107 0.204 0.796 0.000
#> GSM22403     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22404     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22405     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22406     2  0.5760     0.6850 0.328 0.672 0.000
#> GSM22408     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22409     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22410     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22413     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22414     2  0.2261     0.8222 0.068 0.932 0.000
#> GSM22417     1  0.6286     0.1389 0.536 0.000 0.464
#> GSM22418     2  0.0000     0.8076 0.000 1.000 0.000
#> GSM22419     2  0.0000     0.8076 0.000 1.000 0.000
#> GSM22420     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22421     1  0.4654     0.6325 0.792 0.208 0.000
#> GSM22422     3  0.6008     0.5610 0.372 0.000 0.628
#> GSM22423     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22424     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22365     1  0.5988     0.1474 0.632 0.368 0.000
#> GSM22366     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22367     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22368     3  0.6291     0.4603 0.468 0.000 0.532
#> GSM22370     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22371     2  0.3619     0.8257 0.136 0.864 0.000
#> GSM22372     3  0.6286     0.4692 0.464 0.000 0.536
#> GSM22373     2  0.5948     0.6378 0.360 0.640 0.000
#> GSM22375     1  0.6286    -0.3252 0.536 0.000 0.464
#> GSM22376     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22377     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22378     2  0.4555     0.8127 0.200 0.800 0.000
#> GSM22379     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22380     3  0.5431     0.6185 0.284 0.000 0.716
#> GSM22383     1  0.6295    -0.3489 0.528 0.000 0.472
#> GSM22386     3  0.0237     0.6826 0.004 0.000 0.996
#> GSM22389     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22391     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22395     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22396     1  0.6192    -0.1308 0.580 0.420 0.000
#> GSM22398     1  0.6079    -0.0651 0.612 0.000 0.388
#> GSM22399     3  0.6286     0.4692 0.464 0.000 0.536
#> GSM22402     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22407     2  0.3941     0.7816 0.156 0.844 0.000
#> GSM22411     3  0.0000     0.6837 0.000 0.000 1.000
#> GSM22412     3  0.6286     0.4692 0.464 0.000 0.536
#> GSM22415     1  0.0000     0.8605 1.000 0.000 0.000
#> GSM22416     2  0.0000     0.8076 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
#> GSM22369     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22374     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22381     3   0.488     0.6108 0.272 0.000 0.708 0.020
#> GSM22382     4   0.498     0.4179 0.000 0.000 0.464 0.536
#> GSM22384     4   0.726     0.5089 0.252 0.000 0.208 0.540
#> GSM22385     2   0.000     0.8819 0.000 1.000 0.000 0.000
#> GSM22387     3   0.112     0.7638 0.000 0.000 0.964 0.036
#> GSM22388     1   0.194     0.5238 0.924 0.000 0.076 0.000
#> GSM22390     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22392     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22393     3   0.407     0.6388 0.252 0.000 0.748 0.000
#> GSM22394     1   0.422     0.6849 0.728 0.272 0.000 0.000
#> GSM22397     2   0.000     0.8819 0.000 1.000 0.000 0.000
#> GSM22400     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22401     2   0.164     0.8054 0.000 0.940 0.060 0.000
#> GSM22403     3   0.422     0.6204 0.272 0.000 0.728 0.000
#> GSM22404     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22405     3   0.164     0.7681 0.000 0.060 0.940 0.000
#> GSM22406     2   0.147     0.8411 0.052 0.948 0.000 0.000
#> GSM22408     3   0.407     0.6388 0.252 0.000 0.748 0.000
#> GSM22409     3   0.585     0.5763 0.272 0.000 0.660 0.068
#> GSM22410     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22413     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22414     2   0.000     0.8819 0.000 1.000 0.000 0.000
#> GSM22417     3   0.498     0.1883 0.000 0.000 0.536 0.464
#> GSM22418     1   0.422     0.6849 0.728 0.272 0.000 0.000
#> GSM22419     1   0.422     0.6849 0.728 0.272 0.000 0.000
#> GSM22420     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22421     3   0.460     0.4183 0.000 0.336 0.664 0.000
#> GSM22422     4   0.608     0.5889 0.072 0.000 0.300 0.628
#> GSM22423     3   0.164     0.7681 0.000 0.060 0.940 0.000
#> GSM22424     3   0.164     0.7681 0.000 0.060 0.940 0.000
#> GSM22365     1   0.529     0.2118 0.636 0.020 0.344 0.000
#> GSM22366     3   0.422     0.6204 0.272 0.000 0.728 0.000
#> GSM22367     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22368     4   0.499     0.3888 0.000 0.000 0.476 0.524
#> GSM22370     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22371     2   0.000     0.8819 0.000 1.000 0.000 0.000
#> GSM22372     4   0.498     0.4179 0.000 0.000 0.464 0.536
#> GSM22373     3   0.685     0.1600 0.116 0.344 0.540 0.000
#> GSM22375     3   0.464     0.1385 0.000 0.000 0.656 0.344
#> GSM22376     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22377     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22378     2   0.000     0.8819 0.000 1.000 0.000 0.000
#> GSM22379     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22380     4   0.433     0.6208 0.000 0.000 0.288 0.712
#> GSM22383     3   0.489    -0.0923 0.000 0.000 0.588 0.412
#> GSM22386     4   0.187     0.6335 0.000 0.000 0.072 0.928
#> GSM22389     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22391     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22395     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22396     3   0.462     0.4561 0.000 0.340 0.660 0.000
#> GSM22398     3   0.452     0.2199 0.000 0.000 0.680 0.320
#> GSM22399     4   0.725     0.5076 0.272 0.000 0.192 0.536
#> GSM22402     3   0.164     0.7681 0.000 0.060 0.940 0.000
#> GSM22407     2   0.443     0.3694 0.000 0.696 0.304 0.000
#> GSM22411     4   0.000     0.6730 0.000 0.000 0.000 1.000
#> GSM22412     4   0.498     0.4179 0.000 0.000 0.464 0.536
#> GSM22415     3   0.000     0.7884 0.000 0.000 1.000 0.000
#> GSM22416     1   0.422     0.6849 0.728 0.272 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
#> GSM22369     5  0.0000     0.6792 0.000 0.000 0.000 0.000 1.000
#> GSM22374     3  0.1364     0.5687 0.000 0.036 0.952 0.012 0.000
#> GSM22381     4  0.0865     0.5503 0.000 0.000 0.004 0.972 0.024
#> GSM22382     5  0.6905     0.3354 0.000 0.048 0.316 0.124 0.512
#> GSM22384     5  0.6493     0.3915 0.000 0.016 0.136 0.332 0.516
#> GSM22385     2  0.3628     0.8106 0.216 0.772 0.012 0.000 0.000
#> GSM22387     3  0.0404     0.5730 0.000 0.000 0.988 0.012 0.000
#> GSM22388     1  0.3774     0.5943 0.704 0.000 0.000 0.296 0.000
#> GSM22390     3  0.2179     0.4988 0.000 0.000 0.888 0.112 0.000
#> GSM22392     3  0.5492    -0.2011 0.000 0.068 0.536 0.396 0.000
#> GSM22393     4  0.3039     0.5841 0.000 0.000 0.192 0.808 0.000
#> GSM22394     1  0.0000     0.8863 1.000 0.000 0.000 0.000 0.000
#> GSM22397     2  0.3305     0.8204 0.224 0.776 0.000 0.000 0.000
#> GSM22400     4  0.4473     0.5027 0.000 0.008 0.412 0.580 0.000
#> GSM22401     2  0.4058     0.7462 0.152 0.784 0.000 0.064 0.000
#> GSM22403     4  0.0162     0.5570 0.000 0.000 0.004 0.996 0.000
#> GSM22404     5  0.0000     0.6792 0.000 0.000 0.000 0.000 1.000
#> GSM22405     4  0.5260     0.5063 0.000 0.060 0.348 0.592 0.000
#> GSM22406     2  0.4737     0.7702 0.224 0.708 0.000 0.068 0.000
#> GSM22408     4  0.3209     0.5866 0.000 0.000 0.180 0.812 0.008
#> GSM22409     4  0.0955     0.5479 0.000 0.000 0.004 0.968 0.028
#> GSM22410     5  0.0162     0.6782 0.000 0.000 0.000 0.004 0.996
#> GSM22413     5  0.0000     0.6792 0.000 0.000 0.000 0.000 1.000
#> GSM22414     2  0.3305     0.8204 0.224 0.776 0.000 0.000 0.000
#> GSM22417     5  0.4650    -0.1346 0.000 0.000 0.012 0.468 0.520
#> GSM22418     1  0.0000     0.8863 1.000 0.000 0.000 0.000 0.000
#> GSM22419     1  0.0000     0.8863 1.000 0.000 0.000 0.000 0.000
#> GSM22420     3  0.0912     0.5723 0.000 0.016 0.972 0.012 0.000
#> GSM22421     2  0.6289    -0.1488 0.000 0.536 0.232 0.232 0.000
#> GSM22422     5  0.6608     0.4684 0.000 0.024 0.148 0.288 0.540
#> GSM22423     4  0.5966     0.4077 0.000 0.092 0.364 0.536 0.008
#> GSM22424     3  0.4793     0.4361 0.000 0.260 0.684 0.056 0.000
#> GSM22365     4  0.4722     0.0546 0.368 0.024 0.000 0.608 0.000
#> GSM22366     4  0.1582     0.5537 0.000 0.028 0.028 0.944 0.000
#> GSM22367     5  0.0000     0.6792 0.000 0.000 0.000 0.000 1.000
#> GSM22368     5  0.6825     0.2874 0.000 0.024 0.340 0.156 0.480
#> GSM22370     3  0.0404     0.5730 0.000 0.000 0.988 0.012 0.000
#> GSM22371     2  0.3366     0.8183 0.232 0.768 0.000 0.000 0.000
#> GSM22372     5  0.7028     0.3094 0.000 0.024 0.304 0.204 0.468
#> GSM22373     3  0.5435     0.3208 0.104 0.236 0.656 0.004 0.000
#> GSM22375     3  0.7243    -0.0884 0.000 0.024 0.380 0.236 0.360
#> GSM22376     4  0.5037     0.5063 0.000 0.024 0.352 0.612 0.012
#> GSM22377     3  0.0404     0.5730 0.000 0.000 0.988 0.012 0.000
#> GSM22378     2  0.3366     0.8183 0.232 0.768 0.000 0.000 0.000
#> GSM22379     4  0.4657     0.5169 0.000 0.008 0.380 0.604 0.008
#> GSM22380     5  0.4649     0.5207 0.000 0.004 0.244 0.044 0.708
#> GSM22383     3  0.6917    -0.1192 0.000 0.024 0.428 0.160 0.388
#> GSM22386     5  0.1281     0.6586 0.000 0.000 0.012 0.032 0.956
#> GSM22389     4  0.4464     0.4956 0.000 0.008 0.408 0.584 0.000
#> GSM22391     5  0.0404     0.6757 0.000 0.000 0.000 0.012 0.988
#> GSM22395     3  0.3665     0.3645 0.000 0.008 0.784 0.200 0.008
#> GSM22396     3  0.6771    -0.0708 0.000 0.272 0.368 0.360 0.000
#> GSM22398     3  0.7266    -0.0284 0.000 0.024 0.388 0.248 0.340
#> GSM22399     4  0.6396    -0.3303 0.000 0.012 0.120 0.468 0.400
#> GSM22402     4  0.6014     0.4311 0.000 0.252 0.172 0.576 0.000
#> GSM22407     3  0.4452     0.4369 0.000 0.272 0.696 0.032 0.000
#> GSM22411     5  0.0000     0.6792 0.000 0.000 0.000 0.000 1.000
#> GSM22412     5  0.6825     0.2874 0.000 0.024 0.340 0.156 0.480
#> GSM22415     4  0.5021     0.5091 0.000 0.008 0.380 0.588 0.024
#> GSM22416     1  0.0000     0.8863 1.000 0.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
#> GSM22369     5  0.0146     0.6563 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM22374     6  0.3136     0.7945 0.016 0.000 0.188 0.000 0.000 0.796
#> GSM22381     4  0.1745     0.6642 0.056 0.000 0.020 0.924 0.000 0.000
#> GSM22382     5  0.6545    -0.0669 0.008 0.000 0.344 0.224 0.408 0.016
#> GSM22384     5  0.5934    -0.0601 0.000 0.000 0.216 0.364 0.420 0.000
#> GSM22385     2  0.1049     0.9454 0.008 0.960 0.000 0.000 0.000 0.032
#> GSM22387     6  0.2199     0.8026 0.020 0.000 0.088 0.000 0.000 0.892
#> GSM22388     1  0.3101     0.6526 0.820 0.000 0.032 0.148 0.000 0.000
#> GSM22390     3  0.3993     0.2622 0.008 0.000 0.592 0.000 0.000 0.400
#> GSM22392     6  0.4323     0.6557 0.032 0.000 0.312 0.004 0.000 0.652
#> GSM22393     3  0.3566     0.5400 0.056 0.000 0.788 0.156 0.000 0.000
#> GSM22394     1  0.2793     0.8401 0.800 0.200 0.000 0.000 0.000 0.000
#> GSM22397     2  0.0000     0.9744 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22400     3  0.2163     0.6402 0.008 0.000 0.892 0.004 0.000 0.096
#> GSM22401     2  0.1649     0.9022 0.036 0.932 0.000 0.000 0.000 0.032
#> GSM22403     4  0.3254     0.6368 0.056 0.000 0.124 0.820 0.000 0.000
#> GSM22404     5  0.0146     0.6563 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM22405     3  0.0405     0.6652 0.000 0.000 0.988 0.004 0.000 0.008
#> GSM22406     2  0.0146     0.9719 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM22408     3  0.3455     0.5464 0.056 0.000 0.800 0.144 0.000 0.000
#> GSM22409     4  0.1204     0.6609 0.056 0.000 0.000 0.944 0.000 0.000
#> GSM22410     5  0.0363     0.6546 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM22413     5  0.0146     0.6563 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM22414     2  0.0000     0.9744 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22417     5  0.4616     0.2759 0.008 0.000 0.368 0.000 0.592 0.032
#> GSM22418     1  0.2793     0.8401 0.800 0.200 0.000 0.000 0.000 0.000
#> GSM22419     1  0.2793     0.8401 0.800 0.200 0.000 0.000 0.000 0.000
#> GSM22420     6  0.2883     0.7793 0.000 0.000 0.212 0.000 0.000 0.788
#> GSM22421     3  0.5138     0.5745 0.100 0.132 0.704 0.000 0.000 0.064
#> GSM22422     4  0.4814     0.3321 0.000 0.000 0.100 0.644 0.256 0.000
#> GSM22423     3  0.2436     0.6463 0.032 0.000 0.880 0.000 0.000 0.088
#> GSM22424     6  0.2784     0.7911 0.124 0.000 0.028 0.000 0.000 0.848
#> GSM22365     1  0.5435     0.5217 0.672 0.060 0.124 0.144 0.000 0.000
#> GSM22366     4  0.4484     0.4837 0.056 0.004 0.268 0.672 0.000 0.000
#> GSM22367     5  0.2006     0.5963 0.000 0.000 0.004 0.104 0.892 0.000
#> GSM22368     3  0.5690     0.0835 0.000 0.000 0.452 0.160 0.388 0.000
#> GSM22370     6  0.2147     0.8040 0.020 0.000 0.084 0.000 0.000 0.896
#> GSM22371     2  0.0000     0.9744 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22372     3  0.6024     0.0920 0.000 0.000 0.416 0.256 0.328 0.000
#> GSM22373     6  0.2775     0.7870 0.104 0.040 0.000 0.000 0.000 0.856
#> GSM22375     3  0.2696     0.6332 0.000 0.000 0.856 0.028 0.116 0.000
#> GSM22376     3  0.4761    -0.0143 0.008 0.000 0.492 0.468 0.000 0.032
#> GSM22377     6  0.2199     0.8026 0.020 0.000 0.088 0.000 0.000 0.892
#> GSM22378     2  0.0000     0.9744 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM22379     3  0.0291     0.6652 0.004 0.000 0.992 0.004 0.000 0.000
#> GSM22380     5  0.4099     0.4304 0.008 0.000 0.272 0.000 0.696 0.024
#> GSM22383     3  0.6494     0.3406 0.020 0.000 0.464 0.008 0.292 0.216
#> GSM22386     5  0.3867     0.3706 0.000 0.000 0.012 0.328 0.660 0.000
#> GSM22389     3  0.0622     0.6647 0.000 0.000 0.980 0.008 0.000 0.012
#> GSM22391     5  0.4057     0.2873 0.000 0.000 0.012 0.388 0.600 0.000
#> GSM22395     3  0.3641     0.5716 0.020 0.000 0.732 0.000 0.000 0.248
#> GSM22396     6  0.4264     0.7199 0.124 0.000 0.128 0.004 0.000 0.744
#> GSM22398     3  0.4735     0.6089 0.020 0.000 0.740 0.012 0.104 0.124
#> GSM22399     4  0.5133     0.3503 0.000 0.000 0.000 0.592 0.292 0.116
#> GSM22402     3  0.3968     0.5746 0.124 0.000 0.772 0.004 0.000 0.100
#> GSM22407     6  0.2092     0.7930 0.124 0.000 0.000 0.000 0.000 0.876
#> GSM22411     5  0.0000     0.6543 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM22412     3  0.6058     0.0294 0.000 0.000 0.384 0.260 0.356 0.000
#> GSM22415     3  0.0000     0.6652 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM22416     1  0.2793     0.8401 0.800 0.200 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> ATC:pam 59            0.827 2
#> ATC:pam 47            0.784 3
#> ATC:pam 47            0.639 4
#> ATC:pam 37            0.708 5
#> ATC:pam 45            0.541 6

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 21446 rows and 60 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.514           0.910       0.923         0.3871 0.587   0.587
#> 3 3 0.413           0.825       0.840         0.3437 0.873   0.798
#> 4 4 0.533           0.645       0.782         0.2564 0.785   0.615
#> 5 5 0.480           0.500       0.712         0.1364 0.747   0.416
#> 6 6 0.611           0.643       0.755         0.0813 0.909   0.653

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
#> GSM22369     1   0.000      0.950 1.000 0.000
#> GSM22374     1   0.000      0.950 1.000 0.000
#> GSM22381     1   0.000      0.950 1.000 0.000
#> GSM22382     1   0.000      0.950 1.000 0.000
#> GSM22384     1   0.000      0.950 1.000 0.000
#> GSM22385     2   0.653      0.966 0.168 0.832
#> GSM22387     1   0.653      0.804 0.832 0.168
#> GSM22388     2   0.653      0.966 0.168 0.832
#> GSM22390     1   0.653      0.804 0.832 0.168
#> GSM22392     1   0.788      0.648 0.764 0.236
#> GSM22393     1   0.000      0.950 1.000 0.000
#> GSM22394     2   0.653      0.966 0.168 0.832
#> GSM22397     2   0.653      0.966 0.168 0.832
#> GSM22400     1   0.000      0.950 1.000 0.000
#> GSM22401     2   0.653      0.966 0.168 0.832
#> GSM22403     1   0.000      0.950 1.000 0.000
#> GSM22404     1   0.000      0.950 1.000 0.000
#> GSM22405     1   0.163      0.934 0.976 0.024
#> GSM22406     2   0.653      0.966 0.168 0.832
#> GSM22408     1   0.000      0.950 1.000 0.000
#> GSM22409     1   0.000      0.950 1.000 0.000
#> GSM22410     1   0.000      0.950 1.000 0.000
#> GSM22413     1   0.000      0.950 1.000 0.000
#> GSM22414     2   0.653      0.966 0.168 0.832
#> GSM22417     1   0.000      0.950 1.000 0.000
#> GSM22418     2   0.653      0.966 0.168 0.832
#> GSM22419     2   0.653      0.966 0.168 0.832
#> GSM22420     1   0.625      0.815 0.844 0.156
#> GSM22421     1   0.839      0.532 0.732 0.268
#> GSM22422     1   0.000      0.950 1.000 0.000
#> GSM22423     1   0.000      0.950 1.000 0.000
#> GSM22424     2   0.936      0.537 0.352 0.648
#> GSM22365     2   0.653      0.966 0.168 0.832
#> GSM22366     1   0.000      0.950 1.000 0.000
#> GSM22367     1   0.000      0.950 1.000 0.000
#> GSM22368     1   0.000      0.950 1.000 0.000
#> GSM22370     1   0.653      0.804 0.832 0.168
#> GSM22371     2   0.653      0.966 0.168 0.832
#> GSM22372     1   0.000      0.950 1.000 0.000
#> GSM22373     2   0.584      0.940 0.140 0.860
#> GSM22375     1   0.000      0.950 1.000 0.000
#> GSM22376     1   0.000      0.950 1.000 0.000
#> GSM22377     1   0.242      0.923 0.960 0.040
#> GSM22378     2   0.653      0.966 0.168 0.832
#> GSM22379     1   0.000      0.950 1.000 0.000
#> GSM22380     1   0.000      0.950 1.000 0.000
#> GSM22383     1   0.118      0.939 0.984 0.016
#> GSM22386     1   0.000      0.950 1.000 0.000
#> GSM22389     1   0.141      0.937 0.980 0.020
#> GSM22391     1   0.000      0.950 1.000 0.000
#> GSM22395     1   0.653      0.804 0.832 0.168
#> GSM22396     2   0.118      0.817 0.016 0.984
#> GSM22398     1   0.163      0.934 0.976 0.024
#> GSM22399     1   0.000      0.950 1.000 0.000
#> GSM22402     1   0.909      0.437 0.676 0.324
#> GSM22407     2   0.653      0.966 0.168 0.832
#> GSM22411     1   0.000      0.950 1.000 0.000
#> GSM22412     1   0.000      0.950 1.000 0.000
#> GSM22415     1   0.000      0.950 1.000 0.000
#> GSM22416     2   0.653      0.966 0.168 0.832

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     1  0.5529     0.7447 0.704 0.000 0.296
#> GSM22374     1  0.6393     0.7882 0.764 0.088 0.148
#> GSM22381     1  0.4551     0.8734 0.844 0.132 0.024
#> GSM22382     1  0.4206     0.8841 0.872 0.088 0.040
#> GSM22384     1  0.4075     0.8871 0.880 0.072 0.048
#> GSM22385     2  0.4342     0.8364 0.024 0.856 0.120
#> GSM22387     1  0.2165     0.8758 0.936 0.000 0.064
#> GSM22388     2  0.2743     0.8413 0.020 0.928 0.052
#> GSM22390     1  0.2165     0.8758 0.936 0.000 0.064
#> GSM22392     2  0.7988     0.6749 0.200 0.656 0.144
#> GSM22393     1  0.4677     0.8686 0.840 0.132 0.028
#> GSM22394     2  0.7832     0.6466 0.052 0.496 0.452
#> GSM22397     2  0.0475     0.8433 0.004 0.992 0.004
#> GSM22400     1  0.4349     0.8705 0.852 0.128 0.020
#> GSM22401     2  0.3009     0.8384 0.052 0.920 0.028
#> GSM22403     1  0.4665     0.8716 0.852 0.100 0.048
#> GSM22404     1  0.5517     0.7703 0.728 0.004 0.268
#> GSM22405     1  0.3234     0.8870 0.908 0.072 0.020
#> GSM22406     2  0.1315     0.8441 0.020 0.972 0.008
#> GSM22408     1  0.3965     0.8745 0.860 0.132 0.008
#> GSM22409     1  0.5449     0.8528 0.816 0.116 0.068
#> GSM22410     1  0.3983     0.8684 0.852 0.004 0.144
#> GSM22413     1  0.3349     0.8807 0.888 0.004 0.108
#> GSM22414     2  0.0661     0.8427 0.004 0.988 0.008
#> GSM22417     1  0.1453     0.8882 0.968 0.008 0.024
#> GSM22418     2  0.6252     0.7570 0.024 0.708 0.268
#> GSM22419     2  0.7029     0.6650 0.020 0.540 0.440
#> GSM22420     1  0.4413     0.8063 0.832 0.008 0.160
#> GSM22421     2  0.7980     0.7245 0.168 0.660 0.172
#> GSM22422     1  0.4179     0.8870 0.876 0.072 0.052
#> GSM22423     1  0.3973     0.8838 0.880 0.088 0.032
#> GSM22424     2  0.5634     0.8210 0.056 0.800 0.144
#> GSM22365     2  0.1774     0.8450 0.024 0.960 0.016
#> GSM22366     2  0.8185     0.0679 0.428 0.500 0.072
#> GSM22367     1  0.5529     0.7447 0.704 0.000 0.296
#> GSM22368     1  0.3207     0.8866 0.904 0.084 0.012
#> GSM22370     1  0.2165     0.8758 0.936 0.000 0.064
#> GSM22371     2  0.0475     0.8433 0.004 0.992 0.004
#> GSM22372     1  0.3850     0.8844 0.884 0.088 0.028
#> GSM22373     2  0.4342     0.8364 0.024 0.856 0.120
#> GSM22375     1  0.3043     0.8892 0.908 0.084 0.008
#> GSM22376     1  0.1267     0.8871 0.972 0.004 0.024
#> GSM22377     1  0.2066     0.8767 0.940 0.000 0.060
#> GSM22378     2  0.0475     0.8433 0.004 0.992 0.004
#> GSM22379     1  0.1267     0.8871 0.972 0.004 0.024
#> GSM22380     1  0.0592     0.8910 0.988 0.000 0.012
#> GSM22383     1  0.1267     0.8871 0.972 0.004 0.024
#> GSM22386     1  0.6933     0.8004 0.716 0.076 0.208
#> GSM22389     1  0.2116     0.8860 0.948 0.012 0.040
#> GSM22391     1  0.6437     0.7882 0.732 0.048 0.220
#> GSM22395     1  0.2066     0.8767 0.940 0.000 0.060
#> GSM22396     2  0.4982     0.8293 0.036 0.828 0.136
#> GSM22398     1  0.1525     0.8856 0.964 0.004 0.032
#> GSM22399     1  0.3889     0.8869 0.884 0.084 0.032
#> GSM22402     2  0.6332     0.7982 0.088 0.768 0.144
#> GSM22407     2  0.5435     0.8273 0.048 0.808 0.144
#> GSM22411     1  0.3619     0.8710 0.864 0.000 0.136
#> GSM22412     1  0.3850     0.8844 0.884 0.088 0.028
#> GSM22415     1  0.1453     0.8882 0.968 0.008 0.024
#> GSM22416     2  0.6476     0.6594 0.004 0.548 0.448

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3  0.1284      0.806 0.000 0.024 0.964 0.012
#> GSM22374     2  0.4008      0.515 0.000 0.756 0.244 0.000
#> GSM22381     3  0.5434      0.559 0.000 0.052 0.696 0.252
#> GSM22382     3  0.4436      0.768 0.000 0.148 0.800 0.052
#> GSM22384     3  0.1716      0.799 0.000 0.000 0.936 0.064
#> GSM22385     1  0.4967     -0.382 0.548 0.452 0.000 0.000
#> GSM22387     3  0.4697      0.689 0.000 0.356 0.644 0.000
#> GSM22388     4  0.5047      0.571 0.356 0.004 0.004 0.636
#> GSM22390     3  0.4697      0.689 0.000 0.356 0.644 0.000
#> GSM22392     2  0.4199      0.588 0.164 0.804 0.032 0.000
#> GSM22393     3  0.7824      0.242 0.000 0.260 0.392 0.348
#> GSM22394     1  0.7261      0.480 0.480 0.152 0.000 0.368
#> GSM22397     1  0.0000      0.619 1.000 0.000 0.000 0.000
#> GSM22400     3  0.4776      0.642 0.000 0.376 0.624 0.000
#> GSM22401     1  0.1902      0.589 0.932 0.000 0.004 0.064
#> GSM22403     4  0.5343      0.527 0.000 0.028 0.316 0.656
#> GSM22404     3  0.0188      0.817 0.000 0.004 0.996 0.000
#> GSM22405     2  0.3569      0.529 0.000 0.804 0.196 0.000
#> GSM22406     4  0.5126      0.442 0.444 0.000 0.004 0.552
#> GSM22408     3  0.5111      0.784 0.000 0.204 0.740 0.056
#> GSM22409     4  0.4543      0.528 0.000 0.000 0.324 0.676
#> GSM22410     3  0.0469      0.817 0.000 0.000 0.988 0.012
#> GSM22413     3  0.0000      0.817 0.000 0.000 1.000 0.000
#> GSM22414     1  0.0000      0.619 1.000 0.000 0.000 0.000
#> GSM22417     3  0.2760      0.826 0.000 0.128 0.872 0.000
#> GSM22418     1  0.6731      0.553 0.604 0.148 0.000 0.248
#> GSM22419     1  0.6912      0.538 0.576 0.152 0.000 0.272
#> GSM22420     2  0.3528      0.532 0.000 0.808 0.192 0.000
#> GSM22421     2  0.6926      0.518 0.388 0.532 0.044 0.036
#> GSM22422     3  0.1792      0.797 0.000 0.000 0.932 0.068
#> GSM22423     2  0.4331      0.463 0.000 0.712 0.288 0.000
#> GSM22424     2  0.4761      0.580 0.332 0.664 0.004 0.000
#> GSM22365     4  0.6356      0.457 0.432 0.052 0.004 0.512
#> GSM22366     4  0.6435      0.607 0.244 0.064 0.028 0.664
#> GSM22367     3  0.1624      0.798 0.000 0.028 0.952 0.020
#> GSM22368     3  0.2704      0.823 0.000 0.124 0.876 0.000
#> GSM22370     3  0.4697      0.689 0.000 0.356 0.644 0.000
#> GSM22371     1  0.0000      0.619 1.000 0.000 0.000 0.000
#> GSM22372     3  0.0336      0.816 0.000 0.000 0.992 0.008
#> GSM22373     2  0.4920      0.567 0.368 0.628 0.004 0.000
#> GSM22375     3  0.1792      0.832 0.000 0.068 0.932 0.000
#> GSM22376     3  0.2469      0.829 0.000 0.108 0.892 0.000
#> GSM22377     3  0.4697      0.689 0.000 0.356 0.644 0.000
#> GSM22378     1  0.0000      0.619 1.000 0.000 0.000 0.000
#> GSM22379     3  0.2868      0.823 0.000 0.136 0.864 0.000
#> GSM22380     3  0.1637      0.830 0.000 0.060 0.940 0.000
#> GSM22383     3  0.3873      0.783 0.000 0.228 0.772 0.000
#> GSM22386     3  0.2011      0.818 0.000 0.080 0.920 0.000
#> GSM22389     3  0.4304      0.743 0.000 0.284 0.716 0.000
#> GSM22391     3  0.1256      0.803 0.000 0.028 0.964 0.008
#> GSM22395     3  0.4661      0.697 0.000 0.348 0.652 0.000
#> GSM22396     2  0.5088      0.521 0.424 0.572 0.004 0.000
#> GSM22398     3  0.4222      0.762 0.000 0.272 0.728 0.000
#> GSM22399     3  0.1557      0.803 0.000 0.000 0.944 0.056
#> GSM22402     2  0.5088      0.521 0.424 0.572 0.004 0.000
#> GSM22407     2  0.6381      0.381 0.472 0.472 0.004 0.052
#> GSM22411     3  0.0469      0.817 0.000 0.000 0.988 0.012
#> GSM22412     3  0.0188      0.819 0.000 0.004 0.996 0.000
#> GSM22415     3  0.2921      0.823 0.000 0.140 0.860 0.000
#> GSM22416     1  0.6844      0.543 0.588 0.152 0.000 0.260

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.2068     0.7214 0.092 0.000 0.000 0.004 0.904
#> GSM22374     3  0.1788     0.5778 0.008 0.004 0.932 0.000 0.056
#> GSM22381     4  0.4440     0.0618 0.000 0.004 0.000 0.528 0.468
#> GSM22382     3  0.7522     0.2112 0.160 0.004 0.444 0.060 0.332
#> GSM22384     5  0.5459     0.6366 0.040 0.000 0.140 0.104 0.716
#> GSM22385     2  0.1908     0.6274 0.000 0.908 0.092 0.000 0.000
#> GSM22387     3  0.3039     0.5679 0.000 0.000 0.808 0.000 0.192
#> GSM22388     4  0.3796     0.4645 0.000 0.300 0.000 0.700 0.000
#> GSM22390     3  0.3109     0.5704 0.000 0.000 0.800 0.000 0.200
#> GSM22392     3  0.3527     0.3836 0.024 0.172 0.804 0.000 0.000
#> GSM22393     4  0.6670     0.1085 0.000 0.004 0.256 0.480 0.260
#> GSM22394     1  0.4430     0.9071 0.708 0.256 0.000 0.036 0.000
#> GSM22397     2  0.0510     0.6461 0.016 0.984 0.000 0.000 0.000
#> GSM22400     3  0.4299     0.4178 0.000 0.004 0.608 0.000 0.388
#> GSM22401     2  0.7322     0.2599 0.176 0.464 0.052 0.308 0.000
#> GSM22403     4  0.1608     0.6061 0.000 0.000 0.000 0.928 0.072
#> GSM22404     5  0.1952     0.7259 0.084 0.000 0.000 0.004 0.912
#> GSM22405     3  0.3790     0.4838 0.000 0.004 0.724 0.000 0.272
#> GSM22406     4  0.3177     0.5215 0.000 0.208 0.000 0.792 0.000
#> GSM22408     5  0.5191     0.5074 0.000 0.000 0.124 0.192 0.684
#> GSM22409     4  0.0404     0.6000 0.000 0.000 0.000 0.988 0.012
#> GSM22410     5  0.1124     0.7356 0.036 0.004 0.000 0.000 0.960
#> GSM22413     5  0.3868     0.6654 0.000 0.000 0.140 0.060 0.800
#> GSM22414     2  0.0671     0.6471 0.016 0.980 0.004 0.000 0.000
#> GSM22417     5  0.2813     0.6189 0.000 0.000 0.168 0.000 0.832
#> GSM22418     1  0.4327     0.8957 0.632 0.360 0.008 0.000 0.000
#> GSM22419     1  0.4360     0.9373 0.680 0.300 0.000 0.020 0.000
#> GSM22420     3  0.1282     0.5578 0.000 0.004 0.952 0.000 0.044
#> GSM22421     3  0.7545    -0.1123 0.180 0.340 0.432 0.016 0.032
#> GSM22422     5  0.5277     0.5924 0.040 0.000 0.040 0.228 0.692
#> GSM22423     3  0.5867     0.3435 0.088 0.008 0.560 0.000 0.344
#> GSM22424     3  0.4897    -0.2911 0.024 0.460 0.516 0.000 0.000
#> GSM22365     4  0.4594     0.0833 0.000 0.484 0.004 0.508 0.004
#> GSM22366     4  0.1877     0.6148 0.000 0.064 0.000 0.924 0.012
#> GSM22367     5  0.2597     0.7232 0.092 0.000 0.000 0.024 0.884
#> GSM22368     3  0.4596     0.0367 0.000 0.004 0.496 0.004 0.496
#> GSM22370     3  0.3999     0.5044 0.000 0.000 0.656 0.000 0.344
#> GSM22371     2  0.0510     0.6461 0.016 0.984 0.000 0.000 0.000
#> GSM22372     5  0.4360     0.6580 0.000 0.000 0.064 0.184 0.752
#> GSM22373     3  0.4882    -0.2308 0.024 0.444 0.532 0.000 0.000
#> GSM22375     5  0.4929     0.5314 0.000 0.004 0.292 0.044 0.660
#> GSM22376     5  0.3452     0.5096 0.000 0.000 0.244 0.000 0.756
#> GSM22377     3  0.3143     0.5710 0.000 0.000 0.796 0.000 0.204
#> GSM22378     2  0.0510     0.6461 0.016 0.984 0.000 0.000 0.000
#> GSM22379     5  0.3612     0.4546 0.000 0.000 0.268 0.000 0.732
#> GSM22380     5  0.2424     0.6688 0.000 0.000 0.132 0.000 0.868
#> GSM22383     3  0.3816     0.4462 0.000 0.000 0.696 0.000 0.304
#> GSM22386     5  0.2396     0.7235 0.084 0.004 0.008 0.004 0.900
#> GSM22389     3  0.4114     0.4714 0.000 0.000 0.624 0.000 0.376
#> GSM22391     5  0.2452     0.7254 0.084 0.004 0.000 0.016 0.896
#> GSM22395     3  0.3480     0.5642 0.000 0.000 0.752 0.000 0.248
#> GSM22396     2  0.4905     0.2572 0.024 0.500 0.476 0.000 0.000
#> GSM22398     3  0.4219     0.3822 0.000 0.000 0.584 0.000 0.416
#> GSM22399     5  0.2286     0.7285 0.004 0.000 0.000 0.108 0.888
#> GSM22402     3  0.5292    -0.0527 0.024 0.416 0.544 0.000 0.016
#> GSM22407     2  0.6650     0.3285 0.280 0.448 0.272 0.000 0.000
#> GSM22411     5  0.4679     0.6062 0.004 0.004 0.200 0.056 0.736
#> GSM22412     5  0.3780     0.6985 0.000 0.000 0.132 0.060 0.808
#> GSM22415     5  0.3242     0.5590 0.000 0.000 0.216 0.000 0.784
#> GSM22416     1  0.3895     0.9343 0.680 0.320 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
#> GSM22369     3  0.2597      0.689 0.000 0.000 0.824 0.000 0.176 0.000
#> GSM22374     6  0.1844      0.788 0.000 0.024 0.048 0.000 0.004 0.924
#> GSM22381     4  0.4057      0.272 0.000 0.000 0.388 0.600 0.012 0.000
#> GSM22382     6  0.6059      0.545 0.000 0.056 0.248 0.000 0.124 0.572
#> GSM22384     5  0.2531      0.744 0.000 0.000 0.132 0.012 0.856 0.000
#> GSM22385     2  0.1562      0.649 0.032 0.940 0.000 0.000 0.004 0.024
#> GSM22387     6  0.1003      0.805 0.000 0.000 0.020 0.000 0.016 0.964
#> GSM22388     4  0.2848      0.648 0.008 0.160 0.004 0.828 0.000 0.000
#> GSM22390     6  0.0909      0.805 0.000 0.000 0.020 0.000 0.012 0.968
#> GSM22392     6  0.3221      0.589 0.000 0.264 0.000 0.000 0.000 0.736
#> GSM22393     4  0.5494      0.337 0.000 0.000 0.104 0.588 0.020 0.288
#> GSM22394     1  0.1226      0.891 0.952 0.004 0.004 0.040 0.000 0.000
#> GSM22397     2  0.3489      0.601 0.288 0.708 0.000 0.000 0.004 0.000
#> GSM22400     6  0.3269      0.759 0.000 0.008 0.108 0.000 0.052 0.832
#> GSM22401     4  0.7505     -0.121 0.112 0.328 0.132 0.400 0.000 0.028
#> GSM22403     4  0.0146      0.689 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM22404     3  0.2562      0.680 0.000 0.000 0.828 0.000 0.172 0.000
#> GSM22405     6  0.2895      0.785 0.000 0.016 0.064 0.000 0.052 0.868
#> GSM22406     4  0.2340      0.580 0.148 0.000 0.000 0.852 0.000 0.000
#> GSM22408     3  0.5506      0.559 0.000 0.000 0.664 0.148 0.060 0.128
#> GSM22409     4  0.0260      0.689 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM22410     3  0.2597      0.689 0.000 0.000 0.824 0.000 0.176 0.000
#> GSM22413     5  0.3955      0.514 0.000 0.000 0.384 0.000 0.608 0.008
#> GSM22414     2  0.3489      0.601 0.288 0.708 0.000 0.000 0.004 0.000
#> GSM22417     3  0.3276      0.708 0.000 0.000 0.816 0.000 0.052 0.132
#> GSM22418     1  0.2982      0.732 0.828 0.152 0.000 0.008 0.000 0.012
#> GSM22419     1  0.0713      0.902 0.972 0.000 0.000 0.028 0.000 0.000
#> GSM22420     6  0.0603      0.803 0.000 0.016 0.000 0.000 0.004 0.980
#> GSM22421     6  0.6720      0.400 0.000 0.268 0.148 0.092 0.000 0.492
#> GSM22422     5  0.2901      0.692 0.000 0.000 0.032 0.128 0.840 0.000
#> GSM22423     6  0.4565      0.678 0.000 0.052 0.256 0.012 0.000 0.680
#> GSM22424     2  0.4313      0.486 0.000 0.668 0.000 0.000 0.048 0.284
#> GSM22365     4  0.3593      0.620 0.000 0.208 0.024 0.764 0.000 0.004
#> GSM22366     4  0.0146      0.689 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM22367     3  0.2631      0.686 0.000 0.000 0.820 0.000 0.180 0.000
#> GSM22368     6  0.4831      0.565 0.000 0.000 0.164 0.000 0.168 0.668
#> GSM22370     6  0.2001      0.800 0.000 0.000 0.040 0.000 0.048 0.912
#> GSM22371     2  0.3489      0.601 0.288 0.708 0.000 0.000 0.004 0.000
#> GSM22372     5  0.3142      0.717 0.000 0.000 0.044 0.108 0.840 0.008
#> GSM22373     2  0.2964      0.610 0.004 0.792 0.000 0.000 0.000 0.204
#> GSM22375     5  0.4834      0.522 0.000 0.000 0.104 0.000 0.644 0.252
#> GSM22376     3  0.3499      0.584 0.000 0.000 0.680 0.000 0.000 0.320
#> GSM22377     6  0.0909      0.805 0.000 0.000 0.020 0.000 0.012 0.968
#> GSM22378     2  0.3489      0.601 0.288 0.708 0.000 0.000 0.004 0.000
#> GSM22379     3  0.3823      0.312 0.000 0.000 0.564 0.000 0.000 0.436
#> GSM22380     3  0.4085      0.674 0.000 0.000 0.716 0.000 0.052 0.232
#> GSM22383     6  0.2629      0.763 0.000 0.000 0.068 0.000 0.060 0.872
#> GSM22386     3  0.2178      0.731 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM22389     6  0.2328      0.797 0.000 0.000 0.056 0.000 0.052 0.892
#> GSM22391     3  0.2454      0.688 0.000 0.000 0.840 0.000 0.160 0.000
#> GSM22395     6  0.1285      0.797 0.000 0.000 0.052 0.000 0.004 0.944
#> GSM22396     2  0.3370      0.620 0.000 0.804 0.000 0.000 0.048 0.148
#> GSM22398     6  0.2786      0.777 0.000 0.000 0.084 0.000 0.056 0.860
#> GSM22399     5  0.3027      0.740 0.000 0.000 0.148 0.028 0.824 0.000
#> GSM22402     6  0.4177      0.286 0.000 0.468 0.012 0.000 0.000 0.520
#> GSM22407     2  0.5487      0.557 0.072 0.696 0.132 0.000 0.016 0.084
#> GSM22411     5  0.4173      0.568 0.000 0.000 0.268 0.000 0.688 0.044
#> GSM22412     5  0.4599      0.645 0.000 0.000 0.140 0.000 0.696 0.164
#> GSM22415     3  0.2340      0.730 0.000 0.000 0.852 0.000 0.000 0.148
#> GSM22416     1  0.0000      0.895 1.000 0.000 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-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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:mclust 59            0.872 2
#> ATC:mclust 59            0.719 3
#> ATC:mclust 53            0.307 4
#> ATC:mclust 39            0.627 5
#> ATC:mclust 53            0.702 6

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 21446 rows and 60 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.380           0.747       0.867         0.5001 0.492   0.492
#> 3 3 0.456           0.649       0.830         0.3226 0.656   0.410
#> 4 4 0.424           0.481       0.721         0.1228 0.851   0.589
#> 5 5 0.539           0.471       0.722         0.0711 0.808   0.393
#> 6 6 0.567           0.426       0.665         0.0424 0.879   0.489

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
#> GSM22369     1  0.0672     0.8376 0.992 0.008
#> GSM22374     2  0.0000     0.8078 0.000 1.000
#> GSM22381     1  0.3733     0.7936 0.928 0.072
#> GSM22382     2  0.0672     0.8091 0.008 0.992
#> GSM22384     1  0.7376     0.6064 0.792 0.208
#> GSM22385     2  0.0000     0.8078 0.000 1.000
#> GSM22387     1  0.7376     0.7848 0.792 0.208
#> GSM22388     2  0.7376     0.7909 0.208 0.792
#> GSM22390     1  0.7815     0.7715 0.768 0.232
#> GSM22392     2  0.0000     0.8078 0.000 1.000
#> GSM22393     2  0.9522     0.6191 0.372 0.628
#> GSM22394     2  0.7376     0.7909 0.208 0.792
#> GSM22397     2  0.6148     0.8049 0.152 0.848
#> GSM22400     2  0.9850     0.4858 0.428 0.572
#> GSM22401     2  0.7376     0.7909 0.208 0.792
#> GSM22403     1  0.9775    -0.0462 0.588 0.412
#> GSM22404     1  0.0000     0.8348 1.000 0.000
#> GSM22405     2  0.7299     0.6112 0.204 0.796
#> GSM22406     2  0.7376     0.7909 0.208 0.792
#> GSM22408     1  0.0000     0.8348 1.000 0.000
#> GSM22409     1  0.6712     0.6659 0.824 0.176
#> GSM22410     1  0.7376     0.7848 0.792 0.208
#> GSM22413     1  0.0938     0.8385 0.988 0.012
#> GSM22414     2  0.1184     0.8098 0.016 0.984
#> GSM22417     1  0.7376     0.7848 0.792 0.208
#> GSM22418     2  0.7219     0.7942 0.200 0.800
#> GSM22419     2  0.7376     0.7909 0.208 0.792
#> GSM22420     2  0.0000     0.8078 0.000 1.000
#> GSM22421     2  0.0000     0.8078 0.000 1.000
#> GSM22422     1  0.2236     0.8208 0.964 0.036
#> GSM22423     2  0.7056     0.6303 0.192 0.808
#> GSM22424     2  0.0000     0.8078 0.000 1.000
#> GSM22365     2  0.7376     0.7909 0.208 0.792
#> GSM22366     2  0.8443     0.7457 0.272 0.728
#> GSM22367     1  0.1414     0.8384 0.980 0.020
#> GSM22368     2  0.8909     0.4487 0.308 0.692
#> GSM22370     1  0.8207     0.7532 0.744 0.256
#> GSM22371     2  0.6887     0.7989 0.184 0.816
#> GSM22372     1  0.1414     0.8291 0.980 0.020
#> GSM22373     2  0.0000     0.8078 0.000 1.000
#> GSM22375     1  0.3274     0.8146 0.940 0.060
#> GSM22376     1  0.0938     0.8384 0.988 0.012
#> GSM22377     1  0.7376     0.7848 0.792 0.208
#> GSM22378     2  0.7376     0.7909 0.208 0.792
#> GSM22379     1  0.0938     0.8384 0.988 0.012
#> GSM22380     1  0.7376     0.7848 0.792 0.208
#> GSM22383     1  0.7376     0.7848 0.792 0.208
#> GSM22386     1  0.0000     0.8348 1.000 0.000
#> GSM22389     2  0.9881    -0.0916 0.436 0.564
#> GSM22391     1  0.0000     0.8348 1.000 0.000
#> GSM22395     1  0.7376     0.7848 0.792 0.208
#> GSM22396     2  0.0000     0.8078 0.000 1.000
#> GSM22398     1  0.7376     0.7848 0.792 0.208
#> GSM22399     1  0.0376     0.8342 0.996 0.004
#> GSM22402     2  0.0000     0.8078 0.000 1.000
#> GSM22407     2  0.0000     0.8078 0.000 1.000
#> GSM22411     1  0.7376     0.7848 0.792 0.208
#> GSM22412     1  0.6623     0.6722 0.828 0.172
#> GSM22415     1  0.0672     0.8376 0.992 0.008
#> GSM22416     2  0.7219     0.7942 0.200 0.800

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM22369     3  0.0592   0.828579 0.012 0.000 0.988
#> GSM22374     2  0.0592   0.792017 0.012 0.988 0.000
#> GSM22381     1  0.6476   0.109068 0.548 0.004 0.448
#> GSM22382     2  0.6274   0.302903 0.456 0.544 0.000
#> GSM22384     1  0.0747   0.752846 0.984 0.000 0.016
#> GSM22385     2  0.0000   0.791886 0.000 1.000 0.000
#> GSM22387     2  0.8206   0.000213 0.072 0.480 0.448
#> GSM22388     1  0.2878   0.766477 0.904 0.096 0.000
#> GSM22390     2  0.6832   0.393009 0.020 0.604 0.376
#> GSM22392     2  0.0424   0.791908 0.008 0.992 0.000
#> GSM22393     1  0.4121   0.762456 0.876 0.040 0.084
#> GSM22394     1  0.1753   0.769163 0.952 0.048 0.000
#> GSM22397     2  0.2959   0.721637 0.100 0.900 0.000
#> GSM22400     2  0.7531   0.505462 0.236 0.672 0.092
#> GSM22401     1  0.5431   0.650964 0.716 0.284 0.000
#> GSM22403     1  0.5874   0.674786 0.760 0.032 0.208
#> GSM22404     3  0.0892   0.828337 0.020 0.000 0.980
#> GSM22405     2  0.2448   0.773180 0.000 0.924 0.076
#> GSM22406     1  0.4121   0.745620 0.832 0.168 0.000
#> GSM22408     3  0.4605   0.674813 0.204 0.000 0.796
#> GSM22409     1  0.2496   0.744100 0.928 0.004 0.068
#> GSM22410     3  0.0000   0.826217 0.000 0.000 1.000
#> GSM22413     3  0.3192   0.797767 0.112 0.000 0.888
#> GSM22414     2  0.0892   0.787672 0.020 0.980 0.000
#> GSM22417     3  0.1529   0.818230 0.000 0.040 0.960
#> GSM22418     1  0.5621   0.571438 0.692 0.308 0.000
#> GSM22419     1  0.3482   0.758815 0.872 0.128 0.000
#> GSM22420     2  0.0592   0.792017 0.012 0.988 0.000
#> GSM22421     2  0.0000   0.791886 0.000 1.000 0.000
#> GSM22422     1  0.1643   0.743814 0.956 0.000 0.044
#> GSM22423     2  0.2651   0.775784 0.012 0.928 0.060
#> GSM22424     2  0.0592   0.791277 0.000 0.988 0.012
#> GSM22365     1  0.4750   0.713480 0.784 0.216 0.000
#> GSM22366     1  0.6698   0.615949 0.684 0.280 0.036
#> GSM22367     3  0.2537   0.814579 0.080 0.000 0.920
#> GSM22368     2  0.8994   0.397936 0.184 0.556 0.260
#> GSM22370     2  0.4178   0.718680 0.000 0.828 0.172
#> GSM22371     2  0.4654   0.603983 0.208 0.792 0.000
#> GSM22372     1  0.5882   0.333441 0.652 0.000 0.348
#> GSM22373     2  0.0892   0.787343 0.020 0.980 0.000
#> GSM22375     3  0.6260   0.332029 0.448 0.000 0.552
#> GSM22376     3  0.4931   0.665945 0.212 0.004 0.784
#> GSM22377     3  0.6247   0.665883 0.044 0.212 0.744
#> GSM22378     2  0.6140   0.075588 0.404 0.596 0.000
#> GSM22379     3  0.0592   0.826997 0.012 0.000 0.988
#> GSM22380     3  0.0424   0.826837 0.000 0.008 0.992
#> GSM22383     3  0.6107   0.763282 0.100 0.116 0.784
#> GSM22386     3  0.1163   0.829477 0.028 0.000 0.972
#> GSM22389     2  0.4883   0.684185 0.004 0.788 0.208
#> GSM22391     3  0.2878   0.810382 0.096 0.000 0.904
#> GSM22395     3  0.6608   0.107173 0.008 0.432 0.560
#> GSM22396     2  0.0000   0.791886 0.000 1.000 0.000
#> GSM22398     2  0.6192   0.322834 0.000 0.580 0.420
#> GSM22399     1  0.6192   0.083712 0.580 0.000 0.420
#> GSM22402     2  0.0000   0.791886 0.000 1.000 0.000
#> GSM22407     2  0.3340   0.731091 0.120 0.880 0.000
#> GSM22411     3  0.3192   0.801150 0.112 0.000 0.888
#> GSM22412     1  0.4002   0.658631 0.840 0.000 0.160
#> GSM22415     3  0.5414   0.660102 0.212 0.016 0.772
#> GSM22416     1  0.4702   0.710046 0.788 0.212 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM22369     3  0.3257    0.59873 0.004 0.000 0.844 0.152
#> GSM22374     2  0.4140    0.71481 0.004 0.812 0.024 0.160
#> GSM22381     1  0.5746    0.17307 0.572 0.000 0.396 0.032
#> GSM22382     4  0.5563    0.41221 0.196 0.076 0.004 0.724
#> GSM22384     4  0.3306    0.47555 0.156 0.000 0.004 0.840
#> GSM22385     2  0.2670    0.76196 0.072 0.904 0.024 0.000
#> GSM22387     4  0.7879    0.06994 0.004 0.316 0.244 0.436
#> GSM22388     1  0.3142    0.52622 0.860 0.008 0.000 0.132
#> GSM22390     2  0.7364    0.42591 0.004 0.548 0.208 0.240
#> GSM22392     2  0.3975    0.75766 0.016 0.856 0.064 0.064
#> GSM22393     1  0.4672    0.54934 0.828 0.052 0.060 0.060
#> GSM22394     4  0.6204   -0.00485 0.448 0.052 0.000 0.500
#> GSM22397     2  0.3311    0.69754 0.172 0.828 0.000 0.000
#> GSM22400     2  0.8332    0.08305 0.332 0.420 0.224 0.024
#> GSM22401     1  0.6603    0.37776 0.580 0.316 0.000 0.104
#> GSM22403     1  0.4170    0.51497 0.808 0.012 0.168 0.012
#> GSM22404     3  0.5463    0.48846 0.052 0.000 0.692 0.256
#> GSM22405     2  0.3495    0.74808 0.016 0.844 0.140 0.000
#> GSM22406     1  0.1557    0.58746 0.944 0.056 0.000 0.000
#> GSM22408     3  0.6886    0.45417 0.260 0.080 0.628 0.032
#> GSM22409     1  0.3616    0.52472 0.852 0.000 0.112 0.036
#> GSM22410     3  0.0817    0.65207 0.000 0.000 0.976 0.024
#> GSM22413     4  0.5007    0.20167 0.008 0.000 0.356 0.636
#> GSM22414     2  0.2281    0.73104 0.096 0.904 0.000 0.000
#> GSM22417     3  0.3435    0.58723 0.000 0.100 0.864 0.036
#> GSM22418     1  0.7909    0.12786 0.356 0.304 0.000 0.340
#> GSM22419     1  0.5857    0.38172 0.636 0.056 0.000 0.308
#> GSM22420     2  0.4407    0.74072 0.004 0.820 0.076 0.100
#> GSM22421     2  0.2589    0.72779 0.116 0.884 0.000 0.000
#> GSM22422     4  0.6340    0.28132 0.344 0.000 0.076 0.580
#> GSM22423     2  0.4215    0.74370 0.072 0.824 0.104 0.000
#> GSM22424     2  0.1474    0.77296 0.000 0.948 0.052 0.000
#> GSM22365     1  0.2596    0.58421 0.908 0.068 0.000 0.024
#> GSM22366     1  0.3471    0.58247 0.868 0.072 0.060 0.000
#> GSM22367     3  0.5497    0.11624 0.016 0.000 0.524 0.460
#> GSM22368     4  0.7863    0.38247 0.036 0.268 0.152 0.544
#> GSM22370     2  0.4538    0.69360 0.000 0.760 0.216 0.024
#> GSM22371     2  0.3668    0.65733 0.188 0.808 0.000 0.004
#> GSM22372     4  0.6855    0.29061 0.144 0.000 0.276 0.580
#> GSM22373     2  0.3274    0.75741 0.056 0.884 0.004 0.056
#> GSM22375     4  0.4706    0.34926 0.248 0.000 0.020 0.732
#> GSM22376     3  0.3852    0.57418 0.192 0.000 0.800 0.008
#> GSM22377     3  0.6661    0.08701 0.004 0.076 0.524 0.396
#> GSM22378     1  0.4697    0.39356 0.644 0.356 0.000 0.000
#> GSM22379     3  0.1526    0.65226 0.012 0.016 0.960 0.012
#> GSM22380     3  0.1798    0.64237 0.000 0.040 0.944 0.016
#> GSM22383     4  0.5723    0.28634 0.012 0.024 0.324 0.640
#> GSM22386     3  0.3435    0.61137 0.036 0.000 0.864 0.100
#> GSM22389     2  0.6737    0.64063 0.040 0.660 0.224 0.076
#> GSM22391     3  0.5035    0.53466 0.052 0.000 0.744 0.204
#> GSM22395     3  0.6419   -0.06414 0.000 0.420 0.512 0.068
#> GSM22396     2  0.0779    0.76848 0.016 0.980 0.004 0.000
#> GSM22398     2  0.5733    0.54582 0.000 0.640 0.312 0.048
#> GSM22399     1  0.7620    0.03000 0.460 0.000 0.224 0.316
#> GSM22402     2  0.2699    0.76263 0.068 0.904 0.028 0.000
#> GSM22407     2  0.4784    0.66688 0.112 0.788 0.000 0.100
#> GSM22411     4  0.4746    0.27764 0.000 0.000 0.368 0.632
#> GSM22412     4  0.6452    0.46696 0.140 0.016 0.160 0.684
#> GSM22415     3  0.4356    0.59981 0.124 0.064 0.812 0.000
#> GSM22416     1  0.7697    0.10704 0.404 0.376 0.000 0.220

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM22369     5  0.3835    0.63648 0.012 0.000 0.244 0.000 0.744
#> GSM22374     2  0.5996    0.12548 0.368 0.512 0.120 0.000 0.000
#> GSM22381     4  0.4960    0.59691 0.000 0.000 0.232 0.688 0.080
#> GSM22382     5  0.3631    0.67095 0.012 0.172 0.000 0.012 0.804
#> GSM22384     5  0.5649    0.48029 0.296 0.000 0.000 0.108 0.596
#> GSM22385     2  0.2580    0.75645 0.000 0.892 0.044 0.064 0.000
#> GSM22387     1  0.2777    0.45704 0.864 0.016 0.120 0.000 0.000
#> GSM22388     4  0.2179    0.68470 0.112 0.000 0.000 0.888 0.000
#> GSM22390     1  0.4010    0.39151 0.760 0.032 0.208 0.000 0.000
#> GSM22392     1  0.7008    0.02947 0.460 0.160 0.348 0.032 0.000
#> GSM22393     4  0.5449    0.48427 0.108 0.000 0.256 0.636 0.000
#> GSM22394     1  0.7027   -0.14427 0.420 0.056 0.000 0.416 0.108
#> GSM22397     2  0.1638    0.75305 0.000 0.932 0.004 0.064 0.000
#> GSM22400     3  0.5642    0.37564 0.184 0.000 0.636 0.180 0.000
#> GSM22401     2  0.3704    0.67619 0.000 0.820 0.000 0.092 0.088
#> GSM22403     4  0.3224    0.70459 0.000 0.000 0.160 0.824 0.016
#> GSM22404     5  0.3563    0.66199 0.000 0.000 0.208 0.012 0.780
#> GSM22405     2  0.4938    0.51207 0.004 0.648 0.308 0.040 0.000
#> GSM22406     4  0.1041    0.73607 0.000 0.000 0.032 0.964 0.004
#> GSM22408     3  0.4971    0.44034 0.116 0.000 0.708 0.176 0.000
#> GSM22409     4  0.1106    0.73442 0.000 0.000 0.024 0.964 0.012
#> GSM22410     3  0.4608    0.09854 0.024 0.000 0.640 0.000 0.336
#> GSM22413     5  0.1116    0.73066 0.004 0.000 0.028 0.004 0.964
#> GSM22414     2  0.0566    0.75472 0.000 0.984 0.012 0.000 0.004
#> GSM22417     3  0.4015    0.38549 0.348 0.000 0.652 0.000 0.000
#> GSM22418     1  0.6036    0.12385 0.548 0.076 0.020 0.356 0.000
#> GSM22419     1  0.5181   -0.02351 0.512 0.032 0.000 0.452 0.004
#> GSM22420     1  0.6485    0.18888 0.488 0.288 0.224 0.000 0.000
#> GSM22421     2  0.0671    0.75474 0.000 0.980 0.000 0.016 0.004
#> GSM22422     5  0.4771    0.62742 0.060 0.000 0.008 0.208 0.724
#> GSM22423     2  0.2885    0.75311 0.000 0.880 0.064 0.052 0.004
#> GSM22424     2  0.2583    0.72132 0.000 0.864 0.132 0.004 0.000
#> GSM22365     4  0.2260    0.72295 0.064 0.000 0.028 0.908 0.000
#> GSM22366     4  0.2561    0.71927 0.000 0.000 0.144 0.856 0.000
#> GSM22367     5  0.1478    0.72409 0.000 0.000 0.064 0.000 0.936
#> GSM22368     5  0.4325    0.53263 0.012 0.300 0.000 0.004 0.684
#> GSM22370     3  0.5579    0.18136 0.080 0.368 0.552 0.000 0.000
#> GSM22371     2  0.3696    0.59014 0.016 0.772 0.000 0.212 0.000
#> GSM22372     5  0.3266    0.72013 0.008 0.000 0.032 0.108 0.852
#> GSM22373     2  0.4315    0.49680 0.276 0.700 0.024 0.000 0.000
#> GSM22375     1  0.5236    0.39658 0.720 0.000 0.040 0.180 0.060
#> GSM22376     3  0.5983    0.39780 0.100 0.000 0.632 0.240 0.028
#> GSM22377     1  0.3003    0.41489 0.812 0.000 0.188 0.000 0.000
#> GSM22378     2  0.4684    0.15417 0.004 0.536 0.008 0.452 0.000
#> GSM22379     3  0.5287    0.44585 0.260 0.000 0.656 0.080 0.004
#> GSM22380     3  0.4640    0.46710 0.076 0.016 0.764 0.000 0.144
#> GSM22383     1  0.2280    0.45196 0.880 0.000 0.120 0.000 0.000
#> GSM22386     3  0.5061   -0.27945 0.008 0.000 0.528 0.020 0.444
#> GSM22389     3  0.6903   -0.00803 0.420 0.084 0.432 0.064 0.000
#> GSM22391     5  0.4437    0.57798 0.000 0.000 0.316 0.020 0.664
#> GSM22395     3  0.5892    0.20817 0.372 0.108 0.520 0.000 0.000
#> GSM22396     2  0.1608    0.74983 0.000 0.928 0.072 0.000 0.000
#> GSM22398     2  0.7434   -0.01323 0.124 0.436 0.356 0.000 0.084
#> GSM22399     4  0.5294    0.46828 0.284 0.000 0.044 0.652 0.020
#> GSM22402     2  0.3226    0.74251 0.000 0.852 0.088 0.060 0.000
#> GSM22407     2  0.0898    0.75180 0.008 0.972 0.000 0.000 0.020
#> GSM22411     5  0.5000    0.48661 0.388 0.000 0.036 0.000 0.576
#> GSM22412     5  0.3394    0.71772 0.028 0.012 0.000 0.116 0.844
#> GSM22415     3  0.2921    0.48322 0.004 0.004 0.844 0.148 0.000
#> GSM22416     4  0.7260    0.07457 0.292 0.272 0.000 0.412 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM22369     5  0.3792     0.5974 0.000 0.000 0.156 0.048 0.784 0.012
#> GSM22374     2  0.5007     0.3609 0.000 0.636 0.012 0.080 0.000 0.272
#> GSM22381     4  0.4218     0.3984 0.184 0.000 0.068 0.740 0.008 0.000
#> GSM22382     5  0.2800     0.6268 0.000 0.112 0.004 0.016 0.860 0.008
#> GSM22384     5  0.5699     0.4035 0.220 0.000 0.004 0.028 0.616 0.132
#> GSM22385     2  0.2932     0.7251 0.004 0.852 0.116 0.020 0.000 0.008
#> GSM22387     6  0.1382     0.5730 0.008 0.008 0.036 0.000 0.000 0.948
#> GSM22388     1  0.4385     0.1038 0.532 0.000 0.000 0.444 0.000 0.024
#> GSM22390     6  0.2442     0.5630 0.000 0.048 0.068 0.000 0.000 0.884
#> GSM22392     6  0.7679     0.3432 0.072 0.200 0.120 0.124 0.000 0.484
#> GSM22393     1  0.6529     0.2066 0.540 0.000 0.096 0.144 0.000 0.220
#> GSM22394     1  0.6187     0.3870 0.576 0.008 0.000 0.088 0.072 0.256
#> GSM22397     2  0.3103     0.7375 0.080 0.856 0.048 0.012 0.004 0.000
#> GSM22400     4  0.7764    -0.1515 0.148 0.008 0.268 0.296 0.000 0.280
#> GSM22401     2  0.7296     0.3592 0.152 0.524 0.044 0.168 0.112 0.000
#> GSM22403     4  0.5635     0.0738 0.360 0.000 0.096 0.524 0.020 0.000
#> GSM22404     5  0.4479     0.5290 0.000 0.000 0.236 0.080 0.684 0.000
#> GSM22405     3  0.5562     0.5499 0.048 0.236 0.652 0.036 0.004 0.024
#> GSM22406     1  0.4002     0.4163 0.736 0.008 0.036 0.220 0.000 0.000
#> GSM22408     3  0.5721     0.4649 0.160 0.004 0.648 0.132 0.000 0.056
#> GSM22409     4  0.4313     0.1524 0.372 0.000 0.020 0.604 0.004 0.000
#> GSM22410     3  0.5054     0.4024 0.000 0.000 0.696 0.096 0.168 0.040
#> GSM22413     5  0.2053     0.6222 0.000 0.000 0.004 0.108 0.888 0.000
#> GSM22414     2  0.1138     0.7626 0.024 0.960 0.000 0.012 0.004 0.000
#> GSM22417     3  0.4265     0.4836 0.008 0.000 0.680 0.016 0.008 0.288
#> GSM22418     6  0.6214     0.0626 0.368 0.028 0.024 0.084 0.000 0.496
#> GSM22419     1  0.4477     0.2530 0.588 0.004 0.000 0.028 0.000 0.380
#> GSM22420     6  0.6071     0.1747 0.000 0.392 0.048 0.092 0.000 0.468
#> GSM22421     2  0.1262     0.7611 0.000 0.956 0.008 0.016 0.020 0.000
#> GSM22422     5  0.5719     0.1083 0.168 0.000 0.000 0.372 0.460 0.000
#> GSM22423     2  0.4078     0.5651 0.000 0.724 0.240 0.016 0.016 0.004
#> GSM22424     2  0.1262     0.7569 0.000 0.956 0.016 0.008 0.000 0.020
#> GSM22365     1  0.1889     0.5047 0.920 0.004 0.020 0.056 0.000 0.000
#> GSM22366     1  0.5202     0.3486 0.632 0.004 0.188 0.176 0.000 0.000
#> GSM22367     5  0.3865     0.5432 0.000 0.000 0.056 0.192 0.752 0.000
#> GSM22368     5  0.3457     0.5950 0.028 0.152 0.000 0.008 0.808 0.004
#> GSM22370     3  0.5339     0.4958 0.000 0.312 0.568 0.004 0.000 0.116
#> GSM22371     2  0.3273     0.6736 0.212 0.776 0.004 0.008 0.000 0.000
#> GSM22372     4  0.5134     0.0893 0.088 0.000 0.000 0.524 0.388 0.000
#> GSM22373     2  0.5205     0.4630 0.096 0.664 0.016 0.008 0.000 0.216
#> GSM22375     6  0.6871     0.2004 0.244 0.004 0.036 0.060 0.112 0.544
#> GSM22376     4  0.5619     0.3916 0.088 0.000 0.356 0.532 0.000 0.024
#> GSM22377     6  0.2936     0.5328 0.004 0.000 0.080 0.060 0.000 0.856
#> GSM22378     2  0.5927     0.1131 0.420 0.456 0.044 0.080 0.000 0.000
#> GSM22379     4  0.5898     0.4001 0.016 0.000 0.192 0.548 0.000 0.244
#> GSM22380     4  0.7280     0.3700 0.000 0.012 0.208 0.472 0.124 0.184
#> GSM22383     6  0.1317     0.5641 0.016 0.000 0.016 0.004 0.008 0.956
#> GSM22386     4  0.5743     0.4354 0.004 0.000 0.248 0.600 0.120 0.028
#> GSM22389     6  0.7286     0.0606 0.068 0.128 0.288 0.048 0.000 0.468
#> GSM22391     4  0.5702     0.3463 0.000 0.000 0.188 0.560 0.244 0.008
#> GSM22395     3  0.5889     0.2645 0.004 0.108 0.488 0.012 0.004 0.384
#> GSM22396     2  0.1078     0.7587 0.000 0.964 0.016 0.008 0.000 0.012
#> GSM22398     3  0.6771     0.5495 0.016 0.208 0.568 0.008 0.100 0.100
#> GSM22399     4  0.5627     0.3280 0.228 0.000 0.000 0.600 0.020 0.152
#> GSM22402     2  0.1699     0.7582 0.004 0.928 0.060 0.004 0.000 0.004
#> GSM22407     2  0.0982     0.7634 0.000 0.968 0.004 0.004 0.020 0.004
#> GSM22411     5  0.4154     0.5128 0.000 0.000 0.020 0.004 0.652 0.324
#> GSM22412     4  0.5200     0.2816 0.084 0.004 0.000 0.608 0.296 0.008
#> GSM22415     3  0.2322     0.5436 0.024 0.000 0.904 0.048 0.000 0.024
#> GSM22416     1  0.6319     0.2971 0.580 0.220 0.004 0.028 0.020 0.148

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

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> ATC:NMF 56            0.104 2
#> ATC:NMF 49            0.120 3
#> ATC:NMF 34            0.301 4
#> ATC:NMF 29            0.611 5
#> ATC:NMF 25            0.765 6

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