cola Report for GDS3233

Date: 2019-12-25 20:40:22 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 21168 rows and 61 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] 21168    61

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:kmeans 3 1.000 0.967 0.982 **
SD:skmeans 2 1.000 0.982 0.993 **
SD:pam 4 1.000 0.963 0.987 ** 2,3
CV:kmeans 3 1.000 0.970 0.986 **
CV:pam 4 1.000 0.974 0.990 ** 3
MAD:skmeans 2 1.000 0.976 0.991 **
MAD:NMF 2 1.000 0.972 0.988 **
ATC:pam 4 1.000 0.972 0.989 ** 2,3
ATC:NMF 2 1.000 0.961 0.986 **
MAD:pam 4 0.987 0.944 0.978 ** 2,3
MAD:kmeans 4 0.986 0.967 0.967 **
ATC:hclust 4 0.962 0.934 0.974 **
MAD:mclust 6 0.952 0.934 0.960 ** 4
CV:mclust 4 0.941 0.917 0.966 *
SD:hclust 4 0.935 0.924 0.963 * 3
CV:skmeans 3 0.924 0.939 0.968 * 2
MAD:hclust 4 0.918 0.883 0.944 * 3
SD:NMF 4 0.912 0.885 0.954 *
ATC:skmeans 3 0.900 0.932 0.962 * 2
CV:hclust 3 0.891 0.897 0.954
CV:NMF 3 0.874 0.895 0.956
ATC:kmeans 2 0.847 0.943 0.973
SD:mclust 3 0.840 0.889 0.950
ATC:mclust 2 0.642 0.778 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 0.806           0.892       0.956          0.500 0.498   0.498
#> CV:NMF      2 0.774           0.870       0.947          0.501 0.492   0.492
#> MAD:NMF     2 1.000           0.972       0.988          0.494 0.503   0.503
#> ATC:NMF     2 1.000           0.961       0.986          0.491 0.508   0.508
#> SD:skmeans  2 1.000           0.982       0.993          0.490 0.508   0.508
#> CV:skmeans  2 1.000           0.988       0.995          0.496 0.503   0.503
#> MAD:skmeans 2 1.000           0.976       0.991          0.489 0.515   0.515
#> ATC:skmeans 2 1.000           0.991       0.996          0.496 0.503   0.503
#> SD:mclust   2 0.272           0.658       0.799          0.457 0.493   0.493
#> CV:mclust   2 0.494           0.772       0.885          0.495 0.503   0.503
#> MAD:mclust  2 0.446           0.215       0.581          0.487 0.721   0.721
#> ATC:mclust  2 0.642           0.778       0.913          0.456 0.552   0.552
#> SD:kmeans   2 0.368           0.728       0.773          0.411 0.541   0.541
#> CV:kmeans   2 0.323           0.687       0.700          0.406 0.552   0.552
#> MAD:kmeans  2 0.495           0.920       0.898          0.443 0.515   0.515
#> ATC:kmeans  2 0.847           0.943       0.973          0.469 0.515   0.515
#> SD:pam      2 1.000           0.972       0.987          0.456 0.552   0.552
#> CV:pam      2 0.788           0.887       0.947          0.473 0.541   0.541
#> MAD:pam     2 0.966           0.948       0.965          0.455 0.552   0.552
#> ATC:pam     2 0.932           0.953       0.978          0.450 0.564   0.564
#> SD:hclust   2 0.607           0.915       0.946          0.303 0.744   0.744
#> CV:hclust   2 0.368           0.566       0.712          0.379 0.541   0.541
#> MAD:hclust  2 0.432           0.579       0.718          0.338 0.531   0.531
#> ATC:hclust  2 0.508           0.926       0.909          0.369 0.607   0.607
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.845           0.874       0.947          0.319 0.697   0.466
#> CV:NMF      3 0.874           0.895       0.956          0.301 0.661   0.424
#> MAD:NMF     3 0.814           0.851       0.939          0.345 0.708   0.481
#> ATC:NMF     3 0.869           0.865       0.947          0.334 0.751   0.549
#> SD:skmeans  3 0.869           0.894       0.951          0.375 0.722   0.500
#> CV:skmeans  3 0.924           0.939       0.968          0.359 0.711   0.483
#> MAD:skmeans 3 0.722           0.853       0.930          0.372 0.733   0.517
#> ATC:skmeans 3 0.900           0.932       0.962          0.280 0.803   0.624
#> SD:mclust   3 0.840           0.889       0.950          0.435 0.727   0.511
#> CV:mclust   3 0.842           0.865       0.939          0.314 0.733   0.522
#> MAD:mclust  3 0.818           0.882       0.943          0.335 0.560   0.418
#> ATC:mclust  3 0.668           0.814       0.898          0.374 0.727   0.537
#> SD:kmeans   3 1.000           0.967       0.982          0.459 0.820   0.677
#> CV:kmeans   3 1.000           0.970       0.986          0.477 0.815   0.675
#> MAD:kmeans  3 0.780           0.915       0.944          0.385 0.757   0.579
#> ATC:kmeans  3 0.659           0.782       0.841          0.316 0.734   0.550
#> SD:pam      3 1.000           0.999       1.000          0.328 0.843   0.715
#> CV:pam      3 1.000           0.987       0.994          0.289 0.845   0.715
#> MAD:pam     3 1.000           0.989       0.995          0.338 0.843   0.715
#> ATC:pam     3 1.000           0.971       0.987          0.342 0.838   0.712
#> SD:hclust   3 0.917           0.937       0.974          0.906 0.685   0.577
#> CV:hclust   3 0.891           0.897       0.954          0.548 0.767   0.607
#> MAD:hclust  3 0.915           0.913       0.965          0.723 0.702   0.526
#> ATC:hclust  3 0.725           0.935       0.933          0.565 0.823   0.708
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.912           0.885       0.954         0.0900 0.816   0.543
#> CV:NMF      4 0.885           0.892       0.950         0.1035 0.830   0.579
#> MAD:NMF     4 0.894           0.900       0.953         0.0853 0.804   0.513
#> ATC:NMF     4 0.675           0.653       0.825         0.1239 0.797   0.489
#> SD:skmeans  4 0.858           0.872       0.944         0.1049 0.786   0.463
#> CV:skmeans  4 0.754           0.812       0.911         0.1074 0.797   0.480
#> MAD:skmeans 4 0.835           0.854       0.936         0.1015 0.784   0.464
#> ATC:skmeans 4 0.754           0.800       0.906         0.1530 0.839   0.581
#> SD:mclust   4 0.898           0.857       0.944         0.1089 0.889   0.699
#> CV:mclust   4 0.941           0.917       0.966         0.0982 0.918   0.774
#> MAD:mclust  4 0.918           0.878       0.951         0.1176 0.907   0.744
#> ATC:mclust  4 0.707           0.758       0.881         0.1159 0.946   0.851
#> SD:kmeans   4 0.889           0.900       0.948         0.1583 0.889   0.722
#> CV:kmeans   4 0.848           0.893       0.902         0.1593 0.874   0.693
#> MAD:kmeans  4 0.986           0.967       0.967         0.1480 0.867   0.673
#> ATC:kmeans  4 0.679           0.899       0.896         0.1203 0.863   0.668
#> SD:pam      4 1.000           0.963       0.987         0.1144 0.926   0.814
#> CV:pam      4 1.000           0.974       0.990         0.1074 0.926   0.814
#> MAD:pam     4 0.987           0.944       0.978         0.1157 0.926   0.814
#> ATC:pam     4 1.000           0.972       0.989         0.1370 0.911   0.780
#> SD:hclust   4 0.935           0.924       0.963         0.2386 0.850   0.650
#> CV:hclust   4 0.754           0.827       0.896         0.1977 0.877   0.700
#> MAD:hclust  4 0.918           0.883       0.944         0.2066 0.850   0.650
#> ATC:hclust  4 0.962           0.934       0.974         0.2409 0.843   0.634
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.727           0.706       0.850         0.0625 0.979   0.929
#> CV:NMF      5 0.835           0.800       0.907         0.0507 0.966   0.885
#> MAD:NMF     5 0.770           0.759       0.885         0.0485 0.978   0.921
#> ATC:NMF     5 0.763           0.701       0.858         0.0554 0.954   0.820
#> SD:skmeans  5 0.791           0.680       0.852         0.0707 0.884   0.595
#> CV:skmeans  5 0.744           0.612       0.802         0.0677 0.877   0.574
#> MAD:skmeans 5 0.784           0.688       0.847         0.0769 0.893   0.632
#> ATC:skmeans 5 0.750           0.720       0.853         0.0636 0.925   0.718
#> SD:mclust   5 0.738           0.759       0.806         0.0552 1.000   1.000
#> CV:mclust   5 0.786           0.586       0.803         0.0628 0.923   0.740
#> MAD:mclust  5 0.842           0.872       0.907         0.0369 0.986   0.952
#> ATC:mclust  5 0.778           0.701       0.850         0.0991 0.938   0.808
#> SD:kmeans   5 0.756           0.799       0.862         0.0723 1.000   1.000
#> CV:kmeans   5 0.765           0.786       0.859         0.0739 0.992   0.974
#> MAD:kmeans  5 0.805           0.871       0.888         0.0705 1.000   1.000
#> ATC:kmeans  5 0.791           0.854       0.878         0.0811 1.000   1.000
#> SD:pam      5 0.858           0.811       0.914         0.1411 0.907   0.713
#> CV:pam      5 0.833           0.818       0.905         0.1156 0.928   0.778
#> MAD:pam     5 0.854           0.847       0.923         0.1271 0.920   0.753
#> ATC:pam     5 0.850           0.839       0.918         0.1094 0.920   0.747
#> SD:hclust   5 0.942           0.897       0.958         0.0198 0.987   0.953
#> CV:hclust   5 0.789           0.834       0.908         0.0335 0.990   0.966
#> MAD:hclust  5 0.927           0.910       0.954         0.0306 0.987   0.953
#> ATC:hclust  5 0.904           0.820       0.936         0.0272 0.989   0.960
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.748           0.634       0.784         0.0481 0.951   0.830
#> CV:NMF      6 0.735           0.597       0.792         0.0610 0.961   0.855
#> MAD:NMF     6 0.759           0.667       0.811         0.0493 0.952   0.827
#> ATC:NMF     6 0.745           0.583       0.799         0.0306 0.975   0.889
#> SD:skmeans  6 0.799           0.660       0.799         0.0333 0.918   0.641
#> CV:skmeans  6 0.776           0.579       0.777         0.0353 0.949   0.761
#> MAD:skmeans 6 0.794           0.625       0.792         0.0345 0.954   0.787
#> ATC:skmeans 6 0.762           0.652       0.796         0.0348 0.943   0.743
#> SD:mclust   6 0.783           0.836       0.876         0.0578 0.889   0.611
#> CV:mclust   6 0.805           0.680       0.838         0.0613 0.905   0.621
#> MAD:mclust  6 0.952           0.934       0.960         0.0720 0.916   0.695
#> ATC:mclust  6 0.838           0.774       0.861         0.0271 0.936   0.759
#> SD:kmeans   6 0.743           0.595       0.754         0.0527 0.919   0.732
#> CV:kmeans   6 0.741           0.632       0.782         0.0457 0.962   0.867
#> MAD:kmeans  6 0.776           0.661       0.822         0.0456 0.940   0.794
#> ATC:kmeans  6 0.785           0.772       0.830         0.0496 0.943   0.800
#> SD:pam      6 0.839           0.726       0.877         0.0178 0.979   0.912
#> CV:pam      6 0.854           0.798       0.887         0.0343 0.974   0.899
#> MAD:pam     6 0.882           0.872       0.924         0.0432 0.939   0.756
#> ATC:pam     6 0.819           0.691       0.882         0.0365 0.975   0.896
#> SD:hclust   6 0.919           0.842       0.936         0.0135 0.996   0.984
#> CV:hclust   6 0.765           0.709       0.871         0.0370 0.975   0.909
#> MAD:hclust  6 0.865           0.867       0.926         0.0282 0.996   0.984
#> ATC:hclust  6 0.892           0.803       0.916         0.0244 0.961   0.863

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

collect_stats(res_list, k = 2)

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

collect_stats(res_list, k = 3)

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

collect_stats(res_list, k = 4)

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

collect_stats(res_list, k = 5)

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

collect_stats(res_list, k = 6)

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

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

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

collect_classes(res_list, k = 3)

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

collect_classes(res_list, k = 4)

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

collect_classes(res_list, k = 5)

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

collect_classes(res_list, k = 6)

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

Top rows overlap

Overlap of top rows from different top-row methods:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

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

top_rows_heatmap(res_list, top_n = 2000)

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

top_rows_heatmap(res_list, top_n = 3000)

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

top_rows_heatmap(res_list, top_n = 4000)

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

top_rows_heatmap(res_list, top_n = 5000)

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

Test to known annotations

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

test_to_known_factors(res_list, k = 2)
#>              n disease.state(p) k
#> SD:NMF      58         1.05e-11 2
#> CV:NMF      56         1.75e-09 2
#> MAD:NMF     60         6.78e-13 2
#> ATC:NMF     59         1.54e-13 2
#> SD:skmeans  60         9.36e-14 2
#> CV:skmeans  61         2.53e-12 2
#> MAD:skmeans 60         9.36e-14 2
#> ATC:skmeans 61         2.53e-12 2
#> SD:mclust   51         8.42e-12 2
#> CV:mclust   55         7.58e-12 2
#> MAD:mclust   9               NA 2
#> ATC:mclust  51         8.42e-12 2
#> SD:kmeans   58         2.54e-13 2
#> CV:kmeans   48         3.33e-11 2
#> MAD:kmeans  61         5.68e-14 2
#> ATC:kmeans  61         5.68e-14 2
#> SD:pam      61         1.09e-10 2
#> CV:pam      57         6.32e-10 2
#> MAD:pam     60         1.69e-10 2
#> ATC:pam     61         5.78e-10 2
#> SD:hclust   61         5.68e-14 2
#> CV:hclust   47         1.47e-08 2
#> MAD:hclust  46         2.27e-08 2
#> ATC:hclust  61         5.49e-08 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) k
#> SD:NMF      58         3.82e-14 3
#> CV:NMF      59         3.53e-15 3
#> MAD:NMF     56         2.12e-13 3
#> ATC:NMF     56         1.21e-09 3
#> SD:skmeans  58         1.47e-12 3
#> CV:skmeans  61         1.51e-13 3
#> MAD:skmeans 58         1.47e-12 3
#> ATC:skmeans 59         2.62e-10 3
#> SD:mclust   60         2.13e-19 3
#> CV:mclust   59         4.76e-19 3
#> MAD:mclust  60         2.13e-19 3
#> ATC:mclust  57         2.32e-15 3
#> SD:kmeans   60         1.88e-21 3
#> CV:kmeans   60         1.88e-21 3
#> MAD:kmeans  60         1.88e-21 3
#> ATC:kmeans  61         3.74e-21 3
#> SD:pam      61         6.70e-22 3
#> CV:pam      61         6.70e-22 3
#> MAD:pam     61         6.70e-22 3
#> ATC:pam     61         3.74e-21 3
#> SD:hclust   58         4.67e-19 3
#> CV:hclust   59         1.58e-19 3
#> MAD:hclust  58         8.94e-20 3
#> ATC:hclust  61         3.64e-19 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) k
#> SD:NMF      58         2.45e-19 4
#> CV:NMF      58         8.53e-21 4
#> MAD:NMF     58         2.45e-19 4
#> ATC:NMF     46         7.13e-12 4
#> SD:skmeans  58         5.27e-17 4
#> CV:skmeans  57         6.33e-18 4
#> MAD:skmeans 57         7.66e-18 4
#> ATC:skmeans 56         9.11e-12 4
#> SD:mclust   56         3.11e-20 4
#> CV:mclust   58         8.78e-22 4
#> MAD:mclust  58         4.42e-21 4
#> ATC:mclust  54         9.16e-20 4
#> SD:kmeans   58         3.15e-21 4
#> CV:kmeans   59         1.37e-21 4
#> MAD:kmeans  61         2.38e-22 4
#> ATC:kmeans  61         2.38e-22 4
#> SD:pam      60         1.47e-22 4
#> CV:pam      61         3.47e-22 4
#> MAD:pam     60         9.09e-22 4
#> ATC:pam     60         3.16e-21 4
#> SD:hclust   59         6.37e-21 4
#> CV:hclust   58         1.14e-20 4
#> MAD:hclust  57         2.14e-21 4
#> ATC:hclust  58         8.60e-22 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) k
#> SD:NMF      50         2.51e-19 5
#> CV:NMF      54         6.25e-19 5
#> MAD:NMF     54         1.53e-18 5
#> ATC:NMF     48         1.53e-12 5
#> SD:skmeans  45         1.46e-14 5
#> CV:skmeans  36         1.83e-11 5
#> MAD:skmeans 45         1.62e-14 5
#> ATC:skmeans 49         3.43e-16 5
#> SD:mclust   53         2.63e-19 5
#> CV:mclust   35         4.09e-13 5
#> MAD:mclust  58         3.46e-20 5
#> ATC:mclust  47         7.65e-17 5
#> SD:kmeans   57         6.85e-21 5
#> CV:kmeans   53         2.52e-19 5
#> MAD:kmeans  61         2.38e-22 5
#> ATC:kmeans  61         2.38e-22 5
#> SD:pam      55         3.18e-19 5
#> CV:pam      57         4.82e-20 5
#> MAD:pam     59         7.23e-21 5
#> ATC:pam     58         3.75e-19 5
#> SD:hclust   58         2.22e-21 5
#> CV:hclust   58         2.22e-21 5
#> MAD:hclust  57         5.72e-21 5
#> ATC:hclust  49         2.62e-20 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) k
#> SD:NMF      46         1.82e-16 6
#> CV:NMF      43         3.31e-14 6
#> MAD:NMF     46         1.16e-17 6
#> ATC:NMF     39         5.47e-11 6
#> SD:skmeans  40         5.02e-13 6
#> CV:skmeans  34         1.23e-11 6
#> MAD:skmeans 38         3.11e-13 6
#> ATC:skmeans 42         2.63e-13 6
#> SD:mclust   60         7.11e-20 6
#> CV:mclust   50         8.71e-16 6
#> MAD:mclust  60         7.11e-20 6
#> ATC:mclust  53         4.93e-17 6
#> SD:kmeans   41         1.93e-14 6
#> CV:kmeans   48         3.43e-16 6
#> MAD:kmeans  46         1.82e-16 6
#> ATC:kmeans  57         5.72e-21 6
#> SD:pam      49         1.15e-15 6
#> CV:pam      56         1.70e-18 6
#> MAD:pam     59         5.78e-19 6
#> ATC:pam     47         7.15e-17 6
#> SD:hclust   57         5.72e-21 6
#> CV:hclust   54         1.35e-18 6
#> MAD:hclust  58         2.22e-21 6
#> ATC:hclust  52         3.67e-20 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 21168 rows and 61 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.607           0.915       0.946         0.3032 0.744   0.744
#> 3 3 0.917           0.937       0.974         0.9059 0.685   0.577
#> 4 4 0.935           0.924       0.963         0.2386 0.850   0.650
#> 5 5 0.942           0.897       0.958         0.0198 0.987   0.953
#> 6 6 0.919           0.842       0.936         0.0135 0.996   0.984

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] 3

There is also optional best \(k\) = 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
#> GSM246087     1   0.000      1.000 1.000 0.000
#> GSM246088     1   0.000      1.000 1.000 0.000
#> GSM246089     1   0.000      1.000 1.000 0.000
#> GSM246090     1   0.000      1.000 1.000 0.000
#> GSM246119     1   0.000      1.000 1.000 0.000
#> GSM246120     1   0.000      1.000 1.000 0.000
#> GSM246121     1   0.000      1.000 1.000 0.000
#> GSM246122     1   0.000      1.000 1.000 0.000
#> GSM246123     1   0.000      1.000 1.000 0.000
#> GSM246422     2   0.000      0.930 0.000 1.000
#> GSM246423     2   0.000      0.930 0.000 1.000
#> GSM246484     2   0.000      0.930 0.000 1.000
#> GSM246485     2   0.416      0.895 0.084 0.916
#> GSM246486     2   0.000      0.930 0.000 1.000
#> GSM246487     2   0.000      0.930 0.000 1.000
#> GSM246488     2   0.000      0.930 0.000 1.000
#> GSM246489     2   0.714      0.835 0.196 0.804
#> GSM246490     2   0.706      0.838 0.192 0.808
#> GSM246491     2   0.706      0.838 0.192 0.808
#> GSM247162     2   0.714      0.835 0.196 0.804
#> GSM247163     2   0.706      0.838 0.192 0.808
#> GSM247164     2   0.706      0.838 0.192 0.808
#> GSM247165     2   0.706      0.838 0.192 0.808
#> GSM247166     2   0.714      0.835 0.196 0.804
#> GSM247168     2   0.714      0.835 0.196 0.804
#> GSM247169     2   0.714      0.835 0.196 0.804
#> GSM247171     2   0.714      0.835 0.196 0.804
#> GSM247173     2   0.714      0.835 0.196 0.804
#> GSM247174     2   0.714      0.835 0.196 0.804
#> GSM247175     2   0.714      0.835 0.196 0.804
#> GSM247188     2   0.714      0.835 0.196 0.804
#> GSM247189     2   0.416      0.895 0.084 0.916
#> GSM247190     2   0.714      0.835 0.196 0.804
#> GSM247650     2   0.000      0.930 0.000 1.000
#> GSM247651     2   0.000      0.930 0.000 1.000
#> GSM247652     2   0.000      0.930 0.000 1.000
#> GSM247653     2   0.000      0.930 0.000 1.000
#> GSM247654     2   0.000      0.930 0.000 1.000
#> GSM247655     2   0.000      0.930 0.000 1.000
#> GSM247656     2   0.000      0.930 0.000 1.000
#> GSM247657     2   0.000      0.930 0.000 1.000
#> GSM247658     2   0.000      0.930 0.000 1.000
#> GSM247659     2   0.000      0.930 0.000 1.000
#> GSM247660     2   0.000      0.930 0.000 1.000
#> GSM247661     2   0.000      0.930 0.000 1.000
#> GSM247662     2   0.000      0.930 0.000 1.000
#> GSM247663     2   0.000      0.930 0.000 1.000
#> GSM247856     2   0.000      0.930 0.000 1.000
#> GSM247857     2   0.000      0.930 0.000 1.000
#> GSM247859     2   0.000      0.930 0.000 1.000
#> GSM247860     2   0.000      0.930 0.000 1.000
#> GSM247862     2   0.000      0.930 0.000 1.000
#> GSM247864     2   0.000      0.930 0.000 1.000
#> GSM247865     2   0.000      0.930 0.000 1.000
#> GSM247866     2   0.000      0.930 0.000 1.000
#> GSM247876     2   0.000      0.930 0.000 1.000
#> GSM247877     2   0.000      0.930 0.000 1.000
#> GSM247878     2   0.000      0.930 0.000 1.000
#> GSM247879     2   0.000      0.930 0.000 1.000
#> GSM247881     2   0.000      0.930 0.000 1.000
#> GSM247883     2   0.000      0.930 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM246087     3  0.0000      1.000 0.000 0.000  1
#> GSM246088     3  0.0000      1.000 0.000 0.000  1
#> GSM246089     3  0.0000      1.000 0.000 0.000  1
#> GSM246090     3  0.0000      1.000 0.000 0.000  1
#> GSM246119     3  0.0000      1.000 0.000 0.000  1
#> GSM246120     3  0.0000      1.000 0.000 0.000  1
#> GSM246121     3  0.0000      1.000 0.000 0.000  1
#> GSM246122     3  0.0000      1.000 0.000 0.000  1
#> GSM246123     3  0.0000      1.000 0.000 0.000  1
#> GSM246422     1  0.0000      0.962 1.000 0.000  0
#> GSM246423     1  0.0000      0.962 1.000 0.000  0
#> GSM246484     1  0.0000      0.962 1.000 0.000  0
#> GSM246485     1  0.5968      0.460 0.636 0.364  0
#> GSM246486     1  0.3816      0.824 0.852 0.148  0
#> GSM246487     1  0.3816      0.824 0.852 0.148  0
#> GSM246488     1  0.4291      0.785 0.820 0.180  0
#> GSM246489     2  0.0000      0.968 0.000 1.000  0
#> GSM246490     2  0.0237      0.965 0.004 0.996  0
#> GSM246491     2  0.0237      0.965 0.004 0.996  0
#> GSM247162     2  0.0000      0.968 0.000 1.000  0
#> GSM247163     2  0.0237      0.965 0.004 0.996  0
#> GSM247164     2  0.0237      0.965 0.004 0.996  0
#> GSM247165     2  0.5706      0.486 0.320 0.680  0
#> GSM247166     2  0.0000      0.968 0.000 1.000  0
#> GSM247168     2  0.0000      0.968 0.000 1.000  0
#> GSM247169     2  0.0000      0.968 0.000 1.000  0
#> GSM247171     2  0.0000      0.968 0.000 1.000  0
#> GSM247173     2  0.0000      0.968 0.000 1.000  0
#> GSM247174     2  0.0000      0.968 0.000 1.000  0
#> GSM247175     2  0.0000      0.968 0.000 1.000  0
#> GSM247188     2  0.0000      0.968 0.000 1.000  0
#> GSM247189     1  0.5968      0.460 0.636 0.364  0
#> GSM247190     2  0.0000      0.968 0.000 1.000  0
#> GSM247650     1  0.0000      0.962 1.000 0.000  0
#> GSM247651     1  0.0000      0.962 1.000 0.000  0
#> GSM247652     1  0.0000      0.962 1.000 0.000  0
#> GSM247653     1  0.0000      0.962 1.000 0.000  0
#> GSM247654     1  0.0000      0.962 1.000 0.000  0
#> GSM247655     1  0.0000      0.962 1.000 0.000  0
#> GSM247656     1  0.0000      0.962 1.000 0.000  0
#> GSM247657     1  0.0000      0.962 1.000 0.000  0
#> GSM247658     1  0.0000      0.962 1.000 0.000  0
#> GSM247659     1  0.0000      0.962 1.000 0.000  0
#> GSM247660     1  0.0000      0.962 1.000 0.000  0
#> GSM247661     1  0.0000      0.962 1.000 0.000  0
#> GSM247662     1  0.0000      0.962 1.000 0.000  0
#> GSM247663     1  0.0000      0.962 1.000 0.000  0
#> GSM247856     1  0.0000      0.962 1.000 0.000  0
#> GSM247857     1  0.0000      0.962 1.000 0.000  0
#> GSM247859     1  0.0000      0.962 1.000 0.000  0
#> GSM247860     1  0.0000      0.962 1.000 0.000  0
#> GSM247862     1  0.0000      0.962 1.000 0.000  0
#> GSM247864     1  0.0000      0.962 1.000 0.000  0
#> GSM247865     1  0.1411      0.933 0.964 0.036  0
#> GSM247866     1  0.0000      0.962 1.000 0.000  0
#> GSM247876     1  0.0000      0.962 1.000 0.000  0
#> GSM247877     1  0.0000      0.962 1.000 0.000  0
#> GSM247878     1  0.0000      0.962 1.000 0.000  0
#> GSM247879     1  0.0000      0.962 1.000 0.000  0
#> GSM247881     1  0.0000      0.962 1.000 0.000  0
#> GSM247883     1  0.0000      0.962 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246422     4  0.0921      0.848 0.028 0.000  0 0.972
#> GSM246423     4  0.0921      0.848 0.028 0.000  0 0.972
#> GSM246484     4  0.0921      0.848 0.028 0.000  0 0.972
#> GSM246485     4  0.5371      0.559 0.020 0.364  0 0.616
#> GSM246486     4  0.3913      0.827 0.028 0.148  0 0.824
#> GSM246487     4  0.3913      0.827 0.028 0.148  0 0.824
#> GSM246488     4  0.4281      0.804 0.028 0.180  0 0.792
#> GSM246489     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM246490     2  0.0188      0.969 0.004 0.996  0 0.000
#> GSM246491     2  0.0188      0.969 0.004 0.996  0 0.000
#> GSM247162     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247163     2  0.0188      0.969 0.004 0.996  0 0.000
#> GSM247164     2  0.0188      0.969 0.004 0.996  0 0.000
#> GSM247165     2  0.4677      0.393 0.004 0.680  0 0.316
#> GSM247166     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247168     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247169     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247171     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247173     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247174     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247175     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247188     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247189     4  0.5371      0.559 0.020 0.364  0 0.616
#> GSM247190     2  0.0000      0.972 0.000 1.000  0 0.000
#> GSM247650     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247651     1  0.0336      0.976 0.992 0.000  0 0.008
#> GSM247652     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247653     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247654     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247655     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247656     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247657     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247658     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247659     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247660     1  0.0336      0.976 0.992 0.000  0 0.008
#> GSM247661     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247662     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247663     1  0.0469      0.973 0.988 0.000  0 0.012
#> GSM247856     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247857     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247859     1  0.0336      0.976 0.992 0.000  0 0.008
#> GSM247860     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247862     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247864     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247865     1  0.5742      0.286 0.596 0.036  0 0.368
#> GSM247866     1  0.0000      0.979 1.000 0.000  0 0.000
#> GSM247876     1  0.0707      0.966 0.980 0.000  0 0.020
#> GSM247877     4  0.0921      0.840 0.028 0.000  0 0.972
#> GSM247878     4  0.0000      0.835 0.000 0.000  0 1.000
#> GSM247879     4  0.0921      0.840 0.028 0.000  0 0.972
#> GSM247881     1  0.0336      0.976 0.992 0.000  0 0.008
#> GSM247883     1  0.0336      0.976 0.992 0.000  0 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.0000      0.664 0.000 0.000  0 1.000 0.000
#> GSM246423     4  0.0000      0.664 0.000 0.000  0 1.000 0.000
#> GSM246484     4  0.0000      0.664 0.000 0.000  0 1.000 0.000
#> GSM246485     4  0.4074      0.591 0.000 0.364  0 0.636 0.000
#> GSM246486     4  0.2605      0.756 0.000 0.148  0 0.852 0.000
#> GSM246487     4  0.2605      0.756 0.000 0.148  0 0.852 0.000
#> GSM246488     4  0.2929      0.742 0.000 0.180  0 0.820 0.000
#> GSM246489     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0162      0.969 0.000 0.996  0 0.004 0.000
#> GSM246491     2  0.0162      0.969 0.000 0.996  0 0.004 0.000
#> GSM247162     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.0162      0.969 0.000 0.996  0 0.004 0.000
#> GSM247164     2  0.0162      0.969 0.000 0.996  0 0.004 0.000
#> GSM247165     2  0.3895      0.338 0.000 0.680  0 0.320 0.000
#> GSM247166     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247168     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247171     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247175     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247189     4  0.4074      0.591 0.000 0.364  0 0.636 0.000
#> GSM247190     2  0.0000      0.971 0.000 1.000  0 0.000 0.000
#> GSM247650     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247651     1  0.0404      0.971 0.988 0.000  0 0.012 0.000
#> GSM247652     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247653     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247654     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247655     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247656     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247657     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247658     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247659     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247660     1  0.0404      0.971 0.988 0.000  0 0.012 0.000
#> GSM247661     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247662     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247663     1  0.0404      0.970 0.988 0.000  0 0.000 0.012
#> GSM247856     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247857     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247859     1  0.0404      0.971 0.988 0.000  0 0.012 0.000
#> GSM247860     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247862     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247864     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247865     1  0.4958      0.305 0.592 0.036  0 0.372 0.000
#> GSM247866     1  0.0000      0.977 1.000 0.000  0 0.000 0.000
#> GSM247876     1  0.0609      0.964 0.980 0.000  0 0.000 0.020
#> GSM247877     5  0.0000      0.749 0.000 0.000  0 0.000 1.000
#> GSM247878     5  0.4307      0.182 0.000 0.000  0 0.496 0.504
#> GSM247879     5  0.0000      0.749 0.000 0.000  0 0.000 1.000
#> GSM247881     1  0.0404      0.971 0.988 0.000  0 0.012 0.000
#> GSM247883     1  0.0404      0.971 0.988 0.000  0 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
#> GSM246087     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     6  0.1141      0.000 0.000 0.000 0.052 0.000 0.000 0.948
#> GSM246090     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.3244      0.732 0.000 0.000 0.732 0.000 0.000 0.268
#> GSM246120     3  0.3244      0.732 0.000 0.000 0.732 0.000 0.000 0.268
#> GSM246121     3  0.0865      0.848 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM246122     3  0.0000      0.854 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.3244      0.732 0.000 0.000 0.732 0.000 0.000 0.268
#> GSM246422     4  0.0146      0.668 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM246423     4  0.0146      0.668 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM246484     4  0.0146      0.668 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM246485     4  0.3647      0.592 0.000 0.360 0.000 0.640 0.000 0.000
#> GSM246486     4  0.2300      0.757 0.000 0.144 0.000 0.856 0.000 0.000
#> GSM246487     4  0.2300      0.757 0.000 0.144 0.000 0.856 0.000 0.000
#> GSM246488     4  0.2597      0.743 0.000 0.176 0.000 0.824 0.000 0.000
#> GSM246489     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0146      0.969 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM246491     2  0.0146      0.969 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM247162     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0146      0.969 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM247164     2  0.0146      0.969 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM247165     2  0.3515      0.330 0.000 0.676 0.000 0.324 0.000 0.000
#> GSM247166     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     4  0.3647      0.592 0.000 0.360 0.000 0.640 0.000 0.000
#> GSM247190     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247651     1  0.0363      0.955 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM247652     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247653     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247654     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247655     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247656     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247657     1  0.1075      0.953 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM247658     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247659     1  0.1075      0.953 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM247660     1  0.0363      0.955 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM247661     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247662     1  0.1075      0.953 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM247663     1  0.0363      0.954 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM247856     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247857     1  0.1075      0.953 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM247859     1  0.0363      0.955 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM247860     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247862     1  0.0458      0.958 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM247864     1  0.0000      0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247865     1  0.4400      0.290 0.592 0.032 0.000 0.376 0.000 0.000
#> GSM247866     1  0.1007      0.953 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM247876     1  0.0547      0.952 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM247877     5  0.0000      0.605 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247878     5  0.3998      0.180 0.000 0.000 0.000 0.492 0.504 0.004
#> GSM247879     5  0.0000      0.605 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247881     1  0.0363      0.955 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM247883     1  0.0363      0.955 0.988 0.000 0.000 0.012 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-SD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:hclust 61         5.68e-14 2
#> SD:hclust 58         4.67e-19 3
#> SD:hclust 59         6.37e-21 4
#> SD:hclust 58         2.22e-21 5
#> SD:hclust 57         5.72e-21 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 21168 rows and 61 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.368           0.728       0.773         0.4111 0.541   0.541
#> 3 3 1.000           0.967       0.982         0.4589 0.820   0.677
#> 4 4 0.889           0.900       0.948         0.1583 0.889   0.722
#> 5 5 0.756           0.799       0.862         0.0723 1.000   1.000
#> 6 6 0.743           0.595       0.754         0.0527 0.919   0.732

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
#> GSM246087     1  0.9795      0.525 0.584 0.416
#> GSM246088     1  0.9795      0.525 0.584 0.416
#> GSM246089     1  0.9795      0.525 0.584 0.416
#> GSM246090     1  0.9795      0.525 0.584 0.416
#> GSM246119     1  0.9795      0.525 0.584 0.416
#> GSM246120     1  0.9795      0.525 0.584 0.416
#> GSM246121     1  0.9795      0.525 0.584 0.416
#> GSM246122     1  0.9795      0.525 0.584 0.416
#> GSM246123     1  0.9795      0.525 0.584 0.416
#> GSM246422     1  0.9977     -0.623 0.528 0.472
#> GSM246423     1  0.9977     -0.623 0.528 0.472
#> GSM246484     1  0.9977     -0.623 0.528 0.472
#> GSM246485     2  0.9710      0.868 0.400 0.600
#> GSM246486     2  0.9795      0.838 0.416 0.584
#> GSM246487     2  0.9909      0.795 0.444 0.556
#> GSM246488     2  0.9795      0.838 0.416 0.584
#> GSM246489     2  0.9000      0.967 0.316 0.684
#> GSM246490     2  0.9000      0.967 0.316 0.684
#> GSM246491     2  0.9000      0.967 0.316 0.684
#> GSM247162     2  0.9000      0.967 0.316 0.684
#> GSM247163     2  0.9000      0.967 0.316 0.684
#> GSM247164     2  0.9000      0.967 0.316 0.684
#> GSM247165     2  0.9000      0.967 0.316 0.684
#> GSM247166     2  0.9000      0.967 0.316 0.684
#> GSM247168     2  0.9000      0.967 0.316 0.684
#> GSM247169     2  0.9000      0.967 0.316 0.684
#> GSM247171     2  0.9000      0.967 0.316 0.684
#> GSM247173     2  0.9000      0.967 0.316 0.684
#> GSM247174     2  0.9000      0.967 0.316 0.684
#> GSM247175     2  0.9000      0.967 0.316 0.684
#> GSM247188     2  0.9000      0.967 0.316 0.684
#> GSM247189     2  0.9000      0.967 0.316 0.684
#> GSM247190     2  0.9000      0.967 0.316 0.684
#> GSM247650     1  0.0376      0.780 0.996 0.004
#> GSM247651     1  0.1633      0.779 0.976 0.024
#> GSM247652     1  0.1633      0.779 0.976 0.024
#> GSM247653     1  0.0376      0.780 0.996 0.004
#> GSM247654     1  0.1633      0.779 0.976 0.024
#> GSM247655     1  0.1633      0.779 0.976 0.024
#> GSM247656     1  0.0376      0.780 0.996 0.004
#> GSM247657     1  0.1633      0.779 0.976 0.024
#> GSM247658     1  0.1633      0.779 0.976 0.024
#> GSM247659     1  0.0376      0.780 0.996 0.004
#> GSM247660     1  0.1633      0.779 0.976 0.024
#> GSM247661     1  0.0376      0.780 0.996 0.004
#> GSM247662     1  0.0376      0.780 0.996 0.004
#> GSM247663     1  0.0376      0.780 0.996 0.004
#> GSM247856     1  0.1414      0.780 0.980 0.020
#> GSM247857     1  0.1633      0.779 0.976 0.024
#> GSM247859     1  0.1633      0.779 0.976 0.024
#> GSM247860     1  0.0000      0.781 1.000 0.000
#> GSM247862     1  0.1633      0.779 0.976 0.024
#> GSM247864     1  0.1633      0.779 0.976 0.024
#> GSM247865     1  0.3431      0.725 0.936 0.064
#> GSM247866     1  0.1633      0.779 0.976 0.024
#> GSM247876     1  0.0000      0.781 1.000 0.000
#> GSM247877     1  0.0000      0.781 1.000 0.000
#> GSM247878     1  0.1633      0.779 0.976 0.024
#> GSM247879     1  0.0376      0.780 0.996 0.004
#> GSM247881     1  0.1633      0.779 0.976 0.024
#> GSM247883     1  0.1633      0.779 0.976 0.024

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0424      0.997 0.000 0.008 0.992
#> GSM246088     3  0.0424      0.997 0.000 0.008 0.992
#> GSM246089     3  0.0892      0.996 0.000 0.020 0.980
#> GSM246090     3  0.0424      0.997 0.000 0.008 0.992
#> GSM246119     3  0.0892      0.996 0.000 0.020 0.980
#> GSM246120     3  0.0892      0.996 0.000 0.020 0.980
#> GSM246121     3  0.0424      0.997 0.000 0.008 0.992
#> GSM246122     3  0.0424      0.997 0.000 0.008 0.992
#> GSM246123     3  0.0892      0.996 0.000 0.020 0.980
#> GSM246422     1  0.1832      0.957 0.956 0.036 0.008
#> GSM246423     1  0.1832      0.957 0.956 0.036 0.008
#> GSM246484     1  0.1832      0.957 0.956 0.036 0.008
#> GSM246485     2  0.6295      0.114 0.472 0.528 0.000
#> GSM246486     2  0.1170      0.956 0.016 0.976 0.008
#> GSM246487     1  0.1765      0.955 0.956 0.040 0.004
#> GSM246488     2  0.1170      0.956 0.016 0.976 0.008
#> GSM246489     2  0.0592      0.965 0.012 0.988 0.000
#> GSM246490     2  0.0592      0.965 0.012 0.988 0.000
#> GSM246491     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247162     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247163     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247164     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247165     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247166     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247168     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247169     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247171     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247173     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247174     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247175     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247188     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247189     2  0.0829      0.962 0.012 0.984 0.004
#> GSM247190     2  0.0592      0.965 0.012 0.988 0.000
#> GSM247650     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247651     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247652     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247653     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247654     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247655     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247656     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247657     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247658     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247659     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247660     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247661     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247662     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247663     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247856     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247857     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247859     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247860     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247862     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247876     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247877     1  0.0424      0.988 0.992 0.000 0.008
#> GSM247878     1  0.0424      0.988 0.992 0.000 0.008
#> GSM247879     1  0.0237      0.992 0.996 0.000 0.004
#> GSM247881     1  0.0000      0.992 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.992 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
#> GSM246087     3  0.0000      0.981 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      0.981 0.000 0.000 1.000 0.000
#> GSM246089     3  0.1867      0.964 0.000 0.000 0.928 0.072
#> GSM246090     3  0.0000      0.981 0.000 0.000 1.000 0.000
#> GSM246119     3  0.1389      0.975 0.000 0.000 0.952 0.048
#> GSM246120     3  0.1389      0.975 0.000 0.000 0.952 0.048
#> GSM246121     3  0.0000      0.981 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000      0.981 0.000 0.000 1.000 0.000
#> GSM246123     3  0.1389      0.975 0.000 0.000 0.952 0.048
#> GSM246422     4  0.2859      0.842 0.112 0.008 0.000 0.880
#> GSM246423     4  0.2859      0.842 0.112 0.008 0.000 0.880
#> GSM246484     4  0.2859      0.842 0.112 0.008 0.000 0.880
#> GSM246485     2  0.7483     -0.160 0.184 0.456 0.000 0.360
#> GSM246486     4  0.4624      0.441 0.000 0.340 0.000 0.660
#> GSM246487     4  0.5331      0.618 0.332 0.024 0.000 0.644
#> GSM246488     4  0.2921      0.724 0.000 0.140 0.000 0.860
#> GSM246489     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247166     2  0.1211      0.910 0.000 0.960 0.000 0.040
#> GSM247168     2  0.1211      0.910 0.000 0.960 0.000 0.040
#> GSM247169     2  0.1211      0.910 0.000 0.960 0.000 0.040
#> GSM247171     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247174     2  0.1211      0.910 0.000 0.960 0.000 0.040
#> GSM247175     2  0.0000      0.926 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0592      0.920 0.000 0.984 0.000 0.016
#> GSM247189     2  0.4925      0.166 0.000 0.572 0.000 0.428
#> GSM247190     2  0.0188      0.925 0.000 0.996 0.000 0.004
#> GSM247650     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247651     1  0.2081      0.906 0.916 0.000 0.000 0.084
#> GSM247652     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247653     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247654     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247655     1  0.0188      0.984 0.996 0.000 0.000 0.004
#> GSM247656     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247657     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247658     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247659     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247660     1  0.1716      0.929 0.936 0.000 0.000 0.064
#> GSM247661     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247662     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247663     1  0.0336      0.981 0.992 0.000 0.000 0.008
#> GSM247856     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247859     1  0.1211      0.953 0.960 0.000 0.000 0.040
#> GSM247860     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247862     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247864     1  0.0188      0.984 0.996 0.000 0.000 0.004
#> GSM247865     1  0.1867      0.921 0.928 0.000 0.000 0.072
#> GSM247866     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247876     1  0.0336      0.981 0.992 0.000 0.000 0.008
#> GSM247877     4  0.3172      0.824 0.160 0.000 0.000 0.840
#> GSM247878     4  0.3123      0.826 0.156 0.000 0.000 0.844
#> GSM247879     1  0.0707      0.972 0.980 0.000 0.000 0.020
#> GSM247881     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247883     1  0.0188      0.984 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
#> GSM246087     3  0.0000     0.9534 0.000 0.000 1.000 0.000 NA
#> GSM246088     3  0.0000     0.9534 0.000 0.000 1.000 0.000 NA
#> GSM246089     3  0.2964     0.9214 0.000 0.000 0.856 0.024 NA
#> GSM246090     3  0.0000     0.9534 0.000 0.000 1.000 0.000 NA
#> GSM246119     3  0.2304     0.9395 0.000 0.000 0.892 0.008 NA
#> GSM246120     3  0.2304     0.9395 0.000 0.000 0.892 0.008 NA
#> GSM246121     3  0.0000     0.9534 0.000 0.000 1.000 0.000 NA
#> GSM246122     3  0.0000     0.9534 0.000 0.000 1.000 0.000 NA
#> GSM246123     3  0.2304     0.9395 0.000 0.000 0.892 0.008 NA
#> GSM246422     4  0.0963     0.7390 0.036 0.000 0.000 0.964 NA
#> GSM246423     4  0.0963     0.7390 0.036 0.000 0.000 0.964 NA
#> GSM246484     4  0.0963     0.7390 0.036 0.000 0.000 0.964 NA
#> GSM246485     2  0.8456    -0.3225 0.164 0.312 0.000 0.276 NA
#> GSM246486     4  0.6538     0.3815 0.000 0.272 0.000 0.480 NA
#> GSM246487     4  0.6755     0.4646 0.296 0.004 0.000 0.452 NA
#> GSM246488     4  0.4693     0.6551 0.000 0.056 0.000 0.700 NA
#> GSM246489     2  0.0000     0.8805 0.000 1.000 0.000 0.000 NA
#> GSM246490     2  0.0609     0.8766 0.000 0.980 0.000 0.000 NA
#> GSM246491     2  0.0609     0.8766 0.000 0.980 0.000 0.000 NA
#> GSM247162     2  0.0000     0.8805 0.000 1.000 0.000 0.000 NA
#> GSM247163     2  0.1121     0.8665 0.000 0.956 0.000 0.000 NA
#> GSM247164     2  0.0880     0.8721 0.000 0.968 0.000 0.000 NA
#> GSM247165     2  0.2377     0.8009 0.000 0.872 0.000 0.000 NA
#> GSM247166     2  0.2377     0.8292 0.000 0.872 0.000 0.000 NA
#> GSM247168     2  0.2377     0.8292 0.000 0.872 0.000 0.000 NA
#> GSM247169     2  0.2377     0.8292 0.000 0.872 0.000 0.000 NA
#> GSM247171     2  0.0000     0.8805 0.000 1.000 0.000 0.000 NA
#> GSM247173     2  0.0000     0.8805 0.000 1.000 0.000 0.000 NA
#> GSM247174     2  0.2127     0.8389 0.000 0.892 0.000 0.000 NA
#> GSM247175     2  0.0000     0.8805 0.000 1.000 0.000 0.000 NA
#> GSM247188     2  0.0510     0.8780 0.000 0.984 0.000 0.000 NA
#> GSM247189     2  0.6458     0.0988 0.000 0.496 0.000 0.280 NA
#> GSM247190     2  0.0609     0.8772 0.000 0.980 0.000 0.000 NA
#> GSM247650     1  0.2230     0.8544 0.884 0.000 0.000 0.000 NA
#> GSM247651     1  0.3601     0.8132 0.820 0.000 0.000 0.052 NA
#> GSM247652     1  0.1341     0.8734 0.944 0.000 0.000 0.000 NA
#> GSM247653     1  0.3210     0.8173 0.788 0.000 0.000 0.000 NA
#> GSM247654     1  0.2732     0.8414 0.840 0.000 0.000 0.000 NA
#> GSM247655     1  0.2513     0.8455 0.876 0.000 0.000 0.008 NA
#> GSM247656     1  0.2179     0.8618 0.888 0.000 0.000 0.000 NA
#> GSM247657     1  0.2127     0.8593 0.892 0.000 0.000 0.000 NA
#> GSM247658     1  0.1851     0.8665 0.912 0.000 0.000 0.000 NA
#> GSM247659     1  0.2127     0.8623 0.892 0.000 0.000 0.000 NA
#> GSM247660     1  0.3229     0.8264 0.840 0.000 0.000 0.032 NA
#> GSM247661     1  0.3210     0.8173 0.788 0.000 0.000 0.000 NA
#> GSM247662     1  0.2074     0.8625 0.896 0.000 0.000 0.000 NA
#> GSM247663     1  0.3835     0.7670 0.744 0.000 0.000 0.012 NA
#> GSM247856     1  0.0703     0.8736 0.976 0.000 0.000 0.000 NA
#> GSM247857     1  0.2020     0.8631 0.900 0.000 0.000 0.000 NA
#> GSM247859     1  0.1836     0.8592 0.932 0.000 0.000 0.032 NA
#> GSM247860     1  0.3210     0.8173 0.788 0.000 0.000 0.000 NA
#> GSM247862     1  0.1478     0.8736 0.936 0.000 0.000 0.000 NA
#> GSM247864     1  0.2612     0.8431 0.868 0.000 0.000 0.008 NA
#> GSM247865     1  0.2304     0.8515 0.908 0.000 0.000 0.044 NA
#> GSM247866     1  0.3242     0.8257 0.784 0.000 0.000 0.000 NA
#> GSM247876     1  0.3807     0.7665 0.748 0.000 0.000 0.012 NA
#> GSM247877     4  0.4924     0.6337 0.060 0.000 0.000 0.668 NA
#> GSM247878     4  0.4901     0.6357 0.060 0.000 0.000 0.672 NA
#> GSM247879     1  0.4787     0.6226 0.640 0.000 0.000 0.036 NA
#> GSM247881     1  0.0703     0.8716 0.976 0.000 0.000 0.000 NA
#> GSM247883     1  0.1124     0.8665 0.960 0.000 0.000 0.004 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000     0.9185 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000     0.9185 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.4645     0.8544 0.000 0.000 0.752 0.080 0.080 0.088
#> GSM246090     3  0.0000     0.9185 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.3695     0.8937 0.000 0.000 0.820 0.044 0.052 0.084
#> GSM246120     3  0.3695     0.8937 0.000 0.000 0.820 0.044 0.052 0.084
#> GSM246121     3  0.0146     0.9183 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM246122     3  0.0146     0.9183 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM246123     3  0.3695     0.8937 0.000 0.000 0.820 0.044 0.052 0.084
#> GSM246422     4  0.4726     0.3519 0.000 0.000 0.000 0.528 0.424 0.048
#> GSM246423     4  0.4726     0.3519 0.000 0.000 0.000 0.528 0.424 0.048
#> GSM246484     4  0.4726     0.3519 0.000 0.000 0.000 0.528 0.424 0.048
#> GSM246485     4  0.5272     0.4209 0.104 0.256 0.000 0.624 0.000 0.016
#> GSM246486     4  0.2920     0.5177 0.008 0.168 0.000 0.820 0.000 0.004
#> GSM246487     4  0.3441     0.3429 0.216 0.004 0.000 0.768 0.004 0.008
#> GSM246488     4  0.2637     0.5022 0.000 0.024 0.000 0.872 0.096 0.008
#> GSM246489     2  0.0000     0.8905 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.1257     0.8770 0.000 0.952 0.000 0.028 0.000 0.020
#> GSM246491     2  0.1257     0.8770 0.000 0.952 0.000 0.028 0.000 0.020
#> GSM247162     2  0.0000     0.8905 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.1549     0.8682 0.000 0.936 0.000 0.044 0.000 0.020
#> GSM247164     2  0.1549     0.8682 0.000 0.936 0.000 0.044 0.000 0.020
#> GSM247165     2  0.2536     0.8013 0.000 0.864 0.000 0.116 0.000 0.020
#> GSM247166     2  0.4394     0.6894 0.000 0.688 0.000 0.028 0.020 0.264
#> GSM247168     2  0.4394     0.6894 0.000 0.688 0.000 0.028 0.020 0.264
#> GSM247169     2  0.4394     0.6894 0.000 0.688 0.000 0.028 0.020 0.264
#> GSM247171     2  0.0000     0.8905 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.8905 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.3090     0.8012 0.000 0.828 0.000 0.028 0.004 0.140
#> GSM247175     2  0.0000     0.8905 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0508     0.8872 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM247189     4  0.4172     0.0899 0.000 0.460 0.000 0.528 0.000 0.012
#> GSM247190     2  0.1124     0.8776 0.000 0.956 0.000 0.008 0.000 0.036
#> GSM247650     1  0.2094     0.6019 0.900 0.000 0.000 0.000 0.080 0.020
#> GSM247651     1  0.3346     0.5862 0.840 0.000 0.000 0.056 0.080 0.024
#> GSM247652     1  0.3050     0.2317 0.764 0.000 0.000 0.000 0.000 0.236
#> GSM247653     6  0.3851     0.9749 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM247654     1  0.3923    -0.5746 0.580 0.000 0.000 0.000 0.004 0.416
#> GSM247655     1  0.2755     0.6049 0.876 0.000 0.000 0.040 0.068 0.016
#> GSM247656     1  0.3679     0.1499 0.724 0.000 0.000 0.004 0.012 0.260
#> GSM247657     1  0.3702     0.1148 0.720 0.000 0.000 0.004 0.012 0.264
#> GSM247658     1  0.3244     0.0933 0.732 0.000 0.000 0.000 0.000 0.268
#> GSM247659     1  0.3680     0.2363 0.744 0.000 0.000 0.004 0.020 0.232
#> GSM247660     1  0.3238     0.5906 0.848 0.000 0.000 0.056 0.072 0.024
#> GSM247661     6  0.4076     0.9599 0.452 0.000 0.000 0.000 0.008 0.540
#> GSM247662     1  0.3329     0.3598 0.792 0.000 0.000 0.004 0.020 0.184
#> GSM247663     1  0.4198     0.4200 0.708 0.000 0.000 0.000 0.232 0.060
#> GSM247856     1  0.2001     0.5396 0.900 0.000 0.000 0.004 0.004 0.092
#> GSM247857     1  0.3329     0.3598 0.792 0.000 0.000 0.004 0.020 0.184
#> GSM247859     1  0.1984     0.6068 0.912 0.000 0.000 0.056 0.000 0.032
#> GSM247860     6  0.3854     0.9726 0.464 0.000 0.000 0.000 0.000 0.536
#> GSM247862     1  0.1908     0.5540 0.900 0.000 0.000 0.004 0.000 0.096
#> GSM247864     1  0.2911     0.6040 0.868 0.000 0.000 0.036 0.072 0.024
#> GSM247865     1  0.2288     0.5962 0.896 0.000 0.000 0.072 0.004 0.028
#> GSM247866     1  0.4659    -0.0635 0.624 0.000 0.000 0.004 0.052 0.320
#> GSM247876     1  0.4075     0.4200 0.712 0.000 0.000 0.000 0.240 0.048
#> GSM247877     5  0.2412     0.4355 0.028 0.000 0.000 0.092 0.880 0.000
#> GSM247878     5  0.2412     0.4355 0.028 0.000 0.000 0.092 0.880 0.000
#> GSM247879     5  0.4650    -0.1819 0.472 0.000 0.000 0.000 0.488 0.040
#> GSM247881     1  0.0767     0.5977 0.976 0.000 0.000 0.004 0.012 0.008
#> GSM247883     1  0.1633     0.6086 0.932 0.000 0.000 0.044 0.000 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-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:kmeans 58         2.54e-13 2
#> SD:kmeans 60         1.88e-21 3
#> SD:kmeans 58         3.15e-21 4
#> SD:kmeans 57         6.85e-21 5
#> SD:kmeans 41         1.93e-14 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.982       0.993         0.4901 0.508   0.508
#> 3 3 0.869           0.894       0.951         0.3748 0.722   0.500
#> 4 4 0.858           0.872       0.944         0.1049 0.786   0.463
#> 5 5 0.791           0.680       0.852         0.0707 0.884   0.595
#> 6 6 0.799           0.660       0.799         0.0333 0.918   0.641

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
#> GSM246087     1   0.000      0.999 1.000 0.000
#> GSM246088     1   0.000      0.999 1.000 0.000
#> GSM246089     1   0.000      0.999 1.000 0.000
#> GSM246090     1   0.000      0.999 1.000 0.000
#> GSM246119     1   0.000      0.999 1.000 0.000
#> GSM246120     1   0.000      0.999 1.000 0.000
#> GSM246121     1   0.000      0.999 1.000 0.000
#> GSM246122     1   0.000      0.999 1.000 0.000
#> GSM246123     1   0.000      0.999 1.000 0.000
#> GSM246422     2   0.000      0.984 0.000 1.000
#> GSM246423     2   0.000      0.984 0.000 1.000
#> GSM246484     2   0.000      0.984 0.000 1.000
#> GSM246485     2   0.000      0.984 0.000 1.000
#> GSM246486     2   0.000      0.984 0.000 1.000
#> GSM246487     2   0.000      0.984 0.000 1.000
#> GSM246488     2   0.000      0.984 0.000 1.000
#> GSM246489     2   0.000      0.984 0.000 1.000
#> GSM246490     2   0.000      0.984 0.000 1.000
#> GSM246491     2   0.000      0.984 0.000 1.000
#> GSM247162     2   0.000      0.984 0.000 1.000
#> GSM247163     2   0.000      0.984 0.000 1.000
#> GSM247164     2   0.000      0.984 0.000 1.000
#> GSM247165     2   0.000      0.984 0.000 1.000
#> GSM247166     2   0.000      0.984 0.000 1.000
#> GSM247168     2   0.000      0.984 0.000 1.000
#> GSM247169     2   0.000      0.984 0.000 1.000
#> GSM247171     2   0.000      0.984 0.000 1.000
#> GSM247173     2   0.000      0.984 0.000 1.000
#> GSM247174     2   0.000      0.984 0.000 1.000
#> GSM247175     2   0.000      0.984 0.000 1.000
#> GSM247188     2   0.000      0.984 0.000 1.000
#> GSM247189     2   0.000      0.984 0.000 1.000
#> GSM247190     2   0.000      0.984 0.000 1.000
#> GSM247650     1   0.000      0.999 1.000 0.000
#> GSM247651     1   0.000      0.999 1.000 0.000
#> GSM247652     1   0.000      0.999 1.000 0.000
#> GSM247653     1   0.000      0.999 1.000 0.000
#> GSM247654     1   0.000      0.999 1.000 0.000
#> GSM247655     1   0.000      0.999 1.000 0.000
#> GSM247656     1   0.000      0.999 1.000 0.000
#> GSM247657     1   0.000      0.999 1.000 0.000
#> GSM247658     1   0.000      0.999 1.000 0.000
#> GSM247659     1   0.000      0.999 1.000 0.000
#> GSM247660     1   0.000      0.999 1.000 0.000
#> GSM247661     1   0.000      0.999 1.000 0.000
#> GSM247662     1   0.000      0.999 1.000 0.000
#> GSM247663     1   0.000      0.999 1.000 0.000
#> GSM247856     1   0.000      0.999 1.000 0.000
#> GSM247857     1   0.000      0.999 1.000 0.000
#> GSM247859     1   0.000      0.999 1.000 0.000
#> GSM247860     1   0.000      0.999 1.000 0.000
#> GSM247862     1   0.000      0.999 1.000 0.000
#> GSM247864     1   0.000      0.999 1.000 0.000
#> GSM247865     2   0.952      0.405 0.372 0.628
#> GSM247866     1   0.000      0.999 1.000 0.000
#> GSM247876     1   0.000      0.999 1.000 0.000
#> GSM247877     1   0.000      0.999 1.000 0.000
#> GSM247878     1   0.000      0.999 1.000 0.000
#> GSM247879     1   0.000      0.999 1.000 0.000
#> GSM247881     1   0.000      0.999 1.000 0.000
#> GSM247883     1   0.278      0.948 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.910 0.000 0.000 1.000
#> GSM246422     1  0.0747      0.917 0.984 0.016 0.000
#> GSM246423     1  0.0747      0.917 0.984 0.016 0.000
#> GSM246484     1  0.0747      0.917 0.984 0.016 0.000
#> GSM246485     2  0.0424      0.990 0.008 0.992 0.000
#> GSM246486     2  0.1031      0.977 0.024 0.976 0.000
#> GSM246487     1  0.3267      0.825 0.884 0.116 0.000
#> GSM246488     2  0.1643      0.958 0.044 0.956 0.000
#> GSM246489     2  0.0000      0.996 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.996 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247189     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247190     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247650     1  0.2878      0.860 0.904 0.000 0.096
#> GSM247651     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247652     1  0.6026      0.320 0.624 0.000 0.376
#> GSM247653     3  0.0747      0.906 0.016 0.000 0.984
#> GSM247654     3  0.4654      0.766 0.208 0.000 0.792
#> GSM247655     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247656     3  0.2711      0.866 0.088 0.000 0.912
#> GSM247657     3  0.4750      0.757 0.216 0.000 0.784
#> GSM247658     1  0.1964      0.894 0.944 0.000 0.056
#> GSM247659     3  0.0000      0.910 0.000 0.000 1.000
#> GSM247660     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247661     3  0.0747      0.906 0.016 0.000 0.984
#> GSM247662     3  0.4504      0.779 0.196 0.000 0.804
#> GSM247663     1  0.2625      0.872 0.916 0.000 0.084
#> GSM247856     3  0.6267      0.256 0.452 0.000 0.548
#> GSM247857     3  0.5327      0.680 0.272 0.000 0.728
#> GSM247859     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247860     3  0.0892      0.905 0.020 0.000 0.980
#> GSM247862     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247876     1  0.2261      0.890 0.932 0.000 0.068
#> GSM247877     1  0.4291      0.761 0.820 0.000 0.180
#> GSM247878     1  0.0000      0.924 1.000 0.000 0.000
#> GSM247879     1  0.6045      0.445 0.620 0.000 0.380
#> GSM247881     1  0.0237      0.923 0.996 0.000 0.004
#> GSM247883     1  0.0000      0.924 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
#> GSM246087     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000      0.865 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000      0.865 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000      0.865 0.000 0.000 0.000 1.000
#> GSM246485     2  0.4790      0.441 0.000 0.620 0.000 0.380
#> GSM246486     4  0.1302      0.838 0.000 0.044 0.000 0.956
#> GSM246487     4  0.0000      0.865 0.000 0.000 0.000 1.000
#> GSM246488     4  0.0707      0.855 0.000 0.020 0.000 0.980
#> GSM246489     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247189     2  0.3610      0.757 0.000 0.800 0.000 0.200
#> GSM247190     2  0.0000      0.966 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0336      0.909 0.992 0.000 0.000 0.008
#> GSM247651     4  0.4522      0.543 0.320 0.000 0.000 0.680
#> GSM247652     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> GSM247653     1  0.0469      0.906 0.988 0.000 0.012 0.000
#> GSM247654     1  0.0188      0.908 0.996 0.000 0.004 0.000
#> GSM247655     1  0.2647      0.825 0.880 0.000 0.000 0.120
#> GSM247656     1  0.4916      0.250 0.576 0.000 0.424 0.000
#> GSM247657     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> GSM247658     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> GSM247659     3  0.0921      0.962 0.028 0.000 0.972 0.000
#> GSM247660     4  0.4624      0.501 0.340 0.000 0.000 0.660
#> GSM247661     1  0.1022      0.896 0.968 0.000 0.032 0.000
#> GSM247662     1  0.2469      0.831 0.892 0.000 0.108 0.000
#> GSM247663     1  0.0469      0.907 0.988 0.000 0.000 0.012
#> GSM247856     1  0.0707      0.904 0.980 0.000 0.020 0.000
#> GSM247857     1  0.0000      0.909 1.000 0.000 0.000 0.000
#> GSM247859     1  0.4643      0.456 0.656 0.000 0.000 0.344
#> GSM247860     1  0.0817      0.900 0.976 0.000 0.024 0.000
#> GSM247862     1  0.0188      0.909 0.996 0.000 0.000 0.004
#> GSM247864     1  0.3528      0.743 0.808 0.000 0.000 0.192
#> GSM247865     4  0.3764      0.700 0.216 0.000 0.000 0.784
#> GSM247866     1  0.0336      0.908 0.992 0.000 0.000 0.008
#> GSM247876     1  0.1042      0.903 0.972 0.000 0.008 0.020
#> GSM247877     4  0.3219      0.711 0.000 0.000 0.164 0.836
#> GSM247878     4  0.0000      0.865 0.000 0.000 0.000 1.000
#> GSM247879     3  0.2919      0.889 0.044 0.000 0.896 0.060
#> GSM247881     1  0.0336      0.909 0.992 0.000 0.000 0.008
#> GSM247883     1  0.4008      0.658 0.756 0.000 0.000 0.244

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM246087     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246090     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0162      0.772 0.004 0.000 0.000 0.996 0.000
#> GSM246423     4  0.0162      0.772 0.004 0.000 0.000 0.996 0.000
#> GSM246484     4  0.0162      0.772 0.004 0.000 0.000 0.996 0.000
#> GSM246485     4  0.4455      0.231 0.000 0.404 0.000 0.588 0.008
#> GSM246486     4  0.0794      0.763 0.000 0.028 0.000 0.972 0.000
#> GSM246487     4  0.0566      0.769 0.012 0.004 0.000 0.984 0.000
#> GSM246488     4  0.0510      0.769 0.000 0.016 0.000 0.984 0.000
#> GSM246489     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM246491     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM247164     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM247165     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM247166     2  0.0162      0.970 0.000 0.996 0.000 0.000 0.004
#> GSM247168     2  0.0162      0.970 0.000 0.996 0.000 0.000 0.004
#> GSM247169     2  0.0162      0.970 0.000 0.996 0.000 0.000 0.004
#> GSM247171     2  0.0162      0.970 0.004 0.996 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0162      0.970 0.000 0.996 0.000 0.000 0.004
#> GSM247175     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM247189     2  0.4310      0.305 0.004 0.604 0.000 0.392 0.000
#> GSM247190     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.2170      0.588 0.904 0.000 0.004 0.004 0.088
#> GSM247651     1  0.4083      0.579 0.744 0.000 0.000 0.228 0.028
#> GSM247652     5  0.3366      0.570 0.232 0.000 0.000 0.000 0.768
#> GSM247653     5  0.1408      0.685 0.044 0.000 0.008 0.000 0.948
#> GSM247654     5  0.0963      0.688 0.036 0.000 0.000 0.000 0.964
#> GSM247655     1  0.3427      0.587 0.836 0.000 0.000 0.056 0.108
#> GSM247656     5  0.5091      0.499 0.084 0.000 0.244 0.000 0.672
#> GSM247657     5  0.2280      0.667 0.120 0.000 0.000 0.000 0.880
#> GSM247658     5  0.3876      0.440 0.316 0.000 0.000 0.000 0.684
#> GSM247659     3  0.4575      0.603 0.052 0.000 0.712 0.000 0.236
#> GSM247660     1  0.3929      0.593 0.764 0.000 0.000 0.208 0.028
#> GSM247661     5  0.1893      0.682 0.048 0.000 0.024 0.000 0.928
#> GSM247662     5  0.5652      0.388 0.344 0.000 0.092 0.000 0.564
#> GSM247663     1  0.3421      0.516 0.788 0.000 0.000 0.008 0.204
#> GSM247856     5  0.5071      0.182 0.424 0.000 0.036 0.000 0.540
#> GSM247857     5  0.4470      0.402 0.372 0.000 0.012 0.000 0.616
#> GSM247859     1  0.6111      0.362 0.560 0.000 0.000 0.180 0.260
#> GSM247860     5  0.2110      0.678 0.072 0.000 0.016 0.000 0.912
#> GSM247862     1  0.4449      0.044 0.512 0.000 0.000 0.004 0.484
#> GSM247864     1  0.2983      0.605 0.868 0.000 0.000 0.056 0.076
#> GSM247865     4  0.5044     -0.122 0.464 0.000 0.000 0.504 0.032
#> GSM247866     1  0.4510      0.226 0.560 0.000 0.000 0.008 0.432
#> GSM247876     1  0.3541      0.561 0.824 0.000 0.012 0.020 0.144
#> GSM247877     4  0.5714      0.153 0.412 0.000 0.072 0.512 0.004
#> GSM247878     1  0.4227      0.126 0.580 0.000 0.000 0.420 0.000
#> GSM247879     1  0.5439      0.312 0.596 0.000 0.348 0.032 0.024
#> GSM247881     1  0.4126      0.168 0.620 0.000 0.000 0.000 0.380
#> GSM247883     1  0.5325      0.326 0.616 0.000 0.000 0.076 0.308

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000    0.94453 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000    0.94453 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.0146    0.94486 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM246090     3  0.0000    0.94453 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0146    0.94486 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM246120     3  0.0146    0.94486 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM246121     3  0.0146    0.94486 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM246122     3  0.0000    0.94453 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0146    0.94486 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM246422     4  0.1141    0.84551 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM246423     4  0.1141    0.84551 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM246484     4  0.1141    0.84551 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM246485     4  0.4662    0.41066 0.004 0.332 0.000 0.620 0.040 0.004
#> GSM246486     4  0.1261    0.83093 0.000 0.024 0.000 0.952 0.024 0.000
#> GSM246487     4  0.2001    0.80238 0.048 0.000 0.000 0.912 0.040 0.000
#> GSM246488     4  0.0291    0.84298 0.000 0.004 0.000 0.992 0.004 0.000
#> GSM246489     2  0.0146    0.95928 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM246490     2  0.0551    0.95621 0.004 0.984 0.000 0.008 0.000 0.004
#> GSM246491     2  0.0146    0.95875 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0146    0.95927 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0291    0.95770 0.004 0.992 0.000 0.004 0.000 0.000
#> GSM247164     2  0.0520    0.95438 0.008 0.984 0.000 0.008 0.000 0.000
#> GSM247165     2  0.0717    0.94920 0.008 0.976 0.000 0.016 0.000 0.000
#> GSM247166     2  0.0767    0.95308 0.008 0.976 0.000 0.000 0.012 0.004
#> GSM247168     2  0.0767    0.95308 0.008 0.976 0.000 0.000 0.012 0.004
#> GSM247169     2  0.0767    0.95308 0.008 0.976 0.000 0.000 0.012 0.004
#> GSM247171     2  0.0000    0.95924 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0146    0.95924 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0405    0.95754 0.008 0.988 0.000 0.000 0.004 0.000
#> GSM247175     2  0.0000    0.95924 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0291    0.95849 0.004 0.992 0.000 0.000 0.004 0.000
#> GSM247189     2  0.4886    0.04426 0.012 0.520 0.000 0.432 0.036 0.000
#> GSM247190     2  0.0000    0.95924 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.4971    0.16501 0.508 0.000 0.000 0.000 0.424 0.068
#> GSM247651     1  0.6050    0.35464 0.512 0.000 0.000 0.172 0.296 0.020
#> GSM247652     6  0.4932    0.36761 0.372 0.000 0.000 0.000 0.072 0.556
#> GSM247653     6  0.0820    0.61817 0.012 0.000 0.000 0.000 0.016 0.972
#> GSM247654     6  0.1643    0.61172 0.068 0.000 0.000 0.000 0.008 0.924
#> GSM247655     1  0.4430    0.49533 0.708 0.000 0.000 0.032 0.232 0.028
#> GSM247656     6  0.6882    0.25616 0.284 0.000 0.180 0.000 0.084 0.452
#> GSM247657     6  0.4674    0.37124 0.332 0.000 0.000 0.000 0.060 0.608
#> GSM247658     6  0.4827    0.41658 0.276 0.000 0.000 0.000 0.092 0.632
#> GSM247659     3  0.6604    0.31715 0.220 0.000 0.532 0.000 0.104 0.144
#> GSM247660     1  0.5798    0.41401 0.568 0.000 0.000 0.140 0.268 0.024
#> GSM247661     6  0.1515    0.61006 0.028 0.000 0.008 0.000 0.020 0.944
#> GSM247662     1  0.6202    0.13141 0.560 0.000 0.060 0.000 0.140 0.240
#> GSM247663     5  0.5037    0.44665 0.172 0.000 0.000 0.000 0.640 0.188
#> GSM247856     1  0.6714   -0.12353 0.432 0.000 0.048 0.004 0.176 0.340
#> GSM247857     1  0.5250    0.16678 0.612 0.000 0.008 0.000 0.116 0.264
#> GSM247859     1  0.5374    0.49042 0.688 0.000 0.000 0.112 0.096 0.104
#> GSM247860     6  0.1564    0.61379 0.024 0.000 0.000 0.000 0.040 0.936
#> GSM247862     6  0.5384    0.00606 0.428 0.000 0.000 0.004 0.096 0.472
#> GSM247864     1  0.4511    0.45599 0.672 0.000 0.000 0.036 0.276 0.016
#> GSM247865     1  0.5912    0.27484 0.488 0.000 0.000 0.364 0.128 0.020
#> GSM247866     6  0.5839    0.15544 0.276 0.000 0.000 0.000 0.236 0.488
#> GSM247876     5  0.4162    0.58517 0.144 0.000 0.000 0.004 0.752 0.100
#> GSM247877     5  0.3812    0.61277 0.012 0.000 0.012 0.248 0.728 0.000
#> GSM247878     5  0.4294    0.59826 0.060 0.000 0.000 0.248 0.692 0.000
#> GSM247879     5  0.4624    0.60605 0.068 0.000 0.124 0.020 0.760 0.028
#> GSM247881     1  0.3962    0.45783 0.764 0.000 0.000 0.000 0.116 0.120
#> GSM247883     1  0.3225    0.51860 0.852 0.000 0.000 0.036 0.064 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-SD-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) k
#> SD:skmeans 60         9.36e-14 2
#> SD:skmeans 58         1.47e-12 3
#> SD:skmeans 58         5.27e-17 4
#> SD:skmeans 45         1.46e-14 5
#> SD:skmeans 40         5.02e-13 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 21168 rows and 61 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           0.972       0.987         0.4560 0.552   0.552
#> 3 3 1.000           0.999       1.000         0.3283 0.843   0.715
#> 4 4 1.000           0.963       0.987         0.1144 0.926   0.814
#> 5 5 0.858           0.811       0.914         0.1411 0.907   0.713
#> 6 6 0.839           0.726       0.877         0.0178 0.979   0.912

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
#> GSM246087     1  0.8207      0.676 0.744 0.256
#> GSM246088     1  0.0938      0.971 0.988 0.012
#> GSM246089     1  0.0000      0.981 1.000 0.000
#> GSM246090     1  0.2778      0.939 0.952 0.048
#> GSM246119     1  0.0000      0.981 1.000 0.000
#> GSM246120     1  0.0000      0.981 1.000 0.000
#> GSM246121     1  0.6712      0.794 0.824 0.176
#> GSM246122     1  0.8443      0.649 0.728 0.272
#> GSM246123     1  0.0000      0.981 1.000 0.000
#> GSM246422     1  0.0000      0.981 1.000 0.000
#> GSM246423     1  0.0000      0.981 1.000 0.000
#> GSM246484     1  0.0376      0.978 0.996 0.004
#> GSM246485     2  0.0672      0.992 0.008 0.992
#> GSM246486     2  0.0000      0.999 0.000 1.000
#> GSM246487     1  0.0376      0.978 0.996 0.004
#> GSM246488     2  0.0000      0.999 0.000 1.000
#> GSM246489     2  0.0000      0.999 0.000 1.000
#> GSM246490     2  0.0000      0.999 0.000 1.000
#> GSM246491     2  0.0000      0.999 0.000 1.000
#> GSM247162     2  0.0000      0.999 0.000 1.000
#> GSM247163     2  0.0000      0.999 0.000 1.000
#> GSM247164     2  0.0000      0.999 0.000 1.000
#> GSM247165     2  0.0000      0.999 0.000 1.000
#> GSM247166     2  0.0000      0.999 0.000 1.000
#> GSM247168     2  0.0000      0.999 0.000 1.000
#> GSM247169     2  0.0000      0.999 0.000 1.000
#> GSM247171     2  0.0000      0.999 0.000 1.000
#> GSM247173     2  0.0000      0.999 0.000 1.000
#> GSM247174     2  0.0000      0.999 0.000 1.000
#> GSM247175     2  0.0000      0.999 0.000 1.000
#> GSM247188     2  0.0000      0.999 0.000 1.000
#> GSM247189     2  0.0376      0.996 0.004 0.996
#> GSM247190     2  0.0000      0.999 0.000 1.000
#> GSM247650     1  0.0000      0.981 1.000 0.000
#> GSM247651     1  0.0000      0.981 1.000 0.000
#> GSM247652     1  0.0000      0.981 1.000 0.000
#> GSM247653     1  0.0000      0.981 1.000 0.000
#> GSM247654     1  0.0000      0.981 1.000 0.000
#> GSM247655     1  0.0000      0.981 1.000 0.000
#> GSM247656     1  0.0000      0.981 1.000 0.000
#> GSM247657     1  0.0000      0.981 1.000 0.000
#> GSM247658     1  0.0000      0.981 1.000 0.000
#> GSM247659     1  0.0000      0.981 1.000 0.000
#> GSM247660     1  0.0000      0.981 1.000 0.000
#> GSM247661     1  0.0000      0.981 1.000 0.000
#> GSM247662     1  0.0000      0.981 1.000 0.000
#> GSM247663     1  0.0000      0.981 1.000 0.000
#> GSM247856     1  0.0000      0.981 1.000 0.000
#> GSM247857     1  0.0000      0.981 1.000 0.000
#> GSM247859     1  0.0000      0.981 1.000 0.000
#> GSM247860     1  0.0000      0.981 1.000 0.000
#> GSM247862     1  0.0000      0.981 1.000 0.000
#> GSM247864     1  0.0000      0.981 1.000 0.000
#> GSM247865     1  0.0000      0.981 1.000 0.000
#> GSM247866     1  0.0000      0.981 1.000 0.000
#> GSM247876     1  0.0000      0.981 1.000 0.000
#> GSM247877     1  0.0000      0.981 1.000 0.000
#> GSM247878     1  0.0000      0.981 1.000 0.000
#> GSM247879     1  0.0000      0.981 1.000 0.000
#> GSM247881     1  0.0000      0.981 1.000 0.000
#> GSM247883     1  0.0000      0.981 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1
#> GSM246088     3  0.0000      1.000 0.000 0.000  1
#> GSM246089     3  0.0000      1.000 0.000 0.000  1
#> GSM246090     3  0.0000      1.000 0.000 0.000  1
#> GSM246119     3  0.0000      1.000 0.000 0.000  1
#> GSM246120     3  0.0000      1.000 0.000 0.000  1
#> GSM246121     3  0.0000      1.000 0.000 0.000  1
#> GSM246122     3  0.0000      1.000 0.000 0.000  1
#> GSM246123     3  0.0000      1.000 0.000 0.000  1
#> GSM246422     1  0.0000      1.000 1.000 0.000  0
#> GSM246423     1  0.0000      1.000 1.000 0.000  0
#> GSM246484     1  0.0000      1.000 1.000 0.000  0
#> GSM246485     2  0.0592      0.984 0.012 0.988  0
#> GSM246486     2  0.0000      0.999 0.000 1.000  0
#> GSM246487     1  0.0000      1.000 1.000 0.000  0
#> GSM246488     2  0.0000      0.999 0.000 1.000  0
#> GSM246489     2  0.0000      0.999 0.000 1.000  0
#> GSM246490     2  0.0000      0.999 0.000 1.000  0
#> GSM246491     2  0.0000      0.999 0.000 1.000  0
#> GSM247162     2  0.0000      0.999 0.000 1.000  0
#> GSM247163     2  0.0000      0.999 0.000 1.000  0
#> GSM247164     2  0.0000      0.999 0.000 1.000  0
#> GSM247165     2  0.0000      0.999 0.000 1.000  0
#> GSM247166     2  0.0000      0.999 0.000 1.000  0
#> GSM247168     2  0.0000      0.999 0.000 1.000  0
#> GSM247169     2  0.0000      0.999 0.000 1.000  0
#> GSM247171     2  0.0000      0.999 0.000 1.000  0
#> GSM247173     2  0.0000      0.999 0.000 1.000  0
#> GSM247174     2  0.0000      0.999 0.000 1.000  0
#> GSM247175     2  0.0000      0.999 0.000 1.000  0
#> GSM247188     2  0.0000      0.999 0.000 1.000  0
#> GSM247189     2  0.0237      0.994 0.004 0.996  0
#> GSM247190     2  0.0000      0.999 0.000 1.000  0
#> GSM247650     1  0.0000      1.000 1.000 0.000  0
#> GSM247651     1  0.0000      1.000 1.000 0.000  0
#> GSM247652     1  0.0000      1.000 1.000 0.000  0
#> GSM247653     1  0.0000      1.000 1.000 0.000  0
#> GSM247654     1  0.0000      1.000 1.000 0.000  0
#> GSM247655     1  0.0000      1.000 1.000 0.000  0
#> GSM247656     1  0.0000      1.000 1.000 0.000  0
#> GSM247657     1  0.0000      1.000 1.000 0.000  0
#> GSM247658     1  0.0000      1.000 1.000 0.000  0
#> GSM247659     1  0.0000      1.000 1.000 0.000  0
#> GSM247660     1  0.0000      1.000 1.000 0.000  0
#> GSM247661     1  0.0000      1.000 1.000 0.000  0
#> GSM247662     1  0.0000      1.000 1.000 0.000  0
#> GSM247663     1  0.0000      1.000 1.000 0.000  0
#> GSM247856     1  0.0000      1.000 1.000 0.000  0
#> GSM247857     1  0.0000      1.000 1.000 0.000  0
#> GSM247859     1  0.0000      1.000 1.000 0.000  0
#> GSM247860     1  0.0000      1.000 1.000 0.000  0
#> GSM247862     1  0.0000      1.000 1.000 0.000  0
#> GSM247864     1  0.0000      1.000 1.000 0.000  0
#> GSM247865     1  0.0000      1.000 1.000 0.000  0
#> GSM247866     1  0.0000      1.000 1.000 0.000  0
#> GSM247876     1  0.0000      1.000 1.000 0.000  0
#> GSM247877     1  0.0000      1.000 1.000 0.000  0
#> GSM247878     1  0.0000      1.000 1.000 0.000  0
#> GSM247879     1  0.0000      1.000 1.000 0.000  0
#> GSM247881     1  0.0000      1.000 1.000 0.000  0
#> GSM247883     1  0.0000      1.000 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246422     4  0.0000      0.863 0.000 0.000  0 1.000
#> GSM246423     4  0.0000      0.863 0.000 0.000  0 1.000
#> GSM246484     4  0.0000      0.863 0.000 0.000  0 1.000
#> GSM246485     2  0.0336      0.979 0.008 0.992  0 0.000
#> GSM246486     2  0.3569      0.758 0.000 0.804  0 0.196
#> GSM246487     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM246488     4  0.0000      0.863 0.000 0.000  0 1.000
#> GSM246489     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM246490     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM246491     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247162     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247163     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247164     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247165     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247166     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247168     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247169     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247171     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247173     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247174     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247175     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247188     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247189     2  0.0188      0.984 0.004 0.996  0 0.000
#> GSM247190     2  0.0000      0.988 0.000 1.000  0 0.000
#> GSM247650     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247651     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247652     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247653     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247654     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247655     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247656     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247657     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247658     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247659     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247660     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247661     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247662     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247663     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247856     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247857     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247859     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247860     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247862     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247864     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247865     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247866     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247876     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247877     4  0.4679      0.443 0.352 0.000  0 0.648
#> GSM247878     1  0.4134      0.609 0.740 0.000  0 0.260
#> GSM247879     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247881     1  0.0000      0.989 1.000 0.000  0 0.000
#> GSM247883     1  0.0000      0.989 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
#> GSM246087     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.0000     0.8766 0.000 0.000  0 1.000 0.000
#> GSM246423     4  0.0000     0.8766 0.000 0.000  0 1.000 0.000
#> GSM246484     4  0.0000     0.8766 0.000 0.000  0 1.000 0.000
#> GSM246485     2  0.0579     0.9731 0.008 0.984  0 0.000 0.008
#> GSM246486     2  0.3074     0.7545 0.000 0.804  0 0.196 0.000
#> GSM246487     1  0.0510     0.7607 0.984 0.000  0 0.000 0.016
#> GSM246488     4  0.0000     0.8766 0.000 0.000  0 1.000 0.000
#> GSM246489     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM246491     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247162     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247164     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247165     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247166     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247168     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247171     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247175     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247189     2  0.0162     0.9837 0.004 0.996  0 0.000 0.000
#> GSM247190     2  0.0000     0.9876 0.000 1.000  0 0.000 0.000
#> GSM247650     1  0.1270     0.7625 0.948 0.000  0 0.000 0.052
#> GSM247651     1  0.0510     0.7607 0.984 0.000  0 0.000 0.016
#> GSM247652     5  0.4030     0.4153 0.352 0.000  0 0.000 0.648
#> GSM247653     5  0.3508     0.5882 0.252 0.000  0 0.000 0.748
#> GSM247654     5  0.3074     0.6768 0.196 0.000  0 0.000 0.804
#> GSM247655     1  0.0290     0.7627 0.992 0.000  0 0.000 0.008
#> GSM247656     5  0.1121     0.7457 0.044 0.000  0 0.000 0.956
#> GSM247657     5  0.0609     0.7742 0.020 0.000  0 0.000 0.980
#> GSM247658     1  0.3003     0.6831 0.812 0.000  0 0.000 0.188
#> GSM247659     5  0.1270     0.7783 0.052 0.000  0 0.000 0.948
#> GSM247660     1  0.1121     0.7644 0.956 0.000  0 0.000 0.044
#> GSM247661     5  0.3876     0.4514 0.316 0.000  0 0.000 0.684
#> GSM247662     5  0.2471     0.7315 0.136 0.000  0 0.000 0.864
#> GSM247663     1  0.1608     0.7596 0.928 0.000  0 0.000 0.072
#> GSM247856     1  0.4192     0.4219 0.596 0.000  0 0.000 0.404
#> GSM247857     5  0.1270     0.7783 0.052 0.000  0 0.000 0.948
#> GSM247859     1  0.3876     0.5470 0.684 0.000  0 0.000 0.316
#> GSM247860     1  0.4201     0.0758 0.592 0.000  0 0.000 0.408
#> GSM247862     1  0.1121     0.7644 0.956 0.000  0 0.000 0.044
#> GSM247864     1  0.1121     0.7644 0.956 0.000  0 0.000 0.044
#> GSM247865     1  0.3876     0.5470 0.684 0.000  0 0.000 0.316
#> GSM247866     1  0.1121     0.7644 0.956 0.000  0 0.000 0.044
#> GSM247876     1  0.3999     0.5520 0.656 0.000  0 0.000 0.344
#> GSM247877     4  0.4101     0.3464 0.372 0.000  0 0.628 0.000
#> GSM247878     1  0.1908     0.7255 0.908 0.000  0 0.092 0.000
#> GSM247879     1  0.1908     0.7320 0.908 0.000  0 0.000 0.092
#> GSM247881     1  0.3913     0.5681 0.676 0.000  0 0.000 0.324
#> GSM247883     1  0.4182     0.4193 0.600 0.000  0 0.000 0.400

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.1387     0.9211 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM246088     3  0.1387     0.9211 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM246089     3  0.3789     0.5625 0.000 0.000 0.584 0.000 0.000 0.416
#> GSM246090     3  0.1387     0.9211 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM246119     3  0.0458     0.9203 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM246120     3  0.0458     0.9203 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM246121     3  0.0000     0.9220 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.1387     0.9211 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM246123     3  0.0458     0.9203 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM246422     4  0.0000     0.8655 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246423     4  0.0000     0.8655 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246484     4  0.0000     0.8655 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246485     2  0.0520     0.9731 0.008 0.984 0.000 0.000 0.008 0.000
#> GSM246486     2  0.2762     0.7551 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM246487     1  0.0000     0.6817 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM246488     4  0.0000     0.8655 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246489     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247165     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247166     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     2  0.0146     0.9837 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM247190     2  0.0000     0.9876 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.1267     0.6813 0.940 0.000 0.000 0.000 0.060 0.000
#> GSM247651     1  0.0000     0.6817 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247652     1  0.5731     0.0598 0.516 0.000 0.000 0.000 0.260 0.224
#> GSM247653     6  0.5634     0.7787 0.164 0.000 0.000 0.000 0.336 0.500
#> GSM247654     6  0.5486     0.7559 0.132 0.000 0.000 0.000 0.372 0.496
#> GSM247655     1  0.0260     0.6834 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM247656     5  0.4291    -0.0128 0.052 0.000 0.000 0.000 0.680 0.268
#> GSM247657     5  0.0260     0.6971 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM247658     1  0.4582     0.4210 0.684 0.000 0.000 0.000 0.100 0.216
#> GSM247659     5  0.0146     0.7005 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM247660     1  0.1219     0.6833 0.948 0.000 0.000 0.000 0.048 0.004
#> GSM247661     5  0.5461     0.2169 0.248 0.000 0.000 0.000 0.568 0.184
#> GSM247662     5  0.1444     0.6483 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM247663     1  0.3651     0.5508 0.772 0.000 0.000 0.000 0.048 0.180
#> GSM247856     1  0.5520     0.1184 0.532 0.000 0.000 0.000 0.312 0.156
#> GSM247857     5  0.0146     0.7005 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM247859     1  0.4181     0.4496 0.700 0.000 0.000 0.000 0.248 0.052
#> GSM247860     1  0.5190    -0.1859 0.464 0.000 0.000 0.000 0.088 0.448
#> GSM247862     1  0.1219     0.6833 0.948 0.000 0.000 0.000 0.048 0.004
#> GSM247864     1  0.1219     0.6833 0.948 0.000 0.000 0.000 0.048 0.004
#> GSM247865     1  0.4181     0.4496 0.700 0.000 0.000 0.000 0.248 0.052
#> GSM247866     1  0.1219     0.6833 0.948 0.000 0.000 0.000 0.048 0.004
#> GSM247876     1  0.4481     0.4582 0.648 0.000 0.000 0.000 0.296 0.056
#> GSM247877     4  0.4099     0.3451 0.372 0.000 0.000 0.612 0.000 0.016
#> GSM247878     1  0.1610     0.6534 0.916 0.000 0.000 0.084 0.000 0.000
#> GSM247879     1  0.2581     0.6099 0.856 0.000 0.000 0.000 0.128 0.016
#> GSM247881     1  0.4809     0.4111 0.652 0.000 0.000 0.000 0.240 0.108
#> GSM247883     1  0.5610     0.1153 0.536 0.000 0.000 0.000 0.272 0.192

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) k
#> SD:pam 61         1.09e-10 2
#> SD:pam 61         6.70e-22 3
#> SD:pam 60         1.47e-22 4
#> SD:pam 55         3.18e-19 5
#> SD:pam 49         1.15e-15 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 21168 rows and 61 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.272           0.658       0.799         0.4568 0.493   0.493
#> 3 3 0.840           0.889       0.950         0.4347 0.727   0.511
#> 4 4 0.898           0.857       0.944         0.1089 0.889   0.699
#> 5 5 0.738           0.759       0.806         0.0552 1.000   1.000
#> 6 6 0.783           0.836       0.876         0.0578 0.889   0.611

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
#> GSM246087     2  0.6623      0.584 0.172 0.828
#> GSM246088     2  0.6623      0.584 0.172 0.828
#> GSM246089     2  0.6623      0.584 0.172 0.828
#> GSM246090     2  0.6623      0.584 0.172 0.828
#> GSM246119     2  0.6623      0.584 0.172 0.828
#> GSM246120     2  0.6623      0.584 0.172 0.828
#> GSM246121     2  0.6623      0.584 0.172 0.828
#> GSM246122     2  0.6623      0.584 0.172 0.828
#> GSM246123     2  0.6623      0.584 0.172 0.828
#> GSM246422     2  0.7453      0.499 0.212 0.788
#> GSM246423     2  0.7453      0.499 0.212 0.788
#> GSM246484     2  0.7453      0.499 0.212 0.788
#> GSM246485     1  0.9944     -0.144 0.544 0.456
#> GSM246486     1  0.9944     -0.144 0.544 0.456
#> GSM246487     1  0.8327      0.496 0.736 0.264
#> GSM246488     1  0.9944     -0.144 0.544 0.456
#> GSM246489     2  0.9170      0.630 0.332 0.668
#> GSM246490     2  0.9170      0.630 0.332 0.668
#> GSM246491     2  0.9170      0.630 0.332 0.668
#> GSM247162     2  0.9170      0.630 0.332 0.668
#> GSM247163     2  0.9170      0.630 0.332 0.668
#> GSM247164     2  0.9170      0.630 0.332 0.668
#> GSM247165     2  0.9170      0.630 0.332 0.668
#> GSM247166     2  0.9170      0.630 0.332 0.668
#> GSM247168     2  0.9170      0.630 0.332 0.668
#> GSM247169     2  0.9170      0.630 0.332 0.668
#> GSM247171     2  0.9170      0.630 0.332 0.668
#> GSM247173     2  0.9170      0.630 0.332 0.668
#> GSM247174     2  0.9170      0.630 0.332 0.668
#> GSM247175     2  0.9170      0.630 0.332 0.668
#> GSM247188     2  0.9170      0.630 0.332 0.668
#> GSM247189     2  0.9635      0.537 0.388 0.612
#> GSM247190     2  0.9170      0.630 0.332 0.668
#> GSM247650     1  0.0376      0.883 0.996 0.004
#> GSM247651     1  0.0000      0.886 1.000 0.000
#> GSM247652     1  0.0000      0.886 1.000 0.000
#> GSM247653     1  0.0000      0.886 1.000 0.000
#> GSM247654     1  0.0000      0.886 1.000 0.000
#> GSM247655     1  0.0000      0.886 1.000 0.000
#> GSM247656     1  0.0938      0.874 0.988 0.012
#> GSM247657     1  0.0000      0.886 1.000 0.000
#> GSM247658     1  0.0000      0.886 1.000 0.000
#> GSM247659     1  0.5737      0.723 0.864 0.136
#> GSM247660     1  0.0000      0.886 1.000 0.000
#> GSM247661     1  0.0000      0.886 1.000 0.000
#> GSM247662     1  0.0672      0.878 0.992 0.008
#> GSM247663     1  0.0376      0.883 0.996 0.004
#> GSM247856     1  0.0376      0.883 0.996 0.004
#> GSM247857     1  0.0000      0.886 1.000 0.000
#> GSM247859     1  0.0000      0.886 1.000 0.000
#> GSM247860     1  0.0000      0.886 1.000 0.000
#> GSM247862     1  0.0000      0.886 1.000 0.000
#> GSM247864     1  0.0000      0.886 1.000 0.000
#> GSM247865     1  0.5842      0.701 0.860 0.140
#> GSM247866     1  0.0000      0.886 1.000 0.000
#> GSM247876     1  0.4161      0.784 0.916 0.084
#> GSM247877     2  0.9358      0.376 0.352 0.648
#> GSM247878     2  0.9170      0.399 0.332 0.668
#> GSM247879     2  0.9608      0.330 0.384 0.616
#> GSM247881     1  0.0000      0.886 1.000 0.000
#> GSM247883     1  0.2948      0.829 0.948 0.052

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.947 0.000 0.000 1.000
#> GSM246422     3  0.4346      0.785 0.000 0.184 0.816
#> GSM246423     3  0.4346      0.785 0.000 0.184 0.816
#> GSM246484     3  0.4346      0.785 0.000 0.184 0.816
#> GSM246485     2  0.4750      0.752 0.000 0.784 0.216
#> GSM246486     2  0.4504      0.775 0.000 0.804 0.196
#> GSM246487     2  0.4750      0.752 0.000 0.784 0.216
#> GSM246488     2  0.4654      0.762 0.000 0.792 0.208
#> GSM246489     2  0.0000      0.933 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.933 0.000 1.000 0.000
#> GSM246491     2  0.1163      0.919 0.000 0.972 0.028
#> GSM247162     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247163     2  0.1289      0.916 0.000 0.968 0.032
#> GSM247164     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247189     2  0.5216      0.681 0.000 0.740 0.260
#> GSM247190     2  0.0000      0.933 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247656     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247657     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247659     1  0.5706      0.557 0.680 0.000 0.320
#> GSM247660     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247865     1  0.1950      0.908 0.952 0.008 0.040
#> GSM247866     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247876     1  0.4605      0.732 0.796 0.000 0.204
#> GSM247877     3  0.0000      0.947 0.000 0.000 1.000
#> GSM247878     1  0.5650      0.571 0.688 0.000 0.312
#> GSM247879     1  0.6295      0.212 0.528 0.000 0.472
#> GSM247881     1  0.0000      0.945 1.000 0.000 0.000
#> GSM247883     1  0.0237      0.942 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM246087     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000    1.00000 0.000 0.000  1 0.000
#> GSM246422     4  0.0000    0.90435 0.000 0.000  0 1.000
#> GSM246423     4  0.0000    0.90435 0.000 0.000  0 1.000
#> GSM246484     4  0.0000    0.90435 0.000 0.000  0 1.000
#> GSM246485     4  0.1940    0.89810 0.000 0.076  0 0.924
#> GSM246486     4  0.1940    0.89810 0.000 0.076  0 0.924
#> GSM246487     4  0.1940    0.89810 0.000 0.076  0 0.924
#> GSM246488     4  0.1940    0.89810 0.000 0.076  0 0.924
#> GSM246489     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM246490     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM246491     2  0.4661    0.43616 0.000 0.652  0 0.348
#> GSM247162     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247163     2  0.4999   -0.00421 0.000 0.508  0 0.492
#> GSM247164     2  0.4304    0.59072 0.000 0.716  0 0.284
#> GSM247165     2  0.4304    0.59072 0.000 0.716  0 0.284
#> GSM247166     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247168     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247169     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247171     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247173     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247174     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247175     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247188     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247189     4  0.1940    0.89810 0.000 0.076  0 0.924
#> GSM247190     2  0.0000    0.89358 0.000 1.000  0 0.000
#> GSM247650     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247651     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247652     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247653     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247654     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247655     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247656     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247657     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247658     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247659     1  0.4985    0.06186 0.532 0.000  0 0.468
#> GSM247660     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247661     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247662     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247663     1  0.0188    0.93651 0.996 0.000  0 0.004
#> GSM247856     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247857     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247859     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247860     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247862     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247864     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247865     1  0.4624    0.47944 0.660 0.000  0 0.340
#> GSM247866     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247876     1  0.3486    0.73098 0.812 0.000  0 0.188
#> GSM247877     4  0.0188    0.90351 0.004 0.000  0 0.996
#> GSM247878     4  0.0188    0.90351 0.004 0.000  0 0.996
#> GSM247879     4  0.4643    0.40698 0.344 0.000  0 0.656
#> GSM247881     1  0.0000    0.93973 1.000 0.000  0 0.000
#> GSM247883     1  0.4431    0.54541 0.696 0.000  0 0.304

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4 p5
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 NA
#> GSM246422     4  0.4210      0.655 0.000 0.000  0 0.588 NA
#> GSM246423     4  0.4210      0.655 0.000 0.000  0 0.588 NA
#> GSM246484     4  0.4210      0.655 0.000 0.000  0 0.588 NA
#> GSM246485     4  0.6770      0.440 0.132 0.104  0 0.612 NA
#> GSM246486     4  0.3424      0.409 0.000 0.240  0 0.760 NA
#> GSM246487     4  0.6280      0.361 0.164 0.004  0 0.540 NA
#> GSM246488     4  0.3395      0.416 0.000 0.236  0 0.764 NA
#> GSM246489     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM246490     2  0.0609      0.901 0.000 0.980  0 0.020 NA
#> GSM246491     2  0.4812      0.415 0.000 0.600  0 0.372 NA
#> GSM247162     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247163     2  0.4824      0.405 0.000 0.596  0 0.376 NA
#> GSM247164     2  0.2813      0.782 0.000 0.832  0 0.168 NA
#> GSM247165     2  0.2813      0.782 0.000 0.832  0 0.168 NA
#> GSM247166     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247168     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247169     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247171     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247173     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247174     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247175     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247188     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247189     4  0.3395      0.416 0.000 0.236  0 0.764 NA
#> GSM247190     2  0.0000      0.913 0.000 1.000  0 0.000 NA
#> GSM247650     1  0.3636      0.740 0.728 0.000  0 0.000 NA
#> GSM247651     1  0.1357      0.806 0.948 0.000  0 0.004 NA
#> GSM247652     1  0.0609      0.802 0.980 0.000  0 0.000 NA
#> GSM247653     1  0.3730      0.658 0.712 0.000  0 0.000 NA
#> GSM247654     1  0.3242      0.707 0.784 0.000  0 0.000 NA
#> GSM247655     1  0.1205      0.804 0.956 0.000  0 0.004 NA
#> GSM247656     1  0.3837      0.755 0.692 0.000  0 0.000 NA
#> GSM247657     1  0.3039      0.718 0.808 0.000  0 0.000 NA
#> GSM247658     1  0.0671      0.802 0.980 0.000  0 0.004 NA
#> GSM247659     1  0.6076      0.508 0.536 0.000  0 0.144 NA
#> GSM247660     1  0.1357      0.806 0.948 0.000  0 0.004 NA
#> GSM247661     1  0.3730      0.658 0.712 0.000  0 0.000 NA
#> GSM247662     1  0.3210      0.777 0.788 0.000  0 0.000 NA
#> GSM247663     1  0.3636      0.740 0.728 0.000  0 0.000 NA
#> GSM247856     1  0.3039      0.776 0.808 0.000  0 0.000 NA
#> GSM247857     1  0.2020      0.804 0.900 0.000  0 0.000 NA
#> GSM247859     1  0.4563      0.727 0.708 0.000  0 0.048 NA
#> GSM247860     1  0.3730      0.658 0.712 0.000  0 0.000 NA
#> GSM247862     1  0.0865      0.802 0.972 0.000  0 0.004 NA
#> GSM247864     1  0.1357      0.806 0.948 0.000  0 0.004 NA
#> GSM247865     1  0.6155      0.517 0.556 0.000  0 0.192 NA
#> GSM247866     1  0.0955      0.802 0.968 0.000  0 0.004 NA
#> GSM247876     1  0.5213      0.675 0.640 0.000  0 0.076 NA
#> GSM247877     4  0.4249      0.650 0.000 0.000  0 0.568 NA
#> GSM247878     4  0.4397      0.649 0.004 0.000  0 0.564 NA
#> GSM247879     4  0.6674      0.457 0.248 0.000  0 0.428 NA
#> GSM247881     1  0.2439      0.796 0.876 0.000  0 0.004 NA
#> GSM247883     1  0.5763      0.585 0.620 0.000  0 0.192 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0363      0.948 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM246088     3  0.0363      0.948 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM246089     3  0.1957      0.937 0.000 0.000 0.888 0.112 0.000 0.000
#> GSM246090     3  0.0363      0.948 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM246119     3  0.1957      0.937 0.000 0.000 0.888 0.112 0.000 0.000
#> GSM246120     3  0.1957      0.937 0.000 0.000 0.888 0.112 0.000 0.000
#> GSM246121     3  0.0000      0.948 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0363      0.948 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM246123     3  0.1957      0.937 0.000 0.000 0.888 0.112 0.000 0.000
#> GSM246422     5  0.1075      0.966 0.000 0.000 0.000 0.048 0.952 0.000
#> GSM246423     5  0.1075      0.966 0.000 0.000 0.000 0.048 0.952 0.000
#> GSM246484     5  0.1075      0.966 0.000 0.000 0.000 0.048 0.952 0.000
#> GSM246485     4  0.3001      0.927 0.008 0.024 0.000 0.840 0.128 0.000
#> GSM246486     4  0.2389      0.943 0.000 0.008 0.000 0.864 0.128 0.000
#> GSM246487     4  0.4820      0.823 0.100 0.020 0.000 0.724 0.148 0.008
#> GSM246488     4  0.2278      0.943 0.000 0.004 0.000 0.868 0.128 0.000
#> GSM246489     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.1765      0.880 0.000 0.904 0.000 0.096 0.000 0.000
#> GSM246491     2  0.3777      0.718 0.004 0.788 0.000 0.084 0.124 0.000
#> GSM247162     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.4742      0.605 0.004 0.688 0.000 0.184 0.124 0.000
#> GSM247164     2  0.2260      0.851 0.000 0.860 0.000 0.140 0.000 0.000
#> GSM247165     2  0.2300      0.847 0.000 0.856 0.000 0.144 0.000 0.000
#> GSM247166     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     4  0.2278      0.943 0.000 0.004 0.000 0.868 0.128 0.000
#> GSM247190     2  0.0000      0.936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.2520      0.713 0.844 0.000 0.000 0.004 0.000 0.152
#> GSM247651     1  0.2003      0.814 0.884 0.000 0.000 0.000 0.000 0.116
#> GSM247652     6  0.3309      0.752 0.280 0.000 0.000 0.000 0.000 0.720
#> GSM247653     6  0.1007      0.781 0.044 0.000 0.000 0.000 0.000 0.956
#> GSM247654     6  0.1957      0.801 0.112 0.000 0.000 0.000 0.000 0.888
#> GSM247655     1  0.2092      0.812 0.876 0.000 0.000 0.000 0.000 0.124
#> GSM247656     6  0.2362      0.790 0.136 0.000 0.000 0.004 0.000 0.860
#> GSM247657     6  0.2378      0.800 0.152 0.000 0.000 0.000 0.000 0.848
#> GSM247658     6  0.3266      0.762 0.272 0.000 0.000 0.000 0.000 0.728
#> GSM247659     6  0.5193      0.606 0.200 0.000 0.000 0.004 0.164 0.632
#> GSM247660     1  0.2003      0.814 0.884 0.000 0.000 0.000 0.000 0.116
#> GSM247661     6  0.0547      0.771 0.020 0.000 0.000 0.000 0.000 0.980
#> GSM247662     6  0.3508      0.743 0.292 0.000 0.000 0.004 0.000 0.704
#> GSM247663     1  0.1908      0.758 0.900 0.000 0.000 0.004 0.000 0.096
#> GSM247856     6  0.3547      0.733 0.300 0.000 0.000 0.004 0.000 0.696
#> GSM247857     6  0.3151      0.780 0.252 0.000 0.000 0.000 0.000 0.748
#> GSM247859     1  0.0865      0.806 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM247860     6  0.0865      0.773 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM247862     1  0.2416      0.794 0.844 0.000 0.000 0.000 0.000 0.156
#> GSM247864     1  0.2003      0.814 0.884 0.000 0.000 0.000 0.000 0.116
#> GSM247865     1  0.1346      0.797 0.952 0.000 0.000 0.016 0.008 0.024
#> GSM247866     1  0.2135      0.810 0.872 0.000 0.000 0.000 0.000 0.128
#> GSM247876     1  0.4153      0.629 0.752 0.000 0.000 0.004 0.148 0.096
#> GSM247877     5  0.0000      0.951 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247878     5  0.0000      0.951 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247879     1  0.4751      0.530 0.624 0.000 0.000 0.000 0.300 0.076
#> GSM247881     1  0.3851     -0.079 0.540 0.000 0.000 0.000 0.000 0.460
#> GSM247883     1  0.1700      0.806 0.928 0.000 0.000 0.024 0.000 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-SD-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> SD:mclust 51         8.42e-12 2
#> SD:mclust 60         2.13e-19 3
#> SD:mclust 56         3.11e-20 4
#> SD:mclust 53         2.63e-19 5
#> SD:mclust 60         7.11e-20 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 21168 rows and 61 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.806           0.892       0.956         0.4996 0.498   0.498
#> 3 3 0.845           0.874       0.947         0.3189 0.697   0.466
#> 4 4 0.912           0.885       0.954         0.0900 0.816   0.543
#> 5 5 0.727           0.706       0.850         0.0625 0.979   0.929
#> 6 6 0.748           0.634       0.784         0.0481 0.951   0.830

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     1  0.0000    0.94094 1.000 0.000
#> GSM246088     1  0.0000    0.94094 1.000 0.000
#> GSM246089     1  0.0000    0.94094 1.000 0.000
#> GSM246090     1  0.0000    0.94094 1.000 0.000
#> GSM246119     1  0.0000    0.94094 1.000 0.000
#> GSM246120     1  0.0000    0.94094 1.000 0.000
#> GSM246121     1  0.0000    0.94094 1.000 0.000
#> GSM246122     1  0.0000    0.94094 1.000 0.000
#> GSM246123     1  0.0000    0.94094 1.000 0.000
#> GSM246422     2  0.0376    0.96136 0.004 0.996
#> GSM246423     2  0.3274    0.91007 0.060 0.940
#> GSM246484     2  0.0000    0.96448 0.000 1.000
#> GSM246485     2  0.0000    0.96448 0.000 1.000
#> GSM246486     2  0.0000    0.96448 0.000 1.000
#> GSM246487     2  0.0000    0.96448 0.000 1.000
#> GSM246488     2  0.0000    0.96448 0.000 1.000
#> GSM246489     2  0.0000    0.96448 0.000 1.000
#> GSM246490     2  0.0000    0.96448 0.000 1.000
#> GSM246491     2  0.0000    0.96448 0.000 1.000
#> GSM247162     2  0.0000    0.96448 0.000 1.000
#> GSM247163     2  0.0000    0.96448 0.000 1.000
#> GSM247164     2  0.0000    0.96448 0.000 1.000
#> GSM247165     2  0.0000    0.96448 0.000 1.000
#> GSM247166     2  0.0000    0.96448 0.000 1.000
#> GSM247168     2  0.0000    0.96448 0.000 1.000
#> GSM247169     2  0.0000    0.96448 0.000 1.000
#> GSM247171     2  0.0000    0.96448 0.000 1.000
#> GSM247173     2  0.0000    0.96448 0.000 1.000
#> GSM247174     2  0.0000    0.96448 0.000 1.000
#> GSM247175     2  0.0000    0.96448 0.000 1.000
#> GSM247188     2  0.0000    0.96448 0.000 1.000
#> GSM247189     2  0.0000    0.96448 0.000 1.000
#> GSM247190     2  0.0000    0.96448 0.000 1.000
#> GSM247650     1  0.0000    0.94094 1.000 0.000
#> GSM247651     2  0.9977    0.00698 0.472 0.528
#> GSM247652     1  0.0000    0.94094 1.000 0.000
#> GSM247653     1  0.0000    0.94094 1.000 0.000
#> GSM247654     1  0.0000    0.94094 1.000 0.000
#> GSM247655     1  0.6247    0.81369 0.844 0.156
#> GSM247656     1  0.0000    0.94094 1.000 0.000
#> GSM247657     1  0.0000    0.94094 1.000 0.000
#> GSM247658     1  0.0938    0.93484 0.988 0.012
#> GSM247659     1  0.0000    0.94094 1.000 0.000
#> GSM247660     1  0.9996    0.09283 0.512 0.488
#> GSM247661     1  0.0000    0.94094 1.000 0.000
#> GSM247662     1  0.0000    0.94094 1.000 0.000
#> GSM247663     1  0.0000    0.94094 1.000 0.000
#> GSM247856     1  0.0000    0.94094 1.000 0.000
#> GSM247857     1  0.0000    0.94094 1.000 0.000
#> GSM247859     1  0.9815    0.31846 0.580 0.420
#> GSM247860     1  0.0376    0.93899 0.996 0.004
#> GSM247862     1  0.4562    0.87289 0.904 0.096
#> GSM247864     1  0.2043    0.92239 0.968 0.032
#> GSM247865     2  0.5946    0.81328 0.144 0.856
#> GSM247866     1  0.8713    0.61221 0.708 0.292
#> GSM247876     1  0.0000    0.94094 1.000 0.000
#> GSM247877     1  0.2603    0.91423 0.956 0.044
#> GSM247878     1  0.6343    0.80915 0.840 0.160
#> GSM247879     1  0.0000    0.94094 1.000 0.000
#> GSM247881     1  0.5946    0.82686 0.856 0.144
#> GSM247883     2  0.6247    0.79680 0.156 0.844

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.906 0.000 0.000 1.000
#> GSM246422     1  0.0000      0.948 1.000 0.000 0.000
#> GSM246423     1  0.0000      0.948 1.000 0.000 0.000
#> GSM246484     1  0.0000      0.948 1.000 0.000 0.000
#> GSM246485     2  0.2448      0.889 0.076 0.924 0.000
#> GSM246486     2  0.5678      0.569 0.316 0.684 0.000
#> GSM246487     1  0.1031      0.926 0.976 0.024 0.000
#> GSM246488     2  0.6095      0.410 0.392 0.608 0.000
#> GSM246489     2  0.0000      0.951 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.951 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247189     2  0.1643      0.916 0.044 0.956 0.000
#> GSM247190     2  0.0000      0.951 0.000 1.000 0.000
#> GSM247650     1  0.5216      0.629 0.740 0.000 0.260
#> GSM247651     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247652     1  0.2448      0.884 0.924 0.000 0.076
#> GSM247653     3  0.6274      0.201 0.456 0.000 0.544
#> GSM247654     1  0.6079      0.310 0.612 0.000 0.388
#> GSM247655     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247656     3  0.2959      0.848 0.100 0.000 0.900
#> GSM247657     3  0.5138      0.681 0.252 0.000 0.748
#> GSM247658     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247659     3  0.0000      0.906 0.000 0.000 1.000
#> GSM247660     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247661     3  0.3752      0.810 0.144 0.000 0.856
#> GSM247662     3  0.1411      0.890 0.036 0.000 0.964
#> GSM247663     1  0.2066      0.900 0.940 0.000 0.060
#> GSM247856     1  0.5178      0.634 0.744 0.000 0.256
#> GSM247857     3  0.5650      0.575 0.312 0.000 0.688
#> GSM247859     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247876     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247877     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247878     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247879     1  0.0892      0.934 0.980 0.000 0.020
#> GSM247881     1  0.0000      0.948 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.948 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
#> GSM246087     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000     0.9618 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM246485     2  0.0188     0.9695 0.000 0.996 0.000 0.004
#> GSM246486     2  0.4817     0.2418 0.000 0.612 0.000 0.388
#> GSM246487     1  0.7660    -0.0421 0.428 0.216 0.000 0.356
#> GSM246488     4  0.3688     0.7018 0.000 0.208 0.000 0.792
#> GSM246489     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247189     4  0.4999     0.0504 0.000 0.492 0.000 0.508
#> GSM247190     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0804     0.9365 0.980 0.000 0.008 0.012
#> GSM247651     1  0.3726     0.7609 0.788 0.000 0.000 0.212
#> GSM247652     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247653     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247654     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247655     1  0.0336     0.9395 0.992 0.000 0.000 0.008
#> GSM247656     1  0.1557     0.9041 0.944 0.000 0.056 0.000
#> GSM247657     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247658     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247659     3  0.4040     0.6309 0.248 0.000 0.752 0.000
#> GSM247660     1  0.1940     0.9010 0.924 0.000 0.000 0.076
#> GSM247661     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247662     1  0.2921     0.8157 0.860 0.000 0.140 0.000
#> GSM247663     1  0.1557     0.9152 0.944 0.000 0.000 0.056
#> GSM247856     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247857     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247859     1  0.0188     0.9404 0.996 0.000 0.000 0.004
#> GSM247860     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247862     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247864     1  0.1022     0.9299 0.968 0.000 0.000 0.032
#> GSM247865     1  0.1022     0.9300 0.968 0.000 0.000 0.032
#> GSM247866     1  0.0336     0.9395 0.992 0.000 0.000 0.008
#> GSM247876     1  0.3801     0.7493 0.780 0.000 0.000 0.220
#> GSM247877     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM247878     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM247879     4  0.0000     0.8757 0.000 0.000 0.000 1.000
#> GSM247881     1  0.0000     0.9410 1.000 0.000 0.000 0.000
#> GSM247883     1  0.0188     0.9404 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
#> GSM246087     3  0.0703     0.8530 0.000 0.000 0.976 0.000 0.024
#> GSM246088     3  0.0290     0.8586 0.000 0.000 0.992 0.000 0.008
#> GSM246089     3  0.3752     0.6278 0.000 0.000 0.708 0.000 0.292
#> GSM246090     3  0.0000     0.8601 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.1608     0.8600 0.000 0.000 0.928 0.000 0.072
#> GSM246120     3  0.1608     0.8600 0.000 0.000 0.928 0.000 0.072
#> GSM246121     3  0.1792     0.8558 0.000 0.000 0.916 0.000 0.084
#> GSM246122     3  0.0794     0.8508 0.000 0.000 0.972 0.000 0.028
#> GSM246123     3  0.1732     0.8573 0.000 0.000 0.920 0.000 0.080
#> GSM246422     4  0.0000     0.5499 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0290     0.5488 0.000 0.000 0.000 0.992 0.008
#> GSM246484     4  0.0404     0.5456 0.000 0.000 0.000 0.988 0.012
#> GSM246485     2  0.4690     0.6641 0.004 0.748 0.000 0.140 0.108
#> GSM246486     2  0.5103     0.0195 0.004 0.524 0.000 0.444 0.028
#> GSM246487     4  0.7224     0.1701 0.216 0.212 0.000 0.516 0.056
#> GSM246488     4  0.3327     0.4758 0.000 0.144 0.000 0.828 0.028
#> GSM246489     2  0.0162     0.9477 0.000 0.996 0.000 0.000 0.004
#> GSM246490     2  0.0000     0.9481 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0162     0.9477 0.000 0.996 0.000 0.000 0.004
#> GSM247162     2  0.0162     0.9476 0.000 0.996 0.000 0.000 0.004
#> GSM247163     2  0.0290     0.9462 0.000 0.992 0.000 0.000 0.008
#> GSM247164     2  0.0324     0.9462 0.000 0.992 0.000 0.004 0.004
#> GSM247165     2  0.0693     0.9381 0.000 0.980 0.000 0.008 0.012
#> GSM247166     2  0.0162     0.9481 0.000 0.996 0.000 0.000 0.004
#> GSM247168     2  0.0162     0.9481 0.000 0.996 0.000 0.000 0.004
#> GSM247169     2  0.0162     0.9481 0.000 0.996 0.000 0.000 0.004
#> GSM247171     2  0.0162     0.9476 0.000 0.996 0.000 0.000 0.004
#> GSM247173     2  0.0162     0.9481 0.000 0.996 0.000 0.000 0.004
#> GSM247174     2  0.0162     0.9481 0.000 0.996 0.000 0.000 0.004
#> GSM247175     2  0.0000     0.9481 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0290     0.9459 0.000 0.992 0.000 0.000 0.008
#> GSM247189     4  0.5591     0.1272 0.000 0.432 0.000 0.496 0.072
#> GSM247190     2  0.0162     0.9476 0.000 0.996 0.000 0.000 0.004
#> GSM247650     1  0.3337     0.7898 0.856 0.000 0.064 0.008 0.072
#> GSM247651     1  0.4777     0.5696 0.664 0.000 0.000 0.292 0.044
#> GSM247652     1  0.2127     0.7900 0.892 0.000 0.000 0.000 0.108
#> GSM247653     1  0.2377     0.7846 0.872 0.000 0.000 0.000 0.128
#> GSM247654     1  0.2020     0.8040 0.900 0.000 0.000 0.000 0.100
#> GSM247655     1  0.0912     0.8022 0.972 0.000 0.000 0.016 0.012
#> GSM247656     1  0.5974     0.4401 0.564 0.000 0.292 0.000 0.144
#> GSM247657     1  0.2280     0.7845 0.880 0.000 0.000 0.000 0.120
#> GSM247658     1  0.2020     0.7907 0.900 0.000 0.000 0.000 0.100
#> GSM247659     3  0.6203     0.2633 0.188 0.000 0.544 0.000 0.268
#> GSM247660     1  0.3309     0.7583 0.836 0.000 0.000 0.128 0.036
#> GSM247661     1  0.2690     0.7732 0.844 0.000 0.000 0.000 0.156
#> GSM247662     1  0.6761     0.0637 0.380 0.000 0.352 0.000 0.268
#> GSM247663     1  0.3399     0.7701 0.812 0.000 0.004 0.012 0.172
#> GSM247856     1  0.3336     0.7821 0.832 0.000 0.008 0.016 0.144
#> GSM247857     1  0.4481     0.6786 0.720 0.000 0.048 0.000 0.232
#> GSM247859     1  0.3764     0.7751 0.800 0.000 0.000 0.044 0.156
#> GSM247860     1  0.2516     0.7679 0.860 0.000 0.000 0.000 0.140
#> GSM247862     1  0.2074     0.7885 0.896 0.000 0.000 0.000 0.104
#> GSM247864     1  0.3535     0.7727 0.832 0.000 0.000 0.088 0.080
#> GSM247865     1  0.5399     0.6430 0.664 0.000 0.000 0.188 0.148
#> GSM247866     1  0.2813     0.7402 0.832 0.000 0.000 0.000 0.168
#> GSM247876     1  0.5696     0.3309 0.560 0.000 0.000 0.096 0.344
#> GSM247877     4  0.4313    -0.1482 0.008 0.000 0.000 0.636 0.356
#> GSM247878     4  0.2304     0.4567 0.008 0.000 0.000 0.892 0.100
#> GSM247879     5  0.5789     0.0000 0.076 0.000 0.024 0.272 0.628
#> GSM247881     1  0.0703     0.8017 0.976 0.000 0.000 0.000 0.024
#> GSM247883     1  0.2976     0.7844 0.852 0.004 0.000 0.012 0.132

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM246087     3  0.1152    0.75261 0.000 0.000 0.952 0.000 0.004 NA
#> GSM246088     3  0.0692    0.75908 0.000 0.000 0.976 0.000 0.004 NA
#> GSM246089     3  0.5928    0.36126 0.000 0.000 0.464 0.000 0.268 NA
#> GSM246090     3  0.0146    0.76260 0.000 0.000 0.996 0.000 0.004 NA
#> GSM246119     3  0.3103    0.74981 0.000 0.000 0.836 0.000 0.100 NA
#> GSM246120     3  0.2897    0.75461 0.000 0.000 0.852 0.000 0.088 NA
#> GSM246121     3  0.3321    0.74232 0.000 0.000 0.820 0.000 0.100 NA
#> GSM246122     3  0.1349    0.75005 0.000 0.000 0.940 0.000 0.004 NA
#> GSM246123     3  0.2923    0.75532 0.000 0.000 0.848 0.000 0.100 NA
#> GSM246422     4  0.0000    0.63300 0.000 0.000 0.000 1.000 0.000 NA
#> GSM246423     4  0.0000    0.63300 0.000 0.000 0.000 1.000 0.000 NA
#> GSM246484     4  0.0146    0.63135 0.000 0.000 0.000 0.996 0.004 NA
#> GSM246485     2  0.6949   -0.27737 0.016 0.372 0.000 0.340 0.028 NA
#> GSM246486     4  0.4370    0.39899 0.000 0.356 0.000 0.616 0.008 NA
#> GSM246487     4  0.6136    0.34317 0.236 0.184 0.000 0.552 0.012 NA
#> GSM246488     4  0.1411    0.63340 0.000 0.060 0.000 0.936 0.004 NA
#> GSM246489     2  0.0603    0.93482 0.000 0.980 0.000 0.000 0.004 NA
#> GSM246490     2  0.0458    0.93473 0.000 0.984 0.000 0.000 0.000 NA
#> GSM246491     2  0.0363    0.93604 0.000 0.988 0.000 0.000 0.000 NA
#> GSM247162     2  0.0000    0.93600 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247163     2  0.0520    0.93306 0.000 0.984 0.000 0.000 0.008 NA
#> GSM247164     2  0.0000    0.93600 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247165     2  0.0976    0.92915 0.000 0.968 0.000 0.008 0.008 NA
#> GSM247166     2  0.1802    0.90141 0.000 0.916 0.000 0.000 0.012 NA
#> GSM247168     2  0.1745    0.90275 0.000 0.920 0.000 0.000 0.012 NA
#> GSM247169     2  0.1802    0.90034 0.000 0.916 0.000 0.000 0.012 NA
#> GSM247171     2  0.0405    0.93383 0.000 0.988 0.000 0.000 0.004 NA
#> GSM247173     2  0.0260    0.93642 0.000 0.992 0.000 0.000 0.000 NA
#> GSM247174     2  0.0790    0.93000 0.000 0.968 0.000 0.000 0.000 NA
#> GSM247175     2  0.0291    0.93478 0.000 0.992 0.000 0.000 0.004 NA
#> GSM247188     2  0.0291    0.93596 0.000 0.992 0.000 0.000 0.004 NA
#> GSM247189     4  0.4668    0.39540 0.000 0.276 0.000 0.660 0.052 NA
#> GSM247190     2  0.0000    0.93600 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247650     1  0.5648    0.32046 0.604 0.000 0.224 0.000 0.148 NA
#> GSM247651     1  0.5092    0.43765 0.604 0.000 0.000 0.320 0.024 NA
#> GSM247652     1  0.1152    0.66096 0.952 0.000 0.004 0.000 0.000 NA
#> GSM247653     1  0.4703    0.56422 0.492 0.000 0.000 0.000 0.044 NA
#> GSM247654     1  0.3888    0.64683 0.672 0.000 0.000 0.000 0.016 NA
#> GSM247655     1  0.2573    0.67070 0.872 0.000 0.000 0.012 0.012 NA
#> GSM247656     1  0.5940   -0.00253 0.428 0.000 0.412 0.000 0.012 NA
#> GSM247657     1  0.4051    0.61540 0.560 0.000 0.000 0.000 0.008 NA
#> GSM247658     1  0.1806    0.66205 0.908 0.000 0.000 0.000 0.004 NA
#> GSM247659     3  0.6539    0.32464 0.048 0.004 0.512 0.000 0.192 NA
#> GSM247660     1  0.6112    0.54976 0.548 0.000 0.000 0.216 0.032 NA
#> GSM247661     1  0.4264    0.57867 0.500 0.000 0.000 0.000 0.016 NA
#> GSM247662     3  0.6782    0.22473 0.120 0.000 0.448 0.000 0.104 NA
#> GSM247663     1  0.2039    0.62641 0.904 0.000 0.000 0.000 0.076 NA
#> GSM247856     1  0.1621    0.64722 0.944 0.000 0.016 0.008 0.012 NA
#> GSM247857     1  0.6613    0.36808 0.408 0.000 0.148 0.000 0.060 NA
#> GSM247859     1  0.1794    0.65720 0.924 0.000 0.000 0.036 0.000 NA
#> GSM247860     1  0.5106    0.56602 0.520 0.000 0.000 0.000 0.084 NA
#> GSM247862     1  0.4184    0.62152 0.576 0.000 0.000 0.000 0.016 NA
#> GSM247864     1  0.5811    0.58996 0.644 0.000 0.008 0.096 0.068 NA
#> GSM247865     1  0.3946    0.44526 0.736 0.000 0.000 0.228 0.020 NA
#> GSM247866     1  0.5186    0.61752 0.612 0.000 0.000 0.000 0.156 NA
#> GSM247876     5  0.4910    0.33880 0.312 0.000 0.000 0.052 0.620 NA
#> GSM247877     5  0.3923    0.26910 0.000 0.000 0.000 0.416 0.580 NA
#> GSM247878     4  0.3841    0.25555 0.028 0.000 0.000 0.716 0.256 NA
#> GSM247879     5  0.2908    0.55019 0.020 0.004 0.000 0.124 0.848 NA
#> GSM247881     1  0.4807    0.58833 0.692 0.000 0.008 0.000 0.164 NA
#> GSM247883     1  0.1930    0.63176 0.916 0.000 0.000 0.000 0.048 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-SD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) k
#> SD:NMF 58         1.05e-11 2
#> SD:NMF 58         3.82e-14 3
#> SD:NMF 58         2.45e-19 4
#> SD:NMF 50         2.51e-19 5
#> SD:NMF 46         1.82e-16 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 21168 rows and 61 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.368           0.566       0.712         0.3790 0.541   0.541
#> 3 3 0.891           0.897       0.954         0.5475 0.767   0.607
#> 4 4 0.754           0.827       0.896         0.1977 0.877   0.700
#> 5 5 0.789           0.834       0.908         0.0335 0.990   0.966
#> 6 6 0.765           0.709       0.871         0.0370 0.975   0.909

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
#> GSM246087     1   0.866     0.0371 0.712 0.288
#> GSM246088     1   0.866     0.0371 0.712 0.288
#> GSM246089     1   0.866     0.0371 0.712 0.288
#> GSM246090     1   0.866     0.0371 0.712 0.288
#> GSM246119     1   0.866     0.0371 0.712 0.288
#> GSM246120     1   0.866     0.0371 0.712 0.288
#> GSM246121     1   0.866     0.0371 0.712 0.288
#> GSM246122     1   0.866     0.0371 0.712 0.288
#> GSM246123     1   0.866     0.0371 0.712 0.288
#> GSM246422     1   0.963     0.7004 0.612 0.388
#> GSM246423     1   0.963     0.7004 0.612 0.388
#> GSM246484     1   0.963     0.7004 0.612 0.388
#> GSM246485     2   0.808     0.4082 0.248 0.752
#> GSM246486     2   0.992    -0.2991 0.448 0.552
#> GSM246487     2   0.992    -0.2991 0.448 0.552
#> GSM246488     2   0.998    -0.3691 0.472 0.528
#> GSM246489     2   0.000     0.8195 0.000 1.000
#> GSM246490     2   0.000     0.8195 0.000 1.000
#> GSM246491     2   0.000     0.8195 0.000 1.000
#> GSM247162     2   0.000     0.8195 0.000 1.000
#> GSM247163     2   0.000     0.8195 0.000 1.000
#> GSM247164     2   0.000     0.8195 0.000 1.000
#> GSM247165     2   0.689     0.5496 0.184 0.816
#> GSM247166     2   0.000     0.8195 0.000 1.000
#> GSM247168     2   0.000     0.8195 0.000 1.000
#> GSM247169     2   0.000     0.8195 0.000 1.000
#> GSM247171     2   0.000     0.8195 0.000 1.000
#> GSM247173     2   0.000     0.8195 0.000 1.000
#> GSM247174     2   0.000     0.8195 0.000 1.000
#> GSM247175     2   0.000     0.8195 0.000 1.000
#> GSM247188     2   0.000     0.8195 0.000 1.000
#> GSM247189     2   0.808     0.4082 0.248 0.752
#> GSM247190     2   0.000     0.8195 0.000 1.000
#> GSM247650     1   0.963     0.7004 0.612 0.388
#> GSM247651     1   0.963     0.7004 0.612 0.388
#> GSM247652     1   0.963     0.7004 0.612 0.388
#> GSM247653     1   0.978     0.6646 0.588 0.412
#> GSM247654     1   0.969     0.6911 0.604 0.396
#> GSM247655     1   0.963     0.7004 0.612 0.388
#> GSM247656     1   0.963     0.7004 0.612 0.388
#> GSM247657     1   0.969     0.6911 0.604 0.396
#> GSM247658     1   0.969     0.6911 0.604 0.396
#> GSM247659     1   0.963     0.7004 0.612 0.388
#> GSM247660     1   0.963     0.7004 0.612 0.388
#> GSM247661     1   0.978     0.6646 0.588 0.412
#> GSM247662     1   0.963     0.7004 0.612 0.388
#> GSM247663     1   0.963     0.7004 0.612 0.388
#> GSM247856     1   0.963     0.7004 0.612 0.388
#> GSM247857     1   0.963     0.7004 0.612 0.388
#> GSM247859     1   0.963     0.7004 0.612 0.388
#> GSM247860     1   0.978     0.6646 0.588 0.412
#> GSM247862     1   0.975     0.6716 0.592 0.408
#> GSM247864     1   0.963     0.7004 0.612 0.388
#> GSM247865     1   0.966     0.6950 0.608 0.392
#> GSM247866     1   0.975     0.6716 0.592 0.408
#> GSM247876     1   0.963     0.7004 0.612 0.388
#> GSM247877     1   0.963     0.7004 0.612 0.388
#> GSM247878     1   0.963     0.7004 0.612 0.388
#> GSM247879     1   0.963     0.7004 0.612 0.388
#> GSM247881     1   0.963     0.7004 0.612 0.388
#> GSM247883     1   0.963     0.7004 0.612 0.388

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246422     1  0.0592      0.945 0.988 0.012 0.000
#> GSM246423     1  0.0592      0.945 0.988 0.012 0.000
#> GSM246484     1  0.0592      0.945 0.988 0.012 0.000
#> GSM246485     2  0.6291      0.120 0.468 0.532 0.000
#> GSM246486     1  0.5760      0.509 0.672 0.328 0.000
#> GSM246487     1  0.5760      0.509 0.672 0.328 0.000
#> GSM246488     1  0.5621      0.553 0.692 0.308 0.000
#> GSM246489     2  0.0592      0.913 0.012 0.988 0.000
#> GSM246490     2  0.0592      0.913 0.012 0.988 0.000
#> GSM246491     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247162     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247163     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247164     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247165     2  0.5254      0.630 0.264 0.736 0.000
#> GSM247166     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247168     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247169     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247171     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247173     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247174     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247175     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247188     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247189     2  0.5905      0.455 0.352 0.648 0.000
#> GSM247190     2  0.0592      0.913 0.012 0.988 0.000
#> GSM247650     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247651     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247652     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247653     1  0.2590      0.909 0.924 0.072 0.004
#> GSM247654     1  0.0747      0.949 0.984 0.016 0.000
#> GSM247655     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247656     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247657     1  0.0747      0.949 0.984 0.016 0.000
#> GSM247658     1  0.0892      0.947 0.980 0.020 0.000
#> GSM247659     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247660     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247661     1  0.2261      0.915 0.932 0.068 0.000
#> GSM247662     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247663     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247856     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247857     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247859     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247860     1  0.2590      0.909 0.924 0.072 0.004
#> GSM247862     1  0.2066      0.921 0.940 0.060 0.000
#> GSM247864     1  0.0424      0.952 0.992 0.008 0.000
#> GSM247865     1  0.0592      0.947 0.988 0.012 0.000
#> GSM247866     1  0.2165      0.918 0.936 0.064 0.000
#> GSM247876     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247877     1  0.0592      0.945 0.988 0.012 0.000
#> GSM247878     1  0.0592      0.945 0.988 0.012 0.000
#> GSM247879     1  0.0592      0.945 0.988 0.012 0.000
#> GSM247881     1  0.0237      0.952 0.996 0.004 0.000
#> GSM247883     1  0.0237      0.952 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM246087     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246422     4  0.3764     0.7410 0.216 0.000  0 0.784
#> GSM246423     4  0.3764     0.7410 0.216 0.000  0 0.784
#> GSM246484     4  0.3764     0.7410 0.216 0.000  0 0.784
#> GSM246485     2  0.6979    -0.0452 0.128 0.528  0 0.344
#> GSM246486     4  0.7031     0.5152 0.140 0.324  0 0.536
#> GSM246487     4  0.7031     0.5152 0.140 0.324  0 0.536
#> GSM246488     4  0.6783     0.5304 0.124 0.304  0 0.572
#> GSM246489     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM246490     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM246491     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247162     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247163     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247164     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247165     2  0.4642     0.5962 0.020 0.740  0 0.240
#> GSM247166     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247168     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247169     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247171     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247173     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247174     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247175     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247188     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247189     2  0.5614     0.4142 0.044 0.652  0 0.304
#> GSM247190     2  0.0000     0.9239 0.000 1.000  0 0.000
#> GSM247650     1  0.0188     0.8967 0.996 0.000  0 0.004
#> GSM247651     1  0.2281     0.8320 0.904 0.000  0 0.096
#> GSM247652     1  0.0469     0.8945 0.988 0.000  0 0.012
#> GSM247653     1  0.3764     0.7382 0.784 0.000  0 0.216
#> GSM247654     1  0.0817     0.8919 0.976 0.000  0 0.024
#> GSM247655     1  0.0336     0.8959 0.992 0.000  0 0.008
#> GSM247656     1  0.0469     0.8945 0.988 0.000  0 0.012
#> GSM247657     1  0.0817     0.8922 0.976 0.000  0 0.024
#> GSM247658     1  0.1118     0.8864 0.964 0.000  0 0.036
#> GSM247659     1  0.0592     0.8951 0.984 0.000  0 0.016
#> GSM247660     1  0.2281     0.8320 0.904 0.000  0 0.096
#> GSM247661     1  0.3610     0.7547 0.800 0.000  0 0.200
#> GSM247662     1  0.0592     0.8951 0.984 0.000  0 0.016
#> GSM247663     1  0.0336     0.8961 0.992 0.000  0 0.008
#> GSM247856     1  0.0188     0.8967 0.996 0.000  0 0.004
#> GSM247857     1  0.0592     0.8951 0.984 0.000  0 0.016
#> GSM247859     1  0.2149     0.8401 0.912 0.000  0 0.088
#> GSM247860     1  0.3764     0.7382 0.784 0.000  0 0.216
#> GSM247862     1  0.3172     0.7959 0.840 0.000  0 0.160
#> GSM247864     1  0.0336     0.8970 0.992 0.000  0 0.008
#> GSM247865     1  0.4608     0.4272 0.692 0.004  0 0.304
#> GSM247866     1  0.3610     0.7545 0.800 0.000  0 0.200
#> GSM247876     1  0.1716     0.8594 0.936 0.000  0 0.064
#> GSM247877     4  0.4888     0.6109 0.412 0.000  0 0.588
#> GSM247878     4  0.4877     0.6208 0.408 0.000  0 0.592
#> GSM247879     4  0.4888     0.6109 0.412 0.000  0 0.588
#> GSM247881     1  0.1022     0.8882 0.968 0.000  0 0.032
#> GSM247883     1  0.1022     0.8882 0.968 0.000  0 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.3318      0.615 0.192 0.000  0 0.800 0.008
#> GSM246423     4  0.3318      0.615 0.192 0.000  0 0.800 0.008
#> GSM246484     4  0.3318      0.615 0.192 0.000  0 0.800 0.008
#> GSM246485     2  0.6021     -0.177 0.128 0.524  0 0.348 0.000
#> GSM246486     4  0.6043      0.656 0.140 0.320  0 0.540 0.000
#> GSM246487     4  0.6043      0.656 0.140 0.320  0 0.540 0.000
#> GSM246488     4  0.5827      0.664 0.124 0.300  0 0.576 0.000
#> GSM246489     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM246491     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247162     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247164     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247165     2  0.4026      0.553 0.020 0.736  0 0.244 0.000
#> GSM247166     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247168     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247171     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247175     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247189     2  0.4854      0.340 0.044 0.648  0 0.308 0.000
#> GSM247190     2  0.0000      0.919 0.000 1.000  0 0.000 0.000
#> GSM247650     1  0.0162      0.905 0.996 0.000  0 0.000 0.004
#> GSM247651     1  0.1965      0.848 0.904 0.000  0 0.096 0.000
#> GSM247652     1  0.0404      0.904 0.988 0.000  0 0.012 0.000
#> GSM247653     1  0.3745      0.768 0.780 0.000  0 0.196 0.024
#> GSM247654     1  0.0798      0.902 0.976 0.000  0 0.016 0.008
#> GSM247655     1  0.0290      0.904 0.992 0.000  0 0.008 0.000
#> GSM247656     1  0.0404      0.904 0.988 0.000  0 0.012 0.000
#> GSM247657     1  0.0771      0.902 0.976 0.000  0 0.020 0.004
#> GSM247658     1  0.1106      0.898 0.964 0.000  0 0.024 0.012
#> GSM247659     1  0.0510      0.905 0.984 0.000  0 0.016 0.000
#> GSM247660     1  0.1965      0.848 0.904 0.000  0 0.096 0.000
#> GSM247661     1  0.3318      0.785 0.800 0.000  0 0.192 0.008
#> GSM247662     1  0.0510      0.905 0.984 0.000  0 0.016 0.000
#> GSM247663     1  0.0955      0.901 0.968 0.000  0 0.004 0.028
#> GSM247856     1  0.0162      0.905 0.996 0.000  0 0.000 0.004
#> GSM247857     1  0.0510      0.905 0.984 0.000  0 0.016 0.000
#> GSM247859     1  0.1851      0.855 0.912 0.000  0 0.088 0.000
#> GSM247860     1  0.3745      0.768 0.780 0.000  0 0.196 0.024
#> GSM247862     1  0.2997      0.824 0.840 0.000  0 0.148 0.012
#> GSM247864     1  0.0324      0.905 0.992 0.000  0 0.004 0.004
#> GSM247865     1  0.3837      0.493 0.692 0.000  0 0.308 0.000
#> GSM247866     1  0.3456      0.786 0.800 0.000  0 0.184 0.016
#> GSM247876     1  0.2806      0.811 0.844 0.000  0 0.004 0.152
#> GSM247877     5  0.0703      0.830 0.024 0.000  0 0.000 0.976
#> GSM247878     5  0.5472      0.569 0.108 0.000  0 0.260 0.632
#> GSM247879     5  0.0703      0.830 0.024 0.000  0 0.000 0.976
#> GSM247881     1  0.0880      0.897 0.968 0.000  0 0.032 0.000
#> GSM247883     1  0.0880      0.897 0.968 0.000  0 0.032 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.5030      0.544 0.000 0.000 0.616 0.116 0.000 0.268
#> GSM246090     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000      0.956 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.2003      0.598 0.116 0.000 0.000 0.884 0.000 0.000
#> GSM246423     4  0.2003      0.598 0.116 0.000 0.000 0.884 0.000 0.000
#> GSM246484     4  0.2003      0.598 0.116 0.000 0.000 0.884 0.000 0.000
#> GSM246485     2  0.5771     -0.169 0.128 0.524 0.000 0.332 0.000 0.016
#> GSM246486     4  0.5947      0.646 0.136 0.320 0.000 0.520 0.000 0.024
#> GSM246487     4  0.5947      0.646 0.136 0.320 0.000 0.520 0.000 0.024
#> GSM246488     4  0.5642      0.664 0.124 0.300 0.000 0.560 0.000 0.016
#> GSM246489     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247165     2  0.3946      0.553 0.020 0.736 0.000 0.228 0.000 0.016
#> GSM247166     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     2  0.4712      0.340 0.044 0.648 0.000 0.292 0.000 0.016
#> GSM247190     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.0547      0.759 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM247651     1  0.2163      0.704 0.892 0.000 0.000 0.092 0.000 0.016
#> GSM247652     1  0.0725      0.761 0.976 0.000 0.000 0.012 0.000 0.012
#> GSM247653     6  0.3847      0.980 0.456 0.000 0.000 0.000 0.000 0.544
#> GSM247654     1  0.1556      0.720 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247655     1  0.0622      0.761 0.980 0.000 0.000 0.008 0.000 0.012
#> GSM247656     1  0.1563      0.743 0.932 0.000 0.000 0.012 0.000 0.056
#> GSM247657     1  0.1444      0.725 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM247658     1  0.1267      0.735 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM247659     1  0.1745      0.739 0.920 0.000 0.000 0.012 0.000 0.068
#> GSM247660     1  0.2163      0.704 0.892 0.000 0.000 0.092 0.000 0.016
#> GSM247661     1  0.3851     -0.792 0.540 0.000 0.000 0.000 0.000 0.460
#> GSM247662     1  0.1625      0.743 0.928 0.000 0.000 0.012 0.000 0.060
#> GSM247663     1  0.2814      0.607 0.820 0.000 0.000 0.000 0.008 0.172
#> GSM247856     1  0.0632      0.757 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM247857     1  0.1625      0.743 0.928 0.000 0.000 0.012 0.000 0.060
#> GSM247859     1  0.2147      0.713 0.896 0.000 0.000 0.084 0.000 0.020
#> GSM247860     6  0.3851      0.981 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM247862     1  0.3349      0.161 0.748 0.000 0.000 0.008 0.000 0.244
#> GSM247864     1  0.0603      0.759 0.980 0.000 0.000 0.004 0.000 0.016
#> GSM247865     1  0.4079      0.381 0.680 0.000 0.000 0.288 0.000 0.032
#> GSM247866     1  0.3823     -0.727 0.564 0.000 0.000 0.000 0.000 0.436
#> GSM247876     1  0.4631      0.351 0.692 0.000 0.000 0.000 0.140 0.168
#> GSM247877     5  0.0000      0.837 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247878     5  0.4306      0.599 0.032 0.000 0.000 0.344 0.624 0.000
#> GSM247879     5  0.0000      0.837 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247881     1  0.1168      0.760 0.956 0.000 0.000 0.028 0.000 0.016
#> GSM247883     1  0.1074      0.759 0.960 0.000 0.000 0.028 0.000 0.012

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:hclust 47         1.47e-08 2
#> CV:hclust 59         1.58e-19 3
#> CV:hclust 58         1.14e-20 4
#> CV:hclust 58         2.22e-21 5
#> CV:hclust 54         1.35e-18 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 21168 rows and 61 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.323           0.687       0.700         0.4056 0.552   0.552
#> 3 3 1.000           0.970       0.986         0.4773 0.815   0.675
#> 4 4 0.848           0.893       0.902         0.1593 0.874   0.693
#> 5 5 0.765           0.786       0.859         0.0739 0.992   0.974
#> 6 6 0.741           0.632       0.782         0.0457 0.962   0.867

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
#> GSM246087     1  0.9993      0.428 0.516 0.484
#> GSM246088     1  0.9993      0.428 0.516 0.484
#> GSM246089     1  0.9993      0.428 0.516 0.484
#> GSM246090     1  0.9993      0.428 0.516 0.484
#> GSM246119     1  0.9993      0.428 0.516 0.484
#> GSM246120     1  0.9993      0.428 0.516 0.484
#> GSM246121     1  0.9993      0.428 0.516 0.484
#> GSM246122     1  0.9993      0.428 0.516 0.484
#> GSM246123     1  0.9993      0.428 0.516 0.484
#> GSM246422     1  0.9129     -0.158 0.672 0.328
#> GSM246423     1  0.9129     -0.158 0.672 0.328
#> GSM246484     1  0.9129     -0.158 0.672 0.328
#> GSM246485     2  0.9998      0.703 0.492 0.508
#> GSM246486     2  0.9993      0.718 0.484 0.516
#> GSM246487     1  0.9933     -0.600 0.548 0.452
#> GSM246488     2  0.9993      0.718 0.484 0.516
#> GSM246489     2  0.9209      0.958 0.336 0.664
#> GSM246490     2  0.9209      0.958 0.336 0.664
#> GSM246491     2  0.9209      0.958 0.336 0.664
#> GSM247162     2  0.9209      0.958 0.336 0.664
#> GSM247163     2  0.9209      0.958 0.336 0.664
#> GSM247164     2  0.9209      0.958 0.336 0.664
#> GSM247165     2  0.9209      0.958 0.336 0.664
#> GSM247166     2  0.9209      0.958 0.336 0.664
#> GSM247168     2  0.9209      0.958 0.336 0.664
#> GSM247169     2  0.9209      0.958 0.336 0.664
#> GSM247171     2  0.9209      0.958 0.336 0.664
#> GSM247173     2  0.9209      0.958 0.336 0.664
#> GSM247174     2  0.9209      0.958 0.336 0.664
#> GSM247175     2  0.9209      0.958 0.336 0.664
#> GSM247188     2  0.9209      0.958 0.336 0.664
#> GSM247189     2  0.9209      0.958 0.336 0.664
#> GSM247190     2  0.9209      0.958 0.336 0.664
#> GSM247650     1  0.0376      0.749 0.996 0.004
#> GSM247651     1  0.2043      0.735 0.968 0.032
#> GSM247652     1  0.0000      0.749 1.000 0.000
#> GSM247653     1  0.0000      0.749 1.000 0.000
#> GSM247654     1  0.0000      0.749 1.000 0.000
#> GSM247655     1  0.2043      0.735 0.968 0.032
#> GSM247656     1  0.0376      0.749 0.996 0.004
#> GSM247657     1  0.0000      0.749 1.000 0.000
#> GSM247658     1  0.0000      0.749 1.000 0.000
#> GSM247659     1  0.3431      0.695 0.936 0.064
#> GSM247660     1  0.2043      0.735 0.968 0.032
#> GSM247661     1  0.0376      0.749 0.996 0.004
#> GSM247662     1  0.0376      0.749 0.996 0.004
#> GSM247663     1  0.0376      0.749 0.996 0.004
#> GSM247856     1  0.0000      0.749 1.000 0.000
#> GSM247857     1  0.0000      0.749 1.000 0.000
#> GSM247859     1  0.2043      0.735 0.968 0.032
#> GSM247860     1  0.0000      0.749 1.000 0.000
#> GSM247862     1  0.2043      0.735 0.968 0.032
#> GSM247864     1  0.2043      0.735 0.968 0.032
#> GSM247865     1  0.3733      0.678 0.928 0.072
#> GSM247866     1  0.2043      0.735 0.968 0.032
#> GSM247876     1  0.0376      0.749 0.996 0.004
#> GSM247877     1  0.2236      0.737 0.964 0.036
#> GSM247878     1  0.2043      0.735 0.968 0.032
#> GSM247879     1  0.0376      0.749 0.996 0.004
#> GSM247881     1  0.2043      0.735 0.968 0.032
#> GSM247883     1  0.2043      0.735 0.968 0.032

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0237     0.9984 0.000 0.004 0.996
#> GSM246088     3  0.0237     0.9984 0.000 0.004 0.996
#> GSM246089     3  0.0237     0.9972 0.000 0.004 0.996
#> GSM246090     3  0.0237     0.9984 0.000 0.004 0.996
#> GSM246119     3  0.0000     0.9986 0.000 0.000 1.000
#> GSM246120     3  0.0000     0.9986 0.000 0.000 1.000
#> GSM246121     3  0.0000     0.9986 0.000 0.000 1.000
#> GSM246122     3  0.0237     0.9984 0.000 0.004 0.996
#> GSM246123     3  0.0000     0.9986 0.000 0.000 1.000
#> GSM246422     1  0.0424     0.9742 0.992 0.008 0.000
#> GSM246423     1  0.0424     0.9742 0.992 0.008 0.000
#> GSM246484     1  0.0424     0.9742 0.992 0.008 0.000
#> GSM246485     1  0.6299     0.0706 0.524 0.476 0.000
#> GSM246486     2  0.0592     0.9893 0.012 0.988 0.000
#> GSM246487     1  0.0424     0.9742 0.992 0.008 0.000
#> GSM246488     2  0.2959     0.8712 0.100 0.900 0.000
#> GSM246489     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM246490     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM246491     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247162     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247163     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247164     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247165     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247166     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247168     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247169     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247171     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247173     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247174     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247175     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247188     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247189     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247190     2  0.0424     0.9929 0.008 0.992 0.000
#> GSM247650     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247651     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247652     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247653     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247654     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247655     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247656     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247657     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247658     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247659     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247660     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247661     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247662     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247663     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247856     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247857     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247859     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247860     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247862     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247864     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247865     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247866     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247876     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247877     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247878     1  0.0000     0.9796 1.000 0.000 0.000
#> GSM247879     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247881     1  0.0237     0.9809 0.996 0.000 0.004
#> GSM247883     1  0.0000     0.9796 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
#> GSM246087     3  0.0817      0.986 0.000 0.000 0.976 0.024
#> GSM246088     3  0.0817      0.986 0.000 0.000 0.976 0.024
#> GSM246089     3  0.1635      0.961 0.000 0.008 0.948 0.044
#> GSM246090     3  0.0817      0.986 0.000 0.000 0.976 0.024
#> GSM246119     3  0.0000      0.987 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      0.987 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000      0.987 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0817      0.986 0.000 0.000 0.976 0.024
#> GSM246123     3  0.0000      0.987 0.000 0.000 1.000 0.000
#> GSM246422     4  0.2760      0.804 0.128 0.000 0.000 0.872
#> GSM246423     4  0.2760      0.804 0.128 0.000 0.000 0.872
#> GSM246484     4  0.2760      0.804 0.128 0.000 0.000 0.872
#> GSM246485     4  0.7841      0.416 0.276 0.324 0.000 0.400
#> GSM246486     4  0.4295      0.604 0.008 0.240 0.000 0.752
#> GSM246487     4  0.4468      0.771 0.232 0.016 0.000 0.752
#> GSM246488     4  0.3108      0.710 0.016 0.112 0.000 0.872
#> GSM246489     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM246490     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM246491     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247162     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247163     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247164     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247165     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247166     2  0.1970      0.929 0.008 0.932 0.000 0.060
#> GSM247168     2  0.1970      0.929 0.008 0.932 0.000 0.060
#> GSM247169     2  0.1970      0.929 0.008 0.932 0.000 0.060
#> GSM247171     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247173     2  0.0336      0.957 0.008 0.992 0.000 0.000
#> GSM247174     2  0.1807      0.933 0.008 0.940 0.000 0.052
#> GSM247175     2  0.0524      0.956 0.008 0.988 0.000 0.004
#> GSM247188     2  0.0672      0.955 0.008 0.984 0.000 0.008
#> GSM247189     2  0.5138      0.257 0.008 0.600 0.000 0.392
#> GSM247190     2  0.0672      0.955 0.008 0.984 0.000 0.008
#> GSM247650     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247651     1  0.4277      0.526 0.720 0.000 0.000 0.280
#> GSM247652     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247653     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247654     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247655     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247656     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247657     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247658     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247659     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247660     1  0.4193      0.553 0.732 0.000 0.000 0.268
#> GSM247661     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247662     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247663     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247856     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247859     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247860     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247862     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247864     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247865     1  0.4008      0.611 0.756 0.000 0.000 0.244
#> GSM247866     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247876     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247877     4  0.4277      0.727 0.280 0.000 0.000 0.720
#> GSM247878     4  0.4222      0.735 0.272 0.000 0.000 0.728
#> GSM247879     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247881     1  0.0000      0.960 1.000 0.000 0.000 0.000
#> GSM247883     1  0.0000      0.960 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
#> GSM246087     3  0.1571      0.965 0.000 0.000 0.936 0.004 0.060
#> GSM246088     3  0.1571      0.965 0.000 0.000 0.936 0.004 0.060
#> GSM246089     3  0.0865      0.960 0.000 0.000 0.972 0.004 0.024
#> GSM246090     3  0.1571      0.965 0.000 0.000 0.936 0.004 0.060
#> GSM246119     3  0.0162      0.969 0.000 0.000 0.996 0.000 0.004
#> GSM246120     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0162      0.969 0.000 0.000 0.996 0.000 0.004
#> GSM246122     3  0.1571      0.965 0.000 0.000 0.936 0.004 0.060
#> GSM246123     3  0.0162      0.969 0.000 0.000 0.996 0.000 0.004
#> GSM246422     4  0.2997      0.458 0.012 0.000 0.000 0.840 0.148
#> GSM246423     4  0.2997      0.458 0.012 0.000 0.000 0.840 0.148
#> GSM246484     4  0.2997      0.458 0.012 0.000 0.000 0.840 0.148
#> GSM246485     4  0.6904      0.196 0.184 0.300 0.000 0.492 0.024
#> GSM246486     4  0.3942      0.420 0.000 0.232 0.000 0.748 0.020
#> GSM246487     4  0.4415      0.238 0.184 0.012 0.000 0.760 0.044
#> GSM246488     4  0.0794      0.504 0.000 0.028 0.000 0.972 0.000
#> GSM246489     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0794      0.894 0.000 0.972 0.000 0.028 0.000
#> GSM247164     2  0.0794      0.894 0.000 0.972 0.000 0.028 0.000
#> GSM247165     2  0.1908      0.845 0.000 0.908 0.000 0.092 0.000
#> GSM247166     2  0.3550      0.771 0.000 0.760 0.000 0.004 0.236
#> GSM247168     2  0.3550      0.771 0.000 0.760 0.000 0.004 0.236
#> GSM247169     2  0.3550      0.771 0.000 0.760 0.000 0.004 0.236
#> GSM247171     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0162      0.906 0.000 0.996 0.000 0.000 0.004
#> GSM247174     2  0.1571      0.889 0.000 0.936 0.000 0.004 0.060
#> GSM247175     2  0.0566      0.904 0.000 0.984 0.000 0.004 0.012
#> GSM247188     2  0.1502      0.891 0.000 0.940 0.000 0.004 0.056
#> GSM247189     2  0.4415      0.278 0.000 0.604 0.000 0.388 0.008
#> GSM247190     2  0.1124      0.898 0.000 0.960 0.000 0.004 0.036
#> GSM247650     1  0.1965      0.828 0.904 0.000 0.000 0.000 0.096
#> GSM247651     1  0.4808      0.640 0.728 0.000 0.000 0.136 0.136
#> GSM247652     1  0.1270      0.844 0.948 0.000 0.000 0.000 0.052
#> GSM247653     1  0.3039      0.779 0.808 0.000 0.000 0.000 0.192
#> GSM247654     1  0.1851      0.835 0.912 0.000 0.000 0.000 0.088
#> GSM247655     1  0.2574      0.812 0.876 0.000 0.000 0.012 0.112
#> GSM247656     1  0.1671      0.838 0.924 0.000 0.000 0.000 0.076
#> GSM247657     1  0.1792      0.837 0.916 0.000 0.000 0.000 0.084
#> GSM247658     1  0.2230      0.819 0.884 0.000 0.000 0.000 0.116
#> GSM247659     1  0.2127      0.832 0.892 0.000 0.000 0.000 0.108
#> GSM247660     1  0.4588      0.672 0.748 0.000 0.000 0.136 0.116
#> GSM247661     1  0.3039      0.780 0.808 0.000 0.000 0.000 0.192
#> GSM247662     1  0.1197      0.847 0.952 0.000 0.000 0.000 0.048
#> GSM247663     1  0.2471      0.820 0.864 0.000 0.000 0.000 0.136
#> GSM247856     1  0.0703      0.848 0.976 0.000 0.000 0.000 0.024
#> GSM247857     1  0.1197      0.847 0.952 0.000 0.000 0.000 0.048
#> GSM247859     1  0.1809      0.842 0.928 0.000 0.000 0.012 0.060
#> GSM247860     1  0.3039      0.780 0.808 0.000 0.000 0.000 0.192
#> GSM247862     1  0.1608      0.844 0.928 0.000 0.000 0.000 0.072
#> GSM247864     1  0.2389      0.815 0.880 0.000 0.000 0.004 0.116
#> GSM247865     1  0.4390      0.684 0.760 0.000 0.000 0.156 0.084
#> GSM247866     1  0.3074      0.802 0.804 0.000 0.000 0.000 0.196
#> GSM247876     1  0.3949      0.581 0.668 0.000 0.000 0.000 0.332
#> GSM247877     5  0.6117      0.931 0.136 0.000 0.000 0.360 0.504
#> GSM247878     5  0.6248      0.930 0.148 0.000 0.000 0.384 0.468
#> GSM247879     1  0.4126      0.487 0.620 0.000 0.000 0.000 0.380
#> GSM247881     1  0.1341      0.844 0.944 0.000 0.000 0.000 0.056
#> GSM247883     1  0.1628      0.842 0.936 0.000 0.000 0.008 0.056

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.1720      0.945 0.000 0.000 0.928 0.000 0.032 0.040
#> GSM246088     3  0.1720      0.945 0.000 0.000 0.928 0.000 0.032 0.040
#> GSM246089     3  0.2733      0.873 0.000 0.000 0.864 0.000 0.080 0.056
#> GSM246090     3  0.1720      0.945 0.000 0.000 0.928 0.000 0.032 0.040
#> GSM246119     3  0.0725      0.945 0.000 0.000 0.976 0.000 0.012 0.012
#> GSM246120     3  0.0725      0.945 0.000 0.000 0.976 0.000 0.012 0.012
#> GSM246121     3  0.0000      0.947 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.1720      0.945 0.000 0.000 0.928 0.000 0.032 0.040
#> GSM246123     3  0.0725      0.945 0.000 0.000 0.976 0.000 0.012 0.012
#> GSM246422     4  0.4168      0.506 0.000 0.000 0.000 0.696 0.256 0.048
#> GSM246423     4  0.4168      0.506 0.000 0.000 0.000 0.696 0.256 0.048
#> GSM246484     4  0.4168      0.506 0.000 0.000 0.000 0.696 0.256 0.048
#> GSM246485     4  0.5771      0.365 0.124 0.240 0.000 0.604 0.024 0.008
#> GSM246486     4  0.3352      0.514 0.004 0.180 0.000 0.796 0.016 0.004
#> GSM246487     4  0.3462      0.434 0.180 0.008 0.000 0.792 0.016 0.004
#> GSM246488     4  0.0291      0.570 0.000 0.004 0.000 0.992 0.004 0.000
#> GSM246489     2  0.0000      0.866 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0405      0.865 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM246491     2  0.0622      0.864 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM247162     2  0.0000      0.866 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.1078      0.857 0.000 0.964 0.000 0.016 0.012 0.008
#> GSM247164     2  0.0976      0.858 0.000 0.968 0.000 0.016 0.008 0.008
#> GSM247165     2  0.2982      0.744 0.000 0.828 0.000 0.152 0.012 0.008
#> GSM247166     2  0.5084      0.601 0.000 0.612 0.000 0.000 0.124 0.264
#> GSM247168     2  0.5084      0.601 0.000 0.612 0.000 0.000 0.124 0.264
#> GSM247169     2  0.5100      0.601 0.000 0.612 0.000 0.000 0.128 0.260
#> GSM247171     2  0.0146      0.866 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM247173     2  0.0146      0.866 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM247174     2  0.1934      0.838 0.000 0.916 0.000 0.000 0.040 0.044
#> GSM247175     2  0.0260      0.865 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM247188     2  0.1498      0.849 0.000 0.940 0.000 0.000 0.028 0.032
#> GSM247189     2  0.4617      0.129 0.000 0.524 0.000 0.444 0.024 0.008
#> GSM247190     2  0.0820      0.861 0.000 0.972 0.000 0.000 0.012 0.016
#> GSM247650     1  0.1461      0.627 0.940 0.000 0.000 0.000 0.044 0.016
#> GSM247651     1  0.2822      0.581 0.864 0.000 0.000 0.056 0.076 0.004
#> GSM247652     1  0.2482      0.504 0.848 0.000 0.000 0.000 0.004 0.148
#> GSM247653     6  0.4045      0.973 0.428 0.000 0.000 0.000 0.008 0.564
#> GSM247654     1  0.3547      0.132 0.696 0.000 0.000 0.000 0.004 0.300
#> GSM247655     1  0.1434      0.625 0.940 0.000 0.000 0.012 0.048 0.000
#> GSM247656     1  0.3349      0.337 0.748 0.000 0.000 0.000 0.008 0.244
#> GSM247657     1  0.3690      0.143 0.700 0.000 0.000 0.000 0.012 0.288
#> GSM247658     1  0.3795     -0.357 0.632 0.000 0.000 0.000 0.004 0.364
#> GSM247659     1  0.3756      0.225 0.712 0.000 0.000 0.000 0.020 0.268
#> GSM247660     1  0.2325      0.599 0.892 0.000 0.000 0.048 0.060 0.000
#> GSM247661     6  0.4141      0.946 0.432 0.000 0.000 0.000 0.012 0.556
#> GSM247662     1  0.2946      0.460 0.812 0.000 0.000 0.000 0.012 0.176
#> GSM247663     1  0.3013      0.588 0.844 0.000 0.000 0.000 0.088 0.068
#> GSM247856     1  0.2146      0.544 0.880 0.000 0.000 0.000 0.004 0.116
#> GSM247857     1  0.2946      0.460 0.812 0.000 0.000 0.000 0.012 0.176
#> GSM247859     1  0.0984      0.627 0.968 0.000 0.000 0.012 0.008 0.012
#> GSM247860     6  0.4045      0.973 0.428 0.000 0.000 0.000 0.008 0.564
#> GSM247862     1  0.1957      0.587 0.912 0.000 0.000 0.008 0.008 0.072
#> GSM247864     1  0.1398      0.624 0.940 0.000 0.000 0.008 0.052 0.000
#> GSM247865     1  0.2505      0.577 0.880 0.000 0.000 0.092 0.020 0.008
#> GSM247866     1  0.4139     -0.273 0.640 0.000 0.000 0.000 0.024 0.336
#> GSM247876     1  0.4675      0.177 0.560 0.000 0.000 0.000 0.392 0.048
#> GSM247877     5  0.5045      0.950 0.156 0.000 0.000 0.132 0.688 0.024
#> GSM247878     5  0.4666      0.949 0.168 0.000 0.000 0.144 0.688 0.000
#> GSM247879     1  0.4808     -0.124 0.476 0.000 0.000 0.000 0.472 0.052
#> GSM247881     1  0.0972      0.622 0.964 0.000 0.000 0.000 0.008 0.028
#> GSM247883     1  0.0870      0.627 0.972 0.000 0.000 0.012 0.004 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-CV-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:kmeans 48         3.33e-11 2
#> CV:kmeans 60         1.88e-21 3
#> CV:kmeans 59         1.37e-21 4
#> CV:kmeans 53         2.52e-19 5
#> CV:kmeans 48         3.43e-16 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 21168 rows and 61 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 1.000           0.988       0.995         0.4961 0.503   0.503
#> 3 3 0.924           0.939       0.968         0.3588 0.711   0.483
#> 4 4 0.754           0.812       0.911         0.1074 0.797   0.480
#> 5 5 0.744           0.612       0.802         0.0677 0.877   0.574
#> 6 6 0.776           0.579       0.777         0.0353 0.949   0.761

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
#> GSM246087     1   0.000      1.000 1.000 0.000
#> GSM246088     1   0.000      1.000 1.000 0.000
#> GSM246089     1   0.000      1.000 1.000 0.000
#> GSM246090     1   0.000      1.000 1.000 0.000
#> GSM246119     1   0.000      1.000 1.000 0.000
#> GSM246120     1   0.000      1.000 1.000 0.000
#> GSM246121     1   0.000      1.000 1.000 0.000
#> GSM246122     1   0.000      1.000 1.000 0.000
#> GSM246123     1   0.000      1.000 1.000 0.000
#> GSM246422     2   0.000      0.988 0.000 1.000
#> GSM246423     2   0.000      0.988 0.000 1.000
#> GSM246484     2   0.000      0.988 0.000 1.000
#> GSM246485     2   0.000      0.988 0.000 1.000
#> GSM246486     2   0.000      0.988 0.000 1.000
#> GSM246487     2   0.000      0.988 0.000 1.000
#> GSM246488     2   0.000      0.988 0.000 1.000
#> GSM246489     2   0.000      0.988 0.000 1.000
#> GSM246490     2   0.000      0.988 0.000 1.000
#> GSM246491     2   0.000      0.988 0.000 1.000
#> GSM247162     2   0.000      0.988 0.000 1.000
#> GSM247163     2   0.000      0.988 0.000 1.000
#> GSM247164     2   0.000      0.988 0.000 1.000
#> GSM247165     2   0.000      0.988 0.000 1.000
#> GSM247166     2   0.000      0.988 0.000 1.000
#> GSM247168     2   0.000      0.988 0.000 1.000
#> GSM247169     2   0.000      0.988 0.000 1.000
#> GSM247171     2   0.000      0.988 0.000 1.000
#> GSM247173     2   0.000      0.988 0.000 1.000
#> GSM247174     2   0.000      0.988 0.000 1.000
#> GSM247175     2   0.000      0.988 0.000 1.000
#> GSM247188     2   0.000      0.988 0.000 1.000
#> GSM247189     2   0.000      0.988 0.000 1.000
#> GSM247190     2   0.000      0.988 0.000 1.000
#> GSM247650     1   0.000      1.000 1.000 0.000
#> GSM247651     1   0.000      1.000 1.000 0.000
#> GSM247652     1   0.000      1.000 1.000 0.000
#> GSM247653     1   0.000      1.000 1.000 0.000
#> GSM247654     1   0.000      1.000 1.000 0.000
#> GSM247655     1   0.000      1.000 1.000 0.000
#> GSM247656     1   0.000      1.000 1.000 0.000
#> GSM247657     1   0.000      1.000 1.000 0.000
#> GSM247658     1   0.000      1.000 1.000 0.000
#> GSM247659     1   0.000      1.000 1.000 0.000
#> GSM247660     1   0.000      1.000 1.000 0.000
#> GSM247661     1   0.000      1.000 1.000 0.000
#> GSM247662     1   0.000      1.000 1.000 0.000
#> GSM247663     1   0.000      1.000 1.000 0.000
#> GSM247856     1   0.000      1.000 1.000 0.000
#> GSM247857     1   0.000      1.000 1.000 0.000
#> GSM247859     1   0.000      1.000 1.000 0.000
#> GSM247860     1   0.000      1.000 1.000 0.000
#> GSM247862     1   0.000      1.000 1.000 0.000
#> GSM247864     1   0.000      1.000 1.000 0.000
#> GSM247865     2   0.000      0.988 0.000 1.000
#> GSM247866     1   0.000      1.000 1.000 0.000
#> GSM247876     1   0.000      1.000 1.000 0.000
#> GSM247877     1   0.000      1.000 1.000 0.000
#> GSM247878     1   0.000      1.000 1.000 0.000
#> GSM247879     1   0.000      1.000 1.000 0.000
#> GSM247881     1   0.000      1.000 1.000 0.000
#> GSM247883     2   0.886      0.563 0.304 0.696

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.957 0.000 0.000 1.000
#> GSM246422     1  0.0892      0.935 0.980 0.020 0.000
#> GSM246423     1  0.0892      0.935 0.980 0.020 0.000
#> GSM246484     1  0.0892      0.935 0.980 0.020 0.000
#> GSM246485     2  0.0237      0.993 0.004 0.996 0.000
#> GSM246486     2  0.0592      0.986 0.012 0.988 0.000
#> GSM246487     1  0.2356      0.896 0.928 0.072 0.000
#> GSM246488     2  0.2066      0.938 0.060 0.940 0.000
#> GSM246489     2  0.0000      0.996 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.996 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247189     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247190     2  0.0000      0.996 0.000 1.000 0.000
#> GSM247650     1  0.2066      0.917 0.940 0.000 0.060
#> GSM247651     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247652     1  0.3412      0.858 0.876 0.000 0.124
#> GSM247653     3  0.1031      0.951 0.024 0.000 0.976
#> GSM247654     3  0.4178      0.816 0.172 0.000 0.828
#> GSM247655     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247656     3  0.1411      0.945 0.036 0.000 0.964
#> GSM247657     3  0.3192      0.885 0.112 0.000 0.888
#> GSM247658     1  0.2066      0.916 0.940 0.000 0.060
#> GSM247659     3  0.0000      0.957 0.000 0.000 1.000
#> GSM247660     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247661     3  0.0892      0.951 0.020 0.000 0.980
#> GSM247662     3  0.2066      0.931 0.060 0.000 0.940
#> GSM247663     1  0.2165      0.913 0.936 0.000 0.064
#> GSM247856     1  0.5178      0.668 0.744 0.000 0.256
#> GSM247857     3  0.5098      0.703 0.248 0.000 0.752
#> GSM247859     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247860     3  0.1964      0.933 0.056 0.000 0.944
#> GSM247862     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247876     1  0.2796      0.893 0.908 0.000 0.092
#> GSM247877     1  0.2796      0.891 0.908 0.000 0.092
#> GSM247878     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247879     1  0.5529      0.617 0.704 0.000 0.296
#> GSM247881     1  0.0000      0.943 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.943 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
#> GSM246087     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000     0.9037 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000     0.8501 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000     0.8501 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000     0.8501 0.000 0.000 0.000 1.000
#> GSM246485     2  0.4999     0.0941 0.000 0.508 0.000 0.492
#> GSM246486     4  0.2868     0.7549 0.000 0.136 0.000 0.864
#> GSM246487     4  0.0469     0.8473 0.000 0.012 0.000 0.988
#> GSM246488     4  0.1389     0.8286 0.000 0.048 0.000 0.952
#> GSM246489     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247189     2  0.4193     0.6417 0.000 0.732 0.000 0.268
#> GSM247190     2  0.0000     0.9542 0.000 1.000 0.000 0.000
#> GSM247650     1  0.1767     0.8582 0.944 0.000 0.012 0.044
#> GSM247651     4  0.4500     0.5659 0.316 0.000 0.000 0.684
#> GSM247652     1  0.0336     0.8608 0.992 0.000 0.008 0.000
#> GSM247653     1  0.3024     0.7970 0.852 0.000 0.148 0.000
#> GSM247654     1  0.1940     0.8489 0.924 0.000 0.076 0.000
#> GSM247655     1  0.3649     0.7327 0.796 0.000 0.000 0.204
#> GSM247656     3  0.4961     0.1215 0.448 0.000 0.552 0.000
#> GSM247657     1  0.1792     0.8514 0.932 0.000 0.068 0.000
#> GSM247658     1  0.0188     0.8604 0.996 0.000 0.004 0.000
#> GSM247659     3  0.2408     0.8264 0.104 0.000 0.896 0.000
#> GSM247660     4  0.4564     0.5355 0.328 0.000 0.000 0.672
#> GSM247661     1  0.3400     0.7643 0.820 0.000 0.180 0.000
#> GSM247662     1  0.3978     0.7621 0.796 0.000 0.192 0.012
#> GSM247663     1  0.0524     0.8615 0.988 0.000 0.004 0.008
#> GSM247856     1  0.2342     0.8549 0.912 0.000 0.080 0.008
#> GSM247857     1  0.1305     0.8639 0.960 0.000 0.036 0.004
#> GSM247859     1  0.4989     0.0698 0.528 0.000 0.000 0.472
#> GSM247860     1  0.2011     0.8503 0.920 0.000 0.080 0.000
#> GSM247862     1  0.0592     0.8603 0.984 0.000 0.000 0.016
#> GSM247864     1  0.3074     0.7869 0.848 0.000 0.000 0.152
#> GSM247865     4  0.3074     0.7789 0.152 0.000 0.000 0.848
#> GSM247866     1  0.1389     0.8566 0.952 0.000 0.000 0.048
#> GSM247876     1  0.4953     0.7459 0.776 0.000 0.104 0.120
#> GSM247877     4  0.3850     0.7752 0.044 0.000 0.116 0.840
#> GSM247878     4  0.2868     0.7995 0.136 0.000 0.000 0.864
#> GSM247879     3  0.6883     0.4302 0.212 0.000 0.596 0.192
#> GSM247881     1  0.1792     0.8483 0.932 0.000 0.000 0.068
#> GSM247883     1  0.4193     0.6324 0.732 0.000 0.000 0.268

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM246087     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246090     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000    0.96575 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0510    0.74835 0.016 0.000 0.000 0.984 0.000
#> GSM246423     4  0.0510    0.74835 0.016 0.000 0.000 0.984 0.000
#> GSM246484     4  0.0510    0.74835 0.016 0.000 0.000 0.984 0.000
#> GSM246485     4  0.4919    0.36076 0.016 0.368 0.000 0.604 0.012
#> GSM246486     4  0.2997    0.64947 0.012 0.148 0.000 0.840 0.000
#> GSM246487     4  0.1043    0.73691 0.040 0.000 0.000 0.960 0.000
#> GSM246488     4  0.0671    0.74536 0.004 0.016 0.000 0.980 0.000
#> GSM246489     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0451    0.96709 0.004 0.988 0.000 0.008 0.000
#> GSM246491     2  0.0451    0.96730 0.008 0.988 0.000 0.004 0.000
#> GSM247162     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0579    0.96407 0.008 0.984 0.000 0.008 0.000
#> GSM247164     2  0.0579    0.96407 0.008 0.984 0.000 0.008 0.000
#> GSM247165     2  0.0992    0.95122 0.008 0.968 0.000 0.024 0.000
#> GSM247166     2  0.0162    0.96860 0.000 0.996 0.000 0.004 0.000
#> GSM247168     2  0.0162    0.96860 0.000 0.996 0.000 0.004 0.000
#> GSM247169     2  0.0162    0.96860 0.000 0.996 0.000 0.004 0.000
#> GSM247171     2  0.0162    0.96896 0.004 0.996 0.000 0.000 0.000
#> GSM247173     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0162    0.96896 0.004 0.996 0.000 0.000 0.000
#> GSM247188     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM247189     2  0.4478    0.39518 0.008 0.628 0.000 0.360 0.004
#> GSM247190     2  0.0000    0.96960 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.3631    0.36484 0.788 0.000 0.008 0.008 0.196
#> GSM247651     1  0.5153    0.17878 0.524 0.000 0.000 0.436 0.040
#> GSM247652     5  0.4138    0.36306 0.384 0.000 0.000 0.000 0.616
#> GSM247653     5  0.2221    0.55233 0.052 0.000 0.036 0.000 0.912
#> GSM247654     5  0.2843    0.55355 0.144 0.000 0.008 0.000 0.848
#> GSM247655     1  0.4509    0.42791 0.752 0.000 0.000 0.096 0.152
#> GSM247656     5  0.6424    0.22198 0.176 0.000 0.380 0.000 0.444
#> GSM247657     5  0.3582    0.48300 0.224 0.000 0.008 0.000 0.768
#> GSM247658     5  0.3913    0.45847 0.324 0.000 0.000 0.000 0.676
#> GSM247659     3  0.4964    0.58611 0.096 0.000 0.700 0.000 0.204
#> GSM247660     1  0.5394    0.28286 0.540 0.000 0.000 0.400 0.060
#> GSM247661     5  0.3593    0.52269 0.088 0.000 0.084 0.000 0.828
#> GSM247662     1  0.6299   -0.00702 0.504 0.000 0.144 0.004 0.348
#> GSM247663     1  0.4327    0.12764 0.632 0.000 0.000 0.008 0.360
#> GSM247856     5  0.5457    0.21413 0.460 0.000 0.060 0.000 0.480
#> GSM247857     1  0.5116   -0.05621 0.508 0.000 0.028 0.004 0.460
#> GSM247859     1  0.6442    0.29914 0.504 0.000 0.000 0.252 0.244
#> GSM247860     5  0.3085    0.51912 0.116 0.000 0.032 0.000 0.852
#> GSM247862     1  0.4830   -0.02522 0.492 0.000 0.000 0.020 0.488
#> GSM247864     1  0.3966    0.43844 0.796 0.000 0.000 0.072 0.132
#> GSM247865     4  0.5323    0.27588 0.296 0.000 0.000 0.624 0.080
#> GSM247866     5  0.4522    0.06789 0.440 0.000 0.000 0.008 0.552
#> GSM247876     1  0.5674    0.29685 0.640 0.000 0.036 0.052 0.272
#> GSM247877     4  0.6135   -0.03362 0.444 0.000 0.032 0.468 0.056
#> GSM247878     1  0.4803    0.05279 0.536 0.000 0.000 0.444 0.020
#> GSM247879     1  0.7540    0.23694 0.512 0.000 0.216 0.116 0.156
#> GSM247881     1  0.4080    0.32064 0.728 0.000 0.000 0.020 0.252
#> GSM247883     1  0.5357    0.30309 0.640 0.000 0.000 0.096 0.264

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0146     0.9469 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM246088     3  0.0146     0.9469 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM246089     3  0.0000     0.9474 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246090     3  0.0146     0.9469 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM246119     3  0.0000     0.9474 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000     0.9474 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000     0.9474 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0146     0.9469 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM246123     3  0.0000     0.9474 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.1074     0.7956 0.012 0.000 0.000 0.960 0.028 0.000
#> GSM246423     4  0.1074     0.7956 0.012 0.000 0.000 0.960 0.028 0.000
#> GSM246484     4  0.1074     0.7956 0.012 0.000 0.000 0.960 0.028 0.000
#> GSM246485     4  0.4899     0.4637 0.016 0.252 0.000 0.676 0.032 0.024
#> GSM246486     4  0.2214     0.7254 0.004 0.092 0.000 0.892 0.012 0.000
#> GSM246487     4  0.1477     0.7761 0.048 0.004 0.000 0.940 0.008 0.000
#> GSM246488     4  0.0405     0.7905 0.000 0.004 0.000 0.988 0.008 0.000
#> GSM246489     2  0.0291     0.9466 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM246490     2  0.0767     0.9446 0.004 0.976 0.000 0.008 0.012 0.000
#> GSM246491     2  0.0603     0.9459 0.000 0.980 0.000 0.004 0.016 0.000
#> GSM247162     2  0.0508     0.9471 0.000 0.984 0.000 0.004 0.012 0.000
#> GSM247163     2  0.1346     0.9379 0.008 0.952 0.000 0.016 0.024 0.000
#> GSM247164     2  0.1078     0.9391 0.008 0.964 0.000 0.016 0.012 0.000
#> GSM247165     2  0.1913     0.9058 0.004 0.920 0.000 0.060 0.012 0.004
#> GSM247166     2  0.1268     0.9359 0.000 0.952 0.000 0.004 0.036 0.008
#> GSM247168     2  0.1124     0.9371 0.000 0.956 0.000 0.000 0.036 0.008
#> GSM247169     2  0.1124     0.9371 0.000 0.956 0.000 0.000 0.036 0.008
#> GSM247171     2  0.0436     0.9465 0.004 0.988 0.000 0.004 0.004 0.000
#> GSM247173     2  0.0665     0.9457 0.004 0.980 0.000 0.008 0.008 0.000
#> GSM247174     2  0.0777     0.9418 0.000 0.972 0.000 0.000 0.024 0.004
#> GSM247175     2  0.0000     0.9467 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0363     0.9456 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM247189     2  0.5266     0.0617 0.004 0.492 0.000 0.420 0.084 0.000
#> GSM247190     2  0.0000     0.9467 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.5592     0.1328 0.536 0.000 0.012 0.004 0.352 0.096
#> GSM247651     1  0.6550    -0.0250 0.372 0.000 0.000 0.348 0.256 0.024
#> GSM247652     1  0.4704    -0.1858 0.488 0.000 0.000 0.000 0.044 0.468
#> GSM247653     6  0.3455     0.5193 0.052 0.000 0.036 0.000 0.076 0.836
#> GSM247654     6  0.4263     0.3981 0.276 0.000 0.008 0.000 0.032 0.684
#> GSM247655     1  0.4892     0.3345 0.720 0.000 0.000 0.056 0.148 0.076
#> GSM247656     6  0.7042     0.1703 0.280 0.000 0.256 0.000 0.072 0.392
#> GSM247657     6  0.4917     0.3431 0.300 0.000 0.016 0.000 0.056 0.628
#> GSM247658     6  0.4694     0.2071 0.376 0.000 0.000 0.000 0.052 0.572
#> GSM247659     3  0.6526     0.2980 0.100 0.000 0.544 0.000 0.144 0.212
#> GSM247660     1  0.6813     0.0794 0.424 0.000 0.000 0.296 0.224 0.056
#> GSM247661     6  0.4201     0.4767 0.084 0.000 0.048 0.000 0.084 0.784
#> GSM247662     1  0.6893     0.0609 0.464 0.000 0.100 0.000 0.160 0.276
#> GSM247663     5  0.6240    -0.1069 0.368 0.000 0.004 0.004 0.392 0.232
#> GSM247856     1  0.5999    -0.0138 0.504 0.000 0.052 0.000 0.084 0.360
#> GSM247857     1  0.6267     0.0330 0.464 0.000 0.028 0.000 0.168 0.340
#> GSM247859     1  0.6376     0.2865 0.576 0.000 0.000 0.160 0.112 0.152
#> GSM247860     6  0.4060     0.4801 0.060 0.000 0.016 0.000 0.156 0.768
#> GSM247862     1  0.6095     0.0800 0.432 0.000 0.000 0.012 0.180 0.376
#> GSM247864     1  0.5517     0.2283 0.612 0.000 0.000 0.048 0.268 0.072
#> GSM247865     4  0.6219     0.0294 0.360 0.000 0.000 0.480 0.108 0.052
#> GSM247866     6  0.6182     0.0125 0.264 0.000 0.000 0.004 0.340 0.392
#> GSM247876     5  0.4648     0.4813 0.148 0.000 0.012 0.016 0.740 0.084
#> GSM247877     5  0.4481     0.5229 0.048 0.000 0.008 0.212 0.720 0.012
#> GSM247878     5  0.5454     0.4505 0.160 0.000 0.000 0.232 0.600 0.008
#> GSM247879     5  0.4090     0.5334 0.072 0.000 0.068 0.020 0.808 0.032
#> GSM247881     1  0.4990     0.3203 0.660 0.000 0.000 0.004 0.184 0.152
#> GSM247883     1  0.4824     0.3715 0.736 0.000 0.000 0.072 0.088 0.104

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) k
#> CV:skmeans 61         2.53e-12 2
#> CV:skmeans 61         1.51e-13 3
#> CV:skmeans 57         6.33e-18 4
#> CV:skmeans 36         1.83e-11 5
#> CV:skmeans 34         1.23e-11 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 21168 rows and 61 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.788           0.887       0.947         0.4733 0.541   0.541
#> 3 3 1.000           0.987       0.994         0.2889 0.845   0.715
#> 4 4 1.000           0.974       0.990         0.1074 0.926   0.814
#> 5 5 0.833           0.818       0.905         0.1156 0.928   0.778
#> 6 6 0.854           0.798       0.887         0.0343 0.974   0.899

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] 3

There is also optional best \(k\) = 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
#> GSM246087     1  0.9998      0.142 0.508 0.492
#> GSM246088     1  0.7815      0.727 0.768 0.232
#> GSM246089     1  0.9491      0.481 0.632 0.368
#> GSM246090     1  0.9933      0.268 0.548 0.452
#> GSM246119     1  0.5946      0.827 0.856 0.144
#> GSM246120     1  0.8499      0.662 0.724 0.276
#> GSM246121     1  0.6801      0.789 0.820 0.180
#> GSM246122     2  0.9661      0.230 0.392 0.608
#> GSM246123     1  0.7745      0.729 0.772 0.228
#> GSM246422     1  0.0672      0.928 0.992 0.008
#> GSM246423     1  0.0376      0.930 0.996 0.004
#> GSM246484     1  0.2603      0.903 0.956 0.044
#> GSM246485     2  0.0938      0.977 0.012 0.988
#> GSM246486     2  0.0938      0.977 0.012 0.988
#> GSM246487     1  0.4562      0.858 0.904 0.096
#> GSM246488     2  0.1184      0.973 0.016 0.984
#> GSM246489     2  0.0938      0.977 0.012 0.988
#> GSM246490     2  0.0938      0.977 0.012 0.988
#> GSM246491     2  0.0938      0.977 0.012 0.988
#> GSM247162     2  0.0938      0.977 0.012 0.988
#> GSM247163     2  0.0938      0.977 0.012 0.988
#> GSM247164     2  0.0938      0.977 0.012 0.988
#> GSM247165     2  0.0938      0.977 0.012 0.988
#> GSM247166     2  0.0938      0.977 0.012 0.988
#> GSM247168     2  0.0938      0.977 0.012 0.988
#> GSM247169     2  0.0938      0.977 0.012 0.988
#> GSM247171     2  0.0938      0.977 0.012 0.988
#> GSM247173     2  0.0938      0.977 0.012 0.988
#> GSM247174     2  0.0938      0.977 0.012 0.988
#> GSM247175     2  0.0938      0.977 0.012 0.988
#> GSM247188     2  0.0938      0.977 0.012 0.988
#> GSM247189     2  0.0938      0.977 0.012 0.988
#> GSM247190     2  0.0938      0.977 0.012 0.988
#> GSM247650     1  0.0000      0.932 1.000 0.000
#> GSM247651     1  0.0000      0.932 1.000 0.000
#> GSM247652     1  0.0000      0.932 1.000 0.000
#> GSM247653     1  0.0000      0.932 1.000 0.000
#> GSM247654     1  0.0000      0.932 1.000 0.000
#> GSM247655     1  0.0000      0.932 1.000 0.000
#> GSM247656     1  0.0000      0.932 1.000 0.000
#> GSM247657     1  0.0000      0.932 1.000 0.000
#> GSM247658     1  0.0000      0.932 1.000 0.000
#> GSM247659     1  0.2603      0.911 0.956 0.044
#> GSM247660     1  0.0000      0.932 1.000 0.000
#> GSM247661     1  0.0938      0.924 0.988 0.012
#> GSM247662     1  0.0376      0.930 0.996 0.004
#> GSM247663     1  0.0000      0.932 1.000 0.000
#> GSM247856     1  0.0000      0.932 1.000 0.000
#> GSM247857     1  0.0000      0.932 1.000 0.000
#> GSM247859     1  0.0000      0.932 1.000 0.000
#> GSM247860     1  0.0000      0.932 1.000 0.000
#> GSM247862     1  0.0000      0.932 1.000 0.000
#> GSM247864     1  0.0000      0.932 1.000 0.000
#> GSM247865     1  0.0000      0.932 1.000 0.000
#> GSM247866     1  0.0000      0.932 1.000 0.000
#> GSM247876     1  0.0000      0.932 1.000 0.000
#> GSM247877     1  0.0000      0.932 1.000 0.000
#> GSM247878     1  0.0000      0.932 1.000 0.000
#> GSM247879     1  0.0376      0.930 0.996 0.004
#> GSM247881     1  0.0000      0.932 1.000 0.000
#> GSM247883     1  0.0000      0.932 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246422     1  0.0000      0.988 1.000 0.000 0.000
#> GSM246423     1  0.0000      0.988 1.000 0.000 0.000
#> GSM246484     1  0.0000      0.988 1.000 0.000 0.000
#> GSM246485     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246486     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246487     1  0.0000      0.988 1.000 0.000 0.000
#> GSM246488     2  0.0237      0.995 0.004 0.996 0.000
#> GSM246489     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246490     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246491     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247162     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247163     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247164     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247165     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247166     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247168     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247169     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247171     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247173     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247174     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247175     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247188     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247189     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247190     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247656     1  0.4796      0.720 0.780 0.000 0.220
#> GSM247657     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247659     1  0.4742      0.829 0.848 0.048 0.104
#> GSM247660     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247876     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247877     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247878     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247879     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247881     1  0.0000      0.988 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.988 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> GSM246485     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM246486     2  0.1118      0.963 0.000 0.964 0.000 0.036
#> GSM246487     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM246488     4  0.0000      0.911 0.000 0.000 0.000 1.000
#> GSM246489     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247189     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247190     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247651     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247652     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247653     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247654     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247655     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247656     1  0.0592      0.970 0.984 0.000 0.016 0.000
#> GSM247657     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247658     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247659     1  0.4956      0.702 0.776 0.116 0.108 0.000
#> GSM247660     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247661     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247662     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247663     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247856     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247859     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247860     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247862     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247864     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247865     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247866     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247876     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247877     4  0.3907      0.647 0.232 0.000 0.000 0.768
#> GSM247878     1  0.2530      0.862 0.888 0.000 0.000 0.112
#> GSM247879     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247881     1  0.0000      0.986 1.000 0.000 0.000 0.000
#> GSM247883     1  0.0000      0.986 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0162      0.997 0.000 0.000 0.996 0.000 0.004
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000
#> GSM246484     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000
#> GSM246485     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM246486     2  0.0963      0.963 0.000 0.964 0.000 0.036 0.000
#> GSM246487     1  0.0000      0.767 1.000 0.000 0.000 0.000 0.000
#> GSM246488     4  0.0000      0.865 0.000 0.000 0.000 1.000 0.000
#> GSM246489     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247165     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247166     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247189     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247190     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.1478      0.715 0.936 0.000 0.000 0.000 0.064
#> GSM247651     1  0.0290      0.767 0.992 0.000 0.000 0.000 0.008
#> GSM247652     1  0.3730      0.643 0.712 0.000 0.000 0.000 0.288
#> GSM247653     1  0.4305      0.327 0.512 0.000 0.000 0.000 0.488
#> GSM247654     1  0.4101      0.551 0.628 0.000 0.000 0.000 0.372
#> GSM247655     1  0.0000      0.767 1.000 0.000 0.000 0.000 0.000
#> GSM247656     5  0.3074      0.649 0.196 0.000 0.000 0.000 0.804
#> GSM247657     5  0.3661      0.666 0.276 0.000 0.000 0.000 0.724
#> GSM247658     1  0.3210      0.705 0.788 0.000 0.000 0.000 0.212
#> GSM247659     5  0.4738      0.631 0.164 0.012 0.076 0.000 0.748
#> GSM247660     1  0.0000      0.767 1.000 0.000 0.000 0.000 0.000
#> GSM247661     5  0.3143      0.576 0.204 0.000 0.000 0.000 0.796
#> GSM247662     5  0.4305      0.583 0.488 0.000 0.000 0.000 0.512
#> GSM247663     1  0.2852      0.720 0.828 0.000 0.000 0.000 0.172
#> GSM247856     1  0.4161      0.502 0.608 0.000 0.000 0.000 0.392
#> GSM247857     5  0.4256      0.628 0.436 0.000 0.000 0.000 0.564
#> GSM247859     1  0.2852      0.729 0.828 0.000 0.000 0.000 0.172
#> GSM247860     1  0.3949      0.445 0.668 0.000 0.000 0.000 0.332
#> GSM247862     1  0.0000      0.767 1.000 0.000 0.000 0.000 0.000
#> GSM247864     1  0.0000      0.767 1.000 0.000 0.000 0.000 0.000
#> GSM247865     1  0.2732      0.737 0.840 0.000 0.000 0.000 0.160
#> GSM247866     1  0.0162      0.766 0.996 0.000 0.000 0.000 0.004
#> GSM247876     1  0.2424      0.745 0.868 0.000 0.000 0.000 0.132
#> GSM247877     4  0.4161      0.262 0.392 0.000 0.000 0.608 0.000
#> GSM247878     1  0.1608      0.717 0.928 0.000 0.000 0.072 0.000
#> GSM247879     1  0.3932      0.105 0.672 0.000 0.000 0.000 0.328
#> GSM247881     1  0.2377      0.756 0.872 0.000 0.000 0.000 0.128
#> GSM247883     1  0.2891      0.738 0.824 0.000 0.000 0.000 0.176

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.3953      0.741 0.000 0.000 0.744 0.000 0.060 0.196
#> GSM246090     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.0000      0.844 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246423     4  0.0000      0.844 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246484     4  0.0000      0.844 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246485     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246486     2  0.0865      0.962 0.000 0.964 0.000 0.036 0.000 0.000
#> GSM246487     1  0.0146      0.768 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM246488     4  0.0000      0.844 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246489     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247165     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247166     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247190     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.2558      0.676 0.840 0.000 0.000 0.000 0.004 0.156
#> GSM247651     1  0.0291      0.768 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM247652     1  0.3684      0.584 0.628 0.000 0.000 0.000 0.372 0.000
#> GSM247653     6  0.5663      0.537 0.248 0.000 0.000 0.000 0.220 0.532
#> GSM247654     1  0.3823      0.506 0.564 0.000 0.000 0.000 0.436 0.000
#> GSM247655     1  0.0000      0.769 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247656     5  0.1444      0.426 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM247657     5  0.4487      0.788 0.068 0.000 0.000 0.000 0.668 0.264
#> GSM247658     1  0.3409      0.648 0.700 0.000 0.000 0.000 0.300 0.000
#> GSM247659     5  0.5005      0.758 0.072 0.004 0.004 0.000 0.612 0.308
#> GSM247660     1  0.0146      0.768 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247661     6  0.4176     -0.144 0.064 0.000 0.000 0.000 0.220 0.716
#> GSM247662     5  0.5287      0.767 0.144 0.000 0.000 0.000 0.584 0.272
#> GSM247663     1  0.3151      0.672 0.748 0.000 0.000 0.000 0.252 0.000
#> GSM247856     1  0.3838      0.482 0.552 0.000 0.000 0.000 0.448 0.000
#> GSM247857     5  0.4972      0.800 0.108 0.000 0.000 0.000 0.620 0.272
#> GSM247859     1  0.2597      0.745 0.824 0.000 0.000 0.000 0.176 0.000
#> GSM247860     6  0.5575      0.555 0.296 0.000 0.000 0.000 0.172 0.532
#> GSM247862     1  0.0146      0.768 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247864     1  0.0000      0.769 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247865     1  0.2632      0.751 0.832 0.000 0.000 0.000 0.164 0.004
#> GSM247866     1  0.0363      0.765 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM247876     1  0.2006      0.763 0.892 0.000 0.000 0.000 0.104 0.004
#> GSM247877     4  0.4144      0.179 0.408 0.000 0.000 0.580 0.008 0.004
#> GSM247878     1  0.1644      0.708 0.920 0.000 0.000 0.076 0.000 0.004
#> GSM247879     1  0.5438     -0.178 0.496 0.000 0.000 0.000 0.380 0.124
#> GSM247881     1  0.2482      0.755 0.848 0.000 0.000 0.000 0.148 0.004
#> GSM247883     1  0.2996      0.718 0.772 0.000 0.000 0.000 0.228 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) k
#> CV:pam 57         6.32e-10 2
#> CV:pam 61         6.70e-22 3
#> CV:pam 61         3.47e-22 4
#> CV:pam 57         4.82e-20 5
#> CV:pam 56         1.70e-18 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 21168 rows and 61 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 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-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.494           0.772       0.885         0.4954 0.503   0.503
#> 3 3 0.842           0.865       0.939         0.3144 0.733   0.522
#> 4 4 0.941           0.917       0.966         0.0982 0.918   0.774
#> 5 5 0.786           0.586       0.803         0.0628 0.923   0.740
#> 6 6 0.805           0.680       0.838         0.0613 0.905   0.621

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     2  0.8555      0.698 0.280 0.720
#> GSM246088     2  0.8555      0.698 0.280 0.720
#> GSM246089     2  0.8555      0.698 0.280 0.720
#> GSM246090     2  0.8555      0.698 0.280 0.720
#> GSM246119     2  0.8555      0.698 0.280 0.720
#> GSM246120     2  0.8555      0.698 0.280 0.720
#> GSM246121     2  0.8555      0.698 0.280 0.720
#> GSM246122     2  0.8555      0.698 0.280 0.720
#> GSM246123     2  0.8555      0.698 0.280 0.720
#> GSM246422     1  0.9983      0.373 0.524 0.476
#> GSM246423     1  0.9983      0.373 0.524 0.476
#> GSM246484     1  0.9983      0.373 0.524 0.476
#> GSM246485     1  0.9933      0.401 0.548 0.452
#> GSM246486     1  0.9970      0.368 0.532 0.468
#> GSM246487     1  0.9286      0.563 0.656 0.344
#> GSM246488     1  0.9963      0.377 0.536 0.464
#> GSM246489     2  0.0938      0.867 0.012 0.988
#> GSM246490     2  0.0938      0.867 0.012 0.988
#> GSM246491     2  0.0938      0.867 0.012 0.988
#> GSM247162     2  0.0938      0.867 0.012 0.988
#> GSM247163     2  0.1184      0.865 0.016 0.984
#> GSM247164     2  0.0938      0.867 0.012 0.988
#> GSM247165     2  0.0938      0.867 0.012 0.988
#> GSM247166     2  0.0938      0.867 0.012 0.988
#> GSM247168     2  0.0938      0.867 0.012 0.988
#> GSM247169     2  0.0938      0.867 0.012 0.988
#> GSM247171     2  0.0938      0.867 0.012 0.988
#> GSM247173     2  0.0938      0.867 0.012 0.988
#> GSM247174     2  0.0938      0.867 0.012 0.988
#> GSM247175     2  0.0938      0.867 0.012 0.988
#> GSM247188     2  0.0938      0.867 0.012 0.988
#> GSM247189     2  0.2948      0.833 0.052 0.948
#> GSM247190     2  0.0938      0.867 0.012 0.988
#> GSM247650     1  0.0000      0.859 1.000 0.000
#> GSM247651     1  0.0000      0.859 1.000 0.000
#> GSM247652     1  0.0000      0.859 1.000 0.000
#> GSM247653     1  0.0000      0.859 1.000 0.000
#> GSM247654     1  0.0000      0.859 1.000 0.000
#> GSM247655     1  0.0000      0.859 1.000 0.000
#> GSM247656     1  0.0376      0.856 0.996 0.004
#> GSM247657     1  0.0000      0.859 1.000 0.000
#> GSM247658     1  0.0000      0.859 1.000 0.000
#> GSM247659     1  0.4161      0.806 0.916 0.084
#> GSM247660     1  0.0000      0.859 1.000 0.000
#> GSM247661     1  0.0000      0.859 1.000 0.000
#> GSM247662     1  0.0672      0.854 0.992 0.008
#> GSM247663     1  0.0000      0.859 1.000 0.000
#> GSM247856     1  0.0000      0.859 1.000 0.000
#> GSM247857     1  0.0000      0.859 1.000 0.000
#> GSM247859     1  0.0000      0.859 1.000 0.000
#> GSM247860     1  0.0000      0.859 1.000 0.000
#> GSM247862     1  0.0000      0.859 1.000 0.000
#> GSM247864     1  0.0000      0.859 1.000 0.000
#> GSM247865     1  0.5519      0.775 0.872 0.128
#> GSM247866     1  0.0000      0.859 1.000 0.000
#> GSM247876     1  0.2948      0.830 0.948 0.052
#> GSM247877     1  0.9248      0.562 0.660 0.340
#> GSM247878     1  0.8555      0.657 0.720 0.280
#> GSM247879     1  0.5519      0.773 0.872 0.128
#> GSM247881     1  0.0000      0.859 1.000 0.000
#> GSM247883     1  0.2423      0.839 0.960 0.040

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.948 0.000 0.000 1.000
#> GSM246422     3  0.3589      0.897 0.052 0.048 0.900
#> GSM246423     3  0.3589      0.897 0.052 0.048 0.900
#> GSM246484     3  0.3589      0.897 0.052 0.048 0.900
#> GSM246485     2  0.7425      0.509 0.052 0.620 0.328
#> GSM246486     2  0.6579      0.549 0.020 0.652 0.328
#> GSM246487     2  0.7514      0.504 0.056 0.616 0.328
#> GSM246488     2  0.6819      0.539 0.028 0.644 0.328
#> GSM246489     2  0.0000      0.892 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.892 0.000 1.000 0.000
#> GSM246491     2  0.1289      0.875 0.000 0.968 0.032
#> GSM247162     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247163     2  0.2448      0.845 0.000 0.924 0.076
#> GSM247164     2  0.0237      0.890 0.000 0.996 0.004
#> GSM247165     2  0.0475      0.888 0.004 0.992 0.004
#> GSM247166     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247189     2  0.6579      0.549 0.020 0.652 0.328
#> GSM247190     2  0.0000      0.892 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247656     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247657     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247659     1  0.5810      0.490 0.664 0.000 0.336
#> GSM247660     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247865     1  0.0237      0.943 0.996 0.000 0.004
#> GSM247866     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247876     1  0.5397      0.601 0.720 0.000 0.280
#> GSM247877     3  0.5619      0.668 0.244 0.012 0.744
#> GSM247878     1  0.5178      0.641 0.744 0.000 0.256
#> GSM247879     1  0.5810      0.490 0.664 0.000 0.336
#> GSM247881     1  0.0000      0.947 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.947 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246422     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246423     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246484     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246485     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246486     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246487     4  0.0188      0.940 0.004 0.000  0 0.996
#> GSM246488     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM246489     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM246490     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM246491     2  0.4564      0.459 0.000 0.672  0 0.328
#> GSM247162     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247163     4  0.4925      0.221 0.000 0.428  0 0.572
#> GSM247164     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247165     2  0.0336      0.966 0.000 0.992  0 0.008
#> GSM247166     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247168     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247169     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247171     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247173     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247174     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247175     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247188     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247189     4  0.0000      0.944 0.000 0.000  0 1.000
#> GSM247190     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247650     1  0.0469      0.944 0.988 0.000  0 0.012
#> GSM247651     1  0.0469      0.944 0.988 0.000  0 0.012
#> GSM247652     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247653     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247654     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247655     1  0.0188      0.947 0.996 0.000  0 0.004
#> GSM247656     1  0.0336      0.945 0.992 0.000  0 0.008
#> GSM247657     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247658     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247659     1  0.4564      0.565 0.672 0.000  0 0.328
#> GSM247660     1  0.0188      0.947 0.996 0.000  0 0.004
#> GSM247661     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247662     1  0.0336      0.945 0.992 0.000  0 0.008
#> GSM247663     1  0.0469      0.944 0.988 0.000  0 0.012
#> GSM247856     1  0.0188      0.947 0.996 0.000  0 0.004
#> GSM247857     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247859     1  0.0188      0.947 0.996 0.000  0 0.004
#> GSM247860     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247862     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247864     1  0.0188      0.947 0.996 0.000  0 0.004
#> GSM247865     1  0.1118      0.926 0.964 0.000  0 0.036
#> GSM247866     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247876     1  0.3311      0.792 0.828 0.000  0 0.172
#> GSM247877     4  0.0188      0.940 0.004 0.000  0 0.996
#> GSM247878     1  0.4790      0.464 0.620 0.000  0 0.380
#> GSM247879     1  0.4624      0.544 0.660 0.000  0 0.340
#> GSM247881     1  0.0000      0.947 1.000 0.000  0 0.000
#> GSM247883     1  0.0188      0.947 0.996 0.000  0 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
#> GSM246087     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000    1.00000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.4249    0.68785 0.000 0.000  0 0.568 0.432
#> GSM246423     4  0.4249    0.68785 0.000 0.000  0 0.568 0.432
#> GSM246484     4  0.4249    0.68785 0.000 0.000  0 0.568 0.432
#> GSM246485     4  0.1757    0.77432 0.012 0.004  0 0.936 0.048
#> GSM246486     4  0.1124    0.78774 0.000 0.004  0 0.960 0.036
#> GSM246487     4  0.2052    0.78127 0.004 0.004  0 0.912 0.080
#> GSM246488     4  0.0963    0.78846 0.000 0.000  0 0.964 0.036
#> GSM246489     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM246491     2  0.3966    0.46339 0.000 0.664  0 0.336 0.000
#> GSM247162     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM247163     4  0.4291    0.00574 0.000 0.464  0 0.536 0.000
#> GSM247164     2  0.1043    0.93325 0.000 0.960  0 0.040 0.000
#> GSM247165     2  0.1851    0.88544 0.000 0.912  0 0.088 0.000
#> GSM247166     2  0.0162    0.96116 0.000 0.996  0 0.000 0.004
#> GSM247168     2  0.0162    0.96116 0.000 0.996  0 0.000 0.004
#> GSM247169     2  0.0162    0.96116 0.000 0.996  0 0.000 0.004
#> GSM247171     2  0.0404    0.95471 0.000 0.988  0 0.012 0.000
#> GSM247173     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0162    0.96116 0.000 0.996  0 0.000 0.004
#> GSM247175     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000    0.96145 0.000 1.000  0 0.000 0.000
#> GSM247189     4  0.0963    0.78846 0.000 0.000  0 0.964 0.036
#> GSM247190     2  0.0162    0.96116 0.000 0.996  0 0.000 0.004
#> GSM247650     1  0.4331    0.27343 0.596 0.000  0 0.004 0.400
#> GSM247651     5  0.4555    0.14467 0.472 0.000  0 0.008 0.520
#> GSM247652     1  0.3752    0.46048 0.708 0.000  0 0.000 0.292
#> GSM247653     1  0.1043    0.44886 0.960 0.000  0 0.000 0.040
#> GSM247654     1  0.0510    0.45866 0.984 0.000  0 0.000 0.016
#> GSM247655     5  0.4446    0.13576 0.476 0.000  0 0.004 0.520
#> GSM247656     1  0.3480    0.50164 0.752 0.000  0 0.000 0.248
#> GSM247657     1  0.0510    0.45866 0.984 0.000  0 0.000 0.016
#> GSM247658     1  0.3143    0.50598 0.796 0.000  0 0.000 0.204
#> GSM247659     1  0.5579    0.21167 0.552 0.000  0 0.080 0.368
#> GSM247660     5  0.4555    0.14467 0.472 0.000  0 0.008 0.520
#> GSM247661     1  0.1608    0.45652 0.928 0.000  0 0.000 0.072
#> GSM247662     1  0.3949    0.42266 0.668 0.000  0 0.000 0.332
#> GSM247663     1  0.4331    0.27343 0.596 0.000  0 0.004 0.400
#> GSM247856     1  0.3109    0.51487 0.800 0.000  0 0.000 0.200
#> GSM247857     1  0.2377    0.51026 0.872 0.000  0 0.000 0.128
#> GSM247859     1  0.4449   -0.11743 0.512 0.000  0 0.004 0.484
#> GSM247860     1  0.0794    0.45481 0.972 0.000  0 0.000 0.028
#> GSM247862     1  0.4114    0.28083 0.624 0.000  0 0.000 0.376
#> GSM247864     5  0.4302    0.11600 0.480 0.000  0 0.000 0.520
#> GSM247865     5  0.5114    0.07558 0.476 0.000  0 0.036 0.488
#> GSM247866     1  0.3983    0.34775 0.660 0.000  0 0.000 0.340
#> GSM247876     1  0.4590    0.24471 0.568 0.000  0 0.012 0.420
#> GSM247877     5  0.5594   -0.57579 0.072 0.000  0 0.436 0.492
#> GSM247878     5  0.6429    0.06379 0.296 0.000  0 0.208 0.496
#> GSM247879     1  0.6000    0.03230 0.460 0.000  0 0.112 0.428
#> GSM247881     1  0.4425    0.24517 0.600 0.000  0 0.008 0.392
#> GSM247883     1  0.4656   -0.12766 0.508 0.000  0 0.012 0.480

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4    p5    p6
#> GSM246087     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246088     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246089     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246090     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246119     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246120     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246121     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246122     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246123     3  0.0000     1.0000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246422     6  0.0632     0.8122 0.000 0.000  0 0.024 0.000 0.976
#> GSM246423     6  0.0632     0.8122 0.000 0.000  0 0.024 0.000 0.976
#> GSM246484     6  0.0632     0.8122 0.000 0.000  0 0.024 0.000 0.976
#> GSM246485     4  0.1411     0.9089 0.000 0.004  0 0.936 0.060 0.000
#> GSM246486     4  0.0000     0.9366 0.000 0.000  0 1.000 0.000 0.000
#> GSM246487     4  0.3004     0.8375 0.008 0.004  0 0.860 0.080 0.048
#> GSM246488     4  0.0000     0.9366 0.000 0.000  0 1.000 0.000 0.000
#> GSM246489     2  0.0000     0.9441 0.000 1.000  0 0.000 0.000 0.000
#> GSM246490     2  0.0692     0.9362 0.000 0.976  0 0.020 0.000 0.004
#> GSM246491     2  0.1814     0.8800 0.000 0.900  0 0.100 0.000 0.000
#> GSM247162     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247163     2  0.3101     0.7339 0.000 0.756  0 0.244 0.000 0.000
#> GSM247164     2  0.2320     0.8494 0.000 0.864  0 0.132 0.000 0.004
#> GSM247165     2  0.3383     0.6838 0.000 0.728  0 0.268 0.000 0.004
#> GSM247166     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247168     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247169     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247171     2  0.0603     0.9387 0.000 0.980  0 0.016 0.000 0.004
#> GSM247173     2  0.0146     0.9433 0.000 0.996  0 0.000 0.000 0.004
#> GSM247174     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247175     2  0.0000     0.9441 0.000 1.000  0 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9441 0.000 1.000  0 0.000 0.000 0.000
#> GSM247189     4  0.0146     0.9347 0.000 0.004  0 0.996 0.000 0.000
#> GSM247190     2  0.0260     0.9444 0.000 0.992  0 0.000 0.000 0.008
#> GSM247650     5  0.4062    -0.1954 0.440 0.000  0 0.000 0.552 0.008
#> GSM247651     5  0.3565     0.5203 0.304 0.000  0 0.004 0.692 0.000
#> GSM247652     1  0.2340     0.5754 0.852 0.000  0 0.000 0.148 0.000
#> GSM247653     1  0.0458     0.6456 0.984 0.000  0 0.000 0.016 0.000
#> GSM247654     1  0.0000     0.6431 1.000 0.000  0 0.000 0.000 0.000
#> GSM247655     5  0.3428     0.5225 0.304 0.000  0 0.000 0.696 0.000
#> GSM247656     1  0.3695     0.3653 0.624 0.000  0 0.000 0.376 0.000
#> GSM247657     1  0.0000     0.6431 1.000 0.000  0 0.000 0.000 0.000
#> GSM247658     1  0.2597     0.5451 0.824 0.000  0 0.000 0.176 0.000
#> GSM247659     1  0.5206     0.1550 0.492 0.000  0 0.012 0.436 0.060
#> GSM247660     5  0.3428     0.5225 0.304 0.000  0 0.000 0.696 0.000
#> GSM247661     1  0.1010     0.6400 0.960 0.000  0 0.000 0.036 0.004
#> GSM247662     1  0.4032     0.3100 0.572 0.000  0 0.000 0.420 0.008
#> GSM247663     5  0.4057    -0.1894 0.436 0.000  0 0.000 0.556 0.008
#> GSM247856     1  0.3101     0.5075 0.756 0.000  0 0.000 0.244 0.000
#> GSM247857     1  0.0937     0.6411 0.960 0.000  0 0.000 0.040 0.000
#> GSM247859     5  0.3578     0.4994 0.340 0.000  0 0.000 0.660 0.000
#> GSM247860     1  0.0260     0.6458 0.992 0.000  0 0.000 0.008 0.000
#> GSM247862     1  0.3607     0.1987 0.652 0.000  0 0.000 0.348 0.000
#> GSM247864     5  0.3428     0.5225 0.304 0.000  0 0.000 0.696 0.000
#> GSM247865     5  0.4124     0.5049 0.332 0.000  0 0.008 0.648 0.012
#> GSM247866     1  0.3774     0.0227 0.592 0.000  0 0.000 0.408 0.000
#> GSM247876     5  0.4760    -0.1874 0.436 0.000  0 0.004 0.520 0.040
#> GSM247877     6  0.3649     0.7204 0.000 0.000  0 0.040 0.196 0.764
#> GSM247878     6  0.4565     0.5385 0.000 0.000  0 0.036 0.432 0.532
#> GSM247879     5  0.5407    -0.0553 0.340 0.000  0 0.024 0.564 0.072
#> GSM247881     1  0.3563     0.2412 0.664 0.000  0 0.000 0.336 0.000
#> GSM247883     5  0.3699     0.5038 0.336 0.000  0 0.004 0.660 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-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:mclust 55         7.58e-12 2
#> CV:mclust 59         4.76e-19 3
#> CV:mclust 58         8.78e-22 4
#> CV:mclust 35         4.09e-13 5
#> CV:mclust 50         8.71e-16 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 21168 rows and 61 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.774           0.870       0.947         0.5008 0.492   0.492
#> 3 3 0.874           0.895       0.956         0.3011 0.661   0.424
#> 4 4 0.885           0.892       0.950         0.1035 0.830   0.579
#> 5 5 0.835           0.800       0.907         0.0507 0.966   0.885
#> 6 6 0.735           0.597       0.792         0.0610 0.961   0.855

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
#> GSM246087     1  0.0000      0.939 1.000 0.000
#> GSM246088     1  0.0000      0.939 1.000 0.000
#> GSM246089     1  0.0000      0.939 1.000 0.000
#> GSM246090     1  0.0000      0.939 1.000 0.000
#> GSM246119     1  0.0000      0.939 1.000 0.000
#> GSM246120     1  0.0000      0.939 1.000 0.000
#> GSM246121     1  0.0000      0.939 1.000 0.000
#> GSM246122     1  0.0000      0.939 1.000 0.000
#> GSM246123     1  0.0000      0.939 1.000 0.000
#> GSM246422     2  0.0000      0.940 0.000 1.000
#> GSM246423     2  0.0000      0.940 0.000 1.000
#> GSM246484     2  0.0000      0.940 0.000 1.000
#> GSM246485     2  0.0000      0.940 0.000 1.000
#> GSM246486     2  0.0000      0.940 0.000 1.000
#> GSM246487     2  0.0000      0.940 0.000 1.000
#> GSM246488     2  0.0000      0.940 0.000 1.000
#> GSM246489     2  0.0000      0.940 0.000 1.000
#> GSM246490     2  0.0000      0.940 0.000 1.000
#> GSM246491     2  0.0000      0.940 0.000 1.000
#> GSM247162     2  0.0000      0.940 0.000 1.000
#> GSM247163     2  0.0000      0.940 0.000 1.000
#> GSM247164     2  0.0000      0.940 0.000 1.000
#> GSM247165     2  0.0000      0.940 0.000 1.000
#> GSM247166     2  0.0000      0.940 0.000 1.000
#> GSM247168     2  0.0000      0.940 0.000 1.000
#> GSM247169     2  0.0000      0.940 0.000 1.000
#> GSM247171     2  0.0000      0.940 0.000 1.000
#> GSM247173     2  0.0000      0.940 0.000 1.000
#> GSM247174     2  0.0000      0.940 0.000 1.000
#> GSM247175     2  0.0000      0.940 0.000 1.000
#> GSM247188     2  0.0000      0.940 0.000 1.000
#> GSM247189     2  0.0000      0.940 0.000 1.000
#> GSM247190     2  0.0000      0.940 0.000 1.000
#> GSM247650     1  0.0000      0.939 1.000 0.000
#> GSM247651     2  0.7883      0.688 0.236 0.764
#> GSM247652     1  0.0000      0.939 1.000 0.000
#> GSM247653     1  0.0000      0.939 1.000 0.000
#> GSM247654     1  0.0000      0.939 1.000 0.000
#> GSM247655     1  0.9944      0.142 0.544 0.456
#> GSM247656     1  0.0000      0.939 1.000 0.000
#> GSM247657     1  0.0000      0.939 1.000 0.000
#> GSM247658     1  0.3114      0.895 0.944 0.056
#> GSM247659     1  0.0000      0.939 1.000 0.000
#> GSM247660     2  0.8608      0.609 0.284 0.716
#> GSM247661     1  0.0000      0.939 1.000 0.000
#> GSM247662     1  0.0000      0.939 1.000 0.000
#> GSM247663     1  0.0000      0.939 1.000 0.000
#> GSM247856     1  0.0000      0.939 1.000 0.000
#> GSM247857     1  0.0000      0.939 1.000 0.000
#> GSM247859     2  0.8327      0.644 0.264 0.736
#> GSM247860     1  0.0938      0.930 0.988 0.012
#> GSM247862     1  0.9248      0.481 0.660 0.340
#> GSM247864     1  0.6438      0.780 0.836 0.164
#> GSM247865     2  0.1633      0.922 0.024 0.976
#> GSM247866     2  0.9635      0.374 0.388 0.612
#> GSM247876     1  0.0000      0.939 1.000 0.000
#> GSM247877     1  0.7299      0.726 0.796 0.204
#> GSM247878     1  0.9580      0.380 0.620 0.380
#> GSM247879     1  0.0000      0.939 1.000 0.000
#> GSM247881     2  0.9393      0.457 0.356 0.644
#> GSM247883     2  0.3733      0.881 0.072 0.928

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246088     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246089     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246090     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246119     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246120     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246121     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246122     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246123     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM246422     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM246423     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM246484     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM246485     2  0.2625     0.8872 0.084 0.916 0.000
#> GSM246486     2  0.2537     0.8914 0.080 0.920 0.000
#> GSM246487     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM246488     2  0.6026     0.4174 0.376 0.624 0.000
#> GSM246489     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM246490     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM246491     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247162     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247163     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247164     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247165     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247166     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247168     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247169     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247171     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247173     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247174     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247175     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247188     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247189     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247190     2  0.0000     0.9666 0.000 1.000 0.000
#> GSM247650     1  0.2356     0.8969 0.928 0.000 0.072
#> GSM247651     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247652     1  0.0237     0.9476 0.996 0.000 0.004
#> GSM247653     3  0.5529     0.6190 0.296 0.000 0.704
#> GSM247654     1  0.4291     0.7652 0.820 0.000 0.180
#> GSM247655     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247656     3  0.4291     0.7856 0.180 0.000 0.820
#> GSM247657     1  0.6299     0.0164 0.524 0.000 0.476
#> GSM247658     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247659     3  0.0000     0.9197 0.000 0.000 1.000
#> GSM247660     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247661     3  0.4504     0.7692 0.196 0.000 0.804
#> GSM247662     3  0.5363     0.6305 0.276 0.000 0.724
#> GSM247663     1  0.0424     0.9453 0.992 0.000 0.008
#> GSM247856     1  0.2356     0.8954 0.928 0.000 0.072
#> GSM247857     1  0.5363     0.6175 0.724 0.000 0.276
#> GSM247859     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247860     1  0.2959     0.8680 0.900 0.000 0.100
#> GSM247862     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247864     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247865     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247866     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247876     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247877     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247878     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247879     1  0.0424     0.9453 0.992 0.000 0.008
#> GSM247881     1  0.0000     0.9497 1.000 0.000 0.000
#> GSM247883     1  0.0000     0.9497 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
#> GSM246087     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0336      0.991 0.000 0.000 0.992 0.008
#> GSM246090     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000      0.999 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0336      0.905 0.008 0.000 0.000 0.992
#> GSM246423     4  0.0336      0.905 0.008 0.000 0.000 0.992
#> GSM246484     4  0.0336      0.905 0.008 0.000 0.000 0.992
#> GSM246485     2  0.2408      0.859 0.000 0.896 0.000 0.104
#> GSM246486     2  0.4855      0.361 0.000 0.600 0.000 0.400
#> GSM246487     4  0.5395      0.724 0.092 0.172 0.000 0.736
#> GSM246488     4  0.1576      0.878 0.004 0.048 0.000 0.948
#> GSM246489     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0592      0.938 0.000 0.984 0.000 0.016
#> GSM247166     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247189     2  0.4661      0.490 0.000 0.652 0.000 0.348
#> GSM247190     2  0.0000      0.950 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0469      0.932 0.988 0.000 0.012 0.000
#> GSM247651     1  0.4072      0.675 0.748 0.000 0.000 0.252
#> GSM247652     1  0.0188      0.932 0.996 0.000 0.004 0.000
#> GSM247653     1  0.0672      0.931 0.984 0.000 0.008 0.008
#> GSM247654     1  0.0469      0.931 0.988 0.000 0.012 0.000
#> GSM247655     1  0.0707      0.927 0.980 0.000 0.000 0.020
#> GSM247656     1  0.3764      0.735 0.784 0.000 0.216 0.000
#> GSM247657     1  0.0592      0.930 0.984 0.000 0.016 0.000
#> GSM247658     1  0.0188      0.932 0.996 0.000 0.000 0.004
#> GSM247659     1  0.5143      0.212 0.540 0.000 0.456 0.004
#> GSM247660     1  0.2408      0.862 0.896 0.000 0.000 0.104
#> GSM247661     1  0.0672      0.931 0.984 0.000 0.008 0.008
#> GSM247662     1  0.1302      0.915 0.956 0.000 0.044 0.000
#> GSM247663     1  0.1042      0.927 0.972 0.000 0.008 0.020
#> GSM247856     1  0.0188      0.932 0.996 0.000 0.004 0.000
#> GSM247857     1  0.0336      0.932 0.992 0.000 0.008 0.000
#> GSM247859     1  0.0592      0.929 0.984 0.000 0.000 0.016
#> GSM247860     1  0.0524      0.932 0.988 0.000 0.004 0.008
#> GSM247862     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM247864     1  0.0592      0.929 0.984 0.000 0.000 0.016
#> GSM247865     1  0.1022      0.921 0.968 0.000 0.000 0.032
#> GSM247866     1  0.0336      0.932 0.992 0.000 0.000 0.008
#> GSM247876     1  0.3975      0.691 0.760 0.000 0.000 0.240
#> GSM247877     4  0.0188      0.902 0.004 0.000 0.000 0.996
#> GSM247878     4  0.0817      0.900 0.024 0.000 0.000 0.976
#> GSM247879     4  0.4228      0.675 0.232 0.000 0.008 0.760
#> GSM247881     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM247883     1  0.0592      0.929 0.984 0.000 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM246087     3  0.0510      0.915 0.000 0.000 0.984 0.000 0.016
#> GSM246088     3  0.0404      0.916 0.000 0.000 0.988 0.000 0.012
#> GSM246089     3  0.4291      0.289 0.000 0.000 0.536 0.000 0.464
#> GSM246090     3  0.0000      0.918 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0703      0.917 0.000 0.000 0.976 0.000 0.024
#> GSM246120     3  0.0510      0.918 0.000 0.000 0.984 0.000 0.016
#> GSM246121     3  0.1341      0.904 0.000 0.000 0.944 0.000 0.056
#> GSM246122     3  0.0609      0.913 0.000 0.000 0.980 0.000 0.020
#> GSM246123     3  0.1410      0.902 0.000 0.000 0.940 0.000 0.060
#> GSM246422     4  0.0162      0.885 0.000 0.000 0.000 0.996 0.004
#> GSM246423     4  0.0000      0.884 0.000 0.000 0.000 1.000 0.000
#> GSM246484     4  0.0162      0.885 0.000 0.000 0.000 0.996 0.004
#> GSM246485     2  0.3063      0.839 0.012 0.864 0.000 0.104 0.020
#> GSM246486     2  0.3928      0.593 0.000 0.700 0.000 0.296 0.004
#> GSM246487     4  0.4454      0.705 0.092 0.108 0.000 0.784 0.016
#> GSM246488     4  0.1571      0.846 0.000 0.060 0.000 0.936 0.004
#> GSM246489     2  0.0000      0.954 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0162      0.954 0.000 0.996 0.000 0.000 0.004
#> GSM246491     2  0.0000      0.954 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0290      0.954 0.000 0.992 0.000 0.000 0.008
#> GSM247163     2  0.0000      0.954 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0566      0.952 0.000 0.984 0.000 0.004 0.012
#> GSM247165     2  0.0162      0.953 0.000 0.996 0.000 0.004 0.000
#> GSM247166     2  0.0000      0.954 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.954 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0162      0.954 0.000 0.996 0.000 0.000 0.004
#> GSM247171     2  0.0404      0.953 0.000 0.988 0.000 0.000 0.012
#> GSM247173     2  0.0162      0.954 0.000 0.996 0.000 0.000 0.004
#> GSM247174     2  0.0290      0.954 0.000 0.992 0.000 0.000 0.008
#> GSM247175     2  0.0162      0.954 0.000 0.996 0.000 0.000 0.004
#> GSM247188     2  0.0404      0.953 0.000 0.988 0.000 0.000 0.012
#> GSM247189     2  0.4622      0.591 0.000 0.692 0.000 0.264 0.044
#> GSM247190     2  0.0404      0.953 0.000 0.988 0.000 0.000 0.012
#> GSM247650     1  0.1300      0.859 0.956 0.000 0.016 0.000 0.028
#> GSM247651     1  0.4651      0.379 0.608 0.000 0.000 0.372 0.020
#> GSM247652     1  0.0609      0.856 0.980 0.000 0.000 0.000 0.020
#> GSM247653     1  0.2852      0.750 0.828 0.000 0.000 0.000 0.172
#> GSM247654     1  0.0671      0.858 0.980 0.000 0.004 0.000 0.016
#> GSM247655     1  0.0693      0.860 0.980 0.000 0.000 0.008 0.012
#> GSM247656     1  0.4804      0.413 0.636 0.000 0.328 0.000 0.036
#> GSM247657     1  0.0955      0.856 0.968 0.000 0.004 0.000 0.028
#> GSM247658     1  0.0880      0.858 0.968 0.000 0.000 0.000 0.032
#> GSM247659     1  0.6176      0.219 0.540 0.000 0.172 0.000 0.288
#> GSM247660     1  0.2900      0.797 0.864 0.000 0.000 0.108 0.028
#> GSM247661     1  0.1965      0.824 0.904 0.000 0.000 0.000 0.096
#> GSM247662     1  0.3437      0.750 0.832 0.000 0.120 0.000 0.048
#> GSM247663     1  0.1626      0.855 0.940 0.000 0.000 0.016 0.044
#> GSM247856     1  0.0771      0.856 0.976 0.000 0.000 0.004 0.020
#> GSM247857     1  0.1282      0.854 0.952 0.000 0.004 0.000 0.044
#> GSM247859     1  0.0898      0.855 0.972 0.000 0.000 0.008 0.020
#> GSM247860     5  0.4256      0.155 0.436 0.000 0.000 0.000 0.564
#> GSM247862     1  0.1197      0.852 0.952 0.000 0.000 0.000 0.048
#> GSM247864     1  0.1364      0.855 0.952 0.000 0.000 0.012 0.036
#> GSM247865     1  0.2293      0.819 0.900 0.000 0.000 0.084 0.016
#> GSM247866     1  0.4219      0.233 0.584 0.000 0.000 0.000 0.416
#> GSM247876     5  0.3351      0.634 0.148 0.000 0.004 0.020 0.828
#> GSM247877     5  0.3756      0.409 0.000 0.000 0.008 0.248 0.744
#> GSM247878     4  0.3081      0.747 0.012 0.000 0.000 0.832 0.156
#> GSM247879     5  0.2151      0.589 0.016 0.000 0.020 0.040 0.924
#> GSM247881     1  0.0963      0.855 0.964 0.000 0.000 0.000 0.036
#> GSM247883     1  0.0566      0.858 0.984 0.000 0.000 0.004 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0632     0.7827 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM246088     3  0.0458     0.7877 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM246089     3  0.6217     0.0499 0.000 0.000 0.384 0.004 0.316 0.296
#> GSM246090     3  0.0260     0.7886 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM246119     3  0.1461     0.7842 0.000 0.000 0.940 0.000 0.016 0.044
#> GSM246120     3  0.0909     0.7901 0.000 0.000 0.968 0.000 0.012 0.020
#> GSM246121     3  0.2527     0.7443 0.000 0.000 0.868 0.000 0.024 0.108
#> GSM246122     3  0.1219     0.7676 0.000 0.000 0.948 0.000 0.004 0.048
#> GSM246123     3  0.1408     0.7864 0.000 0.000 0.944 0.000 0.020 0.036
#> GSM246422     4  0.0146     0.8114 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM246423     4  0.0508     0.8098 0.000 0.000 0.000 0.984 0.012 0.004
#> GSM246484     4  0.0405     0.8118 0.000 0.000 0.000 0.988 0.008 0.004
#> GSM246485     2  0.6160     0.0436 0.008 0.428 0.000 0.340 0.000 0.224
#> GSM246486     2  0.4263     0.0831 0.000 0.504 0.000 0.480 0.000 0.016
#> GSM246487     4  0.5361     0.5547 0.128 0.144 0.000 0.676 0.000 0.052
#> GSM246488     4  0.1461     0.7851 0.000 0.044 0.000 0.940 0.000 0.016
#> GSM246489     2  0.0622     0.8756 0.000 0.980 0.000 0.008 0.000 0.012
#> GSM246490     2  0.0692     0.8742 0.000 0.976 0.000 0.000 0.004 0.020
#> GSM246491     2  0.0458     0.8757 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM247162     2  0.0653     0.8747 0.000 0.980 0.000 0.012 0.004 0.004
#> GSM247163     2  0.0909     0.8749 0.000 0.968 0.000 0.012 0.000 0.020
#> GSM247164     2  0.0964     0.8726 0.000 0.968 0.000 0.016 0.004 0.012
#> GSM247165     2  0.1003     0.8718 0.000 0.964 0.000 0.016 0.000 0.020
#> GSM247166     2  0.2048     0.8301 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM247168     2  0.2048     0.8301 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM247169     2  0.2053     0.8330 0.000 0.888 0.000 0.000 0.004 0.108
#> GSM247171     2  0.1269     0.8692 0.000 0.956 0.000 0.012 0.020 0.012
#> GSM247173     2  0.0508     0.8762 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM247174     2  0.1082     0.8659 0.000 0.956 0.000 0.000 0.004 0.040
#> GSM247175     2  0.0260     0.8761 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247188     2  0.0725     0.8739 0.000 0.976 0.000 0.000 0.012 0.012
#> GSM247189     2  0.5978    -0.0877 0.000 0.432 0.000 0.428 0.112 0.028
#> GSM247190     2  0.0622     0.8738 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM247650     1  0.4153     0.5372 0.792 0.000 0.100 0.004 0.048 0.056
#> GSM247651     1  0.3972     0.3746 0.664 0.000 0.000 0.320 0.012 0.004
#> GSM247652     1  0.1219     0.6389 0.948 0.000 0.000 0.000 0.004 0.048
#> GSM247653     1  0.5658     0.2398 0.432 0.000 0.000 0.000 0.152 0.416
#> GSM247654     1  0.3534     0.5958 0.740 0.000 0.000 0.000 0.016 0.244
#> GSM247655     1  0.2902     0.6095 0.800 0.000 0.000 0.004 0.000 0.196
#> GSM247656     3  0.5635    -0.3245 0.408 0.000 0.468 0.000 0.008 0.116
#> GSM247657     1  0.3923     0.4753 0.580 0.000 0.004 0.000 0.000 0.416
#> GSM247658     1  0.2163     0.6333 0.892 0.000 0.000 0.000 0.016 0.092
#> GSM247659     6  0.7497     0.4686 0.148 0.004 0.180 0.000 0.304 0.364
#> GSM247660     1  0.5726     0.4630 0.580 0.000 0.000 0.224 0.016 0.180
#> GSM247661     1  0.5132     0.4000 0.500 0.000 0.000 0.000 0.084 0.416
#> GSM247662     6  0.6664     0.5499 0.236 0.000 0.336 0.000 0.036 0.392
#> GSM247663     1  0.1341     0.6360 0.948 0.000 0.000 0.000 0.028 0.024
#> GSM247856     1  0.0862     0.6323 0.972 0.000 0.016 0.000 0.008 0.004
#> GSM247857     1  0.5473     0.2500 0.520 0.000 0.052 0.000 0.036 0.392
#> GSM247859     1  0.1889     0.6350 0.920 0.000 0.000 0.020 0.004 0.056
#> GSM247860     5  0.6099    -0.0261 0.300 0.000 0.000 0.000 0.384 0.316
#> GSM247862     1  0.4252     0.5475 0.652 0.000 0.000 0.000 0.036 0.312
#> GSM247864     1  0.4306     0.5573 0.700 0.000 0.000 0.008 0.044 0.248
#> GSM247865     1  0.3598     0.5264 0.804 0.000 0.000 0.112 0.004 0.080
#> GSM247866     1  0.5575     0.2061 0.460 0.000 0.000 0.000 0.400 0.140
#> GSM247876     5  0.3339     0.4528 0.188 0.000 0.004 0.008 0.792 0.008
#> GSM247877     5  0.3133     0.4612 0.000 0.000 0.008 0.180 0.804 0.008
#> GSM247878     4  0.4771     0.3612 0.056 0.000 0.000 0.628 0.308 0.008
#> GSM247879     5  0.1639     0.5341 0.020 0.004 0.004 0.008 0.944 0.020
#> GSM247881     1  0.5005     0.4443 0.628 0.000 0.000 0.000 0.124 0.248
#> GSM247883     1  0.1624     0.6173 0.936 0.004 0.000 0.000 0.020 0.040

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) k
#> CV:NMF 56         1.75e-09 2
#> CV:NMF 59         3.53e-15 3
#> CV:NMF 58         8.53e-21 4
#> CV:NMF 54         6.25e-19 5
#> CV:NMF 43         3.31e-14 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 21168 rows and 61 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.432           0.579       0.718         0.3381 0.531   0.531
#> 3 3 0.915           0.913       0.965         0.7230 0.702   0.526
#> 4 4 0.918           0.883       0.944         0.2066 0.850   0.650
#> 5 5 0.927           0.910       0.954         0.0306 0.987   0.953
#> 6 6 0.865           0.867       0.926         0.0282 0.996   0.984

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] 3

There is also optional best \(k\) = 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
#> GSM246087     1  0.1633     0.3361 0.976 0.024
#> GSM246088     1  0.1633     0.3361 0.976 0.024
#> GSM246089     1  0.1633     0.3361 0.976 0.024
#> GSM246090     1  0.1633     0.3361 0.976 0.024
#> GSM246119     1  0.1633     0.3361 0.976 0.024
#> GSM246120     1  0.1633     0.3361 0.976 0.024
#> GSM246121     1  0.1633     0.3361 0.976 0.024
#> GSM246122     1  0.1633     0.3361 0.976 0.024
#> GSM246123     1  0.1633     0.3361 0.976 0.024
#> GSM246422     1  0.9993     0.6938 0.516 0.484
#> GSM246423     1  0.9993     0.6938 0.516 0.484
#> GSM246484     1  0.9993     0.6938 0.516 0.484
#> GSM246485     2  0.9170     0.0331 0.332 0.668
#> GSM246486     2  0.9552    -0.1875 0.376 0.624
#> GSM246487     2  0.9552    -0.1875 0.376 0.624
#> GSM246488     2  0.9323    -0.0429 0.348 0.652
#> GSM246489     2  0.0000     0.7864 0.000 1.000
#> GSM246490     2  0.0672     0.7832 0.008 0.992
#> GSM246491     2  0.0672     0.7832 0.008 0.992
#> GSM247162     2  0.0000     0.7864 0.000 1.000
#> GSM247163     2  0.0672     0.7832 0.008 0.992
#> GSM247164     2  0.0672     0.7832 0.008 0.992
#> GSM247165     2  0.6048     0.5817 0.148 0.852
#> GSM247166     2  0.0000     0.7864 0.000 1.000
#> GSM247168     2  0.0000     0.7864 0.000 1.000
#> GSM247169     2  0.0000     0.7864 0.000 1.000
#> GSM247171     2  0.0000     0.7864 0.000 1.000
#> GSM247173     2  0.0000     0.7864 0.000 1.000
#> GSM247174     2  0.0000     0.7864 0.000 1.000
#> GSM247175     2  0.0000     0.7864 0.000 1.000
#> GSM247188     2  0.0000     0.7864 0.000 1.000
#> GSM247189     2  0.9209     0.0134 0.336 0.664
#> GSM247190     2  0.0000     0.7864 0.000 1.000
#> GSM247650     1  0.9993     0.6938 0.516 0.484
#> GSM247651     1  0.9993     0.6938 0.516 0.484
#> GSM247652     1  0.9993     0.6938 0.516 0.484
#> GSM247653     1  0.9993     0.6938 0.516 0.484
#> GSM247654     1  0.9993     0.6938 0.516 0.484
#> GSM247655     1  0.9993     0.6938 0.516 0.484
#> GSM247656     1  0.9993     0.6938 0.516 0.484
#> GSM247657     1  0.9993     0.6938 0.516 0.484
#> GSM247658     1  0.9993     0.6938 0.516 0.484
#> GSM247659     1  0.9993     0.6938 0.516 0.484
#> GSM247660     1  0.9993     0.6938 0.516 0.484
#> GSM247661     1  0.9993     0.6938 0.516 0.484
#> GSM247662     1  0.9993     0.6938 0.516 0.484
#> GSM247663     1  0.9993     0.6938 0.516 0.484
#> GSM247856     1  0.9993     0.6938 0.516 0.484
#> GSM247857     1  0.9993     0.6938 0.516 0.484
#> GSM247859     1  0.9993     0.6938 0.516 0.484
#> GSM247860     1  0.9993     0.6938 0.516 0.484
#> GSM247862     1  0.9993     0.6938 0.516 0.484
#> GSM247864     1  0.9993     0.6938 0.516 0.484
#> GSM247865     2  0.9933    -0.5178 0.452 0.548
#> GSM247866     1  0.9993     0.6938 0.516 0.484
#> GSM247876     1  0.9993     0.6938 0.516 0.484
#> GSM247877     1  0.9993     0.6938 0.516 0.484
#> GSM247878     1  0.9993     0.6938 0.516 0.484
#> GSM247879     1  0.9993     0.6938 0.516 0.484
#> GSM247881     1  0.9993     0.6938 0.516 0.484
#> GSM247883     1  0.9993     0.6938 0.516 0.484

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM246087     3  0.0000      1.000 0.000 0.000  1
#> GSM246088     3  0.0000      1.000 0.000 0.000  1
#> GSM246089     3  0.0000      1.000 0.000 0.000  1
#> GSM246090     3  0.0000      1.000 0.000 0.000  1
#> GSM246119     3  0.0000      1.000 0.000 0.000  1
#> GSM246120     3  0.0000      1.000 0.000 0.000  1
#> GSM246121     3  0.0000      1.000 0.000 0.000  1
#> GSM246122     3  0.0000      1.000 0.000 0.000  1
#> GSM246123     3  0.0000      1.000 0.000 0.000  1
#> GSM246422     1  0.0000      0.942 1.000 0.000  0
#> GSM246423     1  0.0000      0.942 1.000 0.000  0
#> GSM246484     1  0.0000      0.942 1.000 0.000  0
#> GSM246485     1  0.6111      0.400 0.604 0.396  0
#> GSM246486     1  0.5650      0.574 0.688 0.312  0
#> GSM246487     1  0.5650      0.574 0.688 0.312  0
#> GSM246488     1  0.5988      0.464 0.632 0.368  0
#> GSM246489     2  0.0000      0.971 0.000 1.000  0
#> GSM246490     2  0.0424      0.966 0.008 0.992  0
#> GSM246491     2  0.0424      0.966 0.008 0.992  0
#> GSM247162     2  0.0000      0.971 0.000 1.000  0
#> GSM247163     2  0.0424      0.966 0.008 0.992  0
#> GSM247164     2  0.0424      0.966 0.008 0.992  0
#> GSM247165     2  0.5327      0.582 0.272 0.728  0
#> GSM247166     2  0.0000      0.971 0.000 1.000  0
#> GSM247168     2  0.0000      0.971 0.000 1.000  0
#> GSM247169     2  0.0000      0.971 0.000 1.000  0
#> GSM247171     2  0.0000      0.971 0.000 1.000  0
#> GSM247173     2  0.0000      0.971 0.000 1.000  0
#> GSM247174     2  0.0000      0.971 0.000 1.000  0
#> GSM247175     2  0.0000      0.971 0.000 1.000  0
#> GSM247188     2  0.0000      0.971 0.000 1.000  0
#> GSM247189     1  0.6095      0.410 0.608 0.392  0
#> GSM247190     2  0.0000      0.971 0.000 1.000  0
#> GSM247650     1  0.0000      0.942 1.000 0.000  0
#> GSM247651     1  0.0000      0.942 1.000 0.000  0
#> GSM247652     1  0.0000      0.942 1.000 0.000  0
#> GSM247653     1  0.0000      0.942 1.000 0.000  0
#> GSM247654     1  0.0000      0.942 1.000 0.000  0
#> GSM247655     1  0.0000      0.942 1.000 0.000  0
#> GSM247656     1  0.0000      0.942 1.000 0.000  0
#> GSM247657     1  0.0000      0.942 1.000 0.000  0
#> GSM247658     1  0.0000      0.942 1.000 0.000  0
#> GSM247659     1  0.0000      0.942 1.000 0.000  0
#> GSM247660     1  0.0000      0.942 1.000 0.000  0
#> GSM247661     1  0.0000      0.942 1.000 0.000  0
#> GSM247662     1  0.0000      0.942 1.000 0.000  0
#> GSM247663     1  0.0000      0.942 1.000 0.000  0
#> GSM247856     1  0.0000      0.942 1.000 0.000  0
#> GSM247857     1  0.0000      0.942 1.000 0.000  0
#> GSM247859     1  0.0000      0.942 1.000 0.000  0
#> GSM247860     1  0.0000      0.942 1.000 0.000  0
#> GSM247862     1  0.0000      0.942 1.000 0.000  0
#> GSM247864     1  0.0000      0.942 1.000 0.000  0
#> GSM247865     1  0.2165      0.889 0.936 0.064  0
#> GSM247866     1  0.0000      0.942 1.000 0.000  0
#> GSM247876     1  0.0000      0.942 1.000 0.000  0
#> GSM247877     1  0.0000      0.942 1.000 0.000  0
#> GSM247878     1  0.0000      0.942 1.000 0.000  0
#> GSM247879     1  0.0000      0.942 1.000 0.000  0
#> GSM247881     1  0.0000      0.942 1.000 0.000  0
#> GSM247883     1  0.0000      0.942 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM246422     4  0.0000      0.628 0.000 0.000  0 1.000
#> GSM246423     4  0.0000      0.628 0.000 0.000  0 1.000
#> GSM246484     4  0.0000      0.628 0.000 0.000  0 1.000
#> GSM246485     4  0.4843      0.480 0.000 0.396  0 0.604
#> GSM246486     4  0.4477      0.582 0.000 0.312  0 0.688
#> GSM246487     4  0.4477      0.582 0.000 0.312  0 0.688
#> GSM246488     4  0.4746      0.523 0.000 0.368  0 0.632
#> GSM246489     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM246490     2  0.0336      0.970 0.000 0.992  0 0.008
#> GSM246491     2  0.0336      0.970 0.000 0.992  0 0.008
#> GSM247162     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247163     2  0.0336      0.970 0.000 0.992  0 0.008
#> GSM247164     2  0.0336      0.970 0.000 0.992  0 0.008
#> GSM247165     2  0.4222      0.502 0.000 0.728  0 0.272
#> GSM247166     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247168     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247169     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247171     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247173     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247174     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247175     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247188     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247189     4  0.4830      0.487 0.000 0.392  0 0.608
#> GSM247190     2  0.0000      0.974 0.000 1.000  0 0.000
#> GSM247650     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247651     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247652     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247653     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247654     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247655     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247656     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247657     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247658     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247659     1  0.0469      0.977 0.988 0.000  0 0.012
#> GSM247660     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247661     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247662     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247663     1  0.0188      0.984 0.996 0.000  0 0.004
#> GSM247856     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247857     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247859     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247860     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247862     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247864     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247865     1  0.4514      0.720 0.800 0.064  0 0.136
#> GSM247866     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247876     1  0.1389      0.936 0.952 0.000  0 0.048
#> GSM247877     4  0.4998      0.133 0.488 0.000  0 0.512
#> GSM247878     4  0.2281      0.601 0.096 0.000  0 0.904
#> GSM247879     4  0.4998      0.133 0.488 0.000  0 0.512
#> GSM247881     1  0.0000      0.987 1.000 0.000  0 0.000
#> GSM247883     1  0.0000      0.987 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.0000      0.484 0.000 0.000  0 1.000 0.000
#> GSM246423     4  0.0000      0.484 0.000 0.000  0 1.000 0.000
#> GSM246484     4  0.0000      0.484 0.000 0.000  0 1.000 0.000
#> GSM246485     4  0.4171      0.658 0.000 0.396  0 0.604 0.000
#> GSM246486     4  0.3857      0.725 0.000 0.312  0 0.688 0.000
#> GSM246487     4  0.3857      0.725 0.000 0.312  0 0.688 0.000
#> GSM246488     4  0.4088      0.695 0.000 0.368  0 0.632 0.000
#> GSM246489     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0290      0.967 0.000 0.992  0 0.008 0.000
#> GSM246491     2  0.0290      0.967 0.000 0.992  0 0.008 0.000
#> GSM247162     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.0290      0.967 0.000 0.992  0 0.008 0.000
#> GSM247164     2  0.0290      0.967 0.000 0.992  0 0.008 0.000
#> GSM247165     2  0.3636      0.433 0.000 0.728  0 0.272 0.000
#> GSM247166     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247168     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247171     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247175     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247189     4  0.4161      0.665 0.000 0.392  0 0.608 0.000
#> GSM247190     2  0.0000      0.972 0.000 1.000  0 0.000 0.000
#> GSM247650     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247651     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247652     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247653     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247654     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247655     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247656     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247657     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247658     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247659     1  0.0451      0.978 0.988 0.000  0 0.004 0.008
#> GSM247660     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247661     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247662     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247663     1  0.0162      0.985 0.996 0.000  0 0.000 0.004
#> GSM247856     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247857     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247859     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247860     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247862     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247864     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247865     1  0.3888      0.737 0.800 0.064  0 0.136 0.000
#> GSM247866     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247876     1  0.1341      0.935 0.944 0.000  0 0.000 0.056
#> GSM247877     5  0.0000      0.820 0.000 0.000  0 0.000 1.000
#> GSM247878     5  0.4249      0.551 0.000 0.000  0 0.432 0.568
#> GSM247879     5  0.0000      0.820 0.000 0.000  0 0.000 1.000
#> GSM247881     1  0.0000      0.988 1.000 0.000  0 0.000 0.000
#> GSM247883     1  0.0000      0.988 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     6  0.3482      0.000 0.000 0.000 0.316 0.000 0.000 0.684
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.1863      0.531 0.000 0.000 0.000 0.896 0.000 0.104
#> GSM246423     4  0.1863      0.531 0.000 0.000 0.000 0.896 0.000 0.104
#> GSM246484     4  0.1863      0.531 0.000 0.000 0.000 0.896 0.000 0.104
#> GSM246485     4  0.3784      0.710 0.000 0.308 0.000 0.680 0.000 0.012
#> GSM246486     4  0.3023      0.740 0.000 0.232 0.000 0.768 0.000 0.000
#> GSM246487     4  0.3023      0.740 0.000 0.232 0.000 0.768 0.000 0.000
#> GSM246488     4  0.3575      0.728 0.000 0.284 0.000 0.708 0.000 0.008
#> GSM246489     2  0.0146      0.955 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM246490     2  0.0972      0.937 0.000 0.964 0.000 0.028 0.000 0.008
#> GSM246491     2  0.0972      0.937 0.000 0.964 0.000 0.028 0.000 0.008
#> GSM247162     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0972      0.937 0.000 0.964 0.000 0.028 0.000 0.008
#> GSM247164     2  0.0972      0.937 0.000 0.964 0.000 0.028 0.000 0.008
#> GSM247165     2  0.3927      0.283 0.000 0.644 0.000 0.344 0.000 0.012
#> GSM247166     2  0.0260      0.954 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247168     2  0.0260      0.954 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247169     2  0.0260      0.954 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247171     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0260      0.954 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247175     2  0.0146      0.955 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM247188     2  0.0260      0.954 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247189     4  0.3766      0.714 0.000 0.304 0.000 0.684 0.000 0.012
#> GSM247190     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.0146      0.948 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247651     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247652     1  0.0713      0.947 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM247653     1  0.1556      0.933 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247654     1  0.1501      0.935 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM247655     1  0.0146      0.948 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247656     1  0.1556      0.942 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247657     1  0.1556      0.932 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247658     1  0.0713      0.947 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM247659     1  0.2003      0.919 0.884 0.000 0.000 0.000 0.000 0.116
#> GSM247660     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247661     1  0.1910      0.922 0.892 0.000 0.000 0.000 0.000 0.108
#> GSM247662     1  0.1556      0.932 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247663     1  0.1556      0.925 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247856     1  0.0713      0.947 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM247857     1  0.1556      0.932 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM247859     1  0.0363      0.948 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM247860     1  0.1910      0.922 0.892 0.000 0.000 0.000 0.000 0.108
#> GSM247862     1  0.0713      0.949 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM247864     1  0.0146      0.948 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247865     1  0.3315      0.735 0.780 0.000 0.000 0.200 0.000 0.020
#> GSM247866     1  0.1863      0.924 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM247876     1  0.2660      0.888 0.868 0.000 0.000 0.000 0.048 0.084
#> GSM247877     5  0.0000      0.731 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM247878     5  0.5147      0.464 0.000 0.000 0.000 0.328 0.568 0.104
#> GSM247879     5  0.0260      0.729 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM247881     1  0.0547      0.946 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM247883     1  0.0458      0.947 0.984 0.000 0.000 0.000 0.000 0.016

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:hclust 46         2.27e-08 2
#> MAD:hclust 58         8.94e-20 3
#> MAD:hclust 57         2.14e-21 4
#> MAD:hclust 57         5.72e-21 5
#> MAD:hclust 58         2.22e-21 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 21168 rows and 61 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 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-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.495           0.920       0.898         0.4427 0.515   0.515
#> 3 3 0.780           0.915       0.944         0.3854 0.757   0.579
#> 4 4 0.986           0.967       0.967         0.1480 0.867   0.673
#> 5 5 0.805           0.871       0.888         0.0705 1.000   1.000
#> 6 6 0.776           0.661       0.822         0.0456 0.940   0.794

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     1   0.311      0.787 0.944 0.056
#> GSM246088     1   0.311      0.787 0.944 0.056
#> GSM246089     1   0.311      0.787 0.944 0.056
#> GSM246090     1   0.311      0.787 0.944 0.056
#> GSM246119     1   0.311      0.787 0.944 0.056
#> GSM246120     1   0.311      0.787 0.944 0.056
#> GSM246121     1   0.311      0.787 0.944 0.056
#> GSM246122     1   0.311      0.787 0.944 0.056
#> GSM246123     1   0.311      0.787 0.944 0.056
#> GSM246422     2   0.456      0.905 0.096 0.904
#> GSM246423     2   0.456      0.905 0.096 0.904
#> GSM246484     2   0.456      0.905 0.096 0.904
#> GSM246485     2   0.327      0.934 0.060 0.940
#> GSM246486     2   0.295      0.939 0.052 0.948
#> GSM246487     2   0.443      0.909 0.092 0.908
#> GSM246488     2   0.295      0.939 0.052 0.948
#> GSM246489     2   0.000      0.972 0.000 1.000
#> GSM246490     2   0.000      0.972 0.000 1.000
#> GSM246491     2   0.000      0.972 0.000 1.000
#> GSM247162     2   0.000      0.972 0.000 1.000
#> GSM247163     2   0.000      0.972 0.000 1.000
#> GSM247164     2   0.000      0.972 0.000 1.000
#> GSM247165     2   0.000      0.972 0.000 1.000
#> GSM247166     2   0.000      0.972 0.000 1.000
#> GSM247168     2   0.000      0.972 0.000 1.000
#> GSM247169     2   0.000      0.972 0.000 1.000
#> GSM247171     2   0.000      0.972 0.000 1.000
#> GSM247173     2   0.000      0.972 0.000 1.000
#> GSM247174     2   0.000      0.972 0.000 1.000
#> GSM247175     2   0.000      0.972 0.000 1.000
#> GSM247188     2   0.000      0.972 0.000 1.000
#> GSM247189     2   0.000      0.972 0.000 1.000
#> GSM247190     2   0.000      0.972 0.000 1.000
#> GSM247650     1   0.689      0.931 0.816 0.184
#> GSM247651     1   0.689      0.931 0.816 0.184
#> GSM247652     1   0.689      0.931 0.816 0.184
#> GSM247653     1   0.689      0.931 0.816 0.184
#> GSM247654     1   0.689      0.931 0.816 0.184
#> GSM247655     1   0.689      0.931 0.816 0.184
#> GSM247656     1   0.689      0.931 0.816 0.184
#> GSM247657     1   0.689      0.931 0.816 0.184
#> GSM247658     1   0.689      0.931 0.816 0.184
#> GSM247659     1   0.689      0.931 0.816 0.184
#> GSM247660     1   0.689      0.931 0.816 0.184
#> GSM247661     1   0.689      0.931 0.816 0.184
#> GSM247662     1   0.689      0.931 0.816 0.184
#> GSM247663     1   0.689      0.931 0.816 0.184
#> GSM247856     1   0.689      0.931 0.816 0.184
#> GSM247857     1   0.689      0.931 0.816 0.184
#> GSM247859     1   0.689      0.931 0.816 0.184
#> GSM247860     1   0.689      0.931 0.816 0.184
#> GSM247862     1   0.689      0.931 0.816 0.184
#> GSM247864     1   0.689      0.931 0.816 0.184
#> GSM247865     1   0.689      0.931 0.816 0.184
#> GSM247866     1   0.689      0.931 0.816 0.184
#> GSM247876     1   0.689      0.931 0.816 0.184
#> GSM247877     1   0.689      0.931 0.816 0.184
#> GSM247878     1   0.689      0.931 0.816 0.184
#> GSM247879     1   0.689      0.931 0.816 0.184
#> GSM247881     1   0.689      0.931 0.816 0.184
#> GSM247883     1   0.689      0.931 0.816 0.184

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246422     1  0.2796      0.846 0.908 0.092 0.000
#> GSM246423     1  0.2796      0.846 0.908 0.092 0.000
#> GSM246484     1  0.2796      0.846 0.908 0.092 0.000
#> GSM246485     2  0.6244      0.320 0.440 0.560 0.000
#> GSM246486     2  0.3686      0.831 0.140 0.860 0.000
#> GSM246487     1  0.2625      0.849 0.916 0.084 0.000
#> GSM246488     2  0.3686      0.831 0.140 0.860 0.000
#> GSM246489     2  0.0424      0.950 0.008 0.992 0.000
#> GSM246490     2  0.0424      0.950 0.008 0.992 0.000
#> GSM246491     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247162     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247163     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247164     2  0.0000      0.943 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.943 0.000 1.000 0.000
#> GSM247166     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247168     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247169     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247171     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247173     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247174     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247175     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247188     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247189     2  0.2356      0.893 0.072 0.928 0.000
#> GSM247190     2  0.0424      0.950 0.008 0.992 0.000
#> GSM247650     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247651     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247652     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247653     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247654     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247655     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247656     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247657     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247658     1  0.2878      0.910 0.904 0.000 0.096
#> GSM247659     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247660     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247661     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247662     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247663     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247856     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247857     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247859     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247860     1  0.3686      0.902 0.860 0.000 0.140
#> GSM247862     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247876     1  0.2625      0.911 0.916 0.000 0.084
#> GSM247877     1  0.0424      0.905 0.992 0.008 0.000
#> GSM247878     1  0.0424      0.905 0.992 0.008 0.000
#> GSM247879     1  0.3116      0.908 0.892 0.000 0.108
#> GSM247881     1  0.0000      0.909 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.909 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
#> GSM246087     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246088     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246089     3  0.1833      0.979 0.024 0.000 0.944 0.032
#> GSM246090     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246119     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246120     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246121     3  0.0817      0.985 0.024 0.000 0.976 0.000
#> GSM246122     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246123     3  0.1520      0.984 0.024 0.000 0.956 0.020
#> GSM246422     4  0.2142      0.918 0.056 0.016 0.000 0.928
#> GSM246423     4  0.2142      0.918 0.056 0.016 0.000 0.928
#> GSM246484     4  0.2142      0.918 0.056 0.016 0.000 0.928
#> GSM246485     4  0.3286      0.903 0.044 0.080 0.000 0.876
#> GSM246486     4  0.2530      0.881 0.004 0.100 0.000 0.896
#> GSM246487     4  0.2730      0.905 0.088 0.016 0.000 0.896
#> GSM246488     4  0.1978      0.892 0.004 0.068 0.000 0.928
#> GSM246489     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247166     2  0.1520      0.969 0.000 0.956 0.024 0.020
#> GSM247168     2  0.1520      0.969 0.000 0.956 0.024 0.020
#> GSM247169     2  0.1520      0.969 0.000 0.956 0.024 0.020
#> GSM247171     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247174     2  0.1297      0.973 0.000 0.964 0.016 0.020
#> GSM247175     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247189     4  0.2973      0.841 0.000 0.144 0.000 0.856
#> GSM247190     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247651     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247652     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247653     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247654     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247655     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247656     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247657     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247658     1  0.0188      0.983 0.996 0.000 0.000 0.004
#> GSM247659     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247660     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247661     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247662     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247663     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247856     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247857     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247859     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247860     1  0.0188      0.983 0.996 0.000 0.004 0.000
#> GSM247862     1  0.0817      0.978 0.976 0.000 0.000 0.024
#> GSM247864     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247865     1  0.1022      0.975 0.968 0.000 0.000 0.032
#> GSM247866     1  0.0817      0.978 0.976 0.000 0.000 0.024
#> GSM247876     1  0.0469      0.981 0.988 0.000 0.000 0.012
#> GSM247877     4  0.3074      0.846 0.152 0.000 0.000 0.848
#> GSM247878     4  0.2973      0.852 0.144 0.000 0.000 0.856
#> GSM247879     1  0.0188      0.983 0.996 0.000 0.000 0.004
#> GSM247881     1  0.0817      0.978 0.976 0.000 0.000 0.024
#> GSM247883     1  0.1022      0.975 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
#> GSM246087     3  0.1270      0.966 0.000 0.000 0.948 0.000 0.052
#> GSM246088     3  0.1270      0.966 0.000 0.000 0.948 0.000 0.052
#> GSM246089     3  0.1768      0.939 0.000 0.000 0.924 0.004 0.072
#> GSM246090     3  0.1270      0.966 0.000 0.000 0.948 0.000 0.052
#> GSM246119     3  0.0671      0.966 0.000 0.000 0.980 0.004 0.016
#> GSM246120     3  0.0671      0.966 0.000 0.000 0.980 0.004 0.016
#> GSM246121     3  0.0000      0.968 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.1270      0.966 0.000 0.000 0.948 0.000 0.052
#> GSM246123     3  0.0671      0.966 0.000 0.000 0.980 0.004 0.016
#> GSM246422     4  0.2707      0.823 0.000 0.008 0.000 0.860 0.132
#> GSM246423     4  0.2707      0.823 0.000 0.008 0.000 0.860 0.132
#> GSM246484     4  0.2707      0.823 0.000 0.008 0.000 0.860 0.132
#> GSM246485     4  0.2956      0.803 0.020 0.096 0.000 0.872 0.012
#> GSM246486     4  0.2130      0.812 0.000 0.080 0.000 0.908 0.012
#> GSM246487     4  0.2633      0.799 0.068 0.012 0.000 0.896 0.024
#> GSM246488     4  0.0404      0.823 0.000 0.012 0.000 0.988 0.000
#> GSM246489     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0510      0.947 0.000 0.984 0.000 0.016 0.000
#> GSM247164     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM247165     2  0.1544      0.908 0.000 0.932 0.000 0.068 0.000
#> GSM247166     2  0.2966      0.860 0.000 0.816 0.000 0.000 0.184
#> GSM247168     2  0.2966      0.860 0.000 0.816 0.000 0.000 0.184
#> GSM247169     2  0.2966      0.860 0.000 0.816 0.000 0.000 0.184
#> GSM247171     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.955 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.1671      0.926 0.000 0.924 0.000 0.000 0.076
#> GSM247175     2  0.0162      0.954 0.000 0.996 0.000 0.000 0.004
#> GSM247188     2  0.0609      0.950 0.000 0.980 0.000 0.000 0.020
#> GSM247189     4  0.2561      0.777 0.000 0.144 0.000 0.856 0.000
#> GSM247190     2  0.0703      0.949 0.000 0.976 0.000 0.000 0.024
#> GSM247650     1  0.2074      0.850 0.896 0.000 0.000 0.000 0.104
#> GSM247651     1  0.2763      0.834 0.848 0.000 0.000 0.004 0.148
#> GSM247652     1  0.2471      0.857 0.864 0.000 0.000 0.000 0.136
#> GSM247653     1  0.3816      0.783 0.696 0.000 0.000 0.000 0.304
#> GSM247654     1  0.2929      0.843 0.820 0.000 0.000 0.000 0.180
#> GSM247655     1  0.2674      0.838 0.856 0.000 0.000 0.004 0.140
#> GSM247656     1  0.2561      0.856 0.856 0.000 0.000 0.000 0.144
#> GSM247657     1  0.2648      0.853 0.848 0.000 0.000 0.000 0.152
#> GSM247658     1  0.2966      0.849 0.816 0.000 0.000 0.000 0.184
#> GSM247659     1  0.2179      0.866 0.888 0.000 0.000 0.000 0.112
#> GSM247660     1  0.2763      0.834 0.848 0.000 0.000 0.004 0.148
#> GSM247661     1  0.3816      0.783 0.696 0.000 0.000 0.000 0.304
#> GSM247662     1  0.1544      0.871 0.932 0.000 0.000 0.000 0.068
#> GSM247663     1  0.2648      0.855 0.848 0.000 0.000 0.000 0.152
#> GSM247856     1  0.1965      0.868 0.904 0.000 0.000 0.000 0.096
#> GSM247857     1  0.1544      0.871 0.932 0.000 0.000 0.000 0.068
#> GSM247859     1  0.1205      0.867 0.956 0.000 0.000 0.004 0.040
#> GSM247860     1  0.3816      0.783 0.696 0.000 0.000 0.000 0.304
#> GSM247862     1  0.1608      0.875 0.928 0.000 0.000 0.000 0.072
#> GSM247864     1  0.2674      0.838 0.856 0.000 0.000 0.004 0.140
#> GSM247865     1  0.1357      0.866 0.948 0.000 0.000 0.004 0.048
#> GSM247866     1  0.3752      0.786 0.708 0.000 0.000 0.000 0.292
#> GSM247876     1  0.2929      0.823 0.820 0.000 0.000 0.000 0.180
#> GSM247877     4  0.5990      0.618 0.116 0.000 0.000 0.500 0.384
#> GSM247878     4  0.5996      0.624 0.120 0.000 0.000 0.512 0.368
#> GSM247879     1  0.3612      0.747 0.732 0.000 0.000 0.000 0.268
#> GSM247881     1  0.0609      0.872 0.980 0.000 0.000 0.000 0.020
#> GSM247883     1  0.1205      0.867 0.956 0.000 0.000 0.004 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
#> GSM246087     3  0.1867     0.9366 0.000 0.000 0.916 0.000 0.020 0.064
#> GSM246088     3  0.1867     0.9366 0.000 0.000 0.916 0.000 0.020 0.064
#> GSM246089     3  0.2688     0.8932 0.000 0.000 0.868 0.000 0.068 0.064
#> GSM246090     3  0.1867     0.9366 0.000 0.000 0.916 0.000 0.020 0.064
#> GSM246119     3  0.1168     0.9350 0.000 0.000 0.956 0.000 0.028 0.016
#> GSM246120     3  0.1168     0.9350 0.000 0.000 0.956 0.000 0.028 0.016
#> GSM246121     3  0.0000     0.9396 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.1867     0.9366 0.000 0.000 0.916 0.000 0.020 0.064
#> GSM246123     3  0.1168     0.9350 0.000 0.000 0.956 0.000 0.028 0.016
#> GSM246422     4  0.3852     0.6904 0.004 0.000 0.000 0.740 0.224 0.032
#> GSM246423     4  0.3852     0.6904 0.004 0.000 0.000 0.740 0.224 0.032
#> GSM246484     4  0.3852     0.6904 0.004 0.000 0.000 0.740 0.224 0.032
#> GSM246485     4  0.2508     0.7661 0.004 0.068 0.000 0.892 0.024 0.012
#> GSM246486     4  0.1863     0.7781 0.000 0.060 0.000 0.920 0.016 0.004
#> GSM246487     4  0.2082     0.7417 0.052 0.004 0.000 0.916 0.020 0.008
#> GSM246488     4  0.0603     0.7809 0.000 0.016 0.000 0.980 0.004 0.000
#> GSM246489     2  0.0551     0.9027 0.000 0.984 0.000 0.008 0.004 0.004
#> GSM246490     2  0.1511     0.8962 0.000 0.944 0.000 0.012 0.032 0.012
#> GSM246491     2  0.1605     0.8951 0.000 0.940 0.000 0.012 0.032 0.016
#> GSM247162     2  0.0260     0.9019 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM247163     2  0.2024     0.8863 0.000 0.920 0.000 0.028 0.036 0.016
#> GSM247164     2  0.1773     0.8922 0.000 0.932 0.000 0.016 0.036 0.016
#> GSM247165     2  0.2507     0.8681 0.000 0.892 0.000 0.056 0.036 0.016
#> GSM247166     2  0.4771     0.7041 0.000 0.652 0.000 0.000 0.100 0.248
#> GSM247168     2  0.4771     0.7041 0.000 0.652 0.000 0.000 0.100 0.248
#> GSM247169     2  0.4729     0.7040 0.000 0.656 0.000 0.000 0.096 0.248
#> GSM247171     2  0.0551     0.9015 0.000 0.984 0.000 0.008 0.004 0.004
#> GSM247173     2  0.0000     0.9021 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.2822     0.8405 0.000 0.852 0.000 0.000 0.040 0.108
#> GSM247175     2  0.0146     0.9016 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM247188     2  0.0993     0.8950 0.000 0.964 0.000 0.000 0.012 0.024
#> GSM247189     4  0.3313     0.6883 0.000 0.140 0.000 0.820 0.024 0.016
#> GSM247190     2  0.0935     0.8963 0.000 0.964 0.000 0.000 0.004 0.032
#> GSM247650     1  0.3044     0.5673 0.836 0.000 0.000 0.000 0.116 0.048
#> GSM247651     1  0.3719     0.5637 0.792 0.000 0.000 0.012 0.148 0.048
#> GSM247652     1  0.2738     0.3449 0.820 0.000 0.000 0.000 0.004 0.176
#> GSM247653     6  0.3851     0.9895 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM247654     1  0.3769    -0.3755 0.640 0.000 0.000 0.000 0.004 0.356
#> GSM247655     1  0.3563     0.5728 0.808 0.000 0.000 0.012 0.132 0.048
#> GSM247656     1  0.3440     0.2936 0.776 0.000 0.000 0.000 0.028 0.196
#> GSM247657     1  0.3253     0.3284 0.788 0.000 0.000 0.000 0.020 0.192
#> GSM247658     1  0.3482    -0.1714 0.684 0.000 0.000 0.000 0.000 0.316
#> GSM247659     1  0.3417     0.3861 0.796 0.000 0.000 0.000 0.044 0.160
#> GSM247660     1  0.3719     0.5637 0.792 0.000 0.000 0.012 0.148 0.048
#> GSM247661     6  0.3847     0.9863 0.456 0.000 0.000 0.000 0.000 0.544
#> GSM247662     1  0.2889     0.4819 0.848 0.000 0.000 0.000 0.044 0.108
#> GSM247663     1  0.4121     0.4676 0.748 0.000 0.000 0.000 0.116 0.136
#> GSM247856     1  0.1806     0.5152 0.908 0.000 0.000 0.000 0.004 0.088
#> GSM247857     1  0.2889     0.4819 0.848 0.000 0.000 0.000 0.044 0.108
#> GSM247859     1  0.1434     0.5962 0.948 0.000 0.000 0.012 0.028 0.012
#> GSM247860     6  0.3854     0.9858 0.464 0.000 0.000 0.000 0.000 0.536
#> GSM247862     1  0.3725     0.4586 0.776 0.000 0.000 0.004 0.048 0.172
#> GSM247864     1  0.3583     0.5679 0.800 0.000 0.000 0.008 0.144 0.048
#> GSM247865     1  0.1787     0.5932 0.932 0.000 0.000 0.020 0.032 0.016
#> GSM247866     1  0.5270    -0.2221 0.548 0.000 0.000 0.004 0.096 0.352
#> GSM247876     1  0.4527     0.3784 0.660 0.000 0.000 0.000 0.272 0.068
#> GSM247877     5  0.4164     0.4721 0.040 0.000 0.000 0.220 0.728 0.012
#> GSM247878     5  0.4255     0.4688 0.068 0.000 0.000 0.224 0.708 0.000
#> GSM247879     5  0.5045    -0.0804 0.412 0.000 0.000 0.000 0.512 0.076
#> GSM247881     1  0.0891     0.5874 0.968 0.000 0.000 0.000 0.024 0.008
#> GSM247883     1  0.1622     0.5941 0.940 0.000 0.000 0.016 0.028 0.016

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:kmeans 61         5.68e-14 2
#> MAD:kmeans 60         1.88e-21 3
#> MAD:kmeans 61         2.38e-22 4
#> MAD:kmeans 61         2.38e-22 5
#> MAD:kmeans 46         1.82e-16 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.976       0.991         0.4891 0.515   0.515
#> 3 3 0.722           0.853       0.930         0.3722 0.733   0.517
#> 4 4 0.835           0.854       0.936         0.1015 0.784   0.464
#> 5 5 0.784           0.688       0.847         0.0769 0.893   0.632
#> 6 6 0.794           0.625       0.792         0.0345 0.954   0.787

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
#> GSM246087     1   0.000     0.9853 1.000 0.000
#> GSM246088     1   0.000     0.9853 1.000 0.000
#> GSM246089     1   0.000     0.9853 1.000 0.000
#> GSM246090     1   0.000     0.9853 1.000 0.000
#> GSM246119     1   0.000     0.9853 1.000 0.000
#> GSM246120     1   0.000     0.9853 1.000 0.000
#> GSM246121     1   0.000     0.9853 1.000 0.000
#> GSM246122     1   0.000     0.9853 1.000 0.000
#> GSM246123     1   0.000     0.9853 1.000 0.000
#> GSM246422     2   0.000     1.0000 0.000 1.000
#> GSM246423     2   0.000     1.0000 0.000 1.000
#> GSM246484     2   0.000     1.0000 0.000 1.000
#> GSM246485     2   0.000     1.0000 0.000 1.000
#> GSM246486     2   0.000     1.0000 0.000 1.000
#> GSM246487     2   0.000     1.0000 0.000 1.000
#> GSM246488     2   0.000     1.0000 0.000 1.000
#> GSM246489     2   0.000     1.0000 0.000 1.000
#> GSM246490     2   0.000     1.0000 0.000 1.000
#> GSM246491     2   0.000     1.0000 0.000 1.000
#> GSM247162     2   0.000     1.0000 0.000 1.000
#> GSM247163     2   0.000     1.0000 0.000 1.000
#> GSM247164     2   0.000     1.0000 0.000 1.000
#> GSM247165     2   0.000     1.0000 0.000 1.000
#> GSM247166     2   0.000     1.0000 0.000 1.000
#> GSM247168     2   0.000     1.0000 0.000 1.000
#> GSM247169     2   0.000     1.0000 0.000 1.000
#> GSM247171     2   0.000     1.0000 0.000 1.000
#> GSM247173     2   0.000     1.0000 0.000 1.000
#> GSM247174     2   0.000     1.0000 0.000 1.000
#> GSM247175     2   0.000     1.0000 0.000 1.000
#> GSM247188     2   0.000     1.0000 0.000 1.000
#> GSM247189     2   0.000     1.0000 0.000 1.000
#> GSM247190     2   0.000     1.0000 0.000 1.000
#> GSM247650     1   0.000     0.9853 1.000 0.000
#> GSM247651     1   0.000     0.9853 1.000 0.000
#> GSM247652     1   0.000     0.9853 1.000 0.000
#> GSM247653     1   0.000     0.9853 1.000 0.000
#> GSM247654     1   0.000     0.9853 1.000 0.000
#> GSM247655     1   0.000     0.9853 1.000 0.000
#> GSM247656     1   0.000     0.9853 1.000 0.000
#> GSM247657     1   0.000     0.9853 1.000 0.000
#> GSM247658     1   0.000     0.9853 1.000 0.000
#> GSM247659     1   0.000     0.9853 1.000 0.000
#> GSM247660     1   0.000     0.9853 1.000 0.000
#> GSM247661     1   0.000     0.9853 1.000 0.000
#> GSM247662     1   0.000     0.9853 1.000 0.000
#> GSM247663     1   0.000     0.9853 1.000 0.000
#> GSM247856     1   0.000     0.9853 1.000 0.000
#> GSM247857     1   0.000     0.9853 1.000 0.000
#> GSM247859     1   0.000     0.9853 1.000 0.000
#> GSM247860     1   0.000     0.9853 1.000 0.000
#> GSM247862     1   0.000     0.9853 1.000 0.000
#> GSM247864     1   0.000     0.9853 1.000 0.000
#> GSM247865     1   0.999     0.0817 0.520 0.480
#> GSM247866     1   0.000     0.9853 1.000 0.000
#> GSM247876     1   0.000     0.9853 1.000 0.000
#> GSM247877     1   0.000     0.9853 1.000 0.000
#> GSM247878     1   0.000     0.9853 1.000 0.000
#> GSM247879     1   0.000     0.9853 1.000 0.000
#> GSM247881     1   0.000     0.9853 1.000 0.000
#> GSM247883     1   0.260     0.9421 0.956 0.044

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.859 0.000 0.000 1.000
#> GSM246422     1  0.3816      0.784 0.852 0.148 0.000
#> GSM246423     1  0.3752      0.788 0.856 0.144 0.000
#> GSM246484     1  0.3816      0.784 0.852 0.148 0.000
#> GSM246485     2  0.0424      0.991 0.008 0.992 0.000
#> GSM246486     2  0.0237      0.995 0.004 0.996 0.000
#> GSM246487     1  0.4235      0.756 0.824 0.176 0.000
#> GSM246488     2  0.1163      0.972 0.028 0.972 0.000
#> GSM246489     2  0.0000      0.998 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.998 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247189     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247190     2  0.0000      0.998 0.000 1.000 0.000
#> GSM247650     1  0.4452      0.713 0.808 0.000 0.192
#> GSM247651     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247652     1  0.5882      0.367 0.652 0.000 0.348
#> GSM247653     3  0.3752      0.825 0.144 0.000 0.856
#> GSM247654     3  0.4842      0.763 0.224 0.000 0.776
#> GSM247655     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247656     3  0.3412      0.833 0.124 0.000 0.876
#> GSM247657     3  0.5465      0.681 0.288 0.000 0.712
#> GSM247658     1  0.4291      0.729 0.820 0.000 0.180
#> GSM247659     3  0.0000      0.859 0.000 0.000 1.000
#> GSM247660     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247661     3  0.3551      0.831 0.132 0.000 0.868
#> GSM247662     3  0.4399      0.793 0.188 0.000 0.812
#> GSM247663     1  0.4399      0.719 0.812 0.000 0.188
#> GSM247856     3  0.6305      0.202 0.484 0.000 0.516
#> GSM247857     3  0.5327      0.709 0.272 0.000 0.728
#> GSM247859     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247860     3  0.3686      0.828 0.140 0.000 0.860
#> GSM247862     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247876     1  0.2625      0.832 0.916 0.000 0.084
#> GSM247877     1  0.4399      0.733 0.812 0.000 0.188
#> GSM247878     1  0.0000      0.882 1.000 0.000 0.000
#> GSM247879     3  0.6192      0.185 0.420 0.000 0.580
#> GSM247881     1  0.1289      0.866 0.968 0.000 0.032
#> GSM247883     1  0.0000      0.882 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
#> GSM246087     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000     0.9822 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000     0.8487 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000     0.8487 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000     0.8487 0.000 0.000 0.000 1.000
#> GSM246485     4  0.4877     0.2575 0.000 0.408 0.000 0.592
#> GSM246486     4  0.2081     0.8088 0.000 0.084 0.000 0.916
#> GSM246487     4  0.0000     0.8487 0.000 0.000 0.000 1.000
#> GSM246488     4  0.1211     0.8361 0.000 0.040 0.000 0.960
#> GSM246489     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247189     2  0.4817     0.3142 0.000 0.612 0.000 0.388
#> GSM247190     2  0.0000     0.9735 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247651     1  0.4331     0.6468 0.712 0.000 0.000 0.288
#> GSM247652     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247653     1  0.1022     0.8830 0.968 0.000 0.032 0.000
#> GSM247654     1  0.0817     0.8853 0.976 0.000 0.024 0.000
#> GSM247655     1  0.3024     0.8135 0.852 0.000 0.000 0.148
#> GSM247656     1  0.4972     0.2012 0.544 0.000 0.456 0.000
#> GSM247657     1  0.0817     0.8856 0.976 0.000 0.024 0.000
#> GSM247658     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247659     3  0.0469     0.9712 0.012 0.000 0.988 0.000
#> GSM247660     1  0.4193     0.6784 0.732 0.000 0.000 0.268
#> GSM247661     1  0.2760     0.8179 0.872 0.000 0.128 0.000
#> GSM247662     1  0.4072     0.6819 0.748 0.000 0.252 0.000
#> GSM247663     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247856     1  0.1118     0.8819 0.964 0.000 0.036 0.000
#> GSM247857     1  0.0921     0.8862 0.972 0.000 0.028 0.000
#> GSM247859     1  0.3356     0.7887 0.824 0.000 0.000 0.176
#> GSM247860     1  0.1302     0.8775 0.956 0.000 0.044 0.000
#> GSM247862     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247864     1  0.2814     0.8258 0.868 0.000 0.000 0.132
#> GSM247865     4  0.4916     0.0808 0.424 0.000 0.000 0.576
#> GSM247866     1  0.0188     0.8881 0.996 0.000 0.000 0.004
#> GSM247876     1  0.0524     0.8880 0.988 0.000 0.004 0.008
#> GSM247877     4  0.3142     0.7514 0.008 0.000 0.132 0.860
#> GSM247878     4  0.1389     0.8267 0.048 0.000 0.000 0.952
#> GSM247879     3  0.3217     0.8247 0.128 0.000 0.860 0.012
#> GSM247881     1  0.0000     0.8885 1.000 0.000 0.000 0.000
#> GSM247883     1  0.3486     0.7780 0.812 0.000 0.000 0.188

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM246087     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246090     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000     0.9756 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0162     0.8770 0.004 0.000 0.000 0.996 0.000
#> GSM246423     4  0.0162     0.8770 0.004 0.000 0.000 0.996 0.000
#> GSM246484     4  0.0162     0.8770 0.004 0.000 0.000 0.996 0.000
#> GSM246485     4  0.3462     0.6980 0.000 0.196 0.000 0.792 0.012
#> GSM246486     4  0.1364     0.8617 0.000 0.036 0.000 0.952 0.012
#> GSM246487     4  0.0579     0.8717 0.008 0.000 0.000 0.984 0.008
#> GSM246488     4  0.0865     0.8704 0.000 0.024 0.000 0.972 0.004
#> GSM246489     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0162     0.9655 0.000 0.996 0.000 0.000 0.004
#> GSM246491     2  0.0162     0.9655 0.000 0.996 0.000 0.000 0.004
#> GSM247162     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0162     0.9655 0.000 0.996 0.000 0.000 0.004
#> GSM247164     2  0.0162     0.9655 0.000 0.996 0.000 0.000 0.004
#> GSM247165     2  0.0451     0.9601 0.000 0.988 0.000 0.004 0.008
#> GSM247166     2  0.0162     0.9652 0.000 0.996 0.000 0.000 0.004
#> GSM247168     2  0.0162     0.9652 0.000 0.996 0.000 0.000 0.004
#> GSM247169     2  0.0162     0.9652 0.000 0.996 0.000 0.000 0.004
#> GSM247171     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247189     2  0.4546     0.0744 0.000 0.532 0.000 0.460 0.008
#> GSM247190     2  0.0000     0.9666 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.2329     0.5310 0.876 0.000 0.000 0.000 0.124
#> GSM247651     1  0.4010     0.5474 0.792 0.000 0.000 0.136 0.072
#> GSM247652     5  0.3983     0.5309 0.340 0.000 0.000 0.000 0.660
#> GSM247653     5  0.1956     0.6786 0.076 0.000 0.008 0.000 0.916
#> GSM247654     5  0.2660     0.6864 0.128 0.000 0.008 0.000 0.864
#> GSM247655     1  0.2654     0.5533 0.884 0.000 0.000 0.032 0.084
#> GSM247656     5  0.6206     0.3634 0.172 0.000 0.296 0.000 0.532
#> GSM247657     5  0.3534     0.5832 0.256 0.000 0.000 0.000 0.744
#> GSM247658     5  0.3932     0.5242 0.328 0.000 0.000 0.000 0.672
#> GSM247659     3  0.4194     0.7334 0.088 0.000 0.780 0.000 0.132
#> GSM247660     1  0.3705     0.5540 0.816 0.000 0.000 0.120 0.064
#> GSM247661     5  0.3527     0.6395 0.116 0.000 0.056 0.000 0.828
#> GSM247662     1  0.6084     0.0164 0.508 0.000 0.132 0.000 0.360
#> GSM247663     1  0.4088     0.1953 0.632 0.000 0.000 0.000 0.368
#> GSM247856     5  0.5325     0.3080 0.428 0.000 0.052 0.000 0.520
#> GSM247857     1  0.4590     0.0798 0.568 0.000 0.012 0.000 0.420
#> GSM247859     1  0.4451     0.4401 0.712 0.000 0.000 0.040 0.248
#> GSM247860     5  0.2389     0.6608 0.116 0.000 0.004 0.000 0.880
#> GSM247862     1  0.4249     0.1375 0.568 0.000 0.000 0.000 0.432
#> GSM247864     1  0.2344     0.5594 0.904 0.000 0.000 0.032 0.064
#> GSM247865     1  0.5441     0.3952 0.596 0.000 0.000 0.324 0.080
#> GSM247866     1  0.4533     0.1164 0.544 0.000 0.000 0.008 0.448
#> GSM247876     1  0.3790     0.4459 0.724 0.000 0.004 0.000 0.272
#> GSM247877     4  0.6615     0.3101 0.316 0.000 0.084 0.544 0.056
#> GSM247878     1  0.4989     0.1526 0.552 0.000 0.000 0.416 0.032
#> GSM247879     1  0.6487     0.0761 0.432 0.000 0.404 0.004 0.160
#> GSM247881     1  0.3274     0.4562 0.780 0.000 0.000 0.000 0.220
#> GSM247883     1  0.4462     0.4675 0.740 0.000 0.000 0.064 0.196

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246090     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000    0.94359 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.1219    0.79486 0.004 0.000 0.000 0.948 0.048 0.000
#> GSM246423     4  0.1219    0.79486 0.004 0.000 0.000 0.948 0.048 0.000
#> GSM246484     4  0.1219    0.79486 0.004 0.000 0.000 0.948 0.048 0.000
#> GSM246485     4  0.3327    0.70303 0.004 0.116 0.000 0.828 0.048 0.004
#> GSM246486     4  0.2122    0.77663 0.008 0.040 0.000 0.912 0.040 0.000
#> GSM246487     4  0.2617    0.73665 0.080 0.004 0.000 0.876 0.040 0.000
#> GSM246488     4  0.0000    0.79435 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246489     2  0.0146    0.98521 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM246490     2  0.0603    0.98308 0.000 0.980 0.000 0.004 0.016 0.000
#> GSM246491     2  0.0508    0.98426 0.000 0.984 0.000 0.004 0.012 0.000
#> GSM247162     2  0.0458    0.98405 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM247163     2  0.0603    0.98157 0.000 0.980 0.000 0.004 0.016 0.000
#> GSM247164     2  0.0405    0.98319 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM247165     2  0.1088    0.96304 0.000 0.960 0.000 0.024 0.016 0.000
#> GSM247166     2  0.0865    0.97455 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM247168     2  0.0865    0.97455 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM247169     2  0.0790    0.97677 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM247171     2  0.0146    0.98529 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM247173     2  0.0260    0.98501 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM247174     2  0.0363    0.98388 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM247175     2  0.0146    0.98467 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM247188     2  0.0260    0.98486 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM247189     4  0.4712    0.17611 0.000 0.448 0.000 0.512 0.036 0.004
#> GSM247190     2  0.0547    0.98406 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM247650     1  0.4412    0.44560 0.732 0.000 0.008 0.000 0.160 0.100
#> GSM247651     1  0.3730    0.48316 0.812 0.000 0.000 0.052 0.104 0.032
#> GSM247652     6  0.5421    0.35964 0.308 0.000 0.000 0.000 0.144 0.548
#> GSM247653     6  0.1485    0.57135 0.028 0.000 0.004 0.000 0.024 0.944
#> GSM247654     6  0.3052    0.57872 0.068 0.000 0.004 0.000 0.080 0.848
#> GSM247655     1  0.2001    0.52816 0.912 0.000 0.000 0.000 0.040 0.048
#> GSM247656     6  0.6997    0.23443 0.088 0.000 0.224 0.000 0.244 0.444
#> GSM247657     6  0.5276    0.40737 0.188 0.000 0.000 0.000 0.208 0.604
#> GSM247658     6  0.4655    0.39596 0.300 0.000 0.000 0.000 0.068 0.632
#> GSM247659     3  0.6128    0.24468 0.044 0.000 0.544 0.000 0.272 0.140
#> GSM247660     1  0.3796    0.48946 0.812 0.000 0.000 0.048 0.092 0.048
#> GSM247661     6  0.3324    0.55110 0.080 0.000 0.020 0.000 0.060 0.840
#> GSM247662     5  0.7374   -0.21910 0.304 0.000 0.116 0.000 0.340 0.240
#> GSM247663     1  0.5461    0.23200 0.560 0.000 0.000 0.000 0.168 0.272
#> GSM247856     6  0.6838    0.19759 0.348 0.000 0.060 0.000 0.200 0.392
#> GSM247857     1  0.6242    0.00783 0.416 0.000 0.008 0.000 0.312 0.264
#> GSM247859     1  0.5093    0.43280 0.672 0.000 0.000 0.016 0.164 0.148
#> GSM247860     6  0.2442    0.55885 0.068 0.000 0.000 0.000 0.048 0.884
#> GSM247862     1  0.5387    0.01443 0.464 0.000 0.000 0.000 0.112 0.424
#> GSM247864     1  0.2294    0.51288 0.892 0.000 0.000 0.000 0.072 0.036
#> GSM247865     1  0.5785    0.34842 0.616 0.000 0.000 0.188 0.152 0.044
#> GSM247866     6  0.5782   -0.07517 0.400 0.000 0.000 0.000 0.176 0.424
#> GSM247876     1  0.5558    0.07491 0.448 0.000 0.000 0.000 0.416 0.136
#> GSM247877     5  0.6297    0.11347 0.208 0.000 0.012 0.332 0.444 0.004
#> GSM247878     1  0.5997   -0.17416 0.416 0.000 0.000 0.240 0.344 0.000
#> GSM247879     5  0.7037    0.13388 0.232 0.000 0.200 0.008 0.476 0.084
#> GSM247881     1  0.4963    0.43180 0.636 0.000 0.000 0.000 0.240 0.124
#> GSM247883     1  0.4675    0.45300 0.696 0.000 0.000 0.008 0.200 0.096

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n disease.state(p) k
#> MAD:skmeans 60         9.36e-14 2
#> MAD:skmeans 58         1.47e-12 3
#> MAD:skmeans 57         7.66e-18 4
#> MAD:skmeans 45         1.62e-14 5
#> MAD:skmeans 38         3.11e-13 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.966           0.948       0.965         0.4553 0.552   0.552
#> 3 3 1.000           0.989       0.995         0.3384 0.843   0.715
#> 4 4 0.987           0.944       0.978         0.1157 0.926   0.814
#> 5 5 0.854           0.847       0.923         0.1271 0.920   0.753
#> 6 6 0.882           0.872       0.924         0.0432 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] 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
#> GSM246087     1  0.0938      0.943 0.988 0.012
#> GSM246088     1  0.0000      0.947 1.000 0.000
#> GSM246089     1  0.0000      0.947 1.000 0.000
#> GSM246090     1  0.0000      0.947 1.000 0.000
#> GSM246119     1  0.0000      0.947 1.000 0.000
#> GSM246120     1  0.0000      0.947 1.000 0.000
#> GSM246121     1  0.0000      0.947 1.000 0.000
#> GSM246122     1  0.9170      0.485 0.668 0.332
#> GSM246123     1  0.0000      0.947 1.000 0.000
#> GSM246422     1  0.6438      0.835 0.836 0.164
#> GSM246423     1  0.2236      0.961 0.964 0.036
#> GSM246484     1  0.9170      0.574 0.668 0.332
#> GSM246485     2  0.1184      0.982 0.016 0.984
#> GSM246486     2  0.0000      0.999 0.000 1.000
#> GSM246487     1  0.9170      0.574 0.668 0.332
#> GSM246488     2  0.0000      0.999 0.000 1.000
#> GSM246489     2  0.0000      0.999 0.000 1.000
#> GSM246490     2  0.0000      0.999 0.000 1.000
#> GSM246491     2  0.0000      0.999 0.000 1.000
#> GSM247162     2  0.0000      0.999 0.000 1.000
#> GSM247163     2  0.0000      0.999 0.000 1.000
#> GSM247164     2  0.0000      0.999 0.000 1.000
#> GSM247165     2  0.0000      0.999 0.000 1.000
#> GSM247166     2  0.0000      0.999 0.000 1.000
#> GSM247168     2  0.0000      0.999 0.000 1.000
#> GSM247169     2  0.0000      0.999 0.000 1.000
#> GSM247171     2  0.0000      0.999 0.000 1.000
#> GSM247173     2  0.0000      0.999 0.000 1.000
#> GSM247174     2  0.0000      0.999 0.000 1.000
#> GSM247175     2  0.0000      0.999 0.000 1.000
#> GSM247188     2  0.0000      0.999 0.000 1.000
#> GSM247189     2  0.0000      0.999 0.000 1.000
#> GSM247190     2  0.0000      0.999 0.000 1.000
#> GSM247650     1  0.2236      0.961 0.964 0.036
#> GSM247651     1  0.2236      0.961 0.964 0.036
#> GSM247652     1  0.2236      0.961 0.964 0.036
#> GSM247653     1  0.2236      0.961 0.964 0.036
#> GSM247654     1  0.2236      0.961 0.964 0.036
#> GSM247655     1  0.2236      0.961 0.964 0.036
#> GSM247656     1  0.0938      0.953 0.988 0.012
#> GSM247657     1  0.2236      0.961 0.964 0.036
#> GSM247658     1  0.2236      0.961 0.964 0.036
#> GSM247659     1  0.0000      0.947 1.000 0.000
#> GSM247660     1  0.2236      0.961 0.964 0.036
#> GSM247661     1  0.0376      0.949 0.996 0.004
#> GSM247662     1  0.0376      0.949 0.996 0.004
#> GSM247663     1  0.2236      0.961 0.964 0.036
#> GSM247856     1  0.2236      0.961 0.964 0.036
#> GSM247857     1  0.2236      0.961 0.964 0.036
#> GSM247859     1  0.2236      0.961 0.964 0.036
#> GSM247860     1  0.2236      0.961 0.964 0.036
#> GSM247862     1  0.2236      0.961 0.964 0.036
#> GSM247864     1  0.2236      0.961 0.964 0.036
#> GSM247865     1  0.2236      0.961 0.964 0.036
#> GSM247866     1  0.2236      0.961 0.964 0.036
#> GSM247876     1  0.2236      0.961 0.964 0.036
#> GSM247877     1  0.2236      0.961 0.964 0.036
#> GSM247878     1  0.2236      0.961 0.964 0.036
#> GSM247879     1  0.2236      0.961 0.964 0.036
#> GSM247881     1  0.2236      0.961 0.964 0.036
#> GSM247883     1  0.2236      0.961 0.964 0.036

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246422     1  0.0000      0.990 1.000 0.000 0.000
#> GSM246423     1  0.0000      0.990 1.000 0.000 0.000
#> GSM246484     1  0.0000      0.990 1.000 0.000 0.000
#> GSM246485     2  0.0424      0.989 0.008 0.992 0.000
#> GSM246486     2  0.0000      0.999 0.000 1.000 0.000
#> GSM246487     1  0.0000      0.990 1.000 0.000 0.000
#> GSM246488     2  0.0000      0.999 0.000 1.000 0.000
#> GSM246489     2  0.0000      0.999 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.999 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247189     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247190     2  0.0000      0.999 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247656     1  0.4974      0.692 0.764 0.000 0.236
#> GSM247657     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247659     1  0.2165      0.927 0.936 0.000 0.064
#> GSM247660     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247876     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247877     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247878     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247879     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247881     1  0.0000      0.990 1.000 0.000 0.000
#> GSM247883     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
#> GSM246087     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246088     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246089     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246090     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246119     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246120     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246121     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246122     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246123     3   0.000      1.000 0.000 0.000 1.000 0.000
#> GSM246422     4   0.000      0.877 0.000 0.000 0.000 1.000
#> GSM246423     4   0.000      0.877 0.000 0.000 0.000 1.000
#> GSM246484     4   0.000      0.877 0.000 0.000 0.000 1.000
#> GSM246485     2   0.102      0.931 0.032 0.968 0.000 0.000
#> GSM246486     2   0.394      0.711 0.000 0.764 0.000 0.236
#> GSM246487     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM246488     4   0.000      0.877 0.000 0.000 0.000 1.000
#> GSM246489     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM246490     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM246491     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247162     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247163     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247164     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247165     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247166     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247168     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247169     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247171     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247173     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247174     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247175     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247188     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247189     2   0.425      0.648 0.000 0.724 0.000 0.276
#> GSM247190     2   0.000      0.969 0.000 1.000 0.000 0.000
#> GSM247650     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247651     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247652     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247653     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247654     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247655     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247656     1   0.102      0.949 0.968 0.000 0.032 0.000
#> GSM247657     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247658     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247659     1   0.172      0.912 0.936 0.000 0.064 0.000
#> GSM247660     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247661     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247662     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247663     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247856     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247857     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247859     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247860     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247862     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247864     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247865     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247866     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247876     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247877     4   0.450      0.517 0.316 0.000 0.000 0.684
#> GSM247878     1   0.473      0.361 0.636 0.000 0.000 0.364
#> GSM247879     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247881     1   0.000      0.981 1.000 0.000 0.000 0.000
#> GSM247883     1   0.000      0.981 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0000      0.886 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0000      0.886 0.000 0.000 0.000 1.000 0.000
#> GSM246484     4  0.0000      0.886 0.000 0.000 0.000 1.000 0.000
#> GSM246485     2  0.0794      0.939 0.028 0.972 0.000 0.000 0.000
#> GSM246486     2  0.3395      0.708 0.000 0.764 0.000 0.236 0.000
#> GSM246487     1  0.0162      0.834 0.996 0.000 0.000 0.000 0.004
#> GSM246488     4  0.0000      0.886 0.000 0.000 0.000 1.000 0.000
#> GSM246489     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247165     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247166     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247189     2  0.3661      0.643 0.000 0.724 0.000 0.276 0.000
#> GSM247190     2  0.0000      0.969 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.0703      0.824 0.976 0.000 0.000 0.000 0.024
#> GSM247651     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000
#> GSM247652     1  0.3932      0.646 0.672 0.000 0.000 0.000 0.328
#> GSM247653     1  0.3837      0.672 0.692 0.000 0.000 0.000 0.308
#> GSM247654     1  0.4304      0.350 0.516 0.000 0.000 0.000 0.484
#> GSM247655     1  0.0162      0.833 0.996 0.000 0.000 0.000 0.004
#> GSM247656     5  0.0162      0.724 0.004 0.000 0.000 0.000 0.996
#> GSM247657     5  0.0162      0.724 0.004 0.000 0.000 0.000 0.996
#> GSM247658     1  0.3508      0.715 0.748 0.000 0.000 0.000 0.252
#> GSM247659     5  0.4087      0.757 0.208 0.000 0.036 0.000 0.756
#> GSM247660     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000
#> GSM247661     5  0.2329      0.781 0.124 0.000 0.000 0.000 0.876
#> GSM247662     5  0.3508      0.747 0.252 0.000 0.000 0.000 0.748
#> GSM247663     1  0.3534      0.716 0.744 0.000 0.000 0.000 0.256
#> GSM247856     5  0.3274      0.632 0.220 0.000 0.000 0.000 0.780
#> GSM247857     5  0.3452      0.753 0.244 0.000 0.000 0.000 0.756
#> GSM247859     1  0.0290      0.834 0.992 0.000 0.000 0.000 0.008
#> GSM247860     1  0.3730      0.690 0.712 0.000 0.000 0.000 0.288
#> GSM247862     1  0.0000      0.834 1.000 0.000 0.000 0.000 0.000
#> GSM247864     1  0.0162      0.833 0.996 0.000 0.000 0.000 0.004
#> GSM247865     1  0.0290      0.834 0.992 0.000 0.000 0.000 0.008
#> GSM247866     1  0.0162      0.833 0.996 0.000 0.000 0.000 0.004
#> GSM247876     1  0.0609      0.830 0.980 0.000 0.000 0.000 0.020
#> GSM247877     4  0.4029      0.456 0.316 0.000 0.000 0.680 0.004
#> GSM247878     1  0.3424      0.592 0.760 0.000 0.000 0.240 0.000
#> GSM247879     1  0.2891      0.653 0.824 0.000 0.000 0.000 0.176
#> GSM247881     1  0.1341      0.821 0.944 0.000 0.000 0.000 0.056
#> GSM247883     1  0.3534      0.715 0.744 0.000 0.000 0.000 0.256

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2   p3    p4    p5    p6
#> GSM246087     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246088     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246089     3  0.2941     0.7956 0.000 0.000 0.78 0.000 0.220 0.000
#> GSM246090     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246119     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246120     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246121     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246122     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246123     3  0.0000     0.9773 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM246422     4  0.0000     0.8904 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM246423     4  0.0000     0.8904 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM246484     4  0.0000     0.8904 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM246485     2  0.0713     0.9393 0.028 0.972 0.00 0.000 0.000 0.000
#> GSM246486     2  0.3050     0.7067 0.000 0.764 0.00 0.236 0.000 0.000
#> GSM246487     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM246488     4  0.0000     0.8904 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM246489     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247164     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247165     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247166     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247189     2  0.3288     0.6418 0.000 0.724 0.00 0.276 0.000 0.000
#> GSM247190     2  0.0000     0.9693 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM247650     1  0.1444     0.8879 0.928 0.000 0.00 0.000 0.000 0.072
#> GSM247651     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM247652     5  0.3993     0.8250 0.300 0.000 0.00 0.000 0.676 0.024
#> GSM247653     5  0.2941     0.8170 0.220 0.000 0.00 0.000 0.780 0.000
#> GSM247654     5  0.3806     0.7437 0.152 0.000 0.00 0.000 0.772 0.076
#> GSM247655     1  0.0146     0.9415 0.996 0.000 0.00 0.000 0.000 0.004
#> GSM247656     5  0.3993    -0.0921 0.004 0.000 0.00 0.000 0.520 0.476
#> GSM247657     6  0.0146     0.8893 0.004 0.000 0.00 0.000 0.000 0.996
#> GSM247658     5  0.3515     0.8166 0.324 0.000 0.00 0.000 0.676 0.000
#> GSM247659     6  0.0000     0.8911 0.000 0.000 0.00 0.000 0.000 1.000
#> GSM247660     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM247661     6  0.0622     0.8824 0.008 0.000 0.00 0.000 0.012 0.980
#> GSM247662     6  0.0000     0.8911 0.000 0.000 0.00 0.000 0.000 1.000
#> GSM247663     5  0.3636     0.8167 0.320 0.000 0.00 0.000 0.676 0.004
#> GSM247856     6  0.5257     0.0990 0.104 0.000 0.00 0.000 0.372 0.524
#> GSM247857     6  0.0000     0.8911 0.000 0.000 0.00 0.000 0.000 1.000
#> GSM247859     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM247860     5  0.2969     0.8180 0.224 0.000 0.00 0.000 0.776 0.000
#> GSM247862     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM247864     1  0.0146     0.9415 0.996 0.000 0.00 0.000 0.000 0.004
#> GSM247865     1  0.0000     0.9424 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM247866     1  0.0146     0.9415 0.996 0.000 0.00 0.000 0.000 0.004
#> GSM247876     1  0.0713     0.9276 0.972 0.000 0.00 0.000 0.000 0.028
#> GSM247877     4  0.3619     0.5134 0.316 0.000 0.00 0.680 0.000 0.004
#> GSM247878     1  0.2454     0.7649 0.840 0.000 0.00 0.160 0.000 0.000
#> GSM247879     1  0.2969     0.6854 0.776 0.000 0.00 0.000 0.000 0.224
#> GSM247881     1  0.1387     0.8688 0.932 0.000 0.00 0.000 0.068 0.000
#> GSM247883     5  0.3714     0.7991 0.340 0.000 0.00 0.000 0.656 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-MAD-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) k
#> MAD:pam 60         1.69e-10 2
#> MAD:pam 61         6.70e-22 3
#> MAD:pam 60         9.09e-22 4
#> MAD:pam 59         7.23e-21 5
#> MAD:pam 59         5.78e-19 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 21168 rows and 61 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 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.446           0.215       0.581         0.4869 0.721   0.721
#> 3 3 0.818           0.882       0.943         0.3350 0.560   0.418
#> 4 4 0.918           0.878       0.951         0.1176 0.907   0.744
#> 5 5 0.842           0.872       0.907         0.0369 0.986   0.952
#> 6 6 0.952           0.934       0.960         0.0720 0.916   0.695

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

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

There is also optional best \(k\) = 4 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
#> GSM246087     1  0.7602      0.853 0.780 0.220
#> GSM246088     1  0.7602      0.853 0.780 0.220
#> GSM246089     1  0.7602      0.853 0.780 0.220
#> GSM246090     1  0.7602      0.853 0.780 0.220
#> GSM246119     1  0.7602      0.853 0.780 0.220
#> GSM246120     1  0.7602      0.853 0.780 0.220
#> GSM246121     1  0.7602      0.853 0.780 0.220
#> GSM246122     1  0.7602      0.853 0.780 0.220
#> GSM246123     1  0.7602      0.853 0.780 0.220
#> GSM246422     2  0.3733      0.104 0.072 0.928
#> GSM246423     2  0.3733      0.104 0.072 0.928
#> GSM246484     2  0.3733      0.104 0.072 0.928
#> GSM246485     2  0.0000      0.155 0.000 1.000
#> GSM246486     2  0.0000      0.155 0.000 1.000
#> GSM246487     2  0.7528      0.292 0.216 0.784
#> GSM246488     2  0.0938      0.149 0.012 0.988
#> GSM246489     2  0.9881     -0.294 0.436 0.564
#> GSM246490     2  0.9881     -0.294 0.436 0.564
#> GSM246491     2  0.9881     -0.294 0.436 0.564
#> GSM247162     2  0.9881     -0.294 0.436 0.564
#> GSM247163     2  0.9881     -0.294 0.436 0.564
#> GSM247164     2  0.9881     -0.294 0.436 0.564
#> GSM247165     2  0.9881     -0.294 0.436 0.564
#> GSM247166     2  0.9881     -0.294 0.436 0.564
#> GSM247168     2  0.9881     -0.294 0.436 0.564
#> GSM247169     2  0.9881     -0.294 0.436 0.564
#> GSM247171     2  0.9881     -0.294 0.436 0.564
#> GSM247173     2  0.9881     -0.294 0.436 0.564
#> GSM247174     2  0.9881     -0.294 0.436 0.564
#> GSM247175     2  0.9881     -0.294 0.436 0.564
#> GSM247188     2  0.9881     -0.294 0.436 0.564
#> GSM247189     2  0.6531     -0.114 0.168 0.832
#> GSM247190     2  0.9881     -0.294 0.436 0.564
#> GSM247650     2  0.9998      0.393 0.492 0.508
#> GSM247651     2  0.9998      0.393 0.492 0.508
#> GSM247652     2  0.9998      0.393 0.492 0.508
#> GSM247653     2  0.9998      0.393 0.492 0.508
#> GSM247654     2  0.9998      0.393 0.492 0.508
#> GSM247655     2  0.9998      0.393 0.492 0.508
#> GSM247656     1  1.0000     -0.454 0.504 0.496
#> GSM247657     2  0.9998      0.393 0.492 0.508
#> GSM247658     2  0.9998      0.393 0.492 0.508
#> GSM247659     2  0.9170      0.263 0.332 0.668
#> GSM247660     2  0.9998      0.393 0.492 0.508
#> GSM247661     2  0.9998      0.393 0.492 0.508
#> GSM247662     2  1.0000      0.389 0.496 0.504
#> GSM247663     2  0.9998      0.393 0.492 0.508
#> GSM247856     2  0.9998      0.393 0.492 0.508
#> GSM247857     2  0.9998      0.393 0.492 0.508
#> GSM247859     2  0.9998      0.393 0.492 0.508
#> GSM247860     2  0.9998      0.393 0.492 0.508
#> GSM247862     2  0.9998      0.393 0.492 0.508
#> GSM247864     2  0.9998      0.393 0.492 0.508
#> GSM247865     2  0.9775      0.365 0.412 0.588
#> GSM247866     2  0.9998      0.393 0.492 0.508
#> GSM247876     2  0.9983      0.383 0.476 0.524
#> GSM247877     2  0.6887      0.108 0.184 0.816
#> GSM247878     2  0.5059      0.106 0.112 0.888
#> GSM247879     2  0.9286      0.137 0.344 0.656
#> GSM247881     2  0.9998      0.393 0.492 0.508
#> GSM247883     2  0.9998      0.393 0.492 0.508

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.944 0.000 0.000 1.000
#> GSM246422     3  0.4982      0.830 0.036 0.136 0.828
#> GSM246423     3  0.4982      0.830 0.036 0.136 0.828
#> GSM246484     3  0.4982      0.830 0.036 0.136 0.828
#> GSM246485     2  0.6526      0.658 0.036 0.704 0.260
#> GSM246486     2  0.6526      0.658 0.036 0.704 0.260
#> GSM246487     2  0.7884      0.585 0.100 0.640 0.260
#> GSM246488     2  0.6526      0.658 0.036 0.704 0.260
#> GSM246489     2  0.0000      0.898 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.898 0.000 1.000 0.000
#> GSM246491     2  0.3482      0.822 0.000 0.872 0.128
#> GSM247162     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247163     2  0.3619      0.815 0.000 0.864 0.136
#> GSM247164     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247165     2  0.0237      0.896 0.000 0.996 0.004
#> GSM247166     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247189     2  0.6526      0.658 0.036 0.704 0.260
#> GSM247190     2  0.0000      0.898 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247656     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247657     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247659     1  0.5815      0.558 0.692 0.004 0.304
#> GSM247660     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247865     1  0.0424      0.951 0.992 0.000 0.008
#> GSM247866     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247876     1  0.1529      0.921 0.960 0.000 0.040
#> GSM247877     3  0.3780      0.884 0.044 0.064 0.892
#> GSM247878     1  0.7267      0.521 0.668 0.064 0.268
#> GSM247879     1  0.6333      0.494 0.656 0.012 0.332
#> GSM247881     1  0.0000      0.957 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.957 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
#> GSM246087     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246088     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246089     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246090     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246119     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246120     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246121     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246122     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246123     3  0.0000     1.0000 0.000 0.000  1 0.000
#> GSM246422     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246423     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246484     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246485     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246486     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246487     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246488     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM246489     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM246490     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM246491     2  0.4382     0.5667 0.000 0.704  0 0.296
#> GSM247162     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247163     2  0.4967     0.2096 0.000 0.548  0 0.452
#> GSM247164     2  0.4522     0.5421 0.000 0.680  0 0.320
#> GSM247165     2  0.4522     0.5421 0.000 0.680  0 0.320
#> GSM247166     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247168     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247169     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247171     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247173     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247174     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247175     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247188     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247189     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM247190     2  0.0000     0.8982 0.000 1.000  0 0.000
#> GSM247650     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247651     1  0.0707     0.9173 0.980 0.000  0 0.020
#> GSM247652     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247653     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247654     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247655     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247656     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247657     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247658     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247659     1  0.4933     0.2532 0.568 0.000  0 0.432
#> GSM247660     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247661     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247662     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247663     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247856     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247857     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247859     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247860     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247862     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247864     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247865     1  0.4500     0.5382 0.684 0.000  0 0.316
#> GSM247866     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247876     1  0.0188     0.9298 0.996 0.000  0 0.004
#> GSM247877     4  0.0000     0.9988 0.000 0.000  0 1.000
#> GSM247878     4  0.0336     0.9889 0.008 0.000  0 0.992
#> GSM247879     1  0.4998     0.0812 0.512 0.000  0 0.488
#> GSM247881     1  0.0000     0.9325 1.000 0.000  0 0.000
#> GSM247883     1  0.4477     0.5456 0.688 0.000  0 0.312

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.0703      0.972 0.000 0.000  0 0.976 0.024
#> GSM246423     4  0.0794      0.971 0.000 0.000  0 0.972 0.028
#> GSM246484     4  0.0703      0.972 0.000 0.000  0 0.976 0.024
#> GSM246485     5  0.4378      0.886 0.036 0.000  0 0.248 0.716
#> GSM246486     5  0.3612      0.905 0.000 0.000  0 0.268 0.732
#> GSM246487     5  0.4921      0.783 0.036 0.000  0 0.360 0.604
#> GSM246488     5  0.3636      0.907 0.000 0.000  0 0.272 0.728
#> GSM246489     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0963      0.874 0.000 0.964  0 0.000 0.036
#> GSM246491     2  0.3691      0.722 0.000 0.804  0 0.040 0.156
#> GSM247162     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.5167      0.340 0.000 0.552  0 0.044 0.404
#> GSM247164     2  0.4192      0.403 0.000 0.596  0 0.000 0.404
#> GSM247165     2  0.4192      0.403 0.000 0.596  0 0.000 0.404
#> GSM247166     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247168     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247171     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247174     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247175     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247188     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247189     5  0.3857      0.896 0.000 0.000  0 0.312 0.688
#> GSM247190     2  0.0000      0.896 0.000 1.000  0 0.000 0.000
#> GSM247650     1  0.0000      0.904 1.000 0.000  0 0.000 0.000
#> GSM247651     1  0.1478      0.897 0.936 0.000  0 0.000 0.064
#> GSM247652     1  0.0794      0.903 0.972 0.000  0 0.000 0.028
#> GSM247653     1  0.3210      0.804 0.788 0.000  0 0.000 0.212
#> GSM247654     1  0.3177      0.807 0.792 0.000  0 0.000 0.208
#> GSM247655     1  0.1478      0.897 0.936 0.000  0 0.000 0.064
#> GSM247656     1  0.1410      0.892 0.940 0.000  0 0.000 0.060
#> GSM247657     1  0.3003      0.823 0.812 0.000  0 0.000 0.188
#> GSM247658     1  0.0609      0.905 0.980 0.000  0 0.000 0.020
#> GSM247659     1  0.3586      0.762 0.792 0.000  0 0.188 0.020
#> GSM247660     1  0.1478      0.897 0.936 0.000  0 0.000 0.064
#> GSM247661     1  0.3177      0.807 0.792 0.000  0 0.000 0.208
#> GSM247662     1  0.0404      0.904 0.988 0.000  0 0.000 0.012
#> GSM247663     1  0.0000      0.904 1.000 0.000  0 0.000 0.000
#> GSM247856     1  0.0404      0.904 0.988 0.000  0 0.000 0.012
#> GSM247857     1  0.0703      0.902 0.976 0.000  0 0.000 0.024
#> GSM247859     1  0.2424      0.854 0.868 0.000  0 0.000 0.132
#> GSM247860     1  0.3210      0.804 0.788 0.000  0 0.000 0.212
#> GSM247862     1  0.1043      0.902 0.960 0.000  0 0.000 0.040
#> GSM247864     1  0.1478      0.897 0.936 0.000  0 0.000 0.064
#> GSM247865     1  0.3519      0.763 0.776 0.000  0 0.008 0.216
#> GSM247866     1  0.1043      0.902 0.960 0.000  0 0.000 0.040
#> GSM247876     1  0.0162      0.904 0.996 0.000  0 0.000 0.004
#> GSM247877     4  0.0404      0.961 0.000 0.000  0 0.988 0.012
#> GSM247878     4  0.0671      0.951 0.004 0.000  0 0.980 0.016
#> GSM247879     1  0.3630      0.742 0.780 0.000  0 0.204 0.016
#> GSM247881     1  0.1043      0.902 0.960 0.000  0 0.000 0.040
#> GSM247883     1  0.3039      0.798 0.808 0.000  0 0.000 0.192

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4    p5    p6
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM246422     5  0.0146      0.985 0.000 0.000  0 0.004 0.996 0.000
#> GSM246423     5  0.0146      0.985 0.000 0.000  0 0.004 0.996 0.000
#> GSM246484     5  0.0146      0.985 0.000 0.000  0 0.004 0.996 0.000
#> GSM246485     4  0.0000      0.993 0.000 0.000  0 1.000 0.000 0.000
#> GSM246486     4  0.0000      0.993 0.000 0.000  0 1.000 0.000 0.000
#> GSM246487     4  0.0862      0.971 0.000 0.004  0 0.972 0.008 0.016
#> GSM246488     4  0.0000      0.993 0.000 0.000  0 1.000 0.000 0.000
#> GSM246489     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM246490     2  0.0547      0.967 0.000 0.980  0 0.020 0.000 0.000
#> GSM246491     2  0.0632      0.964 0.000 0.976  0 0.024 0.000 0.000
#> GSM247162     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247163     2  0.2597      0.814 0.000 0.824  0 0.176 0.000 0.000
#> GSM247164     2  0.1387      0.933 0.000 0.932  0 0.068 0.000 0.000
#> GSM247165     2  0.1387      0.933 0.000 0.932  0 0.068 0.000 0.000
#> GSM247166     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247189     4  0.0000      0.993 0.000 0.000  0 1.000 0.000 0.000
#> GSM247190     2  0.0000      0.977 0.000 1.000  0 0.000 0.000 0.000
#> GSM247650     1  0.2491      0.865 0.836 0.000  0 0.000 0.000 0.164
#> GSM247651     6  0.0458      0.896 0.016 0.000  0 0.000 0.000 0.984
#> GSM247652     1  0.1141      0.940 0.948 0.000  0 0.000 0.000 0.052
#> GSM247653     1  0.0260      0.926 0.992 0.000  0 0.000 0.000 0.008
#> GSM247654     1  0.0363      0.928 0.988 0.000  0 0.000 0.000 0.012
#> GSM247655     6  0.0458      0.896 0.016 0.000  0 0.000 0.000 0.984
#> GSM247656     1  0.0937      0.937 0.960 0.000  0 0.000 0.000 0.040
#> GSM247657     1  0.0547      0.932 0.980 0.000  0 0.000 0.000 0.020
#> GSM247658     1  0.1204      0.940 0.944 0.000  0 0.000 0.000 0.056
#> GSM247659     1  0.1802      0.929 0.916 0.000  0 0.000 0.012 0.072
#> GSM247660     6  0.0458      0.896 0.016 0.000  0 0.000 0.000 0.984
#> GSM247661     1  0.0260      0.922 0.992 0.000  0 0.000 0.000 0.008
#> GSM247662     1  0.1141      0.940 0.948 0.000  0 0.000 0.000 0.052
#> GSM247663     1  0.2562      0.860 0.828 0.000  0 0.000 0.000 0.172
#> GSM247856     1  0.1141      0.940 0.948 0.000  0 0.000 0.000 0.052
#> GSM247857     1  0.1075      0.940 0.952 0.000  0 0.000 0.000 0.048
#> GSM247859     6  0.0547      0.895 0.020 0.000  0 0.000 0.000 0.980
#> GSM247860     1  0.0146      0.924 0.996 0.000  0 0.000 0.000 0.004
#> GSM247862     6  0.3817      0.176 0.432 0.000  0 0.000 0.000 0.568
#> GSM247864     6  0.0458      0.896 0.016 0.000  0 0.000 0.000 0.984
#> GSM247865     6  0.0508      0.888 0.012 0.000  0 0.004 0.000 0.984
#> GSM247866     6  0.2527      0.762 0.168 0.000  0 0.000 0.000 0.832
#> GSM247876     1  0.2631      0.850 0.820 0.000  0 0.000 0.000 0.180
#> GSM247877     5  0.0632      0.977 0.000 0.000  0 0.000 0.976 0.024
#> GSM247878     5  0.0632      0.977 0.000 0.000  0 0.000 0.976 0.024
#> GSM247879     1  0.2980      0.847 0.808 0.000  0 0.000 0.012 0.180
#> GSM247881     1  0.1444      0.935 0.928 0.000  0 0.000 0.000 0.072
#> GSM247883     6  0.0692      0.894 0.020 0.000  0 0.004 0.000 0.976

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

plot of chunk tab-MAD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> MAD:mclust  9               NA 2
#> MAD:mclust 60         2.13e-19 3
#> MAD:mclust 58         4.42e-21 4
#> MAD:mclust 58         3.46e-20 5
#> MAD:mclust 60         7.11e-20 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.972       0.988         0.4944 0.503   0.503
#> 3 3 0.814           0.851       0.939         0.3451 0.708   0.481
#> 4 4 0.894           0.900       0.953         0.0853 0.804   0.513
#> 5 5 0.770           0.759       0.885         0.0485 0.978   0.921
#> 6 6 0.759           0.667       0.811         0.0493 0.952   0.827

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
#> GSM246087     1  0.0000      0.996 1.000 0.000
#> GSM246088     1  0.0000      0.996 1.000 0.000
#> GSM246089     1  0.0000      0.996 1.000 0.000
#> GSM246090     1  0.0000      0.996 1.000 0.000
#> GSM246119     1  0.0000      0.996 1.000 0.000
#> GSM246120     1  0.0000      0.996 1.000 0.000
#> GSM246121     1  0.0000      0.996 1.000 0.000
#> GSM246122     1  0.0000      0.996 1.000 0.000
#> GSM246123     1  0.0000      0.996 1.000 0.000
#> GSM246422     2  0.0376      0.972 0.004 0.996
#> GSM246423     2  0.1633      0.955 0.024 0.976
#> GSM246484     2  0.0000      0.975 0.000 1.000
#> GSM246485     2  0.0000      0.975 0.000 1.000
#> GSM246486     2  0.0000      0.975 0.000 1.000
#> GSM246487     2  0.0000      0.975 0.000 1.000
#> GSM246488     2  0.0000      0.975 0.000 1.000
#> GSM246489     2  0.0000      0.975 0.000 1.000
#> GSM246490     2  0.0000      0.975 0.000 1.000
#> GSM246491     2  0.0000      0.975 0.000 1.000
#> GSM247162     2  0.0000      0.975 0.000 1.000
#> GSM247163     2  0.0000      0.975 0.000 1.000
#> GSM247164     2  0.0000      0.975 0.000 1.000
#> GSM247165     2  0.0000      0.975 0.000 1.000
#> GSM247166     2  0.0000      0.975 0.000 1.000
#> GSM247168     2  0.0000      0.975 0.000 1.000
#> GSM247169     2  0.0000      0.975 0.000 1.000
#> GSM247171     2  0.0000      0.975 0.000 1.000
#> GSM247173     2  0.0000      0.975 0.000 1.000
#> GSM247174     2  0.0000      0.975 0.000 1.000
#> GSM247175     2  0.0000      0.975 0.000 1.000
#> GSM247188     2  0.0000      0.975 0.000 1.000
#> GSM247189     2  0.0000      0.975 0.000 1.000
#> GSM247190     2  0.0000      0.975 0.000 1.000
#> GSM247650     1  0.0000      0.996 1.000 0.000
#> GSM247651     1  0.1633      0.978 0.976 0.024
#> GSM247652     1  0.0000      0.996 1.000 0.000
#> GSM247653     1  0.0000      0.996 1.000 0.000
#> GSM247654     1  0.0000      0.996 1.000 0.000
#> GSM247655     1  0.0000      0.996 1.000 0.000
#> GSM247656     1  0.0000      0.996 1.000 0.000
#> GSM247657     1  0.0000      0.996 1.000 0.000
#> GSM247658     1  0.0000      0.996 1.000 0.000
#> GSM247659     1  0.0000      0.996 1.000 0.000
#> GSM247660     1  0.1184      0.984 0.984 0.016
#> GSM247661     1  0.0000      0.996 1.000 0.000
#> GSM247662     1  0.0000      0.996 1.000 0.000
#> GSM247663     1  0.0000      0.996 1.000 0.000
#> GSM247856     1  0.0000      0.996 1.000 0.000
#> GSM247857     1  0.0000      0.996 1.000 0.000
#> GSM247859     1  0.2043      0.970 0.968 0.032
#> GSM247860     1  0.0000      0.996 1.000 0.000
#> GSM247862     1  0.0000      0.996 1.000 0.000
#> GSM247864     1  0.0000      0.996 1.000 0.000
#> GSM247865     2  0.7674      0.714 0.224 0.776
#> GSM247866     1  0.0376      0.993 0.996 0.004
#> GSM247876     1  0.0000      0.996 1.000 0.000
#> GSM247877     1  0.1633      0.978 0.976 0.024
#> GSM247878     1  0.1633      0.978 0.976 0.024
#> GSM247879     1  0.0000      0.996 1.000 0.000
#> GSM247881     1  0.0000      0.996 1.000 0.000
#> GSM247883     2  0.9460      0.443 0.364 0.636

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246088     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246089     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246090     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246119     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246120     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246121     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246122     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246123     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM246422     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM246423     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM246484     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM246485     2  0.2537     0.9150 0.080 0.920 0.000
#> GSM246486     2  0.3482     0.8660 0.128 0.872 0.000
#> GSM246487     1  0.0237     0.8987 0.996 0.004 0.000
#> GSM246488     2  0.4235     0.8136 0.176 0.824 0.000
#> GSM246489     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM246490     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM246491     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247162     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247163     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247164     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247165     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247166     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247168     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247169     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247171     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247173     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247174     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247175     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247188     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247189     2  0.0424     0.9733 0.008 0.992 0.000
#> GSM247190     2  0.0000     0.9787 0.000 1.000 0.000
#> GSM247650     1  0.5678     0.5455 0.684 0.000 0.316
#> GSM247651     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247652     1  0.4399     0.7424 0.812 0.000 0.188
#> GSM247653     3  0.5529     0.5630 0.296 0.000 0.704
#> GSM247654     3  0.6252     0.1621 0.444 0.000 0.556
#> GSM247655     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247656     3  0.0592     0.8905 0.012 0.000 0.988
#> GSM247657     3  0.5835     0.4730 0.340 0.000 0.660
#> GSM247658     1  0.1289     0.8833 0.968 0.000 0.032
#> GSM247659     3  0.0000     0.8961 0.000 0.000 1.000
#> GSM247660     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247661     3  0.1860     0.8631 0.052 0.000 0.948
#> GSM247662     3  0.0237     0.8946 0.004 0.000 0.996
#> GSM247663     1  0.3941     0.7793 0.844 0.000 0.156
#> GSM247856     1  0.6295     0.0924 0.528 0.000 0.472
#> GSM247857     3  0.5291     0.6131 0.268 0.000 0.732
#> GSM247859     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247860     1  0.5882     0.4805 0.652 0.000 0.348
#> GSM247862     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247864     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247865     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247866     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247876     1  0.2261     0.8582 0.932 0.000 0.068
#> GSM247877     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247878     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247879     1  0.5905     0.4674 0.648 0.000 0.352
#> GSM247881     1  0.0000     0.9016 1.000 0.000 0.000
#> GSM247883     1  0.0000     0.9016 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
#> GSM246087     3  0.0336      0.976 0.008 0.000 0.992 0.000
#> GSM246088     3  0.0336      0.976 0.008 0.000 0.992 0.000
#> GSM246089     3  0.0469      0.968 0.000 0.000 0.988 0.012
#> GSM246090     3  0.0336      0.976 0.008 0.000 0.992 0.000
#> GSM246119     3  0.0188      0.976 0.004 0.000 0.996 0.000
#> GSM246120     3  0.0336      0.972 0.000 0.000 0.992 0.008
#> GSM246121     3  0.0188      0.976 0.004 0.000 0.996 0.000
#> GSM246122     3  0.0336      0.976 0.008 0.000 0.992 0.000
#> GSM246123     3  0.0336      0.972 0.000 0.000 0.992 0.008
#> GSM246422     4  0.0188      0.830 0.000 0.000 0.004 0.996
#> GSM246423     4  0.0000      0.831 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000      0.831 0.000 0.000 0.000 1.000
#> GSM246485     2  0.1716      0.912 0.000 0.936 0.000 0.064
#> GSM246486     2  0.4500      0.498 0.000 0.684 0.000 0.316
#> GSM246487     4  0.7123      0.140 0.416 0.112 0.004 0.468
#> GSM246488     4  0.2469      0.779 0.000 0.108 0.000 0.892
#> GSM246489     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0188      0.972 0.000 0.996 0.000 0.004
#> GSM247166     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247189     4  0.4543      0.484 0.000 0.324 0.000 0.676
#> GSM247190     2  0.0000      0.975 0.000 1.000 0.000 0.000
#> GSM247650     1  0.1004      0.946 0.972 0.000 0.024 0.004
#> GSM247651     1  0.4155      0.698 0.756 0.000 0.004 0.240
#> GSM247652     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247653     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247654     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247655     1  0.1305      0.934 0.960 0.000 0.004 0.036
#> GSM247656     1  0.3172      0.814 0.840 0.000 0.160 0.000
#> GSM247657     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247658     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247659     3  0.2647      0.834 0.120 0.000 0.880 0.000
#> GSM247660     1  0.2593      0.879 0.892 0.000 0.004 0.104
#> GSM247661     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247662     1  0.3975      0.706 0.760 0.000 0.240 0.000
#> GSM247663     1  0.1297      0.946 0.964 0.000 0.020 0.016
#> GSM247856     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247857     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247859     1  0.0524      0.947 0.988 0.000 0.004 0.008
#> GSM247860     1  0.0469      0.951 0.988 0.000 0.012 0.000
#> GSM247862     1  0.0000      0.949 1.000 0.000 0.000 0.000
#> GSM247864     1  0.1661      0.924 0.944 0.000 0.004 0.052
#> GSM247865     1  0.1209      0.936 0.964 0.000 0.004 0.032
#> GSM247866     1  0.0895      0.942 0.976 0.000 0.004 0.020
#> GSM247876     1  0.1388      0.944 0.960 0.000 0.012 0.028
#> GSM247877     4  0.0707      0.824 0.000 0.000 0.020 0.980
#> GSM247878     4  0.0469      0.828 0.012 0.000 0.000 0.988
#> GSM247879     4  0.3498      0.705 0.008 0.000 0.160 0.832
#> GSM247881     1  0.0188      0.950 0.996 0.000 0.004 0.000
#> GSM247883     1  0.0524      0.946 0.988 0.000 0.004 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
#> GSM246087     3  0.0290     0.8062 0.000 0.000 0.992 0.000 0.008
#> GSM246088     3  0.0000     0.8080 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.4300     0.0892 0.000 0.000 0.524 0.000 0.476
#> GSM246090     3  0.0404     0.8079 0.000 0.000 0.988 0.000 0.012
#> GSM246119     3  0.1732     0.8004 0.000 0.000 0.920 0.000 0.080
#> GSM246120     3  0.1831     0.8005 0.000 0.000 0.920 0.004 0.076
#> GSM246121     3  0.2179     0.7818 0.000 0.000 0.888 0.000 0.112
#> GSM246122     3  0.0609     0.8011 0.000 0.000 0.980 0.000 0.020
#> GSM246123     3  0.2011     0.7973 0.000 0.000 0.908 0.004 0.088
#> GSM246422     4  0.0000     0.6497 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0290     0.6484 0.000 0.000 0.000 0.992 0.008
#> GSM246484     4  0.0510     0.6465 0.000 0.000 0.000 0.984 0.016
#> GSM246485     2  0.3640     0.8114 0.008 0.836 0.000 0.084 0.072
#> GSM246486     2  0.3762     0.6477 0.004 0.748 0.000 0.244 0.004
#> GSM246487     4  0.6471     0.2540 0.256 0.124 0.000 0.584 0.036
#> GSM246488     4  0.2172     0.6134 0.000 0.076 0.000 0.908 0.016
#> GSM246489     2  0.0000     0.9687 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0162     0.9691 0.000 0.996 0.000 0.000 0.004
#> GSM246491     2  0.0162     0.9679 0.000 0.996 0.000 0.000 0.004
#> GSM247162     2  0.0162     0.9691 0.000 0.996 0.000 0.000 0.004
#> GSM247163     2  0.0451     0.9634 0.000 0.988 0.000 0.008 0.004
#> GSM247164     2  0.0290     0.9682 0.000 0.992 0.000 0.000 0.008
#> GSM247165     2  0.0162     0.9681 0.000 0.996 0.000 0.000 0.004
#> GSM247166     2  0.0000     0.9687 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0162     0.9682 0.000 0.996 0.000 0.000 0.004
#> GSM247169     2  0.0000     0.9687 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0609     0.9633 0.000 0.980 0.000 0.000 0.020
#> GSM247173     2  0.0162     0.9691 0.000 0.996 0.000 0.000 0.004
#> GSM247174     2  0.0162     0.9691 0.000 0.996 0.000 0.000 0.004
#> GSM247175     2  0.0162     0.9691 0.000 0.996 0.000 0.000 0.004
#> GSM247188     2  0.0510     0.9647 0.000 0.984 0.000 0.000 0.016
#> GSM247189     4  0.5810     0.1490 0.000 0.428 0.000 0.480 0.092
#> GSM247190     2  0.0404     0.9666 0.000 0.988 0.000 0.000 0.012
#> GSM247650     1  0.2395     0.8641 0.912 0.000 0.036 0.012 0.040
#> GSM247651     1  0.3849     0.6858 0.752 0.000 0.000 0.232 0.016
#> GSM247652     1  0.1205     0.8668 0.956 0.000 0.004 0.000 0.040
#> GSM247653     1  0.2127     0.8582 0.892 0.000 0.000 0.000 0.108
#> GSM247654     1  0.1124     0.8729 0.960 0.000 0.004 0.000 0.036
#> GSM247655     1  0.1403     0.8733 0.952 0.000 0.000 0.024 0.024
#> GSM247656     1  0.5246     0.2840 0.564 0.000 0.384 0.000 0.052
#> GSM247657     1  0.1952     0.8684 0.912 0.000 0.004 0.000 0.084
#> GSM247658     1  0.1043     0.8694 0.960 0.000 0.000 0.000 0.040
#> GSM247659     3  0.4360     0.5915 0.064 0.000 0.752 0.000 0.184
#> GSM247660     1  0.3169     0.8481 0.856 0.000 0.000 0.084 0.060
#> GSM247661     1  0.2338     0.8602 0.884 0.000 0.004 0.000 0.112
#> GSM247662     3  0.6128     0.2552 0.252 0.000 0.560 0.000 0.188
#> GSM247663     1  0.1357     0.8696 0.948 0.000 0.000 0.004 0.048
#> GSM247856     1  0.1618     0.8673 0.944 0.000 0.008 0.008 0.040
#> GSM247857     1  0.3649     0.8079 0.808 0.000 0.040 0.000 0.152
#> GSM247859     1  0.1331     0.8665 0.952 0.000 0.000 0.008 0.040
#> GSM247860     1  0.4030     0.5729 0.648 0.000 0.000 0.000 0.352
#> GSM247862     1  0.1956     0.8668 0.916 0.000 0.000 0.008 0.076
#> GSM247864     1  0.2446     0.8661 0.900 0.000 0.000 0.044 0.056
#> GSM247865     1  0.3176     0.8219 0.856 0.000 0.000 0.080 0.064
#> GSM247866     1  0.3366     0.7548 0.768 0.000 0.000 0.000 0.232
#> GSM247876     1  0.4134     0.6587 0.704 0.000 0.008 0.004 0.284
#> GSM247877     4  0.4490     0.0121 0.004 0.000 0.004 0.588 0.404
#> GSM247878     4  0.2017     0.6069 0.008 0.000 0.000 0.912 0.080
#> GSM247879     5  0.4558     0.0000 0.028 0.000 0.056 0.140 0.776
#> GSM247881     1  0.1671     0.8691 0.924 0.000 0.000 0.000 0.076
#> GSM247883     1  0.1331     0.8671 0.952 0.000 0.000 0.008 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
#> GSM246087     3  0.0891     0.7629 0.000 0.000 0.968 0.000 0.008 NA
#> GSM246088     3  0.0520     0.7664 0.000 0.000 0.984 0.000 0.008 NA
#> GSM246089     3  0.6109     0.0706 0.000 0.000 0.356 0.000 0.292 NA
#> GSM246090     3  0.0717     0.7651 0.000 0.000 0.976 0.000 0.008 NA
#> GSM246119     3  0.2134     0.7510 0.000 0.000 0.904 0.000 0.044 NA
#> GSM246120     3  0.2066     0.7520 0.000 0.000 0.908 0.000 0.040 NA
#> GSM246121     3  0.3663     0.6795 0.000 0.000 0.784 0.000 0.068 NA
#> GSM246122     3  0.0909     0.7669 0.000 0.000 0.968 0.000 0.012 NA
#> GSM246123     3  0.1418     0.7617 0.000 0.000 0.944 0.000 0.032 NA
#> GSM246422     4  0.0622     0.6584 0.000 0.000 0.000 0.980 0.012 NA
#> GSM246423     4  0.0551     0.6559 0.004 0.000 0.000 0.984 0.008 NA
#> GSM246484     4  0.0547     0.6561 0.000 0.000 0.000 0.980 0.020 NA
#> GSM246485     4  0.6991     0.2690 0.004 0.288 0.000 0.372 0.048 NA
#> GSM246486     2  0.4315    -0.1270 0.000 0.496 0.000 0.488 0.004 NA
#> GSM246487     4  0.5929     0.3952 0.216 0.084 0.000 0.624 0.012 NA
#> GSM246488     4  0.1398     0.6557 0.000 0.052 0.000 0.940 0.000 NA
#> GSM246489     2  0.0000     0.9438 0.000 1.000 0.000 0.000 0.000 NA
#> GSM246490     2  0.0260     0.9428 0.000 0.992 0.000 0.000 0.000 NA
#> GSM246491     2  0.0363     0.9419 0.000 0.988 0.000 0.000 0.000 NA
#> GSM247162     2  0.0000     0.9438 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247163     2  0.0291     0.9432 0.000 0.992 0.000 0.004 0.000 NA
#> GSM247164     2  0.0260     0.9421 0.000 0.992 0.000 0.008 0.000 NA
#> GSM247165     2  0.0547     0.9353 0.000 0.980 0.000 0.020 0.000 NA
#> GSM247166     2  0.1444     0.9110 0.000 0.928 0.000 0.000 0.000 NA
#> GSM247168     2  0.1501     0.9083 0.000 0.924 0.000 0.000 0.000 NA
#> GSM247169     2  0.1444     0.9115 0.000 0.928 0.000 0.000 0.000 NA
#> GSM247171     2  0.0551     0.9394 0.000 0.984 0.000 0.008 0.004 NA
#> GSM247173     2  0.0405     0.9431 0.000 0.988 0.000 0.004 0.000 NA
#> GSM247174     2  0.0790     0.9335 0.000 0.968 0.000 0.000 0.000 NA
#> GSM247175     2  0.0000     0.9438 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247188     2  0.0146     0.9438 0.000 0.996 0.000 0.000 0.000 NA
#> GSM247189     4  0.5650     0.3640 0.000 0.300 0.000 0.564 0.116 NA
#> GSM247190     2  0.0000     0.9438 0.000 1.000 0.000 0.000 0.000 NA
#> GSM247650     1  0.5939     0.3757 0.608 0.000 0.248 0.016 0.076 NA
#> GSM247651     1  0.4071     0.5603 0.716 0.000 0.000 0.248 0.020 NA
#> GSM247652     1  0.1858     0.7399 0.924 0.000 0.000 0.012 0.012 NA
#> GSM247653     1  0.4668     0.6433 0.620 0.000 0.000 0.000 0.064 NA
#> GSM247654     1  0.3374     0.7251 0.772 0.000 0.000 0.000 0.020 NA
#> GSM247655     1  0.1983     0.7434 0.916 0.000 0.000 0.012 0.012 NA
#> GSM247656     3  0.5201     0.2947 0.368 0.000 0.548 0.000 0.008 NA
#> GSM247657     1  0.4002     0.7141 0.704 0.000 0.000 0.000 0.036 NA
#> GSM247658     1  0.1958     0.7400 0.896 0.000 0.000 0.000 0.004 NA
#> GSM247659     3  0.5854     0.4650 0.020 0.004 0.588 0.000 0.192 NA
#> GSM247660     1  0.4805     0.6883 0.700 0.000 0.000 0.144 0.012 NA
#> GSM247661     1  0.4648     0.6438 0.604 0.000 0.000 0.000 0.056 NA
#> GSM247662     3  0.6045     0.4679 0.096 0.000 0.600 0.000 0.096 NA
#> GSM247663     1  0.1844     0.7299 0.932 0.000 0.012 0.004 0.028 NA
#> GSM247856     1  0.1722     0.7291 0.936 0.000 0.004 0.016 0.008 NA
#> GSM247857     1  0.6727     0.3863 0.500 0.000 0.152 0.000 0.096 NA
#> GSM247859     1  0.1577     0.7378 0.940 0.000 0.000 0.016 0.008 NA
#> GSM247860     1  0.5616     0.4569 0.492 0.000 0.000 0.000 0.156 NA
#> GSM247862     1  0.3909     0.7077 0.720 0.000 0.000 0.000 0.036 NA
#> GSM247864     1  0.4061     0.7110 0.792 0.000 0.000 0.052 0.052 NA
#> GSM247865     1  0.3465     0.6745 0.828 0.000 0.000 0.096 0.020 NA
#> GSM247866     1  0.5186     0.6106 0.616 0.000 0.000 0.000 0.216 NA
#> GSM247876     5  0.5249     0.0803 0.412 0.000 0.008 0.020 0.524 NA
#> GSM247877     5  0.4092     0.2170 0.000 0.000 0.000 0.344 0.636 NA
#> GSM247878     4  0.3658     0.4574 0.028 0.000 0.000 0.772 0.192 NA
#> GSM247879     5  0.2848     0.4650 0.016 0.000 0.024 0.064 0.880 NA
#> GSM247881     1  0.4525     0.6341 0.724 0.000 0.008 0.000 0.140 NA
#> GSM247883     1  0.1655     0.7259 0.932 0.000 0.000 0.008 0.008 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-MAD-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-MAD-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-MAD-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-MAD-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-MAD-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> MAD:NMF 60         6.78e-13 2
#> MAD:NMF 56         2.12e-13 3
#> MAD:NMF 58         2.45e-19 4
#> MAD:NMF 54         1.53e-18 5
#> MAD:NMF 46         1.16e-17 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 21168 rows and 61 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 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 ATC-hclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-hclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.508           0.926       0.909         0.3690 0.607   0.607
#> 3 3 0.725           0.935       0.933         0.5653 0.823   0.708
#> 4 4 0.962           0.934       0.974         0.2409 0.843   0.634
#> 5 5 0.904           0.820       0.936         0.0272 0.989   0.960
#> 6 6 0.892           0.803       0.916         0.0244 0.961   0.863

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     1   0.000      0.778 1.000 0.000
#> GSM246088     1   0.000      0.778 1.000 0.000
#> GSM246089     1   0.000      0.778 1.000 0.000
#> GSM246090     1   0.000      0.778 1.000 0.000
#> GSM246119     1   0.000      0.778 1.000 0.000
#> GSM246120     1   0.000      0.778 1.000 0.000
#> GSM246121     1   0.000      0.778 1.000 0.000
#> GSM246122     1   0.000      0.778 1.000 0.000
#> GSM246123     1   0.000      0.778 1.000 0.000
#> GSM246422     1   0.802      0.913 0.756 0.244
#> GSM246423     1   0.802      0.913 0.756 0.244
#> GSM246484     1   0.802      0.913 0.756 0.244
#> GSM246485     1   0.802      0.913 0.756 0.244
#> GSM246486     1   0.802      0.913 0.756 0.244
#> GSM246487     1   0.802      0.913 0.756 0.244
#> GSM246488     1   0.802      0.913 0.756 0.244
#> GSM246489     2   0.000      1.000 0.000 1.000
#> GSM246490     2   0.000      1.000 0.000 1.000
#> GSM246491     2   0.000      1.000 0.000 1.000
#> GSM247162     2   0.000      1.000 0.000 1.000
#> GSM247163     2   0.000      1.000 0.000 1.000
#> GSM247164     2   0.000      1.000 0.000 1.000
#> GSM247165     2   0.000      1.000 0.000 1.000
#> GSM247166     2   0.000      1.000 0.000 1.000
#> GSM247168     2   0.000      1.000 0.000 1.000
#> GSM247169     2   0.000      1.000 0.000 1.000
#> GSM247171     2   0.000      1.000 0.000 1.000
#> GSM247173     2   0.000      1.000 0.000 1.000
#> GSM247174     2   0.000      1.000 0.000 1.000
#> GSM247175     2   0.000      1.000 0.000 1.000
#> GSM247188     2   0.000      1.000 0.000 1.000
#> GSM247189     1   0.802      0.913 0.756 0.244
#> GSM247190     2   0.000      1.000 0.000 1.000
#> GSM247650     1   0.738      0.936 0.792 0.208
#> GSM247651     1   0.738      0.936 0.792 0.208
#> GSM247652     1   0.738      0.936 0.792 0.208
#> GSM247653     1   0.738      0.936 0.792 0.208
#> GSM247654     1   0.738      0.936 0.792 0.208
#> GSM247655     1   0.738      0.936 0.792 0.208
#> GSM247656     1   0.738      0.936 0.792 0.208
#> GSM247657     1   0.738      0.936 0.792 0.208
#> GSM247658     1   0.738      0.936 0.792 0.208
#> GSM247659     1   0.738      0.936 0.792 0.208
#> GSM247660     1   0.738      0.936 0.792 0.208
#> GSM247661     1   0.738      0.936 0.792 0.208
#> GSM247662     1   0.738      0.936 0.792 0.208
#> GSM247663     1   0.738      0.936 0.792 0.208
#> GSM247856     1   0.738      0.936 0.792 0.208
#> GSM247857     1   0.738      0.936 0.792 0.208
#> GSM247859     1   0.738      0.936 0.792 0.208
#> GSM247860     1   0.738      0.936 0.792 0.208
#> GSM247862     1   0.738      0.936 0.792 0.208
#> GSM247864     1   0.738      0.936 0.792 0.208
#> GSM247865     1   0.788      0.919 0.764 0.236
#> GSM247866     1   0.738      0.936 0.792 0.208
#> GSM247876     1   0.738      0.936 0.792 0.208
#> GSM247877     1   0.738      0.936 0.792 0.208
#> GSM247878     1   0.738      0.936 0.792 0.208
#> GSM247879     1   0.738      0.936 0.792 0.208
#> GSM247881     1   0.738      0.936 0.792 0.208
#> GSM247883     1   0.788      0.919 0.764 0.236

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM246087     3   0.455      1.000 0.200  0 0.800
#> GSM246088     3   0.455      1.000 0.200  0 0.800
#> GSM246089     3   0.455      1.000 0.200  0 0.800
#> GSM246090     3   0.455      1.000 0.200  0 0.800
#> GSM246119     3   0.455      1.000 0.200  0 0.800
#> GSM246120     3   0.455      1.000 0.200  0 0.800
#> GSM246121     3   0.455      1.000 0.200  0 0.800
#> GSM246122     3   0.455      1.000 0.200  0 0.800
#> GSM246123     3   0.455      1.000 0.200  0 0.800
#> GSM246422     1   0.455      0.830 0.800  0 0.200
#> GSM246423     1   0.455      0.830 0.800  0 0.200
#> GSM246484     1   0.455      0.830 0.800  0 0.200
#> GSM246485     1   0.455      0.830 0.800  0 0.200
#> GSM246486     1   0.455      0.830 0.800  0 0.200
#> GSM246487     1   0.455      0.830 0.800  0 0.200
#> GSM246488     1   0.455      0.830 0.800  0 0.200
#> GSM246489     2   0.000      1.000 0.000  1 0.000
#> GSM246490     2   0.000      1.000 0.000  1 0.000
#> GSM246491     2   0.000      1.000 0.000  1 0.000
#> GSM247162     2   0.000      1.000 0.000  1 0.000
#> GSM247163     2   0.000      1.000 0.000  1 0.000
#> GSM247164     2   0.000      1.000 0.000  1 0.000
#> GSM247165     2   0.000      1.000 0.000  1 0.000
#> GSM247166     2   0.000      1.000 0.000  1 0.000
#> GSM247168     2   0.000      1.000 0.000  1 0.000
#> GSM247169     2   0.000      1.000 0.000  1 0.000
#> GSM247171     2   0.000      1.000 0.000  1 0.000
#> GSM247173     2   0.000      1.000 0.000  1 0.000
#> GSM247174     2   0.000      1.000 0.000  1 0.000
#> GSM247175     2   0.000      1.000 0.000  1 0.000
#> GSM247188     2   0.000      1.000 0.000  1 0.000
#> GSM247189     1   0.455      0.830 0.800  0 0.200
#> GSM247190     2   0.000      1.000 0.000  1 0.000
#> GSM247650     1   0.000      0.919 1.000  0 0.000
#> GSM247651     1   0.000      0.919 1.000  0 0.000
#> GSM247652     1   0.000      0.919 1.000  0 0.000
#> GSM247653     1   0.000      0.919 1.000  0 0.000
#> GSM247654     1   0.000      0.919 1.000  0 0.000
#> GSM247655     1   0.000      0.919 1.000  0 0.000
#> GSM247656     1   0.000      0.919 1.000  0 0.000
#> GSM247657     1   0.000      0.919 1.000  0 0.000
#> GSM247658     1   0.000      0.919 1.000  0 0.000
#> GSM247659     1   0.000      0.919 1.000  0 0.000
#> GSM247660     1   0.000      0.919 1.000  0 0.000
#> GSM247661     1   0.000      0.919 1.000  0 0.000
#> GSM247662     1   0.000      0.919 1.000  0 0.000
#> GSM247663     1   0.000      0.919 1.000  0 0.000
#> GSM247856     1   0.000      0.919 1.000  0 0.000
#> GSM247857     1   0.000      0.919 1.000  0 0.000
#> GSM247859     1   0.000      0.919 1.000  0 0.000
#> GSM247860     1   0.000      0.919 1.000  0 0.000
#> GSM247862     1   0.000      0.919 1.000  0 0.000
#> GSM247864     1   0.000      0.919 1.000  0 0.000
#> GSM247865     1   0.445      0.834 0.808  0 0.192
#> GSM247866     1   0.000      0.919 1.000  0 0.000
#> GSM247876     1   0.000      0.919 1.000  0 0.000
#> GSM247877     1   0.406      0.848 0.836  0 0.164
#> GSM247878     1   0.406      0.848 0.836  0 0.164
#> GSM247879     1   0.000      0.919 1.000  0 0.000
#> GSM247881     1   0.000      0.919 1.000  0 0.000
#> GSM247883     1   0.445      0.834 0.808  0 0.192

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2 p3    p4
#> GSM246087     3   0.000      1.000 0.000  0  1 0.000
#> GSM246088     3   0.000      1.000 0.000  0  1 0.000
#> GSM246089     3   0.000      1.000 0.000  0  1 0.000
#> GSM246090     3   0.000      1.000 0.000  0  1 0.000
#> GSM246119     3   0.000      1.000 0.000  0  1 0.000
#> GSM246120     3   0.000      1.000 0.000  0  1 0.000
#> GSM246121     3   0.000      1.000 0.000  0  1 0.000
#> GSM246122     3   0.000      1.000 0.000  0  1 0.000
#> GSM246123     3   0.000      1.000 0.000  0  1 0.000
#> GSM246422     4   0.000      0.816 0.000  0  0 1.000
#> GSM246423     4   0.000      0.816 0.000  0  0 1.000
#> GSM246484     4   0.000      0.816 0.000  0  0 1.000
#> GSM246485     4   0.000      0.816 0.000  0  0 1.000
#> GSM246486     4   0.000      0.816 0.000  0  0 1.000
#> GSM246487     4   0.000      0.816 0.000  0  0 1.000
#> GSM246488     4   0.000      0.816 0.000  0  0 1.000
#> GSM246489     2   0.000      1.000 0.000  1  0 0.000
#> GSM246490     2   0.000      1.000 0.000  1  0 0.000
#> GSM246491     2   0.000      1.000 0.000  1  0 0.000
#> GSM247162     2   0.000      1.000 0.000  1  0 0.000
#> GSM247163     2   0.000      1.000 0.000  1  0 0.000
#> GSM247164     2   0.000      1.000 0.000  1  0 0.000
#> GSM247165     2   0.000      1.000 0.000  1  0 0.000
#> GSM247166     2   0.000      1.000 0.000  1  0 0.000
#> GSM247168     2   0.000      1.000 0.000  1  0 0.000
#> GSM247169     2   0.000      1.000 0.000  1  0 0.000
#> GSM247171     2   0.000      1.000 0.000  1  0 0.000
#> GSM247173     2   0.000      1.000 0.000  1  0 0.000
#> GSM247174     2   0.000      1.000 0.000  1  0 0.000
#> GSM247175     2   0.000      1.000 0.000  1  0 0.000
#> GSM247188     2   0.000      1.000 0.000  1  0 0.000
#> GSM247189     4   0.000      0.816 0.000  0  0 1.000
#> GSM247190     2   0.000      1.000 0.000  1  0 0.000
#> GSM247650     1   0.000      0.995 1.000  0  0 0.000
#> GSM247651     1   0.000      0.995 1.000  0  0 0.000
#> GSM247652     1   0.000      0.995 1.000  0  0 0.000
#> GSM247653     1   0.000      0.995 1.000  0  0 0.000
#> GSM247654     1   0.000      0.995 1.000  0  0 0.000
#> GSM247655     1   0.000      0.995 1.000  0  0 0.000
#> GSM247656     1   0.000      0.995 1.000  0  0 0.000
#> GSM247657     1   0.000      0.995 1.000  0  0 0.000
#> GSM247658     1   0.000      0.995 1.000  0  0 0.000
#> GSM247659     1   0.000      0.995 1.000  0  0 0.000
#> GSM247660     1   0.000      0.995 1.000  0  0 0.000
#> GSM247661     1   0.000      0.995 1.000  0  0 0.000
#> GSM247662     1   0.000      0.995 1.000  0  0 0.000
#> GSM247663     1   0.000      0.995 1.000  0  0 0.000
#> GSM247856     1   0.000      0.995 1.000  0  0 0.000
#> GSM247857     1   0.000      0.995 1.000  0  0 0.000
#> GSM247859     1   0.234      0.867 0.900  0  0 0.100
#> GSM247860     1   0.000      0.995 1.000  0  0 0.000
#> GSM247862     1   0.000      0.995 1.000  0  0 0.000
#> GSM247864     1   0.000      0.995 1.000  0  0 0.000
#> GSM247865     4   0.492      0.381 0.428  0  0 0.572
#> GSM247866     1   0.000      0.995 1.000  0  0 0.000
#> GSM247876     1   0.000      0.995 1.000  0  0 0.000
#> GSM247877     4   0.499      0.256 0.472  0  0 0.528
#> GSM247878     4   0.336      0.712 0.176  0  0 0.824
#> GSM247879     1   0.000      0.995 1.000  0  0 0.000
#> GSM247881     1   0.000      0.995 1.000  0  0 0.000
#> GSM247883     4   0.492      0.381 0.428  0  0 0.572

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2    p3    p4    p5
#> GSM246087     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246088     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246089     3   0.393     0.6685 0.000  0 0.672 0.000 0.328
#> GSM246090     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246119     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246120     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246121     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246122     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246123     3   0.000     0.9654 0.000  0 1.000 0.000 0.000
#> GSM246422     4   0.415    -0.0313 0.000  0 0.000 0.612 0.388
#> GSM246423     4   0.415    -0.0313 0.000  0 0.000 0.612 0.388
#> GSM246484     4   0.415    -0.0313 0.000  0 0.000 0.612 0.388
#> GSM246485     4   0.000     0.4843 0.000  0 0.000 1.000 0.000
#> GSM246486     4   0.000     0.4843 0.000  0 0.000 1.000 0.000
#> GSM246487     4   0.000     0.4843 0.000  0 0.000 1.000 0.000
#> GSM246488     4   0.000     0.4843 0.000  0 0.000 1.000 0.000
#> GSM246489     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM246490     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM246491     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247162     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247163     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247164     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247165     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247166     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247168     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247169     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247171     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247173     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247174     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247175     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247188     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247189     4   0.277     0.3402 0.000  0 0.000 0.836 0.164
#> GSM247190     2   0.000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM247650     1   0.088     0.9614 0.968  0 0.000 0.000 0.032
#> GSM247651     1   0.051     0.9706 0.984  0 0.000 0.000 0.016
#> GSM247652     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247653     1   0.029     0.9727 0.992  0 0.000 0.000 0.008
#> GSM247654     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247655     1   0.051     0.9706 0.984  0 0.000 0.000 0.016
#> GSM247656     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247657     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247658     1   0.029     0.9723 0.992  0 0.000 0.000 0.008
#> GSM247659     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247660     1   0.051     0.9706 0.984  0 0.000 0.000 0.016
#> GSM247661     1   0.029     0.9727 0.992  0 0.000 0.000 0.008
#> GSM247662     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247663     1   0.167     0.9234 0.924  0 0.000 0.000 0.076
#> GSM247856     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247857     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247859     1   0.202     0.8620 0.900  0 0.000 0.100 0.000
#> GSM247860     1   0.029     0.9727 0.992  0 0.000 0.000 0.008
#> GSM247862     1   0.051     0.9706 0.984  0 0.000 0.000 0.016
#> GSM247864     1   0.051     0.9706 0.984  0 0.000 0.000 0.016
#> GSM247865     4   0.424     0.0552 0.428  0 0.000 0.572 0.000
#> GSM247866     1   0.029     0.9727 0.992  0 0.000 0.000 0.008
#> GSM247876     1   0.173     0.9194 0.920  0 0.000 0.000 0.080
#> GSM247877     5   0.532     0.3638 0.188  0 0.000 0.140 0.672
#> GSM247878     5   0.426     0.0730 0.000  0 0.000 0.436 0.564
#> GSM247879     1   0.300     0.7900 0.812  0 0.000 0.000 0.188
#> GSM247881     1   0.000     0.9728 1.000  0 0.000 0.000 0.000
#> GSM247883     4   0.424     0.0552 0.428  0 0.000 0.572 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
#> GSM246087     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246089     6  0.3309      0.000 0.000  0 0.28 0.000 0.000 0.720
#> GSM246090     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000  0 1.00 0.000 0.000 0.000
#> GSM246422     4  0.3050      0.376 0.000  0 0.00 0.764 0.236 0.000
#> GSM246423     4  0.3050      0.376 0.000  0 0.00 0.764 0.236 0.000
#> GSM246484     4  0.3050      0.376 0.000  0 0.00 0.764 0.236 0.000
#> GSM246485     4  0.2730      0.674 0.000  0 0.00 0.808 0.000 0.192
#> GSM246486     4  0.2730      0.674 0.000  0 0.00 0.808 0.000 0.192
#> GSM246487     4  0.2730      0.674 0.000  0 0.00 0.808 0.000 0.192
#> GSM246488     4  0.2730      0.674 0.000  0 0.00 0.808 0.000 0.192
#> GSM246489     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM246490     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM246491     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247162     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247163     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247164     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247165     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247166     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247168     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247169     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247171     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247173     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247174     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247175     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247188     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247189     4  0.0000      0.600 0.000  0 0.00 1.000 0.000 0.000
#> GSM247190     2  0.0000      1.000 0.000  1 0.00 0.000 0.000 0.000
#> GSM247650     1  0.1261      0.873 0.952  0 0.00 0.000 0.024 0.024
#> GSM247651     1  0.0909      0.878 0.968  0 0.00 0.000 0.012 0.020
#> GSM247652     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247653     1  0.3276      0.779 0.816  0 0.00 0.000 0.132 0.052
#> GSM247654     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247655     1  0.0909      0.878 0.968  0 0.00 0.000 0.012 0.020
#> GSM247656     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247657     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247658     1  0.0405      0.881 0.988  0 0.00 0.000 0.008 0.004
#> GSM247659     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247660     1  0.0909      0.878 0.968  0 0.00 0.000 0.012 0.020
#> GSM247661     1  0.3276      0.779 0.816  0 0.00 0.000 0.132 0.052
#> GSM247662     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247663     1  0.2376      0.835 0.888  0 0.00 0.000 0.068 0.044
#> GSM247856     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247859     1  0.1814      0.820 0.900  0 0.00 0.100 0.000 0.000
#> GSM247860     1  0.3276      0.779 0.816  0 0.00 0.000 0.132 0.052
#> GSM247862     1  0.0909      0.878 0.968  0 0.00 0.000 0.012 0.020
#> GSM247864     1  0.0909      0.878 0.968  0 0.00 0.000 0.012 0.020
#> GSM247865     1  0.5848     -0.137 0.428  0 0.00 0.380 0.000 0.192
#> GSM247866     1  0.3276      0.779 0.816  0 0.00 0.000 0.132 0.052
#> GSM247876     1  0.2433      0.832 0.884  0 0.00 0.000 0.072 0.044
#> GSM247877     5  0.2278      0.485 0.004  0 0.00 0.128 0.868 0.000
#> GSM247878     5  0.3804      0.221 0.000  0 0.00 0.424 0.576 0.000
#> GSM247879     1  0.4552      0.437 0.592  0 0.00 0.000 0.364 0.044
#> GSM247881     1  0.0000      0.882 1.000  0 0.00 0.000 0.000 0.000
#> GSM247883     1  0.5848     -0.137 0.428  0 0.00 0.380 0.000 0.192

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:hclust 61         5.49e-08 2
#> ATC:hclust 61         3.64e-19 3
#> ATC:hclust 58         8.60e-22 4
#> ATC:hclust 49         2.62e-20 5
#> ATC:hclust 52         3.67e-20 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.847           0.943       0.973         0.4695 0.515   0.515
#> 3 3 0.659           0.782       0.841         0.3161 0.734   0.550
#> 4 4 0.679           0.899       0.896         0.1203 0.863   0.668
#> 5 5 0.791           0.854       0.878         0.0811 1.000   1.000
#> 6 6 0.785           0.772       0.830         0.0496 0.943   0.800

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     1   0.000      1.000 1.000 0.000
#> GSM246088     1   0.000      1.000 1.000 0.000
#> GSM246089     1   0.000      1.000 1.000 0.000
#> GSM246090     1   0.000      1.000 1.000 0.000
#> GSM246119     1   0.000      1.000 1.000 0.000
#> GSM246120     1   0.000      1.000 1.000 0.000
#> GSM246121     1   0.000      1.000 1.000 0.000
#> GSM246122     1   0.000      1.000 1.000 0.000
#> GSM246123     1   0.000      1.000 1.000 0.000
#> GSM246422     2   0.917      0.589 0.332 0.668
#> GSM246423     2   0.917      0.589 0.332 0.668
#> GSM246484     2   0.917      0.589 0.332 0.668
#> GSM246485     2   0.917      0.589 0.332 0.668
#> GSM246486     2   0.000      0.925 0.000 1.000
#> GSM246487     2   0.917      0.589 0.332 0.668
#> GSM246488     2   0.000      0.925 0.000 1.000
#> GSM246489     2   0.000      0.925 0.000 1.000
#> GSM246490     2   0.000      0.925 0.000 1.000
#> GSM246491     2   0.000      0.925 0.000 1.000
#> GSM247162     2   0.000      0.925 0.000 1.000
#> GSM247163     2   0.000      0.925 0.000 1.000
#> GSM247164     2   0.000      0.925 0.000 1.000
#> GSM247165     2   0.000      0.925 0.000 1.000
#> GSM247166     2   0.000      0.925 0.000 1.000
#> GSM247168     2   0.000      0.925 0.000 1.000
#> GSM247169     2   0.000      0.925 0.000 1.000
#> GSM247171     2   0.000      0.925 0.000 1.000
#> GSM247173     2   0.000      0.925 0.000 1.000
#> GSM247174     2   0.000      0.925 0.000 1.000
#> GSM247175     2   0.000      0.925 0.000 1.000
#> GSM247188     2   0.000      0.925 0.000 1.000
#> GSM247189     2   0.000      0.925 0.000 1.000
#> GSM247190     2   0.000      0.925 0.000 1.000
#> GSM247650     1   0.000      1.000 1.000 0.000
#> GSM247651     1   0.000      1.000 1.000 0.000
#> GSM247652     1   0.000      1.000 1.000 0.000
#> GSM247653     1   0.000      1.000 1.000 0.000
#> GSM247654     1   0.000      1.000 1.000 0.000
#> GSM247655     1   0.000      1.000 1.000 0.000
#> GSM247656     1   0.000      1.000 1.000 0.000
#> GSM247657     1   0.000      1.000 1.000 0.000
#> GSM247658     1   0.000      1.000 1.000 0.000
#> GSM247659     1   0.000      1.000 1.000 0.000
#> GSM247660     1   0.000      1.000 1.000 0.000
#> GSM247661     1   0.000      1.000 1.000 0.000
#> GSM247662     1   0.000      1.000 1.000 0.000
#> GSM247663     1   0.000      1.000 1.000 0.000
#> GSM247856     1   0.000      1.000 1.000 0.000
#> GSM247857     1   0.000      1.000 1.000 0.000
#> GSM247859     1   0.000      1.000 1.000 0.000
#> GSM247860     1   0.000      1.000 1.000 0.000
#> GSM247862     1   0.000      1.000 1.000 0.000
#> GSM247864     1   0.000      1.000 1.000 0.000
#> GSM247865     1   0.000      1.000 1.000 0.000
#> GSM247866     1   0.000      1.000 1.000 0.000
#> GSM247876     1   0.000      1.000 1.000 0.000
#> GSM247877     1   0.000      1.000 1.000 0.000
#> GSM247878     1   0.000      1.000 1.000 0.000
#> GSM247879     1   0.000      1.000 1.000 0.000
#> GSM247881     1   0.000      1.000 1.000 0.000
#> GSM247883     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
#> GSM246087     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246088     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246089     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246090     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246119     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246120     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246121     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246122     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246123     3  0.6225      1.000 0.432 0.000 0.568
#> GSM246422     1  0.6244      0.625 0.560 0.440 0.000
#> GSM246423     1  0.6244      0.625 0.560 0.440 0.000
#> GSM246484     1  0.6244      0.625 0.560 0.440 0.000
#> GSM246485     1  0.6244      0.625 0.560 0.440 0.000
#> GSM246486     2  0.2796      0.662 0.000 0.908 0.092
#> GSM246487     1  0.6244      0.625 0.560 0.440 0.000
#> GSM246488     2  0.0424      0.574 0.000 0.992 0.008
#> GSM246489     2  0.6180      0.933 0.000 0.584 0.416
#> GSM246490     2  0.6180      0.933 0.000 0.584 0.416
#> GSM246491     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247162     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247163     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247164     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247165     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247166     2  0.6225      0.928 0.000 0.568 0.432
#> GSM247168     2  0.6225      0.928 0.000 0.568 0.432
#> GSM247169     2  0.6225      0.928 0.000 0.568 0.432
#> GSM247171     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247173     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247174     2  0.6225      0.928 0.000 0.568 0.432
#> GSM247175     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247188     2  0.6225      0.928 0.000 0.568 0.432
#> GSM247189     2  0.0237      0.569 0.000 0.996 0.004
#> GSM247190     2  0.6180      0.933 0.000 0.584 0.416
#> GSM247650     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247651     1  0.5254      0.703 0.736 0.264 0.000
#> GSM247652     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247653     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247654     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247655     1  0.5254      0.703 0.736 0.264 0.000
#> GSM247656     1  0.1163      0.657 0.972 0.000 0.028
#> GSM247657     1  0.0237      0.677 0.996 0.000 0.004
#> GSM247658     1  0.0475      0.679 0.992 0.004 0.004
#> GSM247659     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247660     1  0.5254      0.703 0.736 0.264 0.000
#> GSM247661     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247662     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247663     1  0.0592      0.672 0.988 0.000 0.012
#> GSM247856     1  0.1031      0.663 0.976 0.000 0.024
#> GSM247857     1  0.0000      0.679 1.000 0.000 0.000
#> GSM247859     1  0.5058      0.704 0.756 0.244 0.000
#> GSM247860     1  0.0237      0.680 0.996 0.004 0.000
#> GSM247862     1  0.4796      0.703 0.780 0.220 0.000
#> GSM247864     1  0.5254      0.703 0.736 0.264 0.000
#> GSM247865     1  0.6180      0.640 0.584 0.416 0.000
#> GSM247866     1  0.5254      0.703 0.736 0.264 0.000
#> GSM247876     1  0.0000      0.679 1.000 0.000 0.000
#> GSM247877     1  0.6180      0.640 0.584 0.416 0.000
#> GSM247878     1  0.6180      0.640 0.584 0.416 0.000
#> GSM247879     1  0.0592      0.672 0.988 0.000 0.012
#> GSM247881     1  0.0000      0.679 1.000 0.000 0.000
#> GSM247883     1  0.6180      0.640 0.584 0.416 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM246087     3  0.3108      0.990 0.112 0.000 0.872 0.016
#> GSM246088     3  0.3108      0.990 0.112 0.000 0.872 0.016
#> GSM246089     3  0.3793      0.966 0.112 0.000 0.844 0.044
#> GSM246090     3  0.3108      0.990 0.112 0.000 0.872 0.016
#> GSM246119     3  0.2530      0.990 0.112 0.000 0.888 0.000
#> GSM246120     3  0.2530      0.990 0.112 0.000 0.888 0.000
#> GSM246121     3  0.2530      0.990 0.112 0.000 0.888 0.000
#> GSM246122     3  0.3108      0.990 0.112 0.000 0.872 0.016
#> GSM246123     3  0.2530      0.990 0.112 0.000 0.888 0.000
#> GSM246422     4  0.4442      0.839 0.236 0.004 0.008 0.752
#> GSM246423     4  0.4442      0.839 0.236 0.004 0.008 0.752
#> GSM246484     4  0.4442      0.839 0.236 0.004 0.008 0.752
#> GSM246485     4  0.4682      0.836 0.236 0.004 0.016 0.744
#> GSM246486     4  0.5228      0.565 0.000 0.312 0.024 0.664
#> GSM246487     4  0.4822      0.834 0.240 0.004 0.020 0.736
#> GSM246488     4  0.4826      0.624 0.000 0.264 0.020 0.716
#> GSM246489     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM246490     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM246491     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM247162     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM247163     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM247164     2  0.0336      0.926 0.000 0.992 0.008 0.000
#> GSM247165     2  0.0336      0.924 0.000 0.992 0.008 0.000
#> GSM247166     2  0.4039      0.911 0.000 0.836 0.080 0.084
#> GSM247168     2  0.4039      0.911 0.000 0.836 0.080 0.084
#> GSM247169     2  0.4039      0.911 0.000 0.836 0.080 0.084
#> GSM247171     2  0.0188      0.925 0.000 0.996 0.004 0.000
#> GSM247173     2  0.3056      0.923 0.000 0.888 0.040 0.072
#> GSM247174     2  0.4039      0.911 0.000 0.836 0.080 0.084
#> GSM247175     2  0.3312      0.921 0.000 0.876 0.052 0.072
#> GSM247188     2  0.4039      0.911 0.000 0.836 0.080 0.084
#> GSM247189     4  0.4250      0.613 0.000 0.276 0.000 0.724
#> GSM247190     2  0.3056      0.923 0.000 0.888 0.040 0.072
#> GSM247650     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247651     1  0.1716      0.910 0.936 0.000 0.000 0.064
#> GSM247652     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247653     1  0.2466      0.872 0.900 0.000 0.004 0.096
#> GSM247654     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247655     1  0.1716      0.910 0.936 0.000 0.000 0.064
#> GSM247656     1  0.1356      0.929 0.960 0.000 0.032 0.008
#> GSM247657     1  0.0817      0.936 0.976 0.000 0.024 0.000
#> GSM247658     1  0.0188      0.933 0.996 0.000 0.000 0.004
#> GSM247659     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247660     1  0.1716      0.910 0.936 0.000 0.000 0.064
#> GSM247661     1  0.2466      0.872 0.900 0.000 0.004 0.096
#> GSM247662     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247663     1  0.1406      0.933 0.960 0.000 0.024 0.016
#> GSM247856     1  0.0921      0.935 0.972 0.000 0.028 0.000
#> GSM247857     1  0.0817      0.936 0.976 0.000 0.024 0.000
#> GSM247859     1  0.1637      0.913 0.940 0.000 0.000 0.060
#> GSM247860     1  0.2345      0.874 0.900 0.000 0.000 0.100
#> GSM247862     1  0.2760      0.869 0.872 0.000 0.000 0.128
#> GSM247864     1  0.1716      0.910 0.936 0.000 0.000 0.064
#> GSM247865     1  0.3166      0.833 0.868 0.000 0.016 0.116
#> GSM247866     1  0.2868      0.864 0.864 0.000 0.000 0.136
#> GSM247876     1  0.0895      0.936 0.976 0.000 0.020 0.004
#> GSM247877     4  0.4482      0.790 0.264 0.000 0.008 0.728
#> GSM247878     4  0.4567      0.787 0.276 0.000 0.008 0.716
#> GSM247879     1  0.1724      0.929 0.948 0.000 0.020 0.032
#> GSM247881     1  0.0817      0.936 0.976 0.000 0.024 0.000
#> GSM247883     1  0.3166      0.833 0.868 0.000 0.016 0.116

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM246087     3  0.1243      0.983 0.028 0.000 0.960 0.004 NA
#> GSM246088     3  0.1243      0.983 0.028 0.000 0.960 0.004 NA
#> GSM246089     3  0.3291      0.907 0.028 0.000 0.856 0.016 NA
#> GSM246090     3  0.1243      0.983 0.028 0.000 0.960 0.004 NA
#> GSM246119     3  0.0955      0.983 0.028 0.000 0.968 0.000 NA
#> GSM246120     3  0.0955      0.983 0.028 0.000 0.968 0.000 NA
#> GSM246121     3  0.0794      0.983 0.028 0.000 0.972 0.000 NA
#> GSM246122     3  0.1243      0.983 0.028 0.000 0.960 0.004 NA
#> GSM246123     3  0.0955      0.983 0.028 0.000 0.968 0.000 NA
#> GSM246422     4  0.1121      0.830 0.044 0.000 0.000 0.956 NA
#> GSM246423     4  0.1121      0.830 0.044 0.000 0.000 0.956 NA
#> GSM246484     4  0.1121      0.830 0.044 0.000 0.000 0.956 NA
#> GSM246485     4  0.4622      0.816 0.060 0.000 0.024 0.768 NA
#> GSM246486     4  0.6020      0.720 0.000 0.160 0.024 0.644 NA
#> GSM246487     4  0.6020      0.740 0.160 0.000 0.024 0.644 NA
#> GSM246488     4  0.4512      0.797 0.000 0.044 0.024 0.768 NA
#> GSM246489     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM246490     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM246491     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM247162     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM247163     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM247164     2  0.0671      0.896 0.000 0.980 0.000 0.016 NA
#> GSM247165     2  0.1211      0.893 0.000 0.960 0.000 0.016 NA
#> GSM247166     2  0.3826      0.838 0.000 0.752 0.004 0.008 NA
#> GSM247168     2  0.3826      0.840 0.000 0.752 0.004 0.008 NA
#> GSM247169     2  0.3883      0.836 0.000 0.744 0.004 0.008 NA
#> GSM247171     2  0.0693      0.896 0.000 0.980 0.000 0.012 NA
#> GSM247173     2  0.1671      0.892 0.000 0.924 0.000 0.000 NA
#> GSM247174     2  0.3671      0.841 0.000 0.756 0.000 0.008 NA
#> GSM247175     2  0.2424      0.880 0.000 0.868 0.000 0.000 NA
#> GSM247188     2  0.3671      0.841 0.000 0.756 0.000 0.008 NA
#> GSM247189     4  0.3523      0.811 0.000 0.044 0.004 0.832 NA
#> GSM247190     2  0.1671      0.892 0.000 0.924 0.000 0.000 NA
#> GSM247650     1  0.0290      0.882 0.992 0.000 0.000 0.000 NA
#> GSM247651     1  0.3003      0.831 0.812 0.000 0.000 0.000 NA
#> GSM247652     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247653     1  0.4030      0.689 0.648 0.000 0.000 0.000 NA
#> GSM247654     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247655     1  0.1341      0.874 0.944 0.000 0.000 0.000 NA
#> GSM247656     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247657     1  0.0162      0.882 0.996 0.000 0.000 0.000 NA
#> GSM247658     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247659     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247660     1  0.2605      0.846 0.852 0.000 0.000 0.000 NA
#> GSM247661     1  0.4030      0.689 0.648 0.000 0.000 0.000 NA
#> GSM247662     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247663     1  0.2891      0.833 0.824 0.000 0.000 0.000 NA
#> GSM247856     1  0.0000      0.883 1.000 0.000 0.000 0.000 NA
#> GSM247857     1  0.0290      0.881 0.992 0.000 0.000 0.000 NA
#> GSM247859     1  0.0290      0.881 0.992 0.000 0.000 0.000 NA
#> GSM247860     1  0.4030      0.689 0.648 0.000 0.000 0.000 NA
#> GSM247862     1  0.3774      0.740 0.704 0.000 0.000 0.000 NA
#> GSM247864     1  0.2929      0.834 0.820 0.000 0.000 0.000 NA
#> GSM247865     1  0.2522      0.821 0.896 0.000 0.024 0.004 NA
#> GSM247866     1  0.4294      0.583 0.532 0.000 0.000 0.000 NA
#> GSM247876     1  0.2179      0.858 0.888 0.000 0.000 0.000 NA
#> GSM247877     4  0.4734      0.707 0.064 0.000 0.000 0.704 NA
#> GSM247878     4  0.4734      0.707 0.064 0.000 0.000 0.704 NA
#> GSM247879     1  0.3177      0.814 0.792 0.000 0.000 0.000 NA
#> GSM247881     1  0.0290      0.881 0.992 0.000 0.000 0.000 NA
#> GSM247883     1  0.2522      0.821 0.896 0.000 0.024 0.004 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM246087     3  0.0291      0.959 0.004 0.000 0.992 0.000 0.004 NA
#> GSM246088     3  0.0291      0.959 0.004 0.000 0.992 0.000 0.004 NA
#> GSM246089     3  0.4429      0.791 0.004 0.000 0.740 0.012 0.076 NA
#> GSM246090     3  0.0291      0.959 0.004 0.000 0.992 0.000 0.004 NA
#> GSM246119     3  0.1413      0.956 0.004 0.000 0.948 0.008 0.036 NA
#> GSM246120     3  0.1413      0.956 0.004 0.000 0.948 0.008 0.036 NA
#> GSM246121     3  0.0922      0.958 0.004 0.000 0.968 0.004 0.024 NA
#> GSM246122     3  0.0291      0.959 0.004 0.000 0.992 0.000 0.004 NA
#> GSM246123     3  0.1413      0.956 0.004 0.000 0.948 0.008 0.036 NA
#> GSM246422     4  0.3465      0.760 0.020 0.000 0.000 0.828 0.056 NA
#> GSM246423     4  0.3465      0.760 0.020 0.000 0.000 0.828 0.056 NA
#> GSM246484     4  0.3465      0.760 0.020 0.000 0.000 0.828 0.056 NA
#> GSM246485     4  0.2800      0.737 0.052 0.000 0.000 0.876 0.020 NA
#> GSM246486     4  0.4527      0.625 0.000 0.228 0.000 0.704 0.024 NA
#> GSM246487     4  0.4921      0.563 0.192 0.016 0.000 0.708 0.020 NA
#> GSM246488     4  0.2934      0.739 0.000 0.064 0.000 0.868 0.024 NA
#> GSM246489     2  0.0146      0.830 0.000 0.996 0.000 0.000 0.004 NA
#> GSM246490     2  0.0260      0.831 0.000 0.992 0.000 0.000 0.008 NA
#> GSM246491     2  0.0260      0.831 0.000 0.992 0.000 0.000 0.008 NA
#> GSM247162     2  0.0405      0.831 0.000 0.988 0.000 0.000 0.008 NA
#> GSM247163     2  0.0363      0.829 0.000 0.988 0.000 0.000 0.012 NA
#> GSM247164     2  0.0972      0.834 0.000 0.964 0.000 0.000 0.008 NA
#> GSM247165     2  0.0146      0.830 0.000 0.996 0.000 0.000 0.004 NA
#> GSM247166     2  0.4897      0.699 0.000 0.556 0.004 0.000 0.056 NA
#> GSM247168     2  0.4897      0.699 0.000 0.556 0.004 0.000 0.056 NA
#> GSM247169     2  0.4723      0.698 0.000 0.548 0.004 0.000 0.040 NA
#> GSM247171     2  0.1204      0.832 0.000 0.944 0.000 0.000 0.000 NA
#> GSM247173     2  0.2219      0.826 0.000 0.864 0.000 0.000 0.000 NA
#> GSM247174     2  0.3843      0.707 0.000 0.548 0.000 0.000 0.000 NA
#> GSM247175     2  0.2883      0.808 0.000 0.788 0.000 0.000 0.000 NA
#> GSM247188     2  0.3843      0.707 0.000 0.548 0.000 0.000 0.000 NA
#> GSM247189     4  0.1219      0.755 0.000 0.048 0.000 0.948 0.000 NA
#> GSM247190     2  0.2300      0.824 0.000 0.856 0.000 0.000 0.000 NA
#> GSM247650     1  0.0993      0.814 0.964 0.000 0.000 0.000 0.024 NA
#> GSM247651     1  0.4790      0.503 0.680 0.000 0.000 0.004 0.196 NA
#> GSM247652     1  0.0458      0.819 0.984 0.000 0.000 0.000 0.016 NA
#> GSM247653     5  0.3563      0.919 0.336 0.000 0.000 0.000 0.664 NA
#> GSM247654     1  0.0458      0.819 0.984 0.000 0.000 0.000 0.016 NA
#> GSM247655     1  0.2926      0.737 0.844 0.000 0.000 0.004 0.028 NA
#> GSM247656     1  0.0603      0.817 0.980 0.000 0.004 0.000 0.016 NA
#> GSM247657     1  0.0363      0.819 0.988 0.000 0.000 0.000 0.012 NA
#> GSM247658     1  0.0547      0.818 0.980 0.000 0.000 0.000 0.020 NA
#> GSM247659     1  0.0363      0.819 0.988 0.000 0.000 0.000 0.012 NA
#> GSM247660     1  0.4508      0.551 0.716 0.000 0.000 0.004 0.164 NA
#> GSM247661     5  0.3563      0.919 0.336 0.000 0.000 0.000 0.664 NA
#> GSM247662     1  0.0458      0.819 0.984 0.000 0.000 0.000 0.016 NA
#> GSM247663     1  0.4817      0.482 0.676 0.000 0.000 0.004 0.200 NA
#> GSM247856     1  0.0363      0.819 0.988 0.000 0.000 0.000 0.012 NA
#> GSM247857     1  0.0603      0.815 0.980 0.000 0.000 0.000 0.004 NA
#> GSM247859     1  0.0837      0.812 0.972 0.000 0.000 0.004 0.004 NA
#> GSM247860     5  0.3563      0.919 0.336 0.000 0.000 0.000 0.664 NA
#> GSM247862     5  0.4141      0.753 0.432 0.000 0.000 0.000 0.556 NA
#> GSM247864     1  0.4790      0.503 0.680 0.000 0.000 0.004 0.196 NA
#> GSM247865     1  0.2326      0.754 0.900 0.000 0.000 0.012 0.028 NA
#> GSM247866     5  0.3468      0.836 0.264 0.000 0.000 0.000 0.728 NA
#> GSM247876     1  0.3985      0.651 0.768 0.000 0.000 0.004 0.088 NA
#> GSM247877     4  0.6480      0.458 0.024 0.000 0.000 0.428 0.256 NA
#> GSM247878     4  0.6480      0.458 0.024 0.000 0.000 0.428 0.256 NA
#> GSM247879     1  0.5388      0.305 0.600 0.000 0.000 0.004 0.228 NA
#> GSM247881     1  0.0458      0.816 0.984 0.000 0.000 0.000 0.000 NA
#> GSM247883     1  0.2326      0.754 0.900 0.000 0.000 0.012 0.028 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-ATC-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:kmeans 61         5.68e-14 2
#> ATC:kmeans 61         3.74e-21 3
#> ATC:kmeans 61         2.38e-22 4
#> ATC:kmeans 61         2.38e-22 5
#> ATC:kmeans 57         5.72e-21 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 21168 rows and 61 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.991       0.996         0.4964 0.503   0.503
#> 3 3 0.900           0.932       0.962         0.2802 0.803   0.624
#> 4 4 0.754           0.800       0.906         0.1530 0.839   0.581
#> 5 5 0.750           0.720       0.853         0.0636 0.925   0.718
#> 6 6 0.762           0.652       0.796         0.0348 0.943   0.743

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
#> GSM246087     1   0.000      1.000 1.000 0.000
#> GSM246088     1   0.000      1.000 1.000 0.000
#> GSM246089     1   0.000      1.000 1.000 0.000
#> GSM246090     1   0.000      1.000 1.000 0.000
#> GSM246119     1   0.000      1.000 1.000 0.000
#> GSM246120     1   0.000      1.000 1.000 0.000
#> GSM246121     1   0.000      1.000 1.000 0.000
#> GSM246122     1   0.000      1.000 1.000 0.000
#> GSM246123     1   0.000      1.000 1.000 0.000
#> GSM246422     2   0.000      0.990 0.000 1.000
#> GSM246423     2   0.000      0.990 0.000 1.000
#> GSM246484     2   0.000      0.990 0.000 1.000
#> GSM246485     2   0.000      0.990 0.000 1.000
#> GSM246486     2   0.000      0.990 0.000 1.000
#> GSM246487     2   0.000      0.990 0.000 1.000
#> GSM246488     2   0.000      0.990 0.000 1.000
#> GSM246489     2   0.000      0.990 0.000 1.000
#> GSM246490     2   0.000      0.990 0.000 1.000
#> GSM246491     2   0.000      0.990 0.000 1.000
#> GSM247162     2   0.000      0.990 0.000 1.000
#> GSM247163     2   0.000      0.990 0.000 1.000
#> GSM247164     2   0.000      0.990 0.000 1.000
#> GSM247165     2   0.000      0.990 0.000 1.000
#> GSM247166     2   0.000      0.990 0.000 1.000
#> GSM247168     2   0.000      0.990 0.000 1.000
#> GSM247169     2   0.000      0.990 0.000 1.000
#> GSM247171     2   0.000      0.990 0.000 1.000
#> GSM247173     2   0.000      0.990 0.000 1.000
#> GSM247174     2   0.000      0.990 0.000 1.000
#> GSM247175     2   0.000      0.990 0.000 1.000
#> GSM247188     2   0.000      0.990 0.000 1.000
#> GSM247189     2   0.000      0.990 0.000 1.000
#> GSM247190     2   0.000      0.990 0.000 1.000
#> GSM247650     1   0.000      1.000 1.000 0.000
#> GSM247651     1   0.000      1.000 1.000 0.000
#> GSM247652     1   0.000      1.000 1.000 0.000
#> GSM247653     1   0.000      1.000 1.000 0.000
#> GSM247654     1   0.000      1.000 1.000 0.000
#> GSM247655     1   0.000      1.000 1.000 0.000
#> GSM247656     1   0.000      1.000 1.000 0.000
#> GSM247657     1   0.000      1.000 1.000 0.000
#> GSM247658     1   0.000      1.000 1.000 0.000
#> GSM247659     1   0.000      1.000 1.000 0.000
#> GSM247660     1   0.000      1.000 1.000 0.000
#> GSM247661     1   0.000      1.000 1.000 0.000
#> GSM247662     1   0.000      1.000 1.000 0.000
#> GSM247663     1   0.000      1.000 1.000 0.000
#> GSM247856     1   0.000      1.000 1.000 0.000
#> GSM247857     1   0.000      1.000 1.000 0.000
#> GSM247859     1   0.000      1.000 1.000 0.000
#> GSM247860     1   0.000      1.000 1.000 0.000
#> GSM247862     1   0.000      1.000 1.000 0.000
#> GSM247864     1   0.000      1.000 1.000 0.000
#> GSM247865     2   0.802      0.677 0.244 0.756
#> GSM247866     1   0.000      1.000 1.000 0.000
#> GSM247876     1   0.000      1.000 1.000 0.000
#> GSM247877     1   0.000      1.000 1.000 0.000
#> GSM247878     1   0.000      1.000 1.000 0.000
#> GSM247879     1   0.000      1.000 1.000 0.000
#> GSM247881     1   0.000      1.000 1.000 0.000
#> GSM247883     2   0.000      0.990 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246088     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246089     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246090     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246119     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246120     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246121     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246122     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246123     3  0.0000      0.994 0.000 0.000 1.000
#> GSM246422     1  0.0237      0.819 0.996 0.004 0.000
#> GSM246423     1  0.0237      0.819 0.996 0.004 0.000
#> GSM246484     1  0.0237      0.819 0.996 0.004 0.000
#> GSM246485     1  0.5905      0.345 0.648 0.352 0.000
#> GSM246486     2  0.0000      0.988 0.000 1.000 0.000
#> GSM246487     2  0.0424      0.981 0.008 0.992 0.000
#> GSM246488     2  0.0000      0.988 0.000 1.000 0.000
#> GSM246489     2  0.0000      0.988 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.988 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247189     2  0.4750      0.746 0.216 0.784 0.000
#> GSM247190     2  0.0000      0.988 0.000 1.000 0.000
#> GSM247650     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247651     1  0.4750      0.793 0.784 0.000 0.216
#> GSM247652     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247653     3  0.0237      0.991 0.004 0.000 0.996
#> GSM247654     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247655     1  0.4796      0.790 0.780 0.000 0.220
#> GSM247656     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247657     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247658     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247659     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247660     1  0.4750      0.793 0.784 0.000 0.216
#> GSM247661     3  0.0237      0.991 0.004 0.000 0.996
#> GSM247662     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247663     3  0.0747      0.982 0.016 0.000 0.984
#> GSM247856     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247857     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247859     3  0.1163      0.968 0.028 0.000 0.972
#> GSM247860     3  0.2165      0.921 0.064 0.000 0.936
#> GSM247862     1  0.6126      0.491 0.600 0.000 0.400
#> GSM247864     1  0.4750      0.793 0.784 0.000 0.216
#> GSM247865     1  0.2486      0.800 0.932 0.060 0.008
#> GSM247866     1  0.4796      0.790 0.780 0.000 0.220
#> GSM247876     3  0.0592      0.985 0.012 0.000 0.988
#> GSM247877     1  0.0000      0.819 1.000 0.000 0.000
#> GSM247878     1  0.0000      0.819 1.000 0.000 0.000
#> GSM247879     3  0.0592      0.985 0.012 0.000 0.988
#> GSM247881     3  0.0000      0.994 0.000 0.000 1.000
#> GSM247883     2  0.1015      0.970 0.012 0.980 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM246087     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246089     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246090     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246121     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246122     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM246422     4  0.0000      0.756 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0000      0.756 0.000 0.000 0.000 1.000
#> GSM246484     4  0.0000      0.756 0.000 0.000 0.000 1.000
#> GSM246485     4  0.1211      0.752 0.000 0.040 0.000 0.960
#> GSM246486     2  0.3266      0.772 0.000 0.832 0.000 0.168
#> GSM246487     2  0.4933      0.210 0.000 0.568 0.000 0.432
#> GSM246488     4  0.4933      0.134 0.000 0.432 0.000 0.568
#> GSM246489     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247189     4  0.3311      0.683 0.000 0.172 0.000 0.828
#> GSM247190     2  0.0000      0.953 0.000 1.000 0.000 0.000
#> GSM247650     3  0.4008      0.723 0.244 0.000 0.756 0.000
#> GSM247651     1  0.0927      0.857 0.976 0.000 0.008 0.016
#> GSM247652     3  0.3764      0.754 0.216 0.000 0.784 0.000
#> GSM247653     1  0.1637      0.860 0.940 0.000 0.060 0.000
#> GSM247654     3  0.4382      0.653 0.296 0.000 0.704 0.000
#> GSM247655     1  0.0524      0.861 0.988 0.000 0.008 0.004
#> GSM247656     3  0.0188      0.881 0.004 0.000 0.996 0.000
#> GSM247657     3  0.4500      0.621 0.316 0.000 0.684 0.000
#> GSM247658     1  0.3610      0.767 0.800 0.000 0.200 0.000
#> GSM247659     3  0.0469      0.878 0.012 0.000 0.988 0.000
#> GSM247660     1  0.0672      0.860 0.984 0.000 0.008 0.008
#> GSM247661     1  0.1867      0.856 0.928 0.000 0.072 0.000
#> GSM247662     3  0.3074      0.803 0.152 0.000 0.848 0.000
#> GSM247663     1  0.2814      0.825 0.868 0.000 0.132 0.000
#> GSM247856     3  0.0000      0.882 0.000 0.000 1.000 0.000
#> GSM247857     3  0.4277      0.688 0.280 0.000 0.720 0.000
#> GSM247859     1  0.4843      0.281 0.604 0.000 0.396 0.000
#> GSM247860     1  0.0921      0.863 0.972 0.000 0.028 0.000
#> GSM247862     1  0.0336      0.861 0.992 0.000 0.008 0.000
#> GSM247864     1  0.0804      0.859 0.980 0.000 0.008 0.012
#> GSM247865     4  0.6456      0.271 0.408 0.040 0.016 0.536
#> GSM247866     1  0.0804      0.859 0.980 0.000 0.008 0.012
#> GSM247876     1  0.3764      0.748 0.784 0.000 0.216 0.000
#> GSM247877     4  0.4605      0.485 0.336 0.000 0.000 0.664
#> GSM247878     4  0.4431      0.529 0.304 0.000 0.000 0.696
#> GSM247879     1  0.3908      0.766 0.784 0.000 0.212 0.004
#> GSM247881     3  0.4193      0.701 0.268 0.000 0.732 0.000
#> GSM247883     2  0.3940      0.783 0.116 0.844 0.012 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM246087     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.0162     0.8647 0.004 0.000 0.996 0.000 0.000
#> GSM246090     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246122     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000     0.8687 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0000     0.7374 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0000     0.7374 0.000 0.000 0.000 1.000 0.000
#> GSM246484     4  0.0000     0.7374 0.000 0.000 0.000 1.000 0.000
#> GSM246485     4  0.2438     0.7162 0.000 0.060 0.000 0.900 0.040
#> GSM246486     2  0.3954     0.6812 0.000 0.772 0.000 0.192 0.036
#> GSM246487     2  0.5243     0.1521 0.000 0.540 0.000 0.412 0.048
#> GSM246488     4  0.5037     0.2781 0.000 0.376 0.000 0.584 0.040
#> GSM246489     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247165     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247166     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247189     4  0.3123     0.6641 0.000 0.184 0.000 0.812 0.004
#> GSM247190     2  0.0000     0.9557 0.000 1.000 0.000 0.000 0.000
#> GSM247650     3  0.6301    -0.2223 0.180 0.000 0.512 0.000 0.308
#> GSM247651     1  0.3476     0.7771 0.804 0.000 0.000 0.020 0.176
#> GSM247652     5  0.5077     0.5846 0.040 0.000 0.392 0.000 0.568
#> GSM247653     1  0.1469     0.7733 0.948 0.000 0.036 0.000 0.016
#> GSM247654     5  0.5498     0.6300 0.076 0.000 0.356 0.000 0.568
#> GSM247655     1  0.4130     0.7057 0.696 0.000 0.000 0.012 0.292
#> GSM247656     3  0.3636     0.4614 0.000 0.000 0.728 0.000 0.272
#> GSM247657     5  0.5306     0.6701 0.072 0.000 0.316 0.000 0.612
#> GSM247658     1  0.5834     0.3572 0.584 0.000 0.132 0.000 0.284
#> GSM247659     3  0.3586     0.4840 0.000 0.000 0.736 0.000 0.264
#> GSM247660     1  0.3280     0.7807 0.812 0.000 0.000 0.012 0.176
#> GSM247661     1  0.1981     0.7592 0.920 0.000 0.064 0.000 0.016
#> GSM247662     5  0.4890     0.4566 0.024 0.000 0.452 0.000 0.524
#> GSM247663     1  0.5040     0.7081 0.680 0.000 0.084 0.000 0.236
#> GSM247856     3  0.1410     0.8161 0.000 0.000 0.940 0.000 0.060
#> GSM247857     5  0.5067     0.6835 0.064 0.000 0.288 0.000 0.648
#> GSM247859     5  0.3866     0.5852 0.096 0.000 0.096 0.000 0.808
#> GSM247860     1  0.0912     0.7781 0.972 0.000 0.012 0.000 0.016
#> GSM247862     1  0.0794     0.7815 0.972 0.000 0.000 0.000 0.028
#> GSM247864     1  0.2536     0.7872 0.868 0.000 0.000 0.004 0.128
#> GSM247865     5  0.6057     0.0948 0.164 0.008 0.000 0.224 0.604
#> GSM247866     1  0.0162     0.7743 0.996 0.000 0.000 0.000 0.004
#> GSM247876     1  0.6110     0.3787 0.476 0.000 0.128 0.000 0.396
#> GSM247877     4  0.5297     0.3080 0.360 0.000 0.000 0.580 0.060
#> GSM247878     4  0.5203     0.3632 0.332 0.000 0.000 0.608 0.060
#> GSM247879     1  0.5466     0.6655 0.656 0.000 0.152 0.000 0.192
#> GSM247881     5  0.4666     0.6850 0.056 0.000 0.240 0.000 0.704
#> GSM247883     5  0.3101     0.4602 0.024 0.100 0.000 0.012 0.864

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246090     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000     0.8461 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.0458     0.6705 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM246423     4  0.0458     0.6705 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM246484     4  0.0458     0.6705 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM246485     4  0.4488     0.6480 0.020 0.048 0.000 0.724 0.004 0.204
#> GSM246486     2  0.5793     0.1807 0.020 0.580 0.000 0.204 0.000 0.196
#> GSM246487     4  0.6778     0.3986 0.032 0.344 0.000 0.368 0.004 0.252
#> GSM246488     4  0.5989     0.5824 0.016 0.260 0.000 0.528 0.000 0.196
#> GSM246489     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247165     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247166     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     4  0.3460     0.6115 0.000 0.220 0.000 0.760 0.000 0.020
#> GSM247190     2  0.0000     0.9697 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     3  0.6047    -0.0129 0.220 0.000 0.480 0.000 0.292 0.008
#> GSM247651     5  0.1781     0.4892 0.060 0.000 0.000 0.008 0.924 0.008
#> GSM247652     1  0.4651     0.6120 0.676 0.000 0.256 0.000 0.052 0.016
#> GSM247653     6  0.4987     0.9251 0.044 0.000 0.012 0.000 0.420 0.524
#> GSM247654     1  0.5244     0.6301 0.652 0.000 0.232 0.000 0.080 0.036
#> GSM247655     5  0.3183     0.4848 0.164 0.000 0.000 0.008 0.812 0.016
#> GSM247656     3  0.3747     0.2222 0.396 0.000 0.604 0.000 0.000 0.000
#> GSM247657     1  0.4562     0.6653 0.720 0.000 0.196 0.000 0.056 0.028
#> GSM247658     1  0.7391    -0.0792 0.324 0.000 0.112 0.000 0.284 0.280
#> GSM247659     3  0.4151     0.1555 0.412 0.000 0.576 0.000 0.004 0.008
#> GSM247660     5  0.2052     0.4643 0.056 0.000 0.000 0.004 0.912 0.028
#> GSM247661     6  0.4913     0.9364 0.028 0.000 0.020 0.000 0.428 0.524
#> GSM247662     1  0.4868     0.4532 0.588 0.000 0.352 0.000 0.052 0.008
#> GSM247663     5  0.3936     0.4961 0.124 0.000 0.088 0.000 0.780 0.008
#> GSM247856     3  0.2527     0.7532 0.084 0.000 0.880 0.000 0.004 0.032
#> GSM247857     1  0.4197     0.6745 0.752 0.000 0.172 0.000 0.060 0.016
#> GSM247859     1  0.3755     0.6024 0.816 0.000 0.056 0.000 0.084 0.044
#> GSM247860     6  0.4453     0.9374 0.020 0.000 0.004 0.000 0.452 0.524
#> GSM247862     5  0.4531    -0.8783 0.032 0.000 0.000 0.000 0.504 0.464
#> GSM247864     5  0.2069     0.3553 0.020 0.000 0.000 0.004 0.908 0.068
#> GSM247865     1  0.6861     0.0957 0.424 0.000 0.000 0.128 0.104 0.344
#> GSM247866     6  0.4097     0.8987 0.008 0.000 0.000 0.000 0.492 0.500
#> GSM247876     5  0.5522     0.4139 0.240 0.000 0.108 0.000 0.620 0.032
#> GSM247877     5  0.4399     0.2135 0.000 0.000 0.000 0.460 0.516 0.024
#> GSM247878     5  0.4407     0.1737 0.000 0.000 0.000 0.480 0.496 0.024
#> GSM247879     5  0.4670     0.4693 0.072 0.000 0.148 0.004 0.740 0.036
#> GSM247881     1  0.3457     0.6680 0.820 0.000 0.116 0.000 0.052 0.012
#> GSM247883     1  0.4204     0.4119 0.716 0.012 0.000 0.008 0.020 0.244

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n disease.state(p) k
#> ATC:skmeans 61         2.53e-12 2
#> ATC:skmeans 59         2.62e-10 3
#> ATC:skmeans 56         9.11e-12 4
#> ATC:skmeans 49         3.43e-16 5
#> ATC:skmeans 42         2.63e-13 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 21168 rows and 61 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 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 ATC-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.932           0.953       0.978         0.4497 0.564   0.564
#> 3 3 1.000           0.971       0.987         0.3419 0.838   0.712
#> 4 4 1.000           0.972       0.989         0.1370 0.911   0.780
#> 5 5 0.850           0.839       0.918         0.1094 0.920   0.747
#> 6 6 0.819           0.691       0.882         0.0365 0.975   0.896

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
#> GSM246087     1   0.000      0.967 1.000 0.000
#> GSM246088     1   0.000      0.967 1.000 0.000
#> GSM246089     1   0.000      0.967 1.000 0.000
#> GSM246090     1   0.000      0.967 1.000 0.000
#> GSM246119     1   0.000      0.967 1.000 0.000
#> GSM246120     1   0.000      0.967 1.000 0.000
#> GSM246121     1   0.000      0.967 1.000 0.000
#> GSM246122     1   0.000      0.967 1.000 0.000
#> GSM246123     1   0.000      0.967 1.000 0.000
#> GSM246422     1   0.844      0.663 0.728 0.272
#> GSM246423     1   0.814      0.693 0.748 0.252
#> GSM246484     1   0.844      0.663 0.728 0.272
#> GSM246485     1   0.850      0.656 0.724 0.276
#> GSM246486     2   0.000      1.000 0.000 1.000
#> GSM246487     1   0.814      0.693 0.748 0.252
#> GSM246488     2   0.000      1.000 0.000 1.000
#> GSM246489     2   0.000      1.000 0.000 1.000
#> GSM246490     2   0.000      1.000 0.000 1.000
#> GSM246491     2   0.000      1.000 0.000 1.000
#> GSM247162     2   0.000      1.000 0.000 1.000
#> GSM247163     2   0.000      1.000 0.000 1.000
#> GSM247164     2   0.000      1.000 0.000 1.000
#> GSM247165     2   0.000      1.000 0.000 1.000
#> GSM247166     2   0.000      1.000 0.000 1.000
#> GSM247168     2   0.000      1.000 0.000 1.000
#> GSM247169     2   0.000      1.000 0.000 1.000
#> GSM247171     2   0.000      1.000 0.000 1.000
#> GSM247173     2   0.000      1.000 0.000 1.000
#> GSM247174     2   0.000      1.000 0.000 1.000
#> GSM247175     2   0.000      1.000 0.000 1.000
#> GSM247188     2   0.000      1.000 0.000 1.000
#> GSM247189     2   0.000      1.000 0.000 1.000
#> GSM247190     2   0.000      1.000 0.000 1.000
#> GSM247650     1   0.000      0.967 1.000 0.000
#> GSM247651     1   0.000      0.967 1.000 0.000
#> GSM247652     1   0.000      0.967 1.000 0.000
#> GSM247653     1   0.000      0.967 1.000 0.000
#> GSM247654     1   0.000      0.967 1.000 0.000
#> GSM247655     1   0.000      0.967 1.000 0.000
#> GSM247656     1   0.000      0.967 1.000 0.000
#> GSM247657     1   0.000      0.967 1.000 0.000
#> GSM247658     1   0.000      0.967 1.000 0.000
#> GSM247659     1   0.000      0.967 1.000 0.000
#> GSM247660     1   0.000      0.967 1.000 0.000
#> GSM247661     1   0.000      0.967 1.000 0.000
#> GSM247662     1   0.000      0.967 1.000 0.000
#> GSM247663     1   0.000      0.967 1.000 0.000
#> GSM247856     1   0.000      0.967 1.000 0.000
#> GSM247857     1   0.000      0.967 1.000 0.000
#> GSM247859     1   0.000      0.967 1.000 0.000
#> GSM247860     1   0.000      0.967 1.000 0.000
#> GSM247862     1   0.000      0.967 1.000 0.000
#> GSM247864     1   0.000      0.967 1.000 0.000
#> GSM247865     1   0.000      0.967 1.000 0.000
#> GSM247866     1   0.000      0.967 1.000 0.000
#> GSM247876     1   0.000      0.967 1.000 0.000
#> GSM247877     1   0.000      0.967 1.000 0.000
#> GSM247878     1   0.000      0.967 1.000 0.000
#> GSM247879     1   0.000      0.967 1.000 0.000
#> GSM247881     1   0.000      0.967 1.000 0.000
#> GSM247883     1   0.000      0.967 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
#> GSM246087     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246088     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246089     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246090     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246119     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246120     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246121     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246122     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246123     3  0.0000      1.000 0.000 0.000 1.000
#> GSM246422     1  0.5058      0.698 0.756 0.244 0.000
#> GSM246423     1  0.0592      0.963 0.988 0.012 0.000
#> GSM246484     1  0.5058      0.698 0.756 0.244 0.000
#> GSM246485     1  0.5138      0.686 0.748 0.252 0.000
#> GSM246486     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246487     1  0.0000      0.973 1.000 0.000 0.000
#> GSM246488     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246489     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246490     2  0.0000      1.000 0.000 1.000 0.000
#> GSM246491     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247162     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247163     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247164     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247165     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247166     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247168     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247169     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247171     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247173     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247174     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247175     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247188     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247189     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247190     2  0.0000      1.000 0.000 1.000 0.000
#> GSM247650     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247651     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247652     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247653     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247654     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247655     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247656     1  0.0747      0.960 0.984 0.000 0.016
#> GSM247657     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247658     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247659     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247660     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247661     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247662     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247663     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247856     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247857     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247860     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247862     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247864     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247865     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247866     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247876     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247877     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247878     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247879     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247881     1  0.0000      0.973 1.000 0.000 0.000
#> GSM247883     1  0.0000      0.973 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
#> GSM246087     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246088     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246089     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246090     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246119     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246120     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246121     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246122     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246123     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM246422     4   0.000      0.956 0.000 0.000  0 1.000
#> GSM246423     4   0.000      0.956 0.000 0.000  0 1.000
#> GSM246484     4   0.000      0.956 0.000 0.000  0 1.000
#> GSM246485     1   0.482      0.360 0.612 0.000  0 0.388
#> GSM246486     2   0.156      0.941 0.000 0.944  0 0.056
#> GSM246487     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM246488     2   0.164      0.937 0.000 0.940  0 0.060
#> GSM246489     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM246490     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM246491     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247162     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247163     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247164     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247165     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247166     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247168     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247169     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247171     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247173     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247174     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247175     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247188     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247189     4   0.331      0.776 0.000 0.172  0 0.828
#> GSM247190     2   0.000      0.993 0.000 1.000  0 0.000
#> GSM247650     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247651     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247652     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247653     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247654     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247655     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247656     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247657     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247658     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247659     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247660     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247661     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247662     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247663     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247856     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247857     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247859     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247860     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247862     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247864     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247865     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247866     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247876     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247877     4   0.000      0.956 0.000 0.000  0 1.000
#> GSM247878     4   0.000      0.956 0.000 0.000  0 1.000
#> GSM247879     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247881     1   0.000      0.985 1.000 0.000  0 0.000
#> GSM247883     1   0.000      0.985 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
#> GSM246087     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246088     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246089     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246090     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246119     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246120     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246121     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246122     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246123     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM246422     4  0.0000      0.821 0.000 0.000  0 1.000 0.000
#> GSM246423     4  0.0000      0.821 0.000 0.000  0 1.000 0.000
#> GSM246484     4  0.0000      0.821 0.000 0.000  0 1.000 0.000
#> GSM246485     1  0.5767      0.419 0.612 0.016  0 0.292 0.080
#> GSM246486     2  0.2233      0.902 0.000 0.904  0 0.016 0.080
#> GSM246487     1  0.1732      0.781 0.920 0.000  0 0.000 0.080
#> GSM246488     2  0.2331      0.898 0.000 0.900  0 0.020 0.080
#> GSM246489     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM246490     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM246491     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247162     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247163     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247164     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247165     2  0.0162      0.968 0.000 0.996  0 0.000 0.004
#> GSM247166     2  0.1043      0.961 0.000 0.960  0 0.000 0.040
#> GSM247168     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247169     2  0.1410      0.954 0.000 0.940  0 0.000 0.060
#> GSM247171     2  0.0000      0.970 0.000 1.000  0 0.000 0.000
#> GSM247173     2  0.0290      0.969 0.000 0.992  0 0.000 0.008
#> GSM247174     2  0.1410      0.954 0.000 0.940  0 0.000 0.060
#> GSM247175     2  0.1410      0.954 0.000 0.940  0 0.000 0.060
#> GSM247188     2  0.1410      0.954 0.000 0.940  0 0.000 0.060
#> GSM247189     4  0.3438      0.673 0.000 0.172  0 0.808 0.020
#> GSM247190     2  0.1410      0.954 0.000 0.940  0 0.000 0.060
#> GSM247650     1  0.3452      0.610 0.756 0.000  0 0.000 0.244
#> GSM247651     1  0.3612      0.569 0.732 0.000  0 0.000 0.268
#> GSM247652     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247653     5  0.3707      0.755 0.284 0.000  0 0.000 0.716
#> GSM247654     1  0.0290      0.857 0.992 0.000  0 0.000 0.008
#> GSM247655     1  0.3508      0.596 0.748 0.000  0 0.000 0.252
#> GSM247656     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247657     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247658     1  0.0162      0.859 0.996 0.000  0 0.000 0.004
#> GSM247659     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247660     5  0.2561      0.808 0.144 0.000  0 0.000 0.856
#> GSM247661     5  0.4114      0.628 0.376 0.000  0 0.000 0.624
#> GSM247662     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247663     1  0.4307     -0.180 0.504 0.000  0 0.000 0.496
#> GSM247856     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247857     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247859     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247860     5  0.2561      0.809 0.144 0.000  0 0.000 0.856
#> GSM247862     5  0.2891      0.811 0.176 0.000  0 0.000 0.824
#> GSM247864     5  0.4210      0.429 0.412 0.000  0 0.000 0.588
#> GSM247865     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247866     5  0.2516      0.806 0.140 0.000  0 0.000 0.860
#> GSM247876     1  0.0794      0.843 0.972 0.000  0 0.000 0.028
#> GSM247877     4  0.3612      0.657 0.000 0.000  0 0.732 0.268
#> GSM247878     4  0.3586      0.663 0.000 0.000  0 0.736 0.264
#> GSM247879     1  0.3452      0.609 0.756 0.000  0 0.000 0.244
#> GSM247881     1  0.0000      0.861 1.000 0.000  0 0.000 0.000
#> GSM247883     1  0.0000      0.861 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
#> GSM246087     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.3737      0.583 0.000 0.000 0.608 0.000 0.000 0.392
#> GSM246090     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246122     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000      0.958 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     4  0.0000      0.677 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246423     4  0.0000      0.677 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246484     4  0.0000      0.677 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246485     6  0.6024      0.000 0.404 0.036 0.000 0.104 0.000 0.456
#> GSM246486     2  0.3847      0.311 0.000 0.544 0.000 0.000 0.000 0.456
#> GSM246487     1  0.3847     -0.690 0.544 0.000 0.000 0.000 0.000 0.456
#> GSM246488     2  0.3979      0.304 0.000 0.540 0.000 0.004 0.000 0.456
#> GSM246489     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0146      0.902 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM247165     2  0.1204      0.870 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM247166     2  0.1204      0.891 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM247168     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.2003      0.870 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM247171     2  0.0000      0.902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0458      0.900 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM247174     2  0.2003      0.870 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM247175     2  0.2003      0.870 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM247188     2  0.2003      0.870 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM247189     4  0.5699      0.168 0.000 0.172 0.000 0.484 0.000 0.344
#> GSM247190     2  0.2003      0.870 0.000 0.884 0.000 0.000 0.000 0.116
#> GSM247650     1  0.3634      0.307 0.644 0.000 0.000 0.000 0.356 0.000
#> GSM247651     1  0.3717      0.261 0.616 0.000 0.000 0.000 0.384 0.000
#> GSM247652     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247653     5  0.3134      0.637 0.144 0.000 0.000 0.000 0.820 0.036
#> GSM247654     1  0.0260      0.790 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM247655     1  0.3607      0.320 0.652 0.000 0.000 0.000 0.348 0.000
#> GSM247656     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247657     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247658     1  0.0146      0.793 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM247659     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247660     5  0.0260      0.666 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM247661     5  0.4165      0.458 0.292 0.000 0.000 0.000 0.672 0.036
#> GSM247662     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247663     5  0.3672      0.217 0.368 0.000 0.000 0.000 0.632 0.000
#> GSM247856     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247859     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247860     5  0.1010      0.663 0.004 0.000 0.000 0.000 0.960 0.036
#> GSM247862     5  0.2092      0.673 0.124 0.000 0.000 0.000 0.876 0.000
#> GSM247864     5  0.3309      0.468 0.280 0.000 0.000 0.000 0.720 0.000
#> GSM247865     1  0.0146      0.793 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM247866     5  0.0146      0.663 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM247876     1  0.0937      0.755 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM247877     4  0.3756      0.378 0.000 0.000 0.000 0.600 0.400 0.000
#> GSM247878     4  0.3747      0.385 0.000 0.000 0.000 0.604 0.396 0.000
#> GSM247879     1  0.3578      0.331 0.660 0.000 0.000 0.000 0.340 0.000
#> GSM247881     1  0.0000      0.796 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247883     1  0.0000      0.796 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-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> ATC:pam 61         5.78e-10 2
#> ATC:pam 61         3.74e-21 3
#> ATC:pam 60         3.16e-21 4
#> ATC:pam 58         3.75e-19 5
#> ATC:pam 47         7.15e-17 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.642           0.778       0.913         0.4559 0.552   0.552
#> 3 3 0.668           0.814       0.898         0.3735 0.727   0.537
#> 4 4 0.707           0.758       0.881         0.1159 0.946   0.851
#> 5 5 0.778           0.701       0.850         0.0991 0.938   0.808
#> 6 6 0.838           0.774       0.861         0.0271 0.936   0.759

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
#> GSM246087     1  0.0000     0.8845 1.000 0.000
#> GSM246088     1  0.0000     0.8845 1.000 0.000
#> GSM246089     1  0.0000     0.8845 1.000 0.000
#> GSM246090     1  0.0000     0.8845 1.000 0.000
#> GSM246119     1  0.0000     0.8845 1.000 0.000
#> GSM246120     1  0.0000     0.8845 1.000 0.000
#> GSM246121     1  0.0000     0.8845 1.000 0.000
#> GSM246122     1  0.0000     0.8845 1.000 0.000
#> GSM246123     1  0.0000     0.8845 1.000 0.000
#> GSM246422     1  0.9881     0.2957 0.564 0.436
#> GSM246423     1  0.9881     0.2957 0.564 0.436
#> GSM246484     1  0.9881     0.2957 0.564 0.436
#> GSM246485     1  0.9954     0.2339 0.540 0.460
#> GSM246486     2  0.5946     0.7660 0.144 0.856
#> GSM246487     2  0.9993    -0.0963 0.484 0.516
#> GSM246488     2  0.8144     0.5988 0.252 0.748
#> GSM246489     2  0.0000     0.9156 0.000 1.000
#> GSM246490     2  0.0000     0.9156 0.000 1.000
#> GSM246491     2  0.0000     0.9156 0.000 1.000
#> GSM247162     2  0.0000     0.9156 0.000 1.000
#> GSM247163     2  0.0000     0.9156 0.000 1.000
#> GSM247164     2  0.0000     0.9156 0.000 1.000
#> GSM247165     2  0.0000     0.9156 0.000 1.000
#> GSM247166     2  0.0000     0.9156 0.000 1.000
#> GSM247168     2  0.0000     0.9156 0.000 1.000
#> GSM247169     2  0.0000     0.9156 0.000 1.000
#> GSM247171     2  0.0000     0.9156 0.000 1.000
#> GSM247173     2  0.0000     0.9156 0.000 1.000
#> GSM247174     2  0.0000     0.9156 0.000 1.000
#> GSM247175     2  0.0000     0.9156 0.000 1.000
#> GSM247188     2  0.0000     0.9156 0.000 1.000
#> GSM247189     2  0.9909     0.0627 0.444 0.556
#> GSM247190     2  0.0000     0.9156 0.000 1.000
#> GSM247650     1  0.0376     0.8859 0.996 0.004
#> GSM247651     1  0.5842     0.7846 0.860 0.140
#> GSM247652     1  0.0376     0.8859 0.996 0.004
#> GSM247653     1  0.0376     0.8859 0.996 0.004
#> GSM247654     1  0.0376     0.8859 0.996 0.004
#> GSM247655     1  0.5842     0.7846 0.860 0.140
#> GSM247656     1  0.0376     0.8859 0.996 0.004
#> GSM247657     1  0.0376     0.8859 0.996 0.004
#> GSM247658     1  0.0376     0.8859 0.996 0.004
#> GSM247659     1  0.0376     0.8859 0.996 0.004
#> GSM247660     1  0.5842     0.7846 0.860 0.140
#> GSM247661     1  0.0376     0.8859 0.996 0.004
#> GSM247662     1  0.0376     0.8859 0.996 0.004
#> GSM247663     1  0.0376     0.8859 0.996 0.004
#> GSM247856     1  0.0376     0.8859 0.996 0.004
#> GSM247857     1  0.0376     0.8859 0.996 0.004
#> GSM247859     1  0.0376     0.8859 0.996 0.004
#> GSM247860     1  0.0376     0.8859 0.996 0.004
#> GSM247862     1  0.0376     0.8859 0.996 0.004
#> GSM247864     1  0.4298     0.8284 0.912 0.088
#> GSM247865     1  0.9896     0.2945 0.560 0.440
#> GSM247866     1  0.0376     0.8859 0.996 0.004
#> GSM247876     1  0.0376     0.8859 0.996 0.004
#> GSM247877     1  0.9522     0.4428 0.628 0.372
#> GSM247878     1  0.9522     0.4428 0.628 0.372
#> GSM247879     1  0.0376     0.8859 0.996 0.004
#> GSM247881     1  0.0376     0.8859 0.996 0.004
#> GSM247883     1  0.9896     0.2945 0.560 0.440

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246088     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246089     3  0.5016      0.723 0.240 0.000 0.760
#> GSM246090     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246119     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246120     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246121     3  0.5621      0.682 0.308 0.000 0.692
#> GSM246122     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246123     3  0.1529      0.776 0.040 0.000 0.960
#> GSM246422     3  0.6473      0.637 0.332 0.016 0.652
#> GSM246423     3  0.6473      0.637 0.332 0.016 0.652
#> GSM246484     3  0.6473      0.637 0.332 0.016 0.652
#> GSM246485     1  0.3686      0.766 0.860 0.140 0.000
#> GSM246486     2  0.6244      0.171 0.440 0.560 0.000
#> GSM246487     1  0.3267      0.794 0.884 0.116 0.000
#> GSM246488     1  0.6192      0.286 0.580 0.420 0.000
#> GSM246489     2  0.0000      0.965 0.000 1.000 0.000
#> GSM246490     2  0.0000      0.965 0.000 1.000 0.000
#> GSM246491     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247162     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247163     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247164     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247165     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247166     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247168     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247169     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247171     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247173     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247174     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247175     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247188     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247189     3  0.9865      0.369 0.292 0.292 0.416
#> GSM247190     2  0.0000      0.965 0.000 1.000 0.000
#> GSM247650     1  0.2356      0.865 0.928 0.000 0.072
#> GSM247651     1  0.3752      0.833 0.856 0.000 0.144
#> GSM247652     1  0.0424      0.884 0.992 0.000 0.008
#> GSM247653     1  0.2261      0.874 0.932 0.000 0.068
#> GSM247654     1  0.0237      0.884 0.996 0.000 0.004
#> GSM247655     1  0.3686      0.836 0.860 0.000 0.140
#> GSM247656     1  0.0592      0.884 0.988 0.000 0.012
#> GSM247657     1  0.0237      0.884 0.996 0.000 0.004
#> GSM247658     1  0.0237      0.884 0.996 0.000 0.004
#> GSM247659     1  0.0000      0.884 1.000 0.000 0.000
#> GSM247660     1  0.3752      0.833 0.856 0.000 0.144
#> GSM247661     1  0.2959      0.862 0.900 0.000 0.100
#> GSM247662     1  0.0424      0.884 0.992 0.000 0.008
#> GSM247663     1  0.3752      0.832 0.856 0.000 0.144
#> GSM247856     1  0.0237      0.884 0.996 0.000 0.004
#> GSM247857     1  0.0000      0.884 1.000 0.000 0.000
#> GSM247859     1  0.0000      0.884 1.000 0.000 0.000
#> GSM247860     1  0.2066      0.875 0.940 0.000 0.060
#> GSM247862     1  0.3619      0.842 0.864 0.000 0.136
#> GSM247864     1  0.3752      0.833 0.856 0.000 0.144
#> GSM247865     1  0.2356      0.830 0.928 0.072 0.000
#> GSM247866     1  0.4062      0.816 0.836 0.000 0.164
#> GSM247876     1  0.1031      0.882 0.976 0.000 0.024
#> GSM247877     3  0.6180      0.635 0.332 0.008 0.660
#> GSM247878     3  0.6307      0.637 0.328 0.012 0.660
#> GSM247879     1  0.6026      0.226 0.624 0.000 0.376
#> GSM247881     1  0.0000      0.884 1.000 0.000 0.000
#> GSM247883     1  0.2356      0.830 0.928 0.072 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM246087     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246088     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246089     3  0.3245      0.834 0.064 0.000 0.880 0.056
#> GSM246090     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246119     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246120     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246121     3  0.2530      0.837 0.112 0.000 0.888 0.000
#> GSM246122     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246123     3  0.0000      0.960 0.000 0.000 1.000 0.000
#> GSM246422     4  0.4462      0.832 0.064 0.132 0.000 0.804
#> GSM246423     4  0.4462      0.832 0.064 0.132 0.000 0.804
#> GSM246484     4  0.4462      0.832 0.064 0.132 0.000 0.804
#> GSM246485     1  0.6779      0.188 0.560 0.324 0.000 0.116
#> GSM246486     2  0.6704      0.253 0.264 0.600 0.000 0.136
#> GSM246487     1  0.6779      0.188 0.560 0.324 0.000 0.116
#> GSM246488     2  0.6794      0.212 0.280 0.584 0.000 0.136
#> GSM246489     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM246490     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247174     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247189     4  0.6784      0.441 0.368 0.104 0.000 0.528
#> GSM247190     2  0.0000      0.934 0.000 1.000 0.000 0.000
#> GSM247650     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247651     1  0.4431      0.644 0.696 0.000 0.000 0.304
#> GSM247652     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247653     1  0.4585      0.633 0.668 0.000 0.000 0.332
#> GSM247654     1  0.1211      0.759 0.960 0.000 0.000 0.040
#> GSM247655     1  0.4222      0.665 0.728 0.000 0.000 0.272
#> GSM247656     1  0.0188      0.760 0.996 0.000 0.000 0.004
#> GSM247657     1  0.1022      0.759 0.968 0.000 0.000 0.032
#> GSM247658     1  0.4250      0.665 0.724 0.000 0.000 0.276
#> GSM247659     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247660     1  0.4431      0.644 0.696 0.000 0.000 0.304
#> GSM247661     1  0.4585      0.633 0.668 0.000 0.000 0.332
#> GSM247662     1  0.0188      0.760 0.996 0.000 0.000 0.004
#> GSM247663     1  0.1211      0.757 0.960 0.000 0.000 0.040
#> GSM247856     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247857     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247859     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247860     1  0.4585      0.633 0.668 0.000 0.000 0.332
#> GSM247862     1  0.4585      0.633 0.668 0.000 0.000 0.332
#> GSM247864     1  0.4277      0.661 0.720 0.000 0.000 0.280
#> GSM247865     1  0.6299      0.252 0.600 0.320 0.000 0.080
#> GSM247866     1  0.4790      0.593 0.620 0.000 0.000 0.380
#> GSM247876     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247877     4  0.1716      0.787 0.064 0.000 0.000 0.936
#> GSM247878     4  0.1716      0.787 0.064 0.000 0.000 0.936
#> GSM247879     1  0.2281      0.743 0.904 0.000 0.000 0.096
#> GSM247881     1  0.0000      0.761 1.000 0.000 0.000 0.000
#> GSM247883     1  0.5936      0.286 0.620 0.324 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
#> GSM246087     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246088     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246089     3  0.1270     0.9514 0.000 0.000 0.948 0.000 0.052
#> GSM246090     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246119     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246120     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246121     3  0.1818     0.9397 0.024 0.000 0.932 0.000 0.044
#> GSM246122     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246123     3  0.0000     0.9859 0.000 0.000 1.000 0.000 0.000
#> GSM246422     4  0.0000     0.8388 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0000     0.8388 0.000 0.000 0.000 1.000 0.000
#> GSM246484     4  0.0000     0.8388 0.000 0.000 0.000 1.000 0.000
#> GSM246485     5  0.5960     0.3953 0.264 0.004 0.000 0.140 0.592
#> GSM246486     5  0.6186     0.3247 0.016 0.224 0.000 0.156 0.604
#> GSM246487     5  0.6177     0.3232 0.400 0.000 0.000 0.136 0.464
#> GSM246488     5  0.6214     0.3120 0.016 0.172 0.000 0.208 0.604
#> GSM246489     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0404     0.9864 0.000 0.988 0.000 0.012 0.000
#> GSM247165     2  0.0609     0.9776 0.000 0.980 0.000 0.020 0.000
#> GSM247166     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247174     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247189     4  0.6821    -0.0806 0.168 0.020 0.000 0.476 0.336
#> GSM247190     2  0.0000     0.9976 0.000 1.000 0.000 0.000 0.000
#> GSM247650     1  0.1608     0.6555 0.928 0.000 0.000 0.000 0.072
#> GSM247651     1  0.6495     0.2683 0.424 0.000 0.000 0.188 0.388
#> GSM247652     1  0.0000     0.6670 1.000 0.000 0.000 0.000 0.000
#> GSM247653     1  0.4161     0.5241 0.608 0.000 0.000 0.000 0.392
#> GSM247654     1  0.3109     0.6253 0.800 0.000 0.000 0.000 0.200
#> GSM247655     1  0.6475     0.2727 0.428 0.000 0.000 0.184 0.388
#> GSM247656     1  0.0404     0.6694 0.988 0.000 0.000 0.000 0.012
#> GSM247657     1  0.3074     0.6266 0.804 0.000 0.000 0.000 0.196
#> GSM247658     1  0.5421     0.5396 0.628 0.000 0.000 0.096 0.276
#> GSM247659     1  0.0290     0.6673 0.992 0.000 0.000 0.000 0.008
#> GSM247660     1  0.6436     0.2740 0.428 0.000 0.000 0.176 0.396
#> GSM247661     1  0.4182     0.5243 0.600 0.000 0.000 0.000 0.400
#> GSM247662     1  0.0290     0.6691 0.992 0.000 0.000 0.000 0.008
#> GSM247663     1  0.3561     0.4941 0.740 0.000 0.000 0.000 0.260
#> GSM247856     1  0.0703     0.6693 0.976 0.000 0.000 0.000 0.024
#> GSM247857     1  0.0162     0.6676 0.996 0.000 0.000 0.000 0.004
#> GSM247859     1  0.0000     0.6670 1.000 0.000 0.000 0.000 0.000
#> GSM247860     1  0.4182     0.5243 0.600 0.000 0.000 0.000 0.400
#> GSM247862     1  0.4905     0.4566 0.500 0.000 0.000 0.024 0.476
#> GSM247864     1  0.6475     0.2777 0.428 0.000 0.000 0.184 0.388
#> GSM247865     1  0.4907     0.2260 0.656 0.000 0.000 0.052 0.292
#> GSM247866     5  0.4613    -0.3862 0.360 0.000 0.000 0.020 0.620
#> GSM247876     1  0.2127     0.6335 0.892 0.000 0.000 0.000 0.108
#> GSM247877     4  0.1670     0.8104 0.012 0.000 0.000 0.936 0.052
#> GSM247878     4  0.1430     0.8158 0.004 0.000 0.000 0.944 0.052
#> GSM247879     1  0.4333     0.6130 0.740 0.000 0.000 0.048 0.212
#> GSM247881     1  0.0162     0.6676 0.996 0.000 0.000 0.000 0.004
#> GSM247883     1  0.4030     0.1359 0.648 0.000 0.000 0.000 0.352

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM246087     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246088     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     3  0.5336      0.584 0.000 0.000 0.592 0.180 0.000 0.228
#> GSM246090     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246119     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246120     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246121     3  0.1152      0.917 0.004 0.000 0.952 0.000 0.000 0.044
#> GSM246122     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246123     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246422     5  0.2454      0.835 0.000 0.000 0.000 0.160 0.840 0.000
#> GSM246423     5  0.2454      0.835 0.000 0.000 0.000 0.160 0.840 0.000
#> GSM246484     5  0.2454      0.835 0.000 0.000 0.000 0.160 0.840 0.000
#> GSM246485     4  0.3592      0.751 0.020 0.000 0.000 0.740 0.000 0.240
#> GSM246486     4  0.3420      0.759 0.000 0.012 0.000 0.748 0.000 0.240
#> GSM246487     4  0.3151      0.493 0.252 0.000 0.000 0.748 0.000 0.000
#> GSM246488     4  0.3420      0.759 0.000 0.012 0.000 0.748 0.000 0.240
#> GSM246489     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246490     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247162     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247163     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247164     2  0.0146      0.991 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM247165     2  0.1610      0.907 0.000 0.916 0.000 0.084 0.000 0.000
#> GSM247166     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247168     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247169     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247171     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247173     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247175     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     4  0.3330      0.393 0.000 0.000 0.000 0.716 0.284 0.000
#> GSM247190     2  0.0000      0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247650     1  0.1720      0.763 0.928 0.000 0.000 0.040 0.000 0.032
#> GSM247651     6  0.6528      0.766 0.316 0.000 0.000 0.052 0.164 0.468
#> GSM247652     1  0.0000      0.779 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247653     1  0.3706      0.335 0.620 0.000 0.000 0.000 0.000 0.380
#> GSM247654     1  0.1700      0.743 0.916 0.000 0.000 0.000 0.004 0.080
#> GSM247655     6  0.6732      0.761 0.328 0.000 0.000 0.068 0.164 0.440
#> GSM247656     1  0.1168      0.776 0.956 0.000 0.000 0.016 0.000 0.028
#> GSM247657     1  0.1806      0.741 0.908 0.000 0.000 0.000 0.004 0.088
#> GSM247658     1  0.1858      0.735 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM247659     1  0.1296      0.776 0.952 0.000 0.000 0.012 0.004 0.032
#> GSM247660     6  0.6584      0.765 0.320 0.000 0.000 0.056 0.164 0.460
#> GSM247661     1  0.4310      0.300 0.580 0.000 0.000 0.024 0.000 0.396
#> GSM247662     1  0.0000      0.779 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247663     1  0.4602     -0.290 0.572 0.000 0.000 0.044 0.000 0.384
#> GSM247856     1  0.1390      0.775 0.948 0.000 0.000 0.016 0.004 0.032
#> GSM247857     1  0.0000      0.779 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM247859     1  0.0777      0.770 0.972 0.000 0.000 0.024 0.000 0.004
#> GSM247860     1  0.3727      0.326 0.612 0.000 0.000 0.000 0.000 0.388
#> GSM247862     6  0.4617      0.124 0.444 0.000 0.000 0.024 0.008 0.524
#> GSM247864     6  0.6362      0.761 0.312 0.000 0.000 0.040 0.164 0.484
#> GSM247865     1  0.2994      0.572 0.788 0.000 0.000 0.208 0.000 0.004
#> GSM247866     6  0.3352      0.529 0.172 0.000 0.000 0.012 0.016 0.800
#> GSM247876     1  0.0935      0.778 0.964 0.000 0.000 0.004 0.000 0.032
#> GSM247877     5  0.2240      0.733 0.032 0.000 0.000 0.016 0.908 0.044
#> GSM247878     5  0.1549      0.765 0.000 0.000 0.000 0.020 0.936 0.044
#> GSM247879     1  0.2776      0.705 0.860 0.000 0.000 0.032 0.004 0.104
#> GSM247881     1  0.0405      0.776 0.988 0.000 0.000 0.008 0.000 0.004
#> GSM247883     1  0.3383      0.468 0.728 0.000 0.000 0.268 0.000 0.004

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:mclust 51         8.42e-12 2
#> ATC:mclust 57         2.32e-15 3
#> ATC:mclust 54         9.16e-20 4
#> ATC:mclust 47         7.65e-17 5
#> ATC:mclust 53         4.93e-17 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 21168 rows and 61 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.961       0.986         0.4914 0.508   0.508
#> 3 3 0.869           0.865       0.947         0.3342 0.751   0.549
#> 4 4 0.675           0.653       0.825         0.1239 0.797   0.489
#> 5 5 0.763           0.701       0.858         0.0554 0.954   0.820
#> 6 6 0.745           0.583       0.799         0.0306 0.975   0.889

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 2

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM246087     1  0.0000      0.989 1.000 0.000
#> GSM246088     1  0.0000      0.989 1.000 0.000
#> GSM246089     1  0.0000      0.989 1.000 0.000
#> GSM246090     1  0.0000      0.989 1.000 0.000
#> GSM246119     1  0.0000      0.989 1.000 0.000
#> GSM246120     1  0.0000      0.989 1.000 0.000
#> GSM246121     1  0.0000      0.989 1.000 0.000
#> GSM246122     1  0.0000      0.989 1.000 0.000
#> GSM246123     1  0.0000      0.989 1.000 0.000
#> GSM246422     2  0.0000      0.980 0.000 1.000
#> GSM246423     2  0.0672      0.973 0.008 0.992
#> GSM246484     2  0.0000      0.980 0.000 1.000
#> GSM246485     2  0.0000      0.980 0.000 1.000
#> GSM246486     2  0.0000      0.980 0.000 1.000
#> GSM246487     2  0.0000      0.980 0.000 1.000
#> GSM246488     2  0.0000      0.980 0.000 1.000
#> GSM246489     2  0.0000      0.980 0.000 1.000
#> GSM246490     2  0.0000      0.980 0.000 1.000
#> GSM246491     2  0.0000      0.980 0.000 1.000
#> GSM247162     2  0.0000      0.980 0.000 1.000
#> GSM247163     2  0.0000      0.980 0.000 1.000
#> GSM247164     2  0.0000      0.980 0.000 1.000
#> GSM247165     2  0.0000      0.980 0.000 1.000
#> GSM247166     2  0.0000      0.980 0.000 1.000
#> GSM247168     2  0.0000      0.980 0.000 1.000
#> GSM247169     2  0.0000      0.980 0.000 1.000
#> GSM247171     2  0.0000      0.980 0.000 1.000
#> GSM247173     2  0.0000      0.980 0.000 1.000
#> GSM247174     2  0.0000      0.980 0.000 1.000
#> GSM247175     2  0.0000      0.980 0.000 1.000
#> GSM247188     2  0.0000      0.980 0.000 1.000
#> GSM247189     2  0.0000      0.980 0.000 1.000
#> GSM247190     2  0.0000      0.980 0.000 1.000
#> GSM247650     1  0.0000      0.989 1.000 0.000
#> GSM247651     1  0.0000      0.989 1.000 0.000
#> GSM247652     1  0.0000      0.989 1.000 0.000
#> GSM247653     1  0.0000      0.989 1.000 0.000
#> GSM247654     1  0.0000      0.989 1.000 0.000
#> GSM247655     1  0.0000      0.989 1.000 0.000
#> GSM247656     1  0.0000      0.989 1.000 0.000
#> GSM247657     1  0.0000      0.989 1.000 0.000
#> GSM247658     1  0.0000      0.989 1.000 0.000
#> GSM247659     1  0.0000      0.989 1.000 0.000
#> GSM247660     1  0.0000      0.989 1.000 0.000
#> GSM247661     1  0.0000      0.989 1.000 0.000
#> GSM247662     1  0.0000      0.989 1.000 0.000
#> GSM247663     1  0.0000      0.989 1.000 0.000
#> GSM247856     1  0.0000      0.989 1.000 0.000
#> GSM247857     1  0.0000      0.989 1.000 0.000
#> GSM247859     1  0.0000      0.989 1.000 0.000
#> GSM247860     1  0.0000      0.989 1.000 0.000
#> GSM247862     1  0.0000      0.989 1.000 0.000
#> GSM247864     1  0.0000      0.989 1.000 0.000
#> GSM247865     1  0.9635      0.342 0.612 0.388
#> GSM247866     1  0.0000      0.989 1.000 0.000
#> GSM247876     1  0.0000      0.989 1.000 0.000
#> GSM247877     1  0.0000      0.989 1.000 0.000
#> GSM247878     1  0.0000      0.989 1.000 0.000
#> GSM247879     1  0.0000      0.989 1.000 0.000
#> GSM247881     1  0.0000      0.989 1.000 0.000
#> GSM247883     2  0.9922      0.168 0.448 0.552

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM246087     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246088     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246089     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246090     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246119     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246120     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246121     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246122     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246123     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM246422     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM246423     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM246484     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM246485     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM246486     2  0.0747     0.9587 0.016 0.984 0.000
#> GSM246487     2  0.6095     0.2811 0.392 0.608 0.000
#> GSM246488     1  0.5968     0.4158 0.636 0.364 0.000
#> GSM246489     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM246490     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM246491     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247162     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247163     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247164     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247165     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247166     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247168     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247169     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247171     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247173     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247174     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247175     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247188     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247189     1  0.0424     0.9182 0.992 0.008 0.000
#> GSM247190     2  0.0000     0.9736 0.000 1.000 0.000
#> GSM247650     3  0.0237     0.9222 0.004 0.000 0.996
#> GSM247651     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM247652     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247653     3  0.0424     0.9198 0.008 0.000 0.992
#> GSM247654     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247655     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM247656     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247657     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247658     3  0.4702     0.7136 0.212 0.000 0.788
#> GSM247659     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247660     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM247661     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247662     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247663     3  0.6274     0.1795 0.456 0.000 0.544
#> GSM247856     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247857     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247859     3  0.5431     0.6039 0.284 0.000 0.716
#> GSM247860     3  0.5591     0.5676 0.304 0.000 0.696
#> GSM247862     1  0.4887     0.6680 0.772 0.000 0.228
#> GSM247864     1  0.0237     0.9219 0.996 0.000 0.004
#> GSM247865     1  0.7529     0.4529 0.624 0.060 0.316
#> GSM247866     1  0.0237     0.9219 0.996 0.000 0.004
#> GSM247876     3  0.1031     0.9086 0.024 0.000 0.976
#> GSM247877     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM247878     1  0.0000     0.9238 1.000 0.000 0.000
#> GSM247879     3  0.2537     0.8620 0.080 0.000 0.920
#> GSM247881     3  0.0000     0.9244 0.000 0.000 1.000
#> GSM247883     3  0.6952     0.0931 0.016 0.480 0.504

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM246087     3  0.0188     0.7711 0.004 0.000 0.996 0.000
#> GSM246088     3  0.0188     0.7711 0.004 0.000 0.996 0.000
#> GSM246089     3  0.3831     0.6097 0.204 0.000 0.792 0.004
#> GSM246090     3  0.0188     0.7711 0.004 0.000 0.996 0.000
#> GSM246119     3  0.0707     0.7653 0.020 0.000 0.980 0.000
#> GSM246120     3  0.0336     0.7695 0.008 0.000 0.992 0.000
#> GSM246121     3  0.1637     0.7456 0.060 0.000 0.940 0.000
#> GSM246122     3  0.0336     0.7704 0.008 0.000 0.992 0.000
#> GSM246123     3  0.0188     0.7702 0.004 0.000 0.996 0.000
#> GSM246422     4  0.0000     0.7754 0.000 0.000 0.000 1.000
#> GSM246423     4  0.0188     0.7752 0.004 0.000 0.000 0.996
#> GSM246484     4  0.0000     0.7754 0.000 0.000 0.000 1.000
#> GSM246485     4  0.1637     0.7599 0.060 0.000 0.000 0.940
#> GSM246486     2  0.1406     0.9231 0.016 0.960 0.000 0.024
#> GSM246487     1  0.7641     0.2383 0.500 0.264 0.004 0.232
#> GSM246488     4  0.5592     0.2777 0.024 0.404 0.000 0.572
#> GSM246489     2  0.0188     0.9552 0.004 0.996 0.000 0.000
#> GSM246490     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM246491     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247162     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247163     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247164     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247165     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247166     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247168     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247169     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247171     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247173     2  0.0188     0.9553 0.004 0.996 0.000 0.000
#> GSM247174     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247175     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247188     2  0.0000     0.9577 0.000 1.000 0.000 0.000
#> GSM247189     4  0.1576     0.7552 0.004 0.048 0.000 0.948
#> GSM247190     2  0.0188     0.9553 0.004 0.996 0.000 0.000
#> GSM247650     3  0.3908     0.6089 0.212 0.000 0.784 0.004
#> GSM247651     4  0.4049     0.5753 0.212 0.000 0.008 0.780
#> GSM247652     1  0.4967     0.2916 0.548 0.000 0.452 0.000
#> GSM247653     1  0.2868     0.6321 0.864 0.000 0.136 0.000
#> GSM247654     1  0.4222     0.6063 0.728 0.000 0.272 0.000
#> GSM247655     1  0.5203     0.3021 0.576 0.000 0.008 0.416
#> GSM247656     3  0.3907     0.5793 0.232 0.000 0.768 0.000
#> GSM247657     1  0.4250     0.6029 0.724 0.000 0.276 0.000
#> GSM247658     1  0.5174     0.6742 0.756 0.000 0.152 0.092
#> GSM247659     3  0.4877     0.1369 0.408 0.000 0.592 0.000
#> GSM247660     1  0.4925     0.2144 0.572 0.000 0.000 0.428
#> GSM247661     1  0.3219     0.6077 0.836 0.000 0.164 0.000
#> GSM247662     3  0.4972    -0.0611 0.456 0.000 0.544 0.000
#> GSM247663     4  0.7646     0.0581 0.244 0.000 0.292 0.464
#> GSM247856     3  0.2704     0.7075 0.124 0.000 0.876 0.000
#> GSM247857     1  0.4866     0.3977 0.596 0.000 0.404 0.000
#> GSM247859     1  0.5747     0.6582 0.704 0.000 0.196 0.100
#> GSM247860     1  0.2859     0.6185 0.880 0.000 0.112 0.008
#> GSM247862     1  0.4776     0.6434 0.776 0.000 0.060 0.164
#> GSM247864     4  0.5403     0.3028 0.348 0.000 0.024 0.628
#> GSM247865     1  0.5934     0.6120 0.704 0.012 0.076 0.208
#> GSM247866     1  0.4482     0.3502 0.728 0.000 0.008 0.264
#> GSM247876     3  0.6147     0.4875 0.224 0.000 0.664 0.112
#> GSM247877     4  0.3257     0.6926 0.152 0.000 0.004 0.844
#> GSM247878     4  0.0592     0.7736 0.016 0.000 0.000 0.984
#> GSM247879     3  0.6795     0.1749 0.432 0.000 0.472 0.096
#> GSM247881     1  0.4761     0.4721 0.628 0.000 0.372 0.000
#> GSM247883     2  0.7517    -0.2559 0.388 0.428 0.184 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
#> GSM246087     3  0.0671     0.8279 0.016 0.000 0.980 0.000 0.004
#> GSM246088     3  0.0566     0.8270 0.012 0.000 0.984 0.000 0.004
#> GSM246089     5  0.4015     0.3990 0.000 0.000 0.348 0.000 0.652
#> GSM246090     3  0.0671     0.8275 0.016 0.000 0.980 0.000 0.004
#> GSM246119     3  0.1670     0.7945 0.012 0.000 0.936 0.000 0.052
#> GSM246120     3  0.0865     0.8139 0.004 0.000 0.972 0.000 0.024
#> GSM246121     3  0.2723     0.7211 0.012 0.000 0.864 0.000 0.124
#> GSM246122     3  0.0898     0.8280 0.020 0.000 0.972 0.000 0.008
#> GSM246123     3  0.0671     0.8186 0.004 0.000 0.980 0.000 0.016
#> GSM246422     4  0.0000     0.7549 0.000 0.000 0.000 1.000 0.000
#> GSM246423     4  0.0609     0.7531 0.000 0.000 0.000 0.980 0.020
#> GSM246484     4  0.0290     0.7541 0.000 0.000 0.000 0.992 0.008
#> GSM246485     4  0.1670     0.7423 0.012 0.000 0.000 0.936 0.052
#> GSM246486     2  0.1082     0.9297 0.000 0.964 0.000 0.028 0.008
#> GSM246487     1  0.6646     0.4096 0.608 0.216 0.004 0.112 0.060
#> GSM246488     4  0.3978     0.6210 0.004 0.148 0.000 0.796 0.052
#> GSM246489     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM246490     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM246491     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247162     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247163     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247164     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247165     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247166     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247168     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247169     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247171     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247173     2  0.0162     0.9593 0.000 0.996 0.000 0.000 0.004
#> GSM247174     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247175     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9620 0.000 1.000 0.000 0.000 0.000
#> GSM247189     4  0.2142     0.7365 0.004 0.028 0.000 0.920 0.048
#> GSM247190     2  0.0290     0.9563 0.000 0.992 0.000 0.000 0.008
#> GSM247650     3  0.2930     0.7650 0.164 0.000 0.832 0.000 0.004
#> GSM247651     4  0.5002     0.2885 0.364 0.000 0.000 0.596 0.040
#> GSM247652     1  0.3861     0.5627 0.728 0.000 0.264 0.000 0.008
#> GSM247653     1  0.3741     0.4869 0.732 0.000 0.004 0.000 0.264
#> GSM247654     1  0.1740     0.7224 0.932 0.000 0.056 0.000 0.012
#> GSM247655     1  0.2522     0.6965 0.880 0.000 0.000 0.108 0.012
#> GSM247656     3  0.2583     0.7880 0.132 0.000 0.864 0.000 0.004
#> GSM247657     1  0.1638     0.7218 0.932 0.000 0.064 0.000 0.004
#> GSM247658     1  0.2144     0.7001 0.912 0.000 0.020 0.000 0.068
#> GSM247659     3  0.4238     0.4850 0.368 0.000 0.628 0.000 0.004
#> GSM247660     1  0.3412     0.6457 0.820 0.000 0.000 0.152 0.028
#> GSM247661     1  0.4663     0.2203 0.604 0.000 0.020 0.000 0.376
#> GSM247662     3  0.5013     0.4714 0.352 0.000 0.612 0.008 0.028
#> GSM247663     4  0.7951     0.0331 0.292 0.000 0.260 0.368 0.080
#> GSM247856     3  0.2249     0.8098 0.096 0.000 0.896 0.000 0.008
#> GSM247857     1  0.4043     0.6088 0.756 0.000 0.220 0.012 0.012
#> GSM247859     1  0.1990     0.7204 0.920 0.000 0.068 0.008 0.004
#> GSM247860     5  0.4356     0.4909 0.340 0.000 0.012 0.000 0.648
#> GSM247862     1  0.2629     0.6729 0.880 0.000 0.004 0.012 0.104
#> GSM247864     1  0.5377     0.0370 0.496 0.000 0.004 0.456 0.044
#> GSM247865     1  0.4432     0.6769 0.820 0.040 0.028 0.064 0.048
#> GSM247866     5  0.4244     0.5837 0.268 0.000 0.004 0.016 0.712
#> GSM247876     3  0.6451     0.4551 0.212 0.000 0.612 0.048 0.128
#> GSM247877     4  0.4291     0.2029 0.000 0.000 0.000 0.536 0.464
#> GSM247878     4  0.1571     0.7414 0.004 0.000 0.000 0.936 0.060
#> GSM247879     5  0.3361     0.5935 0.020 0.000 0.092 0.032 0.856
#> GSM247881     1  0.2674     0.6877 0.856 0.000 0.140 0.000 0.004
#> GSM247883     2  0.6447    -0.0629 0.420 0.472 0.080 0.008 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
#> GSM246087     3  0.1152     0.7233 0.004 0.000 0.952 0.000 0.044 0.000
#> GSM246088     3  0.0000     0.7323 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM246089     6  0.4084     0.0928 0.000 0.000 0.400 0.000 0.012 0.588
#> GSM246090     3  0.0260     0.7330 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM246119     3  0.0972     0.7145 0.000 0.000 0.964 0.000 0.008 0.028
#> GSM246120     3  0.0260     0.7295 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM246121     3  0.3351     0.5886 0.004 0.000 0.808 0.000 0.036 0.152
#> GSM246122     3  0.0692     0.7325 0.004 0.000 0.976 0.000 0.020 0.000
#> GSM246123     3  0.0858     0.7306 0.000 0.000 0.968 0.000 0.028 0.004
#> GSM246422     4  0.0000     0.7693 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM246423     4  0.0146     0.7687 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM246484     4  0.0146     0.7695 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM246485     4  0.6525     0.4493 0.104 0.036 0.000 0.556 0.260 0.044
#> GSM246486     2  0.1196     0.9195 0.000 0.952 0.000 0.040 0.008 0.000
#> GSM246487     1  0.7322     0.1080 0.464 0.196 0.000 0.124 0.204 0.012
#> GSM246488     4  0.2804     0.6752 0.000 0.120 0.000 0.852 0.024 0.004
#> GSM246489     2  0.0260     0.9536 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM246490     2  0.0000     0.9547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM246491     2  0.0260     0.9530 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247162     2  0.0260     0.9530 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM247163     2  0.0146     0.9539 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM247164     2  0.0000     0.9547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247165     2  0.0458     0.9512 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM247166     2  0.0547     0.9493 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM247168     2  0.0547     0.9493 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM247169     2  0.0458     0.9512 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM247171     2  0.0405     0.9509 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM247173     2  0.0000     0.9547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247174     2  0.0146     0.9544 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM247175     2  0.0000     0.9547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247188     2  0.0000     0.9547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM247189     4  0.2119     0.7529 0.000 0.008 0.000 0.912 0.044 0.036
#> GSM247190     2  0.0146     0.9541 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM247650     3  0.5117     0.3223 0.116 0.000 0.596 0.000 0.288 0.000
#> GSM247651     4  0.5646     0.1993 0.348 0.000 0.000 0.532 0.100 0.020
#> GSM247652     1  0.4369     0.3783 0.720 0.000 0.116 0.000 0.164 0.000
#> GSM247653     1  0.4312    -0.0327 0.604 0.000 0.000 0.000 0.028 0.368
#> GSM247654     1  0.1341     0.6003 0.948 0.000 0.024 0.000 0.028 0.000
#> GSM247655     1  0.3907     0.5211 0.764 0.000 0.000 0.152 0.084 0.000
#> GSM247656     3  0.4327     0.4694 0.056 0.000 0.680 0.000 0.264 0.000
#> GSM247657     1  0.2011     0.6057 0.912 0.000 0.020 0.000 0.064 0.004
#> GSM247658     1  0.1485     0.6033 0.944 0.000 0.004 0.000 0.024 0.028
#> GSM247659     3  0.5817     0.0320 0.208 0.000 0.480 0.000 0.312 0.000
#> GSM247660     1  0.3233     0.5714 0.828 0.000 0.000 0.132 0.024 0.016
#> GSM247661     1  0.4700    -0.3002 0.500 0.000 0.000 0.000 0.044 0.456
#> GSM247662     3  0.6103    -0.0883 0.320 0.000 0.432 0.004 0.244 0.000
#> GSM247663     5  0.8177     0.4749 0.172 0.000 0.272 0.144 0.356 0.056
#> GSM247856     3  0.4176     0.5328 0.200 0.000 0.740 0.000 0.044 0.016
#> GSM247857     1  0.5044     0.2674 0.644 0.000 0.128 0.004 0.224 0.000
#> GSM247859     1  0.3702     0.4852 0.784 0.000 0.044 0.008 0.164 0.000
#> GSM247860     6  0.3937     0.2553 0.424 0.000 0.000 0.000 0.004 0.572
#> GSM247862     1  0.2112     0.5491 0.896 0.000 0.000 0.000 0.016 0.088
#> GSM247864     1  0.4661     0.0561 0.500 0.000 0.000 0.464 0.004 0.032
#> GSM247865     1  0.5531     0.4518 0.660 0.016 0.000 0.064 0.212 0.048
#> GSM247866     6  0.4157     0.4367 0.276 0.000 0.000 0.004 0.032 0.688
#> GSM247876     5  0.6174     0.5306 0.160 0.000 0.224 0.008 0.572 0.036
#> GSM247877     4  0.5303     0.4249 0.000 0.000 0.000 0.548 0.120 0.332
#> GSM247878     4  0.1934     0.7518 0.000 0.000 0.000 0.916 0.044 0.040
#> GSM247879     5  0.7599     0.1864 0.092 0.000 0.112 0.056 0.380 0.360
#> GSM247881     5  0.5428     0.2468 0.396 0.000 0.120 0.000 0.484 0.000
#> GSM247883     2  0.6913    -0.2032 0.272 0.420 0.064 0.000 0.244 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-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) k
#> ATC:NMF 59         1.54e-13 2
#> ATC:NMF 56         1.21e-09 3
#> ATC:NMF 46         7.13e-12 4
#> ATC:NMF 48         1.53e-12 5
#> ATC:NMF 39         5.47e-11 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