cola Report for GDS711

Date: 2019-12-25 22:15:56 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 11993 rows and 57 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] 11993    57

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.975 0.982 **
SD:skmeans 3 1.000 0.989 0.995 ** 2
SD:mclust 2 1.000 1.000 1.000 **
CV:skmeans 3 1.000 0.995 0.998 ** 2
CV:mclust 2 1.000 1.000 1.000 **
MAD:skmeans 3 1.000 0.997 0.999 ** 2
ATC:mclust 4 1.000 0.966 0.982 ** 3
CV:NMF 3 0.976 0.948 0.976 ** 2
SD:NMF 3 0.974 0.946 0.976 ** 2
MAD:NMF 3 0.954 0.947 0.972 **
MAD:mclust 3 0.935 0.963 0.979 * 2
ATC:pam 6 0.931 0.824 0.925 * 4,5
MAD:pam 3 0.927 0.918 0.967 *
ATC:skmeans 6 0.923 0.872 0.936 * 2,3,4,5
ATC:NMF 3 0.906 0.912 0.961 *
CV:pam 3 0.882 0.893 0.957
CV:kmeans 2 0.874 0.965 0.974
SD:pam 3 0.841 0.872 0.946
MAD:hclust 3 0.832 0.890 0.951
ATC:hclust 4 0.826 0.892 0.933
ATC:kmeans 2 0.781 0.872 0.944
MAD:kmeans 3 0.739 0.977 0.942
SD:hclust 2 0.674 0.934 0.949
CV:hclust 2 0.561 0.891 0.917

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 0.927           0.969       0.985          0.471 0.536   0.536
#> CV:NMF      2 0.927           0.961       0.982          0.472 0.536   0.536
#> MAD:NMF     2 0.892           0.829       0.940          0.482 0.504   0.504
#> ATC:NMF     2 0.825           0.907       0.961          0.486 0.510   0.510
#> SD:skmeans  2 1.000           1.000       1.000          0.464 0.536   0.536
#> CV:skmeans  2 1.000           1.000       1.000          0.464 0.536   0.536
#> MAD:skmeans 2 1.000           0.997       0.998          0.465 0.536   0.536
#> ATC:skmeans 2 1.000           0.950       0.981          0.508 0.492   0.492
#> SD:mclust   2 1.000           1.000       1.000          0.464 0.536   0.536
#> CV:mclust   2 1.000           1.000       1.000          0.464 0.536   0.536
#> MAD:mclust  2 1.000           1.000       1.000          0.464 0.536   0.536
#> ATC:mclust  2 0.518           0.861       0.909          0.462 0.536   0.536
#> SD:kmeans   2 1.000           0.975       0.982          0.467 0.536   0.536
#> CV:kmeans   2 0.874           0.965       0.974          0.467 0.536   0.536
#> MAD:kmeans  2 0.669           0.893       0.934          0.474 0.536   0.536
#> ATC:kmeans  2 0.781           0.872       0.944          0.500 0.491   0.491
#> SD:pam      2 0.665           0.830       0.930          0.495 0.495   0.495
#> CV:pam      2 0.639           0.835       0.932          0.498 0.492   0.492
#> MAD:pam     2 0.622           0.755       0.904          0.495 0.491   0.491
#> ATC:pam     2 0.823           0.904       0.959          0.501 0.495   0.495
#> SD:hclust   2 0.674           0.934       0.949          0.469 0.536   0.536
#> CV:hclust   2 0.561           0.891       0.917          0.469 0.536   0.536
#> MAD:hclust  2 0.408           0.851       0.897          0.471 0.536   0.536
#> ATC:hclust  2 0.501           0.881       0.931          0.488 0.499   0.499
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.974           0.946       0.976          0.434 0.786   0.600
#> CV:NMF      3 0.976           0.948       0.976          0.431 0.786   0.600
#> MAD:NMF     3 0.954           0.947       0.972          0.399 0.713   0.484
#> ATC:NMF     3 0.906           0.912       0.961          0.392 0.736   0.518
#> SD:skmeans  3 1.000           0.989       0.995          0.461 0.786   0.600
#> CV:skmeans  3 1.000           0.995       0.998          0.461 0.786   0.600
#> MAD:skmeans 3 1.000           0.997       0.999          0.460 0.786   0.600
#> ATC:skmeans 3 0.906           0.891       0.955          0.316 0.706   0.469
#> SD:mclust   3 0.718           0.933       0.885          0.396 0.787   0.603
#> CV:mclust   3 0.725           0.947       0.892          0.414 0.787   0.603
#> MAD:mclust  3 0.935           0.963       0.979          0.454 0.787   0.603
#> ATC:mclust  3 0.911           0.910       0.957          0.457 0.723   0.513
#> SD:kmeans   3 0.713           0.941       0.908          0.399 0.786   0.600
#> CV:kmeans   3 0.713           0.950       0.909          0.395 0.786   0.600
#> MAD:kmeans  3 0.739           0.977       0.942          0.395 0.786   0.600
#> ATC:kmeans  3 0.768           0.800       0.902          0.345 0.685   0.448
#> SD:pam      3 0.841           0.872       0.946          0.350 0.731   0.506
#> CV:pam      3 0.882           0.893       0.957          0.354 0.719   0.487
#> MAD:pam     3 0.927           0.918       0.967          0.363 0.742   0.520
#> ATC:pam     3 0.861           0.901       0.959          0.345 0.696   0.459
#> SD:hclust   3 0.867           0.862       0.936          0.410 0.793   0.614
#> CV:hclust   3 0.856           0.865       0.938          0.411 0.793   0.614
#> MAD:hclust  3 0.832           0.890       0.951          0.423 0.787   0.603
#> ATC:hclust  3 0.651           0.863       0.888          0.344 0.842   0.683
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.849           0.843       0.933         0.1141 0.851   0.583
#> CV:NMF      4 0.860           0.833       0.931         0.1123 0.859   0.604
#> MAD:NMF     4 0.853           0.830       0.926         0.1131 0.868   0.628
#> ATC:NMF     4 0.841           0.858       0.908         0.1005 0.903   0.712
#> SD:skmeans  4 0.797           0.851       0.901         0.0898 0.932   0.792
#> CV:skmeans  4 0.826           0.862       0.907         0.0882 0.932   0.792
#> MAD:skmeans 4 0.843           0.893       0.930         0.0873 0.932   0.792
#> ATC:skmeans 4 0.920           0.876       0.947         0.0904 0.941   0.819
#> SD:mclust   4 0.811           0.833       0.921         0.1206 0.837   0.567
#> CV:mclust   4 0.797           0.798       0.894         0.1105 0.855   0.603
#> MAD:mclust  4 0.779           0.793       0.903         0.0876 0.943   0.824
#> ATC:mclust  4 1.000           0.966       0.982         0.0869 0.947   0.837
#> SD:kmeans   4 0.755           0.781       0.819         0.1217 0.943   0.823
#> CV:kmeans   4 0.819           0.841       0.828         0.1287 0.937   0.805
#> MAD:kmeans  4 0.816           0.845       0.785         0.1155 0.937   0.805
#> ATC:kmeans  4 0.774           0.795       0.878         0.1076 0.915   0.750
#> SD:pam      4 0.778           0.845       0.912         0.0970 0.932   0.796
#> CV:pam      4 0.874           0.870       0.935         0.0882 0.934   0.798
#> MAD:pam     4 0.890           0.910       0.944         0.0892 0.934   0.798
#> ATC:pam     4 0.976           0.902       0.962         0.1082 0.893   0.686
#> SD:hclust   4 0.825           0.761       0.880         0.0953 0.956   0.868
#> CV:hclust   4 0.836           0.784       0.885         0.1001 0.944   0.833
#> MAD:hclust  4 0.813           0.872       0.919         0.0809 0.968   0.902
#> ATC:hclust  4 0.826           0.892       0.933         0.1162 0.929   0.790
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.776           0.718       0.841         0.0501 0.976   0.901
#> CV:NMF      5 0.780           0.733       0.852         0.0474 0.967   0.869
#> MAD:NMF     5 0.785           0.700       0.856         0.0510 0.939   0.775
#> ATC:NMF     5 0.740           0.764       0.836         0.0480 0.942   0.788
#> SD:skmeans  5 0.726           0.734       0.841         0.0678 0.925   0.724
#> CV:skmeans  5 0.748           0.742       0.850         0.0686 0.932   0.750
#> MAD:skmeans 5 0.790           0.773       0.865         0.0649 0.938   0.769
#> ATC:skmeans 5 0.919           0.793       0.912         0.0658 0.959   0.849
#> SD:mclust   5 0.855           0.783       0.866         0.0912 0.954   0.828
#> CV:mclust   5 0.820           0.769       0.865         0.0859 0.945   0.800
#> MAD:mclust  5 0.774           0.720       0.858         0.0788 0.902   0.653
#> ATC:mclust  5 0.857           0.800       0.814         0.0805 0.913   0.695
#> SD:kmeans   5 0.746           0.798       0.835         0.0734 0.897   0.637
#> CV:kmeans   5 0.755           0.784       0.825         0.0656 0.920   0.705
#> MAD:kmeans  5 0.747           0.756       0.813         0.0653 0.910   0.671
#> ATC:kmeans  5 0.770           0.771       0.837         0.0568 0.922   0.719
#> SD:pam      5 0.805           0.797       0.895         0.0753 0.920   0.717
#> CV:pam      5 0.820           0.781       0.884         0.0712 0.955   0.834
#> MAD:pam     5 0.872           0.834       0.914         0.0550 0.961   0.853
#> ATC:pam     5 0.990           0.941       0.975         0.0620 0.930   0.736
#> SD:hclust   5 0.839           0.749       0.861         0.0426 0.976   0.917
#> CV:hclust   5 0.844           0.770       0.870         0.0390 0.974   0.910
#> MAD:hclust  5 0.805           0.781       0.872         0.0413 0.977   0.923
#> ATC:hclust  5 0.816           0.872       0.860         0.0656 0.959   0.849
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.758           0.641       0.794         0.0380 0.950   0.784
#> CV:NMF      6 0.744           0.635       0.793         0.0433 0.947   0.774
#> MAD:NMF     6 0.751           0.640       0.800         0.0398 0.956   0.816
#> ATC:NMF     6 0.725           0.706       0.813         0.0361 0.935   0.739
#> SD:skmeans  6 0.734           0.691       0.801         0.0366 0.967   0.848
#> CV:skmeans  6 0.719           0.678       0.793         0.0371 0.961   0.822
#> MAD:skmeans 6 0.744           0.714       0.820         0.0357 0.992   0.965
#> ATC:skmeans 6 0.923           0.872       0.936         0.0319 0.965   0.852
#> SD:mclust   6 0.869           0.775       0.874         0.0506 0.915   0.642
#> CV:mclust   6 0.871           0.801       0.884         0.0525 0.921   0.671
#> MAD:mclust  6 0.818           0.713       0.830         0.0517 0.919   0.630
#> ATC:mclust  6 0.860           0.872       0.907         0.0515 0.910   0.614
#> SD:kmeans   6 0.749           0.718       0.791         0.0365 0.950   0.763
#> CV:kmeans   6 0.758           0.742       0.819         0.0431 0.950   0.766
#> MAD:kmeans  6 0.767           0.722       0.807         0.0439 0.960   0.807
#> ATC:kmeans  6 0.796           0.588       0.824         0.0426 0.977   0.894
#> SD:pam      6 0.788           0.745       0.854         0.0282 0.981   0.910
#> CV:pam      6 0.806           0.748       0.857         0.0317 0.972   0.880
#> MAD:pam     6 0.843           0.776       0.871         0.0356 0.969   0.869
#> ATC:pam     6 0.931           0.824       0.925         0.0231 0.959   0.811
#> SD:hclust   6 0.853           0.733       0.851         0.0302 0.974   0.906
#> CV:hclust   6 0.857           0.744       0.823         0.0297 0.963   0.860
#> MAD:hclust  6 0.804           0.753       0.825         0.0376 0.984   0.941
#> ATC:hclust  6 0.839           0.869       0.875         0.0287 0.981   0.918

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 cell.type(p) disease.state(p) k
#> SD:NMF      57     3.90e-13           0.0525 2
#> CV:NMF      57     3.90e-13           0.0525 2
#> MAD:NMF     51     7.81e-12           0.2057 2
#> ATC:NMF     55     3.96e-05           0.3102 2
#> SD:skmeans  57     3.90e-13           0.0525 2
#> CV:skmeans  57     3.90e-13           0.0525 2
#> MAD:skmeans 57     3.90e-13           0.0525 2
#> ATC:skmeans 55     3.96e-04           0.4648 2
#> SD:mclust   57     3.90e-13           0.0525 2
#> CV:mclust   57     3.90e-13           0.0525 2
#> MAD:mclust  57     3.90e-13           0.0525 2
#> ATC:mclust  57     1.51e-04           0.3057 2
#> SD:kmeans   57     3.90e-13           0.0525 2
#> CV:kmeans   57     3.90e-13           0.0525 2
#> MAD:kmeans  57     3.90e-13           0.0525 2
#> ATC:kmeans  55     3.96e-04           0.4648 2
#> SD:pam      52     2.17e-08           0.7907 2
#> CV:pam      53     1.24e-08           0.7651 2
#> MAD:pam     50     5.48e-07           0.6466 2
#> ATC:pam     55     9.28e-05           0.4563 2
#> SD:hclust   57     3.90e-13           0.0525 2
#> CV:hclust   57     3.90e-13           0.0525 2
#> MAD:hclust  57     3.90e-13           0.0525 2
#> ATC:hclust  57     2.04e-01           0.0251 2
test_to_known_factors(res_list, k = 3)
#>              n cell.type(p) disease.state(p) k
#> SD:NMF      56     6.91e-13         0.000873 3
#> CV:NMF      56     6.91e-13         0.000873 3
#> MAD:NMF     57     4.19e-13         0.000423 3
#> ATC:NMF     53     3.10e-12         0.000593 3
#> SD:skmeans  57     4.19e-13         0.000423 3
#> CV:skmeans  57     4.19e-13         0.000423 3
#> MAD:skmeans 57     4.19e-13         0.000423 3
#> ATC:skmeans 52     4.17e-11         0.000923 3
#> SD:mclust   57     4.19e-13         0.000276 3
#> CV:mclust   57     4.19e-13         0.000276 3
#> MAD:mclust  57     4.19e-13         0.000276 3
#> ATC:mclust  55     1.14e-12         0.000291 3
#> SD:kmeans   57     4.19e-13         0.000423 3
#> CV:kmeans   57     4.19e-13         0.000423 3
#> MAD:kmeans  57     4.19e-13         0.000423 3
#> ATC:kmeans  47     5.27e-10         0.050292 3
#> SD:pam      53     3.10e-12         0.005200 3
#> CV:pam      55     1.14e-12         0.005334 3
#> MAD:pam     54     1.88e-12         0.001248 3
#> ATC:pam     54     1.70e-11         0.000569 3
#> SD:hclust   53     3.10e-12         0.007090 3
#> CV:hclust   53     3.10e-12         0.007090 3
#> MAD:hclust  54     1.88e-12         0.001274 3
#> ATC:hclust  57     9.33e-09         0.000167 3
test_to_known_factors(res_list, k = 4)
#>              n cell.type(p) disease.state(p) k
#> SD:NMF      52     2.05e-09         2.57e-03 4
#> CV:NMF      53     1.30e-09         1.88e-04 4
#> MAD:NMF     51     1.93e-09         5.28e-05 4
#> ATC:NMF     56     9.59e-11         8.60e-06 4
#> SD:skmeans  55     6.87e-12         3.23e-04 4
#> CV:skmeans  55     6.87e-12         3.23e-04 4
#> MAD:skmeans 55     6.87e-12         1.92e-04 4
#> ATC:skmeans 51     4.89e-11         9.50e-04 4
#> SD:mclust   51     4.89e-11         1.35e-03 4
#> CV:mclust   51     4.89e-11         3.85e-04 4
#> MAD:mclust  52     3.00e-11         3.76e-04 4
#> ATC:mclust  57     2.57e-12         2.60e-04 4
#> SD:kmeans   55     6.87e-12         8.63e-04 4
#> CV:kmeans   56     4.20e-12         1.13e-03 4
#> MAD:kmeans  56     4.20e-12         2.78e-03 4
#> ATC:kmeans  52     3.00e-11         3.05e-04 4
#> SD:pam      55     4.19e-11         7.64e-04 4
#> CV:pam      54     1.12e-11         8.76e-04 4
#> MAD:pam     55     4.19e-11         1.34e-04 4
#> ATC:pam     54     6.81e-11         2.20e-04 4
#> SD:hclust   48     2.13e-10         4.95e-04 4
#> CV:hclust   48     2.13e-10         1.75e-04 4
#> MAD:hclust  56     4.20e-12         4.06e-03 4
#> ATC:hclust  57     2.57e-12         3.86e-04 4
test_to_known_factors(res_list, k = 5)
#>              n cell.type(p) disease.state(p) k
#> SD:NMF      48     4.95e-09         8.09e-03 5
#> CV:NMF      49     2.19e-08         2.57e-03 5
#> MAD:NMF     47     6.99e-09         2.87e-03 5
#> ATC:NMF     53     3.72e-10         4.55e-03 5
#> SD:skmeans  47     3.48e-10         3.31e-04 5
#> CV:skmeans  47     3.48e-10         3.31e-04 5
#> MAD:skmeans 48     2.13e-10         7.71e-04 5
#> ATC:skmeans 50     3.61e-10         1.49e-03 5
#> SD:mclust   51     2.23e-10         8.03e-03 5
#> CV:mclust   52     1.38e-10         2.55e-03 5
#> MAD:mclust  45     9.25e-10         8.97e-04 5
#> ATC:mclust  53     8.52e-11         4.08e-03 5
#> SD:kmeans   53     8.52e-11         1.10e-04 5
#> CV:kmeans   51     2.23e-10         1.06e-04 5
#> MAD:kmeans  50     3.61e-10         2.09e-04 5
#> ATC:kmeans  52     1.38e-10         6.34e-03 5
#> SD:pam      53     8.52e-11         6.78e-05 5
#> CV:pam      51     2.23e-10         8.84e-05 5
#> MAD:pam     54     3.06e-10         1.33e-04 5
#> ATC:pam     56     1.21e-10         1.00e-03 5
#> SD:hclust   49     5.84e-10         4.24e-04 5
#> CV:hclust   49     5.84e-10         8.21e-04 5
#> MAD:hclust  54     5.26e-11         3.36e-03 5
#> ATC:hclust  57     1.24e-11         9.27e-05 5
test_to_known_factors(res_list, k = 6)
#>              n cell.type(p) disease.state(p) k
#> SD:NMF      46     5.31e-08         2.44e-03 6
#> CV:NMF      45     8.29e-08         5.40e-03 6
#> MAD:NMF     47     7.51e-08         3.52e-03 6
#> ATC:NMF     52     5.39e-10         1.85e-03 6
#> SD:skmeans  46     5.67e-10         1.69e-04 6
#> CV:skmeans  47     1.52e-09         2.08e-04 6
#> MAD:skmeans 47     1.52e-09         2.44e-04 6
#> ATC:skmeans 53     3.36e-10         7.81e-04 6
#> SD:mclust   52     5.39e-10         2.51e-03 6
#> CV:mclust   52     5.39e-10         2.51e-03 6
#> MAD:mclust  44     2.32e-08         1.31e-03 6
#> ATC:mclust  55     1.31e-10         5.16e-03 6
#> SD:kmeans   49     2.22e-09         1.73e-03 6
#> CV:kmeans   47     1.52e-09         2.41e-05 6
#> MAD:kmeans  44     1.51e-09         5.58e-04 6
#> ATC:kmeans  43     1.03e-08         1.78e-02 6
#> SD:pam      44     6.42e-09         4.36e-05 6
#> CV:pam      47     1.52e-09         7.90e-05 6
#> MAD:pam     51     1.24e-09         9.48e-05 6
#> ATC:pam     52     2.97e-09         1.15e-05 6
#> SD:hclust   49     5.84e-10         3.71e-04 6
#> CV:hclust   51     8.65e-10         2.70e-05 6
#> MAD:hclust  50     3.61e-10         2.82e-04 6
#> ATC:hclust  57     5.06e-11         2.13e-04 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 11993 rows and 57 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.674           0.934       0.949         0.4687 0.536   0.536
#> 3 3 0.867           0.862       0.936         0.4099 0.793   0.614
#> 4 4 0.825           0.761       0.880         0.0953 0.956   0.868
#> 5 5 0.839           0.749       0.861         0.0426 0.976   0.917
#> 6 6 0.853           0.733       0.851         0.0302 0.974   0.906

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
#> GSM23185     1  0.6343      0.897 0.840 0.160
#> GSM23186     1  0.0938      0.930 0.988 0.012
#> GSM23187     1  0.6343      0.897 0.840 0.160
#> GSM23188     1  0.6343      0.897 0.840 0.160
#> GSM23189     1  0.6343      0.897 0.840 0.160
#> GSM23190     1  0.6343      0.897 0.840 0.160
#> GSM23191     1  0.5629      0.907 0.868 0.132
#> GSM23192     1  0.3274      0.925 0.940 0.060
#> GSM23193     1  0.5519      0.909 0.872 0.128
#> GSM23194     1  0.6247      0.899 0.844 0.156
#> GSM23195     1  0.3431      0.925 0.936 0.064
#> GSM23159     1  0.0000      0.931 1.000 0.000
#> GSM23160     1  0.6343      0.897 0.840 0.160
#> GSM23161     1  0.0000      0.931 1.000 0.000
#> GSM23162     1  0.5842      0.905 0.860 0.140
#> GSM23163     1  0.0000      0.931 1.000 0.000
#> GSM23164     1  0.0000      0.931 1.000 0.000
#> GSM23165     1  0.0000      0.931 1.000 0.000
#> GSM23166     1  0.0000      0.931 1.000 0.000
#> GSM23167     1  0.0000      0.931 1.000 0.000
#> GSM23168     1  0.6343      0.897 0.840 0.160
#> GSM23169     1  0.6247      0.899 0.844 0.156
#> GSM23170     1  0.0000      0.931 1.000 0.000
#> GSM23171     1  0.0000      0.931 1.000 0.000
#> GSM23172     1  0.0000      0.931 1.000 0.000
#> GSM23173     1  0.6148      0.901 0.848 0.152
#> GSM23174     1  0.0000      0.931 1.000 0.000
#> GSM23175     1  0.0000      0.931 1.000 0.000
#> GSM23176     1  0.0000      0.931 1.000 0.000
#> GSM23177     1  0.0000      0.931 1.000 0.000
#> GSM23178     1  0.0000      0.931 1.000 0.000
#> GSM23179     1  0.6343      0.897 0.840 0.160
#> GSM23180     1  0.0000      0.931 1.000 0.000
#> GSM23181     1  0.0000      0.931 1.000 0.000
#> GSM23182     1  0.0000      0.931 1.000 0.000
#> GSM23183     1  0.2236      0.928 0.964 0.036
#> GSM23184     1  0.6343      0.897 0.840 0.160
#> GSM23196     2  0.0000      0.975 0.000 1.000
#> GSM23197     2  0.0000      0.975 0.000 1.000
#> GSM23198     2  0.0000      0.975 0.000 1.000
#> GSM23199     2  0.0000      0.975 0.000 1.000
#> GSM23200     2  0.0000      0.975 0.000 1.000
#> GSM23201     2  0.3733      0.940 0.072 0.928
#> GSM23202     2  0.3733      0.940 0.072 0.928
#> GSM23203     2  0.0000      0.975 0.000 1.000
#> GSM23204     2  0.0000      0.975 0.000 1.000
#> GSM23205     2  0.3733      0.940 0.072 0.928
#> GSM23206     2  0.0000      0.975 0.000 1.000
#> GSM23207     2  0.0000      0.975 0.000 1.000
#> GSM23208     2  0.0000      0.975 0.000 1.000
#> GSM23209     2  0.0000      0.975 0.000 1.000
#> GSM23210     2  0.0000      0.975 0.000 1.000
#> GSM23211     2  0.0000      0.975 0.000 1.000
#> GSM23212     2  0.3733      0.940 0.072 0.928
#> GSM23213     2  0.3733      0.940 0.072 0.928
#> GSM23214     2  0.3733      0.940 0.072 0.928
#> GSM23215     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
#> GSM23185     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23186     1  0.2878      0.854 0.904 0.000 0.096
#> GSM23187     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23191     3  0.6225      0.367 0.432 0.000 0.568
#> GSM23192     1  0.6252      0.122 0.556 0.000 0.444
#> GSM23193     3  0.6267      0.308 0.452 0.000 0.548
#> GSM23194     3  0.4555      0.747 0.200 0.000 0.800
#> GSM23195     1  0.6045      0.328 0.620 0.000 0.380
#> GSM23159     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23160     3  0.1964      0.849 0.056 0.000 0.944
#> GSM23161     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23162     3  0.5138      0.710 0.252 0.000 0.748
#> GSM23163     1  0.0892      0.918 0.980 0.000 0.020
#> GSM23164     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23165     1  0.0237      0.926 0.996 0.000 0.004
#> GSM23166     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23167     1  0.0237      0.926 0.996 0.000 0.004
#> GSM23168     3  0.1643      0.851 0.044 0.000 0.956
#> GSM23169     3  0.5138      0.714 0.252 0.000 0.748
#> GSM23170     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23172     1  0.0237      0.926 0.996 0.000 0.004
#> GSM23173     3  0.4178      0.786 0.172 0.000 0.828
#> GSM23174     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23176     1  0.0237      0.926 0.996 0.000 0.004
#> GSM23177     1  0.0000      0.927 1.000 0.000 0.000
#> GSM23178     1  0.0424      0.924 0.992 0.000 0.008
#> GSM23179     3  0.1643      0.852 0.044 0.000 0.956
#> GSM23180     1  0.1411      0.908 0.964 0.000 0.036
#> GSM23181     1  0.1411      0.908 0.964 0.000 0.036
#> GSM23182     1  0.1411      0.908 0.964 0.000 0.036
#> GSM23183     1  0.5138      0.631 0.748 0.000 0.252
#> GSM23184     3  0.0000      0.852 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23201     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23202     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23203     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23205     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23206     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.974 0.000 1.000 0.000
#> GSM23212     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23213     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23214     2  0.2356      0.938 0.072 0.928 0.000
#> GSM23215     2  0.0000      0.974 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
#> GSM23185     3  0.0336     0.8064 0.000 0.000 0.992 0.008
#> GSM23186     1  0.4853     0.6189 0.744 0.000 0.036 0.220
#> GSM23187     3  0.0336     0.8064 0.000 0.000 0.992 0.008
#> GSM23188     3  0.0336     0.8064 0.000 0.000 0.992 0.008
#> GSM23189     3  0.0336     0.8064 0.000 0.000 0.992 0.008
#> GSM23190     3  0.0336     0.8064 0.000 0.000 0.992 0.008
#> GSM23191     4  0.6700     0.4910 0.112 0.000 0.316 0.572
#> GSM23192     4  0.5962     0.5694 0.180 0.000 0.128 0.692
#> GSM23193     4  0.6808     0.5324 0.128 0.000 0.300 0.572
#> GSM23194     3  0.5288    -0.0207 0.008 0.000 0.520 0.472
#> GSM23195     4  0.7516     0.3459 0.328 0.000 0.200 0.472
#> GSM23159     1  0.0921     0.8326 0.972 0.000 0.000 0.028
#> GSM23160     3  0.2443     0.7802 0.024 0.000 0.916 0.060
#> GSM23161     1  0.1716     0.8211 0.936 0.000 0.000 0.064
#> GSM23162     3  0.6005    -0.0791 0.040 0.000 0.500 0.460
#> GSM23163     1  0.3032     0.7755 0.868 0.000 0.008 0.124
#> GSM23164     1  0.2011     0.8130 0.920 0.000 0.000 0.080
#> GSM23165     1  0.1302     0.8210 0.956 0.000 0.000 0.044
#> GSM23166     1  0.1940     0.8157 0.924 0.000 0.000 0.076
#> GSM23167     1  0.1302     0.8210 0.956 0.000 0.000 0.044
#> GSM23168     3  0.2021     0.7880 0.012 0.000 0.932 0.056
#> GSM23169     3  0.6595     0.3642 0.124 0.000 0.608 0.268
#> GSM23170     1  0.1474     0.8264 0.948 0.000 0.000 0.052
#> GSM23171     1  0.0707     0.8321 0.980 0.000 0.000 0.020
#> GSM23172     1  0.1302     0.8210 0.956 0.000 0.000 0.044
#> GSM23173     3  0.5280     0.6037 0.096 0.000 0.748 0.156
#> GSM23174     1  0.0188     0.8312 0.996 0.000 0.000 0.004
#> GSM23175     1  0.0336     0.8297 0.992 0.000 0.000 0.008
#> GSM23176     1  0.1302     0.8210 0.956 0.000 0.000 0.044
#> GSM23177     1  0.1389     0.8288 0.952 0.000 0.000 0.048
#> GSM23178     1  0.1792     0.8298 0.932 0.000 0.000 0.068
#> GSM23179     3  0.1824     0.7925 0.004 0.000 0.936 0.060
#> GSM23180     1  0.4866     0.3887 0.596 0.000 0.000 0.404
#> GSM23181     1  0.4866     0.3887 0.596 0.000 0.000 0.404
#> GSM23182     1  0.4866     0.3887 0.596 0.000 0.000 0.404
#> GSM23183     1  0.6745    -0.1131 0.480 0.000 0.092 0.428
#> GSM23184     3  0.0336     0.8047 0.000 0.000 0.992 0.008
#> GSM23196     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23200     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23201     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23202     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23203     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23205     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23206     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23208     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000     0.9778 0.000 1.000 0.000 0.000
#> GSM23212     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23213     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23214     2  0.1867     0.9468 0.000 0.928 0.000 0.072
#> GSM23215     2  0.0000     0.9778 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
#> GSM23185     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.6034      0.031 0.476 0.000 0.012 0.080 0.432
#> GSM23187     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000      0.798 0.000 0.000 1.000 0.000 0.000
#> GSM23191     4  0.3825      0.763 0.060 0.000 0.136 0.804 0.000
#> GSM23192     5  0.6631      0.152 0.060 0.000 0.064 0.420 0.456
#> GSM23193     4  0.4737      0.739 0.076 0.000 0.136 0.764 0.024
#> GSM23194     3  0.6651     -0.191 0.000 0.000 0.444 0.300 0.256
#> GSM23195     5  0.4048      0.563 0.068 0.000 0.036 0.072 0.824
#> GSM23159     1  0.2228      0.788 0.912 0.000 0.000 0.040 0.048
#> GSM23160     3  0.3184      0.754 0.012 0.000 0.868 0.052 0.068
#> GSM23161     1  0.1942      0.783 0.920 0.000 0.000 0.068 0.012
#> GSM23162     4  0.5108      0.600 0.024 0.000 0.304 0.648 0.024
#> GSM23163     1  0.4550      0.640 0.744 0.000 0.004 0.064 0.188
#> GSM23164     1  0.2189      0.776 0.904 0.000 0.000 0.084 0.012
#> GSM23165     1  0.3051      0.750 0.864 0.000 0.000 0.060 0.076
#> GSM23166     1  0.2130      0.779 0.908 0.000 0.000 0.080 0.012
#> GSM23167     1  0.2989      0.752 0.868 0.000 0.000 0.060 0.072
#> GSM23168     3  0.2625      0.770 0.012 0.000 0.900 0.048 0.040
#> GSM23169     3  0.7054      0.148 0.028 0.000 0.416 0.172 0.384
#> GSM23170     1  0.1943      0.790 0.924 0.000 0.000 0.056 0.020
#> GSM23171     1  0.1310      0.795 0.956 0.000 0.000 0.024 0.020
#> GSM23172     1  0.2729      0.759 0.884 0.000 0.000 0.056 0.060
#> GSM23173     3  0.6277      0.410 0.016 0.000 0.548 0.116 0.320
#> GSM23174     1  0.0865      0.794 0.972 0.000 0.000 0.024 0.004
#> GSM23175     1  0.0798      0.793 0.976 0.000 0.000 0.008 0.016
#> GSM23176     1  0.3051      0.750 0.864 0.000 0.000 0.060 0.076
#> GSM23177     1  0.1670      0.792 0.936 0.000 0.000 0.052 0.012
#> GSM23178     1  0.2535      0.791 0.892 0.000 0.000 0.076 0.032
#> GSM23179     3  0.2536      0.772 0.004 0.000 0.900 0.044 0.052
#> GSM23180     1  0.5365      0.323 0.528 0.000 0.000 0.416 0.056
#> GSM23181     1  0.5365      0.323 0.528 0.000 0.000 0.416 0.056
#> GSM23182     1  0.5365      0.323 0.528 0.000 0.000 0.416 0.056
#> GSM23183     5  0.4519      0.578 0.188 0.000 0.012 0.048 0.752
#> GSM23184     3  0.0771      0.794 0.000 0.000 0.976 0.020 0.004
#> GSM23196     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23200     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23201     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23202     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23203     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23206     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23208     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000      0.977 0.000 1.000 0.000 0.000 0.000
#> GSM23212     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23213     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23214     2  0.1704      0.944 0.000 0.928 0.000 0.068 0.004
#> GSM23215     2  0.0000      0.977 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
#> GSM23185     3  0.0000     0.7989 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.3357     0.3405 0.224 0.000 0.004 0.008 0.000 0.764
#> GSM23187     3  0.0000     0.7989 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.7989 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.7989 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000     0.7989 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.2045     0.8090 0.028 0.000 0.024 0.028 0.920 0.000
#> GSM23192     6  0.6484     0.0289 0.016 0.000 0.052 0.088 0.416 0.428
#> GSM23193     5  0.1994     0.7888 0.040 0.000 0.020 0.008 0.924 0.008
#> GSM23194     3  0.7119    -0.1631 0.000 0.000 0.412 0.108 0.300 0.180
#> GSM23195     6  0.4467     0.3532 0.000 0.000 0.004 0.376 0.028 0.592
#> GSM23159     1  0.3060     0.7324 0.836 0.000 0.000 0.020 0.012 0.132
#> GSM23160     3  0.3445     0.5607 0.000 0.000 0.744 0.244 0.012 0.000
#> GSM23161     1  0.2003     0.7471 0.912 0.000 0.000 0.044 0.044 0.000
#> GSM23162     5  0.4735     0.6071 0.016 0.000 0.128 0.128 0.724 0.004
#> GSM23163     1  0.4569     0.5240 0.636 0.000 0.000 0.016 0.028 0.320
#> GSM23164     1  0.2258     0.7407 0.896 0.000 0.000 0.044 0.060 0.000
#> GSM23165     1  0.3708     0.6739 0.752 0.000 0.000 0.020 0.008 0.220
#> GSM23166     1  0.2190     0.7427 0.900 0.000 0.000 0.040 0.060 0.000
#> GSM23167     1  0.3623     0.6804 0.764 0.000 0.000 0.020 0.008 0.208
#> GSM23168     3  0.3488     0.6133 0.000 0.000 0.780 0.184 0.036 0.000
#> GSM23169     4  0.5388     0.6890 0.004 0.000 0.156 0.684 0.096 0.060
#> GSM23170     1  0.2245     0.7558 0.908 0.000 0.000 0.040 0.036 0.016
#> GSM23171     1  0.1838     0.7606 0.928 0.000 0.000 0.012 0.020 0.040
#> GSM23172     1  0.3393     0.6912 0.784 0.000 0.000 0.020 0.004 0.192
#> GSM23173     4  0.4928     0.6944 0.000 0.000 0.288 0.640 0.040 0.032
#> GSM23174     1  0.1787     0.7562 0.920 0.000 0.000 0.008 0.004 0.068
#> GSM23175     1  0.1434     0.7573 0.940 0.000 0.000 0.012 0.000 0.048
#> GSM23176     1  0.3652     0.6782 0.760 0.000 0.000 0.020 0.008 0.212
#> GSM23177     1  0.2007     0.7552 0.920 0.000 0.000 0.032 0.036 0.012
#> GSM23178     1  0.2896     0.7543 0.864 0.000 0.000 0.012 0.044 0.080
#> GSM23179     3  0.3003     0.6658 0.000 0.000 0.812 0.172 0.016 0.000
#> GSM23180     1  0.6134     0.1953 0.476 0.000 0.000 0.108 0.372 0.044
#> GSM23181     1  0.6134     0.1953 0.476 0.000 0.000 0.108 0.372 0.044
#> GSM23182     1  0.6134     0.1953 0.476 0.000 0.000 0.108 0.372 0.044
#> GSM23183     6  0.3606     0.4875 0.016 0.000 0.004 0.156 0.024 0.800
#> GSM23184     3  0.0972     0.7848 0.000 0.000 0.964 0.028 0.008 0.000
#> GSM23196     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.0146     0.9712 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23200     2  0.0146     0.9712 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23201     2  0.1942     0.9346 0.000 0.916 0.000 0.064 0.012 0.008
#> GSM23202     2  0.2001     0.9339 0.000 0.912 0.000 0.068 0.012 0.008
#> GSM23203     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     2  0.1942     0.9346 0.000 0.916 0.000 0.064 0.012 0.008
#> GSM23206     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.0146     0.9712 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23208     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0146     0.9712 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23211     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     2  0.2001     0.9339 0.000 0.912 0.000 0.068 0.012 0.008
#> GSM23213     2  0.2001     0.9339 0.000 0.912 0.000 0.068 0.012 0.008
#> GSM23214     2  0.2001     0.9339 0.000 0.912 0.000 0.068 0.012 0.008
#> GSM23215     2  0.0000     0.9719 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-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 cell.type(p) disease.state(p) k
#> SD:hclust 57     3.90e-13         0.052490 2
#> SD:hclust 53     3.10e-12         0.007090 3
#> SD:hclust 48     2.13e-10         0.000495 4
#> SD:hclust 49     5.84e-10         0.000424 5
#> SD:hclust 49     5.84e-10         0.000371 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 11993 rows and 57 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.975       0.982         0.4667 0.536   0.536
#> 3 3 0.713           0.941       0.908         0.3995 0.786   0.600
#> 4 4 0.755           0.781       0.819         0.1217 0.943   0.823
#> 5 5 0.746           0.798       0.835         0.0734 0.897   0.637
#> 6 6 0.749           0.718       0.791         0.0365 0.950   0.763

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
#> GSM23185     1  0.3274      0.951 0.940 0.060
#> GSM23186     1  0.0000      0.974 1.000 0.000
#> GSM23187     1  0.3274      0.951 0.940 0.060
#> GSM23188     1  0.3274      0.951 0.940 0.060
#> GSM23189     1  0.3274      0.951 0.940 0.060
#> GSM23190     1  0.3274      0.951 0.940 0.060
#> GSM23191     1  0.0000      0.974 1.000 0.000
#> GSM23192     1  0.0000      0.974 1.000 0.000
#> GSM23193     1  0.0000      0.974 1.000 0.000
#> GSM23194     1  0.3274      0.951 0.940 0.060
#> GSM23195     1  0.0000      0.974 1.000 0.000
#> GSM23159     1  0.1184      0.978 0.984 0.016
#> GSM23160     1  0.3274      0.951 0.940 0.060
#> GSM23161     1  0.1184      0.978 0.984 0.016
#> GSM23162     1  0.0672      0.974 0.992 0.008
#> GSM23163     1  0.1184      0.978 0.984 0.016
#> GSM23164     1  0.1184      0.978 0.984 0.016
#> GSM23165     1  0.1184      0.978 0.984 0.016
#> GSM23166     1  0.1184      0.978 0.984 0.016
#> GSM23167     1  0.1184      0.978 0.984 0.016
#> GSM23168     1  0.3274      0.951 0.940 0.060
#> GSM23169     1  0.0000      0.974 1.000 0.000
#> GSM23170     1  0.1184      0.978 0.984 0.016
#> GSM23171     1  0.1184      0.978 0.984 0.016
#> GSM23172     1  0.1184      0.978 0.984 0.016
#> GSM23173     1  0.0000      0.974 1.000 0.000
#> GSM23174     1  0.1184      0.978 0.984 0.016
#> GSM23175     1  0.1184      0.978 0.984 0.016
#> GSM23176     1  0.1184      0.978 0.984 0.016
#> GSM23177     1  0.1184      0.978 0.984 0.016
#> GSM23178     1  0.1184      0.978 0.984 0.016
#> GSM23179     1  0.3274      0.951 0.940 0.060
#> GSM23180     1  0.1184      0.978 0.984 0.016
#> GSM23181     1  0.1184      0.978 0.984 0.016
#> GSM23182     1  0.1184      0.978 0.984 0.016
#> GSM23183     1  0.0000      0.974 1.000 0.000
#> GSM23184     1  0.3274      0.951 0.940 0.060
#> GSM23196     2  0.0000      0.991 0.000 1.000
#> GSM23197     2  0.0000      0.991 0.000 1.000
#> GSM23198     2  0.0000      0.991 0.000 1.000
#> GSM23199     2  0.0000      0.991 0.000 1.000
#> GSM23200     2  0.0000      0.991 0.000 1.000
#> GSM23201     2  0.0000      0.991 0.000 1.000
#> GSM23202     2  0.2948      0.950 0.052 0.948
#> GSM23203     2  0.0000      0.991 0.000 1.000
#> GSM23204     2  0.0000      0.991 0.000 1.000
#> GSM23205     2  0.0000      0.991 0.000 1.000
#> GSM23206     2  0.0000      0.991 0.000 1.000
#> GSM23207     2  0.0000      0.991 0.000 1.000
#> GSM23208     2  0.0000      0.991 0.000 1.000
#> GSM23209     2  0.0000      0.991 0.000 1.000
#> GSM23210     2  0.0000      0.991 0.000 1.000
#> GSM23211     2  0.0000      0.991 0.000 1.000
#> GSM23212     2  0.0000      0.991 0.000 1.000
#> GSM23213     2  0.2948      0.950 0.052 0.948
#> GSM23214     2  0.2948      0.950 0.052 0.948
#> GSM23215     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
#> GSM23185     3  0.0000      0.929 0.000 0.000 1.000
#> GSM23186     1  0.4887      0.881 0.772 0.000 0.228
#> GSM23187     3  0.0000      0.929 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.929 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.929 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.929 0.000 0.000 1.000
#> GSM23191     3  0.4172      0.840 0.156 0.004 0.840
#> GSM23192     3  0.4399      0.800 0.188 0.000 0.812
#> GSM23193     3  0.3784      0.864 0.132 0.004 0.864
#> GSM23194     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23195     3  0.4233      0.833 0.160 0.004 0.836
#> GSM23159     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23160     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23161     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23162     3  0.1267      0.938 0.024 0.004 0.972
#> GSM23163     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23164     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23165     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23166     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23167     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23168     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23169     3  0.1267      0.938 0.024 0.004 0.972
#> GSM23170     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23171     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23172     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23173     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23174     1  0.3619      0.984 0.864 0.000 0.136
#> GSM23175     1  0.3619      0.984 0.864 0.000 0.136
#> GSM23176     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23177     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23178     1  0.3752      0.989 0.856 0.000 0.144
#> GSM23179     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23180     1  0.3851      0.982 0.860 0.004 0.136
#> GSM23181     1  0.3619      0.984 0.864 0.000 0.136
#> GSM23182     1  0.3573      0.962 0.876 0.004 0.120
#> GSM23183     3  0.4399      0.798 0.188 0.000 0.812
#> GSM23184     3  0.1031      0.939 0.024 0.000 0.976
#> GSM23196     2  0.4270      0.940 0.116 0.860 0.024
#> GSM23197     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23198     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23199     2  0.0000      0.932 0.000 1.000 0.000
#> GSM23200     2  0.2959      0.940 0.100 0.900 0.000
#> GSM23201     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23202     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23203     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23204     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23205     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23206     2  0.4270      0.940 0.116 0.860 0.024
#> GSM23207     2  0.0892      0.929 0.020 0.980 0.000
#> GSM23208     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23209     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23210     2  0.0237      0.932 0.004 0.996 0.000
#> GSM23211     2  0.4397      0.939 0.116 0.856 0.028
#> GSM23212     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23213     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23214     2  0.1163      0.927 0.028 0.972 0.000
#> GSM23215     2  0.3886      0.941 0.096 0.880 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.1209      0.861 0.032 0.000 0.964 0.004
#> GSM23186     1  0.4635      0.781 0.796 0.000 0.080 0.124
#> GSM23187     3  0.1356      0.861 0.032 0.000 0.960 0.008
#> GSM23188     3  0.1356      0.861 0.032 0.000 0.960 0.008
#> GSM23189     3  0.1356      0.861 0.032 0.000 0.960 0.008
#> GSM23190     3  0.1356      0.861 0.032 0.000 0.960 0.008
#> GSM23191     3  0.7201      0.625 0.148 0.000 0.496 0.356
#> GSM23192     3  0.7030      0.626 0.120 0.000 0.472 0.408
#> GSM23193     3  0.7013      0.651 0.128 0.000 0.516 0.356
#> GSM23194     3  0.2722      0.857 0.032 0.000 0.904 0.064
#> GSM23195     3  0.7164      0.660 0.156 0.000 0.524 0.320
#> GSM23159     1  0.0469      0.917 0.988 0.000 0.000 0.012
#> GSM23160     3  0.1022      0.861 0.032 0.000 0.968 0.000
#> GSM23161     1  0.0921      0.910 0.972 0.000 0.000 0.028
#> GSM23162     3  0.4375      0.828 0.032 0.000 0.788 0.180
#> GSM23163     1  0.1211      0.910 0.960 0.000 0.000 0.040
#> GSM23164     1  0.1867      0.889 0.928 0.000 0.000 0.072
#> GSM23165     1  0.1118      0.912 0.964 0.000 0.000 0.036
#> GSM23166     1  0.1867      0.889 0.928 0.000 0.000 0.072
#> GSM23167     1  0.1118      0.912 0.964 0.000 0.000 0.036
#> GSM23168     3  0.1022      0.861 0.032 0.000 0.968 0.000
#> GSM23169     3  0.4199      0.834 0.032 0.000 0.804 0.164
#> GSM23170     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0188      0.917 0.996 0.000 0.000 0.004
#> GSM23172     1  0.1118      0.912 0.964 0.000 0.000 0.036
#> GSM23173     3  0.3694      0.844 0.032 0.000 0.844 0.124
#> GSM23174     1  0.0188      0.916 0.996 0.000 0.000 0.004
#> GSM23175     1  0.0000      0.917 1.000 0.000 0.000 0.000
#> GSM23176     1  0.1118      0.912 0.964 0.000 0.000 0.036
#> GSM23177     1  0.0188      0.916 0.996 0.000 0.000 0.004
#> GSM23178     1  0.0592      0.917 0.984 0.000 0.000 0.016
#> GSM23179     3  0.1022      0.861 0.032 0.000 0.968 0.000
#> GSM23180     1  0.4898      0.572 0.584 0.000 0.000 0.416
#> GSM23181     1  0.3873      0.779 0.772 0.000 0.000 0.228
#> GSM23182     1  0.4941      0.550 0.564 0.000 0.000 0.436
#> GSM23183     3  0.7258      0.642 0.164 0.000 0.508 0.328
#> GSM23184     3  0.1022      0.861 0.032 0.000 0.968 0.000
#> GSM23196     2  0.0188      0.823 0.000 0.996 0.004 0.000
#> GSM23197     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0188      0.823 0.000 0.996 0.004 0.000
#> GSM23199     2  0.5493     -0.767 0.000 0.528 0.016 0.456
#> GSM23200     2  0.2021      0.746 0.000 0.932 0.012 0.056
#> GSM23201     4  0.5558      0.955 0.000 0.432 0.020 0.548
#> GSM23202     4  0.4933      0.965 0.000 0.432 0.000 0.568
#> GSM23203     2  0.0188      0.823 0.000 0.996 0.004 0.000
#> GSM23204     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM23205     4  0.5558      0.955 0.000 0.432 0.020 0.548
#> GSM23206     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM23207     4  0.5296      0.833 0.000 0.492 0.008 0.500
#> GSM23208     2  0.0188      0.823 0.000 0.996 0.004 0.000
#> GSM23209     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM23210     2  0.5760     -0.771 0.000 0.524 0.028 0.448
#> GSM23211     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM23212     4  0.4933      0.965 0.000 0.432 0.000 0.568
#> GSM23213     4  0.4933      0.965 0.000 0.432 0.000 0.568
#> GSM23214     4  0.4933      0.965 0.000 0.432 0.000 0.568
#> GSM23215     2  0.3307      0.619 0.000 0.868 0.028 0.104

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0579      0.857 0.008 0.000 0.984 0.008 0.000
#> GSM23186     1  0.7068      0.320 0.516 0.000 0.040 0.208 0.236
#> GSM23187     3  0.0579      0.857 0.008 0.000 0.984 0.008 0.000
#> GSM23188     3  0.0579      0.857 0.008 0.000 0.984 0.008 0.000
#> GSM23189     3  0.0579      0.857 0.008 0.000 0.984 0.008 0.000
#> GSM23190     3  0.0579      0.857 0.008 0.000 0.984 0.008 0.000
#> GSM23191     5  0.4865      0.645 0.088 0.000 0.160 0.012 0.740
#> GSM23192     5  0.5687      0.653 0.064 0.000 0.108 0.120 0.708
#> GSM23193     5  0.4812      0.630 0.076 0.000 0.172 0.012 0.740
#> GSM23194     3  0.4314      0.708 0.008 0.000 0.780 0.068 0.144
#> GSM23195     5  0.7015      0.518 0.064 0.000 0.192 0.184 0.560
#> GSM23159     1  0.1211      0.885 0.960 0.000 0.000 0.016 0.024
#> GSM23160     3  0.1405      0.850 0.008 0.000 0.956 0.016 0.020
#> GSM23161     1  0.1774      0.858 0.932 0.000 0.000 0.016 0.052
#> GSM23162     3  0.5218      0.216 0.008 0.000 0.516 0.028 0.448
#> GSM23163     1  0.3670      0.841 0.820 0.000 0.000 0.068 0.112
#> GSM23164     1  0.2077      0.832 0.908 0.000 0.000 0.008 0.084
#> GSM23165     1  0.3090      0.853 0.860 0.000 0.000 0.052 0.088
#> GSM23166     1  0.1894      0.842 0.920 0.000 0.000 0.008 0.072
#> GSM23167     1  0.3090      0.853 0.860 0.000 0.000 0.052 0.088
#> GSM23168     3  0.1405      0.850 0.008 0.000 0.956 0.016 0.020
#> GSM23169     3  0.6335      0.314 0.008 0.000 0.528 0.144 0.320
#> GSM23170     1  0.0162      0.883 0.996 0.000 0.000 0.004 0.000
#> GSM23171     1  0.0162      0.885 0.996 0.000 0.000 0.004 0.000
#> GSM23172     1  0.3019      0.854 0.864 0.000 0.000 0.048 0.088
#> GSM23173     3  0.5124      0.643 0.008 0.000 0.704 0.092 0.196
#> GSM23174     1  0.0290      0.883 0.992 0.000 0.000 0.008 0.000
#> GSM23175     1  0.0162      0.884 0.996 0.000 0.000 0.004 0.000
#> GSM23176     1  0.3090      0.853 0.860 0.000 0.000 0.052 0.088
#> GSM23177     1  0.0566      0.880 0.984 0.000 0.000 0.004 0.012
#> GSM23178     1  0.2300      0.873 0.904 0.000 0.000 0.024 0.072
#> GSM23179     3  0.1200      0.852 0.008 0.000 0.964 0.016 0.012
#> GSM23180     5  0.3916      0.642 0.256 0.000 0.000 0.012 0.732
#> GSM23181     5  0.4446      0.200 0.476 0.000 0.000 0.004 0.520
#> GSM23182     5  0.4817      0.614 0.264 0.000 0.000 0.056 0.680
#> GSM23183     5  0.6843      0.523 0.052 0.000 0.196 0.180 0.572
#> GSM23184     3  0.0290      0.857 0.008 0.000 0.992 0.000 0.000
#> GSM23196     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0451      0.947 0.000 0.988 0.004 0.000 0.008
#> GSM23198     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.4538      0.858 0.000 0.348 0.004 0.636 0.012
#> GSM23200     2  0.2930      0.711 0.000 0.832 0.000 0.164 0.004
#> GSM23201     4  0.5158      0.920 0.000 0.264 0.000 0.656 0.080
#> GSM23202     4  0.4326      0.937 0.000 0.264 0.000 0.708 0.028
#> GSM23203     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0451      0.947 0.000 0.988 0.004 0.000 0.008
#> GSM23205     4  0.5105      0.920 0.000 0.264 0.000 0.660 0.076
#> GSM23206     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000
#> GSM23207     4  0.4109      0.927 0.000 0.288 0.000 0.700 0.012
#> GSM23208     2  0.0000      0.949 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0451      0.947 0.000 0.988 0.004 0.000 0.008
#> GSM23210     4  0.5213      0.882 0.000 0.320 0.000 0.616 0.064
#> GSM23211     2  0.0451      0.947 0.000 0.988 0.004 0.000 0.008
#> GSM23212     4  0.3967      0.938 0.000 0.264 0.000 0.724 0.012
#> GSM23213     4  0.3967      0.938 0.000 0.264 0.000 0.724 0.012
#> GSM23214     4  0.4326      0.937 0.000 0.264 0.000 0.708 0.028
#> GSM23215     2  0.3758      0.732 0.000 0.824 0.008 0.112 0.056

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.0000     0.8538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.5310     0.2331 0.316 0.032 0.012 0.000 0.036 0.604
#> GSM23187     3  0.0146     0.8547 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23188     3  0.0146     0.8547 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23189     3  0.0146     0.8547 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23190     3  0.0000     0.8538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.2267     0.5158 0.020 0.004 0.064 0.000 0.904 0.008
#> GSM23192     5  0.5319    -0.0768 0.020 0.008 0.044 0.000 0.544 0.384
#> GSM23193     5  0.2238     0.5115 0.016 0.004 0.068 0.000 0.904 0.008
#> GSM23194     3  0.5862     0.4624 0.000 0.056 0.616 0.000 0.184 0.144
#> GSM23195     6  0.5762     0.5137 0.052 0.000 0.104 0.000 0.236 0.608
#> GSM23159     1  0.1232     0.8834 0.956 0.016 0.000 0.000 0.004 0.024
#> GSM23160     3  0.2872     0.8299 0.000 0.080 0.868 0.000 0.024 0.028
#> GSM23161     1  0.2113     0.8599 0.912 0.048 0.000 0.000 0.032 0.008
#> GSM23162     5  0.5233     0.1495 0.000 0.072 0.260 0.000 0.636 0.032
#> GSM23163     1  0.3917     0.8216 0.784 0.052 0.000 0.000 0.020 0.144
#> GSM23164     1  0.2789     0.8145 0.864 0.044 0.000 0.000 0.088 0.004
#> GSM23165     1  0.3395     0.8182 0.812 0.048 0.000 0.000 0.004 0.136
#> GSM23166     1  0.2519     0.8349 0.884 0.044 0.000 0.000 0.068 0.004
#> GSM23167     1  0.3314     0.8241 0.820 0.048 0.000 0.000 0.004 0.128
#> GSM23168     3  0.2793     0.8299 0.000 0.080 0.872 0.000 0.024 0.024
#> GSM23169     6  0.7156     0.2336 0.000 0.080 0.292 0.000 0.268 0.360
#> GSM23170     1  0.1307     0.8813 0.952 0.032 0.000 0.000 0.008 0.008
#> GSM23171     1  0.0508     0.8844 0.984 0.012 0.000 0.000 0.004 0.000
#> GSM23172     1  0.3355     0.8218 0.816 0.048 0.000 0.000 0.004 0.132
#> GSM23173     3  0.6783     0.1655 0.004 0.092 0.484 0.000 0.128 0.292
#> GSM23174     1  0.0909     0.8812 0.968 0.020 0.000 0.000 0.012 0.000
#> GSM23175     1  0.0508     0.8836 0.984 0.004 0.000 0.000 0.012 0.000
#> GSM23176     1  0.3355     0.8218 0.816 0.048 0.000 0.000 0.004 0.132
#> GSM23177     1  0.1251     0.8784 0.956 0.024 0.000 0.000 0.012 0.008
#> GSM23178     1  0.3019     0.8657 0.864 0.048 0.000 0.000 0.028 0.060
#> GSM23179     3  0.3019     0.8261 0.000 0.080 0.860 0.000 0.024 0.036
#> GSM23180     5  0.4668     0.5434 0.208 0.048 0.000 0.004 0.712 0.028
#> GSM23181     5  0.5126     0.4135 0.348 0.048 0.000 0.000 0.580 0.024
#> GSM23182     5  0.5122     0.5339 0.220 0.048 0.000 0.024 0.684 0.024
#> GSM23183     6  0.5651     0.5044 0.040 0.000 0.104 0.000 0.248 0.608
#> GSM23184     3  0.1296     0.8512 0.000 0.032 0.952 0.000 0.004 0.012
#> GSM23196     2  0.3352     0.9450 0.000 0.776 0.000 0.208 0.008 0.008
#> GSM23197     2  0.3243     0.9502 0.000 0.780 0.000 0.208 0.004 0.008
#> GSM23198     2  0.3352     0.9450 0.000 0.776 0.000 0.208 0.008 0.008
#> GSM23199     4  0.3514     0.7692 0.000 0.040 0.000 0.832 0.048 0.080
#> GSM23200     4  0.5477    -0.3743 0.000 0.452 0.000 0.464 0.040 0.044
#> GSM23201     4  0.3617     0.7602 0.000 0.000 0.000 0.736 0.020 0.244
#> GSM23202     4  0.1686     0.8094 0.000 0.000 0.000 0.924 0.012 0.064
#> GSM23203     2  0.3352     0.9450 0.000 0.776 0.000 0.208 0.008 0.008
#> GSM23204     2  0.3341     0.9496 0.000 0.776 0.000 0.208 0.004 0.012
#> GSM23205     4  0.3617     0.7602 0.000 0.000 0.000 0.736 0.020 0.244
#> GSM23206     2  0.2994     0.9506 0.000 0.788 0.000 0.208 0.000 0.004
#> GSM23207     4  0.1552     0.8041 0.000 0.004 0.000 0.940 0.020 0.036
#> GSM23208     2  0.2854     0.9501 0.000 0.792 0.000 0.208 0.000 0.000
#> GSM23209     2  0.3341     0.9496 0.000 0.776 0.000 0.208 0.004 0.012
#> GSM23210     4  0.3867     0.7650 0.000 0.008 0.000 0.760 0.040 0.192
#> GSM23211     2  0.3341     0.9496 0.000 0.776 0.000 0.208 0.004 0.012
#> GSM23212     4  0.0146     0.8154 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM23213     4  0.0146     0.8154 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM23214     4  0.1625     0.8102 0.000 0.000 0.000 0.928 0.012 0.060
#> GSM23215     2  0.5992     0.5803 0.000 0.532 0.000 0.288 0.024 0.156

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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 cell.type(p) disease.state(p) k
#> SD:kmeans 57     3.90e-13         0.052490 2
#> SD:kmeans 57     4.19e-13         0.000423 3
#> SD:kmeans 55     6.87e-12         0.000863 4
#> SD:kmeans 53     8.52e-11         0.000110 5
#> SD:kmeans 49     2.22e-09         0.001727 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 11993 rows and 57 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 1.000           1.000       1.000         0.4642 0.536   0.536
#> 3 3 1.000           0.989       0.995         0.4609 0.786   0.600
#> 4 4 0.797           0.851       0.901         0.0898 0.932   0.792
#> 5 5 0.726           0.734       0.841         0.0678 0.925   0.724
#> 6 6 0.734           0.691       0.801         0.0366 0.967   0.848

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
#> GSM23185     1       0          1  1  0
#> GSM23186     1       0          1  1  0
#> GSM23187     1       0          1  1  0
#> GSM23188     1       0          1  1  0
#> GSM23189     1       0          1  1  0
#> GSM23190     1       0          1  1  0
#> GSM23191     1       0          1  1  0
#> GSM23192     1       0          1  1  0
#> GSM23193     1       0          1  1  0
#> GSM23194     1       0          1  1  0
#> GSM23195     1       0          1  1  0
#> GSM23159     1       0          1  1  0
#> GSM23160     1       0          1  1  0
#> GSM23161     1       0          1  1  0
#> GSM23162     1       0          1  1  0
#> GSM23163     1       0          1  1  0
#> GSM23164     1       0          1  1  0
#> GSM23165     1       0          1  1  0
#> GSM23166     1       0          1  1  0
#> GSM23167     1       0          1  1  0
#> GSM23168     1       0          1  1  0
#> GSM23169     1       0          1  1  0
#> GSM23170     1       0          1  1  0
#> GSM23171     1       0          1  1  0
#> GSM23172     1       0          1  1  0
#> GSM23173     1       0          1  1  0
#> GSM23174     1       0          1  1  0
#> GSM23175     1       0          1  1  0
#> GSM23176     1       0          1  1  0
#> GSM23177     1       0          1  1  0
#> GSM23178     1       0          1  1  0
#> GSM23179     1       0          1  1  0
#> GSM23180     1       0          1  1  0
#> GSM23181     1       0          1  1  0
#> GSM23182     1       0          1  1  0
#> GSM23183     1       0          1  1  0
#> GSM23184     1       0          1  1  0
#> GSM23196     2       0          1  0  1
#> GSM23197     2       0          1  0  1
#> GSM23198     2       0          1  0  1
#> GSM23199     2       0          1  0  1
#> GSM23200     2       0          1  0  1
#> GSM23201     2       0          1  0  1
#> GSM23202     2       0          1  0  1
#> GSM23203     2       0          1  0  1
#> GSM23204     2       0          1  0  1
#> GSM23205     2       0          1  0  1
#> GSM23206     2       0          1  0  1
#> GSM23207     2       0          1  0  1
#> GSM23208     2       0          1  0  1
#> GSM23209     2       0          1  0  1
#> GSM23210     2       0          1  0  1
#> GSM23211     2       0          1  0  1
#> GSM23212     2       0          1  0  1
#> GSM23213     2       0          1  0  1
#> GSM23214     2       0          1  0  1
#> GSM23215     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM23185     3  0.0000      0.992 0.000  0 1.000
#> GSM23186     1  0.4062      0.804 0.836  0 0.164
#> GSM23187     3  0.0000      0.992 0.000  0 1.000
#> GSM23188     3  0.0000      0.992 0.000  0 1.000
#> GSM23189     3  0.0000      0.992 0.000  0 1.000
#> GSM23190     3  0.0000      0.992 0.000  0 1.000
#> GSM23191     3  0.1643      0.956 0.044  0 0.956
#> GSM23192     3  0.1031      0.975 0.024  0 0.976
#> GSM23193     3  0.0424      0.987 0.008  0 0.992
#> GSM23194     3  0.0000      0.992 0.000  0 1.000
#> GSM23195     3  0.0237      0.989 0.004  0 0.996
#> GSM23159     1  0.0000      0.991 1.000  0 0.000
#> GSM23160     3  0.0000      0.992 0.000  0 1.000
#> GSM23161     1  0.0000      0.991 1.000  0 0.000
#> GSM23162     3  0.0000      0.992 0.000  0 1.000
#> GSM23163     1  0.0237      0.987 0.996  0 0.004
#> GSM23164     1  0.0000      0.991 1.000  0 0.000
#> GSM23165     1  0.0000      0.991 1.000  0 0.000
#> GSM23166     1  0.0000      0.991 1.000  0 0.000
#> GSM23167     1  0.0000      0.991 1.000  0 0.000
#> GSM23168     3  0.0000      0.992 0.000  0 1.000
#> GSM23169     3  0.0000      0.992 0.000  0 1.000
#> GSM23170     1  0.0000      0.991 1.000  0 0.000
#> GSM23171     1  0.0000      0.991 1.000  0 0.000
#> GSM23172     1  0.0000      0.991 1.000  0 0.000
#> GSM23173     3  0.0000      0.992 0.000  0 1.000
#> GSM23174     1  0.0000      0.991 1.000  0 0.000
#> GSM23175     1  0.0000      0.991 1.000  0 0.000
#> GSM23176     1  0.0000      0.991 1.000  0 0.000
#> GSM23177     1  0.0000      0.991 1.000  0 0.000
#> GSM23178     1  0.0000      0.991 1.000  0 0.000
#> GSM23179     3  0.0000      0.992 0.000  0 1.000
#> GSM23180     1  0.0000      0.991 1.000  0 0.000
#> GSM23181     1  0.0000      0.991 1.000  0 0.000
#> GSM23182     1  0.0000      0.991 1.000  0 0.000
#> GSM23183     3  0.2066      0.939 0.060  0 0.940
#> GSM23184     3  0.0000      0.992 0.000  0 1.000
#> GSM23196     2  0.0000      1.000 0.000  1 0.000
#> GSM23197     2  0.0000      1.000 0.000  1 0.000
#> GSM23198     2  0.0000      1.000 0.000  1 0.000
#> GSM23199     2  0.0000      1.000 0.000  1 0.000
#> GSM23200     2  0.0000      1.000 0.000  1 0.000
#> GSM23201     2  0.0000      1.000 0.000  1 0.000
#> GSM23202     2  0.0000      1.000 0.000  1 0.000
#> GSM23203     2  0.0000      1.000 0.000  1 0.000
#> GSM23204     2  0.0000      1.000 0.000  1 0.000
#> GSM23205     2  0.0000      1.000 0.000  1 0.000
#> GSM23206     2  0.0000      1.000 0.000  1 0.000
#> GSM23207     2  0.0000      1.000 0.000  1 0.000
#> GSM23208     2  0.0000      1.000 0.000  1 0.000
#> GSM23209     2  0.0000      1.000 0.000  1 0.000
#> GSM23210     2  0.0000      1.000 0.000  1 0.000
#> GSM23211     2  0.0000      1.000 0.000  1 0.000
#> GSM23212     2  0.0000      1.000 0.000  1 0.000
#> GSM23213     2  0.0000      1.000 0.000  1 0.000
#> GSM23214     2  0.0000      1.000 0.000  1 0.000
#> GSM23215     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
#> GSM23185     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23186     1  0.4072      0.791 0.828 0.000 0.120 0.052
#> GSM23187     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23191     3  0.5693      0.713 0.072 0.000 0.688 0.240
#> GSM23192     3  0.5874      0.721 0.124 0.000 0.700 0.176
#> GSM23193     3  0.4281      0.809 0.028 0.000 0.792 0.180
#> GSM23194     3  0.0336      0.921 0.000 0.000 0.992 0.008
#> GSM23195     3  0.4010      0.834 0.100 0.000 0.836 0.064
#> GSM23159     1  0.0817      0.926 0.976 0.000 0.000 0.024
#> GSM23160     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23161     1  0.2281      0.909 0.904 0.000 0.000 0.096
#> GSM23162     3  0.1716      0.900 0.000 0.000 0.936 0.064
#> GSM23163     1  0.1824      0.918 0.936 0.000 0.004 0.060
#> GSM23164     1  0.2408      0.904 0.896 0.000 0.000 0.104
#> GSM23165     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM23166     1  0.2408      0.903 0.896 0.000 0.000 0.104
#> GSM23167     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM23168     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23169     3  0.1109      0.915 0.004 0.000 0.968 0.028
#> GSM23170     1  0.0817      0.926 0.976 0.000 0.000 0.024
#> GSM23171     1  0.0469      0.925 0.988 0.000 0.000 0.012
#> GSM23172     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM23173     3  0.0927      0.915 0.008 0.000 0.976 0.016
#> GSM23174     1  0.1389      0.923 0.952 0.000 0.000 0.048
#> GSM23175     1  0.0921      0.926 0.972 0.000 0.000 0.028
#> GSM23176     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM23177     1  0.1302      0.924 0.956 0.000 0.000 0.044
#> GSM23178     1  0.1867      0.920 0.928 0.000 0.000 0.072
#> GSM23179     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23180     1  0.4898      0.537 0.584 0.000 0.000 0.416
#> GSM23181     1  0.3688      0.829 0.792 0.000 0.000 0.208
#> GSM23182     4  0.4916     -0.215 0.424 0.000 0.000 0.576
#> GSM23183     3  0.5889      0.681 0.212 0.000 0.688 0.100
#> GSM23184     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23199     2  0.3074      0.773 0.000 0.848 0.000 0.152
#> GSM23200     2  0.0921      0.917 0.000 0.972 0.000 0.028
#> GSM23201     4  0.4103      0.830 0.000 0.256 0.000 0.744
#> GSM23202     4  0.4103      0.830 0.000 0.256 0.000 0.744
#> GSM23203     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23205     4  0.4500      0.750 0.000 0.316 0.000 0.684
#> GSM23206     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23207     2  0.4661      0.305 0.000 0.652 0.000 0.348
#> GSM23208     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23210     2  0.2469      0.835 0.000 0.892 0.000 0.108
#> GSM23211     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM23212     4  0.4103      0.830 0.000 0.256 0.000 0.744
#> GSM23213     4  0.4103      0.830 0.000 0.256 0.000 0.744
#> GSM23214     4  0.4103      0.830 0.000 0.256 0.000 0.744
#> GSM23215     2  0.0188      0.934 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0671   0.907273 0.000 0.000 0.980 0.004 0.016
#> GSM23186     1  0.6636   0.240602 0.544 0.000 0.132 0.032 0.292
#> GSM23187     3  0.0579   0.907035 0.000 0.000 0.984 0.008 0.008
#> GSM23188     3  0.1082   0.903437 0.000 0.000 0.964 0.008 0.028
#> GSM23189     3  0.0324   0.907265 0.000 0.000 0.992 0.004 0.004
#> GSM23190     3  0.0451   0.908177 0.000 0.000 0.988 0.004 0.008
#> GSM23191     5  0.5337   0.485622 0.060 0.000 0.192 0.040 0.708
#> GSM23192     5  0.5388   0.450453 0.068 0.000 0.224 0.024 0.684
#> GSM23193     5  0.5382   0.314772 0.040 0.000 0.340 0.016 0.604
#> GSM23194     3  0.2660   0.832657 0.000 0.000 0.864 0.008 0.128
#> GSM23195     5  0.7086   0.121136 0.156 0.000 0.380 0.036 0.428
#> GSM23159     1  0.2179   0.821079 0.896 0.000 0.000 0.004 0.100
#> GSM23160     3  0.0609   0.904793 0.000 0.000 0.980 0.000 0.020
#> GSM23161     1  0.3724   0.751335 0.788 0.000 0.000 0.028 0.184
#> GSM23162     3  0.3783   0.661752 0.000 0.000 0.740 0.008 0.252
#> GSM23163     1  0.3850   0.756733 0.792 0.000 0.004 0.032 0.172
#> GSM23164     1  0.3779   0.740278 0.776 0.000 0.000 0.024 0.200
#> GSM23165     1  0.2361   0.794575 0.892 0.000 0.000 0.012 0.096
#> GSM23166     1  0.3863   0.725719 0.772 0.000 0.000 0.028 0.200
#> GSM23167     1  0.1942   0.810955 0.920 0.000 0.000 0.012 0.068
#> GSM23168     3  0.1740   0.887128 0.000 0.000 0.932 0.012 0.056
#> GSM23169     3  0.4615   0.702309 0.020 0.000 0.736 0.032 0.212
#> GSM23170     1  0.2331   0.825362 0.900 0.000 0.000 0.020 0.080
#> GSM23171     1  0.1845   0.829795 0.928 0.000 0.000 0.016 0.056
#> GSM23172     1  0.1830   0.809591 0.924 0.000 0.000 0.008 0.068
#> GSM23173     3  0.3913   0.796277 0.036 0.000 0.824 0.032 0.108
#> GSM23174     1  0.2304   0.813016 0.892 0.000 0.000 0.008 0.100
#> GSM23175     1  0.2597   0.820342 0.884 0.000 0.000 0.024 0.092
#> GSM23176     1  0.2448   0.807232 0.892 0.000 0.000 0.020 0.088
#> GSM23177     1  0.2293   0.821006 0.900 0.000 0.000 0.016 0.084
#> GSM23178     1  0.3476   0.793023 0.804 0.000 0.000 0.020 0.176
#> GSM23179     3  0.1041   0.903659 0.000 0.000 0.964 0.004 0.032
#> GSM23180     5  0.5804   0.303491 0.304 0.000 0.000 0.120 0.576
#> GSM23181     5  0.5238  -0.159726 0.476 0.000 0.000 0.044 0.480
#> GSM23182     5  0.6578   0.295627 0.284 0.000 0.000 0.248 0.468
#> GSM23183     5  0.7167   0.249327 0.152 0.000 0.332 0.048 0.468
#> GSM23184     3  0.0771   0.905178 0.000 0.000 0.976 0.004 0.020
#> GSM23196     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.2852   0.766174 0.000 0.828 0.000 0.172 0.000
#> GSM23200     2  0.1851   0.856869 0.000 0.912 0.000 0.088 0.000
#> GSM23201     4  0.2648   0.875664 0.000 0.152 0.000 0.848 0.000
#> GSM23202     4  0.1908   0.908126 0.000 0.092 0.000 0.908 0.000
#> GSM23203     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.4101   0.529285 0.000 0.372 0.000 0.628 0.000
#> GSM23206     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4287   0.000279 0.000 0.540 0.000 0.460 0.000
#> GSM23208     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.3039   0.729368 0.000 0.808 0.000 0.192 0.000
#> GSM23211     2  0.0000   0.914675 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.1965   0.907491 0.000 0.096 0.000 0.904 0.000
#> GSM23213     4  0.1908   0.908126 0.000 0.092 0.000 0.908 0.000
#> GSM23214     4  0.1908   0.908126 0.000 0.092 0.000 0.908 0.000
#> GSM23215     2  0.0963   0.894830 0.000 0.964 0.000 0.036 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.1341     0.8311 0.000 0.000 0.948 0.000 0.024 0.028
#> GSM23186     6  0.6012    -0.0606 0.436 0.000 0.056 0.016 0.040 0.452
#> GSM23187     3  0.0547     0.8327 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM23188     3  0.1477     0.8289 0.000 0.000 0.940 0.004 0.008 0.048
#> GSM23189     3  0.0858     0.8317 0.000 0.000 0.968 0.004 0.000 0.028
#> GSM23190     3  0.1059     0.8329 0.000 0.000 0.964 0.004 0.016 0.016
#> GSM23191     5  0.5015     0.3314 0.044 0.000 0.088 0.012 0.728 0.128
#> GSM23192     6  0.6653     0.1178 0.080 0.000 0.124 0.000 0.368 0.428
#> GSM23193     5  0.5642     0.1935 0.016 0.000 0.204 0.012 0.628 0.140
#> GSM23194     3  0.4207     0.6931 0.000 0.000 0.732 0.012 0.048 0.208
#> GSM23195     6  0.6149     0.4223 0.064 0.000 0.256 0.004 0.104 0.572
#> GSM23159     1  0.4222     0.7523 0.760 0.000 0.000 0.012 0.120 0.108
#> GSM23160     3  0.2019     0.8247 0.000 0.000 0.900 0.000 0.012 0.088
#> GSM23161     1  0.4616     0.6923 0.708 0.000 0.000 0.008 0.180 0.104
#> GSM23162     3  0.5567     0.4395 0.000 0.000 0.584 0.016 0.272 0.128
#> GSM23163     1  0.4590     0.6660 0.712 0.000 0.004 0.004 0.096 0.184
#> GSM23164     1  0.4488     0.6419 0.692 0.000 0.000 0.016 0.248 0.044
#> GSM23165     1  0.2971     0.7445 0.832 0.000 0.000 0.004 0.020 0.144
#> GSM23166     1  0.4607     0.6540 0.684 0.000 0.000 0.016 0.248 0.052
#> GSM23167     1  0.2455     0.7654 0.872 0.000 0.000 0.004 0.012 0.112
#> GSM23168     3  0.2734     0.8152 0.000 0.000 0.864 0.008 0.024 0.104
#> GSM23169     3  0.5157     0.5329 0.004 0.000 0.616 0.004 0.096 0.280
#> GSM23170     1  0.2591     0.7938 0.880 0.000 0.000 0.004 0.064 0.052
#> GSM23171     1  0.2998     0.7868 0.852 0.000 0.000 0.004 0.076 0.068
#> GSM23172     1  0.2624     0.7707 0.856 0.000 0.000 0.000 0.020 0.124
#> GSM23173     3  0.4694     0.6301 0.016 0.000 0.668 0.000 0.052 0.264
#> GSM23174     1  0.3505     0.7639 0.808 0.000 0.000 0.008 0.136 0.048
#> GSM23175     1  0.3932     0.7687 0.796 0.000 0.000 0.024 0.092 0.088
#> GSM23176     1  0.2766     0.7664 0.852 0.000 0.000 0.004 0.020 0.124
#> GSM23177     1  0.3752     0.7745 0.804 0.000 0.000 0.020 0.116 0.060
#> GSM23178     1  0.3592     0.7624 0.812 0.000 0.000 0.020 0.124 0.044
#> GSM23179     3  0.2976     0.8048 0.000 0.000 0.844 0.012 0.020 0.124
#> GSM23180     5  0.4426     0.4946 0.168 0.000 0.000 0.036 0.744 0.052
#> GSM23181     5  0.5393     0.2565 0.352 0.000 0.000 0.024 0.556 0.068
#> GSM23182     5  0.6164     0.4420 0.240 0.000 0.000 0.156 0.556 0.048
#> GSM23183     6  0.6148     0.4565 0.076 0.000 0.196 0.008 0.112 0.608
#> GSM23184     3  0.1332     0.8307 0.000 0.000 0.952 0.008 0.012 0.028
#> GSM23196     2  0.0291     0.9203 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM23197     2  0.0436     0.9204 0.000 0.988 0.000 0.004 0.004 0.004
#> GSM23198     2  0.0146     0.9213 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM23199     2  0.4158     0.6045 0.000 0.720 0.000 0.236 0.020 0.024
#> GSM23200     2  0.2946     0.7707 0.000 0.824 0.000 0.160 0.004 0.012
#> GSM23201     4  0.3740     0.7538 0.000 0.136 0.000 0.800 0.032 0.032
#> GSM23202     4  0.1820     0.7970 0.000 0.056 0.000 0.924 0.008 0.012
#> GSM23203     2  0.0146     0.9213 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM23204     2  0.0665     0.9180 0.000 0.980 0.000 0.008 0.008 0.004
#> GSM23205     4  0.4585     0.6099 0.000 0.304 0.000 0.648 0.020 0.028
#> GSM23206     2  0.0551     0.9199 0.000 0.984 0.000 0.004 0.008 0.004
#> GSM23207     4  0.4652     0.0961 0.000 0.472 0.000 0.496 0.012 0.020
#> GSM23208     2  0.0000     0.9217 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0291     0.9212 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM23210     2  0.3658     0.7060 0.000 0.776 0.000 0.188 0.020 0.016
#> GSM23211     2  0.0291     0.9217 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM23212     4  0.1615     0.8033 0.000 0.064 0.000 0.928 0.004 0.004
#> GSM23213     4  0.1781     0.8014 0.000 0.060 0.000 0.924 0.008 0.008
#> GSM23214     4  0.1462     0.7996 0.000 0.056 0.000 0.936 0.000 0.008
#> GSM23215     2  0.2015     0.8824 0.000 0.916 0.000 0.056 0.012 0.016

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 cell.type(p) disease.state(p) k
#> SD:skmeans 57     3.90e-13         0.052490 2
#> SD:skmeans 57     4.19e-13         0.000423 3
#> SD:skmeans 55     6.87e-12         0.000323 4
#> SD:skmeans 47     3.48e-10         0.000331 5
#> SD:skmeans 46     5.67e-10         0.000169 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.665           0.830       0.930         0.4948 0.495   0.495
#> 3 3 0.841           0.872       0.946         0.3496 0.731   0.506
#> 4 4 0.778           0.845       0.912         0.0970 0.932   0.796
#> 5 5 0.805           0.797       0.895         0.0753 0.920   0.717
#> 6 6 0.788           0.745       0.854         0.0282 0.981   0.910

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
#> GSM23185     2  0.9286     0.5183 0.344 0.656
#> GSM23186     1  0.0000     0.9455 1.000 0.000
#> GSM23187     2  0.9358     0.5018 0.352 0.648
#> GSM23188     2  0.5946     0.7889 0.144 0.856
#> GSM23189     2  0.6712     0.7595 0.176 0.824
#> GSM23190     2  0.8386     0.6495 0.268 0.732
#> GSM23191     1  0.0000     0.9455 1.000 0.000
#> GSM23192     1  0.0000     0.9455 1.000 0.000
#> GSM23193     1  0.0000     0.9455 1.000 0.000
#> GSM23194     1  0.9983    -0.0194 0.524 0.476
#> GSM23195     2  0.9833     0.3192 0.424 0.576
#> GSM23159     1  0.0000     0.9455 1.000 0.000
#> GSM23160     1  0.7299     0.7087 0.796 0.204
#> GSM23161     1  0.0000     0.9455 1.000 0.000
#> GSM23162     1  0.0000     0.9455 1.000 0.000
#> GSM23163     1  0.0000     0.9455 1.000 0.000
#> GSM23164     1  0.0000     0.9455 1.000 0.000
#> GSM23165     1  0.0000     0.9455 1.000 0.000
#> GSM23166     1  0.0000     0.9455 1.000 0.000
#> GSM23167     1  0.0000     0.9455 1.000 0.000
#> GSM23168     1  0.3584     0.8841 0.932 0.068
#> GSM23169     1  0.0000     0.9455 1.000 0.000
#> GSM23170     1  0.0000     0.9455 1.000 0.000
#> GSM23171     1  0.0000     0.9455 1.000 0.000
#> GSM23172     1  0.0000     0.9455 1.000 0.000
#> GSM23173     1  0.3274     0.8923 0.940 0.060
#> GSM23174     1  0.0000     0.9455 1.000 0.000
#> GSM23175     1  0.0000     0.9455 1.000 0.000
#> GSM23176     1  0.0000     0.9455 1.000 0.000
#> GSM23177     1  0.0000     0.9455 1.000 0.000
#> GSM23178     1  0.0000     0.9455 1.000 0.000
#> GSM23179     1  0.9460     0.3679 0.636 0.364
#> GSM23180     1  0.0000     0.9455 1.000 0.000
#> GSM23181     1  0.0000     0.9455 1.000 0.000
#> GSM23182     1  0.0000     0.9455 1.000 0.000
#> GSM23183     1  0.0000     0.9455 1.000 0.000
#> GSM23184     1  0.7528     0.6892 0.784 0.216
#> GSM23196     2  0.0000     0.8841 0.000 1.000
#> GSM23197     2  0.0000     0.8841 0.000 1.000
#> GSM23198     2  0.0000     0.8841 0.000 1.000
#> GSM23199     2  0.0000     0.8841 0.000 1.000
#> GSM23200     2  0.0000     0.8841 0.000 1.000
#> GSM23201     2  0.1184     0.8771 0.016 0.984
#> GSM23202     2  0.9795     0.3204 0.416 0.584
#> GSM23203     2  0.0000     0.8841 0.000 1.000
#> GSM23204     2  0.0000     0.8841 0.000 1.000
#> GSM23205     2  0.0000     0.8841 0.000 1.000
#> GSM23206     2  0.0000     0.8841 0.000 1.000
#> GSM23207     2  0.0000     0.8841 0.000 1.000
#> GSM23208     2  0.0000     0.8841 0.000 1.000
#> GSM23209     2  0.0000     0.8841 0.000 1.000
#> GSM23210     2  0.0000     0.8841 0.000 1.000
#> GSM23211     2  0.0000     0.8841 0.000 1.000
#> GSM23212     2  0.0376     0.8826 0.004 0.996
#> GSM23213     2  0.4939     0.8219 0.108 0.892
#> GSM23214     2  0.9460     0.4709 0.364 0.636
#> GSM23215     2  0.0000     0.8841 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
#> GSM23185     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23186     1  0.4121     0.7614 0.832 0.000 0.168
#> GSM23187     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23188     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23189     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23190     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23191     1  0.3038     0.8262 0.896 0.000 0.104
#> GSM23192     1  0.5926     0.4267 0.644 0.000 0.356
#> GSM23193     3  0.6026     0.5085 0.376 0.000 0.624
#> GSM23194     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23195     3  0.5733     0.6070 0.324 0.000 0.676
#> GSM23159     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23160     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23161     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23162     3  0.1753     0.8711 0.048 0.000 0.952
#> GSM23163     1  0.0237     0.9350 0.996 0.000 0.004
#> GSM23164     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23165     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23166     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23167     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23168     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23169     3  0.3816     0.8085 0.148 0.000 0.852
#> GSM23170     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23171     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23172     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23173     3  0.4654     0.7546 0.208 0.000 0.792
#> GSM23174     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23175     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23176     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23177     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23178     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23179     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23180     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23181     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23182     1  0.0000     0.9382 1.000 0.000 0.000
#> GSM23183     3  0.6280     0.3071 0.460 0.000 0.540
#> GSM23184     3  0.0000     0.8915 0.000 0.000 1.000
#> GSM23196     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23197     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23198     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23199     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23200     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23201     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23202     1  0.6295     0.0551 0.528 0.472 0.000
#> GSM23203     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23204     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23205     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23206     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23207     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23208     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23209     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23210     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23211     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23212     2  0.0000     0.9748 0.000 1.000 0.000
#> GSM23213     2  0.2165     0.9113 0.064 0.936 0.000
#> GSM23214     2  0.5835     0.4701 0.340 0.660 0.000
#> GSM23215     2  0.0000     0.9748 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
#> GSM23185     3  0.0336      0.867 0.000 0.000 0.992 0.008
#> GSM23186     1  0.3732      0.822 0.852 0.000 0.092 0.056
#> GSM23187     3  0.0336      0.867 0.000 0.000 0.992 0.008
#> GSM23188     3  0.0336      0.867 0.000 0.000 0.992 0.008
#> GSM23189     3  0.0336      0.867 0.000 0.000 0.992 0.008
#> GSM23190     3  0.0336      0.867 0.000 0.000 0.992 0.008
#> GSM23191     1  0.5995      0.666 0.660 0.000 0.084 0.256
#> GSM23192     1  0.6745      0.576 0.604 0.000 0.244 0.152
#> GSM23193     3  0.6805      0.528 0.260 0.000 0.592 0.148
#> GSM23194     3  0.0336      0.866 0.000 0.000 0.992 0.008
#> GSM23195     3  0.5206      0.633 0.308 0.000 0.668 0.024
#> GSM23159     1  0.1474      0.914 0.948 0.000 0.000 0.052
#> GSM23160     3  0.0000      0.866 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1637      0.905 0.940 0.000 0.000 0.060
#> GSM23162     3  0.3117      0.821 0.028 0.000 0.880 0.092
#> GSM23163     1  0.1743      0.902 0.940 0.000 0.004 0.056
#> GSM23164     1  0.2345      0.899 0.900 0.000 0.000 0.100
#> GSM23165     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM23166     1  0.2469      0.903 0.892 0.000 0.000 0.108
#> GSM23167     1  0.0188      0.915 0.996 0.000 0.000 0.004
#> GSM23168     3  0.0707      0.864 0.000 0.000 0.980 0.020
#> GSM23169     3  0.4163      0.794 0.076 0.000 0.828 0.096
#> GSM23170     1  0.0469      0.916 0.988 0.000 0.000 0.012
#> GSM23171     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM23173     3  0.4399      0.737 0.212 0.000 0.768 0.020
#> GSM23174     1  0.1940      0.907 0.924 0.000 0.000 0.076
#> GSM23175     1  0.0817      0.917 0.976 0.000 0.000 0.024
#> GSM23176     1  0.0707      0.912 0.980 0.000 0.000 0.020
#> GSM23177     1  0.0000      0.915 1.000 0.000 0.000 0.000
#> GSM23178     1  0.2345      0.899 0.900 0.000 0.000 0.100
#> GSM23179     3  0.0592      0.865 0.000 0.000 0.984 0.016
#> GSM23180     1  0.2345      0.899 0.900 0.000 0.000 0.100
#> GSM23181     1  0.2345      0.899 0.900 0.000 0.000 0.100
#> GSM23182     4  0.4134      0.507 0.260 0.000 0.000 0.740
#> GSM23183     3  0.6315      0.375 0.396 0.000 0.540 0.064
#> GSM23184     3  0.0000      0.866 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23199     2  0.1211      0.914 0.000 0.960 0.000 0.040
#> GSM23200     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23201     4  0.2973      0.863 0.000 0.144 0.000 0.856
#> GSM23202     4  0.3123      0.855 0.000 0.156 0.000 0.844
#> GSM23203     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23205     2  0.4761      0.274 0.000 0.628 0.000 0.372
#> GSM23206     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23207     2  0.3610      0.714 0.000 0.800 0.000 0.200
#> GSM23208     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000      0.949 0.000 1.000 0.000 0.000
#> GSM23212     4  0.3123      0.855 0.000 0.156 0.000 0.844
#> GSM23213     4  0.2281      0.864 0.000 0.096 0.000 0.904
#> GSM23214     4  0.1940      0.853 0.000 0.076 0.000 0.924
#> GSM23215     2  0.0000      0.949 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
#> GSM23185     3  0.0162     0.8790 0.000 0.000 0.996 0.000 0.004
#> GSM23186     1  0.3573     0.7652 0.812 0.000 0.036 0.000 0.152
#> GSM23187     3  0.0162     0.8790 0.000 0.000 0.996 0.000 0.004
#> GSM23188     3  0.0162     0.8790 0.000 0.000 0.996 0.000 0.004
#> GSM23189     3  0.0162     0.8790 0.000 0.000 0.996 0.000 0.004
#> GSM23190     3  0.0162     0.8790 0.000 0.000 0.996 0.000 0.004
#> GSM23191     5  0.2352     0.6971 0.092 0.000 0.008 0.004 0.896
#> GSM23192     5  0.0671     0.6566 0.004 0.000 0.016 0.000 0.980
#> GSM23193     5  0.1597     0.6711 0.012 0.000 0.048 0.000 0.940
#> GSM23194     3  0.0609     0.8749 0.000 0.000 0.980 0.000 0.020
#> GSM23195     3  0.6043     0.3048 0.320 0.000 0.540 0.000 0.140
#> GSM23159     1  0.1608     0.8612 0.928 0.000 0.000 0.000 0.072
#> GSM23160     3  0.0162     0.8780 0.000 0.000 0.996 0.000 0.004
#> GSM23161     1  0.3366     0.7559 0.768 0.000 0.000 0.000 0.232
#> GSM23162     5  0.4829    -0.0832 0.020 0.000 0.480 0.000 0.500
#> GSM23163     1  0.3143     0.7664 0.796 0.000 0.000 0.000 0.204
#> GSM23164     1  0.3177     0.7632 0.792 0.000 0.000 0.000 0.208
#> GSM23165     1  0.0000     0.8751 1.000 0.000 0.000 0.000 0.000
#> GSM23166     1  0.3816     0.6890 0.696 0.000 0.000 0.000 0.304
#> GSM23167     1  0.0162     0.8752 0.996 0.000 0.000 0.000 0.004
#> GSM23168     3  0.1270     0.8565 0.000 0.000 0.948 0.000 0.052
#> GSM23169     3  0.4990     0.4364 0.048 0.000 0.628 0.000 0.324
#> GSM23170     1  0.0880     0.8792 0.968 0.000 0.000 0.000 0.032
#> GSM23171     1  0.0404     0.8763 0.988 0.000 0.000 0.000 0.012
#> GSM23172     1  0.0404     0.8763 0.988 0.000 0.000 0.000 0.012
#> GSM23173     3  0.5105     0.5324 0.264 0.000 0.660 0.000 0.076
#> GSM23174     1  0.1965     0.8432 0.904 0.000 0.000 0.000 0.096
#> GSM23175     1  0.0880     0.8764 0.968 0.000 0.000 0.000 0.032
#> GSM23176     1  0.1792     0.8563 0.916 0.000 0.000 0.000 0.084
#> GSM23177     1  0.0794     0.8751 0.972 0.000 0.000 0.000 0.028
#> GSM23178     1  0.2179     0.8318 0.888 0.000 0.000 0.000 0.112
#> GSM23179     3  0.0880     0.8686 0.000 0.000 0.968 0.000 0.032
#> GSM23180     5  0.4060     0.5481 0.360 0.000 0.000 0.000 0.640
#> GSM23181     5  0.4074     0.5446 0.364 0.000 0.000 0.000 0.636
#> GSM23182     5  0.5731     0.6083 0.196 0.000 0.000 0.180 0.624
#> GSM23183     5  0.5557     0.5889 0.260 0.000 0.116 0.000 0.624
#> GSM23184     3  0.0290     0.8769 0.000 0.000 0.992 0.000 0.008
#> GSM23196     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.2020     0.8520 0.000 0.900 0.000 0.100 0.000
#> GSM23200     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0162     0.9944 0.000 0.004 0.000 0.996 0.000
#> GSM23202     4  0.0000     0.9986 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.3932     0.5084 0.000 0.672 0.000 0.328 0.000
#> GSM23206     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4219     0.3185 0.000 0.584 0.000 0.416 0.000
#> GSM23208     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000     0.9368 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9986 0.000 0.000 0.000 1.000 0.000
#> GSM23213     4  0.0000     0.9986 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000     0.9986 0.000 0.000 0.000 1.000 0.000
#> GSM23215     2  0.0000     0.9368 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
#> GSM23185     3  0.0000     0.8754 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     1  0.5738     0.3570 0.536 0.000 0.016 0.000 0.128 0.320
#> GSM23187     3  0.0000     0.8754 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.8754 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0260     0.8759 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM23190     3  0.0000     0.8754 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.0865     0.4472 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM23192     5  0.3163     0.2921 0.000 0.000 0.004 0.000 0.764 0.232
#> GSM23193     5  0.0405     0.4321 0.004 0.000 0.000 0.000 0.988 0.008
#> GSM23194     3  0.2340     0.8604 0.000 0.000 0.852 0.000 0.000 0.148
#> GSM23195     6  0.4659     0.5625 0.260 0.000 0.028 0.000 0.036 0.676
#> GSM23159     1  0.1480     0.8217 0.940 0.000 0.000 0.000 0.040 0.020
#> GSM23160     3  0.2178     0.8645 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM23161     1  0.4563     0.6727 0.700 0.000 0.000 0.000 0.164 0.136
#> GSM23162     5  0.5615     0.0537 0.012 0.000 0.280 0.000 0.568 0.140
#> GSM23163     1  0.4910     0.6616 0.656 0.000 0.000 0.000 0.152 0.192
#> GSM23164     1  0.3017     0.7843 0.844 0.000 0.000 0.000 0.084 0.072
#> GSM23165     1  0.1957     0.8066 0.888 0.000 0.000 0.000 0.000 0.112
#> GSM23166     1  0.4336     0.7047 0.724 0.000 0.000 0.000 0.160 0.116
#> GSM23167     1  0.1411     0.8275 0.936 0.000 0.000 0.000 0.004 0.060
#> GSM23168     3  0.3200     0.8321 0.000 0.000 0.788 0.000 0.016 0.196
#> GSM23169     3  0.5522     0.4517 0.024 0.000 0.604 0.000 0.260 0.112
#> GSM23170     1  0.2039     0.8310 0.904 0.000 0.000 0.000 0.020 0.076
#> GSM23171     1  0.0458     0.8273 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM23172     1  0.1610     0.8123 0.916 0.000 0.000 0.000 0.000 0.084
#> GSM23173     6  0.4734     0.4106 0.120 0.000 0.208 0.000 0.000 0.672
#> GSM23174     1  0.1719     0.8073 0.924 0.000 0.000 0.000 0.060 0.016
#> GSM23175     1  0.0909     0.8278 0.968 0.000 0.000 0.000 0.020 0.012
#> GSM23176     1  0.3455     0.7884 0.800 0.000 0.000 0.000 0.056 0.144
#> GSM23177     1  0.2494     0.8225 0.864 0.000 0.000 0.000 0.016 0.120
#> GSM23178     1  0.2404     0.8067 0.884 0.000 0.000 0.000 0.080 0.036
#> GSM23179     3  0.3071     0.8422 0.000 0.000 0.804 0.000 0.016 0.180
#> GSM23180     5  0.3993     0.1930 0.476 0.000 0.000 0.000 0.520 0.004
#> GSM23181     5  0.3867     0.1704 0.488 0.000 0.000 0.000 0.512 0.000
#> GSM23182     5  0.5694     0.2835 0.188 0.000 0.000 0.304 0.508 0.000
#> GSM23183     6  0.5283     0.4524 0.180 0.000 0.004 0.000 0.196 0.620
#> GSM23184     3  0.2454     0.8569 0.000 0.000 0.840 0.000 0.000 0.160
#> GSM23196     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.1814     0.8513 0.000 0.900 0.000 0.100 0.000 0.000
#> GSM23200     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.0146     0.9937 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM23202     4  0.0000     0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     2  0.3563     0.4885 0.000 0.664 0.000 0.336 0.000 0.000
#> GSM23206     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.3747     0.3757 0.000 0.604 0.000 0.396 0.000 0.000
#> GSM23208     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23211     2  0.0000     0.9351 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000     0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000     0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000     0.9351 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-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 cell.type(p) disease.state(p) k
#> SD:pam 52     2.17e-08         7.91e-01 2
#> SD:pam 53     3.10e-12         5.20e-03 3
#> SD:pam 55     4.19e-11         7.64e-04 4
#> SD:pam 53     8.52e-11         6.78e-05 5
#> SD:pam 44     6.42e-09         4.36e-05 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 11993 rows and 57 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 1.000           1.000       1.000         0.4642 0.536   0.536
#> 3 3 0.718           0.933       0.885         0.3957 0.787   0.603
#> 4 4 0.811           0.833       0.921         0.1206 0.837   0.567
#> 5 5 0.855           0.783       0.866         0.0912 0.954   0.828
#> 6 6 0.869           0.775       0.874         0.0506 0.915   0.642

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
#> GSM23185     1       0          1  1  0
#> GSM23186     1       0          1  1  0
#> GSM23187     1       0          1  1  0
#> GSM23188     1       0          1  1  0
#> GSM23189     1       0          1  1  0
#> GSM23190     1       0          1  1  0
#> GSM23191     1       0          1  1  0
#> GSM23192     1       0          1  1  0
#> GSM23193     1       0          1  1  0
#> GSM23194     1       0          1  1  0
#> GSM23195     1       0          1  1  0
#> GSM23159     1       0          1  1  0
#> GSM23160     1       0          1  1  0
#> GSM23161     1       0          1  1  0
#> GSM23162     1       0          1  1  0
#> GSM23163     1       0          1  1  0
#> GSM23164     1       0          1  1  0
#> GSM23165     1       0          1  1  0
#> GSM23166     1       0          1  1  0
#> GSM23167     1       0          1  1  0
#> GSM23168     1       0          1  1  0
#> GSM23169     1       0          1  1  0
#> GSM23170     1       0          1  1  0
#> GSM23171     1       0          1  1  0
#> GSM23172     1       0          1  1  0
#> GSM23173     1       0          1  1  0
#> GSM23174     1       0          1  1  0
#> GSM23175     1       0          1  1  0
#> GSM23176     1       0          1  1  0
#> GSM23177     1       0          1  1  0
#> GSM23178     1       0          1  1  0
#> GSM23179     1       0          1  1  0
#> GSM23180     1       0          1  1  0
#> GSM23181     1       0          1  1  0
#> GSM23182     1       0          1  1  0
#> GSM23183     1       0          1  1  0
#> GSM23184     1       0          1  1  0
#> GSM23196     2       0          1  0  1
#> GSM23197     2       0          1  0  1
#> GSM23198     2       0          1  0  1
#> GSM23199     2       0          1  0  1
#> GSM23200     2       0          1  0  1
#> GSM23201     2       0          1  0  1
#> GSM23202     2       0          1  0  1
#> GSM23203     2       0          1  0  1
#> GSM23204     2       0          1  0  1
#> GSM23205     2       0          1  0  1
#> GSM23206     2       0          1  0  1
#> GSM23207     2       0          1  0  1
#> GSM23208     2       0          1  0  1
#> GSM23209     2       0          1  0  1
#> GSM23210     2       0          1  0  1
#> GSM23211     2       0          1  0  1
#> GSM23212     2       0          1  0  1
#> GSM23213     2       0          1  0  1
#> GSM23214     2       0          1  0  1
#> GSM23215     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23186     1  0.1964      0.915 0.944 0.000 0.056
#> GSM23187     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23188     3  0.4750      0.941 0.216 0.000 0.784
#> GSM23189     3  0.4605      0.950 0.204 0.000 0.796
#> GSM23190     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23191     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23192     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23193     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23194     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23195     3  0.5968      0.771 0.364 0.000 0.636
#> GSM23159     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23160     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23161     1  0.1163      0.956 0.972 0.000 0.028
#> GSM23162     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23163     1  0.0747      0.963 0.984 0.000 0.016
#> GSM23164     1  0.1163      0.956 0.972 0.000 0.028
#> GSM23165     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23166     1  0.1163      0.956 0.972 0.000 0.028
#> GSM23167     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23168     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23169     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23170     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23173     3  0.5621      0.853 0.308 0.000 0.692
#> GSM23174     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23177     1  0.0892      0.961 0.980 0.000 0.020
#> GSM23178     1  0.0000      0.970 1.000 0.000 0.000
#> GSM23179     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23180     3  0.5016      0.922 0.240 0.000 0.760
#> GSM23181     1  0.4605      0.678 0.796 0.000 0.204
#> GSM23182     3  0.5098      0.915 0.248 0.000 0.752
#> GSM23183     3  0.5948      0.778 0.360 0.000 0.640
#> GSM23184     3  0.4399      0.959 0.188 0.000 0.812
#> GSM23196     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23197     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23198     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23199     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23200     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23201     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23202     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23203     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23204     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23205     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23206     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23207     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23208     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23209     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23210     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23211     2  0.4399      0.924 0.000 0.812 0.188
#> GSM23212     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23213     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23214     2  0.0000      0.924 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.924 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
#> GSM23185     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23186     1  0.1820      0.860 0.944 0.000 0.036 0.020
#> GSM23187     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23191     3  0.6155      0.238 0.412 0.000 0.536 0.052
#> GSM23192     3  0.5060      0.285 0.412 0.000 0.584 0.004
#> GSM23193     3  0.4459      0.727 0.188 0.000 0.780 0.032
#> GSM23194     3  0.0188      0.868 0.004 0.000 0.996 0.000
#> GSM23195     1  0.5339      0.420 0.624 0.000 0.356 0.020
#> GSM23159     1  0.0469      0.887 0.988 0.000 0.000 0.012
#> GSM23160     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23161     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23162     3  0.4008      0.768 0.148 0.000 0.820 0.032
#> GSM23163     1  0.0804      0.884 0.980 0.000 0.008 0.012
#> GSM23164     1  0.0000      0.888 1.000 0.000 0.000 0.000
#> GSM23165     1  0.0592      0.885 0.984 0.000 0.000 0.016
#> GSM23166     1  0.0000      0.888 1.000 0.000 0.000 0.000
#> GSM23167     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23168     3  0.0469      0.866 0.012 0.000 0.988 0.000
#> GSM23169     3  0.4155      0.666 0.240 0.000 0.756 0.004
#> GSM23170     1  0.0000      0.888 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23172     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23173     1  0.5570      0.170 0.540 0.000 0.440 0.020
#> GSM23174     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23175     1  0.0188      0.888 0.996 0.000 0.000 0.004
#> GSM23176     1  0.0707      0.884 0.980 0.000 0.000 0.020
#> GSM23177     1  0.0000      0.888 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000      0.888 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0336      0.867 0.008 0.000 0.992 0.000
#> GSM23180     1  0.5866      0.418 0.624 0.000 0.324 0.052
#> GSM23181     1  0.0469      0.884 0.988 0.000 0.012 0.000
#> GSM23182     1  0.5866      0.418 0.624 0.000 0.324 0.052
#> GSM23183     1  0.4988      0.558 0.692 0.000 0.288 0.020
#> GSM23184     3  0.0000      0.868 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23199     4  0.3356      0.885 0.000 0.176 0.000 0.824
#> GSM23200     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23201     4  0.0707      0.918 0.000 0.020 0.000 0.980
#> GSM23202     4  0.0707      0.918 0.000 0.020 0.000 0.980
#> GSM23203     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23205     4  0.1637      0.922 0.000 0.060 0.000 0.940
#> GSM23206     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23207     4  0.3400      0.882 0.000 0.180 0.000 0.820
#> GSM23208     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23210     4  0.3311      0.888 0.000 0.172 0.000 0.828
#> GSM23211     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM23212     4  0.1557      0.922 0.000 0.056 0.000 0.944
#> GSM23213     4  0.0707      0.918 0.000 0.020 0.000 0.980
#> GSM23214     4  0.0707      0.918 0.000 0.020 0.000 0.980
#> GSM23215     4  0.3311      0.888 0.000 0.172 0.000 0.828

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.4074     0.7006 0.636 0.000 0.000 0.000 0.364
#> GSM23187     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23191     5  0.4380     0.5124 0.000 0.000 0.376 0.008 0.616
#> GSM23192     3  0.4610    -0.0762 0.012 0.000 0.556 0.000 0.432
#> GSM23193     3  0.3796     0.4327 0.000 0.000 0.700 0.000 0.300
#> GSM23194     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23195     1  0.3304     0.6824 0.816 0.000 0.016 0.000 0.168
#> GSM23159     1  0.0609     0.7620 0.980 0.000 0.000 0.000 0.020
#> GSM23160     3  0.0290     0.8741 0.000 0.000 0.992 0.000 0.008
#> GSM23161     1  0.1121     0.7337 0.956 0.000 0.000 0.000 0.044
#> GSM23162     3  0.3424     0.5595 0.000 0.000 0.760 0.000 0.240
#> GSM23163     1  0.0510     0.7588 0.984 0.000 0.000 0.000 0.016
#> GSM23164     1  0.3707     0.3788 0.716 0.000 0.000 0.000 0.284
#> GSM23165     1  0.4074     0.6992 0.636 0.000 0.000 0.000 0.364
#> GSM23166     1  0.3684     0.3879 0.720 0.000 0.000 0.000 0.280
#> GSM23167     1  0.3816     0.7207 0.696 0.000 0.000 0.000 0.304
#> GSM23168     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23169     3  0.2513     0.7646 0.008 0.000 0.876 0.000 0.116
#> GSM23170     1  0.3452     0.7403 0.756 0.000 0.000 0.000 0.244
#> GSM23171     1  0.2605     0.7627 0.852 0.000 0.000 0.000 0.148
#> GSM23172     1  0.3796     0.7212 0.700 0.000 0.000 0.000 0.300
#> GSM23173     1  0.6342     0.0448 0.476 0.000 0.356 0.000 0.168
#> GSM23174     1  0.2929     0.7587 0.820 0.000 0.000 0.000 0.180
#> GSM23175     1  0.0510     0.7573 0.984 0.000 0.000 0.000 0.016
#> GSM23176     1  0.4015     0.7068 0.652 0.000 0.000 0.000 0.348
#> GSM23177     1  0.0000     0.7565 1.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.0162     0.7584 0.996 0.000 0.000 0.000 0.004
#> GSM23179     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23180     5  0.5514     0.6807 0.068 0.000 0.292 0.012 0.628
#> GSM23181     5  0.4297     0.1253 0.472 0.000 0.000 0.000 0.528
#> GSM23182     5  0.5514     0.6807 0.068 0.000 0.292 0.012 0.628
#> GSM23183     1  0.3304     0.6807 0.816 0.000 0.016 0.000 0.168
#> GSM23184     3  0.0000     0.8806 0.000 0.000 1.000 0.000 0.000
#> GSM23196     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.1410     0.9538 0.000 0.060 0.000 0.940 0.000
#> GSM23200     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0000     0.9691 0.000 0.000 0.000 1.000 0.000
#> GSM23202     4  0.0000     0.9691 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.0162     0.9697 0.000 0.004 0.000 0.996 0.000
#> GSM23206     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23207     4  0.1341     0.9562 0.000 0.056 0.000 0.944 0.000
#> GSM23208     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23210     4  0.1544     0.9468 0.000 0.068 0.000 0.932 0.000
#> GSM23211     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0162     0.9697 0.000 0.004 0.000 0.996 0.000
#> GSM23213     4  0.0000     0.9691 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000     0.9691 0.000 0.000 0.000 1.000 0.000
#> GSM23215     4  0.1341     0.9562 0.000 0.056 0.000 0.944 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
#> GSM23185     3  0.0000     0.9426 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.3629     0.6516 0.276 0.000 0.000 0.000 0.012 0.712
#> GSM23187     3  0.0000     0.9426 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.9426 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.9426 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000     0.9426 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.0000     0.6812 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM23192     5  0.3671     0.6142 0.000 0.000 0.208 0.000 0.756 0.036
#> GSM23193     5  0.4117     0.5862 0.000 0.000 0.296 0.000 0.672 0.032
#> GSM23194     3  0.1921     0.8906 0.000 0.000 0.916 0.000 0.052 0.032
#> GSM23195     1  0.6188    -0.0982 0.404 0.000 0.004 0.000 0.288 0.304
#> GSM23159     1  0.1957     0.6744 0.888 0.000 0.000 0.000 0.000 0.112
#> GSM23160     3  0.0405     0.9407 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM23161     1  0.0146     0.6825 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM23162     5  0.4219     0.5531 0.000 0.000 0.320 0.000 0.648 0.032
#> GSM23163     1  0.1610     0.6859 0.916 0.000 0.000 0.000 0.000 0.084
#> GSM23164     1  0.2201     0.6372 0.896 0.000 0.000 0.000 0.076 0.028
#> GSM23165     6  0.2300     0.7872 0.144 0.000 0.000 0.000 0.000 0.856
#> GSM23166     1  0.2218     0.6239 0.884 0.000 0.000 0.000 0.104 0.012
#> GSM23167     6  0.2527     0.7956 0.168 0.000 0.000 0.000 0.000 0.832
#> GSM23168     3  0.1644     0.9045 0.000 0.000 0.932 0.000 0.040 0.028
#> GSM23169     3  0.4330     0.5374 0.004 0.000 0.680 0.000 0.272 0.044
#> GSM23170     1  0.3578     0.4085 0.660 0.000 0.000 0.000 0.000 0.340
#> GSM23171     1  0.3266     0.5275 0.728 0.000 0.000 0.000 0.000 0.272
#> GSM23172     6  0.2527     0.7956 0.168 0.000 0.000 0.000 0.000 0.832
#> GSM23173     6  0.7515     0.1172 0.276 0.000 0.136 0.000 0.292 0.296
#> GSM23174     1  0.3244     0.5417 0.732 0.000 0.000 0.000 0.000 0.268
#> GSM23175     1  0.1863     0.6867 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM23176     6  0.2491     0.7963 0.164 0.000 0.000 0.000 0.000 0.836
#> GSM23177     1  0.0790     0.6869 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM23178     1  0.1501     0.6865 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM23179     3  0.0603     0.9371 0.000 0.000 0.980 0.000 0.016 0.004
#> GSM23180     5  0.3424     0.6741 0.092 0.000 0.000 0.000 0.812 0.096
#> GSM23181     1  0.5274    -0.1166 0.492 0.000 0.000 0.000 0.408 0.100
#> GSM23182     5  0.3611     0.6649 0.108 0.000 0.000 0.000 0.796 0.096
#> GSM23183     1  0.6680     0.1751 0.484 0.000 0.084 0.000 0.288 0.144
#> GSM23184     3  0.0260     0.9415 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM23196     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     4  0.0790     0.9742 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM23200     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.0146     0.9808 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM23202     4  0.0000     0.9821 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.0000     0.9821 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23206     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     4  0.0790     0.9742 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM23208     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     4  0.0790     0.9742 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM23211     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9821 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000     0.9821 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0146     0.9808 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM23215     4  0.0790     0.9742 0.000 0.032 0.000 0.968 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-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 cell.type(p) disease.state(p) k
#> SD:mclust 57     3.90e-13         0.052490 2
#> SD:mclust 57     4.19e-13         0.000276 3
#> SD:mclust 51     4.89e-11         0.001353 4
#> SD:mclust 51     2.23e-10         0.008026 5
#> SD:mclust 52     5.39e-10         0.002514 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 11993 rows and 57 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 0.927           0.969       0.985         0.4711 0.536   0.536
#> 3 3 0.974           0.946       0.976         0.4344 0.786   0.600
#> 4 4 0.849           0.843       0.933         0.1141 0.851   0.583
#> 5 5 0.776           0.718       0.841         0.0501 0.976   0.901
#> 6 6 0.758           0.641       0.794         0.0380 0.950   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
#> GSM23185     1  0.6887      0.793 0.816 0.184
#> GSM23186     1  0.0000      0.976 1.000 0.000
#> GSM23187     1  0.5059      0.878 0.888 0.112
#> GSM23188     1  0.8909      0.591 0.692 0.308
#> GSM23189     1  0.5842      0.847 0.860 0.140
#> GSM23190     1  0.4939      0.882 0.892 0.108
#> GSM23191     1  0.0000      0.976 1.000 0.000
#> GSM23192     1  0.0000      0.976 1.000 0.000
#> GSM23193     1  0.0000      0.976 1.000 0.000
#> GSM23194     1  0.0000      0.976 1.000 0.000
#> GSM23195     1  0.0000      0.976 1.000 0.000
#> GSM23159     1  0.0000      0.976 1.000 0.000
#> GSM23160     1  0.0000      0.976 1.000 0.000
#> GSM23161     1  0.0000      0.976 1.000 0.000
#> GSM23162     1  0.0000      0.976 1.000 0.000
#> GSM23163     1  0.0000      0.976 1.000 0.000
#> GSM23164     1  0.0000      0.976 1.000 0.000
#> GSM23165     1  0.0000      0.976 1.000 0.000
#> GSM23166     1  0.0000      0.976 1.000 0.000
#> GSM23167     1  0.0000      0.976 1.000 0.000
#> GSM23168     1  0.0000      0.976 1.000 0.000
#> GSM23169     1  0.0000      0.976 1.000 0.000
#> GSM23170     1  0.0000      0.976 1.000 0.000
#> GSM23171     1  0.0000      0.976 1.000 0.000
#> GSM23172     1  0.0000      0.976 1.000 0.000
#> GSM23173     1  0.0000      0.976 1.000 0.000
#> GSM23174     1  0.0000      0.976 1.000 0.000
#> GSM23175     1  0.0000      0.976 1.000 0.000
#> GSM23176     1  0.0000      0.976 1.000 0.000
#> GSM23177     1  0.0000      0.976 1.000 0.000
#> GSM23178     1  0.0000      0.976 1.000 0.000
#> GSM23179     1  0.0000      0.976 1.000 0.000
#> GSM23180     1  0.0000      0.976 1.000 0.000
#> GSM23181     1  0.0000      0.976 1.000 0.000
#> GSM23182     1  0.0000      0.976 1.000 0.000
#> GSM23183     1  0.0000      0.976 1.000 0.000
#> GSM23184     1  0.0000      0.976 1.000 0.000
#> GSM23196     2  0.0000      0.999 0.000 1.000
#> GSM23197     2  0.0000      0.999 0.000 1.000
#> GSM23198     2  0.0000      0.999 0.000 1.000
#> GSM23199     2  0.0000      0.999 0.000 1.000
#> GSM23200     2  0.0000      0.999 0.000 1.000
#> GSM23201     2  0.0000      0.999 0.000 1.000
#> GSM23202     2  0.0938      0.988 0.012 0.988
#> GSM23203     2  0.0000      0.999 0.000 1.000
#> GSM23204     2  0.0000      0.999 0.000 1.000
#> GSM23205     2  0.0000      0.999 0.000 1.000
#> GSM23206     2  0.0000      0.999 0.000 1.000
#> GSM23207     2  0.0000      0.999 0.000 1.000
#> GSM23208     2  0.0000      0.999 0.000 1.000
#> GSM23209     2  0.0000      0.999 0.000 1.000
#> GSM23210     2  0.0000      0.999 0.000 1.000
#> GSM23211     2  0.0000      0.999 0.000 1.000
#> GSM23212     2  0.0000      0.999 0.000 1.000
#> GSM23213     2  0.0000      0.999 0.000 1.000
#> GSM23214     2  0.0000      0.999 0.000 1.000
#> GSM23215     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
#> GSM23185     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23186     1  0.2878      0.883 0.904 0.000 0.096
#> GSM23187     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23191     3  0.6260      0.257 0.448 0.000 0.552
#> GSM23192     3  0.5497      0.623 0.292 0.000 0.708
#> GSM23193     3  0.2878      0.879 0.096 0.000 0.904
#> GSM23194     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23195     3  0.1643      0.918 0.044 0.000 0.956
#> GSM23159     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23160     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23161     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23162     3  0.0237      0.939 0.004 0.000 0.996
#> GSM23163     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23164     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23169     3  0.0592      0.936 0.012 0.000 0.988
#> GSM23170     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23173     3  0.0237      0.939 0.004 0.000 0.996
#> GSM23174     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23180     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23181     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23182     1  0.0000      0.994 1.000 0.000 0.000
#> GSM23183     3  0.3192      0.865 0.112 0.000 0.888
#> GSM23184     3  0.0000      0.940 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23201     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23202     2  0.4887      0.711 0.228 0.772 0.000
#> GSM23203     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23205     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23206     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23212     2  0.0000      0.985 0.000 1.000 0.000
#> GSM23213     2  0.0747      0.972 0.016 0.984 0.000
#> GSM23214     2  0.1411      0.954 0.036 0.964 0.000
#> GSM23215     2  0.0000      0.985 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
#> GSM23185     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23186     1  0.0188      0.959 0.996 0.000 0.000 0.004
#> GSM23187     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0336      0.923 0.000 0.000 0.992 0.008
#> GSM23189     3  0.0336      0.923 0.000 0.000 0.992 0.008
#> GSM23190     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23191     4  0.2868      0.697 0.000 0.000 0.136 0.864
#> GSM23192     3  0.4872      0.484 0.004 0.000 0.640 0.356
#> GSM23193     3  0.4817      0.415 0.000 0.000 0.612 0.388
#> GSM23194     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23195     1  0.2271      0.882 0.916 0.000 0.076 0.008
#> GSM23159     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23161     1  0.2469      0.856 0.892 0.000 0.000 0.108
#> GSM23162     3  0.0336      0.922 0.000 0.000 0.992 0.008
#> GSM23163     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23164     4  0.4866      0.344 0.404 0.000 0.000 0.596
#> GSM23165     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23166     4  0.4933      0.267 0.432 0.000 0.000 0.568
#> GSM23167     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23169     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23170     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23173     3  0.3668      0.727 0.188 0.000 0.808 0.004
#> GSM23174     1  0.0817      0.944 0.976 0.000 0.000 0.024
#> GSM23175     1  0.0188      0.960 0.996 0.000 0.000 0.004
#> GSM23176     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0188      0.960 0.996 0.000 0.000 0.004
#> GSM23178     1  0.0000      0.962 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23180     4  0.0336      0.801 0.008 0.000 0.000 0.992
#> GSM23181     4  0.1211      0.797 0.040 0.000 0.000 0.960
#> GSM23182     4  0.0336      0.801 0.008 0.000 0.000 0.992
#> GSM23183     1  0.4328      0.655 0.748 0.000 0.244 0.008
#> GSM23184     3  0.0000      0.927 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0336      0.938 0.000 0.992 0.000 0.008
#> GSM23200     2  0.0188      0.940 0.000 0.996 0.000 0.004
#> GSM23201     4  0.1211      0.800 0.000 0.040 0.000 0.960
#> GSM23202     4  0.2704      0.759 0.000 0.124 0.000 0.876
#> GSM23203     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23205     2  0.4477      0.530 0.000 0.688 0.000 0.312
#> GSM23206     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0336      0.938 0.000 0.992 0.000 0.008
#> GSM23208     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0188      0.940 0.000 0.996 0.000 0.004
#> GSM23211     2  0.0000      0.941 0.000 1.000 0.000 0.000
#> GSM23212     2  0.4985      0.120 0.000 0.532 0.000 0.468
#> GSM23213     4  0.4008      0.607 0.000 0.244 0.000 0.756
#> GSM23214     4  0.2973      0.740 0.000 0.144 0.000 0.856
#> GSM23215     2  0.0188      0.940 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.3074     0.7335 0.000 0.000 0.804 0.000 0.196
#> GSM23186     1  0.2674     0.8196 0.856 0.000 0.000 0.004 0.140
#> GSM23187     3  0.0609     0.8036 0.000 0.000 0.980 0.000 0.020
#> GSM23188     3  0.1732     0.7942 0.000 0.000 0.920 0.000 0.080
#> GSM23189     3  0.0609     0.8033 0.000 0.000 0.980 0.000 0.020
#> GSM23190     3  0.2966     0.7403 0.000 0.000 0.816 0.000 0.184
#> GSM23191     4  0.1943     0.7256 0.000 0.000 0.020 0.924 0.056
#> GSM23192     3  0.6821    -0.0106 0.000 0.000 0.348 0.336 0.316
#> GSM23193     3  0.4663     0.3764 0.000 0.000 0.604 0.376 0.020
#> GSM23194     3  0.2561     0.7671 0.000 0.000 0.856 0.000 0.144
#> GSM23195     5  0.6108     0.3638 0.208 0.000 0.224 0.000 0.568
#> GSM23159     1  0.0992     0.9459 0.968 0.000 0.000 0.008 0.024
#> GSM23160     3  0.1792     0.7946 0.000 0.000 0.916 0.000 0.084
#> GSM23161     1  0.3527     0.7922 0.828 0.000 0.000 0.116 0.056
#> GSM23162     3  0.2300     0.7895 0.000 0.000 0.908 0.040 0.052
#> GSM23163     1  0.0000     0.9562 1.000 0.000 0.000 0.000 0.000
#> GSM23164     4  0.4451     0.5212 0.248 0.000 0.000 0.712 0.040
#> GSM23165     1  0.0000     0.9562 1.000 0.000 0.000 0.000 0.000
#> GSM23166     4  0.4668     0.4806 0.272 0.000 0.000 0.684 0.044
#> GSM23167     1  0.0000     0.9562 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.1831     0.7959 0.000 0.000 0.920 0.004 0.076
#> GSM23169     3  0.2179     0.7897 0.000 0.000 0.896 0.004 0.100
#> GSM23170     1  0.0703     0.9476 0.976 0.000 0.000 0.000 0.024
#> GSM23171     1  0.0000     0.9562 1.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0290     0.9553 0.992 0.000 0.000 0.000 0.008
#> GSM23173     3  0.4762     0.5575 0.064 0.000 0.700 0.000 0.236
#> GSM23174     1  0.1124     0.9352 0.960 0.000 0.000 0.036 0.004
#> GSM23175     1  0.0671     0.9507 0.980 0.000 0.000 0.004 0.016
#> GSM23176     1  0.0000     0.9562 1.000 0.000 0.000 0.000 0.000
#> GSM23177     1  0.1628     0.9205 0.936 0.000 0.000 0.008 0.056
#> GSM23178     1  0.0162     0.9555 0.996 0.000 0.000 0.000 0.004
#> GSM23179     3  0.1851     0.7909 0.000 0.000 0.912 0.000 0.088
#> GSM23180     4  0.0609     0.7511 0.000 0.000 0.000 0.980 0.020
#> GSM23181     4  0.2491     0.7377 0.036 0.000 0.000 0.896 0.068
#> GSM23182     4  0.1270     0.7473 0.000 0.000 0.000 0.948 0.052
#> GSM23183     5  0.6909     0.2215 0.268 0.000 0.288 0.008 0.436
#> GSM23184     3  0.1851     0.7894 0.000 0.000 0.912 0.000 0.088
#> GSM23196     2  0.0794     0.8342 0.000 0.972 0.000 0.000 0.028
#> GSM23197     2  0.1410     0.8190 0.000 0.940 0.000 0.000 0.060
#> GSM23198     2  0.1792     0.8199 0.000 0.916 0.000 0.000 0.084
#> GSM23199     2  0.2773     0.7757 0.000 0.836 0.000 0.000 0.164
#> GSM23200     2  0.3774     0.6520 0.000 0.704 0.000 0.000 0.296
#> GSM23201     4  0.1522     0.7429 0.000 0.044 0.000 0.944 0.012
#> GSM23202     4  0.3579     0.6577 0.000 0.072 0.000 0.828 0.100
#> GSM23203     2  0.0609     0.8347 0.000 0.980 0.000 0.000 0.020
#> GSM23204     2  0.2127     0.7905 0.000 0.892 0.000 0.000 0.108
#> GSM23205     2  0.4527     0.3743 0.000 0.596 0.000 0.392 0.012
#> GSM23206     2  0.0162     0.8341 0.000 0.996 0.000 0.000 0.004
#> GSM23207     2  0.4323     0.5925 0.000 0.656 0.000 0.012 0.332
#> GSM23208     2  0.0000     0.8345 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0963     0.8275 0.000 0.964 0.000 0.000 0.036
#> GSM23210     2  0.2233     0.8105 0.000 0.892 0.000 0.004 0.104
#> GSM23211     2  0.0404     0.8330 0.000 0.988 0.000 0.000 0.012
#> GSM23212     2  0.6610     0.1386 0.000 0.428 0.000 0.220 0.352
#> GSM23213     5  0.6660    -0.2295 0.000 0.228 0.000 0.380 0.392
#> GSM23214     4  0.5443     0.3110 0.000 0.084 0.000 0.604 0.312
#> GSM23215     2  0.1341     0.8210 0.000 0.944 0.000 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.4767    0.61221 0.000 0.000 0.676 0.168 0.000 0.156
#> GSM23186     1  0.4461    0.17053 0.564 0.000 0.000 0.032 0.000 0.404
#> GSM23187     3  0.2361    0.73431 0.000 0.000 0.884 0.028 0.000 0.088
#> GSM23188     3  0.3819    0.67523 0.000 0.000 0.764 0.064 0.000 0.172
#> GSM23189     3  0.2122    0.73836 0.000 0.000 0.900 0.024 0.000 0.076
#> GSM23190     3  0.4354    0.66249 0.000 0.004 0.720 0.196 0.000 0.080
#> GSM23191     5  0.2852    0.64536 0.000 0.000 0.000 0.080 0.856 0.064
#> GSM23192     6  0.5763    0.58716 0.000 0.000 0.048 0.156 0.172 0.624
#> GSM23193     3  0.5535    0.29863 0.000 0.000 0.516 0.048 0.392 0.044
#> GSM23194     3  0.4757    0.03874 0.000 0.000 0.484 0.048 0.000 0.468
#> GSM23195     6  0.4766    0.74001 0.124 0.000 0.056 0.084 0.000 0.736
#> GSM23159     1  0.1564    0.88548 0.936 0.000 0.000 0.024 0.000 0.040
#> GSM23160     3  0.2680    0.73328 0.000 0.000 0.868 0.056 0.000 0.076
#> GSM23161     1  0.5883    0.56329 0.652 0.000 0.008 0.092 0.132 0.116
#> GSM23162     3  0.3126    0.73285 0.000 0.000 0.856 0.072 0.044 0.028
#> GSM23163     1  0.1341    0.88670 0.948 0.000 0.000 0.028 0.000 0.024
#> GSM23164     5  0.5327    0.46564 0.240 0.000 0.000 0.068 0.644 0.048
#> GSM23165     1  0.0806    0.89510 0.972 0.000 0.000 0.008 0.000 0.020
#> GSM23166     5  0.5913    0.40819 0.268 0.000 0.004 0.072 0.588 0.068
#> GSM23167     1  0.0405    0.89634 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM23168     3  0.3746    0.70826 0.004 0.000 0.800 0.084 0.004 0.108
#> GSM23169     3  0.3832    0.71230 0.000 0.000 0.776 0.104 0.000 0.120
#> GSM23170     1  0.1053    0.88720 0.964 0.000 0.004 0.012 0.000 0.020
#> GSM23171     1  0.0717    0.89622 0.976 0.000 0.000 0.008 0.000 0.016
#> GSM23172     1  0.0508    0.89740 0.984 0.000 0.000 0.004 0.000 0.012
#> GSM23173     3  0.4758    0.65761 0.044 0.000 0.732 0.092 0.000 0.132
#> GSM23174     1  0.1464    0.88531 0.944 0.000 0.000 0.004 0.036 0.016
#> GSM23175     1  0.1074    0.89414 0.960 0.000 0.000 0.012 0.000 0.028
#> GSM23176     1  0.0000    0.89747 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23177     1  0.3039    0.79869 0.852 0.000 0.008 0.056 0.000 0.084
#> GSM23178     1  0.0603    0.89740 0.980 0.000 0.000 0.004 0.000 0.016
#> GSM23179     3  0.2680    0.73549 0.000 0.000 0.868 0.056 0.000 0.076
#> GSM23180     5  0.1524    0.65423 0.000 0.000 0.000 0.008 0.932 0.060
#> GSM23181     5  0.3154    0.59102 0.004 0.000 0.000 0.012 0.800 0.184
#> GSM23182     5  0.1082    0.64304 0.000 0.000 0.000 0.040 0.956 0.004
#> GSM23183     6  0.3028    0.76954 0.104 0.000 0.040 0.008 0.000 0.848
#> GSM23184     3  0.2309    0.74120 0.000 0.000 0.888 0.084 0.000 0.028
#> GSM23196     2  0.1267    0.79339 0.000 0.940 0.000 0.060 0.000 0.000
#> GSM23197     2  0.1075    0.79576 0.000 0.952 0.000 0.048 0.000 0.000
#> GSM23198     2  0.2762    0.66287 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23199     2  0.3727    0.20413 0.000 0.612 0.000 0.388 0.000 0.000
#> GSM23200     2  0.3868   -0.21673 0.000 0.508 0.000 0.492 0.000 0.000
#> GSM23201     5  0.1732    0.63244 0.000 0.072 0.000 0.004 0.920 0.004
#> GSM23202     5  0.3897    0.39761 0.000 0.040 0.000 0.196 0.756 0.008
#> GSM23203     2  0.0865    0.80515 0.000 0.964 0.000 0.036 0.000 0.000
#> GSM23204     2  0.1910    0.74812 0.000 0.892 0.000 0.108 0.000 0.000
#> GSM23205     5  0.4440    0.00958 0.000 0.420 0.000 0.016 0.556 0.008
#> GSM23206     2  0.0260    0.81159 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM23207     4  0.4335    0.06504 0.000 0.472 0.000 0.508 0.020 0.000
#> GSM23208     2  0.0260    0.81131 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM23209     2  0.0547    0.80718 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM23210     2  0.2994    0.63879 0.000 0.788 0.000 0.208 0.004 0.000
#> GSM23211     2  0.0363    0.80936 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM23212     4  0.5680    0.55754 0.000 0.292 0.000 0.516 0.192 0.000
#> GSM23213     4  0.5648    0.52513 0.000 0.116 0.000 0.516 0.356 0.012
#> GSM23214     4  0.4651    0.27935 0.000 0.040 0.000 0.480 0.480 0.000
#> GSM23215     2  0.1531    0.78166 0.000 0.928 0.000 0.068 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-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 cell.type(p) disease.state(p) k
#> SD:NMF 57     3.90e-13         0.052490 2
#> SD:NMF 56     6.91e-13         0.000873 3
#> SD:NMF 52     2.05e-09         0.002566 4
#> SD:NMF 48     4.95e-09         0.008091 5
#> SD:NMF 46     5.31e-08         0.002442 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.561           0.891       0.917         0.4688 0.536   0.536
#> 3 3 0.856           0.865       0.938         0.4114 0.793   0.614
#> 4 4 0.836           0.784       0.885         0.1001 0.944   0.833
#> 5 5 0.844           0.770       0.870         0.0390 0.974   0.910
#> 6 6 0.857           0.744       0.823         0.0297 0.963   0.860

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
#> GSM23185     1  0.8327      0.810 0.736 0.264
#> GSM23186     1  0.2778      0.876 0.952 0.048
#> GSM23187     1  0.8327      0.810 0.736 0.264
#> GSM23188     1  0.8327      0.810 0.736 0.264
#> GSM23189     1  0.8327      0.810 0.736 0.264
#> GSM23190     1  0.8327      0.810 0.736 0.264
#> GSM23191     1  0.7674      0.835 0.776 0.224
#> GSM23192     1  0.5519      0.864 0.872 0.128
#> GSM23193     1  0.7219      0.845 0.800 0.200
#> GSM23194     1  0.8016      0.824 0.756 0.244
#> GSM23195     1  0.6712      0.852 0.824 0.176
#> GSM23159     1  0.0376      0.876 0.996 0.004
#> GSM23160     1  0.8327      0.810 0.736 0.264
#> GSM23161     1  0.0376      0.876 0.996 0.004
#> GSM23162     1  0.7745      0.833 0.772 0.228
#> GSM23163     1  0.2043      0.877 0.968 0.032
#> GSM23164     1  0.0376      0.876 0.996 0.004
#> GSM23165     1  0.0376      0.876 0.996 0.004
#> GSM23166     1  0.0376      0.876 0.996 0.004
#> GSM23167     1  0.0376      0.876 0.996 0.004
#> GSM23168     1  0.8327      0.810 0.736 0.264
#> GSM23169     1  0.7528      0.839 0.784 0.216
#> GSM23170     1  0.0376      0.876 0.996 0.004
#> GSM23171     1  0.0376      0.876 0.996 0.004
#> GSM23172     1  0.0376      0.876 0.996 0.004
#> GSM23173     1  0.7950      0.826 0.760 0.240
#> GSM23174     1  0.0376      0.876 0.996 0.004
#> GSM23175     1  0.0376      0.876 0.996 0.004
#> GSM23176     1  0.0376      0.876 0.996 0.004
#> GSM23177     1  0.0376      0.876 0.996 0.004
#> GSM23178     1  0.0376      0.876 0.996 0.004
#> GSM23179     1  0.8267      0.813 0.740 0.260
#> GSM23180     1  0.0938      0.877 0.988 0.012
#> GSM23181     1  0.0938      0.877 0.988 0.012
#> GSM23182     1  0.0938      0.877 0.988 0.012
#> GSM23183     1  0.4161      0.872 0.916 0.084
#> GSM23184     1  0.8327      0.810 0.736 0.264
#> GSM23196     2  0.0000      0.973 0.000 1.000
#> GSM23197     2  0.0000      0.973 0.000 1.000
#> GSM23198     2  0.0000      0.973 0.000 1.000
#> GSM23199     2  0.0000      0.973 0.000 1.000
#> GSM23200     2  0.0000      0.973 0.000 1.000
#> GSM23201     2  0.3733      0.935 0.072 0.928
#> GSM23202     2  0.3733      0.935 0.072 0.928
#> GSM23203     2  0.0000      0.973 0.000 1.000
#> GSM23204     2  0.0000      0.973 0.000 1.000
#> GSM23205     2  0.3733      0.935 0.072 0.928
#> GSM23206     2  0.0000      0.973 0.000 1.000
#> GSM23207     2  0.0000      0.973 0.000 1.000
#> GSM23208     2  0.0000      0.973 0.000 1.000
#> GSM23209     2  0.0000      0.973 0.000 1.000
#> GSM23210     2  0.0000      0.973 0.000 1.000
#> GSM23211     2  0.0000      0.973 0.000 1.000
#> GSM23212     2  0.3733      0.935 0.072 0.928
#> GSM23213     2  0.3733      0.935 0.072 0.928
#> GSM23214     2  0.3733      0.935 0.072 0.928
#> GSM23215     2  0.0000      0.973 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.864 0.000 0.000 1.000
#> GSM23186     1  0.3816      0.798 0.852 0.000 0.148
#> GSM23187     3  0.0000      0.864 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.864 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.864 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.864 0.000 0.000 1.000
#> GSM23191     3  0.6126      0.421 0.400 0.000 0.600
#> GSM23192     1  0.5882      0.456 0.652 0.000 0.348
#> GSM23193     3  0.6267      0.271 0.452 0.000 0.548
#> GSM23194     3  0.4750      0.727 0.216 0.000 0.784
#> GSM23195     1  0.6180      0.233 0.584 0.000 0.416
#> GSM23159     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23160     3  0.1411      0.861 0.036 0.000 0.964
#> GSM23161     1  0.0592      0.920 0.988 0.000 0.012
#> GSM23162     3  0.5363      0.662 0.276 0.000 0.724
#> GSM23163     1  0.2356      0.872 0.928 0.000 0.072
#> GSM23164     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23165     1  0.0237      0.924 0.996 0.000 0.004
#> GSM23166     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23167     1  0.0237      0.924 0.996 0.000 0.004
#> GSM23168     3  0.0892      0.865 0.020 0.000 0.980
#> GSM23169     3  0.4605      0.755 0.204 0.000 0.796
#> GSM23170     1  0.0237      0.924 0.996 0.000 0.004
#> GSM23171     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23172     1  0.0237      0.924 0.996 0.000 0.004
#> GSM23173     3  0.2959      0.832 0.100 0.000 0.900
#> GSM23174     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23176     1  0.0237      0.924 0.996 0.000 0.004
#> GSM23177     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.924 1.000 0.000 0.000
#> GSM23179     3  0.1031      0.864 0.024 0.000 0.976
#> GSM23180     1  0.0892      0.917 0.980 0.000 0.020
#> GSM23181     1  0.0892      0.917 0.980 0.000 0.020
#> GSM23182     1  0.0892      0.917 0.980 0.000 0.020
#> GSM23183     1  0.5529      0.564 0.704 0.000 0.296
#> GSM23184     3  0.0237      0.865 0.004 0.000 0.996
#> GSM23196     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23201     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23202     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23203     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23205     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23206     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.975 0.000 1.000 0.000
#> GSM23212     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23213     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23214     2  0.2356      0.939 0.072 0.928 0.000
#> GSM23215     2  0.0000      0.975 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
#> GSM23185     3  0.0336    0.84314 0.000 0.000 0.992 0.008
#> GSM23186     1  0.6041    0.35437 0.608 0.000 0.060 0.332
#> GSM23187     3  0.0336    0.84314 0.000 0.000 0.992 0.008
#> GSM23188     3  0.0336    0.84314 0.000 0.000 0.992 0.008
#> GSM23189     3  0.0336    0.84314 0.000 0.000 0.992 0.008
#> GSM23190     3  0.0336    0.84314 0.000 0.000 0.992 0.008
#> GSM23191     4  0.6229    0.23887 0.056 0.000 0.416 0.528
#> GSM23192     4  0.6039    0.59251 0.188 0.000 0.128 0.684
#> GSM23193     4  0.6574    0.37009 0.088 0.000 0.364 0.548
#> GSM23194     3  0.5050    0.18250 0.004 0.000 0.588 0.408
#> GSM23195     4  0.6626    0.54749 0.160 0.000 0.216 0.624
#> GSM23159     1  0.1716    0.83744 0.936 0.000 0.000 0.064
#> GSM23160     3  0.1798    0.82780 0.016 0.000 0.944 0.040
#> GSM23161     1  0.1824    0.84010 0.936 0.000 0.004 0.060
#> GSM23162     3  0.5881    0.00609 0.036 0.000 0.544 0.420
#> GSM23163     1  0.4538    0.65233 0.760 0.000 0.024 0.216
#> GSM23164     1  0.1867    0.83306 0.928 0.000 0.000 0.072
#> GSM23165     1  0.1474    0.83092 0.948 0.000 0.000 0.052
#> GSM23166     1  0.1792    0.83480 0.932 0.000 0.000 0.068
#> GSM23167     1  0.1389    0.83236 0.952 0.000 0.000 0.048
#> GSM23168     3  0.1356    0.83321 0.008 0.000 0.960 0.032
#> GSM23169     3  0.5566    0.55845 0.072 0.000 0.704 0.224
#> GSM23170     1  0.1389    0.84229 0.952 0.000 0.000 0.048
#> GSM23171     1  0.0188    0.84177 0.996 0.000 0.000 0.004
#> GSM23172     1  0.1302    0.83320 0.956 0.000 0.000 0.044
#> GSM23173     3  0.3707    0.74025 0.028 0.000 0.840 0.132
#> GSM23174     1  0.1118    0.84517 0.964 0.000 0.000 0.036
#> GSM23175     1  0.0000    0.84273 1.000 0.000 0.000 0.000
#> GSM23176     1  0.1474    0.83092 0.948 0.000 0.000 0.052
#> GSM23177     1  0.1716    0.83864 0.936 0.000 0.000 0.064
#> GSM23178     1  0.1716    0.84137 0.936 0.000 0.000 0.064
#> GSM23179     3  0.1488    0.83476 0.012 0.000 0.956 0.032
#> GSM23180     1  0.4855    0.44418 0.600 0.000 0.000 0.400
#> GSM23181     1  0.4855    0.44418 0.600 0.000 0.000 0.400
#> GSM23182     1  0.4855    0.44418 0.600 0.000 0.000 0.400
#> GSM23183     4  0.6634    0.46754 0.292 0.000 0.116 0.592
#> GSM23184     3  0.0469    0.84031 0.000 0.000 0.988 0.012
#> GSM23196     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23200     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23201     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23202     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23203     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23205     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23206     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23208     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000    0.97784 0.000 1.000 0.000 0.000
#> GSM23212     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23213     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23214     2  0.1867    0.94692 0.000 0.928 0.000 0.072
#> GSM23215     2  0.0000    0.97784 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
#> GSM23185     3  0.0451    0.81621 0.000 0.000 0.988 0.004 0.008
#> GSM23186     5  0.5503    0.21334 0.404 0.000 0.020 0.032 0.544
#> GSM23187     3  0.0162    0.81849 0.000 0.000 0.996 0.000 0.004
#> GSM23188     3  0.0162    0.81849 0.000 0.000 0.996 0.000 0.004
#> GSM23189     3  0.0162    0.81849 0.000 0.000 0.996 0.000 0.004
#> GSM23190     3  0.0162    0.81849 0.000 0.000 0.996 0.000 0.004
#> GSM23191     4  0.3870    0.84134 0.016 0.000 0.176 0.792 0.016
#> GSM23192     5  0.6294    0.31135 0.076 0.000 0.044 0.304 0.576
#> GSM23193     4  0.4823    0.80745 0.036 0.000 0.164 0.752 0.048
#> GSM23194     3  0.6615   -0.00934 0.004 0.000 0.492 0.236 0.268
#> GSM23195     5  0.4245    0.51103 0.040 0.000 0.076 0.072 0.812
#> GSM23159     1  0.2676    0.77074 0.884 0.000 0.000 0.036 0.080
#> GSM23160     3  0.3008    0.78148 0.004 0.000 0.868 0.092 0.036
#> GSM23161     1  0.2605    0.79219 0.896 0.000 0.004 0.056 0.044
#> GSM23162     4  0.4645    0.73312 0.016 0.000 0.300 0.672 0.012
#> GSM23163     1  0.4797    0.41534 0.676 0.000 0.004 0.040 0.280
#> GSM23164     1  0.2653    0.78205 0.880 0.000 0.000 0.096 0.024
#> GSM23165     1  0.2209    0.76742 0.912 0.000 0.000 0.032 0.056
#> GSM23166     1  0.2482    0.78799 0.892 0.000 0.000 0.084 0.024
#> GSM23167     1  0.2139    0.76989 0.916 0.000 0.000 0.032 0.052
#> GSM23168     3  0.2570    0.78683 0.000 0.000 0.888 0.084 0.028
#> GSM23169     3  0.6824    0.34805 0.024 0.000 0.524 0.204 0.248
#> GSM23170     1  0.2079    0.79697 0.916 0.000 0.000 0.064 0.020
#> GSM23171     1  0.0693    0.79806 0.980 0.000 0.000 0.008 0.012
#> GSM23172     1  0.1992    0.77380 0.924 0.000 0.000 0.032 0.044
#> GSM23173     3  0.5750    0.56275 0.008 0.000 0.644 0.144 0.204
#> GSM23174     1  0.1670    0.80262 0.936 0.000 0.000 0.052 0.012
#> GSM23175     1  0.0579    0.79919 0.984 0.000 0.000 0.008 0.008
#> GSM23176     1  0.2209    0.76742 0.912 0.000 0.000 0.032 0.056
#> GSM23177     1  0.2248    0.79301 0.900 0.000 0.000 0.088 0.012
#> GSM23178     1  0.2325    0.79557 0.904 0.000 0.000 0.068 0.028
#> GSM23179     3  0.2504    0.79423 0.000 0.000 0.896 0.064 0.040
#> GSM23180     1  0.5928    0.32191 0.500 0.000 0.000 0.392 0.108
#> GSM23181     1  0.5928    0.32191 0.500 0.000 0.000 0.392 0.108
#> GSM23182     1  0.5928    0.32191 0.500 0.000 0.000 0.392 0.108
#> GSM23183     5  0.3717    0.59215 0.100 0.000 0.040 0.024 0.836
#> GSM23184     3  0.0794    0.81217 0.000 0.000 0.972 0.028 0.000
#> GSM23196     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23200     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23201     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23202     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23203     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23206     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23208     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000    0.97702 0.000 1.000 0.000 0.000 0.000
#> GSM23212     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23213     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23214     2  0.1608    0.94492 0.000 0.928 0.000 0.072 0.000
#> GSM23215     2  0.0000    0.97702 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
#> GSM23185     3  0.0260     0.7824 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM23186     6  0.5599     0.3909 0.368 0.000 0.004 0.060 0.032 0.536
#> GSM23187     3  0.0000     0.7853 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.7853 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.7853 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000     0.7853 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.4176     0.5719 0.000 0.000 0.044 0.244 0.708 0.004
#> GSM23192     6  0.6228     0.3778 0.028 0.000 0.012 0.216 0.180 0.564
#> GSM23193     5  0.4603     0.5431 0.004 0.000 0.040 0.316 0.636 0.004
#> GSM23194     3  0.6838     0.0221 0.000 0.000 0.424 0.056 0.248 0.272
#> GSM23195     6  0.4356     0.5425 0.024 0.000 0.004 0.132 0.076 0.764
#> GSM23159     1  0.4040     0.6177 0.772 0.000 0.000 0.140 0.012 0.076
#> GSM23160     3  0.4767     0.6616 0.000 0.000 0.716 0.072 0.176 0.036
#> GSM23161     1  0.4235     0.6306 0.684 0.000 0.000 0.280 0.012 0.024
#> GSM23162     5  0.4057     0.5472 0.000 0.000 0.124 0.108 0.764 0.004
#> GSM23163     1  0.4948     0.3104 0.648 0.000 0.000 0.080 0.012 0.260
#> GSM23164     1  0.3515     0.5912 0.676 0.000 0.000 0.324 0.000 0.000
#> GSM23165     1  0.0603     0.6951 0.980 0.000 0.000 0.016 0.000 0.004
#> GSM23166     1  0.3446     0.6187 0.692 0.000 0.000 0.308 0.000 0.000
#> GSM23167     1  0.0458     0.6977 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM23168     3  0.3972     0.7055 0.000 0.000 0.784 0.076 0.124 0.016
#> GSM23169     5  0.7665    -0.1565 0.004 0.000 0.260 0.196 0.352 0.188
#> GSM23170     1  0.3288     0.6548 0.724 0.000 0.000 0.276 0.000 0.000
#> GSM23171     1  0.2340     0.7353 0.852 0.000 0.000 0.148 0.000 0.000
#> GSM23172     1  0.0260     0.7056 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM23173     3  0.7392     0.1261 0.000 0.000 0.372 0.224 0.272 0.132
#> GSM23174     1  0.2664     0.7243 0.816 0.000 0.000 0.184 0.000 0.000
#> GSM23175     1  0.2378     0.7340 0.848 0.000 0.000 0.152 0.000 0.000
#> GSM23176     1  0.0603     0.6951 0.980 0.000 0.000 0.016 0.000 0.004
#> GSM23177     1  0.3288     0.6555 0.724 0.000 0.000 0.276 0.000 0.000
#> GSM23178     1  0.2527     0.7135 0.832 0.000 0.000 0.168 0.000 0.000
#> GSM23179     3  0.4110     0.7040 0.000 0.000 0.776 0.068 0.132 0.024
#> GSM23180     4  0.3490     1.0000 0.268 0.000 0.000 0.724 0.000 0.008
#> GSM23181     4  0.3490     1.0000 0.268 0.000 0.000 0.724 0.000 0.008
#> GSM23182     4  0.3490     1.0000 0.268 0.000 0.000 0.724 0.000 0.008
#> GSM23183     6  0.2221     0.5999 0.040 0.000 0.004 0.044 0.004 0.908
#> GSM23184     3  0.1498     0.7729 0.000 0.000 0.940 0.028 0.032 0.000
#> GSM23196     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23200     2  0.0146     0.9743 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23201     2  0.1444     0.9433 0.000 0.928 0.000 0.072 0.000 0.000
#> GSM23202     2  0.1501     0.9419 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23203     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     2  0.1444     0.9433 0.000 0.928 0.000 0.072 0.000 0.000
#> GSM23206     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.0146     0.9743 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23208     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23211     2  0.0000     0.9757 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     2  0.1501     0.9419 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23213     2  0.1501     0.9419 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23214     2  0.1501     0.9419 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23215     2  0.0000     0.9757 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-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 cell.type(p) disease.state(p) k
#> CV:hclust 57     3.90e-13         0.052490 2
#> CV:hclust 53     3.10e-12         0.007090 3
#> CV:hclust 48     2.13e-10         0.000175 4
#> CV:hclust 49     5.84e-10         0.000821 5
#> CV:hclust 51     8.65e-10         0.000027 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 11993 rows and 57 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.874           0.965       0.974         0.4673 0.536   0.536
#> 3 3 0.713           0.950       0.909         0.3953 0.786   0.600
#> 4 4 0.819           0.841       0.828         0.1287 0.937   0.805
#> 5 5 0.755           0.784       0.825         0.0656 0.920   0.705
#> 6 6 0.758           0.742       0.819         0.0431 0.950   0.766

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
#> GSM23185     1  0.3879      0.935 0.924 0.076
#> GSM23186     1  0.0000      0.963 1.000 0.000
#> GSM23187     1  0.3879      0.935 0.924 0.076
#> GSM23188     1  0.3879      0.935 0.924 0.076
#> GSM23189     1  0.3879      0.935 0.924 0.076
#> GSM23190     1  0.3879      0.935 0.924 0.076
#> GSM23191     1  0.0376      0.963 0.996 0.004
#> GSM23192     1  0.0000      0.963 1.000 0.000
#> GSM23193     1  0.0000      0.963 1.000 0.000
#> GSM23194     1  0.3879      0.935 0.924 0.076
#> GSM23195     1  0.0376      0.963 0.996 0.004
#> GSM23159     1  0.1843      0.968 0.972 0.028
#> GSM23160     1  0.3879      0.935 0.924 0.076
#> GSM23161     1  0.1843      0.968 0.972 0.028
#> GSM23162     1  0.0938      0.962 0.988 0.012
#> GSM23163     1  0.1633      0.967 0.976 0.024
#> GSM23164     1  0.1843      0.968 0.972 0.028
#> GSM23165     1  0.1843      0.968 0.972 0.028
#> GSM23166     1  0.1843      0.968 0.972 0.028
#> GSM23167     1  0.1843      0.968 0.972 0.028
#> GSM23168     1  0.3879      0.935 0.924 0.076
#> GSM23169     1  0.0000      0.963 1.000 0.000
#> GSM23170     1  0.1843      0.968 0.972 0.028
#> GSM23171     1  0.1843      0.968 0.972 0.028
#> GSM23172     1  0.1843      0.968 0.972 0.028
#> GSM23173     1  0.0376      0.963 0.996 0.004
#> GSM23174     1  0.1843      0.968 0.972 0.028
#> GSM23175     1  0.1843      0.968 0.972 0.028
#> GSM23176     1  0.1843      0.968 0.972 0.028
#> GSM23177     1  0.1843      0.968 0.972 0.028
#> GSM23178     1  0.1843      0.968 0.972 0.028
#> GSM23179     1  0.3879      0.935 0.924 0.076
#> GSM23180     1  0.1843      0.968 0.972 0.028
#> GSM23181     1  0.1843      0.968 0.972 0.028
#> GSM23182     1  0.1843      0.968 0.972 0.028
#> GSM23183     1  0.0000      0.963 1.000 0.000
#> GSM23184     1  0.3879      0.935 0.924 0.076
#> GSM23196     2  0.0000      0.988 0.000 1.000
#> GSM23197     2  0.0000      0.988 0.000 1.000
#> GSM23198     2  0.0000      0.988 0.000 1.000
#> GSM23199     2  0.0000      0.988 0.000 1.000
#> GSM23200     2  0.0000      0.988 0.000 1.000
#> GSM23201     2  0.0000      0.988 0.000 1.000
#> GSM23202     2  0.3733      0.928 0.072 0.928
#> GSM23203     2  0.0000      0.988 0.000 1.000
#> GSM23204     2  0.0000      0.988 0.000 1.000
#> GSM23205     2  0.0000      0.988 0.000 1.000
#> GSM23206     2  0.0000      0.988 0.000 1.000
#> GSM23207     2  0.0000      0.988 0.000 1.000
#> GSM23208     2  0.0000      0.988 0.000 1.000
#> GSM23209     2  0.0000      0.988 0.000 1.000
#> GSM23210     2  0.0000      0.988 0.000 1.000
#> GSM23211     2  0.0000      0.988 0.000 1.000
#> GSM23212     2  0.0000      0.988 0.000 1.000
#> GSM23213     2  0.3584      0.932 0.068 0.932
#> GSM23214     2  0.3584      0.932 0.068 0.932
#> GSM23215     2  0.0000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.943 0.000 0.000 1.000
#> GSM23186     1  0.4062      0.987 0.836 0.000 0.164
#> GSM23187     3  0.0000      0.943 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.943 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.943 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.943 0.000 0.000 1.000
#> GSM23191     3  0.3918      0.858 0.140 0.004 0.856
#> GSM23192     3  0.3816      0.850 0.148 0.000 0.852
#> GSM23193     3  0.3784      0.868 0.132 0.004 0.864
#> GSM23194     3  0.0747      0.950 0.016 0.000 0.984
#> GSM23195     3  0.3500      0.882 0.116 0.004 0.880
#> GSM23159     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23160     3  0.0747      0.950 0.016 0.000 0.984
#> GSM23161     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23162     3  0.0983      0.949 0.016 0.004 0.980
#> GSM23163     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23164     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23165     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23166     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23167     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23168     3  0.0747      0.950 0.016 0.000 0.984
#> GSM23169     3  0.0983      0.949 0.016 0.004 0.980
#> GSM23170     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23171     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23172     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23173     3  0.0983      0.949 0.016 0.004 0.980
#> GSM23174     1  0.3752      0.986 0.856 0.000 0.144
#> GSM23175     1  0.3816      0.989 0.852 0.000 0.148
#> GSM23176     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23177     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23178     1  0.3941      0.995 0.844 0.000 0.156
#> GSM23179     3  0.0747      0.950 0.016 0.000 0.984
#> GSM23180     1  0.3983      0.984 0.852 0.004 0.144
#> GSM23181     1  0.3752      0.986 0.856 0.000 0.144
#> GSM23182     1  0.3983      0.984 0.852 0.004 0.144
#> GSM23183     3  0.3619      0.865 0.136 0.000 0.864
#> GSM23184     3  0.0747      0.950 0.016 0.000 0.984
#> GSM23196     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23197     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23198     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23199     2  0.0000      0.930 0.000 1.000 0.000
#> GSM23200     2  0.3551      0.938 0.132 0.868 0.000
#> GSM23201     2  0.1031      0.925 0.024 0.976 0.000
#> GSM23202     2  0.1031      0.925 0.024 0.976 0.000
#> GSM23203     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23204     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23205     2  0.0892      0.926 0.020 0.980 0.000
#> GSM23206     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23207     2  0.0592      0.927 0.012 0.988 0.000
#> GSM23208     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23209     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23210     2  0.0424      0.928 0.008 0.992 0.000
#> GSM23211     2  0.4418      0.938 0.132 0.848 0.020
#> GSM23212     2  0.1031      0.925 0.024 0.976 0.000
#> GSM23213     2  0.1031      0.925 0.024 0.976 0.000
#> GSM23214     2  0.1031      0.925 0.024 0.976 0.000
#> GSM23215     2  0.3752      0.939 0.096 0.884 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.0804      0.871 0.012 0.008 0.980 0.000
#> GSM23186     1  0.2589      0.888 0.884 0.116 0.000 0.000
#> GSM23187     3  0.0469      0.871 0.012 0.000 0.988 0.000
#> GSM23188     3  0.0469      0.871 0.012 0.000 0.988 0.000
#> GSM23189     3  0.0469      0.871 0.012 0.000 0.988 0.000
#> GSM23190     3  0.0804      0.871 0.012 0.008 0.980 0.000
#> GSM23191     3  0.6575      0.702 0.092 0.348 0.560 0.000
#> GSM23192     3  0.6659      0.670 0.088 0.400 0.512 0.000
#> GSM23193     3  0.6412      0.715 0.080 0.348 0.572 0.000
#> GSM23194     3  0.1798      0.870 0.016 0.040 0.944 0.000
#> GSM23195     3  0.6519      0.722 0.096 0.320 0.584 0.000
#> GSM23159     1  0.0188      0.930 0.996 0.004 0.000 0.000
#> GSM23160     3  0.0592      0.872 0.016 0.000 0.984 0.000
#> GSM23161     1  0.0921      0.927 0.972 0.028 0.000 0.000
#> GSM23162     3  0.3836      0.841 0.016 0.168 0.816 0.000
#> GSM23163     1  0.1474      0.925 0.948 0.052 0.000 0.000
#> GSM23164     1  0.1211      0.921 0.960 0.040 0.000 0.000
#> GSM23165     1  0.0921      0.928 0.972 0.028 0.000 0.000
#> GSM23166     1  0.1302      0.920 0.956 0.044 0.000 0.000
#> GSM23167     1  0.0921      0.928 0.972 0.028 0.000 0.000
#> GSM23168     3  0.0592      0.872 0.016 0.000 0.984 0.000
#> GSM23169     3  0.4214      0.827 0.016 0.204 0.780 0.000
#> GSM23170     1  0.0188      0.931 0.996 0.004 0.000 0.000
#> GSM23171     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0921      0.928 0.972 0.028 0.000 0.000
#> GSM23173     3  0.2593      0.862 0.016 0.080 0.904 0.000
#> GSM23174     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0000      0.930 1.000 0.000 0.000 0.000
#> GSM23176     1  0.0921      0.928 0.972 0.028 0.000 0.000
#> GSM23177     1  0.0188      0.930 0.996 0.004 0.000 0.000
#> GSM23178     1  0.1557      0.924 0.944 0.056 0.000 0.000
#> GSM23179     3  0.0592      0.872 0.016 0.000 0.984 0.000
#> GSM23180     1  0.6106      0.613 0.604 0.332 0.000 0.064
#> GSM23181     1  0.3975      0.777 0.760 0.240 0.000 0.000
#> GSM23182     1  0.6374      0.598 0.592 0.324 0.000 0.084
#> GSM23183     3  0.6532      0.714 0.092 0.336 0.572 0.000
#> GSM23184     3  0.0927      0.872 0.016 0.008 0.976 0.000
#> GSM23196     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23197     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23198     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23199     4  0.2814      0.687 0.000 0.132 0.000 0.868
#> GSM23200     2  0.4977      0.905 0.000 0.540 0.000 0.460
#> GSM23201     4  0.0657      0.841 0.000 0.004 0.012 0.984
#> GSM23202     4  0.0188      0.844 0.000 0.000 0.004 0.996
#> GSM23203     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23204     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23205     4  0.0804      0.841 0.000 0.008 0.012 0.980
#> GSM23206     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23207     4  0.1637      0.802 0.000 0.060 0.000 0.940
#> GSM23208     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23209     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23210     4  0.2546      0.765 0.000 0.092 0.008 0.900
#> GSM23211     2  0.5070      0.990 0.000 0.580 0.004 0.416
#> GSM23212     4  0.0000      0.844 0.000 0.000 0.000 1.000
#> GSM23213     4  0.0000      0.844 0.000 0.000 0.000 1.000
#> GSM23214     4  0.0188      0.844 0.000 0.000 0.004 0.996
#> GSM23215     4  0.5292     -0.762 0.000 0.480 0.008 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
#> GSM23185     3  0.0451    0.85626 0.004 0.008 0.988 0.000 0.000
#> GSM23186     1  0.6362    0.45158 0.552 0.264 0.008 0.000 0.176
#> GSM23187     3  0.0451    0.85626 0.004 0.008 0.988 0.000 0.000
#> GSM23188     3  0.0451    0.85626 0.004 0.008 0.988 0.000 0.000
#> GSM23189     3  0.0451    0.85626 0.004 0.008 0.988 0.000 0.000
#> GSM23190     3  0.0451    0.85626 0.004 0.008 0.988 0.000 0.000
#> GSM23191     5  0.4210    0.61744 0.036 0.000 0.224 0.000 0.740
#> GSM23192     5  0.5760    0.64900 0.036 0.120 0.160 0.000 0.684
#> GSM23193     5  0.4210    0.61744 0.036 0.000 0.224 0.000 0.740
#> GSM23194     3  0.3909    0.72431 0.004 0.064 0.808 0.000 0.124
#> GSM23195     5  0.6875    0.51072 0.024 0.220 0.240 0.000 0.516
#> GSM23159     1  0.1281    0.86747 0.956 0.032 0.000 0.000 0.012
#> GSM23160     3  0.1471    0.84896 0.004 0.020 0.952 0.000 0.024
#> GSM23161     1  0.2054    0.84242 0.920 0.028 0.000 0.000 0.052
#> GSM23162     3  0.4604    0.32146 0.004 0.008 0.584 0.000 0.404
#> GSM23163     1  0.3955    0.82211 0.800 0.116 0.000 0.000 0.084
#> GSM23164     1  0.1638    0.84229 0.932 0.004 0.000 0.000 0.064
#> GSM23165     1  0.2983    0.84283 0.864 0.096 0.000 0.000 0.040
#> GSM23166     1  0.1638    0.84180 0.932 0.004 0.000 0.000 0.064
#> GSM23167     1  0.2927    0.84432 0.868 0.092 0.000 0.000 0.040
#> GSM23168     3  0.1560    0.84762 0.004 0.020 0.948 0.000 0.028
#> GSM23169     3  0.6279    0.21614 0.004 0.148 0.520 0.000 0.328
#> GSM23170     1  0.0693    0.86853 0.980 0.012 0.000 0.000 0.008
#> GSM23171     1  0.0671    0.86969 0.980 0.016 0.000 0.000 0.004
#> GSM23172     1  0.2983    0.84283 0.864 0.096 0.000 0.000 0.040
#> GSM23173     3  0.4781    0.65548 0.004 0.080 0.728 0.000 0.188
#> GSM23174     1  0.0162    0.86666 0.996 0.000 0.000 0.000 0.004
#> GSM23175     1  0.0162    0.86666 0.996 0.000 0.000 0.000 0.004
#> GSM23176     1  0.2927    0.84432 0.868 0.092 0.000 0.000 0.040
#> GSM23177     1  0.0324    0.86574 0.992 0.004 0.000 0.000 0.004
#> GSM23178     1  0.2645    0.85726 0.888 0.044 0.000 0.000 0.068
#> GSM23179     3  0.1356    0.85033 0.004 0.028 0.956 0.000 0.012
#> GSM23180     5  0.4329    0.47414 0.312 0.000 0.000 0.016 0.672
#> GSM23181     1  0.4300    0.00155 0.524 0.000 0.000 0.000 0.476
#> GSM23182     5  0.5107    0.47271 0.296 0.000 0.000 0.064 0.640
#> GSM23183     5  0.6750    0.54647 0.024 0.220 0.216 0.000 0.540
#> GSM23184     3  0.0451    0.85496 0.004 0.000 0.988 0.000 0.008
#> GSM23196     2  0.4142    0.94835 0.000 0.684 0.004 0.308 0.004
#> GSM23197     2  0.3837    0.94997 0.000 0.692 0.000 0.308 0.000
#> GSM23198     2  0.4142    0.94835 0.000 0.684 0.004 0.308 0.004
#> GSM23199     4  0.2835    0.82919 0.000 0.080 0.004 0.880 0.036
#> GSM23200     2  0.4843    0.77042 0.000 0.552 0.004 0.428 0.016
#> GSM23201     4  0.2074    0.89577 0.000 0.000 0.000 0.896 0.104
#> GSM23202     4  0.1270    0.90998 0.000 0.000 0.000 0.948 0.052
#> GSM23203     2  0.4142    0.94835 0.000 0.684 0.004 0.308 0.004
#> GSM23204     2  0.3837    0.94997 0.000 0.692 0.000 0.308 0.000
#> GSM23205     4  0.2074    0.89577 0.000 0.000 0.000 0.896 0.104
#> GSM23206     2  0.3837    0.94997 0.000 0.692 0.000 0.308 0.000
#> GSM23207     4  0.1012    0.90297 0.000 0.020 0.000 0.968 0.012
#> GSM23208     2  0.3990    0.94938 0.000 0.688 0.000 0.308 0.004
#> GSM23209     2  0.3837    0.94997 0.000 0.692 0.000 0.308 0.000
#> GSM23210     4  0.3102    0.84968 0.000 0.056 0.000 0.860 0.084
#> GSM23211     2  0.3837    0.94997 0.000 0.692 0.000 0.308 0.000
#> GSM23212     4  0.0703    0.91252 0.000 0.000 0.000 0.976 0.024
#> GSM23213     4  0.0609    0.91303 0.000 0.000 0.000 0.980 0.020
#> GSM23214     4  0.1270    0.90998 0.000 0.000 0.000 0.948 0.052
#> GSM23215     2  0.5492    0.65364 0.000 0.504 0.000 0.432 0.064

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.0146     0.8670 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM23186     6  0.4230     0.1548 0.292 0.004 0.004 0.000 0.024 0.676
#> GSM23187     3  0.0000     0.8682 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.8682 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.8682 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0260     0.8666 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM23191     5  0.1699     0.4877 0.016 0.000 0.032 0.000 0.936 0.016
#> GSM23192     5  0.5282    -0.1784 0.016 0.016 0.032 0.000 0.524 0.412
#> GSM23193     5  0.1679     0.4849 0.012 0.000 0.036 0.000 0.936 0.016
#> GSM23194     3  0.5336     0.5593 0.000 0.056 0.676 0.000 0.168 0.100
#> GSM23195     6  0.6096     0.4756 0.012 0.044 0.108 0.000 0.252 0.584
#> GSM23159     1  0.1657     0.8587 0.928 0.016 0.000 0.000 0.000 0.056
#> GSM23160     3  0.2852     0.8452 0.000 0.064 0.872 0.000 0.044 0.020
#> GSM23161     1  0.2851     0.8134 0.876 0.040 0.000 0.000 0.040 0.044
#> GSM23162     5  0.5181     0.0126 0.000 0.052 0.348 0.000 0.576 0.024
#> GSM23163     1  0.4175     0.7770 0.716 0.028 0.000 0.000 0.016 0.240
#> GSM23164     1  0.2384     0.8202 0.896 0.040 0.000 0.000 0.056 0.008
#> GSM23165     1  0.3610     0.7976 0.768 0.028 0.000 0.000 0.004 0.200
#> GSM23166     1  0.2384     0.8202 0.896 0.040 0.000 0.000 0.056 0.008
#> GSM23167     1  0.3549     0.8024 0.776 0.028 0.000 0.000 0.004 0.192
#> GSM23168     3  0.2852     0.8452 0.000 0.064 0.872 0.000 0.044 0.020
#> GSM23169     6  0.7115     0.2355 0.000 0.076 0.292 0.000 0.264 0.368
#> GSM23170     1  0.1364     0.8612 0.952 0.020 0.000 0.000 0.012 0.016
#> GSM23171     1  0.1232     0.8616 0.956 0.016 0.000 0.000 0.004 0.024
#> GSM23172     1  0.3610     0.7976 0.768 0.028 0.000 0.000 0.004 0.200
#> GSM23173     3  0.6564     0.3376 0.000 0.104 0.540 0.000 0.144 0.212
#> GSM23174     1  0.0820     0.8555 0.972 0.016 0.000 0.000 0.012 0.000
#> GSM23175     1  0.0993     0.8579 0.964 0.024 0.000 0.000 0.012 0.000
#> GSM23176     1  0.3610     0.7976 0.768 0.028 0.000 0.000 0.004 0.200
#> GSM23177     1  0.1296     0.8487 0.952 0.032 0.000 0.000 0.012 0.004
#> GSM23178     1  0.4219     0.8168 0.776 0.040 0.000 0.000 0.064 0.120
#> GSM23179     3  0.2911     0.8431 0.000 0.072 0.868 0.000 0.036 0.024
#> GSM23180     5  0.4420     0.5318 0.200 0.032 0.000 0.000 0.728 0.040
#> GSM23181     5  0.4987     0.4043 0.340 0.040 0.000 0.000 0.596 0.024
#> GSM23182     5  0.5017     0.5225 0.208 0.032 0.000 0.008 0.692 0.060
#> GSM23183     6  0.5866     0.4565 0.012 0.036 0.088 0.000 0.272 0.592
#> GSM23184     3  0.1599     0.8643 0.000 0.028 0.940 0.000 0.024 0.008
#> GSM23196     2  0.3250     0.9369 0.000 0.788 0.000 0.196 0.004 0.012
#> GSM23197     2  0.2762     0.9405 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23198     2  0.3250     0.9369 0.000 0.788 0.000 0.196 0.004 0.012
#> GSM23199     4  0.2875     0.8570 0.000 0.036 0.000 0.872 0.028 0.064
#> GSM23200     2  0.4688     0.6641 0.000 0.572 0.000 0.388 0.012 0.028
#> GSM23201     4  0.3141     0.8630 0.000 0.000 0.000 0.788 0.012 0.200
#> GSM23202     4  0.1967     0.8942 0.000 0.000 0.000 0.904 0.012 0.084
#> GSM23203     2  0.3250     0.9369 0.000 0.788 0.000 0.196 0.004 0.012
#> GSM23204     2  0.2762     0.9405 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23205     4  0.3141     0.8630 0.000 0.000 0.000 0.788 0.012 0.200
#> GSM23206     2  0.2762     0.9405 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23207     4  0.0777     0.8934 0.000 0.004 0.000 0.972 0.000 0.024
#> GSM23208     2  0.2902     0.9399 0.000 0.800 0.000 0.196 0.004 0.000
#> GSM23209     2  0.2762     0.9405 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23210     4  0.2794     0.8685 0.000 0.004 0.000 0.840 0.012 0.144
#> GSM23211     2  0.2762     0.9405 0.000 0.804 0.000 0.196 0.000 0.000
#> GSM23212     4  0.0405     0.8997 0.000 0.000 0.000 0.988 0.004 0.008
#> GSM23213     4  0.0405     0.8997 0.000 0.000 0.000 0.988 0.004 0.008
#> GSM23214     4  0.1644     0.8963 0.000 0.000 0.000 0.920 0.004 0.076
#> GSM23215     2  0.5540     0.6571 0.000 0.576 0.000 0.300 0.020 0.104

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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 cell.type(p) disease.state(p) k
#> CV:kmeans 57     3.90e-13         5.25e-02 2
#> CV:kmeans 57     4.19e-13         4.23e-04 3
#> CV:kmeans 56     4.20e-12         1.13e-03 4
#> CV:kmeans 51     2.23e-10         1.06e-04 5
#> CV:kmeans 47     1.52e-09         2.41e-05 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4642 0.536   0.536
#> 3 3 1.000           0.995       0.998         0.4609 0.786   0.600
#> 4 4 0.826           0.862       0.907         0.0882 0.932   0.792
#> 5 5 0.748           0.742       0.850         0.0686 0.932   0.750
#> 6 6 0.719           0.678       0.793         0.0371 0.961   0.822

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
#> GSM23185     1       0          1  1  0
#> GSM23186     1       0          1  1  0
#> GSM23187     1       0          1  1  0
#> GSM23188     1       0          1  1  0
#> GSM23189     1       0          1  1  0
#> GSM23190     1       0          1  1  0
#> GSM23191     1       0          1  1  0
#> GSM23192     1       0          1  1  0
#> GSM23193     1       0          1  1  0
#> GSM23194     1       0          1  1  0
#> GSM23195     1       0          1  1  0
#> GSM23159     1       0          1  1  0
#> GSM23160     1       0          1  1  0
#> GSM23161     1       0          1  1  0
#> GSM23162     1       0          1  1  0
#> GSM23163     1       0          1  1  0
#> GSM23164     1       0          1  1  0
#> GSM23165     1       0          1  1  0
#> GSM23166     1       0          1  1  0
#> GSM23167     1       0          1  1  0
#> GSM23168     1       0          1  1  0
#> GSM23169     1       0          1  1  0
#> GSM23170     1       0          1  1  0
#> GSM23171     1       0          1  1  0
#> GSM23172     1       0          1  1  0
#> GSM23173     1       0          1  1  0
#> GSM23174     1       0          1  1  0
#> GSM23175     1       0          1  1  0
#> GSM23176     1       0          1  1  0
#> GSM23177     1       0          1  1  0
#> GSM23178     1       0          1  1  0
#> GSM23179     1       0          1  1  0
#> GSM23180     1       0          1  1  0
#> GSM23181     1       0          1  1  0
#> GSM23182     1       0          1  1  0
#> GSM23183     1       0          1  1  0
#> GSM23184     1       0          1  1  0
#> GSM23196     2       0          1  0  1
#> GSM23197     2       0          1  0  1
#> GSM23198     2       0          1  0  1
#> GSM23199     2       0          1  0  1
#> GSM23200     2       0          1  0  1
#> GSM23201     2       0          1  0  1
#> GSM23202     2       0          1  0  1
#> GSM23203     2       0          1  0  1
#> GSM23204     2       0          1  0  1
#> GSM23205     2       0          1  0  1
#> GSM23206     2       0          1  0  1
#> GSM23207     2       0          1  0  1
#> GSM23208     2       0          1  0  1
#> GSM23209     2       0          1  0  1
#> GSM23210     2       0          1  0  1
#> GSM23211     2       0          1  0  1
#> GSM23212     2       0          1  0  1
#> GSM23213     2       0          1  0  1
#> GSM23214     2       0          1  0  1
#> GSM23215     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1 p2    p3
#> GSM23185     3  0.0000      0.995 0.000  0 1.000
#> GSM23186     1  0.1643      0.955 0.956  0 0.044
#> GSM23187     3  0.0000      0.995 0.000  0 1.000
#> GSM23188     3  0.0000      0.995 0.000  0 1.000
#> GSM23189     3  0.0000      0.995 0.000  0 1.000
#> GSM23190     3  0.0000      0.995 0.000  0 1.000
#> GSM23191     3  0.1289      0.970 0.032  0 0.968
#> GSM23192     3  0.1289      0.969 0.032  0 0.968
#> GSM23193     3  0.0747      0.984 0.016  0 0.984
#> GSM23194     3  0.0000      0.995 0.000  0 1.000
#> GSM23195     3  0.0000      0.995 0.000  0 1.000
#> GSM23159     1  0.0000      0.997 1.000  0 0.000
#> GSM23160     3  0.0000      0.995 0.000  0 1.000
#> GSM23161     1  0.0000      0.997 1.000  0 0.000
#> GSM23162     3  0.0000      0.995 0.000  0 1.000
#> GSM23163     1  0.0237      0.994 0.996  0 0.004
#> GSM23164     1  0.0000      0.997 1.000  0 0.000
#> GSM23165     1  0.0000      0.997 1.000  0 0.000
#> GSM23166     1  0.0000      0.997 1.000  0 0.000
#> GSM23167     1  0.0000      0.997 1.000  0 0.000
#> GSM23168     3  0.0000      0.995 0.000  0 1.000
#> GSM23169     3  0.0000      0.995 0.000  0 1.000
#> GSM23170     1  0.0000      0.997 1.000  0 0.000
#> GSM23171     1  0.0000      0.997 1.000  0 0.000
#> GSM23172     1  0.0000      0.997 1.000  0 0.000
#> GSM23173     3  0.0000      0.995 0.000  0 1.000
#> GSM23174     1  0.0000      0.997 1.000  0 0.000
#> GSM23175     1  0.0000      0.997 1.000  0 0.000
#> GSM23176     1  0.0000      0.997 1.000  0 0.000
#> GSM23177     1  0.0000      0.997 1.000  0 0.000
#> GSM23178     1  0.0000      0.997 1.000  0 0.000
#> GSM23179     3  0.0000      0.995 0.000  0 1.000
#> GSM23180     1  0.0000      0.997 1.000  0 0.000
#> GSM23181     1  0.0000      0.997 1.000  0 0.000
#> GSM23182     1  0.0000      0.997 1.000  0 0.000
#> GSM23183     3  0.0592      0.987 0.012  0 0.988
#> GSM23184     3  0.0000      0.995 0.000  0 1.000
#> GSM23196     2  0.0000      1.000 0.000  1 0.000
#> GSM23197     2  0.0000      1.000 0.000  1 0.000
#> GSM23198     2  0.0000      1.000 0.000  1 0.000
#> GSM23199     2  0.0000      1.000 0.000  1 0.000
#> GSM23200     2  0.0000      1.000 0.000  1 0.000
#> GSM23201     2  0.0000      1.000 0.000  1 0.000
#> GSM23202     2  0.0000      1.000 0.000  1 0.000
#> GSM23203     2  0.0000      1.000 0.000  1 0.000
#> GSM23204     2  0.0000      1.000 0.000  1 0.000
#> GSM23205     2  0.0000      1.000 0.000  1 0.000
#> GSM23206     2  0.0000      1.000 0.000  1 0.000
#> GSM23207     2  0.0000      1.000 0.000  1 0.000
#> GSM23208     2  0.0000      1.000 0.000  1 0.000
#> GSM23209     2  0.0000      1.000 0.000  1 0.000
#> GSM23210     2  0.0000      1.000 0.000  1 0.000
#> GSM23211     2  0.0000      1.000 0.000  1 0.000
#> GSM23212     2  0.0000      1.000 0.000  1 0.000
#> GSM23213     2  0.0000      1.000 0.000  1 0.000
#> GSM23214     2  0.0000      1.000 0.000  1 0.000
#> GSM23215     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
#> GSM23185     3  0.0188      0.929 0.000 0.000 0.996 0.004
#> GSM23186     1  0.3168      0.867 0.884 0.000 0.060 0.056
#> GSM23187     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23191     3  0.5877      0.672 0.068 0.000 0.656 0.276
#> GSM23192     3  0.6075      0.696 0.128 0.000 0.680 0.192
#> GSM23193     3  0.4524      0.794 0.028 0.000 0.768 0.204
#> GSM23194     3  0.0592      0.927 0.000 0.000 0.984 0.016
#> GSM23195     3  0.3245      0.876 0.056 0.000 0.880 0.064
#> GSM23159     1  0.1118      0.937 0.964 0.000 0.000 0.036
#> GSM23160     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1716      0.928 0.936 0.000 0.000 0.064
#> GSM23162     3  0.1389      0.914 0.000 0.000 0.952 0.048
#> GSM23163     1  0.1389      0.933 0.952 0.000 0.000 0.048
#> GSM23164     1  0.2281      0.910 0.904 0.000 0.000 0.096
#> GSM23165     1  0.0817      0.931 0.976 0.000 0.000 0.024
#> GSM23166     1  0.2216      0.913 0.908 0.000 0.000 0.092
#> GSM23167     1  0.0817      0.933 0.976 0.000 0.000 0.024
#> GSM23168     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23169     3  0.1004      0.924 0.004 0.000 0.972 0.024
#> GSM23170     1  0.0469      0.937 0.988 0.000 0.000 0.012
#> GSM23171     1  0.0188      0.936 0.996 0.000 0.000 0.004
#> GSM23172     1  0.0592      0.933 0.984 0.000 0.000 0.016
#> GSM23173     3  0.0592      0.927 0.000 0.000 0.984 0.016
#> GSM23174     1  0.1302      0.934 0.956 0.000 0.000 0.044
#> GSM23175     1  0.0592      0.938 0.984 0.000 0.000 0.016
#> GSM23176     1  0.0592      0.933 0.984 0.000 0.000 0.016
#> GSM23177     1  0.0469      0.937 0.988 0.000 0.000 0.012
#> GSM23178     1  0.1389      0.931 0.952 0.000 0.000 0.048
#> GSM23179     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23180     1  0.4898      0.514 0.584 0.000 0.000 0.416
#> GSM23181     1  0.3444      0.842 0.816 0.000 0.000 0.184
#> GSM23182     4  0.4843     -0.147 0.396 0.000 0.000 0.604
#> GSM23183     3  0.4727      0.804 0.108 0.000 0.792 0.100
#> GSM23184     3  0.0000      0.930 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23199     2  0.2760      0.805 0.000 0.872 0.000 0.128
#> GSM23200     2  0.0469      0.939 0.000 0.988 0.000 0.012
#> GSM23201     4  0.4277      0.804 0.000 0.280 0.000 0.720
#> GSM23202     4  0.4222      0.812 0.000 0.272 0.000 0.728
#> GSM23203     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23205     4  0.4830      0.632 0.000 0.392 0.000 0.608
#> GSM23206     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23207     2  0.4382      0.435 0.000 0.704 0.000 0.296
#> GSM23208     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23210     2  0.1867      0.881 0.000 0.928 0.000 0.072
#> GSM23211     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM23212     4  0.4222      0.812 0.000 0.272 0.000 0.728
#> GSM23213     4  0.4222      0.812 0.000 0.272 0.000 0.728
#> GSM23214     4  0.4193      0.810 0.000 0.268 0.000 0.732
#> GSM23215     2  0.0336      0.942 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.1331     0.8650 0.000 0.000 0.952 0.008 0.040
#> GSM23186     1  0.6096     0.4414 0.624 0.000 0.080 0.044 0.252
#> GSM23187     3  0.0290     0.8695 0.000 0.000 0.992 0.000 0.008
#> GSM23188     3  0.0609     0.8687 0.000 0.000 0.980 0.000 0.020
#> GSM23189     3  0.0771     0.8683 0.000 0.000 0.976 0.004 0.020
#> GSM23190     3  0.1043     0.8681 0.000 0.000 0.960 0.000 0.040
#> GSM23191     5  0.5085     0.4458 0.036 0.000 0.232 0.032 0.700
#> GSM23192     5  0.5465     0.3800 0.056 0.000 0.280 0.020 0.644
#> GSM23193     5  0.5037     0.2499 0.024 0.000 0.352 0.012 0.612
#> GSM23194     3  0.2660     0.8204 0.000 0.000 0.864 0.008 0.128
#> GSM23195     3  0.6690     0.1435 0.116 0.000 0.492 0.032 0.360
#> GSM23159     1  0.2984     0.8412 0.860 0.000 0.000 0.032 0.108
#> GSM23160     3  0.1281     0.8681 0.000 0.000 0.956 0.012 0.032
#> GSM23161     1  0.3280     0.7932 0.812 0.000 0.000 0.012 0.176
#> GSM23162     3  0.3861     0.6427 0.000 0.000 0.728 0.008 0.264
#> GSM23163     1  0.3441     0.8206 0.824 0.000 0.004 0.024 0.148
#> GSM23164     1  0.2852     0.7873 0.828 0.000 0.000 0.000 0.172
#> GSM23165     1  0.2511     0.8216 0.892 0.000 0.000 0.028 0.080
#> GSM23166     1  0.3366     0.7412 0.784 0.000 0.000 0.004 0.212
#> GSM23167     1  0.1800     0.8393 0.932 0.000 0.000 0.020 0.048
#> GSM23168     3  0.2079     0.8572 0.000 0.000 0.916 0.020 0.064
#> GSM23169     3  0.4065     0.7200 0.008 0.000 0.760 0.020 0.212
#> GSM23170     1  0.1740     0.8549 0.932 0.000 0.000 0.012 0.056
#> GSM23171     1  0.1485     0.8569 0.948 0.000 0.000 0.020 0.032
#> GSM23172     1  0.1800     0.8414 0.932 0.000 0.000 0.020 0.048
#> GSM23173     3  0.3414     0.8022 0.020 0.000 0.844 0.020 0.116
#> GSM23174     1  0.2077     0.8481 0.908 0.000 0.000 0.008 0.084
#> GSM23175     1  0.2331     0.8492 0.900 0.000 0.000 0.020 0.080
#> GSM23176     1  0.1914     0.8357 0.924 0.000 0.000 0.016 0.060
#> GSM23177     1  0.2068     0.8485 0.904 0.000 0.000 0.004 0.092
#> GSM23178     1  0.2970     0.8128 0.828 0.000 0.000 0.004 0.168
#> GSM23179     3  0.0865     0.8695 0.000 0.000 0.972 0.004 0.024
#> GSM23180     5  0.5461     0.3623 0.284 0.000 0.000 0.096 0.620
#> GSM23181     5  0.4980    -0.1578 0.484 0.000 0.000 0.028 0.488
#> GSM23182     5  0.6504     0.3339 0.288 0.000 0.000 0.228 0.484
#> GSM23183     5  0.6751    -0.0556 0.116 0.000 0.412 0.032 0.440
#> GSM23184     3  0.1205     0.8673 0.000 0.000 0.956 0.004 0.040
#> GSM23196     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.3074     0.7368 0.000 0.804 0.000 0.196 0.000
#> GSM23200     2  0.1478     0.8793 0.000 0.936 0.000 0.064 0.000
#> GSM23201     4  0.2536     0.9038 0.000 0.128 0.000 0.868 0.004
#> GSM23202     4  0.1732     0.9290 0.000 0.080 0.000 0.920 0.000
#> GSM23203     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.3814     0.7176 0.000 0.276 0.000 0.720 0.004
#> GSM23206     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4420     0.0758 0.000 0.548 0.000 0.448 0.004
#> GSM23208     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.2891     0.7583 0.000 0.824 0.000 0.176 0.000
#> GSM23211     2  0.0000     0.9178 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.1952     0.9325 0.000 0.084 0.000 0.912 0.004
#> GSM23213     4  0.1952     0.9325 0.000 0.084 0.000 0.912 0.004
#> GSM23214     4  0.1952     0.9325 0.000 0.084 0.000 0.912 0.004
#> GSM23215     2  0.1197     0.8912 0.000 0.952 0.000 0.048 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
#> GSM23185     3  0.1686     0.8169 0.000 0.000 0.924 0.000 0.012 0.064
#> GSM23186     6  0.6876     0.0939 0.400 0.000 0.092 0.020 0.080 0.408
#> GSM23187     3  0.1226     0.8206 0.000 0.000 0.952 0.004 0.004 0.040
#> GSM23188     3  0.1556     0.8122 0.000 0.000 0.920 0.000 0.000 0.080
#> GSM23189     3  0.1327     0.8174 0.000 0.000 0.936 0.000 0.000 0.064
#> GSM23190     3  0.2039     0.8142 0.000 0.000 0.908 0.004 0.016 0.072
#> GSM23191     5  0.5718     0.1643 0.024 0.000 0.128 0.012 0.628 0.208
#> GSM23192     6  0.6427     0.1516 0.040 0.000 0.116 0.012 0.352 0.480
#> GSM23193     5  0.5988     0.0835 0.012 0.000 0.256 0.012 0.560 0.160
#> GSM23194     3  0.4145     0.6609 0.000 0.000 0.724 0.004 0.052 0.220
#> GSM23195     6  0.5478     0.4908 0.100 0.000 0.204 0.000 0.048 0.648
#> GSM23159     1  0.4330     0.7235 0.748 0.000 0.000 0.012 0.140 0.100
#> GSM23160     3  0.2203     0.8064 0.000 0.000 0.896 0.004 0.016 0.084
#> GSM23161     1  0.4588     0.6897 0.700 0.000 0.000 0.024 0.228 0.048
#> GSM23162     3  0.5594     0.4674 0.000 0.000 0.592 0.012 0.220 0.176
#> GSM23163     1  0.5441     0.6168 0.652 0.000 0.004 0.028 0.120 0.196
#> GSM23164     1  0.4416     0.6348 0.668 0.000 0.000 0.012 0.288 0.032
#> GSM23165     1  0.3260     0.6893 0.824 0.000 0.000 0.012 0.028 0.136
#> GSM23166     1  0.4753     0.6137 0.648 0.000 0.000 0.016 0.288 0.048
#> GSM23167     1  0.2545     0.7468 0.888 0.000 0.000 0.020 0.024 0.068
#> GSM23168     3  0.2979     0.7952 0.000 0.000 0.852 0.004 0.056 0.088
#> GSM23169     3  0.5118     0.5765 0.008 0.000 0.644 0.016 0.064 0.268
#> GSM23170     1  0.2826     0.7686 0.856 0.000 0.000 0.008 0.112 0.024
#> GSM23171     1  0.3558     0.7664 0.812 0.000 0.000 0.008 0.108 0.072
#> GSM23172     1  0.2925     0.7366 0.860 0.000 0.000 0.008 0.052 0.080
#> GSM23173     3  0.4813     0.6211 0.028 0.000 0.684 0.008 0.036 0.244
#> GSM23174     1  0.3590     0.7330 0.776 0.000 0.000 0.004 0.188 0.032
#> GSM23175     1  0.3555     0.7348 0.780 0.000 0.000 0.000 0.176 0.044
#> GSM23176     1  0.3500     0.7175 0.820 0.000 0.000 0.012 0.064 0.104
#> GSM23177     1  0.3503     0.7548 0.808 0.000 0.000 0.016 0.144 0.032
#> GSM23178     1  0.4274     0.7149 0.748 0.000 0.000 0.016 0.168 0.068
#> GSM23179     3  0.2760     0.7984 0.000 0.000 0.856 0.004 0.024 0.116
#> GSM23180     5  0.4620     0.4637 0.220 0.000 0.000 0.032 0.704 0.044
#> GSM23181     5  0.4735     0.0871 0.384 0.000 0.000 0.004 0.568 0.044
#> GSM23182     5  0.5268     0.4355 0.240 0.000 0.000 0.104 0.636 0.020
#> GSM23183     6  0.5517     0.5019 0.068 0.000 0.204 0.004 0.068 0.656
#> GSM23184     3  0.1950     0.8162 0.000 0.000 0.912 0.000 0.024 0.064
#> GSM23196     2  0.0000     0.9235 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0146     0.9234 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23198     2  0.0000     0.9235 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.3716     0.5947 0.000 0.732 0.000 0.248 0.012 0.008
#> GSM23200     2  0.2695     0.7866 0.000 0.844 0.000 0.144 0.004 0.008
#> GSM23201     4  0.3465     0.7669 0.000 0.156 0.000 0.804 0.024 0.016
#> GSM23202     4  0.1728     0.8009 0.000 0.064 0.000 0.924 0.004 0.008
#> GSM23203     2  0.0000     0.9235 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0405     0.9215 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM23205     4  0.4710     0.5574 0.000 0.336 0.000 0.616 0.024 0.024
#> GSM23206     2  0.0405     0.9221 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM23207     4  0.4227     0.1285 0.000 0.488 0.000 0.500 0.008 0.004
#> GSM23208     2  0.0146     0.9234 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23209     2  0.0405     0.9215 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM23210     2  0.3450     0.6722 0.000 0.772 0.000 0.208 0.008 0.012
#> GSM23211     2  0.0000     0.9235 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.1942     0.8010 0.000 0.064 0.000 0.916 0.012 0.008
#> GSM23213     4  0.1728     0.8026 0.000 0.064 0.000 0.924 0.008 0.004
#> GSM23214     4  0.1615     0.8024 0.000 0.064 0.000 0.928 0.004 0.004
#> GSM23215     2  0.2068     0.8763 0.000 0.916 0.000 0.048 0.020 0.016

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 cell.type(p) disease.state(p) k
#> CV:skmeans 57     3.90e-13         0.052490 2
#> CV:skmeans 57     4.19e-13         0.000423 3
#> CV:skmeans 55     6.87e-12         0.000323 4
#> CV:skmeans 47     3.48e-10         0.000331 5
#> CV:skmeans 47     1.52e-09         0.000208 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 11993 rows and 57 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.639           0.835       0.932         0.4977 0.492   0.492
#> 3 3 0.882           0.893       0.957         0.3535 0.719   0.487
#> 4 4 0.874           0.870       0.935         0.0882 0.934   0.798
#> 5 5 0.820           0.781       0.884         0.0712 0.955   0.834
#> 6 6 0.806           0.748       0.857         0.0317 0.972   0.880

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
#> GSM23185     2  0.7674      0.711 0.224 0.776
#> GSM23186     1  0.0000      0.948 1.000 0.000
#> GSM23187     2  0.8207      0.665 0.256 0.744
#> GSM23188     2  0.5842      0.797 0.140 0.860
#> GSM23189     2  0.6623      0.769 0.172 0.828
#> GSM23190     2  0.7219      0.740 0.200 0.800
#> GSM23191     1  0.0000      0.948 1.000 0.000
#> GSM23192     1  0.0000      0.948 1.000 0.000
#> GSM23193     1  0.0000      0.948 1.000 0.000
#> GSM23194     2  0.9983      0.142 0.476 0.524
#> GSM23195     2  0.9988      0.128 0.480 0.520
#> GSM23159     1  0.0000      0.948 1.000 0.000
#> GSM23160     1  0.8443      0.597 0.728 0.272
#> GSM23161     1  0.0000      0.948 1.000 0.000
#> GSM23162     1  0.0000      0.948 1.000 0.000
#> GSM23163     1  0.0000      0.948 1.000 0.000
#> GSM23164     1  0.0000      0.948 1.000 0.000
#> GSM23165     1  0.0000      0.948 1.000 0.000
#> GSM23166     1  0.0000      0.948 1.000 0.000
#> GSM23167     1  0.0000      0.948 1.000 0.000
#> GSM23168     1  0.6801      0.751 0.820 0.180
#> GSM23169     1  0.0000      0.948 1.000 0.000
#> GSM23170     1  0.0000      0.948 1.000 0.000
#> GSM23171     1  0.0000      0.948 1.000 0.000
#> GSM23172     1  0.0000      0.948 1.000 0.000
#> GSM23173     1  0.5737      0.809 0.864 0.136
#> GSM23174     1  0.0000      0.948 1.000 0.000
#> GSM23175     1  0.0000      0.948 1.000 0.000
#> GSM23176     1  0.0000      0.948 1.000 0.000
#> GSM23177     1  0.0000      0.948 1.000 0.000
#> GSM23178     1  0.0000      0.948 1.000 0.000
#> GSM23179     1  0.9522      0.360 0.628 0.372
#> GSM23180     1  0.0000      0.948 1.000 0.000
#> GSM23181     1  0.0000      0.948 1.000 0.000
#> GSM23182     1  0.0000      0.948 1.000 0.000
#> GSM23183     1  0.0000      0.948 1.000 0.000
#> GSM23184     1  0.8955      0.512 0.688 0.312
#> GSM23196     2  0.0000      0.888 0.000 1.000
#> GSM23197     2  0.0000      0.888 0.000 1.000
#> GSM23198     2  0.0000      0.888 0.000 1.000
#> GSM23199     2  0.0000      0.888 0.000 1.000
#> GSM23200     2  0.0000      0.888 0.000 1.000
#> GSM23201     2  0.0000      0.888 0.000 1.000
#> GSM23202     2  0.9850      0.281 0.428 0.572
#> GSM23203     2  0.0000      0.888 0.000 1.000
#> GSM23204     2  0.0000      0.888 0.000 1.000
#> GSM23205     2  0.0000      0.888 0.000 1.000
#> GSM23206     2  0.0000      0.888 0.000 1.000
#> GSM23207     2  0.0000      0.888 0.000 1.000
#> GSM23208     2  0.0000      0.888 0.000 1.000
#> GSM23209     2  0.0000      0.888 0.000 1.000
#> GSM23210     2  0.0000      0.888 0.000 1.000
#> GSM23211     2  0.0000      0.888 0.000 1.000
#> GSM23212     2  0.0000      0.888 0.000 1.000
#> GSM23213     2  0.0672      0.884 0.008 0.992
#> GSM23214     2  0.7950      0.662 0.240 0.760
#> GSM23215     2  0.0000      0.888 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
#> GSM23185     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23186     1  0.4974     0.6615 0.764 0.000 0.236
#> GSM23187     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23188     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23189     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23190     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23191     1  0.5016     0.6181 0.760 0.000 0.240
#> GSM23192     3  0.6225     0.2252 0.432 0.000 0.568
#> GSM23193     3  0.3752     0.8185 0.144 0.000 0.856
#> GSM23194     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23195     3  0.4654     0.7485 0.208 0.000 0.792
#> GSM23159     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23160     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23161     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23162     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23163     1  0.1411     0.9114 0.964 0.000 0.036
#> GSM23164     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23165     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23166     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23167     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23168     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23169     3  0.0747     0.9132 0.016 0.000 0.984
#> GSM23170     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23171     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23172     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23173     3  0.2711     0.8673 0.088 0.000 0.912
#> GSM23174     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23175     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23176     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23177     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23178     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23179     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23180     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23181     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23182     1  0.0000     0.9426 1.000 0.000 0.000
#> GSM23183     3  0.5678     0.5870 0.316 0.000 0.684
#> GSM23184     3  0.0000     0.9204 0.000 0.000 1.000
#> GSM23196     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23197     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23198     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23199     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23200     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23201     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23202     1  0.6305     0.0336 0.516 0.484 0.000
#> GSM23203     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23204     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23205     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23206     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23207     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23208     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23209     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23210     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23211     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23212     2  0.0000     0.9847 0.000 1.000 0.000
#> GSM23213     2  0.0237     0.9809 0.004 0.996 0.000
#> GSM23214     2  0.5098     0.6534 0.248 0.752 0.000
#> GSM23215     2  0.0000     0.9847 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
#> GSM23185     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23186     1  0.5077      0.724 0.760 0.000 0.160 0.080
#> GSM23187     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23191     1  0.7088      0.403 0.568 0.000 0.204 0.228
#> GSM23192     3  0.6646      0.078 0.428 0.000 0.488 0.084
#> GSM23193     3  0.4224      0.791 0.100 0.000 0.824 0.076
#> GSM23194     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23195     3  0.4798      0.726 0.180 0.000 0.768 0.052
#> GSM23159     1  0.0469      0.942 0.988 0.000 0.000 0.012
#> GSM23160     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23161     1  0.2011      0.905 0.920 0.000 0.000 0.080
#> GSM23162     3  0.0188      0.898 0.000 0.000 0.996 0.004
#> GSM23163     1  0.2813      0.887 0.896 0.000 0.024 0.080
#> GSM23164     1  0.0592      0.943 0.984 0.000 0.000 0.016
#> GSM23165     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23166     1  0.1637      0.920 0.940 0.000 0.000 0.060
#> GSM23167     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23168     3  0.0188      0.898 0.000 0.000 0.996 0.004
#> GSM23169     3  0.1767      0.876 0.012 0.000 0.944 0.044
#> GSM23170     1  0.0469      0.943 0.988 0.000 0.000 0.012
#> GSM23171     1  0.0000      0.944 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.944 1.000 0.000 0.000 0.000
#> GSM23173     3  0.2480      0.841 0.088 0.000 0.904 0.008
#> GSM23174     1  0.0000      0.944 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23176     1  0.0707      0.940 0.980 0.000 0.000 0.020
#> GSM23177     1  0.0336      0.944 0.992 0.000 0.000 0.008
#> GSM23178     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23179     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23180     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23181     1  0.0188      0.944 0.996 0.000 0.000 0.004
#> GSM23182     4  0.4643      0.455 0.344 0.000 0.000 0.656
#> GSM23183     3  0.5417      0.602 0.284 0.000 0.676 0.040
#> GSM23184     3  0.0000      0.900 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23199     2  0.1389      0.919 0.000 0.952 0.000 0.048
#> GSM23200     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23201     4  0.2081      0.909 0.000 0.084 0.000 0.916
#> GSM23202     4  0.2081      0.909 0.000 0.084 0.000 0.916
#> GSM23203     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23205     2  0.4164      0.602 0.000 0.736 0.000 0.264
#> GSM23206     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23207     2  0.3688      0.726 0.000 0.792 0.000 0.208
#> GSM23208     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM23212     4  0.2081      0.909 0.000 0.084 0.000 0.916
#> GSM23213     4  0.2011      0.908 0.000 0.080 0.000 0.920
#> GSM23214     4  0.2011      0.908 0.000 0.080 0.000 0.920
#> GSM23215     2  0.0000      0.959 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
#> GSM23185     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23186     1  0.4780      0.631 0.692 0.000 0.060 0.000 0.248
#> GSM23187     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23188     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23189     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23190     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23191     5  0.4261      0.694 0.096 0.000 0.076 0.024 0.804
#> GSM23192     5  0.1117      0.672 0.020 0.000 0.016 0.000 0.964
#> GSM23193     5  0.3132      0.663 0.008 0.000 0.172 0.000 0.820
#> GSM23194     3  0.0162      0.882 0.000 0.000 0.996 0.000 0.004
#> GSM23195     3  0.6438      0.177 0.220 0.000 0.500 0.000 0.280
#> GSM23159     1  0.0880      0.825 0.968 0.000 0.000 0.000 0.032
#> GSM23160     3  0.0000      0.881 0.000 0.000 1.000 0.000 0.000
#> GSM23161     1  0.3796      0.638 0.700 0.000 0.000 0.000 0.300
#> GSM23162     3  0.3534      0.588 0.000 0.000 0.744 0.000 0.256
#> GSM23163     1  0.3661      0.678 0.724 0.000 0.000 0.000 0.276
#> GSM23164     1  0.2605      0.783 0.852 0.000 0.000 0.000 0.148
#> GSM23165     1  0.0880      0.821 0.968 0.000 0.000 0.000 0.032
#> GSM23166     1  0.3534      0.695 0.744 0.000 0.000 0.000 0.256
#> GSM23167     1  0.0609      0.827 0.980 0.000 0.000 0.000 0.020
#> GSM23168     3  0.0290      0.879 0.000 0.000 0.992 0.000 0.008
#> GSM23169     3  0.3282      0.693 0.008 0.000 0.804 0.000 0.188
#> GSM23170     1  0.0794      0.827 0.972 0.000 0.000 0.000 0.028
#> GSM23171     1  0.0162      0.826 0.996 0.000 0.000 0.000 0.004
#> GSM23172     1  0.0510      0.823 0.984 0.000 0.000 0.000 0.016
#> GSM23173     3  0.5446      0.503 0.164 0.000 0.660 0.000 0.176
#> GSM23174     1  0.0404      0.826 0.988 0.000 0.000 0.000 0.012
#> GSM23175     1  0.0290      0.825 0.992 0.000 0.000 0.000 0.008
#> GSM23176     1  0.2471      0.792 0.864 0.000 0.000 0.000 0.136
#> GSM23177     1  0.1544      0.819 0.932 0.000 0.000 0.000 0.068
#> GSM23178     1  0.0609      0.823 0.980 0.000 0.000 0.000 0.020
#> GSM23179     3  0.0290      0.879 0.000 0.000 0.992 0.000 0.008
#> GSM23180     1  0.4297     -0.019 0.528 0.000 0.000 0.000 0.472
#> GSM23181     1  0.4287      0.038 0.540 0.000 0.000 0.000 0.460
#> GSM23182     5  0.6651      0.376 0.248 0.000 0.000 0.312 0.440
#> GSM23183     5  0.6060      0.491 0.208 0.000 0.216 0.000 0.576
#> GSM23184     3  0.0162      0.880 0.000 0.000 0.996 0.000 0.004
#> GSM23196     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.1908      0.872 0.000 0.908 0.000 0.092 0.000
#> GSM23200     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM23202     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.3508      0.656 0.000 0.748 0.000 0.252 0.000
#> GSM23206     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4045      0.472 0.000 0.644 0.000 0.356 0.000
#> GSM23208     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000      0.947 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM23213     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.947 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
#> GSM23185     3  0.0146      0.924 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23186     1  0.5799      0.402 0.460 0.000 0.016 0.000 0.116 0.408
#> GSM23187     3  0.0146      0.924 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23188     3  0.0146      0.924 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23189     3  0.0146      0.924 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23190     3  0.0146      0.924 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23191     5  0.0291      0.459 0.004 0.000 0.000 0.004 0.992 0.000
#> GSM23192     5  0.3634      0.110 0.000 0.000 0.000 0.000 0.644 0.356
#> GSM23193     5  0.0508      0.456 0.000 0.000 0.004 0.000 0.984 0.012
#> GSM23194     3  0.1267      0.918 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM23195     6  0.5781      0.530 0.180 0.000 0.120 0.000 0.068 0.632
#> GSM23159     1  0.1434      0.775 0.940 0.000 0.000 0.000 0.012 0.048
#> GSM23160     3  0.1814      0.906 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM23161     1  0.4638      0.664 0.692 0.000 0.000 0.000 0.152 0.156
#> GSM23162     5  0.4988     -0.135 0.000 0.000 0.448 0.000 0.484 0.068
#> GSM23163     1  0.5156      0.641 0.600 0.000 0.000 0.000 0.128 0.272
#> GSM23164     1  0.3156      0.752 0.800 0.000 0.000 0.000 0.020 0.180
#> GSM23165     1  0.2996      0.732 0.772 0.000 0.000 0.000 0.000 0.228
#> GSM23166     1  0.4030      0.706 0.756 0.000 0.000 0.000 0.104 0.140
#> GSM23167     1  0.2300      0.765 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM23168     3  0.2431      0.888 0.000 0.000 0.860 0.000 0.008 0.132
#> GSM23169     3  0.4064      0.732 0.008 0.000 0.768 0.000 0.132 0.092
#> GSM23170     1  0.1814      0.776 0.900 0.000 0.000 0.000 0.000 0.100
#> GSM23171     1  0.0363      0.770 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM23172     1  0.1910      0.755 0.892 0.000 0.000 0.000 0.000 0.108
#> GSM23173     6  0.4749      0.400 0.092 0.000 0.260 0.000 0.000 0.648
#> GSM23174     1  0.0405      0.769 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM23175     1  0.0858      0.771 0.968 0.000 0.000 0.000 0.004 0.028
#> GSM23176     1  0.3876      0.720 0.700 0.000 0.000 0.000 0.024 0.276
#> GSM23177     1  0.3217      0.751 0.768 0.000 0.000 0.000 0.008 0.224
#> GSM23178     1  0.1625      0.772 0.928 0.000 0.000 0.000 0.012 0.060
#> GSM23179     3  0.2178      0.894 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM23180     1  0.3979      0.273 0.540 0.000 0.000 0.000 0.456 0.004
#> GSM23181     1  0.3833      0.313 0.556 0.000 0.000 0.000 0.444 0.000
#> GSM23182     5  0.5774      0.148 0.176 0.000 0.000 0.384 0.440 0.000
#> GSM23183     6  0.5717      0.289 0.156 0.000 0.016 0.000 0.256 0.572
#> GSM23184     3  0.1714      0.910 0.000 0.000 0.908 0.000 0.000 0.092
#> GSM23196     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.1501      0.886 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23200     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23202     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     2  0.3198      0.642 0.000 0.740 0.000 0.260 0.000 0.000
#> GSM23206     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.3547      0.525 0.000 0.668 0.000 0.332 0.000 0.000
#> GSM23208     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23211     2  0.0000      0.948 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000      0.948 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-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 cell.type(p) disease.state(p) k
#> CV:pam 53     1.24e-08         7.65e-01 2
#> CV:pam 55     1.14e-12         5.33e-03 3
#> CV:pam 54     1.12e-11         8.76e-04 4
#> CV:pam 51     2.23e-10         8.84e-05 5
#> CV:pam 47     1.52e-09         7.90e-05 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 11993 rows and 57 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           1.000       1.000         0.4642 0.536   0.536
#> 3 3 0.725           0.947       0.892         0.4139 0.787   0.603
#> 4 4 0.797           0.798       0.894         0.1105 0.855   0.603
#> 5 5 0.820           0.769       0.865         0.0859 0.945   0.800
#> 6 6 0.871           0.801       0.884         0.0525 0.921   0.671

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM23185     1       0          1  1  0
#> GSM23186     1       0          1  1  0
#> GSM23187     1       0          1  1  0
#> GSM23188     1       0          1  1  0
#> GSM23189     1       0          1  1  0
#> GSM23190     1       0          1  1  0
#> GSM23191     1       0          1  1  0
#> GSM23192     1       0          1  1  0
#> GSM23193     1       0          1  1  0
#> GSM23194     1       0          1  1  0
#> GSM23195     1       0          1  1  0
#> GSM23159     1       0          1  1  0
#> GSM23160     1       0          1  1  0
#> GSM23161     1       0          1  1  0
#> GSM23162     1       0          1  1  0
#> GSM23163     1       0          1  1  0
#> GSM23164     1       0          1  1  0
#> GSM23165     1       0          1  1  0
#> GSM23166     1       0          1  1  0
#> GSM23167     1       0          1  1  0
#> GSM23168     1       0          1  1  0
#> GSM23169     1       0          1  1  0
#> GSM23170     1       0          1  1  0
#> GSM23171     1       0          1  1  0
#> GSM23172     1       0          1  1  0
#> GSM23173     1       0          1  1  0
#> GSM23174     1       0          1  1  0
#> GSM23175     1       0          1  1  0
#> GSM23176     1       0          1  1  0
#> GSM23177     1       0          1  1  0
#> GSM23178     1       0          1  1  0
#> GSM23179     1       0          1  1  0
#> GSM23180     1       0          1  1  0
#> GSM23181     1       0          1  1  0
#> GSM23182     1       0          1  1  0
#> GSM23183     1       0          1  1  0
#> GSM23184     1       0          1  1  0
#> GSM23196     2       0          1  0  1
#> GSM23197     2       0          1  0  1
#> GSM23198     2       0          1  0  1
#> GSM23199     2       0          1  0  1
#> GSM23200     2       0          1  0  1
#> GSM23201     2       0          1  0  1
#> GSM23202     2       0          1  0  1
#> GSM23203     2       0          1  0  1
#> GSM23204     2       0          1  0  1
#> GSM23205     2       0          1  0  1
#> GSM23206     2       0          1  0  1
#> GSM23207     2       0          1  0  1
#> GSM23208     2       0          1  0  1
#> GSM23209     2       0          1  0  1
#> GSM23210     2       0          1  0  1
#> GSM23211     2       0          1  0  1
#> GSM23212     2       0          1  0  1
#> GSM23213     2       0          1  0  1
#> GSM23214     2       0          1  0  1
#> GSM23215     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23186     1  0.4796      0.869 0.780 0.000 0.220
#> GSM23187     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23188     3  0.0237      0.956 0.004 0.000 0.996
#> GSM23189     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23191     3  0.1529      0.946 0.040 0.000 0.960
#> GSM23192     3  0.1529      0.946 0.040 0.000 0.960
#> GSM23193     3  0.0424      0.956 0.008 0.000 0.992
#> GSM23194     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23195     3  0.3816      0.844 0.148 0.000 0.852
#> GSM23159     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23160     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23161     1  0.3482      0.976 0.872 0.000 0.128
#> GSM23162     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23163     1  0.3482      0.976 0.872 0.000 0.128
#> GSM23164     1  0.3482      0.976 0.872 0.000 0.128
#> GSM23165     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23166     1  0.3482      0.976 0.872 0.000 0.128
#> GSM23167     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23168     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23169     3  0.1529      0.946 0.040 0.000 0.960
#> GSM23170     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23171     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23172     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23173     3  0.2878      0.906 0.096 0.000 0.904
#> GSM23174     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23175     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23176     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23177     1  0.3482      0.976 0.872 0.000 0.128
#> GSM23178     1  0.3412      0.977 0.876 0.000 0.124
#> GSM23179     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23180     3  0.2711      0.912 0.088 0.000 0.912
#> GSM23181     1  0.5621      0.729 0.692 0.000 0.308
#> GSM23182     3  0.2711      0.912 0.088 0.000 0.912
#> GSM23183     3  0.3752      0.849 0.144 0.000 0.856
#> GSM23184     3  0.0000      0.958 0.000 0.000 1.000
#> GSM23196     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23197     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23198     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23199     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23200     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23201     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23202     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23203     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23204     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23205     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23206     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23207     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23208     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23209     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23210     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23211     2  0.3412      0.950 0.124 0.876 0.000
#> GSM23212     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23213     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23214     2  0.0000      0.950 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.950 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
#> GSM23185     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23186     1  0.3081     0.8234 0.888 0.000 0.048 0.064
#> GSM23187     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0188     0.8654 0.000 0.000 0.996 0.004
#> GSM23189     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23191     3  0.6232     0.4546 0.332 0.000 0.596 0.072
#> GSM23192     3  0.4564     0.5175 0.328 0.000 0.672 0.000
#> GSM23193     3  0.4452     0.7499 0.156 0.000 0.796 0.048
#> GSM23194     3  0.0336     0.8650 0.008 0.000 0.992 0.000
#> GSM23195     1  0.6387     0.0421 0.492 0.000 0.444 0.064
#> GSM23159     1  0.0921     0.8678 0.972 0.000 0.000 0.028
#> GSM23160     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23161     1  0.0188     0.8702 0.996 0.000 0.000 0.004
#> GSM23162     3  0.3004     0.8243 0.060 0.000 0.892 0.048
#> GSM23163     1  0.1545     0.8625 0.952 0.000 0.008 0.040
#> GSM23164     1  0.0336     0.8686 0.992 0.000 0.000 0.008
#> GSM23165     1  0.1716     0.8547 0.936 0.000 0.000 0.064
#> GSM23166     1  0.0336     0.8698 0.992 0.000 0.000 0.008
#> GSM23167     1  0.1022     0.8668 0.968 0.000 0.000 0.032
#> GSM23168     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23169     3  0.4914     0.6779 0.208 0.000 0.748 0.044
#> GSM23170     1  0.0188     0.8693 0.996 0.000 0.000 0.004
#> GSM23171     1  0.0469     0.8699 0.988 0.000 0.000 0.012
#> GSM23172     1  0.0817     0.8685 0.976 0.000 0.000 0.024
#> GSM23173     3  0.6286     0.2781 0.384 0.000 0.552 0.064
#> GSM23174     1  0.0804     0.8665 0.980 0.000 0.008 0.012
#> GSM23175     1  0.0469     0.8673 0.988 0.000 0.000 0.012
#> GSM23176     1  0.1302     0.8635 0.956 0.000 0.000 0.044
#> GSM23177     1  0.0592     0.8683 0.984 0.000 0.000 0.016
#> GSM23178     1  0.0188     0.8693 0.996 0.000 0.000 0.004
#> GSM23179     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23180     1  0.6600     0.0976 0.520 0.000 0.396 0.084
#> GSM23181     1  0.1767     0.8459 0.944 0.000 0.044 0.012
#> GSM23182     1  0.6600     0.0976 0.520 0.000 0.396 0.084
#> GSM23183     1  0.6286     0.2497 0.552 0.000 0.384 0.064
#> GSM23184     3  0.0000     0.8668 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23199     4  0.4585     0.7632 0.000 0.332 0.000 0.668
#> GSM23200     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23201     4  0.1940     0.8526 0.000 0.076 0.000 0.924
#> GSM23202     4  0.1940     0.8526 0.000 0.076 0.000 0.924
#> GSM23203     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23205     4  0.2814     0.8553 0.000 0.132 0.000 0.868
#> GSM23206     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23207     4  0.4643     0.7468 0.000 0.344 0.000 0.656
#> GSM23208     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23210     4  0.4564     0.7674 0.000 0.328 0.000 0.672
#> GSM23211     2  0.0000     1.0000 0.000 1.000 0.000 0.000
#> GSM23212     4  0.2704     0.8559 0.000 0.124 0.000 0.876
#> GSM23213     4  0.1940     0.8526 0.000 0.076 0.000 0.924
#> GSM23214     4  0.1940     0.8526 0.000 0.076 0.000 0.924
#> GSM23215     4  0.4564     0.7674 0.000 0.328 0.000 0.672

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0162      0.837 0.000 0.000 0.996 0.000 0.004
#> GSM23186     1  0.4264      0.691 0.620 0.000 0.004 0.000 0.376
#> GSM23187     3  0.0162      0.837 0.000 0.000 0.996 0.000 0.004
#> GSM23188     3  0.0162      0.837 0.000 0.000 0.996 0.000 0.004
#> GSM23189     3  0.0162      0.837 0.000 0.000 0.996 0.000 0.004
#> GSM23190     3  0.0162      0.837 0.000 0.000 0.996 0.000 0.004
#> GSM23191     5  0.5039      0.885 0.008 0.000 0.360 0.028 0.604
#> GSM23192     3  0.4746     -0.554 0.016 0.000 0.504 0.000 0.480
#> GSM23193     3  0.4225     -0.092 0.004 0.000 0.632 0.000 0.364
#> GSM23194     3  0.0000      0.835 0.000 0.000 1.000 0.000 0.000
#> GSM23195     1  0.4370      0.638 0.744 0.000 0.056 0.000 0.200
#> GSM23159     1  0.0404      0.773 0.988 0.000 0.000 0.000 0.012
#> GSM23160     3  0.0963      0.808 0.000 0.000 0.964 0.000 0.036
#> GSM23161     1  0.0609      0.765 0.980 0.000 0.000 0.000 0.020
#> GSM23162     3  0.3551      0.483 0.008 0.000 0.772 0.000 0.220
#> GSM23163     1  0.0162      0.772 0.996 0.000 0.000 0.000 0.004
#> GSM23164     1  0.3305      0.600 0.776 0.000 0.000 0.000 0.224
#> GSM23165     1  0.4060      0.702 0.640 0.000 0.000 0.000 0.360
#> GSM23166     1  0.3480      0.568 0.752 0.000 0.000 0.000 0.248
#> GSM23167     1  0.3752      0.728 0.708 0.000 0.000 0.000 0.292
#> GSM23168     3  0.0000      0.835 0.000 0.000 1.000 0.000 0.000
#> GSM23169     3  0.3438      0.605 0.020 0.000 0.808 0.000 0.172
#> GSM23170     1  0.3366      0.748 0.768 0.000 0.000 0.000 0.232
#> GSM23171     1  0.2280      0.772 0.880 0.000 0.000 0.000 0.120
#> GSM23172     1  0.3730      0.729 0.712 0.000 0.000 0.000 0.288
#> GSM23173     1  0.6537     -0.103 0.404 0.000 0.400 0.000 0.196
#> GSM23174     1  0.2929      0.765 0.820 0.000 0.000 0.000 0.180
#> GSM23175     1  0.0290      0.772 0.992 0.000 0.000 0.000 0.008
#> GSM23176     1  0.3857      0.722 0.688 0.000 0.000 0.000 0.312
#> GSM23177     1  0.0000      0.771 1.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.0000      0.771 1.000 0.000 0.000 0.000 0.000
#> GSM23179     3  0.0290      0.833 0.000 0.000 0.992 0.000 0.008
#> GSM23180     5  0.5653      0.947 0.028 0.000 0.312 0.048 0.612
#> GSM23181     1  0.4448      0.071 0.516 0.000 0.004 0.000 0.480
#> GSM23182     5  0.5653      0.947 0.028 0.000 0.312 0.048 0.612
#> GSM23183     1  0.4303      0.643 0.752 0.000 0.056 0.000 0.192
#> GSM23184     3  0.0404      0.831 0.000 0.000 0.988 0.000 0.012
#> GSM23196     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.2020      0.933 0.000 0.100 0.000 0.900 0.000
#> GSM23200     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0000      0.939 0.000 0.000 0.000 1.000 0.000
#> GSM23202     4  0.0000      0.939 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.0794      0.945 0.000 0.028 0.000 0.972 0.000
#> GSM23206     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23207     4  0.2074      0.931 0.000 0.104 0.000 0.896 0.000
#> GSM23208     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23210     4  0.2074      0.931 0.000 0.104 0.000 0.896 0.000
#> GSM23211     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.1270      0.945 0.000 0.052 0.000 0.948 0.000
#> GSM23213     4  0.0000      0.939 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000      0.939 0.000 0.000 0.000 1.000 0.000
#> GSM23215     4  0.1908      0.937 0.000 0.092 0.000 0.908 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
#> GSM23185     3  0.0146    0.96460 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23186     6  0.3368    0.60858 0.232 0.000 0.000 0.000 0.012 0.756
#> GSM23187     3  0.0000    0.96538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000    0.96538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000    0.96538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000    0.96538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.0146    0.71193 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM23192     5  0.3905    0.60540 0.004 0.000 0.256 0.000 0.716 0.024
#> GSM23193     5  0.3841    0.66754 0.000 0.000 0.256 0.000 0.716 0.028
#> GSM23194     3  0.0891    0.94469 0.000 0.000 0.968 0.000 0.008 0.024
#> GSM23195     1  0.6550    0.08711 0.432 0.000 0.032 0.000 0.232 0.304
#> GSM23159     1  0.1910    0.73688 0.892 0.000 0.000 0.000 0.000 0.108
#> GSM23160     3  0.0260    0.96001 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM23161     1  0.1007    0.74388 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM23162     5  0.4210    0.55804 0.000 0.000 0.336 0.000 0.636 0.028
#> GSM23163     1  0.1714    0.74172 0.908 0.000 0.000 0.000 0.000 0.092
#> GSM23164     1  0.0713    0.72091 0.972 0.000 0.000 0.000 0.028 0.000
#> GSM23165     6  0.1075    0.75584 0.048 0.000 0.000 0.000 0.000 0.952
#> GSM23166     1  0.1528    0.71885 0.936 0.000 0.000 0.000 0.048 0.016
#> GSM23167     6  0.1814    0.77452 0.100 0.000 0.000 0.000 0.000 0.900
#> GSM23168     3  0.0508    0.95769 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM23169     3  0.3854    0.66387 0.004 0.000 0.760 0.000 0.188 0.048
#> GSM23170     1  0.3684    0.44914 0.628 0.000 0.000 0.000 0.000 0.372
#> GSM23171     1  0.3175    0.62550 0.744 0.000 0.000 0.000 0.000 0.256
#> GSM23172     6  0.1814    0.77452 0.100 0.000 0.000 0.000 0.000 0.900
#> GSM23173     6  0.7727    0.09075 0.240 0.000 0.240 0.000 0.244 0.276
#> GSM23174     1  0.2854    0.63323 0.792 0.000 0.000 0.000 0.000 0.208
#> GSM23175     1  0.1267    0.74198 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM23176     6  0.1765    0.77528 0.096 0.000 0.000 0.000 0.000 0.904
#> GSM23177     1  0.1387    0.74402 0.932 0.000 0.000 0.000 0.000 0.068
#> GSM23178     1  0.1556    0.74399 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM23179     3  0.0146    0.96460 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM23180     5  0.2147    0.71616 0.084 0.000 0.000 0.000 0.896 0.020
#> GSM23181     1  0.4238   -0.00715 0.540 0.000 0.000 0.000 0.444 0.016
#> GSM23182     5  0.2147    0.71616 0.084 0.000 0.000 0.000 0.896 0.020
#> GSM23183     1  0.6965    0.24533 0.480 0.000 0.124 0.000 0.228 0.168
#> GSM23184     3  0.0000    0.96538 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23196     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     4  0.1075    0.96122 0.000 0.048 0.000 0.952 0.000 0.000
#> GSM23200     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23202     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23206     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     4  0.1007    0.96310 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM23208     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     4  0.1075    0.96122 0.000 0.048 0.000 0.952 0.000 0.000
#> GSM23211     2  0.0000    1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000    0.97515 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     4  0.1075    0.96122 0.000 0.048 0.000 0.952 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 cell.type(p) disease.state(p) k
#> CV:mclust 57     3.90e-13         0.052490 2
#> CV:mclust 57     4.19e-13         0.000276 3
#> CV:mclust 51     4.89e-11         0.000385 4
#> CV:mclust 52     1.38e-10         0.002549 5
#> CV:mclust 52     5.39e-10         0.002514 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.927           0.961       0.982         0.4721 0.536   0.536
#> 3 3 0.976           0.948       0.976         0.4310 0.786   0.600
#> 4 4 0.860           0.833       0.931         0.1123 0.859   0.604
#> 5 5 0.780           0.733       0.852         0.0474 0.967   0.869
#> 6 6 0.744           0.635       0.793         0.0433 0.947   0.774

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
#> GSM23185     1   0.767      0.737 0.776 0.224
#> GSM23186     1   0.000      0.972 1.000 0.000
#> GSM23187     1   0.574      0.848 0.864 0.136
#> GSM23188     1   0.913      0.556 0.672 0.328
#> GSM23189     1   0.697      0.786 0.812 0.188
#> GSM23190     1   0.584      0.843 0.860 0.140
#> GSM23191     1   0.000      0.972 1.000 0.000
#> GSM23192     1   0.000      0.972 1.000 0.000
#> GSM23193     1   0.000      0.972 1.000 0.000
#> GSM23194     1   0.000      0.972 1.000 0.000
#> GSM23195     1   0.000      0.972 1.000 0.000
#> GSM23159     1   0.000      0.972 1.000 0.000
#> GSM23160     1   0.000      0.972 1.000 0.000
#> GSM23161     1   0.000      0.972 1.000 0.000
#> GSM23162     1   0.000      0.972 1.000 0.000
#> GSM23163     1   0.000      0.972 1.000 0.000
#> GSM23164     1   0.000      0.972 1.000 0.000
#> GSM23165     1   0.000      0.972 1.000 0.000
#> GSM23166     1   0.000      0.972 1.000 0.000
#> GSM23167     1   0.000      0.972 1.000 0.000
#> GSM23168     1   0.000      0.972 1.000 0.000
#> GSM23169     1   0.000      0.972 1.000 0.000
#> GSM23170     1   0.000      0.972 1.000 0.000
#> GSM23171     1   0.000      0.972 1.000 0.000
#> GSM23172     1   0.000      0.972 1.000 0.000
#> GSM23173     1   0.000      0.972 1.000 0.000
#> GSM23174     1   0.000      0.972 1.000 0.000
#> GSM23175     1   0.000      0.972 1.000 0.000
#> GSM23176     1   0.000      0.972 1.000 0.000
#> GSM23177     1   0.000      0.972 1.000 0.000
#> GSM23178     1   0.000      0.972 1.000 0.000
#> GSM23179     1   0.000      0.972 1.000 0.000
#> GSM23180     1   0.000      0.972 1.000 0.000
#> GSM23181     1   0.000      0.972 1.000 0.000
#> GSM23182     1   0.000      0.972 1.000 0.000
#> GSM23183     1   0.000      0.972 1.000 0.000
#> GSM23184     1   0.000      0.972 1.000 0.000
#> GSM23196     2   0.000      0.998 0.000 1.000
#> GSM23197     2   0.000      0.998 0.000 1.000
#> GSM23198     2   0.000      0.998 0.000 1.000
#> GSM23199     2   0.000      0.998 0.000 1.000
#> GSM23200     2   0.000      0.998 0.000 1.000
#> GSM23201     2   0.000      0.998 0.000 1.000
#> GSM23202     2   0.224      0.961 0.036 0.964
#> GSM23203     2   0.000      0.998 0.000 1.000
#> GSM23204     2   0.000      0.998 0.000 1.000
#> GSM23205     2   0.000      0.998 0.000 1.000
#> GSM23206     2   0.000      0.998 0.000 1.000
#> GSM23207     2   0.000      0.998 0.000 1.000
#> GSM23208     2   0.000      0.998 0.000 1.000
#> GSM23209     2   0.000      0.998 0.000 1.000
#> GSM23210     2   0.000      0.998 0.000 1.000
#> GSM23211     2   0.000      0.998 0.000 1.000
#> GSM23212     2   0.000      0.998 0.000 1.000
#> GSM23213     2   0.000      0.998 0.000 1.000
#> GSM23214     2   0.000      0.998 0.000 1.000
#> GSM23215     2   0.000      0.998 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
#> GSM23185     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23186     1  0.2066      0.929 0.940 0.000 0.060
#> GSM23187     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23191     3  0.6260      0.267 0.448 0.000 0.552
#> GSM23192     3  0.5497      0.628 0.292 0.000 0.708
#> GSM23193     3  0.3551      0.845 0.132 0.000 0.868
#> GSM23194     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23195     3  0.1163      0.928 0.028 0.000 0.972
#> GSM23159     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23160     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23161     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23162     3  0.0424      0.937 0.008 0.000 0.992
#> GSM23163     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23164     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23169     3  0.0892      0.932 0.020 0.000 0.980
#> GSM23170     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23173     3  0.0424      0.937 0.008 0.000 0.992
#> GSM23174     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23180     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23181     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23182     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23183     3  0.2878      0.879 0.096 0.000 0.904
#> GSM23184     3  0.0000      0.939 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23201     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23202     2  0.4654      0.744 0.208 0.792 0.000
#> GSM23203     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23205     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23206     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23212     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23213     2  0.0747      0.974 0.016 0.984 0.000
#> GSM23214     2  0.1031      0.967 0.024 0.976 0.000
#> GSM23215     2  0.0000      0.986 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.0188     0.9482 0.000 0.000 0.996 0.004
#> GSM23186     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23187     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0188     0.9482 0.000 0.000 0.996 0.004
#> GSM23191     4  0.3539     0.6613 0.004 0.000 0.176 0.820
#> GSM23192     3  0.4741     0.5467 0.004 0.000 0.668 0.328
#> GSM23193     3  0.4103     0.6782 0.000 0.000 0.744 0.256
#> GSM23194     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23195     1  0.3528     0.7182 0.808 0.000 0.192 0.000
#> GSM23159     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1867     0.8623 0.928 0.000 0.000 0.072
#> GSM23162     3  0.0188     0.9475 0.000 0.000 0.996 0.004
#> GSM23163     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23164     1  0.4999    -0.0241 0.508 0.000 0.000 0.492
#> GSM23165     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23166     4  0.4999    -0.0862 0.492 0.000 0.000 0.508
#> GSM23167     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23169     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23170     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0188     0.9141 0.996 0.000 0.000 0.004
#> GSM23172     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23173     3  0.1940     0.8787 0.076 0.000 0.924 0.000
#> GSM23174     1  0.1022     0.8955 0.968 0.000 0.000 0.032
#> GSM23175     1  0.0336     0.9121 0.992 0.000 0.000 0.008
#> GSM23176     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000     0.9160 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000     0.9495 0.000 0.000 1.000 0.000
#> GSM23180     4  0.0188     0.8174 0.004 0.000 0.000 0.996
#> GSM23181     4  0.1474     0.8001 0.052 0.000 0.000 0.948
#> GSM23182     4  0.0188     0.8174 0.004 0.000 0.000 0.996
#> GSM23183     1  0.4697     0.4646 0.644 0.000 0.356 0.000
#> GSM23184     3  0.0188     0.9482 0.000 0.000 0.996 0.004
#> GSM23196     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0188     0.9420 0.000 0.996 0.000 0.004
#> GSM23198     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0592     0.9380 0.000 0.984 0.000 0.016
#> GSM23200     2  0.0336     0.9417 0.000 0.992 0.000 0.008
#> GSM23201     4  0.2011     0.8106 0.000 0.080 0.000 0.920
#> GSM23202     4  0.2469     0.7975 0.000 0.108 0.000 0.892
#> GSM23203     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0188     0.9420 0.000 0.996 0.000 0.004
#> GSM23205     2  0.4222     0.6128 0.000 0.728 0.000 0.272
#> GSM23206     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0707     0.9354 0.000 0.980 0.000 0.020
#> GSM23208     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0592     0.9380 0.000 0.984 0.000 0.016
#> GSM23211     2  0.0000     0.9440 0.000 1.000 0.000 0.000
#> GSM23212     2  0.4916     0.2500 0.000 0.576 0.000 0.424
#> GSM23213     4  0.4008     0.6348 0.000 0.244 0.000 0.756
#> GSM23214     4  0.2921     0.7723 0.000 0.140 0.000 0.860
#> GSM23215     2  0.0188     0.9432 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.3109     0.6912 0.000 0.000 0.800 0.000 0.200
#> GSM23186     1  0.2179     0.8593 0.888 0.000 0.000 0.000 0.112
#> GSM23187     3  0.0703     0.7743 0.000 0.000 0.976 0.000 0.024
#> GSM23188     3  0.1410     0.7685 0.000 0.000 0.940 0.000 0.060
#> GSM23189     3  0.0404     0.7726 0.000 0.000 0.988 0.000 0.012
#> GSM23190     3  0.3177     0.6803 0.000 0.000 0.792 0.000 0.208
#> GSM23191     4  0.2992     0.6022 0.000 0.000 0.064 0.868 0.068
#> GSM23192     3  0.6804    -0.0588 0.000 0.000 0.372 0.304 0.324
#> GSM23193     3  0.4555     0.3495 0.000 0.000 0.636 0.344 0.020
#> GSM23194     3  0.1851     0.7540 0.000 0.000 0.912 0.000 0.088
#> GSM23195     5  0.6294     0.6694 0.192 0.000 0.284 0.000 0.524
#> GSM23159     1  0.0880     0.9493 0.968 0.000 0.000 0.000 0.032
#> GSM23160     3  0.1478     0.7622 0.000 0.000 0.936 0.000 0.064
#> GSM23161     1  0.2989     0.8386 0.868 0.000 0.000 0.072 0.060
#> GSM23162     3  0.2569     0.7533 0.000 0.000 0.892 0.040 0.068
#> GSM23163     1  0.0510     0.9604 0.984 0.000 0.000 0.000 0.016
#> GSM23164     4  0.5220     0.1834 0.440 0.000 0.000 0.516 0.044
#> GSM23165     1  0.0290     0.9599 0.992 0.000 0.000 0.000 0.008
#> GSM23166     4  0.5313     0.2566 0.388 0.000 0.000 0.556 0.056
#> GSM23167     1  0.0000     0.9600 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.1671     0.7577 0.000 0.000 0.924 0.000 0.076
#> GSM23169     3  0.1831     0.7563 0.000 0.000 0.920 0.004 0.076
#> GSM23170     1  0.0510     0.9570 0.984 0.000 0.000 0.000 0.016
#> GSM23171     1  0.0162     0.9600 0.996 0.000 0.000 0.000 0.004
#> GSM23172     1  0.0404     0.9596 0.988 0.000 0.000 0.000 0.012
#> GSM23173     3  0.4083     0.4936 0.028 0.000 0.744 0.000 0.228
#> GSM23174     1  0.1041     0.9415 0.964 0.000 0.000 0.032 0.004
#> GSM23175     1  0.0404     0.9600 0.988 0.000 0.000 0.000 0.012
#> GSM23176     1  0.0290     0.9594 0.992 0.000 0.000 0.000 0.008
#> GSM23177     1  0.1043     0.9389 0.960 0.000 0.000 0.000 0.040
#> GSM23178     1  0.0451     0.9602 0.988 0.000 0.000 0.004 0.008
#> GSM23179     3  0.1608     0.7585 0.000 0.000 0.928 0.000 0.072
#> GSM23180     4  0.0794     0.6658 0.000 0.000 0.000 0.972 0.028
#> GSM23181     4  0.3459     0.6179 0.116 0.000 0.000 0.832 0.052
#> GSM23182     4  0.1608     0.6682 0.000 0.000 0.000 0.928 0.072
#> GSM23183     5  0.6742     0.6618 0.276 0.000 0.316 0.000 0.408
#> GSM23184     3  0.2690     0.7238 0.000 0.000 0.844 0.000 0.156
#> GSM23196     2  0.0290     0.8689 0.000 0.992 0.000 0.000 0.008
#> GSM23197     2  0.1121     0.8608 0.000 0.956 0.000 0.000 0.044
#> GSM23198     2  0.1608     0.8531 0.000 0.928 0.000 0.000 0.072
#> GSM23199     2  0.2424     0.8232 0.000 0.868 0.000 0.000 0.132
#> GSM23200     2  0.3636     0.7165 0.000 0.728 0.000 0.000 0.272
#> GSM23201     4  0.1704     0.6663 0.000 0.068 0.000 0.928 0.004
#> GSM23202     4  0.3401     0.6501 0.000 0.064 0.000 0.840 0.096
#> GSM23203     2  0.0162     0.8687 0.000 0.996 0.000 0.000 0.004
#> GSM23204     2  0.1792     0.8418 0.000 0.916 0.000 0.000 0.084
#> GSM23205     2  0.4101     0.4279 0.000 0.628 0.000 0.372 0.000
#> GSM23206     2  0.0162     0.8684 0.000 0.996 0.000 0.000 0.004
#> GSM23207     2  0.4290     0.6663 0.000 0.680 0.000 0.016 0.304
#> GSM23208     2  0.0000     0.8686 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0880     0.8639 0.000 0.968 0.000 0.000 0.032
#> GSM23210     2  0.1270     0.8608 0.000 0.948 0.000 0.000 0.052
#> GSM23211     2  0.0609     0.8664 0.000 0.980 0.000 0.000 0.020
#> GSM23212     2  0.6526     0.2645 0.000 0.452 0.000 0.204 0.344
#> GSM23213     4  0.6434     0.3289 0.000 0.176 0.000 0.432 0.392
#> GSM23214     4  0.5163     0.5203 0.000 0.068 0.000 0.636 0.296
#> GSM23215     2  0.1197     0.8597 0.000 0.952 0.000 0.000 0.048

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.4774     0.6067 0.000 0.000 0.672 0.192 0.000 0.136
#> GSM23186     1  0.4424     0.3781 0.632 0.000 0.000 0.044 0.000 0.324
#> GSM23187     3  0.2680     0.7178 0.000 0.000 0.860 0.032 0.000 0.108
#> GSM23188     3  0.3435     0.6962 0.000 0.000 0.804 0.060 0.000 0.136
#> GSM23189     3  0.2266     0.7217 0.000 0.000 0.880 0.012 0.000 0.108
#> GSM23190     3  0.4556     0.6373 0.000 0.000 0.688 0.212 0.000 0.100
#> GSM23191     5  0.3264     0.5689 0.000 0.000 0.012 0.076 0.840 0.072
#> GSM23192     6  0.6639     0.4882 0.004 0.000 0.080 0.164 0.220 0.532
#> GSM23193     3  0.4851     0.2237 0.000 0.000 0.524 0.008 0.428 0.040
#> GSM23194     3  0.4504     0.3846 0.000 0.000 0.592 0.040 0.000 0.368
#> GSM23195     6  0.5620     0.6926 0.120 0.000 0.104 0.112 0.000 0.664
#> GSM23159     1  0.1779     0.8541 0.920 0.000 0.000 0.016 0.000 0.064
#> GSM23160     3  0.2706     0.7075 0.000 0.000 0.860 0.036 0.000 0.104
#> GSM23161     1  0.6203     0.5532 0.612 0.000 0.020 0.056 0.120 0.192
#> GSM23162     3  0.2891     0.7221 0.000 0.000 0.872 0.032 0.036 0.060
#> GSM23163     1  0.2722     0.8464 0.872 0.000 0.004 0.032 0.004 0.088
#> GSM23164     5  0.5789     0.3343 0.280 0.000 0.004 0.036 0.584 0.096
#> GSM23165     1  0.0146     0.8804 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM23166     5  0.6119     0.3528 0.248 0.000 0.020 0.036 0.588 0.108
#> GSM23167     1  0.0363     0.8811 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM23168     3  0.3493     0.6774 0.000 0.000 0.796 0.056 0.000 0.148
#> GSM23169     3  0.3506     0.7053 0.000 0.000 0.792 0.052 0.000 0.156
#> GSM23170     1  0.1700     0.8658 0.928 0.000 0.000 0.024 0.000 0.048
#> GSM23171     1  0.0146     0.8806 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM23172     1  0.0405     0.8804 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM23173     3  0.5315     0.5556 0.072 0.000 0.676 0.072 0.000 0.180
#> GSM23174     1  0.1967     0.8432 0.904 0.000 0.000 0.000 0.084 0.012
#> GSM23175     1  0.1124     0.8777 0.956 0.000 0.000 0.008 0.000 0.036
#> GSM23176     1  0.0547     0.8815 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM23177     1  0.4203     0.7457 0.772 0.000 0.020 0.052 0.008 0.148
#> GSM23178     1  0.1080     0.8770 0.960 0.000 0.000 0.004 0.004 0.032
#> GSM23179     3  0.2747     0.7176 0.000 0.000 0.860 0.044 0.000 0.096
#> GSM23180     5  0.2197     0.5960 0.000 0.000 0.000 0.056 0.900 0.044
#> GSM23181     5  0.3900     0.5282 0.008 0.000 0.000 0.048 0.764 0.180
#> GSM23182     5  0.2404     0.5635 0.000 0.000 0.000 0.112 0.872 0.016
#> GSM23183     6  0.4381     0.7164 0.136 0.000 0.080 0.028 0.000 0.756
#> GSM23184     3  0.2867     0.7195 0.000 0.000 0.848 0.112 0.000 0.040
#> GSM23196     2  0.0713     0.8250 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM23197     2  0.1007     0.8143 0.000 0.956 0.000 0.044 0.000 0.000
#> GSM23198     2  0.2793     0.6621 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM23199     2  0.3830     0.2470 0.000 0.620 0.000 0.376 0.000 0.004
#> GSM23200     2  0.3868    -0.2116 0.000 0.504 0.000 0.496 0.000 0.000
#> GSM23201     5  0.2274     0.5647 0.000 0.088 0.000 0.012 0.892 0.008
#> GSM23202     5  0.4336     0.3651 0.004 0.040 0.000 0.212 0.728 0.016
#> GSM23203     2  0.0458     0.8289 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM23204     2  0.1970     0.7755 0.000 0.900 0.000 0.092 0.000 0.008
#> GSM23205     5  0.4636    -0.0742 0.000 0.484 0.000 0.024 0.484 0.008
#> GSM23206     2  0.0146     0.8302 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23207     4  0.3843     0.1323 0.000 0.452 0.000 0.548 0.000 0.000
#> GSM23208     2  0.0260     0.8301 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM23209     2  0.0547     0.8245 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM23210     2  0.2668     0.7041 0.000 0.828 0.000 0.168 0.000 0.004
#> GSM23211     2  0.0000     0.8299 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.5417     0.6232 0.000 0.244 0.000 0.576 0.180 0.000
#> GSM23213     4  0.5315     0.5472 0.000 0.084 0.000 0.584 0.316 0.016
#> GSM23214     4  0.4847     0.3843 0.000 0.048 0.000 0.532 0.416 0.004
#> GSM23215     2  0.1556     0.7928 0.000 0.920 0.000 0.080 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-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 cell.type(p) disease.state(p) k
#> CV:NMF 57     3.90e-13         0.052490 2
#> CV:NMF 56     6.91e-13         0.000873 3
#> CV:NMF 53     1.30e-09         0.000188 4
#> CV:NMF 49     2.19e-08         0.002572 5
#> CV:NMF 45     8.29e-08         0.005398 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 11993 rows and 57 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 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-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.408           0.851       0.897         0.4706 0.536   0.536
#> 3 3 0.832           0.890       0.951         0.4227 0.787   0.603
#> 4 4 0.813           0.872       0.919         0.0809 0.968   0.902
#> 5 5 0.805           0.781       0.872         0.0413 0.977   0.923
#> 6 6 0.804           0.753       0.825         0.0376 0.984   0.941

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
#> GSM23185     1  0.8909      0.766 0.692 0.308
#> GSM23186     1  0.1414      0.843 0.980 0.020
#> GSM23187     1  0.8909      0.766 0.692 0.308
#> GSM23188     1  0.8909      0.766 0.692 0.308
#> GSM23189     1  0.8909      0.766 0.692 0.308
#> GSM23190     1  0.8909      0.766 0.692 0.308
#> GSM23191     1  0.8763      0.773 0.704 0.296
#> GSM23192     1  0.5946      0.824 0.856 0.144
#> GSM23193     1  0.8555      0.780 0.720 0.280
#> GSM23194     1  0.8861      0.769 0.696 0.304
#> GSM23195     1  0.6148      0.822 0.848 0.152
#> GSM23159     1  0.0000      0.844 1.000 0.000
#> GSM23160     1  0.8909      0.766 0.692 0.308
#> GSM23161     1  0.0000      0.844 1.000 0.000
#> GSM23162     1  0.8861      0.769 0.696 0.304
#> GSM23163     1  0.0376      0.844 0.996 0.004
#> GSM23164     1  0.0000      0.844 1.000 0.000
#> GSM23165     1  0.0000      0.844 1.000 0.000
#> GSM23166     1  0.0000      0.844 1.000 0.000
#> GSM23167     1  0.0000      0.844 1.000 0.000
#> GSM23168     1  0.8909      0.766 0.692 0.308
#> GSM23169     1  0.8909      0.766 0.692 0.308
#> GSM23170     1  0.0000      0.844 1.000 0.000
#> GSM23171     1  0.0000      0.844 1.000 0.000
#> GSM23172     1  0.0000      0.844 1.000 0.000
#> GSM23173     1  0.8909      0.766 0.692 0.308
#> GSM23174     1  0.0000      0.844 1.000 0.000
#> GSM23175     1  0.0000      0.844 1.000 0.000
#> GSM23176     1  0.0000      0.844 1.000 0.000
#> GSM23177     1  0.0000      0.844 1.000 0.000
#> GSM23178     1  0.0000      0.844 1.000 0.000
#> GSM23179     1  0.8909      0.766 0.692 0.308
#> GSM23180     1  0.0376      0.844 0.996 0.004
#> GSM23181     1  0.0376      0.844 0.996 0.004
#> GSM23182     1  0.0376      0.844 0.996 0.004
#> GSM23183     1  0.6048      0.823 0.852 0.148
#> GSM23184     1  0.8909      0.766 0.692 0.308
#> GSM23196     2  0.0000      0.948 0.000 1.000
#> GSM23197     2  0.0000      0.948 0.000 1.000
#> GSM23198     2  0.0000      0.948 0.000 1.000
#> GSM23199     2  0.0000      0.948 0.000 1.000
#> GSM23200     2  0.0000      0.948 0.000 1.000
#> GSM23201     2  0.5629      0.872 0.132 0.868
#> GSM23202     2  0.5629      0.872 0.132 0.868
#> GSM23203     2  0.0000      0.948 0.000 1.000
#> GSM23204     2  0.0000      0.948 0.000 1.000
#> GSM23205     2  0.5629      0.872 0.132 0.868
#> GSM23206     2  0.0000      0.948 0.000 1.000
#> GSM23207     2  0.0000      0.948 0.000 1.000
#> GSM23208     2  0.0000      0.948 0.000 1.000
#> GSM23209     2  0.0000      0.948 0.000 1.000
#> GSM23210     2  0.0000      0.948 0.000 1.000
#> GSM23211     2  0.0000      0.948 0.000 1.000
#> GSM23212     2  0.5629      0.872 0.132 0.868
#> GSM23213     2  0.5629      0.872 0.132 0.868
#> GSM23214     2  0.5629      0.872 0.132 0.868
#> GSM23215     2  0.0000      0.948 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
#> GSM23185     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23186     1  0.2878      0.863 0.904 0.000 0.096
#> GSM23187     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23191     3  0.2261      0.885 0.068 0.000 0.932
#> GSM23192     1  0.6307     -0.110 0.512 0.000 0.488
#> GSM23193     3  0.4399      0.766 0.188 0.000 0.812
#> GSM23194     3  0.1964      0.894 0.056 0.000 0.944
#> GSM23195     3  0.6154      0.343 0.408 0.000 0.592
#> GSM23159     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23160     3  0.0237      0.914 0.004 0.000 0.996
#> GSM23161     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23162     3  0.1163      0.908 0.028 0.000 0.972
#> GSM23163     1  0.0592      0.953 0.988 0.000 0.012
#> GSM23164     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23169     3  0.1643      0.902 0.044 0.000 0.956
#> GSM23170     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23173     3  0.1031      0.910 0.024 0.000 0.976
#> GSM23174     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.962 1.000 0.000 0.000
#> GSM23179     3  0.0424      0.914 0.008 0.000 0.992
#> GSM23180     1  0.0829      0.954 0.984 0.012 0.004
#> GSM23181     1  0.0829      0.954 0.984 0.012 0.004
#> GSM23182     1  0.0829      0.954 0.984 0.012 0.004
#> GSM23183     3  0.6295      0.150 0.472 0.000 0.528
#> GSM23184     3  0.0000      0.914 0.000 0.000 1.000
#> GSM23196     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23197     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23198     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23199     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23200     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23201     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23202     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23203     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23204     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23205     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23206     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23207     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23208     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23209     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23210     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23211     2  0.0424      0.955 0.000 0.992 0.008
#> GSM23212     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23213     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23214     2  0.3412      0.890 0.124 0.876 0.000
#> GSM23215     2  0.0424      0.955 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
#> GSM23185     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23186     1  0.4502      0.681 0.748 0.000 0.016 0.236
#> GSM23187     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23188     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23189     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23190     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23191     3  0.3392      0.815 0.020 0.000 0.856 0.124
#> GSM23192     4  0.5533      0.871 0.132 0.000 0.136 0.732
#> GSM23193     3  0.5142      0.643 0.064 0.000 0.744 0.192
#> GSM23194     3  0.4790      0.377 0.000 0.000 0.620 0.380
#> GSM23195     4  0.5240      0.848 0.072 0.000 0.188 0.740
#> GSM23159     1  0.0921      0.903 0.972 0.000 0.000 0.028
#> GSM23160     3  0.0592      0.885 0.000 0.000 0.984 0.016
#> GSM23161     1  0.0336      0.906 0.992 0.000 0.000 0.008
#> GSM23162     3  0.2408      0.849 0.000 0.000 0.896 0.104
#> GSM23163     1  0.2466      0.855 0.900 0.000 0.004 0.096
#> GSM23164     1  0.0336      0.906 0.992 0.000 0.000 0.008
#> GSM23165     1  0.0921      0.904 0.972 0.000 0.000 0.028
#> GSM23166     1  0.0336      0.906 0.992 0.000 0.000 0.008
#> GSM23167     1  0.0921      0.904 0.972 0.000 0.000 0.028
#> GSM23168     3  0.0188      0.889 0.000 0.000 0.996 0.004
#> GSM23169     3  0.3695      0.806 0.016 0.000 0.828 0.156
#> GSM23170     1  0.0336      0.906 0.992 0.000 0.000 0.008
#> GSM23171     1  0.0336      0.907 0.992 0.000 0.000 0.008
#> GSM23172     1  0.0921      0.904 0.972 0.000 0.000 0.028
#> GSM23173     3  0.2704      0.833 0.000 0.000 0.876 0.124
#> GSM23174     1  0.0000      0.907 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0336      0.907 0.992 0.000 0.000 0.008
#> GSM23176     1  0.0921      0.904 0.972 0.000 0.000 0.028
#> GSM23177     1  0.0336      0.906 0.992 0.000 0.000 0.008
#> GSM23178     1  0.0921      0.904 0.972 0.000 0.000 0.028
#> GSM23179     3  0.2408      0.858 0.000 0.000 0.896 0.104
#> GSM23180     1  0.4522      0.602 0.680 0.000 0.000 0.320
#> GSM23181     1  0.4500      0.607 0.684 0.000 0.000 0.316
#> GSM23182     1  0.4522      0.602 0.680 0.000 0.000 0.320
#> GSM23183     4  0.4662      0.896 0.092 0.000 0.112 0.796
#> GSM23184     3  0.0469      0.894 0.000 0.000 0.988 0.012
#> GSM23196     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23200     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23201     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23202     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23203     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23205     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23206     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23208     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23212     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23213     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23214     2  0.2868      0.893 0.000 0.864 0.000 0.136
#> GSM23215     2  0.0000      0.956 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
#> GSM23185     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.5268     0.5262 0.612 0.000 0.000 0.068 0.320
#> GSM23187     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23191     4  0.4604     0.8323 0.000 0.000 0.428 0.560 0.012
#> GSM23192     5  0.3018     0.8499 0.024 0.000 0.020 0.080 0.876
#> GSM23193     4  0.6511     0.7427 0.032 0.000 0.392 0.484 0.092
#> GSM23194     3  0.5125     0.0255 0.000 0.000 0.544 0.040 0.416
#> GSM23195     5  0.2863     0.8453 0.000 0.000 0.064 0.060 0.876
#> GSM23159     1  0.1907     0.8500 0.928 0.000 0.000 0.044 0.028
#> GSM23160     3  0.2012     0.6777 0.000 0.000 0.920 0.060 0.020
#> GSM23161     1  0.2020     0.8462 0.900 0.000 0.000 0.100 0.000
#> GSM23162     4  0.4650     0.7832 0.000 0.000 0.468 0.520 0.012
#> GSM23163     1  0.4309     0.7616 0.768 0.000 0.000 0.084 0.148
#> GSM23164     1  0.2020     0.8462 0.900 0.000 0.000 0.100 0.000
#> GSM23165     1  0.1568     0.8466 0.944 0.000 0.000 0.036 0.020
#> GSM23166     1  0.1965     0.8474 0.904 0.000 0.000 0.096 0.000
#> GSM23167     1  0.1568     0.8466 0.944 0.000 0.000 0.036 0.020
#> GSM23168     3  0.1300     0.6985 0.000 0.000 0.956 0.028 0.016
#> GSM23169     3  0.6180    -0.2502 0.000 0.000 0.460 0.404 0.136
#> GSM23170     1  0.1410     0.8546 0.940 0.000 0.000 0.060 0.000
#> GSM23171     1  0.0703     0.8562 0.976 0.000 0.000 0.024 0.000
#> GSM23172     1  0.1399     0.8492 0.952 0.000 0.000 0.028 0.020
#> GSM23173     3  0.5811    -0.0088 0.000 0.000 0.552 0.340 0.108
#> GSM23174     1  0.1544     0.8583 0.932 0.000 0.000 0.068 0.000
#> GSM23175     1  0.0510     0.8560 0.984 0.000 0.000 0.016 0.000
#> GSM23176     1  0.1485     0.8482 0.948 0.000 0.000 0.032 0.020
#> GSM23177     1  0.1478     0.8538 0.936 0.000 0.000 0.064 0.000
#> GSM23178     1  0.1485     0.8480 0.948 0.000 0.000 0.032 0.020
#> GSM23179     3  0.3346     0.5799 0.000 0.000 0.844 0.064 0.092
#> GSM23180     1  0.6008     0.5317 0.560 0.000 0.000 0.292 0.148
#> GSM23181     1  0.5991     0.5367 0.564 0.000 0.000 0.288 0.148
#> GSM23182     1  0.6008     0.5317 0.560 0.000 0.000 0.292 0.148
#> GSM23183     5  0.0898     0.8897 0.000 0.000 0.020 0.008 0.972
#> GSM23184     3  0.0000     0.7344 0.000 0.000 1.000 0.000 0.000
#> GSM23196     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23200     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23201     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23202     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23203     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23206     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23208     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000     0.9531 0.000 1.000 0.000 0.000 0.000
#> GSM23212     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23213     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23214     2  0.2561     0.8845 0.000 0.856 0.000 0.144 0.000
#> GSM23215     2  0.0000     0.9531 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
#> GSM23185     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23186     1  0.6123      0.367 0.352 0.000 0.000 NA 0.000 0.308
#> GSM23187     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23188     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23189     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23190     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23191     5  0.3515      0.612 0.016 0.000 0.192 NA 0.780 0.000
#> GSM23192     6  0.3251      0.829 0.012 0.000 0.016 NA 0.060 0.856
#> GSM23193     5  0.5995      0.548 0.036 0.000 0.184 NA 0.644 0.048
#> GSM23194     3  0.4881      0.215 0.000 0.000 0.540 NA 0.044 0.408
#> GSM23195     6  0.2647      0.837 0.000 0.000 0.016 NA 0.020 0.876
#> GSM23159     1  0.3688      0.722 0.724 0.000 0.000 NA 0.000 0.020
#> GSM23160     3  0.3018      0.753 0.000 0.000 0.848 NA 0.112 0.016
#> GSM23161     1  0.0547      0.678 0.980 0.000 0.000 NA 0.000 0.000
#> GSM23162     5  0.2883      0.612 0.000 0.000 0.212 NA 0.788 0.000
#> GSM23163     1  0.5255      0.624 0.588 0.000 0.000 NA 0.000 0.140
#> GSM23164     1  0.0458      0.679 0.984 0.000 0.000 NA 0.000 0.000
#> GSM23165     1  0.4099      0.711 0.612 0.000 0.000 NA 0.000 0.016
#> GSM23166     1  0.0363      0.681 0.988 0.000 0.000 NA 0.000 0.000
#> GSM23167     1  0.4088      0.713 0.616 0.000 0.000 NA 0.000 0.016
#> GSM23168     3  0.2171      0.814 0.000 0.000 0.912 NA 0.040 0.016
#> GSM23169     5  0.6848      0.414 0.000 0.000 0.148 NA 0.456 0.096
#> GSM23170     1  0.1501      0.706 0.924 0.000 0.000 NA 0.000 0.000
#> GSM23171     1  0.3409      0.732 0.700 0.000 0.000 NA 0.000 0.000
#> GSM23172     1  0.4076      0.715 0.620 0.000 0.000 NA 0.000 0.016
#> GSM23173     5  0.7073      0.401 0.000 0.000 0.216 NA 0.432 0.096
#> GSM23174     1  0.3023      0.734 0.768 0.000 0.000 NA 0.000 0.000
#> GSM23175     1  0.3446      0.730 0.692 0.000 0.000 NA 0.000 0.000
#> GSM23176     1  0.4064      0.715 0.624 0.000 0.000 NA 0.000 0.016
#> GSM23177     1  0.0937      0.696 0.960 0.000 0.000 NA 0.000 0.000
#> GSM23178     1  0.4076      0.715 0.620 0.000 0.000 NA 0.000 0.016
#> GSM23179     3  0.3411      0.748 0.000 0.000 0.836 NA 0.032 0.088
#> GSM23180     1  0.5426      0.274 0.604 0.000 0.000 NA 0.016 0.116
#> GSM23181     1  0.5342      0.279 0.608 0.000 0.000 NA 0.012 0.116
#> GSM23182     1  0.5426      0.274 0.604 0.000 0.000 NA 0.016 0.116
#> GSM23183     6  0.0964      0.875 0.000 0.000 0.016 NA 0.004 0.968
#> GSM23184     3  0.0000      0.879 0.000 0.000 1.000 NA 0.000 0.000
#> GSM23196     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23197     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23198     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23199     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23200     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23201     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23202     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23203     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23204     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23205     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23206     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23207     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23208     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23209     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23210     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23211     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000
#> GSM23212     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23213     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23214     2  0.3053      0.848 0.000 0.812 0.000 NA 0.020 0.000
#> GSM23215     2  0.0000      0.939 0.000 1.000 0.000 NA 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) disease.state(p) k
#> MAD:hclust 57     3.90e-13         0.052490 2
#> MAD:hclust 54     1.88e-12         0.001274 3
#> MAD:hclust 56     4.20e-12         0.004059 4
#> MAD:hclust 54     5.26e-11         0.003358 5
#> MAD:hclust 50     3.61e-10         0.000282 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.669           0.893       0.934         0.4742 0.536   0.536
#> 3 3 0.739           0.977       0.942         0.3954 0.786   0.600
#> 4 4 0.816           0.845       0.785         0.1155 0.937   0.805
#> 5 5 0.747           0.756       0.813         0.0653 0.910   0.671
#> 6 6 0.767           0.722       0.807         0.0439 0.960   0.807

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
#> GSM23185     1  0.7883      0.768 0.764 0.236
#> GSM23186     1  0.0376      0.913 0.996 0.004
#> GSM23187     1  0.7883      0.768 0.764 0.236
#> GSM23188     1  0.7883      0.768 0.764 0.236
#> GSM23189     1  0.7883      0.768 0.764 0.236
#> GSM23190     1  0.7883      0.768 0.764 0.236
#> GSM23191     1  0.0938      0.911 0.988 0.012
#> GSM23192     1  0.0000      0.912 1.000 0.000
#> GSM23193     1  0.0000      0.912 1.000 0.000
#> GSM23194     1  0.7674      0.780 0.776 0.224
#> GSM23195     1  0.0000      0.912 1.000 0.000
#> GSM23159     1  0.1414      0.917 0.980 0.020
#> GSM23160     1  0.7674      0.780 0.776 0.224
#> GSM23161     1  0.1414      0.917 0.980 0.020
#> GSM23162     1  0.5842      0.841 0.860 0.140
#> GSM23163     1  0.1414      0.917 0.980 0.020
#> GSM23164     1  0.1414      0.917 0.980 0.020
#> GSM23165     1  0.1414      0.917 0.980 0.020
#> GSM23166     1  0.1414      0.917 0.980 0.020
#> GSM23167     1  0.1414      0.917 0.980 0.020
#> GSM23168     1  0.7674      0.780 0.776 0.224
#> GSM23169     1  0.0000      0.912 1.000 0.000
#> GSM23170     1  0.1414      0.917 0.980 0.020
#> GSM23171     1  0.1414      0.917 0.980 0.020
#> GSM23172     1  0.1414      0.917 0.980 0.020
#> GSM23173     1  0.0672      0.912 0.992 0.008
#> GSM23174     1  0.1414      0.917 0.980 0.020
#> GSM23175     1  0.1414      0.917 0.980 0.020
#> GSM23176     1  0.1414      0.917 0.980 0.020
#> GSM23177     1  0.1414      0.917 0.980 0.020
#> GSM23178     1  0.1414      0.917 0.980 0.020
#> GSM23179     1  0.7674      0.780 0.776 0.224
#> GSM23180     1  0.1414      0.917 0.980 0.020
#> GSM23181     1  0.1414      0.917 0.980 0.020
#> GSM23182     1  0.1414      0.917 0.980 0.020
#> GSM23183     1  0.0000      0.912 1.000 0.000
#> GSM23184     1  0.7674      0.780 0.776 0.224
#> GSM23196     2  0.0000      0.960 0.000 1.000
#> GSM23197     2  0.0000      0.960 0.000 1.000
#> GSM23198     2  0.0000      0.960 0.000 1.000
#> GSM23199     2  0.0000      0.960 0.000 1.000
#> GSM23200     2  0.0000      0.960 0.000 1.000
#> GSM23201     2  0.0000      0.960 0.000 1.000
#> GSM23202     2  0.7883      0.712 0.236 0.764
#> GSM23203     2  0.0000      0.960 0.000 1.000
#> GSM23204     2  0.0000      0.960 0.000 1.000
#> GSM23205     2  0.0000      0.960 0.000 1.000
#> GSM23206     2  0.0000      0.960 0.000 1.000
#> GSM23207     2  0.0000      0.960 0.000 1.000
#> GSM23208     2  0.0000      0.960 0.000 1.000
#> GSM23209     2  0.0000      0.960 0.000 1.000
#> GSM23210     2  0.0000      0.960 0.000 1.000
#> GSM23211     2  0.0000      0.960 0.000 1.000
#> GSM23212     2  0.0000      0.960 0.000 1.000
#> GSM23213     2  0.7528      0.739 0.216 0.784
#> GSM23214     2  0.7528      0.739 0.216 0.784
#> GSM23215     2  0.0000      0.960 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
#> GSM23185     3  0.3193      0.978 0.100 0.004 0.896
#> GSM23186     1  0.1289      0.962 0.968 0.000 0.032
#> GSM23187     3  0.3193      0.978 0.100 0.004 0.896
#> GSM23188     3  0.3193      0.978 0.100 0.004 0.896
#> GSM23189     3  0.3193      0.978 0.100 0.004 0.896
#> GSM23190     3  0.3193      0.978 0.100 0.004 0.896
#> GSM23191     3  0.3412      0.987 0.124 0.000 0.876
#> GSM23192     3  0.3482      0.986 0.128 0.000 0.872
#> GSM23193     3  0.3340      0.988 0.120 0.000 0.880
#> GSM23194     3  0.3573      0.989 0.120 0.004 0.876
#> GSM23195     3  0.3482      0.986 0.128 0.000 0.872
#> GSM23159     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23160     3  0.3573      0.989 0.120 0.004 0.876
#> GSM23161     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23162     3  0.3340      0.988 0.120 0.000 0.880
#> GSM23163     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23164     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23168     3  0.3573      0.989 0.120 0.004 0.876
#> GSM23169     3  0.3412      0.988 0.124 0.000 0.876
#> GSM23170     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23173     3  0.3412      0.988 0.124 0.000 0.876
#> GSM23174     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23179     3  0.3573      0.989 0.120 0.004 0.876
#> GSM23180     1  0.0237      0.993 0.996 0.000 0.004
#> GSM23181     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23182     1  0.1031      0.971 0.976 0.000 0.024
#> GSM23183     3  0.3482      0.986 0.128 0.000 0.872
#> GSM23184     3  0.3573      0.989 0.120 0.004 0.876
#> GSM23196     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23197     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23198     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23199     2  0.2537      0.955 0.000 0.920 0.080
#> GSM23200     2  0.1860      0.957 0.000 0.948 0.052
#> GSM23201     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23202     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23203     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23204     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23205     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23206     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23207     2  0.2959      0.952 0.000 0.900 0.100
#> GSM23208     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23209     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23210     2  0.2448      0.955 0.000 0.924 0.076
#> GSM23211     2  0.0892      0.957 0.000 0.980 0.020
#> GSM23212     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23213     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23214     2  0.3038      0.951 0.000 0.896 0.104
#> GSM23215     2  0.1529      0.957 0.000 0.960 0.040

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.0524      0.878 0.008 0.004 0.988 0.000
#> GSM23186     1  0.4939      0.772 0.740 0.220 0.040 0.000
#> GSM23187     3  0.0524      0.878 0.008 0.004 0.988 0.000
#> GSM23188     3  0.0524      0.878 0.008 0.004 0.988 0.000
#> GSM23189     3  0.0524      0.878 0.008 0.004 0.988 0.000
#> GSM23190     3  0.0336      0.878 0.008 0.000 0.992 0.000
#> GSM23191     3  0.5055      0.791 0.008 0.368 0.624 0.000
#> GSM23192     3  0.5161      0.765 0.008 0.400 0.592 0.000
#> GSM23193     3  0.5040      0.793 0.008 0.364 0.628 0.000
#> GSM23194     3  0.1890      0.878 0.008 0.056 0.936 0.000
#> GSM23195     3  0.4990      0.796 0.008 0.352 0.640 0.000
#> GSM23159     1  0.0524      0.921 0.988 0.008 0.004 0.000
#> GSM23160     3  0.1042      0.877 0.008 0.020 0.972 0.000
#> GSM23161     1  0.1576      0.914 0.948 0.048 0.004 0.000
#> GSM23162     3  0.3933      0.855 0.008 0.200 0.792 0.000
#> GSM23163     1  0.1661      0.916 0.944 0.052 0.004 0.000
#> GSM23164     1  0.1576      0.914 0.948 0.048 0.004 0.000
#> GSM23165     1  0.1004      0.920 0.972 0.024 0.004 0.000
#> GSM23166     1  0.1576      0.914 0.948 0.048 0.004 0.000
#> GSM23167     1  0.1004      0.920 0.972 0.024 0.004 0.000
#> GSM23168     3  0.1042      0.877 0.008 0.020 0.972 0.000
#> GSM23169     3  0.4511      0.836 0.008 0.268 0.724 0.000
#> GSM23170     1  0.0376      0.921 0.992 0.004 0.004 0.000
#> GSM23171     1  0.0376      0.921 0.992 0.004 0.004 0.000
#> GSM23172     1  0.1004      0.920 0.972 0.024 0.004 0.000
#> GSM23173     3  0.3893      0.856 0.008 0.196 0.796 0.000
#> GSM23174     1  0.0592      0.920 0.984 0.016 0.000 0.000
#> GSM23175     1  0.0376      0.921 0.992 0.004 0.004 0.000
#> GSM23176     1  0.0895      0.919 0.976 0.020 0.004 0.000
#> GSM23177     1  0.0524      0.921 0.988 0.008 0.004 0.000
#> GSM23178     1  0.1004      0.920 0.972 0.024 0.004 0.000
#> GSM23179     3  0.0672      0.878 0.008 0.008 0.984 0.000
#> GSM23180     1  0.7020      0.547 0.532 0.332 0.000 0.136
#> GSM23181     1  0.3311      0.841 0.828 0.172 0.000 0.000
#> GSM23182     1  0.7327      0.516 0.504 0.320 0.000 0.176
#> GSM23183     3  0.5007      0.794 0.008 0.356 0.636 0.000
#> GSM23184     3  0.0672      0.878 0.008 0.008 0.984 0.000
#> GSM23196     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23197     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23198     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23199     4  0.4049      0.519 0.000 0.212 0.008 0.780
#> GSM23200     4  0.4356      0.187 0.000 0.292 0.000 0.708
#> GSM23201     4  0.0336      0.797 0.000 0.000 0.008 0.992
#> GSM23202     4  0.0469      0.792 0.012 0.000 0.000 0.988
#> GSM23203     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23204     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23205     4  0.0336      0.797 0.000 0.000 0.008 0.992
#> GSM23206     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23207     4  0.3172      0.632 0.000 0.160 0.000 0.840
#> GSM23208     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23209     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23210     4  0.4086      0.509 0.000 0.216 0.008 0.776
#> GSM23211     2  0.4948      0.989 0.000 0.560 0.000 0.440
#> GSM23212     4  0.0188      0.798 0.004 0.000 0.000 0.996
#> GSM23213     4  0.0336      0.797 0.008 0.000 0.000 0.992
#> GSM23214     4  0.0336      0.797 0.008 0.000 0.000 0.992
#> GSM23215     2  0.5292      0.890 0.000 0.512 0.008 0.480

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0162      0.889 0.000 0.000 0.996 0.000 0.004
#> GSM23186     1  0.6756      0.462 0.516 0.000 0.016 0.232 0.236
#> GSM23187     3  0.0000      0.889 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000      0.889 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000      0.889 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0162      0.889 0.000 0.000 0.996 0.000 0.004
#> GSM23191     5  0.3521      0.654 0.004 0.000 0.232 0.000 0.764
#> GSM23192     5  0.5305      0.664 0.000 0.000 0.196 0.132 0.672
#> GSM23193     5  0.3395      0.653 0.000 0.000 0.236 0.000 0.764
#> GSM23194     3  0.3975      0.637 0.000 0.000 0.792 0.064 0.144
#> GSM23195     5  0.6135      0.638 0.004 0.000 0.236 0.180 0.580
#> GSM23159     1  0.0798      0.879 0.976 0.000 0.000 0.016 0.008
#> GSM23160     3  0.1399      0.877 0.000 0.000 0.952 0.020 0.028
#> GSM23161     1  0.2409      0.855 0.900 0.000 0.000 0.032 0.068
#> GSM23162     5  0.4658      0.196 0.000 0.000 0.484 0.012 0.504
#> GSM23163     1  0.3828      0.855 0.808 0.000 0.000 0.072 0.120
#> GSM23164     1  0.2344      0.857 0.904 0.000 0.000 0.032 0.064
#> GSM23165     1  0.3119      0.860 0.860 0.000 0.000 0.072 0.068
#> GSM23166     1  0.2409      0.855 0.900 0.000 0.000 0.032 0.068
#> GSM23167     1  0.3119      0.860 0.860 0.000 0.000 0.072 0.068
#> GSM23168     3  0.1485      0.877 0.000 0.000 0.948 0.020 0.032
#> GSM23169     5  0.5990      0.430 0.000 0.000 0.384 0.116 0.500
#> GSM23170     1  0.1211      0.880 0.960 0.000 0.000 0.024 0.016
#> GSM23171     1  0.0992      0.880 0.968 0.000 0.000 0.024 0.008
#> GSM23172     1  0.3119      0.860 0.860 0.000 0.000 0.072 0.068
#> GSM23173     3  0.5715     -0.181 0.000 0.000 0.524 0.088 0.388
#> GSM23174     1  0.0807      0.876 0.976 0.000 0.000 0.012 0.012
#> GSM23175     1  0.0771      0.880 0.976 0.000 0.000 0.020 0.004
#> GSM23176     1  0.3119      0.860 0.860 0.000 0.000 0.072 0.068
#> GSM23177     1  0.1211      0.874 0.960 0.000 0.000 0.024 0.016
#> GSM23178     1  0.2992      0.862 0.868 0.000 0.000 0.064 0.068
#> GSM23179     3  0.1216      0.882 0.000 0.000 0.960 0.020 0.020
#> GSM23180     5  0.4141      0.476 0.248 0.000 0.000 0.024 0.728
#> GSM23181     1  0.4109      0.614 0.700 0.000 0.000 0.012 0.288
#> GSM23182     5  0.5263      0.434 0.240 0.000 0.000 0.100 0.660
#> GSM23183     5  0.6135      0.638 0.004 0.000 0.236 0.180 0.580
#> GSM23184     3  0.0671      0.887 0.000 0.000 0.980 0.004 0.016
#> GSM23196     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0290      0.905 0.000 0.992 0.000 0.000 0.008
#> GSM23198     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.4774      0.749 0.000 0.424 0.000 0.556 0.020
#> GSM23200     2  0.4291     -0.569 0.000 0.536 0.000 0.464 0.000
#> GSM23201     4  0.5732      0.857 0.000 0.296 0.000 0.588 0.116
#> GSM23202     4  0.5384      0.859 0.004 0.288 0.000 0.632 0.076
#> GSM23203     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0290      0.905 0.000 0.992 0.000 0.000 0.008
#> GSM23205     4  0.5691      0.857 0.000 0.296 0.000 0.592 0.112
#> GSM23206     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23207     4  0.4299      0.802 0.000 0.388 0.000 0.608 0.004
#> GSM23208     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0290      0.905 0.000 0.992 0.000 0.000 0.008
#> GSM23210     4  0.5334      0.720 0.000 0.436 0.000 0.512 0.052
#> GSM23211     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.4249      0.869 0.000 0.296 0.000 0.688 0.016
#> GSM23213     4  0.4249      0.869 0.000 0.296 0.000 0.688 0.016
#> GSM23214     4  0.5218      0.865 0.000 0.296 0.000 0.632 0.072
#> GSM23215     2  0.2592      0.781 0.000 0.892 0.000 0.056 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.0000    0.92068 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.6209    0.11931 0.252 0.040 0.004 0.000 0.152 0.552
#> GSM23187     3  0.0000    0.92068 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000    0.92068 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000    0.92068 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000    0.92068 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.1398    0.47367 0.000 0.000 0.052 0.000 0.940 0.008
#> GSM23192     5  0.4435   -0.08217 0.000 0.004 0.028 0.000 0.604 0.364
#> GSM23193     5  0.1942    0.46653 0.000 0.008 0.064 0.000 0.916 0.012
#> GSM23194     3  0.5093    0.40167 0.000 0.004 0.644 0.000 0.204 0.148
#> GSM23195     6  0.4831    0.31580 0.000 0.000 0.060 0.000 0.392 0.548
#> GSM23159     1  0.1364    0.84145 0.952 0.012 0.000 0.000 0.020 0.016
#> GSM23160     3  0.2222    0.89008 0.000 0.040 0.908 0.000 0.012 0.040
#> GSM23161     1  0.2969    0.80254 0.860 0.020 0.000 0.000 0.088 0.032
#> GSM23162     5  0.4521    0.20536 0.000 0.016 0.292 0.000 0.660 0.032
#> GSM23163     1  0.4249    0.81217 0.776 0.048 0.000 0.000 0.060 0.116
#> GSM23164     1  0.2990    0.80365 0.860 0.020 0.000 0.000 0.084 0.036
#> GSM23165     1  0.3544    0.79992 0.800 0.080 0.000 0.000 0.000 0.120
#> GSM23166     1  0.2990    0.80365 0.860 0.020 0.000 0.000 0.084 0.036
#> GSM23167     1  0.3544    0.79992 0.800 0.080 0.000 0.000 0.000 0.120
#> GSM23168     3  0.2222    0.89008 0.000 0.040 0.908 0.000 0.012 0.040
#> GSM23169     5  0.6357   -0.28744 0.000 0.032 0.164 0.000 0.412 0.392
#> GSM23170     1  0.1458    0.84515 0.948 0.016 0.000 0.000 0.016 0.020
#> GSM23171     1  0.1572    0.84017 0.936 0.036 0.000 0.000 0.000 0.028
#> GSM23172     1  0.3544    0.79992 0.800 0.080 0.000 0.000 0.000 0.120
#> GSM23173     6  0.6864   -0.00692 0.000 0.044 0.328 0.000 0.300 0.328
#> GSM23174     1  0.1275    0.84022 0.956 0.012 0.000 0.000 0.016 0.016
#> GSM23175     1  0.1340    0.84221 0.948 0.040 0.000 0.000 0.004 0.008
#> GSM23176     1  0.3685    0.79983 0.796 0.080 0.000 0.000 0.004 0.120
#> GSM23177     1  0.1452    0.83890 0.948 0.012 0.000 0.000 0.020 0.020
#> GSM23178     1  0.3534    0.80170 0.800 0.076 0.000 0.000 0.000 0.124
#> GSM23179     3  0.2257    0.88782 0.000 0.040 0.904 0.000 0.008 0.048
#> GSM23180     5  0.4115    0.41161 0.132 0.020 0.000 0.004 0.780 0.064
#> GSM23181     1  0.5005    0.24698 0.540 0.020 0.000 0.000 0.404 0.036
#> GSM23182     5  0.5198    0.38291 0.124 0.020 0.000 0.036 0.716 0.104
#> GSM23183     6  0.4831    0.31580 0.000 0.000 0.060 0.000 0.392 0.548
#> GSM23184     3  0.0405    0.91868 0.000 0.004 0.988 0.000 0.000 0.008
#> GSM23196     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23197     2  0.2558    0.97011 0.000 0.840 0.000 0.156 0.000 0.004
#> GSM23198     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23199     4  0.3095    0.83035 0.000 0.052 0.000 0.856 0.020 0.072
#> GSM23200     4  0.3790    0.68329 0.000 0.184 0.000 0.772 0.020 0.024
#> GSM23201     4  0.3740    0.81124 0.000 0.008 0.000 0.728 0.012 0.252
#> GSM23202     4  0.2613    0.83611 0.000 0.000 0.000 0.848 0.012 0.140
#> GSM23203     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23204     2  0.2558    0.97011 0.000 0.840 0.000 0.156 0.000 0.004
#> GSM23205     4  0.3716    0.81312 0.000 0.008 0.000 0.732 0.012 0.248
#> GSM23206     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23207     4  0.2103    0.83823 0.000 0.040 0.000 0.916 0.020 0.024
#> GSM23208     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23209     2  0.2558    0.97011 0.000 0.840 0.000 0.156 0.000 0.004
#> GSM23210     4  0.3624    0.81880 0.000 0.060 0.000 0.812 0.016 0.112
#> GSM23211     2  0.2491    0.97477 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM23212     4  0.0000    0.85471 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0458    0.85524 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM23214     4  0.2613    0.83633 0.000 0.000 0.000 0.848 0.012 0.140
#> GSM23215     2  0.4653    0.79216 0.000 0.684 0.000 0.196 0.000 0.120

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 cell.type(p) disease.state(p) k
#> MAD:kmeans 57     3.90e-13         0.052490 2
#> MAD:kmeans 57     4.19e-13         0.000423 3
#> MAD:kmeans 56     4.20e-12         0.002783 4
#> MAD:kmeans 50     3.61e-10         0.000209 5
#> MAD:kmeans 44     1.51e-09         0.000558 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.997       0.998         0.4645 0.536   0.536
#> 3 3 1.000           0.997       0.999         0.4601 0.786   0.600
#> 4 4 0.843           0.893       0.930         0.0873 0.932   0.792
#> 5 5 0.790           0.773       0.865         0.0649 0.938   0.769
#> 6 6 0.744           0.714       0.820         0.0357 0.992   0.965

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
#> GSM23185     1  0.0672      0.994 0.992 0.008
#> GSM23186     1  0.0000      0.997 1.000 0.000
#> GSM23187     1  0.0672      0.994 0.992 0.008
#> GSM23188     1  0.0672      0.994 0.992 0.008
#> GSM23189     1  0.0672      0.994 0.992 0.008
#> GSM23190     1  0.0672      0.994 0.992 0.008
#> GSM23191     1  0.0000      0.997 1.000 0.000
#> GSM23192     1  0.0000      0.997 1.000 0.000
#> GSM23193     1  0.0000      0.997 1.000 0.000
#> GSM23194     1  0.0672      0.994 0.992 0.008
#> GSM23195     1  0.0000      0.997 1.000 0.000
#> GSM23159     1  0.0000      0.997 1.000 0.000
#> GSM23160     1  0.0672      0.994 0.992 0.008
#> GSM23161     1  0.0000      0.997 1.000 0.000
#> GSM23162     1  0.0672      0.994 0.992 0.008
#> GSM23163     1  0.0000      0.997 1.000 0.000
#> GSM23164     1  0.0000      0.997 1.000 0.000
#> GSM23165     1  0.0000      0.997 1.000 0.000
#> GSM23166     1  0.0000      0.997 1.000 0.000
#> GSM23167     1  0.0000      0.997 1.000 0.000
#> GSM23168     1  0.0672      0.994 0.992 0.008
#> GSM23169     1  0.0000      0.997 1.000 0.000
#> GSM23170     1  0.0000      0.997 1.000 0.000
#> GSM23171     1  0.0000      0.997 1.000 0.000
#> GSM23172     1  0.0000      0.997 1.000 0.000
#> GSM23173     1  0.0376      0.996 0.996 0.004
#> GSM23174     1  0.0000      0.997 1.000 0.000
#> GSM23175     1  0.0000      0.997 1.000 0.000
#> GSM23176     1  0.0000      0.997 1.000 0.000
#> GSM23177     1  0.0000      0.997 1.000 0.000
#> GSM23178     1  0.0000      0.997 1.000 0.000
#> GSM23179     1  0.0672      0.994 0.992 0.008
#> GSM23180     1  0.0000      0.997 1.000 0.000
#> GSM23181     1  0.0000      0.997 1.000 0.000
#> GSM23182     1  0.0000      0.997 1.000 0.000
#> GSM23183     1  0.0000      0.997 1.000 0.000
#> GSM23184     1  0.0672      0.994 0.992 0.008
#> GSM23196     2  0.0000      0.999 0.000 1.000
#> GSM23197     2  0.0000      0.999 0.000 1.000
#> GSM23198     2  0.0000      0.999 0.000 1.000
#> GSM23199     2  0.0000      0.999 0.000 1.000
#> GSM23200     2  0.0000      0.999 0.000 1.000
#> GSM23201     2  0.0000      0.999 0.000 1.000
#> GSM23202     2  0.0672      0.993 0.008 0.992
#> GSM23203     2  0.0000      0.999 0.000 1.000
#> GSM23204     2  0.0000      0.999 0.000 1.000
#> GSM23205     2  0.0000      0.999 0.000 1.000
#> GSM23206     2  0.0000      0.999 0.000 1.000
#> GSM23207     2  0.0000      0.999 0.000 1.000
#> GSM23208     2  0.0000      0.999 0.000 1.000
#> GSM23209     2  0.0000      0.999 0.000 1.000
#> GSM23210     2  0.0000      0.999 0.000 1.000
#> GSM23211     2  0.0000      0.999 0.000 1.000
#> GSM23212     2  0.0000      0.999 0.000 1.000
#> GSM23213     2  0.0672      0.993 0.008 0.992
#> GSM23214     2  0.0672      0.993 0.008 0.992
#> GSM23215     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
#> GSM23185     3  0.0000      0.998 0.000  0 1.000
#> GSM23186     1  0.1643      0.954 0.956  0 0.044
#> GSM23187     3  0.0000      0.998 0.000  0 1.000
#> GSM23188     3  0.0000      0.998 0.000  0 1.000
#> GSM23189     3  0.0000      0.998 0.000  0 1.000
#> GSM23190     3  0.0000      0.998 0.000  0 1.000
#> GSM23191     3  0.0000      0.998 0.000  0 1.000
#> GSM23192     3  0.0892      0.981 0.020  0 0.980
#> GSM23193     3  0.0237      0.995 0.004  0 0.996
#> GSM23194     3  0.0000      0.998 0.000  0 1.000
#> GSM23195     3  0.0237      0.995 0.004  0 0.996
#> GSM23159     1  0.0000      0.998 1.000  0 0.000
#> GSM23160     3  0.0000      0.998 0.000  0 1.000
#> GSM23161     1  0.0000      0.998 1.000  0 0.000
#> GSM23162     3  0.0000      0.998 0.000  0 1.000
#> GSM23163     1  0.0000      0.998 1.000  0 0.000
#> GSM23164     1  0.0000      0.998 1.000  0 0.000
#> GSM23165     1  0.0000      0.998 1.000  0 0.000
#> GSM23166     1  0.0000      0.998 1.000  0 0.000
#> GSM23167     1  0.0000      0.998 1.000  0 0.000
#> GSM23168     3  0.0000      0.998 0.000  0 1.000
#> GSM23169     3  0.0000      0.998 0.000  0 1.000
#> GSM23170     1  0.0000      0.998 1.000  0 0.000
#> GSM23171     1  0.0000      0.998 1.000  0 0.000
#> GSM23172     1  0.0000      0.998 1.000  0 0.000
#> GSM23173     3  0.0000      0.998 0.000  0 1.000
#> GSM23174     1  0.0000      0.998 1.000  0 0.000
#> GSM23175     1  0.0000      0.998 1.000  0 0.000
#> GSM23176     1  0.0000      0.998 1.000  0 0.000
#> GSM23177     1  0.0000      0.998 1.000  0 0.000
#> GSM23178     1  0.0000      0.998 1.000  0 0.000
#> GSM23179     3  0.0000      0.998 0.000  0 1.000
#> GSM23180     1  0.0000      0.998 1.000  0 0.000
#> GSM23181     1  0.0000      0.998 1.000  0 0.000
#> GSM23182     1  0.0000      0.998 1.000  0 0.000
#> GSM23183     3  0.0592      0.989 0.012  0 0.988
#> GSM23184     3  0.0000      0.998 0.000  0 1.000
#> GSM23196     2  0.0000      1.000 0.000  1 0.000
#> GSM23197     2  0.0000      1.000 0.000  1 0.000
#> GSM23198     2  0.0000      1.000 0.000  1 0.000
#> GSM23199     2  0.0000      1.000 0.000  1 0.000
#> GSM23200     2  0.0000      1.000 0.000  1 0.000
#> GSM23201     2  0.0000      1.000 0.000  1 0.000
#> GSM23202     2  0.0000      1.000 0.000  1 0.000
#> GSM23203     2  0.0000      1.000 0.000  1 0.000
#> GSM23204     2  0.0000      1.000 0.000  1 0.000
#> GSM23205     2  0.0000      1.000 0.000  1 0.000
#> GSM23206     2  0.0000      1.000 0.000  1 0.000
#> GSM23207     2  0.0000      1.000 0.000  1 0.000
#> GSM23208     2  0.0000      1.000 0.000  1 0.000
#> GSM23209     2  0.0000      1.000 0.000  1 0.000
#> GSM23210     2  0.0000      1.000 0.000  1 0.000
#> GSM23211     2  0.0000      1.000 0.000  1 0.000
#> GSM23212     2  0.0000      1.000 0.000  1 0.000
#> GSM23213     2  0.0000      1.000 0.000  1 0.000
#> GSM23214     2  0.0000      1.000 0.000  1 0.000
#> GSM23215     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
#> GSM23185     3  0.0336      0.940 0.000 0.000 0.992 0.008
#> GSM23186     1  0.3533      0.851 0.864 0.000 0.056 0.080
#> GSM23187     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23188     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23189     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23190     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23191     3  0.4307      0.808 0.024 0.000 0.784 0.192
#> GSM23192     3  0.5951      0.712 0.152 0.000 0.696 0.152
#> GSM23193     3  0.2796      0.891 0.016 0.000 0.892 0.092
#> GSM23194     3  0.0707      0.938 0.000 0.000 0.980 0.020
#> GSM23195     3  0.3687      0.868 0.064 0.000 0.856 0.080
#> GSM23159     1  0.0469      0.956 0.988 0.000 0.000 0.012
#> GSM23160     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1211      0.943 0.960 0.000 0.000 0.040
#> GSM23162     3  0.0707      0.936 0.000 0.000 0.980 0.020
#> GSM23163     1  0.0817      0.952 0.976 0.000 0.000 0.024
#> GSM23164     1  0.0469      0.956 0.988 0.000 0.000 0.012
#> GSM23165     1  0.0336      0.956 0.992 0.000 0.000 0.008
#> GSM23166     1  0.0817      0.951 0.976 0.000 0.000 0.024
#> GSM23167     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM23169     3  0.1211      0.931 0.000 0.000 0.960 0.040
#> GSM23170     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23173     3  0.0817      0.935 0.000 0.000 0.976 0.024
#> GSM23174     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23176     1  0.0336      0.956 0.992 0.000 0.000 0.008
#> GSM23177     1  0.0000      0.958 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0188      0.958 0.996 0.000 0.000 0.004
#> GSM23179     3  0.0000      0.940 0.000 0.000 1.000 0.000
#> GSM23180     1  0.4776      0.483 0.624 0.000 0.000 0.376
#> GSM23181     1  0.2345      0.895 0.900 0.000 0.000 0.100
#> GSM23182     4  0.4817      0.139 0.388 0.000 0.000 0.612
#> GSM23183     3  0.5204      0.755 0.160 0.000 0.752 0.088
#> GSM23184     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23196     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23199     2  0.2408      0.870 0.000 0.896 0.000 0.104
#> GSM23200     2  0.1474      0.922 0.000 0.948 0.000 0.052
#> GSM23201     4  0.3569      0.856 0.000 0.196 0.000 0.804
#> GSM23202     4  0.3444      0.863 0.000 0.184 0.000 0.816
#> GSM23203     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23205     4  0.4250      0.758 0.000 0.276 0.000 0.724
#> GSM23206     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23207     2  0.4134      0.605 0.000 0.740 0.000 0.260
#> GSM23208     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23210     2  0.1637      0.915 0.000 0.940 0.000 0.060
#> GSM23211     2  0.0000      0.956 0.000 1.000 0.000 0.000
#> GSM23212     4  0.3444      0.863 0.000 0.184 0.000 0.816
#> GSM23213     4  0.3400      0.861 0.000 0.180 0.000 0.820
#> GSM23214     4  0.3444      0.863 0.000 0.184 0.000 0.816
#> GSM23215     2  0.0188      0.954 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.1124     0.8907 0.000 0.000 0.960 0.004 0.036
#> GSM23186     1  0.5355     0.3605 0.588 0.000 0.040 0.012 0.360
#> GSM23187     3  0.0865     0.8910 0.000 0.000 0.972 0.004 0.024
#> GSM23188     3  0.1205     0.8840 0.000 0.000 0.956 0.004 0.040
#> GSM23189     3  0.0771     0.8899 0.000 0.000 0.976 0.004 0.020
#> GSM23190     3  0.0955     0.8903 0.000 0.000 0.968 0.004 0.028
#> GSM23191     5  0.5637     0.3802 0.024 0.000 0.312 0.052 0.612
#> GSM23192     5  0.4333     0.4615 0.048 0.000 0.212 0.000 0.740
#> GSM23193     5  0.5173     0.0928 0.012 0.000 0.460 0.020 0.508
#> GSM23194     3  0.3003     0.7541 0.000 0.000 0.812 0.000 0.188
#> GSM23195     5  0.5718     0.2244 0.068 0.000 0.380 0.008 0.544
#> GSM23159     1  0.1809     0.8933 0.928 0.000 0.000 0.012 0.060
#> GSM23160     3  0.0290     0.8884 0.000 0.000 0.992 0.000 0.008
#> GSM23161     1  0.2338     0.8705 0.884 0.000 0.000 0.004 0.112
#> GSM23162     3  0.3274     0.6791 0.000 0.000 0.780 0.000 0.220
#> GSM23163     1  0.2464     0.8773 0.888 0.000 0.000 0.016 0.096
#> GSM23164     1  0.2513     0.8632 0.876 0.000 0.000 0.008 0.116
#> GSM23165     1  0.1568     0.8838 0.944 0.000 0.000 0.020 0.036
#> GSM23166     1  0.2439     0.8650 0.876 0.000 0.000 0.004 0.120
#> GSM23167     1  0.1386     0.8877 0.952 0.000 0.000 0.016 0.032
#> GSM23168     3  0.1697     0.8666 0.000 0.000 0.932 0.008 0.060
#> GSM23169     3  0.3635     0.6380 0.000 0.000 0.748 0.004 0.248
#> GSM23170     1  0.0794     0.8963 0.972 0.000 0.000 0.000 0.028
#> GSM23171     1  0.1364     0.8958 0.952 0.000 0.000 0.012 0.036
#> GSM23172     1  0.1399     0.8856 0.952 0.000 0.000 0.020 0.028
#> GSM23173     3  0.3080     0.7904 0.008 0.000 0.844 0.008 0.140
#> GSM23174     1  0.1741     0.8931 0.936 0.000 0.000 0.024 0.040
#> GSM23175     1  0.1648     0.8923 0.940 0.000 0.000 0.020 0.040
#> GSM23176     1  0.1195     0.8889 0.960 0.000 0.000 0.012 0.028
#> GSM23177     1  0.1341     0.8921 0.944 0.000 0.000 0.000 0.056
#> GSM23178     1  0.1981     0.8926 0.920 0.000 0.000 0.016 0.064
#> GSM23179     3  0.0963     0.8837 0.000 0.000 0.964 0.000 0.036
#> GSM23180     5  0.6175     0.1625 0.332 0.000 0.000 0.152 0.516
#> GSM23181     1  0.4822     0.5833 0.664 0.000 0.000 0.048 0.288
#> GSM23182     5  0.6818     0.1146 0.328 0.000 0.000 0.316 0.356
#> GSM23183     5  0.5735     0.2965 0.076 0.000 0.348 0.008 0.568
#> GSM23184     3  0.1041     0.8837 0.000 0.000 0.964 0.004 0.032
#> GSM23196     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.3395     0.6998 0.000 0.764 0.000 0.236 0.000
#> GSM23200     2  0.2471     0.8243 0.000 0.864 0.000 0.136 0.000
#> GSM23201     4  0.2612     0.8941 0.000 0.124 0.000 0.868 0.008
#> GSM23202     4  0.1571     0.9245 0.004 0.060 0.000 0.936 0.000
#> GSM23203     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.3508     0.7400 0.000 0.252 0.000 0.748 0.000
#> GSM23206     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4101     0.4113 0.000 0.628 0.000 0.372 0.000
#> GSM23208     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.2732     0.7936 0.000 0.840 0.000 0.160 0.000
#> GSM23211     2  0.0000     0.9201 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.1608     0.9264 0.000 0.072 0.000 0.928 0.000
#> GSM23213     4  0.1410     0.9249 0.000 0.060 0.000 0.940 0.000
#> GSM23214     4  0.1478     0.9271 0.000 0.064 0.000 0.936 0.000
#> GSM23215     2  0.0703     0.9069 0.000 0.976 0.000 0.024 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
#> GSM23185     3  0.1542   0.800340 0.000 0.000 0.936 0.004 0.008 0.052
#> GSM23186     1  0.6116   0.161604 0.476 0.000 0.040 0.008 0.084 0.392
#> GSM23187     3  0.0713   0.802738 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM23188     3  0.1387   0.793677 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM23189     3  0.0858   0.803754 0.000 0.000 0.968 0.004 0.000 0.028
#> GSM23190     3  0.1219   0.802993 0.000 0.000 0.948 0.000 0.004 0.048
#> GSM23191     5  0.5701   0.159475 0.016 0.000 0.164 0.012 0.624 0.184
#> GSM23192     6  0.6231   0.419520 0.036 0.000 0.144 0.004 0.288 0.528
#> GSM23193     5  0.6101  -0.000514 0.016 0.000 0.304 0.008 0.520 0.152
#> GSM23194     3  0.3695   0.669449 0.000 0.000 0.776 0.000 0.060 0.164
#> GSM23195     6  0.5246   0.661871 0.044 0.000 0.240 0.004 0.056 0.656
#> GSM23159     1  0.3608   0.785665 0.800 0.000 0.000 0.004 0.128 0.068
#> GSM23160     3  0.2291   0.801140 0.000 0.000 0.904 0.012 0.040 0.044
#> GSM23161     1  0.4015   0.752440 0.744 0.000 0.000 0.012 0.208 0.036
#> GSM23162     3  0.5170   0.409049 0.000 0.000 0.596 0.004 0.296 0.104
#> GSM23163     1  0.3427   0.792353 0.824 0.000 0.000 0.008 0.088 0.080
#> GSM23164     1  0.3702   0.770003 0.760 0.000 0.000 0.008 0.208 0.024
#> GSM23165     1  0.2145   0.778019 0.900 0.000 0.000 0.000 0.028 0.072
#> GSM23166     1  0.3936   0.750910 0.736 0.000 0.000 0.012 0.228 0.024
#> GSM23167     1  0.2325   0.796886 0.892 0.000 0.000 0.000 0.060 0.048
#> GSM23168     3  0.3210   0.780857 0.000 0.000 0.844 0.012 0.072 0.072
#> GSM23169     3  0.5707   0.327297 0.004 0.000 0.544 0.008 0.132 0.312
#> GSM23170     1  0.2255   0.811972 0.892 0.000 0.000 0.004 0.088 0.016
#> GSM23171     1  0.2146   0.812309 0.908 0.000 0.000 0.008 0.060 0.024
#> GSM23172     1  0.1649   0.795269 0.932 0.000 0.000 0.000 0.032 0.036
#> GSM23173     3  0.5000   0.535318 0.004 0.000 0.652 0.004 0.100 0.240
#> GSM23174     1  0.2961   0.799494 0.840 0.000 0.000 0.008 0.132 0.020
#> GSM23175     1  0.3150   0.802494 0.840 0.000 0.000 0.012 0.112 0.036
#> GSM23176     1  0.2307   0.783962 0.896 0.000 0.000 0.004 0.032 0.068
#> GSM23177     1  0.3125   0.796833 0.828 0.000 0.000 0.004 0.136 0.032
#> GSM23178     1  0.2837   0.789468 0.856 0.000 0.000 0.000 0.088 0.056
#> GSM23179     3  0.2821   0.784237 0.000 0.000 0.860 0.004 0.040 0.096
#> GSM23180     5  0.5241   0.337984 0.224 0.000 0.000 0.052 0.660 0.064
#> GSM23181     1  0.5344   0.335709 0.520 0.000 0.000 0.024 0.400 0.056
#> GSM23182     5  0.6133   0.323620 0.204 0.000 0.000 0.188 0.564 0.044
#> GSM23183     6  0.5327   0.678300 0.060 0.000 0.220 0.000 0.064 0.656
#> GSM23184     3  0.1845   0.801313 0.000 0.000 0.920 0.000 0.028 0.052
#> GSM23196     2  0.0291   0.904928 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM23197     2  0.0146   0.904988 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23198     2  0.0405   0.905604 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM23199     2  0.4561   0.578754 0.000 0.676 0.000 0.268 0.024 0.032
#> GSM23200     2  0.3159   0.786211 0.000 0.820 0.000 0.152 0.008 0.020
#> GSM23201     4  0.4007   0.821678 0.000 0.108 0.000 0.792 0.068 0.032
#> GSM23202     4  0.1693   0.887355 0.000 0.032 0.000 0.936 0.020 0.012
#> GSM23203     2  0.0291   0.905368 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM23204     2  0.0260   0.904450 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM23205     4  0.4570   0.709463 0.000 0.216 0.000 0.708 0.052 0.024
#> GSM23206     2  0.0436   0.905366 0.000 0.988 0.000 0.004 0.004 0.004
#> GSM23207     2  0.4510   0.379372 0.000 0.588 0.000 0.380 0.008 0.024
#> GSM23208     2  0.0146   0.905450 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23209     2  0.0260   0.904450 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM23210     2  0.3154   0.805002 0.000 0.836 0.000 0.124 0.020 0.020
#> GSM23211     2  0.0260   0.904464 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM23212     4  0.1464   0.890031 0.000 0.036 0.000 0.944 0.004 0.016
#> GSM23213     4  0.1245   0.890901 0.000 0.032 0.000 0.952 0.000 0.016
#> GSM23214     4  0.1080   0.891855 0.000 0.032 0.000 0.960 0.004 0.004
#> GSM23215     2  0.1605   0.881287 0.000 0.940 0.000 0.032 0.016 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 cell.type(p) disease.state(p) k
#> MAD:skmeans 57     3.90e-13         0.052490 2
#> MAD:skmeans 57     4.19e-13         0.000423 3
#> MAD:skmeans 55     6.87e-12         0.000192 4
#> MAD:skmeans 48     2.13e-10         0.000771 5
#> MAD:skmeans 47     1.52e-09         0.000244 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.622           0.755       0.904         0.4954 0.491   0.491
#> 3 3 0.927           0.918       0.967         0.3631 0.742   0.520
#> 4 4 0.890           0.910       0.944         0.0892 0.934   0.798
#> 5 5 0.872           0.834       0.914         0.0550 0.961   0.853
#> 6 6 0.843           0.776       0.871         0.0356 0.969   0.869

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
#> GSM23185     2  0.8386    0.65274 0.268 0.732
#> GSM23186     1  0.0000    0.91945 1.000 0.000
#> GSM23187     2  0.9170    0.57469 0.332 0.668
#> GSM23188     2  0.7219    0.71615 0.200 0.800
#> GSM23189     2  0.9044    0.59136 0.320 0.680
#> GSM23190     2  0.9129    0.58076 0.328 0.672
#> GSM23191     1  0.0000    0.91945 1.000 0.000
#> GSM23192     1  0.0000    0.91945 1.000 0.000
#> GSM23193     1  0.0000    0.91945 1.000 0.000
#> GSM23194     2  0.9522    0.50670 0.372 0.628
#> GSM23195     2  0.9522    0.50670 0.372 0.628
#> GSM23159     1  0.0000    0.91945 1.000 0.000
#> GSM23160     2  0.9954    0.29285 0.460 0.540
#> GSM23161     1  0.0000    0.91945 1.000 0.000
#> GSM23162     1  0.0672    0.91148 0.992 0.008
#> GSM23163     1  0.0000    0.91945 1.000 0.000
#> GSM23164     1  0.0000    0.91945 1.000 0.000
#> GSM23165     1  0.0000    0.91945 1.000 0.000
#> GSM23166     1  0.0000    0.91945 1.000 0.000
#> GSM23167     1  0.0000    0.91945 1.000 0.000
#> GSM23168     1  1.0000   -0.21761 0.500 0.500
#> GSM23169     1  0.0000    0.91945 1.000 0.000
#> GSM23170     1  0.0000    0.91945 1.000 0.000
#> GSM23171     1  0.0000    0.91945 1.000 0.000
#> GSM23172     1  0.0000    0.91945 1.000 0.000
#> GSM23173     1  0.9944   -0.06656 0.544 0.456
#> GSM23174     1  0.0000    0.91945 1.000 0.000
#> GSM23175     1  0.0000    0.91945 1.000 0.000
#> GSM23176     1  0.0000    0.91945 1.000 0.000
#> GSM23177     1  0.0000    0.91945 1.000 0.000
#> GSM23178     1  0.0000    0.91945 1.000 0.000
#> GSM23179     2  0.9710    0.44751 0.400 0.600
#> GSM23180     1  0.0000    0.91945 1.000 0.000
#> GSM23181     1  0.0000    0.91945 1.000 0.000
#> GSM23182     1  0.0000    0.91945 1.000 0.000
#> GSM23183     1  0.0000    0.91945 1.000 0.000
#> GSM23184     1  0.9896    0.00266 0.560 0.440
#> GSM23196     2  0.0000    0.83897 0.000 1.000
#> GSM23197     2  0.0000    0.83897 0.000 1.000
#> GSM23198     2  0.0000    0.83897 0.000 1.000
#> GSM23199     2  0.0000    0.83897 0.000 1.000
#> GSM23200     2  0.0000    0.83897 0.000 1.000
#> GSM23201     2  0.0000    0.83897 0.000 1.000
#> GSM23202     1  0.9661    0.27825 0.608 0.392
#> GSM23203     2  0.0000    0.83897 0.000 1.000
#> GSM23204     2  0.0000    0.83897 0.000 1.000
#> GSM23205     2  0.0000    0.83897 0.000 1.000
#> GSM23206     2  0.0000    0.83897 0.000 1.000
#> GSM23207     2  0.0000    0.83897 0.000 1.000
#> GSM23208     2  0.0000    0.83897 0.000 1.000
#> GSM23209     2  0.0000    0.83897 0.000 1.000
#> GSM23210     2  0.0000    0.83897 0.000 1.000
#> GSM23211     2  0.0000    0.83897 0.000 1.000
#> GSM23212     2  0.0000    0.83897 0.000 1.000
#> GSM23213     2  0.8144    0.58001 0.252 0.748
#> GSM23214     2  0.9491    0.35885 0.368 0.632
#> GSM23215     2  0.0000    0.83897 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
#> GSM23185     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23186     1  0.6204      0.262 0.576 0.000 0.424
#> GSM23187     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23191     1  0.4346      0.752 0.816 0.000 0.184
#> GSM23192     3  0.4062      0.795 0.164 0.000 0.836
#> GSM23193     3  0.2165      0.926 0.064 0.000 0.936
#> GSM23194     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23195     3  0.0661      0.977 0.008 0.004 0.988
#> GSM23159     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23160     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23161     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23162     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23163     1  0.0237      0.946 0.996 0.000 0.004
#> GSM23164     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23169     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23170     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23173     3  0.0424      0.979 0.008 0.000 0.992
#> GSM23174     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23180     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23181     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23182     1  0.0000      0.949 1.000 0.000 0.000
#> GSM23183     3  0.0237      0.981 0.004 0.000 0.996
#> GSM23184     3  0.0000      0.983 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23201     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23202     1  0.5905      0.416 0.648 0.352 0.000
#> GSM23203     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23205     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23206     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23212     2  0.0000      0.962 0.000 1.000 0.000
#> GSM23213     2  0.5397      0.603 0.280 0.720 0.000
#> GSM23214     2  0.5988      0.415 0.368 0.632 0.000
#> GSM23215     2  0.0000      0.962 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
#> GSM23185     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23186     1  0.5268      0.343 0.592 0.000 0.396 0.012
#> GSM23187     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23191     1  0.6204      0.628 0.672 0.000 0.164 0.164
#> GSM23192     3  0.4849      0.735 0.164 0.000 0.772 0.064
#> GSM23193     3  0.4297      0.820 0.084 0.000 0.820 0.096
#> GSM23194     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23195     3  0.0712      0.956 0.008 0.004 0.984 0.004
#> GSM23159     1  0.1792      0.917 0.932 0.000 0.000 0.068
#> GSM23160     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1557      0.917 0.944 0.000 0.000 0.056
#> GSM23162     3  0.1854      0.932 0.012 0.000 0.940 0.048
#> GSM23163     1  0.1022      0.923 0.968 0.000 0.000 0.032
#> GSM23164     1  0.0817      0.924 0.976 0.000 0.000 0.024
#> GSM23165     1  0.1118      0.924 0.964 0.000 0.000 0.036
#> GSM23166     1  0.1302      0.922 0.956 0.000 0.000 0.044
#> GSM23167     1  0.0921      0.924 0.972 0.000 0.000 0.028
#> GSM23168     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23169     3  0.1022      0.950 0.000 0.000 0.968 0.032
#> GSM23170     1  0.0336      0.927 0.992 0.000 0.000 0.008
#> GSM23171     1  0.1022      0.926 0.968 0.000 0.000 0.032
#> GSM23172     1  0.1118      0.924 0.964 0.000 0.000 0.036
#> GSM23173     3  0.1767      0.929 0.044 0.000 0.944 0.012
#> GSM23174     1  0.1637      0.920 0.940 0.000 0.000 0.060
#> GSM23175     1  0.1118      0.923 0.964 0.000 0.000 0.036
#> GSM23176     1  0.0921      0.923 0.972 0.000 0.000 0.028
#> GSM23177     1  0.1022      0.923 0.968 0.000 0.000 0.032
#> GSM23178     1  0.1118      0.924 0.964 0.000 0.000 0.036
#> GSM23179     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23180     1  0.2011      0.900 0.920 0.000 0.000 0.080
#> GSM23181     1  0.2011      0.904 0.920 0.000 0.000 0.080
#> GSM23182     4  0.2345      0.771 0.100 0.000 0.000 0.900
#> GSM23183     3  0.0779      0.956 0.004 0.000 0.980 0.016
#> GSM23184     3  0.0000      0.963 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23200     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23201     4  0.3074      0.929 0.000 0.152 0.000 0.848
#> GSM23202     4  0.2814      0.946 0.000 0.132 0.000 0.868
#> GSM23203     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23205     2  0.4697      0.317 0.000 0.644 0.000 0.356
#> GSM23206     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0469      0.958 0.000 0.988 0.000 0.012
#> GSM23208     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23211     2  0.0000      0.969 0.000 1.000 0.000 0.000
#> GSM23212     4  0.2814      0.946 0.000 0.132 0.000 0.868
#> GSM23213     4  0.2814      0.946 0.000 0.132 0.000 0.868
#> GSM23214     4  0.2760      0.944 0.000 0.128 0.000 0.872
#> GSM23215     2  0.0000      0.969 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
#> GSM23185     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.5142      0.232 0.564 0.000 0.392 0.000 0.044
#> GSM23187     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23191     5  0.3880      0.656 0.044 0.000 0.152 0.004 0.800
#> GSM23192     5  0.3932      0.399 0.000 0.000 0.328 0.000 0.672
#> GSM23193     5  0.3398      0.706 0.004 0.000 0.216 0.000 0.780
#> GSM23194     3  0.0290      0.894 0.000 0.000 0.992 0.000 0.008
#> GSM23195     3  0.3300      0.698 0.004 0.000 0.792 0.000 0.204
#> GSM23159     1  0.1341      0.875 0.944 0.000 0.000 0.000 0.056
#> GSM23160     3  0.0162      0.897 0.000 0.000 0.996 0.000 0.004
#> GSM23161     1  0.2561      0.867 0.856 0.000 0.000 0.000 0.144
#> GSM23162     5  0.4219      0.537 0.000 0.000 0.416 0.000 0.584
#> GSM23163     1  0.2179      0.879 0.896 0.000 0.000 0.004 0.100
#> GSM23164     1  0.1965      0.881 0.904 0.000 0.000 0.000 0.096
#> GSM23165     1  0.0324      0.890 0.992 0.000 0.000 0.004 0.004
#> GSM23166     1  0.2389      0.876 0.880 0.000 0.000 0.004 0.116
#> GSM23167     1  0.0000      0.890 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.0703      0.880 0.000 0.000 0.976 0.000 0.024
#> GSM23169     3  0.2612      0.756 0.008 0.000 0.868 0.000 0.124
#> GSM23170     1  0.0880      0.893 0.968 0.000 0.000 0.000 0.032
#> GSM23171     1  0.0609      0.893 0.980 0.000 0.000 0.000 0.020
#> GSM23172     1  0.0324      0.890 0.992 0.000 0.000 0.004 0.004
#> GSM23173     3  0.4583      0.626 0.064 0.000 0.740 0.004 0.192
#> GSM23174     1  0.1341      0.879 0.944 0.000 0.000 0.000 0.056
#> GSM23175     1  0.0404      0.889 0.988 0.000 0.000 0.000 0.012
#> GSM23176     1  0.2124      0.880 0.900 0.000 0.000 0.004 0.096
#> GSM23177     1  0.2124      0.882 0.900 0.000 0.000 0.004 0.096
#> GSM23178     1  0.0451      0.891 0.988 0.000 0.000 0.004 0.008
#> GSM23179     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23180     1  0.4101      0.524 0.628 0.000 0.000 0.000 0.372
#> GSM23181     1  0.3074      0.769 0.804 0.000 0.000 0.000 0.196
#> GSM23182     4  0.5404      0.506 0.100 0.000 0.000 0.636 0.264
#> GSM23183     3  0.4009      0.522 0.004 0.000 0.684 0.000 0.312
#> GSM23184     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM23196     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.0162      0.965 0.000 0.996 0.000 0.004 0.000
#> GSM23200     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.1270      0.868 0.000 0.052 0.000 0.948 0.000
#> GSM23202     4  0.0162      0.910 0.000 0.004 0.000 0.996 0.000
#> GSM23203     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23205     2  0.4088      0.395 0.000 0.632 0.000 0.368 0.000
#> GSM23206     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.1197      0.927 0.000 0.952 0.000 0.048 0.000
#> GSM23208     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000      0.968 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0162      0.910 0.000 0.004 0.000 0.996 0.000
#> GSM23213     4  0.0162      0.910 0.000 0.004 0.000 0.996 0.000
#> GSM23214     4  0.0162      0.910 0.000 0.004 0.000 0.996 0.000
#> GSM23215     2  0.0000      0.968 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
#> GSM23185     3  0.0000     0.8569 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.6215    -0.0732 0.356 0.000 0.236 0.000 0.008 0.400
#> GSM23187     3  0.0000     0.8569 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.8569 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.8569 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0146     0.8558 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM23191     5  0.0881     0.8381 0.008 0.000 0.008 0.000 0.972 0.012
#> GSM23192     6  0.5844     0.1820 0.000 0.000 0.216 0.000 0.308 0.476
#> GSM23193     5  0.0837     0.8532 0.004 0.000 0.020 0.000 0.972 0.004
#> GSM23194     3  0.0000     0.8569 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23195     3  0.4189    -0.2418 0.004 0.000 0.552 0.000 0.008 0.436
#> GSM23159     1  0.1176     0.8376 0.956 0.000 0.000 0.000 0.020 0.024
#> GSM23160     3  0.2531     0.7543 0.000 0.000 0.856 0.000 0.012 0.132
#> GSM23161     1  0.2384     0.8322 0.884 0.000 0.000 0.000 0.032 0.084
#> GSM23162     5  0.3655     0.7120 0.004 0.000 0.108 0.000 0.800 0.088
#> GSM23163     1  0.3791     0.8189 0.732 0.000 0.000 0.000 0.032 0.236
#> GSM23164     1  0.2487     0.8382 0.876 0.000 0.000 0.000 0.032 0.092
#> GSM23165     1  0.3221     0.7964 0.736 0.000 0.000 0.000 0.000 0.264
#> GSM23166     1  0.2752     0.8388 0.856 0.000 0.000 0.000 0.036 0.108
#> GSM23167     1  0.2664     0.8283 0.816 0.000 0.000 0.000 0.000 0.184
#> GSM23168     3  0.2831     0.7379 0.000 0.000 0.840 0.000 0.024 0.136
#> GSM23169     3  0.4159     0.6038 0.000 0.000 0.744 0.000 0.116 0.140
#> GSM23170     1  0.3014     0.8342 0.804 0.000 0.000 0.000 0.012 0.184
#> GSM23171     1  0.1219     0.8492 0.948 0.000 0.000 0.000 0.004 0.048
#> GSM23172     1  0.2697     0.8363 0.812 0.000 0.000 0.000 0.000 0.188
#> GSM23173     6  0.4925     0.0261 0.024 0.000 0.436 0.000 0.024 0.516
#> GSM23174     1  0.0692     0.8391 0.976 0.000 0.000 0.000 0.004 0.020
#> GSM23175     1  0.1219     0.8475 0.948 0.000 0.000 0.000 0.004 0.048
#> GSM23176     1  0.4170     0.7822 0.660 0.000 0.000 0.000 0.032 0.308
#> GSM23177     1  0.2740     0.8408 0.852 0.000 0.000 0.000 0.028 0.120
#> GSM23178     1  0.3266     0.7978 0.728 0.000 0.000 0.000 0.000 0.272
#> GSM23179     3  0.0914     0.8454 0.000 0.000 0.968 0.000 0.016 0.016
#> GSM23180     1  0.3898     0.5739 0.684 0.000 0.000 0.000 0.296 0.020
#> GSM23181     1  0.2572     0.7691 0.852 0.000 0.000 0.000 0.136 0.012
#> GSM23182     4  0.5031     0.5563 0.088 0.000 0.000 0.672 0.216 0.024
#> GSM23183     6  0.4837     0.2647 0.000 0.000 0.432 0.000 0.056 0.512
#> GSM23184     3  0.0777     0.8480 0.000 0.000 0.972 0.000 0.004 0.024
#> GSM23196     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.0146     0.9641 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23200     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.1075     0.8707 0.000 0.048 0.000 0.952 0.000 0.000
#> GSM23202     4  0.0000     0.9154 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     2  0.3672     0.3969 0.000 0.632 0.000 0.368 0.000 0.000
#> GSM23206     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.1075     0.9246 0.000 0.952 0.000 0.048 0.000 0.000
#> GSM23208     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23211     2  0.0000     0.9671 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9154 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000     0.9154 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000     0.9154 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000     0.9671 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-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 cell.type(p) disease.state(p) k
#> MAD:pam 50     5.48e-07         6.47e-01 2
#> MAD:pam 54     1.88e-12         1.25e-03 3
#> MAD:pam 55     4.19e-11         1.34e-04 4
#> MAD:pam 54     3.06e-10         1.33e-04 5
#> MAD:pam 51     1.24e-09         9.48e-05 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 11993 rows and 57 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 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-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           1.000       1.000         0.4642 0.536   0.536
#> 3 3 0.935           0.963       0.979         0.4536 0.787   0.603
#> 4 4 0.779           0.793       0.903         0.0876 0.943   0.824
#> 5 5 0.774           0.720       0.858         0.0788 0.902   0.653
#> 6 6 0.818           0.713       0.830         0.0517 0.919   0.630

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
#> GSM23185     1       0          1  1  0
#> GSM23186     1       0          1  1  0
#> GSM23187     1       0          1  1  0
#> GSM23188     1       0          1  1  0
#> GSM23189     1       0          1  1  0
#> GSM23190     1       0          1  1  0
#> GSM23191     1       0          1  1  0
#> GSM23192     1       0          1  1  0
#> GSM23193     1       0          1  1  0
#> GSM23194     1       0          1  1  0
#> GSM23195     1       0          1  1  0
#> GSM23159     1       0          1  1  0
#> GSM23160     1       0          1  1  0
#> GSM23161     1       0          1  1  0
#> GSM23162     1       0          1  1  0
#> GSM23163     1       0          1  1  0
#> GSM23164     1       0          1  1  0
#> GSM23165     1       0          1  1  0
#> GSM23166     1       0          1  1  0
#> GSM23167     1       0          1  1  0
#> GSM23168     1       0          1  1  0
#> GSM23169     1       0          1  1  0
#> GSM23170     1       0          1  1  0
#> GSM23171     1       0          1  1  0
#> GSM23172     1       0          1  1  0
#> GSM23173     1       0          1  1  0
#> GSM23174     1       0          1  1  0
#> GSM23175     1       0          1  1  0
#> GSM23176     1       0          1  1  0
#> GSM23177     1       0          1  1  0
#> GSM23178     1       0          1  1  0
#> GSM23179     1       0          1  1  0
#> GSM23180     1       0          1  1  0
#> GSM23181     1       0          1  1  0
#> GSM23182     1       0          1  1  0
#> GSM23183     1       0          1  1  0
#> GSM23184     1       0          1  1  0
#> GSM23196     2       0          1  0  1
#> GSM23197     2       0          1  0  1
#> GSM23198     2       0          1  0  1
#> GSM23199     2       0          1  0  1
#> GSM23200     2       0          1  0  1
#> GSM23201     2       0          1  0  1
#> GSM23202     2       0          1  0  1
#> GSM23203     2       0          1  0  1
#> GSM23204     2       0          1  0  1
#> GSM23205     2       0          1  0  1
#> GSM23206     2       0          1  0  1
#> GSM23207     2       0          1  0  1
#> GSM23208     2       0          1  0  1
#> GSM23209     2       0          1  0  1
#> GSM23210     2       0          1  0  1
#> GSM23211     2       0          1  0  1
#> GSM23212     2       0          1  0  1
#> GSM23213     2       0          1  0  1
#> GSM23214     2       0          1  0  1
#> GSM23215     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23186     1  0.5465      0.651 0.712 0.000 0.288
#> GSM23187     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23188     3  0.0237      0.976 0.004 0.000 0.996
#> GSM23189     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23191     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23192     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23193     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23194     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23195     3  0.1860      0.939 0.052 0.000 0.948
#> GSM23159     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23160     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23161     1  0.0237      0.956 0.996 0.000 0.004
#> GSM23162     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23163     1  0.3619      0.858 0.864 0.000 0.136
#> GSM23164     1  0.0237      0.956 0.996 0.000 0.004
#> GSM23165     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23166     1  0.0237      0.956 0.996 0.000 0.004
#> GSM23167     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23168     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23169     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23170     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23171     1  0.0747      0.955 0.984 0.000 0.016
#> GSM23172     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23173     3  0.0747      0.968 0.016 0.000 0.984
#> GSM23174     1  0.1860      0.934 0.948 0.000 0.052
#> GSM23175     1  0.1289      0.946 0.968 0.000 0.032
#> GSM23176     1  0.0592      0.957 0.988 0.000 0.012
#> GSM23177     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23178     1  0.0424      0.958 0.992 0.000 0.008
#> GSM23179     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23180     3  0.3551      0.857 0.132 0.000 0.868
#> GSM23181     1  0.4121      0.808 0.832 0.000 0.168
#> GSM23182     3  0.3551      0.857 0.132 0.000 0.868
#> GSM23183     3  0.1860      0.939 0.052 0.000 0.948
#> GSM23184     3  0.0000      0.978 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23201     2  0.0237      0.997 0.004 0.996 0.000
#> GSM23202     2  0.0237      0.997 0.004 0.996 0.000
#> GSM23203     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23205     2  0.0237      0.997 0.004 0.996 0.000
#> GSM23206     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.999 0.000 1.000 0.000
#> GSM23212     2  0.0237      0.997 0.004 0.996 0.000
#> GSM23213     2  0.0424      0.995 0.008 0.992 0.000
#> GSM23214     2  0.0424      0.995 0.008 0.992 0.000
#> GSM23215     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
#> GSM23185     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23186     1  0.5058     0.7561 0.768 0.000 0.128 0.104
#> GSM23187     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0188     0.8780 0.000 0.000 0.996 0.004
#> GSM23189     3  0.0188     0.8780 0.000 0.000 0.996 0.004
#> GSM23190     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23191     3  0.2546     0.8440 0.092 0.000 0.900 0.008
#> GSM23192     3  0.2796     0.8412 0.092 0.000 0.892 0.016
#> GSM23193     3  0.1042     0.8751 0.020 0.000 0.972 0.008
#> GSM23194     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23195     3  0.6373     0.6113 0.248 0.000 0.636 0.116
#> GSM23159     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0469     0.8766 0.000 0.000 0.988 0.012
#> GSM23161     1  0.0188     0.9634 0.996 0.000 0.000 0.004
#> GSM23162     3  0.0672     0.8770 0.008 0.000 0.984 0.008
#> GSM23163     1  0.2943     0.9071 0.892 0.000 0.032 0.076
#> GSM23164     1  0.0188     0.9634 0.996 0.000 0.000 0.004
#> GSM23165     1  0.2281     0.9181 0.904 0.000 0.000 0.096
#> GSM23166     1  0.0188     0.9634 0.996 0.000 0.000 0.004
#> GSM23167     1  0.0469     0.9609 0.988 0.000 0.000 0.012
#> GSM23168     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23169     3  0.1629     0.8697 0.024 0.000 0.952 0.024
#> GSM23170     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23172     1  0.1716     0.9371 0.936 0.000 0.000 0.064
#> GSM23173     3  0.5361     0.7458 0.148 0.000 0.744 0.108
#> GSM23174     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23176     1  0.1867     0.9327 0.928 0.000 0.000 0.072
#> GSM23177     1  0.0188     0.9634 0.996 0.000 0.000 0.004
#> GSM23178     1  0.0000     0.9644 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000     0.8782 0.000 0.000 1.000 0.000
#> GSM23180     3  0.5587     0.5166 0.372 0.000 0.600 0.028
#> GSM23181     1  0.0336     0.9622 0.992 0.000 0.000 0.008
#> GSM23182     3  0.5587     0.5166 0.372 0.000 0.600 0.028
#> GSM23183     3  0.6928     0.3412 0.372 0.000 0.512 0.116
#> GSM23184     3  0.0336     0.8778 0.000 0.000 0.992 0.008
#> GSM23196     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23199     2  0.5000    -0.2055 0.000 0.504 0.000 0.496
#> GSM23200     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23201     4  0.2589     0.9042 0.000 0.116 0.000 0.884
#> GSM23202     4  0.2589     0.9042 0.000 0.116 0.000 0.884
#> GSM23203     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23205     4  0.2760     0.8994 0.000 0.128 0.000 0.872
#> GSM23206     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23207     2  0.4977    -0.0857 0.000 0.540 0.000 0.460
#> GSM23208     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23210     2  0.4999    -0.1923 0.000 0.508 0.000 0.492
#> GSM23211     2  0.0000     0.8393 0.000 1.000 0.000 0.000
#> GSM23212     4  0.2760     0.8994 0.000 0.128 0.000 0.872
#> GSM23213     4  0.2589     0.9042 0.000 0.116 0.000 0.884
#> GSM23214     4  0.2589     0.9042 0.000 0.116 0.000 0.884
#> GSM23215     4  0.5000     0.0369 0.000 0.496 0.000 0.504

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.3821      0.605 0.800 0.000 0.148 0.000 0.052
#> GSM23187     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23191     5  0.4156      0.428 0.004 0.000 0.288 0.008 0.700
#> GSM23192     5  0.4420      0.101 0.004 0.000 0.448 0.000 0.548
#> GSM23193     3  0.4030      0.367 0.000 0.000 0.648 0.000 0.352
#> GSM23194     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23195     5  0.6361      0.327 0.296 0.000 0.196 0.000 0.508
#> GSM23159     1  0.2280      0.815 0.880 0.000 0.000 0.000 0.120
#> GSM23160     3  0.0510      0.853 0.000 0.000 0.984 0.000 0.016
#> GSM23161     1  0.3876      0.687 0.684 0.000 0.000 0.000 0.316
#> GSM23162     3  0.2648      0.708 0.000 0.000 0.848 0.000 0.152
#> GSM23163     1  0.2719      0.808 0.852 0.000 0.004 0.000 0.144
#> GSM23164     1  0.4291      0.465 0.536 0.000 0.000 0.000 0.464
#> GSM23165     1  0.1270      0.790 0.948 0.000 0.000 0.000 0.052
#> GSM23166     1  0.4287      0.469 0.540 0.000 0.000 0.000 0.460
#> GSM23167     1  0.1197      0.792 0.952 0.000 0.000 0.000 0.048
#> GSM23168     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23169     3  0.3707      0.489 0.000 0.000 0.716 0.000 0.284
#> GSM23170     1  0.0000      0.807 1.000 0.000 0.000 0.000 0.000
#> GSM23171     1  0.1121      0.815 0.956 0.000 0.000 0.000 0.044
#> GSM23172     1  0.1197      0.792 0.952 0.000 0.000 0.000 0.048
#> GSM23173     3  0.6281     -0.125 0.160 0.000 0.488 0.000 0.352
#> GSM23174     1  0.3109      0.765 0.800 0.000 0.000 0.000 0.200
#> GSM23175     1  0.2852      0.797 0.828 0.000 0.000 0.000 0.172
#> GSM23176     1  0.1197      0.792 0.952 0.000 0.000 0.000 0.048
#> GSM23177     1  0.2648      0.806 0.848 0.000 0.000 0.000 0.152
#> GSM23178     1  0.2230      0.816 0.884 0.000 0.000 0.000 0.116
#> GSM23179     3  0.0000      0.863 0.000 0.000 1.000 0.000 0.000
#> GSM23180     5  0.3935      0.491 0.008 0.000 0.220 0.012 0.760
#> GSM23181     5  0.4283     -0.431 0.456 0.000 0.000 0.000 0.544
#> GSM23182     5  0.3935      0.491 0.008 0.000 0.220 0.012 0.760
#> GSM23183     5  0.6323      0.320 0.292 0.000 0.192 0.000 0.516
#> GSM23184     3  0.0404      0.856 0.000 0.000 0.988 0.000 0.012
#> GSM23196     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.4030      0.622 0.000 0.352 0.000 0.648 0.000
#> GSM23200     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000
#> GSM23202     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.0290      0.823 0.000 0.008 0.000 0.992 0.000
#> GSM23206     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23207     4  0.4101      0.589 0.000 0.372 0.000 0.628 0.000
#> GSM23208     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23210     4  0.4126      0.578 0.000 0.380 0.000 0.620 0.000
#> GSM23211     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0404      0.822 0.000 0.012 0.000 0.988 0.000
#> GSM23213     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000
#> GSM23215     4  0.3612      0.706 0.000 0.268 0.000 0.732 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
#> GSM23185     3  0.0000     0.9375 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.5209     0.4717 0.172 0.000 0.048 0.000 0.096 0.684
#> GSM23187     3  0.0000     0.9375 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0717     0.9216 0.016 0.000 0.976 0.000 0.008 0.000
#> GSM23189     3  0.0000     0.9375 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0146     0.9379 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM23191     5  0.1074     0.5207 0.028 0.000 0.012 0.000 0.960 0.000
#> GSM23192     5  0.3670     0.4331 0.012 0.000 0.284 0.000 0.704 0.000
#> GSM23193     5  0.4066     0.2260 0.012 0.000 0.392 0.000 0.596 0.000
#> GSM23194     3  0.0547     0.9380 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM23195     5  0.6905     0.1513 0.316 0.000 0.096 0.000 0.436 0.152
#> GSM23159     1  0.3672     0.5253 0.632 0.000 0.000 0.000 0.000 0.368
#> GSM23160     3  0.0363     0.9391 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM23161     1  0.3506     0.6533 0.792 0.000 0.000 0.000 0.052 0.156
#> GSM23162     5  0.3851     0.0775 0.000 0.000 0.460 0.000 0.540 0.000
#> GSM23163     1  0.3629     0.6103 0.724 0.000 0.000 0.000 0.016 0.260
#> GSM23164     1  0.3307     0.6211 0.820 0.000 0.000 0.000 0.108 0.072
#> GSM23165     6  0.0146     0.7355 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM23166     1  0.3607     0.6265 0.796 0.000 0.000 0.000 0.112 0.092
#> GSM23167     6  0.0260     0.7382 0.008 0.000 0.000 0.000 0.000 0.992
#> GSM23168     3  0.1007     0.9273 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM23169     3  0.3844     0.4673 0.004 0.000 0.676 0.000 0.312 0.008
#> GSM23170     6  0.3578     0.2507 0.340 0.000 0.000 0.000 0.000 0.660
#> GSM23171     6  0.3804    -0.0315 0.424 0.000 0.000 0.000 0.000 0.576
#> GSM23172     6  0.0260     0.7382 0.008 0.000 0.000 0.000 0.000 0.992
#> GSM23173     5  0.6081     0.1911 0.064 0.000 0.412 0.000 0.452 0.072
#> GSM23174     1  0.4066     0.2418 0.596 0.000 0.000 0.000 0.012 0.392
#> GSM23175     1  0.3468     0.5413 0.712 0.000 0.000 0.000 0.004 0.284
#> GSM23176     6  0.0260     0.7382 0.008 0.000 0.000 0.000 0.000 0.992
#> GSM23177     1  0.3309     0.6185 0.720 0.000 0.000 0.000 0.000 0.280
#> GSM23178     1  0.3659     0.5265 0.636 0.000 0.000 0.000 0.000 0.364
#> GSM23179     3  0.0865     0.9313 0.000 0.000 0.964 0.000 0.036 0.000
#> GSM23180     5  0.3101     0.4492 0.244 0.000 0.000 0.000 0.756 0.000
#> GSM23181     1  0.3247     0.5527 0.808 0.000 0.000 0.000 0.156 0.036
#> GSM23182     5  0.3101     0.4492 0.244 0.000 0.000 0.000 0.756 0.000
#> GSM23183     5  0.6948     0.1288 0.332 0.000 0.104 0.000 0.420 0.144
#> GSM23184     3  0.0937     0.9293 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM23196     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     4  0.2219     0.8731 0.000 0.136 0.000 0.864 0.000 0.000
#> GSM23200     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23201     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23202     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23206     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     4  0.2416     0.8569 0.000 0.156 0.000 0.844 0.000 0.000
#> GSM23208     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     4  0.2664     0.8289 0.000 0.184 0.000 0.816 0.000 0.000
#> GSM23211     2  0.0000     1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000     0.9276 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     4  0.1663     0.8999 0.000 0.088 0.000 0.912 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-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 cell.type(p) disease.state(p) k
#> MAD:mclust 57     3.90e-13         0.052490 2
#> MAD:mclust 57     4.19e-13         0.000276 3
#> MAD:mclust 52     3.00e-11         0.000376 4
#> MAD:mclust 45     9.25e-10         0.000897 5
#> MAD:mclust 44     2.32e-08         0.001311 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 11993 rows and 57 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.892           0.829       0.940         0.4816 0.504   0.504
#> 3 3 0.954           0.947       0.972         0.3988 0.713   0.484
#> 4 4 0.853           0.830       0.926         0.1131 0.868   0.628
#> 5 5 0.785           0.700       0.856         0.0510 0.939   0.775
#> 6 6 0.751           0.640       0.800         0.0398 0.956   0.816

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
#> GSM23185     2   0.000     0.1915 0.000 1.000
#> GSM23186     1   0.998     0.9719 0.524 0.476
#> GSM23187     2   0.541    -0.2144 0.124 0.876
#> GSM23188     2   0.373     0.3650 0.072 0.928
#> GSM23189     2   0.358    -0.0269 0.068 0.932
#> GSM23190     2   0.482    -0.1495 0.104 0.896
#> GSM23191     1   0.998     0.9719 0.524 0.476
#> GSM23192     1   0.998     0.9719 0.524 0.476
#> GSM23193     1   0.998     0.9719 0.524 0.476
#> GSM23194     1   1.000     0.9499 0.504 0.496
#> GSM23195     1   0.998     0.9719 0.524 0.476
#> GSM23159     1   0.998     0.9719 0.524 0.476
#> GSM23160     1   0.998     0.9719 0.524 0.476
#> GSM23161     1   0.998     0.9719 0.524 0.476
#> GSM23162     1   0.998     0.9719 0.524 0.476
#> GSM23163     1   0.998     0.9719 0.524 0.476
#> GSM23164     1   0.998     0.9719 0.524 0.476
#> GSM23165     1   0.998     0.9719 0.524 0.476
#> GSM23166     1   0.998     0.9719 0.524 0.476
#> GSM23167     1   0.998     0.9719 0.524 0.476
#> GSM23168     1   0.998     0.9719 0.524 0.476
#> GSM23169     1   0.998     0.9719 0.524 0.476
#> GSM23170     1   0.998     0.9719 0.524 0.476
#> GSM23171     1   0.998     0.9719 0.524 0.476
#> GSM23172     1   0.998     0.9719 0.524 0.476
#> GSM23173     1   0.998     0.9719 0.524 0.476
#> GSM23174     1   0.998     0.9719 0.524 0.476
#> GSM23175     1   0.998     0.9719 0.524 0.476
#> GSM23176     1   0.998     0.9719 0.524 0.476
#> GSM23177     1   0.998     0.9719 0.524 0.476
#> GSM23178     1   0.998     0.9719 0.524 0.476
#> GSM23179     1   0.999     0.9677 0.520 0.480
#> GSM23180     1   0.998     0.9719 0.524 0.476
#> GSM23181     1   0.998     0.9719 0.524 0.476
#> GSM23182     1   0.998     0.9719 0.524 0.476
#> GSM23183     1   0.998     0.9719 0.524 0.476
#> GSM23184     1   0.998     0.9719 0.524 0.476
#> GSM23196     2   0.998     0.8780 0.476 0.524
#> GSM23197     2   0.998     0.8780 0.476 0.524
#> GSM23198     2   0.998     0.8780 0.476 0.524
#> GSM23199     2   0.998     0.8780 0.476 0.524
#> GSM23200     2   0.998     0.8780 0.476 0.524
#> GSM23201     2   0.998     0.8780 0.476 0.524
#> GSM23202     1   0.871    -0.6535 0.708 0.292
#> GSM23203     2   0.998     0.8780 0.476 0.524
#> GSM23204     2   0.998     0.8780 0.476 0.524
#> GSM23205     2   0.998     0.8780 0.476 0.524
#> GSM23206     2   0.998     0.8780 0.476 0.524
#> GSM23207     2   0.998     0.8780 0.476 0.524
#> GSM23208     2   0.998     0.8780 0.476 0.524
#> GSM23209     2   0.998     0.8780 0.476 0.524
#> GSM23210     2   0.998     0.8780 0.476 0.524
#> GSM23211     2   0.998     0.8780 0.476 0.524
#> GSM23212     2   0.998     0.8780 0.476 0.524
#> GSM23213     2   0.999     0.8728 0.484 0.516
#> GSM23214     2   1.000     0.8699 0.488 0.512
#> GSM23215     2   0.998     0.8780 0.476 0.524

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23186     1  0.2066      0.929 0.940 0.000 0.060
#> GSM23187     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23191     3  0.5733      0.614 0.324 0.000 0.676
#> GSM23192     3  0.5138      0.736 0.252 0.000 0.748
#> GSM23193     3  0.3879      0.856 0.152 0.000 0.848
#> GSM23194     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23195     3  0.2878      0.901 0.096 0.000 0.904
#> GSM23159     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23160     3  0.0237      0.933 0.004 0.000 0.996
#> GSM23161     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23162     3  0.1643      0.926 0.044 0.000 0.956
#> GSM23163     1  0.0237      0.992 0.996 0.000 0.004
#> GSM23164     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23168     3  0.0747      0.932 0.016 0.000 0.984
#> GSM23169     3  0.2448      0.912 0.076 0.000 0.924
#> GSM23170     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23173     3  0.1643      0.926 0.044 0.000 0.956
#> GSM23174     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23176     1  0.0237      0.992 0.996 0.000 0.004
#> GSM23177     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23180     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23181     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23182     1  0.0000      0.996 1.000 0.000 0.000
#> GSM23183     3  0.3551      0.874 0.132 0.000 0.868
#> GSM23184     3  0.0000      0.933 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23201     2  0.0592      0.970 0.012 0.988 0.000
#> GSM23202     2  0.5733      0.536 0.324 0.676 0.000
#> GSM23203     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23205     2  0.0237      0.975 0.004 0.996 0.000
#> GSM23206     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23210     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23211     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23212     2  0.0000      0.977 0.000 1.000 0.000
#> GSM23213     2  0.1289      0.954 0.032 0.968 0.000
#> GSM23214     2  0.1643      0.943 0.044 0.956 0.000
#> GSM23215     2  0.0000      0.977 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.0336     0.9650 0.000 0.000 0.992 0.008
#> GSM23186     1  0.0779     0.8758 0.980 0.000 0.016 0.004
#> GSM23187     3  0.0188     0.9655 0.000 0.000 0.996 0.004
#> GSM23188     3  0.0188     0.9655 0.000 0.000 0.996 0.004
#> GSM23189     3  0.0188     0.9655 0.000 0.000 0.996 0.004
#> GSM23190     3  0.0188     0.9652 0.000 0.000 0.996 0.004
#> GSM23191     4  0.4746     0.3270 0.000 0.000 0.368 0.632
#> GSM23192     3  0.3356     0.7946 0.000 0.000 0.824 0.176
#> GSM23193     3  0.3024     0.8320 0.000 0.000 0.852 0.148
#> GSM23194     3  0.0188     0.9655 0.000 0.000 0.996 0.004
#> GSM23195     1  0.4250     0.6169 0.724 0.000 0.276 0.000
#> GSM23159     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0000     0.9657 0.000 0.000 1.000 0.000
#> GSM23161     1  0.3219     0.7686 0.836 0.000 0.000 0.164
#> GSM23162     3  0.0707     0.9583 0.000 0.000 0.980 0.020
#> GSM23163     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23164     1  0.4907     0.3530 0.580 0.000 0.000 0.420
#> GSM23165     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23166     1  0.5070     0.3761 0.580 0.000 0.004 0.416
#> GSM23167     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000     0.9657 0.000 0.000 1.000 0.000
#> GSM23169     3  0.0469     0.9612 0.000 0.000 0.988 0.012
#> GSM23170     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23173     3  0.1867     0.9004 0.072 0.000 0.928 0.000
#> GSM23174     1  0.1302     0.8617 0.956 0.000 0.000 0.044
#> GSM23175     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23176     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000     0.8853 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000     0.9657 0.000 0.000 1.000 0.000
#> GSM23180     4  0.0657     0.8319 0.012 0.000 0.004 0.984
#> GSM23181     4  0.2973     0.7205 0.144 0.000 0.000 0.856
#> GSM23182     4  0.0336     0.8344 0.008 0.000 0.000 0.992
#> GSM23183     1  0.4933     0.2953 0.568 0.000 0.432 0.000
#> GSM23184     3  0.0188     0.9652 0.000 0.000 0.996 0.004
#> GSM23196     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0592     0.9267 0.000 0.984 0.000 0.016
#> GSM23200     2  0.0469     0.9286 0.000 0.988 0.000 0.012
#> GSM23201     4  0.1792     0.8378 0.000 0.068 0.000 0.932
#> GSM23202     4  0.2011     0.8340 0.000 0.080 0.000 0.920
#> GSM23203     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23205     2  0.4746     0.4017 0.000 0.632 0.000 0.368
#> GSM23206     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0921     0.9180 0.000 0.972 0.000 0.028
#> GSM23208     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0592     0.9267 0.000 0.984 0.000 0.016
#> GSM23211     2  0.0000     0.9322 0.000 1.000 0.000 0.000
#> GSM23212     2  0.4992     0.0815 0.000 0.524 0.000 0.476
#> GSM23213     4  0.4040     0.6269 0.000 0.248 0.000 0.752
#> GSM23214     4  0.2345     0.8218 0.000 0.100 0.000 0.900
#> GSM23215     2  0.0336     0.9301 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.2813     0.7613 0.000 0.000 0.832 0.000 0.168
#> GSM23186     1  0.2819     0.8841 0.884 0.000 0.024 0.012 0.080
#> GSM23187     3  0.0609     0.8269 0.000 0.000 0.980 0.000 0.020
#> GSM23188     3  0.0963     0.8252 0.000 0.000 0.964 0.000 0.036
#> GSM23189     3  0.0510     0.8265 0.000 0.000 0.984 0.000 0.016
#> GSM23190     3  0.3143     0.7286 0.000 0.000 0.796 0.000 0.204
#> GSM23191     4  0.2946     0.6133 0.000 0.000 0.088 0.868 0.044
#> GSM23192     3  0.6314     0.3218 0.004 0.000 0.548 0.260 0.188
#> GSM23193     3  0.3037     0.7690 0.004 0.000 0.864 0.100 0.032
#> GSM23194     3  0.1121     0.8236 0.000 0.000 0.956 0.000 0.044
#> GSM23195     5  0.5639    -0.1053 0.080 0.000 0.396 0.000 0.524
#> GSM23159     1  0.0510     0.9643 0.984 0.000 0.000 0.000 0.016
#> GSM23160     3  0.1197     0.8245 0.000 0.000 0.952 0.000 0.048
#> GSM23161     1  0.3551     0.7861 0.820 0.000 0.000 0.136 0.044
#> GSM23162     3  0.2308     0.8141 0.004 0.000 0.912 0.036 0.048
#> GSM23163     1  0.0510     0.9670 0.984 0.000 0.000 0.000 0.016
#> GSM23164     4  0.4620     0.4828 0.320 0.000 0.000 0.652 0.028
#> GSM23165     1  0.0510     0.9664 0.984 0.000 0.000 0.000 0.016
#> GSM23166     4  0.4949     0.3396 0.396 0.000 0.000 0.572 0.032
#> GSM23167     1  0.0510     0.9674 0.984 0.000 0.000 0.000 0.016
#> GSM23168     3  0.1571     0.8226 0.004 0.000 0.936 0.000 0.060
#> GSM23169     3  0.1638     0.8191 0.004 0.000 0.932 0.000 0.064
#> GSM23170     1  0.0162     0.9669 0.996 0.000 0.000 0.000 0.004
#> GSM23171     1  0.0162     0.9673 0.996 0.000 0.000 0.000 0.004
#> GSM23172     1  0.0404     0.9666 0.988 0.000 0.000 0.000 0.012
#> GSM23173     3  0.3897     0.6527 0.028 0.000 0.768 0.000 0.204
#> GSM23174     1  0.0671     0.9606 0.980 0.000 0.000 0.016 0.004
#> GSM23175     1  0.0671     0.9632 0.980 0.000 0.000 0.004 0.016
#> GSM23176     1  0.0510     0.9670 0.984 0.000 0.000 0.000 0.016
#> GSM23177     1  0.0703     0.9595 0.976 0.000 0.000 0.000 0.024
#> GSM23178     1  0.0162     0.9667 0.996 0.000 0.000 0.000 0.004
#> GSM23179     3  0.1341     0.8211 0.000 0.000 0.944 0.000 0.056
#> GSM23180     4  0.0794     0.6838 0.000 0.000 0.000 0.972 0.028
#> GSM23181     4  0.4297     0.6098 0.164 0.000 0.000 0.764 0.072
#> GSM23182     4  0.1792     0.6714 0.000 0.000 0.000 0.916 0.084
#> GSM23183     3  0.6704    -0.1396 0.204 0.000 0.416 0.004 0.376
#> GSM23184     3  0.2377     0.7929 0.000 0.000 0.872 0.000 0.128
#> GSM23196     2  0.0404     0.8048 0.000 0.988 0.000 0.000 0.012
#> GSM23197     2  0.2280     0.7597 0.000 0.880 0.000 0.000 0.120
#> GSM23198     2  0.1270     0.7952 0.000 0.948 0.000 0.000 0.052
#> GSM23199     2  0.2536     0.7561 0.000 0.868 0.000 0.004 0.128
#> GSM23200     2  0.3932     0.5379 0.000 0.672 0.000 0.000 0.328
#> GSM23201     4  0.0880     0.6790 0.000 0.032 0.000 0.968 0.000
#> GSM23202     4  0.2769     0.6438 0.000 0.032 0.000 0.876 0.092
#> GSM23203     2  0.0290     0.8051 0.000 0.992 0.000 0.000 0.008
#> GSM23204     2  0.2773     0.7278 0.000 0.836 0.000 0.000 0.164
#> GSM23205     2  0.4297     0.2142 0.000 0.528 0.000 0.472 0.000
#> GSM23206     2  0.0000     0.8051 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.4551     0.4461 0.000 0.616 0.000 0.016 0.368
#> GSM23208     2  0.0000     0.8051 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.1270     0.7917 0.000 0.948 0.000 0.000 0.052
#> GSM23210     2  0.2286     0.7690 0.000 0.888 0.000 0.004 0.108
#> GSM23211     2  0.0404     0.8034 0.000 0.988 0.000 0.000 0.012
#> GSM23212     2  0.6102    -0.0211 0.000 0.440 0.000 0.124 0.436
#> GSM23213     5  0.6498    -0.0702 0.000 0.224 0.000 0.292 0.484
#> GSM23214     4  0.5129     0.2498 0.000 0.056 0.000 0.616 0.328
#> GSM23215     2  0.2377     0.7572 0.000 0.872 0.000 0.000 0.128

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM23185     3  0.4520     0.6472 0.000 0.000 0.704 0.168 0.000 0.128
#> GSM23186     1  0.4987     0.0963 0.516 0.000 0.004 0.040 0.008 0.432
#> GSM23187     3  0.1196     0.7960 0.000 0.000 0.952 0.008 0.000 0.040
#> GSM23188     3  0.2624     0.7614 0.000 0.000 0.856 0.020 0.000 0.124
#> GSM23189     3  0.1152     0.7966 0.000 0.000 0.952 0.004 0.000 0.044
#> GSM23190     3  0.3717     0.7290 0.000 0.000 0.780 0.148 0.000 0.072
#> GSM23191     5  0.3699     0.5503 0.000 0.000 0.040 0.036 0.812 0.112
#> GSM23192     6  0.5576     0.6013 0.004 0.000 0.112 0.064 0.152 0.668
#> GSM23193     3  0.3891     0.6691 0.000 0.000 0.768 0.004 0.164 0.064
#> GSM23194     3  0.3515     0.4835 0.000 0.000 0.676 0.000 0.000 0.324
#> GSM23195     6  0.6005     0.6749 0.036 0.000 0.148 0.256 0.000 0.560
#> GSM23159     1  0.1408     0.8778 0.944 0.000 0.000 0.020 0.000 0.036
#> GSM23160     3  0.2586     0.7825 0.000 0.000 0.868 0.032 0.000 0.100
#> GSM23161     1  0.5583     0.6256 0.652 0.000 0.000 0.060 0.116 0.172
#> GSM23162     3  0.1932     0.8019 0.000 0.000 0.924 0.020 0.016 0.040
#> GSM23163     1  0.2201     0.8683 0.896 0.000 0.000 0.028 0.000 0.076
#> GSM23164     5  0.5650     0.3610 0.284 0.000 0.000 0.040 0.588 0.088
#> GSM23165     1  0.0260     0.8884 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23166     5  0.6190     0.2778 0.316 0.000 0.000 0.052 0.516 0.116
#> GSM23167     1  0.0692     0.8890 0.976 0.000 0.000 0.004 0.000 0.020
#> GSM23168     3  0.3585     0.7391 0.000 0.000 0.792 0.048 0.004 0.156
#> GSM23169     3  0.3703     0.7454 0.000 0.000 0.792 0.072 0.004 0.132
#> GSM23170     1  0.1421     0.8848 0.944 0.000 0.000 0.028 0.000 0.028
#> GSM23171     1  0.0000     0.8891 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0146     0.8890 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM23173     3  0.4890     0.6657 0.032 0.000 0.708 0.096 0.000 0.164
#> GSM23174     1  0.1194     0.8845 0.956 0.000 0.000 0.004 0.032 0.008
#> GSM23175     1  0.1644     0.8772 0.932 0.000 0.000 0.028 0.000 0.040
#> GSM23176     1  0.1196     0.8858 0.952 0.000 0.000 0.008 0.000 0.040
#> GSM23177     1  0.3445     0.7764 0.796 0.000 0.000 0.048 0.000 0.156
#> GSM23178     1  0.0790     0.8847 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM23179     3  0.1908     0.7955 0.000 0.000 0.916 0.028 0.000 0.056
#> GSM23180     5  0.2311     0.5824 0.000 0.000 0.000 0.016 0.880 0.104
#> GSM23181     5  0.4934     0.4517 0.052 0.000 0.000 0.044 0.684 0.220
#> GSM23182     5  0.2538     0.5437 0.000 0.000 0.000 0.124 0.860 0.016
#> GSM23183     6  0.5662     0.7277 0.112 0.000 0.116 0.112 0.000 0.660
#> GSM23184     3  0.2445     0.7810 0.000 0.000 0.872 0.108 0.000 0.020
#> GSM23196     2  0.0632     0.7863 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM23197     2  0.1814     0.7515 0.000 0.900 0.000 0.100 0.000 0.000
#> GSM23198     2  0.1501     0.7582 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM23199     2  0.3288     0.4878 0.000 0.724 0.000 0.276 0.000 0.000
#> GSM23200     2  0.3857    -0.1397 0.000 0.532 0.000 0.468 0.000 0.000
#> GSM23201     5  0.0748     0.5848 0.000 0.004 0.000 0.016 0.976 0.004
#> GSM23202     5  0.2734     0.5071 0.000 0.004 0.000 0.148 0.840 0.008
#> GSM23203     2  0.0458     0.7887 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM23204     2  0.2454     0.6991 0.000 0.840 0.000 0.160 0.000 0.000
#> GSM23205     5  0.4037     0.0111 0.000 0.380 0.000 0.012 0.608 0.000
#> GSM23206     2  0.0000     0.7898 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.3999    -0.2633 0.000 0.500 0.000 0.496 0.004 0.000
#> GSM23208     2  0.0146     0.7897 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM23209     2  0.1075     0.7783 0.000 0.952 0.000 0.048 0.000 0.000
#> GSM23210     2  0.2793     0.6253 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM23211     2  0.0458     0.7875 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM23212     4  0.5515     0.6056 0.000 0.320 0.000 0.528 0.152 0.000
#> GSM23213     4  0.5483     0.5703 0.000 0.124 0.000 0.584 0.280 0.012
#> GSM23214     5  0.4472    -0.3418 0.000 0.028 0.000 0.476 0.496 0.000
#> GSM23215     2  0.2146     0.7380 0.000 0.880 0.000 0.116 0.000 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) disease.state(p) k
#> MAD:NMF 51     7.81e-12         2.06e-01 2
#> MAD:NMF 57     4.19e-13         4.23e-04 3
#> MAD:NMF 51     1.93e-09         5.28e-05 4
#> MAD:NMF 47     6.99e-09         2.87e-03 5
#> MAD:NMF 47     7.51e-08         3.52e-03 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.501           0.881       0.931         0.4880 0.499   0.499
#> 3 3 0.651           0.863       0.888         0.3444 0.842   0.683
#> 4 4 0.826           0.892       0.933         0.1162 0.929   0.790
#> 5 5 0.816           0.872       0.860         0.0656 0.959   0.849
#> 6 6 0.839           0.869       0.875         0.0287 0.981   0.918

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM23185     2   0.141      0.904 0.020 0.980
#> GSM23186     1   0.605      0.806 0.852 0.148
#> GSM23187     2   0.141      0.904 0.020 0.980
#> GSM23188     2   0.141      0.904 0.020 0.980
#> GSM23189     2   0.141      0.904 0.020 0.980
#> GSM23190     2   0.141      0.904 0.020 0.980
#> GSM23191     2   0.814      0.769 0.252 0.748
#> GSM23192     2   0.781      0.793 0.232 0.768
#> GSM23193     2   0.955      0.548 0.376 0.624
#> GSM23194     2   0.295      0.898 0.052 0.948
#> GSM23195     2   0.781      0.793 0.232 0.768
#> GSM23159     1   0.000      0.948 1.000 0.000
#> GSM23160     2   0.595      0.862 0.144 0.856
#> GSM23161     1   0.000      0.948 1.000 0.000
#> GSM23162     2   0.753      0.808 0.216 0.784
#> GSM23163     1   0.000      0.948 1.000 0.000
#> GSM23164     1   0.000      0.948 1.000 0.000
#> GSM23165     1   0.000      0.948 1.000 0.000
#> GSM23166     1   0.000      0.948 1.000 0.000
#> GSM23167     1   0.000      0.948 1.000 0.000
#> GSM23168     2   0.595      0.862 0.144 0.856
#> GSM23169     2   0.767      0.800 0.224 0.776
#> GSM23170     1   0.000      0.948 1.000 0.000
#> GSM23171     1   0.000      0.948 1.000 0.000
#> GSM23172     1   0.000      0.948 1.000 0.000
#> GSM23173     2   0.753      0.808 0.216 0.784
#> GSM23174     1   0.000      0.948 1.000 0.000
#> GSM23175     1   0.000      0.948 1.000 0.000
#> GSM23176     1   0.000      0.948 1.000 0.000
#> GSM23177     1   0.000      0.948 1.000 0.000
#> GSM23178     1   0.000      0.948 1.000 0.000
#> GSM23179     2   0.295      0.898 0.052 0.948
#> GSM23180     1   0.000      0.948 1.000 0.000
#> GSM23181     1   0.000      0.948 1.000 0.000
#> GSM23182     1   0.000      0.948 1.000 0.000
#> GSM23183     2   0.781      0.793 0.232 0.768
#> GSM23184     2   0.529      0.875 0.120 0.880
#> GSM23196     2   0.000      0.902 0.000 1.000
#> GSM23197     2   0.000      0.902 0.000 1.000
#> GSM23198     2   0.000      0.902 0.000 1.000
#> GSM23199     2   0.563      0.863 0.132 0.868
#> GSM23200     2   0.000      0.902 0.000 1.000
#> GSM23201     1   0.839      0.641 0.732 0.268
#> GSM23202     1   0.482      0.875 0.896 0.104
#> GSM23203     2   0.000      0.902 0.000 1.000
#> GSM23204     2   0.000      0.902 0.000 1.000
#> GSM23205     1   0.839      0.641 0.732 0.268
#> GSM23206     2   0.000      0.902 0.000 1.000
#> GSM23207     2   0.000      0.902 0.000 1.000
#> GSM23208     2   0.000      0.902 0.000 1.000
#> GSM23209     2   0.000      0.902 0.000 1.000
#> GSM23210     2   0.563      0.863 0.132 0.868
#> GSM23211     2   0.000      0.902 0.000 1.000
#> GSM23212     1   0.482      0.875 0.896 0.104
#> GSM23213     1   0.482      0.875 0.896 0.104
#> GSM23214     1   0.482      0.875 0.896 0.104
#> GSM23215     2   0.000      0.902 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
#> GSM23185     3  0.4605      0.837 0.000 0.204 0.796
#> GSM23186     1  0.4351      0.737 0.828 0.004 0.168
#> GSM23187     3  0.4605      0.837 0.000 0.204 0.796
#> GSM23188     3  0.4605      0.837 0.000 0.204 0.796
#> GSM23189     3  0.4605      0.837 0.000 0.204 0.796
#> GSM23190     3  0.4605      0.837 0.000 0.204 0.796
#> GSM23191     3  0.4551      0.840 0.140 0.020 0.840
#> GSM23192     3  0.4446      0.866 0.112 0.032 0.856
#> GSM23193     3  0.5058      0.675 0.244 0.000 0.756
#> GSM23194     3  0.4178      0.853 0.000 0.172 0.828
#> GSM23195     3  0.4446      0.866 0.112 0.032 0.856
#> GSM23159     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23160     3  0.5179      0.881 0.080 0.088 0.832
#> GSM23161     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23162     3  0.4335      0.873 0.100 0.036 0.864
#> GSM23163     1  0.0892      0.889 0.980 0.000 0.020
#> GSM23164     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23165     1  0.0892      0.889 0.980 0.000 0.020
#> GSM23166     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23167     1  0.0892      0.889 0.980 0.000 0.020
#> GSM23168     3  0.5179      0.881 0.080 0.088 0.832
#> GSM23169     3  0.4489      0.870 0.108 0.036 0.856
#> GSM23170     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23173     3  0.4335      0.873 0.100 0.036 0.864
#> GSM23174     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23175     1  0.2261      0.874 0.932 0.000 0.068
#> GSM23176     1  0.0892      0.889 0.980 0.000 0.020
#> GSM23177     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23178     1  0.0892      0.889 0.980 0.000 0.020
#> GSM23179     3  0.4178      0.853 0.000 0.172 0.828
#> GSM23180     1  0.2878      0.861 0.904 0.000 0.096
#> GSM23181     1  0.0000      0.896 1.000 0.000 0.000
#> GSM23182     1  0.2261      0.874 0.932 0.000 0.068
#> GSM23183     3  0.4446      0.866 0.112 0.032 0.856
#> GSM23184     3  0.5229      0.877 0.068 0.104 0.828
#> GSM23196     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23199     2  0.3551      0.842 0.000 0.868 0.132
#> GSM23200     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23201     1  0.8648      0.543 0.548 0.120 0.332
#> GSM23202     1  0.7360      0.738 0.692 0.096 0.212
#> GSM23203     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23205     1  0.8648      0.543 0.548 0.120 0.332
#> GSM23206     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23208     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23210     2  0.5363      0.687 0.000 0.724 0.276
#> GSM23211     2  0.0000      0.968 0.000 1.000 0.000
#> GSM23212     1  0.7360      0.738 0.692 0.096 0.212
#> GSM23213     1  0.7360      0.738 0.692 0.096 0.212
#> GSM23214     1  0.7360      0.738 0.692 0.096 0.212
#> GSM23215     2  0.0000      0.968 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
#> GSM23185     3  0.2413      0.865 0.000 0.064 0.916 0.020
#> GSM23186     1  0.3306      0.781 0.840 0.000 0.156 0.004
#> GSM23187     3  0.2413      0.865 0.000 0.064 0.916 0.020
#> GSM23188     3  0.2413      0.865 0.000 0.064 0.916 0.020
#> GSM23189     3  0.2413      0.865 0.000 0.064 0.916 0.020
#> GSM23190     3  0.2413      0.865 0.000 0.064 0.916 0.020
#> GSM23191     3  0.3984      0.829 0.040 0.000 0.828 0.132
#> GSM23192     3  0.3612      0.856 0.044 0.000 0.856 0.100
#> GSM23193     3  0.5598      0.663 0.076 0.000 0.704 0.220
#> GSM23194     3  0.1474      0.874 0.000 0.052 0.948 0.000
#> GSM23195     3  0.3612      0.856 0.044 0.000 0.856 0.100
#> GSM23159     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23160     3  0.1520      0.884 0.024 0.000 0.956 0.020
#> GSM23161     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23162     3  0.3051      0.870 0.028 0.000 0.884 0.088
#> GSM23163     1  0.0188      0.936 0.996 0.000 0.004 0.000
#> GSM23164     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23165     1  0.0188      0.936 0.996 0.000 0.004 0.000
#> GSM23166     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23167     1  0.0188      0.936 0.996 0.000 0.004 0.000
#> GSM23168     3  0.1520      0.884 0.024 0.000 0.956 0.020
#> GSM23169     3  0.3182      0.867 0.028 0.000 0.876 0.096
#> GSM23170     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23171     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23172     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23173     3  0.3051      0.870 0.028 0.000 0.884 0.088
#> GSM23174     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23175     1  0.3486      0.798 0.812 0.000 0.000 0.188
#> GSM23176     1  0.0188      0.936 0.996 0.000 0.004 0.000
#> GSM23177     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23178     1  0.0188      0.936 0.996 0.000 0.004 0.000
#> GSM23179     3  0.1474      0.874 0.000 0.052 0.948 0.000
#> GSM23180     1  0.5328      0.651 0.704 0.000 0.048 0.248
#> GSM23181     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23182     1  0.3649      0.779 0.796 0.000 0.000 0.204
#> GSM23183     3  0.3612      0.856 0.044 0.000 0.856 0.100
#> GSM23184     3  0.0707      0.882 0.020 0.000 0.980 0.000
#> GSM23196     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23199     2  0.3024      0.807 0.000 0.852 0.000 0.148
#> GSM23200     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23201     4  0.3157      0.836 0.000 0.004 0.144 0.852
#> GSM23202     4  0.0707      0.929 0.000 0.000 0.020 0.980
#> GSM23203     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23205     4  0.3157      0.836 0.000 0.004 0.144 0.852
#> GSM23206     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23208     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23210     2  0.6031      0.571 0.000 0.688 0.144 0.168
#> GSM23211     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM23212     4  0.0707      0.929 0.000 0.000 0.020 0.980
#> GSM23213     4  0.0707      0.929 0.000 0.000 0.020 0.980
#> GSM23214     4  0.0707      0.929 0.000 0.000 0.020 0.980
#> GSM23215     2  0.0000      0.962 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
#> GSM23185     3  0.3661      1.000 0.000 0.000 0.724 0.000 0.276
#> GSM23186     1  0.4993      0.742 0.684 0.000 0.248 0.004 0.064
#> GSM23187     3  0.3661      1.000 0.000 0.000 0.724 0.000 0.276
#> GSM23188     3  0.3661      1.000 0.000 0.000 0.724 0.000 0.276
#> GSM23189     3  0.3661      1.000 0.000 0.000 0.724 0.000 0.276
#> GSM23190     3  0.3661      1.000 0.000 0.000 0.724 0.000 0.276
#> GSM23191     5  0.1981      0.806 0.016 0.000 0.000 0.064 0.920
#> GSM23192     5  0.3183      0.763 0.000 0.000 0.156 0.016 0.828
#> GSM23193     5  0.4231      0.697 0.052 0.000 0.020 0.132 0.796
#> GSM23194     5  0.3143      0.664 0.000 0.000 0.204 0.000 0.796
#> GSM23195     5  0.3183      0.763 0.000 0.000 0.156 0.016 0.828
#> GSM23159     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23160     5  0.1638      0.806 0.004 0.000 0.064 0.000 0.932
#> GSM23161     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23162     5  0.0771      0.828 0.004 0.000 0.000 0.020 0.976
#> GSM23163     1  0.2921      0.862 0.844 0.000 0.148 0.004 0.004
#> GSM23164     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.2921      0.862 0.844 0.000 0.148 0.004 0.004
#> GSM23166     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.2921      0.862 0.844 0.000 0.148 0.004 0.004
#> GSM23168     5  0.1638      0.806 0.004 0.000 0.064 0.000 0.932
#> GSM23169     5  0.0955      0.827 0.004 0.000 0.000 0.028 0.968
#> GSM23170     1  0.0162      0.907 0.996 0.000 0.004 0.000 0.000
#> GSM23171     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0162      0.907 0.996 0.000 0.004 0.000 0.000
#> GSM23173     5  0.0771      0.828 0.004 0.000 0.000 0.020 0.976
#> GSM23174     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.3805      0.793 0.828 0.000 0.020 0.108 0.044
#> GSM23176     1  0.2921      0.862 0.844 0.000 0.148 0.004 0.004
#> GSM23177     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.2921      0.862 0.844 0.000 0.148 0.004 0.004
#> GSM23179     5  0.3039      0.658 0.000 0.000 0.192 0.000 0.808
#> GSM23180     1  0.5638      0.631 0.680 0.000 0.020 0.168 0.132
#> GSM23181     1  0.0000      0.907 1.000 0.000 0.000 0.000 0.000
#> GSM23182     1  0.4045      0.778 0.812 0.000 0.020 0.116 0.052
#> GSM23183     5  0.3183      0.763 0.000 0.000 0.156 0.016 0.828
#> GSM23184     5  0.2488      0.755 0.004 0.000 0.124 0.000 0.872
#> GSM23196     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.2877      0.815 0.000 0.848 0.004 0.144 0.004
#> GSM23200     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.2930      0.847 0.000 0.000 0.164 0.832 0.004
#> GSM23202     4  0.0290      0.931 0.000 0.000 0.000 0.992 0.008
#> GSM23203     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.2930      0.847 0.000 0.000 0.164 0.832 0.004
#> GSM23206     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23208     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.5350      0.602 0.000 0.684 0.164 0.148 0.004
#> GSM23211     2  0.0000      0.964 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0290      0.931 0.000 0.000 0.000 0.992 0.008
#> GSM23213     4  0.0290      0.931 0.000 0.000 0.000 0.992 0.008
#> GSM23214     4  0.0290      0.931 0.000 0.000 0.000 0.992 0.008
#> GSM23215     2  0.0000      0.964 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
#> GSM23185     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     1  0.5331      0.622 0.580 0.000 0.000 0.000 0.152 0.268
#> GSM23187     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.3358      0.777 0.008 0.000 0.116 0.052 0.824 0.000
#> GSM23192     6  0.3405      1.000 0.000 0.000 0.000 0.004 0.272 0.724
#> GSM23193     5  0.4228      0.602 0.044 0.000 0.060 0.120 0.776 0.000
#> GSM23194     5  0.4798      0.674 0.000 0.000 0.376 0.000 0.564 0.060
#> GSM23195     6  0.3405      1.000 0.000 0.000 0.000 0.004 0.272 0.724
#> GSM23159     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23160     5  0.3076      0.831 0.000 0.000 0.240 0.000 0.760 0.000
#> GSM23161     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23162     5  0.2778      0.829 0.000 0.000 0.168 0.008 0.824 0.000
#> GSM23163     1  0.4190      0.777 0.740 0.000 0.000 0.000 0.148 0.112
#> GSM23164     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.4190      0.777 0.740 0.000 0.000 0.000 0.148 0.112
#> GSM23166     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.4190      0.777 0.740 0.000 0.000 0.000 0.148 0.112
#> GSM23168     5  0.3076      0.831 0.000 0.000 0.240 0.000 0.760 0.000
#> GSM23169     5  0.2968      0.827 0.000 0.000 0.168 0.016 0.816 0.000
#> GSM23170     1  0.0146      0.868 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM23171     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0291      0.867 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM23173     5  0.2778      0.829 0.000 0.000 0.168 0.008 0.824 0.000
#> GSM23174     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.3274      0.758 0.824 0.000 0.000 0.096 0.080 0.000
#> GSM23176     1  0.4190      0.777 0.740 0.000 0.000 0.000 0.148 0.112
#> GSM23177     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.4190      0.777 0.740 0.000 0.000 0.000 0.148 0.112
#> GSM23179     5  0.3717      0.714 0.000 0.000 0.384 0.000 0.616 0.000
#> GSM23180     1  0.4798      0.624 0.672 0.000 0.000 0.156 0.172 0.000
#> GSM23181     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23182     1  0.3469      0.743 0.808 0.000 0.000 0.104 0.088 0.000
#> GSM23183     6  0.3405      1.000 0.000 0.000 0.000 0.004 0.272 0.724
#> GSM23184     5  0.3446      0.796 0.000 0.000 0.308 0.000 0.692 0.000
#> GSM23196     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.2624      0.814 0.000 0.844 0.000 0.148 0.004 0.004
#> GSM23200     2  0.0146      0.961 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23201     4  0.2632      0.878 0.000 0.000 0.000 0.832 0.004 0.164
#> GSM23202     4  0.0000      0.941 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.2632      0.878 0.000 0.000 0.000 0.832 0.004 0.164
#> GSM23206     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.0146      0.961 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23208     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.4838      0.613 0.000 0.680 0.000 0.148 0.004 0.168
#> GSM23211     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      0.941 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000      0.941 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000      0.941 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000      0.963 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-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 cell.type(p) disease.state(p) k
#> ATC:hclust 57     2.04e-01         2.51e-02 2
#> ATC:hclust 57     9.33e-09         1.67e-04 3
#> ATC:hclust 57     2.57e-12         3.86e-04 4
#> ATC:hclust 57     1.24e-11         9.27e-05 5
#> ATC:hclust 57     5.06e-11         2.13e-04 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.781           0.872       0.944         0.5000 0.491   0.491
#> 3 3 0.768           0.800       0.902         0.3446 0.685   0.448
#> 4 4 0.774           0.795       0.878         0.1076 0.915   0.750
#> 5 5 0.770           0.771       0.837         0.0568 0.922   0.719
#> 6 6 0.796           0.588       0.824         0.0426 0.977   0.894

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
#> GSM23185     2  0.2043     0.9219 0.032 0.968
#> GSM23186     1  0.0000     0.9451 1.000 0.000
#> GSM23187     2  0.2043     0.9219 0.032 0.968
#> GSM23188     2  0.2043     0.9219 0.032 0.968
#> GSM23189     2  0.2043     0.9219 0.032 0.968
#> GSM23190     2  0.2043     0.9219 0.032 0.968
#> GSM23191     1  0.8713     0.5342 0.708 0.292
#> GSM23192     1  0.0672     0.9409 0.992 0.008
#> GSM23193     1  0.0672     0.9409 0.992 0.008
#> GSM23194     2  0.6438     0.8261 0.164 0.836
#> GSM23195     2  0.8608     0.6642 0.284 0.716
#> GSM23159     1  0.0000     0.9451 1.000 0.000
#> GSM23160     2  0.9209     0.5640 0.336 0.664
#> GSM23161     1  0.0000     0.9451 1.000 0.000
#> GSM23162     1  0.9944     0.0582 0.544 0.456
#> GSM23163     1  0.0000     0.9451 1.000 0.000
#> GSM23164     1  0.0000     0.9451 1.000 0.000
#> GSM23165     1  0.0000     0.9451 1.000 0.000
#> GSM23166     1  0.0000     0.9451 1.000 0.000
#> GSM23167     1  0.0000     0.9451 1.000 0.000
#> GSM23168     2  0.7139     0.7913 0.196 0.804
#> GSM23169     1  0.0672     0.9409 0.992 0.008
#> GSM23170     1  0.0000     0.9451 1.000 0.000
#> GSM23171     1  0.0000     0.9451 1.000 0.000
#> GSM23172     1  0.0000     0.9451 1.000 0.000
#> GSM23173     1  0.9954     0.0421 0.540 0.460
#> GSM23174     1  0.0000     0.9451 1.000 0.000
#> GSM23175     1  0.0000     0.9451 1.000 0.000
#> GSM23176     1  0.0000     0.9451 1.000 0.000
#> GSM23177     1  0.0000     0.9451 1.000 0.000
#> GSM23178     1  0.0000     0.9451 1.000 0.000
#> GSM23179     2  0.3114     0.9119 0.056 0.944
#> GSM23180     1  0.0000     0.9451 1.000 0.000
#> GSM23181     1  0.0000     0.9451 1.000 0.000
#> GSM23182     1  0.0000     0.9451 1.000 0.000
#> GSM23183     1  0.0672     0.9409 0.992 0.008
#> GSM23184     2  0.6531     0.8219 0.168 0.832
#> GSM23196     2  0.0000     0.9281 0.000 1.000
#> GSM23197     2  0.0000     0.9281 0.000 1.000
#> GSM23198     2  0.0000     0.9281 0.000 1.000
#> GSM23199     2  0.0000     0.9281 0.000 1.000
#> GSM23200     2  0.0000     0.9281 0.000 1.000
#> GSM23201     2  0.8861     0.6038 0.304 0.696
#> GSM23202     1  0.2043     0.9199 0.968 0.032
#> GSM23203     2  0.0000     0.9281 0.000 1.000
#> GSM23204     2  0.0000     0.9281 0.000 1.000
#> GSM23205     2  0.3733     0.8969 0.072 0.928
#> GSM23206     2  0.0000     0.9281 0.000 1.000
#> GSM23207     2  0.0000     0.9281 0.000 1.000
#> GSM23208     2  0.0000     0.9281 0.000 1.000
#> GSM23209     2  0.0000     0.9281 0.000 1.000
#> GSM23210     2  0.0000     0.9281 0.000 1.000
#> GSM23211     2  0.0000     0.9281 0.000 1.000
#> GSM23212     2  0.3733     0.8969 0.072 0.928
#> GSM23213     1  0.2603     0.9152 0.956 0.044
#> GSM23214     1  0.2603     0.9152 0.956 0.044
#> GSM23215     2  0.0000     0.9281 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
#> GSM23185     3  0.6286      0.266 0.000 0.464 0.536
#> GSM23186     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23187     3  0.6286      0.266 0.000 0.464 0.536
#> GSM23188     3  0.6305      0.212 0.000 0.484 0.516
#> GSM23189     3  0.6286      0.266 0.000 0.464 0.536
#> GSM23190     3  0.6286      0.266 0.000 0.464 0.536
#> GSM23191     3  0.1525      0.793 0.032 0.004 0.964
#> GSM23192     3  0.1529      0.790 0.040 0.000 0.960
#> GSM23193     3  0.1411      0.792 0.036 0.000 0.964
#> GSM23194     3  0.1919      0.792 0.024 0.020 0.956
#> GSM23195     3  0.1163      0.792 0.028 0.000 0.972
#> GSM23159     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23160     3  0.1919      0.792 0.024 0.020 0.956
#> GSM23161     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23162     3  0.1525      0.793 0.032 0.004 0.964
#> GSM23163     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23164     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23165     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23166     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23167     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23168     3  0.1919      0.792 0.024 0.020 0.956
#> GSM23169     3  0.1289      0.792 0.032 0.000 0.968
#> GSM23170     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23173     3  0.1289      0.792 0.032 0.000 0.968
#> GSM23174     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23176     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23177     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23178     1  0.0237      0.952 0.996 0.000 0.004
#> GSM23179     3  0.1919      0.790 0.020 0.024 0.956
#> GSM23180     1  0.3412      0.830 0.876 0.000 0.124
#> GSM23181     1  0.0000      0.953 1.000 0.000 0.000
#> GSM23182     1  0.4654      0.721 0.792 0.000 0.208
#> GSM23183     3  0.1529      0.790 0.040 0.000 0.960
#> GSM23184     3  0.1919      0.792 0.024 0.020 0.956
#> GSM23196     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23199     2  0.1529      0.965 0.000 0.960 0.040
#> GSM23200     2  0.1529      0.965 0.000 0.960 0.040
#> GSM23201     3  0.2796      0.731 0.000 0.092 0.908
#> GSM23202     1  0.6944      0.164 0.516 0.016 0.468
#> GSM23203     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23205     3  0.5905      0.430 0.000 0.352 0.648
#> GSM23206     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23207     2  0.1529      0.965 0.000 0.960 0.040
#> GSM23208     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23210     2  0.1529      0.965 0.000 0.960 0.040
#> GSM23211     2  0.0000      0.986 0.000 1.000 0.000
#> GSM23212     3  0.5905      0.430 0.000 0.352 0.648
#> GSM23213     3  0.7931      0.412 0.284 0.092 0.624
#> GSM23214     3  0.7931      0.412 0.284 0.092 0.624
#> GSM23215     2  0.0000      0.986 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM23185     3  0.2921      0.664 0.000 0.140 0.860 0.000
#> GSM23186     1  0.2124      0.928 0.924 0.000 0.008 0.068
#> GSM23187     3  0.2921      0.664 0.000 0.140 0.860 0.000
#> GSM23188     3  0.2921      0.664 0.000 0.140 0.860 0.000
#> GSM23189     3  0.2921      0.664 0.000 0.140 0.860 0.000
#> GSM23190     3  0.2921      0.664 0.000 0.140 0.860 0.000
#> GSM23191     3  0.4916      0.455 0.000 0.000 0.576 0.424
#> GSM23192     3  0.4477      0.599 0.000 0.000 0.688 0.312
#> GSM23193     3  0.4916      0.455 0.000 0.000 0.576 0.424
#> GSM23194     3  0.2011      0.699 0.000 0.000 0.920 0.080
#> GSM23195     3  0.4454      0.599 0.000 0.000 0.692 0.308
#> GSM23159     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23160     3  0.0336      0.709 0.000 0.000 0.992 0.008
#> GSM23161     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23162     3  0.4907      0.462 0.000 0.000 0.580 0.420
#> GSM23163     1  0.2124      0.928 0.924 0.000 0.008 0.068
#> GSM23164     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23165     1  0.2124      0.928 0.924 0.000 0.008 0.068
#> GSM23166     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23167     1  0.1557      0.935 0.944 0.000 0.000 0.056
#> GSM23168     3  0.0336      0.709 0.000 0.000 0.992 0.008
#> GSM23169     3  0.4907      0.462 0.000 0.000 0.580 0.420
#> GSM23170     1  0.0707      0.944 0.980 0.000 0.000 0.020
#> GSM23171     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23172     1  0.0592      0.944 0.984 0.000 0.000 0.016
#> GSM23173     3  0.4697      0.553 0.000 0.000 0.644 0.356
#> GSM23174     1  0.0000      0.946 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23176     1  0.2124      0.928 0.924 0.000 0.008 0.068
#> GSM23177     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23178     1  0.2124      0.928 0.924 0.000 0.008 0.068
#> GSM23179     3  0.0336      0.709 0.000 0.000 0.992 0.008
#> GSM23180     1  0.4103      0.612 0.744 0.000 0.000 0.256
#> GSM23181     1  0.0817      0.947 0.976 0.000 0.000 0.024
#> GSM23182     4  0.4972      0.134 0.456 0.000 0.000 0.544
#> GSM23183     3  0.4477      0.599 0.000 0.000 0.688 0.312
#> GSM23184     3  0.0336      0.709 0.000 0.000 0.992 0.008
#> GSM23196     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23199     2  0.4500      0.648 0.000 0.684 0.000 0.316
#> GSM23200     2  0.1637      0.910 0.000 0.940 0.000 0.060
#> GSM23201     4  0.2530      0.824 0.000 0.000 0.112 0.888
#> GSM23202     4  0.2563      0.842 0.020 0.000 0.072 0.908
#> GSM23203     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23205     4  0.2699      0.834 0.000 0.028 0.068 0.904
#> GSM23206     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23207     2  0.2647      0.868 0.000 0.880 0.000 0.120
#> GSM23208     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23210     2  0.4304      0.694 0.000 0.716 0.000 0.284
#> GSM23211     2  0.0000      0.942 0.000 1.000 0.000 0.000
#> GSM23212     4  0.2623      0.832 0.000 0.028 0.064 0.908
#> GSM23213     4  0.2334      0.848 0.004 0.000 0.088 0.908
#> GSM23214     4  0.2334      0.848 0.004 0.000 0.088 0.908
#> GSM23215     2  0.0000      0.942 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
#> GSM23185     3  0.4029     0.8779 0.000 0.024 0.744 0.000 0.232
#> GSM23186     1  0.6343     0.7344 0.644 0.000 0.140 0.064 0.152
#> GSM23187     3  0.4029     0.8779 0.000 0.024 0.744 0.000 0.232
#> GSM23188     3  0.4029     0.8779 0.000 0.024 0.744 0.000 0.232
#> GSM23189     3  0.4029     0.8779 0.000 0.024 0.744 0.000 0.232
#> GSM23190     3  0.4029     0.8779 0.000 0.024 0.744 0.000 0.232
#> GSM23191     5  0.3401     0.8160 0.000 0.000 0.064 0.096 0.840
#> GSM23192     5  0.1430     0.7471 0.000 0.000 0.052 0.004 0.944
#> GSM23193     5  0.3454     0.8142 0.000 0.000 0.064 0.100 0.836
#> GSM23194     5  0.4210    -0.2176 0.000 0.000 0.412 0.000 0.588
#> GSM23195     5  0.1670     0.7466 0.000 0.000 0.052 0.012 0.936
#> GSM23159     1  0.0162     0.8652 0.996 0.000 0.000 0.000 0.004
#> GSM23160     3  0.4150     0.8051 0.000 0.000 0.612 0.000 0.388
#> GSM23161     1  0.0162     0.8652 0.996 0.000 0.000 0.000 0.004
#> GSM23162     5  0.3464     0.8159 0.000 0.000 0.068 0.096 0.836
#> GSM23163     1  0.5087     0.8055 0.748 0.000 0.136 0.060 0.056
#> GSM23164     1  0.0000     0.8657 1.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.5149     0.8036 0.744 0.000 0.136 0.064 0.056
#> GSM23166     1  0.0000     0.8657 1.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.3971     0.8269 0.804 0.000 0.136 0.052 0.008
#> GSM23168     3  0.4150     0.8051 0.000 0.000 0.612 0.000 0.388
#> GSM23169     5  0.3390     0.8143 0.000 0.000 0.060 0.100 0.840
#> GSM23170     1  0.2753     0.8481 0.876 0.000 0.104 0.012 0.008
#> GSM23171     1  0.0000     0.8657 1.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.2352     0.8523 0.896 0.000 0.092 0.004 0.008
#> GSM23173     5  0.3410     0.8147 0.000 0.000 0.068 0.092 0.840
#> GSM23174     1  0.0000     0.8657 1.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.0162     0.8652 0.996 0.000 0.000 0.000 0.004
#> GSM23176     1  0.5149     0.8036 0.744 0.000 0.136 0.064 0.056
#> GSM23177     1  0.0162     0.8652 0.996 0.000 0.000 0.000 0.004
#> GSM23178     1  0.5149     0.8036 0.744 0.000 0.136 0.064 0.056
#> GSM23179     3  0.4088     0.8210 0.000 0.000 0.632 0.000 0.368
#> GSM23180     1  0.4905     0.5604 0.696 0.000 0.000 0.080 0.224
#> GSM23181     1  0.0162     0.8652 0.996 0.000 0.000 0.000 0.004
#> GSM23182     1  0.6365     0.2489 0.520 0.000 0.000 0.252 0.228
#> GSM23183     5  0.1430     0.7471 0.000 0.000 0.052 0.004 0.944
#> GSM23184     3  0.4088     0.8210 0.000 0.000 0.632 0.000 0.368
#> GSM23196     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23199     4  0.6032    -0.1551 0.000 0.424 0.116 0.460 0.000
#> GSM23200     2  0.4844     0.6497 0.000 0.720 0.108 0.172 0.000
#> GSM23201     4  0.2358     0.8643 0.000 0.000 0.008 0.888 0.104
#> GSM23202     4  0.2179     0.8672 0.004 0.000 0.000 0.896 0.100
#> GSM23203     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.2349     0.8621 0.000 0.004 0.012 0.900 0.084
#> GSM23206     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.5535     0.4913 0.000 0.620 0.108 0.272 0.000
#> GSM23208     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.6037     0.0153 0.000 0.444 0.116 0.440 0.000
#> GSM23211     2  0.0000     0.8948 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.1731     0.8492 0.000 0.004 0.004 0.932 0.060
#> GSM23213     4  0.2179     0.8672 0.004 0.000 0.000 0.896 0.100
#> GSM23214     4  0.2179     0.8672 0.004 0.000 0.000 0.896 0.100
#> GSM23215     2  0.0000     0.8948 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
#> GSM23185     3  0.1625     0.8402 0.000 0.012 0.928 0.000 0.060 0.000
#> GSM23186     6  0.4315     0.0000 0.328 0.000 0.000 0.000 0.036 0.636
#> GSM23187     3  0.1625     0.8402 0.000 0.012 0.928 0.000 0.060 0.000
#> GSM23188     3  0.1625     0.8402 0.000 0.012 0.928 0.000 0.060 0.000
#> GSM23189     3  0.1625     0.8402 0.000 0.012 0.928 0.000 0.060 0.000
#> GSM23190     3  0.1625     0.8402 0.000 0.012 0.928 0.000 0.060 0.000
#> GSM23191     5  0.1528     0.8173 0.000 0.000 0.048 0.016 0.936 0.000
#> GSM23192     5  0.4282     0.7411 0.000 0.000 0.088 0.000 0.720 0.192
#> GSM23193     5  0.1666     0.8103 0.000 0.000 0.036 0.020 0.936 0.008
#> GSM23194     5  0.4463     0.5057 0.000 0.000 0.292 0.000 0.652 0.056
#> GSM23195     5  0.4282     0.7411 0.000 0.000 0.088 0.000 0.720 0.192
#> GSM23159     1  0.0000     0.6265 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23160     3  0.4034     0.6966 0.000 0.000 0.652 0.000 0.328 0.020
#> GSM23161     1  0.0000     0.6265 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23162     5  0.2068     0.8102 0.000 0.000 0.048 0.016 0.916 0.020
#> GSM23163     1  0.4175    -0.3596 0.524 0.000 0.000 0.000 0.012 0.464
#> GSM23164     1  0.0000     0.6265 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.3989    -0.3552 0.528 0.000 0.000 0.000 0.004 0.468
#> GSM23166     1  0.0000     0.6265 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.3937    -0.2220 0.572 0.000 0.004 0.000 0.000 0.424
#> GSM23168     3  0.4034     0.6966 0.000 0.000 0.652 0.000 0.328 0.020
#> GSM23169     5  0.1693     0.8145 0.000 0.000 0.032 0.020 0.936 0.012
#> GSM23170     1  0.3488     0.3174 0.744 0.000 0.004 0.000 0.008 0.244
#> GSM23171     1  0.0146     0.6257 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM23172     1  0.3357     0.3577 0.764 0.000 0.004 0.000 0.008 0.224
#> GSM23173     5  0.1644     0.8167 0.000 0.000 0.052 0.012 0.932 0.004
#> GSM23174     1  0.0405     0.6237 0.988 0.000 0.004 0.000 0.008 0.000
#> GSM23175     1  0.0291     0.6245 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM23176     1  0.3989    -0.3552 0.528 0.000 0.000 0.000 0.004 0.468
#> GSM23177     1  0.0000     0.6265 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.3989    -0.3552 0.528 0.000 0.000 0.000 0.004 0.468
#> GSM23179     3  0.3711     0.7563 0.000 0.000 0.720 0.000 0.260 0.020
#> GSM23180     1  0.4183     0.2562 0.696 0.000 0.000 0.016 0.268 0.020
#> GSM23181     1  0.0551     0.6223 0.984 0.000 0.004 0.000 0.008 0.004
#> GSM23182     1  0.6141     0.0486 0.512 0.000 0.000 0.244 0.224 0.020
#> GSM23183     5  0.4282     0.7411 0.000 0.000 0.088 0.000 0.720 0.192
#> GSM23184     3  0.3711     0.7563 0.000 0.000 0.720 0.000 0.260 0.020
#> GSM23196     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     4  0.7085     0.2750 0.000 0.256 0.060 0.376 0.004 0.304
#> GSM23200     2  0.6577     0.2900 0.000 0.512 0.060 0.160 0.004 0.264
#> GSM23201     4  0.1930     0.7972 0.000 0.000 0.000 0.916 0.036 0.048
#> GSM23202     4  0.0790     0.8004 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM23203     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0291     0.8944 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM23205     4  0.1590     0.7964 0.000 0.000 0.008 0.936 0.008 0.048
#> GSM23206     2  0.0520     0.8913 0.000 0.984 0.008 0.000 0.000 0.008
#> GSM23207     2  0.6986     0.0463 0.000 0.420 0.060 0.232 0.004 0.284
#> GSM23208     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     4  0.7090     0.2745 0.000 0.256 0.060 0.372 0.004 0.308
#> GSM23211     2  0.0000     0.8968 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0862     0.7974 0.000 0.000 0.008 0.972 0.004 0.016
#> GSM23213     4  0.0790     0.8004 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM23214     4  0.0790     0.8004 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM23215     2  0.0520     0.8913 0.000 0.984 0.008 0.000 0.000 0.008

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 cell.type(p) disease.state(p) k
#> ATC:kmeans 55     3.96e-04         0.464825 2
#> ATC:kmeans 47     5.27e-10         0.050292 3
#> ATC:kmeans 52     3.00e-11         0.000305 4
#> ATC:kmeans 52     1.38e-10         0.006335 5
#> ATC:kmeans 43     1.03e-08         0.017845 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 11993 rows and 57 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 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 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.950       0.981         0.5084 0.492   0.492
#> 3 3 0.906           0.891       0.955         0.3160 0.706   0.469
#> 4 4 0.920           0.876       0.947         0.0904 0.941   0.819
#> 5 5 0.919           0.793       0.912         0.0658 0.959   0.849
#> 6 6 0.923           0.872       0.936         0.0319 0.965   0.852

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 3 4 5

There is also optional best \(k\) = 2 3 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
#> GSM23185     2   0.000      0.967 0.000 1.000
#> GSM23186     1   0.000      0.994 1.000 0.000
#> GSM23187     2   0.000      0.967 0.000 1.000
#> GSM23188     2   0.000      0.967 0.000 1.000
#> GSM23189     2   0.000      0.967 0.000 1.000
#> GSM23190     2   0.000      0.967 0.000 1.000
#> GSM23191     1   0.584      0.831 0.860 0.140
#> GSM23192     1   0.000      0.994 1.000 0.000
#> GSM23193     1   0.000      0.994 1.000 0.000
#> GSM23194     2   0.000      0.967 0.000 1.000
#> GSM23195     2   0.260      0.927 0.044 0.956
#> GSM23159     1   0.000      0.994 1.000 0.000
#> GSM23160     2   0.000      0.967 0.000 1.000
#> GSM23161     1   0.000      0.994 1.000 0.000
#> GSM23162     2   0.971      0.341 0.400 0.600
#> GSM23163     1   0.000      0.994 1.000 0.000
#> GSM23164     1   0.000      0.994 1.000 0.000
#> GSM23165     1   0.000      0.994 1.000 0.000
#> GSM23166     1   0.000      0.994 1.000 0.000
#> GSM23167     1   0.000      0.994 1.000 0.000
#> GSM23168     2   0.000      0.967 0.000 1.000
#> GSM23169     1   0.000      0.994 1.000 0.000
#> GSM23170     1   0.000      0.994 1.000 0.000
#> GSM23171     1   0.000      0.994 1.000 0.000
#> GSM23172     1   0.000      0.994 1.000 0.000
#> GSM23173     2   0.999      0.101 0.480 0.520
#> GSM23174     1   0.000      0.994 1.000 0.000
#> GSM23175     1   0.000      0.994 1.000 0.000
#> GSM23176     1   0.000      0.994 1.000 0.000
#> GSM23177     1   0.000      0.994 1.000 0.000
#> GSM23178     1   0.000      0.994 1.000 0.000
#> GSM23179     2   0.000      0.967 0.000 1.000
#> GSM23180     1   0.000      0.994 1.000 0.000
#> GSM23181     1   0.000      0.994 1.000 0.000
#> GSM23182     1   0.000      0.994 1.000 0.000
#> GSM23183     1   0.000      0.994 1.000 0.000
#> GSM23184     2   0.000      0.967 0.000 1.000
#> GSM23196     2   0.000      0.967 0.000 1.000
#> GSM23197     2   0.000      0.967 0.000 1.000
#> GSM23198     2   0.000      0.967 0.000 1.000
#> GSM23199     2   0.000      0.967 0.000 1.000
#> GSM23200     2   0.000      0.967 0.000 1.000
#> GSM23201     2   0.000      0.967 0.000 1.000
#> GSM23202     1   0.000      0.994 1.000 0.000
#> GSM23203     2   0.000      0.967 0.000 1.000
#> GSM23204     2   0.000      0.967 0.000 1.000
#> GSM23205     2   0.000      0.967 0.000 1.000
#> GSM23206     2   0.000      0.967 0.000 1.000
#> GSM23207     2   0.000      0.967 0.000 1.000
#> GSM23208     2   0.000      0.967 0.000 1.000
#> GSM23209     2   0.000      0.967 0.000 1.000
#> GSM23210     2   0.000      0.967 0.000 1.000
#> GSM23211     2   0.000      0.967 0.000 1.000
#> GSM23212     2   0.000      0.967 0.000 1.000
#> GSM23213     1   0.000      0.994 1.000 0.000
#> GSM23214     1   0.000      0.994 1.000 0.000
#> GSM23215     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
#> GSM23185     3   0.000      0.890 0.000 0.000 1.000
#> GSM23186     1   0.000      0.997 1.000 0.000 0.000
#> GSM23187     3   0.000      0.890 0.000 0.000 1.000
#> GSM23188     3   0.000      0.890 0.000 0.000 1.000
#> GSM23189     3   0.000      0.890 0.000 0.000 1.000
#> GSM23190     3   0.000      0.890 0.000 0.000 1.000
#> GSM23191     3   0.000      0.890 0.000 0.000 1.000
#> GSM23192     3   0.613      0.427 0.400 0.000 0.600
#> GSM23193     3   0.628      0.276 0.460 0.000 0.540
#> GSM23194     3   0.000      0.890 0.000 0.000 1.000
#> GSM23195     3   0.445      0.714 0.000 0.192 0.808
#> GSM23159     1   0.000      0.997 1.000 0.000 0.000
#> GSM23160     3   0.000      0.890 0.000 0.000 1.000
#> GSM23161     1   0.000      0.997 1.000 0.000 0.000
#> GSM23162     3   0.000      0.890 0.000 0.000 1.000
#> GSM23163     1   0.000      0.997 1.000 0.000 0.000
#> GSM23164     1   0.000      0.997 1.000 0.000 0.000
#> GSM23165     1   0.000      0.997 1.000 0.000 0.000
#> GSM23166     1   0.000      0.997 1.000 0.000 0.000
#> GSM23167     1   0.000      0.997 1.000 0.000 0.000
#> GSM23168     3   0.000      0.890 0.000 0.000 1.000
#> GSM23169     3   0.614      0.418 0.404 0.000 0.596
#> GSM23170     1   0.000      0.997 1.000 0.000 0.000
#> GSM23171     1   0.000      0.997 1.000 0.000 0.000
#> GSM23172     1   0.000      0.997 1.000 0.000 0.000
#> GSM23173     3   0.000      0.890 0.000 0.000 1.000
#> GSM23174     1   0.000      0.997 1.000 0.000 0.000
#> GSM23175     1   0.000      0.997 1.000 0.000 0.000
#> GSM23176     1   0.000      0.997 1.000 0.000 0.000
#> GSM23177     1   0.000      0.997 1.000 0.000 0.000
#> GSM23178     1   0.000      0.997 1.000 0.000 0.000
#> GSM23179     3   0.000      0.890 0.000 0.000 1.000
#> GSM23180     1   0.000      0.997 1.000 0.000 0.000
#> GSM23181     1   0.000      0.997 1.000 0.000 0.000
#> GSM23182     1   0.000      0.997 1.000 0.000 0.000
#> GSM23183     3   0.533      0.643 0.272 0.000 0.728
#> GSM23184     3   0.000      0.890 0.000 0.000 1.000
#> GSM23196     2   0.000      0.949 0.000 1.000 0.000
#> GSM23197     2   0.000      0.949 0.000 1.000 0.000
#> GSM23198     2   0.000      0.949 0.000 1.000 0.000
#> GSM23199     2   0.000      0.949 0.000 1.000 0.000
#> GSM23200     2   0.000      0.949 0.000 1.000 0.000
#> GSM23201     2   0.000      0.949 0.000 1.000 0.000
#> GSM23202     1   0.164      0.948 0.956 0.044 0.000
#> GSM23203     2   0.000      0.949 0.000 1.000 0.000
#> GSM23204     2   0.000      0.949 0.000 1.000 0.000
#> GSM23205     2   0.000      0.949 0.000 1.000 0.000
#> GSM23206     2   0.000      0.949 0.000 1.000 0.000
#> GSM23207     2   0.000      0.949 0.000 1.000 0.000
#> GSM23208     2   0.000      0.949 0.000 1.000 0.000
#> GSM23209     2   0.000      0.949 0.000 1.000 0.000
#> GSM23210     2   0.000      0.949 0.000 1.000 0.000
#> GSM23211     2   0.000      0.949 0.000 1.000 0.000
#> GSM23212     2   0.000      0.949 0.000 1.000 0.000
#> GSM23213     2   0.611      0.348 0.396 0.604 0.000
#> GSM23214     2   0.611      0.348 0.396 0.604 0.000
#> GSM23215     2   0.000      0.949 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
#> GSM23185     3  0.0188     0.8389 0.000 0.004 0.996 0.000
#> GSM23186     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23187     3  0.0188     0.8389 0.000 0.004 0.996 0.000
#> GSM23188     3  0.0188     0.8389 0.000 0.004 0.996 0.000
#> GSM23189     3  0.0188     0.8389 0.000 0.004 0.996 0.000
#> GSM23190     3  0.0188     0.8389 0.000 0.004 0.996 0.000
#> GSM23191     3  0.0707     0.8296 0.000 0.000 0.980 0.020
#> GSM23192     3  0.5444     0.3711 0.424 0.000 0.560 0.016
#> GSM23193     3  0.5768     0.2680 0.456 0.000 0.516 0.028
#> GSM23194     3  0.0469     0.8360 0.000 0.000 0.988 0.012
#> GSM23195     3  0.6479     0.4990 0.000 0.140 0.636 0.224
#> GSM23159     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0000     0.8392 0.000 0.000 1.000 0.000
#> GSM23161     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23162     3  0.0188     0.8382 0.000 0.000 0.996 0.004
#> GSM23163     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23164     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23165     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23166     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23167     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000     0.8392 0.000 0.000 1.000 0.000
#> GSM23169     3  0.5487     0.4156 0.400 0.000 0.580 0.020
#> GSM23170     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23173     3  0.0592     0.8346 0.000 0.000 0.984 0.016
#> GSM23174     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23176     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000     0.8392 0.000 0.000 1.000 0.000
#> GSM23180     1  0.0469     0.9604 0.988 0.000 0.000 0.012
#> GSM23181     1  0.0000     0.9716 1.000 0.000 0.000 0.000
#> GSM23182     1  0.4998     0.0711 0.512 0.000 0.000 0.488
#> GSM23183     3  0.5472     0.3337 0.440 0.000 0.544 0.016
#> GSM23184     3  0.0000     0.8392 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23199     2  0.0188     0.9964 0.000 0.996 0.000 0.004
#> GSM23200     2  0.0188     0.9964 0.000 0.996 0.000 0.004
#> GSM23201     4  0.1792     0.9323 0.000 0.068 0.000 0.932
#> GSM23202     4  0.0592     0.9561 0.016 0.000 0.000 0.984
#> GSM23203     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23205     4  0.2647     0.8837 0.000 0.120 0.000 0.880
#> GSM23206     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0188     0.9964 0.000 0.996 0.000 0.004
#> GSM23208     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0188     0.9964 0.000 0.996 0.000 0.004
#> GSM23211     2  0.0000     0.9986 0.000 1.000 0.000 0.000
#> GSM23212     4  0.0592     0.9534 0.000 0.016 0.000 0.984
#> GSM23213     4  0.0592     0.9561 0.016 0.000 0.000 0.984
#> GSM23214     4  0.0592     0.9561 0.016 0.000 0.000 0.984
#> GSM23215     2  0.0000     0.9986 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
#> GSM23185     3  0.3662      0.645 0.000 0.004 0.744 0.000 0.252
#> GSM23186     1  0.2280      0.853 0.880 0.000 0.000 0.000 0.120
#> GSM23187     3  0.3662      0.645 0.000 0.004 0.744 0.000 0.252
#> GSM23188     3  0.3662      0.645 0.000 0.004 0.744 0.000 0.252
#> GSM23189     3  0.3662      0.645 0.000 0.004 0.744 0.000 0.252
#> GSM23190     3  0.3662      0.645 0.000 0.004 0.744 0.000 0.252
#> GSM23191     3  0.3551      0.301 0.000 0.000 0.772 0.008 0.220
#> GSM23192     5  0.1117      0.702 0.020 0.000 0.016 0.000 0.964
#> GSM23193     3  0.7049     -0.231 0.256 0.000 0.400 0.012 0.332
#> GSM23194     5  0.4249     -0.114 0.000 0.000 0.432 0.000 0.568
#> GSM23195     5  0.0771      0.704 0.000 0.000 0.020 0.004 0.976
#> GSM23159     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23160     3  0.0000      0.557 0.000 0.000 1.000 0.000 0.000
#> GSM23161     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23162     3  0.2127      0.470 0.000 0.000 0.892 0.000 0.108
#> GSM23163     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23164     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23166     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.0162      0.559 0.000 0.000 0.996 0.000 0.004
#> GSM23169     5  0.4060      0.387 0.000 0.000 0.360 0.000 0.640
#> GSM23170     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23171     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23173     3  0.4302     -0.315 0.000 0.000 0.520 0.000 0.480
#> GSM23174     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23176     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23177     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23179     3  0.3508      0.644 0.000 0.000 0.748 0.000 0.252
#> GSM23180     1  0.0798      0.945 0.976 0.000 0.000 0.008 0.016
#> GSM23181     1  0.0000      0.965 1.000 0.000 0.000 0.000 0.000
#> GSM23182     1  0.4738      0.107 0.520 0.000 0.000 0.464 0.016
#> GSM23183     5  0.0798      0.708 0.008 0.000 0.016 0.000 0.976
#> GSM23184     3  0.3508      0.644 0.000 0.000 0.748 0.000 0.252
#> GSM23196     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.0703      0.975 0.000 0.976 0.000 0.024 0.000
#> GSM23200     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23201     4  0.0880      0.947 0.000 0.032 0.000 0.968 0.000
#> GSM23202     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.1965      0.878 0.000 0.096 0.000 0.904 0.000
#> GSM23206     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23208     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23211     2  0.0000      0.998 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM23213     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.998 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
#> GSM23185     3  0.0000      0.864 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     1  0.4252      0.416 0.604 0.000 0.000 0.000 0.024 0.372
#> GSM23187     3  0.0000      0.864 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000      0.864 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000      0.864 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000      0.864 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.1584      0.889 0.000 0.000 0.064 0.000 0.928 0.008
#> GSM23192     6  0.1059      0.990 0.004 0.000 0.016 0.000 0.016 0.964
#> GSM23193     5  0.1649      0.858 0.040 0.000 0.008 0.000 0.936 0.016
#> GSM23194     3  0.4010      0.278 0.000 0.000 0.584 0.000 0.008 0.408
#> GSM23195     6  0.0717      0.990 0.000 0.000 0.016 0.000 0.008 0.976
#> GSM23159     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23160     3  0.3923      0.269 0.000 0.000 0.580 0.000 0.416 0.004
#> GSM23161     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23162     5  0.2003      0.863 0.000 0.000 0.116 0.000 0.884 0.000
#> GSM23163     1  0.0692      0.915 0.976 0.000 0.000 0.000 0.020 0.004
#> GSM23164     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23165     1  0.0891      0.912 0.968 0.000 0.000 0.000 0.024 0.008
#> GSM23166     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23167     1  0.0777      0.914 0.972 0.000 0.000 0.000 0.024 0.004
#> GSM23168     3  0.3314      0.603 0.000 0.000 0.740 0.000 0.256 0.004
#> GSM23169     5  0.2553      0.842 0.000 0.000 0.008 0.000 0.848 0.144
#> GSM23170     1  0.0692      0.915 0.976 0.000 0.000 0.000 0.020 0.004
#> GSM23171     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23172     1  0.0458      0.916 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23173     5  0.3315      0.863 0.000 0.000 0.076 0.000 0.820 0.104
#> GSM23174     1  0.0000      0.918 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23176     1  0.0891      0.912 0.968 0.000 0.000 0.000 0.024 0.008
#> GSM23177     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23178     1  0.1088      0.908 0.960 0.000 0.000 0.000 0.024 0.016
#> GSM23179     3  0.0146      0.863 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM23180     1  0.3360      0.647 0.732 0.000 0.000 0.000 0.264 0.004
#> GSM23181     1  0.0458      0.919 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM23182     1  0.5888      0.246 0.500 0.000 0.000 0.212 0.284 0.004
#> GSM23183     6  0.0862      0.992 0.004 0.000 0.016 0.000 0.008 0.972
#> GSM23184     3  0.0260      0.861 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM23196     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.2333      0.856 0.000 0.872 0.000 0.120 0.004 0.004
#> GSM23200     2  0.0146      0.985 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23201     4  0.1851      0.923 0.000 0.024 0.000 0.928 0.036 0.012
#> GSM23202     4  0.0000      0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.2833      0.837 0.000 0.104 0.000 0.860 0.024 0.012
#> GSM23206     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.0146      0.985 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM23208     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.0837      0.966 0.000 0.972 0.000 0.020 0.004 0.004
#> GSM23211     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000      0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000      0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000      0.987 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 cell.type(p) disease.state(p) k
#> ATC:skmeans 55     3.96e-04         0.464825 2
#> ATC:skmeans 52     4.17e-11         0.000923 3
#> ATC:skmeans 51     4.89e-11         0.000950 4
#> ATC:skmeans 50     3.61e-10         0.001492 5
#> ATC:skmeans 53     3.36e-10         0.000781 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 11993 rows and 57 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 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 ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.823           0.904       0.959         0.5013 0.495   0.495
#> 3 3 0.861           0.901       0.959         0.3448 0.696   0.459
#> 4 4 0.976           0.902       0.962         0.1082 0.893   0.686
#> 5 5 0.990           0.941       0.975         0.0620 0.930   0.736
#> 6 6 0.931           0.824       0.925         0.0231 0.959   0.811

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

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

There is also optional best \(k\) = 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
#> GSM23185     2   0.000     0.9581 0.000 1.000
#> GSM23186     1   0.000     0.9496 1.000 0.000
#> GSM23187     2   0.000     0.9581 0.000 1.000
#> GSM23188     2   0.000     0.9581 0.000 1.000
#> GSM23189     2   0.000     0.9581 0.000 1.000
#> GSM23190     2   0.000     0.9581 0.000 1.000
#> GSM23191     1   0.760     0.7328 0.780 0.220
#> GSM23192     1   0.000     0.9496 1.000 0.000
#> GSM23193     1   0.000     0.9496 1.000 0.000
#> GSM23194     2   0.311     0.9230 0.056 0.944
#> GSM23195     2   0.327     0.9196 0.060 0.940
#> GSM23159     1   0.000     0.9496 1.000 0.000
#> GSM23160     1   0.760     0.7328 0.780 0.220
#> GSM23161     1   0.000     0.9496 1.000 0.000
#> GSM23162     1   0.760     0.7328 0.780 0.220
#> GSM23163     1   0.000     0.9496 1.000 0.000
#> GSM23164     1   0.000     0.9496 1.000 0.000
#> GSM23165     1   0.000     0.9496 1.000 0.000
#> GSM23166     1   0.000     0.9496 1.000 0.000
#> GSM23167     1   0.000     0.9496 1.000 0.000
#> GSM23168     1   0.932     0.4886 0.652 0.348
#> GSM23169     1   0.000     0.9496 1.000 0.000
#> GSM23170     1   0.000     0.9496 1.000 0.000
#> GSM23171     1   0.000     0.9496 1.000 0.000
#> GSM23172     1   0.000     0.9496 1.000 0.000
#> GSM23173     1   0.722     0.7588 0.800 0.200
#> GSM23174     1   0.000     0.9496 1.000 0.000
#> GSM23175     1   0.000     0.9496 1.000 0.000
#> GSM23176     1   0.000     0.9496 1.000 0.000
#> GSM23177     1   0.000     0.9496 1.000 0.000
#> GSM23178     1   0.000     0.9496 1.000 0.000
#> GSM23179     2   0.295     0.9261 0.052 0.948
#> GSM23180     1   0.000     0.9496 1.000 0.000
#> GSM23181     1   0.000     0.9496 1.000 0.000
#> GSM23182     1   0.000     0.9496 1.000 0.000
#> GSM23183     1   0.000     0.9496 1.000 0.000
#> GSM23184     2   0.753     0.7217 0.216 0.784
#> GSM23196     2   0.000     0.9581 0.000 1.000
#> GSM23197     2   0.000     0.9581 0.000 1.000
#> GSM23198     2   0.000     0.9581 0.000 1.000
#> GSM23199     2   0.000     0.9581 0.000 1.000
#> GSM23200     2   0.000     0.9581 0.000 1.000
#> GSM23201     2   0.998     0.0116 0.476 0.524
#> GSM23202     1   0.000     0.9496 1.000 0.000
#> GSM23203     2   0.000     0.9581 0.000 1.000
#> GSM23204     2   0.000     0.9581 0.000 1.000
#> GSM23205     2   0.295     0.9261 0.052 0.948
#> GSM23206     2   0.000     0.9581 0.000 1.000
#> GSM23207     2   0.000     0.9581 0.000 1.000
#> GSM23208     2   0.000     0.9581 0.000 1.000
#> GSM23209     2   0.000     0.9581 0.000 1.000
#> GSM23210     2   0.000     0.9581 0.000 1.000
#> GSM23211     2   0.000     0.9581 0.000 1.000
#> GSM23212     2   0.311     0.9230 0.056 0.944
#> GSM23213     1   0.506     0.8528 0.888 0.112
#> GSM23214     1   0.343     0.9003 0.936 0.064
#> GSM23215     2   0.000     0.9581 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
#> GSM23185     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23186     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23187     3  0.0747     0.9351 0.000 0.016 0.984
#> GSM23188     3  0.3879     0.7908 0.000 0.152 0.848
#> GSM23189     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23190     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23191     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23192     3  0.0237     0.9444 0.004 0.000 0.996
#> GSM23193     3  0.3816     0.8143 0.148 0.000 0.852
#> GSM23194     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23195     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23159     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23160     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23161     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23162     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23163     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23164     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23165     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23166     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23167     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23168     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23169     3  0.3752     0.8187 0.144 0.000 0.856
#> GSM23170     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23171     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23172     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23173     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23174     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23175     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23176     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23177     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23178     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23179     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23180     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23181     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23182     1  0.0000     0.9658 1.000 0.000 0.000
#> GSM23183     3  0.0237     0.9443 0.004 0.000 0.996
#> GSM23184     3  0.0000     0.9465 0.000 0.000 1.000
#> GSM23196     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23197     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23198     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23199     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23200     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23201     3  0.6140     0.2808 0.000 0.404 0.596
#> GSM23202     1  0.3879     0.7928 0.848 0.000 0.152
#> GSM23203     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23204     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23205     2  0.4002     0.7935 0.000 0.840 0.160
#> GSM23206     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23207     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23208     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23209     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23210     2  0.0424     0.9431 0.000 0.992 0.008
#> GSM23211     2  0.0000     0.9489 0.000 1.000 0.000
#> GSM23212     2  0.4002     0.7935 0.000 0.840 0.160
#> GSM23213     2  0.9046     0.3585 0.312 0.528 0.160
#> GSM23214     1  0.9389     0.0872 0.468 0.352 0.180
#> GSM23215     2  0.0000     0.9489 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
#> GSM23185     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23186     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23187     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23188     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23189     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23190     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23191     3  0.2408     0.8698 0.000 0.000 0.896 0.104
#> GSM23192     3  0.2522     0.8853 0.016 0.000 0.908 0.076
#> GSM23193     4  0.4998     0.0111 0.000 0.000 0.488 0.512
#> GSM23194     3  0.0707     0.9210 0.000 0.000 0.980 0.020
#> GSM23195     3  0.4898     0.2774 0.000 0.000 0.584 0.416
#> GSM23159     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0592     0.9221 0.000 0.000 0.984 0.016
#> GSM23161     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23162     3  0.1557     0.9041 0.000 0.000 0.944 0.056
#> GSM23163     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23164     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23165     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23166     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23167     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23169     4  0.4996     0.0264 0.000 0.000 0.484 0.516
#> GSM23170     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23173     3  0.3764     0.7232 0.000 0.000 0.784 0.216
#> GSM23174     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0921     0.9693 0.972 0.000 0.000 0.028
#> GSM23176     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23180     1  0.1389     0.9478 0.952 0.000 0.000 0.048
#> GSM23181     1  0.0000     0.9952 1.000 0.000 0.000 0.000
#> GSM23182     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23183     3  0.2271     0.8893 0.008 0.000 0.916 0.076
#> GSM23184     3  0.0000     0.9251 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23199     2  0.2149     0.9075 0.000 0.912 0.000 0.088
#> GSM23200     2  0.0469     0.9845 0.000 0.988 0.000 0.012
#> GSM23201     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23202     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23203     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23205     4  0.0336     0.8518 0.000 0.008 0.000 0.992
#> GSM23206     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23207     2  0.0469     0.9845 0.000 0.988 0.000 0.012
#> GSM23208     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23210     2  0.0469     0.9845 0.000 0.988 0.000 0.012
#> GSM23211     2  0.0000     0.9905 0.000 1.000 0.000 0.000
#> GSM23212     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23213     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23214     4  0.0000     0.8588 0.000 0.000 0.000 1.000
#> GSM23215     2  0.0000     0.9905 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
#> GSM23185     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23186     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23187     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23188     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23189     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23190     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23191     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23192     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23193     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23194     3  0.4294      0.150 0.000 0.000 0.532 0.000 0.468
#> GSM23195     5  0.0609      0.945 0.000 0.000 0.020 0.000 0.980
#> GSM23159     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23160     3  0.3003      0.753 0.000 0.000 0.812 0.000 0.188
#> GSM23161     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23162     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23163     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23164     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23166     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23169     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23170     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23171     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23173     5  0.0000      0.957 0.000 0.000 0.000 0.000 1.000
#> GSM23174     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23176     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23177     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23179     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23180     5  0.3305      0.676 0.224 0.000 0.000 0.000 0.776
#> GSM23181     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM23182     4  0.2648      0.811 0.000 0.000 0.000 0.848 0.152
#> GSM23183     5  0.0609      0.945 0.000 0.000 0.020 0.000 0.980
#> GSM23184     3  0.0000      0.923 0.000 0.000 1.000 0.000 0.000
#> GSM23196     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23199     2  0.1908      0.924 0.000 0.908 0.000 0.092 0.000
#> GSM23200     2  0.1908      0.924 0.000 0.908 0.000 0.092 0.000
#> GSM23201     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23202     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23203     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23205     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23206     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23207     2  0.1908      0.924 0.000 0.908 0.000 0.092 0.000
#> GSM23208     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23210     2  0.1908      0.924 0.000 0.908 0.000 0.092 0.000
#> GSM23211     2  0.0000      0.971 0.000 1.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23213     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23214     4  0.0000      0.973 0.000 0.000 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.971 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
#> GSM23185     3  0.0000     0.8357 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.3634     0.4239 0.356 0.000 0.000 0.000 0.000 0.644
#> GSM23187     3  0.0000     0.8357 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000     0.8357 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000     0.8357 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000     0.8357 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.1910     0.6229 0.000 0.000 0.000 0.000 0.892 0.108
#> GSM23192     6  0.0363     0.7922 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM23193     5  0.2048     0.6197 0.000 0.000 0.000 0.000 0.880 0.120
#> GSM23194     3  0.5051     0.5169 0.000 0.000 0.596 0.000 0.104 0.300
#> GSM23195     6  0.0363     0.7922 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM23159     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23160     5  0.3843    -0.1811 0.000 0.000 0.452 0.000 0.548 0.000
#> GSM23161     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23162     5  0.0000     0.6005 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM23163     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23164     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23165     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23166     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23167     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23168     5  0.3860    -0.2307 0.000 0.000 0.472 0.000 0.528 0.000
#> GSM23169     5  0.3126     0.5071 0.000 0.000 0.000 0.000 0.752 0.248
#> GSM23170     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23171     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23172     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23173     5  0.2135     0.6185 0.000 0.000 0.000 0.000 0.872 0.128
#> GSM23174     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23175     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23176     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23177     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23178     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23179     3  0.2950     0.7416 0.000 0.000 0.828 0.000 0.148 0.024
#> GSM23180     5  0.5355     0.0743 0.424 0.000 0.000 0.000 0.468 0.108
#> GSM23181     1  0.0000     1.0000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23182     4  0.2651     0.8319 0.000 0.000 0.000 0.860 0.112 0.028
#> GSM23183     6  0.0363     0.7922 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM23184     3  0.4264     0.1098 0.000 0.000 0.496 0.000 0.488 0.016
#> GSM23196     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.2070     0.9108 0.000 0.896 0.000 0.092 0.000 0.012
#> GSM23200     2  0.1745     0.9302 0.000 0.920 0.000 0.068 0.000 0.012
#> GSM23201     4  0.1075     0.9307 0.000 0.000 0.000 0.952 0.048 0.000
#> GSM23202     4  0.0000     0.9626 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.0363     0.9569 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM23206     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23207     2  0.1745     0.9302 0.000 0.920 0.000 0.068 0.000 0.012
#> GSM23208     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.2164     0.9186 0.000 0.900 0.000 0.068 0.000 0.032
#> GSM23211     2  0.0000     0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.9626 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000     0.9626 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000     0.9626 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000     0.9719 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 cell.type(p) disease.state(p) k
#> ATC:pam 55     9.28e-05         4.56e-01 2
#> ATC:pam 54     1.70e-11         5.69e-04 3
#> ATC:pam 54     6.81e-11         2.20e-04 4
#> ATC:pam 56     1.21e-10         1.00e-03 5
#> ATC:pam 52     2.97e-09         1.15e-05 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 11993 rows and 57 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-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.518           0.861       0.909         0.4621 0.536   0.536
#> 3 3 0.911           0.910       0.957         0.4573 0.723   0.513
#> 4 4 1.000           0.966       0.982         0.0869 0.947   0.837
#> 5 5 0.857           0.800       0.814         0.0805 0.913   0.695
#> 6 6 0.860           0.872       0.907         0.0515 0.910   0.614

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM23185     2  0.8713      0.758 0.292 0.708
#> GSM23186     1  0.0000      0.981 1.000 0.000
#> GSM23187     2  0.8713      0.758 0.292 0.708
#> GSM23188     2  0.8713      0.758 0.292 0.708
#> GSM23189     2  0.8713      0.758 0.292 0.708
#> GSM23190     2  0.8713      0.758 0.292 0.708
#> GSM23191     2  0.8713      0.758 0.292 0.708
#> GSM23192     1  0.5059      0.852 0.888 0.112
#> GSM23193     2  0.8713      0.758 0.292 0.708
#> GSM23194     2  0.8713      0.758 0.292 0.708
#> GSM23195     2  0.6247      0.806 0.156 0.844
#> GSM23159     1  0.0000      0.981 1.000 0.000
#> GSM23160     2  0.8713      0.758 0.292 0.708
#> GSM23161     1  0.0000      0.981 1.000 0.000
#> GSM23162     2  0.8713      0.758 0.292 0.708
#> GSM23163     1  0.0000      0.981 1.000 0.000
#> GSM23164     1  0.0000      0.981 1.000 0.000
#> GSM23165     1  0.0000      0.981 1.000 0.000
#> GSM23166     1  0.0000      0.981 1.000 0.000
#> GSM23167     1  0.0000      0.981 1.000 0.000
#> GSM23168     2  0.8713      0.758 0.292 0.708
#> GSM23169     2  0.8713      0.758 0.292 0.708
#> GSM23170     1  0.0000      0.981 1.000 0.000
#> GSM23171     1  0.0000      0.981 1.000 0.000
#> GSM23172     1  0.0000      0.981 1.000 0.000
#> GSM23173     2  0.8713      0.758 0.292 0.708
#> GSM23174     1  0.0000      0.981 1.000 0.000
#> GSM23175     1  0.0000      0.981 1.000 0.000
#> GSM23176     1  0.0000      0.981 1.000 0.000
#> GSM23177     1  0.0000      0.981 1.000 0.000
#> GSM23178     1  0.0000      0.981 1.000 0.000
#> GSM23179     2  0.8713      0.758 0.292 0.708
#> GSM23180     1  0.3584      0.910 0.932 0.068
#> GSM23181     1  0.0000      0.981 1.000 0.000
#> GSM23182     2  0.8555      0.764 0.280 0.720
#> GSM23183     1  0.5059      0.852 0.888 0.112
#> GSM23184     2  0.8713      0.758 0.292 0.708
#> GSM23196     2  0.0376      0.843 0.004 0.996
#> GSM23197     2  0.0376      0.843 0.004 0.996
#> GSM23198     2  0.0376      0.843 0.004 0.996
#> GSM23199     2  0.0376      0.843 0.004 0.996
#> GSM23200     2  0.0376      0.843 0.004 0.996
#> GSM23201     2  0.0376      0.843 0.004 0.996
#> GSM23202     2  0.0376      0.843 0.004 0.996
#> GSM23203     2  0.0376      0.843 0.004 0.996
#> GSM23204     2  0.0376      0.843 0.004 0.996
#> GSM23205     2  0.0376      0.843 0.004 0.996
#> GSM23206     2  0.0376      0.843 0.004 0.996
#> GSM23207     2  0.0376      0.843 0.004 0.996
#> GSM23208     2  0.0376      0.843 0.004 0.996
#> GSM23209     2  0.0376      0.843 0.004 0.996
#> GSM23210     2  0.0376      0.843 0.004 0.996
#> GSM23211     2  0.0376      0.843 0.004 0.996
#> GSM23212     2  0.0376      0.843 0.004 0.996
#> GSM23213     2  0.0376      0.843 0.004 0.996
#> GSM23214     2  0.0376      0.843 0.004 0.996
#> GSM23215     2  0.0376      0.843 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM23185     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23186     1  0.1163      0.949 0.972 0.000 0.028
#> GSM23187     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23191     3  0.0424      0.920 0.008 0.000 0.992
#> GSM23192     3  0.4702      0.745 0.212 0.000 0.788
#> GSM23193     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23194     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23195     3  0.3551      0.828 0.132 0.000 0.868
#> GSM23159     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23160     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23161     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23162     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23163     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23164     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23169     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23170     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23173     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23174     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23175     1  0.5058      0.628 0.756 0.000 0.244
#> GSM23176     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23180     3  0.6204      0.344 0.424 0.000 0.576
#> GSM23181     1  0.0000      0.980 1.000 0.000 0.000
#> GSM23182     3  0.5621      0.593 0.308 0.000 0.692
#> GSM23183     3  0.5529      0.627 0.296 0.000 0.704
#> GSM23184     3  0.0000      0.924 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23197     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23198     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23199     2  0.1411      0.955 0.000 0.964 0.036
#> GSM23200     2  0.1411      0.955 0.000 0.964 0.036
#> GSM23201     2  0.6026      0.462 0.000 0.624 0.376
#> GSM23202     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23203     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23204     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23205     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23206     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23207     2  0.1411      0.955 0.000 0.964 0.036
#> GSM23208     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23209     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23210     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23211     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23212     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23213     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23214     2  0.1860      0.949 0.000 0.948 0.052
#> GSM23215     2  0.0000      0.957 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
#> GSM23185     3  0.0336      0.977 0.000 0.000 0.992 0.008
#> GSM23186     1  0.0336      0.989 0.992 0.000 0.008 0.000
#> GSM23187     3  0.0336      0.977 0.000 0.000 0.992 0.008
#> GSM23188     3  0.0336      0.977 0.000 0.000 0.992 0.008
#> GSM23189     3  0.0336      0.977 0.000 0.000 0.992 0.008
#> GSM23190     3  0.0336      0.977 0.000 0.000 0.992 0.008
#> GSM23191     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23192     3  0.0921      0.968 0.000 0.000 0.972 0.028
#> GSM23193     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23194     3  0.0188      0.980 0.000 0.000 0.996 0.004
#> GSM23195     3  0.0921      0.968 0.000 0.000 0.972 0.028
#> GSM23159     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23160     3  0.0000      0.980 0.000 0.000 1.000 0.000
#> GSM23161     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23162     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23163     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23164     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23165     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23166     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23167     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23168     3  0.0188      0.980 0.000 0.000 0.996 0.004
#> GSM23169     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23170     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23171     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23172     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23173     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23174     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23175     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23176     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23177     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23178     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23179     3  0.0188      0.980 0.000 0.000 0.996 0.004
#> GSM23180     3  0.3300      0.810 0.144 0.000 0.848 0.008
#> GSM23181     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM23182     3  0.0336      0.980 0.000 0.000 0.992 0.008
#> GSM23183     3  0.1936      0.941 0.032 0.000 0.940 0.028
#> GSM23184     3  0.0000      0.980 0.000 0.000 1.000 0.000
#> GSM23196     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23197     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23198     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23199     2  0.2342      0.901 0.000 0.912 0.008 0.080
#> GSM23200     2  0.2197      0.904 0.000 0.916 0.004 0.080
#> GSM23201     4  0.0469      0.995 0.000 0.000 0.012 0.988
#> GSM23202     4  0.0336      0.999 0.000 0.000 0.008 0.992
#> GSM23203     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23204     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23205     4  0.0336      0.999 0.000 0.000 0.008 0.992
#> GSM23206     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23207     2  0.2342      0.901 0.000 0.912 0.008 0.080
#> GSM23208     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23209     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23210     2  0.4973      0.503 0.000 0.644 0.008 0.348
#> GSM23211     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM23212     4  0.0336      0.999 0.000 0.000 0.008 0.992
#> GSM23213     4  0.0336      0.999 0.000 0.000 0.008 0.992
#> GSM23214     4  0.0336      0.999 0.000 0.000 0.008 0.992
#> GSM23215     2  0.0000      0.952 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
#> GSM23185     3  0.0290     0.7648 0.008 0.000 0.992 0.000 0.000
#> GSM23186     1  0.4542     0.9801 0.536 0.000 0.000 0.008 0.456
#> GSM23187     3  0.0290     0.7648 0.008 0.000 0.992 0.000 0.000
#> GSM23188     3  0.0290     0.7648 0.008 0.000 0.992 0.000 0.000
#> GSM23189     3  0.0290     0.7648 0.008 0.000 0.992 0.000 0.000
#> GSM23190     3  0.0290     0.7648 0.008 0.000 0.992 0.000 0.000
#> GSM23191     3  0.4283     0.7255 0.000 0.456 0.544 0.000 0.000
#> GSM23192     3  0.5856     0.6687 0.000 0.456 0.468 0.012 0.064
#> GSM23193     3  0.4283     0.7255 0.000 0.456 0.544 0.000 0.000
#> GSM23194     3  0.0162     0.7672 0.000 0.004 0.996 0.000 0.000
#> GSM23195     3  0.4953     0.7160 0.000 0.440 0.532 0.028 0.000
#> GSM23159     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23160     3  0.0000     0.7672 0.000 0.000 1.000 0.000 0.000
#> GSM23161     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23162     3  0.4219     0.7332 0.000 0.416 0.584 0.000 0.000
#> GSM23163     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23164     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23165     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23166     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23167     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23168     3  0.0000     0.7672 0.000 0.000 1.000 0.000 0.000
#> GSM23169     3  0.4283     0.7255 0.000 0.456 0.544 0.000 0.000
#> GSM23170     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23171     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23172     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23173     3  0.4283     0.7255 0.000 0.456 0.544 0.000 0.000
#> GSM23174     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23175     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23176     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23177     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23178     1  0.4291     0.9975 0.536 0.000 0.000 0.000 0.464
#> GSM23179     3  0.0000     0.7672 0.000 0.000 1.000 0.000 0.000
#> GSM23180     3  0.5241     0.7150 0.000 0.436 0.528 0.016 0.020
#> GSM23181     5  0.0000     1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM23182     3  0.5071     0.7170 0.000 0.440 0.532 0.016 0.012
#> GSM23183     2  0.6788    -0.4248 0.000 0.456 0.188 0.012 0.344
#> GSM23184     3  0.0000     0.7672 0.000 0.000 1.000 0.000 0.000
#> GSM23196     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23197     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23198     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23199     4  0.6392    -0.0423 0.332 0.184 0.000 0.484 0.000
#> GSM23200     2  0.6787     0.4690 0.332 0.380 0.000 0.288 0.000
#> GSM23201     4  0.1121     0.8289 0.000 0.044 0.000 0.956 0.000
#> GSM23202     4  0.0404     0.8542 0.000 0.000 0.000 0.988 0.012
#> GSM23203     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23204     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23205     4  0.0000     0.8532 0.000 0.000 0.000 1.000 0.000
#> GSM23206     2  0.4533     0.8385 0.448 0.544 0.000 0.008 0.000
#> GSM23207     2  0.6787     0.4690 0.332 0.380 0.000 0.288 0.000
#> GSM23208     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23209     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23210     4  0.4597     0.5257 0.260 0.044 0.000 0.696 0.000
#> GSM23211     2  0.4283     0.8451 0.456 0.544 0.000 0.000 0.000
#> GSM23212     4  0.0000     0.8532 0.000 0.000 0.000 1.000 0.000
#> GSM23213     4  0.0404     0.8542 0.000 0.000 0.000 0.988 0.012
#> GSM23214     4  0.0404     0.8542 0.000 0.000 0.000 0.988 0.012
#> GSM23215     2  0.4283     0.8451 0.456 0.544 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
#> GSM23185     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23186     6  0.2302      0.963 0.120 0.000 0.000 0.000 0.008 0.872
#> GSM23187     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23188     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23189     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23190     3  0.0000      0.784 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM23191     5  0.0146      0.957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM23192     5  0.0146      0.957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM23193     5  0.0000      0.956 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM23194     3  0.3584      0.749 0.000 0.000 0.688 0.000 0.308 0.004
#> GSM23195     5  0.0891      0.944 0.000 0.000 0.000 0.024 0.968 0.008
#> GSM23159     1  0.0260      0.993 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23160     3  0.3489      0.767 0.000 0.000 0.708 0.000 0.288 0.004
#> GSM23161     1  0.0260      0.993 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23162     3  0.3847      0.506 0.000 0.000 0.544 0.000 0.456 0.000
#> GSM23163     6  0.2178      0.974 0.132 0.000 0.000 0.000 0.000 0.868
#> GSM23164     1  0.0363      0.991 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM23165     6  0.2092      0.971 0.124 0.000 0.000 0.000 0.000 0.876
#> GSM23166     1  0.0865      0.966 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM23167     6  0.2491      0.970 0.164 0.000 0.000 0.000 0.000 0.836
#> GSM23168     3  0.3489      0.767 0.000 0.000 0.708 0.000 0.288 0.004
#> GSM23169     5  0.0000      0.956 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM23170     6  0.2491      0.970 0.164 0.000 0.000 0.000 0.000 0.836
#> GSM23171     1  0.0260      0.993 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23172     6  0.2527      0.968 0.168 0.000 0.000 0.000 0.000 0.832
#> GSM23173     5  0.0000      0.956 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM23174     6  0.2562      0.964 0.172 0.000 0.000 0.000 0.000 0.828
#> GSM23175     1  0.0000      0.986 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM23176     6  0.2135      0.973 0.128 0.000 0.000 0.000 0.000 0.872
#> GSM23177     1  0.0260      0.993 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23178     6  0.2178      0.974 0.132 0.000 0.000 0.000 0.000 0.868
#> GSM23179     3  0.3489      0.767 0.000 0.000 0.708 0.000 0.288 0.004
#> GSM23180     5  0.2731      0.884 0.012 0.000 0.000 0.044 0.876 0.068
#> GSM23181     1  0.0260      0.993 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23182     5  0.3213      0.839 0.004 0.000 0.000 0.084 0.836 0.076
#> GSM23183     5  0.0146      0.957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM23184     3  0.3489      0.767 0.000 0.000 0.708 0.000 0.288 0.004
#> GSM23196     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23197     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23198     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23199     2  0.3872      0.496 0.000 0.604 0.000 0.392 0.000 0.004
#> GSM23200     2  0.3862      0.503 0.000 0.608 0.000 0.388 0.000 0.004
#> GSM23201     4  0.1480      0.942 0.000 0.000 0.000 0.940 0.020 0.040
#> GSM23202     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23203     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23204     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23205     4  0.0146      0.986 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM23206     2  0.0260      0.859 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM23207     2  0.3862      0.503 0.000 0.608 0.000 0.388 0.000 0.004
#> GSM23208     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23209     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23210     2  0.3937      0.431 0.000 0.572 0.000 0.424 0.000 0.004
#> GSM23211     2  0.0000      0.863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM23212     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23213     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23214     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM23215     2  0.0000      0.863 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-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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 cell.type(p) disease.state(p) k
#> ATC:mclust 57     1.51e-04         0.305652 2
#> ATC:mclust 55     1.14e-12         0.000291 3
#> ATC:mclust 57     2.57e-12         0.000260 4
#> ATC:mclust 53     8.52e-11         0.004079 5
#> ATC:mclust 55     1.31e-10         0.005162 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 11993 rows and 57 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.825           0.907       0.961         0.4857 0.510   0.510
#> 3 3 0.906           0.912       0.961         0.3921 0.736   0.518
#> 4 4 0.841           0.858       0.908         0.1005 0.903   0.712
#> 5 5 0.740           0.764       0.836         0.0480 0.942   0.788
#> 6 6 0.725           0.706       0.813         0.0361 0.935   0.739

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
#> GSM23185     2  0.0000      0.964 0.000 1.000
#> GSM23186     1  0.0000      0.946 1.000 0.000
#> GSM23187     2  0.0000      0.964 0.000 1.000
#> GSM23188     2  0.0000      0.964 0.000 1.000
#> GSM23189     2  0.0000      0.964 0.000 1.000
#> GSM23190     2  0.0000      0.964 0.000 1.000
#> GSM23191     2  0.1633      0.947 0.024 0.976
#> GSM23192     1  0.8267      0.653 0.740 0.260
#> GSM23193     1  0.7453      0.729 0.788 0.212
#> GSM23194     2  0.0000      0.964 0.000 1.000
#> GSM23195     2  0.1633      0.947 0.024 0.976
#> GSM23159     1  0.0000      0.946 1.000 0.000
#> GSM23160     2  0.7219      0.744 0.200 0.800
#> GSM23161     1  0.0000      0.946 1.000 0.000
#> GSM23162     2  0.6438      0.794 0.164 0.836
#> GSM23163     1  0.0000      0.946 1.000 0.000
#> GSM23164     1  0.0000      0.946 1.000 0.000
#> GSM23165     1  0.0000      0.946 1.000 0.000
#> GSM23166     1  0.0000      0.946 1.000 0.000
#> GSM23167     1  0.0000      0.946 1.000 0.000
#> GSM23168     2  0.1414      0.950 0.020 0.980
#> GSM23169     1  0.6887      0.766 0.816 0.184
#> GSM23170     1  0.0000      0.946 1.000 0.000
#> GSM23171     1  0.0000      0.946 1.000 0.000
#> GSM23172     1  0.0000      0.946 1.000 0.000
#> GSM23173     2  0.8813      0.568 0.300 0.700
#> GSM23174     1  0.0000      0.946 1.000 0.000
#> GSM23175     1  0.0000      0.946 1.000 0.000
#> GSM23176     1  0.0000      0.946 1.000 0.000
#> GSM23177     1  0.0000      0.946 1.000 0.000
#> GSM23178     1  0.0000      0.946 1.000 0.000
#> GSM23179     2  0.0000      0.964 0.000 1.000
#> GSM23180     1  0.0000      0.946 1.000 0.000
#> GSM23181     1  0.0000      0.946 1.000 0.000
#> GSM23182     1  0.0000      0.946 1.000 0.000
#> GSM23183     1  0.9909      0.201 0.556 0.444
#> GSM23184     2  0.0000      0.964 0.000 1.000
#> GSM23196     2  0.0000      0.964 0.000 1.000
#> GSM23197     2  0.0000      0.964 0.000 1.000
#> GSM23198     2  0.0000      0.964 0.000 1.000
#> GSM23199     2  0.0000      0.964 0.000 1.000
#> GSM23200     2  0.0000      0.964 0.000 1.000
#> GSM23201     2  0.0000      0.964 0.000 1.000
#> GSM23202     2  0.9491      0.409 0.368 0.632
#> GSM23203     2  0.0000      0.964 0.000 1.000
#> GSM23204     2  0.0000      0.964 0.000 1.000
#> GSM23205     2  0.0000      0.964 0.000 1.000
#> GSM23206     2  0.0000      0.964 0.000 1.000
#> GSM23207     2  0.0000      0.964 0.000 1.000
#> GSM23208     2  0.0000      0.964 0.000 1.000
#> GSM23209     2  0.0000      0.964 0.000 1.000
#> GSM23210     2  0.0000      0.964 0.000 1.000
#> GSM23211     2  0.0000      0.964 0.000 1.000
#> GSM23212     2  0.0000      0.964 0.000 1.000
#> GSM23213     2  0.0000      0.964 0.000 1.000
#> GSM23214     2  0.0672      0.958 0.008 0.992
#> GSM23215     2  0.0000      0.964 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
#> GSM23185     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23186     1  0.1860      0.941 0.948 0.000 0.052
#> GSM23187     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23188     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23189     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23190     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23191     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23192     3  0.1753      0.894 0.048 0.000 0.952
#> GSM23193     3  0.5968      0.476 0.364 0.000 0.636
#> GSM23194     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23195     3  0.5180      0.765 0.032 0.156 0.812
#> GSM23159     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23160     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23161     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23162     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23163     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23164     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23165     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23166     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23167     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23168     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23169     3  0.5968      0.476 0.364 0.000 0.636
#> GSM23170     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23171     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23172     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23173     3  0.2066      0.887 0.060 0.000 0.940
#> GSM23174     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23175     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23176     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23177     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23178     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23179     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23180     1  0.0237      0.993 0.996 0.000 0.004
#> GSM23181     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23182     1  0.0000      0.997 1.000 0.000 0.000
#> GSM23183     3  0.1860      0.892 0.052 0.000 0.948
#> GSM23184     3  0.0000      0.916 0.000 0.000 1.000
#> GSM23196     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23197     2  0.5968      0.438 0.000 0.636 0.364
#> GSM23198     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23199     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23200     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23201     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23202     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23203     2  0.0237      0.955 0.000 0.996 0.004
#> GSM23204     3  0.5859      0.418 0.000 0.344 0.656
#> GSM23205     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23206     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23207     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23208     2  0.3116      0.859 0.000 0.892 0.108
#> GSM23209     2  0.5016      0.683 0.000 0.760 0.240
#> GSM23210     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23211     2  0.0237      0.955 0.000 0.996 0.004
#> GSM23212     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23213     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23214     2  0.0000      0.957 0.000 1.000 0.000
#> GSM23215     2  0.0000      0.957 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
#> GSM23185     3  0.1661      0.917 0.000 0.052 0.944 0.004
#> GSM23186     1  0.0672      0.956 0.984 0.008 0.000 0.008
#> GSM23187     3  0.0592      0.938 0.000 0.016 0.984 0.000
#> GSM23188     3  0.0707      0.937 0.000 0.020 0.980 0.000
#> GSM23189     3  0.0592      0.938 0.000 0.016 0.984 0.000
#> GSM23190     3  0.1305      0.928 0.000 0.036 0.960 0.004
#> GSM23191     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM23192     3  0.0657      0.940 0.000 0.004 0.984 0.012
#> GSM23193     3  0.3219      0.836 0.000 0.000 0.836 0.164
#> GSM23194     3  0.0336      0.940 0.000 0.000 0.992 0.008
#> GSM23195     3  0.5409      0.768 0.044 0.044 0.772 0.140
#> GSM23159     1  0.1557      0.950 0.944 0.000 0.000 0.056
#> GSM23160     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM23161     1  0.1557      0.950 0.944 0.000 0.000 0.056
#> GSM23162     3  0.0817      0.935 0.000 0.000 0.976 0.024
#> GSM23163     1  0.0336      0.960 0.992 0.000 0.000 0.008
#> GSM23164     1  0.1474      0.952 0.948 0.000 0.000 0.052
#> GSM23165     1  0.0524      0.958 0.988 0.004 0.000 0.008
#> GSM23166     1  0.1211      0.956 0.960 0.000 0.000 0.040
#> GSM23167     1  0.0336      0.960 0.992 0.000 0.000 0.008
#> GSM23168     3  0.0000      0.941 0.000 0.000 1.000 0.000
#> GSM23169     3  0.2973      0.857 0.000 0.000 0.856 0.144
#> GSM23170     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM23171     1  0.1211      0.956 0.960 0.000 0.000 0.040
#> GSM23172     1  0.0000      0.961 1.000 0.000 0.000 0.000
#> GSM23173     3  0.1940      0.907 0.000 0.000 0.924 0.076
#> GSM23174     1  0.0188      0.961 0.996 0.000 0.000 0.004
#> GSM23175     1  0.4382      0.646 0.704 0.000 0.000 0.296
#> GSM23176     1  0.0336      0.960 0.992 0.000 0.000 0.008
#> GSM23177     1  0.1474      0.952 0.948 0.000 0.000 0.052
#> GSM23178     1  0.0336      0.960 0.992 0.000 0.000 0.008
#> GSM23179     3  0.0188      0.940 0.000 0.000 0.996 0.004
#> GSM23180     4  0.5428      0.578 0.120 0.000 0.140 0.740
#> GSM23181     1  0.0921      0.959 0.972 0.000 0.000 0.028
#> GSM23182     4  0.3400      0.680 0.064 0.000 0.064 0.872
#> GSM23183     3  0.4034      0.739 0.192 0.008 0.796 0.004
#> GSM23184     3  0.0376      0.940 0.000 0.004 0.992 0.004
#> GSM23196     2  0.2408      0.860 0.000 0.896 0.000 0.104
#> GSM23197     2  0.0927      0.855 0.000 0.976 0.016 0.008
#> GSM23198     2  0.2408      0.860 0.000 0.896 0.000 0.104
#> GSM23199     2  0.4164      0.719 0.000 0.736 0.000 0.264
#> GSM23200     2  0.3975      0.751 0.000 0.760 0.000 0.240
#> GSM23201     4  0.2530      0.778 0.000 0.100 0.004 0.896
#> GSM23202     4  0.2760      0.776 0.000 0.128 0.000 0.872
#> GSM23203     2  0.1716      0.872 0.000 0.936 0.000 0.064
#> GSM23204     2  0.0804      0.851 0.000 0.980 0.012 0.008
#> GSM23205     4  0.4961      0.107 0.000 0.448 0.000 0.552
#> GSM23206     2  0.0469      0.868 0.000 0.988 0.000 0.012
#> GSM23207     2  0.3975      0.751 0.000 0.760 0.000 0.240
#> GSM23208     2  0.0188      0.862 0.000 0.996 0.004 0.000
#> GSM23209     2  0.0376      0.860 0.000 0.992 0.004 0.004
#> GSM23210     2  0.4356      0.678 0.000 0.708 0.000 0.292
#> GSM23211     2  0.1211      0.874 0.000 0.960 0.000 0.040
#> GSM23212     4  0.4008      0.646 0.000 0.244 0.000 0.756
#> GSM23213     4  0.2647      0.781 0.000 0.120 0.000 0.880
#> GSM23214     4  0.2530      0.782 0.000 0.112 0.000 0.888
#> GSM23215     2  0.1118      0.874 0.000 0.964 0.000 0.036

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM23185     3  0.3163      0.811 0.000 0.164 0.824 0.000 0.012
#> GSM23186     1  0.2722      0.798 0.868 0.008 0.004 0.000 0.120
#> GSM23187     3  0.1117      0.859 0.000 0.016 0.964 0.000 0.020
#> GSM23188     3  0.2722      0.836 0.000 0.020 0.872 0.000 0.108
#> GSM23189     3  0.1697      0.856 0.000 0.060 0.932 0.000 0.008
#> GSM23190     3  0.3884      0.674 0.000 0.288 0.708 0.000 0.004
#> GSM23191     3  0.5006      0.685 0.000 0.180 0.704 0.000 0.116
#> GSM23192     3  0.3471      0.794 0.000 0.012 0.820 0.012 0.156
#> GSM23193     3  0.2669      0.826 0.000 0.000 0.876 0.020 0.104
#> GSM23194     3  0.2645      0.831 0.000 0.008 0.884 0.012 0.096
#> GSM23195     3  0.6172      0.524 0.000 0.012 0.600 0.216 0.172
#> GSM23159     1  0.4074      0.589 0.636 0.000 0.000 0.000 0.364
#> GSM23160     3  0.1877      0.853 0.000 0.064 0.924 0.000 0.012
#> GSM23161     1  0.2690      0.835 0.844 0.000 0.000 0.000 0.156
#> GSM23162     3  0.2729      0.839 0.000 0.028 0.884 0.004 0.084
#> GSM23163     1  0.0703      0.881 0.976 0.000 0.000 0.000 0.024
#> GSM23164     1  0.3274      0.784 0.780 0.000 0.000 0.000 0.220
#> GSM23165     1  0.0798      0.880 0.976 0.008 0.000 0.000 0.016
#> GSM23166     1  0.2605      0.840 0.852 0.000 0.000 0.000 0.148
#> GSM23167     1  0.0000      0.886 1.000 0.000 0.000 0.000 0.000
#> GSM23168     3  0.1877      0.853 0.000 0.064 0.924 0.000 0.012
#> GSM23169     3  0.1836      0.849 0.000 0.000 0.932 0.032 0.036
#> GSM23170     1  0.0000      0.886 1.000 0.000 0.000 0.000 0.000
#> GSM23171     1  0.1043      0.883 0.960 0.000 0.000 0.000 0.040
#> GSM23172     1  0.0162      0.886 0.996 0.000 0.000 0.000 0.004
#> GSM23173     3  0.1996      0.851 0.000 0.004 0.928 0.036 0.032
#> GSM23174     1  0.0794      0.886 0.972 0.000 0.000 0.000 0.028
#> GSM23175     1  0.3224      0.825 0.824 0.000 0.000 0.016 0.160
#> GSM23176     1  0.0510      0.882 0.984 0.000 0.000 0.000 0.016
#> GSM23177     1  0.4262      0.441 0.560 0.000 0.000 0.000 0.440
#> GSM23178     1  0.0955      0.878 0.968 0.004 0.000 0.000 0.028
#> GSM23179     3  0.0693      0.856 0.000 0.008 0.980 0.000 0.012
#> GSM23180     5  0.4386      0.760 0.036 0.000 0.096 0.068 0.800
#> GSM23181     1  0.0794      0.886 0.972 0.000 0.000 0.000 0.028
#> GSM23182     5  0.4305      0.786 0.008 0.000 0.048 0.176 0.768
#> GSM23183     3  0.5078      0.717 0.068 0.012 0.736 0.012 0.172
#> GSM23184     3  0.2136      0.845 0.000 0.088 0.904 0.000 0.008
#> GSM23196     4  0.4171      0.438 0.000 0.396 0.000 0.604 0.000
#> GSM23197     2  0.1569      0.761 0.000 0.944 0.008 0.044 0.004
#> GSM23198     4  0.4126      0.474 0.000 0.380 0.000 0.620 0.000
#> GSM23199     4  0.2929      0.771 0.000 0.180 0.000 0.820 0.000
#> GSM23200     4  0.2929      0.769 0.000 0.180 0.000 0.820 0.000
#> GSM23201     5  0.5524      0.567 0.000 0.092 0.004 0.276 0.628
#> GSM23202     4  0.2830      0.740 0.000 0.044 0.000 0.876 0.080
#> GSM23203     2  0.4171      0.349 0.000 0.604 0.000 0.396 0.000
#> GSM23204     2  0.0898      0.723 0.000 0.972 0.020 0.008 0.000
#> GSM23205     4  0.4360      0.616 0.000 0.284 0.000 0.692 0.024
#> GSM23206     2  0.3336      0.731 0.000 0.772 0.000 0.228 0.000
#> GSM23207     4  0.2966      0.768 0.000 0.184 0.000 0.816 0.000
#> GSM23208     2  0.2561      0.789 0.000 0.856 0.000 0.144 0.000
#> GSM23209     2  0.1430      0.771 0.000 0.944 0.004 0.052 0.000
#> GSM23210     4  0.2471      0.775 0.000 0.136 0.000 0.864 0.000
#> GSM23211     2  0.3684      0.654 0.000 0.720 0.000 0.280 0.000
#> GSM23212     4  0.0162      0.737 0.000 0.000 0.000 0.996 0.004
#> GSM23213     4  0.0162      0.737 0.000 0.000 0.000 0.996 0.004
#> GSM23214     4  0.1251      0.732 0.000 0.008 0.000 0.956 0.036
#> GSM23215     2  0.2732      0.784 0.000 0.840 0.000 0.160 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
#> GSM23185     3  0.3432     0.7302 0.000 0.040 0.828 0.000 0.024 0.108
#> GSM23186     1  0.2998     0.8090 0.852 0.000 0.000 0.004 0.068 0.076
#> GSM23187     3  0.1738     0.7748 0.000 0.004 0.928 0.000 0.016 0.052
#> GSM23188     3  0.2810     0.7028 0.000 0.004 0.832 0.000 0.008 0.156
#> GSM23189     3  0.1036     0.7840 0.000 0.008 0.964 0.000 0.024 0.004
#> GSM23190     3  0.3790     0.7104 0.000 0.088 0.812 0.004 0.020 0.076
#> GSM23191     3  0.4714     0.6600 0.000 0.048 0.720 0.000 0.180 0.052
#> GSM23192     6  0.3946     0.8392 0.008 0.000 0.304 0.004 0.004 0.680
#> GSM23193     3  0.4093     0.6281 0.000 0.000 0.680 0.024 0.292 0.004
#> GSM23194     6  0.3620     0.7896 0.000 0.000 0.352 0.000 0.000 0.648
#> GSM23195     6  0.5051     0.7751 0.020 0.000 0.192 0.112 0.000 0.676
#> GSM23159     1  0.4333     0.5480 0.596 0.000 0.004 0.000 0.380 0.020
#> GSM23160     3  0.1007     0.7898 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM23161     1  0.3161     0.7901 0.776 0.000 0.000 0.000 0.216 0.008
#> GSM23162     3  0.3187     0.7586 0.000 0.000 0.836 0.008 0.112 0.044
#> GSM23163     1  0.1059     0.8700 0.964 0.000 0.000 0.004 0.016 0.016
#> GSM23164     1  0.2593     0.8345 0.844 0.000 0.000 0.000 0.148 0.008
#> GSM23165     1  0.1897     0.8470 0.908 0.000 0.000 0.004 0.084 0.004
#> GSM23166     1  0.2442     0.8355 0.852 0.000 0.000 0.000 0.144 0.004
#> GSM23167     1  0.1003     0.8700 0.964 0.000 0.000 0.004 0.028 0.004
#> GSM23168     3  0.0972     0.7890 0.000 0.000 0.964 0.000 0.028 0.008
#> GSM23169     3  0.4840     0.5452 0.000 0.000 0.700 0.024 0.088 0.188
#> GSM23170     1  0.0551     0.8710 0.984 0.000 0.000 0.004 0.008 0.004
#> GSM23171     1  0.1196     0.8708 0.952 0.000 0.000 0.000 0.040 0.008
#> GSM23172     1  0.0260     0.8726 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM23173     3  0.5187     0.6318 0.000 0.000 0.696 0.152 0.068 0.084
#> GSM23174     1  0.0937     0.8712 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM23175     1  0.3737     0.7872 0.772 0.000 0.000 0.036 0.184 0.008
#> GSM23176     1  0.1296     0.8637 0.948 0.000 0.000 0.004 0.044 0.004
#> GSM23177     1  0.4404     0.5116 0.576 0.000 0.008 0.000 0.400 0.016
#> GSM23178     1  0.1642     0.8604 0.936 0.000 0.000 0.004 0.028 0.032
#> GSM23179     3  0.2408     0.7480 0.000 0.000 0.876 0.004 0.012 0.108
#> GSM23180     5  0.4018     0.5107 0.016 0.000 0.120 0.072 0.788 0.004
#> GSM23181     1  0.1787     0.8671 0.920 0.000 0.000 0.004 0.068 0.008
#> GSM23182     5  0.3918     0.5377 0.000 0.000 0.036 0.208 0.748 0.008
#> GSM23183     6  0.4625     0.8253 0.072 0.000 0.236 0.008 0.000 0.684
#> GSM23184     3  0.2897     0.7444 0.000 0.012 0.852 0.004 0.012 0.120
#> GSM23196     2  0.3531     0.5178 0.000 0.672 0.000 0.328 0.000 0.000
#> GSM23197     2  0.1413     0.7902 0.000 0.948 0.004 0.036 0.008 0.004
#> GSM23198     2  0.3993     0.3305 0.000 0.592 0.000 0.400 0.000 0.008
#> GSM23199     4  0.3940     0.4209 0.000 0.348 0.000 0.640 0.000 0.012
#> GSM23200     4  0.2738     0.7242 0.000 0.176 0.000 0.820 0.000 0.004
#> GSM23201     5  0.7329    -0.0164 0.000 0.372 0.020 0.124 0.376 0.108
#> GSM23202     4  0.4794     0.6606 0.000 0.140 0.000 0.724 0.100 0.036
#> GSM23203     2  0.2773     0.7460 0.000 0.828 0.004 0.164 0.000 0.004
#> GSM23204     2  0.2058     0.7165 0.000 0.916 0.024 0.000 0.012 0.048
#> GSM23205     2  0.6593     0.2931 0.000 0.524 0.000 0.232 0.156 0.088
#> GSM23206     2  0.1926     0.7962 0.000 0.912 0.000 0.068 0.000 0.020
#> GSM23207     4  0.2814     0.7268 0.000 0.172 0.000 0.820 0.000 0.008
#> GSM23208     2  0.1429     0.7983 0.000 0.940 0.004 0.052 0.000 0.004
#> GSM23209     2  0.0696     0.7735 0.000 0.980 0.004 0.004 0.004 0.008
#> GSM23210     4  0.6003     0.2692 0.000 0.308 0.000 0.432 0.000 0.260
#> GSM23211     2  0.2146     0.7804 0.000 0.880 0.004 0.116 0.000 0.000
#> GSM23212     4  0.1124     0.7042 0.000 0.036 0.000 0.956 0.008 0.000
#> GSM23213     4  0.1448     0.6799 0.000 0.024 0.000 0.948 0.012 0.016
#> GSM23214     4  0.2803     0.6611 0.000 0.028 0.000 0.876 0.064 0.032
#> GSM23215     2  0.1010     0.7959 0.000 0.960 0.000 0.036 0.004 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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 cell.type(p) disease.state(p) k
#> ATC:NMF 55     3.96e-05         3.10e-01 2
#> ATC:NMF 53     3.10e-12         5.93e-04 3
#> ATC:NMF 56     9.59e-11         8.60e-06 4
#> ATC:NMF 53     3.72e-10         4.55e-03 5
#> ATC:NMF 52     5.39e-10         1.85e-03 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