cola Report for GDS1597

Date: 2019-12-25 20:17:11 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 19411 rows and 51 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] 19411    51

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 2 1.000 0.982 0.992 **
SD:NMF 3 1.000 0.978 0.990 ** 2
CV:mclust 2 1.000 0.983 0.993 **
MAD:hclust 2 1.000 0.979 0.990 **
MAD:mclust 2 1.000 0.949 0.981 **
ATC:hclust 3 1.000 1.000 1.000 **
ATC:kmeans 2 1.000 0.974 0.990 **
ATC:pam 2 1.000 0.991 0.996 **
SD:pam 6 0.995 0.952 0.975 ** 2,4,5
MAD:skmeans 3 0.943 0.950 0.975 * 2
MAD:NMF 3 0.937 0.908 0.961 * 2
MAD:pam 6 0.925 0.903 0.956 * 5
ATC:skmeans 3 0.918 0.936 0.956 * 2
SD:skmeans 3 0.918 0.932 0.972 * 2
SD:hclust 5 0.903 0.938 0.971 * 2
CV:pam 3 0.888 0.928 0.965
CV:skmeans 3 0.880 0.932 0.970
ATC:NMF 2 0.879 0.891 0.957
ATC:mclust 5 0.871 0.899 0.956
SD:mclust 2 0.824 0.882 0.938
MAD:kmeans 5 0.768 0.813 0.852
CV:NMF 2 0.728 0.845 0.938
CV:kmeans 2 0.437 0.794 0.886
CV:hclust 3 0.400 0.584 0.765

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.978       0.990          0.415 0.594   0.594
#> CV:NMF      2 0.728           0.845       0.938          0.465 0.547   0.547
#> MAD:NMF     2 0.918           0.908       0.964          0.440 0.561   0.561
#> ATC:NMF     2 0.879           0.891       0.957          0.441 0.547   0.547
#> SD:skmeans  2 0.957           0.965       0.982          0.497 0.506   0.506
#> CV:skmeans  2 0.841           0.929       0.970          0.508 0.492   0.492
#> MAD:skmeans 2 0.918           0.924       0.967          0.500 0.506   0.506
#> ATC:skmeans 2 1.000           0.991       0.996          0.488 0.514   0.514
#> SD:mclust   2 0.824           0.882       0.938          0.445 0.534   0.534
#> CV:mclust   2 1.000           0.983       0.993          0.394 0.613   0.613
#> MAD:mclust  2 1.000           0.949       0.981          0.465 0.534   0.534
#> ATC:mclust  2 0.680           0.868       0.926          0.471 0.534   0.534
#> SD:kmeans   2 1.000           0.982       0.992          0.402 0.594   0.594
#> CV:kmeans   2 0.437           0.794       0.886          0.468 0.500   0.500
#> MAD:kmeans  2 0.849           0.933       0.967          0.429 0.594   0.594
#> ATC:kmeans  2 1.000           0.974       0.990          0.479 0.523   0.523
#> SD:pam      2 0.958           0.926       0.972          0.381 0.613   0.613
#> CV:pam      2 0.731           0.800       0.924          0.361 0.633   0.633
#> MAD:pam     2 0.841           0.872       0.949          0.429 0.561   0.561
#> ATC:pam     2 1.000           0.991       0.996          0.479 0.523   0.523
#> SD:hclust   2 1.000           0.995       0.998          0.390 0.613   0.613
#> CV:hclust   2 0.361           0.661       0.827          0.370 0.730   0.730
#> MAD:hclust  2 1.000           0.979       0.990          0.422 0.576   0.576
#> ATC:hclust  2 0.758           0.957       0.977          0.405 0.613   0.613
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.978       0.990          0.396 0.749   0.603
#> CV:NMF      3 0.570           0.765       0.871          0.343 0.742   0.564
#> MAD:NMF     3 0.937           0.908       0.961          0.357 0.772   0.618
#> ATC:NMF     3 0.713           0.775       0.867          0.202 0.881   0.787
#> SD:skmeans  3 0.918           0.932       0.972          0.313 0.699   0.477
#> CV:skmeans  3 0.880           0.932       0.970          0.308 0.737   0.517
#> MAD:skmeans 3 0.943           0.950       0.975          0.305 0.733   0.523
#> ATC:skmeans 3 0.918           0.936       0.956          0.172 0.900   0.807
#> SD:mclust   3 0.596           0.551       0.812          0.325 0.721   0.522
#> CV:mclust   3 0.624           0.815       0.893          0.626 0.708   0.531
#> MAD:mclust  3 0.746           0.900       0.925          0.359 0.654   0.434
#> ATC:mclust  3 0.648           0.849       0.883          0.349 0.767   0.576
#> SD:kmeans   3 0.522           0.652       0.844          0.473 0.795   0.668
#> CV:kmeans   3 0.662           0.781       0.883          0.349 0.695   0.463
#> MAD:kmeans  3 0.676           0.780       0.882          0.451 0.757   0.596
#> ATC:kmeans  3 0.867           0.831       0.929          0.302 0.809   0.651
#> SD:pam      3 0.848           0.867       0.950          0.683 0.663   0.484
#> CV:pam      3 0.888           0.928       0.965          0.793 0.645   0.473
#> MAD:pam     3 0.674           0.833       0.928          0.509 0.707   0.514
#> ATC:pam     3 0.821           0.938       0.968          0.374 0.706   0.488
#> SD:hclust   3 0.687           0.926       0.915          0.207 0.967   0.946
#> CV:hclust   3 0.400           0.584       0.765          0.563 0.802   0.729
#> MAD:hclust  3 0.750           0.833       0.910          0.480 0.784   0.626
#> ATC:hclust  3 1.000           1.000       1.000          0.380 0.830   0.722
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.830           0.855       0.923         0.2735 0.788   0.522
#> CV:NMF      4 0.539           0.499       0.748         0.1233 0.940   0.844
#> MAD:NMF     4 0.855           0.862       0.936         0.2510 0.807   0.549
#> ATC:NMF     4 0.596           0.657       0.799         0.1870 0.874   0.738
#> SD:skmeans  4 0.828           0.823       0.907         0.1173 0.897   0.711
#> CV:skmeans  4 0.718           0.610       0.823         0.1139 0.976   0.929
#> MAD:skmeans 4 0.794           0.822       0.860         0.1237 0.882   0.675
#> ATC:skmeans 4 0.802           0.901       0.929         0.1754 0.874   0.702
#> SD:mclust   4 0.586           0.681       0.806         0.2060 0.839   0.596
#> CV:mclust   4 0.801           0.859       0.901         0.0926 0.962   0.890
#> MAD:mclust  4 0.866           0.907       0.954         0.1468 0.939   0.821
#> ATC:mclust  4 0.717           0.757       0.883         0.0983 0.835   0.574
#> SD:kmeans   4 0.615           0.733       0.798         0.1664 0.740   0.472
#> CV:kmeans   4 0.579           0.611       0.770         0.1149 0.976   0.929
#> MAD:kmeans  4 0.629           0.621       0.777         0.1514 0.817   0.553
#> ATC:kmeans  4 0.723           0.867       0.867         0.1586 0.805   0.530
#> SD:pam      4 0.972           0.954       0.980         0.1122 0.889   0.708
#> CV:pam      4 0.860           0.920       0.938         0.0707 0.955   0.874
#> MAD:pam     4 0.761           0.824       0.889         0.0950 0.865   0.650
#> ATC:pam     4 0.838           0.905       0.919         0.0801 0.967   0.901
#> SD:hclust   4 0.889           0.938       0.971         0.4410 0.745   0.560
#> CV:hclust   4 0.551           0.641       0.745         0.1180 0.869   0.765
#> MAD:hclust  4 0.725           0.821       0.907         0.0818 0.956   0.878
#> ATC:hclust  4 0.793           0.935       0.916         0.1170 0.967   0.926
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.814           0.779       0.893         0.0416 0.940   0.779
#> CV:NMF      5 0.668           0.678       0.825         0.1012 0.829   0.527
#> MAD:NMF     5 0.777           0.691       0.871         0.0327 0.890   0.641
#> ATC:NMF     5 0.566           0.598       0.768         0.1163 0.894   0.735
#> SD:skmeans  5 0.749           0.747       0.821         0.0618 0.978   0.917
#> CV:skmeans  5 0.682           0.487       0.707         0.0582 0.786   0.412
#> MAD:skmeans 5 0.735           0.715       0.831         0.0579 0.960   0.850
#> ATC:skmeans 5 0.778           0.810       0.890         0.0584 0.982   0.940
#> SD:mclust   5 0.662           0.624       0.769         0.0810 0.854   0.546
#> CV:mclust   5 0.675           0.795       0.862         0.0458 0.952   0.850
#> MAD:mclust  5 0.771           0.574       0.820         0.0906 0.929   0.749
#> ATC:mclust  5 0.871           0.899       0.956         0.0620 0.944   0.806
#> SD:kmeans   5 0.839           0.882       0.900         0.0828 0.978   0.924
#> CV:kmeans   5 0.644           0.667       0.764         0.0807 0.933   0.788
#> MAD:kmeans  5 0.768           0.813       0.852         0.0727 0.964   0.869
#> ATC:kmeans  5 0.865           0.852       0.865         0.0728 0.972   0.889
#> SD:pam      5 1.000           0.967       0.986         0.0507 0.955   0.846
#> CV:pam      5 0.705           0.767       0.876         0.0617 0.835   0.569
#> MAD:pam     5 0.944           0.958       0.978         0.0553 0.965   0.879
#> ATC:pam     5 0.873           0.783       0.889         0.0783 0.882   0.631
#> SD:hclust   5 0.903           0.938       0.971         0.0946 0.934   0.797
#> CV:hclust   5 0.571           0.671       0.760         0.0390 0.991   0.979
#> MAD:hclust  5 0.698           0.800       0.874         0.1189 0.934   0.792
#> ATC:hclust  5 0.780           0.826       0.873         0.1731 0.813   0.544
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.708           0.666       0.832         0.0343 0.944   0.784
#> CV:NMF      6 0.702           0.529       0.779         0.0440 0.951   0.799
#> MAD:NMF     6 0.694           0.658       0.837         0.0305 0.975   0.900
#> ATC:NMF     6 0.573           0.522       0.738         0.0529 0.921   0.761
#> SD:skmeans  6 0.777           0.751       0.853         0.0555 0.878   0.552
#> CV:skmeans  6 0.756           0.699       0.835         0.0483 0.876   0.511
#> MAD:skmeans 6 0.767           0.732       0.849         0.0553 0.896   0.593
#> ATC:skmeans 6 0.809           0.843       0.915         0.0498 0.947   0.818
#> SD:mclust   6 0.775           0.808       0.862         0.0529 0.893   0.574
#> CV:mclust   6 0.748           0.738       0.839         0.0796 0.909   0.688
#> MAD:mclust  6 0.818           0.756       0.825         0.0405 0.896   0.574
#> ATC:mclust  6 0.855           0.833       0.880         0.0609 0.917   0.683
#> SD:kmeans   6 0.799           0.736       0.822         0.0757 0.933   0.749
#> CV:kmeans   6 0.684           0.592       0.727         0.0554 0.875   0.558
#> MAD:kmeans  6 0.773           0.763       0.839         0.0568 0.917   0.677
#> ATC:kmeans  6 0.846           0.818       0.864         0.0450 0.955   0.801
#> SD:pam      6 0.995           0.952       0.975         0.0980 0.870   0.535
#> CV:pam      6 0.864           0.874       0.931         0.1038 0.801   0.409
#> MAD:pam     6 0.925           0.903       0.956         0.1023 0.870   0.535
#> ATC:pam     6 0.868           0.813       0.901         0.0569 0.953   0.794
#> SD:hclust   6 0.871           0.915       0.929         0.0357 0.969   0.879
#> CV:hclust   6 0.761           0.813       0.868         0.1635 0.787   0.518
#> MAD:hclust  6 0.738           0.750       0.844         0.0361 0.988   0.953
#> ATC:hclust  6 0.761           0.843       0.847         0.0223 0.957   0.813

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 individual(p) k
#> SD:NMF      51       0.04614 2
#> CV:NMF      47       0.11853 2
#> MAD:NMF     48       0.07959 2
#> ATC:NMF     47       0.09479 2
#> SD:skmeans  51       0.07878 2
#> CV:skmeans  50       0.04377 2
#> MAD:skmeans 48       0.03827 2
#> ATC:skmeans 51       0.02014 2
#> SD:mclust   49       0.01812 2
#> CV:mclust   50       0.01498 2
#> MAD:mclust  49       0.02556 2
#> ATC:mclust  47       0.00427 2
#> SD:kmeans   51       0.04614 2
#> CV:kmeans   49       0.06203 2
#> MAD:kmeans  50       0.05554 2
#> ATC:kmeans  50       0.02722 2
#> SD:pam      48       0.02976 2
#> CV:pam      43       0.01685 2
#> MAD:pam     47       0.04562 2
#> ATC:pam     51       0.04827 2
#> SD:hclust   51       0.05676 2
#> CV:hclust   41       0.15730 2
#> MAD:hclust  51       0.13676 2
#> ATC:hclust  51       0.05676 2
test_to_known_factors(res_list, k = 3)
#>              n individual(p) k
#> SD:NMF      51      0.008714 3
#> CV:NMF      47      0.001895 3
#> MAD:NMF     49      0.008434 3
#> ATC:NMF     46      0.002682 3
#> SD:skmeans  50      0.000260 3
#> CV:skmeans  50      0.003367 3
#> MAD:skmeans 51      0.000385 3
#> ATC:skmeans 50      0.019085 3
#> SD:mclust   31      0.004521 3
#> CV:mclust   47      0.002891 3
#> MAD:mclust  51      0.000095 3
#> ATC:mclust  49      0.003068 3
#> SD:kmeans   38      0.007908 3
#> CV:kmeans   43      0.002090 3
#> MAD:kmeans  49      0.032939 3
#> ATC:kmeans  46      0.031872 3
#> SD:pam      46      0.008049 3
#> CV:pam      51      0.003902 3
#> MAD:pam     46      0.003165 3
#> ATC:pam     50      0.068536 3
#> SD:hclust   51      0.006531 3
#> CV:hclust   34      0.002249 3
#> MAD:hclust  48      0.033987 3
#> ATC:hclust  51      0.014136 3
test_to_known_factors(res_list, k = 4)
#>              n individual(p) k
#> SD:NMF      48      0.000723 4
#> CV:NMF      35      0.000419 4
#> MAD:NMF     47      0.000522 4
#> ATC:NMF     36      0.068195 4
#> SD:skmeans  47      0.000834 4
#> CV:skmeans  41      0.003736 4
#> MAD:skmeans 50      0.001025 4
#> ATC:skmeans 50      0.002094 4
#> SD:mclust   43      0.000760 4
#> CV:mclust   48      0.003170 4
#> MAD:mclust  51      0.000448 4
#> ATC:mclust  40      0.012193 4
#> SD:kmeans   46      0.001667 4
#> CV:kmeans   39      0.008902 4
#> MAD:kmeans  37      0.034876 4
#> ATC:kmeans  50      0.031703 4
#> SD:pam      51      0.013915 4
#> CV:pam      51      0.001096 4
#> MAD:pam     50      0.017650 4
#> ATC:pam     50      0.005452 4
#> SD:hclust   51      0.003686 4
#> CV:hclust   43      0.000987 4
#> MAD:hclust  48      0.004140 4
#> ATC:hclust  51      0.001835 4
test_to_known_factors(res_list, k = 5)
#>              n individual(p) k
#> SD:NMF      46      0.002081 5
#> CV:NMF      38      0.000213 5
#> MAD:NMF     41      0.001165 5
#> ATC:NMF     39      0.014891 5
#> SD:skmeans  47      0.000199 5
#> CV:skmeans  26      0.037852 5
#> MAD:skmeans 45      0.002264 5
#> ATC:skmeans 44      0.006353 5
#> SD:mclust   40      0.005273 5
#> CV:mclust   49      0.004350 5
#> MAD:mclust  34      0.016251 5
#> ATC:mclust  47      0.000492 5
#> SD:kmeans   51      0.000942 5
#> CV:kmeans   44      0.000842 5
#> MAD:kmeans  49      0.000212 5
#> ATC:kmeans  50      0.013392 5
#> SD:pam      51      0.003717 5
#> CV:pam      47      0.003156 5
#> MAD:pam     51      0.003717 5
#> ATC:pam     43      0.003428 5
#> SD:hclust   51      0.000733 5
#> CV:hclust   44      0.000811 5
#> MAD:hclust  46      0.000429 5
#> ATC:hclust  47      0.001404 5
test_to_known_factors(res_list, k = 6)
#>              n individual(p) k
#> SD:NMF      42      0.003813 6
#> CV:NMF      35      0.000478 6
#> MAD:NMF     41      0.000245 6
#> ATC:NMF     30      0.000921 6
#> SD:skmeans  45      0.000932 6
#> CV:skmeans  44      0.000724 6
#> MAD:skmeans 45      0.000476 6
#> ATC:skmeans 47      0.004663 6
#> SD:mclust   49      0.000791 6
#> CV:mclust   44      0.031893 6
#> MAD:mclust  47      0.000245 6
#> ATC:mclust  47      0.002607 6
#> SD:kmeans   44      0.001207 6
#> CV:kmeans   31      0.000702 6
#> MAD:kmeans  47      0.000536 6
#> ATC:kmeans  49      0.001691 6
#> SD:pam      50      0.001075 6
#> CV:pam      50      0.003227 6
#> MAD:pam     49      0.000743 6
#> ATC:pam     48      0.000235 6
#> SD:hclust   51      0.000234 6
#> CV:hclust   48      0.005963 6
#> MAD:hclust  44      0.001062 6
#> ATC:hclust  49      0.000480 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 19411 rows and 51 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.995       0.998         0.3902 0.613   0.613
#> 3 3 0.687           0.926       0.915         0.2068 0.967   0.946
#> 4 4 0.889           0.938       0.971         0.4410 0.745   0.560
#> 5 5 0.903           0.938       0.971         0.0946 0.934   0.797
#> 6 6 0.871           0.915       0.929         0.0357 0.969   0.879

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

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

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
#> GSM38712     1   0.000      0.997 1.000 0.000
#> GSM38713     1   0.000      0.997 1.000 0.000
#> GSM38714     1   0.000      0.997 1.000 0.000
#> GSM38715     1   0.000      0.997 1.000 0.000
#> GSM38716     1   0.000      0.997 1.000 0.000
#> GSM38717     1   0.000      0.997 1.000 0.000
#> GSM38718     1   0.000      0.997 1.000 0.000
#> GSM38719     1   0.000      0.997 1.000 0.000
#> GSM38720     1   0.000      0.997 1.000 0.000
#> GSM38721     1   0.000      0.997 1.000 0.000
#> GSM38722     1   0.000      0.997 1.000 0.000
#> GSM38723     1   0.000      0.997 1.000 0.000
#> GSM38724     1   0.000      0.997 1.000 0.000
#> GSM38725     1   0.000      0.997 1.000 0.000
#> GSM38726     1   0.000      0.997 1.000 0.000
#> GSM38727     1   0.000      0.997 1.000 0.000
#> GSM38728     1   0.000      0.997 1.000 0.000
#> GSM38729     1   0.000      0.997 1.000 0.000
#> GSM38730     1   0.000      0.997 1.000 0.000
#> GSM38731     1   0.000      0.997 1.000 0.000
#> GSM38732     1   0.358      0.929 0.932 0.068
#> GSM38733     1   0.000      0.997 1.000 0.000
#> GSM38734     2   0.000      1.000 0.000 1.000
#> GSM38735     1   0.000      0.997 1.000 0.000
#> GSM38736     2   0.000      1.000 0.000 1.000
#> GSM38737     2   0.000      1.000 0.000 1.000
#> GSM38738     1   0.295      0.946 0.948 0.052
#> GSM38739     1   0.000      0.997 1.000 0.000
#> GSM38740     1   0.000      0.997 1.000 0.000
#> GSM38741     1   0.000      0.997 1.000 0.000
#> GSM38742     2   0.000      1.000 0.000 1.000
#> GSM38743     2   0.000      1.000 0.000 1.000
#> GSM38744     1   0.000      0.997 1.000 0.000
#> GSM38745     1   0.000      0.997 1.000 0.000
#> GSM38746     1   0.000      0.997 1.000 0.000
#> GSM38747     1   0.000      0.997 1.000 0.000
#> GSM38748     2   0.000      1.000 0.000 1.000
#> GSM38749     1   0.000      0.997 1.000 0.000
#> GSM38750     1   0.000      0.997 1.000 0.000
#> GSM38751     1   0.000      0.997 1.000 0.000
#> GSM38752     2   0.000      1.000 0.000 1.000
#> GSM38753     2   0.000      1.000 0.000 1.000
#> GSM38754     2   0.000      1.000 0.000 1.000
#> GSM38755     1   0.000      0.997 1.000 0.000
#> GSM38756     2   0.000      1.000 0.000 1.000
#> GSM38757     1   0.000      0.997 1.000 0.000
#> GSM38758     2   0.000      1.000 0.000 1.000
#> GSM38759     1   0.000      0.997 1.000 0.000
#> GSM38760     1   0.000      0.997 1.000 0.000
#> GSM38761     2   0.000      1.000 0.000 1.000
#> GSM38762     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38721     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38722     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38724     1  0.4555      0.866 0.800 0.200 0.000
#> GSM38725     1  0.2959      0.904 0.900 0.100 0.000
#> GSM38726     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38728     1  0.4796      0.854 0.780 0.220 0.000
#> GSM38729     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38732     1  0.6810      0.801 0.720 0.212 0.068
#> GSM38733     1  0.0237      0.925 0.996 0.004 0.000
#> GSM38734     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38735     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38736     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38737     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38738     1  0.6446      0.817 0.736 0.212 0.052
#> GSM38739     1  0.3116      0.902 0.892 0.108 0.000
#> GSM38740     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38741     1  0.4796      0.854 0.780 0.220 0.000
#> GSM38742     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38743     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38744     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38745     1  0.0000      0.926 1.000 0.000 0.000
#> GSM38746     1  0.4796      0.854 0.780 0.220 0.000
#> GSM38747     1  0.4796      0.854 0.780 0.220 0.000
#> GSM38748     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38749     1  0.3116      0.902 0.892 0.108 0.000
#> GSM38750     1  0.4555      0.866 0.800 0.200 0.000
#> GSM38751     1  0.4555      0.866 0.800 0.200 0.000
#> GSM38752     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38753     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38754     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38755     1  0.3482      0.896 0.872 0.128 0.000
#> GSM38756     3  0.0000      1.000 0.000 0.000 1.000
#> GSM38757     1  0.4555      0.866 0.800 0.200 0.000
#> GSM38758     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38759     1  0.4796      0.854 0.780 0.220 0.000
#> GSM38760     1  0.3482      0.896 0.872 0.128 0.000
#> GSM38761     2  0.4796      1.000 0.000 0.780 0.220
#> GSM38762     2  0.4796      1.000 0.000 0.780 0.220

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM38712     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38713     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38714     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38715     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38716     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38717     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38718     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38719     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38720     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38721     1  0.2704      0.858 0.876  0 0.124 0.000
#> GSM38722     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38723     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38724     3  0.0707      0.944 0.020  0 0.980 0.000
#> GSM38725     1  0.2345      0.873 0.900  0 0.100 0.000
#> GSM38726     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38727     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38728     3  0.0000      0.944 0.000  0 1.000 0.000
#> GSM38729     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38730     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38731     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38732     3  0.1792      0.905 0.000  0 0.932 0.068
#> GSM38733     1  0.2760      0.854 0.872  0 0.128 0.000
#> GSM38734     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38735     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38738     3  0.1474      0.918 0.000  0 0.948 0.052
#> GSM38739     1  0.4356      0.614 0.708  0 0.292 0.000
#> GSM38740     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38741     3  0.0000      0.944 0.000  0 1.000 0.000
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38744     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38745     1  0.0000      0.958 1.000  0 0.000 0.000
#> GSM38746     3  0.0000      0.944 0.000  0 1.000 0.000
#> GSM38747     3  0.0000      0.944 0.000  0 1.000 0.000
#> GSM38748     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38749     1  0.4356      0.614 0.708  0 0.292 0.000
#> GSM38750     3  0.0707      0.944 0.020  0 0.980 0.000
#> GSM38751     3  0.0707      0.944 0.020  0 0.980 0.000
#> GSM38752     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38753     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38754     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38755     3  0.2704      0.839 0.124  0 0.876 0.000
#> GSM38756     4  0.0000      1.000 0.000  0 0.000 1.000
#> GSM38757     3  0.0707      0.944 0.020  0 0.980 0.000
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38759     3  0.0000      0.944 0.000  0 1.000 0.000
#> GSM38760     3  0.3688      0.732 0.208  0 0.792 0.000
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000  1 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
#> GSM38712     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38713     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38714     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38715     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38716     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38717     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38718     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38719     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38720     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38721     1  0.2329      0.851 0.876  0 0.124 0.000  0
#> GSM38722     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38723     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38724     3  0.0609      0.944 0.020  0 0.980 0.000  0
#> GSM38725     1  0.2020      0.865 0.900  0 0.100 0.000  0
#> GSM38726     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38727     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38728     3  0.0000      0.944 0.000  0 1.000 0.000  0
#> GSM38729     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38730     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38731     1  0.0000      0.947 1.000  0 0.000 0.000  0
#> GSM38732     3  0.1544      0.905 0.000  0 0.932 0.068  0
#> GSM38733     1  0.2377      0.848 0.872  0 0.128 0.000  0
#> GSM38734     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38735     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38738     3  0.1270      0.918 0.000  0 0.948 0.052  0
#> GSM38739     1  0.3752      0.622 0.708  0 0.292 0.000  0
#> GSM38740     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38741     3  0.0000      0.944 0.000  0 1.000 0.000  0
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38744     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38745     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38746     3  0.0000      0.944 0.000  0 1.000 0.000  0
#> GSM38747     3  0.0000      0.944 0.000  0 1.000 0.000  0
#> GSM38748     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38749     1  0.3752      0.622 0.708  0 0.292 0.000  0
#> GSM38750     3  0.0609      0.944 0.020  0 0.980 0.000  0
#> GSM38751     3  0.0609      0.944 0.020  0 0.980 0.000  0
#> GSM38752     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38753     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38754     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38755     3  0.2329      0.839 0.124  0 0.876 0.000  0
#> GSM38756     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38757     3  0.0609      0.944 0.020  0 0.980 0.000  0
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38759     3  0.0000      0.944 0.000  0 1.000 0.000  0
#> GSM38760     3  0.3177      0.732 0.208  0 0.792 0.000  0
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38762     2  0.0000      1.000 0.000  1 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4 p5    p6
#> GSM38712     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38713     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38714     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38715     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38716     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38717     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38718     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38719     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38720     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38721     1  0.2092      0.845 0.876  0 0.124 0.000  0 0.000
#> GSM38722     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38723     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38724     3  0.0291      0.875 0.004  0 0.992 0.000  0 0.004
#> GSM38725     1  0.1814      0.866 0.900  0 0.100 0.000  0 0.000
#> GSM38726     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38727     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38728     6  0.3482      0.978 0.000  0 0.316 0.000  0 0.684
#> GSM38729     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38730     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38731     1  0.0000      0.948 1.000  0 0.000 0.000  0 0.000
#> GSM38732     3  0.1814      0.829 0.000  0 0.900 0.000  0 0.100
#> GSM38733     1  0.2135      0.841 0.872  0 0.128 0.000  0 0.000
#> GSM38734     4  0.2994      0.843 0.000  0 0.004 0.788  0 0.208
#> GSM38735     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38738     3  0.1610      0.841 0.000  0 0.916 0.000  0 0.084
#> GSM38739     1  0.3428      0.595 0.696  0 0.304 0.000  0 0.000
#> GSM38740     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38741     6  0.3482      0.978 0.000  0 0.316 0.000  0 0.684
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38744     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38745     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38746     6  0.3482      0.967 0.000  0 0.316 0.000  0 0.684
#> GSM38747     6  0.3482      0.967 0.000  0 0.316 0.000  0 0.684
#> GSM38748     4  0.2730      0.849 0.000  0 0.000 0.808  0 0.192
#> GSM38749     1  0.3428      0.595 0.696  0 0.304 0.000  0 0.000
#> GSM38750     3  0.0291      0.875 0.004  0 0.992 0.000  0 0.004
#> GSM38751     3  0.0291      0.875 0.004  0 0.992 0.000  0 0.004
#> GSM38752     4  0.1765      0.888 0.000  0 0.000 0.904  0 0.096
#> GSM38753     4  0.0000      0.904 0.000  0 0.000 1.000  0 0.000
#> GSM38754     4  0.1765      0.888 0.000  0 0.000 0.904  0 0.096
#> GSM38755     3  0.1910      0.777 0.108  0 0.892 0.000  0 0.000
#> GSM38756     4  0.0000      0.904 0.000  0 0.000 1.000  0 0.000
#> GSM38757     3  0.0291      0.875 0.004  0 0.992 0.000  0 0.004
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38759     6  0.3482      0.978 0.000  0 0.316 0.000  0 0.684
#> GSM38760     3  0.2730      0.654 0.192  0 0.808 0.000  0 0.000
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38762     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.982       0.992         0.4016 0.594   0.594
#> 3 3 0.522           0.652       0.844         0.4734 0.795   0.668
#> 4 4 0.615           0.733       0.798         0.1664 0.740   0.472
#> 5 5 0.839           0.882       0.900         0.0828 0.978   0.924
#> 6 6 0.799           0.736       0.822         0.0757 0.933   0.749

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
#> GSM38712     1  0.0000      0.997 1.000 0.000
#> GSM38713     1  0.0000      0.997 1.000 0.000
#> GSM38714     1  0.0000      0.997 1.000 0.000
#> GSM38715     1  0.0000      0.997 1.000 0.000
#> GSM38716     1  0.0000      0.997 1.000 0.000
#> GSM38717     1  0.0000      0.997 1.000 0.000
#> GSM38718     1  0.0000      0.997 1.000 0.000
#> GSM38719     1  0.0000      0.997 1.000 0.000
#> GSM38720     1  0.0000      0.997 1.000 0.000
#> GSM38721     1  0.0000      0.997 1.000 0.000
#> GSM38722     1  0.0000      0.997 1.000 0.000
#> GSM38723     1  0.0000      0.997 1.000 0.000
#> GSM38724     1  0.0000      0.997 1.000 0.000
#> GSM38725     1  0.0000      0.997 1.000 0.000
#> GSM38726     1  0.0000      0.997 1.000 0.000
#> GSM38727     1  0.0000      0.997 1.000 0.000
#> GSM38728     1  0.0672      0.994 0.992 0.008
#> GSM38729     1  0.0000      0.997 1.000 0.000
#> GSM38730     1  0.0000      0.997 1.000 0.000
#> GSM38731     1  0.0000      0.997 1.000 0.000
#> GSM38732     1  0.0672      0.994 0.992 0.008
#> GSM38733     1  0.0000      0.997 1.000 0.000
#> GSM38734     2  0.0000      0.975 0.000 1.000
#> GSM38735     1  0.0672      0.994 0.992 0.008
#> GSM38736     2  0.0000      0.975 0.000 1.000
#> GSM38737     2  0.0000      0.975 0.000 1.000
#> GSM38738     1  0.0672      0.994 0.992 0.008
#> GSM38739     1  0.0000      0.997 1.000 0.000
#> GSM38740     1  0.0000      0.997 1.000 0.000
#> GSM38741     2  0.9044      0.526 0.320 0.680
#> GSM38742     2  0.0000      0.975 0.000 1.000
#> GSM38743     2  0.0000      0.975 0.000 1.000
#> GSM38744     1  0.0000      0.997 1.000 0.000
#> GSM38745     1  0.0672      0.994 0.992 0.008
#> GSM38746     1  0.0672      0.994 0.992 0.008
#> GSM38747     1  0.0672      0.994 0.992 0.008
#> GSM38748     2  0.0000      0.975 0.000 1.000
#> GSM38749     1  0.0000      0.997 1.000 0.000
#> GSM38750     1  0.0672      0.994 0.992 0.008
#> GSM38751     1  0.0672      0.994 0.992 0.008
#> GSM38752     2  0.0000      0.975 0.000 1.000
#> GSM38753     2  0.0000      0.975 0.000 1.000
#> GSM38754     2  0.0000      0.975 0.000 1.000
#> GSM38755     1  0.0000      0.997 1.000 0.000
#> GSM38756     2  0.0000      0.975 0.000 1.000
#> GSM38757     1  0.0672      0.994 0.992 0.008
#> GSM38758     2  0.0000      0.975 0.000 1.000
#> GSM38759     1  0.0672      0.994 0.992 0.008
#> GSM38760     1  0.0000      0.997 1.000 0.000
#> GSM38761     2  0.0000      0.975 0.000 1.000
#> GSM38762     2  0.0000      0.975 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
#> GSM38712     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38713     1  0.2796      0.797 0.908 0.000 0.092
#> GSM38714     1  0.2959      0.792 0.900 0.000 0.100
#> GSM38715     1  0.2625      0.802 0.916 0.000 0.084
#> GSM38716     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38721     1  0.2796      0.797 0.908 0.000 0.092
#> GSM38722     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38724     1  0.6307      0.183 0.512 0.000 0.488
#> GSM38725     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38728     3  0.4504      0.662 0.196 0.000 0.804
#> GSM38729     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.834 1.000 0.000 0.000
#> GSM38732     3  0.2878      0.678 0.096 0.000 0.904
#> GSM38733     1  0.3267      0.784 0.884 0.000 0.116
#> GSM38734     3  0.5465      0.383 0.000 0.288 0.712
#> GSM38735     1  0.8880      0.421 0.564 0.268 0.168
#> GSM38736     2  0.0000      0.851 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.851 0.000 1.000 0.000
#> GSM38738     3  0.2878      0.678 0.096 0.000 0.904
#> GSM38739     1  0.3412      0.774 0.876 0.000 0.124
#> GSM38740     1  0.5791      0.711 0.784 0.048 0.168
#> GSM38741     3  0.2384      0.656 0.056 0.008 0.936
#> GSM38742     2  0.0237      0.851 0.000 0.996 0.004
#> GSM38743     2  0.0000      0.851 0.000 1.000 0.000
#> GSM38744     1  0.3765      0.767 0.888 0.028 0.084
#> GSM38745     1  0.8853      0.428 0.568 0.264 0.168
#> GSM38746     1  0.6307      0.183 0.512 0.000 0.488
#> GSM38747     1  0.6307      0.183 0.512 0.000 0.488
#> GSM38748     3  0.6026      0.155 0.000 0.376 0.624
#> GSM38749     1  0.2165      0.814 0.936 0.000 0.064
#> GSM38750     3  0.5363      0.563 0.276 0.000 0.724
#> GSM38751     3  0.5397      0.555 0.280 0.000 0.720
#> GSM38752     3  0.5529      0.370 0.000 0.296 0.704
#> GSM38753     2  0.6309      0.156 0.000 0.504 0.496
#> GSM38754     3  0.5529      0.370 0.000 0.296 0.704
#> GSM38755     1  0.6291      0.216 0.532 0.000 0.468
#> GSM38756     2  0.6309      0.156 0.000 0.504 0.496
#> GSM38757     3  0.5363      0.563 0.276 0.000 0.724
#> GSM38758     2  0.1163      0.837 0.000 0.972 0.028
#> GSM38759     1  0.6305      0.195 0.516 0.000 0.484
#> GSM38760     1  0.2165      0.814 0.936 0.000 0.064
#> GSM38761     2  0.0237      0.851 0.000 0.996 0.004
#> GSM38762     2  0.0000      0.851 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38713     1  0.3102      0.849 0.872 0.004 0.116 0.008
#> GSM38714     1  0.3632      0.807 0.832 0.004 0.156 0.008
#> GSM38715     1  0.1994      0.900 0.936 0.004 0.052 0.008
#> GSM38716     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0188      0.932 0.996 0.000 0.000 0.004
#> GSM38718     1  0.0336      0.930 0.992 0.000 0.000 0.008
#> GSM38719     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38721     1  0.3102      0.849 0.872 0.004 0.116 0.008
#> GSM38722     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38724     3  0.2944      0.805 0.128 0.000 0.868 0.004
#> GSM38725     1  0.0188      0.932 0.996 0.000 0.000 0.004
#> GSM38726     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38728     3  0.2565      0.778 0.032 0.000 0.912 0.056
#> GSM38729     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38732     3  0.3182      0.680 0.004 0.004 0.860 0.132
#> GSM38733     1  0.3907      0.774 0.808 0.004 0.180 0.008
#> GSM38734     4  0.4948      0.638 0.000 0.000 0.440 0.560
#> GSM38735     2  0.8521      0.300 0.212 0.536 0.148 0.104
#> GSM38736     2  0.4730      0.559 0.000 0.636 0.000 0.364
#> GSM38737     2  0.4730      0.559 0.000 0.636 0.000 0.364
#> GSM38738     3  0.3128      0.686 0.004 0.004 0.864 0.128
#> GSM38739     1  0.3727      0.797 0.824 0.008 0.164 0.004
#> GSM38740     2  0.8996      0.223 0.324 0.424 0.148 0.104
#> GSM38741     3  0.2868      0.671 0.000 0.000 0.864 0.136
#> GSM38742     2  0.4761      0.555 0.000 0.628 0.000 0.372
#> GSM38743     2  0.4730      0.559 0.000 0.636 0.000 0.364
#> GSM38744     2  0.8923      0.206 0.336 0.424 0.136 0.104
#> GSM38745     2  0.8547      0.299 0.216 0.532 0.148 0.104
#> GSM38746     3  0.2859      0.809 0.112 0.008 0.880 0.000
#> GSM38747     3  0.2530      0.812 0.112 0.000 0.888 0.000
#> GSM38748     4  0.4164      0.700 0.000 0.000 0.264 0.736
#> GSM38749     1  0.3355      0.810 0.836 0.000 0.160 0.004
#> GSM38750     3  0.1722      0.819 0.048 0.008 0.944 0.000
#> GSM38751     3  0.1722      0.819 0.048 0.008 0.944 0.000
#> GSM38752     4  0.4948      0.638 0.000 0.000 0.440 0.560
#> GSM38753     4  0.2737      0.561 0.000 0.008 0.104 0.888
#> GSM38754     4  0.4948      0.638 0.000 0.000 0.440 0.560
#> GSM38755     3  0.4772      0.618 0.244 0.012 0.736 0.008
#> GSM38756     4  0.2737      0.561 0.000 0.008 0.104 0.888
#> GSM38757     3  0.1975      0.817 0.048 0.000 0.936 0.016
#> GSM38758     2  0.4925      0.487 0.000 0.572 0.000 0.428
#> GSM38759     3  0.2944      0.805 0.128 0.000 0.868 0.004
#> GSM38760     1  0.2921      0.829 0.860 0.000 0.140 0.000
#> GSM38761     2  0.4761      0.555 0.000 0.628 0.000 0.372
#> GSM38762     2  0.4730      0.559 0.000 0.636 0.000 0.364

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0451      0.880 0.988 0.000 0.000 0.004 0.008
#> GSM38713     1  0.4425      0.814 0.784 0.000 0.020 0.132 0.064
#> GSM38714     1  0.5106      0.785 0.748 0.000 0.056 0.132 0.064
#> GSM38715     1  0.4332      0.816 0.788 0.000 0.016 0.132 0.064
#> GSM38716     1  0.0324      0.880 0.992 0.000 0.000 0.004 0.004
#> GSM38717     1  0.2889      0.850 0.872 0.000 0.000 0.084 0.044
#> GSM38718     1  0.3593      0.832 0.824 0.000 0.000 0.116 0.060
#> GSM38719     1  0.1701      0.871 0.936 0.000 0.000 0.048 0.016
#> GSM38720     1  0.0798      0.879 0.976 0.000 0.000 0.016 0.008
#> GSM38721     1  0.4425      0.814 0.784 0.000 0.020 0.132 0.064
#> GSM38722     1  0.0671      0.875 0.980 0.000 0.000 0.016 0.004
#> GSM38723     1  0.0671      0.875 0.980 0.000 0.000 0.016 0.004
#> GSM38724     3  0.1200      0.945 0.012 0.000 0.964 0.016 0.008
#> GSM38725     1  0.0693      0.879 0.980 0.000 0.000 0.008 0.012
#> GSM38726     1  0.0290      0.878 0.992 0.000 0.000 0.008 0.000
#> GSM38727     1  0.0671      0.875 0.980 0.000 0.000 0.016 0.004
#> GSM38728     3  0.1770      0.933 0.008 0.000 0.936 0.048 0.008
#> GSM38729     1  0.0162      0.880 0.996 0.000 0.000 0.000 0.004
#> GSM38730     1  0.0290      0.878 0.992 0.000 0.000 0.008 0.000
#> GSM38731     1  0.0290      0.878 0.992 0.000 0.000 0.008 0.000
#> GSM38732     3  0.1965      0.933 0.000 0.000 0.924 0.052 0.024
#> GSM38733     1  0.4514      0.813 0.780 0.000 0.024 0.132 0.064
#> GSM38734     4  0.3354      0.862 0.000 0.024 0.140 0.832 0.004
#> GSM38735     5  0.3443      0.955 0.044 0.092 0.008 0.004 0.852
#> GSM38736     2  0.0290      0.965 0.000 0.992 0.000 0.000 0.008
#> GSM38737     2  0.0290      0.965 0.000 0.992 0.000 0.000 0.008
#> GSM38738     3  0.1893      0.934 0.000 0.000 0.928 0.048 0.024
#> GSM38739     1  0.4690      0.653 0.724 0.000 0.224 0.016 0.036
#> GSM38740     5  0.3202      0.955 0.080 0.056 0.004 0.000 0.860
#> GSM38741     3  0.1626      0.925 0.000 0.000 0.940 0.044 0.016
#> GSM38742     2  0.1251      0.953 0.000 0.956 0.008 0.036 0.000
#> GSM38743     2  0.0290      0.965 0.000 0.992 0.000 0.000 0.008
#> GSM38744     5  0.3191      0.951 0.084 0.052 0.004 0.000 0.860
#> GSM38745     5  0.3443      0.955 0.044 0.092 0.008 0.004 0.852
#> GSM38746     3  0.1200      0.944 0.012 0.000 0.964 0.008 0.016
#> GSM38747     3  0.1095      0.945 0.012 0.000 0.968 0.008 0.012
#> GSM38748     4  0.4293      0.865 0.000 0.092 0.076 0.804 0.028
#> GSM38749     1  0.4660      0.659 0.728 0.000 0.220 0.016 0.036
#> GSM38750     3  0.1596      0.943 0.012 0.000 0.948 0.012 0.028
#> GSM38751     3  0.1195      0.946 0.012 0.000 0.960 0.000 0.028
#> GSM38752     4  0.3631      0.864 0.000 0.024 0.144 0.820 0.012
#> GSM38753     4  0.3687      0.810 0.000 0.180 0.000 0.792 0.028
#> GSM38754     4  0.3631      0.864 0.000 0.024 0.144 0.820 0.012
#> GSM38755     3  0.3647      0.872 0.020 0.000 0.844 0.068 0.068
#> GSM38756     4  0.3687      0.810 0.000 0.180 0.000 0.792 0.028
#> GSM38757     3  0.1314      0.945 0.012 0.000 0.960 0.012 0.016
#> GSM38758     2  0.1628      0.933 0.000 0.936 0.008 0.056 0.000
#> GSM38759     3  0.2900      0.879 0.020 0.000 0.876 0.092 0.012
#> GSM38760     1  0.4296      0.680 0.756 0.000 0.204 0.016 0.024
#> GSM38761     2  0.1251      0.953 0.000 0.956 0.008 0.036 0.000
#> GSM38762     2  0.0290      0.965 0.000 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1556      0.599 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM38713     6  0.3950      0.943 0.432 0.000 0.004 0.000 0.000 0.564
#> GSM38714     6  0.4403      0.922 0.408 0.000 0.028 0.000 0.000 0.564
#> GSM38715     6  0.3950      0.943 0.432 0.000 0.004 0.000 0.000 0.564
#> GSM38716     1  0.1556      0.599 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM38717     1  0.3774     -0.550 0.592 0.000 0.000 0.000 0.000 0.408
#> GSM38718     1  0.3864     -0.763 0.520 0.000 0.000 0.000 0.000 0.480
#> GSM38719     1  0.3050      0.220 0.764 0.000 0.000 0.000 0.000 0.236
#> GSM38720     1  0.2562      0.424 0.828 0.000 0.000 0.000 0.000 0.172
#> GSM38721     6  0.3961      0.931 0.440 0.000 0.004 0.000 0.000 0.556
#> GSM38722     1  0.1204      0.649 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38723     1  0.1204      0.649 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38724     3  0.2135      0.843 0.000 0.000 0.872 0.000 0.000 0.128
#> GSM38725     1  0.0146      0.659 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38726     1  0.0000      0.660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.1204      0.649 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38728     3  0.3342      0.790 0.000 0.000 0.760 0.012 0.000 0.228
#> GSM38729     1  0.1267      0.620 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM38730     1  0.0000      0.660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.2620      0.840 0.000 0.000 0.868 0.012 0.012 0.108
#> GSM38733     6  0.4747      0.867 0.376 0.000 0.056 0.000 0.000 0.568
#> GSM38734     4  0.2665      0.915 0.000 0.000 0.012 0.868 0.016 0.104
#> GSM38735     5  0.1109      0.990 0.004 0.012 0.000 0.004 0.964 0.016
#> GSM38736     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38737     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38738     3  0.2114      0.847 0.000 0.000 0.904 0.008 0.012 0.076
#> GSM38739     1  0.5316      0.362 0.592 0.000 0.240 0.000 0.000 0.168
#> GSM38740     5  0.0508      0.989 0.004 0.012 0.000 0.000 0.984 0.000
#> GSM38741     3  0.2664      0.832 0.000 0.000 0.848 0.016 0.000 0.136
#> GSM38742     2  0.1194      0.964 0.000 0.956 0.000 0.008 0.004 0.032
#> GSM38743     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38744     5  0.0520      0.987 0.008 0.008 0.000 0.000 0.984 0.000
#> GSM38745     5  0.1109      0.990 0.004 0.012 0.000 0.004 0.964 0.016
#> GSM38746     3  0.2738      0.833 0.000 0.000 0.820 0.004 0.000 0.176
#> GSM38747     3  0.2848      0.835 0.000 0.000 0.816 0.008 0.000 0.176
#> GSM38748     4  0.0964      0.919 0.000 0.004 0.012 0.968 0.000 0.016
#> GSM38749     1  0.5275      0.370 0.600 0.000 0.232 0.000 0.000 0.168
#> GSM38750     3  0.2685      0.822 0.000 0.000 0.852 0.008 0.008 0.132
#> GSM38751     3  0.1910      0.827 0.000 0.000 0.892 0.000 0.000 0.108
#> GSM38752     4  0.2500      0.915 0.000 0.000 0.012 0.868 0.004 0.116
#> GSM38753     4  0.0937      0.917 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM38754     4  0.2500      0.915 0.000 0.000 0.012 0.868 0.004 0.116
#> GSM38755     3  0.2742      0.826 0.000 0.000 0.852 0.008 0.012 0.128
#> GSM38756     4  0.0937      0.917 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM38757     3  0.1149      0.853 0.000 0.000 0.960 0.008 0.008 0.024
#> GSM38758     2  0.1151      0.960 0.000 0.956 0.000 0.012 0.000 0.032
#> GSM38759     3  0.3804      0.679 0.000 0.000 0.656 0.008 0.000 0.336
#> GSM38760     1  0.5095      0.396 0.632 0.000 0.188 0.000 0.000 0.180
#> GSM38761     2  0.1049      0.963 0.000 0.960 0.000 0.008 0.000 0.032
#> GSM38762     2  0.0547      0.973 0.000 0.980 0.000 0.000 0.020 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 individual(p) k
#> SD:kmeans 51      0.046137 2
#> SD:kmeans 38      0.007908 3
#> SD:kmeans 46      0.001667 4
#> SD:kmeans 51      0.000942 5
#> SD:kmeans 44      0.001207 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 19411 rows and 51 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 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-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.957           0.965       0.982         0.4972 0.506   0.506
#> 3 3 0.918           0.932       0.972         0.3126 0.699   0.477
#> 4 4 0.828           0.823       0.907         0.1173 0.897   0.711
#> 5 5 0.749           0.747       0.821         0.0618 0.978   0.917
#> 6 6 0.777           0.751       0.853         0.0555 0.878   0.552

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
#> GSM38712     1   0.000      0.971 1.000 0.000
#> GSM38713     1   0.000      0.971 1.000 0.000
#> GSM38714     1   0.000      0.971 1.000 0.000
#> GSM38715     1   0.000      0.971 1.000 0.000
#> GSM38716     1   0.000      0.971 1.000 0.000
#> GSM38717     1   0.000      0.971 1.000 0.000
#> GSM38718     1   0.000      0.971 1.000 0.000
#> GSM38719     1   0.000      0.971 1.000 0.000
#> GSM38720     1   0.000      0.971 1.000 0.000
#> GSM38721     1   0.000      0.971 1.000 0.000
#> GSM38722     1   0.000      0.971 1.000 0.000
#> GSM38723     1   0.000      0.971 1.000 0.000
#> GSM38724     1   0.518      0.873 0.884 0.116
#> GSM38725     1   0.000      0.971 1.000 0.000
#> GSM38726     1   0.000      0.971 1.000 0.000
#> GSM38727     1   0.000      0.971 1.000 0.000
#> GSM38728     2   0.000      0.995 0.000 1.000
#> GSM38729     1   0.000      0.971 1.000 0.000
#> GSM38730     1   0.000      0.971 1.000 0.000
#> GSM38731     1   0.000      0.971 1.000 0.000
#> GSM38732     2   0.000      0.995 0.000 1.000
#> GSM38733     1   0.000      0.971 1.000 0.000
#> GSM38734     2   0.000      0.995 0.000 1.000
#> GSM38735     2   0.430      0.899 0.088 0.912
#> GSM38736     2   0.000      0.995 0.000 1.000
#> GSM38737     2   0.000      0.995 0.000 1.000
#> GSM38738     2   0.000      0.995 0.000 1.000
#> GSM38739     1   0.000      0.971 1.000 0.000
#> GSM38740     1   0.000      0.971 1.000 0.000
#> GSM38741     2   0.000      0.995 0.000 1.000
#> GSM38742     2   0.000      0.995 0.000 1.000
#> GSM38743     2   0.000      0.995 0.000 1.000
#> GSM38744     1   0.000      0.971 1.000 0.000
#> GSM38745     1   0.402      0.908 0.920 0.080
#> GSM38746     1   0.722      0.779 0.800 0.200
#> GSM38747     1   0.722      0.779 0.800 0.200
#> GSM38748     2   0.000      0.995 0.000 1.000
#> GSM38749     1   0.000      0.971 1.000 0.000
#> GSM38750     2   0.000      0.995 0.000 1.000
#> GSM38751     2   0.000      0.995 0.000 1.000
#> GSM38752     2   0.000      0.995 0.000 1.000
#> GSM38753     2   0.000      0.995 0.000 1.000
#> GSM38754     2   0.000      0.995 0.000 1.000
#> GSM38755     1   0.141      0.957 0.980 0.020
#> GSM38756     2   0.000      0.995 0.000 1.000
#> GSM38757     2   0.000      0.995 0.000 1.000
#> GSM38758     2   0.000      0.995 0.000 1.000
#> GSM38759     1   0.722      0.779 0.800 0.200
#> GSM38760     1   0.000      0.971 1.000 0.000
#> GSM38761     2   0.000      0.995 0.000 1.000
#> GSM38762     2   0.000      0.995 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38713     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38714     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38715     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38716     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38717     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38718     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38719     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38720     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38721     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38722     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38723     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38724     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38725     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38726     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38727     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38728     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38729     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38730     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38731     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38732     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38733     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38734     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38735     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38736     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38737     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38738     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38739     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38740     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38741     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38742     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38743     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38744     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38745     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38746     3   0.327     0.8203 0.116 0.000 0.884
#> GSM38747     3   0.327     0.8203 0.116 0.000 0.884
#> GSM38748     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38749     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38750     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38751     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38752     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38753     3   0.455     0.7231 0.000 0.200 0.800
#> GSM38754     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38755     3   0.568     0.5605 0.316 0.000 0.684
#> GSM38756     3   0.450     0.7281 0.000 0.196 0.804
#> GSM38757     3   0.000     0.9012 0.000 0.000 1.000
#> GSM38758     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38759     3   0.631     0.0798 0.492 0.000 0.508
#> GSM38760     1   0.000     1.0000 1.000 0.000 0.000
#> GSM38761     2   0.000     1.0000 0.000 1.000 0.000
#> GSM38762     2   0.000     1.0000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38713     1  0.1867      0.903 0.928 0.000 0.072 0.000
#> GSM38714     1  0.1867      0.903 0.928 0.000 0.072 0.000
#> GSM38715     1  0.1867      0.903 0.928 0.000 0.072 0.000
#> GSM38716     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38721     1  0.1867      0.903 0.928 0.000 0.072 0.000
#> GSM38722     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38724     3  0.0592      0.749 0.000 0.000 0.984 0.016
#> GSM38725     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38728     4  0.4564      0.677 0.000 0.000 0.328 0.672
#> GSM38729     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.945 1.000 0.000 0.000 0.000
#> GSM38732     4  0.2868      0.814 0.000 0.000 0.136 0.864
#> GSM38733     1  0.1867      0.903 0.928 0.000 0.072 0.000
#> GSM38734     4  0.0707      0.856 0.000 0.000 0.020 0.980
#> GSM38735     2  0.0000      0.902 0.000 1.000 0.000 0.000
#> GSM38736     2  0.2868      0.937 0.000 0.864 0.000 0.136
#> GSM38737     2  0.2868      0.937 0.000 0.864 0.000 0.136
#> GSM38738     4  0.2868      0.814 0.000 0.000 0.136 0.864
#> GSM38739     3  0.4941      0.354 0.436 0.000 0.564 0.000
#> GSM38740     2  0.0000      0.902 0.000 1.000 0.000 0.000
#> GSM38741     4  0.4103      0.726 0.000 0.000 0.256 0.744
#> GSM38742     2  0.2868      0.937 0.000 0.864 0.000 0.136
#> GSM38743     2  0.2868      0.937 0.000 0.864 0.000 0.136
#> GSM38744     2  0.0000      0.902 0.000 1.000 0.000 0.000
#> GSM38745     2  0.0000      0.902 0.000 1.000 0.000 0.000
#> GSM38746     3  0.0000      0.754 0.000 0.000 1.000 0.000
#> GSM38747     3  0.0000      0.754 0.000 0.000 1.000 0.000
#> GSM38748     4  0.0336      0.851 0.000 0.000 0.008 0.992
#> GSM38749     3  0.4941      0.354 0.436 0.000 0.564 0.000
#> GSM38750     3  0.1867      0.745 0.000 0.000 0.928 0.072
#> GSM38751     3  0.1867      0.745 0.000 0.000 0.928 0.072
#> GSM38752     4  0.0707      0.856 0.000 0.000 0.020 0.980
#> GSM38753     4  0.0000      0.847 0.000 0.000 0.000 1.000
#> GSM38754     4  0.0707      0.856 0.000 0.000 0.020 0.980
#> GSM38755     3  0.6027      0.638 0.192 0.000 0.684 0.124
#> GSM38756     4  0.0000      0.847 0.000 0.000 0.000 1.000
#> GSM38757     3  0.2011      0.740 0.000 0.000 0.920 0.080
#> GSM38758     2  0.3688      0.875 0.000 0.792 0.000 0.208
#> GSM38759     4  0.7517      0.395 0.212 0.000 0.304 0.484
#> GSM38760     1  0.5000     -0.274 0.500 0.000 0.500 0.000
#> GSM38761     2  0.2868      0.937 0.000 0.864 0.000 0.136
#> GSM38762     2  0.2868      0.937 0.000 0.864 0.000 0.136

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0404      0.804 0.988 0.000 0.000 0.000 0.012
#> GSM38713     1  0.5873      0.602 0.556 0.000 0.024 0.056 0.364
#> GSM38714     1  0.5873      0.602 0.556 0.000 0.024 0.056 0.364
#> GSM38715     1  0.5873      0.602 0.556 0.000 0.024 0.056 0.364
#> GSM38716     1  0.0510      0.804 0.984 0.000 0.000 0.000 0.016
#> GSM38717     1  0.3011      0.761 0.844 0.000 0.000 0.016 0.140
#> GSM38718     1  0.4645      0.682 0.688 0.000 0.000 0.044 0.268
#> GSM38719     1  0.2124      0.782 0.900 0.000 0.000 0.004 0.096
#> GSM38720     1  0.0794      0.802 0.972 0.000 0.000 0.000 0.028
#> GSM38721     1  0.5873      0.602 0.556 0.000 0.024 0.056 0.364
#> GSM38722     1  0.0290      0.799 0.992 0.000 0.000 0.000 0.008
#> GSM38723     1  0.0451      0.797 0.988 0.000 0.004 0.000 0.008
#> GSM38724     3  0.3885      0.624 0.000 0.000 0.784 0.040 0.176
#> GSM38725     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0290      0.799 0.992 0.000 0.000 0.000 0.008
#> GSM38728     4  0.5798      0.546 0.000 0.000 0.156 0.608 0.236
#> GSM38729     1  0.0162      0.803 0.996 0.000 0.000 0.000 0.004
#> GSM38730     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000
#> GSM38732     4  0.1408      0.803 0.000 0.000 0.044 0.948 0.008
#> GSM38733     1  0.5792      0.610 0.568 0.000 0.024 0.052 0.356
#> GSM38734     4  0.1341      0.824 0.000 0.056 0.000 0.944 0.000
#> GSM38735     5  0.4268      1.000 0.000 0.444 0.000 0.000 0.556
#> GSM38736     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> GSM38738     4  0.1626      0.801 0.000 0.000 0.044 0.940 0.016
#> GSM38739     3  0.4656      0.259 0.480 0.000 0.508 0.000 0.012
#> GSM38740     5  0.4268      1.000 0.000 0.444 0.000 0.000 0.556
#> GSM38741     4  0.3710      0.727 0.000 0.000 0.144 0.808 0.048
#> GSM38742     2  0.0290      0.971 0.000 0.992 0.000 0.008 0.000
#> GSM38743     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000
#> GSM38744     5  0.4268      1.000 0.000 0.444 0.000 0.000 0.556
#> GSM38745     5  0.4268      1.000 0.000 0.444 0.000 0.000 0.556
#> GSM38746     3  0.1121      0.735 0.000 0.000 0.956 0.000 0.044
#> GSM38747     3  0.1410      0.730 0.000 0.000 0.940 0.000 0.060
#> GSM38748     4  0.2561      0.794 0.000 0.144 0.000 0.856 0.000
#> GSM38749     3  0.4656      0.259 0.480 0.000 0.508 0.000 0.012
#> GSM38750     3  0.1626      0.740 0.000 0.000 0.940 0.044 0.016
#> GSM38751     3  0.0880      0.743 0.000 0.000 0.968 0.032 0.000
#> GSM38752     4  0.1544      0.824 0.000 0.068 0.000 0.932 0.000
#> GSM38753     4  0.2852      0.774 0.000 0.172 0.000 0.828 0.000
#> GSM38754     4  0.1544      0.824 0.000 0.068 0.000 0.932 0.000
#> GSM38755     3  0.5288      0.658 0.176 0.000 0.712 0.088 0.024
#> GSM38756     4  0.2813      0.778 0.000 0.168 0.000 0.832 0.000
#> GSM38757     3  0.2110      0.730 0.000 0.000 0.912 0.072 0.016
#> GSM38758     2  0.1270      0.890 0.000 0.948 0.000 0.052 0.000
#> GSM38759     4  0.7664      0.208 0.128 0.000 0.104 0.388 0.380
#> GSM38760     1  0.4582     -0.102 0.572 0.000 0.416 0.000 0.012
#> GSM38761     2  0.0290      0.971 0.000 0.992 0.000 0.008 0.000
#> GSM38762     2  0.0000      0.975 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1714     0.7780 0.908 0.000 0.000 0.000 0.000 0.092
#> GSM38713     6  0.2730     0.7805 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38714     6  0.2730     0.7805 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38715     6  0.2730     0.7805 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38716     1  0.1556     0.7867 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM38717     1  0.3860    -0.0914 0.528 0.000 0.000 0.000 0.000 0.472
#> GSM38718     6  0.3499     0.5918 0.320 0.000 0.000 0.000 0.000 0.680
#> GSM38719     1  0.3482     0.4268 0.684 0.000 0.000 0.000 0.000 0.316
#> GSM38720     1  0.2300     0.7266 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM38721     6  0.2730     0.7805 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38722     1  0.0260     0.8069 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38723     1  0.0260     0.8069 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38724     3  0.4724     0.5962 0.000 0.000 0.616 0.012 0.040 0.332
#> GSM38725     1  0.0547     0.8127 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM38726     1  0.0547     0.8127 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM38727     1  0.0260     0.8069 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38728     6  0.6367    -0.1989 0.000 0.000 0.168 0.372 0.032 0.428
#> GSM38729     1  0.1204     0.8001 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38730     1  0.0547     0.8127 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM38731     1  0.0547     0.8127 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM38732     4  0.3114     0.7767 0.000 0.000 0.048 0.860 0.040 0.052
#> GSM38733     6  0.2631     0.7698 0.180 0.000 0.000 0.000 0.000 0.820
#> GSM38734     4  0.0291     0.8372 0.000 0.000 0.004 0.992 0.004 0.000
#> GSM38735     5  0.1663     0.9979 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM38736     2  0.0000     0.9851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000     0.9851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     4  0.3368     0.7637 0.000 0.000 0.056 0.844 0.044 0.056
#> GSM38739     1  0.4124     0.4570 0.648 0.000 0.332 0.000 0.012 0.008
#> GSM38740     5  0.1663     0.9979 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM38741     4  0.4700     0.6219 0.000 0.000 0.168 0.716 0.020 0.096
#> GSM38742     2  0.0363     0.9820 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM38743     2  0.0000     0.9851 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.1753     0.9936 0.004 0.084 0.000 0.000 0.912 0.000
#> GSM38745     5  0.1663     0.9979 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM38746     3  0.2527     0.7668 0.000 0.000 0.880 0.004 0.032 0.084
#> GSM38747     3  0.3314     0.7442 0.000 0.000 0.816 0.008 0.032 0.144
#> GSM38748     4  0.2146     0.8305 0.000 0.116 0.000 0.880 0.004 0.000
#> GSM38749     1  0.4124     0.4570 0.648 0.000 0.332 0.000 0.012 0.008
#> GSM38750     3  0.2875     0.7712 0.000 0.000 0.872 0.064 0.036 0.028
#> GSM38751     3  0.0603     0.7829 0.000 0.000 0.980 0.016 0.000 0.004
#> GSM38752     4  0.1542     0.8446 0.000 0.024 0.016 0.944 0.000 0.016
#> GSM38753     4  0.2697     0.7864 0.000 0.188 0.000 0.812 0.000 0.000
#> GSM38754     4  0.1622     0.8448 0.000 0.028 0.016 0.940 0.000 0.016
#> GSM38755     3  0.6345     0.6222 0.140 0.000 0.632 0.116 0.048 0.064
#> GSM38756     4  0.2664     0.7903 0.000 0.184 0.000 0.816 0.000 0.000
#> GSM38757     3  0.3763     0.7633 0.000 0.000 0.816 0.080 0.044 0.060
#> GSM38758     2  0.1007     0.9479 0.000 0.956 0.000 0.044 0.000 0.000
#> GSM38759     6  0.5366     0.4005 0.032 0.000 0.112 0.124 0.028 0.704
#> GSM38760     1  0.3704     0.5960 0.744 0.000 0.232 0.000 0.016 0.008
#> GSM38761     2  0.0363     0.9820 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM38762     2  0.0000     0.9851 0.000 1.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-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 individual(p) k
#> SD:skmeans 51      0.078777 2
#> SD:skmeans 50      0.000260 3
#> SD:skmeans 47      0.000834 4
#> SD:skmeans 47      0.000199 5
#> SD:skmeans 45      0.000932 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 19411 rows and 51 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 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 SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.958           0.926       0.972         0.3806 0.613   0.613
#> 3 3 0.848           0.867       0.950         0.6830 0.663   0.484
#> 4 4 0.972           0.954       0.980         0.1122 0.889   0.708
#> 5 5 1.000           0.967       0.986         0.0507 0.955   0.846
#> 6 6 0.995           0.952       0.975         0.0980 0.870   0.535

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] 2 4 5

There is also optional best \(k\) = 2 4 5 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
#> GSM38712     1  0.0000      0.983 1.000 0.000
#> GSM38713     1  0.0000      0.983 1.000 0.000
#> GSM38714     1  0.0000      0.983 1.000 0.000
#> GSM38715     1  0.0000      0.983 1.000 0.000
#> GSM38716     1  0.0000      0.983 1.000 0.000
#> GSM38717     1  0.0000      0.983 1.000 0.000
#> GSM38718     1  0.0000      0.983 1.000 0.000
#> GSM38719     1  0.0000      0.983 1.000 0.000
#> GSM38720     1  0.0000      0.983 1.000 0.000
#> GSM38721     1  0.0000      0.983 1.000 0.000
#> GSM38722     1  0.0000      0.983 1.000 0.000
#> GSM38723     1  0.0000      0.983 1.000 0.000
#> GSM38724     1  0.0000      0.983 1.000 0.000
#> GSM38725     1  0.0000      0.983 1.000 0.000
#> GSM38726     1  0.0000      0.983 1.000 0.000
#> GSM38727     1  0.0000      0.983 1.000 0.000
#> GSM38728     1  0.0000      0.983 1.000 0.000
#> GSM38729     1  0.0000      0.983 1.000 0.000
#> GSM38730     1  0.0000      0.983 1.000 0.000
#> GSM38731     1  0.0000      0.983 1.000 0.000
#> GSM38732     1  0.0000      0.983 1.000 0.000
#> GSM38733     1  0.0000      0.983 1.000 0.000
#> GSM38734     1  0.0000      0.983 1.000 0.000
#> GSM38735     2  0.1184      0.916 0.016 0.984
#> GSM38736     2  0.0000      0.925 0.000 1.000
#> GSM38737     2  0.0000      0.925 0.000 1.000
#> GSM38738     1  0.0000      0.983 1.000 0.000
#> GSM38739     1  0.0000      0.983 1.000 0.000
#> GSM38740     2  0.9881      0.262 0.436 0.564
#> GSM38741     1  0.0000      0.983 1.000 0.000
#> GSM38742     2  0.0000      0.925 0.000 1.000
#> GSM38743     2  0.0000      0.925 0.000 1.000
#> GSM38744     1  0.0376      0.979 0.996 0.004
#> GSM38745     2  0.1184      0.916 0.016 0.984
#> GSM38746     1  0.0000      0.983 1.000 0.000
#> GSM38747     1  0.0000      0.983 1.000 0.000
#> GSM38748     2  0.9661      0.379 0.392 0.608
#> GSM38749     1  0.0000      0.983 1.000 0.000
#> GSM38750     1  0.0000      0.983 1.000 0.000
#> GSM38751     1  0.0000      0.983 1.000 0.000
#> GSM38752     1  0.7139      0.727 0.804 0.196
#> GSM38753     2  0.0000      0.925 0.000 1.000
#> GSM38754     1  0.9608      0.311 0.616 0.384
#> GSM38755     1  0.0000      0.983 1.000 0.000
#> GSM38756     2  0.0000      0.925 0.000 1.000
#> GSM38757     1  0.0000      0.983 1.000 0.000
#> GSM38758     2  0.0000      0.925 0.000 1.000
#> GSM38759     1  0.0000      0.983 1.000 0.000
#> GSM38760     1  0.0000      0.983 1.000 0.000
#> GSM38761     2  0.0000      0.925 0.000 1.000
#> GSM38762     2  0.0000      0.925 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
#> GSM38712     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38714     1  0.5835      0.457 0.660 0.000 0.340
#> GSM38715     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38721     1  0.3752      0.809 0.856 0.000 0.144
#> GSM38722     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38724     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38725     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38728     3  0.0000      0.894 0.000 0.000 1.000
#> GSM38729     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38732     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38733     1  0.1163      0.940 0.972 0.000 0.028
#> GSM38734     3  0.0000      0.894 0.000 0.000 1.000
#> GSM38735     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38736     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38738     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38739     1  0.0237      0.961 0.996 0.000 0.004
#> GSM38740     1  0.5291      0.629 0.732 0.268 0.000
#> GSM38741     3  0.0000      0.894 0.000 0.000 1.000
#> GSM38742     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38744     1  0.0000      0.963 1.000 0.000 0.000
#> GSM38745     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38746     3  0.5905      0.445 0.352 0.000 0.648
#> GSM38747     3  0.5905      0.445 0.352 0.000 0.648
#> GSM38748     3  0.0237      0.892 0.000 0.004 0.996
#> GSM38749     1  0.0237      0.961 0.996 0.000 0.004
#> GSM38750     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38751     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38752     3  0.0000      0.894 0.000 0.000 1.000
#> GSM38753     3  0.6302     -0.078 0.000 0.480 0.520
#> GSM38754     3  0.0000      0.894 0.000 0.000 1.000
#> GSM38755     3  0.2165      0.849 0.064 0.000 0.936
#> GSM38756     2  0.6180      0.292 0.000 0.584 0.416
#> GSM38757     3  0.0424      0.896 0.008 0.000 0.992
#> GSM38758     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38759     3  0.1289      0.879 0.032 0.000 0.968
#> GSM38760     1  0.0237      0.961 0.996 0.000 0.004
#> GSM38761     2  0.0000      0.951 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.951 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38713     1   0.139      0.931 0.952 0.000 0.048 0.000
#> GSM38714     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38715     1   0.139      0.931 0.952 0.000 0.048 0.000
#> GSM38716     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38717     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38718     1   0.139      0.931 0.952 0.000 0.048 0.000
#> GSM38719     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38720     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38721     3   0.265      0.825 0.120 0.000 0.880 0.000
#> GSM38722     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38723     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38724     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38725     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38726     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38727     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38728     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38729     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38730     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38731     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38732     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38733     1   0.404      0.679 0.752 0.000 0.248 0.000
#> GSM38734     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38735     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38736     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38737     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38738     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38739     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38740     1   0.455      0.649 0.732 0.256 0.012 0.000
#> GSM38741     3   0.401      0.684 0.000 0.000 0.756 0.244
#> GSM38742     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38743     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38744     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38745     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38746     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38747     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38748     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38749     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38750     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38751     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38752     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38753     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38754     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38755     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38756     4   0.000      1.000 0.000 0.000 0.000 1.000
#> GSM38757     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38758     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38759     3   0.000      0.969 0.000 0.000 1.000 0.000
#> GSM38760     1   0.000      0.966 1.000 0.000 0.000 0.000
#> GSM38761     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM38762     2   0.000      1.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1 p2    p3    p4 p5
#> GSM38712     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38713     1  0.1197      0.941 0.952  0 0.048 0.000  0
#> GSM38714     3  0.0162      0.963 0.004  0 0.996 0.000  0
#> GSM38715     1  0.1197      0.941 0.952  0 0.048 0.000  0
#> GSM38716     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38717     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38718     1  0.1197      0.941 0.952  0 0.048 0.000  0
#> GSM38719     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38720     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38721     3  0.2329      0.812 0.124  0 0.876 0.000  0
#> GSM38722     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38723     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38724     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38725     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38726     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38727     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38728     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38729     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38730     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38731     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38732     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38733     1  0.3143      0.738 0.796  0 0.204 0.000  0
#> GSM38734     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38735     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38738     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38739     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38740     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38741     3  0.3452      0.684 0.000  0 0.756 0.244  0
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38744     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38745     5  0.0000      1.000 0.000  0 0.000 0.000  1
#> GSM38746     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38747     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38748     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38749     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38750     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38751     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38752     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38753     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38754     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38755     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38756     4  0.0000      1.000 0.000  0 0.000 1.000  0
#> GSM38757     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38759     3  0.0000      0.967 0.000  0 1.000 0.000  0
#> GSM38760     1  0.0000      0.979 1.000  0 0.000 0.000  0
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000  0
#> GSM38762     2  0.0000      1.000 0.000  1 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4 p5    p6
#> GSM38712     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38713     6  0.0865      0.960 0.036  0 0.000 0.000  0 0.964
#> GSM38714     6  0.0865      0.972 0.000  0 0.036 0.000  0 0.964
#> GSM38715     6  0.0865      0.960 0.036  0 0.000 0.000  0 0.964
#> GSM38716     1  0.0146      0.965 0.996  0 0.000 0.000  0 0.004
#> GSM38717     1  0.3717      0.354 0.616  0 0.000 0.000  0 0.384
#> GSM38718     6  0.0865      0.960 0.036  0 0.000 0.000  0 0.964
#> GSM38719     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38720     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38721     6  0.0865      0.972 0.000  0 0.036 0.000  0 0.964
#> GSM38722     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38723     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38724     6  0.0937      0.971 0.000  0 0.040 0.000  0 0.960
#> GSM38725     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38726     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38727     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38728     6  0.0937      0.971 0.000  0 0.040 0.000  0 0.960
#> GSM38729     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38730     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38731     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38732     3  0.1765      0.867 0.000  0 0.904 0.000  0 0.096
#> GSM38733     6  0.1168      0.966 0.028  0 0.016 0.000  0 0.956
#> GSM38734     4  0.0865      0.978 0.000  0 0.000 0.964  0 0.036
#> GSM38735     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38738     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38739     3  0.2416      0.764 0.156  0 0.844 0.000  0 0.000
#> GSM38740     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38741     4  0.1007      0.946 0.000  0 0.044 0.956  0 0.000
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38744     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38745     5  0.0000      1.000 0.000  0 0.000 0.000  1 0.000
#> GSM38746     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38747     3  0.2048      0.839 0.000  0 0.880 0.000  0 0.120
#> GSM38748     4  0.0000      0.978 0.000  0 0.000 1.000  0 0.000
#> GSM38749     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38750     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38751     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38752     4  0.0865      0.978 0.000  0 0.000 0.964  0 0.036
#> GSM38753     4  0.0000      0.978 0.000  0 0.000 1.000  0 0.000
#> GSM38754     4  0.0865      0.978 0.000  0 0.000 0.964  0 0.036
#> GSM38755     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38756     4  0.0000      0.978 0.000  0 0.000 1.000  0 0.000
#> GSM38757     3  0.0000      0.940 0.000  0 1.000 0.000  0 0.000
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38759     6  0.0937      0.971 0.000  0 0.040 0.000  0 0.960
#> GSM38760     1  0.0000      0.968 1.000  0 0.000 0.000  0 0.000
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000
#> GSM38762     2  0.0000      1.000 0.000  1 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 individual(p) k
#> SD:pam 48       0.02976 2
#> SD:pam 46       0.00805 3
#> SD:pam 51       0.01392 4
#> SD:pam 51       0.00372 5
#> SD:pam 50       0.00107 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 19411 rows and 51 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 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-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.824           0.882       0.938         0.4445 0.534   0.534
#> 3 3 0.596           0.551       0.812         0.3250 0.721   0.522
#> 4 4 0.586           0.681       0.806         0.2060 0.839   0.596
#> 5 5 0.662           0.624       0.769         0.0810 0.854   0.546
#> 6 6 0.775           0.808       0.862         0.0529 0.893   0.574

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
#> GSM38712     1   0.000      0.948 1.000 0.000
#> GSM38713     1   0.204      0.952 0.968 0.032
#> GSM38714     1   0.204      0.952 0.968 0.032
#> GSM38715     1   0.204      0.952 0.968 0.032
#> GSM38716     1   0.000      0.948 1.000 0.000
#> GSM38717     1   0.000      0.948 1.000 0.000
#> GSM38718     1   0.204      0.952 0.968 0.032
#> GSM38719     1   0.000      0.948 1.000 0.000
#> GSM38720     1   0.000      0.948 1.000 0.000
#> GSM38721     1   0.204      0.952 0.968 0.032
#> GSM38722     1   0.000      0.948 1.000 0.000
#> GSM38723     1   0.000      0.948 1.000 0.000
#> GSM38724     1   0.358      0.941 0.932 0.068
#> GSM38725     1   0.000      0.948 1.000 0.000
#> GSM38726     1   0.000      0.948 1.000 0.000
#> GSM38727     1   0.000      0.948 1.000 0.000
#> GSM38728     1   0.358      0.941 0.932 0.068
#> GSM38729     1   0.680      0.735 0.820 0.180
#> GSM38730     1   0.000      0.948 1.000 0.000
#> GSM38731     1   0.000      0.948 1.000 0.000
#> GSM38732     1   0.358      0.941 0.932 0.068
#> GSM38733     1   0.204      0.952 0.968 0.032
#> GSM38734     2   0.895      0.607 0.312 0.688
#> GSM38735     2   0.000      0.890 0.000 1.000
#> GSM38736     2   0.000      0.890 0.000 1.000
#> GSM38737     2   0.000      0.890 0.000 1.000
#> GSM38738     1   0.358      0.941 0.932 0.068
#> GSM38739     1   0.204      0.950 0.968 0.032
#> GSM38740     2   0.000      0.890 0.000 1.000
#> GSM38741     1   0.925      0.463 0.660 0.340
#> GSM38742     2   0.000      0.890 0.000 1.000
#> GSM38743     2   0.000      0.890 0.000 1.000
#> GSM38744     2   0.000      0.890 0.000 1.000
#> GSM38745     2   0.000      0.890 0.000 1.000
#> GSM38746     1   0.358      0.941 0.932 0.068
#> GSM38747     1   0.358      0.941 0.932 0.068
#> GSM38748     2   0.808      0.695 0.248 0.752
#> GSM38749     1   0.163      0.951 0.976 0.024
#> GSM38750     1   0.358      0.941 0.932 0.068
#> GSM38751     1   0.358      0.941 0.932 0.068
#> GSM38752     2   0.891      0.614 0.308 0.692
#> GSM38753     2   0.260      0.872 0.044 0.956
#> GSM38754     2   0.891      0.614 0.308 0.692
#> GSM38755     1   0.358      0.941 0.932 0.068
#> GSM38756     2   0.260      0.872 0.044 0.956
#> GSM38757     1   0.358      0.941 0.932 0.068
#> GSM38758     2   0.000      0.890 0.000 1.000
#> GSM38759     2   0.975      0.380 0.408 0.592
#> GSM38760     1   0.184      0.952 0.972 0.028
#> GSM38761     2   0.000      0.890 0.000 1.000
#> GSM38762     2   0.000      0.890 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
#> GSM38712     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38713     1  0.6079     0.2541 0.612 0.000 0.388
#> GSM38714     1  0.6079     0.2541 0.612 0.000 0.388
#> GSM38715     1  0.6079     0.2541 0.612 0.000 0.388
#> GSM38716     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38717     1  0.0892     0.6673 0.980 0.000 0.020
#> GSM38718     1  0.6062     0.2605 0.616 0.000 0.384
#> GSM38719     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38720     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38721     1  0.6062     0.2605 0.616 0.000 0.384
#> GSM38722     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38723     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38724     1  0.6291    -0.0793 0.532 0.000 0.468
#> GSM38725     1  0.0892     0.6673 0.980 0.000 0.020
#> GSM38726     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38727     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38728     1  0.6302    -0.0932 0.520 0.000 0.480
#> GSM38729     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38730     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38731     1  0.0000     0.6745 1.000 0.000 0.000
#> GSM38732     3  0.6267     0.3100 0.452 0.000 0.548
#> GSM38733     1  0.6062     0.2605 0.616 0.000 0.384
#> GSM38734     3  0.1765     0.5812 0.040 0.004 0.956
#> GSM38735     2  0.0000     0.9967 0.000 1.000 0.000
#> GSM38736     2  0.0237     0.9976 0.000 0.996 0.004
#> GSM38737     2  0.0237     0.9976 0.000 0.996 0.004
#> GSM38738     3  0.6267     0.3100 0.452 0.000 0.548
#> GSM38739     1  0.6192     0.0596 0.580 0.000 0.420
#> GSM38740     2  0.0000     0.9967 0.000 1.000 0.000
#> GSM38741     3  0.3272     0.5739 0.104 0.004 0.892
#> GSM38742     2  0.0237     0.9976 0.000 0.996 0.004
#> GSM38743     2  0.0237     0.9976 0.000 0.996 0.004
#> GSM38744     2  0.0000     0.9967 0.000 1.000 0.000
#> GSM38745     2  0.0000     0.9967 0.000 1.000 0.000
#> GSM38746     3  0.6314     0.4267 0.392 0.004 0.604
#> GSM38747     3  0.6379     0.4532 0.368 0.008 0.624
#> GSM38748     3  0.0661     0.5799 0.008 0.004 0.988
#> GSM38749     1  0.6410     0.0504 0.576 0.004 0.420
#> GSM38750     3  0.6410     0.3804 0.420 0.004 0.576
#> GSM38751     3  0.6228     0.4501 0.372 0.004 0.624
#> GSM38752     3  0.0237     0.5774 0.000 0.004 0.996
#> GSM38753     3  0.0592     0.5765 0.000 0.012 0.988
#> GSM38754     3  0.0237     0.5774 0.000 0.004 0.996
#> GSM38755     3  0.6286     0.2810 0.464 0.000 0.536
#> GSM38756     3  0.0592     0.5761 0.000 0.012 0.988
#> GSM38757     3  0.6286     0.2810 0.464 0.000 0.536
#> GSM38758     2  0.0747     0.9898 0.000 0.984 0.016
#> GSM38759     3  0.6309     0.0581 0.500 0.000 0.500
#> GSM38760     1  0.6286    -0.0668 0.536 0.000 0.464
#> GSM38761     2  0.0237     0.9976 0.000 0.996 0.004
#> GSM38762     2  0.0237     0.9976 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0188      0.793 0.996 0.000 0.004 0.000
#> GSM38713     1  0.5917      0.539 0.624 0.000 0.320 0.056
#> GSM38714     1  0.6570      0.492 0.580 0.000 0.320 0.100
#> GSM38715     1  0.5130      0.572 0.668 0.000 0.312 0.020
#> GSM38716     1  0.0188      0.793 0.996 0.000 0.004 0.000
#> GSM38717     1  0.0524      0.793 0.988 0.000 0.004 0.008
#> GSM38718     1  0.3266      0.739 0.868 0.000 0.108 0.024
#> GSM38719     1  0.0336      0.793 0.992 0.000 0.000 0.008
#> GSM38720     1  0.0672      0.792 0.984 0.000 0.008 0.008
#> GSM38721     1  0.6280      0.516 0.612 0.000 0.304 0.084
#> GSM38722     1  0.1022      0.774 0.968 0.000 0.032 0.000
#> GSM38723     1  0.1118      0.771 0.964 0.000 0.036 0.000
#> GSM38724     3  0.5426      0.416 0.232 0.000 0.708 0.060
#> GSM38725     1  0.0469      0.791 0.988 0.000 0.012 0.000
#> GSM38726     1  0.0188      0.793 0.996 0.000 0.004 0.000
#> GSM38727     1  0.1716      0.742 0.936 0.000 0.064 0.000
#> GSM38728     1  0.6960      0.316 0.468 0.000 0.420 0.112
#> GSM38729     1  0.0672      0.792 0.984 0.000 0.008 0.008
#> GSM38730     1  0.0188      0.793 0.996 0.000 0.004 0.000
#> GSM38731     1  0.0188      0.793 0.996 0.000 0.004 0.000
#> GSM38732     3  0.7248      0.521 0.148 0.000 0.472 0.380
#> GSM38733     1  0.6810      0.467 0.596 0.000 0.248 0.156
#> GSM38734     4  0.3392      0.466 0.020 0.000 0.124 0.856
#> GSM38735     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM38736     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38738     3  0.7113      0.567 0.152 0.000 0.532 0.316
#> GSM38739     3  0.4916      0.547 0.424 0.000 0.576 0.000
#> GSM38740     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM38741     3  0.2919      0.349 0.044 0.000 0.896 0.060
#> GSM38742     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38744     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM38745     2  0.0336      0.971 0.000 0.992 0.000 0.008
#> GSM38746     3  0.4331      0.557 0.288 0.000 0.712 0.000
#> GSM38747     3  0.3320      0.321 0.068 0.000 0.876 0.056
#> GSM38748     4  0.1118      0.562 0.000 0.000 0.036 0.964
#> GSM38749     3  0.4916      0.547 0.424 0.000 0.576 0.000
#> GSM38750     3  0.6476      0.574 0.112 0.000 0.616 0.272
#> GSM38751     3  0.4936      0.574 0.316 0.000 0.672 0.012
#> GSM38752     4  0.4855      0.571 0.000 0.000 0.400 0.600
#> GSM38753     4  0.4869      0.544 0.260 0.004 0.016 0.720
#> GSM38754     4  0.4855      0.571 0.000 0.000 0.400 0.600
#> GSM38755     3  0.7149      0.566 0.156 0.000 0.528 0.316
#> GSM38756     4  0.4869      0.544 0.260 0.004 0.016 0.720
#> GSM38757     3  0.7159      0.596 0.180 0.000 0.548 0.272
#> GSM38758     2  0.3907      0.700 0.000 0.768 0.000 0.232
#> GSM38759     1  0.5772      0.595 0.708 0.000 0.176 0.116
#> GSM38760     3  0.5292      0.468 0.480 0.000 0.512 0.008
#> GSM38761     2  0.0188      0.971 0.000 0.996 0.000 0.004
#> GSM38762     2  0.0000      0.972 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0963     0.7460 0.964 0.000 0.036 0.000 0.000
#> GSM38713     5  0.4958     0.6936 0.372 0.000 0.036 0.000 0.592
#> GSM38714     5  0.5392     0.7259 0.252 0.000 0.056 0.024 0.668
#> GSM38715     5  0.5262     0.6765 0.388 0.000 0.036 0.008 0.568
#> GSM38716     1  0.0703     0.7314 0.976 0.000 0.000 0.000 0.024
#> GSM38717     1  0.3282     0.6304 0.804 0.000 0.008 0.000 0.188
#> GSM38718     1  0.6930    -0.0715 0.488 0.000 0.072 0.084 0.356
#> GSM38719     1  0.2806     0.6608 0.844 0.000 0.004 0.000 0.152
#> GSM38720     1  0.3715     0.5625 0.736 0.000 0.004 0.000 0.260
#> GSM38721     5  0.4853     0.7353 0.296 0.000 0.032 0.008 0.664
#> GSM38722     1  0.1043     0.7458 0.960 0.000 0.040 0.000 0.000
#> GSM38723     1  0.1043     0.7458 0.960 0.000 0.040 0.000 0.000
#> GSM38724     3  0.5454     0.4503 0.036 0.000 0.608 0.024 0.332
#> GSM38725     1  0.1043     0.7459 0.960 0.000 0.040 0.000 0.000
#> GSM38726     1  0.0162     0.7445 0.996 0.000 0.004 0.000 0.000
#> GSM38727     1  0.0290     0.7444 0.992 0.000 0.008 0.000 0.000
#> GSM38728     5  0.6521    -0.1479 0.024 0.000 0.388 0.108 0.480
#> GSM38729     1  0.3452     0.5761 0.756 0.000 0.000 0.000 0.244
#> GSM38730     1  0.0963     0.7454 0.964 0.000 0.036 0.000 0.000
#> GSM38731     1  0.0451     0.7413 0.988 0.000 0.004 0.000 0.008
#> GSM38732     3  0.3312     0.6245 0.048 0.000 0.864 0.020 0.068
#> GSM38733     5  0.5519     0.7258 0.292 0.000 0.076 0.008 0.624
#> GSM38734     4  0.4558     0.6460 0.000 0.000 0.324 0.652 0.024
#> GSM38735     2  0.3395     0.7985 0.000 0.764 0.000 0.000 0.236
#> GSM38736     2  0.1043     0.8718 0.000 0.960 0.000 0.040 0.000
#> GSM38737     2  0.1043     0.8718 0.000 0.960 0.000 0.040 0.000
#> GSM38738     3  0.2885     0.6334 0.052 0.000 0.880 0.004 0.064
#> GSM38739     1  0.4302     0.0803 0.520 0.000 0.480 0.000 0.000
#> GSM38740     2  0.3395     0.7985 0.000 0.764 0.000 0.000 0.236
#> GSM38741     3  0.5760     0.4787 0.008 0.000 0.620 0.108 0.264
#> GSM38742     2  0.1270     0.8669 0.000 0.948 0.000 0.052 0.000
#> GSM38743     2  0.1043     0.8718 0.000 0.960 0.000 0.040 0.000
#> GSM38744     2  0.3395     0.7985 0.000 0.764 0.000 0.000 0.236
#> GSM38745     2  0.3395     0.7985 0.000 0.764 0.000 0.000 0.236
#> GSM38746     3  0.5373     0.4683 0.296 0.000 0.620 0.000 0.084
#> GSM38747     3  0.5515     0.4749 0.000 0.000 0.624 0.108 0.268
#> GSM38748     4  0.3895     0.6602 0.000 0.000 0.320 0.680 0.000
#> GSM38749     1  0.4192     0.3362 0.596 0.000 0.404 0.000 0.000
#> GSM38750     3  0.1357     0.6463 0.048 0.000 0.948 0.000 0.004
#> GSM38751     3  0.4503     0.4448 0.312 0.000 0.664 0.000 0.024
#> GSM38752     4  0.4622     0.5734 0.000 0.000 0.044 0.692 0.264
#> GSM38753     4  0.2685     0.7096 0.092 0.000 0.028 0.880 0.000
#> GSM38754     4  0.4264     0.6198 0.000 0.000 0.044 0.744 0.212
#> GSM38755     3  0.3019     0.6316 0.088 0.000 0.864 0.000 0.048
#> GSM38756     4  0.2685     0.7096 0.092 0.000 0.028 0.880 0.000
#> GSM38757     3  0.1800     0.6486 0.048 0.000 0.932 0.000 0.020
#> GSM38758     2  0.3109     0.7227 0.000 0.800 0.000 0.200 0.000
#> GSM38759     3  0.8134    -0.0348 0.228 0.000 0.344 0.108 0.320
#> GSM38760     1  0.4482     0.4036 0.636 0.000 0.348 0.000 0.016
#> GSM38761     2  0.1197     0.8689 0.000 0.952 0.000 0.048 0.000
#> GSM38762     2  0.1043     0.8718 0.000 0.960 0.000 0.040 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
#> GSM38712     1  0.3126      0.745 0.752 0.000 0.000 0.000 0.000 0.248
#> GSM38713     6  0.3193      0.815 0.052 0.000 0.124 0.000 0.000 0.824
#> GSM38714     6  0.2791      0.791 0.032 0.000 0.096 0.000 0.008 0.864
#> GSM38715     6  0.3193      0.815 0.052 0.000 0.124 0.000 0.000 0.824
#> GSM38716     1  0.2527      0.790 0.832 0.000 0.000 0.000 0.000 0.168
#> GSM38717     1  0.4203      0.591 0.596 0.000 0.008 0.000 0.008 0.388
#> GSM38718     6  0.5331      0.234 0.320 0.000 0.088 0.004 0.008 0.580
#> GSM38719     1  0.3874      0.649 0.636 0.000 0.000 0.000 0.008 0.356
#> GSM38720     1  0.3887      0.646 0.632 0.000 0.000 0.000 0.008 0.360
#> GSM38721     6  0.3130      0.815 0.048 0.000 0.124 0.000 0.000 0.828
#> GSM38722     1  0.0000      0.770 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.770 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38724     3  0.1970      0.804 0.008 0.000 0.900 0.000 0.000 0.092
#> GSM38725     1  0.1913      0.784 0.908 0.000 0.012 0.000 0.000 0.080
#> GSM38726     1  0.1204      0.795 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38727     1  0.0000      0.770 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38728     6  0.3819      0.531 0.012 0.000 0.316 0.000 0.000 0.672
#> GSM38729     1  0.3887      0.646 0.632 0.000 0.000 0.000 0.008 0.360
#> GSM38730     1  0.1765      0.804 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM38731     1  0.2003      0.803 0.884 0.000 0.000 0.000 0.000 0.116
#> GSM38732     3  0.0865      0.817 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM38733     6  0.3130      0.815 0.048 0.000 0.124 0.000 0.000 0.828
#> GSM38734     4  0.0713      0.969 0.000 0.000 0.028 0.972 0.000 0.000
#> GSM38735     5  0.1141      1.000 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM38736     2  0.0146      0.990 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38737     2  0.0146      0.990 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38738     3  0.0363      0.823 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM38739     3  0.4967      0.632 0.200 0.000 0.692 0.000 0.044 0.064
#> GSM38740     5  0.1141      1.000 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM38741     3  0.3062      0.766 0.000 0.000 0.836 0.052 0.000 0.112
#> GSM38742     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0146      0.990 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38744     5  0.1141      1.000 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM38745     5  0.1141      1.000 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM38746     3  0.2852      0.805 0.020 0.000 0.872 0.000 0.044 0.064
#> GSM38747     3  0.3808      0.599 0.012 0.000 0.700 0.004 0.000 0.284
#> GSM38748     4  0.0363      0.976 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM38749     3  0.5022      0.621 0.208 0.000 0.684 0.000 0.044 0.064
#> GSM38750     3  0.0146      0.824 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM38751     3  0.2259      0.814 0.008 0.000 0.904 0.000 0.044 0.044
#> GSM38752     4  0.1141      0.966 0.000 0.000 0.000 0.948 0.000 0.052
#> GSM38753     4  0.0146      0.977 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM38754     4  0.1075      0.967 0.000 0.000 0.000 0.952 0.000 0.048
#> GSM38755     3  0.0713      0.820 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM38756     4  0.0146      0.977 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM38757     3  0.0363      0.823 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM38758     2  0.1007      0.947 0.000 0.956 0.000 0.044 0.000 0.000
#> GSM38759     6  0.4259      0.557 0.020 0.000 0.292 0.004 0.008 0.676
#> GSM38760     3  0.5554      0.430 0.316 0.000 0.576 0.000 0.044 0.064
#> GSM38761     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0146      0.990 0.000 0.996 0.000 0.000 0.004 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.978       0.990         0.4154 0.594   0.594
#> 3 3 1.000           0.978       0.990         0.3965 0.749   0.603
#> 4 4 0.830           0.855       0.923         0.2735 0.788   0.522
#> 5 5 0.814           0.779       0.893         0.0416 0.940   0.779
#> 6 6 0.708           0.666       0.832         0.0343 0.944   0.784

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
#> GSM38712     1  0.0000      0.986 1.000 0.000
#> GSM38713     1  0.0000      0.986 1.000 0.000
#> GSM38714     1  0.0000      0.986 1.000 0.000
#> GSM38715     1  0.0000      0.986 1.000 0.000
#> GSM38716     1  0.0000      0.986 1.000 0.000
#> GSM38717     1  0.0000      0.986 1.000 0.000
#> GSM38718     1  0.0000      0.986 1.000 0.000
#> GSM38719     1  0.0000      0.986 1.000 0.000
#> GSM38720     1  0.0000      0.986 1.000 0.000
#> GSM38721     1  0.0000      0.986 1.000 0.000
#> GSM38722     1  0.0000      0.986 1.000 0.000
#> GSM38723     1  0.0000      0.986 1.000 0.000
#> GSM38724     1  0.0000      0.986 1.000 0.000
#> GSM38725     1  0.0000      0.986 1.000 0.000
#> GSM38726     1  0.0000      0.986 1.000 0.000
#> GSM38727     1  0.0000      0.986 1.000 0.000
#> GSM38728     1  0.6712      0.791 0.824 0.176
#> GSM38729     1  0.0000      0.986 1.000 0.000
#> GSM38730     1  0.0000      0.986 1.000 0.000
#> GSM38731     1  0.0000      0.986 1.000 0.000
#> GSM38732     1  0.0000      0.986 1.000 0.000
#> GSM38733     1  0.0000      0.986 1.000 0.000
#> GSM38734     2  0.0000      1.000 0.000 1.000
#> GSM38735     1  0.8661      0.605 0.712 0.288
#> GSM38736     2  0.0000      1.000 0.000 1.000
#> GSM38737     2  0.0000      1.000 0.000 1.000
#> GSM38738     1  0.0376      0.983 0.996 0.004
#> GSM38739     1  0.0000      0.986 1.000 0.000
#> GSM38740     1  0.0000      0.986 1.000 0.000
#> GSM38741     2  0.0000      1.000 0.000 1.000
#> GSM38742     2  0.0000      1.000 0.000 1.000
#> GSM38743     2  0.0000      1.000 0.000 1.000
#> GSM38744     1  0.0000      0.986 1.000 0.000
#> GSM38745     1  0.0000      0.986 1.000 0.000
#> GSM38746     1  0.0000      0.986 1.000 0.000
#> GSM38747     1  0.2423      0.950 0.960 0.040
#> GSM38748     2  0.0000      1.000 0.000 1.000
#> GSM38749     1  0.0000      0.986 1.000 0.000
#> GSM38750     1  0.0000      0.986 1.000 0.000
#> GSM38751     1  0.0376      0.983 0.996 0.004
#> GSM38752     2  0.0000      1.000 0.000 1.000
#> GSM38753     2  0.0000      1.000 0.000 1.000
#> GSM38754     2  0.0000      1.000 0.000 1.000
#> GSM38755     1  0.0000      0.986 1.000 0.000
#> GSM38756     2  0.0000      1.000 0.000 1.000
#> GSM38757     1  0.0000      0.986 1.000 0.000
#> GSM38758     2  0.0000      1.000 0.000 1.000
#> GSM38759     1  0.0000      0.986 1.000 0.000
#> GSM38760     1  0.0000      0.986 1.000 0.000
#> GSM38761     2  0.0000      1.000 0.000 1.000
#> GSM38762     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38721     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38722     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38724     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38725     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38728     3  0.3192      0.861 0.112 0.000 0.888
#> GSM38729     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38732     3  0.1860      0.928 0.052 0.000 0.948
#> GSM38733     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38734     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38735     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38736     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38738     3  0.2625      0.898 0.084 0.000 0.916
#> GSM38739     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38740     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38741     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38742     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38744     2  0.0237      0.994 0.004 0.996 0.000
#> GSM38745     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38746     1  0.0424      0.985 0.992 0.000 0.008
#> GSM38747     1  0.4062      0.802 0.836 0.000 0.164
#> GSM38748     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38749     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38750     1  0.0592      0.982 0.988 0.000 0.012
#> GSM38751     1  0.0237      0.988 0.996 0.000 0.004
#> GSM38752     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38753     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38754     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38755     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38756     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38757     1  0.1529      0.957 0.960 0.000 0.040
#> GSM38758     2  0.0237      0.995 0.000 0.996 0.004
#> GSM38759     1  0.1163      0.968 0.972 0.000 0.028
#> GSM38760     1  0.0000      0.991 1.000 0.000 0.000
#> GSM38761     2  0.0000      0.999 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.999 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.1557      0.904 0.944 0.000 0.056 0.000
#> GSM38713     1  0.0707      0.912 0.980 0.000 0.020 0.000
#> GSM38714     1  0.0188      0.924 0.996 0.000 0.004 0.000
#> GSM38715     1  0.0000      0.922 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0817      0.919 0.976 0.000 0.024 0.000
#> GSM38717     1  0.0336      0.924 0.992 0.000 0.008 0.000
#> GSM38718     1  0.0336      0.924 0.992 0.000 0.008 0.000
#> GSM38719     1  0.0336      0.924 0.992 0.000 0.008 0.000
#> GSM38720     1  0.0336      0.924 0.992 0.000 0.008 0.000
#> GSM38721     1  0.0188      0.924 0.996 0.000 0.004 0.000
#> GSM38722     3  0.2921      0.829 0.140 0.000 0.860 0.000
#> GSM38723     3  0.1940      0.876 0.076 0.000 0.924 0.000
#> GSM38724     3  0.7876      0.128 0.352 0.000 0.368 0.280
#> GSM38725     1  0.4222      0.632 0.728 0.000 0.272 0.000
#> GSM38726     1  0.3024      0.820 0.852 0.000 0.148 0.000
#> GSM38727     3  0.2011      0.874 0.080 0.000 0.920 0.000
#> GSM38728     1  0.4800      0.481 0.656 0.000 0.004 0.340
#> GSM38729     1  0.0336      0.924 0.992 0.000 0.008 0.000
#> GSM38730     1  0.3219      0.800 0.836 0.000 0.164 0.000
#> GSM38731     1  0.1940      0.888 0.924 0.000 0.076 0.000
#> GSM38732     4  0.5596      0.664 0.236 0.000 0.068 0.696
#> GSM38733     1  0.1211      0.896 0.960 0.000 0.040 0.000
#> GSM38734     4  0.2048      0.916 0.008 0.000 0.064 0.928
#> GSM38735     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38736     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38738     4  0.2593      0.894 0.004 0.000 0.104 0.892
#> GSM38739     3  0.1716      0.879 0.064 0.000 0.936 0.000
#> GSM38740     3  0.4964      0.348 0.004 0.380 0.616 0.000
#> GSM38741     4  0.0336      0.940 0.000 0.000 0.008 0.992
#> GSM38742     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38744     2  0.4599      0.618 0.016 0.736 0.248 0.000
#> GSM38745     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38746     3  0.1824      0.878 0.060 0.000 0.936 0.004
#> GSM38747     3  0.2926      0.856 0.048 0.000 0.896 0.056
#> GSM38748     4  0.0376      0.942 0.004 0.000 0.004 0.992
#> GSM38749     3  0.1716      0.879 0.064 0.000 0.936 0.000
#> GSM38750     3  0.0188      0.846 0.004 0.000 0.996 0.000
#> GSM38751     3  0.1637      0.878 0.060 0.000 0.940 0.000
#> GSM38752     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> GSM38753     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> GSM38754     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> GSM38755     3  0.0000      0.843 0.000 0.000 1.000 0.000
#> GSM38756     4  0.0000      0.943 0.000 0.000 0.000 1.000
#> GSM38757     3  0.3668      0.671 0.004 0.000 0.808 0.188
#> GSM38758     2  0.1022      0.937 0.000 0.968 0.000 0.032
#> GSM38759     1  0.1042      0.916 0.972 0.000 0.008 0.020
#> GSM38760     3  0.1792      0.878 0.068 0.000 0.932 0.000
#> GSM38761     2  0.0000      0.963 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0000      0.963 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0510      0.896 0.984 0.000 0.016 0.000 0.000
#> GSM38713     1  0.2891      0.782 0.824 0.000 0.000 0.000 0.176
#> GSM38714     1  0.0510      0.897 0.984 0.000 0.000 0.000 0.016
#> GSM38715     1  0.1341      0.879 0.944 0.000 0.000 0.000 0.056
#> GSM38716     1  0.0162      0.899 0.996 0.000 0.004 0.000 0.000
#> GSM38717     1  0.0162      0.899 0.996 0.000 0.004 0.000 0.000
#> GSM38718     1  0.0290      0.899 0.992 0.000 0.000 0.000 0.008
#> GSM38719     1  0.0404      0.898 0.988 0.000 0.000 0.000 0.012
#> GSM38720     1  0.0451      0.899 0.988 0.000 0.004 0.000 0.008
#> GSM38721     1  0.0162      0.899 0.996 0.000 0.000 0.000 0.004
#> GSM38722     3  0.4249      0.253 0.432 0.000 0.568 0.000 0.000
#> GSM38723     3  0.0794      0.769 0.028 0.000 0.972 0.000 0.000
#> GSM38724     1  0.5191      0.597 0.684 0.000 0.192 0.124 0.000
#> GSM38725     1  0.3586      0.622 0.736 0.000 0.264 0.000 0.000
#> GSM38726     1  0.1205      0.887 0.956 0.000 0.040 0.000 0.004
#> GSM38727     3  0.2074      0.692 0.104 0.000 0.896 0.000 0.000
#> GSM38728     1  0.5263      0.378 0.576 0.000 0.000 0.368 0.056
#> GSM38729     1  0.0162      0.899 0.996 0.000 0.004 0.000 0.000
#> GSM38730     1  0.0703      0.893 0.976 0.000 0.024 0.000 0.000
#> GSM38731     1  0.0324      0.899 0.992 0.000 0.004 0.000 0.004
#> GSM38732     5  0.2390      0.587 0.000 0.000 0.020 0.084 0.896
#> GSM38733     1  0.3949      0.585 0.668 0.000 0.000 0.000 0.332
#> GSM38734     5  0.2424      0.549 0.000 0.000 0.000 0.132 0.868
#> GSM38735     2  0.1792      0.876 0.000 0.916 0.000 0.000 0.084
#> GSM38736     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM38738     5  0.5086      0.664 0.000 0.000 0.304 0.060 0.636
#> GSM38739     3  0.0000      0.781 0.000 0.000 1.000 0.000 0.000
#> GSM38740     3  0.7679      0.233 0.268 0.192 0.456 0.000 0.084
#> GSM38741     4  0.0162      0.973 0.000 0.000 0.004 0.996 0.000
#> GSM38742     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM38744     2  0.6791      0.402 0.292 0.548 0.076 0.000 0.084
#> GSM38745     2  0.1952      0.874 0.004 0.912 0.000 0.000 0.084
#> GSM38746     3  0.0000      0.781 0.000 0.000 1.000 0.000 0.000
#> GSM38747     3  0.2763      0.635 0.004 0.000 0.848 0.148 0.000
#> GSM38748     4  0.2074      0.878 0.000 0.000 0.000 0.896 0.104
#> GSM38749     3  0.0000      0.781 0.000 0.000 1.000 0.000 0.000
#> GSM38750     3  0.0880      0.749 0.000 0.000 0.968 0.000 0.032
#> GSM38751     3  0.0000      0.781 0.000 0.000 1.000 0.000 0.000
#> GSM38752     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> GSM38753     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> GSM38754     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> GSM38755     5  0.4256      0.561 0.000 0.000 0.436 0.000 0.564
#> GSM38756     4  0.0000      0.976 0.000 0.000 0.000 1.000 0.000
#> GSM38757     5  0.4305      0.471 0.000 0.000 0.488 0.000 0.512
#> GSM38758     2  0.2179      0.822 0.000 0.888 0.000 0.112 0.000
#> GSM38759     1  0.1608      0.866 0.928 0.000 0.000 0.072 0.000
#> GSM38760     3  0.0000      0.781 0.000 0.000 1.000 0.000 0.000
#> GSM38761     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      0.911 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1010     0.7310 0.960 0.000 0.004 0.000 0.036 0.000
#> GSM38713     1  0.3221     0.6889 0.828 0.000 0.000 0.000 0.096 0.076
#> GSM38714     1  0.1075     0.7318 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM38715     1  0.1616     0.7276 0.932 0.000 0.000 0.000 0.048 0.020
#> GSM38716     1  0.1003     0.7338 0.964 0.000 0.016 0.000 0.020 0.000
#> GSM38717     1  0.0632     0.7340 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM38718     1  0.1863     0.7133 0.896 0.000 0.000 0.000 0.104 0.000
#> GSM38719     1  0.0458     0.7365 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM38720     1  0.1444     0.7288 0.928 0.000 0.000 0.000 0.072 0.000
#> GSM38721     1  0.1075     0.7292 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM38722     1  0.4335     0.0550 0.508 0.000 0.472 0.000 0.020 0.000
#> GSM38723     3  0.2070     0.7557 0.100 0.000 0.892 0.000 0.008 0.000
#> GSM38724     1  0.6396     0.1997 0.580 0.000 0.092 0.148 0.176 0.004
#> GSM38725     1  0.5852    -0.0608 0.544 0.000 0.192 0.000 0.252 0.012
#> GSM38726     1  0.3756     0.5077 0.712 0.000 0.268 0.000 0.020 0.000
#> GSM38727     3  0.2704     0.7095 0.140 0.000 0.844 0.000 0.016 0.000
#> GSM38728     1  0.5874     0.2862 0.500 0.000 0.000 0.292 0.204 0.004
#> GSM38729     1  0.1501     0.7312 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM38730     1  0.1418     0.7269 0.944 0.000 0.024 0.000 0.032 0.000
#> GSM38731     1  0.4175     0.6028 0.740 0.000 0.156 0.000 0.104 0.000
#> GSM38732     6  0.2454     0.7910 0.000 0.000 0.000 0.000 0.160 0.840
#> GSM38733     1  0.5851     0.2650 0.484 0.000 0.000 0.000 0.280 0.236
#> GSM38734     6  0.0291     0.8169 0.000 0.000 0.000 0.004 0.004 0.992
#> GSM38735     2  0.2730     0.7309 0.000 0.808 0.000 0.000 0.192 0.000
#> GSM38736     2  0.0000     0.8987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000     0.8987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     6  0.3376     0.7656 0.000 0.000 0.128 0.004 0.052 0.816
#> GSM38739     3  0.0777     0.7939 0.000 0.000 0.972 0.000 0.024 0.004
#> GSM38740     5  0.6840     0.7420 0.240 0.080 0.208 0.000 0.472 0.000
#> GSM38741     4  0.0405     0.8468 0.000 0.000 0.008 0.988 0.004 0.000
#> GSM38742     2  0.0146     0.8975 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38743     2  0.0000     0.8987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.6642     0.7354 0.256 0.220 0.052 0.000 0.472 0.000
#> GSM38745     2  0.4099     0.3656 0.000 0.612 0.016 0.000 0.372 0.000
#> GSM38746     3  0.2941     0.6264 0.000 0.000 0.780 0.000 0.220 0.000
#> GSM38747     3  0.5307     0.4920 0.020 0.000 0.664 0.144 0.168 0.004
#> GSM38748     4  0.5657     0.0730 0.000 0.000 0.000 0.436 0.152 0.412
#> GSM38749     3  0.0551     0.7984 0.008 0.000 0.984 0.000 0.004 0.004
#> GSM38750     3  0.1812     0.7829 0.000 0.000 0.912 0.000 0.008 0.080
#> GSM38751     3  0.0363     0.7970 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM38752     4  0.1462     0.8411 0.000 0.000 0.000 0.936 0.008 0.056
#> GSM38753     4  0.0520     0.8488 0.000 0.000 0.000 0.984 0.008 0.008
#> GSM38754     4  0.2039     0.8282 0.000 0.000 0.000 0.904 0.020 0.076
#> GSM38755     3  0.4434     0.2155 0.000 0.000 0.544 0.000 0.028 0.428
#> GSM38756     4  0.0858     0.8452 0.000 0.000 0.000 0.968 0.004 0.028
#> GSM38757     3  0.3512     0.6623 0.000 0.000 0.772 0.000 0.032 0.196
#> GSM38758     2  0.2020     0.8084 0.000 0.896 0.000 0.096 0.008 0.000
#> GSM38759     1  0.4011     0.5636 0.736 0.000 0.000 0.204 0.060 0.000
#> GSM38760     3  0.1471     0.7824 0.064 0.000 0.932 0.000 0.004 0.000
#> GSM38761     2  0.0146     0.8975 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38762     2  0.0000     0.8987 0.000 1.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-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 individual(p) k
#> SD:NMF 51      0.046137 2
#> SD:NMF 51      0.008714 3
#> SD:NMF 48      0.000723 4
#> SD:NMF 46      0.002081 5
#> SD:NMF 42      0.003813 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 19411 rows and 51 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.361           0.661       0.827          0.370 0.730   0.730
#> 3 3 0.400           0.584       0.765          0.563 0.802   0.729
#> 4 4 0.551           0.641       0.745          0.118 0.869   0.765
#> 5 5 0.571           0.671       0.760          0.039 0.991   0.979
#> 6 6 0.761           0.813       0.868          0.164 0.787   0.518

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
#> GSM38712     1  0.0000      0.764 1.000 0.000
#> GSM38713     1  0.2778      0.765 0.952 0.048
#> GSM38714     1  0.2778      0.765 0.952 0.048
#> GSM38715     1  0.2778      0.765 0.952 0.048
#> GSM38716     1  0.0000      0.764 1.000 0.000
#> GSM38717     1  0.2423      0.767 0.960 0.040
#> GSM38718     1  0.1843      0.766 0.972 0.028
#> GSM38719     1  0.0000      0.764 1.000 0.000
#> GSM38720     1  0.0000      0.764 1.000 0.000
#> GSM38721     1  0.8909      0.639 0.692 0.308
#> GSM38722     1  0.0000      0.764 1.000 0.000
#> GSM38723     1  0.0000      0.764 1.000 0.000
#> GSM38724     1  0.9286      0.610 0.656 0.344
#> GSM38725     1  0.2236      0.766 0.964 0.036
#> GSM38726     1  0.0000      0.764 1.000 0.000
#> GSM38727     1  0.0000      0.764 1.000 0.000
#> GSM38728     1  0.9983      0.421 0.524 0.476
#> GSM38729     1  0.0000      0.764 1.000 0.000
#> GSM38730     1  0.0000      0.764 1.000 0.000
#> GSM38731     1  0.0000      0.764 1.000 0.000
#> GSM38732     2  0.5294      0.773 0.120 0.880
#> GSM38733     1  0.9661      0.531 0.608 0.392
#> GSM38734     2  0.0376      0.880 0.004 0.996
#> GSM38735     1  0.0376      0.762 0.996 0.004
#> GSM38736     1  0.9993      0.396 0.516 0.484
#> GSM38737     1  0.9993      0.396 0.516 0.484
#> GSM38738     2  0.9963     -0.246 0.464 0.536
#> GSM38739     1  0.6712      0.723 0.824 0.176
#> GSM38740     1  0.0376      0.762 0.996 0.004
#> GSM38741     1  0.9775      0.528 0.588 0.412
#> GSM38742     1  0.9996      0.388 0.512 0.488
#> GSM38743     1  0.9993      0.396 0.516 0.484
#> GSM38744     1  0.0376      0.762 0.996 0.004
#> GSM38745     1  0.0376      0.762 0.996 0.004
#> GSM38746     1  0.9286      0.613 0.656 0.344
#> GSM38747     1  0.9286      0.613 0.656 0.344
#> GSM38748     2  0.0376      0.880 0.004 0.996
#> GSM38749     1  0.6712      0.723 0.824 0.176
#> GSM38750     1  0.8499      0.669 0.724 0.276
#> GSM38751     1  0.8499      0.669 0.724 0.276
#> GSM38752     2  0.0376      0.880 0.004 0.996
#> GSM38753     2  0.1633      0.876 0.024 0.976
#> GSM38754     2  0.0376      0.880 0.004 0.996
#> GSM38755     1  0.9286      0.583 0.656 0.344
#> GSM38756     2  0.1633      0.876 0.024 0.976
#> GSM38757     1  1.0000      0.316 0.504 0.496
#> GSM38758     1  0.9996      0.388 0.512 0.488
#> GSM38759     1  0.1633      0.766 0.976 0.024
#> GSM38760     1  0.5737      0.737 0.864 0.136
#> GSM38761     1  0.9996      0.388 0.512 0.488
#> GSM38762     1  0.9993      0.396 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
#> GSM38712     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38713     1  0.2031      0.695 0.952 0.032 0.016
#> GSM38714     1  0.2031      0.695 0.952 0.032 0.016
#> GSM38715     1  0.2031      0.695 0.952 0.032 0.016
#> GSM38716     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38717     1  0.3879      0.668 0.848 0.152 0.000
#> GSM38718     1  0.1163      0.696 0.972 0.028 0.000
#> GSM38719     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38721     1  0.9042      0.481 0.544 0.280 0.176
#> GSM38722     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38724     1  0.9553      0.421 0.484 0.244 0.272
#> GSM38725     1  0.1525      0.696 0.964 0.032 0.004
#> GSM38726     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38728     1  0.9947      0.196 0.376 0.288 0.336
#> GSM38729     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.697 1.000 0.000 0.000
#> GSM38732     3  0.7613      0.496 0.116 0.204 0.680
#> GSM38733     1  0.9657      0.355 0.460 0.300 0.240
#> GSM38734     3  0.5404      0.649 0.004 0.256 0.740
#> GSM38735     1  0.7710      0.161 0.576 0.368 0.056
#> GSM38736     2  0.0237      0.996 0.004 0.996 0.000
#> GSM38737     2  0.0237      0.996 0.004 0.996 0.000
#> GSM38738     3  0.9986     -0.131 0.340 0.308 0.352
#> GSM38739     1  0.7966      0.580 0.652 0.220 0.128
#> GSM38740     1  0.7710      0.161 0.576 0.368 0.056
#> GSM38741     1  0.9736      0.306 0.416 0.228 0.356
#> GSM38742     2  0.0475      0.994 0.004 0.992 0.004
#> GSM38743     2  0.0237      0.996 0.004 0.996 0.000
#> GSM38744     1  0.7710      0.161 0.576 0.368 0.056
#> GSM38745     1  0.7710      0.161 0.576 0.368 0.056
#> GSM38746     1  0.9485      0.428 0.484 0.212 0.304
#> GSM38747     1  0.9485      0.428 0.484 0.212 0.304
#> GSM38748     3  0.4654      0.609 0.000 0.208 0.792
#> GSM38749     1  0.7966      0.580 0.652 0.220 0.128
#> GSM38750     1  0.9063      0.502 0.552 0.200 0.248
#> GSM38751     1  0.9063      0.502 0.552 0.200 0.248
#> GSM38752     3  0.5404      0.649 0.004 0.256 0.740
#> GSM38753     3  0.6168      0.436 0.000 0.412 0.588
#> GSM38754     3  0.5404      0.649 0.004 0.256 0.740
#> GSM38755     1  0.9553      0.409 0.484 0.244 0.272
#> GSM38756     3  0.6168      0.436 0.000 0.412 0.588
#> GSM38757     1  0.9970      0.117 0.356 0.296 0.348
#> GSM38758     2  0.0475      0.994 0.004 0.992 0.004
#> GSM38759     1  0.4452      0.653 0.808 0.192 0.000
#> GSM38760     1  0.7333      0.606 0.704 0.180 0.116
#> GSM38761     2  0.0475      0.994 0.004 0.992 0.004
#> GSM38762     2  0.0237      0.996 0.004 0.996 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.4967      0.524 0.548 0.000 0.452 0.000
#> GSM38713     1  0.4877      0.579 0.664 0.000 0.328 0.008
#> GSM38714     1  0.4877      0.579 0.664 0.000 0.328 0.008
#> GSM38715     1  0.4877      0.579 0.664 0.000 0.328 0.008
#> GSM38716     1  0.4967      0.524 0.548 0.000 0.452 0.000
#> GSM38717     1  0.3764      0.606 0.784 0.000 0.216 0.000
#> GSM38718     1  0.4624      0.574 0.660 0.000 0.340 0.000
#> GSM38719     1  0.4843      0.554 0.604 0.000 0.396 0.000
#> GSM38720     1  0.4843      0.554 0.604 0.000 0.396 0.000
#> GSM38721     1  0.3283      0.568 0.872 0.020 0.004 0.104
#> GSM38722     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38723     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38724     1  0.3910      0.523 0.820 0.024 0.000 0.156
#> GSM38725     1  0.4585      0.576 0.668 0.000 0.332 0.000
#> GSM38726     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38727     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38728     1  0.5742      0.396 0.664 0.060 0.000 0.276
#> GSM38729     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38730     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38731     1  0.4972      0.521 0.544 0.000 0.456 0.000
#> GSM38732     4  0.5949      0.619 0.288 0.068 0.000 0.644
#> GSM38733     1  0.4689      0.458 0.784 0.044 0.004 0.168
#> GSM38734     4  0.3156      0.765 0.048 0.068 0.000 0.884
#> GSM38735     3  0.0804      1.000 0.008 0.012 0.980 0.000
#> GSM38736     2  0.0469      0.993 0.000 0.988 0.012 0.000
#> GSM38737     2  0.0469      0.993 0.000 0.988 0.012 0.000
#> GSM38738     1  0.5929      0.149 0.640 0.064 0.000 0.296
#> GSM38739     1  0.0592      0.601 0.984 0.000 0.016 0.000
#> GSM38740     3  0.0804      1.000 0.008 0.012 0.980 0.000
#> GSM38741     1  0.4807      0.467 0.728 0.024 0.000 0.248
#> GSM38742     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0469      0.993 0.000 0.988 0.012 0.000
#> GSM38744     3  0.0804      1.000 0.008 0.012 0.980 0.000
#> GSM38745     3  0.0804      1.000 0.008 0.012 0.980 0.000
#> GSM38746     1  0.3400      0.552 0.820 0.000 0.000 0.180
#> GSM38747     1  0.3400      0.552 0.820 0.000 0.000 0.180
#> GSM38748     4  0.1042      0.722 0.000 0.020 0.008 0.972
#> GSM38749     1  0.0592      0.601 0.984 0.000 0.016 0.000
#> GSM38750     1  0.2530      0.582 0.888 0.000 0.000 0.112
#> GSM38751     1  0.2530      0.582 0.888 0.000 0.000 0.112
#> GSM38752     4  0.3156      0.765 0.048 0.068 0.000 0.884
#> GSM38753     4  0.5007      0.418 0.000 0.356 0.008 0.636
#> GSM38754     4  0.3156      0.765 0.048 0.068 0.000 0.884
#> GSM38755     1  0.3943      0.483 0.832 0.028 0.004 0.136
#> GSM38756     4  0.5007      0.418 0.000 0.356 0.008 0.636
#> GSM38757     1  0.5767      0.276 0.660 0.060 0.000 0.280
#> GSM38758     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM38759     1  0.4983      0.573 0.704 0.024 0.272 0.000
#> GSM38760     1  0.2704      0.600 0.876 0.000 0.124 0.000
#> GSM38761     2  0.0000      0.990 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0469      0.993 0.000 0.988 0.012 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
#> GSM38712     1  0.5757     0.6012 0.560 0.000 0.000 0.104 0.336
#> GSM38713     1  0.4348     0.6263 0.668 0.000 0.000 0.016 0.316
#> GSM38714     1  0.4348     0.6263 0.668 0.000 0.000 0.016 0.316
#> GSM38715     1  0.4348     0.6263 0.668 0.000 0.000 0.016 0.316
#> GSM38716     1  0.5757     0.6012 0.560 0.000 0.000 0.104 0.336
#> GSM38717     1  0.3427     0.6467 0.796 0.000 0.000 0.012 0.192
#> GSM38718     1  0.4251     0.6247 0.672 0.000 0.000 0.012 0.316
#> GSM38719     1  0.5213     0.6173 0.616 0.000 0.000 0.064 0.320
#> GSM38720     1  0.5213     0.6173 0.616 0.000 0.000 0.064 0.320
#> GSM38721     1  0.3464     0.5577 0.836 0.000 0.096 0.068 0.000
#> GSM38722     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38723     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38724     1  0.3888     0.5205 0.804 0.000 0.120 0.076 0.000
#> GSM38725     1  0.4029     0.6258 0.680 0.000 0.000 0.004 0.316
#> GSM38726     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38727     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38728     1  0.4251     0.3256 0.624 0.000 0.372 0.004 0.000
#> GSM38729     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38730     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38731     1  0.5798     0.5994 0.556 0.000 0.000 0.108 0.336
#> GSM38732     3  0.4707     0.5654 0.228 0.000 0.708 0.064 0.000
#> GSM38733     1  0.4522     0.4275 0.736 0.000 0.196 0.068 0.000
#> GSM38734     3  0.0404     0.8316 0.000 0.000 0.988 0.012 0.000
#> GSM38735     5  0.0912     1.0000 0.000 0.016 0.000 0.012 0.972
#> GSM38736     2  0.0162     0.9858 0.000 0.996 0.000 0.000 0.004
#> GSM38737     2  0.0162     0.9858 0.000 0.996 0.000 0.000 0.004
#> GSM38738     1  0.5357     0.0775 0.588 0.000 0.344 0.068 0.000
#> GSM38739     1  0.0609     0.6269 0.980 0.000 0.000 0.020 0.000
#> GSM38740     5  0.0912     1.0000 0.000 0.016 0.000 0.012 0.972
#> GSM38741     1  0.3885     0.4388 0.724 0.000 0.268 0.008 0.000
#> GSM38742     2  0.0510     0.9809 0.000 0.984 0.000 0.016 0.000
#> GSM38743     2  0.0162     0.9858 0.000 0.996 0.000 0.000 0.004
#> GSM38744     5  0.0912     1.0000 0.000 0.016 0.000 0.012 0.972
#> GSM38745     5  0.0912     1.0000 0.000 0.016 0.000 0.012 0.972
#> GSM38746     1  0.3898     0.5532 0.804 0.000 0.116 0.080 0.000
#> GSM38747     1  0.3898     0.5532 0.804 0.000 0.116 0.080 0.000
#> GSM38748     4  0.3913     0.4368 0.000 0.000 0.324 0.676 0.000
#> GSM38749     1  0.0609     0.6269 0.980 0.000 0.000 0.020 0.000
#> GSM38750     1  0.2914     0.5834 0.872 0.000 0.052 0.076 0.000
#> GSM38751     1  0.2914     0.5834 0.872 0.000 0.052 0.076 0.000
#> GSM38752     3  0.0000     0.8392 0.000 0.000 1.000 0.000 0.000
#> GSM38753     4  0.3242     0.7782 0.000 0.216 0.000 0.784 0.000
#> GSM38754     3  0.0000     0.8392 0.000 0.000 1.000 0.000 0.000
#> GSM38755     1  0.3622     0.4768 0.820 0.000 0.124 0.056 0.000
#> GSM38756     4  0.3242     0.7782 0.000 0.216 0.000 0.784 0.000
#> GSM38757     1  0.5289     0.2377 0.616 0.000 0.312 0.072 0.000
#> GSM38758     2  0.0510     0.9809 0.000 0.984 0.000 0.016 0.000
#> GSM38759     1  0.4595     0.6115 0.716 0.004 0.000 0.044 0.236
#> GSM38760     1  0.2676     0.6346 0.884 0.000 0.000 0.080 0.036
#> GSM38761     2  0.0510     0.9809 0.000 0.984 0.000 0.016 0.000
#> GSM38762     2  0.0162     0.9858 0.000 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1   p2    p3    p4    p5    p6
#> GSM38712     1  0.0146      0.902 0.996 0.00 0.004 0.000 0.000 0.000
#> GSM38713     1  0.3361      0.856 0.816 0.00 0.076 0.108 0.000 0.000
#> GSM38714     1  0.3361      0.856 0.816 0.00 0.076 0.108 0.000 0.000
#> GSM38715     1  0.3361      0.856 0.816 0.00 0.076 0.108 0.000 0.000
#> GSM38716     1  0.0291      0.902 0.992 0.00 0.004 0.004 0.000 0.000
#> GSM38717     1  0.4947      0.579 0.636 0.00 0.244 0.120 0.000 0.000
#> GSM38718     1  0.3211      0.861 0.824 0.00 0.056 0.120 0.000 0.000
#> GSM38719     1  0.2066      0.890 0.908 0.00 0.040 0.052 0.000 0.000
#> GSM38720     1  0.2066      0.890 0.908 0.00 0.040 0.052 0.000 0.000
#> GSM38721     3  0.3494      0.746 0.020 0.00 0.828 0.072 0.000 0.080
#> GSM38722     1  0.0458      0.899 0.984 0.00 0.000 0.016 0.000 0.000
#> GSM38723     1  0.0458      0.899 0.984 0.00 0.000 0.016 0.000 0.000
#> GSM38724     3  0.1285      0.759 0.000 0.00 0.944 0.004 0.000 0.052
#> GSM38725     1  0.3196      0.862 0.828 0.00 0.064 0.108 0.000 0.000
#> GSM38726     1  0.0260      0.901 0.992 0.00 0.000 0.008 0.000 0.000
#> GSM38727     1  0.0458      0.899 0.984 0.00 0.000 0.016 0.000 0.000
#> GSM38728     3  0.3634      0.541 0.000 0.00 0.644 0.000 0.000 0.356
#> GSM38729     1  0.0260      0.901 0.992 0.00 0.000 0.008 0.000 0.000
#> GSM38730     1  0.0260      0.901 0.992 0.00 0.000 0.008 0.000 0.000
#> GSM38731     1  0.0363      0.900 0.988 0.00 0.000 0.012 0.000 0.000
#> GSM38732     6  0.4513      0.526 0.012 0.00 0.228 0.060 0.000 0.700
#> GSM38733     3  0.4131      0.688 0.004 0.00 0.744 0.072 0.000 0.180
#> GSM38734     6  0.0291      0.819 0.000 0.00 0.004 0.004 0.000 0.992
#> GSM38735     5  0.0000      1.000 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM38736     2  0.0547      0.986 0.000 0.98 0.000 0.000 0.020 0.000
#> GSM38737     2  0.0547      0.986 0.000 0.98 0.000 0.000 0.020 0.000
#> GSM38738     3  0.5016      0.487 0.012 0.00 0.592 0.060 0.000 0.336
#> GSM38739     3  0.2905      0.755 0.084 0.00 0.852 0.064 0.000 0.000
#> GSM38740     5  0.0000      1.000 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM38741     3  0.3151      0.633 0.000 0.00 0.748 0.000 0.000 0.252
#> GSM38742     2  0.0000      0.981 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0547      0.986 0.000 0.98 0.000 0.000 0.020 0.000
#> GSM38744     5  0.0000      1.000 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM38745     5  0.0000      1.000 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM38746     3  0.1542      0.747 0.008 0.00 0.936 0.052 0.000 0.004
#> GSM38747     3  0.1542      0.747 0.008 0.00 0.936 0.052 0.000 0.004
#> GSM38748     4  0.3699      0.469 0.000 0.00 0.004 0.660 0.000 0.336
#> GSM38749     3  0.2905      0.755 0.084 0.00 0.852 0.064 0.000 0.000
#> GSM38750     3  0.0547      0.768 0.020 0.00 0.980 0.000 0.000 0.000
#> GSM38751     3  0.0547      0.768 0.020 0.00 0.980 0.000 0.000 0.000
#> GSM38752     6  0.0458      0.829 0.000 0.00 0.016 0.000 0.000 0.984
#> GSM38753     4  0.2793      0.798 0.000 0.20 0.000 0.800 0.000 0.000
#> GSM38754     6  0.0458      0.829 0.000 0.00 0.016 0.000 0.000 0.984
#> GSM38755     3  0.4452      0.717 0.056 0.00 0.760 0.060 0.000 0.124
#> GSM38756     4  0.2793      0.798 0.000 0.20 0.000 0.800 0.000 0.000
#> GSM38757     3  0.3518      0.637 0.012 0.00 0.732 0.000 0.000 0.256
#> GSM38758     2  0.0000      0.981 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM38759     3  0.6286      0.483 0.264 0.02 0.572 0.060 0.084 0.000
#> GSM38760     3  0.4446      0.509 0.348 0.00 0.612 0.040 0.000 0.000
#> GSM38761     2  0.0000      0.981 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0547      0.986 0.000 0.98 0.000 0.000 0.020 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n individual(p) k
#> CV:hclust 41      0.157301 2
#> CV:hclust 34      0.002249 3
#> CV:hclust 43      0.000987 4
#> CV:hclust 44      0.000811 5
#> CV:hclust 48      0.005963 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.437           0.794       0.886         0.4680 0.500   0.500
#> 3 3 0.662           0.781       0.883         0.3493 0.695   0.463
#> 4 4 0.579           0.611       0.770         0.1149 0.976   0.929
#> 5 5 0.644           0.667       0.764         0.0807 0.933   0.788
#> 6 6 0.684           0.592       0.727         0.0554 0.875   0.558

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
#> GSM38712     1   0.000      0.919 1.000 0.000
#> GSM38713     1   0.000      0.919 1.000 0.000
#> GSM38714     1   0.000      0.919 1.000 0.000
#> GSM38715     1   0.000      0.919 1.000 0.000
#> GSM38716     1   0.000      0.919 1.000 0.000
#> GSM38717     1   0.000      0.919 1.000 0.000
#> GSM38718     1   0.000      0.919 1.000 0.000
#> GSM38719     1   0.000      0.919 1.000 0.000
#> GSM38720     1   0.000      0.919 1.000 0.000
#> GSM38721     1   0.494      0.797 0.892 0.108
#> GSM38722     1   0.000      0.919 1.000 0.000
#> GSM38723     1   0.000      0.919 1.000 0.000
#> GSM38724     2   0.971      0.612 0.400 0.600
#> GSM38725     1   0.000      0.919 1.000 0.000
#> GSM38726     1   0.000      0.919 1.000 0.000
#> GSM38727     1   0.000      0.919 1.000 0.000
#> GSM38728     2   0.998      0.438 0.472 0.528
#> GSM38729     1   0.000      0.919 1.000 0.000
#> GSM38730     1   0.000      0.919 1.000 0.000
#> GSM38731     1   0.000      0.919 1.000 0.000
#> GSM38732     2   0.876      0.734 0.296 0.704
#> GSM38733     1   0.000      0.919 1.000 0.000
#> GSM38734     2   0.745      0.782 0.212 0.788
#> GSM38735     1   0.913      0.551 0.672 0.328
#> GSM38736     2   0.000      0.777 0.000 1.000
#> GSM38737     2   0.000      0.777 0.000 1.000
#> GSM38738     2   0.929      0.694 0.344 0.656
#> GSM38739     1   0.000      0.919 1.000 0.000
#> GSM38740     1   0.753      0.693 0.784 0.216
#> GSM38741     2   0.745      0.782 0.212 0.788
#> GSM38742     2   0.000      0.777 0.000 1.000
#> GSM38743     2   0.000      0.777 0.000 1.000
#> GSM38744     1   0.753      0.693 0.784 0.216
#> GSM38745     1   0.839      0.630 0.732 0.268
#> GSM38746     1   0.821      0.532 0.744 0.256
#> GSM38747     1   0.821      0.532 0.744 0.256
#> GSM38748     2   0.574      0.790 0.136 0.864
#> GSM38749     1   0.000      0.919 1.000 0.000
#> GSM38750     2   0.932      0.690 0.348 0.652
#> GSM38751     2   0.932      0.690 0.348 0.652
#> GSM38752     2   0.745      0.782 0.212 0.788
#> GSM38753     2   0.204      0.785 0.032 0.968
#> GSM38754     2   0.745      0.782 0.212 0.788
#> GSM38755     2   0.999      0.446 0.480 0.520
#> GSM38756     2   0.204      0.785 0.032 0.968
#> GSM38757     2   0.932      0.690 0.348 0.652
#> GSM38758     2   0.000      0.777 0.000 1.000
#> GSM38759     1   0.373      0.848 0.928 0.072
#> GSM38760     1   0.000      0.919 1.000 0.000
#> GSM38761     2   0.000      0.777 0.000 1.000
#> GSM38762     2   0.000      0.777 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
#> GSM38712     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38713     1  0.2625      0.901 0.916 0.000 0.084
#> GSM38714     1  0.2625      0.901 0.916 0.000 0.084
#> GSM38715     1  0.2625      0.901 0.916 0.000 0.084
#> GSM38716     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38721     3  0.6330      0.487 0.396 0.004 0.600
#> GSM38722     1  0.1170      0.961 0.976 0.016 0.008
#> GSM38723     1  0.1170      0.961 0.976 0.016 0.008
#> GSM38724     3  0.1765      0.834 0.040 0.004 0.956
#> GSM38725     1  0.0237      0.966 0.996 0.004 0.000
#> GSM38726     1  0.0592      0.964 0.988 0.012 0.000
#> GSM38727     1  0.1170      0.961 0.976 0.016 0.008
#> GSM38728     3  0.4164      0.776 0.144 0.008 0.848
#> GSM38729     1  0.0000      0.966 1.000 0.000 0.000
#> GSM38730     1  0.0237      0.966 0.996 0.004 0.000
#> GSM38731     1  0.0592      0.964 0.988 0.012 0.000
#> GSM38732     3  0.1711      0.836 0.032 0.008 0.960
#> GSM38733     3  0.6168      0.452 0.412 0.000 0.588
#> GSM38734     3  0.0892      0.816 0.000 0.020 0.980
#> GSM38735     2  0.6973      0.374 0.416 0.564 0.020
#> GSM38736     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38737     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38738     3  0.1585      0.836 0.028 0.008 0.964
#> GSM38739     1  0.2176      0.944 0.948 0.020 0.032
#> GSM38740     2  0.7004      0.348 0.428 0.552 0.020
#> GSM38741     3  0.1015      0.826 0.012 0.008 0.980
#> GSM38742     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38743     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38744     2  0.7004      0.348 0.428 0.552 0.020
#> GSM38745     2  0.6973      0.374 0.416 0.564 0.020
#> GSM38746     3  0.6205      0.584 0.336 0.008 0.656
#> GSM38747     3  0.6357      0.587 0.336 0.012 0.652
#> GSM38748     3  0.1753      0.809 0.000 0.048 0.952
#> GSM38749     1  0.2176      0.944 0.948 0.020 0.032
#> GSM38750     3  0.1399      0.837 0.028 0.004 0.968
#> GSM38751     3  0.1399      0.837 0.028 0.004 0.968
#> GSM38752     3  0.0892      0.816 0.000 0.020 0.980
#> GSM38753     2  0.6225      0.293 0.000 0.568 0.432
#> GSM38754     3  0.0892      0.816 0.000 0.020 0.980
#> GSM38755     3  0.4033      0.761 0.136 0.008 0.856
#> GSM38756     2  0.6235      0.283 0.000 0.564 0.436
#> GSM38757     3  0.1399      0.837 0.028 0.004 0.968
#> GSM38758     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38759     1  0.2772      0.903 0.916 0.004 0.080
#> GSM38760     1  0.1170      0.961 0.976 0.016 0.008
#> GSM38761     2  0.2625      0.732 0.000 0.916 0.084
#> GSM38762     2  0.2625      0.732 0.000 0.916 0.084

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.1389     0.8584 0.952 0.000 0.000 0.048
#> GSM38713     1  0.5842     0.7264 0.704 0.000 0.128 0.168
#> GSM38714     1  0.5842     0.7264 0.704 0.000 0.128 0.168
#> GSM38715     1  0.5582     0.7416 0.724 0.000 0.108 0.168
#> GSM38716     1  0.0817     0.8584 0.976 0.000 0.000 0.024
#> GSM38717     1  0.2831     0.8352 0.876 0.000 0.004 0.120
#> GSM38718     1  0.4123     0.8099 0.820 0.000 0.044 0.136
#> GSM38719     1  0.1637     0.8561 0.940 0.000 0.000 0.060
#> GSM38720     1  0.1211     0.8589 0.960 0.000 0.000 0.040
#> GSM38721     3  0.7079     0.4072 0.276 0.000 0.556 0.168
#> GSM38722     1  0.0592     0.8546 0.984 0.000 0.000 0.016
#> GSM38723     1  0.0592     0.8546 0.984 0.000 0.000 0.016
#> GSM38724     3  0.2714     0.6825 0.004 0.000 0.884 0.112
#> GSM38725     1  0.1610     0.8598 0.952 0.000 0.016 0.032
#> GSM38726     1  0.0188     0.8583 0.996 0.000 0.000 0.004
#> GSM38727     1  0.0592     0.8546 0.984 0.000 0.000 0.016
#> GSM38728     3  0.4565     0.6656 0.064 0.000 0.796 0.140
#> GSM38729     1  0.0707     0.8582 0.980 0.000 0.000 0.020
#> GSM38730     1  0.0188     0.8582 0.996 0.000 0.000 0.004
#> GSM38731     1  0.0469     0.8559 0.988 0.000 0.000 0.012
#> GSM38732     3  0.1474     0.6997 0.000 0.000 0.948 0.052
#> GSM38733     3  0.6946     0.4440 0.252 0.000 0.580 0.168
#> GSM38734     3  0.4720     0.4402 0.000 0.004 0.672 0.324
#> GSM38735     2  0.7843     0.0192 0.264 0.372 0.000 0.364
#> GSM38736     2  0.0188     0.6445 0.000 0.996 0.004 0.000
#> GSM38737     2  0.0188     0.6445 0.000 0.996 0.004 0.000
#> GSM38738     3  0.1302     0.7002 0.000 0.000 0.956 0.044
#> GSM38739     1  0.5339     0.5777 0.688 0.000 0.272 0.040
#> GSM38740     4  0.7844    -0.4085 0.264 0.368 0.000 0.368
#> GSM38741     3  0.2408     0.6570 0.000 0.000 0.896 0.104
#> GSM38742     2  0.1109     0.6295 0.000 0.968 0.004 0.028
#> GSM38743     2  0.0188     0.6445 0.000 0.996 0.004 0.000
#> GSM38744     2  0.7844     0.0142 0.264 0.368 0.000 0.368
#> GSM38745     2  0.7844     0.0142 0.264 0.368 0.000 0.368
#> GSM38746     3  0.5728     0.5614 0.188 0.000 0.708 0.104
#> GSM38747     3  0.5728     0.5614 0.188 0.000 0.708 0.104
#> GSM38748     3  0.5161     0.1472 0.000 0.004 0.520 0.476
#> GSM38749     1  0.5339     0.5777 0.688 0.000 0.272 0.040
#> GSM38750     3  0.0592     0.6984 0.000 0.000 0.984 0.016
#> GSM38751     3  0.0921     0.7001 0.000 0.000 0.972 0.028
#> GSM38752     3  0.4655     0.4452 0.000 0.004 0.684 0.312
#> GSM38753     4  0.7899     0.3826 0.000 0.340 0.296 0.364
#> GSM38754     3  0.4655     0.4452 0.000 0.004 0.684 0.312
#> GSM38755     3  0.2319     0.6880 0.036 0.000 0.924 0.040
#> GSM38756     4  0.7782     0.3674 0.000 0.276 0.296 0.428
#> GSM38757     3  0.0000     0.6999 0.000 0.000 1.000 0.000
#> GSM38758     2  0.2944     0.5000 0.000 0.868 0.004 0.128
#> GSM38759     1  0.5800     0.7309 0.708 0.000 0.128 0.164
#> GSM38760     1  0.3763     0.7607 0.832 0.000 0.144 0.024
#> GSM38761     2  0.1109     0.6295 0.000 0.968 0.004 0.028
#> GSM38762     2  0.0188     0.6445 0.000 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.2446     0.7318 0.900 0.000 0.000 0.044 0.056
#> GSM38713     1  0.7170     0.5336 0.532 0.000 0.080 0.132 0.256
#> GSM38714     1  0.7170     0.5336 0.532 0.000 0.080 0.132 0.256
#> GSM38715     1  0.7170     0.5336 0.532 0.000 0.080 0.132 0.256
#> GSM38716     1  0.1568     0.7365 0.944 0.000 0.000 0.036 0.020
#> GSM38717     1  0.4199     0.6892 0.772 0.000 0.000 0.068 0.160
#> GSM38718     1  0.5633     0.6302 0.664 0.000 0.024 0.084 0.228
#> GSM38719     1  0.3090     0.7196 0.860 0.000 0.000 0.052 0.088
#> GSM38720     1  0.2376     0.7323 0.904 0.000 0.000 0.044 0.052
#> GSM38721     3  0.7946     0.3751 0.184 0.000 0.452 0.136 0.228
#> GSM38722     1  0.0693     0.7307 0.980 0.000 0.000 0.008 0.012
#> GSM38723     1  0.0912     0.7284 0.972 0.000 0.000 0.012 0.016
#> GSM38724     3  0.3898     0.6673 0.000 0.000 0.804 0.080 0.116
#> GSM38725     1  0.1280     0.7415 0.960 0.000 0.008 0.008 0.024
#> GSM38726     1  0.0693     0.7312 0.980 0.000 0.000 0.008 0.012
#> GSM38727     1  0.0912     0.7284 0.972 0.000 0.000 0.012 0.016
#> GSM38728     3  0.5716     0.5322 0.008 0.000 0.652 0.168 0.172
#> GSM38729     1  0.0693     0.7362 0.980 0.000 0.000 0.008 0.012
#> GSM38730     1  0.0000     0.7350 1.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0566     0.7309 0.984 0.000 0.000 0.004 0.012
#> GSM38732     3  0.3608     0.6216 0.000 0.000 0.824 0.064 0.112
#> GSM38733     3  0.7518     0.4505 0.124 0.000 0.512 0.136 0.228
#> GSM38734     4  0.5276     0.5343 0.000 0.000 0.436 0.516 0.048
#> GSM38735     5  0.5854     0.9952 0.160 0.240 0.000 0.000 0.600
#> GSM38736     2  0.0451     0.9537 0.000 0.988 0.004 0.000 0.008
#> GSM38737     2  0.0451     0.9537 0.000 0.988 0.004 0.000 0.008
#> GSM38738     3  0.1753     0.6718 0.000 0.000 0.936 0.032 0.032
#> GSM38739     1  0.6577    -0.0036 0.456 0.000 0.408 0.024 0.112
#> GSM38740     5  0.5864     0.9952 0.164 0.236 0.000 0.000 0.600
#> GSM38741     3  0.3596     0.4165 0.000 0.000 0.784 0.200 0.016
#> GSM38742     2  0.0771     0.9459 0.000 0.976 0.004 0.020 0.000
#> GSM38743     2  0.0451     0.9537 0.000 0.988 0.004 0.000 0.008
#> GSM38744     5  0.5864     0.9952 0.164 0.236 0.000 0.000 0.600
#> GSM38745     5  0.5854     0.9952 0.160 0.240 0.000 0.000 0.600
#> GSM38746     3  0.5013     0.6392 0.052 0.000 0.756 0.068 0.124
#> GSM38747     3  0.5432     0.6329 0.052 0.000 0.712 0.064 0.172
#> GSM38748     4  0.2806     0.6155 0.000 0.000 0.152 0.844 0.004
#> GSM38749     1  0.6577    -0.0036 0.456 0.000 0.408 0.024 0.112
#> GSM38750     3  0.2248     0.6490 0.000 0.000 0.900 0.012 0.088
#> GSM38751     3  0.2351     0.6489 0.000 0.000 0.896 0.016 0.088
#> GSM38752     4  0.5216     0.5443 0.000 0.000 0.436 0.520 0.044
#> GSM38753     4  0.5264     0.4049 0.000 0.264 0.068 0.660 0.008
#> GSM38754     4  0.5216     0.5443 0.000 0.000 0.436 0.520 0.044
#> GSM38755     3  0.1996     0.6809 0.004 0.000 0.928 0.032 0.036
#> GSM38756     4  0.4696     0.5068 0.000 0.184 0.068 0.740 0.008
#> GSM38757     3  0.0000     0.6698 0.000 0.000 1.000 0.000 0.000
#> GSM38758     2  0.2536     0.8215 0.000 0.868 0.004 0.128 0.000
#> GSM38759     1  0.7003     0.5441 0.548 0.000 0.068 0.132 0.252
#> GSM38760     1  0.5375     0.4829 0.684 0.000 0.216 0.016 0.084
#> GSM38761     2  0.0865     0.9452 0.000 0.972 0.004 0.024 0.000
#> GSM38762     2  0.0613     0.9530 0.000 0.984 0.004 0.004 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.3212      0.728 0.800 0.000 0.000 0.004 0.016 0.180
#> GSM38713     6  0.4649      0.556 0.324 0.000 0.016 0.004 0.024 0.632
#> GSM38714     6  0.4788      0.551 0.324 0.000 0.016 0.004 0.032 0.624
#> GSM38715     6  0.4649      0.556 0.324 0.000 0.016 0.004 0.024 0.632
#> GSM38716     1  0.2489      0.764 0.860 0.000 0.000 0.000 0.012 0.128
#> GSM38717     1  0.4182      0.507 0.660 0.000 0.000 0.004 0.024 0.312
#> GSM38718     1  0.4746      0.174 0.544 0.000 0.004 0.004 0.032 0.416
#> GSM38719     1  0.3430      0.697 0.772 0.000 0.000 0.004 0.016 0.208
#> GSM38720     1  0.3178      0.730 0.804 0.000 0.000 0.004 0.016 0.176
#> GSM38721     6  0.4508      0.457 0.096 0.000 0.120 0.008 0.020 0.756
#> GSM38722     1  0.0622      0.773 0.980 0.000 0.008 0.000 0.012 0.000
#> GSM38723     1  0.1261      0.760 0.956 0.000 0.008 0.004 0.028 0.004
#> GSM38724     3  0.4533      0.373 0.000 0.000 0.504 0.004 0.024 0.468
#> GSM38725     1  0.2780      0.765 0.868 0.000 0.004 0.008 0.024 0.096
#> GSM38726     1  0.0146      0.777 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM38727     1  0.0951      0.766 0.968 0.000 0.008 0.000 0.020 0.004
#> GSM38728     6  0.5931     -0.279 0.000 0.000 0.240 0.148 0.036 0.576
#> GSM38729     1  0.1913      0.782 0.908 0.000 0.000 0.000 0.012 0.080
#> GSM38730     1  0.1411      0.786 0.936 0.000 0.000 0.000 0.004 0.060
#> GSM38731     1  0.0146      0.779 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38732     3  0.5936      0.228 0.000 0.000 0.460 0.048 0.076 0.416
#> GSM38733     6  0.4323      0.372 0.060 0.000 0.132 0.008 0.028 0.772
#> GSM38734     4  0.7158      0.273 0.000 0.000 0.272 0.360 0.080 0.288
#> GSM38735     5  0.4018      0.984 0.040 0.168 0.000 0.008 0.772 0.012
#> GSM38736     2  0.0632      0.939 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM38737     2  0.0632      0.939 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM38738     3  0.4749      0.484 0.000 0.000 0.676 0.016 0.064 0.244
#> GSM38739     3  0.5226      0.257 0.376 0.000 0.556 0.008 0.044 0.016
#> GSM38740     5  0.3481      0.984 0.048 0.160 0.000 0.000 0.792 0.000
#> GSM38741     3  0.6349      0.141 0.000 0.000 0.552 0.196 0.064 0.188
#> GSM38742     2  0.0632      0.930 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM38743     2  0.0632      0.939 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM38744     5  0.3481      0.984 0.048 0.160 0.000 0.000 0.792 0.000
#> GSM38745     5  0.4018      0.984 0.040 0.168 0.000 0.008 0.772 0.012
#> GSM38746     3  0.3419      0.520 0.012 0.000 0.792 0.000 0.016 0.180
#> GSM38747     3  0.3748      0.494 0.012 0.000 0.756 0.000 0.020 0.212
#> GSM38748     4  0.1630      0.472 0.000 0.000 0.024 0.940 0.016 0.020
#> GSM38749     3  0.5226      0.257 0.376 0.000 0.556 0.008 0.044 0.016
#> GSM38750     3  0.0458      0.541 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM38751     3  0.0603      0.541 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM38752     4  0.6967      0.354 0.000 0.000 0.304 0.400 0.068 0.228
#> GSM38753     4  0.3693      0.336 0.000 0.216 0.012 0.756 0.016 0.000
#> GSM38754     4  0.6967      0.354 0.000 0.000 0.304 0.400 0.068 0.228
#> GSM38755     3  0.5079      0.485 0.000 0.000 0.640 0.016 0.084 0.260
#> GSM38756     4  0.3352      0.389 0.000 0.172 0.012 0.800 0.016 0.000
#> GSM38757     3  0.3714      0.514 0.000 0.000 0.760 0.000 0.044 0.196
#> GSM38758     2  0.3011      0.835 0.000 0.852 0.000 0.100 0.012 0.036
#> GSM38759     6  0.4843      0.497 0.340 0.000 0.004 0.016 0.032 0.608
#> GSM38760     1  0.4648      0.305 0.636 0.000 0.312 0.004 0.044 0.004
#> GSM38761     2  0.1575      0.918 0.000 0.936 0.000 0.032 0.000 0.032
#> GSM38762     2  0.1405      0.935 0.000 0.948 0.000 0.004 0.024 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-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 individual(p) k
#> CV:kmeans 49      0.062029 2
#> CV:kmeans 43      0.002090 3
#> CV:kmeans 39      0.008902 4
#> CV:kmeans 44      0.000842 5
#> CV:kmeans 31      0.000702 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.841           0.929       0.970         0.5077 0.492   0.492
#> 3 3 0.880           0.932       0.970         0.3085 0.737   0.517
#> 4 4 0.718           0.610       0.823         0.1139 0.976   0.929
#> 5 5 0.682           0.487       0.707         0.0582 0.786   0.412
#> 6 6 0.756           0.699       0.835         0.0483 0.876   0.511

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
#> GSM38712     1   0.000      0.967 1.000 0.000
#> GSM38713     1   0.000      0.967 1.000 0.000
#> GSM38714     1   0.000      0.967 1.000 0.000
#> GSM38715     1   0.000      0.967 1.000 0.000
#> GSM38716     1   0.000      0.967 1.000 0.000
#> GSM38717     1   0.000      0.967 1.000 0.000
#> GSM38718     1   0.000      0.967 1.000 0.000
#> GSM38719     1   0.000      0.967 1.000 0.000
#> GSM38720     1   0.000      0.967 1.000 0.000
#> GSM38721     1   0.855      0.594 0.720 0.280
#> GSM38722     1   0.000      0.967 1.000 0.000
#> GSM38723     1   0.000      0.967 1.000 0.000
#> GSM38724     2   0.000      0.967 0.000 1.000
#> GSM38725     1   0.000      0.967 1.000 0.000
#> GSM38726     1   0.000      0.967 1.000 0.000
#> GSM38727     1   0.000      0.967 1.000 0.000
#> GSM38728     2   0.000      0.967 0.000 1.000
#> GSM38729     1   0.000      0.967 1.000 0.000
#> GSM38730     1   0.000      0.967 1.000 0.000
#> GSM38731     1   0.000      0.967 1.000 0.000
#> GSM38732     2   0.000      0.967 0.000 1.000
#> GSM38733     1   0.000      0.967 1.000 0.000
#> GSM38734     2   0.000      0.967 0.000 1.000
#> GSM38735     1   0.722      0.755 0.800 0.200
#> GSM38736     2   0.000      0.967 0.000 1.000
#> GSM38737     2   0.000      0.967 0.000 1.000
#> GSM38738     2   0.000      0.967 0.000 1.000
#> GSM38739     1   0.000      0.967 1.000 0.000
#> GSM38740     1   0.000      0.967 1.000 0.000
#> GSM38741     2   0.000      0.967 0.000 1.000
#> GSM38742     2   0.000      0.967 0.000 1.000
#> GSM38743     2   0.000      0.967 0.000 1.000
#> GSM38744     1   0.000      0.967 1.000 0.000
#> GSM38745     1   0.529      0.854 0.880 0.120
#> GSM38746     2   0.518      0.849 0.116 0.884
#> GSM38747     2   0.971      0.295 0.400 0.600
#> GSM38748     2   0.000      0.967 0.000 1.000
#> GSM38749     1   0.000      0.967 1.000 0.000
#> GSM38750     2   0.000      0.967 0.000 1.000
#> GSM38751     2   0.000      0.967 0.000 1.000
#> GSM38752     2   0.000      0.967 0.000 1.000
#> GSM38753     2   0.000      0.967 0.000 1.000
#> GSM38754     2   0.000      0.967 0.000 1.000
#> GSM38755     2   0.722      0.738 0.200 0.800
#> GSM38756     2   0.000      0.967 0.000 1.000
#> GSM38757     2   0.000      0.967 0.000 1.000
#> GSM38758     2   0.000      0.967 0.000 1.000
#> GSM38759     1   0.722      0.755 0.800 0.200
#> GSM38760     1   0.000      0.967 1.000 0.000
#> GSM38761     2   0.000      0.967 0.000 1.000
#> GSM38762     2   0.000      0.967 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
#> GSM38712     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38713     1  0.0892      0.969 0.980 0.000 0.020
#> GSM38714     1  0.0892      0.969 0.980 0.000 0.020
#> GSM38715     1  0.0892      0.969 0.980 0.000 0.020
#> GSM38716     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38721     3  0.4399      0.786 0.188 0.000 0.812
#> GSM38722     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38724     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38725     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38728     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38729     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38732     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38733     3  0.4178      0.803 0.172 0.000 0.828
#> GSM38734     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38735     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38736     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38738     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38739     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38740     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38741     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38742     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38744     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38745     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38746     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38747     3  0.4452      0.781 0.192 0.000 0.808
#> GSM38748     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38749     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38750     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38751     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38752     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38753     2  0.4452      0.769 0.000 0.808 0.192
#> GSM38754     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38755     3  0.3192      0.854 0.112 0.000 0.888
#> GSM38756     2  0.6026      0.446 0.000 0.624 0.376
#> GSM38757     3  0.0000      0.948 0.000 0.000 1.000
#> GSM38758     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38759     1  0.5216      0.643 0.740 0.260 0.000
#> GSM38760     1  0.0000      0.983 1.000 0.000 0.000
#> GSM38761     2  0.0000      0.952 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.952 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.2530     0.7745 0.888 0.000 0.000 0.112
#> GSM38713     1  0.5039     0.6233 0.592 0.000 0.004 0.404
#> GSM38714     1  0.5039     0.6233 0.592 0.000 0.004 0.404
#> GSM38715     1  0.5039     0.6233 0.592 0.000 0.004 0.404
#> GSM38716     1  0.1474     0.7825 0.948 0.000 0.000 0.052
#> GSM38717     1  0.3356     0.7551 0.824 0.000 0.000 0.176
#> GSM38718     1  0.4713     0.6577 0.640 0.000 0.000 0.360
#> GSM38719     1  0.3219     0.7597 0.836 0.000 0.000 0.164
#> GSM38720     1  0.2589     0.7737 0.884 0.000 0.000 0.116
#> GSM38721     3  0.7589     0.0632 0.196 0.000 0.404 0.400
#> GSM38722     1  0.0188     0.7831 0.996 0.000 0.000 0.004
#> GSM38723     1  0.0336     0.7816 0.992 0.000 0.000 0.008
#> GSM38724     3  0.0469     0.6629 0.000 0.000 0.988 0.012
#> GSM38725     1  0.0000     0.7842 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000     0.7842 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0336     0.7816 0.992 0.000 0.000 0.008
#> GSM38728     3  0.1637     0.6116 0.000 0.000 0.940 0.060
#> GSM38729     1  0.0000     0.7842 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000     0.7842 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000     0.7842 1.000 0.000 0.000 0.000
#> GSM38732     3  0.0336     0.6638 0.000 0.000 0.992 0.008
#> GSM38733     3  0.5766     0.2200 0.032 0.000 0.564 0.404
#> GSM38734     3  0.0000     0.6657 0.000 0.000 1.000 0.000
#> GSM38735     2  0.2469     0.8675 0.000 0.892 0.000 0.108
#> GSM38736     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38738     3  0.0592     0.6556 0.000 0.000 0.984 0.016
#> GSM38739     1  0.4998     0.1181 0.512 0.000 0.000 0.488
#> GSM38740     2  0.2469     0.8675 0.000 0.892 0.000 0.108
#> GSM38741     3  0.0336     0.6632 0.000 0.000 0.992 0.008
#> GSM38742     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38744     2  0.2469     0.8675 0.000 0.892 0.000 0.108
#> GSM38745     2  0.2469     0.8675 0.000 0.892 0.000 0.108
#> GSM38746     4  0.4998     0.9022 0.000 0.000 0.488 0.512
#> GSM38747     4  0.5132     0.9055 0.004 0.000 0.448 0.548
#> GSM38748     3  0.0000     0.6657 0.000 0.000 1.000 0.000
#> GSM38749     1  0.4998     0.1181 0.512 0.000 0.000 0.488
#> GSM38750     3  0.4994    -0.8886 0.000 0.000 0.520 0.480
#> GSM38751     3  0.4998    -0.9003 0.000 0.000 0.512 0.488
#> GSM38752     3  0.0188     0.6653 0.000 0.000 0.996 0.004
#> GSM38753     2  0.5277     0.5554 0.000 0.668 0.304 0.028
#> GSM38754     3  0.0188     0.6653 0.000 0.000 0.996 0.004
#> GSM38755     3  0.4375     0.3823 0.180 0.000 0.788 0.032
#> GSM38756     2  0.5409     0.1028 0.000 0.496 0.492 0.012
#> GSM38757     3  0.0817     0.6483 0.000 0.000 0.976 0.024
#> GSM38758     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38759     1  0.7535     0.4859 0.492 0.156 0.008 0.344
#> GSM38760     1  0.5158     0.1470 0.524 0.000 0.004 0.472
#> GSM38761     2  0.0000     0.8923 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0000     0.8923 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.4101      0.361 0.664 0.000 0.332 0.000 0.004
#> GSM38713     1  0.1410      0.555 0.940 0.060 0.000 0.000 0.000
#> GSM38714     1  0.1410      0.555 0.940 0.060 0.000 0.000 0.000
#> GSM38715     1  0.1410      0.555 0.940 0.060 0.000 0.000 0.000
#> GSM38716     1  0.4649      0.153 0.580 0.000 0.404 0.000 0.016
#> GSM38717     1  0.3534      0.458 0.744 0.000 0.256 0.000 0.000
#> GSM38718     1  0.1608      0.542 0.928 0.000 0.072 0.000 0.000
#> GSM38719     1  0.3661      0.443 0.724 0.000 0.276 0.000 0.000
#> GSM38720     1  0.4084      0.368 0.668 0.000 0.328 0.000 0.004
#> GSM38721     1  0.5342      0.186 0.612 0.076 0.000 0.312 0.000
#> GSM38722     3  0.4882      0.143 0.444 0.000 0.532 0.000 0.024
#> GSM38723     3  0.4867      0.148 0.432 0.000 0.544 0.000 0.024
#> GSM38724     4  0.3333      0.864 0.008 0.164 0.008 0.820 0.000
#> GSM38725     3  0.4807      0.139 0.448 0.000 0.532 0.000 0.020
#> GSM38726     3  0.4807      0.139 0.448 0.000 0.532 0.000 0.020
#> GSM38727     3  0.4948      0.147 0.436 0.000 0.536 0.000 0.028
#> GSM38728     4  0.3051      0.824 0.076 0.060 0.000 0.864 0.000
#> GSM38729     3  0.4894      0.113 0.456 0.000 0.520 0.000 0.024
#> GSM38730     3  0.4807      0.139 0.448 0.000 0.532 0.000 0.020
#> GSM38731     3  0.4882      0.143 0.444 0.000 0.532 0.000 0.024
#> GSM38732     4  0.1168      0.904 0.032 0.008 0.000 0.960 0.000
#> GSM38733     1  0.5513     -0.098 0.524 0.068 0.000 0.408 0.000
#> GSM38734     4  0.0671      0.910 0.004 0.016 0.000 0.980 0.000
#> GSM38735     5  0.0510      0.810 0.000 0.016 0.000 0.000 0.984
#> GSM38736     2  0.3752      0.820 0.000 0.708 0.000 0.000 0.292
#> GSM38737     2  0.3752      0.820 0.000 0.708 0.000 0.000 0.292
#> GSM38738     4  0.0693      0.909 0.012 0.008 0.000 0.980 0.000
#> GSM38739     3  0.1121      0.281 0.000 0.044 0.956 0.000 0.000
#> GSM38740     5  0.0000      0.831 0.000 0.000 0.000 0.000 1.000
#> GSM38741     4  0.1892      0.903 0.000 0.080 0.004 0.916 0.000
#> GSM38742     2  0.3684      0.819 0.000 0.720 0.000 0.000 0.280
#> GSM38743     2  0.3752      0.820 0.000 0.708 0.000 0.000 0.292
#> GSM38744     5  0.0000      0.831 0.000 0.000 0.000 0.000 1.000
#> GSM38745     5  0.0000      0.831 0.000 0.000 0.000 0.000 1.000
#> GSM38746     3  0.6896     -0.200 0.040 0.124 0.472 0.364 0.000
#> GSM38747     3  0.7164     -0.193 0.064 0.120 0.468 0.348 0.000
#> GSM38748     4  0.2020      0.898 0.000 0.100 0.000 0.900 0.000
#> GSM38749     3  0.1197      0.281 0.000 0.048 0.952 0.000 0.000
#> GSM38750     3  0.6100     -0.274 0.000 0.124 0.448 0.428 0.000
#> GSM38751     3  0.6089     -0.244 0.000 0.124 0.468 0.408 0.000
#> GSM38752     4  0.1341      0.912 0.000 0.056 0.000 0.944 0.000
#> GSM38753     2  0.6448      0.309 0.000 0.500 0.000 0.228 0.272
#> GSM38754     4  0.1341      0.912 0.000 0.056 0.000 0.944 0.000
#> GSM38755     4  0.4142      0.773 0.024 0.036 0.128 0.808 0.004
#> GSM38756     2  0.6191      0.322 0.000 0.528 0.000 0.308 0.164
#> GSM38757     4  0.2193      0.874 0.000 0.092 0.008 0.900 0.000
#> GSM38758     2  0.3942      0.805 0.000 0.728 0.000 0.012 0.260
#> GSM38759     5  0.6591      0.390 0.316 0.160 0.004 0.008 0.512
#> GSM38760     3  0.2120      0.268 0.048 0.004 0.924 0.004 0.020
#> GSM38761     2  0.3684      0.819 0.000 0.720 0.000 0.000 0.280
#> GSM38762     2  0.3752      0.820 0.000 0.708 0.000 0.000 0.292

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.2491     0.7573 0.836 0.000 0.000 0.000 0.000 0.164
#> GSM38713     6  0.2730     0.6689 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38714     6  0.2730     0.6689 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38715     6  0.2730     0.6689 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM38716     1  0.1863     0.8024 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM38717     1  0.3714     0.4643 0.656 0.000 0.004 0.000 0.000 0.340
#> GSM38718     6  0.3907     0.2703 0.408 0.000 0.004 0.000 0.000 0.588
#> GSM38719     1  0.3337     0.6249 0.736 0.000 0.004 0.000 0.000 0.260
#> GSM38720     1  0.2772     0.7378 0.816 0.000 0.004 0.000 0.000 0.180
#> GSM38721     6  0.4083     0.5009 0.044 0.000 0.012 0.168 0.008 0.768
#> GSM38722     1  0.0291     0.8463 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM38723     1  0.0862     0.8357 0.972 0.000 0.016 0.000 0.008 0.004
#> GSM38724     4  0.4737     0.6022 0.000 0.000 0.248 0.672 0.012 0.068
#> GSM38725     1  0.0436     0.8460 0.988 0.000 0.004 0.000 0.004 0.004
#> GSM38726     1  0.0000     0.8479 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0964     0.8331 0.968 0.000 0.016 0.000 0.012 0.004
#> GSM38728     4  0.4601     0.5601 0.000 0.000 0.044 0.640 0.008 0.308
#> GSM38729     1  0.0508     0.8461 0.984 0.000 0.004 0.000 0.000 0.012
#> GSM38730     1  0.0146     0.8480 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38731     1  0.0000     0.8479 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     4  0.3277     0.7466 0.000 0.000 0.020 0.828 0.024 0.128
#> GSM38733     6  0.4236     0.3897 0.012 0.000 0.020 0.208 0.020 0.740
#> GSM38734     4  0.2658     0.7529 0.000 0.000 0.008 0.864 0.016 0.112
#> GSM38735     5  0.1285     0.9935 0.004 0.052 0.000 0.000 0.944 0.000
#> GSM38736     2  0.0547     0.8899 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38737     2  0.0547     0.8899 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38738     4  0.3185     0.7503 0.000 0.000 0.024 0.840 0.024 0.112
#> GSM38739     3  0.3767     0.6394 0.276 0.000 0.708 0.000 0.012 0.004
#> GSM38740     5  0.1333     0.9978 0.008 0.048 0.000 0.000 0.944 0.000
#> GSM38741     4  0.2815     0.7141 0.000 0.000 0.096 0.864 0.012 0.028
#> GSM38742     2  0.0000     0.8875 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0547     0.8899 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM38744     5  0.1333     0.9978 0.008 0.048 0.000 0.000 0.944 0.000
#> GSM38745     5  0.1333     0.9978 0.008 0.048 0.000 0.000 0.944 0.000
#> GSM38746     3  0.1757     0.7943 0.000 0.000 0.916 0.076 0.000 0.008
#> GSM38747     3  0.2509     0.7763 0.000 0.000 0.876 0.088 0.000 0.036
#> GSM38748     4  0.2655     0.7156 0.000 0.000 0.036 0.884 0.020 0.060
#> GSM38749     3  0.3767     0.6394 0.276 0.000 0.708 0.000 0.012 0.004
#> GSM38750     3  0.2135     0.7630 0.000 0.000 0.872 0.128 0.000 0.000
#> GSM38751     3  0.1714     0.7910 0.000 0.000 0.908 0.092 0.000 0.000
#> GSM38752     4  0.1226     0.7515 0.000 0.004 0.040 0.952 0.004 0.000
#> GSM38753     2  0.7518    -0.0331 0.000 0.380 0.056 0.364 0.132 0.068
#> GSM38754     4  0.1226     0.7515 0.000 0.004 0.040 0.952 0.004 0.000
#> GSM38755     4  0.6262     0.6526 0.056 0.000 0.116 0.640 0.052 0.136
#> GSM38756     4  0.6701    -0.0329 0.000 0.392 0.056 0.444 0.040 0.068
#> GSM38757     4  0.5129     0.6540 0.000 0.000 0.216 0.656 0.016 0.112
#> GSM38758     2  0.0405     0.8800 0.000 0.988 0.000 0.008 0.004 0.000
#> GSM38759     6  0.8609    -0.1095 0.060 0.100 0.052 0.124 0.312 0.352
#> GSM38760     1  0.4318     0.2577 0.632 0.000 0.340 0.000 0.020 0.008
#> GSM38761     2  0.0000     0.8875 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0547     0.8899 0.000 0.980 0.000 0.000 0.020 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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 individual(p) k
#> CV:skmeans 50      0.043771 2
#> CV:skmeans 50      0.003367 3
#> CV:skmeans 41      0.003736 4
#> CV:skmeans 26      0.037852 5
#> CV:skmeans 44      0.000724 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.731           0.800       0.924         0.3606 0.633   0.633
#> 3 3 0.888           0.928       0.965         0.7926 0.645   0.473
#> 4 4 0.860           0.920       0.938         0.0707 0.955   0.874
#> 5 5 0.705           0.767       0.876         0.0617 0.835   0.569
#> 6 6 0.864           0.874       0.931         0.1038 0.801   0.409

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
#> GSM38712     1  0.0000     0.9356 1.000 0.000
#> GSM38713     1  0.0000     0.9356 1.000 0.000
#> GSM38714     1  0.0672     0.9336 0.992 0.008
#> GSM38715     1  0.0000     0.9356 1.000 0.000
#> GSM38716     1  0.0000     0.9356 1.000 0.000
#> GSM38717     1  0.0000     0.9356 1.000 0.000
#> GSM38718     1  0.0000     0.9356 1.000 0.000
#> GSM38719     1  0.0000     0.9356 1.000 0.000
#> GSM38720     1  0.0000     0.9356 1.000 0.000
#> GSM38721     1  0.0672     0.9336 0.992 0.008
#> GSM38722     1  0.0000     0.9356 1.000 0.000
#> GSM38723     1  0.0000     0.9356 1.000 0.000
#> GSM38724     1  0.0672     0.9336 0.992 0.008
#> GSM38725     1  0.0000     0.9356 1.000 0.000
#> GSM38726     1  0.0000     0.9356 1.000 0.000
#> GSM38727     1  0.0000     0.9356 1.000 0.000
#> GSM38728     1  0.0672     0.9336 0.992 0.008
#> GSM38729     1  0.0000     0.9356 1.000 0.000
#> GSM38730     1  0.0000     0.9356 1.000 0.000
#> GSM38731     1  0.0000     0.9356 1.000 0.000
#> GSM38732     1  0.0672     0.9336 0.992 0.008
#> GSM38733     1  0.0000     0.9356 1.000 0.000
#> GSM38734     1  0.9881     0.0657 0.564 0.436
#> GSM38735     2  0.9732     0.3624 0.404 0.596
#> GSM38736     2  0.0000     0.7951 0.000 1.000
#> GSM38737     2  0.0000     0.7951 0.000 1.000
#> GSM38738     1  0.1184     0.9293 0.984 0.016
#> GSM38739     1  0.0000     0.9356 1.000 0.000
#> GSM38740     1  0.7219     0.6688 0.800 0.200
#> GSM38741     1  0.1633     0.9237 0.976 0.024
#> GSM38742     2  0.0000     0.7951 0.000 1.000
#> GSM38743     2  0.0000     0.7951 0.000 1.000
#> GSM38744     1  0.7219     0.6688 0.800 0.200
#> GSM38745     2  0.9850     0.3077 0.428 0.572
#> GSM38746     1  0.1633     0.9237 0.976 0.024
#> GSM38747     1  0.1633     0.9237 0.976 0.024
#> GSM38748     2  0.9522     0.4566 0.372 0.628
#> GSM38749     1  0.0000     0.9356 1.000 0.000
#> GSM38750     1  0.0672     0.9336 0.992 0.008
#> GSM38751     1  0.1633     0.9237 0.976 0.024
#> GSM38752     1  0.9909     0.0368 0.556 0.444
#> GSM38753     2  0.9522     0.4566 0.372 0.628
#> GSM38754     1  0.9909     0.0368 0.556 0.444
#> GSM38755     1  0.0672     0.9336 0.992 0.008
#> GSM38756     2  0.9522     0.4566 0.372 0.628
#> GSM38757     1  0.0672     0.9336 0.992 0.008
#> GSM38758     2  0.0000     0.7951 0.000 1.000
#> GSM38759     1  0.1633     0.9237 0.976 0.024
#> GSM38760     1  0.0000     0.9356 1.000 0.000
#> GSM38761     2  0.0000     0.7951 0.000 1.000
#> GSM38762     2  0.0000     0.7951 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
#> GSM38712     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38713     1  0.4750      0.756 0.784 0.000 0.216
#> GSM38714     3  0.1643      0.938 0.044 0.000 0.956
#> GSM38715     1  0.4555      0.773 0.800 0.000 0.200
#> GSM38716     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38718     1  0.0237      0.941 0.996 0.000 0.004
#> GSM38719     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38721     3  0.1643      0.938 0.044 0.000 0.956
#> GSM38722     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38724     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38725     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38728     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38729     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.943 1.000 0.000 0.000
#> GSM38732     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38733     1  0.4887      0.748 0.772 0.000 0.228
#> GSM38734     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38735     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38736     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38738     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38739     1  0.0747      0.934 0.984 0.000 0.016
#> GSM38740     1  0.4605      0.755 0.796 0.204 0.000
#> GSM38741     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38742     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38744     1  0.4555      0.760 0.800 0.200 0.000
#> GSM38745     2  0.1643      0.951 0.044 0.956 0.000
#> GSM38746     3  0.1163      0.948 0.028 0.000 0.972
#> GSM38747     3  0.1163      0.948 0.028 0.000 0.972
#> GSM38748     3  0.1163      0.944 0.000 0.028 0.972
#> GSM38749     1  0.0747      0.934 0.984 0.000 0.016
#> GSM38750     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38751     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38752     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38753     3  0.4887      0.711 0.000 0.228 0.772
#> GSM38754     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38755     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38756     3  0.4555      0.744 0.000 0.200 0.800
#> GSM38757     3  0.0000      0.962 0.000 0.000 1.000
#> GSM38758     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38759     3  0.1643      0.938 0.044 0.000 0.956
#> GSM38760     1  0.0592      0.936 0.988 0.000 0.012
#> GSM38761     2  0.0000      0.994 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.994 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38713     1  0.3764      0.744 0.784 0.000 0.216 0.000
#> GSM38714     3  0.0921      0.894 0.028 0.000 0.972 0.000
#> GSM38715     1  0.3610      0.763 0.800 0.000 0.200 0.000
#> GSM38716     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0188      0.958 0.996 0.000 0.004 0.000
#> GSM38719     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38721     3  0.0921      0.894 0.028 0.000 0.972 0.000
#> GSM38722     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38724     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38725     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38728     3  0.3528      0.845 0.000 0.000 0.808 0.192
#> GSM38729     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38733     1  0.3873      0.736 0.772 0.000 0.228 0.000
#> GSM38734     3  0.3610      0.840 0.000 0.000 0.800 0.200
#> GSM38735     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38738     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38739     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38740     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> GSM38741     3  0.3486      0.847 0.000 0.000 0.812 0.188
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38744     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> GSM38745     4  0.3610      1.000 0.000 0.200 0.000 0.800
#> GSM38746     3  0.0921      0.894 0.028 0.000 0.972 0.000
#> GSM38747     3  0.0921      0.894 0.028 0.000 0.972 0.000
#> GSM38748     3  0.3610      0.840 0.000 0.000 0.800 0.200
#> GSM38749     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38750     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38751     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38752     3  0.3610      0.840 0.000 0.000 0.800 0.200
#> GSM38753     3  0.3764      0.738 0.000 0.216 0.784 0.000
#> GSM38754     3  0.3610      0.840 0.000 0.000 0.800 0.200
#> GSM38755     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38756     3  0.3610      0.755 0.000 0.200 0.800 0.000
#> GSM38757     3  0.0000      0.903 0.000 0.000 1.000 0.000
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38759     3  0.0921      0.894 0.028 0.000 0.972 0.000
#> GSM38760     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4 p5
#> GSM38712     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38713     1  0.4491      0.652 0.652 0.000 0.020 0.328  0
#> GSM38714     1  0.5353      0.588 0.600 0.000 0.072 0.328  0
#> GSM38715     1  0.4491      0.652 0.652 0.000 0.020 0.328  0
#> GSM38716     1  0.2605      0.788 0.852 0.000 0.000 0.148  0
#> GSM38717     1  0.2605      0.788 0.852 0.000 0.000 0.148  0
#> GSM38718     1  0.2516      0.792 0.860 0.000 0.000 0.140  0
#> GSM38719     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38720     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38721     1  0.5353      0.588 0.600 0.000 0.072 0.328  0
#> GSM38722     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38723     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38724     3  0.3932      0.685 0.000 0.000 0.672 0.328  0
#> GSM38725     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38726     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38727     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38728     3  0.3690      0.466 0.224 0.000 0.764 0.012  0
#> GSM38729     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38730     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38731     1  0.0000      0.840 1.000 0.000 0.000 0.000  0
#> GSM38732     3  0.2929      0.740 0.000 0.000 0.820 0.180  0
#> GSM38733     1  0.5513      0.590 0.652 0.000 0.168 0.180  0
#> GSM38734     3  0.0609      0.648 0.000 0.000 0.980 0.020  0
#> GSM38735     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38738     3  0.2929      0.740 0.000 0.000 0.820 0.180  0
#> GSM38739     3  0.4182      0.432 0.400 0.000 0.600 0.000  0
#> GSM38740     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM38741     3  0.2690      0.639 0.000 0.000 0.844 0.156  0
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38744     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM38745     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM38746     3  0.3932      0.685 0.000 0.000 0.672 0.328  0
#> GSM38747     3  0.6638      0.424 0.236 0.000 0.436 0.328  0
#> GSM38748     4  0.3932      0.519 0.000 0.000 0.328 0.672  0
#> GSM38749     3  0.4242      0.407 0.428 0.000 0.572 0.000  0
#> GSM38750     3  0.2929      0.740 0.000 0.000 0.820 0.180  0
#> GSM38751     3  0.3932      0.685 0.000 0.000 0.672 0.328  0
#> GSM38752     3  0.0609      0.648 0.000 0.000 0.980 0.020  0
#> GSM38753     4  0.3274      0.736 0.000 0.220 0.000 0.780  0
#> GSM38754     3  0.0609      0.648 0.000 0.000 0.980 0.020  0
#> GSM38755     3  0.2929      0.740 0.000 0.000 0.820 0.180  0
#> GSM38756     4  0.3395      0.731 0.000 0.236 0.000 0.764  0
#> GSM38757     3  0.2929      0.740 0.000 0.000 0.820 0.180  0
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38759     1  0.5353      0.588 0.600 0.000 0.072 0.328  0
#> GSM38760     1  0.1121      0.808 0.956 0.000 0.044 0.000  0
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1  p2    p3    p4 p5    p6
#> GSM38712     1  0.0146      0.937 0.996 0.0 0.000 0.000  0 0.004
#> GSM38713     6  0.0146      0.871 0.004 0.0 0.000 0.000  0 0.996
#> GSM38714     6  0.0000      0.871 0.000 0.0 0.000 0.000  0 1.000
#> GSM38715     6  0.0146      0.871 0.004 0.0 0.000 0.000  0 0.996
#> GSM38716     6  0.2854      0.713 0.208 0.0 0.000 0.000  0 0.792
#> GSM38717     6  0.0632      0.865 0.024 0.0 0.000 0.000  0 0.976
#> GSM38718     1  0.3797      0.313 0.580 0.0 0.000 0.000  0 0.420
#> GSM38719     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38720     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38721     6  0.0000      0.871 0.000 0.0 0.000 0.000  0 1.000
#> GSM38722     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38723     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38724     6  0.0146      0.871 0.000 0.0 0.004 0.000  0 0.996
#> GSM38725     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38726     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38727     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38728     3  0.0146      0.837 0.000 0.0 0.996 0.000  0 0.004
#> GSM38729     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38730     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38731     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38732     3  0.3522      0.816 0.000 0.0 0.800 0.072  0 0.128
#> GSM38733     3  0.2823      0.754 0.000 0.0 0.796 0.000  0 0.204
#> GSM38734     3  0.0000      0.839 0.000 0.0 1.000 0.000  0 0.000
#> GSM38735     5  0.0000      1.000 0.000 0.0 0.000 0.000  1 0.000
#> GSM38736     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38738     3  0.2793      0.847 0.000 0.0 0.800 0.200  0 0.000
#> GSM38739     1  0.2668      0.780 0.828 0.0 0.004 0.168  0 0.000
#> GSM38740     5  0.0000      1.000 0.000 0.0 0.000 0.000  1 0.000
#> GSM38741     6  0.2823      0.738 0.000 0.0 0.204 0.000  0 0.796
#> GSM38742     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38744     5  0.0000      1.000 0.000 0.0 0.000 0.000  1 0.000
#> GSM38745     5  0.0000      1.000 0.000 0.0 0.000 0.000  1 0.000
#> GSM38746     6  0.2933      0.770 0.000 0.0 0.004 0.200  0 0.796
#> GSM38747     6  0.5308      0.585 0.180 0.0 0.004 0.200  0 0.616
#> GSM38748     4  0.2793      0.696 0.000 0.0 0.200 0.800  0 0.000
#> GSM38749     1  0.2320      0.820 0.864 0.0 0.004 0.132  0 0.000
#> GSM38750     3  0.2933      0.846 0.000 0.0 0.796 0.200  0 0.004
#> GSM38751     6  0.3043      0.767 0.000 0.0 0.008 0.200  0 0.792
#> GSM38752     3  0.0000      0.839 0.000 0.0 1.000 0.000  0 0.000
#> GSM38753     4  0.2793      0.847 0.000 0.2 0.000 0.800  0 0.000
#> GSM38754     3  0.0000      0.839 0.000 0.0 1.000 0.000  0 0.000
#> GSM38755     3  0.2933      0.846 0.000 0.0 0.796 0.200  0 0.004
#> GSM38756     4  0.2793      0.847 0.000 0.2 0.000 0.800  0 0.000
#> GSM38757     3  0.2793      0.847 0.000 0.0 0.800 0.200  0 0.000
#> GSM38758     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38759     6  0.0000      0.871 0.000 0.0 0.000 0.000  0 1.000
#> GSM38760     1  0.0000      0.940 1.000 0.0 0.000 0.000  0 0.000
#> GSM38761     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.0 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 individual(p) k
#> CV:pam 43       0.01685 2
#> CV:pam 51       0.00390 3
#> CV:pam 51       0.00110 4
#> CV:pam 47       0.00316 5
#> CV:pam 50       0.00323 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 19411 rows and 51 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 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-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 1.000           0.983       0.993         0.3945 0.613   0.613
#> 3 3 0.624           0.815       0.893         0.6261 0.708   0.531
#> 4 4 0.801           0.859       0.901         0.0926 0.962   0.890
#> 5 5 0.675           0.795       0.862         0.0458 0.952   0.850
#> 6 6 0.748           0.738       0.839         0.0796 0.909   0.688

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
#> GSM38712     1   0.000      0.991 1.00 0.00
#> GSM38713     1   0.000      0.991 1.00 0.00
#> GSM38714     1   0.000      0.991 1.00 0.00
#> GSM38715     1   0.000      0.991 1.00 0.00
#> GSM38716     1   0.000      0.991 1.00 0.00
#> GSM38717     1   0.000      0.991 1.00 0.00
#> GSM38718     1   0.000      0.991 1.00 0.00
#> GSM38719     1   0.000      0.991 1.00 0.00
#> GSM38720     1   0.000      0.991 1.00 0.00
#> GSM38721     1   0.000      0.991 1.00 0.00
#> GSM38722     1   0.000      0.991 1.00 0.00
#> GSM38723     1   0.000      0.991 1.00 0.00
#> GSM38724     1   0.000      0.991 1.00 0.00
#> GSM38725     1   0.000      0.991 1.00 0.00
#> GSM38726     1   0.000      0.991 1.00 0.00
#> GSM38727     1   0.000      0.991 1.00 0.00
#> GSM38728     1   0.000      0.991 1.00 0.00
#> GSM38729     1   0.000      0.991 1.00 0.00
#> GSM38730     1   0.000      0.991 1.00 0.00
#> GSM38731     1   0.000      0.991 1.00 0.00
#> GSM38732     1   0.000      0.991 1.00 0.00
#> GSM38733     1   0.000      0.991 1.00 0.00
#> GSM38734     1   0.000      0.991 1.00 0.00
#> GSM38735     2   0.000      1.000 0.00 1.00
#> GSM38736     2   0.000      1.000 0.00 1.00
#> GSM38737     2   0.000      1.000 0.00 1.00
#> GSM38738     1   0.000      0.991 1.00 0.00
#> GSM38739     1   0.000      0.991 1.00 0.00
#> GSM38740     2   0.000      1.000 0.00 1.00
#> GSM38741     1   0.000      0.991 1.00 0.00
#> GSM38742     2   0.000      1.000 0.00 1.00
#> GSM38743     2   0.000      1.000 0.00 1.00
#> GSM38744     2   0.000      1.000 0.00 1.00
#> GSM38745     2   0.000      1.000 0.00 1.00
#> GSM38746     1   0.000      0.991 1.00 0.00
#> GSM38747     1   0.000      0.991 1.00 0.00
#> GSM38748     1   0.925      0.485 0.66 0.34
#> GSM38749     1   0.000      0.991 1.00 0.00
#> GSM38750     1   0.000      0.991 1.00 0.00
#> GSM38751     1   0.000      0.991 1.00 0.00
#> GSM38752     1   0.000      0.991 1.00 0.00
#> GSM38753     2   0.000      1.000 0.00 1.00
#> GSM38754     1   0.000      0.991 1.00 0.00
#> GSM38755     1   0.000      0.991 1.00 0.00
#> GSM38756     2   0.000      1.000 0.00 1.00
#> GSM38757     1   0.000      0.991 1.00 0.00
#> GSM38758     2   0.000      1.000 0.00 1.00
#> GSM38759     1   0.000      0.991 1.00 0.00
#> GSM38760     1   0.000      0.991 1.00 0.00
#> GSM38761     2   0.000      1.000 0.00 1.00
#> GSM38762     2   0.000      1.000 0.00 1.00

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38713     1  0.0237      0.837 0.996 0.000 0.004
#> GSM38714     1  0.2959      0.803 0.900 0.000 0.100
#> GSM38715     1  0.0237      0.837 0.996 0.000 0.004
#> GSM38716     1  0.4121      0.769 0.832 0.000 0.168
#> GSM38717     1  0.0237      0.838 0.996 0.000 0.004
#> GSM38718     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38721     1  0.4750      0.644 0.784 0.000 0.216
#> GSM38722     1  0.4062      0.772 0.836 0.000 0.164
#> GSM38723     1  0.4062      0.772 0.836 0.000 0.164
#> GSM38724     1  0.6260      0.256 0.552 0.000 0.448
#> GSM38725     1  0.2261      0.825 0.932 0.000 0.068
#> GSM38726     1  0.1289      0.833 0.968 0.000 0.032
#> GSM38727     1  0.4062      0.772 0.836 0.000 0.164
#> GSM38728     3  0.6026      0.615 0.376 0.000 0.624
#> GSM38729     1  0.1860      0.832 0.948 0.000 0.052
#> GSM38730     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.837 1.000 0.000 0.000
#> GSM38732     3  0.4654      0.857 0.208 0.000 0.792
#> GSM38733     1  0.4750      0.644 0.784 0.000 0.216
#> GSM38734     3  0.1163      0.785 0.028 0.000 0.972
#> GSM38735     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38736     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38738     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38739     3  0.4605      0.860 0.204 0.000 0.796
#> GSM38740     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38741     3  0.0592      0.791 0.012 0.000 0.988
#> GSM38742     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38744     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38745     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38746     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38747     3  0.4605      0.860 0.204 0.000 0.796
#> GSM38748     2  0.6540      0.424 0.008 0.584 0.408
#> GSM38749     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38750     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38751     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38752     3  0.1289      0.788 0.032 0.000 0.968
#> GSM38753     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38754     3  0.1163      0.785 0.028 0.000 0.972
#> GSM38755     1  0.6260      0.256 0.552 0.000 0.448
#> GSM38756     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38757     3  0.4235      0.880 0.176 0.000 0.824
#> GSM38758     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38759     1  0.6168      0.499 0.588 0.000 0.412
#> GSM38760     1  0.4931      0.705 0.768 0.000 0.232
#> GSM38761     2  0.0000      0.970 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.970 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0336      0.914 0.992 0.008 0.000 0.000
#> GSM38713     1  0.0376      0.913 0.992 0.004 0.004 0.000
#> GSM38714     1  0.0712      0.910 0.984 0.004 0.004 0.008
#> GSM38715     1  0.0376      0.913 0.992 0.004 0.004 0.000
#> GSM38716     1  0.3774      0.870 0.844 0.128 0.020 0.008
#> GSM38717     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0188      0.914 0.996 0.000 0.004 0.000
#> GSM38720     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM38721     1  0.0188      0.914 0.996 0.000 0.004 0.000
#> GSM38722     1  0.4194      0.846 0.800 0.172 0.028 0.000
#> GSM38723     1  0.4514      0.846 0.800 0.136 0.064 0.000
#> GSM38724     1  0.4606      0.704 0.724 0.012 0.264 0.000
#> GSM38725     1  0.1256      0.911 0.964 0.028 0.008 0.000
#> GSM38726     1  0.0469      0.913 0.988 0.012 0.000 0.000
#> GSM38727     1  0.4194      0.846 0.800 0.172 0.028 0.000
#> GSM38728     3  0.3726      0.752 0.212 0.000 0.788 0.000
#> GSM38729     1  0.2530      0.883 0.888 0.112 0.000 0.000
#> GSM38730     1  0.0469      0.913 0.988 0.012 0.000 0.000
#> GSM38731     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM38732     3  0.2197      0.923 0.080 0.004 0.916 0.000
#> GSM38733     1  0.0188      0.914 0.996 0.000 0.004 0.000
#> GSM38734     3  0.1624      0.935 0.020 0.028 0.952 0.000
#> GSM38735     4  0.1302      0.805 0.000 0.044 0.000 0.956
#> GSM38736     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38737     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38738     3  0.1284      0.949 0.024 0.012 0.964 0.000
#> GSM38739     3  0.0817      0.950 0.024 0.000 0.976 0.000
#> GSM38740     4  0.1302      0.805 0.000 0.044 0.000 0.956
#> GSM38741     3  0.0937      0.946 0.012 0.012 0.976 0.000
#> GSM38742     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38743     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38744     4  0.1302      0.805 0.000 0.044 0.000 0.956
#> GSM38745     4  0.1302      0.805 0.000 0.044 0.000 0.956
#> GSM38746     3  0.1389      0.936 0.048 0.000 0.952 0.000
#> GSM38747     3  0.1474      0.936 0.052 0.000 0.948 0.000
#> GSM38748     4  0.5910      0.372 0.008 0.040 0.316 0.636
#> GSM38749     3  0.0817      0.950 0.024 0.000 0.976 0.000
#> GSM38750     3  0.0817      0.950 0.024 0.000 0.976 0.000
#> GSM38751     3  0.0779      0.948 0.016 0.004 0.980 0.000
#> GSM38752     3  0.1624      0.935 0.020 0.028 0.952 0.000
#> GSM38753     4  0.0000      0.793 0.000 0.000 0.000 1.000
#> GSM38754     3  0.1624      0.935 0.020 0.028 0.952 0.000
#> GSM38755     1  0.5414      0.471 0.604 0.020 0.376 0.000
#> GSM38756     4  0.0000      0.793 0.000 0.000 0.000 1.000
#> GSM38757     3  0.1284      0.949 0.024 0.012 0.964 0.000
#> GSM38758     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38759     1  0.4424      0.852 0.808 0.148 0.036 0.008
#> GSM38760     1  0.4121      0.798 0.796 0.020 0.184 0.000
#> GSM38761     2  0.3688      1.000 0.000 0.792 0.000 0.208
#> GSM38762     4  0.4981     -0.262 0.000 0.464 0.000 0.536

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.2127      0.853 0.892 0.108 0.000 0.000 0.000
#> GSM38713     1  0.0162      0.861 0.996 0.000 0.004 0.000 0.000
#> GSM38714     1  0.0162      0.861 0.996 0.000 0.004 0.000 0.000
#> GSM38715     1  0.0162      0.861 0.996 0.000 0.004 0.000 0.000
#> GSM38716     1  0.2020      0.852 0.900 0.100 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.861 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.861 1.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.861 1.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.861 1.000 0.000 0.000 0.000 0.000
#> GSM38721     1  0.3840      0.686 0.780 0.016 0.196 0.008 0.000
#> GSM38722     1  0.4832      0.781 0.712 0.200 0.000 0.088 0.000
#> GSM38723     1  0.4883      0.778 0.708 0.200 0.000 0.092 0.000
#> GSM38724     1  0.7072      0.249 0.464 0.112 0.364 0.060 0.000
#> GSM38725     1  0.2813      0.835 0.832 0.168 0.000 0.000 0.000
#> GSM38726     1  0.2179      0.852 0.888 0.112 0.000 0.000 0.000
#> GSM38727     1  0.4883      0.778 0.708 0.200 0.000 0.092 0.000
#> GSM38728     3  0.4069      0.758 0.088 0.004 0.800 0.108 0.000
#> GSM38729     1  0.1851      0.846 0.912 0.000 0.000 0.088 0.000
#> GSM38730     1  0.2179      0.852 0.888 0.112 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.861 1.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.4358      0.771 0.052 0.040 0.800 0.108 0.000
#> GSM38733     1  0.3840      0.686 0.780 0.016 0.196 0.008 0.000
#> GSM38734     3  0.3366      0.748 0.000 0.000 0.768 0.232 0.000
#> GSM38735     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM38736     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38737     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38738     3  0.3216      0.779 0.000 0.044 0.848 0.108 0.000
#> GSM38739     3  0.3074      0.617 0.196 0.000 0.804 0.000 0.000
#> GSM38740     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM38741     3  0.3276      0.778 0.000 0.032 0.836 0.132 0.000
#> GSM38742     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38743     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38744     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM38745     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM38746     3  0.2179      0.712 0.112 0.000 0.888 0.000 0.000
#> GSM38747     3  0.0000      0.779 0.000 0.000 1.000 0.000 0.000
#> GSM38748     4  0.2172      0.504 0.000 0.000 0.076 0.908 0.016
#> GSM38749     3  0.3074      0.617 0.196 0.000 0.804 0.000 0.000
#> GSM38750     3  0.0000      0.779 0.000 0.000 1.000 0.000 0.000
#> GSM38751     3  0.0162      0.779 0.004 0.000 0.996 0.000 0.000
#> GSM38752     3  0.3366      0.748 0.000 0.000 0.768 0.232 0.000
#> GSM38753     4  0.3913      0.664 0.000 0.000 0.000 0.676 0.324
#> GSM38754     3  0.3366      0.748 0.000 0.000 0.768 0.232 0.000
#> GSM38755     3  0.6488     -0.213 0.408 0.160 0.428 0.004 0.000
#> GSM38756     4  0.3913      0.664 0.000 0.000 0.000 0.676 0.324
#> GSM38757     3  0.0404      0.781 0.000 0.012 0.988 0.000 0.000
#> GSM38758     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38759     1  0.3323      0.811 0.844 0.000 0.056 0.100 0.000
#> GSM38760     1  0.5699      0.764 0.696 0.168 0.064 0.072 0.000
#> GSM38761     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200
#> GSM38762     2  0.3109      1.000 0.000 0.800 0.000 0.000 0.200

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1387      0.856 0.932 0.000 0.000 0.000 0.000 0.068
#> GSM38713     6  0.3448      0.571 0.280 0.000 0.004 0.000 0.000 0.716
#> GSM38714     6  0.3769      0.454 0.356 0.000 0.000 0.000 0.004 0.640
#> GSM38715     6  0.3756      0.340 0.400 0.000 0.000 0.000 0.000 0.600
#> GSM38716     1  0.2320      0.832 0.864 0.000 0.000 0.000 0.004 0.132
#> GSM38717     1  0.2805      0.789 0.812 0.000 0.000 0.000 0.004 0.184
#> GSM38718     1  0.3076      0.616 0.760 0.000 0.000 0.000 0.000 0.240
#> GSM38719     1  0.2772      0.794 0.816 0.000 0.000 0.000 0.004 0.180
#> GSM38720     1  0.1152      0.855 0.952 0.000 0.000 0.000 0.004 0.044
#> GSM38721     6  0.1895      0.631 0.072 0.000 0.016 0.000 0.000 0.912
#> GSM38722     1  0.0993      0.834 0.964 0.000 0.000 0.012 0.000 0.024
#> GSM38723     1  0.1563      0.813 0.932 0.000 0.000 0.012 0.000 0.056
#> GSM38724     6  0.4469      0.360 0.012 0.000 0.088 0.172 0.000 0.728
#> GSM38725     1  0.1814      0.847 0.900 0.000 0.000 0.000 0.000 0.100
#> GSM38726     1  0.1204      0.857 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM38727     1  0.1563      0.813 0.932 0.000 0.000 0.012 0.000 0.056
#> GSM38728     3  0.2692      0.680 0.012 0.000 0.840 0.000 0.000 0.148
#> GSM38729     1  0.0935      0.841 0.964 0.000 0.000 0.000 0.004 0.032
#> GSM38730     1  0.2092      0.836 0.876 0.000 0.000 0.000 0.000 0.124
#> GSM38731     1  0.0508      0.845 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM38732     3  0.3652      0.618 0.004 0.000 0.672 0.000 0.000 0.324
#> GSM38733     6  0.1895      0.631 0.072 0.000 0.016 0.000 0.000 0.912
#> GSM38734     3  0.0260      0.592 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38735     5  0.0146      1.000 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     3  0.4868      0.706 0.004 0.000 0.676 0.172 0.000 0.148
#> GSM38739     3  0.7038      0.448 0.092 0.000 0.396 0.180 0.000 0.332
#> GSM38740     5  0.0146      1.000 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38741     3  0.2340      0.688 0.000 0.000 0.852 0.000 0.000 0.148
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.0146      1.000 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38745     5  0.0146      1.000 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38746     3  0.5774      0.564 0.000 0.000 0.456 0.180 0.000 0.364
#> GSM38747     3  0.5921      0.537 0.004 0.000 0.432 0.180 0.000 0.384
#> GSM38748     4  0.3198      0.650 0.000 0.000 0.260 0.740 0.000 0.000
#> GSM38749     3  0.6946      0.451 0.080 0.000 0.396 0.180 0.000 0.344
#> GSM38750     3  0.4825      0.706 0.000 0.000 0.668 0.180 0.000 0.152
#> GSM38751     3  0.5774      0.564 0.000 0.000 0.456 0.180 0.000 0.364
#> GSM38752     3  0.0260      0.592 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38753     4  0.2793      0.825 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM38754     3  0.0260      0.592 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38755     6  0.4516      0.349 0.012 0.000 0.092 0.172 0.000 0.724
#> GSM38756     4  0.2793      0.825 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM38757     3  0.4795      0.707 0.000 0.000 0.672 0.176 0.000 0.152
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38759     1  0.4462      0.295 0.572 0.000 0.012 0.008 0.004 0.404
#> GSM38760     1  0.2632      0.809 0.832 0.000 0.004 0.000 0.000 0.164
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.728           0.845       0.938          0.465 0.547   0.547
#> 3 3 0.570           0.765       0.871          0.343 0.742   0.564
#> 4 4 0.539           0.499       0.748          0.123 0.940   0.844
#> 5 5 0.668           0.678       0.825          0.101 0.829   0.527
#> 6 6 0.702           0.529       0.779          0.044 0.951   0.799

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
#> GSM38712     1  0.0000      0.923 1.000 0.000
#> GSM38713     1  0.0000      0.923 1.000 0.000
#> GSM38714     1  0.0000      0.923 1.000 0.000
#> GSM38715     1  0.0000      0.923 1.000 0.000
#> GSM38716     1  0.0000      0.923 1.000 0.000
#> GSM38717     1  0.0000      0.923 1.000 0.000
#> GSM38718     1  0.0000      0.923 1.000 0.000
#> GSM38719     1  0.0000      0.923 1.000 0.000
#> GSM38720     1  0.0000      0.923 1.000 0.000
#> GSM38721     1  0.0376      0.921 0.996 0.004
#> GSM38722     1  0.0000      0.923 1.000 0.000
#> GSM38723     1  0.0000      0.923 1.000 0.000
#> GSM38724     1  0.6148      0.788 0.848 0.152
#> GSM38725     1  0.0000      0.923 1.000 0.000
#> GSM38726     1  0.0000      0.923 1.000 0.000
#> GSM38727     1  0.0000      0.923 1.000 0.000
#> GSM38728     2  0.9833      0.213 0.424 0.576
#> GSM38729     1  0.0000      0.923 1.000 0.000
#> GSM38730     1  0.0000      0.923 1.000 0.000
#> GSM38731     1  0.0000      0.923 1.000 0.000
#> GSM38732     2  0.5737      0.805 0.136 0.864
#> GSM38733     1  0.0000      0.923 1.000 0.000
#> GSM38734     2  0.0000      0.939 0.000 1.000
#> GSM38735     1  0.8207      0.633 0.744 0.256
#> GSM38736     2  0.0000      0.939 0.000 1.000
#> GSM38737     2  0.0938      0.930 0.012 0.988
#> GSM38738     2  0.8661      0.563 0.288 0.712
#> GSM38739     1  0.0000      0.923 1.000 0.000
#> GSM38740     1  0.0000      0.923 1.000 0.000
#> GSM38741     2  0.0000      0.939 0.000 1.000
#> GSM38742     2  0.0000      0.939 0.000 1.000
#> GSM38743     2  0.0000      0.939 0.000 1.000
#> GSM38744     1  0.0000      0.923 1.000 0.000
#> GSM38745     1  0.1184      0.913 0.984 0.016
#> GSM38746     1  0.8661      0.598 0.712 0.288
#> GSM38747     1  0.9491      0.432 0.632 0.368
#> GSM38748     2  0.0000      0.939 0.000 1.000
#> GSM38749     1  0.0000      0.923 1.000 0.000
#> GSM38750     1  0.9983      0.112 0.524 0.476
#> GSM38751     1  0.8443      0.638 0.728 0.272
#> GSM38752     2  0.0000      0.939 0.000 1.000
#> GSM38753     2  0.0000      0.939 0.000 1.000
#> GSM38754     2  0.0000      0.939 0.000 1.000
#> GSM38755     1  0.0000      0.923 1.000 0.000
#> GSM38756     2  0.0000      0.939 0.000 1.000
#> GSM38757     1  0.9815      0.293 0.580 0.420
#> GSM38758     2  0.0000      0.939 0.000 1.000
#> GSM38759     1  0.2948      0.885 0.948 0.052
#> GSM38760     1  0.0000      0.923 1.000 0.000
#> GSM38761     2  0.0000      0.939 0.000 1.000
#> GSM38762     2  0.0000      0.939 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
#> GSM38712     1  0.0237     0.8832 0.996 0.004 0.000
#> GSM38713     1  0.1031     0.8753 0.976 0.000 0.024
#> GSM38714     1  0.0892     0.8769 0.980 0.000 0.020
#> GSM38715     1  0.1031     0.8753 0.976 0.000 0.024
#> GSM38716     1  0.0424     0.8832 0.992 0.008 0.000
#> GSM38717     1  0.0237     0.8832 0.996 0.004 0.000
#> GSM38718     1  0.0000     0.8827 1.000 0.000 0.000
#> GSM38719     1  0.0000     0.8827 1.000 0.000 0.000
#> GSM38720     1  0.0237     0.8832 0.996 0.004 0.000
#> GSM38721     1  0.1031     0.8753 0.976 0.000 0.024
#> GSM38722     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38723     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38724     3  0.5905     0.4712 0.352 0.000 0.648
#> GSM38725     1  0.0000     0.8827 1.000 0.000 0.000
#> GSM38726     1  0.0592     0.8830 0.988 0.012 0.000
#> GSM38727     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38728     3  0.5327     0.5730 0.272 0.000 0.728
#> GSM38729     1  0.0424     0.8832 0.992 0.008 0.000
#> GSM38730     1  0.2625     0.8644 0.916 0.084 0.000
#> GSM38731     1  0.2448     0.8672 0.924 0.076 0.000
#> GSM38732     3  0.4002     0.6921 0.160 0.000 0.840
#> GSM38733     1  0.1031     0.8753 0.976 0.000 0.024
#> GSM38734     3  0.0237     0.7949 0.004 0.000 0.996
#> GSM38735     2  0.1031     0.7868 0.024 0.976 0.000
#> GSM38736     2  0.4235     0.8450 0.000 0.824 0.176
#> GSM38737     2  0.4235     0.8450 0.000 0.824 0.176
#> GSM38738     3  0.0424     0.7959 0.008 0.000 0.992
#> GSM38739     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38740     2  0.1031     0.7868 0.024 0.976 0.000
#> GSM38741     3  0.1031     0.7908 0.000 0.024 0.976
#> GSM38742     2  0.4235     0.8450 0.000 0.824 0.176
#> GSM38743     2  0.4235     0.8450 0.000 0.824 0.176
#> GSM38744     2  0.1031     0.7868 0.024 0.976 0.000
#> GSM38745     2  0.1031     0.7868 0.024 0.976 0.000
#> GSM38746     1  0.5911     0.7352 0.784 0.060 0.156
#> GSM38747     1  0.5331     0.7128 0.792 0.024 0.184
#> GSM38748     3  0.0000     0.7951 0.000 0.000 1.000
#> GSM38749     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38750     3  0.6977     0.6377 0.212 0.076 0.712
#> GSM38751     1  0.9433    -0.0485 0.420 0.176 0.404
#> GSM38752     3  0.0424     0.7950 0.000 0.008 0.992
#> GSM38753     3  0.4974     0.5628 0.000 0.236 0.764
#> GSM38754     3  0.1031     0.7908 0.000 0.024 0.976
#> GSM38755     1  0.8260    -0.0151 0.492 0.076 0.432
#> GSM38756     3  0.1031     0.7908 0.000 0.024 0.976
#> GSM38757     3  0.5058     0.6533 0.244 0.000 0.756
#> GSM38758     2  0.6280     0.4104 0.000 0.540 0.460
#> GSM38759     1  0.1129     0.8756 0.976 0.020 0.004
#> GSM38760     1  0.4235     0.8240 0.824 0.176 0.000
#> GSM38761     2  0.4235     0.8450 0.000 0.824 0.176
#> GSM38762     2  0.4235     0.8450 0.000 0.824 0.176

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0188    0.71019 0.996 0.004 0.000 0.000
#> GSM38713     1  0.0592    0.70793 0.984 0.000 0.016 0.000
#> GSM38714     1  0.0817    0.70363 0.976 0.000 0.024 0.000
#> GSM38715     1  0.0188    0.70898 0.996 0.000 0.004 0.000
#> GSM38716     1  0.2469    0.63394 0.892 0.000 0.108 0.000
#> GSM38717     1  0.0592    0.70709 0.984 0.000 0.016 0.000
#> GSM38718     1  0.2216    0.67452 0.908 0.000 0.092 0.000
#> GSM38719     1  0.0817    0.70363 0.976 0.000 0.024 0.000
#> GSM38720     1  0.0188    0.70901 0.996 0.000 0.004 0.000
#> GSM38721     1  0.2973    0.63663 0.856 0.000 0.144 0.000
#> GSM38722     1  0.6159    0.44958 0.672 0.196 0.132 0.000
#> GSM38723     1  0.7479    0.10135 0.480 0.196 0.324 0.000
#> GSM38724     4  0.7977    0.00328 0.280 0.004 0.304 0.412
#> GSM38725     1  0.1913    0.70274 0.940 0.040 0.020 0.000
#> GSM38726     1  0.2450    0.68677 0.912 0.016 0.072 0.000
#> GSM38727     1  0.6790    0.34265 0.608 0.196 0.196 0.000
#> GSM38728     4  0.7776   -0.23328 0.248 0.000 0.340 0.412
#> GSM38729     1  0.1022    0.69943 0.968 0.000 0.032 0.000
#> GSM38730     1  0.1406    0.70616 0.960 0.016 0.024 0.000
#> GSM38731     1  0.1211    0.70762 0.960 0.000 0.040 0.000
#> GSM38732     4  0.4501    0.53661 0.024 0.000 0.212 0.764
#> GSM38733     1  0.4158    0.53414 0.768 0.000 0.224 0.008
#> GSM38734     4  0.4382    0.57062 0.000 0.000 0.296 0.704
#> GSM38735     2  0.3037    0.65615 0.020 0.880 0.100 0.000
#> GSM38736     2  0.3726    0.75015 0.000 0.788 0.000 0.212
#> GSM38737     2  0.3610    0.75339 0.000 0.800 0.000 0.200
#> GSM38738     4  0.5161    0.50087 0.024 0.000 0.300 0.676
#> GSM38739     1  0.7793    0.05655 0.464 0.196 0.332 0.008
#> GSM38740     2  0.5998    0.47357 0.200 0.684 0.116 0.000
#> GSM38741     4  0.0921    0.59571 0.000 0.000 0.028 0.972
#> GSM38742     2  0.3610    0.75339 0.000 0.800 0.000 0.200
#> GSM38743     2  0.3569    0.75338 0.000 0.804 0.000 0.196
#> GSM38744     2  0.5839    0.48227 0.200 0.696 0.104 0.000
#> GSM38745     2  0.3674    0.64184 0.044 0.852 0.104 0.000
#> GSM38746     1  0.8771   -0.16774 0.408 0.168 0.356 0.068
#> GSM38747     1  0.8195   -0.02675 0.452 0.156 0.356 0.036
#> GSM38748     4  0.5158    0.53160 0.000 0.004 0.472 0.524
#> GSM38749     1  0.7667    0.07038 0.468 0.196 0.332 0.004
#> GSM38750     3  0.9630    0.53988 0.172 0.172 0.352 0.304
#> GSM38751     3  0.9764    0.37067 0.292 0.196 0.332 0.180
#> GSM38752     4  0.0000    0.59170 0.000 0.000 0.000 1.000
#> GSM38753     4  0.6498    0.38540 0.000 0.072 0.440 0.488
#> GSM38754     4  0.0000    0.59170 0.000 0.000 0.000 1.000
#> GSM38755     3  0.8458   -0.17364 0.224 0.032 0.428 0.316
#> GSM38756     4  0.4872    0.51489 0.000 0.004 0.356 0.640
#> GSM38757     3  0.8560    0.41771 0.204 0.040 0.404 0.352
#> GSM38758     2  0.4679    0.60854 0.000 0.648 0.000 0.352
#> GSM38759     1  0.3432    0.59117 0.848 0.004 0.140 0.008
#> GSM38760     1  0.7501    0.08280 0.472 0.196 0.332 0.000
#> GSM38761     2  0.3764    0.74830 0.000 0.784 0.000 0.216
#> GSM38762     2  0.3751    0.63163 0.000 0.800 0.196 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
#> GSM38712     1  0.1628     0.8616 0.936 0.000 0.056 0.008 0.000
#> GSM38713     1  0.0771     0.8654 0.976 0.000 0.000 0.004 0.020
#> GSM38714     1  0.0451     0.8698 0.988 0.000 0.004 0.008 0.000
#> GSM38715     1  0.0671     0.8664 0.980 0.000 0.000 0.004 0.016
#> GSM38716     1  0.2628     0.8442 0.884 0.000 0.088 0.028 0.000
#> GSM38717     1  0.0162     0.8700 0.996 0.000 0.004 0.000 0.000
#> GSM38718     1  0.0579     0.8702 0.984 0.000 0.008 0.000 0.008
#> GSM38719     1  0.0290     0.8707 0.992 0.000 0.008 0.000 0.000
#> GSM38720     1  0.0451     0.8705 0.988 0.000 0.008 0.004 0.000
#> GSM38721     1  0.3477     0.7748 0.824 0.000 0.000 0.040 0.136
#> GSM38722     3  0.4323     0.4646 0.332 0.000 0.656 0.012 0.000
#> GSM38723     3  0.1410     0.7998 0.060 0.000 0.940 0.000 0.000
#> GSM38724     4  0.8077     0.1541 0.304 0.000 0.092 0.340 0.264
#> GSM38725     1  0.3656     0.7364 0.784 0.000 0.196 0.020 0.000
#> GSM38726     1  0.2329     0.8360 0.876 0.000 0.124 0.000 0.000
#> GSM38727     3  0.2077     0.7861 0.084 0.000 0.908 0.008 0.000
#> GSM38728     1  0.4522     0.3571 0.552 0.000 0.008 0.000 0.440
#> GSM38729     1  0.0693     0.8697 0.980 0.000 0.008 0.012 0.000
#> GSM38730     1  0.2674     0.8204 0.856 0.000 0.140 0.004 0.000
#> GSM38731     1  0.3689     0.6761 0.740 0.000 0.256 0.004 0.000
#> GSM38732     5  0.4176     0.4767 0.108 0.000 0.004 0.096 0.792
#> GSM38733     1  0.4019     0.7417 0.792 0.000 0.004 0.052 0.152
#> GSM38734     5  0.3992     0.4688 0.004 0.000 0.004 0.280 0.712
#> GSM38735     2  0.4497     0.7734 0.016 0.780 0.088 0.116 0.000
#> GSM38736     2  0.0162     0.8318 0.000 0.996 0.000 0.000 0.004
#> GSM38737     2  0.0000     0.8328 0.000 1.000 0.000 0.000 0.000
#> GSM38738     5  0.6060     0.3859 0.004 0.000 0.176 0.228 0.592
#> GSM38739     3  0.1270     0.8014 0.052 0.000 0.948 0.000 0.000
#> GSM38740     2  0.6876     0.6161 0.068 0.572 0.132 0.228 0.000
#> GSM38741     5  0.6122     0.4418 0.000 0.080 0.060 0.216 0.644
#> GSM38742     2  0.0000     0.8328 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000     0.8328 0.000 1.000 0.000 0.000 0.000
#> GSM38744     2  0.6435     0.6723 0.068 0.636 0.156 0.140 0.000
#> GSM38745     2  0.5337     0.7360 0.024 0.716 0.136 0.124 0.000
#> GSM38746     3  0.2625     0.7452 0.016 0.000 0.900 0.056 0.028
#> GSM38747     3  0.6558     0.3970 0.104 0.028 0.540 0.004 0.324
#> GSM38748     4  0.3790     0.3911 0.004 0.000 0.004 0.744 0.248
#> GSM38749     3  0.1270     0.8014 0.052 0.000 0.948 0.000 0.000
#> GSM38750     3  0.3141     0.6942 0.016 0.000 0.832 0.000 0.152
#> GSM38751     3  0.0727     0.7746 0.004 0.000 0.980 0.012 0.004
#> GSM38752     5  0.3297     0.5864 0.000 0.080 0.048 0.012 0.860
#> GSM38753     4  0.4250     0.4805 0.000 0.084 0.004 0.784 0.128
#> GSM38754     5  0.3366     0.5878 0.004 0.084 0.040 0.012 0.860
#> GSM38755     4  0.5839     0.3451 0.008 0.000 0.192 0.636 0.164
#> GSM38756     4  0.4794     0.4788 0.000 0.080 0.012 0.744 0.164
#> GSM38757     3  0.5225     0.0143 0.008 0.000 0.508 0.028 0.456
#> GSM38758     2  0.3496     0.6594 0.000 0.788 0.012 0.000 0.200
#> GSM38759     1  0.4491     0.7131 0.772 0.008 0.004 0.152 0.064
#> GSM38760     3  0.1430     0.8004 0.052 0.000 0.944 0.000 0.004
#> GSM38761     2  0.0324     0.8302 0.000 0.992 0.004 0.000 0.004
#> GSM38762     2  0.1792     0.7932 0.000 0.916 0.000 0.000 0.084

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1984    0.82202 0.912 0.000 0.032 0.000 0.056 0.000
#> GSM38713     1  0.1666    0.82347 0.936 0.000 0.000 0.020 0.036 0.008
#> GSM38714     1  0.1686    0.82238 0.924 0.000 0.000 0.012 0.064 0.000
#> GSM38715     1  0.1003    0.83007 0.964 0.000 0.000 0.016 0.020 0.000
#> GSM38716     1  0.3560    0.77447 0.808 0.000 0.104 0.000 0.084 0.004
#> GSM38717     1  0.0260    0.83408 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38718     1  0.0405    0.83417 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM38719     1  0.0000    0.83432 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0653    0.83470 0.980 0.000 0.012 0.000 0.004 0.004
#> GSM38721     1  0.2667    0.76165 0.852 0.000 0.000 0.000 0.020 0.128
#> GSM38722     3  0.4863    0.08893 0.412 0.000 0.528 0.000 0.060 0.000
#> GSM38723     3  0.0692    0.77511 0.020 0.000 0.976 0.000 0.004 0.000
#> GSM38724     4  0.7670    0.21417 0.272 0.000 0.056 0.440 0.100 0.132
#> GSM38725     1  0.5001    0.63170 0.692 0.000 0.176 0.028 0.104 0.000
#> GSM38726     1  0.2488    0.79229 0.864 0.000 0.124 0.000 0.004 0.008
#> GSM38727     3  0.1657    0.75056 0.056 0.000 0.928 0.000 0.016 0.000
#> GSM38728     1  0.7327    0.00225 0.440 0.000 0.004 0.196 0.144 0.216
#> GSM38729     1  0.0806    0.83452 0.972 0.000 0.000 0.008 0.020 0.000
#> GSM38730     1  0.2573    0.79812 0.864 0.000 0.112 0.000 0.024 0.000
#> GSM38731     1  0.3619    0.69041 0.744 0.000 0.232 0.000 0.024 0.000
#> GSM38732     6  0.4511    0.59531 0.060 0.000 0.004 0.048 0.128 0.760
#> GSM38733     6  0.4406    0.39284 0.336 0.000 0.000 0.000 0.040 0.624
#> GSM38734     6  0.0937    0.67437 0.000 0.000 0.000 0.040 0.000 0.960
#> GSM38735     2  0.4527   -0.29545 0.008 0.604 0.028 0.000 0.360 0.000
#> GSM38736     2  0.0291    0.68039 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM38737     2  0.0000    0.68024 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     6  0.2214    0.66506 0.000 0.000 0.092 0.012 0.004 0.892
#> GSM38739     3  0.0260    0.77616 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM38740     5  0.6000    0.00000 0.076 0.380 0.056 0.000 0.488 0.000
#> GSM38741     4  0.2339    0.50329 0.000 0.028 0.024 0.908 0.004 0.036
#> GSM38742     2  0.0632    0.68150 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM38743     2  0.0547    0.68268 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM38744     2  0.6081   -0.78963 0.092 0.456 0.048 0.000 0.404 0.000
#> GSM38745     2  0.4853   -0.46866 0.004 0.556 0.052 0.000 0.388 0.000
#> GSM38746     3  0.3952    0.63964 0.000 0.000 0.788 0.088 0.108 0.016
#> GSM38747     3  0.7681   -0.02909 0.016 0.012 0.416 0.292 0.148 0.116
#> GSM38748     6  0.4828    0.36780 0.000 0.000 0.000 0.176 0.156 0.668
#> GSM38749     3  0.0000    0.77688 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38750     3  0.1141    0.76034 0.000 0.000 0.948 0.000 0.000 0.052
#> GSM38751     3  0.0363    0.77539 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM38752     4  0.5291    0.41823 0.000 0.028 0.004 0.676 0.136 0.156
#> GSM38753     4  0.5956    0.43892 0.000 0.028 0.000 0.504 0.348 0.120
#> GSM38754     4  0.5585    0.39381 0.000 0.028 0.004 0.640 0.160 0.168
#> GSM38755     6  0.2706    0.66442 0.000 0.000 0.068 0.024 0.028 0.880
#> GSM38756     4  0.5993    0.43828 0.000 0.028 0.000 0.508 0.336 0.128
#> GSM38757     3  0.4550    0.06524 0.000 0.000 0.524 0.008 0.020 0.448
#> GSM38758     2  0.2704    0.54108 0.000 0.844 0.000 0.140 0.016 0.000
#> GSM38759     1  0.6129    0.08153 0.448 0.000 0.000 0.320 0.224 0.008
#> GSM38760     3  0.0881    0.77644 0.012 0.000 0.972 0.000 0.008 0.008
#> GSM38761     2  0.0713    0.67938 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM38762     2  0.0806    0.65648 0.000 0.972 0.000 0.000 0.008 0.020

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 individual(p) k
#> CV:NMF 47      0.118530 2
#> CV:NMF 47      0.001895 3
#> CV:NMF 35      0.000419 4
#> CV:NMF 38      0.000213 5
#> CV:NMF 35      0.000478 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.979       0.990         0.4220 0.576   0.576
#> 3 3 0.750           0.833       0.910         0.4800 0.784   0.626
#> 4 4 0.725           0.821       0.907         0.0818 0.956   0.878
#> 5 5 0.698           0.800       0.874         0.1189 0.934   0.792
#> 6 6 0.738           0.750       0.844         0.0361 0.988   0.953

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
#> GSM38712     1   0.000      0.993 1.000 0.000
#> GSM38713     1   0.000      0.993 1.000 0.000
#> GSM38714     1   0.000      0.993 1.000 0.000
#> GSM38715     1   0.000      0.993 1.000 0.000
#> GSM38716     1   0.000      0.993 1.000 0.000
#> GSM38717     1   0.000      0.993 1.000 0.000
#> GSM38718     1   0.000      0.993 1.000 0.000
#> GSM38719     1   0.000      0.993 1.000 0.000
#> GSM38720     1   0.000      0.993 1.000 0.000
#> GSM38721     1   0.000      0.993 1.000 0.000
#> GSM38722     1   0.000      0.993 1.000 0.000
#> GSM38723     1   0.000      0.993 1.000 0.000
#> GSM38724     1   0.000      0.993 1.000 0.000
#> GSM38725     1   0.000      0.993 1.000 0.000
#> GSM38726     1   0.000      0.993 1.000 0.000
#> GSM38727     1   0.000      0.993 1.000 0.000
#> GSM38728     1   0.260      0.958 0.956 0.044
#> GSM38729     1   0.000      0.993 1.000 0.000
#> GSM38730     1   0.000      0.993 1.000 0.000
#> GSM38731     1   0.000      0.993 1.000 0.000
#> GSM38732     2   0.311      0.930 0.056 0.944
#> GSM38733     1   0.000      0.993 1.000 0.000
#> GSM38734     2   0.000      0.979 0.000 1.000
#> GSM38735     1   0.000      0.993 1.000 0.000
#> GSM38736     2   0.000      0.979 0.000 1.000
#> GSM38737     2   0.000      0.979 0.000 1.000
#> GSM38738     2   0.775      0.707 0.228 0.772
#> GSM38739     1   0.000      0.993 1.000 0.000
#> GSM38740     1   0.000      0.993 1.000 0.000
#> GSM38741     1   0.311      0.946 0.944 0.056
#> GSM38742     2   0.000      0.979 0.000 1.000
#> GSM38743     2   0.000      0.979 0.000 1.000
#> GSM38744     1   0.000      0.993 1.000 0.000
#> GSM38745     1   0.000      0.993 1.000 0.000
#> GSM38746     1   0.260      0.958 0.956 0.044
#> GSM38747     1   0.260      0.958 0.956 0.044
#> GSM38748     2   0.000      0.979 0.000 1.000
#> GSM38749     1   0.000      0.993 1.000 0.000
#> GSM38750     1   0.000      0.993 1.000 0.000
#> GSM38751     1   0.000      0.993 1.000 0.000
#> GSM38752     2   0.000      0.979 0.000 1.000
#> GSM38753     2   0.000      0.979 0.000 1.000
#> GSM38754     2   0.000      0.979 0.000 1.000
#> GSM38755     1   0.000      0.993 1.000 0.000
#> GSM38756     2   0.000      0.979 0.000 1.000
#> GSM38757     1   0.000      0.993 1.000 0.000
#> GSM38758     2   0.000      0.979 0.000 1.000
#> GSM38759     1   0.260      0.958 0.956 0.044
#> GSM38760     1   0.000      0.993 1.000 0.000
#> GSM38761     2   0.000      0.979 0.000 1.000
#> GSM38762     2   0.000      0.979 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38713     1  0.3879      0.808 0.848 0.000 0.152
#> GSM38714     1  0.3879      0.808 0.848 0.000 0.152
#> GSM38715     1  0.3879      0.808 0.848 0.000 0.152
#> GSM38716     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38717     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38718     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38719     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38720     1  0.2066      0.881 0.940 0.000 0.060
#> GSM38721     1  0.6079      0.305 0.612 0.000 0.388
#> GSM38722     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38724     3  0.4974      0.780 0.236 0.000 0.764
#> GSM38725     1  0.0237      0.891 0.996 0.000 0.004
#> GSM38726     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38728     3  0.1411      0.807 0.036 0.000 0.964
#> GSM38729     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38732     2  0.3038      0.907 0.000 0.896 0.104
#> GSM38733     1  0.6079      0.305 0.612 0.000 0.388
#> GSM38734     2  0.1753      0.946 0.000 0.952 0.048
#> GSM38735     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38736     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38737     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38738     2  0.5698      0.689 0.012 0.736 0.252
#> GSM38739     1  0.4605      0.692 0.796 0.000 0.204
#> GSM38740     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38741     3  0.1877      0.803 0.032 0.012 0.956
#> GSM38742     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38743     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38744     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38745     1  0.0000      0.893 1.000 0.000 0.000
#> GSM38746     3  0.1289      0.806 0.032 0.000 0.968
#> GSM38747     3  0.1289      0.806 0.032 0.000 0.968
#> GSM38748     2  0.0592      0.957 0.000 0.988 0.012
#> GSM38749     1  0.4605      0.692 0.796 0.000 0.204
#> GSM38750     3  0.4887      0.787 0.228 0.000 0.772
#> GSM38751     3  0.4887      0.787 0.228 0.000 0.772
#> GSM38752     2  0.1753      0.946 0.000 0.952 0.048
#> GSM38753     2  0.0592      0.957 0.000 0.988 0.012
#> GSM38754     2  0.1753      0.946 0.000 0.952 0.048
#> GSM38755     3  0.5706      0.658 0.320 0.000 0.680
#> GSM38756     2  0.0592      0.957 0.000 0.988 0.012
#> GSM38757     3  0.4842      0.789 0.224 0.000 0.776
#> GSM38758     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38759     3  0.1529      0.807 0.040 0.000 0.960
#> GSM38760     3  0.6299      0.232 0.476 0.000 0.524
#> GSM38761     2  0.0892      0.959 0.000 0.980 0.020
#> GSM38762     2  0.0892      0.959 0.000 0.980 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38713     1  0.3172      0.804 0.840 0.000 0.160 0.000
#> GSM38714     1  0.3172      0.804 0.840 0.000 0.160 0.000
#> GSM38715     1  0.3172      0.804 0.840 0.000 0.160 0.000
#> GSM38716     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38717     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38718     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38719     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38720     1  0.1792      0.873 0.932 0.000 0.068 0.000
#> GSM38721     1  0.4907      0.256 0.580 0.000 0.420 0.000
#> GSM38722     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38724     3  0.3444      0.797 0.184 0.000 0.816 0.000
#> GSM38725     1  0.0188      0.883 0.996 0.000 0.004 0.000
#> GSM38726     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38728     3  0.0992      0.774 0.004 0.012 0.976 0.008
#> GSM38729     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM38732     4  0.1716      0.878 0.000 0.000 0.064 0.936
#> GSM38733     1  0.4907      0.256 0.580 0.000 0.420 0.000
#> GSM38734     4  0.0336      0.897 0.000 0.000 0.008 0.992
#> GSM38735     1  0.1229      0.874 0.968 0.004 0.020 0.008
#> GSM38736     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38737     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38738     4  0.3942      0.697 0.000 0.000 0.236 0.764
#> GSM38739     1  0.3837      0.683 0.776 0.000 0.224 0.000
#> GSM38740     1  0.1229      0.874 0.968 0.004 0.020 0.008
#> GSM38741     3  0.0895      0.767 0.000 0.004 0.976 0.020
#> GSM38742     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38743     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38744     1  0.1229      0.874 0.968 0.004 0.020 0.008
#> GSM38745     1  0.1229      0.874 0.968 0.004 0.020 0.008
#> GSM38746     3  0.0804      0.772 0.000 0.012 0.980 0.008
#> GSM38747     3  0.0804      0.772 0.000 0.012 0.980 0.008
#> GSM38748     4  0.1118      0.889 0.000 0.036 0.000 0.964
#> GSM38749     1  0.3837      0.683 0.776 0.000 0.224 0.000
#> GSM38750     3  0.3356      0.804 0.176 0.000 0.824 0.000
#> GSM38751     3  0.3356      0.804 0.176 0.000 0.824 0.000
#> GSM38752     4  0.0336      0.897 0.000 0.000 0.008 0.992
#> GSM38753     4  0.3266      0.808 0.000 0.168 0.000 0.832
#> GSM38754     4  0.0336      0.897 0.000 0.000 0.008 0.992
#> GSM38755     3  0.4222      0.678 0.272 0.000 0.728 0.000
#> GSM38756     4  0.3266      0.808 0.000 0.168 0.000 0.832
#> GSM38757     3  0.3311      0.805 0.172 0.000 0.828 0.000
#> GSM38758     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38759     3  0.1139      0.775 0.008 0.012 0.972 0.008
#> GSM38760     3  0.4948      0.242 0.440 0.000 0.560 0.000
#> GSM38761     2  0.0592      1.000 0.000 0.984 0.000 0.016
#> GSM38762     2  0.0592      1.000 0.000 0.984 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
#> GSM38712     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.2260      0.785 0.908 0.000 0.028 0.000 0.064
#> GSM38714     1  0.2260      0.785 0.908 0.000 0.028 0.000 0.064
#> GSM38715     1  0.2260      0.785 0.908 0.000 0.028 0.000 0.064
#> GSM38716     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.822 1.000 0.000 0.000 0.000 0.000
#> GSM38721     1  0.5067      0.418 0.648 0.000 0.288 0.000 0.064
#> GSM38722     1  0.2966      0.752 0.816 0.000 0.000 0.000 0.184
#> GSM38723     1  0.3336      0.714 0.772 0.000 0.000 0.000 0.228
#> GSM38724     3  0.5301      0.744 0.176 0.000 0.676 0.000 0.148
#> GSM38725     1  0.2233      0.806 0.892 0.000 0.004 0.000 0.104
#> GSM38726     1  0.2020      0.808 0.900 0.000 0.000 0.000 0.100
#> GSM38727     1  0.3336      0.714 0.772 0.000 0.000 0.000 0.228
#> GSM38728     3  0.3055      0.750 0.072 0.000 0.864 0.000 0.064
#> GSM38729     1  0.2020      0.808 0.900 0.000 0.000 0.000 0.100
#> GSM38730     1  0.2020      0.808 0.900 0.000 0.000 0.000 0.100
#> GSM38731     1  0.2020      0.808 0.900 0.000 0.000 0.000 0.100
#> GSM38732     4  0.1341      0.864 0.000 0.000 0.056 0.944 0.000
#> GSM38733     1  0.5067      0.418 0.648 0.000 0.288 0.000 0.064
#> GSM38734     4  0.0000      0.882 0.000 0.000 0.000 1.000 0.000
#> GSM38735     5  0.1732      1.000 0.080 0.000 0.000 0.000 0.920
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38738     4  0.3461      0.676 0.000 0.000 0.224 0.772 0.004
#> GSM38739     1  0.6366      0.410 0.512 0.000 0.204 0.000 0.284
#> GSM38740     5  0.1732      1.000 0.080 0.000 0.000 0.000 0.920
#> GSM38741     3  0.0404      0.764 0.000 0.000 0.988 0.012 0.000
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38744     5  0.1732      1.000 0.080 0.000 0.000 0.000 0.920
#> GSM38745     5  0.1732      1.000 0.080 0.000 0.000 0.000 0.920
#> GSM38746     3  0.0162      0.765 0.000 0.000 0.996 0.000 0.004
#> GSM38747     3  0.0162      0.765 0.000 0.000 0.996 0.000 0.004
#> GSM38748     4  0.1124      0.880 0.000 0.036 0.000 0.960 0.004
#> GSM38749     1  0.6366      0.410 0.512 0.000 0.204 0.000 0.284
#> GSM38750     3  0.3918      0.783 0.096 0.000 0.804 0.000 0.100
#> GSM38751     3  0.3918      0.783 0.096 0.000 0.804 0.000 0.100
#> GSM38752     4  0.0404      0.884 0.000 0.000 0.000 0.988 0.012
#> GSM38753     4  0.3456      0.789 0.000 0.184 0.000 0.800 0.016
#> GSM38754     4  0.0404      0.884 0.000 0.000 0.000 0.988 0.012
#> GSM38755     3  0.5358      0.683 0.248 0.000 0.648 0.000 0.104
#> GSM38756     4  0.3456      0.789 0.000 0.184 0.000 0.800 0.016
#> GSM38757     3  0.3918      0.785 0.096 0.000 0.804 0.000 0.100
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38759     3  0.3116      0.750 0.076 0.000 0.860 0.000 0.064
#> GSM38760     3  0.6344      0.426 0.344 0.000 0.484 0.000 0.172
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.2123      0.774 0.908 0.000 0.008 0.000 0.064 0.020
#> GSM38714     1  0.2123      0.774 0.908 0.000 0.008 0.000 0.064 0.020
#> GSM38715     1  0.2123      0.774 0.908 0.000 0.008 0.000 0.064 0.020
#> GSM38716     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38721     1  0.4957      0.476 0.648 0.000 0.268 0.000 0.064 0.020
#> GSM38722     1  0.3279      0.738 0.796 0.000 0.000 0.000 0.176 0.028
#> GSM38723     1  0.3727      0.698 0.748 0.000 0.000 0.000 0.216 0.036
#> GSM38724     3  0.5754      0.730 0.080 0.000 0.596 0.000 0.060 0.264
#> GSM38725     1  0.2537      0.792 0.872 0.000 0.000 0.000 0.096 0.032
#> GSM38726     1  0.2412      0.794 0.880 0.000 0.000 0.000 0.092 0.028
#> GSM38727     1  0.3727      0.698 0.748 0.000 0.000 0.000 0.216 0.036
#> GSM38728     3  0.3275      0.693 0.072 0.000 0.844 0.000 0.064 0.020
#> GSM38729     1  0.2412      0.794 0.880 0.000 0.000 0.000 0.092 0.028
#> GSM38730     1  0.2412      0.794 0.880 0.000 0.000 0.000 0.092 0.028
#> GSM38731     1  0.2412      0.794 0.880 0.000 0.000 0.000 0.092 0.028
#> GSM38732     4  0.4020      0.658 0.000 0.000 0.032 0.692 0.000 0.276
#> GSM38733     1  0.4957      0.476 0.648 0.000 0.268 0.000 0.064 0.020
#> GSM38734     4  0.3151      0.657 0.000 0.000 0.000 0.748 0.000 0.252
#> GSM38735     5  0.1327      1.000 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     4  0.5684      0.477 0.000 0.000 0.200 0.520 0.000 0.280
#> GSM38739     1  0.7360      0.272 0.416 0.000 0.188 0.000 0.216 0.180
#> GSM38740     5  0.1327      1.000 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM38741     3  0.0508      0.742 0.000 0.000 0.984 0.012 0.000 0.004
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.1327      1.000 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM38745     5  0.1327      1.000 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM38746     3  0.0000      0.743 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38747     3  0.0000      0.743 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38748     6  0.4344      0.275 0.000 0.036 0.000 0.336 0.000 0.628
#> GSM38749     1  0.7360      0.272 0.416 0.000 0.188 0.000 0.216 0.180
#> GSM38750     3  0.3266      0.756 0.000 0.000 0.728 0.000 0.000 0.272
#> GSM38751     3  0.3266      0.756 0.000 0.000 0.728 0.000 0.000 0.272
#> GSM38752     4  0.0000      0.560 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38753     6  0.5820      0.744 0.000 0.184 0.000 0.400 0.000 0.416
#> GSM38754     4  0.0000      0.560 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38755     3  0.5351      0.688 0.148 0.000 0.572 0.000 0.000 0.280
#> GSM38756     6  0.5820      0.744 0.000 0.184 0.000 0.400 0.000 0.416
#> GSM38757     3  0.3221      0.759 0.000 0.000 0.736 0.000 0.000 0.264
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38759     3  0.3329      0.691 0.076 0.000 0.840 0.000 0.064 0.020
#> GSM38760     3  0.6871      0.486 0.220 0.000 0.408 0.000 0.060 0.312
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.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-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 individual(p) k
#> MAD:hclust 51      0.136757 2
#> MAD:hclust 48      0.033987 3
#> MAD:hclust 48      0.004140 4
#> MAD:hclust 46      0.000429 5
#> MAD:hclust 44      0.001062 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 19411 rows and 51 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.849           0.933       0.967         0.4293 0.594   0.594
#> 3 3 0.676           0.780       0.882         0.4509 0.757   0.596
#> 4 4 0.629           0.621       0.777         0.1514 0.817   0.553
#> 5 5 0.768           0.813       0.852         0.0727 0.964   0.869
#> 6 6 0.773           0.763       0.839         0.0568 0.917   0.677

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM38712     1  0.0000      0.952 1.000 0.000
#> GSM38713     1  0.0000      0.952 1.000 0.000
#> GSM38714     1  0.0000      0.952 1.000 0.000
#> GSM38715     1  0.0000      0.952 1.000 0.000
#> GSM38716     1  0.0000      0.952 1.000 0.000
#> GSM38717     1  0.0000      0.952 1.000 0.000
#> GSM38718     1  0.0000      0.952 1.000 0.000
#> GSM38719     1  0.0000      0.952 1.000 0.000
#> GSM38720     1  0.0000      0.952 1.000 0.000
#> GSM38721     1  0.0000      0.952 1.000 0.000
#> GSM38722     1  0.0000      0.952 1.000 0.000
#> GSM38723     1  0.0000      0.952 1.000 0.000
#> GSM38724     1  0.1184      0.944 0.984 0.016
#> GSM38725     1  0.0000      0.952 1.000 0.000
#> GSM38726     1  0.0000      0.952 1.000 0.000
#> GSM38727     1  0.0000      0.952 1.000 0.000
#> GSM38728     1  0.4815      0.880 0.896 0.104
#> GSM38729     1  0.0000      0.952 1.000 0.000
#> GSM38730     1  0.0000      0.952 1.000 0.000
#> GSM38731     1  0.0000      0.952 1.000 0.000
#> GSM38732     1  0.9608      0.468 0.616 0.384
#> GSM38733     1  0.0000      0.952 1.000 0.000
#> GSM38734     2  0.0000      1.000 0.000 1.000
#> GSM38735     1  0.0672      0.948 0.992 0.008
#> GSM38736     2  0.0000      1.000 0.000 1.000
#> GSM38737     2  0.0000      1.000 0.000 1.000
#> GSM38738     1  0.9323      0.546 0.652 0.348
#> GSM38739     1  0.0000      0.952 1.000 0.000
#> GSM38740     1  0.0000      0.952 1.000 0.000
#> GSM38741     2  0.0000      1.000 0.000 1.000
#> GSM38742     2  0.0000      1.000 0.000 1.000
#> GSM38743     2  0.0000      1.000 0.000 1.000
#> GSM38744     1  0.0000      0.952 1.000 0.000
#> GSM38745     1  0.0376      0.950 0.996 0.004
#> GSM38746     1  0.4562      0.887 0.904 0.096
#> GSM38747     1  0.4562      0.887 0.904 0.096
#> GSM38748     2  0.0000      1.000 0.000 1.000
#> GSM38749     1  0.0000      0.952 1.000 0.000
#> GSM38750     1  0.7528      0.762 0.784 0.216
#> GSM38751     1  0.7528      0.762 0.784 0.216
#> GSM38752     2  0.0000      1.000 0.000 1.000
#> GSM38753     2  0.0000      1.000 0.000 1.000
#> GSM38754     2  0.0000      1.000 0.000 1.000
#> GSM38755     1  0.0000      0.952 1.000 0.000
#> GSM38756     2  0.0000      1.000 0.000 1.000
#> GSM38757     1  0.7299      0.777 0.796 0.204
#> GSM38758     2  0.0000      1.000 0.000 1.000
#> GSM38759     1  0.1184      0.944 0.984 0.016
#> GSM38760     1  0.0000      0.952 1.000 0.000
#> GSM38761     2  0.0000      1.000 0.000 1.000
#> GSM38762     2  0.0000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38713     1  0.1289      0.884 0.968 0.000 0.032
#> GSM38714     1  0.1289      0.884 0.968 0.000 0.032
#> GSM38715     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38721     1  0.1289      0.884 0.968 0.000 0.032
#> GSM38722     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38724     3  0.5560      0.651 0.300 0.000 0.700
#> GSM38725     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38728     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38729     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.902 1.000 0.000 0.000
#> GSM38732     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38733     1  0.3686      0.782 0.860 0.000 0.140
#> GSM38734     2  0.6215      0.608 0.000 0.572 0.428
#> GSM38735     1  0.6319      0.676 0.732 0.040 0.228
#> GSM38736     2  0.0424      0.815 0.000 0.992 0.008
#> GSM38737     2  0.0424      0.815 0.000 0.992 0.008
#> GSM38738     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38739     1  0.6079      0.308 0.612 0.000 0.388
#> GSM38740     1  0.5292      0.709 0.764 0.008 0.228
#> GSM38741     3  0.1753      0.730 0.000 0.048 0.952
#> GSM38742     2  0.0000      0.816 0.000 1.000 0.000
#> GSM38743     2  0.0424      0.815 0.000 0.992 0.008
#> GSM38744     1  0.1753      0.864 0.952 0.000 0.048
#> GSM38745     1  0.6319      0.676 0.732 0.040 0.228
#> GSM38746     3  0.5560      0.651 0.300 0.000 0.700
#> GSM38747     3  0.5560      0.651 0.300 0.000 0.700
#> GSM38748     2  0.5678      0.721 0.000 0.684 0.316
#> GSM38749     1  0.5810      0.446 0.664 0.000 0.336
#> GSM38750     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38751     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38752     2  0.6192      0.620 0.000 0.580 0.420
#> GSM38753     2  0.5363      0.747 0.000 0.724 0.276
#> GSM38754     2  0.6192      0.620 0.000 0.580 0.420
#> GSM38755     3  0.3551      0.776 0.132 0.000 0.868
#> GSM38756     2  0.5363      0.747 0.000 0.724 0.276
#> GSM38757     3  0.1753      0.810 0.048 0.000 0.952
#> GSM38758     2  0.0000      0.816 0.000 1.000 0.000
#> GSM38759     3  0.5968      0.506 0.364 0.000 0.636
#> GSM38760     1  0.5560      0.531 0.700 0.000 0.300
#> GSM38761     2  0.0000      0.816 0.000 1.000 0.000
#> GSM38762     2  0.0424      0.815 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38713     1  0.2300      0.911 0.924 0.048 0.028 0.000
#> GSM38714     1  0.2300      0.911 0.924 0.048 0.028 0.000
#> GSM38715     1  0.1975      0.919 0.936 0.048 0.016 0.000
#> GSM38716     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0817      0.933 0.976 0.024 0.000 0.000
#> GSM38718     1  0.1576      0.924 0.948 0.048 0.004 0.000
#> GSM38719     1  0.0817      0.933 0.976 0.024 0.000 0.000
#> GSM38720     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38721     1  0.2300      0.911 0.924 0.048 0.028 0.000
#> GSM38722     1  0.2760      0.830 0.872 0.128 0.000 0.000
#> GSM38723     1  0.3123      0.798 0.844 0.156 0.000 0.000
#> GSM38724     3  0.2216      0.746 0.092 0.000 0.908 0.000
#> GSM38725     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38727     1  0.3123      0.798 0.844 0.156 0.000 0.000
#> GSM38728     3  0.3505      0.715 0.000 0.048 0.864 0.088
#> GSM38729     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.937 1.000 0.000 0.000 0.000
#> GSM38732     3  0.4004      0.664 0.000 0.024 0.812 0.164
#> GSM38733     1  0.3758      0.825 0.848 0.048 0.104 0.000
#> GSM38734     4  0.3688      0.635 0.000 0.000 0.208 0.792
#> GSM38735     2  0.6924      0.336 0.232 0.588 0.180 0.000
#> GSM38736     2  0.5000     -0.174 0.000 0.504 0.000 0.496
#> GSM38737     2  0.5000     -0.174 0.000 0.504 0.000 0.496
#> GSM38738     3  0.3219      0.675 0.000 0.000 0.836 0.164
#> GSM38739     3  0.7271      0.378 0.244 0.216 0.540 0.000
#> GSM38740     2  0.7095      0.320 0.260 0.560 0.180 0.000
#> GSM38741     3  0.3311      0.666 0.000 0.000 0.828 0.172
#> GSM38742     4  0.4948      0.145 0.000 0.440 0.000 0.560
#> GSM38743     2  0.5000     -0.174 0.000 0.504 0.000 0.496
#> GSM38744     2  0.7264      0.273 0.320 0.512 0.168 0.000
#> GSM38745     2  0.6924      0.336 0.232 0.588 0.180 0.000
#> GSM38746     3  0.3004      0.734 0.060 0.048 0.892 0.000
#> GSM38747     3  0.1970      0.750 0.060 0.008 0.932 0.000
#> GSM38748     4  0.2647      0.658 0.000 0.000 0.120 0.880
#> GSM38749     3  0.7483      0.324 0.288 0.216 0.496 0.000
#> GSM38750     3  0.2197      0.751 0.000 0.024 0.928 0.048
#> GSM38751     3  0.1610      0.752 0.000 0.032 0.952 0.016
#> GSM38752     4  0.3649      0.639 0.000 0.000 0.204 0.796
#> GSM38753     4  0.1637      0.650 0.000 0.000 0.060 0.940
#> GSM38754     4  0.3649      0.639 0.000 0.000 0.204 0.796
#> GSM38755     3  0.2739      0.752 0.000 0.060 0.904 0.036
#> GSM38756     4  0.1637      0.650 0.000 0.000 0.060 0.940
#> GSM38757     3  0.1389      0.747 0.000 0.000 0.952 0.048
#> GSM38758     4  0.4817      0.231 0.000 0.388 0.000 0.612
#> GSM38759     3  0.4307      0.687 0.144 0.048 0.808 0.000
#> GSM38760     3  0.7665      0.195 0.360 0.216 0.424 0.000
#> GSM38761     4  0.4948      0.145 0.000 0.440 0.000 0.560
#> GSM38762     2  0.5000     -0.174 0.000 0.504 0.000 0.496

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0609      0.842 0.980 0.000 0.000 0.000 0.020
#> GSM38713     1  0.4832      0.753 0.748 0.000 0.016 0.152 0.084
#> GSM38714     1  0.4832      0.753 0.748 0.000 0.016 0.152 0.084
#> GSM38715     1  0.4733      0.756 0.752 0.000 0.012 0.152 0.084
#> GSM38716     1  0.0992      0.841 0.968 0.000 0.000 0.008 0.024
#> GSM38717     1  0.1403      0.838 0.952 0.000 0.000 0.024 0.024
#> GSM38718     1  0.3921      0.780 0.800 0.000 0.000 0.128 0.072
#> GSM38719     1  0.1310      0.838 0.956 0.000 0.000 0.020 0.024
#> GSM38720     1  0.0609      0.841 0.980 0.000 0.000 0.020 0.000
#> GSM38721     1  0.4832      0.753 0.748 0.000 0.016 0.152 0.084
#> GSM38722     1  0.3445      0.721 0.824 0.000 0.000 0.036 0.140
#> GSM38723     1  0.4087      0.626 0.756 0.000 0.000 0.036 0.208
#> GSM38724     3  0.1399      0.818 0.000 0.000 0.952 0.028 0.020
#> GSM38725     1  0.1195      0.840 0.960 0.000 0.000 0.012 0.028
#> GSM38726     1  0.1310      0.837 0.956 0.000 0.000 0.020 0.024
#> GSM38727     1  0.4087      0.626 0.756 0.000 0.000 0.036 0.208
#> GSM38728     3  0.5108      0.676 0.020 0.000 0.728 0.160 0.092
#> GSM38729     1  0.0609      0.842 0.980 0.000 0.000 0.000 0.020
#> GSM38730     1  0.1310      0.837 0.956 0.000 0.000 0.020 0.024
#> GSM38731     1  0.1310      0.837 0.956 0.000 0.000 0.020 0.024
#> GSM38732     3  0.2522      0.801 0.000 0.000 0.880 0.108 0.012
#> GSM38733     1  0.4979      0.747 0.740 0.000 0.020 0.152 0.088
#> GSM38734     4  0.4062      0.878 0.000 0.132 0.068 0.796 0.004
#> GSM38735     5  0.3423      0.984 0.080 0.044 0.020 0.000 0.856
#> GSM38736     2  0.0703      0.961 0.000 0.976 0.000 0.000 0.024
#> GSM38737     2  0.0703      0.961 0.000 0.976 0.000 0.000 0.024
#> GSM38738     3  0.2193      0.808 0.000 0.000 0.900 0.092 0.008
#> GSM38739     3  0.5940      0.503 0.092 0.000 0.640 0.032 0.236
#> GSM38740     5  0.3815      0.982 0.080 0.044 0.020 0.012 0.844
#> GSM38741     3  0.2248      0.805 0.000 0.000 0.900 0.088 0.012
#> GSM38742     2  0.0898      0.947 0.000 0.972 0.000 0.020 0.008
#> GSM38743     2  0.0703      0.961 0.000 0.976 0.000 0.000 0.024
#> GSM38744     5  0.3654      0.961 0.104 0.020 0.020 0.012 0.844
#> GSM38745     5  0.3423      0.984 0.080 0.044 0.020 0.000 0.856
#> GSM38746     3  0.0794      0.823 0.000 0.000 0.972 0.000 0.028
#> GSM38747     3  0.0510      0.824 0.000 0.000 0.984 0.000 0.016
#> GSM38748     4  0.4414      0.884 0.000 0.248 0.008 0.720 0.024
#> GSM38749     3  0.6415      0.447 0.132 0.000 0.600 0.036 0.232
#> GSM38750     3  0.1117      0.822 0.000 0.000 0.964 0.016 0.020
#> GSM38751     3  0.0798      0.823 0.000 0.000 0.976 0.008 0.016
#> GSM38752     4  0.4017      0.892 0.000 0.148 0.064 0.788 0.000
#> GSM38753     4  0.4106      0.879 0.000 0.256 0.000 0.724 0.020
#> GSM38754     4  0.4017      0.892 0.000 0.148 0.064 0.788 0.000
#> GSM38755     3  0.1830      0.814 0.000 0.000 0.932 0.028 0.040
#> GSM38756     4  0.4106      0.879 0.000 0.256 0.000 0.724 0.020
#> GSM38757     3  0.0671      0.824 0.000 0.000 0.980 0.016 0.004
#> GSM38758     2  0.1557      0.912 0.000 0.940 0.000 0.052 0.008
#> GSM38759     3  0.5846      0.618 0.044 0.000 0.672 0.192 0.092
#> GSM38760     3  0.7022      0.293 0.208 0.000 0.516 0.036 0.240
#> GSM38761     2  0.0898      0.947 0.000 0.972 0.000 0.020 0.008
#> GSM38762     2  0.0703      0.961 0.000 0.976 0.000 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1152     0.8462 0.952 0.000 0.000 0.004 0.000 0.044
#> GSM38713     6  0.3830     0.6615 0.376 0.000 0.000 0.004 0.000 0.620
#> GSM38714     6  0.3830     0.6615 0.376 0.000 0.000 0.004 0.000 0.620
#> GSM38715     6  0.3852     0.6479 0.384 0.000 0.000 0.004 0.000 0.612
#> GSM38716     1  0.1010     0.8490 0.960 0.000 0.000 0.004 0.000 0.036
#> GSM38717     1  0.2053     0.7945 0.888 0.000 0.000 0.004 0.000 0.108
#> GSM38718     1  0.3982    -0.2903 0.536 0.000 0.000 0.004 0.000 0.460
#> GSM38719     1  0.2006     0.7991 0.892 0.000 0.000 0.004 0.000 0.104
#> GSM38720     1  0.1908     0.8061 0.900 0.000 0.000 0.004 0.000 0.096
#> GSM38721     6  0.3695     0.6623 0.376 0.000 0.000 0.000 0.000 0.624
#> GSM38722     1  0.2164     0.7759 0.900 0.000 0.000 0.000 0.032 0.068
#> GSM38723     1  0.3210     0.7346 0.852 0.000 0.000 0.032 0.048 0.068
#> GSM38724     3  0.4124     0.6229 0.000 0.008 0.648 0.012 0.000 0.332
#> GSM38725     1  0.0717     0.8485 0.976 0.008 0.000 0.000 0.000 0.016
#> GSM38726     1  0.0000     0.8500 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.3210     0.7346 0.852 0.000 0.000 0.032 0.048 0.068
#> GSM38728     6  0.4786     0.0222 0.000 0.008 0.256 0.076 0.000 0.660
#> GSM38729     1  0.1007     0.8475 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM38730     1  0.0000     0.8500 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000     0.8500 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.4780     0.7015 0.000 0.012 0.688 0.092 0.000 0.208
#> GSM38733     6  0.3428     0.6591 0.304 0.000 0.000 0.000 0.000 0.696
#> GSM38734     4  0.2585     0.8959 0.000 0.068 0.004 0.880 0.000 0.048
#> GSM38735     5  0.1096     0.9887 0.008 0.004 0.000 0.004 0.964 0.020
#> GSM38736     2  0.1075     0.9562 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM38737     2  0.1075     0.9562 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM38738     3  0.4467     0.7224 0.000 0.012 0.724 0.080 0.000 0.184
#> GSM38739     3  0.5920     0.5963 0.112 0.012 0.692 0.040 0.072 0.072
#> GSM38740     5  0.0405     0.9877 0.008 0.004 0.000 0.000 0.988 0.000
#> GSM38741     3  0.4815     0.6967 0.000 0.008 0.668 0.088 0.000 0.236
#> GSM38742     2  0.1334     0.9404 0.000 0.948 0.000 0.032 0.000 0.020
#> GSM38743     2  0.1075     0.9562 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM38744     5  0.0260     0.9864 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM38745     5  0.1096     0.9887 0.008 0.004 0.000 0.004 0.964 0.020
#> GSM38746     3  0.1964     0.7655 0.000 0.004 0.920 0.008 0.012 0.056
#> GSM38747     3  0.2326     0.7634 0.000 0.008 0.888 0.012 0.000 0.092
#> GSM38748     4  0.2431     0.8990 0.000 0.132 0.000 0.860 0.008 0.000
#> GSM38749     3  0.6183     0.5700 0.140 0.012 0.664 0.040 0.072 0.072
#> GSM38750     3  0.0508     0.7680 0.000 0.000 0.984 0.004 0.012 0.000
#> GSM38751     3  0.0363     0.7684 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM38752     4  0.3038     0.8952 0.000 0.060 0.012 0.856 0.000 0.072
#> GSM38753     4  0.2593     0.8935 0.000 0.148 0.000 0.844 0.008 0.000
#> GSM38754     4  0.3038     0.8952 0.000 0.060 0.012 0.856 0.000 0.072
#> GSM38755     3  0.3610     0.7687 0.000 0.020 0.812 0.008 0.024 0.136
#> GSM38756     4  0.2593     0.8935 0.000 0.148 0.000 0.844 0.008 0.000
#> GSM38757     3  0.2462     0.7668 0.000 0.004 0.860 0.004 0.000 0.132
#> GSM38758     2  0.1807     0.9198 0.000 0.920 0.000 0.060 0.000 0.020
#> GSM38759     6  0.3707     0.3419 0.020 0.008 0.164 0.016 0.000 0.792
#> GSM38760     3  0.6674     0.4989 0.208 0.012 0.596 0.040 0.072 0.072
#> GSM38761     2  0.1334     0.9404 0.000 0.948 0.000 0.032 0.000 0.020
#> GSM38762     2  0.1333     0.9533 0.000 0.944 0.000 0.000 0.048 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

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

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.918           0.924       0.967         0.5004 0.506   0.506
#> 3 3 0.943           0.950       0.975         0.3048 0.733   0.523
#> 4 4 0.794           0.822       0.860         0.1237 0.882   0.675
#> 5 5 0.735           0.715       0.831         0.0579 0.960   0.850
#> 6 6 0.767           0.732       0.849         0.0553 0.896   0.593

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
#> GSM38712     1   0.000      0.948 1.000 0.000
#> GSM38713     1   0.000      0.948 1.000 0.000
#> GSM38714     1   0.000      0.948 1.000 0.000
#> GSM38715     1   0.000      0.948 1.000 0.000
#> GSM38716     1   0.000      0.948 1.000 0.000
#> GSM38717     1   0.000      0.948 1.000 0.000
#> GSM38718     1   0.000      0.948 1.000 0.000
#> GSM38719     1   0.000      0.948 1.000 0.000
#> GSM38720     1   0.000      0.948 1.000 0.000
#> GSM38721     1   0.000      0.948 1.000 0.000
#> GSM38722     1   0.000      0.948 1.000 0.000
#> GSM38723     1   0.000      0.948 1.000 0.000
#> GSM38724     1   0.971      0.406 0.600 0.400
#> GSM38725     1   0.000      0.948 1.000 0.000
#> GSM38726     1   0.000      0.948 1.000 0.000
#> GSM38727     1   0.000      0.948 1.000 0.000
#> GSM38728     2   0.000      0.990 0.000 1.000
#> GSM38729     1   0.000      0.948 1.000 0.000
#> GSM38730     1   0.000      0.948 1.000 0.000
#> GSM38731     1   0.000      0.948 1.000 0.000
#> GSM38732     2   0.000      0.990 0.000 1.000
#> GSM38733     1   0.000      0.948 1.000 0.000
#> GSM38734     2   0.000      0.990 0.000 1.000
#> GSM38735     1   0.430      0.876 0.912 0.088
#> GSM38736     2   0.000      0.990 0.000 1.000
#> GSM38737     2   0.000      0.990 0.000 1.000
#> GSM38738     2   0.000      0.990 0.000 1.000
#> GSM38739     1   0.000      0.948 1.000 0.000
#> GSM38740     1   0.000      0.948 1.000 0.000
#> GSM38741     2   0.000      0.990 0.000 1.000
#> GSM38742     2   0.000      0.990 0.000 1.000
#> GSM38743     2   0.000      0.990 0.000 1.000
#> GSM38744     1   0.000      0.948 1.000 0.000
#> GSM38745     1   0.141      0.933 0.980 0.020
#> GSM38746     1   0.969      0.415 0.604 0.396
#> GSM38747     1   0.969      0.415 0.604 0.396
#> GSM38748     2   0.000      0.990 0.000 1.000
#> GSM38749     1   0.000      0.948 1.000 0.000
#> GSM38750     2   0.000      0.990 0.000 1.000
#> GSM38751     2   0.000      0.990 0.000 1.000
#> GSM38752     2   0.000      0.990 0.000 1.000
#> GSM38753     2   0.000      0.990 0.000 1.000
#> GSM38754     2   0.000      0.990 0.000 1.000
#> GSM38755     2   0.697      0.753 0.188 0.812
#> GSM38756     2   0.000      0.990 0.000 1.000
#> GSM38757     2   0.000      0.990 0.000 1.000
#> GSM38758     2   0.000      0.990 0.000 1.000
#> GSM38759     1   0.680      0.774 0.820 0.180
#> GSM38760     1   0.000      0.948 1.000 0.000
#> GSM38761     2   0.000      0.990 0.000 1.000
#> GSM38762     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
#> GSM38712     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38721     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38722     1  0.0237      0.984 0.996 0.004 0.000
#> GSM38723     1  0.0237      0.984 0.996 0.004 0.000
#> GSM38724     3  0.0237      0.947 0.004 0.000 0.996
#> GSM38725     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38727     1  0.0237      0.984 0.996 0.004 0.000
#> GSM38728     3  0.0237      0.947 0.004 0.000 0.996
#> GSM38729     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38732     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38733     1  0.0000      0.986 1.000 0.000 0.000
#> GSM38734     3  0.0592      0.946 0.000 0.012 0.988
#> GSM38735     2  0.0000      0.980 0.000 1.000 0.000
#> GSM38736     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38737     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38738     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38739     1  0.0661      0.979 0.988 0.004 0.008
#> GSM38740     2  0.1031      0.964 0.024 0.976 0.000
#> GSM38741     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38742     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38743     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38744     2  0.2959      0.880 0.100 0.900 0.000
#> GSM38745     2  0.0747      0.971 0.016 0.984 0.000
#> GSM38746     3  0.0475      0.946 0.004 0.004 0.992
#> GSM38747     3  0.0424      0.945 0.008 0.000 0.992
#> GSM38748     3  0.2537      0.900 0.000 0.080 0.920
#> GSM38749     1  0.0661      0.979 0.988 0.004 0.008
#> GSM38750     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38751     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38752     3  0.0592      0.946 0.000 0.012 0.988
#> GSM38753     3  0.4842      0.749 0.000 0.224 0.776
#> GSM38754     3  0.0747      0.944 0.000 0.016 0.984
#> GSM38755     3  0.4755      0.754 0.184 0.008 0.808
#> GSM38756     3  0.4842      0.749 0.000 0.224 0.776
#> GSM38757     3  0.0000      0.949 0.000 0.000 1.000
#> GSM38758     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38759     1  0.5216      0.654 0.740 0.000 0.260
#> GSM38760     1  0.0475      0.982 0.992 0.004 0.004
#> GSM38761     2  0.0237      0.982 0.000 0.996 0.004
#> GSM38762     2  0.0237      0.982 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38713     1  0.1792      0.907 0.932 0.000 0.068 0.000
#> GSM38714     1  0.1792      0.907 0.932 0.000 0.068 0.000
#> GSM38715     1  0.1792      0.907 0.932 0.000 0.068 0.000
#> GSM38716     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0188      0.935 0.996 0.000 0.004 0.000
#> GSM38718     1  0.0188      0.935 0.996 0.000 0.004 0.000
#> GSM38719     1  0.0188      0.935 0.996 0.000 0.004 0.000
#> GSM38720     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38721     1  0.1792      0.907 0.932 0.000 0.068 0.000
#> GSM38722     1  0.2256      0.884 0.924 0.056 0.020 0.000
#> GSM38723     1  0.2565      0.875 0.912 0.056 0.032 0.000
#> GSM38724     3  0.3400      0.618 0.000 0.000 0.820 0.180
#> GSM38725     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38727     1  0.2565      0.875 0.912 0.056 0.032 0.000
#> GSM38728     4  0.4560      0.745 0.004 0.000 0.296 0.700
#> GSM38729     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.936 1.000 0.000 0.000 0.000
#> GSM38732     4  0.3649      0.822 0.000 0.000 0.204 0.796
#> GSM38733     1  0.1792      0.907 0.932 0.000 0.068 0.000
#> GSM38734     4  0.2081      0.863 0.000 0.000 0.084 0.916
#> GSM38735     2  0.0000      0.817 0.000 1.000 0.000 0.000
#> GSM38736     2  0.3837      0.888 0.000 0.776 0.000 0.224
#> GSM38737     2  0.3837      0.888 0.000 0.776 0.000 0.224
#> GSM38738     4  0.3837      0.804 0.000 0.000 0.224 0.776
#> GSM38739     3  0.5478      0.653 0.248 0.056 0.696 0.000
#> GSM38740     2  0.0779      0.807 0.004 0.980 0.016 0.000
#> GSM38741     4  0.3837      0.806 0.000 0.000 0.224 0.776
#> GSM38742     2  0.3837      0.888 0.000 0.776 0.000 0.224
#> GSM38743     2  0.3837      0.888 0.000 0.776 0.000 0.224
#> GSM38744     2  0.2413      0.749 0.064 0.916 0.020 0.000
#> GSM38745     2  0.0336      0.813 0.000 0.992 0.008 0.000
#> GSM38746     3  0.0188      0.739 0.004 0.000 0.996 0.000
#> GSM38747     3  0.0188      0.738 0.000 0.000 0.996 0.004
#> GSM38748     4  0.0469      0.828 0.000 0.000 0.012 0.988
#> GSM38749     3  0.5478      0.653 0.248 0.056 0.696 0.000
#> GSM38750     3  0.2408      0.726 0.000 0.000 0.896 0.104
#> GSM38751     3  0.2281      0.730 0.000 0.000 0.904 0.096
#> GSM38752     4  0.2345      0.866 0.000 0.000 0.100 0.900
#> GSM38753     4  0.0336      0.813 0.000 0.008 0.000 0.992
#> GSM38754     4  0.2345      0.866 0.000 0.000 0.100 0.900
#> GSM38755     3  0.6431      0.641 0.008 0.120 0.664 0.208
#> GSM38756     4  0.0336      0.813 0.000 0.008 0.000 0.992
#> GSM38757     3  0.3649      0.637 0.000 0.000 0.796 0.204
#> GSM38758     2  0.4454      0.804 0.000 0.692 0.000 0.308
#> GSM38759     1  0.7344      0.186 0.512 0.000 0.188 0.300
#> GSM38760     3  0.5814      0.579 0.300 0.056 0.644 0.000
#> GSM38761     2  0.3837      0.888 0.000 0.776 0.000 0.224
#> GSM38762     2  0.3837      0.888 0.000 0.776 0.000 0.224

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0290      0.826 0.992 0.000 0.000 0.000 0.008
#> GSM38713     1  0.4779      0.581 0.588 0.000 0.024 0.000 0.388
#> GSM38714     1  0.4779      0.581 0.588 0.000 0.024 0.000 0.388
#> GSM38715     1  0.4779      0.581 0.588 0.000 0.024 0.000 0.388
#> GSM38716     1  0.0162      0.826 0.996 0.000 0.000 0.000 0.004
#> GSM38717     1  0.1341      0.818 0.944 0.000 0.000 0.000 0.056
#> GSM38718     1  0.3336      0.716 0.772 0.000 0.000 0.000 0.228
#> GSM38719     1  0.1270      0.819 0.948 0.000 0.000 0.000 0.052
#> GSM38720     1  0.1121      0.821 0.956 0.000 0.000 0.000 0.044
#> GSM38721     1  0.4779      0.581 0.588 0.000 0.024 0.000 0.388
#> GSM38722     1  0.1484      0.792 0.944 0.000 0.008 0.000 0.048
#> GSM38723     1  0.1701      0.786 0.936 0.000 0.016 0.000 0.048
#> GSM38724     3  0.6044      0.410 0.000 0.000 0.576 0.236 0.188
#> GSM38725     1  0.0162      0.825 0.996 0.000 0.004 0.000 0.000
#> GSM38726     1  0.0162      0.825 0.996 0.000 0.004 0.000 0.000
#> GSM38727     1  0.1701      0.786 0.936 0.000 0.016 0.000 0.048
#> GSM38728     4  0.5160      0.458 0.000 0.000 0.056 0.608 0.336
#> GSM38729     1  0.0290      0.826 0.992 0.000 0.000 0.000 0.008
#> GSM38730     1  0.0162      0.825 0.996 0.000 0.004 0.000 0.000
#> GSM38731     1  0.0162      0.825 0.996 0.000 0.004 0.000 0.000
#> GSM38732     4  0.1908      0.788 0.000 0.000 0.092 0.908 0.000
#> GSM38733     1  0.4779      0.581 0.588 0.000 0.024 0.000 0.388
#> GSM38734     4  0.0404      0.833 0.000 0.012 0.000 0.988 0.000
#> GSM38735     5  0.4708      0.475 0.000 0.436 0.016 0.000 0.548
#> GSM38736     2  0.2020      0.981 0.000 0.900 0.000 0.100 0.000
#> GSM38737     2  0.2020      0.981 0.000 0.900 0.000 0.100 0.000
#> GSM38738     4  0.2074      0.777 0.000 0.000 0.104 0.896 0.000
#> GSM38739     3  0.4548      0.607 0.232 0.000 0.716 0.000 0.052
#> GSM38740     5  0.5368      0.537 0.036 0.356 0.016 0.000 0.592
#> GSM38741     4  0.2179      0.780 0.000 0.000 0.100 0.896 0.004
#> GSM38742     2  0.2020      0.981 0.000 0.900 0.000 0.100 0.000
#> GSM38743     2  0.2020      0.981 0.000 0.900 0.000 0.100 0.000
#> GSM38744     5  0.6280      0.496 0.200 0.188 0.016 0.000 0.596
#> GSM38745     5  0.4822      0.501 0.004 0.416 0.016 0.000 0.564
#> GSM38746     3  0.0963      0.739 0.000 0.000 0.964 0.036 0.000
#> GSM38747     3  0.1469      0.733 0.000 0.000 0.948 0.036 0.016
#> GSM38748     4  0.2424      0.769 0.000 0.132 0.000 0.868 0.000
#> GSM38749     3  0.4509      0.606 0.236 0.000 0.716 0.000 0.048
#> GSM38750     3  0.1410      0.742 0.000 0.000 0.940 0.060 0.000
#> GSM38751     3  0.1341      0.742 0.000 0.000 0.944 0.056 0.000
#> GSM38752     4  0.0404      0.833 0.000 0.012 0.000 0.988 0.000
#> GSM38753     4  0.3074      0.702 0.000 0.196 0.000 0.804 0.000
#> GSM38754     4  0.0510      0.833 0.000 0.016 0.000 0.984 0.000
#> GSM38755     3  0.4648      0.602 0.024 0.004 0.716 0.244 0.012
#> GSM38756     4  0.3003      0.713 0.000 0.188 0.000 0.812 0.000
#> GSM38757     3  0.3508      0.609 0.000 0.000 0.748 0.252 0.000
#> GSM38758     2  0.2813      0.888 0.000 0.832 0.000 0.168 0.000
#> GSM38759     5  0.7260     -0.306 0.344 0.000 0.028 0.224 0.404
#> GSM38760     3  0.5128      0.476 0.344 0.000 0.604 0.000 0.052
#> GSM38761     2  0.2020      0.981 0.000 0.900 0.000 0.100 0.000
#> GSM38762     2  0.2020      0.981 0.000 0.900 0.000 0.100 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
#> GSM38712     1  0.1075      0.794 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM38713     6  0.3198      0.721 0.260 0.000 0.000 0.000 0.000 0.740
#> GSM38714     6  0.3198      0.721 0.260 0.000 0.000 0.000 0.000 0.740
#> GSM38715     6  0.3198      0.721 0.260 0.000 0.000 0.000 0.000 0.740
#> GSM38716     1  0.0937      0.797 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM38717     1  0.2793      0.654 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM38718     1  0.3737      0.209 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM38719     1  0.2597      0.687 0.824 0.000 0.000 0.000 0.000 0.176
#> GSM38720     1  0.2340      0.717 0.852 0.000 0.000 0.000 0.000 0.148
#> GSM38721     6  0.3314      0.721 0.256 0.000 0.000 0.000 0.004 0.740
#> GSM38722     1  0.2673      0.724 0.856 0.000 0.008 0.004 0.004 0.128
#> GSM38723     1  0.2673      0.724 0.856 0.000 0.008 0.004 0.004 0.128
#> GSM38724     6  0.5000     -0.103 0.000 0.000 0.464 0.032 0.020 0.484
#> GSM38725     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.2673      0.724 0.856 0.000 0.008 0.004 0.004 0.128
#> GSM38728     6  0.5056      0.197 0.000 0.000 0.048 0.380 0.016 0.556
#> GSM38729     1  0.1141      0.792 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM38730     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.803 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     4  0.0622      0.882 0.000 0.000 0.012 0.980 0.000 0.008
#> GSM38733     6  0.3337      0.719 0.260 0.000 0.000 0.000 0.004 0.736
#> GSM38734     4  0.0405      0.887 0.000 0.008 0.004 0.988 0.000 0.000
#> GSM38735     5  0.0937      0.983 0.000 0.040 0.000 0.000 0.960 0.000
#> GSM38736     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     4  0.1088      0.874 0.000 0.000 0.016 0.960 0.000 0.024
#> GSM38739     3  0.5853      0.420 0.304 0.000 0.544 0.004 0.016 0.132
#> GSM38740     5  0.0972      0.986 0.008 0.028 0.000 0.000 0.964 0.000
#> GSM38741     4  0.1867      0.850 0.000 0.000 0.036 0.924 0.004 0.036
#> GSM38742     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.1003      0.978 0.016 0.020 0.000 0.000 0.964 0.000
#> GSM38745     5  0.0865      0.986 0.000 0.036 0.000 0.000 0.964 0.000
#> GSM38746     3  0.0976      0.699 0.000 0.000 0.968 0.008 0.008 0.016
#> GSM38747     3  0.2525      0.659 0.000 0.000 0.876 0.012 0.012 0.100
#> GSM38748     4  0.2697      0.817 0.000 0.188 0.000 0.812 0.000 0.000
#> GSM38749     3  0.5853      0.420 0.304 0.000 0.544 0.004 0.016 0.132
#> GSM38750     3  0.1578      0.713 0.000 0.000 0.936 0.048 0.004 0.012
#> GSM38751     3  0.1007      0.714 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM38752     4  0.0717      0.889 0.000 0.016 0.000 0.976 0.000 0.008
#> GSM38753     4  0.2941      0.788 0.000 0.220 0.000 0.780 0.000 0.000
#> GSM38754     4  0.0717      0.889 0.000 0.016 0.000 0.976 0.000 0.008
#> GSM38755     3  0.6149      0.517 0.032 0.000 0.584 0.268 0.040 0.076
#> GSM38756     4  0.2883      0.796 0.000 0.212 0.000 0.788 0.000 0.000
#> GSM38757     3  0.3933      0.596 0.000 0.000 0.740 0.220 0.008 0.032
#> GSM38758     2  0.0547      0.973 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM38759     6  0.5182      0.610 0.108 0.000 0.024 0.160 0.012 0.696
#> GSM38760     1  0.6232     -0.275 0.420 0.000 0.412 0.004 0.024 0.140
#> GSM38761     2  0.0000      0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      0.996 0.000 1.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-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 individual(p) k
#> MAD:skmeans 48      0.038273 2
#> MAD:skmeans 51      0.000385 3
#> MAD:skmeans 50      0.001025 4
#> MAD:skmeans 45      0.002264 5
#> MAD:skmeans 45      0.000476 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 19411 rows and 51 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 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-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.841           0.872       0.949         0.4287 0.561   0.561
#> 3 3 0.674           0.833       0.928         0.5095 0.707   0.514
#> 4 4 0.761           0.824       0.889         0.0950 0.865   0.650
#> 5 5 0.944           0.958       0.978         0.0553 0.965   0.879
#> 6 6 0.925           0.903       0.956         0.1023 0.870   0.535

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

There is also optional best \(k\) = 5 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
#> GSM38712     1   0.000     0.9632 1.000 0.000
#> GSM38713     1   0.000     0.9632 1.000 0.000
#> GSM38714     1   0.000     0.9632 1.000 0.000
#> GSM38715     1   0.000     0.9632 1.000 0.000
#> GSM38716     1   0.000     0.9632 1.000 0.000
#> GSM38717     1   0.000     0.9632 1.000 0.000
#> GSM38718     1   0.000     0.9632 1.000 0.000
#> GSM38719     1   0.000     0.9632 1.000 0.000
#> GSM38720     1   0.000     0.9632 1.000 0.000
#> GSM38721     1   0.000     0.9632 1.000 0.000
#> GSM38722     1   0.000     0.9632 1.000 0.000
#> GSM38723     1   0.000     0.9632 1.000 0.000
#> GSM38724     1   0.000     0.9632 1.000 0.000
#> GSM38725     1   0.000     0.9632 1.000 0.000
#> GSM38726     1   0.000     0.9632 1.000 0.000
#> GSM38727     1   0.000     0.9632 1.000 0.000
#> GSM38728     1   0.000     0.9632 1.000 0.000
#> GSM38729     1   0.000     0.9632 1.000 0.000
#> GSM38730     1   0.000     0.9632 1.000 0.000
#> GSM38731     1   0.000     0.9632 1.000 0.000
#> GSM38732     1   0.000     0.9632 1.000 0.000
#> GSM38733     1   0.000     0.9632 1.000 0.000
#> GSM38734     2   0.995     0.2287 0.460 0.540
#> GSM38735     2   0.850     0.6343 0.276 0.724
#> GSM38736     2   0.000     0.8944 0.000 1.000
#> GSM38737     2   0.000     0.8944 0.000 1.000
#> GSM38738     1   0.343     0.9008 0.936 0.064
#> GSM38739     1   0.000     0.9632 1.000 0.000
#> GSM38740     1   0.949     0.3518 0.632 0.368
#> GSM38741     2   0.929     0.5274 0.344 0.656
#> GSM38742     2   0.000     0.8944 0.000 1.000
#> GSM38743     2   0.000     0.8944 0.000 1.000
#> GSM38744     1   0.000     0.9632 1.000 0.000
#> GSM38745     2   0.946     0.4786 0.364 0.636
#> GSM38746     1   0.327     0.9051 0.940 0.060
#> GSM38747     1   0.000     0.9632 1.000 0.000
#> GSM38748     2   0.000     0.8944 0.000 1.000
#> GSM38749     1   0.000     0.9632 1.000 0.000
#> GSM38750     1   0.615     0.7889 0.848 0.152
#> GSM38751     1   0.994     0.0276 0.544 0.456
#> GSM38752     2   0.204     0.8750 0.032 0.968
#> GSM38753     2   0.000     0.8944 0.000 1.000
#> GSM38754     2   0.000     0.8944 0.000 1.000
#> GSM38755     1   0.000     0.9632 1.000 0.000
#> GSM38756     2   0.000     0.8944 0.000 1.000
#> GSM38757     1   0.000     0.9632 1.000 0.000
#> GSM38758     2   0.000     0.8944 0.000 1.000
#> GSM38759     1   0.000     0.9632 1.000 0.000
#> GSM38760     1   0.000     0.9632 1.000 0.000
#> GSM38761     2   0.000     0.8944 0.000 1.000
#> GSM38762     2   0.000     0.8944 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
#> GSM38712     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38713     1  0.0237      0.914 0.996 0.000 0.004
#> GSM38714     1  0.3619      0.802 0.864 0.000 0.136
#> GSM38715     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38721     1  0.2878      0.841 0.904 0.000 0.096
#> GSM38722     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38724     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38725     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38728     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38729     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38732     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38733     1  0.0592      0.908 0.988 0.000 0.012
#> GSM38734     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38735     2  0.7412      0.670 0.176 0.700 0.124
#> GSM38736     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38738     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38739     1  0.5905      0.452 0.648 0.000 0.352
#> GSM38740     1  0.7915      0.457 0.644 0.248 0.108
#> GSM38741     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38742     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38744     1  0.0000      0.916 1.000 0.000 0.000
#> GSM38745     2  0.7365      0.670 0.188 0.700 0.112
#> GSM38746     3  0.2878      0.832 0.096 0.000 0.904
#> GSM38747     3  0.2959      0.828 0.100 0.000 0.900
#> GSM38748     3  0.4555      0.725 0.000 0.200 0.800
#> GSM38749     1  0.5905      0.452 0.648 0.000 0.352
#> GSM38750     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38751     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38752     3  0.3267      0.822 0.000 0.116 0.884
#> GSM38753     2  0.4346      0.755 0.000 0.816 0.184
#> GSM38754     3  0.3551      0.806 0.000 0.132 0.868
#> GSM38755     3  0.0592      0.903 0.012 0.000 0.988
#> GSM38756     2  0.4235      0.764 0.000 0.824 0.176
#> GSM38757     3  0.0000      0.910 0.000 0.000 1.000
#> GSM38758     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38759     3  0.6111      0.290 0.396 0.000 0.604
#> GSM38760     1  0.5905      0.452 0.648 0.000 0.352
#> GSM38761     2  0.0000      0.897 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.897 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38713     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38714     3  0.3801      0.675 0.220 0.000 0.780 0.000
#> GSM38715     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38721     3  0.4431      0.564 0.304 0.000 0.696 0.000
#> GSM38722     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38724     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38725     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38728     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38729     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.953 1.000 0.000 0.000 0.000
#> GSM38732     3  0.1474      0.868 0.000 0.000 0.948 0.052
#> GSM38733     1  0.1940      0.883 0.924 0.000 0.076 0.000
#> GSM38734     4  0.4406      0.677 0.000 0.000 0.300 0.700
#> GSM38735     2  0.0000      0.617 0.000 1.000 0.000 0.000
#> GSM38736     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38737     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38738     3  0.1474      0.868 0.000 0.000 0.948 0.052
#> GSM38739     1  0.3074      0.807 0.848 0.000 0.152 0.000
#> GSM38740     2  0.7188     -0.192 0.428 0.436 0.136 0.000
#> GSM38741     3  0.1940      0.837 0.000 0.000 0.924 0.076
#> GSM38742     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38743     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38744     1  0.4406      0.645 0.700 0.300 0.000 0.000
#> GSM38745     2  0.0000      0.617 0.000 1.000 0.000 0.000
#> GSM38746     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38747     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38748     4  0.3444      0.825 0.000 0.000 0.184 0.816
#> GSM38749     1  0.3074      0.807 0.848 0.000 0.152 0.000
#> GSM38750     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38751     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38752     4  0.3528      0.822 0.000 0.000 0.192 0.808
#> GSM38753     4  0.0707      0.663 0.000 0.020 0.000 0.980
#> GSM38754     4  0.3219      0.822 0.000 0.000 0.164 0.836
#> GSM38755     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38756     4  0.1557      0.618 0.000 0.056 0.000 0.944
#> GSM38757     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM38758     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38759     3  0.3074      0.747 0.152 0.000 0.848 0.000
#> GSM38760     1  0.3074      0.807 0.848 0.000 0.152 0.000
#> GSM38761     2  0.4406      0.800 0.000 0.700 0.000 0.300
#> GSM38762     2  0.4406      0.800 0.000 0.700 0.000 0.300

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1   p2    p3    p4 p5
#> GSM38712     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38713     1  0.0162      0.987 0.996 0.00 0.004 0.000  0
#> GSM38714     3  0.0162      0.956 0.004 0.00 0.996 0.000  0
#> GSM38715     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38716     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38717     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38718     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38719     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38720     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38721     3  0.2179      0.837 0.112 0.00 0.888 0.000  0
#> GSM38722     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38723     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38724     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38725     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38726     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38727     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38728     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38729     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38730     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38731     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38732     3  0.1908      0.902 0.000 0.00 0.908 0.092  0
#> GSM38733     1  0.2424      0.827 0.868 0.00 0.132 0.000  0
#> GSM38734     4  0.0000      0.886 0.000 0.00 0.000 1.000  0
#> GSM38735     5  0.0000      1.000 0.000 0.00 0.000 0.000  1
#> GSM38736     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38737     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38738     3  0.1908      0.902 0.000 0.00 0.908 0.092  0
#> GSM38739     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38740     5  0.0000      1.000 0.000 0.00 0.000 0.000  1
#> GSM38741     3  0.3039      0.781 0.000 0.00 0.808 0.192  0
#> GSM38742     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38743     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38744     5  0.0000      1.000 0.000 0.00 0.000 0.000  1
#> GSM38745     5  0.0000      1.000 0.000 0.00 0.000 0.000  1
#> GSM38746     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38747     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38748     4  0.1732      0.881 0.000 0.08 0.000 0.920  0
#> GSM38749     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38750     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38751     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38752     4  0.0000      0.886 0.000 0.00 0.000 1.000  0
#> GSM38753     4  0.3109      0.820 0.000 0.20 0.000 0.800  0
#> GSM38754     4  0.0000      0.886 0.000 0.00 0.000 1.000  0
#> GSM38755     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38756     4  0.3109      0.820 0.000 0.20 0.000 0.800  0
#> GSM38757     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38758     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38759     3  0.0000      0.959 0.000 0.00 1.000 0.000  0
#> GSM38760     1  0.0000      0.991 1.000 0.00 0.000 0.000  0
#> GSM38761     2  0.0000      1.000 0.000 1.00 0.000 0.000  0
#> GSM38762     2  0.0000      1.000 0.000 1.00 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM38712     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38713     6  0.0260      0.992 0.008 0.000 0.000 0.000  0 0.992
#> GSM38714     6  0.0260      0.993 0.000 0.000 0.008 0.000  0 0.992
#> GSM38715     6  0.0260      0.992 0.008 0.000 0.000 0.000  0 0.992
#> GSM38716     1  0.3076      0.677 0.760 0.000 0.000 0.000  0 0.240
#> GSM38717     1  0.3672      0.453 0.632 0.000 0.000 0.000  0 0.368
#> GSM38718     6  0.0260      0.992 0.008 0.000 0.000 0.000  0 0.992
#> GSM38719     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38720     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38721     6  0.0260      0.993 0.000 0.000 0.008 0.000  0 0.992
#> GSM38722     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38723     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38724     6  0.0363      0.990 0.000 0.000 0.012 0.000  0 0.988
#> GSM38725     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38726     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38727     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38728     6  0.0260      0.993 0.000 0.000 0.008 0.000  0 0.992
#> GSM38729     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38730     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38731     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38732     3  0.2595      0.794 0.000 0.000 0.836 0.004  0 0.160
#> GSM38733     6  0.0260      0.992 0.008 0.000 0.000 0.000  0 0.992
#> GSM38734     4  0.0000      0.841 0.000 0.000 0.000 1.000  0 0.000
#> GSM38735     5  0.0000      1.000 0.000 0.000 0.000 0.000  1 0.000
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38738     3  0.0146      0.941 0.000 0.000 0.996 0.004  0 0.000
#> GSM38739     3  0.0260      0.935 0.008 0.000 0.992 0.000  0 0.000
#> GSM38740     5  0.0000      1.000 0.000 0.000 0.000 0.000  1 0.000
#> GSM38741     4  0.3244      0.584 0.000 0.000 0.268 0.732  0 0.000
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38744     5  0.0000      1.000 0.000 0.000 0.000 0.000  1 0.000
#> GSM38745     5  0.0000      1.000 0.000 0.000 0.000 0.000  1 0.000
#> GSM38746     3  0.0000      0.942 0.000 0.000 1.000 0.000  0 0.000
#> GSM38747     3  0.2730      0.738 0.000 0.000 0.808 0.000  0 0.192
#> GSM38748     4  0.2257      0.831 0.000 0.116 0.000 0.876  0 0.008
#> GSM38749     1  0.3737      0.355 0.608 0.000 0.392 0.000  0 0.000
#> GSM38750     3  0.0000      0.942 0.000 0.000 1.000 0.000  0 0.000
#> GSM38751     3  0.0000      0.942 0.000 0.000 1.000 0.000  0 0.000
#> GSM38752     4  0.0000      0.841 0.000 0.000 0.000 1.000  0 0.000
#> GSM38753     4  0.3043      0.784 0.000 0.200 0.000 0.792  0 0.008
#> GSM38754     4  0.0000      0.841 0.000 0.000 0.000 1.000  0 0.000
#> GSM38755     3  0.0000      0.942 0.000 0.000 1.000 0.000  0 0.000
#> GSM38756     4  0.3043      0.784 0.000 0.200 0.000 0.792  0 0.008
#> GSM38757     3  0.0000      0.942 0.000 0.000 1.000 0.000  0 0.000
#> GSM38758     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38759     6  0.0260      0.993 0.000 0.000 0.008 0.000  0 0.992
#> GSM38760     1  0.0000      0.918 1.000 0.000 0.000 0.000  0 0.000
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 individual(p) k
#> MAD:pam 47      0.045619 2
#> MAD:pam 46      0.003165 3
#> MAD:pam 50      0.017650 4
#> MAD:pam 51      0.003717 5
#> MAD:pam 49      0.000743 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 19411 rows and 51 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 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-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 1.000           0.949       0.981         0.4650 0.534   0.534
#> 3 3 0.746           0.900       0.925         0.3586 0.654   0.434
#> 4 4 0.866           0.907       0.954         0.1468 0.939   0.821
#> 5 5 0.771           0.574       0.820         0.0906 0.929   0.749
#> 6 6 0.818           0.756       0.825         0.0405 0.896   0.574

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
#> GSM38712     1   0.000      0.985 1.000 0.000
#> GSM38713     1   0.000      0.985 1.000 0.000
#> GSM38714     1   0.000      0.985 1.000 0.000
#> GSM38715     1   0.000      0.985 1.000 0.000
#> GSM38716     1   0.000      0.985 1.000 0.000
#> GSM38717     1   0.000      0.985 1.000 0.000
#> GSM38718     1   0.000      0.985 1.000 0.000
#> GSM38719     1   0.000      0.985 1.000 0.000
#> GSM38720     1   0.000      0.985 1.000 0.000
#> GSM38721     1   0.000      0.985 1.000 0.000
#> GSM38722     1   0.000      0.985 1.000 0.000
#> GSM38723     1   0.000      0.985 1.000 0.000
#> GSM38724     1   0.000      0.985 1.000 0.000
#> GSM38725     1   0.000      0.985 1.000 0.000
#> GSM38726     1   0.000      0.985 1.000 0.000
#> GSM38727     1   0.000      0.985 1.000 0.000
#> GSM38728     1   0.000      0.985 1.000 0.000
#> GSM38729     1   0.995      0.091 0.540 0.460
#> GSM38730     1   0.000      0.985 1.000 0.000
#> GSM38731     1   0.000      0.985 1.000 0.000
#> GSM38732     1   0.000      0.985 1.000 0.000
#> GSM38733     1   0.000      0.985 1.000 0.000
#> GSM38734     2   0.184      0.954 0.028 0.972
#> GSM38735     2   0.000      0.970 0.000 1.000
#> GSM38736     2   0.000      0.970 0.000 1.000
#> GSM38737     2   0.000      0.970 0.000 1.000
#> GSM38738     1   0.000      0.985 1.000 0.000
#> GSM38739     1   0.000      0.985 1.000 0.000
#> GSM38740     2   0.000      0.970 0.000 1.000
#> GSM38741     1   0.000      0.985 1.000 0.000
#> GSM38742     2   0.000      0.970 0.000 1.000
#> GSM38743     2   0.000      0.970 0.000 1.000
#> GSM38744     2   0.000      0.970 0.000 1.000
#> GSM38745     2   0.000      0.970 0.000 1.000
#> GSM38746     1   0.000      0.985 1.000 0.000
#> GSM38747     1   0.000      0.985 1.000 0.000
#> GSM38748     2   0.184      0.954 0.028 0.972
#> GSM38749     1   0.000      0.985 1.000 0.000
#> GSM38750     1   0.000      0.985 1.000 0.000
#> GSM38751     1   0.000      0.985 1.000 0.000
#> GSM38752     2   0.141      0.960 0.020 0.980
#> GSM38753     2   0.000      0.970 0.000 1.000
#> GSM38754     2   0.141      0.960 0.020 0.980
#> GSM38755     1   0.000      0.985 1.000 0.000
#> GSM38756     2   0.000      0.970 0.000 1.000
#> GSM38757     1   0.000      0.985 1.000 0.000
#> GSM38758     2   0.000      0.970 0.000 1.000
#> GSM38759     2   0.969      0.338 0.396 0.604
#> GSM38760     1   0.000      0.985 1.000 0.000
#> GSM38761     2   0.000      0.970 0.000 1.000
#> GSM38762     2   0.000      0.970 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
#> GSM38712     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38720     1  0.0237      0.990 0.996 0.000 0.004
#> GSM38721     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38722     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38724     3  0.6215      0.529 0.428 0.000 0.572
#> GSM38725     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38728     1  0.1753      0.950 0.952 0.000 0.048
#> GSM38729     1  0.1015      0.975 0.980 0.008 0.012
#> GSM38730     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38732     3  0.5216      0.810 0.260 0.000 0.740
#> GSM38733     1  0.0000      0.993 1.000 0.000 0.000
#> GSM38734     3  0.0424      0.745 0.000 0.008 0.992
#> GSM38735     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38736     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38737     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38738     3  0.5138      0.813 0.252 0.000 0.748
#> GSM38739     3  0.4931      0.819 0.232 0.000 0.768
#> GSM38740     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38741     3  0.1643      0.773 0.044 0.000 0.956
#> GSM38742     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38743     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38744     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38745     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38746     3  0.5216      0.810 0.260 0.000 0.740
#> GSM38747     3  0.5254      0.807 0.264 0.000 0.736
#> GSM38748     3  0.4452      0.588 0.000 0.192 0.808
#> GSM38749     3  0.4931      0.819 0.232 0.000 0.768
#> GSM38750     3  0.5178      0.812 0.256 0.000 0.744
#> GSM38751     3  0.2537      0.790 0.080 0.000 0.920
#> GSM38752     3  0.0424      0.745 0.000 0.008 0.992
#> GSM38753     3  0.4654      0.567 0.000 0.208 0.792
#> GSM38754     3  0.0424      0.745 0.000 0.008 0.992
#> GSM38755     3  0.5254      0.807 0.264 0.000 0.736
#> GSM38756     3  0.4654      0.567 0.000 0.208 0.792
#> GSM38757     3  0.4931      0.819 0.232 0.000 0.768
#> GSM38758     2  0.0237      0.997 0.000 0.996 0.004
#> GSM38759     1  0.2063      0.947 0.948 0.008 0.044
#> GSM38760     3  0.5254      0.807 0.264 0.000 0.736
#> GSM38761     2  0.0000      1.000 0.000 1.000 0.000
#> GSM38762     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38713     1  0.2868      0.846 0.864 0.000 0.000 0.136
#> GSM38714     1  0.3219      0.822 0.836 0.000 0.000 0.164
#> GSM38715     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38721     1  0.2868      0.846 0.864 0.000 0.000 0.136
#> GSM38722     1  0.0188      0.930 0.996 0.000 0.004 0.000
#> GSM38723     1  0.0188      0.930 0.996 0.000 0.004 0.000
#> GSM38724     3  0.0188      0.970 0.004 0.000 0.996 0.000
#> GSM38725     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0188      0.930 0.996 0.000 0.004 0.000
#> GSM38728     1  0.6595      0.563 0.628 0.000 0.160 0.212
#> GSM38729     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.933 1.000 0.000 0.000 0.000
#> GSM38732     3  0.4446      0.654 0.196 0.000 0.776 0.028
#> GSM38733     1  0.5722      0.690 0.716 0.000 0.148 0.136
#> GSM38734     4  0.1792      0.868 0.000 0.000 0.068 0.932
#> GSM38735     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38736     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38738     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38739     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38740     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38741     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38742     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38744     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38745     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38746     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38747     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38748     4  0.2706      0.864 0.000 0.020 0.080 0.900
#> GSM38749     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38750     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38751     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38752     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> GSM38753     4  0.3610      0.784 0.000 0.200 0.000 0.800
#> GSM38754     4  0.0000      0.879 0.000 0.000 0.000 1.000
#> GSM38755     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38756     4  0.3610      0.784 0.000 0.200 0.000 0.800
#> GSM38757     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38758     2  0.4008      0.630 0.000 0.756 0.000 0.244
#> GSM38759     1  0.3726      0.771 0.788 0.000 0.000 0.212
#> GSM38760     3  0.0000      0.974 0.000 0.000 1.000 0.000
#> GSM38761     2  0.0000      0.972 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0000      0.972 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.4161    -0.4029 0.608 0.000 0.000 0.000 0.392
#> GSM38713     5  0.4171    -0.2328 0.396 0.000 0.000 0.000 0.604
#> GSM38714     1  0.4045     0.3717 0.644 0.000 0.000 0.000 0.356
#> GSM38715     5  0.4201     0.0216 0.408 0.000 0.000 0.000 0.592
#> GSM38716     1  0.4171    -0.4123 0.604 0.000 0.000 0.000 0.396
#> GSM38717     1  0.0000     0.2482 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.3366     0.3410 0.768 0.000 0.000 0.000 0.232
#> GSM38719     1  0.3837    -0.2942 0.692 0.000 0.000 0.000 0.308
#> GSM38720     1  0.0000     0.2482 1.000 0.000 0.000 0.000 0.000
#> GSM38721     1  0.4114     0.3684 0.624 0.000 0.000 0.000 0.376
#> GSM38722     5  0.4291     0.5769 0.464 0.000 0.000 0.000 0.536
#> GSM38723     5  0.4291     0.5769 0.464 0.000 0.000 0.000 0.536
#> GSM38724     3  0.6582     0.5834 0.092 0.000 0.628 0.120 0.160
#> GSM38725     5  0.4307     0.5347 0.496 0.000 0.000 0.000 0.504
#> GSM38726     1  0.4192    -0.4247 0.596 0.000 0.000 0.000 0.404
#> GSM38727     5  0.4291     0.5769 0.464 0.000 0.000 0.000 0.536
#> GSM38728     1  0.4225     0.3696 0.632 0.000 0.004 0.000 0.364
#> GSM38729     1  0.0000     0.2482 1.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.4192    -0.4242 0.596 0.000 0.000 0.000 0.404
#> GSM38731     1  0.3966    -0.3250 0.664 0.000 0.000 0.000 0.336
#> GSM38732     3  0.6101     0.6065 0.156 0.000 0.664 0.124 0.056
#> GSM38733     1  0.4126     0.3663 0.620 0.000 0.000 0.000 0.380
#> GSM38734     4  0.0000     0.9096 0.000 0.000 0.000 1.000 0.000
#> GSM38735     2  0.2127     0.9120 0.000 0.892 0.000 0.000 0.108
#> GSM38736     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000
#> GSM38738     3  0.1121     0.9176 0.000 0.000 0.956 0.000 0.044
#> GSM38739     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38740     2  0.2127     0.9120 0.000 0.892 0.000 0.000 0.108
#> GSM38741     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38742     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000
#> GSM38744     2  0.2127     0.9120 0.000 0.892 0.000 0.000 0.108
#> GSM38745     2  0.2127     0.9120 0.000 0.892 0.000 0.000 0.108
#> GSM38746     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38747     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38748     4  0.0162     0.9091 0.000 0.004 0.000 0.996 0.000
#> GSM38749     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38750     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38751     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38752     4  0.0000     0.9096 0.000 0.000 0.000 1.000 0.000
#> GSM38753     4  0.3109     0.7837 0.000 0.200 0.000 0.800 0.000
#> GSM38754     4  0.0000     0.9096 0.000 0.000 0.000 1.000 0.000
#> GSM38755     3  0.1121     0.9176 0.000 0.000 0.956 0.000 0.044
#> GSM38756     4  0.3109     0.7837 0.000 0.200 0.000 0.800 0.000
#> GSM38757     3  0.0000     0.9333 0.000 0.000 1.000 0.000 0.000
#> GSM38758     2  0.3210     0.6785 0.000 0.788 0.000 0.212 0.000
#> GSM38759     1  0.4045     0.3717 0.644 0.000 0.000 0.000 0.356
#> GSM38760     3  0.1121     0.9176 0.000 0.000 0.956 0.000 0.044
#> GSM38761     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.2219     0.7600 0.864 0.000 0.000 0.000 0.000 0.136
#> GSM38713     6  0.2762     0.6854 0.196 0.000 0.000 0.000 0.000 0.804
#> GSM38714     6  0.1444     0.7551 0.072 0.000 0.000 0.000 0.000 0.928
#> GSM38715     6  0.3838     0.1772 0.448 0.000 0.000 0.000 0.000 0.552
#> GSM38716     1  0.2092     0.7660 0.876 0.000 0.000 0.000 0.000 0.124
#> GSM38717     6  0.3330     0.6667 0.284 0.000 0.000 0.000 0.000 0.716
#> GSM38718     6  0.2912     0.7181 0.216 0.000 0.000 0.000 0.000 0.784
#> GSM38719     1  0.3868    -0.1550 0.508 0.000 0.000 0.000 0.000 0.492
#> GSM38720     6  0.3330     0.6667 0.284 0.000 0.000 0.000 0.000 0.716
#> GSM38721     6  0.1501     0.7551 0.076 0.000 0.000 0.000 0.000 0.924
#> GSM38722     1  0.0000     0.7819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0000     0.7819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38724     3  0.5108     0.7847 0.000 0.264 0.620 0.004 0.000 0.112
#> GSM38725     1  0.1267     0.8019 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM38726     1  0.1663     0.7946 0.912 0.000 0.000 0.000 0.000 0.088
#> GSM38727     1  0.0000     0.7819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38728     6  0.3503     0.5723 0.000 0.020 0.012 0.180 0.000 0.788
#> GSM38729     6  0.3330     0.6667 0.284 0.000 0.000 0.000 0.000 0.716
#> GSM38730     1  0.1267     0.8019 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM38731     1  0.3847    -0.0252 0.544 0.000 0.000 0.000 0.000 0.456
#> GSM38732     3  0.6011     0.6948 0.000 0.264 0.532 0.184 0.000 0.020
#> GSM38733     6  0.0458     0.7313 0.016 0.000 0.000 0.000 0.000 0.984
#> GSM38734     4  0.0820     0.8719 0.000 0.016 0.000 0.972 0.000 0.012
#> GSM38735     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM38736     2  0.3756     0.8674 0.000 0.600 0.000 0.000 0.400 0.000
#> GSM38737     2  0.3756     0.8674 0.000 0.600 0.000 0.000 0.400 0.000
#> GSM38738     3  0.3905     0.8312 0.000 0.264 0.712 0.012 0.000 0.012
#> GSM38739     3  0.0000     0.8283 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38740     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM38741     3  0.4822     0.8081 0.000 0.264 0.656 0.068 0.000 0.012
#> GSM38742     2  0.3717     0.8620 0.000 0.616 0.000 0.000 0.384 0.000
#> GSM38743     2  0.3756     0.8674 0.000 0.600 0.000 0.000 0.400 0.000
#> GSM38744     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM38745     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM38746     3  0.0000     0.8283 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38747     3  0.3360     0.8363 0.000 0.264 0.732 0.004 0.000 0.000
#> GSM38748     4  0.2454     0.8840 0.000 0.160 0.000 0.840 0.000 0.000
#> GSM38749     3  0.0000     0.8283 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38750     3  0.0547     0.8320 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM38751     3  0.0000     0.8283 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38752     4  0.0000     0.8877 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38753     4  0.2793     0.8690 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM38754     4  0.0000     0.8877 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38755     3  0.4152     0.8316 0.024 0.264 0.700 0.000 0.000 0.012
#> GSM38756     4  0.2793     0.8690 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM38757     3  0.3360     0.8363 0.000 0.264 0.732 0.004 0.000 0.000
#> GSM38758     2  0.3617     0.3247 0.000 0.736 0.000 0.244 0.020 0.000
#> GSM38759     6  0.0909     0.7251 0.012 0.000 0.000 0.020 0.000 0.968
#> GSM38760     3  0.1267     0.7983 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38761     2  0.3717     0.8620 0.000 0.616 0.000 0.000 0.384 0.000
#> GSM38762     2  0.3756     0.8674 0.000 0.600 0.000 0.000 0.400 0.000

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

consensus_heatmap(res, k = 2)

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.918           0.908       0.964         0.4396 0.561   0.561
#> 3 3 0.937           0.908       0.961         0.3574 0.772   0.618
#> 4 4 0.855           0.862       0.936         0.2510 0.807   0.549
#> 5 5 0.777           0.691       0.871         0.0327 0.890   0.641
#> 6 6 0.694           0.658       0.837         0.0305 0.975   0.900

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
#> GSM38712     1  0.0000      0.968 1.000 0.000
#> GSM38713     1  0.0000      0.968 1.000 0.000
#> GSM38714     1  0.0000      0.968 1.000 0.000
#> GSM38715     1  0.0000      0.968 1.000 0.000
#> GSM38716     1  0.0000      0.968 1.000 0.000
#> GSM38717     1  0.0000      0.968 1.000 0.000
#> GSM38718     1  0.0000      0.968 1.000 0.000
#> GSM38719     1  0.0000      0.968 1.000 0.000
#> GSM38720     1  0.0000      0.968 1.000 0.000
#> GSM38721     1  0.0000      0.968 1.000 0.000
#> GSM38722     1  0.0000      0.968 1.000 0.000
#> GSM38723     1  0.0000      0.968 1.000 0.000
#> GSM38724     1  0.0000      0.968 1.000 0.000
#> GSM38725     1  0.0000      0.968 1.000 0.000
#> GSM38726     1  0.0000      0.968 1.000 0.000
#> GSM38727     1  0.0000      0.968 1.000 0.000
#> GSM38728     1  0.9710      0.313 0.600 0.400
#> GSM38729     1  0.0000      0.968 1.000 0.000
#> GSM38730     1  0.0000      0.968 1.000 0.000
#> GSM38731     1  0.0000      0.968 1.000 0.000
#> GSM38732     2  0.9393      0.432 0.356 0.644
#> GSM38733     1  0.0000      0.968 1.000 0.000
#> GSM38734     2  0.0000      0.942 0.000 1.000
#> GSM38735     1  0.0938      0.959 0.988 0.012
#> GSM38736     2  0.0000      0.942 0.000 1.000
#> GSM38737     2  0.0000      0.942 0.000 1.000
#> GSM38738     2  0.9954      0.118 0.460 0.540
#> GSM38739     1  0.0000      0.968 1.000 0.000
#> GSM38740     1  0.0000      0.968 1.000 0.000
#> GSM38741     2  0.0000      0.942 0.000 1.000
#> GSM38742     2  0.0000      0.942 0.000 1.000
#> GSM38743     2  0.0000      0.942 0.000 1.000
#> GSM38744     1  0.0000      0.968 1.000 0.000
#> GSM38745     1  0.0000      0.968 1.000 0.000
#> GSM38746     1  0.0672      0.962 0.992 0.008
#> GSM38747     1  0.6438      0.793 0.836 0.164
#> GSM38748     2  0.0000      0.942 0.000 1.000
#> GSM38749     1  0.0000      0.968 1.000 0.000
#> GSM38750     1  0.4298      0.888 0.912 0.088
#> GSM38751     1  0.8499      0.610 0.724 0.276
#> GSM38752     2  0.0000      0.942 0.000 1.000
#> GSM38753     2  0.0000      0.942 0.000 1.000
#> GSM38754     2  0.0000      0.942 0.000 1.000
#> GSM38755     1  0.0000      0.968 1.000 0.000
#> GSM38756     2  0.0000      0.942 0.000 1.000
#> GSM38757     1  0.3274      0.917 0.940 0.060
#> GSM38758     2  0.0000      0.942 0.000 1.000
#> GSM38759     1  0.0000      0.968 1.000 0.000
#> GSM38760     1  0.0000      0.968 1.000 0.000
#> GSM38761     2  0.0000      0.942 0.000 1.000
#> GSM38762     2  0.0000      0.942 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
#> GSM38712     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38713     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38716     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38717     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38721     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38722     1  0.0747      0.961 0.984 0.016 0.000
#> GSM38723     1  0.0592      0.963 0.988 0.012 0.000
#> GSM38724     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38725     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38726     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38727     1  0.0592      0.963 0.988 0.012 0.000
#> GSM38728     3  0.2165      0.870 0.064 0.000 0.936
#> GSM38729     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38730     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38731     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38732     3  0.1529      0.893 0.040 0.000 0.960
#> GSM38733     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38734     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38735     2  0.0000      0.950 0.000 1.000 0.000
#> GSM38736     2  0.1031      0.957 0.000 0.976 0.024
#> GSM38737     2  0.1031      0.957 0.000 0.976 0.024
#> GSM38738     3  0.1031      0.906 0.024 0.000 0.976
#> GSM38739     1  0.0592      0.963 0.988 0.012 0.000
#> GSM38740     2  0.0747      0.942 0.016 0.984 0.000
#> GSM38741     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38742     2  0.1411      0.952 0.000 0.964 0.036
#> GSM38743     2  0.1031      0.957 0.000 0.976 0.024
#> GSM38744     2  0.1411      0.923 0.036 0.964 0.000
#> GSM38745     2  0.0000      0.950 0.000 1.000 0.000
#> GSM38746     1  0.2564      0.926 0.936 0.036 0.028
#> GSM38747     1  0.4399      0.766 0.812 0.000 0.188
#> GSM38748     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38749     1  0.0424      0.965 0.992 0.008 0.000
#> GSM38750     1  0.6215      0.213 0.572 0.000 0.428
#> GSM38751     1  0.3918      0.850 0.868 0.012 0.120
#> GSM38752     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38753     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38754     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38755     1  0.0000      0.967 1.000 0.000 0.000
#> GSM38756     3  0.0000      0.918 0.000 0.000 1.000
#> GSM38757     3  0.6274      0.136 0.456 0.000 0.544
#> GSM38758     2  0.5178      0.691 0.000 0.744 0.256
#> GSM38759     1  0.0424      0.962 0.992 0.000 0.008
#> GSM38760     1  0.0237      0.967 0.996 0.004 0.000
#> GSM38761     2  0.1753      0.945 0.000 0.952 0.048
#> GSM38762     2  0.1031      0.957 0.000 0.976 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.2345      0.859 0.900 0.000 0.100 0.000
#> GSM38713     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38714     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38715     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38716     1  0.2281      0.862 0.904 0.000 0.096 0.000
#> GSM38717     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38721     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38722     3  0.2868      0.798 0.136 0.000 0.864 0.000
#> GSM38723     3  0.0707      0.918 0.020 0.000 0.980 0.000
#> GSM38724     1  0.7676      0.271 0.452 0.000 0.240 0.308
#> GSM38725     1  0.3975      0.714 0.760 0.000 0.240 0.000
#> GSM38726     1  0.2589      0.848 0.884 0.000 0.116 0.000
#> GSM38727     3  0.0921      0.912 0.028 0.000 0.972 0.000
#> GSM38728     1  0.4933      0.292 0.568 0.000 0.000 0.432
#> GSM38729     1  0.0188      0.904 0.996 0.000 0.004 0.000
#> GSM38730     1  0.3486      0.782 0.812 0.000 0.188 0.000
#> GSM38731     1  0.0817      0.897 0.976 0.000 0.024 0.000
#> GSM38732     4  0.1302      0.947 0.044 0.000 0.000 0.956
#> GSM38733     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38734     4  0.0000      0.987 0.000 0.000 0.000 1.000
#> GSM38735     2  0.0336      0.926 0.000 0.992 0.008 0.000
#> GSM38736     2  0.0000      0.929 0.000 1.000 0.000 0.000
#> GSM38737     2  0.0000      0.929 0.000 1.000 0.000 0.000
#> GSM38738     4  0.0469      0.982 0.000 0.000 0.012 0.988
#> GSM38739     3  0.0000      0.924 0.000 0.000 1.000 0.000
#> GSM38740     2  0.5536      0.389 0.024 0.592 0.384 0.000
#> GSM38741     4  0.0592      0.979 0.000 0.000 0.016 0.984
#> GSM38742     2  0.0000      0.929 0.000 1.000 0.000 0.000
#> GSM38743     2  0.0000      0.929 0.000 1.000 0.000 0.000
#> GSM38744     2  0.4996      0.708 0.056 0.752 0.192 0.000
#> GSM38745     2  0.1022      0.913 0.000 0.968 0.032 0.000
#> GSM38746     3  0.0000      0.924 0.000 0.000 1.000 0.000
#> GSM38747     3  0.2266      0.871 0.004 0.000 0.912 0.084
#> GSM38748     4  0.0000      0.987 0.000 0.000 0.000 1.000
#> GSM38749     3  0.0000      0.924 0.000 0.000 1.000 0.000
#> GSM38750     3  0.1118      0.909 0.000 0.000 0.964 0.036
#> GSM38751     3  0.0336      0.922 0.000 0.000 0.992 0.008
#> GSM38752     4  0.0188      0.987 0.000 0.004 0.000 0.996
#> GSM38753     4  0.0336      0.986 0.000 0.008 0.000 0.992
#> GSM38754     4  0.0188      0.987 0.000 0.004 0.000 0.996
#> GSM38755     3  0.0188      0.924 0.000 0.000 0.996 0.004
#> GSM38756     4  0.0336      0.986 0.000 0.008 0.000 0.992
#> GSM38757     3  0.4898      0.287 0.000 0.000 0.584 0.416
#> GSM38758     2  0.0336      0.924 0.000 0.992 0.000 0.008
#> GSM38759     1  0.0000      0.905 1.000 0.000 0.000 0.000
#> GSM38760     3  0.0188      0.924 0.004 0.000 0.996 0.000
#> GSM38761     2  0.0000      0.929 0.000 1.000 0.000 0.000
#> GSM38762     2  0.0000      0.929 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.1106     0.8100 0.964 0.000 0.024 0.000 0.012
#> GSM38713     1  0.4074     0.3642 0.636 0.000 0.000 0.000 0.364
#> GSM38714     1  0.0794     0.8091 0.972 0.000 0.000 0.000 0.028
#> GSM38715     1  0.2424     0.7382 0.868 0.000 0.000 0.000 0.132
#> GSM38716     1  0.1331     0.8065 0.952 0.000 0.040 0.000 0.008
#> GSM38717     1  0.0451     0.8130 0.988 0.000 0.004 0.000 0.008
#> GSM38718     1  0.1544     0.7903 0.932 0.000 0.000 0.000 0.068
#> GSM38719     1  0.0404     0.8124 0.988 0.000 0.000 0.000 0.012
#> GSM38720     1  0.0609     0.8113 0.980 0.000 0.000 0.000 0.020
#> GSM38721     1  0.0324     0.8135 0.992 0.000 0.004 0.000 0.004
#> GSM38722     1  0.4425     0.3733 0.600 0.000 0.392 0.000 0.008
#> GSM38723     3  0.1410     0.8134 0.060 0.000 0.940 0.000 0.000
#> GSM38724     1  0.4911     0.6260 0.736 0.000 0.132 0.124 0.008
#> GSM38725     1  0.4042     0.6452 0.756 0.000 0.212 0.000 0.032
#> GSM38726     1  0.1478     0.7987 0.936 0.000 0.064 0.000 0.000
#> GSM38727     3  0.2179     0.7498 0.112 0.000 0.888 0.000 0.000
#> GSM38728     4  0.5414     0.1119 0.412 0.000 0.000 0.528 0.060
#> GSM38729     1  0.0162     0.8133 0.996 0.000 0.000 0.000 0.004
#> GSM38730     1  0.1469     0.8056 0.948 0.000 0.036 0.000 0.016
#> GSM38731     1  0.0992     0.8132 0.968 0.000 0.008 0.000 0.024
#> GSM38732     5  0.2423     0.3286 0.024 0.000 0.000 0.080 0.896
#> GSM38733     5  0.3932     0.2585 0.328 0.000 0.000 0.000 0.672
#> GSM38734     4  0.4305     0.2026 0.000 0.000 0.000 0.512 0.488
#> GSM38735     2  0.1341     0.9317 0.000 0.944 0.000 0.000 0.056
#> GSM38736     2  0.0000     0.9597 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000     0.9597 0.000 1.000 0.000 0.000 0.000
#> GSM38738     5  0.6191    -0.1392 0.000 0.000 0.424 0.136 0.440
#> GSM38739     3  0.0000     0.8567 0.000 0.000 1.000 0.000 0.000
#> GSM38740     1  0.7324     0.1071 0.432 0.372 0.124 0.000 0.072
#> GSM38741     4  0.1478     0.7231 0.000 0.000 0.064 0.936 0.000
#> GSM38742     2  0.0000     0.9597 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000     0.9597 0.000 1.000 0.000 0.000 0.000
#> GSM38744     1  0.5949     0.0718 0.472 0.444 0.012 0.000 0.072
#> GSM38745     2  0.2429     0.9007 0.020 0.904 0.008 0.000 0.068
#> GSM38746     3  0.0451     0.8537 0.000 0.000 0.988 0.004 0.008
#> GSM38747     3  0.3636     0.5472 0.000 0.000 0.728 0.272 0.000
#> GSM38748     4  0.3003     0.6625 0.000 0.000 0.000 0.812 0.188
#> GSM38749     3  0.0000     0.8567 0.000 0.000 1.000 0.000 0.000
#> GSM38750     3  0.0955     0.8426 0.000 0.000 0.968 0.004 0.028
#> GSM38751     3  0.0000     0.8567 0.000 0.000 1.000 0.000 0.000
#> GSM38752     4  0.0404     0.7678 0.000 0.000 0.000 0.988 0.012
#> GSM38753     4  0.0290     0.7652 0.000 0.008 0.000 0.992 0.000
#> GSM38754     4  0.0898     0.7648 0.000 0.008 0.000 0.972 0.020
#> GSM38755     3  0.4182     0.2314 0.000 0.000 0.600 0.000 0.400
#> GSM38756     4  0.0290     0.7672 0.000 0.000 0.000 0.992 0.008
#> GSM38757     3  0.3532     0.7296 0.000 0.000 0.824 0.048 0.128
#> GSM38758     2  0.2690     0.8037 0.000 0.844 0.000 0.156 0.000
#> GSM38759     1  0.1571     0.7943 0.936 0.000 0.000 0.004 0.060
#> GSM38760     3  0.0000     0.8567 0.000 0.000 1.000 0.000 0.000
#> GSM38761     2  0.0000     0.9597 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0162     0.9583 0.000 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.1267      0.796 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM38713     1  0.4012      0.608 0.748 0.000 0.000 0.000 0.076 0.176
#> GSM38714     1  0.0717      0.797 0.976 0.000 0.000 0.000 0.008 0.016
#> GSM38715     1  0.2119      0.781 0.904 0.000 0.000 0.000 0.036 0.060
#> GSM38716     1  0.1408      0.796 0.944 0.000 0.020 0.000 0.000 0.036
#> GSM38717     1  0.0458      0.799 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38718     1  0.2300      0.735 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM38719     1  0.0363      0.798 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM38720     1  0.1007      0.790 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM38721     1  0.0790      0.798 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM38722     1  0.3943      0.657 0.756 0.000 0.184 0.000 0.004 0.056
#> GSM38723     3  0.2810      0.736 0.156 0.000 0.832 0.000 0.004 0.008
#> GSM38724     1  0.4616      0.681 0.756 0.000 0.028 0.084 0.012 0.120
#> GSM38725     1  0.5769      0.462 0.608 0.000 0.216 0.000 0.040 0.136
#> GSM38726     1  0.2249      0.779 0.900 0.000 0.064 0.000 0.004 0.032
#> GSM38727     3  0.3430      0.662 0.208 0.000 0.772 0.000 0.004 0.016
#> GSM38728     4  0.6489     -0.225 0.292 0.000 0.000 0.400 0.020 0.288
#> GSM38729     1  0.1501      0.791 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM38730     1  0.1418      0.798 0.944 0.000 0.024 0.000 0.000 0.032
#> GSM38731     1  0.3114      0.740 0.832 0.000 0.036 0.000 0.004 0.128
#> GSM38732     5  0.4093     -0.395 0.004 0.000 0.000 0.004 0.552 0.440
#> GSM38733     6  0.5438      0.000 0.148 0.000 0.000 0.000 0.304 0.548
#> GSM38734     5  0.1720      0.402 0.000 0.000 0.000 0.032 0.928 0.040
#> GSM38735     2  0.2994      0.760 0.004 0.788 0.000 0.000 0.000 0.208
#> GSM38736     2  0.0000      0.901 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.901 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     5  0.3014      0.490 0.000 0.000 0.184 0.012 0.804 0.000
#> GSM38739     3  0.0692      0.842 0.000 0.000 0.976 0.000 0.004 0.020
#> GSM38740     1  0.7155      0.126 0.396 0.148 0.132 0.000 0.000 0.324
#> GSM38741     4  0.0935      0.748 0.000 0.000 0.032 0.964 0.000 0.004
#> GSM38742     2  0.0146      0.900 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM38743     2  0.0000      0.901 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     1  0.6551      0.206 0.448 0.184 0.044 0.000 0.000 0.324
#> GSM38745     2  0.4501      0.626 0.012 0.660 0.036 0.000 0.000 0.292
#> GSM38746     3  0.1806      0.806 0.000 0.000 0.908 0.004 0.000 0.088
#> GSM38747     3  0.4444      0.638 0.016 0.000 0.736 0.164 0.000 0.084
#> GSM38748     5  0.4594      0.317 0.000 0.000 0.000 0.340 0.608 0.052
#> GSM38749     3  0.0260      0.847 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM38750     3  0.1411      0.828 0.000 0.000 0.936 0.000 0.060 0.004
#> GSM38751     3  0.0291      0.846 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM38752     4  0.2146      0.733 0.000 0.000 0.000 0.880 0.116 0.004
#> GSM38753     4  0.0000      0.760 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38754     4  0.2520      0.709 0.000 0.000 0.000 0.844 0.152 0.004
#> GSM38755     5  0.4074      0.428 0.004 0.000 0.288 0.000 0.684 0.024
#> GSM38756     4  0.0777      0.754 0.000 0.004 0.000 0.972 0.024 0.000
#> GSM38757     3  0.2527      0.733 0.000 0.000 0.832 0.000 0.168 0.000
#> GSM38758     2  0.2631      0.728 0.000 0.820 0.000 0.180 0.000 0.000
#> GSM38759     1  0.4672      0.602 0.728 0.000 0.000 0.152 0.028 0.092
#> GSM38760     3  0.1268      0.838 0.036 0.000 0.952 0.000 0.008 0.004
#> GSM38761     2  0.0146      0.900 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM38762     2  0.0000      0.901 0.000 1.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-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 individual(p) k
#> MAD:NMF 48      0.079586 2
#> MAD:NMF 49      0.008434 3
#> MAD:NMF 47      0.000522 4
#> MAD:NMF 41      0.001165 5
#> MAD:NMF 41      0.000245 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 19411 rows and 51 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 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-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.758           0.957       0.977         0.4046 0.613   0.613
#> 3 3 1.000           1.000       1.000         0.3795 0.830   0.722
#> 4 4 0.793           0.935       0.916         0.1170 0.967   0.926
#> 5 5 0.780           0.826       0.873         0.1731 0.813   0.544
#> 6 6 0.761           0.843       0.847         0.0223 0.957   0.813

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
#> GSM38712     1   0.000      0.967 1.000 0.000
#> GSM38713     1   0.000      0.967 1.000 0.000
#> GSM38714     1   0.000      0.967 1.000 0.000
#> GSM38715     1   0.000      0.967 1.000 0.000
#> GSM38716     1   0.000      0.967 1.000 0.000
#> GSM38717     1   0.000      0.967 1.000 0.000
#> GSM38718     1   0.000      0.967 1.000 0.000
#> GSM38719     1   0.000      0.967 1.000 0.000
#> GSM38720     1   0.000      0.967 1.000 0.000
#> GSM38721     1   0.000      0.967 1.000 0.000
#> GSM38722     1   0.000      0.967 1.000 0.000
#> GSM38723     1   0.000      0.967 1.000 0.000
#> GSM38724     1   0.000      0.967 1.000 0.000
#> GSM38725     1   0.000      0.967 1.000 0.000
#> GSM38726     1   0.000      0.967 1.000 0.000
#> GSM38727     1   0.000      0.967 1.000 0.000
#> GSM38728     1   0.000      0.967 1.000 0.000
#> GSM38729     1   0.000      0.967 1.000 0.000
#> GSM38730     1   0.000      0.967 1.000 0.000
#> GSM38731     1   0.000      0.967 1.000 0.000
#> GSM38732     1   0.653      0.831 0.832 0.168
#> GSM38733     1   0.000      0.967 1.000 0.000
#> GSM38734     2   0.000      1.000 0.000 1.000
#> GSM38735     1   0.000      0.967 1.000 0.000
#> GSM38736     2   0.000      1.000 0.000 1.000
#> GSM38737     2   0.000      1.000 0.000 1.000
#> GSM38738     1   0.653      0.831 0.832 0.168
#> GSM38739     1   0.000      0.967 1.000 0.000
#> GSM38740     1   0.000      0.967 1.000 0.000
#> GSM38741     1   0.653      0.831 0.832 0.168
#> GSM38742     2   0.000      1.000 0.000 1.000
#> GSM38743     2   0.000      1.000 0.000 1.000
#> GSM38744     1   0.000      0.967 1.000 0.000
#> GSM38745     1   0.000      0.967 1.000 0.000
#> GSM38746     1   0.000      0.967 1.000 0.000
#> GSM38747     1   0.000      0.967 1.000 0.000
#> GSM38748     2   0.000      1.000 0.000 1.000
#> GSM38749     1   0.000      0.967 1.000 0.000
#> GSM38750     1   0.653      0.831 0.832 0.168
#> GSM38751     1   0.653      0.831 0.832 0.168
#> GSM38752     2   0.000      1.000 0.000 1.000
#> GSM38753     2   0.000      1.000 0.000 1.000
#> GSM38754     2   0.000      1.000 0.000 1.000
#> GSM38755     1   0.653      0.831 0.832 0.168
#> GSM38756     2   0.000      1.000 0.000 1.000
#> GSM38757     1   0.653      0.831 0.832 0.168
#> GSM38758     2   0.000      1.000 0.000 1.000
#> GSM38759     1   0.000      0.967 1.000 0.000
#> GSM38760     1   0.000      0.967 1.000 0.000
#> GSM38761     2   0.000      1.000 0.000 1.000
#> GSM38762     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM38712     1  0.0000      1.000 1.000  0 0.000
#> GSM38713     1  0.0000      1.000 1.000  0 0.000
#> GSM38714     1  0.0000      1.000 1.000  0 0.000
#> GSM38715     1  0.0000      1.000 1.000  0 0.000
#> GSM38716     1  0.0000      1.000 1.000  0 0.000
#> GSM38717     1  0.0000      1.000 1.000  0 0.000
#> GSM38718     1  0.0000      1.000 1.000  0 0.000
#> GSM38719     1  0.0000      1.000 1.000  0 0.000
#> GSM38720     1  0.0000      1.000 1.000  0 0.000
#> GSM38721     1  0.0000      1.000 1.000  0 0.000
#> GSM38722     1  0.0000      1.000 1.000  0 0.000
#> GSM38723     1  0.0000      1.000 1.000  0 0.000
#> GSM38724     1  0.0237      0.996 0.996  0 0.004
#> GSM38725     1  0.0000      1.000 1.000  0 0.000
#> GSM38726     1  0.0000      1.000 1.000  0 0.000
#> GSM38727     1  0.0000      1.000 1.000  0 0.000
#> GSM38728     1  0.0000      1.000 1.000  0 0.000
#> GSM38729     1  0.0000      1.000 1.000  0 0.000
#> GSM38730     1  0.0000      1.000 1.000  0 0.000
#> GSM38731     1  0.0000      1.000 1.000  0 0.000
#> GSM38732     3  0.0000      1.000 0.000  0 1.000
#> GSM38733     1  0.0000      1.000 1.000  0 0.000
#> GSM38734     2  0.0000      1.000 0.000  1 0.000
#> GSM38735     1  0.0000      1.000 1.000  0 0.000
#> GSM38736     2  0.0000      1.000 0.000  1 0.000
#> GSM38737     2  0.0000      1.000 0.000  1 0.000
#> GSM38738     3  0.0000      1.000 0.000  0 1.000
#> GSM38739     1  0.0000      1.000 1.000  0 0.000
#> GSM38740     1  0.0000      1.000 1.000  0 0.000
#> GSM38741     3  0.0000      1.000 0.000  0 1.000
#> GSM38742     2  0.0000      1.000 0.000  1 0.000
#> GSM38743     2  0.0000      1.000 0.000  1 0.000
#> GSM38744     1  0.0000      1.000 1.000  0 0.000
#> GSM38745     1  0.0000      1.000 1.000  0 0.000
#> GSM38746     1  0.0000      1.000 1.000  0 0.000
#> GSM38747     1  0.0000      1.000 1.000  0 0.000
#> GSM38748     2  0.0000      1.000 0.000  1 0.000
#> GSM38749     1  0.0000      1.000 1.000  0 0.000
#> GSM38750     3  0.0000      1.000 0.000  0 1.000
#> GSM38751     3  0.0000      1.000 0.000  0 1.000
#> GSM38752     2  0.0000      1.000 0.000  1 0.000
#> GSM38753     2  0.0000      1.000 0.000  1 0.000
#> GSM38754     2  0.0000      1.000 0.000  1 0.000
#> GSM38755     3  0.0000      1.000 0.000  0 1.000
#> GSM38756     2  0.0000      1.000 0.000  1 0.000
#> GSM38757     3  0.0000      1.000 0.000  0 1.000
#> GSM38758     2  0.0000      1.000 0.000  1 0.000
#> GSM38759     1  0.0000      1.000 1.000  0 0.000
#> GSM38760     1  0.0000      1.000 1.000  0 0.000
#> GSM38761     2  0.0000      1.000 0.000  1 0.000
#> GSM38762     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38713     1  0.2921      0.896 0.860 0.140 0.000 0.000
#> GSM38714     1  0.2921      0.896 0.860 0.140 0.000 0.000
#> GSM38715     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38721     1  0.3311      0.887 0.828 0.172 0.000 0.000
#> GSM38722     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38724     1  0.4088      0.860 0.764 0.232 0.004 0.000
#> GSM38725     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38728     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38729     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38733     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38734     4  0.0000      0.990 0.000 0.000 0.000 1.000
#> GSM38735     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38736     2  0.3907      0.989 0.000 0.768 0.000 0.232
#> GSM38737     2  0.4040      0.986 0.000 0.752 0.000 0.248
#> GSM38738     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38739     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38740     1  0.1637      0.911 0.940 0.060 0.000 0.000
#> GSM38741     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38742     2  0.4040      0.986 0.000 0.752 0.000 0.248
#> GSM38743     2  0.3907      0.989 0.000 0.768 0.000 0.232
#> GSM38744     1  0.0000      0.916 1.000 0.000 0.000 0.000
#> GSM38745     1  0.1637      0.911 0.940 0.060 0.000 0.000
#> GSM38746     1  0.3356      0.886 0.824 0.176 0.000 0.000
#> GSM38747     1  0.3356      0.886 0.824 0.176 0.000 0.000
#> GSM38748     4  0.0707      0.980 0.000 0.020 0.000 0.980
#> GSM38749     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38750     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38751     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38752     4  0.0000      0.990 0.000 0.000 0.000 1.000
#> GSM38753     4  0.0000      0.990 0.000 0.000 0.000 1.000
#> GSM38754     4  0.0000      0.990 0.000 0.000 0.000 1.000
#> GSM38755     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38756     4  0.0707      0.980 0.000 0.020 0.000 0.980
#> GSM38757     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM38758     2  0.3907      0.989 0.000 0.768 0.000 0.232
#> GSM38759     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38760     1  0.3907      0.862 0.768 0.232 0.000 0.000
#> GSM38761     2  0.3907      0.989 0.000 0.768 0.000 0.232
#> GSM38762     2  0.4040      0.986 0.000 0.752 0.000 0.248

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.2516      0.716 0.860 0.000 0.000 0.000 0.140
#> GSM38714     1  0.2516      0.716 0.860 0.000 0.000 0.000 0.140
#> GSM38715     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38721     5  0.4287      0.646 0.460 0.000 0.000 0.000 0.540
#> GSM38722     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38724     5  0.4321      0.708 0.396 0.000 0.004 0.000 0.600
#> GSM38725     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38728     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38729     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.969 1.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38733     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38734     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> GSM38735     5  0.0000      0.336 0.000 0.000 0.000 0.000 1.000
#> GSM38736     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.3305      0.763 0.000 0.776 0.000 0.224 0.000
#> GSM38738     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38739     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38740     5  0.3983      0.272 0.340 0.000 0.000 0.000 0.660
#> GSM38741     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38742     2  0.3305      0.763 0.000 0.776 0.000 0.224 0.000
#> GSM38743     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM38744     5  0.4182      0.175 0.400 0.000 0.000 0.000 0.600
#> GSM38745     5  0.3983      0.272 0.340 0.000 0.000 0.000 0.660
#> GSM38746     5  0.4283      0.652 0.456 0.000 0.000 0.000 0.544
#> GSM38747     5  0.4283      0.652 0.456 0.000 0.000 0.000 0.544
#> GSM38748     4  0.3336      0.764 0.000 0.228 0.000 0.772 0.000
#> GSM38749     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38750     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38751     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38752     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> GSM38753     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> GSM38754     4  0.0000      0.895 0.000 0.000 0.000 1.000 0.000
#> GSM38755     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38756     4  0.3336      0.764 0.000 0.228 0.000 0.772 0.000
#> GSM38757     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38758     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM38759     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38760     5  0.4182      0.710 0.400 0.000 0.000 0.000 0.600
#> GSM38761     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0794      0.899 0.000 0.972 0.000 0.028 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
#> GSM38712     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38713     1   0.226      0.732 0.860 0.000 0.000 0.000 0.000 0.140
#> GSM38714     1   0.226      0.732 0.860 0.000 0.000 0.000 0.000 0.140
#> GSM38715     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38716     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38717     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38718     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38719     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38720     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38721     6   0.379      0.791 0.416 0.000 0.000 0.000 0.000 0.584
#> GSM38722     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38723     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38724     6   0.376      0.834 0.352 0.000 0.004 0.000 0.000 0.644
#> GSM38725     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38726     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38728     6   0.363      0.837 0.356 0.000 0.000 0.000 0.000 0.644
#> GSM38729     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38730     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38731     1   0.000      0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38733     6   0.374      0.818 0.392 0.000 0.000 0.000 0.000 0.608
#> GSM38734     4   0.000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38735     5   0.376      0.294 0.000 0.000 0.000 0.000 0.600 0.400
#> GSM38736     2   0.000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2   0.300      0.809 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM38738     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38739     6   0.363      0.837 0.356 0.000 0.000 0.000 0.000 0.644
#> GSM38740     5   0.470      0.760 0.340 0.000 0.000 0.000 0.600 0.060
#> GSM38741     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38742     2   0.300      0.809 0.000 0.772 0.000 0.000 0.228 0.000
#> GSM38743     2   0.000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5   0.376      0.693 0.400 0.000 0.000 0.000 0.600 0.000
#> GSM38745     5   0.470      0.760 0.340 0.000 0.000 0.000 0.600 0.060
#> GSM38746     6   0.378      0.797 0.412 0.000 0.000 0.000 0.000 0.588
#> GSM38747     6   0.378      0.797 0.412 0.000 0.000 0.000 0.000 0.588
#> GSM38748     4   0.466      0.601 0.000 0.228 0.000 0.672 0.100 0.000
#> GSM38749     6   0.363      0.837 0.356 0.000 0.000 0.000 0.000 0.644
#> GSM38750     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38751     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38752     4   0.000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38753     4   0.489      0.615 0.000 0.000 0.000 0.572 0.072 0.356
#> GSM38754     4   0.000      0.837 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38755     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38756     6   0.725     -0.674 0.000 0.228 0.000 0.316 0.100 0.356
#> GSM38757     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38758     2   0.000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38759     6   0.365      0.836 0.360 0.000 0.000 0.000 0.000 0.640
#> GSM38760     6   0.374      0.818 0.392 0.000 0.000 0.000 0.000 0.608
#> GSM38761     2   0.000      0.919 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2   0.079      0.911 0.000 0.968 0.000 0.000 0.032 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

test_to_known_factors(res)
#>             n individual(p) k
#> ATC:hclust 51       0.05676 2
#> ATC:hclust 51       0.01414 3
#> ATC:hclust 51       0.00184 4
#> ATC:hclust 47       0.00140 5
#> ATC:hclust 49       0.00048 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.974       0.990         0.4792 0.523   0.523
#> 3 3 0.867           0.831       0.929         0.3015 0.809   0.651
#> 4 4 0.723           0.867       0.867         0.1586 0.805   0.530
#> 5 5 0.865           0.852       0.865         0.0728 0.972   0.889
#> 6 6 0.846           0.818       0.864         0.0450 0.955   0.801

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
#> GSM38712     1  0.0000      0.987 1.000 0.000
#> GSM38713     1  0.0000      0.987 1.000 0.000
#> GSM38714     1  0.0000      0.987 1.000 0.000
#> GSM38715     1  0.0000      0.987 1.000 0.000
#> GSM38716     1  0.0000      0.987 1.000 0.000
#> GSM38717     1  0.0000      0.987 1.000 0.000
#> GSM38718     1  0.0000      0.987 1.000 0.000
#> GSM38719     1  0.0000      0.987 1.000 0.000
#> GSM38720     1  0.0000      0.987 1.000 0.000
#> GSM38721     1  0.0000      0.987 1.000 0.000
#> GSM38722     1  0.0000      0.987 1.000 0.000
#> GSM38723     1  0.0000      0.987 1.000 0.000
#> GSM38724     1  0.0000      0.987 1.000 0.000
#> GSM38725     1  0.0000      0.987 1.000 0.000
#> GSM38726     1  0.0000      0.987 1.000 0.000
#> GSM38727     1  0.0000      0.987 1.000 0.000
#> GSM38728     1  0.0000      0.987 1.000 0.000
#> GSM38729     1  0.0000      0.987 1.000 0.000
#> GSM38730     1  0.0000      0.987 1.000 0.000
#> GSM38731     1  0.0000      0.987 1.000 0.000
#> GSM38732     2  0.0000      0.991 0.000 1.000
#> GSM38733     1  0.0000      0.987 1.000 0.000
#> GSM38734     2  0.0000      0.991 0.000 1.000
#> GSM38735     1  0.0000      0.987 1.000 0.000
#> GSM38736     2  0.0000      0.991 0.000 1.000
#> GSM38737     2  0.0000      0.991 0.000 1.000
#> GSM38738     2  0.0000      0.991 0.000 1.000
#> GSM38739     1  0.0000      0.987 1.000 0.000
#> GSM38740     1  0.0000      0.987 1.000 0.000
#> GSM38741     2  0.0376      0.989 0.004 0.996
#> GSM38742     2  0.0000      0.991 0.000 1.000
#> GSM38743     2  0.0000      0.991 0.000 1.000
#> GSM38744     1  0.0000      0.987 1.000 0.000
#> GSM38745     1  0.0000      0.987 1.000 0.000
#> GSM38746     1  0.0000      0.987 1.000 0.000
#> GSM38747     1  0.0000      0.987 1.000 0.000
#> GSM38748     2  0.0000      0.991 0.000 1.000
#> GSM38749     1  0.0000      0.987 1.000 0.000
#> GSM38750     2  0.0376      0.989 0.004 0.996
#> GSM38751     2  0.4022      0.916 0.080 0.920
#> GSM38752     2  0.0000      0.991 0.000 1.000
#> GSM38753     2  0.0000      0.991 0.000 1.000
#> GSM38754     2  0.0000      0.991 0.000 1.000
#> GSM38755     1  0.9580      0.374 0.620 0.380
#> GSM38756     2  0.0000      0.991 0.000 1.000
#> GSM38757     2  0.3431      0.934 0.064 0.936
#> GSM38758     2  0.0000      0.991 0.000 1.000
#> GSM38759     1  0.0000      0.987 1.000 0.000
#> GSM38760     1  0.0000      0.987 1.000 0.000
#> GSM38761     2  0.0000      0.991 0.000 1.000
#> GSM38762     2  0.0000      0.991 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
#> GSM38712     1   0.000      0.899 1.000 0.000 0.000
#> GSM38713     1   0.000      0.899 1.000 0.000 0.000
#> GSM38714     1   0.000      0.899 1.000 0.000 0.000
#> GSM38715     1   0.000      0.899 1.000 0.000 0.000
#> GSM38716     1   0.000      0.899 1.000 0.000 0.000
#> GSM38717     1   0.000      0.899 1.000 0.000 0.000
#> GSM38718     1   0.000      0.899 1.000 0.000 0.000
#> GSM38719     1   0.000      0.899 1.000 0.000 0.000
#> GSM38720     1   0.000      0.899 1.000 0.000 0.000
#> GSM38721     1   0.568      0.532 0.684 0.000 0.316
#> GSM38722     1   0.000      0.899 1.000 0.000 0.000
#> GSM38723     1   0.000      0.899 1.000 0.000 0.000
#> GSM38724     3   0.271      0.834 0.088 0.000 0.912
#> GSM38725     1   0.000      0.899 1.000 0.000 0.000
#> GSM38726     1   0.000      0.899 1.000 0.000 0.000
#> GSM38727     1   0.000      0.899 1.000 0.000 0.000
#> GSM38728     3   0.271      0.834 0.088 0.000 0.912
#> GSM38729     1   0.000      0.899 1.000 0.000 0.000
#> GSM38730     1   0.000      0.899 1.000 0.000 0.000
#> GSM38731     1   0.000      0.899 1.000 0.000 0.000
#> GSM38732     3   0.116      0.862 0.000 0.028 0.972
#> GSM38733     1   0.597      0.432 0.636 0.000 0.364
#> GSM38734     2   0.207      0.959 0.000 0.940 0.060
#> GSM38735     3   0.603      0.327 0.376 0.000 0.624
#> GSM38736     2   0.000      0.979 0.000 1.000 0.000
#> GSM38737     2   0.000      0.979 0.000 1.000 0.000
#> GSM38738     3   0.116      0.862 0.000 0.028 0.972
#> GSM38739     1   0.615      0.316 0.592 0.000 0.408
#> GSM38740     1   0.116      0.880 0.972 0.000 0.028
#> GSM38741     3   0.116      0.862 0.000 0.028 0.972
#> GSM38742     2   0.000      0.979 0.000 1.000 0.000
#> GSM38743     2   0.000      0.979 0.000 1.000 0.000
#> GSM38744     1   0.116      0.880 0.972 0.000 0.028
#> GSM38745     1   0.116      0.880 0.972 0.000 0.028
#> GSM38746     3   0.626      0.120 0.448 0.000 0.552
#> GSM38747     1   0.000      0.899 1.000 0.000 0.000
#> GSM38748     2   0.129      0.970 0.000 0.968 0.032
#> GSM38749     1   0.565      0.539 0.688 0.000 0.312
#> GSM38750     3   0.116      0.862 0.000 0.028 0.972
#> GSM38751     3   0.116      0.862 0.000 0.028 0.972
#> GSM38752     2   0.207      0.959 0.000 0.940 0.060
#> GSM38753     2   0.207      0.959 0.000 0.940 0.060
#> GSM38754     2   0.207      0.959 0.000 0.940 0.060
#> GSM38755     3   0.116      0.857 0.028 0.000 0.972
#> GSM38756     2   0.000      0.979 0.000 1.000 0.000
#> GSM38757     3   0.116      0.862 0.000 0.028 0.972
#> GSM38758     2   0.000      0.979 0.000 1.000 0.000
#> GSM38759     1   0.553      0.564 0.704 0.000 0.296
#> GSM38760     1   0.608      0.372 0.612 0.000 0.388
#> GSM38761     2   0.000      0.979 0.000 1.000 0.000
#> GSM38762     2   0.000      0.979 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38713     2  0.4981      0.516 0.464 0.536 0.000 0.000
#> GSM38714     2  0.4746      0.680 0.368 0.632 0.000 0.000
#> GSM38715     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38721     2  0.6364      0.796 0.204 0.652 0.144 0.000
#> GSM38722     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38724     2  0.4819      0.541 0.004 0.652 0.344 0.000
#> GSM38725     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38728     2  0.4781      0.553 0.004 0.660 0.336 0.000
#> GSM38729     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.988 1.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      0.969 0.000 0.000 1.000 0.000
#> GSM38733     2  0.6295      0.796 0.196 0.660 0.144 0.000
#> GSM38734     4  0.5142      0.867 0.000 0.192 0.064 0.744
#> GSM38735     2  0.4487      0.725 0.092 0.808 0.100 0.000
#> GSM38736     4  0.0000      0.901 0.000 0.000 0.000 1.000
#> GSM38737     4  0.1059      0.900 0.000 0.016 0.012 0.972
#> GSM38738     3  0.0000      0.969 0.000 0.000 1.000 0.000
#> GSM38739     2  0.6121      0.785 0.156 0.680 0.164 0.000
#> GSM38740     2  0.4888      0.460 0.412 0.588 0.000 0.000
#> GSM38741     3  0.0592      0.978 0.000 0.016 0.984 0.000
#> GSM38742     4  0.1059      0.900 0.000 0.016 0.012 0.972
#> GSM38743     4  0.0000      0.901 0.000 0.000 0.000 1.000
#> GSM38744     1  0.3123      0.798 0.844 0.156 0.000 0.000
#> GSM38745     2  0.4431      0.660 0.304 0.696 0.000 0.000
#> GSM38746     2  0.5716      0.686 0.068 0.680 0.252 0.000
#> GSM38747     2  0.4697      0.690 0.356 0.644 0.000 0.000
#> GSM38748     4  0.4149      0.881 0.000 0.168 0.028 0.804
#> GSM38749     2  0.6104      0.799 0.180 0.680 0.140 0.000
#> GSM38750     3  0.0592      0.978 0.000 0.016 0.984 0.000
#> GSM38751     3  0.1302      0.967 0.000 0.044 0.956 0.000
#> GSM38752     4  0.5212      0.866 0.000 0.192 0.068 0.740
#> GSM38753     4  0.5212      0.866 0.000 0.192 0.068 0.740
#> GSM38754     4  0.5212      0.866 0.000 0.192 0.068 0.740
#> GSM38755     3  0.1302      0.967 0.000 0.044 0.956 0.000
#> GSM38756     4  0.3591      0.885 0.000 0.168 0.008 0.824
#> GSM38757     3  0.1022      0.975 0.000 0.032 0.968 0.000
#> GSM38758     4  0.0000      0.901 0.000 0.000 0.000 1.000
#> GSM38759     2  0.6058      0.799 0.180 0.684 0.136 0.000
#> GSM38760     2  0.6110      0.797 0.176 0.680 0.144 0.000
#> GSM38761     4  0.0000      0.901 0.000 0.000 0.000 1.000
#> GSM38762     4  0.0000      0.901 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0290      0.961 0.992 0.000 0.000 0.000 0.008
#> GSM38713     4  0.3906      0.715 0.132 0.000 0.000 0.800 0.068
#> GSM38714     4  0.3390      0.780 0.100 0.000 0.000 0.840 0.060
#> GSM38715     1  0.0290      0.961 0.992 0.000 0.000 0.000 0.008
#> GSM38716     1  0.0290      0.961 0.992 0.000 0.000 0.000 0.008
#> GSM38717     1  0.0510      0.956 0.984 0.000 0.000 0.000 0.016
#> GSM38718     1  0.0510      0.956 0.984 0.000 0.000 0.000 0.016
#> GSM38719     1  0.0290      0.961 0.992 0.000 0.000 0.000 0.008
#> GSM38720     1  0.0290      0.961 0.992 0.000 0.000 0.000 0.008
#> GSM38721     4  0.2790      0.828 0.068 0.000 0.000 0.880 0.052
#> GSM38722     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38723     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38724     4  0.1877      0.788 0.000 0.000 0.064 0.924 0.012
#> GSM38725     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38726     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38727     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38728     4  0.1877      0.788 0.000 0.000 0.064 0.924 0.012
#> GSM38729     1  0.0000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38731     1  0.0162      0.962 0.996 0.000 0.000 0.000 0.004
#> GSM38732     3  0.1281      0.988 0.000 0.000 0.956 0.032 0.012
#> GSM38733     4  0.1877      0.837 0.064 0.000 0.000 0.924 0.012
#> GSM38734     2  0.4597      0.758 0.000 0.564 0.012 0.000 0.424
#> GSM38735     5  0.5646      0.609 0.028 0.000 0.028 0.460 0.484
#> GSM38736     2  0.0000      0.799 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.1787      0.797 0.000 0.940 0.012 0.016 0.032
#> GSM38738     3  0.1281      0.988 0.000 0.000 0.956 0.032 0.012
#> GSM38739     4  0.2868      0.808 0.032 0.000 0.012 0.884 0.072
#> GSM38740     5  0.6633      0.746 0.168 0.000 0.020 0.276 0.536
#> GSM38741     3  0.1124      0.994 0.000 0.000 0.960 0.036 0.004
#> GSM38742     2  0.1787      0.797 0.000 0.940 0.012 0.016 0.032
#> GSM38743     2  0.0000      0.799 0.000 1.000 0.000 0.000 0.000
#> GSM38744     1  0.5430      0.220 0.576 0.000 0.020 0.032 0.372
#> GSM38745     5  0.6333      0.787 0.108 0.000 0.020 0.336 0.536
#> GSM38746     4  0.3592      0.776 0.016 0.000 0.028 0.832 0.124
#> GSM38747     4  0.4083      0.743 0.080 0.000 0.000 0.788 0.132
#> GSM38748     2  0.4517      0.766 0.000 0.616 0.004 0.008 0.372
#> GSM38749     4  0.2830      0.813 0.044 0.000 0.000 0.876 0.080
#> GSM38750     3  0.1124      0.994 0.000 0.000 0.960 0.036 0.004
#> GSM38751     3  0.1124      0.994 0.000 0.000 0.960 0.036 0.004
#> GSM38752     2  0.4597      0.758 0.000 0.564 0.012 0.000 0.424
#> GSM38753     2  0.4936      0.757 0.000 0.564 0.012 0.012 0.412
#> GSM38754     2  0.4597      0.758 0.000 0.564 0.012 0.000 0.424
#> GSM38755     3  0.0963      0.994 0.000 0.000 0.964 0.036 0.000
#> GSM38756     2  0.4675      0.767 0.000 0.620 0.004 0.016 0.360
#> GSM38757     3  0.0963      0.994 0.000 0.000 0.964 0.036 0.000
#> GSM38758     2  0.0162      0.800 0.000 0.996 0.000 0.004 0.000
#> GSM38759     4  0.1597      0.843 0.048 0.000 0.000 0.940 0.012
#> GSM38760     4  0.1522      0.843 0.044 0.000 0.000 0.944 0.012
#> GSM38761     2  0.0162      0.800 0.000 0.996 0.000 0.004 0.000
#> GSM38762     2  0.0798      0.798 0.000 0.976 0.008 0.016 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
#> GSM38712     1  0.0363      0.918 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM38713     6  0.5124      0.638 0.056 0.000 0.000 0.232 0.048 0.664
#> GSM38714     6  0.4696      0.685 0.036 0.000 0.000 0.212 0.048 0.704
#> GSM38715     1  0.2941      0.801 0.780 0.000 0.000 0.220 0.000 0.000
#> GSM38716     1  0.1863      0.878 0.896 0.000 0.000 0.104 0.000 0.000
#> GSM38717     1  0.3073      0.808 0.788 0.000 0.000 0.204 0.008 0.000
#> GSM38718     1  0.3073      0.808 0.788 0.000 0.000 0.204 0.008 0.000
#> GSM38719     1  0.0260      0.919 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM38720     1  0.2562      0.838 0.828 0.000 0.000 0.172 0.000 0.000
#> GSM38721     6  0.2934      0.836 0.024 0.000 0.000 0.064 0.044 0.868
#> GSM38722     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38723     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38724     6  0.1492      0.833 0.000 0.000 0.024 0.036 0.000 0.940
#> GSM38725     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38726     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38727     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38728     6  0.1552      0.834 0.004 0.000 0.020 0.036 0.000 0.940
#> GSM38729     1  0.0717      0.919 0.976 0.000 0.000 0.016 0.008 0.000
#> GSM38730     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38731     1  0.0363      0.921 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38732     3  0.0291      0.992 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38733     6  0.1492      0.840 0.024 0.000 0.000 0.036 0.000 0.940
#> GSM38734     4  0.3756      0.925 0.000 0.400 0.000 0.600 0.000 0.000
#> GSM38735     5  0.3777      0.718 0.008 0.000 0.000 0.028 0.756 0.208
#> GSM38736     2  0.0000      0.802 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.2328      0.762 0.000 0.904 0.000 0.044 0.032 0.020
#> GSM38738     3  0.0291      0.992 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38739     6  0.3972      0.809 0.020 0.000 0.004 0.108 0.072 0.796
#> GSM38740     5  0.2867      0.791 0.040 0.000 0.000 0.000 0.848 0.112
#> GSM38741     3  0.0291      0.994 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38742     2  0.2328      0.762 0.000 0.904 0.000 0.044 0.032 0.020
#> GSM38743     2  0.0000      0.802 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.3592      0.457 0.344 0.000 0.000 0.000 0.656 0.000
#> GSM38745     5  0.2815      0.787 0.032 0.000 0.000 0.000 0.848 0.120
#> GSM38746     6  0.4250      0.798 0.008 0.000 0.016 0.108 0.092 0.776
#> GSM38747     6  0.4505      0.789 0.028 0.000 0.000 0.120 0.104 0.748
#> GSM38748     4  0.4992      0.793 0.000 0.460 0.000 0.472 0.068 0.000
#> GSM38749     6  0.3965      0.810 0.024 0.000 0.000 0.108 0.076 0.792
#> GSM38750     3  0.0291      0.994 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38751     3  0.0291      0.994 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38752     4  0.3756      0.925 0.000 0.400 0.000 0.600 0.000 0.000
#> GSM38753     4  0.5160      0.880 0.000 0.400 0.000 0.520 0.076 0.004
#> GSM38754     4  0.3756      0.925 0.000 0.400 0.000 0.600 0.000 0.000
#> GSM38755     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38756     2  0.5454     -0.823 0.000 0.460 0.000 0.432 0.104 0.004
#> GSM38757     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38758     2  0.0865      0.788 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM38759     6  0.0632      0.846 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM38760     6  0.1564      0.844 0.024 0.000 0.000 0.040 0.000 0.936
#> GSM38761     2  0.0865      0.788 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM38762     2  0.1257      0.792 0.000 0.952 0.000 0.000 0.028 0.020

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 individual(p) k
#> ATC:kmeans 50       0.02722 2
#> ATC:kmeans 46       0.03187 3
#> ATC:kmeans 50       0.03170 4
#> ATC:kmeans 50       0.01339 5
#> ATC:kmeans 49       0.00169 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 19411 rows and 51 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.4884 0.514   0.514
#> 3 3 0.918           0.936       0.956         0.1724 0.900   0.807
#> 4 4 0.802           0.901       0.929         0.1754 0.874   0.702
#> 5 5 0.778           0.810       0.890         0.0584 0.982   0.940
#> 6 6 0.809           0.843       0.915         0.0498 0.947   0.818

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
#> GSM38712     1   0.000      0.993 1.000 0.000
#> GSM38713     1   0.000      0.993 1.000 0.000
#> GSM38714     1   0.000      0.993 1.000 0.000
#> GSM38715     1   0.000      0.993 1.000 0.000
#> GSM38716     1   0.000      0.993 1.000 0.000
#> GSM38717     1   0.000      0.993 1.000 0.000
#> GSM38718     1   0.000      0.993 1.000 0.000
#> GSM38719     1   0.000      0.993 1.000 0.000
#> GSM38720     1   0.000      0.993 1.000 0.000
#> GSM38721     1   0.000      0.993 1.000 0.000
#> GSM38722     1   0.000      0.993 1.000 0.000
#> GSM38723     1   0.000      0.993 1.000 0.000
#> GSM38724     1   0.738      0.737 0.792 0.208
#> GSM38725     1   0.000      0.993 1.000 0.000
#> GSM38726     1   0.000      0.993 1.000 0.000
#> GSM38727     1   0.000      0.993 1.000 0.000
#> GSM38728     1   0.000      0.993 1.000 0.000
#> GSM38729     1   0.000      0.993 1.000 0.000
#> GSM38730     1   0.000      0.993 1.000 0.000
#> GSM38731     1   0.000      0.993 1.000 0.000
#> GSM38732     2   0.000      1.000 0.000 1.000
#> GSM38733     1   0.000      0.993 1.000 0.000
#> GSM38734     2   0.000      1.000 0.000 1.000
#> GSM38735     1   0.000      0.993 1.000 0.000
#> GSM38736     2   0.000      1.000 0.000 1.000
#> GSM38737     2   0.000      1.000 0.000 1.000
#> GSM38738     2   0.000      1.000 0.000 1.000
#> GSM38739     1   0.000      0.993 1.000 0.000
#> GSM38740     1   0.000      0.993 1.000 0.000
#> GSM38741     2   0.000      1.000 0.000 1.000
#> GSM38742     2   0.000      1.000 0.000 1.000
#> GSM38743     2   0.000      1.000 0.000 1.000
#> GSM38744     1   0.000      0.993 1.000 0.000
#> GSM38745     1   0.000      0.993 1.000 0.000
#> GSM38746     1   0.000      0.993 1.000 0.000
#> GSM38747     1   0.000      0.993 1.000 0.000
#> GSM38748     2   0.000      1.000 0.000 1.000
#> GSM38749     1   0.000      0.993 1.000 0.000
#> GSM38750     2   0.000      1.000 0.000 1.000
#> GSM38751     2   0.000      1.000 0.000 1.000
#> GSM38752     2   0.000      1.000 0.000 1.000
#> GSM38753     2   0.000      1.000 0.000 1.000
#> GSM38754     2   0.000      1.000 0.000 1.000
#> GSM38755     2   0.000      1.000 0.000 1.000
#> GSM38756     2   0.000      1.000 0.000 1.000
#> GSM38757     2   0.000      1.000 0.000 1.000
#> GSM38758     2   0.000      1.000 0.000 1.000
#> GSM38759     1   0.000      0.993 1.000 0.000
#> GSM38760     1   0.000      0.993 1.000 0.000
#> GSM38761     2   0.000      1.000 0.000 1.000
#> GSM38762     2   0.000      1.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM38712     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38721     1  0.0892      0.967 0.980 0.000 0.020
#> GSM38722     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38723     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38724     3  0.6180      0.271 0.416 0.000 0.584
#> GSM38725     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38727     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38728     1  0.1163      0.962 0.972 0.000 0.028
#> GSM38729     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38730     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38731     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38732     3  0.5216      0.718 0.000 0.260 0.740
#> GSM38733     1  0.1163      0.962 0.972 0.000 0.028
#> GSM38734     2  0.4235      0.744 0.000 0.824 0.176
#> GSM38735     1  0.2711      0.930 0.912 0.000 0.088
#> GSM38736     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38737     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38738     3  0.3267      0.877 0.000 0.116 0.884
#> GSM38739     1  0.2537      0.935 0.920 0.000 0.080
#> GSM38740     1  0.2625      0.933 0.916 0.000 0.084
#> GSM38741     3  0.3619      0.863 0.000 0.136 0.864
#> GSM38742     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38743     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38744     1  0.2625      0.933 0.916 0.000 0.084
#> GSM38745     1  0.2711      0.930 0.912 0.000 0.088
#> GSM38746     1  0.2537      0.935 0.920 0.000 0.080
#> GSM38747     1  0.0237      0.976 0.996 0.000 0.004
#> GSM38748     2  0.0237      0.978 0.000 0.996 0.004
#> GSM38749     1  0.2448      0.938 0.924 0.000 0.076
#> GSM38750     3  0.3267      0.877 0.000 0.116 0.884
#> GSM38751     3  0.3267      0.877 0.000 0.116 0.884
#> GSM38752     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38753     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38754     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38755     3  0.3267      0.877 0.000 0.116 0.884
#> GSM38756     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38757     3  0.3267      0.877 0.000 0.116 0.884
#> GSM38758     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38759     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38760     1  0.0000      0.978 1.000 0.000 0.000
#> GSM38761     2  0.0000      0.982 0.000 1.000 0.000
#> GSM38762     2  0.0000      0.982 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38713     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38714     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38715     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38721     1  0.2466      0.844 0.900 0.096 0.004 0.000
#> GSM38722     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38724     3  0.6903      0.433 0.224 0.184 0.592 0.000
#> GSM38725     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38728     1  0.3626      0.718 0.812 0.184 0.004 0.000
#> GSM38729     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM38732     3  0.3444      0.754 0.000 0.000 0.816 0.184
#> GSM38733     1  0.3626      0.718 0.812 0.184 0.004 0.000
#> GSM38734     4  0.3311      0.773 0.000 0.000 0.172 0.828
#> GSM38735     2  0.3444      0.776 0.184 0.816 0.000 0.000
#> GSM38736     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38737     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38738     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM38739     2  0.4978      0.800 0.384 0.612 0.004 0.000
#> GSM38740     2  0.4222      0.850 0.272 0.728 0.000 0.000
#> GSM38741     3  0.1867      0.861 0.000 0.000 0.928 0.072
#> GSM38742     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38743     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38744     2  0.4222      0.850 0.272 0.728 0.000 0.000
#> GSM38745     2  0.3528      0.787 0.192 0.808 0.000 0.000
#> GSM38746     2  0.4950      0.806 0.376 0.620 0.004 0.000
#> GSM38747     1  0.1576      0.899 0.948 0.048 0.004 0.000
#> GSM38748     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38749     2  0.5168      0.594 0.492 0.504 0.004 0.000
#> GSM38750     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM38751     3  0.0469      0.896 0.000 0.000 0.988 0.012
#> GSM38752     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38753     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38754     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38755     3  0.0188      0.894 0.000 0.000 0.996 0.004
#> GSM38756     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38757     3  0.0336      0.896 0.000 0.000 0.992 0.008
#> GSM38758     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38759     1  0.1118      0.922 0.964 0.036 0.000 0.000
#> GSM38760     1  0.0336      0.953 0.992 0.008 0.000 0.000
#> GSM38761     4  0.0000      0.984 0.000 0.000 0.000 1.000
#> GSM38762     4  0.0000      0.984 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38714     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38715     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38716     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38721     1  0.4558      0.547 0.724 0.000 0.000 0.060 0.216
#> GSM38722     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM38723     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM38724     5  0.6626     -0.226 0.000 0.000 0.340 0.228 0.432
#> GSM38725     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM38726     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0162      0.900 0.996 0.000 0.000 0.004 0.000
#> GSM38728     1  0.5591      0.073 0.496 0.000 0.000 0.072 0.432
#> GSM38729     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.902 1.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.2891      0.748 0.000 0.176 0.824 0.000 0.000
#> GSM38733     1  0.4109      0.501 0.700 0.000 0.000 0.012 0.288
#> GSM38734     2  0.3123      0.791 0.000 0.828 0.160 0.000 0.012
#> GSM38735     5  0.4268      0.433 0.000 0.000 0.000 0.444 0.556
#> GSM38736     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38738     3  0.0404      0.918 0.000 0.012 0.988 0.000 0.000
#> GSM38739     4  0.3957      0.896 0.280 0.000 0.000 0.712 0.008
#> GSM38740     5  0.6282      0.397 0.216 0.000 0.000 0.248 0.536
#> GSM38741     3  0.2674      0.811 0.000 0.120 0.868 0.000 0.012
#> GSM38742     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38744     5  0.6278      0.403 0.212 0.000 0.000 0.252 0.536
#> GSM38745     5  0.5781      0.460 0.104 0.000 0.000 0.344 0.552
#> GSM38746     4  0.3395      0.839 0.236 0.000 0.000 0.764 0.000
#> GSM38747     1  0.3561      0.486 0.740 0.000 0.000 0.260 0.000
#> GSM38748     2  0.0693      0.973 0.000 0.980 0.008 0.000 0.012
#> GSM38749     4  0.4029      0.865 0.316 0.000 0.000 0.680 0.004
#> GSM38750     3  0.0000      0.922 0.000 0.000 1.000 0.000 0.000
#> GSM38751     3  0.0000      0.922 0.000 0.000 1.000 0.000 0.000
#> GSM38752     2  0.0404      0.978 0.000 0.988 0.000 0.000 0.012
#> GSM38753     2  0.0404      0.978 0.000 0.988 0.000 0.000 0.012
#> GSM38754     2  0.0404      0.978 0.000 0.988 0.000 0.000 0.012
#> GSM38755     3  0.0000      0.922 0.000 0.000 1.000 0.000 0.000
#> GSM38756     2  0.0404      0.978 0.000 0.988 0.000 0.000 0.012
#> GSM38757     3  0.0000      0.922 0.000 0.000 1.000 0.000 0.000
#> GSM38758     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38759     1  0.1914      0.824 0.924 0.000 0.000 0.016 0.060
#> GSM38760     1  0.2230      0.760 0.884 0.000 0.000 0.116 0.000
#> GSM38761     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.0146      0.939 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM38713     1  0.0458      0.933 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38714     1  0.0458      0.933 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38715     1  0.0458      0.933 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38716     1  0.0291      0.939 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM38717     1  0.0260      0.937 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM38718     1  0.0260      0.937 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM38719     1  0.0146      0.938 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38720     1  0.0146      0.938 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38721     6  0.3804      0.469 0.424 0.000 0.000 0.000 0.000 0.576
#> GSM38722     1  0.0458      0.935 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM38723     1  0.0632      0.929 0.976 0.000 0.000 0.024 0.000 0.000
#> GSM38724     6  0.4554      0.228 0.000 0.000 0.160 0.124 0.004 0.712
#> GSM38725     1  0.0363      0.937 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM38726     1  0.0260      0.939 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM38727     1  0.0547      0.932 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM38728     6  0.1814      0.451 0.100 0.000 0.000 0.000 0.000 0.900
#> GSM38729     1  0.0000      0.939 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0260      0.939 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM38731     1  0.0260      0.939 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM38732     3  0.3593      0.711 0.000 0.176 0.788 0.024 0.004 0.008
#> GSM38733     6  0.3765      0.505 0.404 0.000 0.000 0.000 0.000 0.596
#> GSM38734     2  0.4303      0.748 0.000 0.752 0.176 0.028 0.004 0.040
#> GSM38735     5  0.0363      0.617 0.000 0.000 0.000 0.012 0.988 0.000
#> GSM38736     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38738     3  0.0260      0.888 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38739     4  0.1983      0.968 0.072 0.000 0.000 0.908 0.020 0.000
#> GSM38740     5  0.3896      0.780 0.196 0.000 0.000 0.056 0.748 0.000
#> GSM38741     3  0.4305      0.661 0.000 0.196 0.740 0.020 0.004 0.040
#> GSM38742     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.3896      0.780 0.196 0.000 0.000 0.056 0.748 0.000
#> GSM38745     5  0.3159      0.772 0.100 0.000 0.000 0.068 0.832 0.000
#> GSM38746     4  0.2711      0.953 0.080 0.000 0.000 0.876 0.020 0.024
#> GSM38747     1  0.4328      0.435 0.672 0.000 0.000 0.284 0.004 0.040
#> GSM38748     2  0.2763      0.910 0.000 0.884 0.048 0.024 0.004 0.040
#> GSM38749     4  0.2094      0.968 0.080 0.000 0.000 0.900 0.020 0.000
#> GSM38750     3  0.0000      0.889 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38751     3  0.0291      0.888 0.000 0.004 0.992 0.000 0.000 0.004
#> GSM38752     2  0.2409      0.925 0.000 0.904 0.024 0.028 0.004 0.040
#> GSM38753     2  0.1788      0.934 0.000 0.928 0.000 0.028 0.004 0.040
#> GSM38754     2  0.2326      0.927 0.000 0.908 0.020 0.028 0.004 0.040
#> GSM38755     3  0.0405      0.885 0.000 0.000 0.988 0.000 0.004 0.008
#> GSM38756     2  0.1708      0.935 0.000 0.932 0.000 0.024 0.004 0.040
#> GSM38757     3  0.0146      0.888 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM38758     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38759     1  0.2318      0.842 0.904 0.000 0.000 0.020 0.048 0.028
#> GSM38760     1  0.3555      0.518 0.712 0.000 0.000 0.280 0.000 0.008
#> GSM38761     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      0.947 0.000 1.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-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 individual(p) k
#> ATC:skmeans 51       0.02014 2
#> ATC:skmeans 50       0.01908 3
#> ATC:skmeans 50       0.00209 4
#> ATC:skmeans 44       0.00635 5
#> ATC:skmeans 47       0.00466 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 19411 rows and 51 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.991       0.996         0.4790 0.523   0.523
#> 3 3 0.821           0.938       0.968         0.3736 0.706   0.488
#> 4 4 0.838           0.905       0.919         0.0801 0.967   0.901
#> 5 5 0.873           0.783       0.889         0.0783 0.882   0.631
#> 6 6 0.868           0.813       0.901         0.0569 0.953   0.794

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
#> GSM38712     1  0.0000      0.994 1.000 0.000
#> GSM38713     1  0.0000      0.994 1.000 0.000
#> GSM38714     1  0.0000      0.994 1.000 0.000
#> GSM38715     1  0.0000      0.994 1.000 0.000
#> GSM38716     1  0.0000      0.994 1.000 0.000
#> GSM38717     1  0.0000      0.994 1.000 0.000
#> GSM38718     1  0.0000      0.994 1.000 0.000
#> GSM38719     1  0.0000      0.994 1.000 0.000
#> GSM38720     1  0.0000      0.994 1.000 0.000
#> GSM38721     1  0.0000      0.994 1.000 0.000
#> GSM38722     1  0.0000      0.994 1.000 0.000
#> GSM38723     1  0.0000      0.994 1.000 0.000
#> GSM38724     1  0.0000      0.994 1.000 0.000
#> GSM38725     1  0.0000      0.994 1.000 0.000
#> GSM38726     1  0.0000      0.994 1.000 0.000
#> GSM38727     1  0.0000      0.994 1.000 0.000
#> GSM38728     1  0.0000      0.994 1.000 0.000
#> GSM38729     1  0.0000      0.994 1.000 0.000
#> GSM38730     1  0.0000      0.994 1.000 0.000
#> GSM38731     1  0.0000      0.994 1.000 0.000
#> GSM38732     2  0.0376      0.997 0.004 0.996
#> GSM38733     1  0.0000      0.994 1.000 0.000
#> GSM38734     2  0.0000      0.999 0.000 1.000
#> GSM38735     1  0.0000      0.994 1.000 0.000
#> GSM38736     2  0.0000      0.999 0.000 1.000
#> GSM38737     2  0.0000      0.999 0.000 1.000
#> GSM38738     2  0.0376      0.997 0.004 0.996
#> GSM38739     1  0.0000      0.994 1.000 0.000
#> GSM38740     1  0.0000      0.994 1.000 0.000
#> GSM38741     2  0.0376      0.997 0.004 0.996
#> GSM38742     2  0.0000      0.999 0.000 1.000
#> GSM38743     2  0.0000      0.999 0.000 1.000
#> GSM38744     1  0.0000      0.994 1.000 0.000
#> GSM38745     1  0.0000      0.994 1.000 0.000
#> GSM38746     1  0.0000      0.994 1.000 0.000
#> GSM38747     1  0.0000      0.994 1.000 0.000
#> GSM38748     2  0.0000      0.999 0.000 1.000
#> GSM38749     1  0.0000      0.994 1.000 0.000
#> GSM38750     2  0.0376      0.997 0.004 0.996
#> GSM38751     2  0.0376      0.997 0.004 0.996
#> GSM38752     2  0.0000      0.999 0.000 1.000
#> GSM38753     2  0.0000      0.999 0.000 1.000
#> GSM38754     2  0.0000      0.999 0.000 1.000
#> GSM38755     1  0.7139      0.756 0.804 0.196
#> GSM38756     2  0.0000      0.999 0.000 1.000
#> GSM38757     2  0.0376      0.997 0.004 0.996
#> GSM38758     2  0.0000      0.999 0.000 1.000
#> GSM38759     1  0.0000      0.994 1.000 0.000
#> GSM38760     1  0.0000      0.994 1.000 0.000
#> GSM38761     2  0.0000      0.999 0.000 1.000
#> GSM38762     2  0.0000      0.999 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
#> GSM38712     1   0.000      0.987 1.000 0.000 0.000
#> GSM38713     1   0.000      0.987 1.000 0.000 0.000
#> GSM38714     1   0.175      0.938 0.952 0.000 0.048
#> GSM38715     1   0.000      0.987 1.000 0.000 0.000
#> GSM38716     1   0.000      0.987 1.000 0.000 0.000
#> GSM38717     1   0.000      0.987 1.000 0.000 0.000
#> GSM38718     1   0.000      0.987 1.000 0.000 0.000
#> GSM38719     1   0.000      0.987 1.000 0.000 0.000
#> GSM38720     1   0.000      0.987 1.000 0.000 0.000
#> GSM38721     3   0.382      0.887 0.148 0.000 0.852
#> GSM38722     1   0.000      0.987 1.000 0.000 0.000
#> GSM38723     1   0.000      0.987 1.000 0.000 0.000
#> GSM38724     3   0.000      0.922 0.000 0.000 1.000
#> GSM38725     1   0.000      0.987 1.000 0.000 0.000
#> GSM38726     1   0.000      0.987 1.000 0.000 0.000
#> GSM38727     1   0.000      0.987 1.000 0.000 0.000
#> GSM38728     3   0.000      0.922 0.000 0.000 1.000
#> GSM38729     1   0.000      0.987 1.000 0.000 0.000
#> GSM38730     1   0.000      0.987 1.000 0.000 0.000
#> GSM38731     1   0.000      0.987 1.000 0.000 0.000
#> GSM38732     3   0.000      0.922 0.000 0.000 1.000
#> GSM38733     3   0.382      0.887 0.148 0.000 0.852
#> GSM38734     2   0.000      0.967 0.000 1.000 0.000
#> GSM38735     3   0.000      0.922 0.000 0.000 1.000
#> GSM38736     2   0.000      0.967 0.000 1.000 0.000
#> GSM38737     2   0.000      0.967 0.000 1.000 0.000
#> GSM38738     3   0.000      0.922 0.000 0.000 1.000
#> GSM38739     3   0.382      0.887 0.148 0.000 0.852
#> GSM38740     1   0.000      0.987 1.000 0.000 0.000
#> GSM38741     3   0.000      0.922 0.000 0.000 1.000
#> GSM38742     2   0.000      0.967 0.000 1.000 0.000
#> GSM38743     2   0.000      0.967 0.000 1.000 0.000
#> GSM38744     1   0.000      0.987 1.000 0.000 0.000
#> GSM38745     1   0.000      0.987 1.000 0.000 0.000
#> GSM38746     3   0.382      0.887 0.148 0.000 0.852
#> GSM38747     1   0.440      0.739 0.812 0.000 0.188
#> GSM38748     2   0.000      0.967 0.000 1.000 0.000
#> GSM38749     3   0.382      0.887 0.148 0.000 0.852
#> GSM38750     3   0.000      0.922 0.000 0.000 1.000
#> GSM38751     3   0.000      0.922 0.000 0.000 1.000
#> GSM38752     2   0.000      0.967 0.000 1.000 0.000
#> GSM38753     2   0.603      0.363 0.000 0.624 0.376
#> GSM38754     2   0.000      0.967 0.000 1.000 0.000
#> GSM38755     3   0.000      0.922 0.000 0.000 1.000
#> GSM38756     2   0.000      0.967 0.000 1.000 0.000
#> GSM38757     3   0.000      0.922 0.000 0.000 1.000
#> GSM38758     2   0.000      0.967 0.000 1.000 0.000
#> GSM38759     3   0.382      0.887 0.148 0.000 0.852
#> GSM38760     3   0.375      0.888 0.144 0.000 0.856
#> GSM38761     2   0.000      0.967 0.000 1.000 0.000
#> GSM38762     2   0.000      0.967 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38713     1   0.102      0.924 0.968 0.000 0.032 0.000
#> GSM38714     1   0.361      0.785 0.800 0.000 0.200 0.000
#> GSM38715     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38716     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38717     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38718     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38719     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38720     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38721     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38722     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38723     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38724     3   0.253      0.891 0.000 0.112 0.888 0.000
#> GSM38725     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38726     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38727     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38728     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38729     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38730     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38731     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38732     3   0.555      0.809 0.000 0.200 0.716 0.084
#> GSM38733     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38734     4   0.000      0.917 0.000 0.000 0.000 1.000
#> GSM38735     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38736     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38737     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38738     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38739     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38740     1   0.361      0.785 0.800 0.000 0.200 0.000
#> GSM38741     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38742     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38743     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38744     1   0.000      0.945 1.000 0.000 0.000 0.000
#> GSM38745     1   0.361      0.785 0.800 0.000 0.200 0.000
#> GSM38746     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38747     1   0.482      0.494 0.612 0.000 0.388 0.000
#> GSM38748     4   0.265      0.831 0.000 0.120 0.000 0.880
#> GSM38749     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38750     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38751     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38752     4   0.000      0.917 0.000 0.000 0.000 1.000
#> GSM38753     4   0.000      0.917 0.000 0.000 0.000 1.000
#> GSM38754     4   0.000      0.917 0.000 0.000 0.000 1.000
#> GSM38755     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38756     4   0.361      0.715 0.000 0.200 0.000 0.800
#> GSM38757     3   0.361      0.873 0.000 0.200 0.800 0.000
#> GSM38758     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38759     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38760     3   0.000      0.903 0.000 0.000 1.000 0.000
#> GSM38761     2   0.361      1.000 0.000 0.800 0.000 0.200
#> GSM38762     2   0.361      1.000 0.000 0.800 0.000 0.200

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.0880     0.9203 0.968 0.000 0.000 0.000 0.032
#> GSM38714     1  0.4211     0.3642 0.636 0.000 0.004 0.000 0.360
#> GSM38715     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38716     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38719     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38721     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38722     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38724     3  0.1851     0.7748 0.000 0.000 0.912 0.000 0.088
#> GSM38725     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38728     3  0.4294    -0.4308 0.000 0.000 0.532 0.000 0.468
#> GSM38729     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000     0.9497 1.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38733     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38734     4  0.0000     0.8470 0.000 0.000 0.000 1.000 0.000
#> GSM38735     5  0.0000     0.4817 0.000 0.000 0.000 0.000 1.000
#> GSM38736     2  0.0000     0.9984 0.000 1.000 0.000 0.000 0.000
#> GSM38737     2  0.0162     0.9953 0.000 0.996 0.000 0.004 0.000
#> GSM38738     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38739     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38740     5  0.4150    -0.0999 0.388 0.000 0.000 0.000 0.612
#> GSM38741     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38742     2  0.0162     0.9953 0.000 0.996 0.000 0.004 0.000
#> GSM38743     2  0.0000     0.9984 0.000 1.000 0.000 0.000 0.000
#> GSM38744     1  0.4182     0.4812 0.600 0.000 0.000 0.000 0.400
#> GSM38745     5  0.0000     0.4817 0.000 0.000 0.000 0.000 1.000
#> GSM38746     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38747     5  0.5900     0.4922 0.212 0.000 0.188 0.000 0.600
#> GSM38748     4  0.3895     0.5945 0.000 0.320 0.000 0.680 0.000
#> GSM38749     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38750     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38751     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38752     4  0.0000     0.8470 0.000 0.000 0.000 1.000 0.000
#> GSM38753     4  0.0000     0.8470 0.000 0.000 0.000 1.000 0.000
#> GSM38754     4  0.0000     0.8470 0.000 0.000 0.000 1.000 0.000
#> GSM38755     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38756     4  0.4182     0.4544 0.000 0.400 0.000 0.600 0.000
#> GSM38757     3  0.0000     0.8914 0.000 0.000 1.000 0.000 0.000
#> GSM38758     2  0.0000     0.9984 0.000 1.000 0.000 0.000 0.000
#> GSM38759     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38760     5  0.4182     0.6529 0.000 0.000 0.400 0.000 0.600
#> GSM38761     2  0.0000     0.9984 0.000 1.000 0.000 0.000 0.000
#> GSM38762     2  0.0000     0.9984 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM38712     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38713     1  0.3464      0.610 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM38714     1  0.3634      0.536 0.644 0.000 0.000 0.000 0.000 0.356
#> GSM38715     1  0.1863      0.854 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM38716     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38717     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38718     1  0.1863      0.854 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM38719     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38720     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38721     6  0.0000      0.620 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM38722     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38724     3  0.2454      0.815 0.000 0.000 0.840 0.000 0.000 0.160
#> GSM38725     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38728     6  0.3998     -0.226 0.000 0.000 0.492 0.000 0.004 0.504
#> GSM38729     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.936 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38733     6  0.2854      0.378 0.208 0.000 0.000 0.000 0.000 0.792
#> GSM38734     4  0.0000      0.830 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38735     5  0.1327      0.682 0.000 0.000 0.000 0.000 0.936 0.064
#> GSM38736     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38737     2  0.1075      0.959 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM38738     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38739     6  0.3309      0.702 0.000 0.000 0.000 0.000 0.280 0.720
#> GSM38740     5  0.3468      0.696 0.128 0.000 0.000 0.000 0.804 0.068
#> GSM38741     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38742     2  0.1075      0.959 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM38743     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38744     5  0.3592      0.512 0.344 0.000 0.000 0.000 0.656 0.000
#> GSM38745     5  0.1327      0.682 0.000 0.000 0.000 0.000 0.936 0.064
#> GSM38746     6  0.3309      0.702 0.000 0.000 0.000 0.000 0.280 0.720
#> GSM38747     6  0.2664      0.699 0.000 0.000 0.000 0.000 0.184 0.816
#> GSM38748     4  0.3888      0.610 0.000 0.312 0.000 0.672 0.016 0.000
#> GSM38749     6  0.3309      0.702 0.000 0.000 0.000 0.000 0.280 0.720
#> GSM38750     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38751     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38752     4  0.0000      0.830 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38753     4  0.0363      0.827 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM38754     4  0.0000      0.830 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38755     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38756     4  0.4131      0.489 0.000 0.384 0.000 0.600 0.016 0.000
#> GSM38757     3  0.0000      0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38758     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38759     6  0.2135      0.688 0.000 0.000 0.000 0.000 0.128 0.872
#> GSM38760     6  0.3309      0.702 0.000 0.000 0.000 0.000 0.280 0.720
#> GSM38761     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      0.984 0.000 1.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 individual(p) k
#> ATC:pam 51      0.048267 2
#> ATC:pam 50      0.068536 3
#> ATC:pam 50      0.005452 4
#> ATC:pam 43      0.003428 5
#> ATC:pam 48      0.000235 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 19411 rows and 51 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-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.680           0.868       0.926         0.4711 0.534   0.534
#> 3 3 0.648           0.849       0.883         0.3489 0.767   0.576
#> 4 4 0.717           0.757       0.883         0.0983 0.835   0.574
#> 5 5 0.871           0.899       0.956         0.0620 0.944   0.806
#> 6 6 0.855           0.833       0.880         0.0609 0.917   0.683

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM38712     1   0.000      0.977 1.000 0.000
#> GSM38713     1   0.000      0.977 1.000 0.000
#> GSM38714     1   0.000      0.977 1.000 0.000
#> GSM38715     1   0.000      0.977 1.000 0.000
#> GSM38716     1   0.000      0.977 1.000 0.000
#> GSM38717     1   0.000      0.977 1.000 0.000
#> GSM38718     1   0.000      0.977 1.000 0.000
#> GSM38719     1   0.000      0.977 1.000 0.000
#> GSM38720     1   0.000      0.977 1.000 0.000
#> GSM38721     2   0.975      0.500 0.408 0.592
#> GSM38722     1   0.000      0.977 1.000 0.000
#> GSM38723     1   0.000      0.977 1.000 0.000
#> GSM38724     2   0.781      0.778 0.232 0.768
#> GSM38725     1   0.000      0.977 1.000 0.000
#> GSM38726     1   0.000      0.977 1.000 0.000
#> GSM38727     1   0.000      0.977 1.000 0.000
#> GSM38728     2   0.975      0.500 0.408 0.592
#> GSM38729     1   0.000      0.977 1.000 0.000
#> GSM38730     1   0.000      0.977 1.000 0.000
#> GSM38731     1   0.000      0.977 1.000 0.000
#> GSM38732     2   0.416      0.883 0.084 0.916
#> GSM38733     2   0.975      0.500 0.408 0.592
#> GSM38734     2   0.278      0.890 0.048 0.952
#> GSM38735     2   0.000      0.887 0.000 1.000
#> GSM38736     2   0.000      0.887 0.000 1.000
#> GSM38737     2   0.000      0.887 0.000 1.000
#> GSM38738     2   0.416      0.883 0.084 0.916
#> GSM38739     2   0.781      0.778 0.232 0.768
#> GSM38740     2   0.000      0.887 0.000 1.000
#> GSM38741     2   0.343      0.888 0.064 0.936
#> GSM38742     2   0.000      0.887 0.000 1.000
#> GSM38743     2   0.000      0.887 0.000 1.000
#> GSM38744     2   0.000      0.887 0.000 1.000
#> GSM38745     2   0.000      0.887 0.000 1.000
#> GSM38746     2   0.781      0.778 0.232 0.768
#> GSM38747     1   0.909      0.372 0.676 0.324
#> GSM38748     2   0.224      0.890 0.036 0.964
#> GSM38749     2   0.781      0.778 0.232 0.768
#> GSM38750     2   0.416      0.883 0.084 0.916
#> GSM38751     2   0.402      0.885 0.080 0.920
#> GSM38752     2   0.278      0.890 0.048 0.952
#> GSM38753     2   0.000      0.887 0.000 1.000
#> GSM38754     2   0.278      0.890 0.048 0.952
#> GSM38755     2   0.416      0.883 0.084 0.916
#> GSM38756     2   0.000      0.887 0.000 1.000
#> GSM38757     2   0.416      0.883 0.084 0.916
#> GSM38758     2   0.000      0.887 0.000 1.000
#> GSM38759     2   0.921      0.624 0.336 0.664
#> GSM38760     2   0.781      0.778 0.232 0.768
#> GSM38761     2   0.000      0.887 0.000 1.000
#> GSM38762     2   0.000      0.887 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
#> GSM38712     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38713     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38714     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38715     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38716     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38717     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38718     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38719     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38720     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38721     3  0.4504     0.6804 0.196 0.000 0.804
#> GSM38722     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38723     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38724     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38725     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38726     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38727     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38728     3  0.4555     0.6757 0.200 0.000 0.800
#> GSM38729     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38730     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38731     1  0.4291     1.0000 0.820 0.000 0.180
#> GSM38732     3  0.0000     0.8147 0.000 0.000 1.000
#> GSM38733     3  0.4555     0.6757 0.200 0.000 0.800
#> GSM38734     3  0.7815     0.5780 0.180 0.148 0.672
#> GSM38735     2  0.0747     0.9665 0.016 0.984 0.000
#> GSM38736     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38737     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38738     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38739     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38740     2  0.0747     0.9665 0.016 0.984 0.000
#> GSM38741     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38742     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38743     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38744     2  0.0747     0.9665 0.016 0.984 0.000
#> GSM38745     2  0.0747     0.9665 0.016 0.984 0.000
#> GSM38746     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38747     3  0.6308    -0.2107 0.492 0.000 0.508
#> GSM38748     3  0.7829     0.5735 0.164 0.164 0.672
#> GSM38749     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38750     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38751     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38752     3  0.7815     0.5780 0.180 0.148 0.672
#> GSM38753     2  0.5178     0.8450 0.164 0.808 0.028
#> GSM38754     3  0.7815     0.5780 0.180 0.148 0.672
#> GSM38755     3  0.0000     0.8147 0.000 0.000 1.000
#> GSM38756     2  0.5178     0.8450 0.164 0.808 0.028
#> GSM38757     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38758     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38759     3  0.7555    -0.0423 0.440 0.040 0.520
#> GSM38760     3  0.1163     0.8258 0.028 0.000 0.972
#> GSM38761     2  0.0000     0.9695 0.000 1.000 0.000
#> GSM38762     2  0.0000     0.9695 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38713     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38714     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38715     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38716     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38720     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38721     3  0.4998    0.20426 0.488 0.000 0.512 0.000
#> GSM38722     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38723     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38724     3  0.2704    0.79947 0.124 0.000 0.876 0.000
#> GSM38725     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38726     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38727     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38728     1  0.4999   -0.23499 0.508 0.000 0.492 0.000
#> GSM38729     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38730     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38731     1  0.0000    0.95385 1.000 0.000 0.000 0.000
#> GSM38732     3  0.2408    0.80632 0.104 0.000 0.896 0.000
#> GSM38733     3  0.5000    0.16597 0.500 0.000 0.500 0.000
#> GSM38734     3  0.4804   -0.00187 0.000 0.000 0.616 0.384
#> GSM38735     4  0.0000    0.48979 0.000 0.000 0.000 1.000
#> GSM38736     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38737     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38738     3  0.2408    0.80632 0.104 0.000 0.896 0.000
#> GSM38739     3  0.0707    0.76700 0.020 0.000 0.980 0.000
#> GSM38740     4  0.0000    0.48979 0.000 0.000 0.000 1.000
#> GSM38741     3  0.0707    0.76700 0.020 0.000 0.980 0.000
#> GSM38742     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38743     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38744     4  0.0000    0.48979 0.000 0.000 0.000 1.000
#> GSM38745     4  0.0000    0.48979 0.000 0.000 0.000 1.000
#> GSM38746     3  0.0707    0.76700 0.020 0.000 0.980 0.000
#> GSM38747     1  0.0921    0.92396 0.972 0.000 0.028 0.000
#> GSM38748     4  0.4977    0.36815 0.000 0.000 0.460 0.540
#> GSM38749     3  0.0707    0.76700 0.020 0.000 0.980 0.000
#> GSM38750     3  0.2408    0.80632 0.104 0.000 0.896 0.000
#> GSM38751     3  0.0707    0.76700 0.020 0.000 0.980 0.000
#> GSM38752     4  0.5570    0.37124 0.020 0.000 0.440 0.540
#> GSM38753     4  0.4877    0.55128 0.000 0.408 0.000 0.592
#> GSM38754     4  0.5570    0.37124 0.020 0.000 0.440 0.540
#> GSM38755     3  0.2408    0.80632 0.104 0.000 0.896 0.000
#> GSM38756     4  0.4877    0.55128 0.000 0.408 0.000 0.592
#> GSM38757     3  0.2408    0.80632 0.104 0.000 0.896 0.000
#> GSM38758     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38759     1  0.3801    0.69909 0.780 0.000 0.000 0.220
#> GSM38760     3  0.2704    0.79947 0.124 0.000 0.876 0.000
#> GSM38761     2  0.4877    1.00000 0.000 0.592 0.000 0.408
#> GSM38762     2  0.4877    1.00000 0.000 0.592 0.000 0.408

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1 p2    p3    p4 p5
#> GSM38712     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38713     1   0.029      0.963 0.992  0 0.008 0.000  0
#> GSM38714     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38715     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38716     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38717     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38718     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38719     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38720     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38721     3   0.414      0.437 0.384  0 0.616 0.000  0
#> GSM38722     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38723     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38724     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38725     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38726     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38727     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38728     3   0.414      0.437 0.384  0 0.616 0.000  0
#> GSM38729     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38730     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38731     1   0.000      0.971 1.000  0 0.000 0.000  0
#> GSM38732     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38733     3   0.414      0.437 0.384  0 0.616 0.000  0
#> GSM38734     4   0.289      0.868 0.000  0 0.176 0.824  0
#> GSM38735     5   0.000      1.000 0.000  0 0.000 0.000  1
#> GSM38736     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38737     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38738     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38739     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38740     5   0.000      1.000 0.000  0 0.000 0.000  1
#> GSM38741     3   0.029      0.867 0.000  0 0.992 0.008  0
#> GSM38742     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38743     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38744     5   0.000      1.000 0.000  0 0.000 0.000  1
#> GSM38745     5   0.000      1.000 0.000  0 0.000 0.000  1
#> GSM38746     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38747     1   0.179      0.880 0.916  0 0.084 0.000  0
#> GSM38748     4   0.242      0.906 0.000  0 0.132 0.868  0
#> GSM38749     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38750     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38751     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38752     4   0.252      0.906 0.000  0 0.140 0.860  0
#> GSM38753     4   0.000      0.825 0.000  0 0.000 1.000  0
#> GSM38754     4   0.252      0.906 0.000  0 0.140 0.860  0
#> GSM38755     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38756     4   0.000      0.825 0.000  0 0.000 1.000  0
#> GSM38757     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38758     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38759     1   0.592      0.425 0.596  0 0.220 0.184  0
#> GSM38760     3   0.000      0.875 0.000  0 1.000 0.000  0
#> GSM38761     2   0.000      1.000 0.000  1 0.000 0.000  0
#> GSM38762     2   0.000      1.000 0.000  1 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM38712     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38713     1  0.3592      0.400 0.656  0 0.000 0.000 0.000 0.344
#> GSM38714     6  0.3672      0.528 0.368  0 0.000 0.000 0.000 0.632
#> GSM38715     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38716     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38717     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38718     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38719     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38720     1  0.1267      0.917 0.940  0 0.000 0.000 0.000 0.060
#> GSM38721     6  0.4482      0.594 0.360  0 0.040 0.000 0.000 0.600
#> GSM38722     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38723     1  0.0146      0.926 0.996  0 0.004 0.000 0.000 0.000
#> GSM38724     6  0.4602      0.518 0.044  0 0.384 0.000 0.000 0.572
#> GSM38725     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38726     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38727     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38728     6  0.4504      0.583 0.368  0 0.040 0.000 0.000 0.592
#> GSM38729     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38730     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38731     1  0.0000      0.928 1.000  0 0.000 0.000 0.000 0.000
#> GSM38732     3  0.0000      0.956 0.000  0 1.000 0.000 0.000 0.000
#> GSM38733     6  0.4482      0.594 0.360  0 0.040 0.000 0.000 0.600
#> GSM38734     4  0.0547      0.870 0.000  0 0.020 0.980 0.000 0.000
#> GSM38735     5  0.0146      0.994 0.000  0 0.000 0.000 0.996 0.004
#> GSM38736     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38737     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38738     3  0.0000      0.956 0.000  0 1.000 0.000 0.000 0.000
#> GSM38739     6  0.3810      0.455 0.000  0 0.428 0.000 0.000 0.572
#> GSM38740     5  0.0000      0.998 0.000  0 0.000 0.000 1.000 0.000
#> GSM38741     3  0.2664      0.744 0.000  0 0.816 0.184 0.000 0.000
#> GSM38742     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38743     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38744     5  0.0000      0.998 0.000  0 0.000 0.000 1.000 0.000
#> GSM38745     5  0.0000      0.998 0.000  0 0.000 0.000 1.000 0.000
#> GSM38746     6  0.3810      0.455 0.000  0 0.428 0.000 0.000 0.572
#> GSM38747     1  0.3782      0.543 0.740  0 0.036 0.000 0.000 0.224
#> GSM38748     4  0.0363      0.869 0.000  0 0.012 0.988 0.000 0.000
#> GSM38749     6  0.3810      0.455 0.000  0 0.428 0.000 0.000 0.572
#> GSM38750     3  0.0260      0.955 0.000  0 0.992 0.000 0.000 0.008
#> GSM38751     3  0.0000      0.956 0.000  0 1.000 0.000 0.000 0.000
#> GSM38752     4  0.0547      0.870 0.000  0 0.020 0.980 0.000 0.000
#> GSM38753     4  0.3647      0.725 0.000  0 0.000 0.640 0.000 0.360
#> GSM38754     4  0.0547      0.870 0.000  0 0.020 0.980 0.000 0.000
#> GSM38755     3  0.0260      0.955 0.000  0 0.992 0.000 0.000 0.008
#> GSM38756     4  0.3647      0.725 0.000  0 0.000 0.640 0.000 0.360
#> GSM38757     3  0.0260      0.955 0.000  0 0.992 0.000 0.000 0.008
#> GSM38758     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38759     6  0.4241      0.565 0.368  0 0.024 0.000 0.000 0.608
#> GSM38760     6  0.4758      0.539 0.060  0 0.360 0.000 0.000 0.580
#> GSM38761     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM38762     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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

test_to_known_factors(res)
#>             n individual(p) k
#> ATC:mclust 47      0.004273 2
#> ATC:mclust 49      0.003068 3
#> ATC:mclust 40      0.012193 4
#> ATC:mclust 47      0.000492 5
#> ATC:mclust 47      0.002607 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 19411 rows and 51 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.879           0.891       0.957         0.4407 0.547   0.547
#> 3 3 0.713           0.775       0.867         0.2019 0.881   0.787
#> 4 4 0.596           0.657       0.799         0.1870 0.874   0.738
#> 5 5 0.566           0.598       0.768         0.1163 0.894   0.735
#> 6 6 0.573           0.522       0.738         0.0529 0.921   0.761

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
#> GSM38712     1   0.000     0.9725 1.000 0.000
#> GSM38713     1   0.000     0.9725 1.000 0.000
#> GSM38714     1   0.000     0.9725 1.000 0.000
#> GSM38715     1   0.000     0.9725 1.000 0.000
#> GSM38716     1   0.000     0.9725 1.000 0.000
#> GSM38717     1   0.000     0.9725 1.000 0.000
#> GSM38718     1   0.000     0.9725 1.000 0.000
#> GSM38719     1   0.000     0.9725 1.000 0.000
#> GSM38720     1   0.000     0.9725 1.000 0.000
#> GSM38721     1   0.000     0.9725 1.000 0.000
#> GSM38722     1   0.000     0.9725 1.000 0.000
#> GSM38723     1   0.000     0.9725 1.000 0.000
#> GSM38724     1   0.000     0.9725 1.000 0.000
#> GSM38725     1   0.000     0.9725 1.000 0.000
#> GSM38726     1   0.000     0.9725 1.000 0.000
#> GSM38727     1   0.000     0.9725 1.000 0.000
#> GSM38728     1   0.000     0.9725 1.000 0.000
#> GSM38729     1   0.000     0.9725 1.000 0.000
#> GSM38730     1   0.000     0.9725 1.000 0.000
#> GSM38731     1   0.000     0.9725 1.000 0.000
#> GSM38732     2   0.833     0.6575 0.264 0.736
#> GSM38733     1   0.000     0.9725 1.000 0.000
#> GSM38734     2   0.000     0.9066 0.000 1.000
#> GSM38735     1   0.000     0.9725 1.000 0.000
#> GSM38736     2   0.000     0.9066 0.000 1.000
#> GSM38737     2   0.000     0.9066 0.000 1.000
#> GSM38738     2   0.932     0.5252 0.348 0.652
#> GSM38739     1   0.000     0.9725 1.000 0.000
#> GSM38740     1   0.000     0.9725 1.000 0.000
#> GSM38741     2   0.973     0.4008 0.404 0.596
#> GSM38742     2   0.000     0.9066 0.000 1.000
#> GSM38743     2   0.000     0.9066 0.000 1.000
#> GSM38744     1   0.000     0.9725 1.000 0.000
#> GSM38745     1   0.000     0.9725 1.000 0.000
#> GSM38746     1   0.000     0.9725 1.000 0.000
#> GSM38747     1   0.000     0.9725 1.000 0.000
#> GSM38748     2   0.000     0.9066 0.000 1.000
#> GSM38749     1   0.000     0.9725 1.000 0.000
#> GSM38750     2   0.955     0.4685 0.376 0.624
#> GSM38751     1   0.925     0.4026 0.660 0.340
#> GSM38752     2   0.000     0.9066 0.000 1.000
#> GSM38753     2   0.000     0.9066 0.000 1.000
#> GSM38754     2   0.000     0.9066 0.000 1.000
#> GSM38755     1   0.141     0.9519 0.980 0.020
#> GSM38756     2   0.000     0.9066 0.000 1.000
#> GSM38757     1   0.988     0.0949 0.564 0.436
#> GSM38758     2   0.000     0.9066 0.000 1.000
#> GSM38759     1   0.000     0.9725 1.000 0.000
#> GSM38760     1   0.000     0.9725 1.000 0.000
#> GSM38761     2   0.000     0.9066 0.000 1.000
#> GSM38762     2   0.000     0.9066 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
#> GSM38712     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38713     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38714     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38715     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38716     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38717     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38718     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38719     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38720     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38721     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38722     1  0.0592      0.929 0.988 0.012 0.000
#> GSM38723     1  0.0592      0.929 0.988 0.012 0.000
#> GSM38724     1  0.1031      0.913 0.976 0.000 0.024
#> GSM38725     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38726     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38727     1  0.0592      0.929 0.988 0.012 0.000
#> GSM38728     1  0.0237      0.932 0.996 0.000 0.004
#> GSM38729     1  0.0237      0.934 0.996 0.004 0.000
#> GSM38730     1  0.0237      0.934 0.996 0.004 0.000
#> GSM38731     1  0.0424      0.932 0.992 0.008 0.000
#> GSM38732     3  0.5363      0.630 0.276 0.000 0.724
#> GSM38733     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38734     3  0.0000      0.557 0.000 0.000 1.000
#> GSM38735     2  0.4291      0.362 0.180 0.820 0.000
#> GSM38736     2  0.5835      0.875 0.000 0.660 0.340
#> GSM38737     2  0.5760      0.871 0.000 0.672 0.328
#> GSM38738     3  0.5785      0.622 0.332 0.000 0.668
#> GSM38739     1  0.0424      0.932 0.992 0.008 0.000
#> GSM38740     1  0.4235      0.761 0.824 0.176 0.000
#> GSM38741     3  0.5968      0.589 0.364 0.000 0.636
#> GSM38742     2  0.5810      0.876 0.000 0.664 0.336
#> GSM38743     2  0.5810      0.876 0.000 0.664 0.336
#> GSM38744     1  0.3482      0.818 0.872 0.128 0.000
#> GSM38745     1  0.6308      0.209 0.508 0.492 0.000
#> GSM38746     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38747     1  0.0237      0.934 0.996 0.004 0.000
#> GSM38748     3  0.0424      0.551 0.000 0.008 0.992
#> GSM38749     1  0.0424      0.932 0.992 0.008 0.000
#> GSM38750     3  0.5760      0.623 0.328 0.000 0.672
#> GSM38751     1  0.5785      0.343 0.668 0.000 0.332
#> GSM38752     3  0.0000      0.557 0.000 0.000 1.000
#> GSM38753     3  0.4087      0.529 0.052 0.068 0.880
#> GSM38754     3  0.0237      0.554 0.000 0.004 0.996
#> GSM38755     1  0.6307     -0.250 0.512 0.000 0.488
#> GSM38756     3  0.2878      0.414 0.000 0.096 0.904
#> GSM38757     3  0.6045      0.555 0.380 0.000 0.620
#> GSM38758     2  0.6309      0.654 0.000 0.500 0.500
#> GSM38759     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38760     1  0.0000      0.935 1.000 0.000 0.000
#> GSM38761     2  0.5835      0.875 0.000 0.660 0.340
#> GSM38762     2  0.5810      0.876 0.000 0.664 0.336

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM38712     1  0.0376     0.9027 0.992 0.004 0.004 0.000
#> GSM38713     1  0.0376     0.9024 0.992 0.004 0.004 0.000
#> GSM38714     1  0.0469     0.9035 0.988 0.012 0.000 0.000
#> GSM38715     1  0.0376     0.9024 0.992 0.004 0.004 0.000
#> GSM38716     1  0.0000     0.9032 1.000 0.000 0.000 0.000
#> GSM38717     1  0.0000     0.9032 1.000 0.000 0.000 0.000
#> GSM38718     1  0.0000     0.9032 1.000 0.000 0.000 0.000
#> GSM38719     1  0.0188     0.9035 0.996 0.004 0.000 0.000
#> GSM38720     1  0.0188     0.9029 0.996 0.000 0.004 0.000
#> GSM38721     1  0.1743     0.8792 0.940 0.000 0.056 0.004
#> GSM38722     1  0.0779     0.9021 0.980 0.016 0.004 0.000
#> GSM38723     1  0.1109     0.8989 0.968 0.028 0.004 0.000
#> GSM38724     1  0.2958     0.8287 0.876 0.004 0.116 0.004
#> GSM38725     1  0.0657     0.9028 0.984 0.012 0.004 0.000
#> GSM38726     1  0.0188     0.9032 0.996 0.000 0.004 0.000
#> GSM38727     1  0.1489     0.8931 0.952 0.044 0.004 0.000
#> GSM38728     1  0.6179     0.4821 0.664 0.012 0.256 0.068
#> GSM38729     1  0.0188     0.9039 0.996 0.004 0.000 0.000
#> GSM38730     1  0.0376     0.9036 0.992 0.004 0.004 0.000
#> GSM38731     1  0.0524     0.9034 0.988 0.008 0.004 0.000
#> GSM38732     3  0.2111     0.7297 0.024 0.000 0.932 0.044
#> GSM38733     1  0.4262     0.6447 0.756 0.008 0.236 0.000
#> GSM38734     3  0.3486     0.6671 0.000 0.000 0.812 0.188
#> GSM38735     2  0.4485     0.2830 0.200 0.772 0.000 0.028
#> GSM38736     4  0.5404     0.4846 0.000 0.476 0.012 0.512
#> GSM38737     2  0.5155    -0.6462 0.000 0.528 0.004 0.468
#> GSM38738     3  0.2089     0.7316 0.020 0.012 0.940 0.028
#> GSM38739     1  0.4595     0.7405 0.776 0.184 0.040 0.000
#> GSM38740     1  0.4761     0.5043 0.664 0.332 0.004 0.000
#> GSM38741     3  0.5984     0.5826 0.048 0.000 0.580 0.372
#> GSM38742     4  0.4996     0.4823 0.000 0.484 0.000 0.516
#> GSM38743     4  0.5165     0.4792 0.000 0.484 0.004 0.512
#> GSM38744     1  0.3726     0.7312 0.788 0.212 0.000 0.000
#> GSM38745     2  0.5060     0.1668 0.412 0.584 0.004 0.000
#> GSM38746     1  0.3215     0.8550 0.888 0.076 0.016 0.020
#> GSM38747     1  0.1833     0.8904 0.944 0.024 0.000 0.032
#> GSM38748     4  0.4356     0.1263 0.000 0.000 0.292 0.708
#> GSM38749     1  0.3812     0.8053 0.832 0.140 0.028 0.000
#> GSM38750     3  0.2329     0.7306 0.024 0.020 0.932 0.024
#> GSM38751     3  0.8048     0.1993 0.360 0.088 0.484 0.068
#> GSM38752     3  0.4972     0.5074 0.000 0.000 0.544 0.456
#> GSM38753     4  0.6181     0.0577 0.128 0.000 0.204 0.668
#> GSM38754     3  0.5132     0.4796 0.000 0.004 0.548 0.448
#> GSM38755     3  0.2839     0.6842 0.108 0.004 0.884 0.004
#> GSM38756     4  0.3873     0.2336 0.000 0.000 0.228 0.772
#> GSM38757     3  0.1510     0.7330 0.028 0.000 0.956 0.016
#> GSM38758     4  0.4934     0.4863 0.000 0.252 0.028 0.720
#> GSM38759     1  0.3027     0.8444 0.888 0.088 0.004 0.020
#> GSM38760     1  0.3959     0.8138 0.840 0.068 0.092 0.000
#> GSM38761     4  0.4972     0.4917 0.000 0.456 0.000 0.544
#> GSM38762     4  0.4998     0.4777 0.000 0.488 0.000 0.512

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM38712     1  0.0693     0.7997 0.980 0.000 0.000 0.008 0.012
#> GSM38713     1  0.1469     0.7877 0.948 0.000 0.000 0.016 0.036
#> GSM38714     1  0.1443     0.7985 0.948 0.000 0.004 0.004 0.044
#> GSM38715     1  0.2074     0.7709 0.920 0.000 0.004 0.016 0.060
#> GSM38716     1  0.0609     0.7999 0.980 0.000 0.000 0.000 0.020
#> GSM38717     1  0.0898     0.7987 0.972 0.000 0.000 0.008 0.020
#> GSM38718     1  0.0992     0.7955 0.968 0.000 0.000 0.008 0.024
#> GSM38719     1  0.1251     0.7895 0.956 0.000 0.000 0.008 0.036
#> GSM38720     1  0.1082     0.7923 0.964 0.000 0.000 0.008 0.028
#> GSM38721     1  0.2968     0.7437 0.872 0.000 0.092 0.008 0.028
#> GSM38722     1  0.1478     0.7888 0.936 0.000 0.000 0.000 0.064
#> GSM38723     1  0.3462     0.6667 0.792 0.000 0.000 0.012 0.196
#> GSM38724     1  0.4578     0.6759 0.784 0.000 0.048 0.048 0.120
#> GSM38725     1  0.1965     0.7711 0.904 0.000 0.000 0.000 0.096
#> GSM38726     1  0.2011     0.7756 0.908 0.000 0.000 0.004 0.088
#> GSM38727     1  0.3171     0.7007 0.816 0.000 0.000 0.008 0.176
#> GSM38728     1  0.5411     0.2125 0.560 0.000 0.392 0.024 0.024
#> GSM38729     1  0.0404     0.7996 0.988 0.000 0.000 0.000 0.012
#> GSM38730     1  0.1041     0.7962 0.964 0.000 0.000 0.004 0.032
#> GSM38731     1  0.1043     0.7954 0.960 0.000 0.000 0.000 0.040
#> GSM38732     3  0.1356     0.5383 0.004 0.000 0.956 0.028 0.012
#> GSM38733     1  0.3992     0.5153 0.712 0.000 0.280 0.004 0.004
#> GSM38734     3  0.4387     0.2330 0.000 0.012 0.640 0.348 0.000
#> GSM38735     5  0.7802     0.3488 0.164 0.300 0.000 0.104 0.432
#> GSM38736     2  0.0324     0.9072 0.000 0.992 0.000 0.004 0.004
#> GSM38737     2  0.2574     0.8314 0.000 0.876 0.000 0.012 0.112
#> GSM38738     3  0.5001     0.5693 0.004 0.000 0.700 0.080 0.216
#> GSM38739     5  0.4996     0.5983 0.228 0.000 0.052 0.016 0.704
#> GSM38740     1  0.5347    -0.1186 0.528 0.004 0.000 0.044 0.424
#> GSM38741     4  0.7388    -0.1081 0.048 0.000 0.312 0.444 0.196
#> GSM38742     2  0.1082     0.9022 0.000 0.964 0.000 0.028 0.008
#> GSM38743     2  0.0404     0.9076 0.000 0.988 0.000 0.000 0.012
#> GSM38744     1  0.4836     0.2099 0.628 0.000 0.000 0.036 0.336
#> GSM38745     5  0.7418     0.5331 0.280 0.188 0.000 0.060 0.472
#> GSM38746     5  0.5901     0.3725 0.436 0.000 0.032 0.040 0.492
#> GSM38747     1  0.3723     0.7391 0.840 0.000 0.032 0.040 0.088
#> GSM38748     4  0.5805     0.5641 0.000 0.200 0.132 0.652 0.016
#> GSM38749     5  0.5211     0.5865 0.320 0.000 0.040 0.012 0.628
#> GSM38750     3  0.6621     0.4246 0.044 0.000 0.516 0.092 0.348
#> GSM38751     5  0.6162     0.3299 0.140 0.000 0.204 0.028 0.628
#> GSM38752     3  0.5552     0.1615 0.000 0.024 0.596 0.340 0.040
#> GSM38753     4  0.5817     0.5207 0.088 0.092 0.040 0.732 0.048
#> GSM38754     3  0.6341     0.1797 0.000 0.116 0.592 0.260 0.032
#> GSM38755     3  0.5212     0.5538 0.036 0.000 0.732 0.084 0.148
#> GSM38756     4  0.4788     0.5845 0.000 0.240 0.064 0.696 0.000
#> GSM38757     3  0.5153     0.5697 0.024 0.000 0.708 0.060 0.208
#> GSM38758     2  0.3684     0.6877 0.000 0.788 0.004 0.192 0.016
#> GSM38759     1  0.4025     0.6869 0.796 0.000 0.004 0.060 0.140
#> GSM38760     1  0.5951     0.0269 0.552 0.000 0.076 0.016 0.356
#> GSM38761     2  0.1717     0.8763 0.000 0.936 0.004 0.052 0.008
#> GSM38762     2  0.1059     0.9019 0.000 0.968 0.004 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
#> GSM38712     1  0.1074    0.83319 0.960 0.000 0.012 0.000 0.028 0.000
#> GSM38713     1  0.1340    0.82882 0.948 0.000 0.008 0.004 0.040 0.000
#> GSM38714     1  0.1644    0.82139 0.920 0.000 0.004 0.000 0.076 0.000
#> GSM38715     1  0.1801    0.82017 0.924 0.000 0.016 0.004 0.056 0.000
#> GSM38716     1  0.1088    0.83436 0.960 0.000 0.016 0.000 0.024 0.000
#> GSM38717     1  0.0935    0.83495 0.964 0.000 0.004 0.000 0.032 0.000
#> GSM38718     1  0.1320    0.82859 0.948 0.000 0.016 0.000 0.036 0.000
#> GSM38719     1  0.0964    0.83384 0.968 0.000 0.012 0.004 0.016 0.000
#> GSM38720     1  0.1320    0.82882 0.948 0.000 0.016 0.000 0.036 0.000
#> GSM38721     1  0.2495    0.81491 0.896 0.000 0.012 0.004 0.052 0.036
#> GSM38722     1  0.1625    0.82350 0.928 0.000 0.060 0.000 0.012 0.000
#> GSM38723     1  0.3796    0.69566 0.764 0.000 0.176 0.000 0.060 0.000
#> GSM38724     1  0.4118    0.75221 0.804 0.000 0.088 0.052 0.040 0.016
#> GSM38725     1  0.1858    0.81450 0.912 0.000 0.076 0.000 0.012 0.000
#> GSM38726     1  0.1789    0.82554 0.924 0.000 0.044 0.000 0.032 0.000
#> GSM38727     1  0.3236    0.75364 0.820 0.000 0.140 0.004 0.036 0.000
#> GSM38728     6  0.5360    0.02568 0.420 0.000 0.004 0.032 0.036 0.508
#> GSM38729     1  0.1196    0.83568 0.952 0.000 0.008 0.000 0.040 0.000
#> GSM38730     1  0.1168    0.83147 0.956 0.000 0.028 0.000 0.016 0.000
#> GSM38731     1  0.0909    0.83423 0.968 0.000 0.020 0.000 0.012 0.000
#> GSM38732     6  0.4701   -0.27992 0.000 0.000 0.028 0.480 0.008 0.484
#> GSM38733     1  0.4763    0.67806 0.756 0.000 0.016 0.100 0.044 0.084
#> GSM38734     4  0.3328    0.29388 0.000 0.008 0.000 0.788 0.012 0.192
#> GSM38735     3  0.7723    0.19102 0.124 0.296 0.340 0.004 0.228 0.008
#> GSM38736     2  0.2130    0.89239 0.000 0.920 0.008 0.028 0.016 0.028
#> GSM38737     2  0.1755    0.86459 0.000 0.932 0.028 0.008 0.032 0.000
#> GSM38738     4  0.6452    0.24069 0.000 0.000 0.300 0.384 0.016 0.300
#> GSM38739     3  0.2915    0.51319 0.120 0.000 0.848 0.000 0.008 0.024
#> GSM38740     3  0.6435    0.29221 0.368 0.020 0.412 0.000 0.196 0.004
#> GSM38741     6  0.6310    0.09403 0.036 0.000 0.344 0.036 0.068 0.516
#> GSM38742     2  0.0696    0.89942 0.000 0.980 0.004 0.004 0.004 0.008
#> GSM38743     2  0.0405    0.90198 0.000 0.988 0.000 0.008 0.004 0.000
#> GSM38744     1  0.6340   -0.22809 0.428 0.016 0.316 0.000 0.240 0.000
#> GSM38745     3  0.7193    0.39734 0.188 0.140 0.468 0.000 0.200 0.004
#> GSM38746     3  0.6020    0.47025 0.252 0.000 0.580 0.000 0.076 0.092
#> GSM38747     1  0.5192    0.50069 0.644 0.000 0.072 0.000 0.032 0.252
#> GSM38748     4  0.5133   -0.21798 0.000 0.052 0.008 0.716 0.128 0.096
#> GSM38749     3  0.3469    0.51115 0.168 0.000 0.800 0.008 0.016 0.008
#> GSM38750     3  0.6416   -0.00903 0.048 0.000 0.544 0.156 0.008 0.244
#> GSM38751     3  0.4251    0.41257 0.076 0.000 0.768 0.008 0.012 0.136
#> GSM38752     6  0.2372    0.29920 0.004 0.016 0.012 0.024 0.032 0.912
#> GSM38753     5  0.6783    0.00000 0.044 0.012 0.012 0.304 0.500 0.128
#> GSM38754     6  0.3174    0.29434 0.004 0.124 0.012 0.016 0.004 0.840
#> GSM38755     4  0.6570    0.33333 0.072 0.000 0.152 0.596 0.032 0.148
#> GSM38756     4  0.6701   -0.47218 0.000 0.080 0.020 0.540 0.252 0.108
#> GSM38757     4  0.6465    0.31156 0.032 0.000 0.268 0.492 0.004 0.204
#> GSM38758     2  0.4802    0.77082 0.000 0.760 0.020 0.084 0.068 0.068
#> GSM38759     1  0.5655    0.39339 0.588 0.000 0.096 0.000 0.280 0.036
#> GSM38760     1  0.5776    0.06103 0.500 0.000 0.396 0.068 0.028 0.008
#> GSM38761     2  0.3417    0.85098 0.000 0.852 0.016 0.048 0.052 0.032
#> GSM38762     2  0.1520    0.89914 0.000 0.948 0.008 0.020 0.016 0.008

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 individual(p) k
#> ATC:NMF 47      0.094790 2
#> ATC:NMF 46      0.002682 3
#> ATC:NMF 36      0.068195 4
#> ATC:NMF 39      0.014891 5
#> ATC:NMF 30      0.000921 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