cola Report for GDS830

Date: 2019-12-25 22:20:24 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 21342 rows and 50 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] 21342    50

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 Optional k
SD:skmeans 2 1.000 1.000 1.000 **
SD:pam 4 1.000 0.979 0.990 ** 2,3
SD:NMF 3 1.000 0.974 0.991 ** 2
CV:hclust 2 1.000 0.961 0.982 **
CV:pam 3 1.000 0.975 0.990 ** 2
MAD:hclust 2 1.000 0.970 0.987 **
MAD:kmeans 3 1.000 0.986 0.987 **
MAD:pam 4 1.000 0.994 0.997 ** 2,3
MAD:NMF 3 1.000 0.965 0.986 ** 2
ATC:kmeans 3 1.000 0.992 0.991 **
ATC:skmeans 3 1.000 0.981 0.992 ** 2
ATC:pam 3 1.000 1.000 1.000 ** 2
ATC:mclust 2 1.000 0.991 0.995 **
ATC:NMF 3 1.000 0.951 0.981 **
CV:kmeans 3 0.944 0.959 0.961 *
SD:kmeans 3 0.943 0.956 0.959 *
MAD:skmeans 3 0.939 0.949 0.978 * 2
CV:NMF 4 0.923 0.920 0.954 * 2,3
ATC:hclust 5 0.915 0.893 0.939 * 2,3
SD:hclust 3 0.908 0.910 0.960 * 2
CV:skmeans 3 0.856 0.838 0.938
CV:mclust 3 0.811 0.856 0.935
MAD:mclust 5 0.704 0.795 0.878
SD:mclust 3 0.622 0.826 0.913

**: 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 1.000           0.983       0.992          0.386 0.607   0.607
#> CV:NMF      2 1.000           0.990       0.995          0.393 0.607   0.607
#> MAD:NMF     2 1.000           0.980       0.991          0.391 0.607   0.607
#> ATC:NMF     2 0.486           0.796       0.893          0.452 0.556   0.556
#> SD:skmeans  2 1.000           1.000       1.000          0.471 0.530   0.530
#> CV:skmeans  2 0.735           0.842       0.927          0.461 0.519   0.519
#> MAD:skmeans 2 1.000           0.976       0.991          0.477 0.519   0.519
#> ATC:skmeans 2 1.000           0.979       0.986          0.474 0.519   0.519
#> SD:mclust   2 0.458           0.482       0.775          0.456 0.503   0.503
#> CV:mclust   2 0.499           0.882       0.913          0.450 0.519   0.519
#> MAD:mclust  2 0.689           0.818       0.912          0.358 0.726   0.726
#> ATC:mclust  2 1.000           0.991       0.995          0.468 0.530   0.530
#> SD:kmeans   2 0.426           0.768       0.829          0.356 0.650   0.650
#> CV:kmeans   2 0.362           0.843       0.823          0.363 0.650   0.650
#> MAD:kmeans  2 0.393           0.280       0.614          0.364 0.556   0.556
#> ATC:kmeans  2 0.486           0.772       0.854          0.333 0.556   0.556
#> SD:pam      2 1.000           1.000       1.000          0.351 0.650   0.650
#> CV:pam      2 1.000           1.000       1.000          0.351 0.650   0.650
#> MAD:pam     2 1.000           1.000       1.000          0.351 0.650   0.650
#> ATC:pam     2 1.000           1.000       1.000          0.327 0.673   0.673
#> SD:hclust   2 1.000           0.999       1.000          0.351 0.650   0.650
#> CV:hclust   2 1.000           0.961       0.982          0.334 0.673   0.673
#> MAD:hclust  2 1.000           0.970       0.987          0.344 0.650   0.650
#> ATC:hclust  2 1.000           1.000       1.000          0.216 0.784   0.784
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.974       0.991          0.499 0.731   0.588
#> CV:NMF      3 0.968           0.948       0.979          0.514 0.718   0.566
#> MAD:NMF     3 1.000           0.965       0.986          0.489 0.731   0.588
#> ATC:NMF     3 1.000           0.951       0.981          0.326 0.591   0.406
#> SD:skmeans  3 0.825           0.913       0.961          0.354 0.746   0.557
#> CV:skmeans  3 0.856           0.838       0.938          0.433 0.726   0.518
#> MAD:skmeans 3 0.939           0.949       0.978          0.353 0.754   0.561
#> ATC:skmeans 3 1.000           0.981       0.992          0.318 0.784   0.610
#> SD:mclust   3 0.622           0.826       0.913          0.336 0.603   0.376
#> CV:mclust   3 0.811           0.856       0.935          0.389 0.760   0.574
#> MAD:mclust  3 0.423           0.594       0.783          0.619 0.653   0.522
#> ATC:mclust  3 0.771           0.813       0.919          0.263 0.776   0.610
#> SD:kmeans   3 0.943           0.956       0.959          0.492 0.764   0.651
#> CV:kmeans   3 0.944           0.959       0.961          0.498 0.764   0.651
#> MAD:kmeans  3 1.000           0.986       0.987          0.523 0.616   0.445
#> ATC:kmeans  3 1.000           0.992       0.991          0.553 0.919   0.856
#> SD:pam      3 1.000           0.999       1.000          0.575 0.798   0.688
#> CV:pam      3 1.000           0.975       0.990          0.601 0.798   0.688
#> MAD:pam     3 1.000           1.000       1.000          0.576 0.798   0.688
#> ATC:pam     3 1.000           1.000       1.000          0.508 0.833   0.753
#> SD:hclust   3 0.908           0.910       0.960          0.559 0.838   0.751
#> CV:hclust   3 0.690           0.847       0.899          0.726 0.740   0.613
#> MAD:hclust  3 0.835           0.864       0.944          0.583 0.838   0.751
#> ATC:hclust  3 1.000           0.999       1.000          1.369 0.704   0.622
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.876           0.913       0.950         0.2138 0.882   0.726
#> CV:NMF      4 0.923           0.920       0.954         0.2296 0.838   0.616
#> MAD:NMF     4 0.793           0.852       0.913         0.2486 0.837   0.620
#> ATC:NMF     4 0.737           0.751       0.841         0.1698 0.864   0.692
#> SD:skmeans  4 0.802           0.843       0.892         0.1763 0.789   0.484
#> CV:skmeans  4 0.757           0.746       0.878         0.1360 0.776   0.451
#> MAD:skmeans 4 0.798           0.741       0.898         0.1612 0.797   0.494
#> ATC:skmeans 4 0.738           0.591       0.814         0.1768 0.932   0.820
#> SD:mclust   4 0.784           0.887       0.920         0.0839 0.864   0.691
#> CV:mclust   4 0.773           0.807       0.898         0.0629 0.909   0.776
#> MAD:mclust  4 0.607           0.748       0.862         0.1984 0.716   0.396
#> ATC:mclust  4 0.661           0.690       0.854         0.0894 0.848   0.664
#> SD:kmeans   4 0.708           0.767       0.871         0.2925 0.909   0.803
#> CV:kmeans   4 0.716           0.790       0.866         0.2598 0.909   0.803
#> MAD:kmeans  4 0.700           0.712       0.808         0.2712 0.804   0.560
#> ATC:kmeans  4 0.645           0.543       0.742         0.2998 0.778   0.542
#> SD:pam      4 1.000           0.979       0.990         0.1658 0.912   0.803
#> CV:pam      4 0.876           0.965       0.974         0.1616 0.912   0.803
#> MAD:pam     4 1.000           0.994       0.997         0.1284 0.931   0.847
#> ATC:pam     4 0.804           0.922       0.954         0.1605 0.948   0.897
#> SD:hclust   4 0.765           0.844       0.902         0.2747 0.812   0.615
#> CV:hclust   4 0.728           0.852       0.936         0.1630 0.890   0.739
#> MAD:hclust  4 0.771           0.826       0.909         0.2694 0.800   0.594
#> ATC:hclust  4 0.881           0.859       0.943         0.2575 0.905   0.806
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.747           0.721       0.849         0.1135 0.900   0.686
#> CV:NMF      5 0.767           0.650       0.840         0.0614 0.904   0.664
#> MAD:NMF     5 0.765           0.743       0.861         0.0860 0.929   0.743
#> ATC:NMF     5 0.785           0.890       0.923         0.0940 0.897   0.690
#> SD:skmeans  5 0.846           0.815       0.904         0.0711 0.949   0.797
#> CV:skmeans  5 0.802           0.782       0.886         0.0700 0.933   0.738
#> MAD:skmeans 5 0.824           0.741       0.879         0.0727 0.872   0.550
#> ATC:skmeans 5 0.794           0.529       0.744         0.0757 0.864   0.589
#> SD:mclust   5 0.664           0.702       0.838         0.1410 0.819   0.537
#> CV:mclust   5 0.745           0.799       0.885         0.1234 0.845   0.591
#> MAD:mclust  5 0.704           0.795       0.878         0.0964 0.935   0.777
#> ATC:mclust  5 0.695           0.677       0.849         0.1334 0.883   0.686
#> SD:kmeans   5 0.698           0.780       0.848         0.1082 0.853   0.606
#> CV:kmeans   5 0.772           0.804       0.883         0.1189 0.853   0.606
#> MAD:kmeans  5 0.754           0.735       0.860         0.0996 0.951   0.814
#> ATC:kmeans  5 0.632           0.774       0.803         0.1125 0.795   0.420
#> SD:pam      5 0.780           0.743       0.890         0.1341 0.925   0.791
#> CV:pam      5 0.764           0.734       0.879         0.1246 0.910   0.750
#> MAD:pam     5 0.851           0.872       0.943         0.1083 0.939   0.838
#> ATC:pam     5 0.831           0.948       0.972         0.2292 0.843   0.655
#> SD:hclust   5 0.831           0.875       0.923         0.0426 0.980   0.935
#> CV:hclust   5 0.778           0.786       0.869         0.1027 0.971   0.908
#> MAD:hclust  5 0.808           0.885       0.910         0.0567 0.975   0.916
#> ATC:hclust  5 0.915           0.893       0.939         0.0485 0.913   0.780
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.716           0.567       0.758         0.0521 0.885   0.554
#> CV:NMF      6 0.742           0.618       0.784         0.0592 0.892   0.554
#> MAD:NMF     6 0.746           0.521       0.747         0.0449 0.949   0.768
#> ATC:NMF     6 0.761           0.741       0.858         0.0315 0.987   0.943
#> SD:skmeans  6 0.841           0.753       0.808         0.0393 0.980   0.903
#> CV:skmeans  6 0.818           0.705       0.807         0.0389 0.968   0.842
#> MAD:skmeans 6 0.824           0.639       0.824         0.0387 0.928   0.668
#> ATC:skmeans 6 0.878           0.849       0.915         0.0483 0.924   0.674
#> SD:mclust   6 0.695           0.567       0.740         0.0526 0.855   0.470
#> CV:mclust   6 0.762           0.815       0.860         0.0766 0.894   0.605
#> MAD:mclust  6 0.693           0.664       0.806         0.0653 0.927   0.696
#> ATC:mclust  6 0.862           0.819       0.895         0.0592 0.916   0.715
#> SD:kmeans   6 0.773           0.661       0.825         0.0633 0.974   0.884
#> CV:kmeans   6 0.793           0.717       0.819         0.0629 0.939   0.756
#> MAD:kmeans  6 0.797           0.644       0.813         0.0522 0.943   0.759
#> ATC:kmeans  6 0.726           0.801       0.870         0.0678 0.958   0.826
#> SD:pam      6 0.797           0.800       0.863         0.0758 0.930   0.760
#> CV:pam      6 0.805           0.712       0.842         0.0679 0.913   0.706
#> MAD:pam     6 0.896           0.837       0.938         0.0740 0.910   0.736
#> ATC:pam     6 0.811           0.942       0.965         0.0123 0.993   0.978
#> SD:hclust   6 0.787           0.811       0.889         0.0424 0.996   0.985
#> CV:hclust   6 0.763           0.712       0.838         0.0390 0.969   0.896
#> MAD:hclust  6 0.785           0.809       0.873         0.0485 0.996   0.985
#> ATC:hclust  6 0.848           0.821       0.916         0.0826 0.946   0.828

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 tissue(p) k
#> SD:NMF      50     0.394 2
#> CV:NMF      50     0.394 2
#> MAD:NMF     50     0.394 2
#> ATC:NMF     47     0.391 2
#> SD:skmeans  50     0.394 2
#> CV:skmeans  48     0.392 2
#> MAD:skmeans 49     0.393 2
#> ATC:skmeans 50     0.394 2
#> SD:mclust   30     0.414 2
#> CV:mclust   50     0.394 2
#> MAD:mclust  48     0.392 2
#> ATC:mclust  50     0.394 2
#> SD:kmeans   44     0.387 2
#> CV:kmeans   50     0.394 2
#> MAD:kmeans   0        NA 2
#> ATC:kmeans  41     0.383 2
#> SD:pam      50     0.394 2
#> CV:pam      50     0.394 2
#> MAD:pam     50     0.394 2
#> ATC:pam     50     0.394 2
#> SD:hclust   50     0.394 2
#> CV:hclust   49     0.393 2
#> MAD:hclust  50     0.394 2
#> ATC:hclust  50     0.394 2
test_to_known_factors(res_list, k = 3)
#>              n tissue(p) k
#> SD:NMF      49     0.368 3
#> CV:NMF      48     0.423 3
#> MAD:NMF     49     0.368 3
#> ATC:NMF     49     0.368 3
#> SD:skmeans  49     0.449 3
#> CV:skmeans  45     0.447 3
#> MAD:skmeans 49     0.449 3
#> ATC:skmeans 50     0.370 3
#> SD:mclust   47     0.440 3
#> CV:mclust   47     0.437 3
#> MAD:mclust  37     0.413 3
#> ATC:mclust  45     0.421 3
#> SD:kmeans   49     0.368 3
#> CV:kmeans   50     0.370 3
#> MAD:kmeans  50     0.370 3
#> ATC:kmeans  50     0.370 3
#> SD:pam      50     0.370 3
#> CV:pam      49     0.368 3
#> MAD:pam     50     0.370 3
#> ATC:pam     50     0.370 3
#> SD:hclust   47     0.366 3
#> CV:hclust   48     0.367 3
#> MAD:hclust  46     0.364 3
#> ATC:hclust  50     0.370 3
test_to_known_factors(res_list, k = 4)
#>              n tissue(p) k
#> SD:NMF      49     0.464 4
#> CV:NMF      49     0.436 4
#> MAD:NMF     48     0.430 4
#> ATC:NMF     46     0.412 4
#> SD:skmeans  49     0.348 4
#> CV:skmeans  40     0.406 4
#> MAD:skmeans 40     0.406 4
#> ATC:skmeans 33     0.397 4
#> SD:mclust   50     0.511 4
#> CV:mclust   47     0.504 4
#> MAD:mclust  44     0.411 4
#> ATC:mclust  37     0.413 4
#> SD:kmeans   41     0.407 4
#> CV:kmeans   49     0.509 4
#> MAD:kmeans  39     0.405 4
#> ATC:kmeans  33     0.316 4
#> SD:pam      50     0.512 4
#> CV:pam      50     0.512 4
#> MAD:pam     50     0.560 4
#> ATC:pam     50     0.349 4
#> SD:hclust   49     0.432 4
#> CV:hclust   48     0.509 4
#> MAD:hclust  48     0.437 4
#> ATC:hclust  44     0.339 4
test_to_known_factors(res_list, k = 5)
#>              n tissue(p) k
#> SD:NMF      43     0.436 5
#> CV:NMF      38     0.486 5
#> MAD:NMF     42     0.422 5
#> ATC:NMF     50     0.479 5
#> SD:skmeans  45     0.471 5
#> CV:skmeans  43     0.463 5
#> MAD:skmeans 42     0.459 5
#> ATC:skmeans 28     0.400 5
#> SD:mclust   42     0.494 5
#> CV:mclust   47     0.512 5
#> MAD:mclust  50     0.536 5
#> ATC:mclust  39     0.521 5
#> SD:kmeans   45     0.483 5
#> CV:kmeans   45     0.483 5
#> MAD:kmeans  41     0.517 5
#> ATC:kmeans  47     0.404 5
#> SD:pam      43     0.451 5
#> CV:pam      42     0.457 5
#> MAD:pam     47     0.503 5
#> ATC:pam     50     0.331 5
#> SD:hclust   50     0.473 5
#> CV:hclust   47     0.464 5
#> MAD:hclust  50     0.473 5
#> ATC:hclust  47     0.326 5
test_to_known_factors(res_list, k = 6)
#>              n tissue(p) k
#> SD:NMF      30     0.445 6
#> CV:NMF      35     0.418 6
#> MAD:NMF     31     0.474 6
#> ATC:NMF     43     0.493 6
#> SD:skmeans  44     0.440 6
#> CV:skmeans  35     0.435 6
#> MAD:skmeans 36     0.455 6
#> ATC:skmeans 48     0.399 6
#> SD:mclust   34     0.461 6
#> CV:mclust   46     0.477 6
#> MAD:mclust  36     0.472 6
#> ATC:mclust  44     0.495 6
#> SD:kmeans   38     0.472 6
#> CV:kmeans   43     0.487 6
#> MAD:kmeans  38     0.509 6
#> ATC:kmeans  46     0.474 6
#> SD:pam      49     0.439 6
#> CV:pam      41     0.448 6
#> MAD:pam     46     0.465 6
#> ATC:pam     50     0.315 6
#> SD:hclust   48     0.466 6
#> CV:hclust   42     0.448 6
#> MAD:hclust  47     0.463 6
#> ATC:hclust  44     0.401 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 21342 rows and 50 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 1.000           0.999       1.000         0.3512 0.650   0.650
#> 3 3 0.908           0.910       0.960         0.5593 0.838   0.751
#> 4 4 0.765           0.844       0.902         0.2747 0.812   0.615
#> 5 5 0.831           0.875       0.923         0.0426 0.980   0.935
#> 6 6 0.787           0.811       0.889         0.0424 0.996   0.985

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1   0.000      1.000 1.000 0.000
#> GSM28736     1   0.000      1.000 1.000 0.000
#> GSM28737     1   0.000      1.000 1.000 0.000
#> GSM11249     1   0.000      1.000 1.000 0.000
#> GSM28745     2   0.000      1.000 0.000 1.000
#> GSM11244     2   0.000      1.000 0.000 1.000
#> GSM28748     2   0.000      1.000 0.000 1.000
#> GSM11266     2   0.000      1.000 0.000 1.000
#> GSM28730     2   0.000      1.000 0.000 1.000
#> GSM11253     2   0.000      1.000 0.000 1.000
#> GSM11254     2   0.000      1.000 0.000 1.000
#> GSM11260     2   0.000      1.000 0.000 1.000
#> GSM28733     2   0.000      1.000 0.000 1.000
#> GSM11265     1   0.000      1.000 1.000 0.000
#> GSM28739     1   0.000      1.000 1.000 0.000
#> GSM11243     1   0.000      1.000 1.000 0.000
#> GSM28740     1   0.000      1.000 1.000 0.000
#> GSM11259     1   0.000      1.000 1.000 0.000
#> GSM28726     1   0.000      1.000 1.000 0.000
#> GSM28743     1   0.000      1.000 1.000 0.000
#> GSM11256     1   0.000      1.000 1.000 0.000
#> GSM11262     1   0.000      1.000 1.000 0.000
#> GSM28724     1   0.000      1.000 1.000 0.000
#> GSM28725     1   0.000      1.000 1.000 0.000
#> GSM11263     1   0.000      1.000 1.000 0.000
#> GSM11267     1   0.000      1.000 1.000 0.000
#> GSM28744     1   0.000      1.000 1.000 0.000
#> GSM28734     1   0.000      1.000 1.000 0.000
#> GSM28747     1   0.000      1.000 1.000 0.000
#> GSM11257     1   0.000      1.000 1.000 0.000
#> GSM11252     1   0.000      1.000 1.000 0.000
#> GSM11264     1   0.000      1.000 1.000 0.000
#> GSM11247     1   0.000      1.000 1.000 0.000
#> GSM11258     1   0.000      1.000 1.000 0.000
#> GSM28728     1   0.000      1.000 1.000 0.000
#> GSM28746     1   0.000      1.000 1.000 0.000
#> GSM28738     1   0.000      1.000 1.000 0.000
#> GSM28741     2   0.000      1.000 0.000 1.000
#> GSM28729     1   0.000      1.000 1.000 0.000
#> GSM28742     1   0.000      1.000 1.000 0.000
#> GSM11250     2   0.000      1.000 0.000 1.000
#> GSM11245     1   0.000      1.000 1.000 0.000
#> GSM11246     1   0.000      1.000 1.000 0.000
#> GSM11261     1   0.118      0.984 0.984 0.016
#> GSM11248     1   0.000      1.000 1.000 0.000
#> GSM28732     1   0.000      1.000 1.000 0.000
#> GSM11255     1   0.000      1.000 1.000 0.000
#> GSM28731     1   0.000      1.000 1.000 0.000
#> GSM28727     1   0.000      1.000 1.000 0.000
#> GSM11251     1   0.000      1.000 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
#> GSM28735     1   0.000      0.935 1.000 0.000 0.000
#> GSM28736     1   0.000      0.935 1.000 0.000 0.000
#> GSM28737     1   0.000      0.935 1.000 0.000 0.000
#> GSM11249     1   0.611      0.440 0.604 0.000 0.396
#> GSM28745     2   0.000      1.000 0.000 1.000 0.000
#> GSM11244     2   0.000      1.000 0.000 1.000 0.000
#> GSM28748     2   0.000      1.000 0.000 1.000 0.000
#> GSM11266     2   0.000      1.000 0.000 1.000 0.000
#> GSM28730     2   0.000      1.000 0.000 1.000 0.000
#> GSM11253     2   0.000      1.000 0.000 1.000 0.000
#> GSM11254     2   0.000      1.000 0.000 1.000 0.000
#> GSM11260     2   0.000      1.000 0.000 1.000 0.000
#> GSM28733     2   0.000      1.000 0.000 1.000 0.000
#> GSM11265     1   0.000      0.935 1.000 0.000 0.000
#> GSM28739     1   0.000      0.935 1.000 0.000 0.000
#> GSM11243     3   0.000      1.000 0.000 0.000 1.000
#> GSM28740     1   0.000      0.935 1.000 0.000 0.000
#> GSM11259     1   0.000      0.935 1.000 0.000 0.000
#> GSM28726     1   0.000      0.935 1.000 0.000 0.000
#> GSM28743     1   0.000      0.935 1.000 0.000 0.000
#> GSM11256     1   0.000      0.935 1.000 0.000 0.000
#> GSM11262     1   0.000      0.935 1.000 0.000 0.000
#> GSM28724     1   0.000      0.935 1.000 0.000 0.000
#> GSM28725     3   0.000      1.000 0.000 0.000 1.000
#> GSM11263     3   0.000      1.000 0.000 0.000 1.000
#> GSM11267     3   0.000      1.000 0.000 0.000 1.000
#> GSM28744     1   0.000      0.935 1.000 0.000 0.000
#> GSM28734     1   0.000      0.935 1.000 0.000 0.000
#> GSM28747     1   0.000      0.935 1.000 0.000 0.000
#> GSM11257     1   0.000      0.935 1.000 0.000 0.000
#> GSM11252     1   0.518      0.682 0.744 0.000 0.256
#> GSM11264     3   0.000      1.000 0.000 0.000 1.000
#> GSM11247     3   0.000      1.000 0.000 0.000 1.000
#> GSM11258     1   0.000      0.935 1.000 0.000 0.000
#> GSM28728     1   0.000      0.935 1.000 0.000 0.000
#> GSM28746     1   0.000      0.935 1.000 0.000 0.000
#> GSM28738     1   0.000      0.935 1.000 0.000 0.000
#> GSM28741     2   0.000      1.000 0.000 1.000 0.000
#> GSM28729     1   0.000      0.935 1.000 0.000 0.000
#> GSM28742     1   0.000      0.935 1.000 0.000 0.000
#> GSM11250     2   0.000      1.000 0.000 1.000 0.000
#> GSM11245     1   0.518      0.682 0.744 0.000 0.256
#> GSM11246     1   0.000      0.935 1.000 0.000 0.000
#> GSM11261     1   0.688      0.330 0.556 0.016 0.428
#> GSM11248     1   0.611      0.440 0.604 0.000 0.396
#> GSM28732     1   0.000      0.935 1.000 0.000 0.000
#> GSM11255     1   0.506      0.698 0.756 0.000 0.244
#> GSM28731     1   0.000      0.935 1.000 0.000 0.000
#> GSM28727     1   0.000      0.935 1.000 0.000 0.000
#> GSM11251     1   0.000      0.935 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
#> GSM28735     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28736     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28737     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM11249     4  0.4843      0.576 0.000 0.000 0.396 0.604
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM28739     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28740     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM11259     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28726     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28743     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM11256     4  0.0000      0.683 0.000 0.000 0.000 1.000
#> GSM11262     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM28724     1  0.0469      0.874 0.988 0.000 0.000 0.012
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28744     4  0.0000      0.683 0.000 0.000 0.000 1.000
#> GSM28734     4  0.0000      0.683 0.000 0.000 0.000 1.000
#> GSM28747     1  0.0469      0.874 0.988 0.000 0.000 0.012
#> GSM11257     1  0.0336      0.874 0.992 0.000 0.000 0.008
#> GSM11252     4  0.6698      0.649 0.140 0.000 0.256 0.604
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11258     4  0.0000      0.683 0.000 0.000 0.000 1.000
#> GSM28728     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28746     1  0.4304      0.699 0.716 0.000 0.000 0.284
#> GSM28738     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28729     1  0.1792      0.859 0.932 0.000 0.000 0.068
#> GSM28742     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11245     4  0.6698      0.649 0.140 0.000 0.256 0.604
#> GSM11246     1  0.4103      0.749 0.744 0.000 0.000 0.256
#> GSM11261     4  0.6165      0.521 0.024 0.016 0.428 0.532
#> GSM11248     4  0.4843      0.576 0.000 0.000 0.396 0.604
#> GSM28732     1  0.0817      0.872 0.976 0.000 0.000 0.024
#> GSM11255     4  0.7694      0.481 0.308 0.000 0.244 0.448
#> GSM28731     1  0.1940      0.856 0.924 0.000 0.000 0.076
#> GSM28727     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.874 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3   p4    p5
#> GSM28735     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM28736     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM28737     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM11249     5  0.3106      0.763 0.000 0.000 0.140 0.02 0.840
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11265     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM28739     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM11243     3  0.2471      0.891 0.000 0.000 0.864 0.00 0.136
#> GSM28740     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM11259     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM28726     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM28743     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000
#> GSM11262     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM28724     1  0.0404      0.863 0.988 0.000 0.000 0.00 0.012
#> GSM28725     3  0.0000      0.947 0.000 0.000 1.000 0.00 0.000
#> GSM11263     3  0.0000      0.947 0.000 0.000 1.000 0.00 0.000
#> GSM11267     3  0.0000      0.947 0.000 0.000 1.000 0.00 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000
#> GSM28747     1  0.0404      0.864 0.988 0.000 0.000 0.00 0.012
#> GSM11257     1  0.0794      0.862 0.972 0.000 0.000 0.00 0.028
#> GSM11252     5  0.3106      0.805 0.140 0.000 0.000 0.02 0.840
#> GSM11264     3  0.0000      0.947 0.000 0.000 1.000 0.00 0.000
#> GSM11247     3  0.2471      0.891 0.000 0.000 0.864 0.00 0.136
#> GSM11258     4  0.0000      1.000 0.000 0.000 0.000 1.00 0.000
#> GSM28728     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM28746     1  0.4157      0.697 0.716 0.000 0.000 0.02 0.264
#> GSM28738     1  0.0609      0.862 0.980 0.000 0.000 0.00 0.020
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM28729     1  0.1851      0.845 0.912 0.000 0.000 0.00 0.088
#> GSM28742     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.00 0.000
#> GSM11245     5  0.3106      0.805 0.140 0.000 0.000 0.02 0.840
#> GSM11246     1  0.3661      0.732 0.724 0.000 0.000 0.00 0.276
#> GSM11261     5  0.2815      0.729 0.024 0.012 0.044 0.02 0.900
#> GSM11248     5  0.3106      0.763 0.000 0.000 0.140 0.02 0.840
#> GSM28732     1  0.0703      0.862 0.976 0.000 0.000 0.00 0.024
#> GSM11255     5  0.3730      0.613 0.288 0.000 0.000 0.00 0.712
#> GSM28731     1  0.1965      0.842 0.904 0.000 0.000 0.00 0.096
#> GSM28727     1  0.0000      0.862 1.000 0.000 0.000 0.00 0.000
#> GSM11251     1  0.0000      0.862 1.000 0.000 0.000 0.00 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
#> GSM28735     1  0.0291      0.802 0.992  0 0.000  0 0.004 0.004
#> GSM28736     1  0.0291      0.802 0.992  0 0.000  0 0.004 0.004
#> GSM28737     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM11249     6  0.2219      0.600 0.000  0 0.136  0 0.000 0.864
#> GSM28745     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11265     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM28739     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM11243     3  0.2814      0.822 0.000  0 0.820  0 0.172 0.008
#> GSM28740     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM11259     1  0.0865      0.811 0.964  0 0.000  0 0.036 0.000
#> GSM28726     1  0.0291      0.802 0.992  0 0.000  0 0.004 0.004
#> GSM28743     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM11256     4  0.0000      1.000 0.000  0 0.000  1 0.000 0.000
#> GSM11262     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM28724     1  0.0914      0.806 0.968  0 0.000  0 0.016 0.016
#> GSM28725     3  0.0000      0.919 0.000  0 1.000  0 0.000 0.000
#> GSM11263     3  0.0000      0.919 0.000  0 1.000  0 0.000 0.000
#> GSM11267     3  0.0000      0.919 0.000  0 1.000  0 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000  0 0.000  1 0.000 0.000
#> GSM28734     4  0.0000      1.000 0.000  0 0.000  1 0.000 0.000
#> GSM28747     1  0.0937      0.812 0.960  0 0.000  0 0.040 0.000
#> GSM11257     1  0.3435      0.675 0.804  0 0.000  0 0.060 0.136
#> GSM11252     6  0.2260      0.682 0.140  0 0.000  0 0.000 0.860
#> GSM11264     3  0.0000      0.919 0.000  0 1.000  0 0.000 0.000
#> GSM11247     3  0.2814      0.822 0.000  0 0.820  0 0.172 0.008
#> GSM11258     4  0.0000      1.000 0.000  0 0.000  1 0.000 0.000
#> GSM28728     1  0.0603      0.806 0.980  0 0.000  0 0.016 0.004
#> GSM28746     1  0.4890      0.660 0.660  0 0.000  0 0.180 0.160
#> GSM28738     1  0.3354      0.678 0.812  0 0.000  0 0.060 0.128
#> GSM28741     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM28729     1  0.2558      0.790 0.840  0 0.000  0 0.156 0.004
#> GSM28742     1  0.0291      0.802 0.992  0 0.000  0 0.004 0.004
#> GSM11250     2  0.0000      1.000 0.000  1 0.000  0 0.000 0.000
#> GSM11245     6  0.2260      0.682 0.140  0 0.000  0 0.000 0.860
#> GSM11246     1  0.3717      0.687 0.616  0 0.000  0 0.384 0.000
#> GSM11261     5  0.2823      0.000 0.000  0 0.000  0 0.796 0.204
#> GSM11248     6  0.2219      0.600 0.000  0 0.136  0 0.000 0.864
#> GSM28732     1  0.1501      0.810 0.924  0 0.000  0 0.076 0.000
#> GSM11255     6  0.5134      0.388 0.228  0 0.000  0 0.152 0.620
#> GSM28731     1  0.2778      0.786 0.824  0 0.000  0 0.168 0.008
#> GSM28727     1  0.0713      0.810 0.972  0 0.000  0 0.028 0.000
#> GSM11251     1  0.0713      0.810 0.972  0 0.000  0 0.028 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 tissue(p) k
#> SD:hclust 50     0.394 2
#> SD:hclust 47     0.366 3
#> SD:hclust 49     0.432 4
#> SD:hclust 50     0.473 5
#> SD:hclust 48     0.466 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 21342 rows and 50 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 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-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.426           0.768       0.829         0.3563 0.650   0.650
#> 3 3 0.943           0.956       0.959         0.4921 0.764   0.651
#> 4 4 0.708           0.767       0.871         0.2925 0.909   0.803
#> 5 5 0.698           0.780       0.848         0.1082 0.853   0.606
#> 6 6 0.773           0.661       0.825         0.0633 0.974   0.884

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
#> GSM28735     1   0.939      0.820 0.644 0.356
#> GSM28736     1   0.939      0.820 0.644 0.356
#> GSM28737     1   0.939      0.820 0.644 0.356
#> GSM11249     1   0.000      0.520 1.000 0.000
#> GSM28745     2   0.000      0.975 0.000 1.000
#> GSM11244     2   0.000      0.975 0.000 1.000
#> GSM28748     2   0.000      0.975 0.000 1.000
#> GSM11266     2   0.000      0.975 0.000 1.000
#> GSM28730     2   0.000      0.975 0.000 1.000
#> GSM11253     2   0.000      0.975 0.000 1.000
#> GSM11254     2   0.000      0.975 0.000 1.000
#> GSM11260     2   0.000      0.975 0.000 1.000
#> GSM28733     2   0.000      0.975 0.000 1.000
#> GSM11265     1   0.939      0.820 0.644 0.356
#> GSM28739     1   0.939      0.820 0.644 0.356
#> GSM11243     1   0.680      0.308 0.820 0.180
#> GSM28740     1   0.939      0.820 0.644 0.356
#> GSM11259     1   0.939      0.820 0.644 0.356
#> GSM28726     1   0.939      0.820 0.644 0.356
#> GSM28743     1   0.939      0.820 0.644 0.356
#> GSM11256     1   0.855      0.793 0.720 0.280
#> GSM11262     1   0.939      0.820 0.644 0.356
#> GSM28724     1   0.939      0.820 0.644 0.356
#> GSM28725     1   0.680      0.308 0.820 0.180
#> GSM11263     1   0.680      0.308 0.820 0.180
#> GSM11267     1   0.680      0.308 0.820 0.180
#> GSM28744     1   0.855      0.793 0.720 0.280
#> GSM28734     1   0.855      0.793 0.720 0.280
#> GSM28747     1   0.939      0.820 0.644 0.356
#> GSM11257     1   0.917      0.813 0.668 0.332
#> GSM11252     1   0.866      0.798 0.712 0.288
#> GSM11264     1   0.680      0.308 0.820 0.180
#> GSM11247     1   0.680      0.308 0.820 0.180
#> GSM11258     1   0.855      0.793 0.720 0.280
#> GSM28728     1   0.939      0.820 0.644 0.356
#> GSM28746     1   0.881      0.802 0.700 0.300
#> GSM28738     1   0.939      0.820 0.644 0.356
#> GSM28741     2   0.605      0.703 0.148 0.852
#> GSM28729     1   0.939      0.820 0.644 0.356
#> GSM28742     1   0.939      0.820 0.644 0.356
#> GSM11250     2   0.000      0.975 0.000 1.000
#> GSM11245     1   0.866      0.798 0.712 0.288
#> GSM11246     1   0.939      0.820 0.644 0.356
#> GSM11261     1   0.971      0.655 0.600 0.400
#> GSM11248     1   0.000      0.520 1.000 0.000
#> GSM28732     1   0.939      0.820 0.644 0.356
#> GSM11255     1   0.866      0.798 0.712 0.288
#> GSM28731     1   0.939      0.820 0.644 0.356
#> GSM28727     1   0.939      0.820 0.644 0.356
#> GSM11251     1   0.939      0.820 0.644 0.356

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM28735     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28736     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28737     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11249     3  0.2261      0.994 0.068 0.000 0.932
#> GSM28745     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11244     2  0.1860      1.000 0.052 0.948 0.000
#> GSM28748     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11266     2  0.1860      1.000 0.052 0.948 0.000
#> GSM28730     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11253     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11254     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11260     2  0.1860      1.000 0.052 0.948 0.000
#> GSM28733     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11265     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28739     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11243     3  0.2749      0.994 0.064 0.012 0.924
#> GSM28740     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11259     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28726     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28743     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11256     1  0.3875      0.886 0.888 0.044 0.068
#> GSM11262     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28724     1  0.0000      0.967 1.000 0.000 0.000
#> GSM28725     3  0.2400      0.997 0.064 0.004 0.932
#> GSM11263     3  0.2400      0.997 0.064 0.004 0.932
#> GSM11267     3  0.2400      0.997 0.064 0.004 0.932
#> GSM28744     1  0.3875      0.886 0.888 0.044 0.068
#> GSM28734     1  0.3780      0.887 0.892 0.044 0.064
#> GSM28747     1  0.0000      0.967 1.000 0.000 0.000
#> GSM11257     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11252     1  0.0000      0.967 1.000 0.000 0.000
#> GSM11264     3  0.2400      0.997 0.064 0.004 0.932
#> GSM11247     3  0.2749      0.994 0.064 0.012 0.924
#> GSM11258     1  0.3780      0.887 0.892 0.044 0.064
#> GSM28728     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28746     1  0.0000      0.967 1.000 0.000 0.000
#> GSM28738     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28741     1  0.6398      0.234 0.580 0.416 0.004
#> GSM28729     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28742     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11250     2  0.1860      1.000 0.052 0.948 0.000
#> GSM11245     1  0.0000      0.967 1.000 0.000 0.000
#> GSM11246     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11261     1  0.1999      0.929 0.952 0.012 0.036
#> GSM11248     3  0.2261      0.994 0.068 0.000 0.932
#> GSM28732     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11255     1  0.0000      0.967 1.000 0.000 0.000
#> GSM28731     1  0.0000      0.967 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.967 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.967 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
#> GSM28735     1  0.0817      0.723 0.976 0.000 0.000 0.024
#> GSM28736     1  0.1302      0.715 0.956 0.000 0.000 0.044
#> GSM28737     1  0.4356      0.627 0.708 0.000 0.000 0.292
#> GSM11249     3  0.1940      0.927 0.000 0.000 0.924 0.076
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.4972      0.444 0.544 0.000 0.000 0.456
#> GSM28739     1  0.4972      0.444 0.544 0.000 0.000 0.456
#> GSM11243     3  0.1474      0.950 0.000 0.000 0.948 0.052
#> GSM28740     1  0.4972      0.444 0.544 0.000 0.000 0.456
#> GSM11259     1  0.0000      0.728 1.000 0.000 0.000 0.000
#> GSM28726     1  0.1302      0.715 0.956 0.000 0.000 0.044
#> GSM28743     1  0.4972      0.444 0.544 0.000 0.000 0.456
#> GSM11256     4  0.3123      0.916 0.156 0.000 0.000 0.844
#> GSM11262     1  0.4972      0.444 0.544 0.000 0.000 0.456
#> GSM28724     1  0.0707      0.731 0.980 0.000 0.000 0.020
#> GSM28725     3  0.0000      0.966 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.966 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.966 0.000 0.000 1.000 0.000
#> GSM28744     4  0.3123      0.916 0.156 0.000 0.000 0.844
#> GSM28734     4  0.2469      0.911 0.108 0.000 0.000 0.892
#> GSM28747     1  0.2345      0.721 0.900 0.000 0.000 0.100
#> GSM11257     1  0.3172      0.667 0.840 0.000 0.000 0.160
#> GSM11252     1  0.4830      0.501 0.608 0.000 0.000 0.392
#> GSM11264     3  0.0000      0.966 0.000 0.000 1.000 0.000
#> GSM11247     3  0.1474      0.950 0.000 0.000 0.948 0.052
#> GSM11258     4  0.1637      0.857 0.060 0.000 0.000 0.940
#> GSM28728     1  0.0188      0.728 0.996 0.000 0.000 0.004
#> GSM28746     1  0.4164      0.648 0.736 0.000 0.000 0.264
#> GSM28738     1  0.1302      0.715 0.956 0.000 0.000 0.044
#> GSM28741     1  0.4343      0.439 0.732 0.264 0.000 0.004
#> GSM28729     1  0.1211      0.717 0.960 0.000 0.000 0.040
#> GSM28742     1  0.1302      0.715 0.956 0.000 0.000 0.044
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11245     1  0.4877      0.480 0.592 0.000 0.000 0.408
#> GSM11246     1  0.4955      0.463 0.556 0.000 0.000 0.444
#> GSM11261     1  0.6194      0.436 0.644 0.000 0.096 0.260
#> GSM11248     3  0.1940      0.927 0.000 0.000 0.924 0.076
#> GSM28732     1  0.0188      0.729 0.996 0.000 0.000 0.004
#> GSM11255     1  0.4855      0.517 0.600 0.000 0.000 0.400
#> GSM28731     1  0.1557      0.729 0.944 0.000 0.000 0.056
#> GSM28727     1  0.1557      0.729 0.944 0.000 0.000 0.056
#> GSM11251     1  0.1557      0.729 0.944 0.000 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.0798      0.773 0.008 0.000 0.000 0.016 0.976
#> GSM28736     5  0.0798      0.773 0.008 0.000 0.000 0.016 0.976
#> GSM28737     1  0.3752      0.744 0.708 0.000 0.000 0.000 0.292
#> GSM11249     3  0.4035      0.753 0.060 0.000 0.784 0.156 0.000
#> GSM28745     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.3427      0.862 0.796 0.000 0.000 0.012 0.192
#> GSM28739     1  0.3427      0.862 0.796 0.000 0.000 0.012 0.192
#> GSM11243     3  0.3704      0.815 0.092 0.000 0.820 0.088 0.000
#> GSM28740     1  0.3427      0.862 0.796 0.000 0.000 0.012 0.192
#> GSM11259     5  0.1124      0.771 0.036 0.000 0.000 0.004 0.960
#> GSM28726     5  0.0798      0.773 0.008 0.000 0.000 0.016 0.976
#> GSM28743     1  0.3427      0.862 0.796 0.000 0.000 0.012 0.192
#> GSM11256     4  0.3193      0.953 0.132 0.000 0.000 0.840 0.028
#> GSM11262     1  0.3427      0.862 0.796 0.000 0.000 0.012 0.192
#> GSM28724     5  0.1965      0.763 0.052 0.000 0.000 0.024 0.924
#> GSM28725     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.3193      0.953 0.132 0.000 0.000 0.840 0.028
#> GSM28734     4  0.3106      0.952 0.140 0.000 0.000 0.840 0.020
#> GSM28747     5  0.4283      0.294 0.348 0.000 0.000 0.008 0.644
#> GSM11257     5  0.3825      0.660 0.060 0.000 0.000 0.136 0.804
#> GSM11252     1  0.6034      0.579 0.572 0.000 0.000 0.172 0.256
#> GSM11264     3  0.0000      0.885 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.3704      0.815 0.092 0.000 0.820 0.088 0.000
#> GSM11258     4  0.3642      0.871 0.232 0.000 0.000 0.760 0.008
#> GSM28728     5  0.0898      0.774 0.020 0.000 0.000 0.008 0.972
#> GSM28746     5  0.6085     -0.187 0.404 0.000 0.000 0.124 0.472
#> GSM28738     5  0.1549      0.752 0.040 0.000 0.000 0.016 0.944
#> GSM28741     5  0.4271      0.597 0.024 0.180 0.000 0.024 0.772
#> GSM28729     5  0.1281      0.774 0.032 0.000 0.000 0.012 0.956
#> GSM28742     5  0.0807      0.773 0.012 0.000 0.000 0.012 0.976
#> GSM11250     2  0.0579      0.986 0.008 0.984 0.000 0.008 0.000
#> GSM11245     1  0.6023      0.581 0.576 0.000 0.000 0.176 0.248
#> GSM11246     1  0.3177      0.851 0.792 0.000 0.000 0.000 0.208
#> GSM11261     5  0.6107      0.431 0.144 0.000 0.012 0.244 0.600
#> GSM11248     3  0.4159      0.746 0.068 0.000 0.776 0.156 0.000
#> GSM28732     5  0.1282      0.769 0.044 0.000 0.000 0.004 0.952
#> GSM11255     1  0.4087      0.769 0.756 0.000 0.000 0.036 0.208
#> GSM28731     5  0.4387      0.293 0.348 0.000 0.000 0.012 0.640
#> GSM28727     5  0.3671      0.555 0.236 0.000 0.000 0.008 0.756
#> GSM11251     5  0.4003      0.455 0.288 0.000 0.000 0.008 0.704

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.2213     0.6170 0.008 0.000 0.000 0.004 0.888 0.100
#> GSM28736     5  0.2213     0.6170 0.008 0.000 0.000 0.004 0.888 0.100
#> GSM28737     1  0.1610     0.7443 0.916 0.000 0.000 0.000 0.084 0.000
#> GSM11249     3  0.5560     0.5159 0.056 0.000 0.588 0.056 0.000 0.300
#> GSM28745     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0146     0.9939 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM11266     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.1531     0.7577 0.928 0.000 0.000 0.004 0.068 0.000
#> GSM28739     1  0.1531     0.7577 0.928 0.000 0.000 0.004 0.068 0.000
#> GSM11243     3  0.3582     0.6944 0.000 0.000 0.732 0.016 0.000 0.252
#> GSM28740     1  0.1531     0.7577 0.928 0.000 0.000 0.004 0.068 0.000
#> GSM11259     5  0.2003     0.6314 0.044 0.000 0.000 0.000 0.912 0.044
#> GSM28726     5  0.2791     0.6108 0.008 0.000 0.000 0.016 0.852 0.124
#> GSM28743     1  0.1531     0.7577 0.928 0.000 0.000 0.004 0.068 0.000
#> GSM11256     4  0.1219     0.9697 0.048 0.000 0.000 0.948 0.004 0.000
#> GSM11262     1  0.1531     0.7577 0.928 0.000 0.000 0.004 0.068 0.000
#> GSM28724     5  0.4171     0.4022 0.040 0.000 0.000 0.008 0.716 0.236
#> GSM28725     3  0.0000     0.8022 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000     0.8022 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     0.8022 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.1219     0.9697 0.048 0.000 0.000 0.948 0.004 0.000
#> GSM28734     4  0.1219     0.9697 0.048 0.000 0.000 0.948 0.004 0.000
#> GSM28747     5  0.4637     0.2022 0.308 0.000 0.000 0.000 0.628 0.064
#> GSM11257     5  0.5166     0.0718 0.012 0.000 0.000 0.060 0.528 0.400
#> GSM11252     1  0.6233     0.0838 0.460 0.000 0.000 0.044 0.120 0.376
#> GSM11264     3  0.0000     0.8022 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.3582     0.6944 0.000 0.000 0.732 0.016 0.000 0.252
#> GSM11258     4  0.2048     0.9082 0.120 0.000 0.000 0.880 0.000 0.000
#> GSM28728     5  0.2070     0.6100 0.008 0.000 0.000 0.000 0.892 0.100
#> GSM28746     6  0.6666     0.1726 0.304 0.000 0.000 0.028 0.324 0.344
#> GSM28738     5  0.4138     0.4206 0.012 0.000 0.000 0.012 0.664 0.312
#> GSM28741     5  0.4802     0.4119 0.008 0.132 0.000 0.016 0.724 0.120
#> GSM28729     5  0.3030     0.5905 0.008 0.000 0.000 0.008 0.816 0.168
#> GSM28742     5  0.2658     0.6176 0.008 0.000 0.000 0.016 0.864 0.112
#> GSM11250     2  0.0964     0.9718 0.004 0.968 0.000 0.012 0.000 0.016
#> GSM11245     1  0.6299     0.0885 0.460 0.000 0.000 0.052 0.116 0.372
#> GSM11246     1  0.1556     0.7492 0.920 0.000 0.000 0.000 0.080 0.000
#> GSM11261     6  0.5034     0.1775 0.004 0.000 0.000 0.080 0.328 0.588
#> GSM11248     3  0.5575     0.5112 0.056 0.000 0.584 0.056 0.000 0.304
#> GSM28732     5  0.2190     0.6251 0.040 0.000 0.000 0.000 0.900 0.060
#> GSM11255     1  0.5119     0.2444 0.552 0.000 0.000 0.008 0.068 0.372
#> GSM28731     5  0.5169     0.1772 0.292 0.000 0.000 0.000 0.588 0.120
#> GSM28727     5  0.2573     0.5750 0.132 0.000 0.000 0.004 0.856 0.008
#> GSM11251     5  0.3329     0.4365 0.236 0.000 0.000 0.004 0.756 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 tissue(p) k
#> SD:kmeans 44     0.387 2
#> SD:kmeans 49     0.368 3
#> SD:kmeans 41     0.407 4
#> SD:kmeans 45     0.483 5
#> SD:kmeans 38     0.472 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 21342 rows and 50 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

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

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4708 0.530   0.530
#> 3 3 0.825           0.913       0.961         0.3542 0.746   0.557
#> 4 4 0.802           0.843       0.892         0.1763 0.789   0.484
#> 5 5 0.846           0.815       0.904         0.0711 0.949   0.797
#> 6 6 0.841           0.753       0.808         0.0393 0.980   0.903

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
#> GSM28735     1  0.0000      1.000 1.000 0.000
#> GSM28736     1  0.0376      0.996 0.996 0.004
#> GSM28737     1  0.0000      1.000 1.000 0.000
#> GSM11249     1  0.0000      1.000 1.000 0.000
#> GSM28745     2  0.0000      1.000 0.000 1.000
#> GSM11244     2  0.0000      1.000 0.000 1.000
#> GSM28748     2  0.0000      1.000 0.000 1.000
#> GSM11266     2  0.0000      1.000 0.000 1.000
#> GSM28730     2  0.0000      1.000 0.000 1.000
#> GSM11253     2  0.0000      1.000 0.000 1.000
#> GSM11254     2  0.0000      1.000 0.000 1.000
#> GSM11260     2  0.0000      1.000 0.000 1.000
#> GSM28733     2  0.0000      1.000 0.000 1.000
#> GSM11265     1  0.0000      1.000 1.000 0.000
#> GSM28739     1  0.0000      1.000 1.000 0.000
#> GSM11243     2  0.0000      1.000 0.000 1.000
#> GSM28740     1  0.0000      1.000 1.000 0.000
#> GSM11259     1  0.0000      1.000 1.000 0.000
#> GSM28726     1  0.0000      1.000 1.000 0.000
#> GSM28743     1  0.0000      1.000 1.000 0.000
#> GSM11256     1  0.0000      1.000 1.000 0.000
#> GSM11262     1  0.0000      1.000 1.000 0.000
#> GSM28724     1  0.0000      1.000 1.000 0.000
#> GSM28725     2  0.0000      1.000 0.000 1.000
#> GSM11263     2  0.0000      1.000 0.000 1.000
#> GSM11267     2  0.0000      1.000 0.000 1.000
#> GSM28744     1  0.0000      1.000 1.000 0.000
#> GSM28734     1  0.0000      1.000 1.000 0.000
#> GSM28747     1  0.0000      1.000 1.000 0.000
#> GSM11257     1  0.0000      1.000 1.000 0.000
#> GSM11252     1  0.0000      1.000 1.000 0.000
#> GSM11264     2  0.0000      1.000 0.000 1.000
#> GSM11247     2  0.0000      1.000 0.000 1.000
#> GSM11258     1  0.0000      1.000 1.000 0.000
#> GSM28728     1  0.0000      1.000 1.000 0.000
#> GSM28746     1  0.0000      1.000 1.000 0.000
#> GSM28738     1  0.0000      1.000 1.000 0.000
#> GSM28741     2  0.0000      1.000 0.000 1.000
#> GSM28729     1  0.0000      1.000 1.000 0.000
#> GSM28742     1  0.0000      1.000 1.000 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000
#> GSM11245     1  0.0000      1.000 1.000 0.000
#> GSM11246     1  0.0000      1.000 1.000 0.000
#> GSM11261     2  0.0000      1.000 0.000 1.000
#> GSM11248     1  0.0000      1.000 1.000 0.000
#> GSM28732     1  0.0000      1.000 1.000 0.000
#> GSM11255     1  0.0000      1.000 1.000 0.000
#> GSM28731     1  0.0000      1.000 1.000 0.000
#> GSM28727     1  0.0000      1.000 1.000 0.000
#> GSM11251     1  0.0000      1.000 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
#> GSM28735     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28736     2  0.0747      0.980 0.016 0.984 0.000
#> GSM28737     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11249     3  0.0000      0.915 0.000 0.000 1.000
#> GSM28745     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11244     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28748     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11266     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28730     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11253     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11254     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11260     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28733     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11243     3  0.0000      0.915 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28726     1  0.4235      0.783 0.824 0.176 0.000
#> GSM28743     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11256     3  0.4931      0.727 0.232 0.000 0.768
#> GSM11262     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28724     1  0.4654      0.733 0.792 0.000 0.208
#> GSM28725     3  0.0000      0.915 0.000 0.000 1.000
#> GSM11263     3  0.0000      0.915 0.000 0.000 1.000
#> GSM11267     3  0.0000      0.915 0.000 0.000 1.000
#> GSM28744     3  0.4931      0.727 0.232 0.000 0.768
#> GSM28734     3  0.1753      0.888 0.048 0.000 0.952
#> GSM28747     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11257     1  0.3116      0.856 0.892 0.000 0.108
#> GSM11252     1  0.5785      0.454 0.668 0.000 0.332
#> GSM11264     3  0.0000      0.915 0.000 0.000 1.000
#> GSM11247     3  0.0000      0.915 0.000 0.000 1.000
#> GSM11258     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28728     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28746     1  0.1964      0.906 0.944 0.000 0.056
#> GSM28738     1  0.0747      0.939 0.984 0.016 0.000
#> GSM28741     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28729     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28742     1  0.4121      0.793 0.832 0.168 0.000
#> GSM11250     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11245     3  0.5835      0.535 0.340 0.000 0.660
#> GSM11246     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11261     3  0.0000      0.915 0.000 0.000 1.000
#> GSM11248     3  0.0000      0.915 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11255     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28731     1  0.0000      0.951 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.951 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.951 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
#> GSM28735     1  0.0469      0.770 0.988 0.000 0.000 0.012
#> GSM28736     1  0.1004      0.753 0.972 0.024 0.000 0.004
#> GSM28737     4  0.1389      0.846 0.048 0.000 0.000 0.952
#> GSM11249     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11265     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM28739     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28740     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM11259     1  0.4072      0.742 0.748 0.000 0.000 0.252
#> GSM28726     1  0.0779      0.776 0.980 0.004 0.000 0.016
#> GSM28743     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM11256     4  0.5206      0.577 0.308 0.000 0.024 0.668
#> GSM11262     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM28724     1  0.6614      0.553 0.548 0.000 0.092 0.360
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28744     4  0.5161      0.587 0.300 0.000 0.024 0.676
#> GSM28734     4  0.5964      0.613 0.208 0.000 0.108 0.684
#> GSM28747     1  0.4776      0.594 0.624 0.000 0.000 0.376
#> GSM11257     1  0.5149      0.291 0.648 0.000 0.016 0.336
#> GSM11252     4  0.3933      0.653 0.200 0.000 0.008 0.792
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11258     4  0.1211      0.832 0.040 0.000 0.000 0.960
#> GSM28728     1  0.1716      0.781 0.936 0.000 0.000 0.064
#> GSM28746     4  0.2805      0.791 0.100 0.000 0.012 0.888
#> GSM28738     1  0.0336      0.763 0.992 0.000 0.000 0.008
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28729     1  0.1118      0.780 0.964 0.000 0.000 0.036
#> GSM28742     1  0.0707      0.777 0.980 0.000 0.000 0.020
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11245     4  0.4364      0.749 0.092 0.000 0.092 0.816
#> GSM11246     4  0.0921      0.858 0.028 0.000 0.000 0.972
#> GSM11261     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM11248     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM28732     1  0.4103      0.740 0.744 0.000 0.000 0.256
#> GSM11255     4  0.0592      0.855 0.016 0.000 0.000 0.984
#> GSM28731     1  0.4356      0.712 0.708 0.000 0.000 0.292
#> GSM28727     1  0.4222      0.729 0.728 0.000 0.000 0.272
#> GSM11251     1  0.4222      0.729 0.728 0.000 0.000 0.272

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.1952      0.769 0.004 0.000 0.000 0.084 0.912
#> GSM28736     5  0.1892      0.768 0.000 0.004 0.000 0.080 0.916
#> GSM28737     1  0.0162      0.824 0.996 0.000 0.000 0.000 0.004
#> GSM11249     3  0.0794      0.973 0.000 0.000 0.972 0.028 0.000
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM11259     5  0.2329      0.786 0.124 0.000 0.000 0.000 0.876
#> GSM28726     5  0.1197      0.780 0.000 0.000 0.000 0.048 0.952
#> GSM28743     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.0290      0.879 0.008 0.000 0.000 0.992 0.000
#> GSM11262     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM28724     5  0.7145      0.399 0.212 0.000 0.040 0.248 0.500
#> GSM28725     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.0290      0.879 0.008 0.000 0.000 0.992 0.000
#> GSM28734     4  0.0794      0.870 0.028 0.000 0.000 0.972 0.000
#> GSM28747     5  0.4781      0.387 0.428 0.000 0.000 0.020 0.552
#> GSM11257     4  0.2011      0.827 0.004 0.000 0.000 0.908 0.088
#> GSM11252     1  0.6144      0.286 0.496 0.000 0.008 0.392 0.104
#> GSM11264     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000
#> GSM11258     4  0.3837      0.525 0.308 0.000 0.000 0.692 0.000
#> GSM28728     5  0.1579      0.790 0.032 0.000 0.000 0.024 0.944
#> GSM28746     1  0.6092      0.167 0.464 0.000 0.000 0.412 0.124
#> GSM28738     5  0.3210      0.650 0.000 0.000 0.000 0.212 0.788
#> GSM28741     2  0.0162      0.995 0.000 0.996 0.000 0.000 0.004
#> GSM28729     5  0.1082      0.786 0.008 0.000 0.000 0.028 0.964
#> GSM28742     5  0.1121      0.780 0.000 0.000 0.000 0.044 0.956
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11245     1  0.6245      0.255 0.496 0.000 0.048 0.408 0.048
#> GSM11246     1  0.0162      0.824 0.996 0.000 0.000 0.000 0.004
#> GSM11261     3  0.0162      0.991 0.000 0.000 0.996 0.004 0.000
#> GSM11248     3  0.0510      0.983 0.000 0.000 0.984 0.016 0.000
#> GSM28732     5  0.2338      0.787 0.112 0.000 0.000 0.004 0.884
#> GSM11255     1  0.2522      0.769 0.896 0.000 0.004 0.076 0.024
#> GSM28731     5  0.4430      0.534 0.360 0.000 0.000 0.012 0.628
#> GSM28727     5  0.3210      0.736 0.212 0.000 0.000 0.000 0.788
#> GSM11251     5  0.3707      0.670 0.284 0.000 0.000 0.000 0.716

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.3978      0.551 0.000 0.000 0.000 0.032 0.700 0.268
#> GSM28736     5  0.4060      0.547 0.000 0.000 0.000 0.032 0.684 0.284
#> GSM28737     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11249     3  0.3279      0.783 0.000 0.000 0.796 0.028 0.000 0.176
#> GSM28745     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28740     1  0.0000      0.910 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     5  0.3308      0.606 0.072 0.000 0.000 0.004 0.828 0.096
#> GSM28726     5  0.3482      0.569 0.000 0.000 0.000 0.000 0.684 0.316
#> GSM28743     1  0.0146      0.908 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11256     4  0.0146      0.818 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM11262     1  0.0146      0.908 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM28724     5  0.7454      0.223 0.108 0.000 0.040 0.140 0.480 0.232
#> GSM28725     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0146      0.818 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM28734     4  0.0291      0.815 0.004 0.000 0.000 0.992 0.000 0.004
#> GSM28747     5  0.5572      0.332 0.288 0.000 0.000 0.004 0.552 0.156
#> GSM11257     4  0.4092      0.584 0.004 0.000 0.000 0.740 0.060 0.196
#> GSM11252     6  0.6347      0.651 0.224 0.000 0.004 0.264 0.020 0.488
#> GSM11264     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000      0.950 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11258     4  0.2941      0.561 0.220 0.000 0.000 0.780 0.000 0.000
#> GSM28728     5  0.3919      0.598 0.016 0.000 0.008 0.004 0.728 0.244
#> GSM28746     6  0.7522      0.290 0.224 0.000 0.000 0.232 0.176 0.368
#> GSM28738     5  0.5259      0.468 0.000 0.000 0.000 0.096 0.468 0.436
#> GSM28741     2  0.0520      0.983 0.000 0.984 0.000 0.000 0.008 0.008
#> GSM28729     5  0.3944      0.519 0.000 0.000 0.000 0.004 0.568 0.428
#> GSM28742     5  0.3578      0.565 0.000 0.000 0.000 0.000 0.660 0.340
#> GSM11250     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.6425      0.646 0.208 0.000 0.008 0.280 0.020 0.484
#> GSM11246     1  0.0146      0.906 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11261     3  0.0146      0.947 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM11248     3  0.2932      0.809 0.000 0.000 0.820 0.016 0.000 0.164
#> GSM28732     5  0.3727      0.552 0.040 0.000 0.000 0.004 0.768 0.188
#> GSM11255     1  0.4868     -0.115 0.548 0.000 0.000 0.044 0.008 0.400
#> GSM28731     5  0.5837      0.384 0.212 0.000 0.000 0.008 0.536 0.244
#> GSM28727     5  0.3279      0.564 0.176 0.000 0.000 0.000 0.796 0.028
#> GSM11251     5  0.3695      0.519 0.244 0.000 0.000 0.000 0.732 0.024

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 tissue(p) k
#> SD:skmeans 50     0.394 2
#> SD:skmeans 49     0.449 3
#> SD:skmeans 49     0.348 4
#> SD:skmeans 45     0.471 5
#> SD:skmeans 44     0.440 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 21342 rows and 50 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 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 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 1.000           1.000       1.000         0.3509 0.650   0.650
#> 3 3 1.000           0.999       1.000         0.5752 0.798   0.688
#> 4 4 1.000           0.979       0.990         0.1658 0.912   0.803
#> 5 5 0.780           0.743       0.890         0.1341 0.925   0.791
#> 6 6 0.797           0.800       0.863         0.0758 0.930   0.760

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

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following 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
#> GSM28735     1       0          1  1  0
#> GSM28736     1       0          1  1  0
#> GSM28737     1       0          1  1  0
#> GSM11249     1       0          1  1  0
#> GSM28745     2       0          1  0  1
#> GSM11244     2       0          1  0  1
#> GSM28748     2       0          1  0  1
#> GSM11266     2       0          1  0  1
#> GSM28730     2       0          1  0  1
#> GSM11253     2       0          1  0  1
#> GSM11254     2       0          1  0  1
#> GSM11260     2       0          1  0  1
#> GSM28733     2       0          1  0  1
#> GSM11265     1       0          1  1  0
#> GSM28739     1       0          1  1  0
#> GSM11243     1       0          1  1  0
#> GSM28740     1       0          1  1  0
#> GSM11259     1       0          1  1  0
#> GSM28726     1       0          1  1  0
#> GSM28743     1       0          1  1  0
#> GSM11256     1       0          1  1  0
#> GSM11262     1       0          1  1  0
#> GSM28724     1       0          1  1  0
#> GSM28725     1       0          1  1  0
#> GSM11263     1       0          1  1  0
#> GSM11267     1       0          1  1  0
#> GSM28744     1       0          1  1  0
#> GSM28734     1       0          1  1  0
#> GSM28747     1       0          1  1  0
#> GSM11257     1       0          1  1  0
#> GSM11252     1       0          1  1  0
#> GSM11264     1       0          1  1  0
#> GSM11247     1       0          1  1  0
#> GSM11258     1       0          1  1  0
#> GSM28728     1       0          1  1  0
#> GSM28746     1       0          1  1  0
#> GSM28738     1       0          1  1  0
#> GSM28741     2       0          1  0  1
#> GSM28729     1       0          1  1  0
#> GSM28742     1       0          1  1  0
#> GSM11250     2       0          1  0  1
#> GSM11245     1       0          1  1  0
#> GSM11246     1       0          1  1  0
#> GSM11261     1       0          1  1  0
#> GSM11248     1       0          1  1  0
#> GSM28732     1       0          1  1  0
#> GSM11255     1       0          1  1  0
#> GSM28731     1       0          1  1  0
#> GSM28727     1       0          1  1  0
#> GSM11251     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM28735     1   0.000      1.000 1.000  0 0.000
#> GSM28736     1   0.000      1.000 1.000  0 0.000
#> GSM28737     1   0.000      1.000 1.000  0 0.000
#> GSM11249     3   0.000      0.995 0.000  0 1.000
#> GSM28745     2   0.000      1.000 0.000  1 0.000
#> GSM11244     2   0.000      1.000 0.000  1 0.000
#> GSM28748     2   0.000      1.000 0.000  1 0.000
#> GSM11266     2   0.000      1.000 0.000  1 0.000
#> GSM28730     2   0.000      1.000 0.000  1 0.000
#> GSM11253     2   0.000      1.000 0.000  1 0.000
#> GSM11254     2   0.000      1.000 0.000  1 0.000
#> GSM11260     2   0.000      1.000 0.000  1 0.000
#> GSM28733     2   0.000      1.000 0.000  1 0.000
#> GSM11265     1   0.000      1.000 1.000  0 0.000
#> GSM28739     1   0.000      1.000 1.000  0 0.000
#> GSM11243     3   0.000      0.995 0.000  0 1.000
#> GSM28740     1   0.000      1.000 1.000  0 0.000
#> GSM11259     1   0.000      1.000 1.000  0 0.000
#> GSM28726     1   0.000      1.000 1.000  0 0.000
#> GSM28743     1   0.000      1.000 1.000  0 0.000
#> GSM11256     1   0.000      1.000 1.000  0 0.000
#> GSM11262     1   0.000      1.000 1.000  0 0.000
#> GSM28724     1   0.000      1.000 1.000  0 0.000
#> GSM28725     3   0.000      0.995 0.000  0 1.000
#> GSM11263     3   0.000      0.995 0.000  0 1.000
#> GSM11267     3   0.000      0.995 0.000  0 1.000
#> GSM28744     1   0.000      1.000 1.000  0 0.000
#> GSM28734     1   0.000      1.000 1.000  0 0.000
#> GSM28747     1   0.000      1.000 1.000  0 0.000
#> GSM11257     1   0.000      1.000 1.000  0 0.000
#> GSM11252     1   0.000      1.000 1.000  0 0.000
#> GSM11264     3   0.000      0.995 0.000  0 1.000
#> GSM11247     3   0.000      0.995 0.000  0 1.000
#> GSM11258     1   0.000      1.000 1.000  0 0.000
#> GSM28728     1   0.000      1.000 1.000  0 0.000
#> GSM28746     1   0.000      1.000 1.000  0 0.000
#> GSM28738     1   0.000      1.000 1.000  0 0.000
#> GSM28741     2   0.000      1.000 0.000  1 0.000
#> GSM28729     1   0.000      1.000 1.000  0 0.000
#> GSM28742     1   0.000      1.000 1.000  0 0.000
#> GSM11250     2   0.000      1.000 0.000  1 0.000
#> GSM11245     1   0.000      1.000 1.000  0 0.000
#> GSM11246     1   0.000      1.000 1.000  0 0.000
#> GSM11261     1   0.000      1.000 1.000  0 0.000
#> GSM11248     3   0.103      0.965 0.024  0 0.976
#> GSM28732     1   0.000      1.000 1.000  0 0.000
#> GSM11255     1   0.000      1.000 1.000  0 0.000
#> GSM28731     1   0.000      1.000 1.000  0 0.000
#> GSM28727     1   0.000      1.000 1.000  0 0.000
#> GSM11251     1   0.000      1.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM28735     1  0.0592      0.982 0.984  0 0.000 0.016
#> GSM28736     1  0.0707      0.980 0.980  0 0.000 0.020
#> GSM28737     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11249     3  0.0707      0.972 0.000  0 0.980 0.020
#> GSM28745     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11265     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28739     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11243     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM28740     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11259     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28726     1  0.0336      0.985 0.992  0 0.000 0.008
#> GSM28743     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11256     4  0.0000      0.955 0.000  0 0.000 1.000
#> GSM11262     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28724     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28725     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM11263     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM11267     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM28744     4  0.0188      0.958 0.004  0 0.000 0.996
#> GSM28734     4  0.0188      0.958 0.004  0 0.000 0.996
#> GSM28747     1  0.0336      0.985 0.992  0 0.000 0.008
#> GSM11257     1  0.3486      0.781 0.812  0 0.000 0.188
#> GSM11252     1  0.0707      0.980 0.980  0 0.000 0.020
#> GSM11264     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM11247     3  0.0000      0.987 0.000  0 1.000 0.000
#> GSM11258     4  0.2081      0.880 0.084  0 0.000 0.916
#> GSM28728     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28746     1  0.0592      0.982 0.984  0 0.000 0.016
#> GSM28738     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28741     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28729     1  0.0336      0.985 0.992  0 0.000 0.008
#> GSM28742     1  0.0707      0.980 0.980  0 0.000 0.020
#> GSM11250     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11245     1  0.0707      0.980 0.980  0 0.000 0.020
#> GSM11246     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11261     1  0.0336      0.985 0.992  0 0.000 0.008
#> GSM11248     3  0.1624      0.935 0.028  0 0.952 0.020
#> GSM28732     1  0.0707      0.980 0.980  0 0.000 0.020
#> GSM11255     1  0.0188      0.986 0.996  0 0.000 0.004
#> GSM28731     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM28727     1  0.0000      0.987 1.000  0 0.000 0.000
#> GSM11251     1  0.0000      0.987 1.000  0 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
#> GSM28735     1   0.366     0.5898 0.724 0.00 0.000 0.000 0.276
#> GSM28736     5   0.228     0.5566 0.120 0.00 0.000 0.000 0.880
#> GSM28737     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM11249     3   0.426     0.4887 0.000 0.00 0.564 0.000 0.436
#> GSM28745     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11244     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM28748     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11266     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM28730     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11253     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11254     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11260     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM28733     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11265     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM28739     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM11243     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM28740     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM11259     1   0.233     0.7706 0.876 0.00 0.000 0.000 0.124
#> GSM28726     5   0.410     0.4669 0.372 0.00 0.000 0.000 0.628
#> GSM28743     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM11256     4   0.000     0.9508 0.000 0.00 0.000 1.000 0.000
#> GSM11262     1   0.000     0.7982 1.000 0.00 0.000 0.000 0.000
#> GSM28724     1   0.191     0.7897 0.908 0.00 0.000 0.000 0.092
#> GSM28725     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM11263     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM11267     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM28744     4   0.000     0.9508 0.000 0.00 0.000 1.000 0.000
#> GSM28734     4   0.000     0.9508 0.000 0.00 0.000 1.000 0.000
#> GSM28747     1   0.252     0.7649 0.860 0.00 0.000 0.000 0.140
#> GSM11257     5   0.499     0.0490 0.416 0.00 0.000 0.032 0.552
#> GSM11252     1   0.430    -0.0821 0.524 0.00 0.000 0.000 0.476
#> GSM11264     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM11247     3   0.000     0.8616 0.000 0.00 1.000 0.000 0.000
#> GSM11258     4   0.223     0.8403 0.116 0.00 0.000 0.884 0.000
#> GSM28728     1   0.104     0.8038 0.960 0.00 0.000 0.000 0.040
#> GSM28746     1   0.297     0.5945 0.816 0.00 0.000 0.000 0.184
#> GSM28738     1   0.273     0.7447 0.840 0.00 0.000 0.000 0.160
#> GSM28741     2   0.413     0.5246 0.000 0.62 0.000 0.000 0.380
#> GSM28729     1   0.218     0.7859 0.888 0.00 0.000 0.000 0.112
#> GSM28742     5   0.337     0.6403 0.232 0.00 0.000 0.000 0.768
#> GSM11250     2   0.000     0.9621 0.000 1.00 0.000 0.000 0.000
#> GSM11245     1   0.429    -0.0740 0.540 0.00 0.000 0.000 0.460
#> GSM11246     1   0.104     0.8038 0.960 0.00 0.000 0.000 0.040
#> GSM11261     1   0.088     0.7901 0.968 0.00 0.000 0.000 0.032
#> GSM11248     3   0.440     0.4815 0.004 0.00 0.560 0.000 0.436
#> GSM28732     1   0.377     0.5271 0.704 0.00 0.000 0.000 0.296
#> GSM11255     1   0.324     0.4918 0.784 0.00 0.000 0.000 0.216
#> GSM28731     1   0.104     0.8038 0.960 0.00 0.000 0.000 0.040
#> GSM28727     1   0.238     0.7701 0.872 0.00 0.000 0.000 0.128
#> GSM11251     1   0.233     0.7706 0.876 0.00 0.000 0.000 0.124

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     1  0.2491      0.534 0.836 0.000 0.000 0.000 0.164 0.000
#> GSM28736     5  0.3927      0.899 0.344 0.000 0.000 0.000 0.644 0.012
#> GSM28737     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM11249     6  0.0790      0.856 0.000 0.000 0.032 0.000 0.000 0.968
#> GSM28745     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM28739     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM11243     3  0.0458      0.988 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM28740     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM11259     1  0.0146      0.737 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM28726     5  0.3634      0.899 0.356 0.000 0.000 0.000 0.644 0.000
#> GSM28743     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM11256     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11262     1  0.3446      0.716 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM28724     1  0.1967      0.753 0.904 0.000 0.000 0.000 0.084 0.012
#> GSM28725     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28747     1  0.0146      0.737 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11257     6  0.3511      0.691 0.148 0.000 0.000 0.004 0.048 0.800
#> GSM11252     6  0.0790      0.867 0.032 0.000 0.000 0.000 0.000 0.968
#> GSM11264     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0458      0.988 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM11258     4  0.4265      0.570 0.040 0.000 0.000 0.660 0.300 0.000
#> GSM28728     1  0.0000      0.739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28746     1  0.5449      0.602 0.572 0.000 0.000 0.000 0.240 0.188
#> GSM28738     1  0.2968      0.521 0.816 0.000 0.000 0.000 0.168 0.016
#> GSM28741     2  0.4702      0.104 0.044 0.496 0.000 0.000 0.460 0.000
#> GSM28729     1  0.0692      0.738 0.976 0.000 0.000 0.000 0.004 0.020
#> GSM28742     5  0.5624      0.805 0.356 0.000 0.000 0.000 0.488 0.156
#> GSM11250     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.0790      0.867 0.032 0.000 0.000 0.000 0.000 0.968
#> GSM11246     1  0.2135      0.752 0.872 0.000 0.000 0.000 0.128 0.000
#> GSM11261     1  0.4653      0.664 0.684 0.000 0.000 0.000 0.120 0.196
#> GSM11248     6  0.0790      0.856 0.000 0.000 0.032 0.000 0.000 0.968
#> GSM28732     1  0.2854      0.602 0.792 0.000 0.000 0.000 0.000 0.208
#> GSM11255     6  0.2941      0.643 0.220 0.000 0.000 0.000 0.000 0.780
#> GSM28731     1  0.0363      0.741 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM28727     1  0.0146      0.737 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11251     1  0.0146      0.737 0.996 0.000 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-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 tissue(p) k
#> SD:pam 50     0.394 2
#> SD:pam 50     0.370 3
#> SD:pam 50     0.512 4
#> SD:pam 43     0.451 5
#> SD:pam 49     0.439 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 21342 rows and 50 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

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

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.458           0.482       0.775         0.4558 0.503   0.503
#> 3 3 0.622           0.826       0.913         0.3358 0.603   0.376
#> 4 4 0.784           0.887       0.920         0.0839 0.864   0.691
#> 5 5 0.664           0.702       0.838         0.1410 0.819   0.537
#> 6 6 0.695           0.567       0.740         0.0526 0.855   0.470

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
#> GSM28735     2   0.983     -0.523 0.424 0.576
#> GSM28736     2   0.595      0.220 0.144 0.856
#> GSM28737     1   0.988      0.761 0.564 0.436
#> GSM11249     1   0.000      0.376 1.000 0.000
#> GSM28745     2   0.975      0.571 0.408 0.592
#> GSM11244     2   0.975      0.571 0.408 0.592
#> GSM28748     2   0.975      0.571 0.408 0.592
#> GSM11266     2   0.975      0.571 0.408 0.592
#> GSM28730     2   0.975      0.571 0.408 0.592
#> GSM11253     2   0.975      0.571 0.408 0.592
#> GSM11254     2   0.975      0.571 0.408 0.592
#> GSM11260     2   0.975      0.571 0.408 0.592
#> GSM28733     2   0.975      0.571 0.408 0.592
#> GSM11265     1   0.988      0.761 0.564 0.436
#> GSM28739     1   0.988      0.761 0.564 0.436
#> GSM11243     1   0.000      0.376 1.000 0.000
#> GSM28740     1   0.988      0.761 0.564 0.436
#> GSM11259     1   0.988      0.761 0.564 0.436
#> GSM28726     2   0.985     -0.531 0.428 0.572
#> GSM28743     1   0.988      0.761 0.564 0.436
#> GSM11256     2   0.714      0.273 0.196 0.804
#> GSM11262     1   0.988      0.761 0.564 0.436
#> GSM28724     1   0.988      0.761 0.564 0.436
#> GSM28725     1   0.000      0.376 1.000 0.000
#> GSM11263     1   0.000      0.376 1.000 0.000
#> GSM11267     1   0.000      0.376 1.000 0.000
#> GSM28744     2   0.714      0.273 0.196 0.804
#> GSM28734     2   0.714      0.273 0.196 0.804
#> GSM28747     1   0.988      0.761 0.564 0.436
#> GSM11257     2   0.722      0.196 0.200 0.800
#> GSM11252     1   0.988      0.761 0.564 0.436
#> GSM11264     1   0.000      0.376 1.000 0.000
#> GSM11247     1   0.000      0.376 1.000 0.000
#> GSM11258     2   0.706      0.268 0.192 0.808
#> GSM28728     1   0.988      0.761 0.564 0.436
#> GSM28746     1   0.988      0.761 0.564 0.436
#> GSM28738     2   0.988     -0.547 0.436 0.564
#> GSM28741     2   0.416      0.418 0.084 0.916
#> GSM28729     1   0.988      0.761 0.564 0.436
#> GSM28742     2   0.993     -0.581 0.452 0.548
#> GSM11250     2   0.975      0.571 0.408 0.592
#> GSM11245     1   0.988      0.761 0.564 0.436
#> GSM11246     1   0.988      0.761 0.564 0.436
#> GSM11261     1   0.402      0.427 0.920 0.080
#> GSM11248     1   0.000      0.376 1.000 0.000
#> GSM28732     1   0.988      0.761 0.564 0.436
#> GSM11255     1   0.988      0.761 0.564 0.436
#> GSM28731     1   0.988      0.761 0.564 0.436
#> GSM28727     1   0.988      0.761 0.564 0.436
#> GSM11251     1   0.988      0.761 0.564 0.436

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM28735     1   0.547     0.8132 0.800 0.040 0.160
#> GSM28736     1   0.614     0.7414 0.748 0.040 0.212
#> GSM28737     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11249     3   0.196     0.8407 0.056 0.000 0.944
#> GSM28745     2   0.000     0.9394 0.000 1.000 0.000
#> GSM11244     2   0.000     0.9394 0.000 1.000 0.000
#> GSM28748     2   0.656     0.1652 0.008 0.576 0.416
#> GSM11266     2   0.000     0.9394 0.000 1.000 0.000
#> GSM28730     2   0.000     0.9394 0.000 1.000 0.000
#> GSM11253     2   0.000     0.9394 0.000 1.000 0.000
#> GSM11254     2   0.000     0.9394 0.000 1.000 0.000
#> GSM11260     2   0.000     0.9394 0.000 1.000 0.000
#> GSM28733     2   0.000     0.9394 0.000 1.000 0.000
#> GSM11265     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28739     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11243     3   0.000     0.8265 0.000 0.000 1.000
#> GSM28740     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11259     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28726     1   0.575     0.7894 0.780 0.040 0.180
#> GSM28743     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11256     3   0.355     0.8262 0.132 0.000 0.868
#> GSM11262     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28724     1   0.400     0.8385 0.840 0.000 0.160
#> GSM28725     3   0.000     0.8265 0.000 0.000 1.000
#> GSM11263     3   0.000     0.8265 0.000 0.000 1.000
#> GSM11267     3   0.000     0.8265 0.000 0.000 1.000
#> GSM28744     3   0.355     0.8262 0.132 0.000 0.868
#> GSM28734     3   0.355     0.8262 0.132 0.000 0.868
#> GSM28747     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11257     3   0.525     0.6661 0.264 0.000 0.736
#> GSM11252     1   0.388     0.8452 0.848 0.000 0.152
#> GSM11264     3   0.000     0.8265 0.000 0.000 1.000
#> GSM11247     3   0.000     0.8265 0.000 0.000 1.000
#> GSM11258     3   0.355     0.8262 0.132 0.000 0.868
#> GSM28728     1   0.400     0.8385 0.840 0.000 0.160
#> GSM28746     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28738     1   0.400     0.8385 0.840 0.000 0.160
#> GSM28741     3   0.927     0.0857 0.416 0.156 0.428
#> GSM28729     1   0.348     0.8591 0.872 0.000 0.128
#> GSM28742     1   0.400     0.8385 0.840 0.000 0.160
#> GSM11250     3   0.974     0.1895 0.236 0.336 0.428
#> GSM11245     1   0.435     0.8120 0.816 0.000 0.184
#> GSM11246     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11261     3   0.277     0.8385 0.080 0.004 0.916
#> GSM11248     3   0.196     0.8407 0.056 0.000 0.944
#> GSM28732     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11255     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28731     1   0.000     0.9123 1.000 0.000 0.000
#> GSM28727     1   0.000     0.9123 1.000 0.000 0.000
#> GSM11251     1   0.000     0.9123 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
#> GSM28735     1  0.3933      0.821 0.792 0.008 0.000 0.200
#> GSM28736     1  0.4260      0.819 0.792 0.008 0.012 0.188
#> GSM28737     1  0.0707      0.876 0.980 0.000 0.000 0.020
#> GSM11249     3  0.2670      0.877 0.052 0.000 0.908 0.040
#> GSM28745     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM28748     2  0.1767      0.915 0.000 0.944 0.012 0.044
#> GSM11266     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      0.965 0.000 1.000 0.000 0.000
#> GSM11265     1  0.1716      0.868 0.936 0.000 0.000 0.064
#> GSM28739     1  0.2149      0.860 0.912 0.000 0.000 0.088
#> GSM11243     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM28740     1  0.2281      0.852 0.904 0.000 0.000 0.096
#> GSM11259     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28726     1  0.3933      0.821 0.792 0.008 0.000 0.200
#> GSM28743     1  0.2216      0.853 0.908 0.000 0.000 0.092
#> GSM11256     4  0.0817      0.990 0.000 0.000 0.024 0.976
#> GSM11262     1  0.2408      0.849 0.896 0.000 0.000 0.104
#> GSM28724     1  0.4059      0.839 0.788 0.000 0.012 0.200
#> GSM28725     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM28744     4  0.0817      0.990 0.000 0.000 0.024 0.976
#> GSM28734     4  0.0817      0.990 0.000 0.000 0.024 0.976
#> GSM28747     1  0.0469      0.875 0.988 0.000 0.000 0.012
#> GSM11257     1  0.4456      0.784 0.716 0.000 0.004 0.280
#> GSM11252     1  0.2542      0.878 0.904 0.000 0.012 0.084
#> GSM11264     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM11258     4  0.0804      0.972 0.008 0.000 0.012 0.980
#> GSM28728     1  0.3962      0.841 0.820 0.000 0.028 0.152
#> GSM28746     1  0.1302      0.876 0.956 0.000 0.000 0.044
#> GSM28738     1  0.3528      0.829 0.808 0.000 0.000 0.192
#> GSM28741     1  0.7223      0.609 0.592 0.172 0.012 0.224
#> GSM28729     1  0.3718      0.838 0.820 0.000 0.012 0.168
#> GSM28742     1  0.3444      0.834 0.816 0.000 0.000 0.184
#> GSM11250     2  0.3937      0.703 0.000 0.800 0.012 0.188
#> GSM11245     1  0.2676      0.878 0.896 0.000 0.012 0.092
#> GSM11246     1  0.1211      0.874 0.960 0.000 0.000 0.040
#> GSM11261     1  0.5558      0.723 0.712 0.000 0.208 0.080
#> GSM11248     3  0.2751      0.871 0.056 0.000 0.904 0.040
#> GSM28732     1  0.2741      0.867 0.892 0.000 0.012 0.096
#> GSM11255     1  0.1211      0.877 0.960 0.000 0.000 0.040
#> GSM28731     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM28727     1  0.0000      0.874 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.874 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.3395     0.6950 0.236 0.000 0.000 0.000 0.764
#> GSM28736     5  0.3210     0.6997 0.212 0.000 0.000 0.000 0.788
#> GSM28737     1  0.1478     0.7878 0.936 0.000 0.000 0.000 0.064
#> GSM11249     3  0.4941     0.5696 0.044 0.000 0.628 0.000 0.328
#> GSM28745     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.4455     0.2838 0.000 0.588 0.008 0.000 0.404
#> GSM11266     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9334 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.2782     0.7603 0.880 0.000 0.000 0.048 0.072
#> GSM28739     1  0.3359     0.7486 0.840 0.000 0.000 0.052 0.108
#> GSM11243     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.3375     0.7376 0.840 0.000 0.000 0.056 0.104
#> GSM11259     1  0.1732     0.7691 0.920 0.000 0.000 0.000 0.080
#> GSM28726     5  0.3242     0.6996 0.216 0.000 0.000 0.000 0.784
#> GSM28743     1  0.3375     0.7376 0.840 0.000 0.000 0.056 0.104
#> GSM11256     4  0.0162     0.9976 0.000 0.000 0.000 0.996 0.004
#> GSM11262     1  0.4088     0.6927 0.776 0.000 0.000 0.056 0.168
#> GSM28724     1  0.4481    -0.0325 0.576 0.000 0.008 0.000 0.416
#> GSM28725     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.0162     0.9976 0.000 0.000 0.000 0.996 0.004
#> GSM28734     4  0.0290     0.9953 0.000 0.000 0.000 0.992 0.008
#> GSM28747     1  0.1965     0.7627 0.904 0.000 0.000 0.000 0.096
#> GSM11257     5  0.2561     0.6579 0.144 0.000 0.000 0.000 0.856
#> GSM11252     5  0.4126     0.6137 0.380 0.000 0.000 0.000 0.620
#> GSM11264     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000     0.8667 0.000 0.000 1.000 0.000 0.000
#> GSM11258     5  0.4074     0.3487 0.000 0.000 0.000 0.364 0.636
#> GSM28728     5  0.4559     0.4016 0.480 0.000 0.008 0.000 0.512
#> GSM28746     1  0.2813     0.6761 0.832 0.000 0.000 0.000 0.168
#> GSM28738     5  0.4268     0.4943 0.444 0.000 0.000 0.000 0.556
#> GSM28741     5  0.4412     0.6376 0.080 0.164 0.000 0.000 0.756
#> GSM28729     1  0.4533    -0.2676 0.544 0.000 0.008 0.000 0.448
#> GSM28742     5  0.4552     0.4351 0.468 0.000 0.008 0.000 0.524
#> GSM11250     5  0.4201     0.3765 0.000 0.328 0.008 0.000 0.664
#> GSM11245     5  0.4030     0.6360 0.352 0.000 0.000 0.000 0.648
#> GSM11246     1  0.0510     0.7848 0.984 0.000 0.000 0.000 0.016
#> GSM11261     5  0.4022     0.5624 0.104 0.000 0.100 0.000 0.796
#> GSM11248     3  0.5131     0.5171 0.048 0.000 0.588 0.000 0.364
#> GSM28732     1  0.2077     0.7538 0.908 0.000 0.008 0.000 0.084
#> GSM11255     1  0.3395     0.5497 0.764 0.000 0.000 0.000 0.236
#> GSM28731     1  0.0794     0.7824 0.972 0.000 0.000 0.000 0.028
#> GSM28727     1  0.1270     0.7767 0.948 0.000 0.000 0.000 0.052
#> GSM11251     1  0.1270     0.7767 0.948 0.000 0.000 0.000 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
#> GSM28735     5  0.5390    0.01841 0.128 0.000 0.000 0.000 0.532 0.340
#> GSM28736     6  0.6076    0.14876 0.272 0.000 0.000 0.000 0.344 0.384
#> GSM28737     1  0.3699    0.75862 0.660 0.000 0.000 0.000 0.336 0.004
#> GSM11249     6  0.5071    0.00371 0.056 0.000 0.376 0.000 0.012 0.556
#> GSM28745     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.2764    0.80315 0.000 0.864 0.028 0.000 0.008 0.100
#> GSM11266     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000    0.91824 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3628    0.77633 0.720 0.000 0.000 0.008 0.268 0.004
#> GSM28739     1  0.4416    0.64211 0.600 0.000 0.000 0.020 0.372 0.008
#> GSM11243     3  0.1267    0.94072 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM28740     1  0.4592    0.77010 0.668 0.000 0.000 0.020 0.276 0.036
#> GSM11259     1  0.3838    0.67319 0.552 0.000 0.000 0.000 0.448 0.000
#> GSM28726     5  0.6197   -0.29706 0.268 0.000 0.000 0.004 0.376 0.352
#> GSM28743     1  0.4509    0.77032 0.684 0.000 0.000 0.020 0.260 0.036
#> GSM11256     4  0.0260    0.81110 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM11262     1  0.4158    0.71564 0.740 0.000 0.000 0.020 0.204 0.036
#> GSM28724     5  0.3569    0.46274 0.164 0.000 0.008 0.000 0.792 0.036
#> GSM28725     3  0.0000    0.97118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000    0.97118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000    0.97118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0260    0.81110 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM28734     4  0.0146    0.80725 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM28747     1  0.3309    0.73017 0.720 0.000 0.000 0.000 0.280 0.000
#> GSM11257     6  0.5925   -0.07159 0.236 0.000 0.000 0.000 0.308 0.456
#> GSM11252     5  0.4970    0.42859 0.224 0.000 0.004 0.000 0.652 0.120
#> GSM11264     3  0.0000    0.97118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.1267    0.94072 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM11258     4  0.5576    0.22108 0.012 0.000 0.000 0.512 0.104 0.372
#> GSM28728     5  0.0858    0.51599 0.028 0.000 0.000 0.000 0.968 0.004
#> GSM28746     5  0.4921   -0.16417 0.436 0.000 0.000 0.004 0.508 0.052
#> GSM28738     5  0.1501    0.51337 0.000 0.000 0.000 0.000 0.924 0.076
#> GSM28741     6  0.7292    0.24929 0.256 0.116 0.004 0.000 0.200 0.424
#> GSM28729     5  0.1363    0.50975 0.028 0.000 0.004 0.004 0.952 0.012
#> GSM28742     5  0.1204    0.51759 0.000 0.000 0.000 0.000 0.944 0.056
#> GSM11250     2  0.6212    0.02246 0.064 0.440 0.004 0.000 0.072 0.420
#> GSM11245     5  0.5350    0.41714 0.228 0.000 0.016 0.000 0.628 0.128
#> GSM11246     1  0.3468    0.77381 0.712 0.000 0.000 0.000 0.284 0.004
#> GSM11261     6  0.6154    0.27211 0.024 0.000 0.212 0.004 0.216 0.544
#> GSM11248     6  0.5074    0.04469 0.060 0.000 0.356 0.000 0.012 0.572
#> GSM28732     5  0.4411   -0.38997 0.356 0.000 0.028 0.004 0.612 0.000
#> GSM11255     5  0.4905   -0.12081 0.420 0.000 0.000 0.004 0.524 0.052
#> GSM28731     1  0.3823    0.72757 0.564 0.000 0.000 0.000 0.436 0.000
#> GSM28727     1  0.3866    0.66257 0.516 0.000 0.000 0.000 0.484 0.000
#> GSM11251     1  0.3857    0.68038 0.532 0.000 0.000 0.000 0.468 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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 tissue(p) k
#> SD:mclust 30     0.414 2
#> SD:mclust 47     0.440 3
#> SD:mclust 50     0.511 4
#> SD:mclust 42     0.494 5
#> SD:mclust 34     0.461 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 21342 rows and 50 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 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-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 1.000           0.983       0.992         0.3858 0.607   0.607
#> 3 3 1.000           0.974       0.991         0.4994 0.731   0.588
#> 4 4 0.876           0.913       0.950         0.2138 0.882   0.726
#> 5 5 0.747           0.721       0.849         0.1135 0.900   0.686
#> 6 6 0.716           0.567       0.758         0.0521 0.885   0.554

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1  0.0000      0.999 1.000 0.000
#> GSM28736     2  0.5178      0.866 0.116 0.884
#> GSM28737     1  0.0000      0.999 1.000 0.000
#> GSM11249     1  0.0000      0.999 1.000 0.000
#> GSM28745     2  0.0000      0.969 0.000 1.000
#> GSM11244     2  0.0000      0.969 0.000 1.000
#> GSM28748     2  0.0000      0.969 0.000 1.000
#> GSM11266     2  0.0000      0.969 0.000 1.000
#> GSM28730     2  0.0000      0.969 0.000 1.000
#> GSM11253     2  0.0000      0.969 0.000 1.000
#> GSM11254     2  0.0000      0.969 0.000 1.000
#> GSM11260     2  0.0000      0.969 0.000 1.000
#> GSM28733     2  0.0000      0.969 0.000 1.000
#> GSM11265     1  0.0000      0.999 1.000 0.000
#> GSM28739     1  0.0000      0.999 1.000 0.000
#> GSM11243     1  0.0000      0.999 1.000 0.000
#> GSM28740     1  0.0000      0.999 1.000 0.000
#> GSM11259     1  0.0000      0.999 1.000 0.000
#> GSM28726     2  0.8267      0.663 0.260 0.740
#> GSM28743     1  0.0000      0.999 1.000 0.000
#> GSM11256     1  0.0000      0.999 1.000 0.000
#> GSM11262     1  0.0000      0.999 1.000 0.000
#> GSM28724     1  0.0000      0.999 1.000 0.000
#> GSM28725     1  0.0000      0.999 1.000 0.000
#> GSM11263     1  0.0000      0.999 1.000 0.000
#> GSM11267     1  0.0000      0.999 1.000 0.000
#> GSM28744     1  0.0000      0.999 1.000 0.000
#> GSM28734     1  0.0000      0.999 1.000 0.000
#> GSM28747     1  0.0000      0.999 1.000 0.000
#> GSM11257     1  0.0000      0.999 1.000 0.000
#> GSM11252     1  0.0000      0.999 1.000 0.000
#> GSM11264     1  0.0000      0.999 1.000 0.000
#> GSM11247     1  0.0000      0.999 1.000 0.000
#> GSM11258     1  0.0000      0.999 1.000 0.000
#> GSM28728     1  0.0000      0.999 1.000 0.000
#> GSM28746     1  0.0000      0.999 1.000 0.000
#> GSM28738     1  0.0000      0.999 1.000 0.000
#> GSM28741     2  0.0000      0.969 0.000 1.000
#> GSM28729     1  0.0000      0.999 1.000 0.000
#> GSM28742     1  0.1184      0.983 0.984 0.016
#> GSM11250     2  0.0000      0.969 0.000 1.000
#> GSM11245     1  0.0000      0.999 1.000 0.000
#> GSM11246     1  0.0000      0.999 1.000 0.000
#> GSM11261     1  0.0376      0.996 0.996 0.004
#> GSM11248     1  0.0000      0.999 1.000 0.000
#> GSM28732     1  0.0000      0.999 1.000 0.000
#> GSM11255     1  0.0000      0.999 1.000 0.000
#> GSM28731     1  0.0000      0.999 1.000 0.000
#> GSM28727     1  0.0000      0.999 1.000 0.000
#> GSM11251     1  0.0000      0.999 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
#> GSM28735     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28736     1  0.0747      0.969 0.984 0.016 0.000
#> GSM28737     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11249     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28745     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11244     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28748     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11266     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28730     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11253     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11254     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11260     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28733     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28726     1  0.0237      0.980 0.996 0.004 0.000
#> GSM28743     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11256     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11262     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28744     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28734     1  0.6252      0.203 0.556 0.000 0.444
#> GSM28747     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11257     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11252     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11258     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28728     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28746     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28738     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28741     2  0.0237      0.994 0.004 0.996 0.000
#> GSM28729     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11250     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11245     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11246     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11261     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11248     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11255     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28731     1  0.0000      0.984 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.984 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.984 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
#> GSM28735     1  0.4804      0.450 0.616 0.000 0.000 0.384
#> GSM28736     4  0.7001      0.547 0.180 0.244 0.000 0.576
#> GSM28737     1  0.0188      0.919 0.996 0.000 0.000 0.004
#> GSM11249     3  0.0188      0.990 0.000 0.000 0.996 0.004
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.0336      0.918 0.992 0.000 0.000 0.008
#> GSM28739     1  0.0469      0.916 0.988 0.000 0.000 0.012
#> GSM11243     3  0.0707      0.982 0.000 0.000 0.980 0.020
#> GSM28740     1  0.0469      0.919 0.988 0.000 0.000 0.012
#> GSM11259     1  0.0469      0.917 0.988 0.000 0.000 0.012
#> GSM28726     1  0.4677      0.768 0.776 0.048 0.000 0.176
#> GSM28743     1  0.0592      0.919 0.984 0.000 0.000 0.016
#> GSM11256     4  0.1004      0.902 0.024 0.000 0.004 0.972
#> GSM11262     1  0.0817      0.915 0.976 0.000 0.000 0.024
#> GSM28724     1  0.0817      0.913 0.976 0.000 0.000 0.024
#> GSM28725     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM28744     4  0.1004      0.902 0.024 0.000 0.004 0.972
#> GSM28734     4  0.1004      0.885 0.004 0.000 0.024 0.972
#> GSM28747     1  0.0817      0.915 0.976 0.000 0.000 0.024
#> GSM11257     4  0.1389      0.899 0.048 0.000 0.000 0.952
#> GSM11252     1  0.3123      0.829 0.844 0.000 0.000 0.156
#> GSM11264     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11247     3  0.1151      0.972 0.008 0.000 0.968 0.024
#> GSM11258     4  0.1557      0.895 0.056 0.000 0.000 0.944
#> GSM28728     1  0.0817      0.913 0.976 0.000 0.000 0.024
#> GSM28746     1  0.2469      0.860 0.892 0.000 0.000 0.108
#> GSM28738     1  0.4008      0.719 0.756 0.000 0.000 0.244
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28729     1  0.2408      0.877 0.896 0.000 0.000 0.104
#> GSM28742     1  0.3726      0.778 0.788 0.000 0.000 0.212
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11245     1  0.3668      0.794 0.808 0.000 0.004 0.188
#> GSM11246     1  0.0188      0.918 0.996 0.000 0.000 0.004
#> GSM11261     3  0.0336      0.989 0.000 0.000 0.992 0.008
#> GSM11248     3  0.0188      0.990 0.000 0.000 0.996 0.004
#> GSM28732     1  0.0592      0.918 0.984 0.000 0.000 0.016
#> GSM11255     1  0.0592      0.918 0.984 0.000 0.000 0.016
#> GSM28731     1  0.0336      0.918 0.992 0.000 0.000 0.008
#> GSM28727     1  0.0188      0.919 0.996 0.000 0.000 0.004
#> GSM11251     1  0.0188      0.919 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     1  0.5443      0.230 0.604 0.000 0.000 0.312 0.084
#> GSM28736     4  0.7304      0.427 0.228 0.160 0.000 0.528 0.084
#> GSM28737     1  0.3086      0.712 0.816 0.000 0.000 0.004 0.180
#> GSM11249     3  0.1717      0.901 0.004 0.000 0.936 0.008 0.052
#> GSM28745     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.3109      0.698 0.800 0.000 0.000 0.000 0.200
#> GSM28739     1  0.3366      0.680 0.768 0.000 0.000 0.000 0.232
#> GSM11243     3  0.3774      0.616 0.000 0.000 0.704 0.000 0.296
#> GSM28740     1  0.3242      0.691 0.784 0.000 0.000 0.000 0.216
#> GSM11259     5  0.4283      0.354 0.456 0.000 0.000 0.000 0.544
#> GSM28726     1  0.5284     -0.236 0.532 0.004 0.000 0.040 0.424
#> GSM28743     1  0.3171      0.704 0.816 0.000 0.000 0.008 0.176
#> GSM11256     4  0.0451      0.856 0.004 0.000 0.000 0.988 0.008
#> GSM11262     1  0.3209      0.702 0.812 0.000 0.000 0.008 0.180
#> GSM28724     5  0.4504      0.349 0.428 0.000 0.008 0.000 0.564
#> GSM28725     3  0.0609      0.923 0.000 0.000 0.980 0.000 0.020
#> GSM11263     3  0.0162      0.926 0.000 0.000 0.996 0.000 0.004
#> GSM11267     3  0.0162      0.926 0.000 0.000 0.996 0.000 0.004
#> GSM28744     4  0.0324      0.856 0.004 0.000 0.000 0.992 0.004
#> GSM28734     4  0.0613      0.852 0.004 0.000 0.008 0.984 0.004
#> GSM28747     1  0.1831      0.687 0.920 0.000 0.000 0.004 0.076
#> GSM11257     4  0.2628      0.814 0.028 0.000 0.000 0.884 0.088
#> GSM11252     1  0.3187      0.667 0.864 0.000 0.012 0.036 0.088
#> GSM11264     3  0.0000      0.926 0.000 0.000 1.000 0.000 0.000
#> GSM11247     5  0.4302     -0.259 0.000 0.000 0.480 0.000 0.520
#> GSM11258     4  0.2685      0.792 0.092 0.000 0.000 0.880 0.028
#> GSM28728     5  0.2806      0.600 0.152 0.000 0.004 0.000 0.844
#> GSM28746     1  0.3521      0.636 0.820 0.000 0.000 0.040 0.140
#> GSM28738     5  0.3555      0.624 0.124 0.000 0.000 0.052 0.824
#> GSM28741     2  0.0771      0.969 0.020 0.976 0.000 0.000 0.004
#> GSM28729     5  0.3612      0.636 0.228 0.000 0.000 0.008 0.764
#> GSM28742     5  0.4467      0.567 0.344 0.000 0.000 0.016 0.640
#> GSM11250     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000
#> GSM11245     1  0.4160      0.617 0.816 0.000 0.064 0.036 0.084
#> GSM11246     1  0.2852      0.712 0.828 0.000 0.000 0.000 0.172
#> GSM11261     3  0.1478      0.900 0.000 0.000 0.936 0.000 0.064
#> GSM11248     3  0.1341      0.906 0.000 0.000 0.944 0.000 0.056
#> GSM28732     1  0.2929      0.585 0.820 0.000 0.000 0.000 0.180
#> GSM11255     1  0.2707      0.683 0.860 0.000 0.000 0.008 0.132
#> GSM28731     1  0.3895      0.417 0.680 0.000 0.000 0.000 0.320
#> GSM28727     1  0.1270      0.699 0.948 0.000 0.000 0.000 0.052
#> GSM11251     1  0.2280      0.719 0.880 0.000 0.000 0.000 0.120

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.6999     0.3005 0.256 0.000 0.000 0.172 0.460 0.112
#> GSM28736     5  0.7272     0.0449 0.092 0.108 0.000 0.356 0.412 0.032
#> GSM28737     1  0.1572     0.7490 0.936 0.000 0.000 0.000 0.028 0.036
#> GSM11249     3  0.3079     0.6947 0.004 0.000 0.844 0.000 0.056 0.096
#> GSM28745     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.1471     0.7403 0.932 0.000 0.000 0.000 0.004 0.064
#> GSM28739     1  0.2320     0.6847 0.864 0.000 0.000 0.000 0.004 0.132
#> GSM11243     3  0.4555     0.2396 0.028 0.000 0.548 0.000 0.004 0.420
#> GSM28740     1  0.1327     0.7429 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM11259     5  0.6018     0.1164 0.256 0.000 0.000 0.000 0.420 0.324
#> GSM28726     5  0.4319     0.3779 0.168 0.000 0.000 0.000 0.724 0.108
#> GSM28743     1  0.1391     0.7517 0.944 0.000 0.000 0.000 0.016 0.040
#> GSM11256     4  0.0000     0.8582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11262     1  0.1760     0.7480 0.928 0.000 0.000 0.004 0.020 0.048
#> GSM28724     6  0.5907     0.3053 0.236 0.000 0.016 0.000 0.200 0.548
#> GSM28725     3  0.1387     0.7582 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM11263     3  0.0865     0.7694 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM11267     3  0.0291     0.7720 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM28744     4  0.0000     0.8582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0260     0.8568 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM28747     5  0.4594    -0.0246 0.480 0.000 0.000 0.000 0.484 0.036
#> GSM11257     4  0.4361     0.5949 0.016 0.000 0.000 0.692 0.260 0.032
#> GSM11252     5  0.6440     0.1524 0.396 0.000 0.060 0.000 0.424 0.120
#> GSM11264     3  0.0603     0.7724 0.000 0.000 0.980 0.000 0.016 0.004
#> GSM11247     6  0.5223    -0.0485 0.052 0.000 0.364 0.000 0.024 0.560
#> GSM11258     4  0.3017     0.7170 0.164 0.000 0.000 0.816 0.000 0.020
#> GSM28728     6  0.5036     0.3176 0.140 0.000 0.000 0.000 0.228 0.632
#> GSM28746     1  0.5717    -0.0102 0.492 0.000 0.000 0.012 0.376 0.120
#> GSM28738     5  0.5377    -0.2027 0.084 0.000 0.000 0.008 0.464 0.444
#> GSM28741     2  0.1753     0.8903 0.000 0.912 0.000 0.000 0.084 0.004
#> GSM28729     5  0.4953    -0.0345 0.056 0.000 0.008 0.000 0.572 0.364
#> GSM28742     5  0.2912     0.2802 0.040 0.000 0.000 0.000 0.844 0.116
#> GSM11250     2  0.0000     0.9898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     5  0.6982     0.2099 0.324 0.000 0.128 0.000 0.424 0.124
#> GSM11246     1  0.1049     0.7523 0.960 0.000 0.000 0.000 0.032 0.008
#> GSM11261     3  0.4525     0.4853 0.008 0.000 0.664 0.004 0.036 0.288
#> GSM11248     3  0.4140     0.6020 0.000 0.000 0.744 0.000 0.152 0.104
#> GSM28732     5  0.4597     0.3527 0.276 0.000 0.000 0.000 0.652 0.072
#> GSM11255     5  0.6271     0.1973 0.384 0.000 0.036 0.000 0.440 0.140
#> GSM28731     5  0.5940     0.2954 0.332 0.000 0.000 0.000 0.440 0.228
#> GSM28727     1  0.4283     0.2019 0.592 0.000 0.000 0.000 0.384 0.024
#> GSM11251     1  0.3287     0.5598 0.768 0.000 0.000 0.000 0.220 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 tissue(p) k
#> SD:NMF 50     0.394 2
#> SD:NMF 49     0.368 3
#> SD:NMF 49     0.464 4
#> SD:NMF 43     0.436 5
#> SD:NMF 30     0.445 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 21342 rows and 50 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

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

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.961       0.982          0.334 0.673   0.673
#> 3 3 0.690           0.847       0.899          0.726 0.740   0.613
#> 4 4 0.728           0.852       0.936          0.163 0.890   0.739
#> 5 5 0.778           0.786       0.869          0.103 0.971   0.908
#> 6 6 0.763           0.712       0.838          0.039 0.969   0.896

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
#> GSM28735     1  0.0376      0.981 0.996 0.004
#> GSM28736     1  0.0376      0.981 0.996 0.004
#> GSM28737     1  0.0000      0.984 1.000 0.000
#> GSM11249     1  0.0938      0.979 0.988 0.012
#> GSM28745     2  0.0938      0.979 0.012 0.988
#> GSM11244     2  0.0938      0.979 0.012 0.988
#> GSM28748     2  0.0938      0.979 0.012 0.988
#> GSM11266     2  0.0938      0.979 0.012 0.988
#> GSM28730     2  0.0938      0.979 0.012 0.988
#> GSM11253     2  0.0938      0.979 0.012 0.988
#> GSM11254     2  0.0938      0.979 0.012 0.988
#> GSM11260     2  0.0938      0.979 0.012 0.988
#> GSM28733     2  0.0938      0.979 0.012 0.988
#> GSM11265     1  0.0000      0.984 1.000 0.000
#> GSM28739     1  0.0000      0.984 1.000 0.000
#> GSM11243     1  0.0938      0.979 0.988 0.012
#> GSM28740     1  0.0000      0.984 1.000 0.000
#> GSM11259     1  0.0000      0.984 1.000 0.000
#> GSM28726     1  0.0000      0.984 1.000 0.000
#> GSM28743     1  0.0000      0.984 1.000 0.000
#> GSM11256     1  0.0000      0.984 1.000 0.000
#> GSM11262     1  0.0000      0.984 1.000 0.000
#> GSM28724     1  0.0000      0.984 1.000 0.000
#> GSM28725     1  0.0938      0.979 0.988 0.012
#> GSM11263     1  0.0938      0.979 0.988 0.012
#> GSM11267     1  0.0938      0.979 0.988 0.012
#> GSM28744     1  0.0000      0.984 1.000 0.000
#> GSM28734     1  0.0000      0.984 1.000 0.000
#> GSM28747     1  0.0000      0.984 1.000 0.000
#> GSM11257     1  0.0000      0.984 1.000 0.000
#> GSM11252     1  0.0938      0.979 0.988 0.012
#> GSM11264     1  0.0938      0.979 0.988 0.012
#> GSM11247     1  0.0938      0.979 0.988 0.012
#> GSM11258     1  0.0000      0.984 1.000 0.000
#> GSM28728     1  0.0000      0.984 1.000 0.000
#> GSM28746     1  0.0000      0.984 1.000 0.000
#> GSM28738     1  0.0000      0.984 1.000 0.000
#> GSM28741     1  0.9896      0.167 0.560 0.440
#> GSM28729     1  0.0000      0.984 1.000 0.000
#> GSM28742     1  0.0000      0.984 1.000 0.000
#> GSM11250     2  0.7056      0.771 0.192 0.808
#> GSM11245     1  0.0938      0.979 0.988 0.012
#> GSM11246     1  0.0000      0.984 1.000 0.000
#> GSM11261     1  0.2236      0.960 0.964 0.036
#> GSM11248     1  0.0938      0.979 0.988 0.012
#> GSM28732     1  0.0000      0.984 1.000 0.000
#> GSM11255     1  0.0000      0.984 1.000 0.000
#> GSM28731     1  0.0000      0.984 1.000 0.000
#> GSM28727     1  0.0000      0.984 1.000 0.000
#> GSM11251     1  0.0000      0.984 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
#> GSM28735     1  0.0237      0.903 0.996 0.004 0.000
#> GSM28736     1  0.0237      0.903 0.996 0.004 0.000
#> GSM28737     1  0.2537      0.873 0.920 0.000 0.080
#> GSM11249     3  0.3267      0.892 0.116 0.000 0.884
#> GSM28745     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11244     2  0.0000      0.972 0.000 1.000 0.000
#> GSM28748     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11266     2  0.0000      0.972 0.000 1.000 0.000
#> GSM28730     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11253     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11254     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11260     2  0.0000      0.972 0.000 1.000 0.000
#> GSM28733     2  0.0000      0.972 0.000 1.000 0.000
#> GSM11265     1  0.2537      0.873 0.920 0.000 0.080
#> GSM28739     1  0.2537      0.873 0.920 0.000 0.080
#> GSM11243     3  0.2878      0.896 0.096 0.000 0.904
#> GSM28740     1  0.2537      0.873 0.920 0.000 0.080
#> GSM11259     1  0.0000      0.904 1.000 0.000 0.000
#> GSM28726     1  0.0000      0.904 1.000 0.000 0.000
#> GSM28743     1  0.2537      0.873 0.920 0.000 0.080
#> GSM11256     1  0.2878      0.834 0.904 0.000 0.096
#> GSM11262     1  0.2537      0.873 0.920 0.000 0.080
#> GSM28724     1  0.0000      0.904 1.000 0.000 0.000
#> GSM28725     3  0.2878      0.896 0.096 0.000 0.904
#> GSM11263     3  0.2878      0.896 0.096 0.000 0.904
#> GSM11267     3  0.2878      0.896 0.096 0.000 0.904
#> GSM28744     1  0.2878      0.834 0.904 0.000 0.096
#> GSM28734     1  0.2878      0.834 0.904 0.000 0.096
#> GSM28747     1  0.0000      0.904 1.000 0.000 0.000
#> GSM11257     1  0.1163      0.898 0.972 0.000 0.028
#> GSM11252     3  0.5859      0.653 0.344 0.000 0.656
#> GSM11264     3  0.2878      0.896 0.096 0.000 0.904
#> GSM11247     3  0.2878      0.896 0.096 0.000 0.904
#> GSM11258     1  0.2878      0.834 0.904 0.000 0.096
#> GSM28728     1  0.0237      0.903 0.996 0.000 0.004
#> GSM28746     1  0.4346      0.740 0.816 0.000 0.184
#> GSM28738     1  0.0237      0.903 0.996 0.000 0.004
#> GSM28741     1  0.6267      0.130 0.548 0.452 0.000
#> GSM28729     1  0.1411      0.895 0.964 0.000 0.036
#> GSM28742     1  0.0000      0.904 1.000 0.000 0.000
#> GSM11250     2  0.4291      0.717 0.180 0.820 0.000
#> GSM11245     3  0.5859      0.653 0.344 0.000 0.656
#> GSM11246     1  0.2448      0.875 0.924 0.000 0.076
#> GSM11261     3  0.6512      0.709 0.300 0.024 0.676
#> GSM11248     3  0.3267      0.892 0.116 0.000 0.884
#> GSM28732     1  0.0000      0.904 1.000 0.000 0.000
#> GSM11255     1  0.6286     -0.121 0.536 0.000 0.464
#> GSM28731     1  0.1031      0.899 0.976 0.000 0.024
#> GSM28727     1  0.0000      0.904 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.904 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
#> GSM28735     1  0.0188     0.9110 0.996 0.004 0.000 0.000
#> GSM28736     1  0.0188     0.9110 0.996 0.004 0.000 0.000
#> GSM28737     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM11249     3  0.1209     0.8143 0.032 0.000 0.964 0.004
#> GSM28745     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000     0.9679 0.000 1.000 0.000 0.000
#> GSM11265     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM28739     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM11243     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM28740     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM11259     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM28726     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM28743     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM11256     4  0.0000     1.0000 0.000 0.000 0.000 1.000
#> GSM11262     1  0.2773     0.8698 0.880 0.000 0.116 0.004
#> GSM28724     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM28725     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM28744     4  0.0000     1.0000 0.000 0.000 0.000 1.000
#> GSM28734     4  0.0000     1.0000 0.000 0.000 0.000 1.000
#> GSM28747     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM11257     1  0.1118     0.9044 0.964 0.000 0.036 0.000
#> GSM11252     3  0.4313     0.6718 0.260 0.000 0.736 0.004
#> GSM11264     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000     0.8183 0.000 0.000 1.000 0.000
#> GSM11258     4  0.0000     1.0000 0.000 0.000 0.000 1.000
#> GSM28728     1  0.0188     0.9129 0.996 0.000 0.004 0.000
#> GSM28746     1  0.4155     0.6892 0.756 0.000 0.240 0.004
#> GSM28738     1  0.0188     0.9129 0.996 0.000 0.004 0.000
#> GSM28741     1  0.4967     0.0945 0.548 0.452 0.000 0.000
#> GSM28729     1  0.1557     0.9000 0.944 0.000 0.056 0.000
#> GSM28742     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM11250     2  0.3400     0.6923 0.180 0.820 0.000 0.000
#> GSM11245     3  0.4313     0.6718 0.260 0.000 0.736 0.004
#> GSM11246     1  0.2714     0.8722 0.884 0.000 0.112 0.004
#> GSM11261     3  0.4607     0.6988 0.204 0.024 0.768 0.004
#> GSM11248     3  0.1209     0.8143 0.032 0.000 0.964 0.004
#> GSM28732     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM11255     3  0.5165     0.0824 0.484 0.000 0.512 0.004
#> GSM28731     1  0.1118     0.9068 0.964 0.000 0.036 0.000
#> GSM28727     1  0.0000     0.9128 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0000     0.9128 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3 p4    p5
#> GSM28735     1  0.1792      0.756 0.916 0.000 0.000  0 0.084
#> GSM28736     1  0.1792      0.756 0.916 0.000 0.000  0 0.084
#> GSM28737     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM11249     5  0.3913      0.586 0.000 0.000 0.324  0 0.676
#> GSM28745     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11244     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM28748     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11266     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM28730     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11253     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11254     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11260     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM28733     2  0.0000      0.973 0.000 1.000 0.000  0 0.000
#> GSM11265     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM28739     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM11243     3  0.0609      0.982 0.000 0.000 0.980  0 0.020
#> GSM28740     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM11259     1  0.0609      0.785 0.980 0.000 0.000  0 0.020
#> GSM28726     1  0.1732      0.760 0.920 0.000 0.000  0 0.080
#> GSM28743     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM11262     1  0.4135      0.615 0.656 0.000 0.004  0 0.340
#> GSM28724     1  0.0404      0.786 0.988 0.000 0.000  0 0.012
#> GSM28725     3  0.0000      0.991 0.000 0.000 1.000  0 0.000
#> GSM11263     3  0.0000      0.991 0.000 0.000 1.000  0 0.000
#> GSM11267     3  0.0000      0.991 0.000 0.000 1.000  0 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM28747     1  0.0880      0.785 0.968 0.000 0.000  0 0.032
#> GSM11257     1  0.2358      0.761 0.888 0.000 0.008  0 0.104
#> GSM11252     5  0.3336      0.739 0.060 0.000 0.096  0 0.844
#> GSM11264     3  0.0000      0.991 0.000 0.000 1.000  0 0.000
#> GSM11247     3  0.0609      0.982 0.000 0.000 0.980  0 0.020
#> GSM11258     4  0.0000      1.000 0.000 0.000 0.000  1 0.000
#> GSM28728     1  0.0404      0.785 0.988 0.000 0.000  0 0.012
#> GSM28746     1  0.5143      0.394 0.532 0.000 0.040  0 0.428
#> GSM28738     1  0.1965      0.761 0.904 0.000 0.000  0 0.096
#> GSM28741     1  0.5736     -0.101 0.468 0.448 0.000  0 0.084
#> GSM28729     1  0.2424      0.761 0.868 0.000 0.000  0 0.132
#> GSM28742     1  0.1732      0.760 0.920 0.000 0.000  0 0.080
#> GSM11250     2  0.3171      0.733 0.176 0.816 0.000  0 0.008
#> GSM11245     5  0.3336      0.739 0.060 0.000 0.096  0 0.844
#> GSM11246     1  0.4101      0.622 0.664 0.000 0.004  0 0.332
#> GSM11261     5  0.4185      0.622 0.024 0.008 0.216  0 0.752
#> GSM11248     5  0.3913      0.586 0.000 0.000 0.324  0 0.676
#> GSM28732     1  0.0794      0.785 0.972 0.000 0.000  0 0.028
#> GSM11255     5  0.4350      0.431 0.268 0.000 0.028  0 0.704
#> GSM28731     1  0.1732      0.774 0.920 0.000 0.000  0 0.080
#> GSM28727     1  0.1043      0.785 0.960 0.000 0.000  0 0.040
#> GSM11251     1  0.1043      0.785 0.960 0.000 0.000  0 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3 p4    p5    p6
#> GSM28735     1  0.2912      0.683 0.816 0.000 0.000  0 0.172 0.012
#> GSM28736     1  0.2912      0.683 0.816 0.000 0.000  0 0.172 0.012
#> GSM28737     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM11249     6  0.3201      0.358 0.000 0.000 0.208  0 0.012 0.780
#> GSM28745     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11244     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM28748     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11266     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM28730     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11253     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11254     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11260     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM28733     2  0.0000      0.903 0.000 1.000 0.000  0 0.000 0.000
#> GSM11265     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM28739     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM11243     3  0.0972      0.961 0.000 0.000 0.964  0 0.028 0.008
#> GSM28740     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM11259     1  0.0146      0.751 0.996 0.000 0.000  0 0.004 0.000
#> GSM28726     1  0.2527      0.692 0.832 0.000 0.000  0 0.168 0.000
#> GSM28743     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM11262     1  0.4915      0.608 0.652 0.000 0.000  0 0.140 0.208
#> GSM28724     1  0.0935      0.751 0.964 0.000 0.000  0 0.032 0.004
#> GSM28725     3  0.0000      0.981 0.000 0.000 1.000  0 0.000 0.000
#> GSM11263     3  0.0000      0.981 0.000 0.000 1.000  0 0.000 0.000
#> GSM11267     3  0.0000      0.981 0.000 0.000 1.000  0 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM28747     1  0.0547      0.750 0.980 0.000 0.000  0 0.020 0.000
#> GSM11257     1  0.4461      0.411 0.564 0.000 0.000  0 0.404 0.032
#> GSM11252     6  0.1327      0.501 0.064 0.000 0.000  0 0.000 0.936
#> GSM11264     3  0.0000      0.981 0.000 0.000 1.000  0 0.000 0.000
#> GSM11247     3  0.0972      0.961 0.000 0.000 0.964  0 0.028 0.008
#> GSM11258     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM28728     1  0.1204      0.752 0.944 0.000 0.000  0 0.056 0.000
#> GSM28746     1  0.4660      0.355 0.540 0.000 0.000  0 0.044 0.416
#> GSM28738     1  0.3833      0.411 0.556 0.000 0.000  0 0.444 0.000
#> GSM28741     2  0.5886      0.123 0.400 0.448 0.000  0 0.140 0.012
#> GSM28729     1  0.2883      0.726 0.788 0.000 0.000  0 0.212 0.000
#> GSM28742     1  0.2527      0.692 0.832 0.000 0.000  0 0.168 0.000
#> GSM11250     2  0.3300      0.695 0.148 0.816 0.000  0 0.024 0.012
#> GSM11245     6  0.1327      0.501 0.064 0.000 0.000  0 0.000 0.936
#> GSM11246     1  0.4855      0.613 0.660 0.000 0.000  0 0.136 0.204
#> GSM11261     5  0.6340      0.000 0.024 0.000 0.188  0 0.420 0.368
#> GSM11248     6  0.3201      0.358 0.000 0.000 0.208  0 0.012 0.780
#> GSM28732     1  0.0146      0.752 0.996 0.000 0.000  0 0.004 0.000
#> GSM11255     6  0.5103      0.171 0.268 0.000 0.000  0 0.124 0.608
#> GSM28731     1  0.1501      0.742 0.924 0.000 0.000  0 0.076 0.000
#> GSM28727     1  0.0547      0.750 0.980 0.000 0.000  0 0.020 0.000
#> GSM11251     1  0.0547      0.750 0.980 0.000 0.000  0 0.020 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 tissue(p) k
#> CV:hclust 49     0.393 2
#> CV:hclust 48     0.367 3
#> CV:hclust 48     0.509 4
#> CV:hclust 47     0.464 5
#> CV:hclust 42     0.448 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 21342 rows and 50 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 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-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.362           0.843       0.823         0.3625 0.650   0.650
#> 3 3 0.944           0.959       0.961         0.4982 0.764   0.651
#> 4 4 0.716           0.790       0.866         0.2598 0.909   0.803
#> 5 5 0.772           0.804       0.883         0.1189 0.853   0.606
#> 6 6 0.793           0.717       0.819         0.0629 0.939   0.756

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
#> GSM28735     1  0.6048      0.848 0.852 0.148
#> GSM28736     1  0.6048      0.848 0.852 0.148
#> GSM28737     1  0.6048      0.848 0.852 0.148
#> GSM11249     1  0.6438      0.704 0.836 0.164
#> GSM28745     2  0.6438      0.989 0.164 0.836
#> GSM11244     2  0.6438      0.989 0.164 0.836
#> GSM28748     2  0.6438      0.989 0.164 0.836
#> GSM11266     2  0.6438      0.989 0.164 0.836
#> GSM28730     2  0.6438      0.989 0.164 0.836
#> GSM11253     2  0.6438      0.989 0.164 0.836
#> GSM11254     2  0.6438      0.989 0.164 0.836
#> GSM11260     2  0.6438      0.989 0.164 0.836
#> GSM28733     2  0.6438      0.989 0.164 0.836
#> GSM11265     1  0.6048      0.848 0.852 0.148
#> GSM28739     1  0.6048      0.848 0.852 0.148
#> GSM11243     1  0.7674      0.664 0.776 0.224
#> GSM28740     1  0.6048      0.848 0.852 0.148
#> GSM11259     1  0.6048      0.848 0.852 0.148
#> GSM28726     1  0.6048      0.848 0.852 0.148
#> GSM28743     1  0.6048      0.848 0.852 0.148
#> GSM11256     1  0.0376      0.818 0.996 0.004
#> GSM11262     1  0.6048      0.848 0.852 0.148
#> GSM28724     1  0.6048      0.848 0.852 0.148
#> GSM28725     1  0.7674      0.664 0.776 0.224
#> GSM11263     1  0.7674      0.664 0.776 0.224
#> GSM11267     1  0.7674      0.664 0.776 0.224
#> GSM28744     1  0.0376      0.818 0.996 0.004
#> GSM28734     1  0.2603      0.795 0.956 0.044
#> GSM28747     1  0.6048      0.848 0.852 0.148
#> GSM11257     1  0.3431      0.835 0.936 0.064
#> GSM11252     1  0.0000      0.820 1.000 0.000
#> GSM11264     1  0.7674      0.664 0.776 0.224
#> GSM11247     1  0.7674      0.664 0.776 0.224
#> GSM11258     1  0.0376      0.818 0.996 0.004
#> GSM28728     1  0.6048      0.848 0.852 0.148
#> GSM28746     1  0.1414      0.825 0.980 0.020
#> GSM28738     1  0.6048      0.848 0.852 0.148
#> GSM28741     2  0.7950      0.884 0.240 0.760
#> GSM28729     1  0.6048      0.848 0.852 0.148
#> GSM28742     1  0.6048      0.848 0.852 0.148
#> GSM11250     2  0.6438      0.989 0.164 0.836
#> GSM11245     1  0.0376      0.818 0.996 0.004
#> GSM11246     1  0.6048      0.848 0.852 0.148
#> GSM11261     1  0.4298      0.792 0.912 0.088
#> GSM11248     1  0.6438      0.704 0.836 0.164
#> GSM28732     1  0.6048      0.848 0.852 0.148
#> GSM11255     1  0.0000      0.820 1.000 0.000
#> GSM28731     1  0.6048      0.848 0.852 0.148
#> GSM28727     1  0.6048      0.848 0.852 0.148
#> GSM11251     1  0.6048      0.848 0.852 0.148

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM28735     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28736     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28737     1  0.0237      0.960 0.996 0.000 0.004
#> GSM11249     3  0.0892      1.000 0.020 0.000 0.980
#> GSM28745     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11244     2  0.1753      1.000 0.048 0.952 0.000
#> GSM28748     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11266     2  0.1753      1.000 0.048 0.952 0.000
#> GSM28730     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11253     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11254     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11260     2  0.1753      1.000 0.048 0.952 0.000
#> GSM28733     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11265     1  0.1289      0.956 0.968 0.000 0.032
#> GSM28739     1  0.1289      0.956 0.968 0.000 0.032
#> GSM11243     3  0.0892      1.000 0.020 0.000 0.980
#> GSM28740     1  0.1289      0.956 0.968 0.000 0.032
#> GSM11259     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28726     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28743     1  0.1289      0.956 0.968 0.000 0.032
#> GSM11256     1  0.3692      0.910 0.896 0.048 0.056
#> GSM11262     1  0.1289      0.956 0.968 0.000 0.032
#> GSM28724     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28725     3  0.0892      1.000 0.020 0.000 0.980
#> GSM11263     3  0.0892      1.000 0.020 0.000 0.980
#> GSM11267     3  0.0892      1.000 0.020 0.000 0.980
#> GSM28744     1  0.3589      0.912 0.900 0.048 0.052
#> GSM28734     1  0.5435      0.829 0.808 0.048 0.144
#> GSM28747     1  0.0000      0.961 1.000 0.000 0.000
#> GSM11257     1  0.1453      0.948 0.968 0.024 0.008
#> GSM11252     1  0.1411      0.953 0.964 0.000 0.036
#> GSM11264     3  0.0892      1.000 0.020 0.000 0.980
#> GSM11247     3  0.0892      1.000 0.020 0.000 0.980
#> GSM11258     1  0.3983      0.908 0.884 0.048 0.068
#> GSM28728     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28746     1  0.1529      0.951 0.960 0.000 0.040
#> GSM28738     1  0.1015      0.954 0.980 0.012 0.008
#> GSM28741     1  0.3267      0.861 0.884 0.116 0.000
#> GSM28729     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.961 1.000 0.000 0.000
#> GSM11250     2  0.1753      1.000 0.048 0.952 0.000
#> GSM11245     1  0.1529      0.951 0.960 0.000 0.040
#> GSM11246     1  0.0747      0.959 0.984 0.000 0.016
#> GSM11261     1  0.5497      0.635 0.708 0.000 0.292
#> GSM11248     3  0.0892      1.000 0.020 0.000 0.980
#> GSM28732     1  0.0000      0.961 1.000 0.000 0.000
#> GSM11255     1  0.1529      0.951 0.960 0.000 0.040
#> GSM28731     1  0.0000      0.961 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.961 1.000 0.000 0.000
#> GSM11251     1  0.0237      0.960 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM28735     1  0.2011      0.727 0.920 0.000 0.000 0.080
#> GSM28736     1  0.3311      0.666 0.828 0.000 0.000 0.172
#> GSM28737     1  0.4401      0.659 0.724 0.000 0.004 0.272
#> GSM11249     3  0.2164      0.932 0.004 0.004 0.924 0.068
#> GSM28745     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11244     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28748     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11266     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28730     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11253     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11254     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11260     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28733     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11265     1  0.4608      0.634 0.692 0.000 0.004 0.304
#> GSM28739     1  0.4608      0.634 0.692 0.000 0.004 0.304
#> GSM11243     3  0.0895      0.968 0.004 0.000 0.976 0.020
#> GSM28740     1  0.4608      0.634 0.692 0.000 0.004 0.304
#> GSM11259     1  0.0336      0.753 0.992 0.000 0.000 0.008
#> GSM28726     1  0.3311      0.666 0.828 0.000 0.000 0.172
#> GSM28743     1  0.4608      0.634 0.692 0.000 0.004 0.304
#> GSM11256     4  0.3626      0.743 0.184 0.000 0.004 0.812
#> GSM11262     1  0.4608      0.634 0.692 0.000 0.004 0.304
#> GSM28724     1  0.0336      0.753 0.992 0.000 0.000 0.008
#> GSM28725     3  0.0188      0.973 0.004 0.000 0.996 0.000
#> GSM11263     3  0.0188      0.973 0.004 0.000 0.996 0.000
#> GSM11267     3  0.0376      0.973 0.004 0.004 0.992 0.000
#> GSM28744     4  0.1978      0.862 0.068 0.000 0.004 0.928
#> GSM28734     4  0.1833      0.850 0.024 0.000 0.032 0.944
#> GSM28747     1  0.0921      0.754 0.972 0.000 0.000 0.028
#> GSM11257     1  0.4122      0.585 0.760 0.004 0.000 0.236
#> GSM11252     1  0.4401      0.640 0.724 0.000 0.004 0.272
#> GSM11264     3  0.0376      0.973 0.004 0.004 0.992 0.000
#> GSM11247     3  0.0895      0.968 0.004 0.000 0.976 0.020
#> GSM11258     4  0.2345      0.785 0.100 0.000 0.000 0.900
#> GSM28728     1  0.1716      0.735 0.936 0.000 0.000 0.064
#> GSM28746     1  0.3208      0.722 0.848 0.000 0.004 0.148
#> GSM28738     1  0.4018      0.598 0.772 0.004 0.000 0.224
#> GSM28741     1  0.3198      0.701 0.880 0.080 0.000 0.040
#> GSM28729     1  0.3024      0.686 0.852 0.000 0.000 0.148
#> GSM28742     1  0.3311      0.666 0.828 0.000 0.000 0.172
#> GSM11250     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11245     1  0.4655      0.602 0.684 0.000 0.004 0.312
#> GSM11246     1  0.4584      0.637 0.696 0.000 0.004 0.300
#> GSM11261     1  0.6627      0.144 0.504 0.000 0.412 0.084
#> GSM11248     3  0.2088      0.936 0.004 0.004 0.928 0.064
#> GSM28732     1  0.0188      0.754 0.996 0.000 0.000 0.004
#> GSM11255     1  0.4313      0.664 0.736 0.000 0.004 0.260
#> GSM28731     1  0.0817      0.754 0.976 0.000 0.000 0.024
#> GSM28727     1  0.0000      0.754 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0188      0.754 0.996 0.000 0.004 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
#> GSM28735     5  0.1195     0.7849 0.028 0.000 0.000 0.012 0.960
#> GSM28736     5  0.0771     0.7802 0.004 0.000 0.000 0.020 0.976
#> GSM28737     1  0.3093     0.8858 0.824 0.000 0.000 0.008 0.168
#> GSM11249     3  0.3612     0.8399 0.100 0.000 0.832 0.064 0.004
#> GSM28745     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.3123     0.8901 0.828 0.000 0.000 0.012 0.160
#> GSM28739     1  0.3123     0.8901 0.828 0.000 0.000 0.012 0.160
#> GSM11243     3  0.1907     0.9099 0.044 0.000 0.928 0.028 0.000
#> GSM28740     1  0.3123     0.8901 0.828 0.000 0.000 0.012 0.160
#> GSM11259     5  0.1732     0.7735 0.080 0.000 0.000 0.000 0.920
#> GSM28726     5  0.0771     0.7802 0.004 0.000 0.000 0.020 0.976
#> GSM28743     1  0.3123     0.8901 0.828 0.000 0.000 0.012 0.160
#> GSM11256     4  0.1211     0.9800 0.016 0.000 0.000 0.960 0.024
#> GSM11262     1  0.3123     0.8901 0.828 0.000 0.000 0.012 0.160
#> GSM28724     5  0.2011     0.7747 0.088 0.000 0.000 0.004 0.908
#> GSM28725     3  0.0000     0.9313 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0404     0.9300 0.012 0.000 0.988 0.000 0.000
#> GSM11267     3  0.0162     0.9312 0.000 0.000 0.996 0.004 0.000
#> GSM28744     4  0.1211     0.9889 0.024 0.000 0.000 0.960 0.016
#> GSM28734     4  0.1211     0.9889 0.024 0.000 0.000 0.960 0.016
#> GSM28747     5  0.4227     0.1409 0.420 0.000 0.000 0.000 0.580
#> GSM11257     5  0.1522     0.7581 0.012 0.000 0.000 0.044 0.944
#> GSM11252     1  0.4728     0.6548 0.700 0.000 0.000 0.060 0.240
#> GSM11264     3  0.0162     0.9312 0.000 0.000 0.996 0.004 0.000
#> GSM11247     3  0.2139     0.9038 0.052 0.000 0.916 0.032 0.000
#> GSM11258     4  0.1364     0.9790 0.036 0.000 0.000 0.952 0.012
#> GSM28728     5  0.1768     0.7801 0.072 0.000 0.000 0.004 0.924
#> GSM28746     5  0.4446    -0.0207 0.476 0.000 0.000 0.004 0.520
#> GSM28738     5  0.1444     0.7597 0.012 0.000 0.000 0.040 0.948
#> GSM28741     5  0.1455     0.7846 0.032 0.008 0.000 0.008 0.952
#> GSM28729     5  0.0798     0.7775 0.016 0.000 0.000 0.008 0.976
#> GSM28742     5  0.0798     0.7790 0.008 0.000 0.000 0.016 0.976
#> GSM11250     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11245     1  0.4701     0.6608 0.704 0.000 0.000 0.060 0.236
#> GSM11246     1  0.3163     0.8886 0.824 0.000 0.000 0.012 0.164
#> GSM11261     5  0.6536     0.0134 0.088 0.000 0.392 0.036 0.484
#> GSM11248     3  0.3547     0.8437 0.100 0.000 0.836 0.060 0.004
#> GSM28732     5  0.1792     0.7703 0.084 0.000 0.000 0.000 0.916
#> GSM11255     1  0.3109     0.7479 0.800 0.000 0.000 0.000 0.200
#> GSM28731     5  0.4235     0.1423 0.424 0.000 0.000 0.000 0.576
#> GSM28727     5  0.2690     0.7096 0.156 0.000 0.000 0.000 0.844
#> GSM11251     5  0.3837     0.4649 0.308 0.000 0.000 0.000 0.692

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM28735     5  0.0458     0.6830 0.016 0.000 0.000 0.000 0.984 NA
#> GSM28736     5  0.1590     0.6786 0.008 0.000 0.000 0.008 0.936 NA
#> GSM28737     1  0.0458     0.7036 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11249     3  0.3986     0.7496 0.012 0.000 0.748 0.036 0.000 NA
#> GSM28745     2  0.0260     0.9959 0.000 0.992 0.000 0.000 0.000 NA
#> GSM11244     2  0.0000     0.9972 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28748     2  0.0146     0.9970 0.000 0.996 0.000 0.000 0.000 NA
#> GSM11266     2  0.0000     0.9972 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28730     2  0.0260     0.9959 0.000 0.992 0.000 0.000 0.000 NA
#> GSM11253     2  0.0146     0.9970 0.000 0.996 0.000 0.000 0.000 NA
#> GSM11254     2  0.0000     0.9972 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11260     2  0.0260     0.9959 0.000 0.992 0.000 0.000 0.000 NA
#> GSM28733     2  0.0000     0.9972 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11265     1  0.0748     0.7026 0.976 0.000 0.000 0.004 0.016 NA
#> GSM28739     1  0.0748     0.7026 0.976 0.000 0.000 0.004 0.016 NA
#> GSM11243     3  0.2302     0.8473 0.000 0.000 0.872 0.008 0.000 NA
#> GSM28740     1  0.0603     0.7033 0.980 0.000 0.000 0.004 0.016 NA
#> GSM11259     5  0.4535     0.6220 0.152 0.000 0.000 0.000 0.704 NA
#> GSM28726     5  0.3133     0.6486 0.008 0.000 0.000 0.008 0.804 NA
#> GSM28743     1  0.0862     0.7025 0.972 0.000 0.000 0.004 0.016 NA
#> GSM11256     4  0.0725     0.9829 0.012 0.000 0.000 0.976 0.000 NA
#> GSM11262     1  0.0862     0.7025 0.972 0.000 0.000 0.004 0.016 NA
#> GSM28724     5  0.5156     0.5658 0.164 0.000 0.000 0.000 0.620 NA
#> GSM28725     3  0.0000     0.8928 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11263     3  0.0000     0.8928 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11267     3  0.0000     0.8928 0.000 0.000 1.000 0.000 0.000 NA
#> GSM28744     4  0.0260     0.9856 0.008 0.000 0.000 0.992 0.000 NA
#> GSM28734     4  0.0520     0.9845 0.008 0.000 0.000 0.984 0.000 NA
#> GSM28747     1  0.5954     0.0174 0.408 0.000 0.000 0.000 0.372 NA
#> GSM11257     5  0.4635     0.5559 0.008 0.000 0.000 0.024 0.488 NA
#> GSM11252     1  0.5961     0.4687 0.456 0.000 0.000 0.036 0.096 NA
#> GSM11264     3  0.0000     0.8928 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11247     3  0.2346     0.8452 0.000 0.000 0.868 0.008 0.000 NA
#> GSM11258     4  0.0713     0.9765 0.028 0.000 0.000 0.972 0.000 NA
#> GSM28728     5  0.4261     0.6472 0.112 0.000 0.000 0.000 0.732 NA
#> GSM28746     1  0.6149     0.1944 0.380 0.000 0.000 0.004 0.244 NA
#> GSM28738     5  0.4362     0.5768 0.004 0.000 0.000 0.020 0.584 NA
#> GSM28741     5  0.1074     0.6776 0.012 0.000 0.000 0.000 0.960 NA
#> GSM28729     5  0.4321     0.6229 0.012 0.000 0.000 0.008 0.580 NA
#> GSM28742     5  0.3023     0.6479 0.004 0.000 0.000 0.008 0.808 NA
#> GSM11250     2  0.0000     0.9972 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11245     1  0.5961     0.4687 0.456 0.000 0.000 0.036 0.096 NA
#> GSM11246     1  0.0458     0.7036 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11261     5  0.6840     0.1910 0.040 0.000 0.252 0.004 0.404 NA
#> GSM11248     3  0.4015     0.7464 0.012 0.000 0.744 0.036 0.000 NA
#> GSM28732     5  0.5170     0.5213 0.176 0.000 0.000 0.000 0.620 NA
#> GSM11255     1  0.4388     0.5438 0.572 0.000 0.000 0.000 0.028 NA
#> GSM28731     1  0.6051    -0.0274 0.384 0.000 0.000 0.000 0.360 NA
#> GSM28727     5  0.4358     0.5862 0.196 0.000 0.000 0.000 0.712 NA
#> GSM11251     5  0.5083     0.3888 0.320 0.000 0.000 0.000 0.580 NA

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 tissue(p) k
#> CV:kmeans 50     0.394 2
#> CV:kmeans 50     0.370 3
#> CV:kmeans 49     0.509 4
#> CV:kmeans 45     0.483 5
#> CV:kmeans 43     0.487 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 21342 rows and 50 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 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-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.735           0.842       0.927         0.4614 0.519   0.519
#> 3 3 0.856           0.838       0.938         0.4334 0.726   0.518
#> 4 4 0.757           0.746       0.878         0.1360 0.776   0.451
#> 5 5 0.802           0.782       0.886         0.0700 0.933   0.738
#> 6 6 0.818           0.705       0.807         0.0389 0.968   0.842

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
#> GSM28735     1   0.224      0.921 0.964 0.036
#> GSM28736     2   0.871      0.523 0.292 0.708
#> GSM28737     1   0.000      0.958 1.000 0.000
#> GSM11249     1   0.000      0.958 1.000 0.000
#> GSM28745     2   0.000      0.836 0.000 1.000
#> GSM11244     2   0.000      0.836 0.000 1.000
#> GSM28748     2   0.000      0.836 0.000 1.000
#> GSM11266     2   0.000      0.836 0.000 1.000
#> GSM28730     2   0.000      0.836 0.000 1.000
#> GSM11253     2   0.000      0.836 0.000 1.000
#> GSM11254     2   0.000      0.836 0.000 1.000
#> GSM11260     2   0.000      0.836 0.000 1.000
#> GSM28733     2   0.000      0.836 0.000 1.000
#> GSM11265     1   0.000      0.958 1.000 0.000
#> GSM28739     1   0.000      0.958 1.000 0.000
#> GSM11243     2   0.955      0.571 0.376 0.624
#> GSM28740     1   0.000      0.958 1.000 0.000
#> GSM11259     1   0.000      0.958 1.000 0.000
#> GSM28726     1   0.958      0.358 0.620 0.380
#> GSM28743     1   0.000      0.958 1.000 0.000
#> GSM11256     1   0.000      0.958 1.000 0.000
#> GSM11262     1   0.000      0.958 1.000 0.000
#> GSM28724     1   0.000      0.958 1.000 0.000
#> GSM28725     2   0.955      0.571 0.376 0.624
#> GSM11263     2   0.955      0.571 0.376 0.624
#> GSM11267     2   0.961      0.556 0.384 0.616
#> GSM28744     1   0.000      0.958 1.000 0.000
#> GSM28734     1   0.000      0.958 1.000 0.000
#> GSM28747     1   0.000      0.958 1.000 0.000
#> GSM11257     1   0.000      0.958 1.000 0.000
#> GSM11252     1   0.000      0.958 1.000 0.000
#> GSM11264     2   0.955      0.571 0.376 0.624
#> GSM11247     2   0.955      0.571 0.376 0.624
#> GSM11258     1   0.000      0.958 1.000 0.000
#> GSM28728     1   0.000      0.958 1.000 0.000
#> GSM28746     1   0.000      0.958 1.000 0.000
#> GSM28738     1   0.973      0.301 0.596 0.404
#> GSM28741     2   0.000      0.836 0.000 1.000
#> GSM28729     1   0.000      0.958 1.000 0.000
#> GSM28742     1   0.730      0.696 0.796 0.204
#> GSM11250     2   0.000      0.836 0.000 1.000
#> GSM11245     1   0.000      0.958 1.000 0.000
#> GSM11246     1   0.000      0.958 1.000 0.000
#> GSM11261     2   0.388      0.805 0.076 0.924
#> GSM11248     1   0.000      0.958 1.000 0.000
#> GSM28732     1   0.000      0.958 1.000 0.000
#> GSM11255     1   0.000      0.958 1.000 0.000
#> GSM28731     1   0.000      0.958 1.000 0.000
#> GSM28727     1   0.000      0.958 1.000 0.000
#> GSM11251     1   0.000      0.958 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
#> GSM28735     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28736     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM28737     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11249     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM28745     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11244     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM28748     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11266     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM28730     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11253     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11254     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11260     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM28733     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11265     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28739     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11243     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM28740     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11259     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28726     2  0.3551     0.8384 0.132 0.868 0.000
#> GSM28743     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11256     3  0.0747     0.9207 0.016 0.000 0.984
#> GSM11262     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28724     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28725     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM11263     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM11267     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM28744     3  0.1964     0.8898 0.056 0.000 0.944
#> GSM28734     3  0.0747     0.9207 0.016 0.000 0.984
#> GSM28747     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11257     3  0.5397     0.5787 0.280 0.000 0.720
#> GSM11252     1  0.6180     0.2528 0.584 0.000 0.416
#> GSM11264     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM11247     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM11258     1  0.5948     0.4028 0.640 0.000 0.360
#> GSM28728     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28746     1  0.4654     0.6777 0.792 0.000 0.208
#> GSM28738     1  0.9857     0.0571 0.404 0.336 0.260
#> GSM28741     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM28729     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28742     1  0.6299     0.0478 0.524 0.476 0.000
#> GSM11250     2  0.0000     0.9875 0.000 1.000 0.000
#> GSM11245     3  0.6286     0.0752 0.464 0.000 0.536
#> GSM11246     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11261     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM11248     3  0.0000     0.9275 0.000 0.000 1.000
#> GSM28732     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11255     1  0.2261     0.8384 0.932 0.000 0.068
#> GSM28731     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM28727     1  0.0000     0.8944 1.000 0.000 0.000
#> GSM11251     1  0.0000     0.8944 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
#> GSM28735     1  0.0817     0.6374 0.976 0.000 0.000 0.024
#> GSM28736     1  0.3837     0.4586 0.776 0.224 0.000 0.000
#> GSM28737     4  0.0188     0.8693 0.004 0.000 0.000 0.996
#> GSM11249     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM28745     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11265     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM28739     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM11243     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM28740     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM11259     1  0.4925     0.4281 0.572 0.000 0.000 0.428
#> GSM28726     1  0.0188     0.6377 0.996 0.000 0.000 0.004
#> GSM28743     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM11256     1  0.6865    -0.0340 0.524 0.000 0.364 0.112
#> GSM11262     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM28724     1  0.4992     0.3528 0.524 0.000 0.000 0.476
#> GSM28725     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM28744     1  0.6602     0.0312 0.484 0.000 0.080 0.436
#> GSM28734     3  0.6719     0.5287 0.204 0.000 0.616 0.180
#> GSM28747     1  0.4998     0.3280 0.512 0.000 0.000 0.488
#> GSM11257     1  0.2060     0.6108 0.932 0.000 0.052 0.016
#> GSM11252     4  0.4776     0.6549 0.016 0.000 0.272 0.712
#> GSM11264     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM11258     4  0.1022     0.8456 0.032 0.000 0.000 0.968
#> GSM28728     1  0.2814     0.6133 0.868 0.000 0.000 0.132
#> GSM28746     4  0.5613     0.6302 0.120 0.000 0.156 0.724
#> GSM28738     1  0.0188     0.6355 0.996 0.004 0.000 0.000
#> GSM28741     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM28729     1  0.0188     0.6377 0.996 0.000 0.000 0.004
#> GSM28742     1  0.0188     0.6377 0.996 0.000 0.000 0.004
#> GSM11250     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM11245     4  0.4819     0.5631 0.004 0.000 0.344 0.652
#> GSM11246     4  0.0000     0.8723 0.000 0.000 0.000 1.000
#> GSM11261     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM11248     3  0.0000     0.9597 0.000 0.000 1.000 0.000
#> GSM28732     1  0.4941     0.4197 0.564 0.000 0.000 0.436
#> GSM11255     4  0.2944     0.7943 0.004 0.000 0.128 0.868
#> GSM28731     1  0.4994     0.3462 0.520 0.000 0.000 0.480
#> GSM28727     1  0.4955     0.4095 0.556 0.000 0.000 0.444
#> GSM11251     1  0.4955     0.4095 0.556 0.000 0.000 0.444

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.2773     0.6905 0.020 0.000 0.000 0.112 0.868
#> GSM28736     5  0.5413     0.4875 0.000 0.172 0.000 0.164 0.664
#> GSM28737     1  0.0162     0.8518 0.996 0.000 0.000 0.000 0.004
#> GSM11249     3  0.2439     0.8447 0.000 0.000 0.876 0.120 0.004
#> GSM28745     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0000     0.8548 1.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000     0.8548 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.0000     0.8548 1.000 0.000 0.000 0.000 0.000
#> GSM11259     5  0.2605     0.7314 0.148 0.000 0.000 0.000 0.852
#> GSM28726     5  0.2583     0.6753 0.000 0.004 0.000 0.132 0.864
#> GSM28743     1  0.0000     0.8548 1.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.0000     0.7837 0.000 0.000 0.000 1.000 0.000
#> GSM11262     1  0.0000     0.8548 1.000 0.000 0.000 0.000 0.000
#> GSM28724     5  0.6053     0.5269 0.292 0.000 0.004 0.136 0.568
#> GSM28725     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.0162     0.7854 0.004 0.000 0.000 0.996 0.000
#> GSM28734     4  0.2300     0.7567 0.024 0.000 0.072 0.904 0.000
#> GSM28747     5  0.4957     0.3565 0.444 0.000 0.000 0.028 0.528
#> GSM11257     4  0.1671     0.7395 0.000 0.000 0.000 0.924 0.076
#> GSM11252     1  0.6775     0.3056 0.528 0.000 0.104 0.316 0.052
#> GSM11264     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000     0.9804 0.000 0.000 1.000 0.000 0.000
#> GSM11258     4  0.3242     0.6376 0.216 0.000 0.000 0.784 0.000
#> GSM28728     5  0.2464     0.7303 0.096 0.000 0.000 0.016 0.888
#> GSM28746     4  0.6614    -0.0518 0.416 0.000 0.012 0.424 0.148
#> GSM28738     5  0.4101     0.4159 0.000 0.000 0.000 0.372 0.628
#> GSM28741     2  0.0290     0.9913 0.000 0.992 0.000 0.000 0.008
#> GSM28729     5  0.2338     0.6870 0.004 0.000 0.000 0.112 0.884
#> GSM28742     5  0.2280     0.6825 0.000 0.000 0.000 0.120 0.880
#> GSM11250     2  0.0000     0.9991 0.000 1.000 0.000 0.000 0.000
#> GSM11245     1  0.6938     0.2285 0.492 0.000 0.148 0.324 0.036
#> GSM11246     1  0.0162     0.8526 0.996 0.000 0.000 0.000 0.004
#> GSM11261     3  0.0290     0.9747 0.000 0.000 0.992 0.008 0.000
#> GSM11248     3  0.0324     0.9758 0.000 0.000 0.992 0.004 0.004
#> GSM28732     5  0.2848     0.7286 0.156 0.000 0.000 0.004 0.840
#> GSM11255     1  0.4195     0.7202 0.812 0.000 0.056 0.096 0.036
#> GSM28731     5  0.4288     0.4847 0.384 0.000 0.000 0.004 0.612
#> GSM28727     5  0.3305     0.7065 0.224 0.000 0.000 0.000 0.776
#> GSM11251     5  0.3586     0.6777 0.264 0.000 0.000 0.000 0.736

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.4514      0.456 0.008 0.000 0.000 0.044 0.660 0.288
#> GSM28736     5  0.5695      0.381 0.000 0.076 0.000 0.044 0.564 0.316
#> GSM28737     1  0.0405      0.889 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM11249     3  0.3977      0.725 0.000 0.000 0.760 0.096 0.000 0.144
#> GSM28745     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0146      0.939 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM28740     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     5  0.2775      0.555 0.104 0.000 0.000 0.000 0.856 0.040
#> GSM28726     5  0.4401      0.356 0.000 0.000 0.000 0.024 0.512 0.464
#> GSM28743     1  0.0458      0.888 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM11256     4  0.0260      0.860 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM11262     1  0.0458      0.888 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM28724     5  0.5551      0.414 0.160 0.000 0.000 0.044 0.648 0.148
#> GSM28725     3  0.0000      0.940 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.940 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.940 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0146      0.861 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM28734     4  0.0622      0.849 0.000 0.000 0.008 0.980 0.000 0.012
#> GSM28747     5  0.5595      0.322 0.268 0.000 0.000 0.000 0.540 0.192
#> GSM11257     4  0.3641      0.654 0.000 0.000 0.000 0.748 0.028 0.224
#> GSM11252     6  0.7479      0.445 0.248 0.000 0.056 0.196 0.052 0.448
#> GSM11264     3  0.0000      0.940 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0146      0.939 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM11258     4  0.2300      0.730 0.144 0.000 0.000 0.856 0.000 0.000
#> GSM28728     5  0.3431      0.547 0.056 0.000 0.008 0.016 0.840 0.080
#> GSM28746     6  0.7766      0.286 0.244 0.000 0.008 0.272 0.156 0.320
#> GSM28738     6  0.5763     -0.343 0.000 0.000 0.000 0.180 0.356 0.464
#> GSM28741     2  0.0914      0.967 0.000 0.968 0.000 0.000 0.016 0.016
#> GSM28729     5  0.4830      0.279 0.004 0.000 0.000 0.044 0.496 0.456
#> GSM28742     5  0.4331      0.358 0.000 0.000 0.000 0.020 0.516 0.464
#> GSM11250     2  0.0000      0.997 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.7536      0.449 0.240 0.000 0.068 0.196 0.048 0.448
#> GSM11246     1  0.0547      0.880 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM11261     3  0.1180      0.917 0.000 0.004 0.960 0.024 0.008 0.004
#> GSM11248     3  0.2983      0.812 0.000 0.000 0.832 0.032 0.000 0.136
#> GSM28732     5  0.3983      0.466 0.056 0.000 0.000 0.000 0.736 0.208
#> GSM11255     1  0.5802     -0.193 0.472 0.000 0.012 0.060 0.028 0.428
#> GSM28731     5  0.5991      0.282 0.260 0.000 0.000 0.004 0.480 0.256
#> GSM28727     5  0.3772      0.536 0.160 0.000 0.000 0.000 0.772 0.068
#> GSM11251     5  0.4135      0.468 0.300 0.000 0.000 0.000 0.668 0.032

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 tissue(p) k
#> CV:skmeans 48     0.392 2
#> CV:skmeans 45     0.447 3
#> CV:skmeans 40     0.406 4
#> CV:skmeans 43     0.463 5
#> CV:skmeans 35     0.435 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 21342 rows and 50 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 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-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 1.000           1.000       1.000         0.3511 0.650   0.650
#> 3 3 1.000           0.975       0.990         0.6008 0.798   0.688
#> 4 4 0.876           0.965       0.974         0.1616 0.912   0.803
#> 5 5 0.764           0.734       0.879         0.1246 0.910   0.750
#> 6 6 0.805           0.712       0.842         0.0679 0.913   0.706

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1  0.0000      1.000 1.000 0.000
#> GSM28736     1  0.0938      0.988 0.988 0.012
#> GSM28737     1  0.0000      1.000 1.000 0.000
#> GSM11249     1  0.0000      1.000 1.000 0.000
#> GSM28745     2  0.0000      1.000 0.000 1.000
#> GSM11244     2  0.0000      1.000 0.000 1.000
#> GSM28748     2  0.0000      1.000 0.000 1.000
#> GSM11266     2  0.0000      1.000 0.000 1.000
#> GSM28730     2  0.0000      1.000 0.000 1.000
#> GSM11253     2  0.0000      1.000 0.000 1.000
#> GSM11254     2  0.0000      1.000 0.000 1.000
#> GSM11260     2  0.0000      1.000 0.000 1.000
#> GSM28733     2  0.0000      1.000 0.000 1.000
#> GSM11265     1  0.0000      1.000 1.000 0.000
#> GSM28739     1  0.0000      1.000 1.000 0.000
#> GSM11243     1  0.0000      1.000 1.000 0.000
#> GSM28740     1  0.0000      1.000 1.000 0.000
#> GSM11259     1  0.0000      1.000 1.000 0.000
#> GSM28726     1  0.0000      1.000 1.000 0.000
#> GSM28743     1  0.0000      1.000 1.000 0.000
#> GSM11256     1  0.0000      1.000 1.000 0.000
#> GSM11262     1  0.0000      1.000 1.000 0.000
#> GSM28724     1  0.0000      1.000 1.000 0.000
#> GSM28725     1  0.0000      1.000 1.000 0.000
#> GSM11263     1  0.0000      1.000 1.000 0.000
#> GSM11267     1  0.0000      1.000 1.000 0.000
#> GSM28744     1  0.0000      1.000 1.000 0.000
#> GSM28734     1  0.0000      1.000 1.000 0.000
#> GSM28747     1  0.0000      1.000 1.000 0.000
#> GSM11257     1  0.0000      1.000 1.000 0.000
#> GSM11252     1  0.0000      1.000 1.000 0.000
#> GSM11264     1  0.0000      1.000 1.000 0.000
#> GSM11247     1  0.0000      1.000 1.000 0.000
#> GSM11258     1  0.0000      1.000 1.000 0.000
#> GSM28728     1  0.0000      1.000 1.000 0.000
#> GSM28746     1  0.0000      1.000 1.000 0.000
#> GSM28738     1  0.0000      1.000 1.000 0.000
#> GSM28741     2  0.0000      1.000 0.000 1.000
#> GSM28729     1  0.0000      1.000 1.000 0.000
#> GSM28742     1  0.0000      1.000 1.000 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000
#> GSM11245     1  0.0000      1.000 1.000 0.000
#> GSM11246     1  0.0000      1.000 1.000 0.000
#> GSM11261     1  0.0000      1.000 1.000 0.000
#> GSM11248     1  0.0000      1.000 1.000 0.000
#> GSM28732     1  0.0000      1.000 1.000 0.000
#> GSM11255     1  0.0000      1.000 1.000 0.000
#> GSM28731     1  0.0000      1.000 1.000 0.000
#> GSM28727     1  0.0000      1.000 1.000 0.000
#> GSM11251     1  0.0000      1.000 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
#> GSM28735     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28736     1  0.0592      0.972 0.988 0.012 0.000
#> GSM28737     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11249     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28726     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28743     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11256     1  0.3412      0.854 0.876 0.000 0.124
#> GSM11262     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28744     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28734     1  0.5988      0.434 0.632 0.000 0.368
#> GSM28747     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11257     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11252     1  0.0237      0.980 0.996 0.000 0.004
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11258     1  0.0237      0.980 0.996 0.000 0.004
#> GSM28728     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28746     1  0.0237      0.980 0.996 0.000 0.004
#> GSM28738     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28729     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11245     1  0.0237      0.980 0.996 0.000 0.004
#> GSM11246     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11261     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11248     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11255     1  0.0237      0.980 0.996 0.000 0.004
#> GSM28731     1  0.0000      0.982 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.982 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.982 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
#> GSM28735     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28736     1  0.0469      0.948 0.988 0.012 0.000 0.000
#> GSM28737     1  0.2408      0.931 0.896 0.000 0.000 0.104
#> GSM11249     3  0.1557      0.941 0.000 0.000 0.944 0.056
#> GSM28745     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11265     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM28739     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM11243     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM28740     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM11259     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28726     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28743     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM11256     4  0.0336      0.989 0.008 0.000 0.000 0.992
#> GSM11262     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM28724     1  0.1940      0.940 0.924 0.000 0.000 0.076
#> GSM28725     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM28744     4  0.0336      0.989 0.008 0.000 0.000 0.992
#> GSM28734     4  0.0592      0.979 0.000 0.000 0.016 0.984
#> GSM28747     1  0.0469      0.954 0.988 0.000 0.000 0.012
#> GSM11257     1  0.0592      0.952 0.984 0.000 0.000 0.016
#> GSM11252     1  0.1940      0.940 0.924 0.000 0.000 0.076
#> GSM11264     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM11258     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM28728     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28746     1  0.0336      0.954 0.992 0.000 0.000 0.008
#> GSM28738     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28741     2  0.0817      0.968 0.024 0.976 0.000 0.000
#> GSM28729     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28742     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM11250     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM11245     1  0.2469      0.929 0.892 0.000 0.000 0.108
#> GSM11246     1  0.0336      0.954 0.992 0.000 0.000 0.008
#> GSM11261     1  0.2593      0.929 0.892 0.000 0.004 0.104
#> GSM11248     3  0.0000      0.992 0.000 0.000 1.000 0.000
#> GSM28732     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM11255     1  0.2345      0.932 0.900 0.000 0.000 0.100
#> GSM28731     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM28727     1  0.0000      0.955 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.955 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1   p2    p3    p4    p5
#> GSM28735     1  0.4273      0.137 0.552 0.00 0.000 0.000 0.448
#> GSM28736     5  0.3684      0.678 0.280 0.00 0.000 0.000 0.720
#> GSM28737     1  0.0566      0.654 0.984 0.00 0.000 0.004 0.012
#> GSM11249     3  0.3210      0.873 0.008 0.00 0.860 0.040 0.092
#> GSM28745     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11265     1  0.0290      0.650 0.992 0.00 0.000 0.008 0.000
#> GSM28739     1  0.0290      0.650 0.992 0.00 0.000 0.008 0.000
#> GSM11243     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM28740     1  0.0290      0.650 0.992 0.00 0.000 0.008 0.000
#> GSM11259     1  0.4138      0.337 0.616 0.00 0.000 0.000 0.384
#> GSM28726     5  0.4030      0.591 0.352 0.00 0.000 0.000 0.648
#> GSM28743     1  0.0290      0.650 0.992 0.00 0.000 0.008 0.000
#> GSM11256     4  0.0000      0.994 0.000 0.00 0.000 1.000 0.000
#> GSM11262     1  0.0290      0.650 0.992 0.00 0.000 0.008 0.000
#> GSM28724     1  0.3586      0.499 0.736 0.00 0.000 0.000 0.264
#> GSM28725     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM28744     4  0.0000      0.994 0.000 0.00 0.000 1.000 0.000
#> GSM28734     4  0.0000      0.994 0.000 0.00 0.000 1.000 0.000
#> GSM28747     1  0.4150      0.332 0.612 0.00 0.000 0.000 0.388
#> GSM11257     5  0.3612      0.527 0.268 0.00 0.000 0.000 0.732
#> GSM11252     1  0.3796      0.448 0.700 0.00 0.000 0.000 0.300
#> GSM11264     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM11247     3  0.0000      0.966 0.000 0.00 1.000 0.000 0.000
#> GSM11258     4  0.0510      0.981 0.016 0.00 0.000 0.984 0.000
#> GSM28728     1  0.3534      0.552 0.744 0.00 0.000 0.000 0.256
#> GSM28746     1  0.1270      0.655 0.948 0.00 0.000 0.000 0.052
#> GSM28738     5  0.3561      0.577 0.260 0.00 0.000 0.000 0.740
#> GSM28741     2  0.2280      0.860 0.000 0.88 0.000 0.000 0.120
#> GSM28729     1  0.4101      0.363 0.628 0.00 0.000 0.000 0.372
#> GSM28742     5  0.3661      0.670 0.276 0.00 0.000 0.000 0.724
#> GSM11250     2  0.0000      0.987 0.000 1.00 0.000 0.000 0.000
#> GSM11245     1  0.2561      0.564 0.856 0.00 0.000 0.000 0.144
#> GSM11246     1  0.1544      0.655 0.932 0.00 0.000 0.000 0.068
#> GSM11261     1  0.2171      0.631 0.912 0.00 0.064 0.000 0.024
#> GSM11248     3  0.2193      0.900 0.008 0.00 0.900 0.000 0.092
#> GSM28732     1  0.3707      0.517 0.716 0.00 0.000 0.000 0.284
#> GSM11255     1  0.1478      0.587 0.936 0.00 0.000 0.000 0.064
#> GSM28731     1  0.3534      0.552 0.744 0.00 0.000 0.000 0.256
#> GSM28727     1  0.4161      0.321 0.608 0.00 0.000 0.000 0.392
#> GSM11251     1  0.4138      0.337 0.616 0.00 0.000 0.000 0.384

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     1  0.3318     0.2807 0.796 0.000 0.000 0.000 0.172 0.032
#> GSM28736     5  0.3747     0.9030 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM28737     1  0.3706     0.6320 0.620 0.000 0.000 0.000 0.380 0.000
#> GSM11249     6  0.3647     0.3261 0.000 0.000 0.360 0.000 0.000 0.640
#> GSM28745     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3727     0.6289 0.612 0.000 0.000 0.000 0.388 0.000
#> GSM28739     1  0.3727     0.6289 0.612 0.000 0.000 0.000 0.388 0.000
#> GSM11243     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28740     1  0.3727     0.6289 0.612 0.000 0.000 0.000 0.388 0.000
#> GSM11259     1  0.0000     0.6078 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28726     5  0.3747     0.9030 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM28743     1  0.3727     0.6289 0.612 0.000 0.000 0.000 0.388 0.000
#> GSM11256     4  0.0000     0.9900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11262     1  0.3727     0.6289 0.612 0.000 0.000 0.000 0.388 0.000
#> GSM28724     1  0.2402     0.6560 0.856 0.000 0.000 0.000 0.140 0.004
#> GSM28725     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0000     0.9900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0000     0.9900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28747     1  0.0146     0.6060 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11257     6  0.1757     0.2770 0.076 0.000 0.000 0.000 0.008 0.916
#> GSM11252     6  0.3620     0.4913 0.352 0.000 0.000 0.000 0.000 0.648
#> GSM11264     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11258     4  0.0632     0.9699 0.000 0.000 0.000 0.976 0.024 0.000
#> GSM28728     1  0.0000     0.6078 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28746     1  0.5137     0.5677 0.596 0.000 0.000 0.000 0.284 0.120
#> GSM28738     1  0.5818    -0.6398 0.456 0.000 0.000 0.000 0.192 0.352
#> GSM28741     2  0.2046     0.8879 0.060 0.908 0.000 0.000 0.032 0.000
#> GSM28729     1  0.1088     0.5651 0.960 0.000 0.000 0.000 0.024 0.016
#> GSM28742     5  0.5759     0.7792 0.392 0.000 0.000 0.000 0.436 0.172
#> GSM11250     2  0.0000     0.9897 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.3620     0.4913 0.352 0.000 0.000 0.000 0.000 0.648
#> GSM11246     1  0.3531     0.6434 0.672 0.000 0.000 0.000 0.328 0.000
#> GSM11261     1  0.5363     0.5379 0.608 0.000 0.196 0.000 0.192 0.004
#> GSM11248     6  0.3620     0.3384 0.000 0.000 0.352 0.000 0.000 0.648
#> GSM28732     1  0.3789     0.0867 0.584 0.000 0.000 0.000 0.000 0.416
#> GSM11255     6  0.3847     0.2465 0.456 0.000 0.000 0.000 0.000 0.544
#> GSM28731     1  0.0000     0.6078 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28727     1  0.0363     0.6013 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM11251     1  0.0000     0.6078 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-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 tissue(p) k
#> CV:pam 50     0.394 2
#> CV:pam 49     0.368 3
#> CV:pam 50     0.512 4
#> CV:pam 42     0.457 5
#> CV:pam 41     0.448 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 21342 rows and 50 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.499           0.882       0.913         0.4503 0.519   0.519
#> 3 3 0.811           0.856       0.935         0.3889 0.760   0.574
#> 4 4 0.773           0.807       0.898         0.0629 0.909   0.776
#> 5 5 0.745           0.799       0.885         0.1234 0.845   0.591
#> 6 6 0.762           0.815       0.860         0.0766 0.894   0.605

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
#> GSM28735     1  0.2778      0.935 0.952 0.048
#> GSM28736     1  0.5178      0.886 0.884 0.116
#> GSM28737     1  0.0000      0.951 1.000 0.000
#> GSM11249     2  0.8909      0.770 0.308 0.692
#> GSM28745     2  0.1843      0.834 0.028 0.972
#> GSM11244     2  0.1843      0.834 0.028 0.972
#> GSM28748     2  0.1843      0.834 0.028 0.972
#> GSM11266     2  0.1843      0.834 0.028 0.972
#> GSM28730     2  0.1843      0.834 0.028 0.972
#> GSM11253     2  0.1843      0.834 0.028 0.972
#> GSM11254     2  0.1843      0.834 0.028 0.972
#> GSM11260     2  0.1843      0.834 0.028 0.972
#> GSM28733     2  0.1843      0.834 0.028 0.972
#> GSM11265     1  0.0000      0.951 1.000 0.000
#> GSM28739     1  0.0000      0.951 1.000 0.000
#> GSM11243     2  0.8909      0.770 0.308 0.692
#> GSM28740     1  0.0000      0.951 1.000 0.000
#> GSM11259     1  0.0000      0.951 1.000 0.000
#> GSM28726     1  0.4939      0.894 0.892 0.108
#> GSM28743     1  0.0000      0.951 1.000 0.000
#> GSM11256     1  0.6048      0.879 0.852 0.148
#> GSM11262     1  0.1633      0.943 0.976 0.024
#> GSM28724     1  0.0000      0.951 1.000 0.000
#> GSM28725     2  0.8909      0.770 0.308 0.692
#> GSM11263     2  0.8909      0.770 0.308 0.692
#> GSM11267     2  0.8909      0.770 0.308 0.692
#> GSM28744     1  0.6048      0.879 0.852 0.148
#> GSM28734     1  0.6048      0.879 0.852 0.148
#> GSM28747     1  0.0000      0.951 1.000 0.000
#> GSM11257     1  0.5294      0.887 0.880 0.120
#> GSM11252     1  0.0376      0.948 0.996 0.004
#> GSM11264     2  0.8909      0.770 0.308 0.692
#> GSM11247     2  0.8909      0.770 0.308 0.692
#> GSM11258     1  0.6048      0.879 0.852 0.148
#> GSM28728     1  0.0000      0.951 1.000 0.000
#> GSM28746     1  0.0376      0.948 0.996 0.004
#> GSM28738     1  0.2778      0.935 0.952 0.048
#> GSM28741     1  0.5629      0.877 0.868 0.132
#> GSM28729     1  0.2778      0.935 0.952 0.048
#> GSM28742     1  0.2778      0.935 0.952 0.048
#> GSM11250     2  0.1843      0.834 0.028 0.972
#> GSM11245     1  0.0376      0.948 0.996 0.004
#> GSM11246     1  0.0000      0.951 1.000 0.000
#> GSM11261     2  0.8909      0.770 0.308 0.692
#> GSM11248     2  0.8909      0.770 0.308 0.692
#> GSM28732     1  0.0000      0.951 1.000 0.000
#> GSM11255     1  0.0000      0.951 1.000 0.000
#> GSM28731     1  0.0000      0.951 1.000 0.000
#> GSM28727     1  0.0000      0.951 1.000 0.000
#> GSM11251     1  0.0000      0.951 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
#> GSM28735     1   0.280      0.894 0.908 0.000 0.092
#> GSM28736     1   0.611      0.391 0.604 0.000 0.396
#> GSM28737     1   0.000      0.933 1.000 0.000 0.000
#> GSM11249     3   0.129      0.936 0.032 0.000 0.968
#> GSM28745     2   0.000      0.884 0.000 1.000 0.000
#> GSM11244     2   0.000      0.884 0.000 1.000 0.000
#> GSM28748     2   0.630      0.133 0.000 0.524 0.476
#> GSM11266     2   0.000      0.884 0.000 1.000 0.000
#> GSM28730     2   0.000      0.884 0.000 1.000 0.000
#> GSM11253     2   0.000      0.884 0.000 1.000 0.000
#> GSM11254     2   0.000      0.884 0.000 1.000 0.000
#> GSM11260     2   0.000      0.884 0.000 1.000 0.000
#> GSM28733     2   0.000      0.884 0.000 1.000 0.000
#> GSM11265     1   0.000      0.933 1.000 0.000 0.000
#> GSM28739     1   0.000      0.933 1.000 0.000 0.000
#> GSM11243     3   0.000      0.929 0.000 0.000 1.000
#> GSM28740     1   0.000      0.933 1.000 0.000 0.000
#> GSM11259     1   0.000      0.933 1.000 0.000 0.000
#> GSM28726     1   0.382      0.847 0.852 0.000 0.148
#> GSM28743     1   0.000      0.933 1.000 0.000 0.000
#> GSM11256     3   0.129      0.936 0.032 0.000 0.968
#> GSM11262     1   0.000      0.933 1.000 0.000 0.000
#> GSM28724     1   0.280      0.894 0.908 0.000 0.092
#> GSM28725     3   0.000      0.929 0.000 0.000 1.000
#> GSM11263     3   0.000      0.929 0.000 0.000 1.000
#> GSM11267     3   0.000      0.929 0.000 0.000 1.000
#> GSM28744     3   0.129      0.936 0.032 0.000 0.968
#> GSM28734     3   0.129      0.936 0.032 0.000 0.968
#> GSM28747     1   0.000      0.933 1.000 0.000 0.000
#> GSM11257     3   0.455      0.732 0.200 0.000 0.800
#> GSM11252     1   0.129      0.923 0.968 0.000 0.032
#> GSM11264     3   0.000      0.929 0.000 0.000 1.000
#> GSM11247     3   0.000      0.929 0.000 0.000 1.000
#> GSM11258     3   0.153      0.929 0.040 0.000 0.960
#> GSM28728     1   0.271      0.896 0.912 0.000 0.088
#> GSM28746     1   0.186      0.913 0.948 0.000 0.052
#> GSM28738     1   0.581      0.521 0.664 0.000 0.336
#> GSM28741     3   0.810      0.568 0.200 0.152 0.648
#> GSM28729     1   0.271      0.896 0.912 0.000 0.088
#> GSM28742     1   0.280      0.894 0.908 0.000 0.092
#> GSM11250     2   0.630      0.133 0.000 0.524 0.476
#> GSM11245     1   0.153      0.920 0.960 0.000 0.040
#> GSM11246     1   0.000      0.933 1.000 0.000 0.000
#> GSM11261     3   0.129      0.936 0.032 0.000 0.968
#> GSM11248     3   0.129      0.936 0.032 0.000 0.968
#> GSM28732     1   0.000      0.933 1.000 0.000 0.000
#> GSM11255     1   0.141      0.922 0.964 0.000 0.036
#> GSM28731     1   0.000      0.933 1.000 0.000 0.000
#> GSM28727     1   0.000      0.933 1.000 0.000 0.000
#> GSM11251     1   0.000      0.933 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
#> GSM28735     1  0.2081     0.7624 0.916 0.000 0.000 0.084
#> GSM28736     1  0.2216     0.7551 0.908 0.000 0.000 0.092
#> GSM28737     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM11249     3  0.1452     0.8751 0.036 0.000 0.956 0.008
#> GSM28745     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0779     0.9541 0.016 0.980 0.000 0.004
#> GSM11266     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000     0.9742 0.000 1.000 0.000 0.000
#> GSM11265     1  0.3444     0.8096 0.816 0.000 0.000 0.184
#> GSM28739     1  0.3444     0.8096 0.816 0.000 0.000 0.184
#> GSM11243     3  0.0000     0.8973 0.000 0.000 1.000 0.000
#> GSM28740     1  0.3444     0.8096 0.816 0.000 0.000 0.184
#> GSM11259     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM28726     1  0.2216     0.7551 0.908 0.000 0.000 0.092
#> GSM28743     1  0.3444     0.8096 0.816 0.000 0.000 0.184
#> GSM11256     4  0.3444     0.8831 0.184 0.000 0.000 0.816
#> GSM11262     1  0.3356     0.8138 0.824 0.000 0.000 0.176
#> GSM28724     1  0.1940     0.7672 0.924 0.000 0.000 0.076
#> GSM28725     3  0.0000     0.8973 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000     0.8973 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000     0.8973 0.000 0.000 1.000 0.000
#> GSM28744     4  0.3444     0.8831 0.184 0.000 0.000 0.816
#> GSM28734     4  0.3444     0.8831 0.184 0.000 0.000 0.816
#> GSM28747     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM11257     1  0.4072     0.4862 0.748 0.000 0.000 0.252
#> GSM11252     1  0.0469     0.7959 0.988 0.000 0.000 0.012
#> GSM11264     3  0.0000     0.8973 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0707     0.8901 0.020 0.000 0.980 0.000
#> GSM11258     4  0.4830     0.6156 0.392 0.000 0.000 0.608
#> GSM28728     1  0.2081     0.7624 0.916 0.000 0.000 0.084
#> GSM28746     1  0.0336     0.7974 0.992 0.000 0.000 0.008
#> GSM28738     1  0.2081     0.7624 0.916 0.000 0.000 0.084
#> GSM28741     1  0.6532     0.0533 0.572 0.336 0.000 0.092
#> GSM28729     1  0.2081     0.7624 0.916 0.000 0.000 0.084
#> GSM28742     1  0.2081     0.7624 0.916 0.000 0.000 0.084
#> GSM11250     2  0.3447     0.7627 0.128 0.852 0.000 0.020
#> GSM11245     1  0.0592     0.7945 0.984 0.000 0.000 0.016
#> GSM11246     1  0.3444     0.8096 0.816 0.000 0.000 0.184
#> GSM11261     3  0.5721     0.0995 0.412 0.008 0.564 0.016
#> GSM11248     3  0.1978     0.8430 0.068 0.000 0.928 0.004
#> GSM28732     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM11255     1  0.0188     0.7981 0.996 0.000 0.000 0.004
#> GSM28731     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM28727     1  0.3266     0.8174 0.832 0.000 0.000 0.168
#> GSM11251     1  0.3266     0.8174 0.832 0.000 0.000 0.168

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.3876      0.798 0.316 0.000 0.000 0.000 0.684
#> GSM28736     5  0.2690      0.837 0.156 0.000 0.000 0.000 0.844
#> GSM28737     1  0.0290      0.761 0.992 0.000 0.000 0.000 0.008
#> GSM11249     3  0.0703      0.970 0.000 0.000 0.976 0.000 0.024
#> GSM28745     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.979 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.2690      0.696 0.844 0.000 0.000 0.000 0.156
#> GSM28739     1  0.2690      0.696 0.844 0.000 0.000 0.000 0.156
#> GSM11243     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.2773      0.693 0.836 0.000 0.000 0.000 0.164
#> GSM11259     1  0.0162      0.762 0.996 0.000 0.000 0.000 0.004
#> GSM28726     5  0.2690      0.837 0.156 0.000 0.000 0.000 0.844
#> GSM28743     1  0.2773      0.693 0.836 0.000 0.000 0.000 0.164
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM11262     1  0.1478      0.726 0.936 0.000 0.000 0.000 0.064
#> GSM28724     1  0.4292      0.460 0.704 0.000 0.024 0.000 0.272
#> GSM28725     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM28747     1  0.0162      0.762 0.996 0.000 0.000 0.000 0.004
#> GSM11257     5  0.3388      0.841 0.200 0.000 0.000 0.008 0.792
#> GSM11252     1  0.3534      0.520 0.744 0.000 0.000 0.000 0.256
#> GSM11264     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM11258     1  0.6263      0.160 0.532 0.000 0.000 0.192 0.276
#> GSM28728     1  0.4734      0.106 0.604 0.000 0.024 0.000 0.372
#> GSM28746     1  0.3480      0.533 0.752 0.000 0.000 0.000 0.248
#> GSM28738     5  0.3876      0.799 0.316 0.000 0.000 0.000 0.684
#> GSM28741     5  0.2690      0.837 0.156 0.000 0.000 0.000 0.844
#> GSM28729     5  0.4235      0.583 0.424 0.000 0.000 0.000 0.576
#> GSM28742     5  0.3949      0.779 0.332 0.000 0.000 0.000 0.668
#> GSM11250     2  0.2471      0.801 0.000 0.864 0.000 0.000 0.136
#> GSM11245     1  0.3534      0.520 0.744 0.000 0.000 0.000 0.256
#> GSM11246     1  0.2690      0.696 0.844 0.000 0.000 0.000 0.156
#> GSM11261     5  0.4617      0.786 0.148 0.000 0.108 0.000 0.744
#> GSM11248     3  0.0703      0.970 0.000 0.000 0.976 0.000 0.024
#> GSM28732     1  0.0162      0.762 0.996 0.000 0.000 0.000 0.004
#> GSM11255     1  0.3480      0.531 0.752 0.000 0.000 0.000 0.248
#> GSM28731     1  0.0000      0.762 1.000 0.000 0.000 0.000 0.000
#> GSM28727     1  0.0162      0.762 0.996 0.000 0.000 0.000 0.004
#> GSM11251     1  0.0000      0.762 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
#> GSM28735     5  0.2743      0.669 0.164 0.000 0.000 0.000 0.828 0.008
#> GSM28736     5  0.0000      0.641 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM28737     1  0.0717      0.893 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM11249     3  0.2527      0.859 0.000 0.000 0.832 0.000 0.000 0.168
#> GSM28745     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0622      0.953 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM11266     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.2491      0.850 0.836 0.000 0.000 0.000 0.000 0.164
#> GSM28739     1  0.2562      0.844 0.828 0.000 0.000 0.000 0.000 0.172
#> GSM11243     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28740     1  0.2593      0.853 0.844 0.000 0.000 0.000 0.008 0.148
#> GSM11259     1  0.0806      0.891 0.972 0.000 0.000 0.000 0.020 0.008
#> GSM28726     5  0.0000      0.641 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM28743     1  0.2706      0.845 0.832 0.000 0.000 0.000 0.008 0.160
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11262     1  0.1918      0.839 0.904 0.000 0.000 0.000 0.088 0.008
#> GSM28724     5  0.5561      0.335 0.308 0.000 0.000 0.000 0.528 0.164
#> GSM28725     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28747     1  0.0692      0.891 0.976 0.000 0.000 0.000 0.020 0.004
#> GSM11257     5  0.3714      0.628 0.052 0.000 0.000 0.024 0.808 0.116
#> GSM11252     6  0.4915      0.889 0.188 0.000 0.000 0.000 0.156 0.656
#> GSM11264     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000      0.957 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11258     5  0.7074      0.128 0.108 0.000 0.000 0.188 0.440 0.264
#> GSM28728     5  0.5670      0.359 0.296 0.000 0.000 0.000 0.516 0.188
#> GSM28746     6  0.4915      0.889 0.188 0.000 0.000 0.000 0.156 0.656
#> GSM28738     5  0.2743      0.670 0.164 0.000 0.000 0.000 0.828 0.008
#> GSM28741     5  0.0713      0.631 0.000 0.000 0.000 0.000 0.972 0.028
#> GSM28729     5  0.4585      0.545 0.284 0.000 0.000 0.000 0.648 0.068
#> GSM28742     5  0.2664      0.658 0.184 0.000 0.000 0.000 0.816 0.000
#> GSM11250     2  0.3543      0.683 0.000 0.768 0.000 0.000 0.200 0.032
#> GSM11245     6  0.4910      0.888 0.192 0.000 0.000 0.000 0.152 0.656
#> GSM11246     1  0.2416      0.850 0.844 0.000 0.000 0.000 0.000 0.156
#> GSM11261     5  0.5485      0.337 0.020 0.000 0.076 0.000 0.516 0.388
#> GSM11248     3  0.2454      0.865 0.000 0.000 0.840 0.000 0.000 0.160
#> GSM28732     1  0.0937      0.873 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM11255     6  0.5027      0.705 0.304 0.000 0.000 0.000 0.100 0.596
#> GSM28731     1  0.0603      0.892 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM28727     1  0.0717      0.892 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM11251     1  0.0717      0.892 0.976 0.000 0.000 0.000 0.016 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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 tissue(p) k
#> CV:mclust 50     0.394 2
#> CV:mclust 47     0.437 3
#> CV:mclust 47     0.504 4
#> CV:mclust 47     0.512 5
#> CV:mclust 46     0.477 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 21342 rows and 50 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 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 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 1.000           0.990       0.995         0.3933 0.607   0.607
#> 3 3 0.968           0.948       0.979         0.5141 0.718   0.566
#> 4 4 0.923           0.920       0.954         0.2296 0.838   0.616
#> 5 5 0.767           0.650       0.840         0.0614 0.904   0.664
#> 6 6 0.742           0.618       0.784         0.0592 0.892   0.554

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

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following 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
#> GSM28735     1  0.0000      0.996 1.000 0.000
#> GSM28736     2  0.2043      0.965 0.032 0.968
#> GSM28737     1  0.0000      0.996 1.000 0.000
#> GSM11249     1  0.0000      0.996 1.000 0.000
#> GSM28745     2  0.0000      0.991 0.000 1.000
#> GSM11244     2  0.0000      0.991 0.000 1.000
#> GSM28748     2  0.0000      0.991 0.000 1.000
#> GSM11266     2  0.0000      0.991 0.000 1.000
#> GSM28730     2  0.0000      0.991 0.000 1.000
#> GSM11253     2  0.0000      0.991 0.000 1.000
#> GSM11254     2  0.0000      0.991 0.000 1.000
#> GSM11260     2  0.0000      0.991 0.000 1.000
#> GSM28733     2  0.0000      0.991 0.000 1.000
#> GSM11265     1  0.0000      0.996 1.000 0.000
#> GSM28739     1  0.0000      0.996 1.000 0.000
#> GSM11243     1  0.0000      0.996 1.000 0.000
#> GSM28740     1  0.0000      0.996 1.000 0.000
#> GSM11259     1  0.0000      0.996 1.000 0.000
#> GSM28726     2  0.4022      0.916 0.080 0.920
#> GSM28743     1  0.0000      0.996 1.000 0.000
#> GSM11256     1  0.0000      0.996 1.000 0.000
#> GSM11262     1  0.0000      0.996 1.000 0.000
#> GSM28724     1  0.0000      0.996 1.000 0.000
#> GSM28725     1  0.0000      0.996 1.000 0.000
#> GSM11263     1  0.0000      0.996 1.000 0.000
#> GSM11267     1  0.0000      0.996 1.000 0.000
#> GSM28744     1  0.0000      0.996 1.000 0.000
#> GSM28734     1  0.0000      0.996 1.000 0.000
#> GSM28747     1  0.0000      0.996 1.000 0.000
#> GSM11257     1  0.0000      0.996 1.000 0.000
#> GSM11252     1  0.0000      0.996 1.000 0.000
#> GSM11264     1  0.0000      0.996 1.000 0.000
#> GSM11247     1  0.0000      0.996 1.000 0.000
#> GSM11258     1  0.0000      0.996 1.000 0.000
#> GSM28728     1  0.0000      0.996 1.000 0.000
#> GSM28746     1  0.0000      0.996 1.000 0.000
#> GSM28738     1  0.4431      0.899 0.908 0.092
#> GSM28741     2  0.0000      0.991 0.000 1.000
#> GSM28729     1  0.0000      0.996 1.000 0.000
#> GSM28742     1  0.1633      0.974 0.976 0.024
#> GSM11250     2  0.0000      0.991 0.000 1.000
#> GSM11245     1  0.0000      0.996 1.000 0.000
#> GSM11246     1  0.0000      0.996 1.000 0.000
#> GSM11261     1  0.0938      0.986 0.988 0.012
#> GSM11248     1  0.0000      0.996 1.000 0.000
#> GSM28732     1  0.0000      0.996 1.000 0.000
#> GSM11255     1  0.0000      0.996 1.000 0.000
#> GSM28731     1  0.0000      0.996 1.000 0.000
#> GSM28727     1  0.0000      0.996 1.000 0.000
#> GSM11251     1  0.0000      0.996 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
#> GSM28735     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28736     1  0.5882      0.478 0.652 0.348 0.000
#> GSM28737     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11249     3  0.0000      0.971 0.000 0.000 1.000
#> GSM28745     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11244     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28748     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11266     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28730     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11253     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11254     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11260     2  0.0000      0.998 0.000 1.000 0.000
#> GSM28733     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11243     3  0.0000      0.971 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28726     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28743     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11256     1  0.5859      0.476 0.656 0.000 0.344
#> GSM11262     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28725     3  0.0000      0.971 0.000 0.000 1.000
#> GSM11263     3  0.0000      0.971 0.000 0.000 1.000
#> GSM11267     3  0.0000      0.971 0.000 0.000 1.000
#> GSM28744     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28734     3  0.4399      0.732 0.188 0.000 0.812
#> GSM28747     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11257     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11252     1  0.0237      0.967 0.996 0.000 0.004
#> GSM11264     3  0.0000      0.971 0.000 0.000 1.000
#> GSM11247     3  0.0000      0.971 0.000 0.000 1.000
#> GSM11258     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28728     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28746     1  0.0747      0.957 0.984 0.000 0.016
#> GSM28738     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28741     2  0.0747      0.978 0.016 0.984 0.000
#> GSM28729     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11250     2  0.0000      0.998 0.000 1.000 0.000
#> GSM11245     1  0.3267      0.855 0.884 0.000 0.116
#> GSM11246     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11261     3  0.0237      0.968 0.000 0.004 0.996
#> GSM11248     3  0.0000      0.971 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11255     1  0.0237      0.967 0.996 0.000 0.004
#> GSM28731     1  0.0000      0.969 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.969 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.969 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
#> GSM28735     4  0.4843      0.422 0.396 0.000 0.000 0.604
#> GSM28736     4  0.2775      0.840 0.020 0.084 0.000 0.896
#> GSM28737     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM11249     3  0.0188      0.993 0.000 0.000 0.996 0.004
#> GSM28745     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0188      0.997 0.000 0.996 0.000 0.004
#> GSM11266     2  0.0188      0.997 0.000 0.996 0.000 0.004
#> GSM28730     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11265     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM28739     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM11243     3  0.0524      0.989 0.004 0.000 0.988 0.008
#> GSM28740     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM11259     1  0.1389      0.926 0.952 0.000 0.000 0.048
#> GSM28726     4  0.2300      0.874 0.064 0.016 0.000 0.920
#> GSM28743     1  0.0592      0.939 0.984 0.000 0.000 0.016
#> GSM11256     4  0.1004      0.876 0.024 0.000 0.004 0.972
#> GSM11262     1  0.0592      0.939 0.984 0.000 0.000 0.016
#> GSM28724     1  0.0817      0.941 0.976 0.000 0.000 0.024
#> GSM28725     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM28744     4  0.1302      0.876 0.044 0.000 0.000 0.956
#> GSM28734     4  0.1767      0.858 0.012 0.000 0.044 0.944
#> GSM28747     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM11257     4  0.0817      0.876 0.024 0.000 0.000 0.976
#> GSM11252     1  0.2300      0.910 0.924 0.000 0.028 0.048
#> GSM11264     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0895      0.981 0.004 0.000 0.976 0.020
#> GSM11258     1  0.4608      0.559 0.692 0.000 0.004 0.304
#> GSM28728     1  0.1389      0.925 0.952 0.000 0.000 0.048
#> GSM28746     1  0.3863      0.812 0.828 0.000 0.028 0.144
#> GSM28738     4  0.3142      0.838 0.132 0.008 0.000 0.860
#> GSM28741     2  0.0376      0.993 0.004 0.992 0.000 0.004
#> GSM28729     4  0.3975      0.738 0.240 0.000 0.000 0.760
#> GSM28742     4  0.0707      0.874 0.020 0.000 0.000 0.980
#> GSM11250     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM11245     1  0.4678      0.690 0.744 0.000 0.232 0.024
#> GSM11246     1  0.0188      0.942 0.996 0.000 0.000 0.004
#> GSM11261     3  0.0188      0.993 0.004 0.000 0.996 0.000
#> GSM11248     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM28732     1  0.0707      0.940 0.980 0.000 0.000 0.020
#> GSM11255     1  0.0779      0.940 0.980 0.000 0.016 0.004
#> GSM28731     1  0.0707      0.940 0.980 0.000 0.000 0.020
#> GSM28727     1  0.0336      0.942 0.992 0.000 0.000 0.008
#> GSM11251     1  0.0336      0.942 0.992 0.000 0.000 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
#> GSM28735     5  0.5223    -0.0985 0.444 0.000 0.000 0.044 0.512
#> GSM28736     5  0.6021    -0.0706 0.004 0.124 0.000 0.312 0.560
#> GSM28737     1  0.1478     0.6705 0.936 0.000 0.000 0.000 0.064
#> GSM11249     3  0.0798     0.8937 0.008 0.000 0.976 0.016 0.000
#> GSM28745     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0162     0.6618 0.996 0.000 0.000 0.004 0.000
#> GSM28739     1  0.0000     0.6632 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.1628     0.8732 0.000 0.000 0.936 0.008 0.056
#> GSM28740     1  0.0290     0.6604 0.992 0.000 0.000 0.008 0.000
#> GSM11259     5  0.4268    -0.0988 0.444 0.000 0.000 0.000 0.556
#> GSM28726     5  0.3779     0.5893 0.124 0.004 0.000 0.056 0.816
#> GSM28743     1  0.0609     0.6532 0.980 0.000 0.000 0.020 0.000
#> GSM11256     4  0.1430     0.7365 0.004 0.000 0.000 0.944 0.052
#> GSM11262     1  0.0963     0.6407 0.964 0.000 0.000 0.036 0.000
#> GSM28724     1  0.4597     0.3702 0.564 0.000 0.000 0.012 0.424
#> GSM28725     3  0.0162     0.9018 0.000 0.000 0.996 0.004 0.000
#> GSM11263     3  0.0000     0.9021 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0162     0.9017 0.000 0.000 0.996 0.004 0.000
#> GSM28744     4  0.0865     0.7446 0.004 0.000 0.000 0.972 0.024
#> GSM28734     4  0.1725     0.7379 0.044 0.000 0.000 0.936 0.020
#> GSM28747     1  0.4015     0.5096 0.652 0.000 0.000 0.000 0.348
#> GSM11257     4  0.4294     0.2701 0.000 0.000 0.000 0.532 0.468
#> GSM11252     1  0.4920     0.5792 0.756 0.000 0.036 0.072 0.136
#> GSM11264     3  0.0000     0.9021 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.2563     0.8188 0.000 0.000 0.872 0.008 0.120
#> GSM11258     4  0.4161     0.4370 0.392 0.000 0.000 0.608 0.000
#> GSM28728     5  0.4449     0.2129 0.352 0.000 0.004 0.008 0.636
#> GSM28746     1  0.4874     0.4279 0.588 0.000 0.016 0.008 0.388
#> GSM28738     5  0.1282     0.5439 0.000 0.000 0.004 0.044 0.952
#> GSM28741     2  0.2338     0.8362 0.000 0.884 0.000 0.004 0.112
#> GSM28729     5  0.2362     0.6103 0.076 0.000 0.000 0.024 0.900
#> GSM28742     5  0.1041     0.5603 0.004 0.000 0.000 0.032 0.964
#> GSM11250     2  0.0000     0.9848 0.000 1.000 0.000 0.000 0.000
#> GSM11245     3  0.6169     0.1616 0.444 0.000 0.464 0.064 0.028
#> GSM11246     1  0.1478     0.6705 0.936 0.000 0.000 0.000 0.064
#> GSM11261     3  0.0693     0.8975 0.000 0.000 0.980 0.008 0.012
#> GSM11248     3  0.0404     0.8995 0.000 0.000 0.988 0.012 0.000
#> GSM28732     1  0.4307     0.1672 0.500 0.000 0.000 0.000 0.500
#> GSM11255     1  0.3670     0.6272 0.792 0.000 0.008 0.012 0.188
#> GSM28731     1  0.4304     0.2136 0.516 0.000 0.000 0.000 0.484
#> GSM28727     1  0.4210     0.4088 0.588 0.000 0.000 0.000 0.412
#> GSM11251     1  0.3796     0.5422 0.700 0.000 0.000 0.000 0.300

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     6  0.4853     0.5113 0.156 0.000 0.000 0.020 0.120 0.704
#> GSM28736     6  0.7106     0.0599 0.008 0.068 0.000 0.232 0.260 0.432
#> GSM28737     1  0.1196     0.7390 0.952 0.000 0.000 0.000 0.008 0.040
#> GSM11249     3  0.2982     0.7740 0.012 0.000 0.828 0.000 0.008 0.152
#> GSM28745     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0146     0.7520 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM28739     1  0.0891     0.7367 0.968 0.000 0.008 0.000 0.000 0.024
#> GSM11243     3  0.3336     0.7946 0.016 0.000 0.808 0.000 0.016 0.160
#> GSM28740     1  0.0000     0.7524 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     6  0.5760     0.4226 0.224 0.000 0.000 0.000 0.268 0.508
#> GSM28726     5  0.5741     0.2799 0.160 0.000 0.000 0.028 0.600 0.212
#> GSM28743     1  0.0972     0.7479 0.964 0.000 0.000 0.008 0.000 0.028
#> GSM11256     4  0.0458     0.8423 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM11262     1  0.0820     0.7436 0.972 0.000 0.000 0.016 0.000 0.012
#> GSM28724     6  0.5073     0.4843 0.220 0.000 0.016 0.000 0.104 0.660
#> GSM28725     3  0.0603     0.8464 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM11263     3  0.0000     0.8469 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0363     0.8454 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM28744     4  0.0146     0.8512 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM28734     4  0.0547     0.8512 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM28747     6  0.4847     0.4331 0.340 0.000 0.000 0.000 0.072 0.588
#> GSM11257     5  0.4265     0.1001 0.004 0.000 0.000 0.384 0.596 0.016
#> GSM11252     6  0.5817     0.1603 0.300 0.000 0.080 0.004 0.044 0.572
#> GSM11264     3  0.1719     0.8375 0.000 0.000 0.924 0.000 0.060 0.016
#> GSM11247     3  0.4278     0.7329 0.020 0.000 0.716 0.000 0.032 0.232
#> GSM11258     4  0.3446     0.5811 0.308 0.000 0.000 0.692 0.000 0.000
#> GSM28728     6  0.6077     0.2233 0.248 0.000 0.004 0.000 0.300 0.448
#> GSM28746     1  0.6193    -0.1301 0.472 0.000 0.004 0.008 0.224 0.292
#> GSM28738     5  0.0665     0.5685 0.008 0.000 0.000 0.004 0.980 0.008
#> GSM28741     2  0.4211     0.3513 0.004 0.616 0.000 0.000 0.016 0.364
#> GSM28729     5  0.3013     0.5685 0.068 0.000 0.000 0.000 0.844 0.088
#> GSM28742     5  0.2482     0.5459 0.000 0.000 0.000 0.004 0.848 0.148
#> GSM11250     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.6502     0.1704 0.208 0.000 0.256 0.004 0.036 0.496
#> GSM11246     1  0.1049     0.7416 0.960 0.000 0.000 0.000 0.008 0.032
#> GSM11261     3  0.3803     0.7137 0.020 0.000 0.724 0.000 0.004 0.252
#> GSM11248     3  0.3963     0.7257 0.008 0.000 0.756 0.000 0.048 0.188
#> GSM28732     6  0.5276     0.4934 0.208 0.000 0.000 0.000 0.188 0.604
#> GSM11255     1  0.6586     0.0285 0.420 0.000 0.056 0.000 0.152 0.372
#> GSM28731     5  0.5759    -0.0132 0.392 0.000 0.000 0.000 0.436 0.172
#> GSM28727     6  0.5276     0.5030 0.312 0.000 0.000 0.000 0.124 0.564
#> GSM11251     1  0.4843     0.1244 0.616 0.000 0.000 0.000 0.084 0.300

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 tissue(p) k
#> CV:NMF 50     0.394 2
#> CV:NMF 48     0.423 3
#> CV:NMF 49     0.436 4
#> CV:NMF 38     0.486 5
#> CV:NMF 35     0.418 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 21342 rows and 50 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 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-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 1.000           0.970       0.987         0.3439 0.650   0.650
#> 3 3 0.835           0.864       0.944         0.5830 0.838   0.751
#> 4 4 0.771           0.826       0.909         0.2694 0.800   0.594
#> 5 5 0.808           0.885       0.910         0.0567 0.975   0.916
#> 6 6 0.785           0.809       0.873         0.0485 0.996   0.985

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
#> GSM28735     1   0.163      0.972 0.976 0.024
#> GSM28736     1   0.163      0.972 0.976 0.024
#> GSM28737     1   0.000      0.994 1.000 0.000
#> GSM11249     1   0.000      0.994 1.000 0.000
#> GSM28745     2   0.000      0.953 0.000 1.000
#> GSM11244     2   0.000      0.953 0.000 1.000
#> GSM28748     2   0.000      0.953 0.000 1.000
#> GSM11266     2   0.000      0.953 0.000 1.000
#> GSM28730     2   0.000      0.953 0.000 1.000
#> GSM11253     2   0.000      0.953 0.000 1.000
#> GSM11254     2   0.000      0.953 0.000 1.000
#> GSM11260     2   0.000      0.953 0.000 1.000
#> GSM28733     2   0.000      0.953 0.000 1.000
#> GSM11265     1   0.000      0.994 1.000 0.000
#> GSM28739     1   0.000      0.994 1.000 0.000
#> GSM11243     1   0.000      0.994 1.000 0.000
#> GSM28740     1   0.000      0.994 1.000 0.000
#> GSM11259     1   0.000      0.994 1.000 0.000
#> GSM28726     1   0.000      0.994 1.000 0.000
#> GSM28743     1   0.000      0.994 1.000 0.000
#> GSM11256     1   0.000      0.994 1.000 0.000
#> GSM11262     1   0.000      0.994 1.000 0.000
#> GSM28724     1   0.000      0.994 1.000 0.000
#> GSM28725     1   0.000      0.994 1.000 0.000
#> GSM11263     1   0.000      0.994 1.000 0.000
#> GSM11267     1   0.000      0.994 1.000 0.000
#> GSM28744     1   0.000      0.994 1.000 0.000
#> GSM28734     1   0.000      0.994 1.000 0.000
#> GSM28747     1   0.000      0.994 1.000 0.000
#> GSM11257     1   0.000      0.994 1.000 0.000
#> GSM11252     1   0.000      0.994 1.000 0.000
#> GSM11264     1   0.000      0.994 1.000 0.000
#> GSM11247     1   0.000      0.994 1.000 0.000
#> GSM11258     1   0.000      0.994 1.000 0.000
#> GSM28728     1   0.000      0.994 1.000 0.000
#> GSM28746     1   0.000      0.994 1.000 0.000
#> GSM28738     1   0.000      0.994 1.000 0.000
#> GSM28741     2   0.913      0.528 0.328 0.672
#> GSM28729     1   0.000      0.994 1.000 0.000
#> GSM28742     1   0.000      0.994 1.000 0.000
#> GSM11250     2   0.574      0.833 0.136 0.864
#> GSM11245     1   0.000      0.994 1.000 0.000
#> GSM11246     1   0.000      0.994 1.000 0.000
#> GSM11261     1   0.615      0.812 0.848 0.152
#> GSM11248     1   0.000      0.994 1.000 0.000
#> GSM28732     1   0.000      0.994 1.000 0.000
#> GSM11255     1   0.000      0.994 1.000 0.000
#> GSM28731     1   0.000      0.994 1.000 0.000
#> GSM28727     1   0.000      0.994 1.000 0.000
#> GSM11251     1   0.000      0.994 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
#> GSM28735     1   0.103      0.904 0.976 0.024 0.000
#> GSM28736     1   0.103      0.904 0.976 0.024 0.000
#> GSM28737     1   0.000      0.923 1.000 0.000 0.000
#> GSM11249     1   0.608      0.458 0.612 0.000 0.388
#> GSM28745     2   0.000      0.928 0.000 1.000 0.000
#> GSM11244     2   0.000      0.928 0.000 1.000 0.000
#> GSM28748     2   0.000      0.928 0.000 1.000 0.000
#> GSM11266     2   0.000      0.928 0.000 1.000 0.000
#> GSM28730     2   0.000      0.928 0.000 1.000 0.000
#> GSM11253     2   0.000      0.928 0.000 1.000 0.000
#> GSM11254     2   0.000      0.928 0.000 1.000 0.000
#> GSM11260     2   0.000      0.928 0.000 1.000 0.000
#> GSM28733     2   0.000      0.928 0.000 1.000 0.000
#> GSM11265     1   0.000      0.923 1.000 0.000 0.000
#> GSM28739     1   0.000      0.923 1.000 0.000 0.000
#> GSM11243     3   0.000      1.000 0.000 0.000 1.000
#> GSM28740     1   0.000      0.923 1.000 0.000 0.000
#> GSM11259     1   0.000      0.923 1.000 0.000 0.000
#> GSM28726     1   0.000      0.923 1.000 0.000 0.000
#> GSM28743     1   0.000      0.923 1.000 0.000 0.000
#> GSM11256     1   0.000      0.923 1.000 0.000 0.000
#> GSM11262     1   0.000      0.923 1.000 0.000 0.000
#> GSM28724     1   0.000      0.923 1.000 0.000 0.000
#> GSM28725     3   0.000      1.000 0.000 0.000 1.000
#> GSM11263     3   0.000      1.000 0.000 0.000 1.000
#> GSM11267     3   0.000      1.000 0.000 0.000 1.000
#> GSM28744     1   0.000      0.923 1.000 0.000 0.000
#> GSM28734     1   0.000      0.923 1.000 0.000 0.000
#> GSM28747     1   0.000      0.923 1.000 0.000 0.000
#> GSM11257     1   0.000      0.923 1.000 0.000 0.000
#> GSM11252     1   0.586      0.540 0.656 0.000 0.344
#> GSM11264     3   0.000      1.000 0.000 0.000 1.000
#> GSM11247     3   0.000      1.000 0.000 0.000 1.000
#> GSM11258     1   0.000      0.923 1.000 0.000 0.000
#> GSM28728     1   0.000      0.923 1.000 0.000 0.000
#> GSM28746     1   0.000      0.923 1.000 0.000 0.000
#> GSM28738     1   0.000      0.923 1.000 0.000 0.000
#> GSM28741     2   0.576      0.475 0.328 0.672 0.000
#> GSM28729     1   0.000      0.923 1.000 0.000 0.000
#> GSM28742     1   0.000      0.923 1.000 0.000 0.000
#> GSM11250     2   0.362      0.766 0.136 0.864 0.000
#> GSM11245     1   0.586      0.540 0.656 0.000 0.344
#> GSM11246     1   0.000      0.923 1.000 0.000 0.000
#> GSM11261     1   0.919      0.149 0.468 0.152 0.380
#> GSM11248     1   0.608      0.458 0.612 0.000 0.388
#> GSM28732     1   0.000      0.923 1.000 0.000 0.000
#> GSM11255     1   0.559      0.602 0.696 0.000 0.304
#> GSM28731     1   0.000      0.923 1.000 0.000 0.000
#> GSM28727     1   0.000      0.923 1.000 0.000 0.000
#> GSM11251     1   0.000      0.923 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
#> GSM28735     1  0.1406      0.923 0.960 0.024 0.000 0.016
#> GSM28736     1  0.1406      0.923 0.960 0.024 0.000 0.016
#> GSM28737     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM11249     4  0.4817      0.562 0.000 0.000 0.388 0.612
#> GSM28745     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM11265     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM28739     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM11243     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM28740     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM11259     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> GSM28726     1  0.0592      0.936 0.984 0.000 0.000 0.016
#> GSM28743     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM11256     4  0.1302      0.658 0.044 0.000 0.000 0.956
#> GSM11262     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM28724     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> GSM28725     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM28744     4  0.1302      0.658 0.044 0.000 0.000 0.956
#> GSM28734     4  0.0592      0.658 0.016 0.000 0.000 0.984
#> GSM28747     1  0.1118      0.937 0.964 0.000 0.000 0.036
#> GSM11257     1  0.0336      0.939 0.992 0.000 0.000 0.008
#> GSM11252     4  0.5807      0.606 0.044 0.000 0.344 0.612
#> GSM11264     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000      0.870 0.000 0.000 1.000 0.000
#> GSM11258     4  0.2281      0.633 0.096 0.000 0.000 0.904
#> GSM28728     1  0.0592      0.936 0.984 0.000 0.000 0.016
#> GSM28746     1  0.3356      0.842 0.824 0.000 0.000 0.176
#> GSM28738     1  0.0336      0.939 0.992 0.000 0.000 0.008
#> GSM28741     2  0.5026      0.535 0.312 0.672 0.000 0.016
#> GSM28729     1  0.1118      0.940 0.964 0.000 0.000 0.036
#> GSM28742     1  0.0592      0.936 0.984 0.000 0.000 0.016
#> GSM11250     2  0.3224      0.795 0.120 0.864 0.000 0.016
#> GSM11245     4  0.5807      0.606 0.044 0.000 0.344 0.612
#> GSM11246     1  0.2469      0.911 0.892 0.000 0.000 0.108
#> GSM11261     3  0.8994     -0.373 0.096 0.152 0.380 0.372
#> GSM11248     4  0.4817      0.562 0.000 0.000 0.388 0.612
#> GSM28732     1  0.0336      0.941 0.992 0.000 0.000 0.008
#> GSM11255     4  0.7359      0.477 0.188 0.000 0.304 0.508
#> GSM28731     1  0.1389      0.934 0.952 0.000 0.000 0.048
#> GSM28727     1  0.0000      0.940 1.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.940 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     1  0.2674      0.838 0.868 0.000 0.000 0.120 0.012
#> GSM28736     1  0.2674      0.838 0.868 0.000 0.000 0.120 0.012
#> GSM28737     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM11249     5  0.1043      0.815 0.000 0.000 0.040 0.000 0.960
#> GSM28745     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.943 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM28739     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM11259     1  0.0290      0.907 0.992 0.000 0.000 0.008 0.000
#> GSM28726     1  0.1774      0.893 0.932 0.000 0.000 0.052 0.016
#> GSM28743     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM11256     4  0.3093      0.899 0.008 0.000 0.000 0.824 0.168
#> GSM11262     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM28724     1  0.0963      0.902 0.964 0.000 0.000 0.036 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.3093      0.899 0.008 0.000 0.000 0.824 0.168
#> GSM28734     4  0.3231      0.888 0.004 0.000 0.000 0.800 0.196
#> GSM28747     1  0.1493      0.909 0.948 0.000 0.000 0.024 0.028
#> GSM11257     1  0.1469      0.909 0.948 0.000 0.000 0.036 0.016
#> GSM11252     5  0.1997      0.832 0.040 0.000 0.036 0.000 0.924
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM11258     4  0.4763      0.736 0.076 0.000 0.000 0.712 0.212
#> GSM28728     1  0.1809      0.886 0.928 0.000 0.000 0.060 0.012
#> GSM28746     1  0.3861      0.845 0.804 0.000 0.000 0.068 0.128
#> GSM28738     1  0.1469      0.909 0.948 0.000 0.000 0.036 0.016
#> GSM28741     2  0.5727      0.543 0.220 0.648 0.000 0.120 0.012
#> GSM28729     1  0.2645      0.903 0.888 0.000 0.000 0.068 0.044
#> GSM28742     1  0.1774      0.893 0.932 0.000 0.000 0.052 0.016
#> GSM11250     2  0.3556      0.806 0.044 0.840 0.000 0.104 0.012
#> GSM11245     5  0.1997      0.832 0.040 0.000 0.036 0.000 0.924
#> GSM11246     1  0.3255      0.881 0.848 0.000 0.000 0.052 0.100
#> GSM11261     5  0.6150      0.618 0.040 0.128 0.040 0.092 0.700
#> GSM11248     5  0.1043      0.815 0.000 0.000 0.040 0.000 0.960
#> GSM28732     1  0.0912      0.910 0.972 0.000 0.000 0.016 0.012
#> GSM11255     5  0.4036      0.651 0.132 0.000 0.012 0.052 0.804
#> GSM28731     1  0.2520      0.901 0.896 0.000 0.000 0.056 0.048
#> GSM28727     1  0.0404      0.906 0.988 0.000 0.000 0.012 0.000
#> GSM11251     1  0.0404      0.906 0.988 0.000 0.000 0.012 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
#> GSM28735     1  0.3101      0.674 0.756 0.000 0.000 0.000 0.244 0.000
#> GSM28736     1  0.3101      0.674 0.756 0.000 0.000 0.000 0.244 0.000
#> GSM28737     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM11249     6  0.0291      0.764 0.000 0.000 0.004 0.004 0.000 0.992
#> GSM28745     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.939 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM28739     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28740     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM11259     1  0.0146      0.813 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM28726     1  0.2668      0.754 0.828 0.000 0.000 0.000 0.168 0.004
#> GSM28743     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM11256     4  0.0260      0.893 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM11262     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM28724     1  0.1556      0.809 0.920 0.000 0.000 0.000 0.080 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0260      0.893 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM28734     4  0.1257      0.886 0.000 0.000 0.000 0.952 0.020 0.028
#> GSM28747     1  0.1714      0.817 0.908 0.000 0.000 0.000 0.092 0.000
#> GSM11257     1  0.3230      0.771 0.776 0.000 0.000 0.012 0.212 0.000
#> GSM11252     6  0.1226      0.793 0.040 0.000 0.000 0.004 0.004 0.952
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11258     4  0.3572      0.730 0.060 0.000 0.000 0.820 0.100 0.020
#> GSM28728     1  0.2416      0.756 0.844 0.000 0.000 0.000 0.156 0.000
#> GSM28746     1  0.4619      0.751 0.712 0.000 0.000 0.056 0.204 0.028
#> GSM28738     1  0.3230      0.771 0.776 0.000 0.000 0.012 0.212 0.000
#> GSM28741     2  0.4969      0.473 0.156 0.648 0.000 0.000 0.196 0.000
#> GSM28729     1  0.3398      0.782 0.768 0.000 0.000 0.012 0.216 0.004
#> GSM28742     1  0.2668      0.754 0.828 0.000 0.000 0.000 0.168 0.004
#> GSM11250     2  0.2558      0.782 0.004 0.840 0.000 0.000 0.156 0.000
#> GSM11245     6  0.1226      0.793 0.040 0.000 0.000 0.004 0.004 0.952
#> GSM11246     1  0.3337      0.773 0.736 0.000 0.000 0.000 0.260 0.004
#> GSM11261     5  0.5304      0.000 0.024 0.044 0.004 0.000 0.536 0.392
#> GSM11248     6  0.0291      0.764 0.000 0.000 0.004 0.004 0.000 0.992
#> GSM28732     1  0.1411      0.818 0.936 0.000 0.000 0.004 0.060 0.000
#> GSM11255     6  0.4272      0.433 0.080 0.000 0.000 0.012 0.160 0.748
#> GSM28731     1  0.2982      0.806 0.820 0.000 0.000 0.012 0.164 0.004
#> GSM28727     1  0.0260      0.812 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM11251     1  0.0260      0.812 0.992 0.000 0.000 0.000 0.008 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-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 tissue(p) k
#> MAD:hclust 50     0.394 2
#> MAD:hclust 46     0.364 3
#> MAD:hclust 48     0.437 4
#> MAD:hclust 50     0.473 5
#> MAD:hclust 47     0.463 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 21342 rows and 50 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.393           0.280       0.614         0.3639 0.556   0.556
#> 3 3 1.000           0.986       0.987         0.5228 0.616   0.445
#> 4 4 0.700           0.712       0.808         0.2712 0.804   0.560
#> 5 5 0.754           0.735       0.860         0.0996 0.951   0.814
#> 6 6 0.797           0.644       0.813         0.0522 0.943   0.759

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
#> GSM28735     2   0.980     0.3074 0.416 0.584
#> GSM28736     2   0.980     0.3074 0.416 0.584
#> GSM28737     2   0.980     0.3074 0.416 0.584
#> GSM11249     1   0.760     0.4468 0.780 0.220
#> GSM28745     2   0.760     0.2347 0.220 0.780
#> GSM11244     2   0.760     0.2347 0.220 0.780
#> GSM28748     2   0.760     0.2347 0.220 0.780
#> GSM11266     2   0.760     0.2347 0.220 0.780
#> GSM28730     2   0.760     0.2347 0.220 0.780
#> GSM11253     2   0.760     0.2347 0.220 0.780
#> GSM11254     2   0.760     0.2347 0.220 0.780
#> GSM11260     2   0.760     0.2347 0.220 0.780
#> GSM28733     2   0.760     0.2347 0.220 0.780
#> GSM11265     2   0.980     0.3074 0.416 0.584
#> GSM28739     2   0.980     0.3074 0.416 0.584
#> GSM11243     1   0.000     0.4942 1.000 0.000
#> GSM28740     2   0.980     0.3074 0.416 0.584
#> GSM11259     2   0.980     0.3074 0.416 0.584
#> GSM28726     2   0.980     0.3074 0.416 0.584
#> GSM28743     2   0.980     0.3074 0.416 0.584
#> GSM11256     1   1.000     0.0780 0.504 0.496
#> GSM11262     2   0.980     0.3074 0.416 0.584
#> GSM28724     2   0.980     0.3074 0.416 0.584
#> GSM28725     1   0.000     0.4942 1.000 0.000
#> GSM11263     1   0.000     0.4942 1.000 0.000
#> GSM11267     1   0.000     0.4942 1.000 0.000
#> GSM28744     1   1.000     0.0780 0.504 0.496
#> GSM28734     1   0.996     0.1598 0.536 0.464
#> GSM28747     2   0.980     0.3074 0.416 0.584
#> GSM11257     2   0.980     0.3074 0.416 0.584
#> GSM11252     1   1.000     0.0945 0.508 0.492
#> GSM11264     1   0.000     0.4942 1.000 0.000
#> GSM11247     1   0.000     0.4942 1.000 0.000
#> GSM11258     1   1.000     0.0572 0.500 0.500
#> GSM28728     2   0.980     0.3074 0.416 0.584
#> GSM28746     2   1.000    -0.0733 0.488 0.512
#> GSM28738     2   0.980     0.3074 0.416 0.584
#> GSM28741     2   0.184     0.2095 0.028 0.972
#> GSM28729     2   0.980     0.3074 0.416 0.584
#> GSM28742     2   0.980     0.3074 0.416 0.584
#> GSM11250     2   0.760     0.2347 0.220 0.780
#> GSM11245     1   1.000     0.0945 0.508 0.492
#> GSM11246     2   0.980     0.3074 0.416 0.584
#> GSM11261     1   0.833     0.2249 0.736 0.264
#> GSM11248     1   0.760     0.4468 0.780 0.220
#> GSM28732     2   0.980     0.3074 0.416 0.584
#> GSM11255     1   1.000     0.0945 0.508 0.492
#> GSM28731     2   0.980     0.3074 0.416 0.584
#> GSM28727     2   0.980     0.3074 0.416 0.584
#> GSM11251     2   0.980     0.3074 0.416 0.584

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM28735     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28736     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28737     1  0.0000      0.990 1.000 0.000 0.000
#> GSM11249     3  0.0237      0.990 0.004 0.000 0.996
#> GSM28745     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11244     2  0.0892      1.000 0.020 0.980 0.000
#> GSM28748     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11266     2  0.0892      1.000 0.020 0.980 0.000
#> GSM28730     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11253     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11254     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11260     2  0.0892      1.000 0.020 0.980 0.000
#> GSM28733     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11265     1  0.0237      0.989 0.996 0.000 0.004
#> GSM28739     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11243     3  0.0829      0.989 0.004 0.012 0.984
#> GSM28740     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11259     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28726     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28743     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11256     1  0.1015      0.980 0.980 0.012 0.008
#> GSM11262     1  0.0237      0.989 0.996 0.000 0.004
#> GSM28724     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28725     3  0.0475      0.991 0.004 0.004 0.992
#> GSM11263     3  0.0475      0.991 0.004 0.004 0.992
#> GSM11267     3  0.0475      0.991 0.004 0.004 0.992
#> GSM28744     1  0.1015      0.980 0.980 0.012 0.008
#> GSM28734     1  0.1015      0.980 0.980 0.012 0.008
#> GSM28747     1  0.0000      0.990 1.000 0.000 0.000
#> GSM11257     1  0.0237      0.988 0.996 0.000 0.004
#> GSM11252     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11264     3  0.0475      0.991 0.004 0.004 0.992
#> GSM11247     3  0.0829      0.989 0.004 0.012 0.984
#> GSM11258     1  0.1015      0.980 0.980 0.012 0.008
#> GSM28728     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28746     1  0.0237      0.989 0.996 0.000 0.004
#> GSM28738     1  0.0237      0.988 0.996 0.000 0.004
#> GSM28741     1  0.4399      0.764 0.812 0.188 0.000
#> GSM28729     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.990 1.000 0.000 0.000
#> GSM11250     2  0.0892      1.000 0.020 0.980 0.000
#> GSM11245     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11246     1  0.0237      0.989 0.996 0.000 0.004
#> GSM11261     3  0.1999      0.952 0.036 0.012 0.952
#> GSM11248     3  0.0237      0.990 0.004 0.000 0.996
#> GSM28732     1  0.0000      0.990 1.000 0.000 0.000
#> GSM11255     1  0.0237      0.989 0.996 0.000 0.004
#> GSM28731     1  0.0000      0.990 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.990 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.990 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
#> GSM28735     1  0.0592      0.807 0.984 0.000 0.000 0.016
#> GSM28736     1  0.0592      0.807 0.984 0.000 0.000 0.016
#> GSM28737     4  0.4972      0.504 0.456 0.000 0.000 0.544
#> GSM11249     3  0.2868      0.858 0.000 0.000 0.864 0.136
#> GSM28745     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11244     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28748     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11266     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28730     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11253     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11254     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11260     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM28733     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11265     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM28739     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM11243     3  0.1635      0.901 0.000 0.008 0.948 0.044
#> GSM28740     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM11259     1  0.1867      0.779 0.928 0.000 0.000 0.072
#> GSM28726     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM28743     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM11256     4  0.4998      0.065 0.488 0.000 0.000 0.512
#> GSM11262     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM28724     1  0.1557      0.793 0.944 0.000 0.000 0.056
#> GSM28725     3  0.0188      0.910 0.000 0.004 0.996 0.000
#> GSM11263     3  0.0000      0.910 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.910 0.000 0.000 1.000 0.000
#> GSM28744     4  0.4998      0.065 0.488 0.000 0.000 0.512
#> GSM28734     4  0.4431      0.289 0.304 0.000 0.000 0.696
#> GSM28747     1  0.4250      0.396 0.724 0.000 0.000 0.276
#> GSM11257     1  0.2216      0.710 0.908 0.000 0.000 0.092
#> GSM11252     4  0.4888      0.434 0.412 0.000 0.000 0.588
#> GSM11264     3  0.0000      0.910 0.000 0.000 1.000 0.000
#> GSM11247     3  0.1635      0.901 0.000 0.008 0.948 0.044
#> GSM11258     4  0.1389      0.448 0.048 0.000 0.000 0.952
#> GSM28728     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM28746     4  0.4999      0.384 0.492 0.000 0.000 0.508
#> GSM28738     1  0.0592      0.804 0.984 0.000 0.000 0.016
#> GSM28741     1  0.0707      0.802 0.980 0.020 0.000 0.000
#> GSM28729     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM28742     1  0.0000      0.816 1.000 0.000 0.000 0.000
#> GSM11250     2  0.0336      1.000 0.008 0.992 0.000 0.000
#> GSM11245     4  0.4888      0.434 0.412 0.000 0.000 0.588
#> GSM11246     4  0.4916      0.567 0.424 0.000 0.000 0.576
#> GSM11261     3  0.7041      0.515 0.304 0.004 0.560 0.132
#> GSM11248     3  0.2868      0.858 0.000 0.000 0.864 0.136
#> GSM28732     1  0.1637      0.789 0.940 0.000 0.000 0.060
#> GSM11255     4  0.4406      0.560 0.300 0.000 0.000 0.700
#> GSM28731     1  0.4103      0.454 0.744 0.000 0.000 0.256
#> GSM28727     1  0.4008      0.484 0.756 0.000 0.000 0.244
#> GSM11251     1  0.4134      0.448 0.740 0.000 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
#> GSM28735     5  0.1270      0.776 0.000 0.000 0.000 0.052 0.948
#> GSM28736     5  0.1270      0.776 0.000 0.000 0.000 0.052 0.948
#> GSM28737     1  0.2516      0.785 0.860 0.000 0.000 0.000 0.140
#> GSM11249     3  0.4272      0.714 0.052 0.000 0.752 0.196 0.000
#> GSM28745     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0290      0.993 0.000 0.992 0.000 0.008 0.000
#> GSM11266     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM28739     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM11243     3  0.2304      0.867 0.044 0.000 0.908 0.048 0.000
#> GSM28740     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM11259     5  0.0955      0.778 0.028 0.000 0.000 0.004 0.968
#> GSM28726     5  0.0794      0.783 0.000 0.000 0.000 0.028 0.972
#> GSM28743     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM11256     4  0.2228      0.974 0.040 0.000 0.000 0.912 0.048
#> GSM11262     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM28724     5  0.1124      0.777 0.036 0.000 0.000 0.004 0.960
#> GSM28725     3  0.0000      0.897 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.897 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.897 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.2228      0.974 0.040 0.000 0.000 0.912 0.048
#> GSM28734     4  0.2300      0.947 0.072 0.000 0.000 0.904 0.024
#> GSM28747     5  0.4367      0.207 0.416 0.000 0.000 0.004 0.580
#> GSM11257     5  0.3885      0.631 0.040 0.000 0.000 0.176 0.784
#> GSM11252     1  0.5989      0.364 0.536 0.000 0.000 0.336 0.128
#> GSM11264     3  0.0000      0.897 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.2376      0.865 0.044 0.000 0.904 0.052 0.000
#> GSM11258     1  0.4287     -0.100 0.540 0.000 0.000 0.460 0.000
#> GSM28728     5  0.0404      0.784 0.012 0.000 0.000 0.000 0.988
#> GSM28746     1  0.6492      0.303 0.456 0.000 0.000 0.196 0.348
#> GSM28738     5  0.1661      0.770 0.036 0.000 0.000 0.024 0.940
#> GSM28741     5  0.0794      0.782 0.000 0.000 0.000 0.028 0.972
#> GSM28729     5  0.0693      0.784 0.012 0.000 0.000 0.008 0.980
#> GSM28742     5  0.0865      0.783 0.004 0.000 0.000 0.024 0.972
#> GSM11250     2  0.0290      0.993 0.000 0.992 0.000 0.008 0.000
#> GSM11245     1  0.5989      0.364 0.536 0.000 0.000 0.336 0.128
#> GSM11246     1  0.2377      0.794 0.872 0.000 0.000 0.000 0.128
#> GSM11261     5  0.7443     -0.179 0.084 0.000 0.364 0.124 0.428
#> GSM11248     3  0.4337      0.710 0.056 0.000 0.748 0.196 0.000
#> GSM28732     5  0.0955      0.778 0.028 0.000 0.000 0.004 0.968
#> GSM11255     1  0.3055      0.706 0.864 0.000 0.000 0.072 0.064
#> GSM28731     5  0.4310      0.261 0.392 0.000 0.000 0.004 0.604
#> GSM28727     5  0.4505      0.270 0.384 0.000 0.000 0.012 0.604
#> GSM11251     5  0.4574      0.218 0.412 0.000 0.000 0.012 0.576

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.2074     0.6341 0.004 0.000 0.000 0.048 0.912 0.036
#> GSM28736     5  0.2074     0.6341 0.004 0.000 0.000 0.048 0.912 0.036
#> GSM28737     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11249     3  0.5937     0.3508 0.012 0.000 0.520 0.188 0.000 0.280
#> GSM28745     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0260     0.9956 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM28748     2  0.0146     0.9940 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11266     2  0.0260     0.9956 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM28730     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0260     0.9956 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM11260     2  0.0000     0.9956 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0260     0.9956 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM11265     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM28739     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11243     3  0.2595     0.7334 0.000 0.000 0.836 0.004 0.000 0.160
#> GSM28740     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11259     5  0.3512     0.6735 0.032 0.000 0.000 0.000 0.772 0.196
#> GSM28726     5  0.1464     0.6558 0.004 0.000 0.000 0.016 0.944 0.036
#> GSM28743     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11256     4  0.0790     0.9521 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM11262     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM28724     5  0.4093     0.6442 0.024 0.000 0.000 0.004 0.680 0.292
#> GSM28725     3  0.0000     0.7953 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000     0.7953 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     0.7953 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0790     0.9521 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM28734     4  0.1370     0.9017 0.012 0.000 0.000 0.948 0.004 0.036
#> GSM28747     1  0.5945    -0.3526 0.392 0.000 0.000 0.000 0.392 0.216
#> GSM11257     5  0.5232     0.5010 0.008 0.000 0.000 0.072 0.508 0.412
#> GSM11252     6  0.6612     0.4186 0.304 0.000 0.000 0.252 0.032 0.412
#> GSM11264     3  0.0000     0.7953 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.2772     0.7223 0.000 0.000 0.816 0.004 0.000 0.180
#> GSM11258     1  0.3852     0.1776 0.612 0.000 0.000 0.384 0.000 0.004
#> GSM28728     5  0.3109     0.6711 0.004 0.000 0.000 0.000 0.772 0.224
#> GSM28746     6  0.7030     0.0288 0.304 0.000 0.000 0.072 0.236 0.388
#> GSM28738     5  0.4337     0.5921 0.008 0.000 0.000 0.016 0.604 0.372
#> GSM28741     5  0.0951     0.6569 0.004 0.000 0.000 0.008 0.968 0.020
#> GSM28729     5  0.3628     0.6589 0.004 0.000 0.000 0.008 0.720 0.268
#> GSM28742     5  0.1320     0.6558 0.000 0.000 0.000 0.016 0.948 0.036
#> GSM11250     2  0.0363     0.9940 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM11245     6  0.6612     0.4186 0.304 0.000 0.000 0.252 0.032 0.412
#> GSM11246     1  0.0632     0.7564 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11261     6  0.6616     0.0462 0.008 0.000 0.156 0.048 0.300 0.488
#> GSM11248     3  0.5988     0.3227 0.012 0.000 0.504 0.188 0.000 0.296
#> GSM28732     5  0.3394     0.6637 0.012 0.000 0.000 0.000 0.752 0.236
#> GSM11255     1  0.5031    -0.1837 0.528 0.000 0.000 0.064 0.004 0.404
#> GSM28731     5  0.6006     0.2122 0.316 0.000 0.000 0.000 0.428 0.256
#> GSM28727     5  0.5159     0.2385 0.380 0.000 0.000 0.000 0.528 0.092
#> GSM11251     5  0.5123     0.2009 0.408 0.000 0.000 0.000 0.508 0.084

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 tissue(p) k
#> MAD:kmeans  0        NA 2
#> MAD:kmeans 50     0.370 3
#> MAD:kmeans 39     0.405 4
#> MAD:kmeans 41     0.517 5
#> MAD:kmeans 38     0.509 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 21342 rows and 50 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

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

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.976       0.991         0.4768 0.519   0.519
#> 3 3 0.939           0.949       0.978         0.3534 0.754   0.561
#> 4 4 0.798           0.741       0.898         0.1612 0.797   0.494
#> 5 5 0.824           0.741       0.879         0.0727 0.872   0.550
#> 6 6 0.824           0.639       0.824         0.0387 0.928   0.668

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1   0.000      1.000 1.000 0.000
#> GSM28736     2   0.987      0.239 0.432 0.568
#> GSM28737     1   0.000      1.000 1.000 0.000
#> GSM11249     1   0.000      1.000 1.000 0.000
#> GSM28745     2   0.000      0.976 0.000 1.000
#> GSM11244     2   0.000      0.976 0.000 1.000
#> GSM28748     2   0.000      0.976 0.000 1.000
#> GSM11266     2   0.000      0.976 0.000 1.000
#> GSM28730     2   0.000      0.976 0.000 1.000
#> GSM11253     2   0.000      0.976 0.000 1.000
#> GSM11254     2   0.000      0.976 0.000 1.000
#> GSM11260     2   0.000      0.976 0.000 1.000
#> GSM28733     2   0.000      0.976 0.000 1.000
#> GSM11265     1   0.000      1.000 1.000 0.000
#> GSM28739     1   0.000      1.000 1.000 0.000
#> GSM11243     2   0.000      0.976 0.000 1.000
#> GSM28740     1   0.000      1.000 1.000 0.000
#> GSM11259     1   0.000      1.000 1.000 0.000
#> GSM28726     1   0.000      1.000 1.000 0.000
#> GSM28743     1   0.000      1.000 1.000 0.000
#> GSM11256     1   0.000      1.000 1.000 0.000
#> GSM11262     1   0.000      1.000 1.000 0.000
#> GSM28724     1   0.000      1.000 1.000 0.000
#> GSM28725     2   0.000      0.976 0.000 1.000
#> GSM11263     2   0.000      0.976 0.000 1.000
#> GSM11267     2   0.000      0.976 0.000 1.000
#> GSM28744     1   0.000      1.000 1.000 0.000
#> GSM28734     1   0.000      1.000 1.000 0.000
#> GSM28747     1   0.000      1.000 1.000 0.000
#> GSM11257     1   0.000      1.000 1.000 0.000
#> GSM11252     1   0.000      1.000 1.000 0.000
#> GSM11264     2   0.000      0.976 0.000 1.000
#> GSM11247     2   0.000      0.976 0.000 1.000
#> GSM11258     1   0.000      1.000 1.000 0.000
#> GSM28728     1   0.000      1.000 1.000 0.000
#> GSM28746     1   0.000      1.000 1.000 0.000
#> GSM28738     1   0.000      1.000 1.000 0.000
#> GSM28741     2   0.000      0.976 0.000 1.000
#> GSM28729     1   0.000      1.000 1.000 0.000
#> GSM28742     1   0.000      1.000 1.000 0.000
#> GSM11250     2   0.000      0.976 0.000 1.000
#> GSM11245     1   0.000      1.000 1.000 0.000
#> GSM11246     1   0.000      1.000 1.000 0.000
#> GSM11261     2   0.000      0.976 0.000 1.000
#> GSM11248     1   0.000      1.000 1.000 0.000
#> GSM28732     1   0.000      1.000 1.000 0.000
#> GSM11255     1   0.000      1.000 1.000 0.000
#> GSM28731     1   0.000      1.000 1.000 0.000
#> GSM28727     1   0.000      1.000 1.000 0.000
#> GSM11251     1   0.000      1.000 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
#> GSM28735     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28736     2  0.0424      0.990 0.008 0.992 0.000
#> GSM28737     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11249     3  0.0000      0.943 0.000 0.000 1.000
#> GSM28745     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11244     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28748     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11266     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28730     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11253     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11254     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11260     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28733     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11243     3  0.0000      0.943 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28726     1  0.4399      0.778 0.812 0.188 0.000
#> GSM28743     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11256     3  0.1643      0.920 0.044 0.000 0.956
#> GSM11262     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28725     3  0.0000      0.943 0.000 0.000 1.000
#> GSM11263     3  0.0000      0.943 0.000 0.000 1.000
#> GSM11267     3  0.0000      0.943 0.000 0.000 1.000
#> GSM28744     3  0.1643      0.920 0.044 0.000 0.956
#> GSM28734     3  0.0747      0.936 0.016 0.000 0.984
#> GSM28747     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11257     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11252     3  0.6111      0.389 0.396 0.000 0.604
#> GSM11264     3  0.0000      0.943 0.000 0.000 1.000
#> GSM11247     3  0.0000      0.943 0.000 0.000 1.000
#> GSM11258     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28728     1  0.3038      0.875 0.896 0.000 0.104
#> GSM28746     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28738     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28741     2  0.0000      0.999 0.000 1.000 0.000
#> GSM28729     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28742     1  0.4399      0.778 0.812 0.188 0.000
#> GSM11250     2  0.0000      0.999 0.000 1.000 0.000
#> GSM11245     3  0.3551      0.835 0.132 0.000 0.868
#> GSM11246     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11261     3  0.0000      0.943 0.000 0.000 1.000
#> GSM11248     3  0.0000      0.943 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11255     1  0.0237      0.974 0.996 0.000 0.004
#> GSM28731     1  0.0000      0.978 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.978 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.978 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
#> GSM28735     4  0.0188    0.76383 0.004 0.000 0.000 0.996
#> GSM28736     4  0.1716    0.72884 0.000 0.064 0.000 0.936
#> GSM28737     1  0.0188    0.78501 0.996 0.000 0.000 0.004
#> GSM11249     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM28745     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM28739     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM11243     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM28740     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM11259     4  0.4941   -0.00528 0.436 0.000 0.000 0.564
#> GSM28726     4  0.0336    0.76395 0.008 0.000 0.000 0.992
#> GSM28743     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM11256     4  0.5855    0.35848 0.356 0.000 0.044 0.600
#> GSM11262     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM28724     1  0.4994    0.17789 0.520 0.000 0.000 0.480
#> GSM28725     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM28744     4  0.5943    0.34816 0.360 0.000 0.048 0.592
#> GSM28734     3  0.7240    0.17919 0.400 0.000 0.456 0.144
#> GSM28747     1  0.4661    0.44798 0.652 0.000 0.000 0.348
#> GSM11257     4  0.3801    0.59441 0.220 0.000 0.000 0.780
#> GSM11252     1  0.2737    0.72045 0.888 0.000 0.104 0.008
#> GSM11264     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM11258     1  0.0188    0.78404 0.996 0.000 0.000 0.004
#> GSM28728     4  0.1406    0.75320 0.024 0.000 0.016 0.960
#> GSM28746     1  0.2216    0.73615 0.908 0.000 0.000 0.092
#> GSM28738     4  0.0188    0.76367 0.004 0.000 0.000 0.996
#> GSM28741     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28729     4  0.0336    0.76395 0.008 0.000 0.000 0.992
#> GSM28742     4  0.0188    0.76383 0.004 0.000 0.000 0.996
#> GSM11250     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11245     1  0.3972    0.61402 0.788 0.000 0.204 0.008
#> GSM11246     1  0.0000    0.78616 1.000 0.000 0.000 0.000
#> GSM11261     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM11248     3  0.0000    0.93862 0.000 0.000 1.000 0.000
#> GSM28732     4  0.4817    0.15653 0.388 0.000 0.000 0.612
#> GSM11255     1  0.0188    0.78404 0.996 0.000 0.000 0.004
#> GSM28731     1  0.4916    0.31987 0.576 0.000 0.000 0.424
#> GSM28727     1  0.4961    0.27008 0.552 0.000 0.000 0.448
#> GSM11251     1  0.4948    0.28828 0.560 0.000 0.000 0.440

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.3336     0.5598 0.000 0.000 0.000 0.228 0.772
#> GSM28736     5  0.4325     0.5272 0.000 0.044 0.000 0.220 0.736
#> GSM28737     1  0.0404     0.7932 0.988 0.000 0.000 0.000 0.012
#> GSM11249     3  0.1608     0.9282 0.000 0.000 0.928 0.072 0.000
#> GSM28745     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0000     0.7997 1.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000     0.7997 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.0000     0.7997 1.000 0.000 0.000 0.000 0.000
#> GSM11259     5  0.3430     0.6428 0.220 0.000 0.000 0.004 0.776
#> GSM28726     5  0.1768     0.6702 0.000 0.004 0.000 0.072 0.924
#> GSM28743     1  0.0000     0.7997 1.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.0324     0.7601 0.004 0.000 0.000 0.992 0.004
#> GSM11262     1  0.0000     0.7997 1.000 0.000 0.000 0.000 0.000
#> GSM28724     5  0.5862     0.4219 0.344 0.000 0.000 0.112 0.544
#> GSM28725     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.0324     0.7601 0.004 0.000 0.000 0.992 0.004
#> GSM28734     4  0.1377     0.7569 0.020 0.000 0.020 0.956 0.004
#> GSM28747     1  0.5022     0.1675 0.620 0.000 0.000 0.048 0.332
#> GSM11257     4  0.4822     0.5478 0.076 0.000 0.000 0.704 0.220
#> GSM11252     4  0.4618     0.4809 0.344 0.000 0.016 0.636 0.004
#> GSM11264     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM11258     1  0.4256     0.0222 0.564 0.000 0.000 0.436 0.000
#> GSM28728     5  0.2568     0.6915 0.048 0.000 0.016 0.032 0.904
#> GSM28746     1  0.6262     0.1626 0.504 0.000 0.000 0.332 0.164
#> GSM28738     5  0.2813     0.6123 0.000 0.000 0.000 0.168 0.832
#> GSM28741     2  0.0510     0.9832 0.000 0.984 0.000 0.000 0.016
#> GSM28729     5  0.1043     0.6794 0.000 0.000 0.000 0.040 0.960
#> GSM28742     5  0.1544     0.6718 0.000 0.000 0.000 0.068 0.932
#> GSM11250     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM11245     4  0.4882     0.5020 0.328 0.000 0.032 0.636 0.004
#> GSM11246     1  0.0162     0.7979 0.996 0.000 0.000 0.000 0.004
#> GSM11261     3  0.0000     0.9846 0.000 0.000 1.000 0.000 0.000
#> GSM11248     3  0.1197     0.9512 0.000 0.000 0.952 0.048 0.000
#> GSM28732     5  0.2843     0.6880 0.144 0.000 0.000 0.008 0.848
#> GSM11255     1  0.3579     0.5013 0.756 0.000 0.000 0.240 0.004
#> GSM28731     5  0.4882     0.3128 0.444 0.000 0.000 0.024 0.532
#> GSM28727     5  0.4283     0.3418 0.456 0.000 0.000 0.000 0.544
#> GSM11251     5  0.4306     0.2581 0.492 0.000 0.000 0.000 0.508

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.3707     0.6111 0.000 0.000 0.000 0.136 0.784 0.080
#> GSM28736     5  0.3856     0.6159 0.000 0.012 0.000 0.132 0.788 0.068
#> GSM28737     1  0.0405     0.7072 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM11249     3  0.3920     0.7520 0.000 0.000 0.768 0.112 0.000 0.120
#> GSM28745     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28740     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     6  0.5349     0.5044 0.144 0.000 0.000 0.004 0.256 0.596
#> GSM28726     5  0.1075     0.6316 0.000 0.000 0.000 0.000 0.952 0.048
#> GSM28743     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.0891     0.6576 0.000 0.000 0.000 0.968 0.024 0.008
#> GSM11262     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28724     6  0.6228     0.4794 0.188 0.000 0.000 0.076 0.156 0.580
#> GSM28725     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0622     0.6648 0.000 0.000 0.000 0.980 0.012 0.008
#> GSM28734     4  0.0436     0.6669 0.000 0.000 0.004 0.988 0.004 0.004
#> GSM28747     1  0.6301    -0.1298 0.436 0.000 0.000 0.048 0.120 0.396
#> GSM11257     4  0.6035     0.2373 0.020 0.000 0.000 0.528 0.188 0.264
#> GSM11252     4  0.6105     0.4902 0.200 0.000 0.008 0.488 0.004 0.300
#> GSM11264     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000     0.9434 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11258     1  0.3872     0.1927 0.604 0.000 0.000 0.392 0.000 0.004
#> GSM28728     6  0.5418     0.2721 0.024 0.000 0.012 0.048 0.336 0.580
#> GSM28746     6  0.6602     0.1634 0.316 0.000 0.000 0.264 0.028 0.392
#> GSM28738     5  0.5386    -0.0110 0.000 0.000 0.000 0.116 0.496 0.388
#> GSM28741     2  0.1563     0.9285 0.000 0.932 0.000 0.000 0.056 0.012
#> GSM28729     6  0.4250    -0.0516 0.000 0.000 0.000 0.016 0.456 0.528
#> GSM28742     5  0.1714     0.6105 0.000 0.000 0.000 0.000 0.908 0.092
#> GSM11250     2  0.0000     0.9932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     4  0.6320     0.4971 0.180 0.000 0.024 0.488 0.004 0.304
#> GSM11246     1  0.0000     0.7144 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11261     3  0.0405     0.9359 0.000 0.000 0.988 0.004 0.000 0.008
#> GSM11248     3  0.3552     0.7893 0.000 0.000 0.800 0.084 0.000 0.116
#> GSM28732     6  0.4544     0.4532 0.056 0.000 0.000 0.004 0.280 0.660
#> GSM11255     1  0.5067     0.2925 0.612 0.000 0.000 0.120 0.000 0.268
#> GSM28731     6  0.4947     0.5056 0.244 0.000 0.000 0.000 0.120 0.636
#> GSM28727     1  0.6219    -0.2713 0.372 0.000 0.000 0.004 0.284 0.340
#> GSM11251     1  0.5949    -0.1211 0.452 0.000 0.000 0.000 0.248 0.300

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 tissue(p) k
#> MAD:skmeans 49     0.393 2
#> MAD:skmeans 49     0.449 3
#> MAD:skmeans 40     0.406 4
#> MAD:skmeans 42     0.459 5
#> MAD:skmeans 36     0.455 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 21342 rows and 50 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 1.000           1.000       1.000          0.351 0.650   0.650
#> 3 3 1.000           1.000       1.000          0.576 0.798   0.688
#> 4 4 1.000           0.994       0.997          0.128 0.931   0.847
#> 5 5 0.851           0.872       0.943          0.108 0.939   0.838
#> 6 6 0.896           0.837       0.938          0.074 0.910   0.736

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

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following 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
#> GSM28735     1       0          1  1  0
#> GSM28736     1       0          1  1  0
#> GSM28737     1       0          1  1  0
#> GSM11249     1       0          1  1  0
#> GSM28745     2       0          1  0  1
#> GSM11244     2       0          1  0  1
#> GSM28748     2       0          1  0  1
#> GSM11266     2       0          1  0  1
#> GSM28730     2       0          1  0  1
#> GSM11253     2       0          1  0  1
#> GSM11254     2       0          1  0  1
#> GSM11260     2       0          1  0  1
#> GSM28733     2       0          1  0  1
#> GSM11265     1       0          1  1  0
#> GSM28739     1       0          1  1  0
#> GSM11243     1       0          1  1  0
#> GSM28740     1       0          1  1  0
#> GSM11259     1       0          1  1  0
#> GSM28726     1       0          1  1  0
#> GSM28743     1       0          1  1  0
#> GSM11256     1       0          1  1  0
#> GSM11262     1       0          1  1  0
#> GSM28724     1       0          1  1  0
#> GSM28725     1       0          1  1  0
#> GSM11263     1       0          1  1  0
#> GSM11267     1       0          1  1  0
#> GSM28744     1       0          1  1  0
#> GSM28734     1       0          1  1  0
#> GSM28747     1       0          1  1  0
#> GSM11257     1       0          1  1  0
#> GSM11252     1       0          1  1  0
#> GSM11264     1       0          1  1  0
#> GSM11247     1       0          1  1  0
#> GSM11258     1       0          1  1  0
#> GSM28728     1       0          1  1  0
#> GSM28746     1       0          1  1  0
#> GSM28738     1       0          1  1  0
#> GSM28741     2       0          1  0  1
#> GSM28729     1       0          1  1  0
#> GSM28742     1       0          1  1  0
#> GSM11250     2       0          1  0  1
#> GSM11245     1       0          1  1  0
#> GSM11246     1       0          1  1  0
#> GSM11261     1       0          1  1  0
#> GSM11248     1       0          1  1  0
#> GSM28732     1       0          1  1  0
#> GSM11255     1       0          1  1  0
#> GSM28731     1       0          1  1  0
#> GSM28727     1       0          1  1  0
#> GSM11251     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette p1 p2 p3
#> GSM28735     1       0          1  1  0  0
#> GSM28736     1       0          1  1  0  0
#> GSM28737     1       0          1  1  0  0
#> GSM11249     3       0          1  0  0  1
#> GSM28745     2       0          1  0  1  0
#> GSM11244     2       0          1  0  1  0
#> GSM28748     2       0          1  0  1  0
#> GSM11266     2       0          1  0  1  0
#> GSM28730     2       0          1  0  1  0
#> GSM11253     2       0          1  0  1  0
#> GSM11254     2       0          1  0  1  0
#> GSM11260     2       0          1  0  1  0
#> GSM28733     2       0          1  0  1  0
#> GSM11265     1       0          1  1  0  0
#> GSM28739     1       0          1  1  0  0
#> GSM11243     3       0          1  0  0  1
#> GSM28740     1       0          1  1  0  0
#> GSM11259     1       0          1  1  0  0
#> GSM28726     1       0          1  1  0  0
#> GSM28743     1       0          1  1  0  0
#> GSM11256     1       0          1  1  0  0
#> GSM11262     1       0          1  1  0  0
#> GSM28724     1       0          1  1  0  0
#> GSM28725     3       0          1  0  0  1
#> GSM11263     3       0          1  0  0  1
#> GSM11267     3       0          1  0  0  1
#> GSM28744     1       0          1  1  0  0
#> GSM28734     1       0          1  1  0  0
#> GSM28747     1       0          1  1  0  0
#> GSM11257     1       0          1  1  0  0
#> GSM11252     1       0          1  1  0  0
#> GSM11264     3       0          1  0  0  1
#> GSM11247     3       0          1  0  0  1
#> GSM11258     1       0          1  1  0  0
#> GSM28728     1       0          1  1  0  0
#> GSM28746     1       0          1  1  0  0
#> GSM28738     1       0          1  1  0  0
#> GSM28741     2       0          1  0  1  0
#> GSM28729     1       0          1  1  0  0
#> GSM28742     1       0          1  1  0  0
#> GSM11250     2       0          1  0  1  0
#> GSM11245     1       0          1  1  0  0
#> GSM11246     1       0          1  1  0  0
#> GSM11261     1       0          1  1  0  0
#> GSM11248     3       0          1  0  0  1
#> GSM28732     1       0          1  1  0  0
#> GSM11255     1       0          1  1  0  0
#> GSM28731     1       0          1  1  0  0
#> GSM28727     1       0          1  1  0  0
#> GSM11251     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2 p3    p4
#> GSM28735     1   0.000      0.995 1.000  0  0 0.000
#> GSM28736     1   0.000      0.995 1.000  0  0 0.000
#> GSM28737     1   0.000      0.995 1.000  0  0 0.000
#> GSM11249     3   0.000      1.000 0.000  0  1 0.000
#> GSM28745     2   0.000      1.000 0.000  1  0 0.000
#> GSM11244     2   0.000      1.000 0.000  1  0 0.000
#> GSM28748     2   0.000      1.000 0.000  1  0 0.000
#> GSM11266     2   0.000      1.000 0.000  1  0 0.000
#> GSM28730     2   0.000      1.000 0.000  1  0 0.000
#> GSM11253     2   0.000      1.000 0.000  1  0 0.000
#> GSM11254     2   0.000      1.000 0.000  1  0 0.000
#> GSM11260     2   0.000      1.000 0.000  1  0 0.000
#> GSM28733     2   0.000      1.000 0.000  1  0 0.000
#> GSM11265     1   0.000      0.995 1.000  0  0 0.000
#> GSM28739     1   0.000      0.995 1.000  0  0 0.000
#> GSM11243     3   0.000      1.000 0.000  0  1 0.000
#> GSM28740     1   0.000      0.995 1.000  0  0 0.000
#> GSM11259     1   0.000      0.995 1.000  0  0 0.000
#> GSM28726     1   0.000      0.995 1.000  0  0 0.000
#> GSM28743     1   0.000      0.995 1.000  0  0 0.000
#> GSM11256     4   0.000      1.000 0.000  0  0 1.000
#> GSM11262     1   0.000      0.995 1.000  0  0 0.000
#> GSM28724     1   0.000      0.995 1.000  0  0 0.000
#> GSM28725     3   0.000      1.000 0.000  0  1 0.000
#> GSM11263     3   0.000      1.000 0.000  0  1 0.000
#> GSM11267     3   0.000      1.000 0.000  0  1 0.000
#> GSM28744     4   0.000      1.000 0.000  0  0 1.000
#> GSM28734     4   0.000      1.000 0.000  0  0 1.000
#> GSM28747     1   0.000      0.995 1.000  0  0 0.000
#> GSM11257     1   0.000      0.995 1.000  0  0 0.000
#> GSM11252     1   0.000      0.995 1.000  0  0 0.000
#> GSM11264     3   0.000      1.000 0.000  0  1 0.000
#> GSM11247     3   0.000      1.000 0.000  0  1 0.000
#> GSM11258     1   0.276      0.853 0.872  0  0 0.128
#> GSM28728     1   0.000      0.995 1.000  0  0 0.000
#> GSM28746     1   0.000      0.995 1.000  0  0 0.000
#> GSM28738     1   0.000      0.995 1.000  0  0 0.000
#> GSM28741     2   0.000      1.000 0.000  1  0 0.000
#> GSM28729     1   0.000      0.995 1.000  0  0 0.000
#> GSM28742     1   0.000      0.995 1.000  0  0 0.000
#> GSM11250     2   0.000      1.000 0.000  1  0 0.000
#> GSM11245     1   0.000      0.995 1.000  0  0 0.000
#> GSM11246     1   0.000      0.995 1.000  0  0 0.000
#> GSM11261     1   0.000      0.995 1.000  0  0 0.000
#> GSM11248     3   0.000      1.000 0.000  0  1 0.000
#> GSM28732     1   0.000      0.995 1.000  0  0 0.000
#> GSM11255     1   0.000      0.995 1.000  0  0 0.000
#> GSM28731     1   0.000      0.995 1.000  0  0 0.000
#> GSM28727     1   0.000      0.995 1.000  0  0 0.000
#> GSM11251     1   0.000      0.995 1.000  0  0 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
#> GSM28735     1  0.4219     -0.136 0.584 0.000 0.00 0.000 0.416
#> GSM28736     5  0.3074      0.705 0.196 0.000 0.00 0.000 0.804
#> GSM28737     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11249     3  0.2516      0.870 0.000 0.000 0.86 0.000 0.140
#> GSM28745     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11244     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM28748     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11266     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM28730     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11253     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11254     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11260     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM28733     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11265     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28739     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11243     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM28740     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11259     1  0.0609      0.913 0.980 0.000 0.00 0.000 0.020
#> GSM28726     5  0.3074      0.705 0.196 0.000 0.00 0.000 0.804
#> GSM28743     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11256     4  0.0000      1.000 0.000 0.000 0.00 1.000 0.000
#> GSM11262     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28724     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28725     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM11263     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM11267     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.000 0.00 1.000 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.000 0.00 1.000 0.000
#> GSM28747     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11257     1  0.2813      0.774 0.832 0.000 0.00 0.000 0.168
#> GSM11252     1  0.2516      0.790 0.860 0.000 0.00 0.000 0.140
#> GSM11264     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM11247     3  0.0000      0.959 0.000 0.000 1.00 0.000 0.000
#> GSM11258     1  0.2377      0.794 0.872 0.000 0.00 0.128 0.000
#> GSM28728     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28746     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28738     1  0.1732      0.863 0.920 0.000 0.00 0.000 0.080
#> GSM28741     2  0.4201      0.425 0.000 0.592 0.00 0.000 0.408
#> GSM28729     1  0.0510      0.916 0.984 0.000 0.00 0.000 0.016
#> GSM28742     5  0.4305      0.387 0.488 0.000 0.00 0.000 0.512
#> GSM11250     2  0.0000      0.958 0.000 1.000 0.00 0.000 0.000
#> GSM11245     1  0.2516      0.790 0.860 0.000 0.00 0.000 0.140
#> GSM11246     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11261     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11248     3  0.2516      0.870 0.000 0.000 0.86 0.000 0.140
#> GSM28732     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM11255     1  0.2329      0.809 0.876 0.000 0.00 0.000 0.124
#> GSM28731     1  0.0000      0.925 1.000 0.000 0.00 0.000 0.000
#> GSM28727     1  0.0609      0.913 0.980 0.000 0.00 0.000 0.020
#> GSM11251     1  0.0609      0.913 0.980 0.000 0.00 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1   p2    p3    p4    p5    p6
#> GSM28735     5  0.3864      0.326 0.480 0.00 0.000 0.000 0.520 0.000
#> GSM28736     5  0.2491      0.682 0.164 0.00 0.000 0.000 0.836 0.000
#> GSM28737     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11249     6  0.0458      0.978 0.000 0.00 0.016 0.000 0.000 0.984
#> GSM28745     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM28740     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11259     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28726     5  0.2491      0.682 0.164 0.00 0.000 0.000 0.836 0.000
#> GSM28743     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11256     4  0.0000      1.000 0.000 0.00 0.000 1.000 0.000 0.000
#> GSM11262     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28724     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM28744     4  0.0000      1.000 0.000 0.00 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0000      1.000 0.000 0.00 0.000 1.000 0.000 0.000
#> GSM28747     1  0.0146      0.882 0.996 0.00 0.000 0.000 0.000 0.004
#> GSM11257     1  0.5723     -0.119 0.428 0.00 0.000 0.000 0.164 0.408
#> GSM11252     6  0.0458      0.978 0.016 0.00 0.000 0.000 0.000 0.984
#> GSM11264     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11258     1  0.2135      0.740 0.872 0.00 0.000 0.128 0.000 0.000
#> GSM28728     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28746     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28738     1  0.3003      0.666 0.812 0.00 0.000 0.000 0.172 0.016
#> GSM28741     2  0.3647      0.515 0.000 0.64 0.000 0.000 0.360 0.000
#> GSM28729     1  0.0146      0.881 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM28742     1  0.5984     -0.430 0.420 0.00 0.000 0.000 0.344 0.236
#> GSM11250     2  0.0000      0.964 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11245     6  0.0458      0.978 0.016 0.00 0.000 0.000 0.000 0.984
#> GSM11246     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11261     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11248     6  0.0458      0.978 0.000 0.00 0.016 0.000 0.000 0.984
#> GSM28732     1  0.0458      0.871 0.984 0.00 0.000 0.000 0.000 0.016
#> GSM11255     1  0.3607      0.354 0.652 0.00 0.000 0.000 0.000 0.348
#> GSM28731     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM28727     1  0.0000      0.885 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.885 1.000 0.00 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-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 tissue(p) k
#> MAD:pam 50     0.394 2
#> MAD:pam 50     0.370 3
#> MAD:pam 50     0.560 4
#> MAD:pam 47     0.503 5
#> MAD:pam 46     0.465 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 21342 rows and 50 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.689           0.818       0.912         0.3577 0.726   0.726
#> 3 3 0.423           0.594       0.783         0.6193 0.653   0.522
#> 4 4 0.607           0.748       0.862         0.1984 0.716   0.396
#> 5 5 0.704           0.795       0.878         0.0964 0.935   0.777
#> 6 6 0.693           0.664       0.806         0.0653 0.927   0.696

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
#> GSM28735     1  0.0672      0.878 0.992 0.008
#> GSM28736     1  0.0672      0.878 0.992 0.008
#> GSM28737     1  0.0000      0.880 1.000 0.000
#> GSM11249     1  0.9580      0.531 0.620 0.380
#> GSM28745     2  0.0000      1.000 0.000 1.000
#> GSM11244     2  0.0000      1.000 0.000 1.000
#> GSM28748     1  0.9866      0.438 0.568 0.432
#> GSM11266     2  0.0000      1.000 0.000 1.000
#> GSM28730     2  0.0000      1.000 0.000 1.000
#> GSM11253     2  0.0000      1.000 0.000 1.000
#> GSM11254     2  0.0000      1.000 0.000 1.000
#> GSM11260     2  0.0000      1.000 0.000 1.000
#> GSM28733     2  0.0000      1.000 0.000 1.000
#> GSM11265     1  0.0000      0.880 1.000 0.000
#> GSM28739     1  0.0000      0.880 1.000 0.000
#> GSM11243     1  0.9580      0.531 0.620 0.380
#> GSM28740     1  0.0000      0.880 1.000 0.000
#> GSM11259     1  0.0000      0.880 1.000 0.000
#> GSM28726     1  0.0672      0.878 0.992 0.008
#> GSM28743     1  0.0000      0.880 1.000 0.000
#> GSM11256     1  0.0672      0.878 0.992 0.008
#> GSM11262     1  0.0000      0.880 1.000 0.000
#> GSM28724     1  0.0000      0.880 1.000 0.000
#> GSM28725     1  0.9580      0.531 0.620 0.380
#> GSM11263     1  0.9580      0.531 0.620 0.380
#> GSM11267     1  0.9580      0.531 0.620 0.380
#> GSM28744     1  0.0672      0.878 0.992 0.008
#> GSM28734     1  0.0672      0.878 0.992 0.008
#> GSM28747     1  0.0000      0.880 1.000 0.000
#> GSM11257     1  0.0672      0.878 0.992 0.008
#> GSM11252     1  0.0000      0.880 1.000 0.000
#> GSM11264     1  0.9580      0.531 0.620 0.380
#> GSM11247     1  0.9580      0.531 0.620 0.380
#> GSM11258     1  0.0672      0.878 0.992 0.008
#> GSM28728     1  0.0000      0.880 1.000 0.000
#> GSM28746     1  0.0000      0.880 1.000 0.000
#> GSM28738     1  0.0672      0.878 0.992 0.008
#> GSM28741     1  0.2603      0.858 0.956 0.044
#> GSM28729     1  0.0672      0.878 0.992 0.008
#> GSM28742     1  0.0672      0.878 0.992 0.008
#> GSM11250     1  0.9866      0.438 0.568 0.432
#> GSM11245     1  0.0000      0.880 1.000 0.000
#> GSM11246     1  0.0000      0.880 1.000 0.000
#> GSM11261     1  0.9580      0.531 0.620 0.380
#> GSM11248     1  0.9580      0.531 0.620 0.380
#> GSM28732     1  0.0000      0.880 1.000 0.000
#> GSM11255     1  0.0000      0.880 1.000 0.000
#> GSM28731     1  0.0000      0.880 1.000 0.000
#> GSM28727     1  0.0000      0.880 1.000 0.000
#> GSM11251     1  0.0000      0.880 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
#> GSM28735     1   0.671   0.206682 0.572 0.012 0.416
#> GSM28736     1   0.844  -0.000943 0.492 0.088 0.420
#> GSM28737     1   0.369   0.651192 0.860 0.000 0.140
#> GSM11249     3   0.432   0.672722 0.112 0.028 0.860
#> GSM28745     2   0.000   1.000000 0.000 1.000 0.000
#> GSM11244     2   0.000   1.000000 0.000 1.000 0.000
#> GSM28748     3   0.912   0.554874 0.220 0.232 0.548
#> GSM11266     2   0.000   1.000000 0.000 1.000 0.000
#> GSM28730     2   0.000   1.000000 0.000 1.000 0.000
#> GSM11253     2   0.000   1.000000 0.000 1.000 0.000
#> GSM11254     2   0.000   1.000000 0.000 1.000 0.000
#> GSM11260     2   0.000   1.000000 0.000 1.000 0.000
#> GSM28733     2   0.000   1.000000 0.000 1.000 0.000
#> GSM11265     1   0.312   0.637739 0.892 0.000 0.108
#> GSM28739     1   0.312   0.637739 0.892 0.000 0.108
#> GSM11243     3   0.116   0.670475 0.000 0.028 0.972
#> GSM28740     1   0.312   0.637739 0.892 0.000 0.108
#> GSM11259     1   0.186   0.673796 0.948 0.000 0.052
#> GSM28726     1   0.802   0.088182 0.520 0.064 0.416
#> GSM28743     1   0.312   0.637739 0.892 0.000 0.108
#> GSM11256     3   0.618   0.407432 0.416 0.000 0.584
#> GSM11262     1   0.312   0.637739 0.892 0.000 0.108
#> GSM28724     1   0.593   0.387487 0.644 0.000 0.356
#> GSM28725     3   0.116   0.670475 0.000 0.028 0.972
#> GSM11263     3   0.116   0.670475 0.000 0.028 0.972
#> GSM11267     3   0.116   0.670475 0.000 0.028 0.972
#> GSM28744     3   0.618   0.407432 0.416 0.000 0.584
#> GSM28734     3   0.562   0.539454 0.308 0.000 0.692
#> GSM28747     1   0.175   0.673902 0.952 0.000 0.048
#> GSM11257     3   0.628   0.263884 0.460 0.000 0.540
#> GSM11252     1   0.540   0.500203 0.720 0.000 0.280
#> GSM11264     3   0.116   0.670475 0.000 0.028 0.972
#> GSM11247     3   0.116   0.670475 0.000 0.028 0.972
#> GSM11258     3   0.623   0.276924 0.436 0.000 0.564
#> GSM28728     1   0.620   0.209360 0.576 0.000 0.424
#> GSM28746     1   0.280   0.666039 0.908 0.000 0.092
#> GSM28738     1   0.709   0.185610 0.560 0.024 0.416
#> GSM28741     3   0.849   0.519225 0.312 0.116 0.572
#> GSM28729     1   0.670   0.218073 0.576 0.012 0.412
#> GSM28742     1   0.709   0.185610 0.560 0.024 0.416
#> GSM11250     3   0.912   0.554874 0.220 0.232 0.548
#> GSM11245     1   0.601   0.428681 0.628 0.000 0.372
#> GSM11246     1   0.312   0.637739 0.892 0.000 0.108
#> GSM11261     3   0.585   0.635731 0.216 0.028 0.756
#> GSM11248     3   0.580   0.638721 0.212 0.028 0.760
#> GSM28732     1   0.424   0.612947 0.824 0.000 0.176
#> GSM11255     1   0.369   0.659181 0.860 0.000 0.140
#> GSM28731     1   0.186   0.673796 0.948 0.000 0.052
#> GSM28727     1   0.175   0.673902 0.952 0.000 0.048
#> GSM11251     1   0.164   0.673177 0.956 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM28735     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28736     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28737     1  0.3074     0.8666 0.848 0.000 0.000 0.152
#> GSM11249     3  0.4730     0.4983 0.000 0.000 0.636 0.364
#> GSM28745     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM28748     2  0.5000    -0.1765 0.000 0.504 0.000 0.496
#> GSM11266     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000     0.9129 0.000 1.000 0.000 0.000
#> GSM11265     1  0.0000     0.8715 1.000 0.000 0.000 0.000
#> GSM28739     1  0.1211     0.8590 0.960 0.000 0.000 0.040
#> GSM11243     3  0.0000     0.7991 0.000 0.000 1.000 0.000
#> GSM28740     1  0.0000     0.8715 1.000 0.000 0.000 0.000
#> GSM11259     1  0.3356     0.8411 0.824 0.000 0.000 0.176
#> GSM28726     4  0.3400     0.8135 0.180 0.000 0.000 0.820
#> GSM28743     1  0.0000     0.8715 1.000 0.000 0.000 0.000
#> GSM11256     4  0.1929     0.7210 0.024 0.000 0.036 0.940
#> GSM11262     1  0.0000     0.8715 1.000 0.000 0.000 0.000
#> GSM28724     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28725     3  0.0000     0.7991 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000     0.7991 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000     0.7991 0.000 0.000 1.000 0.000
#> GSM28744     4  0.2032     0.7196 0.028 0.000 0.036 0.936
#> GSM28734     4  0.2124     0.7169 0.028 0.000 0.040 0.932
#> GSM28747     1  0.3172     0.8643 0.840 0.000 0.000 0.160
#> GSM11257     4  0.1302     0.7599 0.044 0.000 0.000 0.956
#> GSM11252     4  0.3494     0.8174 0.172 0.000 0.004 0.824
#> GSM11264     3  0.0000     0.7991 0.000 0.000 1.000 0.000
#> GSM11247     3  0.4304     0.6097 0.000 0.000 0.716 0.284
#> GSM11258     4  0.4746     0.3652 0.368 0.000 0.000 0.632
#> GSM28728     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28746     4  0.4356     0.7003 0.292 0.000 0.000 0.708
#> GSM28738     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28741     4  0.4883     0.5806 0.016 0.288 0.000 0.696
#> GSM28729     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM28742     4  0.3172     0.8222 0.160 0.000 0.000 0.840
#> GSM11250     4  0.5000     0.0582 0.000 0.496 0.000 0.504
#> GSM11245     4  0.3494     0.8182 0.172 0.000 0.004 0.824
#> GSM11246     1  0.0707     0.8767 0.980 0.000 0.000 0.020
#> GSM11261     4  0.6263     0.0656 0.016 0.028 0.436 0.520
#> GSM11248     3  0.4817     0.4384 0.000 0.000 0.612 0.388
#> GSM28732     4  0.4250     0.6929 0.276 0.000 0.000 0.724
#> GSM11255     4  0.4228     0.7781 0.232 0.000 0.008 0.760
#> GSM28731     1  0.3172     0.8643 0.840 0.000 0.000 0.160
#> GSM28727     1  0.3172     0.8643 0.840 0.000 0.000 0.160
#> GSM11251     1  0.3172     0.8643 0.840 0.000 0.000 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
#> GSM28735     5  0.1341      0.748 0.000 0.000 0.000 0.056 0.944
#> GSM28736     5  0.0510      0.759 0.000 0.000 0.000 0.016 0.984
#> GSM28737     1  0.4021      0.775 0.780 0.000 0.000 0.052 0.168
#> GSM11249     3  0.4297      0.718 0.000 0.000 0.764 0.164 0.072
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28748     5  0.5334      0.529 0.000 0.244 0.000 0.104 0.652
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0000      0.917 0.000 0.000 1.000 0.000 0.000
#> GSM28740     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM11259     1  0.4014      0.751 0.728 0.000 0.000 0.016 0.256
#> GSM28726     5  0.0703      0.764 0.000 0.000 0.000 0.024 0.976
#> GSM28743     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.3752      0.844 0.000 0.000 0.000 0.708 0.292
#> GSM11262     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM28724     5  0.2875      0.750 0.052 0.000 0.008 0.056 0.884
#> GSM28725     3  0.0000      0.917 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000      0.917 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000      0.917 0.000 0.000 1.000 0.000 0.000
#> GSM28744     4  0.3684      0.854 0.000 0.000 0.000 0.720 0.280
#> GSM28734     4  0.2329      0.725 0.000 0.000 0.000 0.876 0.124
#> GSM28747     1  0.3934      0.767 0.740 0.000 0.000 0.016 0.244
#> GSM11257     5  0.0000      0.762 0.000 0.000 0.000 0.000 1.000
#> GSM11252     5  0.5527      0.632 0.156 0.000 0.004 0.176 0.664
#> GSM11264     3  0.0000      0.917 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.0162      0.916 0.000 0.000 0.996 0.004 0.000
#> GSM11258     5  0.4905      0.616 0.256 0.000 0.016 0.036 0.692
#> GSM28728     5  0.0613      0.763 0.004 0.000 0.004 0.008 0.984
#> GSM28746     5  0.5940      0.581 0.200 0.000 0.004 0.184 0.612
#> GSM28738     5  0.1341      0.748 0.000 0.000 0.000 0.056 0.944
#> GSM28741     5  0.2482      0.748 0.000 0.024 0.000 0.084 0.892
#> GSM28729     5  0.1341      0.748 0.000 0.000 0.000 0.056 0.944
#> GSM28742     5  0.1270      0.750 0.000 0.000 0.000 0.052 0.948
#> GSM11250     5  0.5045      0.594 0.000 0.196 0.000 0.108 0.696
#> GSM11245     5  0.5523      0.644 0.124 0.000 0.008 0.200 0.668
#> GSM11246     1  0.0162      0.806 0.996 0.000 0.000 0.004 0.000
#> GSM11261     5  0.4480      0.645 0.000 0.004 0.044 0.220 0.732
#> GSM11248     3  0.4479      0.695 0.000 0.000 0.744 0.184 0.072
#> GSM28732     5  0.3421      0.654 0.164 0.000 0.004 0.016 0.816
#> GSM11255     5  0.6445      0.562 0.188 0.000 0.020 0.212 0.580
#> GSM28731     1  0.3934      0.767 0.740 0.000 0.000 0.016 0.244
#> GSM28727     1  0.3906      0.770 0.744 0.000 0.000 0.016 0.240
#> GSM11251     1  0.3906      0.770 0.744 0.000 0.000 0.016 0.240

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.0260     0.6973 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM28736     5  0.1829     0.6763 0.000 0.000 0.000 0.024 0.920 0.056
#> GSM28737     1  0.3028     0.8315 0.848 0.000 0.000 0.008 0.104 0.040
#> GSM11249     3  0.4987     0.4953 0.000 0.000 0.584 0.016 0.048 0.352
#> GSM28745     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     6  0.7242     0.2387 0.000 0.252 0.000 0.112 0.232 0.404
#> GSM11266     2  0.0146     0.9956 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28730     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000     0.8418 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0260     0.8389 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM11243     3  0.0146     0.8485 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM28740     1  0.0000     0.8418 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     1  0.4466     0.7968 0.736 0.000 0.000 0.060 0.176 0.028
#> GSM28726     5  0.2908     0.6263 0.000 0.000 0.000 0.048 0.848 0.104
#> GSM28743     1  0.0000     0.8418 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11256     4  0.3587     0.7964 0.000 0.000 0.000 0.772 0.188 0.040
#> GSM11262     1  0.0000     0.8418 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28724     6  0.5612     0.1458 0.116 0.000 0.000 0.012 0.340 0.532
#> GSM28725     3  0.0000     0.8494 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000     0.8494 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     0.8494 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.3344     0.8268 0.000 0.000 0.000 0.804 0.152 0.044
#> GSM28734     4  0.2980     0.6893 0.000 0.000 0.000 0.808 0.012 0.180
#> GSM28747     1  0.4334     0.8139 0.752 0.000 0.000 0.060 0.160 0.028
#> GSM11257     5  0.1531     0.6870 0.004 0.000 0.000 0.000 0.928 0.068
#> GSM11252     6  0.6177     0.2160 0.092 0.000 0.000 0.056 0.404 0.448
#> GSM11264     3  0.0000     0.8494 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.1267     0.8238 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM11258     5  0.6266    -0.1355 0.260 0.000 0.008 0.000 0.392 0.340
#> GSM28728     5  0.5240     0.2073 0.076 0.000 0.000 0.016 0.588 0.320
#> GSM28746     6  0.6306     0.2981 0.140 0.000 0.000 0.060 0.264 0.536
#> GSM28738     5  0.0508     0.6962 0.000 0.000 0.000 0.004 0.984 0.012
#> GSM28741     6  0.6079     0.0599 0.000 0.024 0.000 0.136 0.408 0.432
#> GSM28729     5  0.0935     0.6966 0.000 0.000 0.000 0.004 0.964 0.032
#> GSM28742     5  0.0508     0.6970 0.000 0.000 0.000 0.004 0.984 0.012
#> GSM11250     6  0.7136     0.2396 0.000 0.196 0.000 0.116 0.252 0.436
#> GSM11245     6  0.6263     0.2723 0.088 0.000 0.000 0.072 0.356 0.484
#> GSM11246     1  0.0405     0.8424 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM11261     6  0.4912     0.3197 0.000 0.000 0.112 0.016 0.184 0.688
#> GSM11248     3  0.5208     0.3608 0.000 0.000 0.500 0.020 0.048 0.432
#> GSM28732     5  0.5701     0.0240 0.148 0.000 0.000 0.004 0.492 0.356
#> GSM11255     6  0.5959     0.3557 0.144 0.000 0.008 0.056 0.164 0.628
#> GSM28731     1  0.4334     0.8139 0.752 0.000 0.000 0.060 0.160 0.028
#> GSM28727     1  0.4334     0.8139 0.752 0.000 0.000 0.060 0.160 0.028
#> GSM11251     1  0.4334     0.8139 0.752 0.000 0.000 0.060 0.160 0.028

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 tissue(p) k
#> MAD:mclust 48     0.392 2
#> MAD:mclust 37     0.413 3
#> MAD:mclust 44     0.411 4
#> MAD:mclust 50     0.536 5
#> MAD:mclust 36     0.472 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 21342 rows and 50 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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 1.000           0.980       0.991         0.3906 0.607   0.607
#> 3 3 1.000           0.965       0.986         0.4890 0.731   0.588
#> 4 4 0.793           0.852       0.913         0.2486 0.837   0.620
#> 5 5 0.765           0.743       0.861         0.0860 0.929   0.743
#> 6 6 0.746           0.521       0.747         0.0449 0.949   0.768

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1  0.0376      0.992 0.996 0.004
#> GSM28736     2  0.3114      0.930 0.056 0.944
#> GSM28737     1  0.0000      0.995 1.000 0.000
#> GSM11249     1  0.0000      0.995 1.000 0.000
#> GSM28745     2  0.0000      0.976 0.000 1.000
#> GSM11244     2  0.0000      0.976 0.000 1.000
#> GSM28748     2  0.0000      0.976 0.000 1.000
#> GSM11266     2  0.0000      0.976 0.000 1.000
#> GSM28730     2  0.0000      0.976 0.000 1.000
#> GSM11253     2  0.0000      0.976 0.000 1.000
#> GSM11254     2  0.0000      0.976 0.000 1.000
#> GSM11260     2  0.0000      0.976 0.000 1.000
#> GSM28733     2  0.0000      0.976 0.000 1.000
#> GSM11265     1  0.0000      0.995 1.000 0.000
#> GSM28739     1  0.0000      0.995 1.000 0.000
#> GSM11243     1  0.0000      0.995 1.000 0.000
#> GSM28740     1  0.0000      0.995 1.000 0.000
#> GSM11259     1  0.0000      0.995 1.000 0.000
#> GSM28726     2  0.7674      0.715 0.224 0.776
#> GSM28743     1  0.0000      0.995 1.000 0.000
#> GSM11256     1  0.0000      0.995 1.000 0.000
#> GSM11262     1  0.0000      0.995 1.000 0.000
#> GSM28724     1  0.0000      0.995 1.000 0.000
#> GSM28725     1  0.0000      0.995 1.000 0.000
#> GSM11263     1  0.0000      0.995 1.000 0.000
#> GSM11267     1  0.0000      0.995 1.000 0.000
#> GSM28744     1  0.0000      0.995 1.000 0.000
#> GSM28734     1  0.0000      0.995 1.000 0.000
#> GSM28747     1  0.0000      0.995 1.000 0.000
#> GSM11257     1  0.0000      0.995 1.000 0.000
#> GSM11252     1  0.0000      0.995 1.000 0.000
#> GSM11264     1  0.0000      0.995 1.000 0.000
#> GSM11247     1  0.0376      0.992 0.996 0.004
#> GSM11258     1  0.0000      0.995 1.000 0.000
#> GSM28728     1  0.0000      0.995 1.000 0.000
#> GSM28746     1  0.0000      0.995 1.000 0.000
#> GSM28738     1  0.0938      0.985 0.988 0.012
#> GSM28741     2  0.0000      0.976 0.000 1.000
#> GSM28729     1  0.0376      0.992 0.996 0.004
#> GSM28742     1  0.2423      0.957 0.960 0.040
#> GSM11250     2  0.0000      0.976 0.000 1.000
#> GSM11245     1  0.0000      0.995 1.000 0.000
#> GSM11246     1  0.0000      0.995 1.000 0.000
#> GSM11261     1  0.5178      0.868 0.884 0.116
#> GSM11248     1  0.0000      0.995 1.000 0.000
#> GSM28732     1  0.0000      0.995 1.000 0.000
#> GSM11255     1  0.0000      0.995 1.000 0.000
#> GSM28731     1  0.0000      0.995 1.000 0.000
#> GSM28727     1  0.0000      0.995 1.000 0.000
#> GSM11251     1  0.0000      0.995 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
#> GSM28735     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28736     1  0.4931      0.696 0.768 0.232 0.000
#> GSM28737     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11249     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11265     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28740     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11259     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28726     1  0.0237      0.973 0.996 0.004 0.000
#> GSM28743     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11256     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11262     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11263     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11267     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28744     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28734     1  0.6215      0.262 0.572 0.000 0.428
#> GSM28747     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11257     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11252     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11264     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11247     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11258     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28728     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28746     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28738     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000
#> GSM28729     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28742     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000
#> GSM11245     1  0.0424      0.970 0.992 0.000 0.008
#> GSM11246     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11261     3  0.0000      1.000 0.000 0.000 1.000
#> GSM11248     3  0.0000      1.000 0.000 0.000 1.000
#> GSM28732     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11255     1  0.0592      0.966 0.988 0.000 0.012
#> GSM28731     1  0.0000      0.976 1.000 0.000 0.000
#> GSM28727     1  0.0000      0.976 1.000 0.000 0.000
#> GSM11251     1  0.0000      0.976 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
#> GSM28735     4  0.3649      0.746 0.204 0.000 0.000 0.796
#> GSM28736     4  0.4711      0.692 0.064 0.152 0.000 0.784
#> GSM28737     1  0.0188      0.890 0.996 0.000 0.000 0.004
#> GSM11249     3  0.0336      0.972 0.000 0.000 0.992 0.008
#> GSM28745     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.0336      0.888 0.992 0.000 0.000 0.008
#> GSM28739     1  0.0469      0.888 0.988 0.000 0.000 0.012
#> GSM11243     3  0.1867      0.931 0.000 0.000 0.928 0.072
#> GSM28740     1  0.0336      0.889 0.992 0.000 0.000 0.008
#> GSM11259     1  0.1716      0.865 0.936 0.000 0.000 0.064
#> GSM28726     4  0.5055      0.610 0.368 0.008 0.000 0.624
#> GSM28743     1  0.0469      0.889 0.988 0.000 0.000 0.012
#> GSM11256     4  0.2401      0.760 0.092 0.000 0.004 0.904
#> GSM11262     1  0.0921      0.885 0.972 0.000 0.000 0.028
#> GSM28724     1  0.1576      0.876 0.948 0.000 0.004 0.048
#> GSM28725     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0188      0.974 0.000 0.000 0.996 0.004
#> GSM28744     4  0.3052      0.758 0.136 0.000 0.004 0.860
#> GSM28734     4  0.3962      0.680 0.044 0.000 0.124 0.832
#> GSM28747     1  0.1557      0.869 0.944 0.000 0.000 0.056
#> GSM11257     4  0.3219      0.762 0.164 0.000 0.000 0.836
#> GSM11252     1  0.4477      0.517 0.688 0.000 0.000 0.312
#> GSM11264     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM11247     3  0.2647      0.889 0.000 0.000 0.880 0.120
#> GSM11258     1  0.4585      0.458 0.668 0.000 0.000 0.332
#> GSM28728     1  0.3626      0.707 0.812 0.000 0.004 0.184
#> GSM28746     1  0.2469      0.824 0.892 0.000 0.000 0.108
#> GSM28738     4  0.4761      0.549 0.372 0.000 0.000 0.628
#> GSM28741     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM28729     4  0.4713      0.571 0.360 0.000 0.000 0.640
#> GSM28742     4  0.4103      0.687 0.256 0.000 0.000 0.744
#> GSM11250     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM11245     1  0.5577      0.431 0.636 0.000 0.036 0.328
#> GSM11246     1  0.0000      0.890 1.000 0.000 0.000 0.000
#> GSM11261     3  0.0336      0.972 0.000 0.000 0.992 0.008
#> GSM11248     3  0.0188      0.974 0.000 0.000 0.996 0.004
#> GSM28732     1  0.2081      0.850 0.916 0.000 0.000 0.084
#> GSM11255     1  0.1284      0.886 0.964 0.000 0.012 0.024
#> GSM28731     1  0.0817      0.886 0.976 0.000 0.000 0.024
#> GSM28727     1  0.0707      0.888 0.980 0.000 0.000 0.020
#> GSM11251     1  0.0469      0.890 0.988 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     4  0.4548     0.7740 0.120 0.000 0.000 0.752 0.128
#> GSM28736     4  0.5568     0.7701 0.060 0.096 0.000 0.716 0.128
#> GSM28737     1  0.1043     0.7620 0.960 0.000 0.000 0.000 0.040
#> GSM11249     3  0.3005     0.8042 0.020 0.000 0.880 0.068 0.032
#> GSM28745     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.0404     0.7653 0.988 0.000 0.000 0.000 0.012
#> GSM28739     1  0.0290     0.7652 0.992 0.000 0.000 0.000 0.008
#> GSM11243     3  0.3534     0.7110 0.000 0.000 0.744 0.000 0.256
#> GSM28740     1  0.0609     0.7616 0.980 0.000 0.000 0.020 0.000
#> GSM11259     5  0.4437     0.2428 0.464 0.000 0.000 0.004 0.532
#> GSM28726     5  0.6153     0.4689 0.208 0.000 0.000 0.232 0.560
#> GSM28743     1  0.1638     0.7465 0.932 0.000 0.000 0.064 0.004
#> GSM11256     4  0.1608     0.8611 0.000 0.000 0.000 0.928 0.072
#> GSM11262     1  0.1608     0.7446 0.928 0.000 0.000 0.072 0.000
#> GSM28724     1  0.4552    -0.0516 0.524 0.000 0.008 0.000 0.468
#> GSM28725     3  0.0880     0.8704 0.000 0.000 0.968 0.000 0.032
#> GSM11263     3  0.0404     0.8733 0.000 0.000 0.988 0.000 0.012
#> GSM11267     3  0.0162     0.8711 0.000 0.000 0.996 0.000 0.004
#> GSM28744     4  0.1121     0.8624 0.000 0.000 0.000 0.956 0.044
#> GSM28734     4  0.0794     0.8210 0.028 0.000 0.000 0.972 0.000
#> GSM28747     1  0.2824     0.7363 0.864 0.000 0.000 0.020 0.116
#> GSM11257     4  0.3011     0.8375 0.016 0.000 0.000 0.844 0.140
#> GSM11252     1  0.5350     0.5671 0.664 0.000 0.028 0.264 0.044
#> GSM11264     3  0.0162     0.8728 0.000 0.000 0.996 0.000 0.004
#> GSM11247     3  0.4307     0.3030 0.000 0.000 0.504 0.000 0.496
#> GSM11258     1  0.5111     0.4068 0.588 0.000 0.012 0.376 0.024
#> GSM28728     5  0.3010     0.6664 0.172 0.000 0.004 0.000 0.824
#> GSM28746     1  0.4495     0.6114 0.736 0.000 0.000 0.064 0.200
#> GSM28738     5  0.2879     0.6466 0.032 0.000 0.000 0.100 0.868
#> GSM28741     2  0.0510     0.9808 0.000 0.984 0.000 0.000 0.016
#> GSM28729     5  0.3116     0.6754 0.064 0.000 0.000 0.076 0.860
#> GSM28742     5  0.3165     0.6385 0.036 0.000 0.000 0.116 0.848
#> GSM11250     2  0.0000     0.9981 0.000 1.000 0.000 0.000 0.000
#> GSM11245     1  0.6421     0.4820 0.592 0.000 0.104 0.260 0.044
#> GSM11246     1  0.1043     0.7620 0.960 0.000 0.000 0.000 0.040
#> GSM11261     3  0.1270     0.8648 0.000 0.000 0.948 0.000 0.052
#> GSM11248     3  0.1911     0.8450 0.004 0.000 0.932 0.028 0.036
#> GSM28732     5  0.4299     0.4220 0.388 0.000 0.000 0.004 0.608
#> GSM11255     1  0.4187     0.6468 0.764 0.000 0.008 0.032 0.196
#> GSM28731     1  0.4238     0.3050 0.628 0.000 0.000 0.004 0.368
#> GSM28727     1  0.2358     0.7393 0.888 0.000 0.000 0.008 0.104
#> GSM11251     1  0.1732     0.7468 0.920 0.000 0.000 0.000 0.080

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     4  0.6603     0.1908 0.136 0.000 0.000 0.440 0.068 0.356
#> GSM28736     4  0.6413     0.4114 0.080 0.028 0.000 0.552 0.056 0.284
#> GSM28737     1  0.0806     0.6333 0.972 0.000 0.000 0.000 0.020 0.008
#> GSM11249     3  0.3790     0.6045 0.004 0.000 0.716 0.016 0.000 0.264
#> GSM28745     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0632     0.6319 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM28739     1  0.1549     0.6188 0.936 0.000 0.000 0.000 0.020 0.044
#> GSM11243     3  0.4700     0.5814 0.000 0.000 0.636 0.000 0.288 0.076
#> GSM28740     1  0.0777     0.6320 0.972 0.000 0.000 0.004 0.000 0.024
#> GSM11259     5  0.6058    -0.0244 0.324 0.000 0.000 0.000 0.404 0.272
#> GSM28726     6  0.6656    -0.2320 0.164 0.004 0.000 0.048 0.344 0.440
#> GSM28743     1  0.1265     0.6238 0.948 0.000 0.000 0.008 0.000 0.044
#> GSM11256     4  0.0260     0.7061 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM11262     1  0.1196     0.6259 0.952 0.000 0.000 0.008 0.000 0.040
#> GSM28724     5  0.6787     0.0172 0.308 0.000 0.028 0.004 0.344 0.316
#> GSM28725     3  0.0935     0.7567 0.000 0.000 0.964 0.000 0.032 0.004
#> GSM11263     3  0.0000     0.7601 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.1267     0.7517 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM28744     4  0.0000     0.7064 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28734     4  0.0909     0.6973 0.020 0.000 0.000 0.968 0.000 0.012
#> GSM28747     1  0.4925     0.0477 0.512 0.000 0.000 0.000 0.064 0.424
#> GSM11257     4  0.4756     0.5534 0.024 0.000 0.000 0.720 0.124 0.132
#> GSM11252     6  0.5802     0.2303 0.348 0.000 0.068 0.052 0.000 0.532
#> GSM11264     3  0.1007     0.7582 0.000 0.000 0.956 0.000 0.000 0.044
#> GSM11247     3  0.5145     0.3834 0.000 0.000 0.484 0.000 0.432 0.084
#> GSM11258     1  0.4591    -0.0321 0.500 0.000 0.000 0.464 0.000 0.036
#> GSM28728     5  0.3789     0.3730 0.112 0.000 0.024 0.000 0.804 0.060
#> GSM28746     1  0.6485     0.2582 0.560 0.000 0.000 0.112 0.152 0.176
#> GSM28738     5  0.4382     0.4072 0.064 0.000 0.000 0.024 0.744 0.168
#> GSM28741     2  0.3558     0.6614 0.000 0.760 0.000 0.000 0.028 0.212
#> GSM28729     5  0.4449     0.3713 0.036 0.000 0.000 0.016 0.684 0.264
#> GSM28742     5  0.4764     0.2729 0.020 0.000 0.000 0.020 0.540 0.420
#> GSM11250     2  0.0000     0.9726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11245     6  0.6718     0.2842 0.256 0.000 0.160 0.088 0.000 0.496
#> GSM11246     1  0.0622     0.6341 0.980 0.000 0.000 0.000 0.008 0.012
#> GSM11261     3  0.4418     0.6355 0.000 0.000 0.728 0.004 0.128 0.140
#> GSM11248     3  0.3499     0.5792 0.000 0.000 0.680 0.000 0.000 0.320
#> GSM28732     6  0.5802    -0.2004 0.180 0.000 0.000 0.000 0.400 0.420
#> GSM11255     1  0.6369    -0.1706 0.436 0.000 0.040 0.000 0.148 0.376
#> GSM28731     1  0.5654    -0.0992 0.444 0.000 0.000 0.000 0.404 0.152
#> GSM28727     1  0.4859     0.1978 0.584 0.000 0.000 0.000 0.072 0.344
#> GSM11251     1  0.3279     0.5021 0.796 0.000 0.000 0.000 0.028 0.176

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 tissue(p) k
#> MAD:NMF 50     0.394 2
#> MAD:NMF 49     0.368 3
#> MAD:NMF 48     0.430 4
#> MAD:NMF 42     0.422 5
#> MAD:NMF 31     0.474 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 21342 rows and 50 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 1.000           1.000       1.000         0.2163 0.784   0.784
#> 3 3 1.000           0.999       1.000         1.3695 0.704   0.622
#> 4 4 0.881           0.859       0.943         0.2575 0.905   0.806
#> 5 5 0.915           0.893       0.939         0.0485 0.913   0.780
#> 6 6 0.848           0.821       0.916         0.0826 0.946   0.828

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

suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM28735     1       0          1  1  0
#> GSM28736     1       0          1  1  0
#> GSM28737     1       0          1  1  0
#> GSM11249     1       0          1  1  0
#> GSM28745     1       0          1  1  0
#> GSM11244     1       0          1  1  0
#> GSM28748     1       0          1  1  0
#> GSM11266     1       0          1  1  0
#> GSM28730     1       0          1  1  0
#> GSM11253     1       0          1  1  0
#> GSM11254     1       0          1  1  0
#> GSM11260     1       0          1  1  0
#> GSM28733     1       0          1  1  0
#> GSM11265     1       0          1  1  0
#> GSM28739     1       0          1  1  0
#> GSM11243     2       0          1  0  1
#> GSM28740     1       0          1  1  0
#> GSM11259     1       0          1  1  0
#> GSM28726     1       0          1  1  0
#> GSM28743     1       0          1  1  0
#> GSM11256     1       0          1  1  0
#> GSM11262     1       0          1  1  0
#> GSM28724     1       0          1  1  0
#> GSM28725     2       0          1  0  1
#> GSM11263     2       0          1  0  1
#> GSM11267     2       0          1  0  1
#> GSM28744     1       0          1  1  0
#> GSM28734     1       0          1  1  0
#> GSM28747     1       0          1  1  0
#> GSM11257     1       0          1  1  0
#> GSM11252     1       0          1  1  0
#> GSM11264     2       0          1  0  1
#> GSM11247     2       0          1  0  1
#> GSM11258     1       0          1  1  0
#> GSM28728     1       0          1  1  0
#> GSM28746     1       0          1  1  0
#> GSM28738     1       0          1  1  0
#> GSM28741     1       0          1  1  0
#> GSM28729     1       0          1  1  0
#> GSM28742     1       0          1  1  0
#> GSM11250     1       0          1  1  0
#> GSM11245     1       0          1  1  0
#> GSM11246     1       0          1  1  0
#> GSM11261     1       0          1  1  0
#> GSM11248     1       0          1  1  0
#> GSM28732     1       0          1  1  0
#> GSM11255     1       0          1  1  0
#> GSM28731     1       0          1  1  0
#> GSM28727     1       0          1  1  0
#> GSM11251     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2 p3
#> GSM28735     1  0.0237      0.996 0.996 0.004  0
#> GSM28736     1  0.0237      0.996 0.996 0.004  0
#> GSM28737     1  0.0000      0.999 1.000 0.000  0
#> GSM11249     1  0.0000      0.999 1.000 0.000  0
#> GSM28745     2  0.0000      1.000 0.000 1.000  0
#> GSM11244     2  0.0000      1.000 0.000 1.000  0
#> GSM28748     2  0.0000      1.000 0.000 1.000  0
#> GSM11266     2  0.0000      1.000 0.000 1.000  0
#> GSM28730     2  0.0000      1.000 0.000 1.000  0
#> GSM11253     2  0.0000      1.000 0.000 1.000  0
#> GSM11254     2  0.0000      1.000 0.000 1.000  0
#> GSM11260     2  0.0000      1.000 0.000 1.000  0
#> GSM28733     2  0.0000      1.000 0.000 1.000  0
#> GSM11265     1  0.0000      0.999 1.000 0.000  0
#> GSM28739     1  0.0000      0.999 1.000 0.000  0
#> GSM11243     3  0.0000      1.000 0.000 0.000  1
#> GSM28740     1  0.0000      0.999 1.000 0.000  0
#> GSM11259     1  0.0000      0.999 1.000 0.000  0
#> GSM28726     1  0.0237      0.996 0.996 0.004  0
#> GSM28743     1  0.0000      0.999 1.000 0.000  0
#> GSM11256     1  0.0000      0.999 1.000 0.000  0
#> GSM11262     1  0.0000      0.999 1.000 0.000  0
#> GSM28724     1  0.0000      0.999 1.000 0.000  0
#> GSM28725     3  0.0000      1.000 0.000 0.000  1
#> GSM11263     3  0.0000      1.000 0.000 0.000  1
#> GSM11267     3  0.0000      1.000 0.000 0.000  1
#> GSM28744     1  0.0000      0.999 1.000 0.000  0
#> GSM28734     1  0.0000      0.999 1.000 0.000  0
#> GSM28747     1  0.0000      0.999 1.000 0.000  0
#> GSM11257     1  0.0000      0.999 1.000 0.000  0
#> GSM11252     1  0.0000      0.999 1.000 0.000  0
#> GSM11264     3  0.0000      1.000 0.000 0.000  1
#> GSM11247     3  0.0000      1.000 0.000 0.000  1
#> GSM11258     1  0.0000      0.999 1.000 0.000  0
#> GSM28728     1  0.0000      0.999 1.000 0.000  0
#> GSM28746     1  0.0000      0.999 1.000 0.000  0
#> GSM28738     1  0.0000      0.999 1.000 0.000  0
#> GSM28741     2  0.0000      1.000 0.000 1.000  0
#> GSM28729     1  0.0000      0.999 1.000 0.000  0
#> GSM28742     1  0.0237      0.996 0.996 0.004  0
#> GSM11250     2  0.0000      1.000 0.000 1.000  0
#> GSM11245     1  0.0000      0.999 1.000 0.000  0
#> GSM11246     1  0.0000      0.999 1.000 0.000  0
#> GSM11261     1  0.0000      0.999 1.000 0.000  0
#> GSM11248     1  0.0000      0.999 1.000 0.000  0
#> GSM28732     1  0.0000      0.999 1.000 0.000  0
#> GSM11255     1  0.0000      0.999 1.000 0.000  0
#> GSM28731     1  0.0000      0.999 1.000 0.000  0
#> GSM28727     1  0.0000      0.999 1.000 0.000  0
#> GSM11251     1  0.0000      0.999 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2 p3    p4
#> GSM28735     1  0.4905      0.420 0.632 0.004  0 0.364
#> GSM28736     1  0.4905      0.420 0.632 0.004  0 0.364
#> GSM28737     1  0.0336      0.893 0.992 0.000  0 0.008
#> GSM11249     4  0.0707      0.875 0.020 0.000  0 0.980
#> GSM28745     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11244     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM28748     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11266     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM28730     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11253     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11254     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11260     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM28733     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11265     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM28739     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM28740     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM11259     1  0.0336      0.893 0.992 0.000  0 0.008
#> GSM28726     1  0.4905      0.420 0.632 0.004  0 0.364
#> GSM28743     1  0.0336      0.893 0.992 0.000  0 0.008
#> GSM11256     1  0.0707      0.888 0.980 0.000  0 0.020
#> GSM11262     1  0.0336      0.893 0.992 0.000  0 0.008
#> GSM28724     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM28744     1  0.4817      0.319 0.612 0.000  0 0.388
#> GSM28734     1  0.4925      0.224 0.572 0.000  0 0.428
#> GSM28747     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM11257     1  0.0707      0.888 0.980 0.000  0 0.020
#> GSM11252     1  0.1474      0.863 0.948 0.000  0 0.052
#> GSM11264     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM11258     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM28728     1  0.0336      0.893 0.992 0.000  0 0.008
#> GSM28746     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM28738     1  0.0707      0.888 0.980 0.000  0 0.020
#> GSM28741     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM28729     1  0.0469      0.892 0.988 0.000  0 0.012
#> GSM28742     4  0.4088      0.652 0.232 0.004  0 0.764
#> GSM11250     2  0.0000      1.000 0.000 1.000  0 0.000
#> GSM11245     1  0.1474      0.863 0.948 0.000  0 0.052
#> GSM11246     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM11261     4  0.0707      0.875 0.020 0.000  0 0.980
#> GSM11248     4  0.0707      0.875 0.020 0.000  0 0.980
#> GSM28732     1  0.4730      0.425 0.636 0.000  0 0.364
#> GSM11255     1  0.1474      0.863 0.948 0.000  0 0.052
#> GSM28731     1  0.0469      0.892 0.988 0.000  0 0.012
#> GSM28727     1  0.0000      0.894 1.000 0.000  0 0.000
#> GSM11251     1  0.0000      0.894 1.000 0.000  0 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
#> GSM28735     5  0.4249      0.823 0.432 0.000  0 0.000 0.568
#> GSM28736     5  0.4249      0.823 0.432 0.000  0 0.000 0.568
#> GSM28737     1  0.0703      0.915 0.976 0.000  0 0.000 0.024
#> GSM11249     4  0.0162      0.990 0.004 0.000  0 0.996 0.000
#> GSM28745     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11244     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM28748     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11266     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM28730     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11253     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11254     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11260     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM28733     2  0.0000      0.999 0.000 1.000  0 0.000 0.000
#> GSM11265     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM28739     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM11243     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM28740     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM11259     1  0.0703      0.915 0.976 0.000  0 0.000 0.024
#> GSM28726     5  0.4249      0.823 0.432 0.000  0 0.000 0.568
#> GSM28743     1  0.0703      0.915 0.976 0.000  0 0.000 0.024
#> GSM11256     1  0.1041      0.909 0.964 0.000  0 0.004 0.032
#> GSM11262     1  0.0703      0.915 0.976 0.000  0 0.000 0.024
#> GSM28724     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM28725     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM11263     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM11267     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM28744     1  0.4436      0.225 0.596 0.000  0 0.396 0.008
#> GSM28734     1  0.4256      0.164 0.564 0.000  0 0.436 0.000
#> GSM28747     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM11257     1  0.1041      0.909 0.964 0.000  0 0.004 0.032
#> GSM11252     1  0.1270      0.872 0.948 0.000  0 0.052 0.000
#> GSM11264     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM11247     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM11258     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM28728     1  0.0703      0.915 0.976 0.000  0 0.000 0.024
#> GSM28746     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM28738     1  0.1041      0.909 0.964 0.000  0 0.004 0.032
#> GSM28741     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> GSM28729     1  0.0865      0.914 0.972 0.000  0 0.004 0.024
#> GSM28742     5  0.0880      0.112 0.032 0.000  0 0.000 0.968
#> GSM11250     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> GSM11245     1  0.1270      0.872 0.948 0.000  0 0.052 0.000
#> GSM11246     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM11261     4  0.0865      0.981 0.004 0.000  0 0.972 0.024
#> GSM11248     4  0.0162      0.990 0.004 0.000  0 0.996 0.000
#> GSM28732     5  0.4256      0.817 0.436 0.000  0 0.000 0.564
#> GSM11255     1  0.1270      0.872 0.948 0.000  0 0.052 0.000
#> GSM28731     1  0.0865      0.914 0.972 0.000  0 0.004 0.024
#> GSM28727     1  0.0000      0.917 1.000 0.000  0 0.000 0.000
#> GSM11251     1  0.0000      0.917 1.000 0.000  0 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
#> GSM28735     5  0.3817      0.818 0.432 0.000 0.000 0.000 0.568 0.000
#> GSM28736     5  0.3817      0.818 0.432 0.000 0.000 0.000 0.568 0.000
#> GSM28737     1  0.1007      0.846 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM11249     6  0.0000      0.987 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM28745     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28739     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM28740     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11259     1  0.1007      0.846 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM28726     5  0.3817      0.818 0.432 0.000 0.000 0.000 0.568 0.000
#> GSM28743     1  0.0632      0.856 0.976 0.000 0.000 0.024 0.000 0.000
#> GSM11256     4  0.3868     -0.142 0.496 0.000 0.000 0.504 0.000 0.000
#> GSM11262     1  0.0632      0.856 0.976 0.000 0.000 0.024 0.000 0.000
#> GSM28724     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28725     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     1  0.4886      0.189 0.540 0.000 0.000 0.064 0.000 0.396
#> GSM28734     1  0.3823      0.240 0.564 0.000 0.000 0.000 0.000 0.436
#> GSM28747     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11257     4  0.0146      0.491 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM11252     1  0.1141      0.837 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM11264     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0260      0.995 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM11258     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28728     1  0.3101      0.631 0.756 0.000 0.000 0.244 0.000 0.000
#> GSM28746     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28738     4  0.0146      0.491 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM28741     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM28729     1  0.3101      0.630 0.756 0.000 0.000 0.244 0.000 0.000
#> GSM28742     5  0.0260      0.140 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM11250     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM11245     1  0.1141      0.837 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM11246     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11261     6  0.0777      0.974 0.000 0.000 0.000 0.004 0.024 0.972
#> GSM11248     6  0.0000      0.987 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM28732     5  0.3823      0.812 0.436 0.000 0.000 0.000 0.564 0.000
#> GSM11255     1  0.1141      0.837 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM28731     1  0.3050      0.642 0.764 0.000 0.000 0.236 0.000 0.000
#> GSM28727     1  0.0000      0.863 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11251     1  0.0000      0.863 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-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 tissue(p) k
#> ATC:hclust 50     0.394 2
#> ATC:hclust 50     0.370 3
#> ATC:hclust 44     0.339 4
#> ATC:hclust 47     0.326 5
#> ATC:hclust 44     0.401 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 21342 rows and 50 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

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

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

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

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.486           0.772       0.854         0.3326 0.556   0.556
#> 3 3 1.000           0.992       0.991         0.5526 0.919   0.856
#> 4 4 0.645           0.543       0.742         0.2998 0.778   0.542
#> 5 5 0.632           0.774       0.803         0.1125 0.795   0.420
#> 6 6 0.726           0.801       0.870         0.0678 0.958   0.826

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
#> GSM28735     1   0.000     0.9423 1.000 0.000
#> GSM28736     1   0.000     0.9423 1.000 0.000
#> GSM28737     1   0.000     0.9423 1.000 0.000
#> GSM11249     1   0.983    -0.0178 0.576 0.424
#> GSM28745     2   0.983     0.6380 0.424 0.576
#> GSM11244     2   0.983     0.6380 0.424 0.576
#> GSM28748     2   0.983     0.6380 0.424 0.576
#> GSM11266     2   0.983     0.6380 0.424 0.576
#> GSM28730     2   0.983     0.6380 0.424 0.576
#> GSM11253     2   0.983     0.6380 0.424 0.576
#> GSM11254     2   0.983     0.6380 0.424 0.576
#> GSM11260     2   0.983     0.6380 0.424 0.576
#> GSM28733     2   0.983     0.6380 0.424 0.576
#> GSM11265     1   0.000     0.9423 1.000 0.000
#> GSM28739     1   0.000     0.9423 1.000 0.000
#> GSM11243     2   0.925     0.4511 0.340 0.660
#> GSM28740     1   0.000     0.9423 1.000 0.000
#> GSM11259     1   0.000     0.9423 1.000 0.000
#> GSM28726     1   0.000     0.9423 1.000 0.000
#> GSM28743     1   0.000     0.9423 1.000 0.000
#> GSM11256     1   0.000     0.9423 1.000 0.000
#> GSM11262     1   0.000     0.9423 1.000 0.000
#> GSM28724     1   0.000     0.9423 1.000 0.000
#> GSM28725     2   0.925     0.4511 0.340 0.660
#> GSM11263     2   0.925     0.4511 0.340 0.660
#> GSM11267     2   0.925     0.4511 0.340 0.660
#> GSM28744     1   0.000     0.9423 1.000 0.000
#> GSM28734     1   0.000     0.9423 1.000 0.000
#> GSM28747     1   0.000     0.9423 1.000 0.000
#> GSM11257     1   0.000     0.9423 1.000 0.000
#> GSM11252     1   0.000     0.9423 1.000 0.000
#> GSM11264     2   0.925     0.4511 0.340 0.660
#> GSM11247     2   0.925     0.4511 0.340 0.660
#> GSM11258     1   0.000     0.9423 1.000 0.000
#> GSM28728     1   0.000     0.9423 1.000 0.000
#> GSM28746     1   0.000     0.9423 1.000 0.000
#> GSM28738     1   0.000     0.9423 1.000 0.000
#> GSM28741     1   0.925    -0.0040 0.660 0.340
#> GSM28729     1   0.000     0.9423 1.000 0.000
#> GSM28742     1   0.327     0.8386 0.940 0.060
#> GSM11250     2   0.983     0.6380 0.424 0.576
#> GSM11245     1   0.000     0.9423 1.000 0.000
#> GSM11246     1   0.000     0.9423 1.000 0.000
#> GSM11261     1   0.760     0.4195 0.780 0.220
#> GSM11248     1   0.000     0.9423 1.000 0.000
#> GSM28732     1   0.000     0.9423 1.000 0.000
#> GSM11255     1   0.000     0.9423 1.000 0.000
#> GSM28731     1   0.000     0.9423 1.000 0.000
#> GSM28727     1   0.000     0.9423 1.000 0.000
#> GSM11251     1   0.000     0.9423 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
#> GSM28735     1  0.0237      0.993 0.996 0.000 0.004
#> GSM28736     1  0.0237      0.993 0.996 0.000 0.004
#> GSM28737     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11249     3  0.1163      0.961 0.028 0.000 0.972
#> GSM28745     2  0.0237      0.999 0.004 0.996 0.000
#> GSM11244     2  0.0237      0.999 0.004 0.996 0.000
#> GSM28748     2  0.0475      0.996 0.004 0.992 0.004
#> GSM11266     2  0.0237      0.999 0.004 0.996 0.000
#> GSM28730     2  0.0237      0.999 0.004 0.996 0.000
#> GSM11253     2  0.0237      0.999 0.004 0.996 0.000
#> GSM11254     2  0.0237      0.999 0.004 0.996 0.000
#> GSM11260     2  0.0237      0.999 0.004 0.996 0.000
#> GSM28733     2  0.0237      0.999 0.004 0.996 0.000
#> GSM11265     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28739     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11243     3  0.1267      0.993 0.004 0.024 0.972
#> GSM28740     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11259     1  0.0237      0.993 0.996 0.000 0.004
#> GSM28726     1  0.0237      0.993 0.996 0.000 0.004
#> GSM28743     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11256     1  0.1129      0.978 0.976 0.004 0.020
#> GSM11262     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28724     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28725     3  0.1267      0.993 0.004 0.024 0.972
#> GSM11263     3  0.1267      0.993 0.004 0.024 0.972
#> GSM11267     3  0.1267      0.993 0.004 0.024 0.972
#> GSM28744     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28734     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28747     1  0.0237      0.993 0.996 0.000 0.004
#> GSM11257     1  0.1129      0.978 0.976 0.004 0.020
#> GSM11252     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11264     3  0.1267      0.993 0.004 0.024 0.972
#> GSM11247     3  0.1267      0.993 0.004 0.024 0.972
#> GSM11258     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28728     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28746     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28738     1  0.1129      0.978 0.976 0.004 0.020
#> GSM28741     1  0.2384      0.935 0.936 0.056 0.008
#> GSM28729     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28742     1  0.0237      0.993 0.996 0.000 0.004
#> GSM11250     2  0.0661      0.993 0.004 0.988 0.008
#> GSM11245     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11246     1  0.0000      0.994 1.000 0.000 0.000
#> GSM11261     1  0.0892      0.978 0.980 0.020 0.000
#> GSM11248     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28732     1  0.0237      0.993 0.996 0.000 0.004
#> GSM11255     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28731     1  0.0000      0.994 1.000 0.000 0.000
#> GSM28727     1  0.0237      0.993 0.996 0.000 0.004
#> GSM11251     1  0.0237      0.993 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM28735     1  0.4431     0.3686 0.696 0.000 0.000 0.304
#> GSM28736     1  0.4431     0.3686 0.696 0.000 0.000 0.304
#> GSM28737     1  0.4981     0.6396 0.536 0.000 0.000 0.464
#> GSM11249     3  0.5678     0.4534 0.024 0.000 0.524 0.452
#> GSM28745     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0707     0.9838 0.020 0.980 0.000 0.000
#> GSM11266     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000     0.9955 0.000 1.000 0.000 0.000
#> GSM11265     4  0.3569     0.3177 0.196 0.000 0.000 0.804
#> GSM28739     4  0.3569     0.3177 0.196 0.000 0.000 0.804
#> GSM11243     3  0.1042     0.9144 0.020 0.008 0.972 0.000
#> GSM28740     1  0.4981     0.6269 0.536 0.000 0.000 0.464
#> GSM11259     1  0.4981     0.6386 0.536 0.000 0.000 0.464
#> GSM28726     1  0.4431     0.3686 0.696 0.000 0.000 0.304
#> GSM28743     1  0.4994     0.6228 0.520 0.000 0.000 0.480
#> GSM11256     1  0.4456     0.5119 0.716 0.000 0.004 0.280
#> GSM11262     1  0.4994     0.6228 0.520 0.000 0.000 0.480
#> GSM28724     4  0.4961    -0.5118 0.448 0.000 0.000 0.552
#> GSM28725     3  0.0336     0.9183 0.000 0.008 0.992 0.000
#> GSM11263     3  0.0336     0.9183 0.000 0.008 0.992 0.000
#> GSM11267     3  0.0336     0.9183 0.000 0.008 0.992 0.000
#> GSM28744     4  0.2011     0.4797 0.080 0.000 0.000 0.920
#> GSM28734     4  0.0817     0.5108 0.024 0.000 0.000 0.976
#> GSM28747     4  0.4972    -0.5190 0.456 0.000 0.000 0.544
#> GSM11257     1  0.4567     0.5105 0.716 0.000 0.008 0.276
#> GSM11252     4  0.0188     0.5164 0.004 0.000 0.000 0.996
#> GSM11264     3  0.0336     0.9183 0.000 0.008 0.992 0.000
#> GSM11247     3  0.1042     0.9144 0.020 0.008 0.972 0.000
#> GSM11258     4  0.4713    -0.0794 0.360 0.000 0.000 0.640
#> GSM28728     1  0.4972     0.6303 0.544 0.000 0.000 0.456
#> GSM28746     4  0.4277     0.0923 0.280 0.000 0.000 0.720
#> GSM28738     1  0.4567     0.5105 0.716 0.000 0.008 0.276
#> GSM28741     1  0.4663     0.3393 0.716 0.012 0.000 0.272
#> GSM28729     1  0.4967     0.6298 0.548 0.000 0.000 0.452
#> GSM28742     4  0.4134     0.3604 0.260 0.000 0.000 0.740
#> GSM11250     2  0.0921     0.9772 0.028 0.972 0.000 0.000
#> GSM11245     4  0.0188     0.5164 0.004 0.000 0.000 0.996
#> GSM11246     4  0.4961    -0.5118 0.448 0.000 0.000 0.552
#> GSM11261     4  0.4228     0.3651 0.232 0.008 0.000 0.760
#> GSM11248     4  0.1118     0.5047 0.036 0.000 0.000 0.964
#> GSM28732     4  0.4907     0.2450 0.420 0.000 0.000 0.580
#> GSM11255     4  0.0000     0.5160 0.000 0.000 0.000 1.000
#> GSM28731     1  0.4941     0.6382 0.564 0.000 0.000 0.436
#> GSM28727     4  0.4981    -0.5364 0.464 0.000 0.000 0.536
#> GSM11251     1  0.4981     0.6386 0.536 0.000 0.000 0.464

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2   p3    p4    p5
#> GSM28735     5  0.4356      0.843 0.340 0.000 0.00 0.012 0.648
#> GSM28736     5  0.4367      0.825 0.372 0.000 0.00 0.008 0.620
#> GSM28737     1  0.0324      0.725 0.992 0.000 0.00 0.004 0.004
#> GSM11249     4  0.3318      0.576 0.000 0.000 0.18 0.808 0.012
#> GSM28745     2  0.0162      0.978 0.000 0.996 0.00 0.004 0.000
#> GSM11244     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM28748     2  0.2569      0.917 0.000 0.892 0.00 0.040 0.068
#> GSM11266     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM28730     2  0.0162      0.978 0.000 0.996 0.00 0.004 0.000
#> GSM11253     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM11254     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM11260     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM28733     2  0.0000      0.979 0.000 1.000 0.00 0.000 0.000
#> GSM11265     1  0.5102      0.549 0.696 0.000 0.00 0.176 0.128
#> GSM28739     1  0.5064      0.528 0.680 0.000 0.00 0.232 0.088
#> GSM11243     3  0.1661      0.965 0.000 0.000 0.94 0.024 0.036
#> GSM28740     1  0.0162      0.728 0.996 0.000 0.00 0.004 0.000
#> GSM11259     1  0.1638      0.716 0.932 0.000 0.00 0.004 0.064
#> GSM28726     5  0.4283      0.845 0.348 0.000 0.00 0.008 0.644
#> GSM28743     1  0.0566      0.730 0.984 0.000 0.00 0.004 0.012
#> GSM11256     1  0.5238      0.442 0.652 0.000 0.00 0.088 0.260
#> GSM11262     1  0.0324      0.727 0.992 0.000 0.00 0.004 0.004
#> GSM28724     1  0.3409      0.682 0.836 0.000 0.00 0.052 0.112
#> GSM28725     3  0.0000      0.983 0.000 0.000 1.00 0.000 0.000
#> GSM11263     3  0.0000      0.983 0.000 0.000 1.00 0.000 0.000
#> GSM11267     3  0.0000      0.983 0.000 0.000 1.00 0.000 0.000
#> GSM28744     4  0.5195      0.745 0.216 0.000 0.00 0.676 0.108
#> GSM28734     4  0.3074      0.821 0.196 0.000 0.00 0.804 0.000
#> GSM28747     1  0.3318      0.617 0.800 0.000 0.00 0.008 0.192
#> GSM11257     1  0.5758      0.376 0.600 0.000 0.00 0.132 0.268
#> GSM11252     4  0.4847      0.793 0.240 0.000 0.00 0.692 0.068
#> GSM11264     3  0.0000      0.983 0.000 0.000 1.00 0.000 0.000
#> GSM11247     3  0.1661      0.965 0.000 0.000 0.94 0.024 0.036
#> GSM11258     1  0.3769      0.635 0.788 0.000 0.00 0.180 0.032
#> GSM28728     1  0.3991      0.651 0.780 0.000 0.00 0.048 0.172
#> GSM28746     1  0.4335      0.622 0.760 0.000 0.00 0.168 0.072
#> GSM28738     1  0.5758      0.376 0.600 0.000 0.00 0.132 0.268
#> GSM28741     5  0.4949      0.782 0.296 0.004 0.00 0.044 0.656
#> GSM28729     1  0.3882      0.651 0.788 0.000 0.00 0.044 0.168
#> GSM28742     5  0.5555      0.568 0.140 0.000 0.00 0.220 0.640
#> GSM11250     2  0.2554      0.916 0.000 0.892 0.00 0.036 0.072
#> GSM11245     4  0.4847      0.793 0.240 0.000 0.00 0.692 0.068
#> GSM11246     1  0.3413      0.676 0.832 0.000 0.00 0.044 0.124
#> GSM11261     4  0.3565      0.631 0.024 0.000 0.00 0.800 0.176
#> GSM11248     4  0.3074      0.821 0.196 0.000 0.00 0.804 0.000
#> GSM28732     5  0.5002      0.830 0.312 0.000 0.00 0.052 0.636
#> GSM11255     4  0.4465      0.818 0.204 0.000 0.00 0.736 0.060
#> GSM28731     1  0.2139      0.689 0.916 0.000 0.00 0.032 0.052
#> GSM28727     1  0.3246      0.623 0.808 0.000 0.00 0.008 0.184
#> GSM11251     1  0.1043      0.721 0.960 0.000 0.00 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.2848    0.87723 0.176 0.000 0.000 0.000 0.816 0.008
#> GSM28736     5  0.2913    0.87406 0.180 0.000 0.000 0.004 0.812 0.004
#> GSM28737     1  0.1471    0.74985 0.932 0.000 0.000 0.064 0.004 0.000
#> GSM11249     6  0.1832    0.78553 0.000 0.000 0.032 0.032 0.008 0.928
#> GSM28745     2  0.0291    0.95072 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM11244     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.4128    0.80178 0.000 0.764 0.000 0.164 0.044 0.028
#> GSM11266     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0717    0.94392 0.000 0.976 0.000 0.016 0.000 0.008
#> GSM11253     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000    0.95307 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3225    0.74428 0.828 0.000 0.000 0.000 0.080 0.092
#> GSM28739     1  0.3439    0.72780 0.808 0.000 0.000 0.000 0.072 0.120
#> GSM11243     3  0.2537    0.91802 0.000 0.000 0.872 0.096 0.032 0.000
#> GSM28740     1  0.0937    0.76843 0.960 0.000 0.000 0.040 0.000 0.000
#> GSM11259     1  0.1434    0.75909 0.940 0.000 0.000 0.048 0.012 0.000
#> GSM28726     5  0.2320    0.87368 0.132 0.000 0.000 0.000 0.864 0.004
#> GSM28743     1  0.0603    0.77815 0.980 0.000 0.000 0.016 0.000 0.004
#> GSM11256     4  0.4470    0.94165 0.268 0.000 0.000 0.680 0.036 0.016
#> GSM11262     1  0.1267    0.75581 0.940 0.000 0.000 0.060 0.000 0.000
#> GSM28724     1  0.2106    0.78468 0.904 0.000 0.000 0.000 0.064 0.032
#> GSM28725     3  0.0000    0.96000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000    0.96000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000    0.96000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     6  0.6320    0.48201 0.116 0.000 0.000 0.216 0.100 0.568
#> GSM28734     6  0.0972    0.83096 0.028 0.000 0.000 0.000 0.008 0.964
#> GSM28747     1  0.2112    0.77728 0.896 0.000 0.000 0.000 0.088 0.016
#> GSM11257     4  0.3831    0.97131 0.268 0.000 0.000 0.712 0.012 0.008
#> GSM11252     6  0.3608    0.78059 0.148 0.000 0.000 0.000 0.064 0.788
#> GSM11264     3  0.0000    0.96000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.2537    0.91802 0.000 0.000 0.872 0.096 0.032 0.000
#> GSM11258     1  0.2587    0.74913 0.868 0.000 0.000 0.004 0.020 0.108
#> GSM28728     1  0.6202   -0.00471 0.508 0.000 0.000 0.256 0.212 0.024
#> GSM28746     1  0.3206    0.74453 0.828 0.000 0.000 0.000 0.068 0.104
#> GSM28738     4  0.3831    0.97131 0.268 0.000 0.000 0.712 0.012 0.008
#> GSM28741     5  0.4785    0.73038 0.120 0.000 0.000 0.148 0.712 0.020
#> GSM28729     1  0.6217   -0.01617 0.504 0.000 0.000 0.260 0.212 0.024
#> GSM28742     5  0.2333    0.80875 0.040 0.000 0.000 0.004 0.896 0.060
#> GSM11250     2  0.3930    0.80916 0.000 0.780 0.000 0.148 0.056 0.016
#> GSM11245     6  0.3608    0.78059 0.148 0.000 0.000 0.000 0.064 0.788
#> GSM11246     1  0.2066    0.78357 0.904 0.000 0.000 0.000 0.072 0.024
#> GSM11261     6  0.1606    0.79912 0.004 0.000 0.000 0.008 0.056 0.932
#> GSM11248     6  0.0858    0.82834 0.028 0.000 0.000 0.004 0.000 0.968
#> GSM28732     5  0.3102    0.86890 0.156 0.000 0.000 0.000 0.816 0.028
#> GSM11255     6  0.2786    0.82035 0.084 0.000 0.000 0.000 0.056 0.860
#> GSM28731     1  0.3834    0.47399 0.748 0.000 0.000 0.216 0.028 0.008
#> GSM28727     1  0.1812    0.77998 0.912 0.000 0.000 0.000 0.080 0.008
#> GSM11251     1  0.0935    0.77155 0.964 0.000 0.000 0.032 0.004 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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 tissue(p) k
#> ATC:kmeans 41     0.383 2
#> ATC:kmeans 50     0.370 3
#> ATC:kmeans 33     0.316 4
#> ATC:kmeans 47     0.404 5
#> ATC:kmeans 46     0.474 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 21342 rows and 50 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 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-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.979       0.986         0.4743 0.519   0.519
#> 3 3 1.000           0.981       0.992         0.3176 0.784   0.610
#> 4 4 0.738           0.591       0.814         0.1768 0.932   0.820
#> 5 5 0.794           0.529       0.744         0.0757 0.864   0.589
#> 6 6 0.878           0.849       0.915         0.0483 0.924   0.674

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1   0.000      0.996 1.000 0.000
#> GSM28736     1   0.184      0.969 0.972 0.028
#> GSM28737     1   0.000      0.996 1.000 0.000
#> GSM11249     1   0.000      0.996 1.000 0.000
#> GSM28745     2   0.000      0.967 0.000 1.000
#> GSM11244     2   0.000      0.967 0.000 1.000
#> GSM28748     2   0.000      0.967 0.000 1.000
#> GSM11266     2   0.000      0.967 0.000 1.000
#> GSM28730     2   0.000      0.967 0.000 1.000
#> GSM11253     2   0.000      0.967 0.000 1.000
#> GSM11254     2   0.000      0.967 0.000 1.000
#> GSM11260     2   0.000      0.967 0.000 1.000
#> GSM28733     2   0.000      0.967 0.000 1.000
#> GSM11265     1   0.000      0.996 1.000 0.000
#> GSM28739     1   0.000      0.996 1.000 0.000
#> GSM11243     2   0.416      0.941 0.084 0.916
#> GSM28740     1   0.000      0.996 1.000 0.000
#> GSM11259     1   0.000      0.996 1.000 0.000
#> GSM28726     1   0.443      0.902 0.908 0.092
#> GSM28743     1   0.000      0.996 1.000 0.000
#> GSM11256     1   0.000      0.996 1.000 0.000
#> GSM11262     1   0.000      0.996 1.000 0.000
#> GSM28724     1   0.000      0.996 1.000 0.000
#> GSM28725     2   0.416      0.941 0.084 0.916
#> GSM11263     2   0.416      0.941 0.084 0.916
#> GSM11267     2   0.416      0.941 0.084 0.916
#> GSM28744     1   0.000      0.996 1.000 0.000
#> GSM28734     1   0.000      0.996 1.000 0.000
#> GSM28747     1   0.000      0.996 1.000 0.000
#> GSM11257     1   0.000      0.996 1.000 0.000
#> GSM11252     1   0.000      0.996 1.000 0.000
#> GSM11264     2   0.416      0.941 0.084 0.916
#> GSM11247     2   0.416      0.941 0.084 0.916
#> GSM11258     1   0.000      0.996 1.000 0.000
#> GSM28728     1   0.000      0.996 1.000 0.000
#> GSM28746     1   0.000      0.996 1.000 0.000
#> GSM28738     1   0.000      0.996 1.000 0.000
#> GSM28741     2   0.000      0.967 0.000 1.000
#> GSM28729     1   0.000      0.996 1.000 0.000
#> GSM28742     2   0.278      0.956 0.048 0.952
#> GSM11250     2   0.000      0.967 0.000 1.000
#> GSM11245     1   0.000      0.996 1.000 0.000
#> GSM11246     1   0.000      0.996 1.000 0.000
#> GSM11261     2   0.278      0.956 0.048 0.952
#> GSM11248     1   0.000      0.996 1.000 0.000
#> GSM28732     1   0.000      0.996 1.000 0.000
#> GSM11255     1   0.000      0.996 1.000 0.000
#> GSM28731     1   0.000      0.996 1.000 0.000
#> GSM28727     1   0.000      0.996 1.000 0.000
#> GSM11251     1   0.000      0.996 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
#> GSM28735     1   0.000      0.996 1.000 0.000 0.000
#> GSM28736     1   0.000      0.996 1.000 0.000 0.000
#> GSM28737     1   0.000      0.996 1.000 0.000 0.000
#> GSM11249     3   0.000      0.997 0.000 0.000 1.000
#> GSM28745     2   0.000      0.969 0.000 1.000 0.000
#> GSM11244     2   0.000      0.969 0.000 1.000 0.000
#> GSM28748     2   0.000      0.969 0.000 1.000 0.000
#> GSM11266     2   0.000      0.969 0.000 1.000 0.000
#> GSM28730     2   0.000      0.969 0.000 1.000 0.000
#> GSM11253     2   0.000      0.969 0.000 1.000 0.000
#> GSM11254     2   0.000      0.969 0.000 1.000 0.000
#> GSM11260     2   0.000      0.969 0.000 1.000 0.000
#> GSM28733     2   0.000      0.969 0.000 1.000 0.000
#> GSM11265     1   0.000      0.996 1.000 0.000 0.000
#> GSM28739     1   0.000      0.996 1.000 0.000 0.000
#> GSM11243     3   0.000      0.997 0.000 0.000 1.000
#> GSM28740     1   0.000      0.996 1.000 0.000 0.000
#> GSM11259     1   0.000      0.996 1.000 0.000 0.000
#> GSM28726     2   0.529      0.632 0.268 0.732 0.000
#> GSM28743     1   0.000      0.996 1.000 0.000 0.000
#> GSM11256     1   0.000      0.996 1.000 0.000 0.000
#> GSM11262     1   0.000      0.996 1.000 0.000 0.000
#> GSM28724     1   0.000      0.996 1.000 0.000 0.000
#> GSM28725     3   0.000      0.997 0.000 0.000 1.000
#> GSM11263     3   0.000      0.997 0.000 0.000 1.000
#> GSM11267     3   0.000      0.997 0.000 0.000 1.000
#> GSM28744     1   0.000      0.996 1.000 0.000 0.000
#> GSM28734     3   0.000      0.997 0.000 0.000 1.000
#> GSM28747     1   0.000      0.996 1.000 0.000 0.000
#> GSM11257     1   0.000      0.996 1.000 0.000 0.000
#> GSM11252     1   0.164      0.956 0.956 0.000 0.044
#> GSM11264     3   0.000      0.997 0.000 0.000 1.000
#> GSM11247     3   0.000      0.997 0.000 0.000 1.000
#> GSM11258     1   0.000      0.996 1.000 0.000 0.000
#> GSM28728     1   0.000      0.996 1.000 0.000 0.000
#> GSM28746     1   0.000      0.996 1.000 0.000 0.000
#> GSM28738     1   0.000      0.996 1.000 0.000 0.000
#> GSM28741     2   0.000      0.969 0.000 1.000 0.000
#> GSM28729     1   0.000      0.996 1.000 0.000 0.000
#> GSM28742     3   0.116      0.970 0.000 0.028 0.972
#> GSM11250     2   0.000      0.969 0.000 1.000 0.000
#> GSM11245     1   0.164      0.956 0.956 0.000 0.044
#> GSM11246     1   0.000      0.996 1.000 0.000 0.000
#> GSM11261     3   0.000      0.997 0.000 0.000 1.000
#> GSM11248     3   0.000      0.997 0.000 0.000 1.000
#> GSM28732     1   0.000      0.996 1.000 0.000 0.000
#> GSM11255     3   0.000      0.997 0.000 0.000 1.000
#> GSM28731     1   0.000      0.996 1.000 0.000 0.000
#> GSM28727     1   0.000      0.996 1.000 0.000 0.000
#> GSM11251     1   0.000      0.996 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
#> GSM28735     4  0.4331    0.71220 0.288 0.000 0.000 0.712
#> GSM28736     4  0.4331    0.71220 0.288 0.000 0.000 0.712
#> GSM28737     1  0.3123    0.45285 0.844 0.000 0.000 0.156
#> GSM11249     3  0.0188    0.86619 0.000 0.000 0.996 0.004
#> GSM28745     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11265     1  0.4304    0.44529 0.716 0.000 0.000 0.284
#> GSM28739     1  0.4304    0.44529 0.716 0.000 0.000 0.284
#> GSM11243     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM28740     1  0.2149    0.51061 0.912 0.000 0.000 0.088
#> GSM11259     1  0.3907    0.35032 0.768 0.000 0.000 0.232
#> GSM28726     4  0.5990    0.66746 0.284 0.072 0.000 0.644
#> GSM28743     1  0.0336    0.54025 0.992 0.000 0.000 0.008
#> GSM11256     1  0.4888   -0.04750 0.588 0.000 0.000 0.412
#> GSM11262     1  0.2216    0.50816 0.908 0.000 0.000 0.092
#> GSM28724     1  0.0469    0.54162 0.988 0.000 0.000 0.012
#> GSM28725     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM28744     4  0.4222    0.02909 0.272 0.000 0.000 0.728
#> GSM28734     3  0.6750    0.55273 0.128 0.000 0.584 0.288
#> GSM28747     1  0.0336    0.54157 0.992 0.000 0.000 0.008
#> GSM11257     1  0.4790    0.05263 0.620 0.000 0.000 0.380
#> GSM11252     1  0.6307    0.36346 0.620 0.000 0.092 0.288
#> GSM11264     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM11247     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM11258     1  0.4304    0.44529 0.716 0.000 0.000 0.284
#> GSM28728     1  0.4961   -0.16530 0.552 0.000 0.000 0.448
#> GSM28746     1  0.4304    0.44529 0.716 0.000 0.000 0.284
#> GSM28738     1  0.4843    0.00515 0.604 0.000 0.000 0.396
#> GSM28741     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM28729     1  0.4961   -0.16530 0.552 0.000 0.000 0.448
#> GSM28742     3  0.4800    0.51818 0.000 0.004 0.656 0.340
#> GSM11250     2  0.0000    1.00000 0.000 1.000 0.000 0.000
#> GSM11245     1  0.6307    0.36346 0.620 0.000 0.092 0.288
#> GSM11246     1  0.1716    0.52714 0.936 0.000 0.000 0.064
#> GSM11261     3  0.0000    0.86765 0.000 0.000 1.000 0.000
#> GSM11248     3  0.3764    0.73593 0.000 0.000 0.784 0.216
#> GSM28732     1  0.4985   -0.14567 0.532 0.000 0.000 0.468
#> GSM11255     3  0.6835    0.54268 0.136 0.000 0.576 0.288
#> GSM28731     1  0.4746    0.08338 0.632 0.000 0.000 0.368
#> GSM28727     1  0.0000    0.54133 1.000 0.000 0.000 0.000
#> GSM11251     1  0.2814    0.47625 0.868 0.000 0.000 0.132

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.4774     0.4489 0.028 0.000 0.360 0.000 0.612
#> GSM28736     5  0.4774     0.4541 0.028 0.000 0.360 0.000 0.612
#> GSM28737     1  0.0609     0.6451 0.980 0.000 0.000 0.000 0.020
#> GSM11249     4  0.4291    -0.5667 0.000 0.000 0.464 0.536 0.000
#> GSM28745     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.4403     0.2924 0.560 0.000 0.000 0.436 0.004
#> GSM28739     1  0.4268     0.2850 0.556 0.000 0.000 0.444 0.000
#> GSM11243     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM28740     1  0.0404     0.6495 0.988 0.000 0.000 0.000 0.012
#> GSM11259     1  0.2068     0.5872 0.904 0.000 0.004 0.000 0.092
#> GSM28726     5  0.5616     0.4374 0.040 0.024 0.360 0.000 0.576
#> GSM28743     1  0.1478     0.6684 0.936 0.000 0.000 0.064 0.000
#> GSM11256     5  0.4557     0.0349 0.476 0.000 0.000 0.008 0.516
#> GSM11262     1  0.0693     0.6569 0.980 0.000 0.000 0.012 0.008
#> GSM28724     1  0.1671     0.6689 0.924 0.000 0.000 0.076 0.000
#> GSM28725     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM11263     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM11267     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM28744     5  0.5992     0.0446 0.112 0.000 0.000 0.416 0.472
#> GSM28734     4  0.0324     0.4821 0.004 0.000 0.004 0.992 0.000
#> GSM28747     1  0.3099     0.6510 0.848 0.000 0.000 0.124 0.028
#> GSM11257     1  0.4304    -0.1161 0.516 0.000 0.000 0.000 0.484
#> GSM11252     4  0.4232     0.2212 0.312 0.000 0.000 0.676 0.012
#> GSM11264     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM11247     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM11258     1  0.4262     0.2927 0.560 0.000 0.000 0.440 0.000
#> GSM28728     5  0.4622     0.1079 0.440 0.000 0.000 0.012 0.548
#> GSM28746     1  0.4410     0.2905 0.556 0.000 0.000 0.440 0.004
#> GSM28738     1  0.4307    -0.1436 0.504 0.000 0.000 0.000 0.496
#> GSM28741     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28729     5  0.4617     0.1139 0.436 0.000 0.000 0.012 0.552
#> GSM28742     3  0.4294    -0.3896 0.000 0.000 0.532 0.000 0.468
#> GSM11250     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11245     4  0.4127     0.2266 0.312 0.000 0.000 0.680 0.008
#> GSM11246     1  0.3011     0.6482 0.844 0.000 0.000 0.140 0.016
#> GSM11261     3  0.4060     0.8110 0.000 0.000 0.640 0.360 0.000
#> GSM11248     4  0.3636    -0.0639 0.000 0.000 0.272 0.728 0.000
#> GSM28732     5  0.5912     0.4240 0.088 0.000 0.360 0.008 0.544
#> GSM11255     4  0.0290     0.4879 0.008 0.000 0.000 0.992 0.000
#> GSM28731     1  0.4297    -0.0934 0.528 0.000 0.000 0.000 0.472
#> GSM28727     1  0.2511     0.6619 0.892 0.000 0.000 0.080 0.028
#> GSM11251     1  0.0510     0.6516 0.984 0.000 0.000 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM28735     5  0.1262      0.938 0.016  0 0.000 0.020 0.956 0.008
#> GSM28736     5  0.2425      0.892 0.012  0 0.000 0.100 0.880 0.008
#> GSM28737     1  0.2378      0.766 0.848  0 0.000 0.152 0.000 0.000
#> GSM11249     3  0.3695      0.330 0.000  0 0.624 0.000 0.000 0.376
#> GSM28745     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11265     1  0.3665      0.611 0.696  0 0.000 0.004 0.004 0.296
#> GSM28739     1  0.3756      0.545 0.644  0 0.000 0.004 0.000 0.352
#> GSM11243     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM28740     1  0.2191      0.793 0.876  0 0.000 0.120 0.000 0.004
#> GSM11259     1  0.3023      0.693 0.784  0 0.000 0.212 0.004 0.000
#> GSM28726     5  0.0622      0.936 0.000  0 0.000 0.012 0.980 0.008
#> GSM28743     1  0.1141      0.817 0.948  0 0.000 0.052 0.000 0.000
#> GSM11256     4  0.0713      0.878 0.028  0 0.000 0.972 0.000 0.000
#> GSM11262     1  0.1663      0.808 0.912  0 0.000 0.088 0.000 0.000
#> GSM28724     1  0.1461      0.820 0.940  0 0.000 0.044 0.000 0.016
#> GSM28725     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM28744     4  0.3468      0.548 0.000  0 0.000 0.712 0.004 0.284
#> GSM28734     6  0.1138      0.884 0.012  0 0.024 0.004 0.000 0.960
#> GSM28747     1  0.1251      0.815 0.956  0 0.000 0.012 0.008 0.024
#> GSM11257     4  0.1970      0.868 0.092  0 0.000 0.900 0.000 0.008
#> GSM11252     6  0.0777      0.887 0.024  0 0.004 0.000 0.000 0.972
#> GSM11264     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM11247     3  0.0000      0.939 0.000  0 1.000 0.000 0.000 0.000
#> GSM11258     1  0.4264      0.578 0.636  0 0.000 0.032 0.000 0.332
#> GSM28728     4  0.1421      0.871 0.028  0 0.000 0.944 0.028 0.000
#> GSM28746     1  0.3861      0.543 0.640  0 0.000 0.008 0.000 0.352
#> GSM28738     4  0.1812      0.874 0.080  0 0.000 0.912 0.000 0.008
#> GSM28741     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM28729     4  0.1572      0.873 0.036  0 0.000 0.936 0.028 0.000
#> GSM28742     5  0.1409      0.923 0.000  0 0.032 0.012 0.948 0.008
#> GSM11250     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM11245     6  0.0777      0.887 0.024  0 0.004 0.000 0.000 0.972
#> GSM11246     1  0.1194      0.812 0.956  0 0.000 0.008 0.004 0.032
#> GSM11261     3  0.0146      0.936 0.000  0 0.996 0.000 0.000 0.004
#> GSM11248     6  0.3601      0.471 0.000  0 0.312 0.004 0.000 0.684
#> GSM28732     5  0.2002      0.924 0.040  0 0.000 0.012 0.920 0.028
#> GSM11255     6  0.0914      0.889 0.016  0 0.016 0.000 0.000 0.968
#> GSM28731     4  0.2527      0.800 0.168  0 0.000 0.832 0.000 0.000
#> GSM28727     1  0.1092      0.814 0.960  0 0.000 0.020 0.020 0.000
#> GSM11251     1  0.2020      0.802 0.896  0 0.000 0.096 0.008 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 tissue(p) k
#> ATC:skmeans 50     0.394 2
#> ATC:skmeans 50     0.370 3
#> ATC:skmeans 33     0.397 4
#> ATC:skmeans 28     0.400 5
#> ATC:skmeans 48     0.399 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 21342 rows and 50 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 1.000           1.000       1.000         0.3272 0.673   0.673
#> 3 3 1.000           1.000       1.000         0.5084 0.833   0.753
#> 4 4 0.804           0.922       0.954         0.1605 0.948   0.897
#> 5 5 0.831           0.948       0.972         0.2292 0.843   0.655
#> 6 6 0.811           0.942       0.965         0.0123 0.993   0.978

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

suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2

There is also optional best \(k\) = 2 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM28735     1       0          1  1  0
#> GSM28736     1       0          1  1  0
#> GSM28737     1       0          1  1  0
#> GSM11249     1       0          1  1  0
#> GSM28745     2       0          1  0  1
#> GSM11244     2       0          1  0  1
#> GSM28748     2       0          1  0  1
#> GSM11266     2       0          1  0  1
#> GSM28730     2       0          1  0  1
#> GSM11253     2       0          1  0  1
#> GSM11254     2       0          1  0  1
#> GSM11260     2       0          1  0  1
#> GSM28733     2       0          1  0  1
#> GSM11265     1       0          1  1  0
#> GSM28739     1       0          1  1  0
#> GSM11243     1       0          1  1  0
#> GSM28740     1       0          1  1  0
#> GSM11259     1       0          1  1  0
#> GSM28726     1       0          1  1  0
#> GSM28743     1       0          1  1  0
#> GSM11256     1       0          1  1  0
#> GSM11262     1       0          1  1  0
#> GSM28724     1       0          1  1  0
#> GSM28725     1       0          1  1  0
#> GSM11263     1       0          1  1  0
#> GSM11267     1       0          1  1  0
#> GSM28744     1       0          1  1  0
#> GSM28734     1       0          1  1  0
#> GSM28747     1       0          1  1  0
#> GSM11257     1       0          1  1  0
#> GSM11252     1       0          1  1  0
#> GSM11264     1       0          1  1  0
#> GSM11247     1       0          1  1  0
#> GSM11258     1       0          1  1  0
#> GSM28728     1       0          1  1  0
#> GSM28746     1       0          1  1  0
#> GSM28738     1       0          1  1  0
#> GSM28741     1       0          1  1  0
#> GSM28729     1       0          1  1  0
#> GSM28742     1       0          1  1  0
#> GSM11250     2       0          1  0  1
#> GSM11245     1       0          1  1  0
#> GSM11246     1       0          1  1  0
#> GSM11261     1       0          1  1  0
#> GSM11248     1       0          1  1  0
#> GSM28732     1       0          1  1  0
#> GSM11255     1       0          1  1  0
#> GSM28731     1       0          1  1  0
#> GSM28727     1       0          1  1  0
#> GSM11251     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette p1 p2 p3
#> GSM28735     1       0          1  1  0  0
#> GSM28736     1       0          1  1  0  0
#> GSM28737     1       0          1  1  0  0
#> GSM11249     1       0          1  1  0  0
#> GSM28745     2       0          1  0  1  0
#> GSM11244     2       0          1  0  1  0
#> GSM28748     2       0          1  0  1  0
#> GSM11266     2       0          1  0  1  0
#> GSM28730     2       0          1  0  1  0
#> GSM11253     2       0          1  0  1  0
#> GSM11254     2       0          1  0  1  0
#> GSM11260     2       0          1  0  1  0
#> GSM28733     2       0          1  0  1  0
#> GSM11265     1       0          1  1  0  0
#> GSM28739     1       0          1  1  0  0
#> GSM11243     3       0          1  0  0  1
#> GSM28740     1       0          1  1  0  0
#> GSM11259     1       0          1  1  0  0
#> GSM28726     1       0          1  1  0  0
#> GSM28743     1       0          1  1  0  0
#> GSM11256     1       0          1  1  0  0
#> GSM11262     1       0          1  1  0  0
#> GSM28724     1       0          1  1  0  0
#> GSM28725     3       0          1  0  0  1
#> GSM11263     3       0          1  0  0  1
#> GSM11267     3       0          1  0  0  1
#> GSM28744     1       0          1  1  0  0
#> GSM28734     1       0          1  1  0  0
#> GSM28747     1       0          1  1  0  0
#> GSM11257     1       0          1  1  0  0
#> GSM11252     1       0          1  1  0  0
#> GSM11264     3       0          1  0  0  1
#> GSM11247     3       0          1  0  0  1
#> GSM11258     1       0          1  1  0  0
#> GSM28728     1       0          1  1  0  0
#> GSM28746     1       0          1  1  0  0
#> GSM28738     1       0          1  1  0  0
#> GSM28741     1       0          1  1  0  0
#> GSM28729     1       0          1  1  0  0
#> GSM28742     1       0          1  1  0  0
#> GSM11250     2       0          1  0  1  0
#> GSM11245     1       0          1  1  0  0
#> GSM11246     1       0          1  1  0  0
#> GSM11261     1       0          1  1  0  0
#> GSM11248     1       0          1  1  0  0
#> GSM28732     1       0          1  1  0  0
#> GSM11255     1       0          1  1  0  0
#> GSM28731     1       0          1  1  0  0
#> GSM28727     1       0          1  1  0  0
#> GSM11251     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM28735     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28736     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28737     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11249     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM28745     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11244     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28748     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11266     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28730     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11253     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11254     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11260     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM28733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11265     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28739     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11243     3  0.0000      0.997 0.000  0 1.000 0.000
#> GSM28740     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11259     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28726     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28743     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11256     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11262     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28724     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28725     3  0.0000      0.997 0.000  0 1.000 0.000
#> GSM11263     3  0.0000      0.997 0.000  0 1.000 0.000
#> GSM11267     3  0.0000      0.997 0.000  0 1.000 0.000
#> GSM28744     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28734     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM28747     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11257     4  0.3907      1.000 0.232  0 0.000 0.768
#> GSM11252     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM11264     3  0.0000      0.997 0.000  0 1.000 0.000
#> GSM11247     3  0.0469      0.985 0.000  0 0.988 0.012
#> GSM11258     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28728     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28746     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28738     4  0.3907      1.000 0.232  0 0.000 0.768
#> GSM28741     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28729     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28742     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM11250     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM11245     1  0.3837      0.752 0.776  0 0.000 0.224
#> GSM11246     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11261     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM11248     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM28732     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11255     1  0.3907      0.745 0.768  0 0.000 0.232
#> GSM28731     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM28727     1  0.0000      0.923 1.000  0 0.000 0.000
#> GSM11251     1  0.0000      0.923 1.000  0 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
#> GSM28735     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28736     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28737     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM11249     4   0.000      0.871 0.000  0 0.00 1.000  0
#> GSM28745     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11244     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM28748     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11266     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM28730     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11253     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11254     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11260     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM28733     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11265     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28739     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM11243     3   0.000      0.940 0.000  0 1.00 0.000  0
#> GSM28740     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM11259     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28726     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28743     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM11256     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM11262     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM28724     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28725     3   0.000      0.940 0.000  0 1.00 0.000  0
#> GSM11263     3   0.000      0.940 0.000  0 1.00 0.000  0
#> GSM11267     3   0.000      0.940 0.000  0 1.00 0.000  0
#> GSM28744     1   0.029      0.962 0.992  0 0.00 0.008  0
#> GSM28734     4   0.000      0.871 0.000  0 0.00 1.000  0
#> GSM28747     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM11257     5   0.000      1.000 0.000  0 0.00 0.000  1
#> GSM11252     4   0.202      0.916 0.100  0 0.00 0.900  0
#> GSM11264     3   0.000      0.940 0.000  0 1.00 0.000  0
#> GSM11247     3   0.327      0.675 0.000  0 0.78 0.220  0
#> GSM11258     1   0.202      0.914 0.900  0 0.00 0.100  0
#> GSM28728     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28746     1   0.191      0.918 0.908  0 0.00 0.092  0
#> GSM28738     5   0.000      1.000 0.000  0 0.00 0.000  1
#> GSM28741     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28729     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28742     4   0.207      0.914 0.104  0 0.00 0.896  0
#> GSM11250     2   0.000      1.000 0.000  1 0.00 0.000  0
#> GSM11245     4   0.213      0.910 0.108  0 0.00 0.892  0
#> GSM11246     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM11261     4   0.179      0.916 0.084  0 0.00 0.916  0
#> GSM11248     4   0.000      0.871 0.000  0 0.00 1.000  0
#> GSM28732     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM11255     4   0.202      0.916 0.100  0 0.00 0.900  0
#> GSM28731     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM28727     1   0.000      0.966 1.000  0 0.00 0.000  0
#> GSM11251     1   0.000      0.966 1.000  0 0.00 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4 p5    p6
#> GSM28735     1  0.0260      0.948 0.992  0 0.000 0.008  0 0.000
#> GSM28736     1  0.0260      0.948 0.992  0 0.000 0.008  0 0.000
#> GSM28737     1  0.2260      0.875 0.860  0 0.000 0.000  0 0.140
#> GSM11249     6  0.0000      0.819 0.000  0 0.000 0.000  0 1.000
#> GSM28745     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11244     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM28748     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11266     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM28730     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11253     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11254     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11260     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM28733     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11265     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28739     1  0.2260      0.875 0.860  0 0.000 0.000  0 0.140
#> GSM11243     4  0.0260      1.000 0.000  0 0.008 0.992  0 0.000
#> GSM28740     1  0.2260      0.875 0.860  0 0.000 0.000  0 0.140
#> GSM11259     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28726     1  0.0260      0.948 0.992  0 0.000 0.008  0 0.000
#> GSM28743     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM11256     1  0.2402      0.874 0.856  0 0.000 0.004  0 0.140
#> GSM11262     1  0.2260      0.875 0.860  0 0.000 0.000  0 0.140
#> GSM28724     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28725     3  0.0000      1.000 0.000  0 1.000 0.000  0 0.000
#> GSM11263     3  0.0000      1.000 0.000  0 1.000 0.000  0 0.000
#> GSM11267     3  0.0000      1.000 0.000  0 1.000 0.000  0 0.000
#> GSM28744     1  0.0363      0.946 0.988  0 0.000 0.000  0 0.012
#> GSM28734     6  0.0146      0.819 0.004  0 0.000 0.000  0 0.996
#> GSM28747     1  0.0146      0.949 0.996  0 0.000 0.004  0 0.000
#> GSM11257     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM11252     6  0.2260      0.880 0.140  0 0.000 0.000  0 0.860
#> GSM11264     3  0.0000      1.000 0.000  0 1.000 0.000  0 0.000
#> GSM11247     4  0.0260      1.000 0.000  0 0.008 0.992  0 0.000
#> GSM11258     1  0.2260      0.875 0.860  0 0.000 0.000  0 0.140
#> GSM28728     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28746     1  0.2178      0.881 0.868  0 0.000 0.000  0 0.132
#> GSM28738     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM28741     1  0.0260      0.948 0.992  0 0.000 0.008  0 0.000
#> GSM28729     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28742     6  0.2442      0.876 0.144  0 0.000 0.004  0 0.852
#> GSM11250     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM11245     6  0.2340      0.874 0.148  0 0.000 0.000  0 0.852
#> GSM11246     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM11261     6  0.1910      0.879 0.108  0 0.000 0.000  0 0.892
#> GSM11248     6  0.0000      0.819 0.000  0 0.000 0.000  0 1.000
#> GSM28732     1  0.0146      0.949 0.996  0 0.000 0.004  0 0.000
#> GSM11255     6  0.2260      0.880 0.140  0 0.000 0.000  0 0.860
#> GSM28731     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM28727     1  0.0000      0.950 1.000  0 0.000 0.000  0 0.000
#> GSM11251     1  0.0000      0.950 1.000  0 0.000 0.000  0 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 tissue(p) k
#> ATC:pam 50     0.394 2
#> ATC:pam 50     0.370 3
#> ATC:pam 50     0.349 4
#> ATC:pam 50     0.331 5
#> ATC:pam 50     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.


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 21342 rows and 50 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 1.000           0.991       0.995         0.4678 0.530   0.530
#> 3 3 0.771           0.813       0.919         0.2633 0.776   0.610
#> 4 4 0.661           0.690       0.854         0.0894 0.848   0.664
#> 5 5 0.695           0.677       0.849         0.1334 0.883   0.686
#> 6 6 0.862           0.819       0.895         0.0592 0.916   0.715

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

suggest_best_k(res)
#> [1] 2

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM28735     1  0.0000      0.999 1.000 0.000
#> GSM28736     1  0.0672      0.992 0.992 0.008
#> GSM28737     1  0.0000      0.999 1.000 0.000
#> GSM11249     1  0.0000      0.999 1.000 0.000
#> GSM28745     2  0.0000      0.986 0.000 1.000
#> GSM11244     2  0.0000      0.986 0.000 1.000
#> GSM28748     2  0.0000      0.986 0.000 1.000
#> GSM11266     2  0.0000      0.986 0.000 1.000
#> GSM28730     2  0.0000      0.986 0.000 1.000
#> GSM11253     2  0.0000      0.986 0.000 1.000
#> GSM11254     2  0.0000      0.986 0.000 1.000
#> GSM11260     2  0.0000      0.986 0.000 1.000
#> GSM28733     2  0.0000      0.986 0.000 1.000
#> GSM11265     1  0.0000      0.999 1.000 0.000
#> GSM28739     1  0.0000      0.999 1.000 0.000
#> GSM11243     2  0.0672      0.984 0.008 0.992
#> GSM28740     1  0.0000      0.999 1.000 0.000
#> GSM11259     1  0.0000      0.999 1.000 0.000
#> GSM28726     1  0.0672      0.992 0.992 0.008
#> GSM28743     1  0.0000      0.999 1.000 0.000
#> GSM11256     1  0.0000      0.999 1.000 0.000
#> GSM11262     1  0.0000      0.999 1.000 0.000
#> GSM28724     1  0.0000      0.999 1.000 0.000
#> GSM28725     2  0.0672      0.984 0.008 0.992
#> GSM11263     2  0.0672      0.984 0.008 0.992
#> GSM11267     2  0.0672      0.984 0.008 0.992
#> GSM28744     1  0.0000      0.999 1.000 0.000
#> GSM28734     1  0.0000      0.999 1.000 0.000
#> GSM28747     1  0.0000      0.999 1.000 0.000
#> GSM11257     1  0.0000      0.999 1.000 0.000
#> GSM11252     1  0.0000      0.999 1.000 0.000
#> GSM11264     2  0.0672      0.984 0.008 0.992
#> GSM11247     2  0.0672      0.984 0.008 0.992
#> GSM11258     1  0.0000      0.999 1.000 0.000
#> GSM28728     1  0.0000      0.999 1.000 0.000
#> GSM28746     1  0.0000      0.999 1.000 0.000
#> GSM28738     1  0.0000      0.999 1.000 0.000
#> GSM28741     2  0.4562      0.902 0.096 0.904
#> GSM28729     1  0.0000      0.999 1.000 0.000
#> GSM28742     1  0.0000      0.999 1.000 0.000
#> GSM11250     2  0.0000      0.986 0.000 1.000
#> GSM11245     1  0.0000      0.999 1.000 0.000
#> GSM11246     1  0.0000      0.999 1.000 0.000
#> GSM11261     2  0.4562      0.902 0.096 0.904
#> GSM11248     1  0.0000      0.999 1.000 0.000
#> GSM28732     1  0.0000      0.999 1.000 0.000
#> GSM11255     1  0.0000      0.999 1.000 0.000
#> GSM28731     1  0.0000      0.999 1.000 0.000
#> GSM28727     1  0.0000      0.999 1.000 0.000
#> GSM11251     1  0.0000      0.999 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
#> GSM28735     1  0.0829     0.9188 0.984 0.004 0.012
#> GSM28736     1  0.5746     0.6740 0.780 0.180 0.040
#> GSM28737     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11249     3  0.5785     0.6502 0.332 0.000 0.668
#> GSM28745     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM11244     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM28748     2  0.0237     0.9491 0.000 0.996 0.004
#> GSM11266     2  0.0237     0.9491 0.000 0.996 0.004
#> GSM28730     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM11253     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM11254     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM11260     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM28733     2  0.0000     0.9506 0.000 1.000 0.000
#> GSM11265     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28739     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11243     3  0.3752     0.6029 0.000 0.144 0.856
#> GSM28740     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11259     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28726     1  0.6603     0.4433 0.648 0.020 0.332
#> GSM28743     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11256     3  0.6280     0.4188 0.460 0.000 0.540
#> GSM11262     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28724     1  0.0592     0.9203 0.988 0.000 0.012
#> GSM28725     3  0.0000     0.7039 0.000 0.000 1.000
#> GSM11263     3  0.0000     0.7039 0.000 0.000 1.000
#> GSM11267     3  0.0000     0.7039 0.000 0.000 1.000
#> GSM28744     1  0.0892     0.9132 0.980 0.000 0.020
#> GSM28734     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28747     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11257     3  0.5882     0.6343 0.348 0.000 0.652
#> GSM11252     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11264     3  0.0000     0.7039 0.000 0.000 1.000
#> GSM11247     3  0.3879     0.5939 0.000 0.152 0.848
#> GSM11258     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28728     1  0.0592     0.9203 0.988 0.000 0.012
#> GSM28746     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28738     3  0.5882     0.6343 0.348 0.000 0.652
#> GSM28741     2  0.5760     0.4422 0.328 0.672 0.000
#> GSM28729     1  0.0592     0.9203 0.988 0.000 0.012
#> GSM28742     1  0.6057     0.4519 0.656 0.004 0.340
#> GSM11250     2  0.0237     0.9491 0.000 0.996 0.004
#> GSM11245     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11246     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11261     1  0.9792    -0.0732 0.408 0.240 0.352
#> GSM11248     3  0.5810     0.6472 0.336 0.000 0.664
#> GSM28732     1  0.0829     0.9188 0.984 0.004 0.012
#> GSM11255     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28731     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM28727     1  0.0000     0.9274 1.000 0.000 0.000
#> GSM11251     1  0.0000     0.9274 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
#> GSM28735     1  0.4804      0.196 0.616 0.000 0.000 0.384
#> GSM28736     1  0.4964      0.180 0.616 0.004 0.000 0.380
#> GSM28737     1  0.0188      0.821 0.996 0.000 0.000 0.004
#> GSM11249     1  0.7513     -0.336 0.492 0.000 0.224 0.284
#> GSM28745     2  0.0188      0.915 0.000 0.996 0.000 0.004
#> GSM11244     2  0.0000      0.915 0.000 1.000 0.000 0.000
#> GSM28748     2  0.4663      0.637 0.000 0.716 0.012 0.272
#> GSM11266     2  0.0592      0.910 0.000 0.984 0.000 0.016
#> GSM28730     2  0.0188      0.915 0.000 0.996 0.000 0.004
#> GSM11253     2  0.0000      0.915 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000      0.915 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000      0.915 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0469      0.910 0.000 0.988 0.000 0.012
#> GSM11265     1  0.1211      0.809 0.960 0.000 0.000 0.040
#> GSM28739     1  0.0000      0.822 1.000 0.000 0.000 0.000
#> GSM11243     3  0.2676      0.871 0.000 0.012 0.896 0.092
#> GSM28740     1  0.0000      0.822 1.000 0.000 0.000 0.000
#> GSM11259     1  0.0000      0.822 1.000 0.000 0.000 0.000
#> GSM28726     4  0.7909      0.312 0.420 0.080 0.060 0.440
#> GSM28743     1  0.0000      0.822 1.000 0.000 0.000 0.000
#> GSM11256     4  0.6091      0.473 0.344 0.000 0.060 0.596
#> GSM11262     1  0.0188      0.821 0.996 0.000 0.000 0.004
#> GSM28724     1  0.2973      0.695 0.856 0.000 0.000 0.144
#> GSM28725     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> GSM11263     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> GSM11267     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> GSM28744     1  0.0672      0.817 0.984 0.000 0.008 0.008
#> GSM28734     1  0.3400      0.554 0.820 0.000 0.000 0.180
#> GSM28747     1  0.1389      0.798 0.952 0.000 0.000 0.048
#> GSM11257     4  0.6037      0.499 0.304 0.000 0.068 0.628
#> GSM11252     1  0.0188      0.821 0.996 0.000 0.000 0.004
#> GSM11264     3  0.0000      0.929 0.000 0.000 1.000 0.000
#> GSM11247     3  0.3937      0.759 0.000 0.012 0.800 0.188
#> GSM11258     1  0.1557      0.789 0.944 0.000 0.000 0.056
#> GSM28728     1  0.1716      0.785 0.936 0.000 0.000 0.064
#> GSM28746     1  0.0000      0.822 1.000 0.000 0.000 0.000
#> GSM28738     4  0.6016      0.498 0.300 0.000 0.068 0.632
#> GSM28741     4  0.8351      0.429 0.300 0.268 0.020 0.412
#> GSM28729     1  0.2011      0.768 0.920 0.000 0.000 0.080
#> GSM28742     4  0.8176      0.475 0.344 0.048 0.132 0.476
#> GSM11250     2  0.6600      0.445 0.084 0.620 0.012 0.284
#> GSM11245     1  0.0188      0.821 0.996 0.000 0.000 0.004
#> GSM11246     1  0.0469      0.819 0.988 0.000 0.000 0.012
#> GSM11261     4  0.8087      0.471 0.320 0.012 0.236 0.432
#> GSM11248     1  0.5925      0.101 0.648 0.000 0.068 0.284
#> GSM28732     1  0.4916      0.095 0.576 0.000 0.000 0.424
#> GSM11255     1  0.2530      0.690 0.888 0.000 0.000 0.112
#> GSM28731     1  0.0188      0.821 0.996 0.000 0.000 0.004
#> GSM28727     1  0.1557      0.794 0.944 0.000 0.000 0.056
#> GSM11251     1  0.0469      0.819 0.988 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM28735     5  0.6638     0.2769 0.320 0.000 0.000 0.240 0.440
#> GSM28736     1  0.6677     0.2097 0.540 0.000 0.020 0.244 0.196
#> GSM28737     1  0.0290     0.8478 0.992 0.000 0.000 0.000 0.008
#> GSM11249     4  0.6605     0.4137 0.252 0.000 0.000 0.460 0.288
#> GSM28745     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM28748     2  0.4657     0.4554 0.000 0.668 0.000 0.036 0.296
#> GSM11266     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM28730     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM11254     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9485 0.000 1.000 0.000 0.000 0.000
#> GSM11265     1  0.5568     0.3083 0.596 0.000 0.000 0.096 0.308
#> GSM28739     1  0.0000     0.8480 1.000 0.000 0.000 0.000 0.000
#> GSM11243     3  0.4843     0.6800 0.000 0.000 0.660 0.048 0.292
#> GSM28740     1  0.0290     0.8475 0.992 0.000 0.000 0.008 0.000
#> GSM11259     1  0.0404     0.8466 0.988 0.000 0.000 0.000 0.012
#> GSM28726     5  0.4173     0.3921 0.300 0.012 0.000 0.000 0.688
#> GSM28743     1  0.0162     0.8484 0.996 0.000 0.000 0.000 0.004
#> GSM11256     4  0.0290     0.6508 0.008 0.000 0.000 0.992 0.000
#> GSM11262     1  0.0162     0.8484 0.996 0.000 0.000 0.000 0.004
#> GSM28724     1  0.3635     0.6291 0.748 0.000 0.000 0.248 0.004
#> GSM28725     3  0.0000     0.7919 0.000 0.000 1.000 0.000 0.000
#> GSM11263     3  0.0000     0.7919 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0000     0.7919 0.000 0.000 1.000 0.000 0.000
#> GSM28744     1  0.0955     0.8339 0.968 0.000 0.000 0.028 0.004
#> GSM28734     1  0.3039     0.6519 0.836 0.000 0.000 0.012 0.152
#> GSM28747     1  0.3684     0.5205 0.720 0.000 0.000 0.000 0.280
#> GSM11257     4  0.0000     0.6542 0.000 0.000 0.000 1.000 0.000
#> GSM11252     1  0.0000     0.8480 1.000 0.000 0.000 0.000 0.000
#> GSM11264     3  0.0000     0.7919 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.4843     0.6800 0.000 0.000 0.660 0.048 0.292
#> GSM11258     1  0.3274     0.6643 0.780 0.000 0.000 0.220 0.000
#> GSM28728     1  0.2629     0.7562 0.860 0.000 0.000 0.136 0.004
#> GSM28746     1  0.0162     0.8482 0.996 0.000 0.000 0.004 0.000
#> GSM28738     4  0.0000     0.6542 0.000 0.000 0.000 1.000 0.000
#> GSM28741     5  0.6124     0.0927 0.052 0.344 0.004 0.036 0.564
#> GSM28729     1  0.3689     0.6220 0.740 0.000 0.000 0.256 0.004
#> GSM28742     5  0.2790     0.2038 0.052 0.000 0.000 0.068 0.880
#> GSM11250     5  0.5096    -0.1842 0.000 0.444 0.000 0.036 0.520
#> GSM11245     1  0.0000     0.8480 1.000 0.000 0.000 0.000 0.000
#> GSM11246     1  0.0162     0.8475 0.996 0.000 0.000 0.000 0.004
#> GSM11261     3  0.5772     0.6165 0.000 0.028 0.580 0.048 0.344
#> GSM11248     4  0.6975     0.4229 0.236 0.000 0.016 0.460 0.288
#> GSM28732     5  0.6275     0.3528 0.300 0.000 0.000 0.180 0.520
#> GSM11255     1  0.0000     0.8480 1.000 0.000 0.000 0.000 0.000
#> GSM28731     1  0.0162     0.8484 0.996 0.000 0.000 0.000 0.004
#> GSM28727     1  0.3730     0.5107 0.712 0.000 0.000 0.000 0.288
#> GSM11251     1  0.0290     0.8479 0.992 0.000 0.000 0.000 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
#> GSM28735     5  0.2890      0.803 0.108 0.000 0.000 0.020 0.856 0.016
#> GSM28736     1  0.2445      0.902 0.896 0.000 0.000 0.020 0.056 0.028
#> GSM28737     1  0.0260      0.947 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM11249     6  0.3915      0.278 0.004 0.000 0.000 0.412 0.000 0.584
#> GSM28745     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.4838      0.477 0.000 0.564 0.000 0.000 0.064 0.372
#> GSM11266     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28730     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11253     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11254     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000      0.899 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     5  0.2696      0.828 0.116 0.000 0.000 0.000 0.856 0.028
#> GSM28739     1  0.0993      0.943 0.964 0.000 0.000 0.000 0.012 0.024
#> GSM11243     3  0.2378      0.846 0.000 0.000 0.848 0.000 0.000 0.152
#> GSM28740     1  0.0790      0.941 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM11259     1  0.0806      0.946 0.972 0.000 0.000 0.000 0.008 0.020
#> GSM28726     5  0.2364      0.824 0.072 0.000 0.004 0.000 0.892 0.032
#> GSM28743     1  0.0146      0.948 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11256     4  0.0458      0.974 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM11262     1  0.0692      0.945 0.976 0.000 0.000 0.000 0.004 0.020
#> GSM28724     1  0.1851      0.928 0.928 0.000 0.000 0.012 0.024 0.036
#> GSM28725     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11263     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     1  0.4045      0.540 0.648 0.000 0.000 0.008 0.008 0.336
#> GSM28734     1  0.1866      0.902 0.908 0.000 0.000 0.000 0.008 0.084
#> GSM28747     5  0.2624      0.821 0.124 0.000 0.000 0.000 0.856 0.020
#> GSM11257     4  0.0363      0.978 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM11252     1  0.0806      0.945 0.972 0.000 0.000 0.000 0.008 0.020
#> GSM11264     3  0.0000      0.929 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     3  0.2378      0.846 0.000 0.000 0.848 0.000 0.000 0.152
#> GSM11258     1  0.1049      0.940 0.960 0.000 0.000 0.008 0.000 0.032
#> GSM28728     1  0.1821      0.929 0.928 0.000 0.000 0.008 0.024 0.040
#> GSM28746     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28738     4  0.0000      0.964 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28741     5  0.5466      0.117 0.008 0.072 0.004 0.004 0.520 0.392
#> GSM28729     1  0.1966      0.924 0.924 0.000 0.000 0.024 0.024 0.028
#> GSM28742     5  0.2651      0.736 0.028 0.000 0.000 0.000 0.860 0.112
#> GSM11250     2  0.5009      0.436 0.000 0.536 0.000 0.000 0.076 0.388
#> GSM11245     1  0.0806      0.945 0.972 0.000 0.000 0.000 0.008 0.020
#> GSM11246     1  0.0146      0.948 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11261     6  0.7074     -0.175 0.112 0.000 0.132 0.004 0.344 0.408
#> GSM11248     6  0.3915      0.278 0.004 0.000 0.000 0.412 0.000 0.584
#> GSM28732     5  0.1732      0.827 0.072 0.000 0.000 0.004 0.920 0.004
#> GSM11255     1  0.1265      0.934 0.948 0.000 0.000 0.000 0.008 0.044
#> GSM28731     1  0.0790      0.941 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM28727     5  0.2398      0.833 0.104 0.000 0.000 0.000 0.876 0.020
#> GSM11251     1  0.0405      0.947 0.988 0.000 0.000 0.000 0.008 0.004

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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 tissue(p) k
#> ATC:mclust 50     0.394 2
#> ATC:mclust 45     0.421 3
#> ATC:mclust 37     0.413 4
#> ATC:mclust 39     0.521 5
#> ATC:mclust 44     0.495 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 21342 rows and 50 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 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-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.486           0.796       0.893         0.4524 0.556   0.556
#> 3 3 1.000           0.951       0.981         0.3255 0.591   0.406
#> 4 4 0.737           0.751       0.841         0.1698 0.864   0.692
#> 5 5 0.785           0.890       0.923         0.0940 0.897   0.690
#> 6 6 0.761           0.741       0.858         0.0315 0.987   0.943

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
#> GSM28735     2  0.4690      0.837 0.100 0.900
#> GSM28736     2  0.0000      0.844 0.000 1.000
#> GSM28737     2  0.1633      0.845 0.024 0.976
#> GSM11249     1  0.0000      0.940 1.000 0.000
#> GSM28745     2  0.0376      0.844 0.004 0.996
#> GSM11244     2  0.0376      0.844 0.004 0.996
#> GSM28748     2  0.0376      0.844 0.004 0.996
#> GSM11266     2  0.0376      0.844 0.004 0.996
#> GSM28730     2  0.0376      0.844 0.004 0.996
#> GSM11253     2  0.0376      0.844 0.004 0.996
#> GSM11254     2  0.0376      0.844 0.004 0.996
#> GSM11260     2  0.0376      0.844 0.004 0.996
#> GSM28733     2  0.0376      0.844 0.004 0.996
#> GSM11265     2  1.0000      0.277 0.496 0.504
#> GSM28739     1  0.8081      0.554 0.752 0.248
#> GSM11243     1  0.0000      0.940 1.000 0.000
#> GSM28740     2  0.8608      0.720 0.284 0.716
#> GSM11259     2  0.0938      0.845 0.012 0.988
#> GSM28726     2  0.0000      0.844 0.000 1.000
#> GSM28743     2  0.8443      0.732 0.272 0.728
#> GSM11256     2  0.8267      0.743 0.260 0.740
#> GSM11262     2  0.4161      0.839 0.084 0.916
#> GSM28724     2  0.8608      0.720 0.284 0.716
#> GSM28725     1  0.0000      0.940 1.000 0.000
#> GSM11263     1  0.0000      0.940 1.000 0.000
#> GSM11267     1  0.0000      0.940 1.000 0.000
#> GSM28744     1  0.0376      0.939 0.996 0.004
#> GSM28734     1  0.0376      0.939 0.996 0.004
#> GSM28747     2  0.7139      0.793 0.196 0.804
#> GSM11257     2  0.5408      0.831 0.124 0.876
#> GSM11252     1  0.0376      0.939 0.996 0.004
#> GSM11264     1  0.0000      0.940 1.000 0.000
#> GSM11247     1  0.0000      0.940 1.000 0.000
#> GSM11258     1  0.9850     -0.056 0.572 0.428
#> GSM28728     2  0.9358      0.626 0.352 0.648
#> GSM28746     2  0.9491      0.598 0.368 0.632
#> GSM28738     2  0.0000      0.844 0.000 1.000
#> GSM28741     2  0.0376      0.844 0.004 0.996
#> GSM28729     2  0.5946      0.822 0.144 0.856
#> GSM28742     2  0.9998      0.294 0.492 0.508
#> GSM11250     2  0.0376      0.844 0.004 0.996
#> GSM11245     1  0.0376      0.939 0.996 0.004
#> GSM11246     2  0.8909      0.691 0.308 0.692
#> GSM11261     1  0.0000      0.940 1.000 0.000
#> GSM11248     1  0.0376      0.939 0.996 0.004
#> GSM28732     2  0.9170      0.658 0.332 0.668
#> GSM11255     1  0.0376      0.939 0.996 0.004
#> GSM28731     2  0.6973      0.798 0.188 0.812
#> GSM28727     2  0.5737      0.826 0.136 0.864
#> GSM11251     2  0.5059      0.834 0.112 0.888

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM28735     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28736     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28737     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11249     3   0.000     0.9946 0.000 0.000 1.000
#> GSM28745     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11244     2   0.000     1.0000 0.000 1.000 0.000
#> GSM28748     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11266     2   0.000     1.0000 0.000 1.000 0.000
#> GSM28730     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11253     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11254     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11260     2   0.000     1.0000 0.000 1.000 0.000
#> GSM28733     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11265     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28739     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11243     3   0.000     0.9946 0.000 0.000 1.000
#> GSM28740     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11259     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28726     1   0.553     0.5824 0.704 0.296 0.000
#> GSM28743     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11256     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11262     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28724     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28725     3   0.000     0.9946 0.000 0.000 1.000
#> GSM11263     3   0.000     0.9946 0.000 0.000 1.000
#> GSM11267     3   0.000     0.9946 0.000 0.000 1.000
#> GSM28744     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28734     1   0.630     0.0853 0.516 0.000 0.484
#> GSM28747     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11257     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11252     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11264     3   0.000     0.9946 0.000 0.000 1.000
#> GSM11247     3   0.000     0.9946 0.000 0.000 1.000
#> GSM11258     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28728     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28746     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28738     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28741     2   0.000     1.0000 0.000 1.000 0.000
#> GSM28729     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28742     3   0.215     0.9493 0.016 0.036 0.948
#> GSM11250     2   0.000     1.0000 0.000 1.000 0.000
#> GSM11245     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11246     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11261     3   0.000     0.9946 0.000 0.000 1.000
#> GSM11248     3   0.000     0.9946 0.000 0.000 1.000
#> GSM28732     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11255     1   0.355     0.8325 0.868 0.000 0.132
#> GSM28731     1   0.000     0.9669 1.000 0.000 0.000
#> GSM28727     1   0.000     0.9669 1.000 0.000 0.000
#> GSM11251     1   0.000     0.9669 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
#> GSM28735     1  0.4647    0.58478 0.704 0.000 0.008 0.288
#> GSM28736     1  0.3074    0.66765 0.848 0.000 0.000 0.152
#> GSM28737     1  0.3942    0.39808 0.764 0.000 0.000 0.236
#> GSM11249     3  0.1022    0.96225 0.000 0.000 0.968 0.032
#> GSM28745     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11244     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM28748     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11266     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM28730     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11253     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11254     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11260     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM28733     2  0.0000    0.99690 0.000 1.000 0.000 0.000
#> GSM11265     1  0.1474    0.68501 0.948 0.000 0.000 0.052
#> GSM28739     1  0.1389    0.66061 0.952 0.000 0.000 0.048
#> GSM11243     3  0.0592    0.96605 0.000 0.000 0.984 0.016
#> GSM28740     1  0.4661   -0.03666 0.652 0.000 0.000 0.348
#> GSM11259     1  0.0000    0.68081 1.000 0.000 0.000 0.000
#> GSM28726     1  0.4304    0.59304 0.716 0.000 0.000 0.284
#> GSM28743     1  0.3219    0.54332 0.836 0.000 0.000 0.164
#> GSM11256     4  0.4661    0.90656 0.348 0.000 0.000 0.652
#> GSM11262     1  0.4164    0.31808 0.736 0.000 0.000 0.264
#> GSM28724     1  0.3024    0.56616 0.852 0.000 0.000 0.148
#> GSM28725     3  0.0188    0.96860 0.000 0.000 0.996 0.004
#> GSM11263     3  0.0592    0.96751 0.000 0.000 0.984 0.016
#> GSM11267     3  0.0188    0.96860 0.000 0.000 0.996 0.004
#> GSM28744     4  0.5167    0.67931 0.488 0.000 0.004 0.508
#> GSM28734     3  0.2676    0.85652 0.092 0.000 0.896 0.012
#> GSM28747     1  0.4072    0.61749 0.748 0.000 0.000 0.252
#> GSM11257     4  0.4624    0.90805 0.340 0.000 0.000 0.660
#> GSM11252     1  0.3401    0.56187 0.840 0.000 0.008 0.152
#> GSM11264     3  0.0592    0.96751 0.000 0.000 0.984 0.016
#> GSM11247     3  0.0707    0.96485 0.000 0.000 0.980 0.020
#> GSM11258     1  0.4624    0.00668 0.660 0.000 0.000 0.340
#> GSM28728     1  0.3942    0.62719 0.764 0.000 0.000 0.236
#> GSM28746     1  0.3444    0.50957 0.816 0.000 0.000 0.184
#> GSM28738     4  0.4781    0.90491 0.336 0.004 0.000 0.660
#> GSM28741     2  0.1042    0.97279 0.008 0.972 0.000 0.020
#> GSM28729     1  0.3074    0.67193 0.848 0.000 0.000 0.152
#> GSM28742     1  0.5878    0.51075 0.632 0.000 0.056 0.312
#> GSM11250     2  0.0188    0.99408 0.000 0.996 0.000 0.004
#> GSM11245     1  0.1488    0.67722 0.956 0.000 0.012 0.032
#> GSM11246     1  0.0592    0.68333 0.984 0.000 0.000 0.016
#> GSM11261     3  0.0336    0.96851 0.000 0.000 0.992 0.008
#> GSM11248     3  0.2081    0.93084 0.000 0.000 0.916 0.084
#> GSM28732     1  0.5344    0.55117 0.668 0.000 0.032 0.300
#> GSM11255     1  0.3335    0.62909 0.860 0.000 0.120 0.020
#> GSM28731     1  0.2011    0.63785 0.920 0.000 0.000 0.080
#> GSM28727     1  0.3486    0.65320 0.812 0.000 0.000 0.188
#> GSM11251     1  0.1022    0.66984 0.968 0.000 0.000 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
#> GSM28735     5  0.1628      0.923 0.056 0.000 0.000 0.008 0.936
#> GSM28736     5  0.3106      0.853 0.140 0.000 0.000 0.020 0.840
#> GSM28737     1  0.0865      0.888 0.972 0.000 0.000 0.024 0.004
#> GSM11249     3  0.0290      0.913 0.000 0.000 0.992 0.000 0.008
#> GSM28745     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM11244     2  0.0162      0.993 0.000 0.996 0.000 0.004 0.000
#> GSM28748     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM11266     2  0.0290      0.992 0.000 0.992 0.000 0.008 0.000
#> GSM28730     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM11253     2  0.0404      0.987 0.000 0.988 0.000 0.012 0.000
#> GSM11254     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM11260     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM28733     2  0.0290      0.992 0.000 0.992 0.000 0.008 0.000
#> GSM11265     1  0.1830      0.891 0.924 0.000 0.000 0.008 0.068
#> GSM28739     1  0.0290      0.893 0.992 0.000 0.000 0.000 0.008
#> GSM11243     3  0.1430      0.886 0.000 0.000 0.944 0.004 0.052
#> GSM28740     1  0.0963      0.880 0.964 0.000 0.000 0.036 0.000
#> GSM11259     1  0.3353      0.811 0.796 0.000 0.000 0.008 0.196
#> GSM28726     5  0.1670      0.922 0.052 0.000 0.000 0.012 0.936
#> GSM28743     1  0.0693      0.891 0.980 0.000 0.000 0.008 0.012
#> GSM11256     4  0.3123      0.881 0.160 0.000 0.000 0.828 0.012
#> GSM11262     1  0.0912      0.884 0.972 0.000 0.000 0.016 0.012
#> GSM28724     1  0.1195      0.887 0.960 0.000 0.000 0.028 0.012
#> GSM28725     3  0.0290      0.913 0.000 0.000 0.992 0.008 0.000
#> GSM11263     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM11267     3  0.0162      0.913 0.000 0.000 0.996 0.004 0.000
#> GSM28744     4  0.4136      0.703 0.048 0.000 0.000 0.764 0.188
#> GSM28734     3  0.3759      0.646 0.220 0.000 0.764 0.000 0.016
#> GSM28747     1  0.4026      0.748 0.736 0.000 0.000 0.020 0.244
#> GSM11257     4  0.2424      0.897 0.132 0.000 0.000 0.868 0.000
#> GSM11252     1  0.0579      0.893 0.984 0.000 0.000 0.008 0.008
#> GSM11264     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM11247     3  0.4016      0.634 0.000 0.000 0.716 0.012 0.272
#> GSM11258     1  0.0912      0.883 0.972 0.000 0.000 0.016 0.012
#> GSM28728     5  0.3410      0.871 0.092 0.000 0.000 0.068 0.840
#> GSM28746     1  0.0566      0.889 0.984 0.000 0.000 0.012 0.004
#> GSM28738     4  0.2389      0.891 0.116 0.004 0.000 0.880 0.000
#> GSM28741     2  0.1116      0.973 0.004 0.964 0.000 0.028 0.004
#> GSM28729     5  0.3339      0.875 0.112 0.000 0.000 0.048 0.840
#> GSM28742     5  0.1267      0.894 0.024 0.000 0.004 0.012 0.960
#> GSM11250     2  0.0404      0.991 0.000 0.988 0.000 0.012 0.000
#> GSM11245     1  0.1768      0.890 0.924 0.000 0.004 0.000 0.072
#> GSM11246     1  0.2605      0.858 0.852 0.000 0.000 0.000 0.148
#> GSM11261     3  0.0451      0.912 0.004 0.000 0.988 0.000 0.008
#> GSM11248     3  0.2140      0.875 0.040 0.000 0.924 0.024 0.012
#> GSM28732     5  0.1270      0.921 0.052 0.000 0.000 0.000 0.948
#> GSM11255     1  0.4064      0.804 0.792 0.000 0.116 0.000 0.092
#> GSM28731     1  0.2813      0.874 0.868 0.000 0.000 0.024 0.108
#> GSM28727     1  0.3906      0.759 0.744 0.000 0.000 0.016 0.240
#> GSM11251     1  0.3061      0.858 0.844 0.000 0.000 0.020 0.136

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM28735     5  0.2647     0.7206 0.088 0.000 0.000 0.016 0.876 0.020
#> GSM28736     5  0.4726     0.6319 0.140 0.000 0.000 0.100 0.728 0.032
#> GSM28737     1  0.1226     0.8525 0.952 0.000 0.000 0.040 0.004 0.004
#> GSM11249     3  0.0767     0.7969 0.000 0.000 0.976 0.008 0.004 0.012
#> GSM28745     2  0.0000     0.9915 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11244     2  0.0000     0.9915 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28748     2  0.0146     0.9906 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11266     2  0.0146     0.9905 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM28730     2  0.0146     0.9908 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM11253     2  0.0260     0.9891 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM11254     2  0.0146     0.9908 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM11260     2  0.0000     0.9915 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28733     2  0.0000     0.9915 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11265     1  0.1333     0.8506 0.944 0.000 0.000 0.000 0.048 0.008
#> GSM28739     1  0.1194     0.8533 0.956 0.000 0.000 0.032 0.008 0.004
#> GSM11243     3  0.3619     0.4330 0.000 0.000 0.744 0.000 0.024 0.232
#> GSM28740     1  0.1462     0.8470 0.936 0.000 0.000 0.056 0.000 0.008
#> GSM11259     1  0.3539     0.7384 0.768 0.000 0.000 0.008 0.208 0.016
#> GSM28726     5  0.2088     0.7140 0.068 0.000 0.000 0.000 0.904 0.028
#> GSM28743     1  0.1511     0.8490 0.940 0.000 0.000 0.012 0.004 0.044
#> GSM11256     4  0.2492     0.5661 0.100 0.000 0.000 0.876 0.004 0.020
#> GSM11262     1  0.1777     0.8476 0.928 0.000 0.000 0.024 0.004 0.044
#> GSM28724     1  0.2755     0.8100 0.844 0.000 0.000 0.004 0.012 0.140
#> GSM28725     3  0.0146     0.8006 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM11263     3  0.0000     0.8020 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11267     3  0.0000     0.8020 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28744     4  0.4513     0.4425 0.032 0.000 0.000 0.732 0.180 0.056
#> GSM28734     3  0.5794     0.3037 0.244 0.000 0.580 0.156 0.004 0.016
#> GSM28747     1  0.3646     0.7605 0.776 0.000 0.000 0.000 0.172 0.052
#> GSM11257     4  0.4165     0.6597 0.036 0.000 0.000 0.672 0.000 0.292
#> GSM11252     1  0.1439     0.8562 0.952 0.000 0.012 0.012 0.016 0.008
#> GSM11264     3  0.0000     0.8020 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11247     6  0.5787     0.1381 0.000 0.000 0.424 0.012 0.124 0.440
#> GSM11258     1  0.2501     0.8112 0.872 0.000 0.000 0.108 0.004 0.016
#> GSM28728     6  0.6107     0.0558 0.044 0.000 0.000 0.128 0.292 0.536
#> GSM28746     1  0.2102     0.8369 0.908 0.000 0.000 0.068 0.012 0.012
#> GSM28738     4  0.4047     0.6585 0.028 0.000 0.000 0.676 0.000 0.296
#> GSM28741     2  0.1684     0.9429 0.008 0.940 0.000 0.008 0.016 0.028
#> GSM28729     5  0.6956     0.0370 0.064 0.000 0.000 0.352 0.360 0.224
#> GSM28742     5  0.1668     0.6109 0.008 0.000 0.000 0.004 0.928 0.060
#> GSM11250     2  0.0291     0.9887 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM11245     1  0.2315     0.8462 0.892 0.000 0.000 0.016 0.084 0.008
#> GSM11246     1  0.1918     0.8381 0.904 0.000 0.000 0.000 0.088 0.008
#> GSM11261     3  0.0748     0.7968 0.000 0.000 0.976 0.004 0.004 0.016
#> GSM11248     3  0.5052     0.4230 0.064 0.000 0.640 0.276 0.004 0.016
#> GSM28732     5  0.3009     0.7073 0.112 0.000 0.000 0.004 0.844 0.040
#> GSM11255     1  0.4404     0.7118 0.732 0.000 0.172 0.004 0.088 0.004
#> GSM28731     1  0.4696     0.5635 0.660 0.000 0.000 0.276 0.048 0.016
#> GSM28727     1  0.4327     0.6310 0.688 0.000 0.000 0.004 0.260 0.048
#> GSM11251     1  0.3351     0.8070 0.832 0.000 0.000 0.016 0.104 0.048

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 tissue(p) k
#> ATC:NMF 47     0.391 2
#> ATC:NMF 49     0.368 3
#> ATC:NMF 46     0.412 4
#> ATC:NMF 50     0.479 5
#> ATC:NMF 43     0.493 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