cola Report for GDS724

Date: 2019-12-25 22:16:32 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 62 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    62

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:mclust 2 1.000 1.000 1.000 **
CV:skmeans 4 1.000 0.971 0.976 ** 2,3
CV:NMF 2 1.000 1.000 1.000 **
MAD:pam 6 1.000 0.976 0.988 ** 2,3
MAD:NMF 2 1.000 0.977 0.992 **
ATC:pam 4 1.000 0.945 0.963 ** 2,3
SD:pam 6 0.969 0.929 0.971 ** 2,3,4
SD:skmeans 6 0.966 0.945 0.961 ** 2,3
MAD:skmeans 6 0.962 0.958 0.969 ** 2,3,5
CV:pam 5 0.948 0.900 0.944 * 2,3,4
MAD:mclust 6 0.930 0.915 0.947 * 2
MAD:hclust 4 0.918 0.984 0.973 *
ATC:skmeans 5 0.918 0.909 0.949 * 2,3,4
ATC:NMF 4 0.910 0.916 0.948 * 2
SD:NMF 3 0.902 0.886 0.951 * 2
ATC:hclust 4 0.877 0.959 0.955
CV:hclust 5 0.867 0.829 0.928
SD:hclust 4 0.859 0.935 0.907
CV:mclust 5 0.840 0.826 0.885
ATC:mclust 3 0.807 0.928 0.958
CV:kmeans 2 0.648 0.946 0.947
ATC:kmeans 2 0.591 0.885 0.907
SD:kmeans 2 0.500 0.930 0.939
MAD:kmeans 2 0.500 0.894 0.915

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.993       0.997          0.509 0.492   0.492
#> CV:NMF      2 1.000           1.000       1.000          0.509 0.492   0.492
#> MAD:NMF     2 1.000           0.977       0.992          0.508 0.492   0.492
#> ATC:NMF     2 1.000           1.000       1.000          0.507 0.494   0.494
#> SD:skmeans  2 1.000           1.000       1.000          0.509 0.492   0.492
#> CV:skmeans  2 1.000           1.000       1.000          0.509 0.492   0.492
#> MAD:skmeans 2 1.000           1.000       1.000          0.509 0.492   0.492
#> ATC:skmeans 2 1.000           0.999       1.000          0.507 0.494   0.494
#> SD:mclust   2 1.000           1.000       1.000          0.509 0.492   0.492
#> CV:mclust   2 0.390           0.232       0.655          0.464 0.772   0.772
#> MAD:mclust  2 1.000           1.000       1.000          0.509 0.492   0.492
#> ATC:mclust  2 0.715           0.850       0.919          0.444 0.535   0.535
#> SD:kmeans   2 0.500           0.930       0.939          0.497 0.492   0.492
#> CV:kmeans   2 0.648           0.946       0.947          0.491 0.492   0.492
#> MAD:kmeans  2 0.500           0.894       0.915          0.497 0.492   0.492
#> ATC:kmeans  2 0.591           0.885       0.907          0.456 0.494   0.494
#> SD:pam      2 1.000           0.986       0.993          0.506 0.494   0.494
#> CV:pam      2 1.000           0.946       0.980          0.505 0.494   0.494
#> MAD:pam     2 1.000           0.993       0.997          0.506 0.494   0.494
#> ATC:pam     2 1.000           0.986       0.994          0.508 0.492   0.492
#> SD:hclust   2 0.316           0.447       0.668          0.448 0.492   0.492
#> CV:hclust   2 0.367           0.799       0.836          0.485 0.492   0.492
#> MAD:hclust  2 0.526           0.915       0.912          0.459 0.511   0.511
#> ATC:hclust  2 0.732           0.887       0.922          0.394 0.535   0.535
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.902           0.886       0.951          0.238 0.862   0.723
#> CV:NMF      3 0.754           0.940       0.924          0.247 0.873   0.742
#> MAD:NMF     3 0.867           0.874       0.949          0.251 0.841   0.685
#> ATC:NMF     3 0.772           0.827       0.926          0.269 0.792   0.603
#> SD:skmeans  3 0.970           0.940       0.973          0.245 0.874   0.744
#> CV:skmeans  3 1.000           0.979       0.987          0.239 0.879   0.755
#> MAD:skmeans 3 1.000           0.976       0.985          0.248 0.874   0.744
#> ATC:skmeans 3 0.993           0.964       0.982          0.238 0.841   0.690
#> SD:mclust   3 0.892           0.865       0.900          0.218 0.876   0.748
#> CV:mclust   3 0.676           0.764       0.880          0.347 0.405   0.315
#> MAD:mclust  3 0.868           0.866       0.912          0.225 0.874   0.744
#> ATC:mclust  3 0.807           0.928       0.958          0.401 0.611   0.402
#> SD:kmeans   3 0.735           0.875       0.854          0.259 0.879   0.755
#> CV:kmeans   3 0.762           0.842       0.850          0.263 0.884   0.763
#> MAD:kmeans  3 0.766           0.871       0.836          0.263 0.879   0.755
#> ATC:kmeans  3 0.773           0.852       0.883          0.366 0.843   0.695
#> SD:pam      3 0.984           0.978       0.986          0.240 0.841   0.690
#> CV:pam      3 1.000           0.974       0.990          0.238 0.841   0.690
#> MAD:pam     3 1.000           0.998       0.999          0.243 0.841   0.690
#> ATC:pam     3 1.000           0.966       0.987          0.229 0.879   0.755
#> SD:hclust   3 0.714           0.813       0.912          0.438 0.874   0.744
#> CV:hclust   3 0.608           0.901       0.910          0.237 0.857   0.716
#> MAD:hclust  3 0.825           0.935       0.965          0.415 0.835   0.677
#> ATC:hclust  3 0.658           0.895       0.887          0.380 0.936   0.880
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.757           0.869       0.897         0.1763 0.824   0.551
#> CV:NMF      4 0.822           0.922       0.908         0.1534 0.889   0.696
#> MAD:NMF     4 0.840           0.808       0.911         0.1828 0.859   0.619
#> ATC:NMF     4 0.910           0.916       0.948         0.1702 0.789   0.469
#> SD:skmeans  4 0.846           0.882       0.928         0.1786 0.884   0.682
#> CV:skmeans  4 1.000           0.971       0.976         0.1623 0.895   0.718
#> MAD:skmeans 4 0.872           0.879       0.940         0.1878 0.884   0.682
#> ATC:skmeans 4 0.921           0.914       0.959         0.1689 0.895   0.718
#> SD:mclust   4 0.770           0.797       0.868         0.1734 0.835   0.584
#> CV:mclust   4 0.768           0.808       0.832         0.1292 0.911   0.761
#> MAD:mclust  4 0.825           0.870       0.912         0.1747 0.822   0.558
#> ATC:mclust  4 0.844           0.807       0.914         0.1792 0.820   0.558
#> SD:kmeans   4 0.659           0.874       0.853         0.1294 0.903   0.738
#> CV:kmeans   4 0.673           0.883       0.856         0.1325 0.887   0.703
#> MAD:kmeans  4 0.661           0.869       0.856         0.1335 0.903   0.738
#> ATC:kmeans  4 0.746           0.909       0.902         0.1348 0.887   0.703
#> SD:pam      4 0.929           0.957       0.972         0.1787 0.889   0.701
#> CV:pam      4 0.984           0.926       0.973         0.1624 0.895   0.718
#> MAD:pam     4 0.773           0.881       0.915         0.1795 0.889   0.701
#> ATC:pam     4 1.000           0.945       0.963         0.1546 0.874   0.671
#> SD:hclust   4 0.859           0.935       0.907         0.0873 0.903   0.734
#> CV:hclust   4 0.750           0.884       0.924         0.1807 0.885   0.698
#> MAD:hclust  4 0.918           0.984       0.973         0.1055 0.928   0.792
#> ATC:hclust  4 0.877           0.959       0.955         0.3192 0.789   0.552
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.777           0.721       0.811         0.0790 0.897   0.617
#> CV:NMF      5 0.857           0.782       0.891         0.0735 0.967   0.869
#> MAD:NMF     5 0.786           0.751       0.833         0.0661 0.886   0.587
#> ATC:NMF     5 0.761           0.722       0.862         0.0366 0.884   0.608
#> SD:skmeans  5 0.868           0.867       0.900         0.0672 0.929   0.726
#> CV:skmeans  5 0.898           0.898       0.900         0.0685 0.959   0.845
#> MAD:skmeans 5 0.930           0.937       0.952         0.0600 0.921   0.700
#> ATC:skmeans 5 0.918           0.909       0.949         0.0522 0.963   0.861
#> SD:mclust   5 0.726           0.642       0.794         0.0758 0.958   0.837
#> CV:mclust   5 0.840           0.826       0.885         0.0916 0.952   0.831
#> MAD:mclust  5 0.712           0.623       0.742         0.0698 0.884   0.647
#> ATC:mclust  5 0.747           0.770       0.874         0.0372 0.836   0.501
#> SD:kmeans   5 0.713           0.781       0.772         0.0805 0.950   0.819
#> CV:kmeans   5 0.745           0.739       0.845         0.0863 0.967   0.881
#> MAD:kmeans  5 0.733           0.875       0.795         0.0821 0.931   0.749
#> ATC:kmeans  5 0.750           0.825       0.843         0.0745 0.950   0.819
#> SD:pam      5 0.852           0.909       0.911         0.0735 0.928   0.732
#> CV:pam      5 0.948           0.900       0.944         0.0660 0.936   0.770
#> MAD:pam     5 0.866           0.893       0.897         0.0724 0.928   0.732
#> ATC:pam     5 0.873           0.838       0.879         0.0736 0.946   0.809
#> SD:hclust   5 0.858           0.903       0.934         0.0434 0.993   0.974
#> CV:hclust   5 0.867           0.829       0.928         0.0494 0.978   0.920
#> MAD:hclust  5 0.977           0.957       0.983         0.0272 0.994   0.977
#> ATC:hclust  5 0.879           0.932       0.952         0.0175 0.989   0.959
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.806           0.752       0.822         0.0440 0.880   0.493
#> CV:NMF      6 0.836           0.732       0.847         0.0467 0.907   0.616
#> MAD:NMF     6 0.813           0.731       0.835         0.0383 0.910   0.596
#> ATC:NMF     6 0.781           0.696       0.813         0.0489 0.893   0.582
#> SD:skmeans  6 0.966           0.945       0.961         0.0479 0.947   0.744
#> CV:skmeans  6 0.890           0.871       0.860         0.0607 0.938   0.725
#> MAD:skmeans 6 0.962           0.958       0.969         0.0446 0.956   0.783
#> ATC:skmeans 6 0.839           0.724       0.839         0.0502 0.956   0.808
#> SD:mclust   6 0.793           0.768       0.863         0.0557 0.925   0.667
#> CV:mclust   6 0.781           0.650       0.783         0.0493 0.909   0.653
#> MAD:mclust  6 0.930           0.915       0.947         0.0739 0.873   0.552
#> ATC:mclust  6 0.861           0.830       0.891         0.0381 0.934   0.741
#> SD:kmeans   6 0.838           0.886       0.856         0.0605 0.931   0.701
#> CV:kmeans   6 0.793           0.562       0.744         0.0508 0.897   0.621
#> MAD:kmeans  6 0.788           0.837       0.822         0.0521 0.942   0.724
#> ATC:kmeans  6 0.817           0.766       0.826         0.0505 0.978   0.910
#> SD:pam      6 0.969           0.929       0.971         0.0593 0.941   0.721
#> CV:pam      6 0.892           0.865       0.872         0.0591 0.905   0.604
#> MAD:pam     6 1.000           0.976       0.988         0.0577 0.942   0.724
#> ATC:pam     6 0.869           0.812       0.875         0.0681 0.915   0.654
#> SD:hclust   6 0.927           0.873       0.948         0.0391 0.988   0.956
#> CV:hclust   6 0.845           0.790       0.918         0.0210 0.969   0.880
#> MAD:hclust  6 0.921           0.901       0.960         0.0304 0.988   0.955
#> ATC:hclust  6 0.835           0.925       0.916         0.0441 0.959   0.834

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

collect_stats(res_list, k = 2)

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

collect_stats(res_list, k = 3)

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

collect_stats(res_list, k = 4)

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

collect_stats(res_list, k = 5)

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

collect_stats(res_list, k = 6)

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

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

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

collect_classes(res_list, k = 3)

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

collect_classes(res_list, k = 4)

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

collect_classes(res_list, k = 5)

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

collect_classes(res_list, k = 6)

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

Top rows overlap

Overlap of top rows from different top-row methods:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

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

top_rows_heatmap(res_list, top_n = 2000)

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

top_rows_heatmap(res_list, top_n = 3000)

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

top_rows_heatmap(res_list, top_n = 4000)

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

top_rows_heatmap(res_list, top_n = 5000)

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

Test to known annotations

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

test_to_known_factors(res_list, k = 2)
#>              n tissue(p) individual(p) k
#> SD:NMF      62  1.14e-12       0.83009 2
#> CV:NMF      62  1.14e-12       0.83009 2
#> MAD:NMF     61  1.90e-12       0.85244 2
#> ATC:NMF     62  3.65e-11       0.89063 2
#> SD:skmeans  62  1.14e-12       0.83009 2
#> CV:skmeans  62  1.14e-12       0.83009 2
#> MAD:skmeans 62  1.14e-12       0.83009 2
#> ATC:skmeans 62  3.65e-11       0.89063 2
#> SD:mclust   62  1.14e-12       0.83009 2
#> CV:mclust   39  1.03e-07       0.07010 2
#> MAD:mclust  62  1.14e-12       0.83009 2
#> ATC:mclust  58  5.61e-07       0.00348 2
#> SD:kmeans   62  1.14e-12       0.83009 2
#> CV:kmeans   62  1.14e-12       0.83009 2
#> MAD:kmeans  62  1.14e-12       0.83009 2
#> ATC:kmeans  62  3.65e-11       0.89063 2
#> SD:pam      62  3.65e-11       0.89063 2
#> CV:pam      60  1.89e-11       0.84582 2
#> MAD:pam     62  3.65e-11       0.89063 2
#> ATC:pam     62  1.14e-12       0.83009 2
#> SD:hclust   22        NA            NA 2
#> CV:hclust   61  1.90e-12       0.78776 2
#> MAD:hclust  62  1.20e-01       0.02271 2
#> ATC:hclust  62  7.91e-01       0.07592 2
test_to_known_factors(res_list, k = 3)
#>              n tissue(p) individual(p) k
#> SD:NMF      58  7.11e-11      2.44e-03 3
#> CV:NMF      62  1.54e-12      9.76e-04 3
#> MAD:NMF     59  4.31e-11      5.75e-03 3
#> ATC:NMF     57  5.80e-10      6.38e-04 3
#> SD:skmeans  60  4.17e-12      1.27e-04 3
#> CV:skmeans  62  1.49e-12      1.94e-04 3
#> MAD:skmeans 61  2.52e-12      2.33e-04 3
#> ATC:skmeans 62  1.49e-12      1.94e-04 3
#> SD:mclust   61  3.93e-13      2.21e-04 3
#> CV:mclust   52  3.63e-11      6.74e-06 3
#> MAD:mclust  60  6.48e-13      3.53e-04 3
#> ATC:mclust  62  9.16e-12      1.83e-04 3
#> SD:kmeans   61  2.46e-12      2.21e-04 3
#> CV:kmeans   60  4.01e-12      1.05e-04 3
#> MAD:kmeans  61  2.46e-12      2.21e-04 3
#> ATC:kmeans  59  6.65e-12      1.69e-04 3
#> SD:pam      62  1.49e-12      1.94e-04 3
#> CV:pam      62  1.49e-12      1.94e-04 3
#> MAD:pam     62  1.49e-12      1.94e-04 3
#> ATC:pam     61  2.42e-12      8.63e-05 3
#> SD:hclust   54  9.11e-11      1.20e-05 3
#> CV:hclust   61  2.42e-12      6.35e-05 3
#> MAD:hclust  62  1.36e-07      1.72e-04 3
#> ATC:hclust  62  9.79e-05      4.21e-05 3
test_to_known_factors(res_list, k = 4)
#>              n tissue(p) individual(p) k
#> SD:NMF      59  3.68e-11      3.90e-05 4
#> CV:NMF      61  1.32e-11      3.88e-05 4
#> MAD:NMF     56  9.86e-10      1.28e-05 4
#> ATC:NMF     60  1.42e-10      9.34e-05 4
#> SD:skmeans  59  3.50e-11      6.30e-06 4
#> CV:skmeans  62  7.66e-12      2.40e-06 4
#> MAD:skmeans 60  2.18e-11      4.00e-06 4
#> ATC:skmeans 60  2.34e-11      3.12e-06 4
#> SD:mclust   59  6.22e-12      6.34e-09 4
#> CV:mclust   58  1.57e-12      3.36e-07 4
#> MAD:mclust  61  1.51e-11      6.46e-09 4
#> ATC:mclust  54  7.45e-11      9.18e-08 4
#> SD:kmeans   62  8.75e-12      2.79e-06 4
#> CV:kmeans   62  8.75e-12      2.79e-06 4
#> MAD:kmeans  62  8.75e-12      2.79e-06 4
#> ATC:kmeans  60  2.31e-11      1.88e-06 4
#> SD:pam      62  7.83e-12      1.05e-05 4
#> CV:pam      60  1.99e-11      3.56e-06 4
#> MAD:pam     61  1.28e-11      1.67e-05 4
#> ATC:pam     60  1.32e-10      4.12e-06 4
#> SD:hclust   60  2.44e-11      4.43e-07 4
#> CV:hclust   60  3.51e-12      3.82e-07 4
#> MAD:hclust  62  5.13e-11      1.26e-06 4
#> ATC:hclust  61  7.52e-11      6.47e-06 4
test_to_known_factors(res_list, k = 5)
#>              n tissue(p) individual(p) k
#> SD:NMF      47  5.45e-08      4.67e-04 5
#> CV:NMF      58  2.62e-10      1.35e-04 5
#> MAD:NMF     52  4.69e-09      1.75e-05 5
#> ATC:NMF     52  1.84e-10      7.21e-06 5
#> SD:skmeans  59  2.84e-11      7.18e-09 5
#> CV:skmeans  62  3.62e-11      4.35e-09 5
#> MAD:skmeans 61  6.13e-11      1.62e-08 5
#> ATC:skmeans 61  6.65e-11      1.89e-08 5
#> SD:mclust   51  1.42e-09      2.99e-08 5
#> CV:mclust   57  7.84e-11      1.39e-06 5
#> MAD:mclust  37  9.24e-09      1.68e-07 5
#> ATC:mclust  55  2.06e-10      1.02e-06 5
#> SD:kmeans   60  1.07e-10      8.81e-09 5
#> CV:kmeans   58  2.84e-10      2.75e-07 5
#> MAD:kmeans  61  5.90e-11      6.14e-09 5
#> ATC:kmeans  59  1.74e-10      1.67e-08 5
#> SD:pam      62  3.70e-11      1.07e-08 5
#> CV:pam      60  9.23e-11      1.88e-05 5
#> MAD:pam     62  3.70e-11      1.07e-08 5
#> ATC:pam     59  1.74e-10      3.95e-07 5
#> SD:hclust   60  2.46e-11      2.10e-06 5
#> CV:hclust   53  1.13e-10      1.55e-06 5
#> MAD:hclust  61  8.39e-11      2.10e-06 5
#> ATC:hclust  60  2.28e-11      3.79e-06 5
test_to_known_factors(res_list, k = 6)
#>              n tissue(p) individual(p) k
#> SD:NMF      55  3.89e-09      2.55e-10 6
#> CV:NMF      49  1.85e-08      4.08e-05 6
#> MAD:NMF     53  1.02e-08      4.46e-09 6
#> ATC:NMF     53  1.88e-09      5.49e-08 6
#> SD:skmeans  61  4.26e-11      1.04e-11 6
#> CV:skmeans  60  3.70e-10      2.02e-11 6
#> MAD:skmeans 62  1.46e-10      2.39e-11 6
#> ATC:skmeans 50  8.13e-09      3.48e-09 6
#> SD:mclust   53  3.36e-10      1.12e-11 6
#> CV:mclust   50  1.39e-09      3.03e-07 6
#> MAD:mclust  62  1.43e-10      8.15e-13 6
#> ATC:mclust  57  3.10e-10      1.28e-06 6
#> SD:kmeans   61  2.35e-10      5.61e-13 6
#> CV:kmeans   46  2.48e-07      1.00e-09 6
#> MAD:kmeans  55  4.08e-09      2.17e-11 6
#> ATC:kmeans  59  2.99e-11      7.29e-10 6
#> SD:pam      61  2.35e-10      4.50e-10 6
#> CV:pam      60  6.95e-11      7.63e-08 6
#> MAD:pam     62  1.46e-10      7.27e-10 6
#> ATC:pam     58  1.00e-09      2.43e-11 6
#> SD:hclust   59  6.15e-12      1.83e-06 6
#> CV:hclust   52  1.86e-10      7.42e-07 6
#> MAD:hclust  59  6.15e-12      1.83e-06 6
#> ATC:hclust  60  1.06e-10      7.14e-09 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.316           0.447       0.668         0.4478 0.492   0.492
#> 3 3 0.714           0.813       0.912         0.4379 0.874   0.744
#> 4 4 0.859           0.935       0.907         0.0873 0.903   0.734
#> 5 5 0.858           0.903       0.934         0.0434 0.993   0.974
#> 6 6 0.927           0.873       0.948         0.0391 0.988   0.956

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
#> GSM26805     2  0.0000      0.746 0.000 1.000
#> GSM26806     2  0.9922      0.170 0.448 0.552
#> GSM26807     2  0.9922      0.170 0.448 0.552
#> GSM26808     2  0.9922      0.170 0.448 0.552
#> GSM26809     2  0.8267      0.232 0.260 0.740
#> GSM26810     2  0.9922      0.170 0.448 0.552
#> GSM26811     2  0.9922      0.170 0.448 0.552
#> GSM26812     2  0.9922      0.170 0.448 0.552
#> GSM26813     2  0.0000      0.746 0.000 1.000
#> GSM26814     2  0.0000      0.746 0.000 1.000
#> GSM26815     2  0.9922      0.170 0.448 0.552
#> GSM26816     2  0.0000      0.746 0.000 1.000
#> GSM26817     2  0.9922      0.170 0.448 0.552
#> GSM26818     1  0.9491      0.324 0.632 0.368
#> GSM26819     2  0.0000      0.746 0.000 1.000
#> GSM26820     2  0.0000      0.746 0.000 1.000
#> GSM26821     2  0.0000      0.746 0.000 1.000
#> GSM26822     2  0.0000      0.746 0.000 1.000
#> GSM26823     2  0.0000      0.746 0.000 1.000
#> GSM26824     2  0.0000      0.746 0.000 1.000
#> GSM26825     2  0.0000      0.746 0.000 1.000
#> GSM26826     2  0.0000      0.746 0.000 1.000
#> GSM26827     2  0.0000      0.746 0.000 1.000
#> GSM26828     2  0.0000      0.746 0.000 1.000
#> GSM26829     2  0.0000      0.746 0.000 1.000
#> GSM26830     2  0.0000      0.746 0.000 1.000
#> GSM26831     2  0.0000      0.746 0.000 1.000
#> GSM26832     2  0.0672      0.739 0.008 0.992
#> GSM26833     2  0.0672      0.739 0.008 0.992
#> GSM26834     2  0.0000      0.746 0.000 1.000
#> GSM26835     2  0.0000      0.746 0.000 1.000
#> GSM26836     1  0.9922      0.304 0.552 0.448
#> GSM26837     1  0.9922      0.304 0.552 0.448
#> GSM26838     1  0.9922      0.304 0.552 0.448
#> GSM26839     1  0.9922      0.304 0.552 0.448
#> GSM26840     1  0.9922      0.304 0.552 0.448
#> GSM26841     1  0.9922      0.304 0.552 0.448
#> GSM26842     1  0.9922      0.304 0.552 0.448
#> GSM26843     1  0.9922      0.304 0.552 0.448
#> GSM26844     1  0.9922      0.304 0.552 0.448
#> GSM26845     1  0.9922      0.304 0.552 0.448
#> GSM26846     1  0.9552      0.320 0.624 0.376
#> GSM26847     1  0.9552      0.320 0.624 0.376
#> GSM26848     1  0.9552      0.320 0.624 0.376
#> GSM26849     1  0.9552      0.320 0.624 0.376
#> GSM26850     1  0.9552      0.320 0.624 0.376
#> GSM26851     2  0.0672      0.739 0.008 0.992
#> GSM26852     1  0.9491      0.324 0.632 0.368
#> GSM26853     1  0.9491      0.324 0.632 0.368
#> GSM26854     1  0.9491      0.324 0.632 0.368
#> GSM26855     1  0.9491      0.324 0.632 0.368
#> GSM26856     1  0.9491      0.324 0.632 0.368
#> GSM26857     1  0.9491      0.324 0.632 0.368
#> GSM26858     1  0.9491      0.324 0.632 0.368
#> GSM26859     1  0.9491      0.324 0.632 0.368
#> GSM26860     1  0.9491      0.324 0.632 0.368
#> GSM26861     1  0.9491      0.324 0.632 0.368
#> GSM26862     1  0.9922      0.304 0.552 0.448
#> GSM26863     1  0.9922      0.304 0.552 0.448
#> GSM26864     1  0.9922      0.304 0.552 0.448
#> GSM26865     1  0.9552      0.320 0.624 0.376
#> GSM26866     1  0.9922      0.304 0.552 0.448

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26806     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26807     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26808     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26809     2  0.5327      0.505 0.272 0.728 0.000
#> GSM26810     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26811     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26812     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26813     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26814     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26815     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26816     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26817     2  0.6252      0.355 0.000 0.556 0.444
#> GSM26818     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26819     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26820     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26821     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26822     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26823     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26824     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26825     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26826     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26827     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26828     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26829     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26830     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26831     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26832     2  0.0237      0.849 0.000 0.996 0.004
#> GSM26833     2  0.0237      0.849 0.000 0.996 0.004
#> GSM26834     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26835     2  0.0237      0.853 0.004 0.996 0.000
#> GSM26836     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26838     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26840     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26841     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26845     1  0.5785      0.524 0.668 0.332 0.000
#> GSM26846     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26847     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26848     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26849     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26850     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26851     2  0.0237      0.849 0.000 0.996 0.004
#> GSM26852     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26853     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26854     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26855     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26856     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26857     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26858     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26859     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26860     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26861     3  0.0237      0.924 0.000 0.004 0.996
#> GSM26862     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.969 1.000 0.000 0.000
#> GSM26865     3  0.4968      0.840 0.188 0.012 0.800
#> GSM26866     1  0.0000      0.969 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26806     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26807     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26808     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26809     2  0.5395      0.486 0.084 0.732 0.000 0.184
#> GSM26810     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26811     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26812     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26813     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26814     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26815     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26816     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26817     4  0.5435      1.000 0.000 0.420 0.016 0.564
#> GSM26818     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26831     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0336      0.965 0.000 0.992 0.000 0.008
#> GSM26833     2  0.0336      0.965 0.000 0.992 0.000 0.008
#> GSM26834     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26840     1  0.4008      0.772 0.756 0.000 0.000 0.244
#> GSM26841     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26845     1  0.7393      0.288 0.488 0.332 0.000 0.180
#> GSM26846     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26847     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26848     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26849     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26850     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26851     2  0.0707      0.952 0.000 0.980 0.000 0.020
#> GSM26852     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.938 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.947 1.000 0.000 0.000 0.000
#> GSM26865     3  0.4151      0.882 0.004 0.016 0.800 0.180
#> GSM26866     1  0.0000      0.947 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2  p3    p4    p5
#> GSM26805     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26806     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26807     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26808     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26809     2  0.4647     0.6344 0.084 0.732 0.0 0.000 0.184
#> GSM26810     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26811     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26812     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26813     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26814     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26815     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26816     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26817     4  0.2966     1.0000 0.000 0.184 0.0 0.816 0.000
#> GSM26818     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26819     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26820     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26821     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26822     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26823     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26824     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26825     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26826     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26827     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26828     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26829     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26830     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26831     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26832     2  0.0963     0.9431 0.000 0.964 0.0 0.036 0.000
#> GSM26833     2  0.0963     0.9431 0.000 0.964 0.0 0.036 0.000
#> GSM26834     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26835     2  0.0000     0.9715 0.000 1.000 0.0 0.000 0.000
#> GSM26836     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26837     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26838     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26839     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26840     5  0.3242     0.0000 0.216 0.000 0.0 0.000 0.784
#> GSM26841     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26842     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26843     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26844     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26845     1  0.6392    -0.0629 0.484 0.332 0.0 0.000 0.184
#> GSM26846     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26847     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26848     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26849     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26850     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26851     2  0.3805     0.7172 0.000 0.784 0.0 0.184 0.032
#> GSM26852     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26853     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26854     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26855     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26856     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26857     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26858     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26859     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26860     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26861     3  0.0000     0.9216 0.000 0.000 1.0 0.000 0.000
#> GSM26862     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26863     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26864     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000
#> GSM26865     3  0.3456     0.8478 0.000 0.016 0.8 0.000 0.184
#> GSM26866     1  0.0000     0.9275 1.000 0.000 0.0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2  p3    p4    p5    p6
#> GSM26805     2  0.0713      0.942 0.000 0.972 0.0 0.000 0.028 0.000
#> GSM26806     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26807     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26808     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26809     2  0.4605      0.563 0.000 0.692 0.0 0.000 0.124 0.184
#> GSM26810     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26811     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26812     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26813     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26814     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26815     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26816     2  0.0713      0.942 0.000 0.972 0.0 0.000 0.028 0.000
#> GSM26817     4  0.0547      1.000 0.000 0.020 0.0 0.980 0.000 0.000
#> GSM26818     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26819     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26828     2  0.0858      0.941 0.000 0.968 0.0 0.004 0.028 0.000
#> GSM26829     2  0.0858      0.941 0.000 0.968 0.0 0.004 0.028 0.000
#> GSM26830     2  0.0000      0.949 0.000 1.000 0.0 0.000 0.000 0.000
#> GSM26831     2  0.0858      0.941 0.000 0.968 0.0 0.004 0.028 0.000
#> GSM26832     2  0.3481      0.732 0.000 0.792 0.0 0.160 0.048 0.000
#> GSM26833     2  0.3481      0.732 0.000 0.792 0.0 0.160 0.048 0.000
#> GSM26834     2  0.0858      0.941 0.000 0.968 0.0 0.004 0.028 0.000
#> GSM26835     2  0.0858      0.941 0.000 0.968 0.0 0.004 0.028 0.000
#> GSM26836     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26840     6  0.3017      0.000 0.164 0.000 0.0 0.020 0.000 0.816
#> GSM26841     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26845     1  0.7138     -0.193 0.384 0.320 0.0 0.000 0.096 0.200
#> GSM26846     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26847     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26848     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26849     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26850     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26851     5  0.1765      0.000 0.000 0.096 0.0 0.000 0.904 0.000
#> GSM26852     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26853     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26854     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26855     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26856     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26857     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26858     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26859     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26860     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26861     3  0.0000      0.921 0.000 0.000 1.0 0.000 0.000 0.000
#> GSM26862     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.926 1.000 0.000 0.0 0.000 0.000 0.000
#> GSM26865     3  0.3104      0.846 0.000 0.016 0.8 0.000 0.000 0.184
#> GSM26866     1  0.0000      0.926 1.000 0.000 0.0 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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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

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

get_signatures(res, k = 6, 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-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> SD:hclust 22        NA            NA 2
#> SD:hclust 54  9.11e-11      1.20e-05 3
#> SD:hclust 60  2.44e-11      4.43e-07 4
#> SD:hclust 60  2.46e-11      2.10e-06 5
#> SD:hclust 59  6.15e-12      1.83e-06 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.500           0.930       0.939         0.4975 0.492   0.492
#> 3 3 0.735           0.875       0.854         0.2588 0.879   0.755
#> 4 4 0.659           0.874       0.853         0.1294 0.903   0.738
#> 5 5 0.713           0.781       0.772         0.0805 0.950   0.819
#> 6 6 0.838           0.886       0.856         0.0605 0.931   0.701

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
#> GSM26805     2  0.0376      0.959 0.004 0.996
#> GSM26806     2  0.5519      0.884 0.128 0.872
#> GSM26807     2  0.5519      0.884 0.128 0.872
#> GSM26808     2  0.5294      0.890 0.120 0.880
#> GSM26809     2  0.0376      0.959 0.004 0.996
#> GSM26810     2  0.5519      0.884 0.128 0.872
#> GSM26811     2  0.5294      0.890 0.120 0.880
#> GSM26812     2  0.5519      0.884 0.128 0.872
#> GSM26813     2  0.0000      0.960 0.000 1.000
#> GSM26814     2  0.0000      0.960 0.000 1.000
#> GSM26815     2  0.5519      0.884 0.128 0.872
#> GSM26816     2  0.0376      0.959 0.004 0.996
#> GSM26817     2  0.5294      0.890 0.120 0.880
#> GSM26818     1  0.0376      0.899 0.996 0.004
#> GSM26819     2  0.0000      0.960 0.000 1.000
#> GSM26820     2  0.0000      0.960 0.000 1.000
#> GSM26821     2  0.0000      0.960 0.000 1.000
#> GSM26822     2  0.0000      0.960 0.000 1.000
#> GSM26823     2  0.0000      0.960 0.000 1.000
#> GSM26824     2  0.0000      0.960 0.000 1.000
#> GSM26825     2  0.0000      0.960 0.000 1.000
#> GSM26826     2  0.0000      0.960 0.000 1.000
#> GSM26827     2  0.0000      0.960 0.000 1.000
#> GSM26828     2  0.0376      0.959 0.004 0.996
#> GSM26829     2  0.0376      0.959 0.004 0.996
#> GSM26830     2  0.0000      0.960 0.000 1.000
#> GSM26831     2  0.0376      0.959 0.004 0.996
#> GSM26832     2  0.0376      0.959 0.004 0.996
#> GSM26833     2  0.0000      0.960 0.000 1.000
#> GSM26834     2  0.0376      0.959 0.004 0.996
#> GSM26835     2  0.0376      0.959 0.004 0.996
#> GSM26836     1  0.5946      0.933 0.856 0.144
#> GSM26837     1  0.5629      0.930 0.868 0.132
#> GSM26838     1  0.5946      0.933 0.856 0.144
#> GSM26839     1  0.5946      0.933 0.856 0.144
#> GSM26840     1  0.5946      0.933 0.856 0.144
#> GSM26841     1  0.5946      0.933 0.856 0.144
#> GSM26842     1  0.5946      0.933 0.856 0.144
#> GSM26843     1  0.5946      0.933 0.856 0.144
#> GSM26844     1  0.5946      0.933 0.856 0.144
#> GSM26845     1  0.5946      0.933 0.856 0.144
#> GSM26846     1  0.6048      0.931 0.852 0.148
#> GSM26847     1  0.5946      0.933 0.856 0.144
#> GSM26848     1  0.5946      0.933 0.856 0.144
#> GSM26849     1  0.0376      0.899 0.996 0.004
#> GSM26850     1  0.5946      0.933 0.856 0.144
#> GSM26851     2  0.0000      0.960 0.000 1.000
#> GSM26852     1  0.0376      0.899 0.996 0.004
#> GSM26853     1  0.0376      0.899 0.996 0.004
#> GSM26854     1  0.0376      0.899 0.996 0.004
#> GSM26855     1  0.0376      0.899 0.996 0.004
#> GSM26856     1  0.0376      0.899 0.996 0.004
#> GSM26857     1  0.0376      0.899 0.996 0.004
#> GSM26858     1  0.0376      0.899 0.996 0.004
#> GSM26859     1  0.0376      0.899 0.996 0.004
#> GSM26860     1  0.0376      0.899 0.996 0.004
#> GSM26861     1  0.0376      0.899 0.996 0.004
#> GSM26862     1  0.5946      0.933 0.856 0.144
#> GSM26863     1  0.5946      0.933 0.856 0.144
#> GSM26864     1  0.5946      0.933 0.856 0.144
#> GSM26865     1  0.5946      0.933 0.856 0.144
#> GSM26866     1  0.5946      0.933 0.856 0.144

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26806     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26807     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26808     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26809     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26810     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26811     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26812     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26813     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26815     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26816     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26817     2  0.5873      0.764 0.312 0.684 0.004
#> GSM26818     3  0.3349      0.814 0.108 0.004 0.888
#> GSM26819     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26828     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26829     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26830     2  0.0000      0.909 0.000 1.000 0.000
#> GSM26831     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26832     2  0.2711      0.896 0.088 0.912 0.000
#> GSM26833     2  0.2711      0.896 0.088 0.912 0.000
#> GSM26834     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26835     2  0.1643      0.901 0.044 0.956 0.000
#> GSM26836     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26837     1  0.6045      0.883 0.620 0.000 0.380
#> GSM26838     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26839     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26840     1  0.7635      0.680 0.676 0.112 0.212
#> GSM26841     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26842     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26843     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26844     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26845     1  0.6420      0.412 0.688 0.288 0.024
#> GSM26846     1  0.6495      0.799 0.536 0.004 0.460
#> GSM26847     1  0.6280      0.804 0.540 0.000 0.460
#> GSM26848     1  0.6495      0.799 0.536 0.004 0.460
#> GSM26849     3  0.0983      0.962 0.016 0.004 0.980
#> GSM26850     1  0.6495      0.799 0.536 0.004 0.460
#> GSM26851     2  0.3500      0.886 0.116 0.880 0.004
#> GSM26852     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26853     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26854     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26855     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26856     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26857     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26858     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26859     3  0.0475      0.975 0.004 0.004 0.992
#> GSM26860     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26861     3  0.0237      0.980 0.000 0.004 0.996
#> GSM26862     1  0.6045      0.883 0.620 0.000 0.380
#> GSM26863     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26864     1  0.5948      0.893 0.640 0.000 0.360
#> GSM26865     1  0.6280      0.804 0.540 0.000 0.460
#> GSM26866     1  0.5948      0.893 0.640 0.000 0.360

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.4060      0.848 0.004 0.836 0.112 0.048
#> GSM26806     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26807     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26808     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26809     2  0.4386      0.815 0.004 0.820 0.068 0.108
#> GSM26810     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26811     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26812     4  0.4661      0.998 0.000 0.348 0.000 0.652
#> GSM26813     2  0.0188      0.872 0.000 0.996 0.004 0.000
#> GSM26814     2  0.0188      0.872 0.000 0.996 0.004 0.000
#> GSM26815     4  0.4973      0.994 0.000 0.348 0.008 0.644
#> GSM26816     2  0.4001      0.850 0.004 0.840 0.108 0.048
#> GSM26817     4  0.4973      0.994 0.000 0.348 0.008 0.644
#> GSM26818     3  0.3687      0.903 0.080 0.000 0.856 0.064
#> GSM26819     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.874 0.000 1.000 0.000 0.000
#> GSM26828     2  0.4060      0.848 0.004 0.836 0.112 0.048
#> GSM26829     2  0.3941      0.852 0.004 0.844 0.104 0.048
#> GSM26830     2  0.0188      0.872 0.000 0.996 0.004 0.000
#> GSM26831     2  0.4060      0.848 0.004 0.836 0.112 0.048
#> GSM26832     2  0.5247      0.787 0.004 0.764 0.112 0.120
#> GSM26833     2  0.5082      0.796 0.004 0.776 0.112 0.108
#> GSM26834     2  0.4296      0.842 0.004 0.824 0.112 0.060
#> GSM26835     2  0.4296      0.842 0.004 0.824 0.112 0.060
#> GSM26836     1  0.2773      0.855 0.880 0.000 0.004 0.116
#> GSM26837     1  0.3384      0.851 0.860 0.000 0.024 0.116
#> GSM26838     1  0.0188      0.853 0.996 0.000 0.004 0.000
#> GSM26839     1  0.2401      0.857 0.904 0.000 0.004 0.092
#> GSM26840     1  0.3874      0.752 0.856 0.008 0.072 0.064
#> GSM26841     1  0.0188      0.853 0.996 0.000 0.004 0.000
#> GSM26842     1  0.0188      0.853 0.996 0.000 0.004 0.000
#> GSM26843     1  0.0000      0.852 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.852 1.000 0.000 0.000 0.000
#> GSM26845     1  0.6888      0.712 0.628 0.020 0.108 0.244
#> GSM26846     1  0.6248      0.742 0.660 0.000 0.128 0.212
#> GSM26847     1  0.6201      0.743 0.664 0.000 0.124 0.212
#> GSM26848     1  0.6201      0.743 0.664 0.000 0.124 0.212
#> GSM26849     3  0.6634      0.661 0.164 0.000 0.624 0.212
#> GSM26850     1  0.6201      0.743 0.664 0.000 0.124 0.212
#> GSM26851     2  0.5686      0.736 0.004 0.728 0.112 0.156
#> GSM26852     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26853     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26854     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26855     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26856     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26857     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26858     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26859     3  0.2704      0.964 0.124 0.000 0.876 0.000
#> GSM26860     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26861     3  0.2760      0.968 0.128 0.000 0.872 0.000
#> GSM26862     1  0.3384      0.851 0.860 0.000 0.024 0.116
#> GSM26863     1  0.2773      0.855 0.880 0.000 0.004 0.116
#> GSM26864     1  0.0188      0.853 0.996 0.000 0.004 0.000
#> GSM26865     1  0.6201      0.743 0.664 0.000 0.124 0.212
#> GSM26866     1  0.0000      0.852 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM26806     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26807     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26808     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26809     2  0.5353      0.657 0.000 0.576 0.000 0.064 0.360
#> GSM26810     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26811     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26812     4  0.2329      0.986 0.000 0.124 0.000 0.876 0.000
#> GSM26813     2  0.5681      0.757 0.000 0.588 0.024 0.048 0.340
#> GSM26814     2  0.5681      0.757 0.000 0.588 0.024 0.048 0.340
#> GSM26815     4  0.3939      0.960 0.000 0.124 0.024 0.816 0.036
#> GSM26816     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM26817     4  0.4256      0.951 0.000 0.124 0.032 0.800 0.044
#> GSM26818     3  0.2457      0.837 0.008 0.000 0.900 0.016 0.076
#> GSM26819     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26820     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26821     2  0.5131      0.760 0.000 0.588 0.000 0.048 0.364
#> GSM26822     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26823     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26824     2  0.5131      0.760 0.000 0.588 0.000 0.048 0.364
#> GSM26825     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26826     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26827     2  0.5107      0.763 0.000 0.596 0.000 0.048 0.356
#> GSM26828     2  0.0000      0.707 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM26830     2  0.5681      0.757 0.000 0.588 0.024 0.048 0.340
#> GSM26831     2  0.0000      0.707 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2  0.1197      0.668 0.000 0.952 0.000 0.048 0.000
#> GSM26833     2  0.1408      0.668 0.000 0.948 0.000 0.044 0.008
#> GSM26834     2  0.0290      0.702 0.000 0.992 0.000 0.008 0.000
#> GSM26835     2  0.0290      0.702 0.000 0.992 0.000 0.008 0.000
#> GSM26836     1  0.4431      0.549 0.732 0.000 0.000 0.052 0.216
#> GSM26837     1  0.4909      0.513 0.716 0.000 0.016 0.052 0.216
#> GSM26838     1  0.0794      0.769 0.972 0.000 0.000 0.028 0.000
#> GSM26839     1  0.3944      0.626 0.788 0.000 0.000 0.052 0.160
#> GSM26840     1  0.4765      0.522 0.776 0.052 0.000 0.064 0.108
#> GSM26841     1  0.0000      0.775 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.775 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0404      0.775 0.988 0.000 0.000 0.012 0.000
#> GSM26844     1  0.0404      0.775 0.988 0.000 0.000 0.012 0.000
#> GSM26845     5  0.6545      0.469 0.412 0.036 0.040 0.024 0.488
#> GSM26846     5  0.6142      0.770 0.396 0.000 0.132 0.000 0.472
#> GSM26847     5  0.6024      0.787 0.412 0.000 0.116 0.000 0.472
#> GSM26848     5  0.6024      0.787 0.412 0.000 0.116 0.000 0.472
#> GSM26849     5  0.5889      0.221 0.100 0.000 0.428 0.000 0.472
#> GSM26850     5  0.6024      0.787 0.412 0.000 0.116 0.000 0.472
#> GSM26851     2  0.2388      0.626 0.000 0.900 0.000 0.072 0.028
#> GSM26852     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26853     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26854     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26855     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26856     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26857     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26858     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26859     3  0.1341      0.959 0.056 0.000 0.944 0.000 0.000
#> GSM26860     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26861     3  0.1671      0.982 0.076 0.000 0.924 0.000 0.000
#> GSM26862     1  0.4909      0.513 0.716 0.000 0.016 0.052 0.216
#> GSM26863     1  0.4431      0.549 0.732 0.000 0.000 0.052 0.216
#> GSM26864     1  0.0000      0.775 1.000 0.000 0.000 0.000 0.000
#> GSM26865     5  0.6024      0.787 0.412 0.000 0.116 0.000 0.472
#> GSM26866     1  0.0404      0.775 0.988 0.000 0.000 0.012 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.3714      0.959 0.000 0.340 0.000 0.000 0.656 0.004
#> GSM26806     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26807     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26808     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26809     2  0.5347      0.500 0.096 0.660 0.000 0.032 0.208 0.004
#> GSM26810     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26811     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26812     4  0.1663      0.979 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM26813     2  0.0951      0.931 0.020 0.968 0.000 0.000 0.008 0.004
#> GSM26814     2  0.0951      0.931 0.020 0.968 0.000 0.000 0.008 0.004
#> GSM26815     4  0.3341      0.945 0.060 0.088 0.000 0.836 0.016 0.000
#> GSM26816     5  0.3714      0.959 0.000 0.340 0.000 0.000 0.656 0.004
#> GSM26817     4  0.4176      0.916 0.080 0.100 0.000 0.788 0.024 0.008
#> GSM26818     3  0.3728      0.784 0.004 0.000 0.800 0.008 0.056 0.132
#> GSM26819     2  0.0508      0.947 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM26820     2  0.0508      0.947 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM26821     2  0.0260      0.942 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM26822     2  0.0508      0.947 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM26823     2  0.0363      0.947 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26824     2  0.0260      0.942 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM26825     2  0.0508      0.947 0.004 0.984 0.000 0.000 0.012 0.000
#> GSM26826     2  0.0363      0.947 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26827     2  0.0363      0.947 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26828     5  0.3563      0.962 0.000 0.336 0.000 0.000 0.664 0.000
#> GSM26829     5  0.3578      0.960 0.000 0.340 0.000 0.000 0.660 0.000
#> GSM26830     2  0.0951      0.931 0.020 0.968 0.000 0.000 0.008 0.004
#> GSM26831     5  0.3563      0.962 0.000 0.336 0.000 0.000 0.664 0.000
#> GSM26832     5  0.4072      0.915 0.004 0.288 0.000 0.012 0.688 0.008
#> GSM26833     5  0.4197      0.944 0.004 0.316 0.000 0.012 0.660 0.008
#> GSM26834     5  0.3699      0.962 0.004 0.336 0.000 0.000 0.660 0.000
#> GSM26835     5  0.3699      0.962 0.004 0.336 0.000 0.000 0.660 0.000
#> GSM26836     1  0.6269      0.636 0.448 0.000 0.012 0.036 0.096 0.408
#> GSM26837     1  0.6418      0.624 0.440 0.000 0.020 0.036 0.096 0.408
#> GSM26838     1  0.5140      0.774 0.684 0.000 0.012 0.020 0.084 0.200
#> GSM26839     1  0.6206      0.682 0.500 0.000 0.012 0.036 0.096 0.356
#> GSM26840     1  0.4789      0.603 0.744 0.000 0.008 0.040 0.100 0.108
#> GSM26841     1  0.3110      0.794 0.792 0.000 0.012 0.000 0.000 0.196
#> GSM26842     1  0.3359      0.791 0.784 0.000 0.012 0.000 0.008 0.196
#> GSM26843     1  0.3110      0.794 0.792 0.000 0.012 0.000 0.000 0.196
#> GSM26844     1  0.3110      0.794 0.792 0.000 0.012 0.000 0.000 0.196
#> GSM26845     6  0.2999      0.779 0.024 0.000 0.000 0.032 0.084 0.860
#> GSM26846     6  0.0865      0.913 0.000 0.000 0.036 0.000 0.000 0.964
#> GSM26847     6  0.0937      0.914 0.000 0.000 0.040 0.000 0.000 0.960
#> GSM26848     6  0.1082      0.916 0.004 0.000 0.040 0.000 0.000 0.956
#> GSM26849     6  0.2793      0.712 0.000 0.000 0.200 0.000 0.000 0.800
#> GSM26850     6  0.1082      0.916 0.004 0.000 0.040 0.000 0.000 0.956
#> GSM26851     5  0.4989      0.832 0.032 0.240 0.000 0.024 0.680 0.024
#> GSM26852     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0260      0.976 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM26857     3  0.0260      0.976 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM26858     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0520      0.970 0.000 0.000 0.984 0.008 0.000 0.008
#> GSM26860     3  0.0260      0.976 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM26861     3  0.0000      0.978 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.6418      0.624 0.440 0.000 0.020 0.036 0.096 0.408
#> GSM26863     1  0.6269      0.636 0.448 0.000 0.012 0.036 0.096 0.408
#> GSM26864     1  0.3359      0.791 0.784 0.000 0.012 0.000 0.008 0.196
#> GSM26865     6  0.1082      0.916 0.004 0.000 0.040 0.000 0.000 0.956
#> GSM26866     1  0.3110      0.794 0.792 0.000 0.012 0.000 0.000 0.196

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

consensus_heatmap(res, k = 2)

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

plot of chunk tab-SD-kmeans-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-kmeans-get-signatures-no-scale-4

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> SD:kmeans 62  1.14e-12      8.30e-01 2
#> SD:kmeans 61  2.46e-12      2.21e-04 3
#> SD:kmeans 62  8.75e-12      2.79e-06 4
#> SD:kmeans 60  1.07e-10      8.81e-09 5
#> SD:kmeans 61  2.35e-10      5.61e-13 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


SD: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 62 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 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-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.5087 0.492   0.492
#> 3 3 0.970           0.940       0.973         0.2453 0.874   0.744
#> 4 4 0.846           0.882       0.928         0.1786 0.884   0.682
#> 5 5 0.868           0.867       0.900         0.0672 0.929   0.726
#> 6 6 0.966           0.945       0.961         0.0479 0.947   0.744

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     1       0          1  1  0
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     1       0          1  1  0
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26806     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26807     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26808     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26809     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26810     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26811     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26812     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26813     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26815     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26816     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26817     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26818     3  0.0237      0.961 0.004 0.000 0.996
#> GSM26819     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26831     2  0.0000      0.998 0.000 1.000 0.000
#> GSM26832     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26833     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26834     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26835     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26836     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26838     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26840     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26841     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26845     1  0.0237      0.921 0.996 0.004 0.000
#> GSM26846     3  0.4555      0.748 0.200 0.000 0.800
#> GSM26847     1  0.6095      0.382 0.608 0.000 0.392
#> GSM26848     1  0.6095      0.382 0.608 0.000 0.392
#> GSM26849     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26850     3  0.4555      0.748 0.200 0.000 0.800
#> GSM26851     2  0.0424      0.996 0.000 0.992 0.008
#> GSM26852     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26853     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26854     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26855     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26856     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26857     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26858     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26859     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26860     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26861     3  0.0424      0.966 0.008 0.000 0.992
#> GSM26862     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.925 1.000 0.000 0.000
#> GSM26865     1  0.5529      0.578 0.704 0.000 0.296
#> GSM26866     1  0.0000      0.925 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.2530      0.863 0.000 0.888 0.000 0.112
#> GSM26806     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26807     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26808     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26809     2  0.0188      0.897 0.000 0.996 0.000 0.004
#> GSM26810     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26811     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26812     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26813     4  0.4855      0.429 0.000 0.400 0.000 0.600
#> GSM26814     2  0.2530      0.857 0.000 0.888 0.000 0.112
#> GSM26815     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26816     2  0.2530      0.863 0.000 0.888 0.000 0.112
#> GSM26817     4  0.1557      0.949 0.000 0.056 0.000 0.944
#> GSM26818     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26819     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26820     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26821     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26822     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26823     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26824     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26825     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26826     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26827     2  0.1211      0.909 0.000 0.960 0.000 0.040
#> GSM26828     2  0.2589      0.860 0.000 0.884 0.000 0.116
#> GSM26829     2  0.1637      0.886 0.000 0.940 0.000 0.060
#> GSM26830     2  0.1637      0.899 0.000 0.940 0.000 0.060
#> GSM26831     2  0.2530      0.863 0.000 0.888 0.000 0.112
#> GSM26832     2  0.3801      0.748 0.000 0.780 0.000 0.220
#> GSM26833     4  0.2814      0.893 0.000 0.132 0.000 0.868
#> GSM26834     2  0.3688      0.765 0.000 0.792 0.000 0.208
#> GSM26835     2  0.3688      0.765 0.000 0.792 0.000 0.208
#> GSM26836     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26840     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26845     1  0.0469      0.919 0.988 0.000 0.000 0.012
#> GSM26846     3  0.4562      0.772 0.152 0.000 0.792 0.056
#> GSM26847     1  0.6083      0.387 0.584 0.000 0.360 0.056
#> GSM26848     1  0.6069      0.397 0.588 0.000 0.356 0.056
#> GSM26849     3  0.1557      0.932 0.000 0.000 0.944 0.056
#> GSM26850     3  0.4562      0.772 0.152 0.000 0.792 0.056
#> GSM26851     4  0.2281      0.915 0.000 0.096 0.000 0.904
#> GSM26852     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.964 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26865     1  0.5537      0.593 0.688 0.000 0.256 0.056
#> GSM26866     1  0.0000      0.926 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     5  0.4800      0.858 0.000 0.272 0.000 0.052 0.676
#> GSM26806     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2  0.1197      0.926 0.000 0.952 0.000 0.000 0.048
#> GSM26810     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.1671      0.885 0.000 0.924 0.000 0.076 0.000
#> GSM26814     2  0.0404      0.972 0.000 0.988 0.000 0.012 0.000
#> GSM26815     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26816     5  0.4800      0.858 0.000 0.272 0.000 0.052 0.676
#> GSM26817     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26818     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26819     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.982 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.4840      0.861 0.000 0.268 0.000 0.056 0.676
#> GSM26829     5  0.4232      0.797 0.000 0.312 0.000 0.012 0.676
#> GSM26830     2  0.0404      0.972 0.000 0.988 0.000 0.012 0.000
#> GSM26831     5  0.4840      0.861 0.000 0.268 0.000 0.056 0.676
#> GSM26832     5  0.5283      0.817 0.000 0.136 0.000 0.188 0.676
#> GSM26833     5  0.4147      0.570 0.000 0.008 0.000 0.316 0.676
#> GSM26834     5  0.5290      0.821 0.000 0.140 0.000 0.184 0.676
#> GSM26835     5  0.5290      0.821 0.000 0.140 0.000 0.184 0.676
#> GSM26836     1  0.0510      0.911 0.984 0.000 0.000 0.000 0.016
#> GSM26837     1  0.0510      0.911 0.984 0.000 0.000 0.000 0.016
#> GSM26838     1  0.0162      0.912 0.996 0.000 0.000 0.000 0.004
#> GSM26839     1  0.0510      0.911 0.984 0.000 0.000 0.000 0.016
#> GSM26840     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.2127      0.860 0.892 0.000 0.000 0.000 0.108
#> GSM26846     3  0.5987      0.537 0.132 0.000 0.544 0.000 0.324
#> GSM26847     1  0.6152      0.478 0.524 0.000 0.152 0.000 0.324
#> GSM26848     1  0.6082      0.489 0.540 0.000 0.148 0.000 0.312
#> GSM26849     3  0.3837      0.707 0.000 0.000 0.692 0.000 0.308
#> GSM26850     3  0.5974      0.544 0.132 0.000 0.548 0.000 0.320
#> GSM26851     4  0.4126      0.229 0.000 0.000 0.000 0.620 0.380
#> GSM26852     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.914 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.0510      0.911 0.984 0.000 0.000 0.000 0.016
#> GSM26863     1  0.0510      0.911 0.984 0.000 0.000 0.000 0.016
#> GSM26864     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000
#> GSM26865     1  0.5538      0.579 0.596 0.000 0.092 0.000 0.312
#> GSM26866     1  0.0000      0.913 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.1075      0.931 0.000 0.048 0.000 0.000 0.952 0.000
#> GSM26806     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.1644      0.911 0.004 0.920 0.000 0.000 0.076 0.000
#> GSM26810     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.1572      0.940 0.000 0.936 0.000 0.036 0.000 0.028
#> GSM26814     2  0.0713      0.971 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM26815     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.1219      0.933 0.000 0.048 0.000 0.004 0.948 0.000
#> GSM26817     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26818     3  0.0146      0.996 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26819     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.1152      0.935 0.000 0.044 0.000 0.004 0.952 0.000
#> GSM26829     5  0.1219      0.933 0.000 0.048 0.000 0.004 0.948 0.000
#> GSM26830     2  0.0713      0.971 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM26831     5  0.1152      0.935 0.000 0.044 0.000 0.004 0.952 0.000
#> GSM26832     5  0.1401      0.933 0.000 0.028 0.000 0.020 0.948 0.004
#> GSM26833     5  0.1296      0.910 0.000 0.004 0.000 0.044 0.948 0.004
#> GSM26834     5  0.1401      0.933 0.000 0.028 0.000 0.020 0.948 0.004
#> GSM26835     5  0.1401      0.933 0.000 0.028 0.000 0.020 0.948 0.004
#> GSM26836     1  0.2795      0.902 0.856 0.000 0.000 0.000 0.044 0.100
#> GSM26837     1  0.2795      0.902 0.856 0.000 0.000 0.000 0.044 0.100
#> GSM26838     1  0.0725      0.930 0.976 0.000 0.000 0.000 0.012 0.012
#> GSM26839     1  0.2542      0.909 0.876 0.000 0.000 0.000 0.044 0.080
#> GSM26840     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.3348      0.784 0.768 0.000 0.000 0.000 0.016 0.216
#> GSM26846     6  0.0632      0.929 0.000 0.000 0.024 0.000 0.000 0.976
#> GSM26847     6  0.1049      0.922 0.032 0.000 0.000 0.000 0.008 0.960
#> GSM26848     6  0.1444      0.924 0.072 0.000 0.000 0.000 0.000 0.928
#> GSM26849     6  0.2260      0.840 0.000 0.000 0.140 0.000 0.000 0.860
#> GSM26850     6  0.0935      0.930 0.004 0.000 0.032 0.000 0.000 0.964
#> GSM26851     5  0.3899      0.351 0.000 0.000 0.000 0.404 0.592 0.004
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.2795      0.902 0.856 0.000 0.000 0.000 0.044 0.100
#> GSM26863     1  0.2747      0.904 0.860 0.000 0.000 0.000 0.044 0.096
#> GSM26864     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.1765      0.911 0.096 0.000 0.000 0.000 0.000 0.904
#> GSM26866     1  0.0000      0.933 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> SD:skmeans 62  1.14e-12      8.30e-01 2
#> SD:skmeans 60  4.17e-12      1.27e-04 3
#> SD:skmeans 59  3.50e-11      6.30e-06 4
#> SD:skmeans 59  2.84e-11      7.18e-09 5
#> SD:skmeans 61  4.26e-11      1.04e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.993         0.5064 0.494   0.494
#> 3 3 0.984           0.978       0.986         0.2396 0.841   0.690
#> 4 4 0.929           0.957       0.972         0.1787 0.889   0.701
#> 5 5 0.852           0.909       0.911         0.0735 0.928   0.732
#> 6 6 0.969           0.929       0.971         0.0593 0.941   0.721

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     2   0.000      0.991 0.000 1.000
#> GSM26806     2   0.000      0.991 0.000 1.000
#> GSM26807     2   0.000      0.991 0.000 1.000
#> GSM26808     2   0.000      0.991 0.000 1.000
#> GSM26809     2   0.000      0.991 0.000 1.000
#> GSM26810     2   0.000      0.991 0.000 1.000
#> GSM26811     2   0.000      0.991 0.000 1.000
#> GSM26812     2   0.000      0.991 0.000 1.000
#> GSM26813     2   0.000      0.991 0.000 1.000
#> GSM26814     2   0.000      0.991 0.000 1.000
#> GSM26815     2   0.000      0.991 0.000 1.000
#> GSM26816     2   0.000      0.991 0.000 1.000
#> GSM26817     2   0.000      0.991 0.000 1.000
#> GSM26818     1   0.000      0.995 1.000 0.000
#> GSM26819     2   0.000      0.991 0.000 1.000
#> GSM26820     2   0.000      0.991 0.000 1.000
#> GSM26821     2   0.000      0.991 0.000 1.000
#> GSM26822     2   0.000      0.991 0.000 1.000
#> GSM26823     2   0.000      0.991 0.000 1.000
#> GSM26824     2   0.000      0.991 0.000 1.000
#> GSM26825     2   0.000      0.991 0.000 1.000
#> GSM26826     2   0.000      0.991 0.000 1.000
#> GSM26827     2   0.000      0.991 0.000 1.000
#> GSM26828     2   0.000      0.991 0.000 1.000
#> GSM26829     2   0.000      0.991 0.000 1.000
#> GSM26830     2   0.000      0.991 0.000 1.000
#> GSM26831     2   0.000      0.991 0.000 1.000
#> GSM26832     2   0.000      0.991 0.000 1.000
#> GSM26833     2   0.000      0.991 0.000 1.000
#> GSM26834     2   0.000      0.991 0.000 1.000
#> GSM26835     2   0.000      0.991 0.000 1.000
#> GSM26836     1   0.000      0.995 1.000 0.000
#> GSM26837     1   0.000      0.995 1.000 0.000
#> GSM26838     1   0.000      0.995 1.000 0.000
#> GSM26839     1   0.000      0.995 1.000 0.000
#> GSM26840     2   0.595      0.835 0.144 0.856
#> GSM26841     1   0.000      0.995 1.000 0.000
#> GSM26842     1   0.000      0.995 1.000 0.000
#> GSM26843     1   0.000      0.995 1.000 0.000
#> GSM26844     1   0.000      0.995 1.000 0.000
#> GSM26845     2   0.563      0.851 0.132 0.868
#> GSM26846     1   0.373      0.924 0.928 0.072
#> GSM26847     1   0.000      0.995 1.000 0.000
#> GSM26848     1   0.000      0.995 1.000 0.000
#> GSM26849     1   0.000      0.995 1.000 0.000
#> GSM26850     1   0.373      0.924 0.928 0.072
#> GSM26851     2   0.000      0.991 0.000 1.000
#> GSM26852     1   0.000      0.995 1.000 0.000
#> GSM26853     1   0.000      0.995 1.000 0.000
#> GSM26854     1   0.000      0.995 1.000 0.000
#> GSM26855     1   0.000      0.995 1.000 0.000
#> GSM26856     1   0.000      0.995 1.000 0.000
#> GSM26857     1   0.000      0.995 1.000 0.000
#> GSM26858     1   0.000      0.995 1.000 0.000
#> GSM26859     1   0.000      0.995 1.000 0.000
#> GSM26860     1   0.000      0.995 1.000 0.000
#> GSM26861     1   0.000      0.995 1.000 0.000
#> GSM26862     1   0.000      0.995 1.000 0.000
#> GSM26863     1   0.000      0.995 1.000 0.000
#> GSM26864     1   0.000      0.995 1.000 0.000
#> GSM26865     1   0.000      0.995 1.000 0.000
#> GSM26866     1   0.000      0.995 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2   0.000      1.000 0.000 1.000 0.000
#> GSM26806     2   0.000      1.000 0.000 1.000 0.000
#> GSM26807     2   0.000      1.000 0.000 1.000 0.000
#> GSM26808     2   0.000      1.000 0.000 1.000 0.000
#> GSM26809     2   0.000      1.000 0.000 1.000 0.000
#> GSM26810     2   0.000      1.000 0.000 1.000 0.000
#> GSM26811     2   0.000      1.000 0.000 1.000 0.000
#> GSM26812     2   0.000      1.000 0.000 1.000 0.000
#> GSM26813     2   0.000      1.000 0.000 1.000 0.000
#> GSM26814     2   0.000      1.000 0.000 1.000 0.000
#> GSM26815     2   0.000      1.000 0.000 1.000 0.000
#> GSM26816     2   0.000      1.000 0.000 1.000 0.000
#> GSM26817     2   0.000      1.000 0.000 1.000 0.000
#> GSM26818     3   0.000      0.993 0.000 0.000 1.000
#> GSM26819     2   0.000      1.000 0.000 1.000 0.000
#> GSM26820     2   0.000      1.000 0.000 1.000 0.000
#> GSM26821     2   0.000      1.000 0.000 1.000 0.000
#> GSM26822     2   0.000      1.000 0.000 1.000 0.000
#> GSM26823     2   0.000      1.000 0.000 1.000 0.000
#> GSM26824     2   0.000      1.000 0.000 1.000 0.000
#> GSM26825     2   0.000      1.000 0.000 1.000 0.000
#> GSM26826     2   0.000      1.000 0.000 1.000 0.000
#> GSM26827     2   0.000      1.000 0.000 1.000 0.000
#> GSM26828     2   0.000      1.000 0.000 1.000 0.000
#> GSM26829     2   0.000      1.000 0.000 1.000 0.000
#> GSM26830     2   0.000      1.000 0.000 1.000 0.000
#> GSM26831     2   0.000      1.000 0.000 1.000 0.000
#> GSM26832     2   0.000      1.000 0.000 1.000 0.000
#> GSM26833     2   0.000      1.000 0.000 1.000 0.000
#> GSM26834     2   0.000      1.000 0.000 1.000 0.000
#> GSM26835     2   0.000      1.000 0.000 1.000 0.000
#> GSM26836     1   0.000      0.955 1.000 0.000 0.000
#> GSM26837     1   0.245      0.930 0.924 0.000 0.076
#> GSM26838     1   0.000      0.955 1.000 0.000 0.000
#> GSM26839     1   0.000      0.955 1.000 0.000 0.000
#> GSM26840     1   0.000      0.955 1.000 0.000 0.000
#> GSM26841     1   0.000      0.955 1.000 0.000 0.000
#> GSM26842     1   0.000      0.955 1.000 0.000 0.000
#> GSM26843     1   0.000      0.955 1.000 0.000 0.000
#> GSM26844     1   0.000      0.955 1.000 0.000 0.000
#> GSM26845     1   0.304      0.865 0.896 0.104 0.000
#> GSM26846     1   0.406      0.905 0.880 0.044 0.076
#> GSM26847     1   0.327      0.905 0.884 0.000 0.116
#> GSM26848     1   0.245      0.931 0.924 0.000 0.076
#> GSM26849     3   0.245      0.912 0.076 0.000 0.924
#> GSM26850     1   0.343      0.907 0.884 0.004 0.112
#> GSM26851     2   0.000      1.000 0.000 1.000 0.000
#> GSM26852     3   0.000      0.993 0.000 0.000 1.000
#> GSM26853     3   0.000      0.993 0.000 0.000 1.000
#> GSM26854     3   0.000      0.993 0.000 0.000 1.000
#> GSM26855     3   0.000      0.993 0.000 0.000 1.000
#> GSM26856     3   0.000      0.993 0.000 0.000 1.000
#> GSM26857     3   0.000      0.993 0.000 0.000 1.000
#> GSM26858     3   0.000      0.993 0.000 0.000 1.000
#> GSM26859     3   0.000      0.993 0.000 0.000 1.000
#> GSM26860     3   0.000      0.993 0.000 0.000 1.000
#> GSM26861     3   0.000      0.993 0.000 0.000 1.000
#> GSM26862     1   0.319      0.908 0.888 0.000 0.112
#> GSM26863     1   0.000      0.955 1.000 0.000 0.000
#> GSM26864     1   0.000      0.955 1.000 0.000 0.000
#> GSM26865     1   0.245      0.931 0.924 0.000 0.076
#> GSM26866     1   0.000      0.955 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26806     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26807     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26808     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26809     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26810     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26811     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26812     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26813     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26814     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26815     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26816     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26817     4  0.0592      0.985 0.000 0.016 0.000 0.984
#> GSM26818     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26831     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26832     2  0.3649      0.737 0.000 0.796 0.000 0.204
#> GSM26833     4  0.1716      0.933 0.000 0.064 0.000 0.936
#> GSM26834     2  0.0000      0.989 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0336      0.982 0.000 0.992 0.000 0.008
#> GSM26836     1  0.0188      0.925 0.996 0.000 0.000 0.004
#> GSM26837     1  0.2714      0.890 0.884 0.000 0.112 0.004
#> GSM26838     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26839     1  0.0000      0.926 1.000 0.000 0.000 0.000
#> GSM26840     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26841     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26842     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26843     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26844     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26845     1  0.3257      0.817 0.844 0.152 0.000 0.004
#> GSM26846     1  0.4271      0.856 0.816 0.040 0.140 0.004
#> GSM26847     1  0.3583      0.846 0.816 0.000 0.180 0.004
#> GSM26848     1  0.3105      0.876 0.856 0.000 0.140 0.004
#> GSM26849     3  0.1004      0.969 0.024 0.000 0.972 0.004
#> GSM26850     1  0.3721      0.848 0.816 0.004 0.176 0.004
#> GSM26851     4  0.0336      0.992 0.000 0.008 0.000 0.992
#> GSM26852     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26862     1  0.3539      0.850 0.820 0.000 0.176 0.004
#> GSM26863     1  0.0188      0.925 0.996 0.000 0.000 0.004
#> GSM26864     1  0.0188      0.926 0.996 0.000 0.000 0.004
#> GSM26865     1  0.3105      0.876 0.856 0.000 0.140 0.004
#> GSM26866     1  0.0188      0.926 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     5  0.3586      0.868 0.000 0.264 0.000 0.000 0.736
#> GSM26806     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26810     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000
#> GSM26816     5  0.3586      0.868 0.000 0.264 0.000 0.000 0.736
#> GSM26817     4  0.0290      0.988 0.000 0.008 0.000 0.992 0.000
#> GSM26818     3  0.2929      0.816 0.000 0.000 0.820 0.000 0.180
#> GSM26819     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.3586      0.868 0.000 0.264 0.000 0.000 0.736
#> GSM26829     5  0.3857      0.811 0.000 0.312 0.000 0.000 0.688
#> GSM26830     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM26831     5  0.3586      0.868 0.000 0.264 0.000 0.000 0.736
#> GSM26832     5  0.4593      0.736 0.000 0.080 0.000 0.184 0.736
#> GSM26833     5  0.3715      0.628 0.000 0.004 0.000 0.260 0.736
#> GSM26834     5  0.3586      0.868 0.000 0.264 0.000 0.000 0.736
#> GSM26835     5  0.3809      0.867 0.000 0.256 0.000 0.008 0.736
#> GSM26836     1  0.1544      0.881 0.932 0.000 0.000 0.000 0.068
#> GSM26837     1  0.4421      0.788 0.748 0.000 0.184 0.000 0.068
#> GSM26838     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.0162      0.882 0.996 0.000 0.000 0.000 0.004
#> GSM26840     1  0.2280      0.785 0.880 0.000 0.000 0.000 0.120
#> GSM26841     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.3684      0.832 0.720 0.000 0.000 0.000 0.280
#> GSM26846     1  0.3967      0.835 0.724 0.000 0.012 0.000 0.264
#> GSM26847     1  0.3967      0.835 0.724 0.000 0.012 0.000 0.264
#> GSM26848     1  0.3967      0.835 0.724 0.000 0.012 0.000 0.264
#> GSM26849     3  0.3861      0.731 0.008 0.000 0.728 0.000 0.264
#> GSM26850     1  0.3967      0.835 0.724 0.000 0.012 0.000 0.264
#> GSM26851     5  0.3586      0.620 0.000 0.000 0.000 0.264 0.736
#> GSM26852     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.960 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.4609      0.806 0.744 0.000 0.152 0.000 0.104
#> GSM26863     1  0.1544      0.881 0.932 0.000 0.000 0.000 0.068
#> GSM26864     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000
#> GSM26865     1  0.3967      0.835 0.724 0.000 0.012 0.000 0.264
#> GSM26866     1  0.0000      0.882 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26806     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26810     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26815     4  0.0000      0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26817     4  0.0405      0.988 0.000 0.008 0.000 0.988 0.004 0.000
#> GSM26818     3  0.2793      0.760 0.000 0.000 0.800 0.000 0.000 0.200
#> GSM26819     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26829     5  0.2996      0.705 0.000 0.228 0.000 0.000 0.772 0.000
#> GSM26830     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26831     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26832     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26833     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26834     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26835     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26836     6  0.3050      0.712 0.236 0.000 0.000 0.000 0.000 0.764
#> GSM26837     6  0.3612      0.753 0.036 0.000 0.200 0.000 0.000 0.764
#> GSM26838     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.3866     -0.119 0.516 0.000 0.000 0.000 0.000 0.484
#> GSM26840     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26846     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26847     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26848     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26849     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26850     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26851     5  0.0000      0.971 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26852     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000      0.980 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     6  0.3278      0.796 0.040 0.000 0.152 0.000 0.000 0.808
#> GSM26863     6  0.3050      0.712 0.236 0.000 0.000 0.000 0.000 0.764
#> GSM26864     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.0000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26866     1  0.0000      0.931 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

test_to_known_factors(res)
#>         n tissue(p) individual(p) k
#> SD:pam 62  3.65e-11      8.91e-01 2
#> SD:pam 62  1.49e-12      1.94e-04 3
#> SD:pam 62  7.83e-12      1.05e-05 4
#> SD:pam 62  3.70e-11      1.07e-08 5
#> SD:pam 61  2.35e-10      4.50e-10 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 62 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.5087 0.492   0.492
#> 3 3 0.892           0.865       0.900         0.2184 0.876   0.748
#> 4 4 0.770           0.797       0.868         0.1734 0.835   0.584
#> 5 5 0.726           0.642       0.794         0.0758 0.958   0.837
#> 6 6 0.793           0.768       0.863         0.0557 0.925   0.667

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
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     1       0          1  1  0
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     1       0          1  1  0
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26806     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26807     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26808     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26809     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26810     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26811     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26812     2  0.1337      0.984 0.012 0.972 0.016
#> GSM26813     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26814     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26815     2  0.1751      0.977 0.012 0.960 0.028
#> GSM26816     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26817     2  0.1482      0.982 0.012 0.968 0.020
#> GSM26818     3  0.0747      0.330 0.016 0.000 0.984
#> GSM26819     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.991 0.000 1.000 0.000
#> GSM26828     2  0.0475      0.991 0.004 0.992 0.004
#> GSM26829     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26830     2  0.0237      0.992 0.004 0.996 0.000
#> GSM26831     2  0.0475      0.991 0.004 0.992 0.004
#> GSM26832     2  0.0661      0.990 0.008 0.988 0.004
#> GSM26833     2  0.0661      0.990 0.008 0.988 0.004
#> GSM26834     2  0.0475      0.991 0.004 0.992 0.004
#> GSM26835     2  0.0475      0.991 0.004 0.992 0.004
#> GSM26836     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26837     1  0.2711      0.534 0.912 0.000 0.088
#> GSM26838     1  0.1163      0.703 0.972 0.000 0.028
#> GSM26839     1  0.3116      0.700 0.892 0.000 0.108
#> GSM26840     1  0.6398      0.637 0.580 0.004 0.416
#> GSM26841     1  0.6008      0.669 0.628 0.000 0.372
#> GSM26842     1  0.6008      0.669 0.628 0.000 0.372
#> GSM26843     1  0.6111      0.657 0.604 0.000 0.396
#> GSM26844     1  0.6111      0.657 0.604 0.000 0.396
#> GSM26845     3  0.8546      0.525 0.276 0.136 0.588
#> GSM26846     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26847     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26848     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26849     3  0.6260      0.887 0.448 0.000 0.552
#> GSM26850     1  0.0892      0.671 0.980 0.000 0.020
#> GSM26851     2  0.0829      0.988 0.012 0.984 0.004
#> GSM26852     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26853     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26854     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26855     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26856     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26857     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26858     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26859     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26860     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26861     3  0.6225      0.909 0.432 0.000 0.568
#> GSM26862     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26864     1  0.6026      0.668 0.624 0.000 0.376
#> GSM26865     1  0.0000      0.699 1.000 0.000 0.000
#> GSM26866     1  0.6079      0.662 0.612 0.000 0.388

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     4  0.4972     0.6444 0.000 0.456 0.000 0.544
#> GSM26806     4  0.0817     0.6113 0.000 0.024 0.000 0.976
#> GSM26807     4  0.1022     0.6175 0.000 0.032 0.000 0.968
#> GSM26808     4  0.1474     0.6262 0.000 0.052 0.000 0.948
#> GSM26809     4  0.4955     0.6508 0.000 0.444 0.000 0.556
#> GSM26810     4  0.1022     0.6175 0.000 0.032 0.000 0.968
#> GSM26811     4  0.2921     0.6470 0.000 0.140 0.000 0.860
#> GSM26812     4  0.0921     0.6146 0.000 0.028 0.000 0.972
#> GSM26813     2  0.4331     0.2699 0.000 0.712 0.000 0.288
#> GSM26814     2  0.0707     0.8826 0.000 0.980 0.000 0.020
#> GSM26815     4  0.1557     0.6258 0.000 0.056 0.000 0.944
#> GSM26816     4  0.4972     0.6444 0.000 0.456 0.000 0.544
#> GSM26817     4  0.3610     0.6531 0.000 0.200 0.000 0.800
#> GSM26818     1  0.7552     0.4505 0.536 0.008 0.232 0.224
#> GSM26819     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0188     0.8998 0.000 0.996 0.000 0.004
#> GSM26825     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000     0.9029 0.000 1.000 0.000 0.000
#> GSM26828     4  0.4967     0.6503 0.000 0.452 0.000 0.548
#> GSM26829     4  0.4972     0.6444 0.000 0.456 0.000 0.544
#> GSM26830     2  0.4605     0.0541 0.000 0.664 0.000 0.336
#> GSM26831     4  0.4967     0.6503 0.000 0.452 0.000 0.548
#> GSM26832     4  0.4941     0.6579 0.000 0.436 0.000 0.564
#> GSM26833     4  0.4955     0.6552 0.000 0.444 0.000 0.556
#> GSM26834     4  0.4967     0.6503 0.000 0.452 0.000 0.548
#> GSM26835     4  0.4967     0.6503 0.000 0.452 0.000 0.548
#> GSM26836     1  0.1211     0.9079 0.960 0.000 0.040 0.000
#> GSM26837     1  0.2647     0.8820 0.880 0.000 0.120 0.000
#> GSM26838     1  0.1792     0.8977 0.932 0.000 0.068 0.000
#> GSM26839     1  0.1867     0.8976 0.928 0.000 0.072 0.000
#> GSM26840     1  0.0469     0.9059 0.988 0.000 0.000 0.012
#> GSM26841     1  0.0188     0.9072 0.996 0.000 0.004 0.000
#> GSM26842     1  0.0188     0.9065 0.996 0.000 0.000 0.004
#> GSM26843     1  0.0000     0.9065 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000     0.9065 1.000 0.000 0.000 0.000
#> GSM26845     1  0.2892     0.8840 0.896 0.000 0.036 0.068
#> GSM26846     1  0.3052     0.8671 0.860 0.000 0.136 0.004
#> GSM26847     1  0.2773     0.8793 0.880 0.000 0.116 0.004
#> GSM26848     1  0.2944     0.8726 0.868 0.000 0.128 0.004
#> GSM26849     1  0.4746     0.5741 0.632 0.000 0.368 0.000
#> GSM26850     1  0.3355     0.8480 0.836 0.000 0.160 0.004
#> GSM26851     4  0.4916     0.6593 0.000 0.424 0.000 0.576
#> GSM26852     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26856     3  0.1389     0.9396 0.048 0.000 0.952 0.000
#> GSM26857     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000     0.9936 0.000 0.000 1.000 0.000
#> GSM26862     1  0.1022     0.9091 0.968 0.000 0.032 0.000
#> GSM26863     1  0.1302     0.9078 0.956 0.000 0.044 0.000
#> GSM26864     1  0.0000     0.9065 1.000 0.000 0.000 0.000
#> GSM26865     1  0.2714     0.8822 0.884 0.000 0.112 0.004
#> GSM26866     1  0.0000     0.9065 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     4  0.3242    0.67738 0.000 0.216 0.000 0.784 0.000
#> GSM26806     4  0.4192    0.60270 0.000 0.000 0.000 0.596 0.404
#> GSM26807     4  0.4321    0.60519 0.000 0.004 0.000 0.600 0.396
#> GSM26808     4  0.4331    0.60334 0.000 0.004 0.000 0.596 0.400
#> GSM26809     4  0.3917    0.67934 0.024 0.184 0.000 0.784 0.008
#> GSM26810     4  0.4331    0.60334 0.000 0.004 0.000 0.596 0.400
#> GSM26811     4  0.5123    0.61636 0.000 0.044 0.000 0.572 0.384
#> GSM26812     4  0.4321    0.60519 0.000 0.004 0.000 0.600 0.396
#> GSM26813     2  0.3177    0.63726 0.000 0.792 0.000 0.208 0.000
#> GSM26814     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4  0.4761    0.63011 0.000 0.104 0.000 0.728 0.168
#> GSM26816     4  0.3274    0.67604 0.000 0.220 0.000 0.780 0.000
#> GSM26817     4  0.5086    0.64230 0.000 0.144 0.000 0.700 0.156
#> GSM26818     1  0.6237    0.30889 0.656 0.000 0.168 0.092 0.084
#> GSM26819     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000    0.94232 0.000 1.000 0.000 0.000 0.000
#> GSM26828     4  0.3210    0.68079 0.000 0.212 0.000 0.788 0.000
#> GSM26829     4  0.4074    0.44937 0.000 0.364 0.000 0.636 0.000
#> GSM26830     2  0.3395    0.57860 0.000 0.764 0.000 0.236 0.000
#> GSM26831     4  0.3210    0.68079 0.000 0.212 0.000 0.788 0.000
#> GSM26832     4  0.2471    0.70066 0.000 0.136 0.000 0.864 0.000
#> GSM26833     4  0.2732    0.69848 0.000 0.160 0.000 0.840 0.000
#> GSM26834     4  0.3210    0.68079 0.000 0.212 0.000 0.788 0.000
#> GSM26835     4  0.3210    0.68079 0.000 0.212 0.000 0.788 0.000
#> GSM26836     1  0.3967    0.07738 0.724 0.000 0.012 0.000 0.264
#> GSM26837     1  0.4109   -0.00627 0.700 0.000 0.012 0.000 0.288
#> GSM26838     1  0.4537   -0.57965 0.592 0.000 0.012 0.000 0.396
#> GSM26839     1  0.4356   -0.26422 0.648 0.000 0.012 0.000 0.340
#> GSM26840     1  0.4318   -0.10992 0.688 0.000 0.000 0.020 0.292
#> GSM26841     1  0.4306   -0.91120 0.508 0.000 0.000 0.000 0.492
#> GSM26842     5  0.4448    0.98739 0.480 0.000 0.000 0.004 0.516
#> GSM26843     5  0.4302    0.99686 0.480 0.000 0.000 0.000 0.520
#> GSM26844     5  0.4302    0.99686 0.480 0.000 0.000 0.000 0.520
#> GSM26845     1  0.4493    0.40672 0.796 0.000 0.044 0.080 0.080
#> GSM26846     1  0.1668    0.52826 0.940 0.000 0.032 0.000 0.028
#> GSM26847     1  0.1485    0.53142 0.948 0.000 0.032 0.000 0.020
#> GSM26848     1  0.1043    0.52968 0.960 0.000 0.040 0.000 0.000
#> GSM26849     1  0.2992    0.52215 0.868 0.000 0.064 0.000 0.068
#> GSM26850     1  0.1668    0.52826 0.940 0.000 0.032 0.000 0.028
#> GSM26851     4  0.4361    0.69297 0.000 0.108 0.000 0.768 0.124
#> GSM26852     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.2280    0.82394 0.120 0.000 0.880 0.000 0.000
#> GSM26857     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0404    0.97288 0.012 0.000 0.988 0.000 0.000
#> GSM26860     3  0.0000    0.98123 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0162    0.97845 0.000 0.000 0.996 0.000 0.004
#> GSM26862     1  0.3807    0.15024 0.748 0.000 0.012 0.000 0.240
#> GSM26863     1  0.3942    0.09181 0.728 0.000 0.012 0.000 0.260
#> GSM26864     5  0.4302    0.99686 0.480 0.000 0.000 0.000 0.520
#> GSM26865     1  0.1918    0.51674 0.928 0.000 0.036 0.000 0.036
#> GSM26866     5  0.4302    0.99686 0.480 0.000 0.000 0.000 0.520

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.1863      0.861 0.000 0.104 0.000 0.000 0.896 0.000
#> GSM26806     4  0.2445      0.730 0.000 0.020 0.000 0.872 0.108 0.000
#> GSM26807     4  0.3670      0.795 0.000 0.012 0.000 0.704 0.284 0.000
#> GSM26808     4  0.3898      0.789 0.000 0.020 0.000 0.684 0.296 0.000
#> GSM26809     5  0.1411      0.839 0.004 0.060 0.000 0.000 0.936 0.000
#> GSM26810     4  0.3650      0.797 0.000 0.012 0.000 0.708 0.280 0.000
#> GSM26811     4  0.4436      0.750 0.000 0.048 0.000 0.640 0.312 0.000
#> GSM26812     4  0.3490      0.796 0.000 0.008 0.000 0.724 0.268 0.000
#> GSM26813     2  0.1075      0.937 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM26814     2  0.0458      0.968 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM26815     4  0.3122      0.657 0.000 0.176 0.000 0.804 0.020 0.000
#> GSM26816     5  0.2730      0.803 0.000 0.192 0.000 0.000 0.808 0.000
#> GSM26817     4  0.4363      0.540 0.000 0.324 0.000 0.636 0.040 0.000
#> GSM26818     6  0.5444      0.488 0.000 0.000 0.044 0.372 0.044 0.540
#> GSM26819     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0363      0.968 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26822     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0458      0.968 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM26825     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.973 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.1714      0.873 0.000 0.092 0.000 0.000 0.908 0.000
#> GSM26829     5  0.3695      0.537 0.000 0.376 0.000 0.000 0.624 0.000
#> GSM26830     2  0.2527      0.773 0.000 0.832 0.000 0.000 0.168 0.000
#> GSM26831     5  0.1714      0.873 0.000 0.092 0.000 0.000 0.908 0.000
#> GSM26832     5  0.1757      0.864 0.000 0.076 0.000 0.008 0.916 0.000
#> GSM26833     5  0.2662      0.828 0.000 0.120 0.000 0.024 0.856 0.000
#> GSM26834     5  0.1663      0.872 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM26835     5  0.1714      0.873 0.000 0.092 0.000 0.000 0.908 0.000
#> GSM26836     6  0.3534      0.422 0.276 0.000 0.000 0.008 0.000 0.716
#> GSM26837     6  0.4076      0.148 0.452 0.000 0.000 0.008 0.000 0.540
#> GSM26838     1  0.3833      0.126 0.556 0.000 0.000 0.000 0.000 0.444
#> GSM26839     1  0.3955      0.139 0.608 0.000 0.000 0.008 0.000 0.384
#> GSM26840     6  0.4729      0.230 0.412 0.000 0.000 0.004 0.040 0.544
#> GSM26841     1  0.0458      0.827 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM26842     1  0.0000      0.838 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.838 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.838 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.5474      0.583 0.016 0.000 0.184 0.004 0.160 0.636
#> GSM26846     6  0.0146      0.639 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM26847     6  0.0000      0.639 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26848     6  0.3383      0.623 0.000 0.000 0.268 0.004 0.000 0.728
#> GSM26849     6  0.3383      0.625 0.004 0.000 0.268 0.000 0.000 0.728
#> GSM26850     6  0.2595      0.657 0.000 0.000 0.160 0.004 0.000 0.836
#> GSM26851     5  0.3999      0.342 0.000 0.032 0.000 0.272 0.696 0.000
#> GSM26852     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0632      0.967 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM26860     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000      0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     6  0.3349      0.459 0.244 0.000 0.000 0.008 0.000 0.748
#> GSM26863     6  0.3512      0.427 0.272 0.000 0.000 0.008 0.000 0.720
#> GSM26864     1  0.0000      0.838 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.4039      0.634 0.060 0.000 0.208 0.000 0.000 0.732
#> GSM26866     1  0.0000      0.838 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> SD:mclust 62  1.14e-12      8.30e-01 2
#> SD:mclust 61  3.93e-13      2.21e-04 3
#> SD:mclust 59  6.22e-12      6.34e-09 4
#> SD:mclust 51  1.42e-09      2.99e-08 5
#> SD:mclust 53  3.36e-10      1.12e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.993       0.997          0.509 0.492   0.492
#> 3 3 0.902           0.886       0.951          0.238 0.862   0.723
#> 4 4 0.757           0.869       0.897          0.176 0.824   0.551
#> 5 5 0.777           0.721       0.811          0.079 0.897   0.617
#> 6 6 0.806           0.752       0.822          0.044 0.880   0.493

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
#> GSM26805     2   0.000      1.000 0.000 1.000
#> GSM26806     2   0.000      1.000 0.000 1.000
#> GSM26807     2   0.000      1.000 0.000 1.000
#> GSM26808     2   0.000      1.000 0.000 1.000
#> GSM26809     2   0.000      1.000 0.000 1.000
#> GSM26810     2   0.000      1.000 0.000 1.000
#> GSM26811     2   0.000      1.000 0.000 1.000
#> GSM26812     2   0.000      1.000 0.000 1.000
#> GSM26813     2   0.000      1.000 0.000 1.000
#> GSM26814     2   0.000      1.000 0.000 1.000
#> GSM26815     2   0.000      1.000 0.000 1.000
#> GSM26816     2   0.000      1.000 0.000 1.000
#> GSM26817     2   0.000      1.000 0.000 1.000
#> GSM26818     1   0.000      0.994 1.000 0.000
#> GSM26819     2   0.000      1.000 0.000 1.000
#> GSM26820     2   0.000      1.000 0.000 1.000
#> GSM26821     2   0.000      1.000 0.000 1.000
#> GSM26822     2   0.000      1.000 0.000 1.000
#> GSM26823     2   0.000      1.000 0.000 1.000
#> GSM26824     2   0.000      1.000 0.000 1.000
#> GSM26825     2   0.000      1.000 0.000 1.000
#> GSM26826     2   0.000      1.000 0.000 1.000
#> GSM26827     2   0.000      1.000 0.000 1.000
#> GSM26828     2   0.000      1.000 0.000 1.000
#> GSM26829     2   0.000      1.000 0.000 1.000
#> GSM26830     2   0.000      1.000 0.000 1.000
#> GSM26831     2   0.000      1.000 0.000 1.000
#> GSM26832     2   0.000      1.000 0.000 1.000
#> GSM26833     2   0.000      1.000 0.000 1.000
#> GSM26834     2   0.000      1.000 0.000 1.000
#> GSM26835     2   0.000      1.000 0.000 1.000
#> GSM26836     1   0.000      0.994 1.000 0.000
#> GSM26837     1   0.000      0.994 1.000 0.000
#> GSM26838     1   0.000      0.994 1.000 0.000
#> GSM26839     1   0.000      0.994 1.000 0.000
#> GSM26840     1   0.000      0.994 1.000 0.000
#> GSM26841     1   0.000      0.994 1.000 0.000
#> GSM26842     1   0.000      0.994 1.000 0.000
#> GSM26843     1   0.000      0.994 1.000 0.000
#> GSM26844     1   0.000      0.994 1.000 0.000
#> GSM26845     1   0.697      0.768 0.812 0.188
#> GSM26846     1   0.000      0.994 1.000 0.000
#> GSM26847     1   0.000      0.994 1.000 0.000
#> GSM26848     1   0.000      0.994 1.000 0.000
#> GSM26849     1   0.000      0.994 1.000 0.000
#> GSM26850     1   0.000      0.994 1.000 0.000
#> GSM26851     2   0.000      1.000 0.000 1.000
#> GSM26852     1   0.000      0.994 1.000 0.000
#> GSM26853     1   0.000      0.994 1.000 0.000
#> GSM26854     1   0.000      0.994 1.000 0.000
#> GSM26855     1   0.000      0.994 1.000 0.000
#> GSM26856     1   0.000      0.994 1.000 0.000
#> GSM26857     1   0.000      0.994 1.000 0.000
#> GSM26858     1   0.000      0.994 1.000 0.000
#> GSM26859     1   0.000      0.994 1.000 0.000
#> GSM26860     1   0.000      0.994 1.000 0.000
#> GSM26861     1   0.000      0.994 1.000 0.000
#> GSM26862     1   0.000      0.994 1.000 0.000
#> GSM26863     1   0.000      0.994 1.000 0.000
#> GSM26864     1   0.000      0.994 1.000 0.000
#> GSM26865     1   0.000      0.994 1.000 0.000
#> GSM26866     1   0.000      0.994 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.6045      0.355 0.380 0.620 0.000
#> GSM26806     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26807     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26808     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26809     1  0.4504      0.685 0.804 0.196 0.000
#> GSM26810     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26811     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26812     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26813     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26815     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26816     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26817     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26818     3  0.0237      0.938 0.004 0.000 0.996
#> GSM26819     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26828     2  0.1860      0.931 0.052 0.948 0.000
#> GSM26829     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26831     2  0.1163      0.957 0.028 0.972 0.000
#> GSM26832     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26833     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26834     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.982 0.000 1.000 0.000
#> GSM26836     1  0.6244      0.320 0.560 0.000 0.440
#> GSM26837     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26838     1  0.1163      0.835 0.972 0.000 0.028
#> GSM26839     3  0.5650      0.486 0.312 0.000 0.688
#> GSM26840     1  0.0237      0.833 0.996 0.000 0.004
#> GSM26841     1  0.1289      0.835 0.968 0.000 0.032
#> GSM26842     1  0.3267      0.792 0.884 0.000 0.116
#> GSM26843     1  0.0237      0.833 0.996 0.000 0.004
#> GSM26844     1  0.0237      0.833 0.996 0.000 0.004
#> GSM26845     1  0.0237      0.830 0.996 0.004 0.000
#> GSM26846     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26847     3  0.0592      0.934 0.012 0.000 0.988
#> GSM26848     3  0.3482      0.818 0.128 0.000 0.872
#> GSM26849     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26850     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26851     2  0.0237      0.981 0.004 0.996 0.000
#> GSM26852     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26853     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26854     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26855     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26856     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26857     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26858     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26859     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26860     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26861     3  0.0000      0.942 0.000 0.000 1.000
#> GSM26862     3  0.5363      0.571 0.276 0.000 0.724
#> GSM26863     1  0.6225      0.343 0.568 0.000 0.432
#> GSM26864     1  0.5926      0.508 0.644 0.000 0.356
#> GSM26865     3  0.3879      0.787 0.152 0.000 0.848
#> GSM26866     1  0.1643      0.832 0.956 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.1118      0.936 0.036 0.964 0.000 0.000
#> GSM26806     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26807     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26808     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26809     2  0.2124      0.897 0.040 0.932 0.000 0.028
#> GSM26810     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26811     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26812     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26813     2  0.1474      0.954 0.000 0.948 0.000 0.052
#> GSM26814     2  0.1211      0.963 0.000 0.960 0.000 0.040
#> GSM26815     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26816     2  0.1940      0.925 0.000 0.924 0.000 0.076
#> GSM26817     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26818     3  0.1302      0.871 0.000 0.000 0.956 0.044
#> GSM26819     2  0.0921      0.966 0.000 0.972 0.000 0.028
#> GSM26820     2  0.0188      0.963 0.000 0.996 0.000 0.004
#> GSM26821     2  0.1118      0.965 0.000 0.964 0.000 0.036
#> GSM26822     2  0.1022      0.966 0.000 0.968 0.000 0.032
#> GSM26823     2  0.1022      0.966 0.000 0.968 0.000 0.032
#> GSM26824     2  0.1211      0.963 0.000 0.960 0.000 0.040
#> GSM26825     2  0.0188      0.963 0.000 0.996 0.000 0.004
#> GSM26826     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0817      0.966 0.000 0.976 0.000 0.024
#> GSM26828     2  0.0921      0.950 0.000 0.972 0.000 0.028
#> GSM26829     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM26830     2  0.1211      0.963 0.000 0.960 0.000 0.040
#> GSM26831     2  0.0524      0.959 0.004 0.988 0.000 0.008
#> GSM26832     4  0.4222      0.774 0.000 0.272 0.000 0.728
#> GSM26833     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26834     4  0.4843      0.557 0.000 0.396 0.000 0.604
#> GSM26835     4  0.4999      0.362 0.000 0.492 0.000 0.508
#> GSM26836     1  0.2546      0.843 0.900 0.000 0.092 0.008
#> GSM26837     1  0.5057      0.444 0.648 0.000 0.340 0.012
#> GSM26838     1  0.1022      0.876 0.968 0.000 0.000 0.032
#> GSM26839     1  0.3428      0.795 0.844 0.000 0.144 0.012
#> GSM26840     1  0.3149      0.843 0.880 0.032 0.000 0.088
#> GSM26841     1  0.0188      0.879 0.996 0.004 0.000 0.000
#> GSM26842     1  0.0524      0.878 0.988 0.004 0.008 0.000
#> GSM26843     1  0.2623      0.858 0.908 0.028 0.000 0.064
#> GSM26844     1  0.2214      0.866 0.928 0.028 0.000 0.044
#> GSM26845     1  0.4640      0.805 0.828 0.076 0.044 0.052
#> GSM26846     3  0.3178      0.838 0.032 0.052 0.896 0.020
#> GSM26847     3  0.3757      0.768 0.152 0.000 0.828 0.020
#> GSM26848     3  0.2275      0.863 0.048 0.004 0.928 0.020
#> GSM26849     3  0.0469      0.881 0.000 0.000 0.988 0.012
#> GSM26850     3  0.1174      0.878 0.000 0.012 0.968 0.020
#> GSM26851     4  0.2530      0.920 0.000 0.112 0.000 0.888
#> GSM26852     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26853     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26854     3  0.2149      0.907 0.088 0.000 0.912 0.000
#> GSM26855     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26856     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26857     3  0.2149      0.907 0.088 0.000 0.912 0.000
#> GSM26858     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26859     3  0.0469      0.881 0.000 0.000 0.988 0.012
#> GSM26860     3  0.2081      0.907 0.084 0.000 0.916 0.000
#> GSM26861     3  0.2334      0.907 0.088 0.000 0.908 0.004
#> GSM26862     1  0.4262      0.674 0.756 0.000 0.236 0.008
#> GSM26863     1  0.2675      0.838 0.892 0.000 0.100 0.008
#> GSM26864     1  0.1174      0.878 0.968 0.020 0.012 0.000
#> GSM26865     3  0.5632      0.289 0.352 0.008 0.620 0.020
#> GSM26866     1  0.0921      0.877 0.972 0.028 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
#> GSM26805     5  0.3819      0.548 0.000 0.228 0.000 0.016 0.756
#> GSM26806     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26807     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26808     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26809     5  0.3816      0.480 0.000 0.304 0.000 0.000 0.696
#> GSM26810     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26811     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26812     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26813     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26814     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26816     4  0.6399      0.268 0.000 0.308 0.000 0.496 0.196
#> GSM26817     4  0.0162      0.888 0.000 0.004 0.000 0.996 0.000
#> GSM26818     3  0.3890      0.733 0.252 0.000 0.736 0.012 0.000
#> GSM26819     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.5577      0.448 0.000 0.256 0.000 0.120 0.624
#> GSM26829     2  0.2471      0.815 0.000 0.864 0.000 0.000 0.136
#> GSM26830     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000
#> GSM26831     5  0.4219      0.255 0.000 0.416 0.000 0.000 0.584
#> GSM26832     4  0.3196      0.768 0.000 0.004 0.000 0.804 0.192
#> GSM26833     4  0.1430      0.869 0.000 0.004 0.000 0.944 0.052
#> GSM26834     4  0.3010      0.788 0.000 0.004 0.000 0.824 0.172
#> GSM26835     4  0.4297      0.304 0.000 0.000 0.000 0.528 0.472
#> GSM26836     1  0.4181      0.712 0.712 0.000 0.268 0.000 0.020
#> GSM26837     1  0.3774      0.704 0.704 0.000 0.296 0.000 0.000
#> GSM26838     1  0.4948      0.627 0.708 0.000 0.108 0.000 0.184
#> GSM26839     1  0.3861      0.710 0.712 0.000 0.284 0.000 0.004
#> GSM26840     5  0.2966      0.478 0.184 0.000 0.000 0.000 0.816
#> GSM26841     1  0.5956      0.487 0.564 0.000 0.140 0.000 0.296
#> GSM26842     1  0.5905      0.498 0.572 0.000 0.136 0.000 0.292
#> GSM26843     5  0.3305      0.457 0.224 0.000 0.000 0.000 0.776
#> GSM26844     5  0.4138      0.387 0.276 0.000 0.016 0.000 0.708
#> GSM26845     1  0.4227      0.466 0.692 0.016 0.000 0.000 0.292
#> GSM26846     1  0.4629      0.369 0.772 0.044 0.144 0.000 0.040
#> GSM26847     1  0.2773      0.423 0.836 0.000 0.164 0.000 0.000
#> GSM26848     3  0.5370      0.633 0.348 0.000 0.584 0.000 0.068
#> GSM26849     3  0.3816      0.712 0.304 0.000 0.696 0.000 0.000
#> GSM26850     3  0.4166      0.681 0.348 0.000 0.648 0.000 0.004
#> GSM26851     4  0.1041      0.877 0.000 0.004 0.000 0.964 0.032
#> GSM26852     3  0.0162      0.822 0.000 0.000 0.996 0.004 0.000
#> GSM26853     3  0.0162      0.822 0.000 0.000 0.996 0.004 0.000
#> GSM26854     3  0.0000      0.823 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0162      0.822 0.000 0.000 0.996 0.004 0.000
#> GSM26856     3  0.0000      0.823 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.823 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0162      0.822 0.000 0.000 0.996 0.004 0.000
#> GSM26859     3  0.3424      0.744 0.240 0.000 0.760 0.000 0.000
#> GSM26860     3  0.0000      0.823 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0162      0.822 0.000 0.000 0.996 0.004 0.000
#> GSM26862     1  0.4206      0.710 0.696 0.000 0.288 0.000 0.016
#> GSM26863     1  0.4451      0.708 0.712 0.000 0.248 0.000 0.040
#> GSM26864     5  0.6589     -0.144 0.364 0.000 0.212 0.000 0.424
#> GSM26865     3  0.5664      0.600 0.348 0.000 0.560 0.000 0.092
#> GSM26866     5  0.5811      0.255 0.264 0.000 0.140 0.000 0.596

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.2873      0.607 0.004 0.044 0.000 0.068 0.872 0.012
#> GSM26806     4  0.0146      0.951 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26807     4  0.0260      0.950 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26808     4  0.0405      0.950 0.000 0.000 0.000 0.988 0.008 0.004
#> GSM26809     5  0.5613      0.171 0.088 0.392 0.000 0.000 0.500 0.020
#> GSM26810     4  0.0260      0.951 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26811     4  0.0260      0.951 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26812     4  0.0000      0.950 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26814     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26815     4  0.0260      0.947 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26816     5  0.4748      0.566 0.000 0.052 0.000 0.316 0.624 0.008
#> GSM26817     4  0.1787      0.887 0.000 0.008 0.000 0.920 0.068 0.004
#> GSM26818     3  0.3514      0.694 0.000 0.000 0.768 0.020 0.004 0.208
#> GSM26819     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26827     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.2201      0.635 0.000 0.056 0.000 0.036 0.904 0.004
#> GSM26829     5  0.4096      0.184 0.000 0.484 0.000 0.000 0.508 0.008
#> GSM26830     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26831     5  0.2692      0.613 0.000 0.148 0.000 0.012 0.840 0.000
#> GSM26832     5  0.3565      0.553 0.000 0.000 0.000 0.304 0.692 0.004
#> GSM26833     5  0.3971      0.274 0.000 0.000 0.000 0.448 0.548 0.004
#> GSM26834     5  0.3636      0.532 0.000 0.000 0.000 0.320 0.676 0.004
#> GSM26835     5  0.2597      0.634 0.000 0.000 0.000 0.176 0.824 0.000
#> GSM26836     1  0.5320      0.556 0.576 0.000 0.144 0.000 0.000 0.280
#> GSM26837     1  0.5667      0.502 0.520 0.000 0.192 0.000 0.000 0.288
#> GSM26838     1  0.3229      0.658 0.816 0.000 0.044 0.000 0.000 0.140
#> GSM26839     1  0.4890      0.621 0.660 0.000 0.160 0.000 0.000 0.180
#> GSM26840     1  0.3955      0.391 0.608 0.000 0.000 0.000 0.384 0.008
#> GSM26841     1  0.3338      0.693 0.844 0.000 0.064 0.000 0.060 0.032
#> GSM26842     1  0.3216      0.693 0.852 0.000 0.064 0.000 0.052 0.032
#> GSM26843     1  0.2915      0.621 0.808 0.000 0.000 0.000 0.184 0.008
#> GSM26844     1  0.2982      0.639 0.820 0.000 0.012 0.000 0.164 0.004
#> GSM26845     6  0.3670      0.391 0.284 0.000 0.000 0.000 0.012 0.704
#> GSM26846     6  0.1442      0.681 0.040 0.000 0.004 0.000 0.012 0.944
#> GSM26847     6  0.2450      0.632 0.116 0.000 0.016 0.000 0.000 0.868
#> GSM26848     6  0.3455      0.690 0.000 0.000 0.056 0.000 0.144 0.800
#> GSM26849     6  0.3695      0.341 0.000 0.000 0.376 0.000 0.000 0.624
#> GSM26850     6  0.3293      0.693 0.000 0.000 0.048 0.000 0.140 0.812
#> GSM26851     4  0.3103      0.695 0.000 0.000 0.000 0.784 0.208 0.008
#> GSM26852     3  0.0508      0.925 0.012 0.000 0.984 0.000 0.000 0.004
#> GSM26853     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26854     3  0.0790      0.928 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM26855     3  0.0260      0.927 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26856     3  0.0790      0.928 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM26857     3  0.0790      0.928 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM26858     3  0.0508      0.925 0.012 0.000 0.984 0.000 0.000 0.004
#> GSM26859     3  0.2631      0.761 0.000 0.000 0.820 0.000 0.000 0.180
#> GSM26860     3  0.0865      0.926 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM26861     3  0.0508      0.925 0.012 0.000 0.984 0.000 0.000 0.004
#> GSM26862     1  0.5771      0.438 0.484 0.000 0.160 0.000 0.004 0.352
#> GSM26863     1  0.5135      0.593 0.616 0.000 0.144 0.000 0.000 0.240
#> GSM26864     1  0.4380      0.673 0.744 0.000 0.108 0.000 0.136 0.012
#> GSM26865     6  0.4423      0.659 0.052 0.000 0.176 0.000 0.032 0.740
#> GSM26866     1  0.3785      0.660 0.780 0.000 0.064 0.000 0.152 0.004

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

consensus_heatmap(res, k = 2)

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

test_to_known_factors(res)
#>         n tissue(p) individual(p) k
#> SD:NMF 62  1.14e-12      8.30e-01 2
#> SD:NMF 58  7.11e-11      2.44e-03 3
#> SD:NMF 59  3.68e-11      3.90e-05 4
#> SD:NMF 47  5.45e-08      4.67e-04 5
#> SD:NMF 55  3.89e-09      2.55e-10 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.367           0.799       0.836         0.4851 0.492   0.492
#> 3 3 0.608           0.901       0.910         0.2372 0.857   0.716
#> 4 4 0.750           0.884       0.924         0.1807 0.885   0.698
#> 5 5 0.867           0.829       0.928         0.0494 0.978   0.920
#> 6 6 0.845           0.790       0.918         0.0210 0.969   0.880

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     2   0.000      0.889 0.000 1.000
#> GSM26806     2   0.760      0.761 0.220 0.780
#> GSM26807     2   0.760      0.761 0.220 0.780
#> GSM26808     2   0.760      0.761 0.220 0.780
#> GSM26809     2   0.952      0.130 0.372 0.628
#> GSM26810     2   0.760      0.761 0.220 0.780
#> GSM26811     2   0.760      0.761 0.220 0.780
#> GSM26812     2   0.760      0.761 0.220 0.780
#> GSM26813     2   0.000      0.889 0.000 1.000
#> GSM26814     2   0.000      0.889 0.000 1.000
#> GSM26815     2   0.760      0.761 0.220 0.780
#> GSM26816     2   0.000      0.889 0.000 1.000
#> GSM26817     2   0.760      0.761 0.220 0.780
#> GSM26818     1   0.680      0.652 0.820 0.180
#> GSM26819     2   0.000      0.889 0.000 1.000
#> GSM26820     2   0.000      0.889 0.000 1.000
#> GSM26821     2   0.000      0.889 0.000 1.000
#> GSM26822     2   0.000      0.889 0.000 1.000
#> GSM26823     2   0.000      0.889 0.000 1.000
#> GSM26824     2   0.000      0.889 0.000 1.000
#> GSM26825     2   0.000      0.889 0.000 1.000
#> GSM26826     2   0.000      0.889 0.000 1.000
#> GSM26827     2   0.000      0.889 0.000 1.000
#> GSM26828     2   0.000      0.889 0.000 1.000
#> GSM26829     2   0.000      0.889 0.000 1.000
#> GSM26830     2   0.000      0.889 0.000 1.000
#> GSM26831     2   0.000      0.889 0.000 1.000
#> GSM26832     2   0.000      0.889 0.000 1.000
#> GSM26833     2   0.000      0.889 0.000 1.000
#> GSM26834     2   0.000      0.889 0.000 1.000
#> GSM26835     2   0.000      0.889 0.000 1.000
#> GSM26836     1   0.760      0.835 0.780 0.220
#> GSM26837     1   0.760      0.835 0.780 0.220
#> GSM26838     1   0.760      0.835 0.780 0.220
#> GSM26839     1   0.760      0.835 0.780 0.220
#> GSM26840     1   0.760      0.835 0.780 0.220
#> GSM26841     1   0.760      0.835 0.780 0.220
#> GSM26842     1   0.760      0.835 0.780 0.220
#> GSM26843     1   0.760      0.835 0.780 0.220
#> GSM26844     1   0.760      0.835 0.780 0.220
#> GSM26845     1   0.760      0.835 0.780 0.220
#> GSM26846     1   0.760      0.835 0.780 0.220
#> GSM26847     1   0.760      0.835 0.780 0.220
#> GSM26848     1   0.760      0.835 0.780 0.220
#> GSM26849     1   0.760      0.835 0.780 0.220
#> GSM26850     1   0.760      0.835 0.780 0.220
#> GSM26851     2   0.760      0.761 0.220 0.780
#> GSM26852     1   0.680      0.652 0.820 0.180
#> GSM26853     1   0.680      0.652 0.820 0.180
#> GSM26854     1   0.680      0.652 0.820 0.180
#> GSM26855     1   0.680      0.652 0.820 0.180
#> GSM26856     1   0.680      0.652 0.820 0.180
#> GSM26857     1   0.680      0.652 0.820 0.180
#> GSM26858     1   0.680      0.652 0.820 0.180
#> GSM26859     1   0.680      0.652 0.820 0.180
#> GSM26860     1   0.680      0.652 0.820 0.180
#> GSM26861     1   0.680      0.652 0.820 0.180
#> GSM26862     1   0.760      0.835 0.780 0.220
#> GSM26863     1   0.760      0.835 0.780 0.220
#> GSM26864     1   0.760      0.835 0.780 0.220
#> GSM26865     1   0.760      0.835 0.780 0.220
#> GSM26866     1   0.760      0.835 0.780 0.220

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26806     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26807     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26808     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26809     1   0.615     0.0125 0.592 0.408 0.000
#> GSM26810     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26811     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26812     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26813     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26814     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26815     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26816     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26817     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26818     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26819     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26820     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26821     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26822     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26823     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26824     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26825     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26826     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26827     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26828     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26829     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26830     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26831     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26832     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26833     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26834     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26835     2   0.480     0.9076 0.220 0.780 0.000
#> GSM26836     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26837     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26838     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26839     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26840     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26841     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26842     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26843     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26844     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26845     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26846     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26847     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26848     1   0.355     0.8547 0.868 0.000 0.132
#> GSM26849     1   0.355     0.8547 0.868 0.000 0.132
#> GSM26850     1   0.355     0.8547 0.868 0.000 0.132
#> GSM26851     2   0.000     0.8010 0.000 1.000 0.000
#> GSM26852     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26853     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26854     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26855     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26856     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26857     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26858     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26859     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26860     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26861     3   0.000     1.0000 0.000 0.000 1.000
#> GSM26862     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26863     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26864     1   0.000     0.9476 1.000 0.000 0.000
#> GSM26865     1   0.355     0.8547 0.868 0.000 0.132
#> GSM26866     1   0.000     0.9476 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26806     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26807     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26808     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26809     2  0.7589     -0.079 0.396 0.408 0.000 0.196
#> GSM26810     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26811     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26812     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26813     2  0.0336      0.933 0.000 0.992 0.000 0.008
#> GSM26814     2  0.0336      0.933 0.000 0.992 0.000 0.008
#> GSM26815     4  0.3569      0.995 0.000 0.196 0.000 0.804
#> GSM26816     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26817     4  0.3837      0.962 0.000 0.224 0.000 0.776
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0336      0.933 0.000 0.992 0.000 0.008
#> GSM26825     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0336      0.933 0.000 0.992 0.000 0.008
#> GSM26831     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26833     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26834     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.939 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26840     1  0.3569      0.742 0.804 0.000 0.000 0.196
#> GSM26841     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26845     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26846     1  0.3801      0.739 0.780 0.220 0.000 0.000
#> GSM26847     1  0.3801      0.739 0.780 0.220 0.000 0.000
#> GSM26848     1  0.6359      0.671 0.648 0.220 0.132 0.000
#> GSM26849     1  0.6359      0.671 0.648 0.220 0.132 0.000
#> GSM26850     1  0.6359      0.671 0.648 0.220 0.132 0.000
#> GSM26851     2  0.4907     -0.122 0.000 0.580 0.000 0.420
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.884 1.000 0.000 0.000 0.000
#> GSM26865     1  0.6359      0.671 0.648 0.220 0.132 0.000
#> GSM26866     1  0.0000      0.884 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26806     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26809     5  0.5747     0.1490 0.088 0.408 0.000 0.000 0.504
#> GSM26810     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.0290     0.9634 0.000 0.992 0.000 0.008 0.000
#> GSM26814     2  0.0290     0.9634 0.000 0.992 0.000 0.008 0.000
#> GSM26815     4  0.0000     0.9938 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26817     4  0.0794     0.9556 0.000 0.028 0.000 0.972 0.000
#> GSM26818     3  0.1908     0.9045 0.000 0.000 0.908 0.000 0.092
#> GSM26819     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0290     0.9634 0.000 0.992 0.000 0.008 0.000
#> GSM26825     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26830     2  0.0290     0.9634 0.000 0.992 0.000 0.008 0.000
#> GSM26831     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26833     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26834     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26835     2  0.0000     0.9702 0.000 1.000 0.000 0.000 0.000
#> GSM26836     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26837     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26838     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26840     5  0.4302    -0.0993 0.480 0.000 0.000 0.000 0.520
#> GSM26841     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012
#> GSM26842     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012
#> GSM26843     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012
#> GSM26844     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012
#> GSM26845     1  0.2773     0.6117 0.836 0.000 0.000 0.000 0.164
#> GSM26846     1  0.6265     0.3713 0.540 0.220 0.000 0.000 0.240
#> GSM26847     1  0.6265     0.3713 0.540 0.220 0.000 0.000 0.240
#> GSM26848     1  0.6717     0.4255 0.572 0.220 0.040 0.000 0.168
#> GSM26849     1  0.6717     0.4255 0.572 0.220 0.040 0.000 0.168
#> GSM26850     1  0.6717     0.4255 0.572 0.220 0.040 0.000 0.168
#> GSM26851     2  0.6024     0.1178 0.000 0.556 0.000 0.296 0.148
#> GSM26852     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000     0.9910 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26863     1  0.0000     0.7618 1.000 0.000 0.000 0.000 0.000
#> GSM26864     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012
#> GSM26865     1  0.6717     0.4255 0.572 0.220 0.040 0.000 0.168
#> GSM26866     1  0.0404     0.7593 0.988 0.000 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26806     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     6  0.3774    -0.2100 0.000 0.408 0.000 0.000 0.000 0.592
#> GSM26810     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.0260     0.9906 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM26814     2  0.0260     0.9906 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM26815     4  0.0000     0.9920 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26817     4  0.0713     0.9424 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26818     3  0.2510     0.8432 0.000 0.000 0.872 0.000 0.100 0.028
#> GSM26819     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0260     0.9906 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM26825     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26829     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26830     2  0.0260     0.9906 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM26831     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26832     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26833     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26834     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26835     2  0.0000     0.9978 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26836     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26837     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26838     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26840     6  0.3737    -0.0928 0.392 0.000 0.000 0.000 0.000 0.608
#> GSM26841     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26842     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26843     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26844     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26845     1  0.3266     0.4280 0.728 0.000 0.000 0.000 0.000 0.272
#> GSM26846     6  0.7278     0.2797 0.308 0.220 0.000 0.000 0.108 0.364
#> GSM26847     6  0.7278     0.2797 0.308 0.220 0.000 0.000 0.108 0.364
#> GSM26848     1  0.7233    -0.1005 0.448 0.220 0.004 0.000 0.208 0.120
#> GSM26849     1  0.7233    -0.1005 0.448 0.220 0.004 0.000 0.208 0.120
#> GSM26850     1  0.7233    -0.1005 0.448 0.220 0.004 0.000 0.208 0.120
#> GSM26851     5  0.3657     0.0000 0.000 0.108 0.000 0.100 0.792 0.000
#> GSM26852     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000     0.9857 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26863     1  0.0000     0.7644 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26864     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26865     1  0.7233    -0.1005 0.448 0.220 0.004 0.000 0.208 0.120
#> GSM26866     1  0.0363     0.7632 0.988 0.000 0.000 0.000 0.000 0.012

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> CV:hclust 61  1.90e-12      7.88e-01 2
#> CV:hclust 61  2.42e-12      6.35e-05 3
#> CV:hclust 60  3.51e-12      3.82e-07 4
#> CV:hclust 53  1.13e-10      1.55e-06 5
#> CV:hclust 52  1.86e-10      7.42e-07 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 62 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.648           0.946       0.947         0.4906 0.492   0.492
#> 3 3 0.762           0.842       0.850         0.2630 0.884   0.763
#> 4 4 0.673           0.883       0.856         0.1325 0.887   0.703
#> 5 5 0.745           0.739       0.845         0.0863 0.967   0.881
#> 6 6 0.793           0.562       0.744         0.0508 0.897   0.621

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
#> GSM26805     2   0.000      0.978 0.000 1.000
#> GSM26806     2   0.388      0.932 0.076 0.924
#> GSM26807     2   0.388      0.932 0.076 0.924
#> GSM26808     2   0.373      0.935 0.072 0.928
#> GSM26809     2   0.000      0.978 0.000 1.000
#> GSM26810     2   0.388      0.932 0.076 0.924
#> GSM26811     2   0.373      0.935 0.072 0.928
#> GSM26812     2   0.388      0.932 0.076 0.924
#> GSM26813     2   0.000      0.978 0.000 1.000
#> GSM26814     2   0.000      0.978 0.000 1.000
#> GSM26815     2   0.388      0.932 0.076 0.924
#> GSM26816     2   0.000      0.978 0.000 1.000
#> GSM26817     2   0.295      0.948 0.052 0.948
#> GSM26818     1   0.000      0.905 1.000 0.000
#> GSM26819     2   0.000      0.978 0.000 1.000
#> GSM26820     2   0.000      0.978 0.000 1.000
#> GSM26821     2   0.000      0.978 0.000 1.000
#> GSM26822     2   0.000      0.978 0.000 1.000
#> GSM26823     2   0.000      0.978 0.000 1.000
#> GSM26824     2   0.000      0.978 0.000 1.000
#> GSM26825     2   0.000      0.978 0.000 1.000
#> GSM26826     2   0.000      0.978 0.000 1.000
#> GSM26827     2   0.000      0.978 0.000 1.000
#> GSM26828     2   0.000      0.978 0.000 1.000
#> GSM26829     2   0.000      0.978 0.000 1.000
#> GSM26830     2   0.000      0.978 0.000 1.000
#> GSM26831     2   0.000      0.978 0.000 1.000
#> GSM26832     2   0.000      0.978 0.000 1.000
#> GSM26833     2   0.000      0.978 0.000 1.000
#> GSM26834     2   0.000      0.978 0.000 1.000
#> GSM26835     2   0.000      0.978 0.000 1.000
#> GSM26836     1   0.595      0.937 0.856 0.144
#> GSM26837     1   0.595      0.937 0.856 0.144
#> GSM26838     1   0.595      0.937 0.856 0.144
#> GSM26839     1   0.595      0.937 0.856 0.144
#> GSM26840     1   0.595      0.937 0.856 0.144
#> GSM26841     1   0.595      0.937 0.856 0.144
#> GSM26842     1   0.595      0.937 0.856 0.144
#> GSM26843     1   0.595      0.937 0.856 0.144
#> GSM26844     1   0.595      0.937 0.856 0.144
#> GSM26845     1   0.595      0.937 0.856 0.144
#> GSM26846     1   0.595      0.937 0.856 0.144
#> GSM26847     1   0.595      0.937 0.856 0.144
#> GSM26848     1   0.595      0.937 0.856 0.144
#> GSM26849     1   0.000      0.905 1.000 0.000
#> GSM26850     1   0.595      0.937 0.856 0.144
#> GSM26851     2   0.000      0.978 0.000 1.000
#> GSM26852     1   0.000      0.905 1.000 0.000
#> GSM26853     1   0.000      0.905 1.000 0.000
#> GSM26854     1   0.000      0.905 1.000 0.000
#> GSM26855     1   0.000      0.905 1.000 0.000
#> GSM26856     1   0.000      0.905 1.000 0.000
#> GSM26857     1   0.000      0.905 1.000 0.000
#> GSM26858     1   0.000      0.905 1.000 0.000
#> GSM26859     1   0.000      0.905 1.000 0.000
#> GSM26860     1   0.000      0.905 1.000 0.000
#> GSM26861     1   0.000      0.905 1.000 0.000
#> GSM26862     1   0.595      0.937 0.856 0.144
#> GSM26863     1   0.595      0.937 0.856 0.144
#> GSM26864     1   0.595      0.937 0.856 0.144
#> GSM26865     1   0.595      0.937 0.856 0.144
#> GSM26866     1   0.595      0.937 0.856 0.144

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26806     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26807     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26808     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26809     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26810     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26811     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26812     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26813     2  0.0237      0.896 0.000 0.996 0.004
#> GSM26814     2  0.0237      0.896 0.000 0.996 0.004
#> GSM26815     2  0.6225      0.666 0.000 0.568 0.432
#> GSM26816     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26817     2  0.5397      0.756 0.000 0.720 0.280
#> GSM26818     3  0.6057      0.820 0.340 0.004 0.656
#> GSM26819     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26830     2  0.0237      0.896 0.000 0.996 0.004
#> GSM26831     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26832     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26833     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26834     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.898 0.000 1.000 0.000
#> GSM26836     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26837     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26838     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26839     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26840     1  0.2280      0.835 0.940 0.052 0.008
#> GSM26841     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26842     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26843     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26844     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26845     1  0.6745      0.235 0.560 0.428 0.012
#> GSM26846     1  0.1482      0.889 0.968 0.020 0.012
#> GSM26847     1  0.1170      0.894 0.976 0.016 0.008
#> GSM26848     1  0.1315      0.892 0.972 0.020 0.008
#> GSM26849     1  0.6460     -0.717 0.556 0.004 0.440
#> GSM26850     1  0.1315      0.892 0.972 0.020 0.008
#> GSM26851     2  0.4399      0.809 0.000 0.812 0.188
#> GSM26852     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26853     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26854     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26855     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26856     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26857     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26858     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26859     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26860     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26861     3  0.6460      0.981 0.440 0.004 0.556
#> GSM26862     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26863     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26864     1  0.0747      0.899 0.984 0.016 0.000
#> GSM26865     1  0.1170      0.894 0.976 0.016 0.008
#> GSM26866     1  0.0747      0.899 0.984 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.2814      0.875 0.132 0.868 0.000 0.000
#> GSM26806     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26807     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26808     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26809     2  0.2521      0.883 0.064 0.912 0.000 0.024
#> GSM26810     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26811     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26812     4  0.4008      0.954 0.000 0.244 0.000 0.756
#> GSM26813     2  0.0469      0.896 0.012 0.988 0.000 0.000
#> GSM26814     2  0.0469      0.896 0.012 0.988 0.000 0.000
#> GSM26815     4  0.4328      0.950 0.008 0.244 0.000 0.748
#> GSM26816     2  0.2921      0.873 0.140 0.860 0.000 0.000
#> GSM26817     4  0.6727      0.561 0.092 0.412 0.000 0.496
#> GSM26818     3  0.2198      0.900 0.008 0.000 0.920 0.072
#> GSM26819     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM26828     2  0.2921      0.873 0.140 0.860 0.000 0.000
#> GSM26829     2  0.2647      0.879 0.120 0.880 0.000 0.000
#> GSM26830     2  0.0469      0.896 0.012 0.988 0.000 0.000
#> GSM26831     2  0.3400      0.850 0.180 0.820 0.000 0.000
#> GSM26832     2  0.3400      0.850 0.180 0.820 0.000 0.000
#> GSM26833     2  0.3400      0.850 0.180 0.820 0.000 0.000
#> GSM26834     2  0.3400      0.850 0.180 0.820 0.000 0.000
#> GSM26835     2  0.3400      0.850 0.180 0.820 0.000 0.000
#> GSM26836     1  0.3764      0.890 0.784 0.000 0.216 0.000
#> GSM26837     1  0.3764      0.890 0.784 0.000 0.216 0.000
#> GSM26838     1  0.4086      0.889 0.776 0.000 0.216 0.008
#> GSM26839     1  0.4086      0.889 0.776 0.000 0.216 0.008
#> GSM26840     1  0.5649      0.828 0.732 0.004 0.148 0.116
#> GSM26841     1  0.5809      0.891 0.692 0.000 0.216 0.092
#> GSM26842     1  0.5809      0.891 0.692 0.000 0.216 0.092
#> GSM26843     1  0.5809      0.891 0.692 0.000 0.216 0.092
#> GSM26844     1  0.5809      0.891 0.692 0.000 0.216 0.092
#> GSM26845     1  0.5891      0.594 0.700 0.168 0.000 0.132
#> GSM26846     1  0.6215      0.832 0.664 0.000 0.208 0.128
#> GSM26847     1  0.6281      0.836 0.656 0.000 0.216 0.128
#> GSM26848     1  0.7036      0.845 0.576 0.000 0.216 0.208
#> GSM26849     3  0.5604      0.583 0.116 0.000 0.724 0.160
#> GSM26850     1  0.7036      0.845 0.576 0.000 0.216 0.208
#> GSM26851     2  0.6058      0.629 0.180 0.684 0.000 0.136
#> GSM26852     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.965 0.000 0.000 1.000 0.000
#> GSM26862     1  0.3764      0.890 0.784 0.000 0.216 0.000
#> GSM26863     1  0.3764      0.890 0.784 0.000 0.216 0.000
#> GSM26864     1  0.5809      0.891 0.692 0.000 0.216 0.092
#> GSM26865     1  0.7065      0.844 0.572 0.000 0.216 0.212
#> GSM26866     1  0.5809      0.891 0.692 0.000 0.216 0.092

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.3143      0.828 0.000 0.796 0.000 0.000 0.204
#> GSM26806     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26807     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26808     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26809     2  0.1469      0.839 0.000 0.948 0.000 0.016 0.036
#> GSM26810     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26811     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26812     4  0.2280      0.949 0.000 0.120 0.000 0.880 0.000
#> GSM26813     2  0.1357      0.859 0.000 0.948 0.004 0.000 0.048
#> GSM26814     2  0.1357      0.859 0.000 0.948 0.004 0.000 0.048
#> GSM26815     4  0.3059      0.938 0.000 0.120 0.008 0.856 0.016
#> GSM26816     2  0.3210      0.826 0.000 0.788 0.000 0.000 0.212
#> GSM26817     4  0.6440      0.564 0.000 0.272 0.012 0.548 0.168
#> GSM26818     3  0.2270      0.910 0.020 0.000 0.904 0.000 0.076
#> GSM26819     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0671      0.861 0.000 0.980 0.004 0.000 0.016
#> GSM26822     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0771      0.859 0.000 0.976 0.004 0.000 0.020
#> GSM26825     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0290      0.863 0.000 0.992 0.000 0.000 0.008
#> GSM26827     2  0.0000      0.865 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2  0.3143      0.827 0.000 0.796 0.000 0.000 0.204
#> GSM26829     2  0.2929      0.834 0.000 0.820 0.000 0.000 0.180
#> GSM26830     2  0.1357      0.859 0.000 0.948 0.004 0.000 0.048
#> GSM26831     2  0.3707      0.786 0.000 0.716 0.000 0.000 0.284
#> GSM26832     2  0.3707      0.786 0.000 0.716 0.000 0.000 0.284
#> GSM26833     2  0.3796      0.781 0.000 0.700 0.000 0.000 0.300
#> GSM26834     2  0.3707      0.786 0.000 0.716 0.000 0.000 0.284
#> GSM26835     2  0.3707      0.786 0.000 0.716 0.000 0.000 0.284
#> GSM26836     1  0.1041      0.610 0.964 0.000 0.004 0.000 0.032
#> GSM26837     1  0.1041      0.610 0.964 0.000 0.004 0.000 0.032
#> GSM26838     1  0.0162      0.624 0.996 0.000 0.004 0.000 0.000
#> GSM26839     1  0.0162      0.624 0.996 0.000 0.004 0.000 0.000
#> GSM26840     1  0.4734      0.589 0.728 0.000 0.000 0.096 0.176
#> GSM26841     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152
#> GSM26842     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152
#> GSM26843     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152
#> GSM26844     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152
#> GSM26845     1  0.5195     -0.315 0.608 0.016 0.000 0.028 0.348
#> GSM26846     1  0.4848     -0.452 0.556 0.000 0.000 0.024 0.420
#> GSM26847     1  0.4639     -0.308 0.632 0.000 0.000 0.024 0.344
#> GSM26848     5  0.4283      0.570 0.456 0.000 0.000 0.000 0.544
#> GSM26849     5  0.6294      0.153 0.152 0.000 0.404 0.000 0.444
#> GSM26850     5  0.4283      0.570 0.456 0.000 0.000 0.000 0.544
#> GSM26851     2  0.6149      0.550 0.000 0.548 0.004 0.140 0.308
#> GSM26852     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26853     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26854     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26855     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26856     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26857     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26858     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26859     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26860     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26861     3  0.0510      0.992 0.016 0.000 0.984 0.000 0.000
#> GSM26862     1  0.1041      0.610 0.964 0.000 0.004 0.000 0.032
#> GSM26863     1  0.1041      0.610 0.964 0.000 0.004 0.000 0.032
#> GSM26864     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152
#> GSM26865     5  0.4278      0.567 0.452 0.000 0.000 0.000 0.548
#> GSM26866     1  0.4450      0.631 0.764 0.000 0.004 0.080 0.152

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     2  0.4468     -0.576 0.000 0.560 0.000 0.000 0.408 0.032
#> GSM26806     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26807     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26808     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26809     2  0.2669      0.631 0.000 0.880 0.000 0.016 0.032 0.072
#> GSM26810     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26811     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26812     4  0.0713      0.918 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM26813     2  0.2728      0.653 0.000 0.860 0.000 0.000 0.040 0.100
#> GSM26814     2  0.2728      0.653 0.000 0.860 0.000 0.000 0.040 0.100
#> GSM26815     4  0.3730      0.835 0.000 0.028 0.000 0.812 0.060 0.100
#> GSM26816     2  0.4475     -0.584 0.000 0.556 0.000 0.000 0.412 0.032
#> GSM26817     4  0.7278      0.356 0.000 0.152 0.000 0.428 0.224 0.196
#> GSM26818     3  0.3042      0.807 0.004 0.000 0.836 0.000 0.128 0.032
#> GSM26819     2  0.0146      0.733 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26820     2  0.0000      0.733 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0717      0.726 0.000 0.976 0.000 0.000 0.016 0.008
#> GSM26822     2  0.0146      0.733 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26823     2  0.0000      0.733 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0891      0.719 0.000 0.968 0.000 0.000 0.024 0.008
#> GSM26825     2  0.0146      0.733 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26826     2  0.0146      0.732 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26827     2  0.0000      0.733 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     2  0.4475     -0.584 0.000 0.556 0.000 0.000 0.412 0.032
#> GSM26829     2  0.4409     -0.504 0.000 0.588 0.000 0.000 0.380 0.032
#> GSM26830     2  0.2775      0.651 0.000 0.856 0.000 0.000 0.040 0.104
#> GSM26831     5  0.3857      0.871 0.000 0.468 0.000 0.000 0.532 0.000
#> GSM26832     5  0.4089      0.868 0.000 0.468 0.000 0.000 0.524 0.008
#> GSM26833     5  0.4161      0.846 0.000 0.448 0.000 0.000 0.540 0.012
#> GSM26834     5  0.3857      0.871 0.000 0.468 0.000 0.000 0.532 0.000
#> GSM26835     5  0.3857      0.871 0.000 0.468 0.000 0.000 0.532 0.000
#> GSM26836     1  0.3672      0.346 0.632 0.000 0.000 0.000 0.000 0.368
#> GSM26837     1  0.3672      0.346 0.632 0.000 0.000 0.000 0.000 0.368
#> GSM26838     1  0.3620      0.364 0.648 0.000 0.000 0.000 0.000 0.352
#> GSM26839     1  0.3634      0.360 0.644 0.000 0.000 0.000 0.000 0.356
#> GSM26840     1  0.2095      0.486 0.916 0.000 0.000 0.016 0.028 0.040
#> GSM26841     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.5029      0.809 0.308 0.004 0.000 0.016 0.052 0.620
#> GSM26846     6  0.6063      0.693 0.316 0.000 0.000 0.012 0.192 0.480
#> GSM26847     6  0.4663      0.807 0.324 0.000 0.000 0.008 0.044 0.624
#> GSM26848     1  0.5937     -0.531 0.436 0.000 0.000 0.000 0.224 0.340
#> GSM26849     3  0.7470     -0.296 0.140 0.000 0.332 0.000 0.224 0.304
#> GSM26850     1  0.5937     -0.531 0.436 0.000 0.000 0.000 0.224 0.340
#> GSM26851     5  0.6314      0.537 0.000 0.292 0.004 0.112 0.532 0.060
#> GSM26852     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26853     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26854     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26855     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26856     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26857     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26858     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26859     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26860     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26861     3  0.0146      0.928 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM26862     1  0.3672      0.346 0.632 0.000 0.000 0.000 0.000 0.368
#> GSM26863     1  0.3672      0.346 0.632 0.000 0.000 0.000 0.000 0.368
#> GSM26864     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     1  0.5932     -0.524 0.440 0.000 0.000 0.000 0.224 0.336
#> GSM26866     1  0.0000      0.548 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> CV:kmeans 62  1.14e-12      8.30e-01 2
#> CV:kmeans 60  4.01e-12      1.05e-04 3
#> CV:kmeans 62  8.75e-12      2.79e-06 4
#> CV:kmeans 58  2.84e-10      2.75e-07 5
#> CV:kmeans 46  2.48e-07      1.00e-09 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 62 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-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.5087 0.492   0.492
#> 3 3 1.000           0.979       0.987         0.2389 0.879   0.755
#> 4 4 1.000           0.971       0.976         0.1623 0.895   0.718
#> 5 5 0.898           0.898       0.900         0.0685 0.959   0.845
#> 6 6 0.890           0.871       0.860         0.0607 0.938   0.725

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     1       0          1  1  0
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     1       0          1  1  0
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26806     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26807     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26808     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26809     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26810     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26811     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26812     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26813     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26815     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26816     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26817     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26818     3  0.0237      0.990 0.004 0.000 0.996
#> GSM26819     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26831     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26832     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26833     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26834     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.997 0.000 1.000 0.000
#> GSM26836     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26838     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26840     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26841     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26845     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26846     1  0.1529      0.939 0.960 0.000 0.040
#> GSM26847     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26848     1  0.4002      0.828 0.840 0.000 0.160
#> GSM26849     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26850     1  0.4842      0.742 0.776 0.000 0.224
#> GSM26851     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26852     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26853     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26854     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26855     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26856     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26857     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26858     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26859     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26860     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26861     3  0.0592      0.999 0.012 0.000 0.988
#> GSM26862     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.967 1.000 0.000 0.000
#> GSM26865     1  0.4002      0.828 0.840 0.000 0.160
#> GSM26866     1  0.0000      0.967 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26806     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26807     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26808     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26809     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26810     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26811     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26812     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26813     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM26814     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM26815     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26816     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26817     4  0.1637      0.981 0.000 0.060 0.000 0.940
#> GSM26818     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM26825     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26831     2  0.0000      0.997 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0469      0.988 0.000 0.988 0.000 0.012
#> GSM26833     2  0.1022      0.968 0.000 0.968 0.000 0.032
#> GSM26834     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM26835     2  0.0188      0.995 0.000 0.996 0.000 0.004
#> GSM26836     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26837     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26838     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26839     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26840     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26841     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26842     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26843     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26844     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26845     1  0.1109      0.941 0.968 0.000 0.004 0.028
#> GSM26846     1  0.2670      0.907 0.908 0.000 0.052 0.040
#> GSM26847     1  0.1398      0.936 0.956 0.000 0.004 0.040
#> GSM26848     1  0.4423      0.790 0.788 0.000 0.176 0.036
#> GSM26849     3  0.0469      0.986 0.000 0.000 0.988 0.012
#> GSM26850     1  0.5172      0.669 0.704 0.000 0.260 0.036
#> GSM26851     4  0.1302      0.998 0.000 0.044 0.000 0.956
#> GSM26852     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26853     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26854     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26855     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26856     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26857     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26858     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26859     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26860     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26861     3  0.0188      0.998 0.004 0.000 0.996 0.000
#> GSM26862     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26863     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26864     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26865     1  0.4511      0.790 0.784 0.000 0.176 0.040
#> GSM26866     1  0.0188      0.951 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.3966      0.786 0.000 0.664 0.000 0.000 0.336
#> GSM26806     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26810     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.0290      0.855 0.000 0.992 0.000 0.008 0.000
#> GSM26814     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4  0.0000      0.997 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2  0.3983      0.785 0.000 0.660 0.000 0.000 0.340
#> GSM26817     4  0.0693      0.977 0.000 0.012 0.000 0.980 0.008
#> GSM26818     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26819     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2  0.3983      0.785 0.000 0.660 0.000 0.000 0.340
#> GSM26829     2  0.3966      0.786 0.000 0.664 0.000 0.000 0.336
#> GSM26830     2  0.0000      0.860 0.000 1.000 0.000 0.000 0.000
#> GSM26831     2  0.3983      0.785 0.000 0.660 0.000 0.000 0.340
#> GSM26832     2  0.4252      0.780 0.000 0.652 0.000 0.008 0.340
#> GSM26833     2  0.5052      0.748 0.000 0.612 0.000 0.048 0.340
#> GSM26834     2  0.3983      0.785 0.000 0.660 0.000 0.000 0.340
#> GSM26835     2  0.3983      0.785 0.000 0.660 0.000 0.000 0.340
#> GSM26836     1  0.1792      0.915 0.916 0.000 0.000 0.000 0.084
#> GSM26837     1  0.1792      0.915 0.916 0.000 0.000 0.000 0.084
#> GSM26838     1  0.1732      0.916 0.920 0.000 0.000 0.000 0.080
#> GSM26839     1  0.1732      0.916 0.920 0.000 0.000 0.000 0.080
#> GSM26840     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26845     5  0.4307      0.576 0.496 0.000 0.000 0.000 0.504
#> GSM26846     5  0.4118      0.861 0.336 0.000 0.004 0.000 0.660
#> GSM26847     5  0.3983      0.859 0.340 0.000 0.000 0.000 0.660
#> GSM26848     5  0.4537      0.870 0.396 0.000 0.012 0.000 0.592
#> GSM26849     3  0.2690      0.828 0.000 0.000 0.844 0.000 0.156
#> GSM26850     5  0.5068      0.843 0.364 0.000 0.044 0.000 0.592
#> GSM26851     4  0.0162      0.994 0.000 0.000 0.000 0.996 0.004
#> GSM26852     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.1792      0.915 0.916 0.000 0.000 0.000 0.084
#> GSM26863     1  0.1792      0.915 0.916 0.000 0.000 0.000 0.084
#> GSM26864     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000
#> GSM26865     5  0.4547      0.868 0.400 0.000 0.012 0.000 0.588
#> GSM26866     1  0.0000      0.930 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.0713     0.9739 0.000 0.028 0.000 0.000 0.972 0.000
#> GSM26806     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.2793     0.9794 0.000 0.800 0.000 0.000 0.200 0.000
#> GSM26810     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.2772     0.9785 0.000 0.816 0.000 0.000 0.180 0.004
#> GSM26814     2  0.2772     0.9785 0.000 0.816 0.000 0.000 0.180 0.004
#> GSM26815     4  0.0000     0.9923 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.0632     0.9761 0.000 0.024 0.000 0.000 0.976 0.000
#> GSM26817     4  0.1367     0.9420 0.000 0.012 0.000 0.944 0.044 0.000
#> GSM26818     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26819     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26820     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26821     2  0.2631     0.9871 0.000 0.820 0.000 0.000 0.180 0.000
#> GSM26822     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26823     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26824     2  0.2597     0.9849 0.000 0.824 0.000 0.000 0.176 0.000
#> GSM26825     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26826     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26827     2  0.2697     0.9899 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM26828     5  0.0458     0.9796 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26829     5  0.1267     0.9392 0.000 0.060 0.000 0.000 0.940 0.000
#> GSM26830     2  0.2772     0.9785 0.000 0.816 0.000 0.000 0.180 0.004
#> GSM26831     5  0.0363     0.9801 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM26832     5  0.0363     0.9710 0.000 0.000 0.000 0.012 0.988 0.000
#> GSM26833     5  0.0858     0.9492 0.000 0.004 0.000 0.028 0.968 0.000
#> GSM26834     5  0.0363     0.9801 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM26835     5  0.0363     0.9801 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM26836     1  0.5440     0.6816 0.616 0.164 0.000 0.000 0.012 0.208
#> GSM26837     1  0.5440     0.6816 0.616 0.164 0.000 0.000 0.012 0.208
#> GSM26838     1  0.5390     0.6854 0.624 0.164 0.000 0.000 0.012 0.200
#> GSM26839     1  0.5360     0.6867 0.628 0.160 0.000 0.000 0.012 0.200
#> GSM26840     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.5740     0.0167 0.284 0.168 0.000 0.000 0.008 0.540
#> GSM26846     6  0.0508     0.6957 0.004 0.012 0.000 0.000 0.000 0.984
#> GSM26847     6  0.3053     0.5976 0.004 0.172 0.000 0.000 0.012 0.812
#> GSM26848     6  0.2730     0.7297 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM26849     3  0.3847     0.2284 0.000 0.000 0.544 0.000 0.000 0.456
#> GSM26850     6  0.2915     0.7300 0.184 0.000 0.008 0.000 0.000 0.808
#> GSM26851     4  0.0146     0.9889 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26852     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000     0.9575 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.5440     0.6816 0.616 0.164 0.000 0.000 0.012 0.208
#> GSM26863     1  0.5440     0.6816 0.616 0.164 0.000 0.000 0.012 0.208
#> GSM26864     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.2762     0.7270 0.196 0.000 0.000 0.000 0.000 0.804
#> GSM26866     1  0.0000     0.7502 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> 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-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> CV:skmeans 62  1.14e-12      8.30e-01 2
#> CV:skmeans 62  1.49e-12      1.94e-04 3
#> CV:skmeans 62  7.66e-12      2.40e-06 4
#> CV:skmeans 62  3.62e-11      4.35e-09 5
#> CV:skmeans 60  3.70e-10      2.02e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


CV:pam*

The object with results only for a single top-value method and a single partition method can be extracted as:

res = res_list["CV", "pam"]
# you can also extract it by
# res = res_list["CV:pam"]

A summary of res and all the functions that can be applied to it:

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 11993 rows and 62 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.946       0.980         0.5052 0.494   0.494
#> 3 3 1.000           0.974       0.990         0.2378 0.841   0.690
#> 4 4 0.984           0.926       0.973         0.1624 0.895   0.718
#> 5 5 0.948           0.900       0.944         0.0660 0.936   0.770
#> 6 6 0.892           0.865       0.872         0.0591 0.905   0.604

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     2   0.000      0.983 0.000 1.000
#> GSM26806     2   0.000      0.983 0.000 1.000
#> GSM26807     2   0.000      0.983 0.000 1.000
#> GSM26808     2   0.000      0.983 0.000 1.000
#> GSM26809     2   0.000      0.983 0.000 1.000
#> GSM26810     2   0.000      0.983 0.000 1.000
#> GSM26811     2   0.000      0.983 0.000 1.000
#> GSM26812     2   0.000      0.983 0.000 1.000
#> GSM26813     2   0.000      0.983 0.000 1.000
#> GSM26814     2   0.000      0.983 0.000 1.000
#> GSM26815     2   0.000      0.983 0.000 1.000
#> GSM26816     2   0.000      0.983 0.000 1.000
#> GSM26817     2   0.000      0.983 0.000 1.000
#> GSM26818     1   0.000      0.973 1.000 0.000
#> GSM26819     2   0.000      0.983 0.000 1.000
#> GSM26820     2   0.000      0.983 0.000 1.000
#> GSM26821     2   0.000      0.983 0.000 1.000
#> GSM26822     2   0.000      0.983 0.000 1.000
#> GSM26823     2   0.000      0.983 0.000 1.000
#> GSM26824     2   0.000      0.983 0.000 1.000
#> GSM26825     2   0.000      0.983 0.000 1.000
#> GSM26826     2   0.000      0.983 0.000 1.000
#> GSM26827     2   0.000      0.983 0.000 1.000
#> GSM26828     2   0.000      0.983 0.000 1.000
#> GSM26829     2   0.000      0.983 0.000 1.000
#> GSM26830     2   0.000      0.983 0.000 1.000
#> GSM26831     2   0.000      0.983 0.000 1.000
#> GSM26832     2   0.000      0.983 0.000 1.000
#> GSM26833     2   0.000      0.983 0.000 1.000
#> GSM26834     2   0.000      0.983 0.000 1.000
#> GSM26835     2   0.000      0.983 0.000 1.000
#> GSM26836     1   0.000      0.973 1.000 0.000
#> GSM26837     1   0.000      0.973 1.000 0.000
#> GSM26838     1   0.000      0.973 1.000 0.000
#> GSM26839     1   0.000      0.973 1.000 0.000
#> GSM26840     2   0.980      0.262 0.416 0.584
#> GSM26841     1   0.000      0.973 1.000 0.000
#> GSM26842     1   0.000      0.973 1.000 0.000
#> GSM26843     1   0.000      0.973 1.000 0.000
#> GSM26844     1   0.000      0.973 1.000 0.000
#> GSM26845     2   0.506      0.860 0.112 0.888
#> GSM26846     1   0.993      0.172 0.548 0.452
#> GSM26847     1   0.000      0.973 1.000 0.000
#> GSM26848     1   0.000      0.973 1.000 0.000
#> GSM26849     1   0.000      0.973 1.000 0.000
#> GSM26850     1   0.855      0.601 0.720 0.280
#> GSM26851     2   0.000      0.983 0.000 1.000
#> GSM26852     1   0.000      0.973 1.000 0.000
#> GSM26853     1   0.000      0.973 1.000 0.000
#> GSM26854     1   0.000      0.973 1.000 0.000
#> GSM26855     1   0.000      0.973 1.000 0.000
#> GSM26856     1   0.000      0.973 1.000 0.000
#> GSM26857     1   0.000      0.973 1.000 0.000
#> GSM26858     1   0.000      0.973 1.000 0.000
#> GSM26859     1   0.000      0.973 1.000 0.000
#> GSM26860     1   0.000      0.973 1.000 0.000
#> GSM26861     1   0.000      0.973 1.000 0.000
#> GSM26862     1   0.000      0.973 1.000 0.000
#> GSM26863     1   0.000      0.973 1.000 0.000
#> GSM26864     1   0.000      0.973 1.000 0.000
#> GSM26865     1   0.000      0.973 1.000 0.000
#> GSM26866     1   0.000      0.973 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2   0.000      1.000 0.000 1.000 0.000
#> GSM26806     2   0.000      1.000 0.000 1.000 0.000
#> GSM26807     2   0.000      1.000 0.000 1.000 0.000
#> GSM26808     2   0.000      1.000 0.000 1.000 0.000
#> GSM26809     2   0.000      1.000 0.000 1.000 0.000
#> GSM26810     2   0.000      1.000 0.000 1.000 0.000
#> GSM26811     2   0.000      1.000 0.000 1.000 0.000
#> GSM26812     2   0.000      1.000 0.000 1.000 0.000
#> GSM26813     2   0.000      1.000 0.000 1.000 0.000
#> GSM26814     2   0.000      1.000 0.000 1.000 0.000
#> GSM26815     2   0.000      1.000 0.000 1.000 0.000
#> GSM26816     2   0.000      1.000 0.000 1.000 0.000
#> GSM26817     2   0.000      1.000 0.000 1.000 0.000
#> GSM26818     3   0.000      0.979 0.000 0.000 1.000
#> GSM26819     2   0.000      1.000 0.000 1.000 0.000
#> GSM26820     2   0.000      1.000 0.000 1.000 0.000
#> GSM26821     2   0.000      1.000 0.000 1.000 0.000
#> GSM26822     2   0.000      1.000 0.000 1.000 0.000
#> GSM26823     2   0.000      1.000 0.000 1.000 0.000
#> GSM26824     2   0.000      1.000 0.000 1.000 0.000
#> GSM26825     2   0.000      1.000 0.000 1.000 0.000
#> GSM26826     2   0.000      1.000 0.000 1.000 0.000
#> GSM26827     2   0.000      1.000 0.000 1.000 0.000
#> GSM26828     2   0.000      1.000 0.000 1.000 0.000
#> GSM26829     2   0.000      1.000 0.000 1.000 0.000
#> GSM26830     2   0.000      1.000 0.000 1.000 0.000
#> GSM26831     2   0.000      1.000 0.000 1.000 0.000
#> GSM26832     2   0.000      1.000 0.000 1.000 0.000
#> GSM26833     2   0.000      1.000 0.000 1.000 0.000
#> GSM26834     2   0.000      1.000 0.000 1.000 0.000
#> GSM26835     2   0.000      1.000 0.000 1.000 0.000
#> GSM26836     1   0.000      0.970 1.000 0.000 0.000
#> GSM26837     1   0.000      0.970 1.000 0.000 0.000
#> GSM26838     1   0.000      0.970 1.000 0.000 0.000
#> GSM26839     1   0.000      0.970 1.000 0.000 0.000
#> GSM26840     1   0.000      0.970 1.000 0.000 0.000
#> GSM26841     1   0.000      0.970 1.000 0.000 0.000
#> GSM26842     1   0.000      0.970 1.000 0.000 0.000
#> GSM26843     1   0.000      0.970 1.000 0.000 0.000
#> GSM26844     1   0.000      0.970 1.000 0.000 0.000
#> GSM26845     1   0.522      0.636 0.740 0.260 0.000
#> GSM26846     1   0.375      0.799 0.856 0.144 0.000
#> GSM26847     1   0.000      0.970 1.000 0.000 0.000
#> GSM26848     1   0.000      0.970 1.000 0.000 0.000
#> GSM26849     3   0.493      0.702 0.232 0.000 0.768
#> GSM26850     1   0.000      0.970 1.000 0.000 0.000
#> GSM26851     2   0.000      1.000 0.000 1.000 0.000
#> GSM26852     3   0.000      0.979 0.000 0.000 1.000
#> GSM26853     3   0.000      0.979 0.000 0.000 1.000
#> GSM26854     3   0.000      0.979 0.000 0.000 1.000
#> GSM26855     3   0.000      0.979 0.000 0.000 1.000
#> GSM26856     3   0.000      0.979 0.000 0.000 1.000
#> GSM26857     3   0.000      0.979 0.000 0.000 1.000
#> GSM26858     3   0.000      0.979 0.000 0.000 1.000
#> GSM26859     3   0.000      0.979 0.000 0.000 1.000
#> GSM26860     3   0.000      0.979 0.000 0.000 1.000
#> GSM26861     3   0.000      0.979 0.000 0.000 1.000
#> GSM26862     1   0.000      0.970 1.000 0.000 0.000
#> GSM26863     1   0.000      0.970 1.000 0.000 0.000
#> GSM26864     1   0.000      0.970 1.000 0.000 0.000
#> GSM26865     1   0.000      0.970 1.000 0.000 0.000
#> GSM26866     1   0.000      0.970 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26806     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26807     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26808     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26809     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26810     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26811     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26812     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26813     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26815     4  0.0000      0.929 0.000 0.000 0.000 1.000
#> GSM26816     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26817     4  0.4941      0.226 0.000 0.436 0.000 0.564
#> GSM26818     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26831     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26833     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26834     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26840     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26845     1  0.4585      0.524 0.668 0.332 0.000 0.000
#> GSM26846     1  0.4103      0.642 0.744 0.256 0.000 0.000
#> GSM26847     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26848     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26849     3  0.4040      0.666 0.248 0.000 0.752 0.000
#> GSM26850     1  0.4888      0.327 0.588 0.412 0.000 0.000
#> GSM26851     4  0.0336      0.923 0.000 0.008 0.000 0.992
#> GSM26852     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.973 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26865     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM26866     1  0.0000      0.929 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26806     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26810     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26814     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4   0.000      0.923 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26817     4   0.426      0.228 0.000 0.436 0.000 0.564 0.000
#> GSM26818     3   0.293      0.818 0.180 0.000 0.820 0.000 0.000
#> GSM26819     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26830     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26831     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26833     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26834     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26835     2   0.000      0.972 0.000 1.000 0.000 0.000 0.000
#> GSM26836     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26837     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26838     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26839     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26840     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26841     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26842     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26843     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26844     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26845     1   0.000      0.799 1.000 0.000 0.000 0.000 0.000
#> GSM26846     1   0.000      0.799 1.000 0.000 0.000 0.000 0.000
#> GSM26847     1   0.000      0.799 1.000 0.000 0.000 0.000 0.000
#> GSM26848     5   0.318      0.756 0.208 0.000 0.000 0.000 0.792
#> GSM26849     3   0.376      0.771 0.208 0.000 0.772 0.000 0.020
#> GSM26850     2   0.679     -0.184 0.296 0.384 0.000 0.000 0.320
#> GSM26851     4   0.029      0.916 0.000 0.008 0.000 0.992 0.000
#> GSM26852     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3   0.000      0.964 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26863     1   0.318      0.895 0.792 0.000 0.000 0.000 0.208
#> GSM26864     5   0.000      0.931 0.000 0.000 0.000 0.000 1.000
#> GSM26865     5   0.318      0.756 0.208 0.000 0.000 0.000 0.792
#> GSM26866     5   0.000      0.931 0.000 0.000 0.000 0.000 1.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
#> GSM26805     5  0.0146     0.8493 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM26806     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26810     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26814     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26815     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.0146     0.8493 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM26817     5  0.3126     0.5719 0.000 0.000 0.000 0.248 0.752 0.000
#> GSM26818     3  0.2996     0.7502 0.228 0.000 0.772 0.000 0.000 0.000
#> GSM26819     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26820     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26821     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26822     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26823     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26824     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26825     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26826     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26827     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26828     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26829     5  0.2416     0.5315 0.000 0.156 0.000 0.000 0.844 0.000
#> GSM26830     2  0.3789     1.0000 0.000 0.584 0.000 0.000 0.416 0.000
#> GSM26831     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26832     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26833     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26834     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26835     5  0.0000     0.8525 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26836     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26837     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26838     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26839     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26840     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26841     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26842     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26843     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26844     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26845     6  0.2454     0.8157 0.160 0.000 0.000 0.000 0.000 0.840
#> GSM26846     6  0.3797     0.5337 0.420 0.000 0.000 0.000 0.000 0.580
#> GSM26847     6  0.0146     0.9279 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM26848     1  0.0000     0.5967 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26849     3  0.3797     0.5182 0.420 0.000 0.580 0.000 0.000 0.000
#> GSM26850     1  0.5561     0.0201 0.568 0.252 0.000 0.000 0.004 0.176
#> GSM26851     5  0.3774     0.0724 0.000 0.000 0.000 0.408 0.592 0.000
#> GSM26852     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000     0.9442 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26863     6  0.0000     0.9301 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26864     1  0.3923     0.8357 0.580 0.416 0.000 0.000 0.000 0.004
#> GSM26865     1  0.0000     0.5967 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26866     1  0.3923     0.8357 0.580 0.416 0.000 0.000 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-CV-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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

test_to_known_factors(res)
#>         n tissue(p) individual(p) k
#> CV:pam 60  1.89e-11      8.46e-01 2
#> CV:pam 62  1.49e-12      1.94e-04 3
#> CV:pam 60  1.99e-11      3.56e-06 4
#> CV:pam 60  9.23e-11      1.88e-05 5
#> CV:pam 60  6.95e-11      7.63e-08 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 62 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.390           0.232       0.655         0.4637 0.772   0.772
#> 3 3 0.676           0.764       0.880         0.3468 0.405   0.315
#> 4 4 0.768           0.808       0.832         0.1292 0.911   0.761
#> 5 5 0.840           0.826       0.885         0.0916 0.952   0.831
#> 6 6 0.781           0.650       0.783         0.0493 0.909   0.653

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     1   1.000     -1.000 0.500 0.500
#> GSM26806     1   0.000      0.225 1.000 0.000
#> GSM26807     1   0.000      0.225 1.000 0.000
#> GSM26808     1   0.000      0.225 1.000 0.000
#> GSM26809     1   0.987     -0.860 0.568 0.432
#> GSM26810     1   0.000      0.225 1.000 0.000
#> GSM26811     1   0.000      0.225 1.000 0.000
#> GSM26812     1   0.000      0.225 1.000 0.000
#> GSM26813     1   0.988     -0.867 0.564 0.436
#> GSM26814     1   0.988     -0.867 0.564 0.436
#> GSM26815     1   0.204      0.278 0.968 0.032
#> GSM26816     1   1.000     -1.000 0.500 0.500
#> GSM26817     1   0.358      0.060 0.932 0.068
#> GSM26818     1   0.963      0.617 0.612 0.388
#> GSM26819     2   1.000      1.000 0.500 0.500
#> GSM26820     2   1.000      1.000 0.500 0.500
#> GSM26821     1   1.000     -1.000 0.500 0.500
#> GSM26822     2   1.000      1.000 0.500 0.500
#> GSM26823     1   1.000     -1.000 0.500 0.500
#> GSM26824     1   0.995     -0.926 0.540 0.460
#> GSM26825     2   1.000      1.000 0.500 0.500
#> GSM26826     2   1.000      1.000 0.500 0.500
#> GSM26827     1   1.000     -1.000 0.500 0.500
#> GSM26828     2   1.000      1.000 0.500 0.500
#> GSM26829     2   1.000      1.000 0.500 0.500
#> GSM26830     1   1.000     -0.965 0.512 0.488
#> GSM26831     2   1.000      1.000 0.500 0.500
#> GSM26832     1   1.000     -1.000 0.500 0.500
#> GSM26833     1   1.000     -0.978 0.512 0.488
#> GSM26834     1   1.000     -1.000 0.500 0.500
#> GSM26835     1   1.000     -1.000 0.500 0.500
#> GSM26836     1   0.981      0.622 0.580 0.420
#> GSM26837     1   0.981      0.622 0.580 0.420
#> GSM26838     1   0.981      0.622 0.580 0.420
#> GSM26839     1   0.981      0.622 0.580 0.420
#> GSM26840     1   0.981      0.622 0.580 0.420
#> GSM26841     1   0.981      0.622 0.580 0.420
#> GSM26842     1   0.981      0.622 0.580 0.420
#> GSM26843     1   0.981      0.622 0.580 0.420
#> GSM26844     1   0.981      0.622 0.580 0.420
#> GSM26845     1   0.981      0.622 0.580 0.420
#> GSM26846     1   0.980      0.621 0.584 0.416
#> GSM26847     1   0.981      0.622 0.580 0.420
#> GSM26848     1   0.980      0.621 0.584 0.416
#> GSM26849     1   0.969      0.618 0.604 0.396
#> GSM26850     1   0.980      0.621 0.584 0.416
#> GSM26851     1   0.963     -0.791 0.612 0.388
#> GSM26852     1   1.000      0.591 0.504 0.496
#> GSM26853     1   1.000      0.591 0.504 0.496
#> GSM26854     1   1.000      0.591 0.504 0.496
#> GSM26855     1   1.000      0.591 0.504 0.496
#> GSM26856     1   1.000      0.591 0.504 0.496
#> GSM26857     1   1.000      0.591 0.504 0.496
#> GSM26858     1   1.000      0.591 0.504 0.496
#> GSM26859     1   1.000      0.591 0.504 0.496
#> GSM26860     1   1.000      0.591 0.504 0.496
#> GSM26861     1   1.000      0.591 0.504 0.496
#> GSM26862     1   0.981      0.622 0.580 0.420
#> GSM26863     1   0.981      0.622 0.580 0.420
#> GSM26864     1   0.981      0.622 0.580 0.420
#> GSM26865     1   0.980      0.621 0.584 0.416
#> GSM26866     1   0.981      0.622 0.580 0.420

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26806     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26807     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26808     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26809     2  0.0892     0.8482 0.020 0.980 0.000
#> GSM26810     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26811     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26812     2  0.7015     0.4512 0.392 0.584 0.024
#> GSM26813     2  0.1031     0.8467 0.024 0.976 0.000
#> GSM26814     2  0.1031     0.8467 0.024 0.976 0.000
#> GSM26815     2  0.7841     0.3701 0.408 0.536 0.056
#> GSM26816     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26817     2  0.6247     0.4941 0.376 0.620 0.004
#> GSM26818     3  0.6244    -0.0265 0.440 0.000 0.560
#> GSM26819     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26820     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26821     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26822     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26823     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26824     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26825     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26826     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26827     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26828     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26829     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26830     2  0.0592     0.8514 0.012 0.988 0.000
#> GSM26831     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26832     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26833     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26834     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26835     2  0.0000     0.8553 0.000 1.000 0.000
#> GSM26836     1  0.0000     0.8506 1.000 0.000 0.000
#> GSM26837     1  0.0424     0.8507 0.992 0.000 0.008
#> GSM26838     1  0.0000     0.8506 1.000 0.000 0.000
#> GSM26839     1  0.0000     0.8506 1.000 0.000 0.000
#> GSM26840     1  0.5791     0.8170 0.792 0.060 0.148
#> GSM26841     1  0.4121     0.8512 0.832 0.000 0.168
#> GSM26842     1  0.4121     0.8512 0.832 0.000 0.168
#> GSM26843     1  0.4178     0.8493 0.828 0.000 0.172
#> GSM26844     1  0.4178     0.8493 0.828 0.000 0.172
#> GSM26845     1  0.5357     0.7538 0.820 0.064 0.116
#> GSM26846     1  0.1860     0.8470 0.948 0.000 0.052
#> GSM26847     1  0.1031     0.8499 0.976 0.000 0.024
#> GSM26848     1  0.5431     0.7388 0.716 0.000 0.284
#> GSM26849     3  0.6244    -0.0740 0.440 0.000 0.560
#> GSM26850     1  0.5591     0.7083 0.696 0.000 0.304
#> GSM26851     2  0.6501     0.5650 0.316 0.664 0.020
#> GSM26852     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26853     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26854     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26855     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26856     3  0.1643     0.8815 0.044 0.000 0.956
#> GSM26857     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26858     3  0.1411     0.8847 0.036 0.000 0.964
#> GSM26859     3  0.1643     0.8815 0.044 0.000 0.956
#> GSM26860     3  0.1031     0.8872 0.024 0.000 0.976
#> GSM26861     3  0.1643     0.8815 0.044 0.000 0.956
#> GSM26862     1  0.0000     0.8506 1.000 0.000 0.000
#> GSM26863     1  0.0000     0.8506 1.000 0.000 0.000
#> GSM26864     1  0.4121     0.8512 0.832 0.000 0.168
#> GSM26865     1  0.5098     0.7844 0.752 0.000 0.248
#> GSM26866     1  0.4235     0.8470 0.824 0.000 0.176

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26806     4  0.6748      0.938 0.112 0.328 0.000 0.560
#> GSM26807     4  0.6819      0.944 0.112 0.348 0.000 0.540
#> GSM26808     4  0.6819      0.944 0.112 0.348 0.000 0.540
#> GSM26809     2  0.0657      0.933 0.000 0.984 0.004 0.012
#> GSM26810     4  0.6733      0.935 0.112 0.324 0.000 0.564
#> GSM26811     4  0.6831      0.939 0.112 0.352 0.000 0.536
#> GSM26812     4  0.6819      0.944 0.112 0.348 0.000 0.540
#> GSM26813     2  0.0592      0.933 0.000 0.984 0.000 0.016
#> GSM26814     2  0.0592      0.933 0.000 0.984 0.000 0.016
#> GSM26815     4  0.7894      0.772 0.232 0.228 0.020 0.520
#> GSM26816     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26817     2  0.6552     -0.186 0.112 0.628 0.004 0.256
#> GSM26818     3  0.7156      0.311 0.328 0.000 0.520 0.152
#> GSM26819     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0336      0.940 0.000 0.992 0.000 0.008
#> GSM26825     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0336      0.941 0.000 0.992 0.000 0.008
#> GSM26831     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26833     2  0.0336      0.941 0.000 0.992 0.000 0.008
#> GSM26834     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM26836     1  0.5161      0.742 0.592 0.000 0.008 0.400
#> GSM26837     1  0.5150      0.743 0.596 0.000 0.008 0.396
#> GSM26838     1  0.5236      0.733 0.560 0.000 0.008 0.432
#> GSM26839     1  0.5150      0.743 0.596 0.000 0.008 0.396
#> GSM26840     1  0.1411      0.728 0.960 0.000 0.020 0.020
#> GSM26841     1  0.0707      0.730 0.980 0.000 0.020 0.000
#> GSM26842     1  0.0707      0.730 0.980 0.000 0.020 0.000
#> GSM26843     1  0.0817      0.729 0.976 0.000 0.024 0.000
#> GSM26844     1  0.0817      0.729 0.976 0.000 0.024 0.000
#> GSM26845     1  0.6376      0.708 0.504 0.000 0.064 0.432
#> GSM26846     1  0.6393      0.697 0.480 0.000 0.064 0.456
#> GSM26847     1  0.6327      0.705 0.496 0.000 0.060 0.444
#> GSM26848     1  0.5123      0.597 0.724 0.000 0.232 0.044
#> GSM26849     3  0.5865      0.334 0.340 0.000 0.612 0.048
#> GSM26850     1  0.5123      0.597 0.724 0.000 0.232 0.044
#> GSM26851     2  0.6350     -0.138 0.112 0.636 0.000 0.252
#> GSM26852     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0336      0.912 0.000 0.000 0.992 0.008
#> GSM26857     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0376      0.912 0.004 0.000 0.992 0.004
#> GSM26859     3  0.0336      0.912 0.000 0.000 0.992 0.008
#> GSM26860     3  0.0000      0.914 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0336      0.912 0.000 0.000 0.992 0.008
#> GSM26862     1  0.5279      0.741 0.588 0.000 0.012 0.400
#> GSM26863     1  0.5161      0.742 0.592 0.000 0.008 0.400
#> GSM26864     1  0.0707      0.730 0.980 0.000 0.020 0.000
#> GSM26865     1  0.4716      0.633 0.764 0.000 0.196 0.040
#> GSM26866     1  0.0817      0.729 0.976 0.000 0.024 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.0451     0.9112 0.008 0.988 0.000 0.004 0.000
#> GSM26806     4  0.0404     0.9689 0.000 0.012 0.000 0.988 0.000
#> GSM26807     4  0.0703     0.9734 0.000 0.024 0.000 0.976 0.000
#> GSM26808     4  0.0963     0.9666 0.000 0.036 0.000 0.964 0.000
#> GSM26809     2  0.3323     0.8342 0.036 0.844 0.000 0.116 0.004
#> GSM26810     4  0.0510     0.9722 0.000 0.016 0.000 0.984 0.000
#> GSM26811     4  0.1121     0.9583 0.000 0.044 0.000 0.956 0.000
#> GSM26812     4  0.0609     0.9737 0.000 0.020 0.000 0.980 0.000
#> GSM26813     2  0.2723     0.8390 0.012 0.864 0.000 0.124 0.000
#> GSM26814     2  0.2825     0.8399 0.016 0.860 0.000 0.124 0.000
#> GSM26815     4  0.2026     0.9182 0.032 0.008 0.004 0.932 0.024
#> GSM26816     2  0.0324     0.9121 0.004 0.992 0.000 0.004 0.000
#> GSM26817     2  0.5155     0.3347 0.028 0.560 0.000 0.404 0.008
#> GSM26818     3  0.8363     0.0243 0.144 0.000 0.312 0.308 0.236
#> GSM26819     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26820     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26821     2  0.1270     0.9114 0.052 0.948 0.000 0.000 0.000
#> GSM26822     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26823     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26824     2  0.3409     0.8576 0.052 0.836 0.000 0.112 0.000
#> GSM26825     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26826     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26827     2  0.1544     0.9098 0.068 0.932 0.000 0.000 0.000
#> GSM26828     2  0.0324     0.9121 0.004 0.992 0.000 0.004 0.000
#> GSM26829     2  0.1478     0.9104 0.064 0.936 0.000 0.000 0.000
#> GSM26830     2  0.1628     0.8915 0.008 0.936 0.000 0.056 0.000
#> GSM26831     2  0.0566     0.9120 0.012 0.984 0.000 0.004 0.000
#> GSM26832     2  0.0324     0.9121 0.004 0.992 0.000 0.004 0.000
#> GSM26833     2  0.0865     0.9076 0.004 0.972 0.000 0.024 0.000
#> GSM26834     2  0.0324     0.9121 0.004 0.992 0.000 0.004 0.000
#> GSM26835     2  0.0324     0.9121 0.004 0.992 0.000 0.004 0.000
#> GSM26836     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26837     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26838     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26839     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26840     1  0.4150     0.6287 0.612 0.000 0.000 0.000 0.388
#> GSM26841     1  0.3452     0.7852 0.756 0.000 0.000 0.000 0.244
#> GSM26842     1  0.3452     0.7852 0.756 0.000 0.000 0.000 0.244
#> GSM26843     1  0.3452     0.7852 0.756 0.000 0.000 0.000 0.244
#> GSM26844     1  0.3452     0.7852 0.756 0.000 0.000 0.000 0.244
#> GSM26845     5  0.2304     0.8611 0.100 0.000 0.008 0.000 0.892
#> GSM26846     5  0.3607     0.7836 0.144 0.000 0.028 0.008 0.820
#> GSM26847     5  0.2653     0.8449 0.096 0.000 0.024 0.000 0.880
#> GSM26848     1  0.6622     0.4089 0.504 0.000 0.204 0.008 0.284
#> GSM26849     3  0.6741     0.1867 0.236 0.000 0.504 0.012 0.248
#> GSM26850     1  0.6627     0.4137 0.500 0.000 0.200 0.008 0.292
#> GSM26851     2  0.4030     0.5619 0.000 0.648 0.000 0.352 0.000
#> GSM26852     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000     0.8892 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0290     0.8875 0.008 0.000 0.992 0.000 0.000
#> GSM26857     3  0.0162     0.8875 0.004 0.000 0.996 0.000 0.000
#> GSM26858     3  0.0162     0.8887 0.004 0.000 0.996 0.000 0.000
#> GSM26859     3  0.0290     0.8875 0.008 0.000 0.992 0.000 0.000
#> GSM26860     3  0.0162     0.8875 0.004 0.000 0.996 0.000 0.000
#> GSM26861     3  0.0290     0.8875 0.008 0.000 0.992 0.000 0.000
#> GSM26862     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26863     5  0.0000     0.9238 0.000 0.000 0.000 0.000 1.000
#> GSM26864     1  0.3480     0.7835 0.752 0.000 0.000 0.000 0.248
#> GSM26865     1  0.5509     0.5303 0.612 0.000 0.080 0.004 0.304
#> GSM26866     1  0.3452     0.7852 0.756 0.000 0.000 0.000 0.244

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.3565      0.506 0.000 0.304 0.000 0.004 0.692 0.000
#> GSM26806     4  0.0146      0.915 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26807     4  0.0806      0.911 0.000 0.020 0.000 0.972 0.008 0.000
#> GSM26808     4  0.0260      0.914 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26809     2  0.4951      0.503 0.004 0.480 0.000 0.008 0.472 0.036
#> GSM26810     4  0.0146      0.915 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26811     4  0.0520      0.912 0.000 0.008 0.000 0.984 0.008 0.000
#> GSM26812     4  0.0806      0.911 0.000 0.020 0.000 0.972 0.008 0.000
#> GSM26813     2  0.4312      0.582 0.000 0.508 0.000 0.012 0.476 0.004
#> GSM26814     2  0.4412      0.583 0.000 0.500 0.000 0.012 0.480 0.008
#> GSM26815     4  0.5295      0.420 0.000 0.440 0.000 0.460 0.000 0.100
#> GSM26816     5  0.3426      0.540 0.000 0.276 0.000 0.004 0.720 0.000
#> GSM26817     2  0.6917      0.375 0.000 0.436 0.000 0.268 0.224 0.072
#> GSM26818     6  0.7333      0.290 0.076 0.372 0.128 0.036 0.000 0.388
#> GSM26819     5  0.0603      0.615 0.000 0.004 0.000 0.016 0.980 0.000
#> GSM26820     5  0.0458      0.617 0.000 0.000 0.000 0.016 0.984 0.000
#> GSM26821     5  0.2877      0.577 0.000 0.124 0.000 0.020 0.848 0.008
#> GSM26822     5  0.1074      0.615 0.000 0.028 0.000 0.012 0.960 0.000
#> GSM26823     5  0.0000      0.629 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26824     5  0.3502      0.482 0.000 0.192 0.000 0.020 0.780 0.008
#> GSM26825     5  0.0146      0.627 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM26826     5  0.0000      0.629 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26827     5  0.0146      0.627 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM26828     5  0.3405      0.546 0.000 0.272 0.000 0.004 0.724 0.000
#> GSM26829     5  0.1387      0.633 0.000 0.068 0.000 0.000 0.932 0.000
#> GSM26830     5  0.3619      0.392 0.000 0.316 0.000 0.004 0.680 0.000
#> GSM26831     5  0.2933      0.597 0.000 0.200 0.000 0.004 0.796 0.000
#> GSM26832     5  0.3448      0.539 0.000 0.280 0.000 0.004 0.716 0.000
#> GSM26833     5  0.3699      0.418 0.000 0.336 0.000 0.004 0.660 0.000
#> GSM26834     5  0.3383      0.552 0.000 0.268 0.000 0.004 0.728 0.000
#> GSM26835     5  0.3405      0.548 0.000 0.272 0.000 0.004 0.724 0.000
#> GSM26836     6  0.2793      0.613 0.200 0.000 0.000 0.000 0.000 0.800
#> GSM26837     6  0.2762      0.615 0.196 0.000 0.000 0.000 0.000 0.804
#> GSM26838     6  0.2793      0.615 0.200 0.000 0.000 0.000 0.000 0.800
#> GSM26839     6  0.2762      0.615 0.196 0.000 0.000 0.000 0.000 0.804
#> GSM26840     1  0.5658      0.161 0.520 0.292 0.000 0.000 0.000 0.188
#> GSM26841     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0260      0.896 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM26843     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.4868      0.508 0.112 0.220 0.004 0.000 0.000 0.664
#> GSM26846     6  0.2649      0.592 0.068 0.052 0.004 0.000 0.000 0.876
#> GSM26847     6  0.2838      0.604 0.116 0.028 0.004 0.000 0.000 0.852
#> GSM26848     6  0.6514      0.248 0.284 0.276 0.024 0.000 0.000 0.416
#> GSM26849     6  0.7521      0.263 0.184 0.192 0.216 0.004 0.000 0.404
#> GSM26850     6  0.6514      0.248 0.284 0.276 0.024 0.000 0.000 0.416
#> GSM26851     5  0.7098     -0.478 0.000 0.312 0.000 0.296 0.324 0.068
#> GSM26852     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26853     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM26855     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26856     3  0.0508      0.984 0.012 0.004 0.984 0.000 0.000 0.000
#> GSM26857     3  0.0146      0.995 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM26858     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0260      0.994 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM26860     3  0.0291      0.994 0.000 0.004 0.992 0.000 0.000 0.004
#> GSM26861     3  0.0000      0.995 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     6  0.2793      0.613 0.200 0.000 0.000 0.000 0.000 0.800
#> GSM26863     6  0.2823      0.612 0.204 0.000 0.000 0.000 0.000 0.796
#> GSM26864     1  0.0146      0.899 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM26865     6  0.6785      0.241 0.300 0.260 0.044 0.000 0.000 0.396
#> GSM26866     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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

test_to_known_factors(res)
#>            n tissue(p) individual(p) k
#> CV:mclust 39  1.03e-07      7.01e-02 2
#> CV:mclust 52  3.63e-11      6.74e-06 3
#> CV:mclust 58  1.57e-12      3.36e-07 4
#> CV:mclust 57  7.84e-11      1.39e-06 5
#> CV:mclust 50  1.39e-09      3.03e-07 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5087 0.492   0.492
#> 3 3 0.754           0.940       0.924         0.2467 0.873   0.742
#> 4 4 0.822           0.922       0.908         0.1534 0.889   0.696
#> 5 5 0.857           0.782       0.891         0.0735 0.967   0.869
#> 6 6 0.836           0.732       0.847         0.0467 0.907   0.616

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
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     1       0          1  1  0
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     1       0          1  1  0
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26806     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26807     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26808     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26809     2  0.1643      0.920 0.044 0.956 0.000
#> GSM26810     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26811     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26812     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26813     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26815     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26816     2  0.3686      0.920 0.000 0.860 0.140
#> GSM26817     2  0.3619      0.921 0.000 0.864 0.136
#> GSM26818     3  0.3551      0.979 0.132 0.000 0.868
#> GSM26819     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26831     2  0.0000      0.951 0.000 1.000 0.000
#> GSM26832     2  0.2261      0.939 0.000 0.932 0.068
#> GSM26833     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26834     2  0.1031      0.948 0.000 0.976 0.024
#> GSM26835     2  0.0237      0.951 0.000 0.996 0.004
#> GSM26836     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26837     1  0.0592      0.927 0.988 0.000 0.012
#> GSM26838     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26840     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26841     1  0.2165      0.911 0.936 0.000 0.064
#> GSM26842     1  0.1529      0.921 0.960 0.000 0.040
#> GSM26843     1  0.3116      0.882 0.892 0.000 0.108
#> GSM26844     1  0.3192      0.878 0.888 0.000 0.112
#> GSM26845     1  0.3752      0.759 0.856 0.144 0.000
#> GSM26846     1  0.3192      0.844 0.888 0.000 0.112
#> GSM26847     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26848     3  0.4121      0.970 0.168 0.000 0.832
#> GSM26849     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26850     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26851     2  0.3752      0.919 0.000 0.856 0.144
#> GSM26852     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26853     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26854     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26855     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26856     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26857     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26858     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26859     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26860     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26861     3  0.3752      0.994 0.144 0.000 0.856
#> GSM26862     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.930 1.000 0.000 0.000
#> GSM26864     1  0.3116      0.882 0.892 0.000 0.108
#> GSM26865     3  0.4121      0.970 0.168 0.000 0.832
#> GSM26866     1  0.3551      0.855 0.868 0.000 0.132

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.1118      0.923 0.000 0.964 0.000 0.036
#> GSM26806     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26807     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26808     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26809     2  0.2216      0.853 0.000 0.908 0.000 0.092
#> GSM26810     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26811     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26812     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26813     2  0.0921      0.925 0.000 0.972 0.000 0.028
#> GSM26814     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26815     4  0.3975      0.977 0.000 0.240 0.000 0.760
#> GSM26816     2  0.4134      0.494 0.000 0.740 0.000 0.260
#> GSM26817     4  0.4585      0.866 0.000 0.332 0.000 0.668
#> GSM26818     3  0.1389      0.940 0.000 0.000 0.952 0.048
#> GSM26819     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0336      0.946 0.000 0.992 0.000 0.008
#> GSM26827     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26828     2  0.1302      0.915 0.000 0.956 0.000 0.044
#> GSM26829     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26831     2  0.1211      0.919 0.000 0.960 0.000 0.040
#> GSM26832     2  0.3400      0.688 0.000 0.820 0.000 0.180
#> GSM26833     4  0.4222      0.952 0.000 0.272 0.000 0.728
#> GSM26834     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.952 0.000 1.000 0.000 0.000
#> GSM26836     1  0.1474      0.910 0.948 0.000 0.000 0.052
#> GSM26837     1  0.0469      0.916 0.988 0.000 0.012 0.000
#> GSM26838     1  0.1474      0.910 0.948 0.000 0.000 0.052
#> GSM26839     1  0.0376      0.916 0.992 0.000 0.004 0.004
#> GSM26840     1  0.3157      0.909 0.852 0.000 0.004 0.144
#> GSM26841     1  0.3550      0.902 0.860 0.000 0.044 0.096
#> GSM26842     1  0.3399      0.904 0.868 0.000 0.040 0.092
#> GSM26843     1  0.3634      0.901 0.856 0.000 0.048 0.096
#> GSM26844     1  0.3634      0.901 0.856 0.000 0.048 0.096
#> GSM26845     1  0.2149      0.900 0.912 0.000 0.000 0.088
#> GSM26846     1  0.4724      0.807 0.792 0.000 0.112 0.096
#> GSM26847     1  0.2760      0.891 0.872 0.000 0.000 0.128
#> GSM26848     3  0.2401      0.922 0.004 0.000 0.904 0.092
#> GSM26849     3  0.1716      0.935 0.000 0.000 0.936 0.064
#> GSM26850     3  0.2216      0.924 0.000 0.000 0.908 0.092
#> GSM26851     4  0.4008      0.981 0.000 0.244 0.000 0.756
#> GSM26852     3  0.1661      0.943 0.052 0.000 0.944 0.004
#> GSM26853     3  0.1489      0.946 0.044 0.000 0.952 0.004
#> GSM26854     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM26855     3  0.1661      0.943 0.052 0.000 0.944 0.004
#> GSM26856     3  0.1305      0.948 0.036 0.000 0.960 0.004
#> GSM26857     3  0.0000      0.952 0.000 0.000 1.000 0.000
#> GSM26858     3  0.1661      0.943 0.052 0.000 0.944 0.004
#> GSM26859     3  0.0469      0.951 0.000 0.000 0.988 0.012
#> GSM26860     3  0.0188      0.952 0.000 0.000 0.996 0.004
#> GSM26861     3  0.1661      0.943 0.052 0.000 0.944 0.004
#> GSM26862     1  0.1474      0.910 0.948 0.000 0.000 0.052
#> GSM26863     1  0.1389      0.911 0.952 0.000 0.000 0.048
#> GSM26864     1  0.3550      0.902 0.860 0.000 0.044 0.096
#> GSM26865     3  0.3533      0.892 0.056 0.000 0.864 0.080
#> GSM26866     1  0.4235      0.877 0.824 0.000 0.084 0.092

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.2233      0.855 0.080 0.904 0.000 0.000 0.016
#> GSM26806     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26807     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26808     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26809     2  0.3336      0.713 0.228 0.772 0.000 0.000 0.000
#> GSM26810     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26811     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26812     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26813     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26814     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26815     4  0.0510      0.967 0.000 0.016 0.000 0.984 0.000
#> GSM26816     2  0.4740      0.178 0.000 0.516 0.000 0.468 0.016
#> GSM26817     4  0.3266      0.734 0.000 0.200 0.000 0.796 0.004
#> GSM26818     3  0.1357      0.892 0.000 0.000 0.948 0.004 0.048
#> GSM26819     2  0.0324      0.906 0.000 0.992 0.000 0.004 0.004
#> GSM26820     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26821     2  0.0324      0.906 0.000 0.992 0.000 0.004 0.004
#> GSM26822     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26823     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26824     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26825     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26826     2  0.0000      0.905 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26828     2  0.0794      0.898 0.000 0.972 0.000 0.000 0.028
#> GSM26829     2  0.0609      0.900 0.000 0.980 0.000 0.000 0.020
#> GSM26830     2  0.0162      0.906 0.000 0.996 0.000 0.004 0.000
#> GSM26831     2  0.0794      0.898 0.000 0.972 0.000 0.000 0.028
#> GSM26832     2  0.4787      0.460 0.000 0.608 0.000 0.364 0.028
#> GSM26833     4  0.1399      0.949 0.000 0.020 0.000 0.952 0.028
#> GSM26834     2  0.4397      0.625 0.000 0.696 0.000 0.276 0.028
#> GSM26835     2  0.4141      0.682 0.000 0.736 0.000 0.236 0.028
#> GSM26836     5  0.4276      0.675 0.380 0.000 0.000 0.004 0.616
#> GSM26837     5  0.4182      0.706 0.352 0.000 0.000 0.004 0.644
#> GSM26838     1  0.4297     -0.425 0.528 0.000 0.000 0.000 0.472
#> GSM26839     1  0.4305     -0.465 0.512 0.000 0.000 0.000 0.488
#> GSM26840     1  0.0162      0.719 0.996 0.004 0.000 0.000 0.000
#> GSM26841     1  0.1041      0.745 0.964 0.004 0.032 0.000 0.000
#> GSM26842     1  0.0671      0.736 0.980 0.004 0.016 0.000 0.000
#> GSM26843     1  0.1851      0.754 0.912 0.000 0.088 0.000 0.000
#> GSM26844     1  0.1908      0.753 0.908 0.000 0.092 0.000 0.000
#> GSM26845     5  0.2763      0.725 0.148 0.000 0.000 0.004 0.848
#> GSM26846     5  0.1200      0.639 0.016 0.008 0.000 0.012 0.964
#> GSM26847     5  0.1410      0.683 0.060 0.000 0.000 0.000 0.940
#> GSM26848     3  0.4356      0.671 0.000 0.000 0.648 0.012 0.340
#> GSM26849     3  0.3242      0.816 0.000 0.000 0.816 0.012 0.172
#> GSM26850     3  0.4152      0.717 0.000 0.000 0.692 0.012 0.296
#> GSM26851     4  0.1117      0.957 0.000 0.016 0.000 0.964 0.020
#> GSM26852     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0162      0.913 0.004 0.000 0.996 0.000 0.000
#> GSM26859     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.915 0.000 0.000 1.000 0.000 0.000
#> GSM26862     5  0.3928      0.732 0.296 0.000 0.000 0.004 0.700
#> GSM26863     5  0.4161      0.656 0.392 0.000 0.000 0.000 0.608
#> GSM26864     1  0.2124      0.751 0.900 0.004 0.096 0.000 0.000
#> GSM26865     3  0.6047      0.621 0.120 0.000 0.592 0.012 0.276
#> GSM26866     1  0.2230      0.732 0.884 0.000 0.116 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
#> GSM26805     2  0.5453     0.4503 0.096 0.568 0.000 0.016 0.000 0.320
#> GSM26806     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.3835     0.6184 0.204 0.748 0.000 0.000 0.000 0.048
#> GSM26810     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26814     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26815     4  0.0000     0.8356 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     4  0.5851     0.1769 0.000 0.236 0.000 0.484 0.000 0.280
#> GSM26817     4  0.3163     0.6623 0.012 0.172 0.000 0.808 0.000 0.008
#> GSM26818     3  0.1908     0.8862 0.000 0.000 0.900 0.004 0.000 0.096
#> GSM26819     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0146     0.8631 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26827     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     2  0.4932     0.4089 0.072 0.556 0.000 0.000 0.000 0.372
#> GSM26829     2  0.3615     0.5934 0.008 0.700 0.000 0.000 0.000 0.292
#> GSM26830     2  0.0000     0.8655 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26831     2  0.4737     0.4293 0.056 0.572 0.000 0.000 0.000 0.372
#> GSM26832     6  0.6841    -0.0176 0.048 0.284 0.000 0.276 0.000 0.392
#> GSM26833     4  0.5038     0.4320 0.048 0.016 0.000 0.564 0.000 0.372
#> GSM26834     6  0.6813    -0.0127 0.048 0.336 0.000 0.236 0.000 0.380
#> GSM26835     6  0.6842    -0.0406 0.052 0.348 0.000 0.228 0.000 0.372
#> GSM26836     5  0.2378     0.8383 0.152 0.000 0.000 0.000 0.848 0.000
#> GSM26837     5  0.2340     0.8390 0.148 0.000 0.000 0.000 0.852 0.000
#> GSM26838     5  0.3547     0.7213 0.332 0.000 0.000 0.000 0.668 0.000
#> GSM26839     5  0.3592     0.7046 0.344 0.000 0.000 0.000 0.656 0.000
#> GSM26840     1  0.1700     0.9207 0.928 0.000 0.000 0.000 0.048 0.024
#> GSM26841     1  0.1257     0.9587 0.952 0.000 0.028 0.000 0.020 0.000
#> GSM26842     1  0.1225     0.9444 0.952 0.000 0.012 0.000 0.036 0.000
#> GSM26843     1  0.1285     0.9623 0.944 0.000 0.052 0.000 0.000 0.004
#> GSM26844     1  0.1285     0.9623 0.944 0.000 0.052 0.000 0.000 0.004
#> GSM26845     5  0.0000     0.7654 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26846     6  0.3823    -0.0308 0.000 0.000 0.000 0.000 0.436 0.564
#> GSM26847     5  0.1556     0.7191 0.000 0.000 0.000 0.000 0.920 0.080
#> GSM26848     6  0.4955     0.3856 0.000 0.000 0.220 0.000 0.136 0.644
#> GSM26849     6  0.4543     0.1362 0.000 0.000 0.384 0.000 0.040 0.576
#> GSM26850     6  0.4888     0.3719 0.000 0.000 0.240 0.000 0.116 0.644
#> GSM26851     4  0.3746     0.6853 0.048 0.000 0.000 0.760 0.000 0.192
#> GSM26852     3  0.0146     0.9794 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26853     3  0.0000     0.9816 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0260     0.9811 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM26855     3  0.0000     0.9816 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0146     0.9816 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26857     3  0.0260     0.9811 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM26858     3  0.0146     0.9794 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26859     3  0.0790     0.9631 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM26860     3  0.0260     0.9811 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM26861     3  0.0000     0.9816 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     5  0.1765     0.8285 0.096 0.000 0.000 0.000 0.904 0.000
#> GSM26863     5  0.3175     0.7947 0.256 0.000 0.000 0.000 0.744 0.000
#> GSM26864     1  0.1152     0.9635 0.952 0.000 0.044 0.000 0.004 0.000
#> GSM26865     6  0.6001     0.3272 0.076 0.000 0.248 0.000 0.092 0.584
#> GSM26866     1  0.1471     0.9490 0.932 0.000 0.064 0.000 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-CV-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

test_to_known_factors(res)
#>         n tissue(p) individual(p) k
#> CV:NMF 62  1.14e-12      8.30e-01 2
#> CV:NMF 62  1.54e-12      9.76e-04 3
#> CV:NMF 61  1.32e-11      3.88e-05 4
#> CV:NMF 58  2.62e-10      1.35e-04 5
#> CV:NMF 49  1.85e-08      4.08e-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: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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.526           0.915       0.912         0.4595 0.511   0.511
#> 3 3 0.825           0.935       0.965         0.4150 0.835   0.677
#> 4 4 0.918           0.984       0.973         0.1055 0.928   0.792
#> 5 5 0.977           0.957       0.983         0.0272 0.994   0.977
#> 6 6 0.921           0.901       0.960         0.0304 0.988   0.955

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
#> GSM26805     2  0.7815      0.880 0.232 0.768
#> GSM26806     1  0.0376      0.996 0.996 0.004
#> GSM26807     1  0.0376      0.996 0.996 0.004
#> GSM26808     1  0.0376      0.996 0.996 0.004
#> GSM26809     2  0.7139      0.872 0.196 0.804
#> GSM26810     1  0.0376      0.996 0.996 0.004
#> GSM26811     1  0.0376      0.996 0.996 0.004
#> GSM26812     1  0.0376      0.996 0.996 0.004
#> GSM26813     2  0.7815      0.880 0.232 0.768
#> GSM26814     2  0.7815      0.880 0.232 0.768
#> GSM26815     1  0.0376      0.996 0.996 0.004
#> GSM26816     2  0.7815      0.880 0.232 0.768
#> GSM26817     1  0.0376      0.996 0.996 0.004
#> GSM26818     1  0.0000      0.998 1.000 0.000
#> GSM26819     2  0.7815      0.880 0.232 0.768
#> GSM26820     2  0.7815      0.880 0.232 0.768
#> GSM26821     2  0.7815      0.880 0.232 0.768
#> GSM26822     2  0.7815      0.880 0.232 0.768
#> GSM26823     2  0.7815      0.880 0.232 0.768
#> GSM26824     2  0.7815      0.880 0.232 0.768
#> GSM26825     2  0.7815      0.880 0.232 0.768
#> GSM26826     2  0.7815      0.880 0.232 0.768
#> GSM26827     2  0.7815      0.880 0.232 0.768
#> GSM26828     2  0.7815      0.880 0.232 0.768
#> GSM26829     2  0.7815      0.880 0.232 0.768
#> GSM26830     2  0.7815      0.880 0.232 0.768
#> GSM26831     2  0.7815      0.880 0.232 0.768
#> GSM26832     2  0.7815      0.880 0.232 0.768
#> GSM26833     2  0.7815      0.880 0.232 0.768
#> GSM26834     2  0.7815      0.880 0.232 0.768
#> GSM26835     2  0.7815      0.880 0.232 0.768
#> GSM26836     2  0.0376      0.827 0.004 0.996
#> GSM26837     2  0.0376      0.827 0.004 0.996
#> GSM26838     2  0.0376      0.827 0.004 0.996
#> GSM26839     2  0.0376      0.827 0.004 0.996
#> GSM26840     2  0.0376      0.827 0.004 0.996
#> GSM26841     2  0.0376      0.827 0.004 0.996
#> GSM26842     2  0.0376      0.827 0.004 0.996
#> GSM26843     2  0.0376      0.827 0.004 0.996
#> GSM26844     2  0.0376      0.827 0.004 0.996
#> GSM26845     2  0.0376      0.827 0.004 0.996
#> GSM26846     1  0.0000      0.998 1.000 0.000
#> GSM26847     1  0.0000      0.998 1.000 0.000
#> GSM26848     1  0.0000      0.998 1.000 0.000
#> GSM26849     1  0.0000      0.998 1.000 0.000
#> GSM26850     1  0.0000      0.998 1.000 0.000
#> GSM26851     2  0.7815      0.880 0.232 0.768
#> GSM26852     1  0.0000      0.998 1.000 0.000
#> GSM26853     1  0.0000      0.998 1.000 0.000
#> GSM26854     1  0.0000      0.998 1.000 0.000
#> GSM26855     1  0.0000      0.998 1.000 0.000
#> GSM26856     1  0.0000      0.998 1.000 0.000
#> GSM26857     1  0.0000      0.998 1.000 0.000
#> GSM26858     1  0.0000      0.998 1.000 0.000
#> GSM26859     1  0.0000      0.998 1.000 0.000
#> GSM26860     1  0.0000      0.998 1.000 0.000
#> GSM26861     1  0.0000      0.998 1.000 0.000
#> GSM26862     2  0.0376      0.827 0.004 0.996
#> GSM26863     2  0.0376      0.827 0.004 0.996
#> GSM26864     2  0.0376      0.827 0.004 0.996
#> GSM26865     1  0.0000      0.998 1.000 0.000
#> GSM26866     2  0.0376      0.827 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
#> GSM26805     2   0.000      0.986 0.000 1.000 0.000
#> GSM26806     3   0.497      0.783 0.000 0.236 0.764
#> GSM26807     3   0.497      0.783 0.000 0.236 0.764
#> GSM26808     3   0.497      0.783 0.000 0.236 0.764
#> GSM26809     2   0.153      0.946 0.040 0.960 0.000
#> GSM26810     3   0.497      0.783 0.000 0.236 0.764
#> GSM26811     3   0.497      0.783 0.000 0.236 0.764
#> GSM26812     3   0.497      0.783 0.000 0.236 0.764
#> GSM26813     2   0.000      0.986 0.000 1.000 0.000
#> GSM26814     2   0.000      0.986 0.000 1.000 0.000
#> GSM26815     3   0.497      0.783 0.000 0.236 0.764
#> GSM26816     2   0.000      0.986 0.000 1.000 0.000
#> GSM26817     3   0.497      0.783 0.000 0.236 0.764
#> GSM26818     3   0.000      0.908 0.000 0.000 1.000
#> GSM26819     2   0.000      0.986 0.000 1.000 0.000
#> GSM26820     2   0.000      0.986 0.000 1.000 0.000
#> GSM26821     2   0.000      0.986 0.000 1.000 0.000
#> GSM26822     2   0.000      0.986 0.000 1.000 0.000
#> GSM26823     2   0.000      0.986 0.000 1.000 0.000
#> GSM26824     2   0.000      0.986 0.000 1.000 0.000
#> GSM26825     2   0.000      0.986 0.000 1.000 0.000
#> GSM26826     2   0.000      0.986 0.000 1.000 0.000
#> GSM26827     2   0.000      0.986 0.000 1.000 0.000
#> GSM26828     2   0.000      0.986 0.000 1.000 0.000
#> GSM26829     2   0.000      0.986 0.000 1.000 0.000
#> GSM26830     2   0.000      0.986 0.000 1.000 0.000
#> GSM26831     2   0.000      0.986 0.000 1.000 0.000
#> GSM26832     2   0.000      0.986 0.000 1.000 0.000
#> GSM26833     2   0.000      0.986 0.000 1.000 0.000
#> GSM26834     2   0.000      0.986 0.000 1.000 0.000
#> GSM26835     2   0.000      0.986 0.000 1.000 0.000
#> GSM26836     1   0.000      1.000 1.000 0.000 0.000
#> GSM26837     1   0.000      1.000 1.000 0.000 0.000
#> GSM26838     1   0.000      1.000 1.000 0.000 0.000
#> GSM26839     1   0.000      1.000 1.000 0.000 0.000
#> GSM26840     1   0.000      1.000 1.000 0.000 0.000
#> GSM26841     1   0.000      1.000 1.000 0.000 0.000
#> GSM26842     1   0.000      1.000 1.000 0.000 0.000
#> GSM26843     1   0.000      1.000 1.000 0.000 0.000
#> GSM26844     1   0.000      1.000 1.000 0.000 0.000
#> GSM26845     2   0.514      0.637 0.252 0.748 0.000
#> GSM26846     3   0.000      0.908 0.000 0.000 1.000
#> GSM26847     3   0.000      0.908 0.000 0.000 1.000
#> GSM26848     3   0.000      0.908 0.000 0.000 1.000
#> GSM26849     3   0.000      0.908 0.000 0.000 1.000
#> GSM26850     3   0.000      0.908 0.000 0.000 1.000
#> GSM26851     2   0.000      0.986 0.000 1.000 0.000
#> GSM26852     3   0.000      0.908 0.000 0.000 1.000
#> GSM26853     3   0.000      0.908 0.000 0.000 1.000
#> GSM26854     3   0.000      0.908 0.000 0.000 1.000
#> GSM26855     3   0.000      0.908 0.000 0.000 1.000
#> GSM26856     3   0.000      0.908 0.000 0.000 1.000
#> GSM26857     3   0.000      0.908 0.000 0.000 1.000
#> GSM26858     3   0.000      0.908 0.000 0.000 1.000
#> GSM26859     3   0.000      0.908 0.000 0.000 1.000
#> GSM26860     3   0.000      0.908 0.000 0.000 1.000
#> GSM26861     3   0.000      0.908 0.000 0.000 1.000
#> GSM26862     1   0.000      1.000 1.000 0.000 0.000
#> GSM26863     1   0.000      1.000 1.000 0.000 0.000
#> GSM26864     1   0.000      1.000 1.000 0.000 0.000
#> GSM26865     3   0.000      0.908 0.000 0.000 1.000
#> GSM26866     1   0.000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26806     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26807     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26808     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26809     2  0.1406      0.950 0.024 0.960 0.000 0.016
#> GSM26810     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26811     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26812     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26813     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26814     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26815     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26816     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26817     4  0.3427      1.000 0.000 0.028 0.112 0.860
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26820     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26821     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26822     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26823     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26824     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26825     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26826     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26827     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26828     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0188      0.983 0.000 0.996 0.000 0.004
#> GSM26831     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0707      0.974 0.000 0.980 0.000 0.020
#> GSM26833     2  0.0707      0.974 0.000 0.980 0.000 0.020
#> GSM26834     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.982 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26840     1  0.2760      0.892 0.872 0.000 0.000 0.128
#> GSM26841     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26845     2  0.4072      0.670 0.252 0.748 0.000 0.000
#> GSM26846     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26847     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26848     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26849     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26850     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26851     2  0.0817      0.969 0.000 0.976 0.000 0.024
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM26865     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26866     1  0.0000      0.992 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2 p3    p4    p5
#> GSM26805     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26806     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26807     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26808     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26809     2  0.1168      0.935 0.008 0.960  0 0.000 0.032
#> GSM26810     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26811     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26812     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26813     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26814     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26815     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26816     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26817     4  0.0000      1.000 0.000 0.000  0 1.000 0.000
#> GSM26818     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26819     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26820     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26821     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26822     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26823     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26824     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26825     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26826     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26827     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26828     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26829     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26830     2  0.0162      0.964 0.000 0.996  0 0.004 0.000
#> GSM26831     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26832     2  0.2536      0.865 0.000 0.868  0 0.004 0.128
#> GSM26833     2  0.2536      0.865 0.000 0.868  0 0.004 0.128
#> GSM26834     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26835     2  0.0000      0.963 0.000 1.000  0 0.000 0.000
#> GSM26836     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26837     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26838     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26839     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26840     5  0.3395      0.000 0.236 0.000  0 0.000 0.764
#> GSM26841     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26845     2  0.3878      0.633 0.236 0.748  0 0.000 0.016
#> GSM26846     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26847     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26848     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26849     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26850     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26851     2  0.3395      0.747 0.000 0.764  0 0.000 0.236
#> GSM26852     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26862     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26863     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26864     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM26865     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM26866     1  0.0000      1.000 1.000 0.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2 p3    p4    p5    p6
#> GSM26805     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26806     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26807     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26808     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26809     2  0.3848      0.758 0.000 0.736  0 0.000 0.224 0.040
#> GSM26810     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26811     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26812     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26813     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26814     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26815     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26816     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26817     4  0.0000      1.000 0.000 0.000  0 1.000 0.000 0.000
#> GSM26818     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26819     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26820     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26821     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26822     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26823     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26824     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26825     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26826     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26827     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26828     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26829     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26830     2  0.0146      0.872 0.000 0.996  0 0.004 0.000 0.000
#> GSM26831     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26832     2  0.3547      0.704 0.000 0.696  0 0.004 0.300 0.000
#> GSM26833     2  0.3547      0.704 0.000 0.696  0 0.004 0.300 0.000
#> GSM26834     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26835     2  0.2562      0.829 0.000 0.828  0 0.000 0.172 0.000
#> GSM26836     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26837     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26838     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26839     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26840     6  0.0000      0.000 0.000 0.000  0 0.000 0.000 1.000
#> GSM26841     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26845     2  0.4647      0.442 0.228 0.696  0 0.000 0.052 0.024
#> GSM26846     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26847     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26848     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26849     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26850     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26851     5  0.1141      0.000 0.000 0.052  0 0.000 0.948 0.000
#> GSM26852     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26862     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26863     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26864     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM26865     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM26866     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> MAD:hclust 62  1.20e-01      2.27e-02 2
#> MAD:hclust 62  1.36e-07      1.72e-04 3
#> MAD:hclust 62  5.13e-11      1.26e-06 4
#> MAD:hclust 61  8.39e-11      2.10e-06 5
#> MAD:hclust 59  6.15e-12      1.83e-06 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 62 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 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.500           0.894       0.915         0.4973 0.492   0.492
#> 3 3 0.766           0.871       0.836         0.2630 0.879   0.755
#> 4 4 0.661           0.869       0.856         0.1335 0.903   0.738
#> 5 5 0.733           0.875       0.795         0.0821 0.931   0.749
#> 6 6 0.788           0.837       0.822         0.0521 0.942   0.724

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
#> GSM26805     2  0.7219      0.925 0.200 0.800
#> GSM26806     2  0.0000      0.827 0.000 1.000
#> GSM26807     2  0.0000      0.827 0.000 1.000
#> GSM26808     2  0.0000      0.827 0.000 1.000
#> GSM26809     2  0.7219      0.925 0.200 0.800
#> GSM26810     2  0.0000      0.827 0.000 1.000
#> GSM26811     2  0.0000      0.827 0.000 1.000
#> GSM26812     2  0.0000      0.827 0.000 1.000
#> GSM26813     2  0.6712      0.934 0.176 0.824
#> GSM26814     2  0.6712      0.934 0.176 0.824
#> GSM26815     2  0.0000      0.827 0.000 1.000
#> GSM26816     2  0.7219      0.925 0.200 0.800
#> GSM26817     2  0.0000      0.827 0.000 1.000
#> GSM26818     1  0.7219      0.856 0.800 0.200
#> GSM26819     2  0.6712      0.934 0.176 0.824
#> GSM26820     2  0.6712      0.934 0.176 0.824
#> GSM26821     2  0.6712      0.934 0.176 0.824
#> GSM26822     2  0.6712      0.934 0.176 0.824
#> GSM26823     2  0.6712      0.934 0.176 0.824
#> GSM26824     2  0.6712      0.934 0.176 0.824
#> GSM26825     2  0.6712      0.934 0.176 0.824
#> GSM26826     2  0.6887      0.931 0.184 0.816
#> GSM26827     2  0.6712      0.934 0.176 0.824
#> GSM26828     2  0.7219      0.925 0.200 0.800
#> GSM26829     2  0.7219      0.925 0.200 0.800
#> GSM26830     2  0.6712      0.934 0.176 0.824
#> GSM26831     2  0.7219      0.925 0.200 0.800
#> GSM26832     2  0.7219      0.925 0.200 0.800
#> GSM26833     2  0.6712      0.934 0.176 0.824
#> GSM26834     2  0.7219      0.925 0.200 0.800
#> GSM26835     2  0.7219      0.925 0.200 0.800
#> GSM26836     1  0.0000      0.905 1.000 0.000
#> GSM26837     1  0.0000      0.905 1.000 0.000
#> GSM26838     1  0.0000      0.905 1.000 0.000
#> GSM26839     1  0.0000      0.905 1.000 0.000
#> GSM26840     1  0.0000      0.905 1.000 0.000
#> GSM26841     1  0.0000      0.905 1.000 0.000
#> GSM26842     1  0.0000      0.905 1.000 0.000
#> GSM26843     1  0.0000      0.905 1.000 0.000
#> GSM26844     1  0.0000      0.905 1.000 0.000
#> GSM26845     1  0.0376      0.901 0.996 0.004
#> GSM26846     1  0.1633      0.894 0.976 0.024
#> GSM26847     1  0.0000      0.905 1.000 0.000
#> GSM26848     1  0.0000      0.905 1.000 0.000
#> GSM26849     1  0.7219      0.856 0.800 0.200
#> GSM26850     1  0.0000      0.905 1.000 0.000
#> GSM26851     2  0.6712      0.934 0.176 0.824
#> GSM26852     1  0.7219      0.856 0.800 0.200
#> GSM26853     1  0.7219      0.856 0.800 0.200
#> GSM26854     1  0.7219      0.856 0.800 0.200
#> GSM26855     1  0.7219      0.856 0.800 0.200
#> GSM26856     1  0.7219      0.856 0.800 0.200
#> GSM26857     1  0.7219      0.856 0.800 0.200
#> GSM26858     1  0.7219      0.856 0.800 0.200
#> GSM26859     1  0.7219      0.856 0.800 0.200
#> GSM26860     1  0.7219      0.856 0.800 0.200
#> GSM26861     1  0.7219      0.856 0.800 0.200
#> GSM26862     1  0.0000      0.905 1.000 0.000
#> GSM26863     1  0.0000      0.905 1.000 0.000
#> GSM26864     1  0.0000      0.905 1.000 0.000
#> GSM26865     1  0.0000      0.905 1.000 0.000
#> GSM26866     1  0.0000      0.905 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.2448      0.893 0.076 0.924 0.000
#> GSM26806     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26807     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26808     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26809     2  0.2537      0.893 0.080 0.920 0.000
#> GSM26810     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26811     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26812     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26813     2  0.0000      0.904 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.904 0.000 1.000 0.000
#> GSM26815     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26816     2  0.2448      0.893 0.076 0.924 0.000
#> GSM26817     2  0.5797      0.774 0.280 0.712 0.008
#> GSM26818     3  0.4702      0.656 0.212 0.000 0.788
#> GSM26819     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26820     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26821     2  0.0000      0.904 0.000 1.000 0.000
#> GSM26822     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26823     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26824     2  0.0000      0.904 0.000 1.000 0.000
#> GSM26825     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26826     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26827     2  0.0592      0.904 0.012 0.988 0.000
#> GSM26828     2  0.2448      0.893 0.076 0.924 0.000
#> GSM26829     2  0.2448      0.893 0.076 0.924 0.000
#> GSM26830     2  0.0000      0.904 0.000 1.000 0.000
#> GSM26831     2  0.2448      0.893 0.076 0.924 0.000
#> GSM26832     2  0.3038      0.893 0.104 0.896 0.000
#> GSM26833     2  0.3116      0.891 0.108 0.892 0.000
#> GSM26834     2  0.2878      0.893 0.096 0.904 0.000
#> GSM26835     2  0.2878      0.893 0.096 0.904 0.000
#> GSM26836     1  0.6126      0.890 0.644 0.004 0.352
#> GSM26837     1  0.6359      0.867 0.592 0.004 0.404
#> GSM26838     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26839     1  0.6148      0.888 0.640 0.004 0.356
#> GSM26840     1  0.7155      0.590 0.720 0.152 0.128
#> GSM26841     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26842     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26843     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26844     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26845     1  0.6414      0.465 0.716 0.248 0.036
#> GSM26846     1  0.6617      0.835 0.556 0.008 0.436
#> GSM26847     1  0.6617      0.835 0.556 0.008 0.436
#> GSM26848     1  0.6598      0.844 0.564 0.008 0.428
#> GSM26849     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26850     1  0.6608      0.840 0.560 0.008 0.432
#> GSM26851     2  0.3425      0.889 0.112 0.884 0.004
#> GSM26852     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26853     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26854     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26855     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26856     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26857     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26858     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26859     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26860     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26861     3  0.0237      0.965 0.000 0.004 0.996
#> GSM26862     1  0.6359      0.867 0.592 0.004 0.404
#> GSM26863     1  0.6126      0.890 0.644 0.004 0.352
#> GSM26864     1  0.6081      0.891 0.652 0.004 0.344
#> GSM26865     1  0.6432      0.848 0.568 0.004 0.428
#> GSM26866     1  0.6081      0.891 0.652 0.004 0.344

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0336      0.813 0.000 0.992 0.000 0.008
#> GSM26806     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26807     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26808     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26809     2  0.1661      0.769 0.000 0.944 0.004 0.052
#> GSM26810     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26811     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26812     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26813     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26814     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26815     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26816     2  0.0336      0.813 0.000 0.992 0.000 0.008
#> GSM26817     4  0.4134      1.000 0.000 0.260 0.000 0.740
#> GSM26818     3  0.3156      0.892 0.048 0.000 0.884 0.068
#> GSM26819     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26820     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26821     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26822     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26823     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26824     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26825     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26826     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26827     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26828     2  0.0336      0.813 0.000 0.992 0.000 0.008
#> GSM26829     2  0.0188      0.813 0.000 0.996 0.000 0.004
#> GSM26830     2  0.4840      0.828 0.000 0.784 0.116 0.100
#> GSM26831     2  0.0336      0.813 0.000 0.992 0.000 0.008
#> GSM26832     2  0.1302      0.790 0.000 0.956 0.000 0.044
#> GSM26833     2  0.1118      0.794 0.000 0.964 0.000 0.036
#> GSM26834     2  0.0707      0.807 0.000 0.980 0.000 0.020
#> GSM26835     2  0.0707      0.807 0.000 0.980 0.000 0.020
#> GSM26836     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM26837     1  0.1661      0.852 0.944 0.000 0.052 0.004
#> GSM26838     1  0.2530      0.862 0.888 0.000 0.000 0.112
#> GSM26839     1  0.0707      0.868 0.980 0.000 0.000 0.020
#> GSM26840     1  0.5594      0.739 0.724 0.112 0.000 0.164
#> GSM26841     1  0.2530      0.862 0.888 0.000 0.000 0.112
#> GSM26842     1  0.2530      0.862 0.888 0.000 0.000 0.112
#> GSM26843     1  0.2714      0.861 0.884 0.004 0.000 0.112
#> GSM26844     1  0.2714      0.861 0.884 0.004 0.000 0.112
#> GSM26845     1  0.5400      0.756 0.772 0.100 0.020 0.108
#> GSM26846     1  0.4424      0.792 0.812 0.000 0.100 0.088
#> GSM26847     1  0.4424      0.792 0.812 0.000 0.100 0.088
#> GSM26848     1  0.4362      0.796 0.816 0.000 0.096 0.088
#> GSM26849     3  0.5940      0.733 0.240 0.000 0.672 0.088
#> GSM26850     1  0.4424      0.792 0.812 0.000 0.100 0.088
#> GSM26851     2  0.1302      0.790 0.000 0.956 0.000 0.044
#> GSM26852     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26853     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26854     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26855     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26856     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26857     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26858     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26859     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26860     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26861     3  0.2589      0.971 0.116 0.000 0.884 0.000
#> GSM26862     1  0.2282      0.848 0.924 0.000 0.052 0.024
#> GSM26863     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM26864     1  0.2530      0.862 0.888 0.000 0.000 0.112
#> GSM26865     1  0.4362      0.796 0.816 0.000 0.096 0.088
#> GSM26866     1  0.2714      0.861 0.884 0.004 0.000 0.112

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     5  0.4450      0.961 0.000 0.488 0.000 0.004 0.508
#> GSM26806     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26807     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26808     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26809     2  0.3991      0.564 0.000 0.780 0.000 0.048 0.172
#> GSM26810     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26811     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26812     4  0.2929      0.991 0.000 0.180 0.000 0.820 0.000
#> GSM26813     2  0.0693      0.949 0.012 0.980 0.008 0.000 0.000
#> GSM26814     2  0.0693      0.949 0.012 0.980 0.008 0.000 0.000
#> GSM26815     4  0.4003      0.974 0.000 0.180 0.004 0.780 0.036
#> GSM26816     5  0.4450      0.961 0.000 0.488 0.000 0.004 0.508
#> GSM26817     4  0.4124      0.972 0.000 0.180 0.008 0.776 0.036
#> GSM26818     3  0.0955      0.921 0.004 0.000 0.968 0.028 0.000
#> GSM26819     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.4450      0.961 0.000 0.488 0.000 0.004 0.508
#> GSM26829     5  0.4306      0.954 0.000 0.492 0.000 0.000 0.508
#> GSM26830     2  0.0693      0.949 0.012 0.980 0.008 0.000 0.000
#> GSM26831     5  0.4450      0.961 0.000 0.488 0.000 0.004 0.508
#> GSM26832     5  0.5042      0.953 0.000 0.460 0.000 0.032 0.508
#> GSM26833     5  0.5106      0.947 0.000 0.456 0.000 0.036 0.508
#> GSM26834     5  0.4902      0.960 0.000 0.468 0.000 0.024 0.508
#> GSM26835     5  0.4902      0.960 0.000 0.468 0.000 0.024 0.508
#> GSM26836     1  0.3826      0.776 0.832 0.000 0.024 0.052 0.092
#> GSM26837     1  0.4689      0.757 0.784 0.000 0.084 0.052 0.080
#> GSM26838     1  0.5759      0.759 0.592 0.000 0.024 0.056 0.328
#> GSM26839     1  0.4233      0.778 0.804 0.000 0.024 0.064 0.108
#> GSM26840     1  0.5689      0.679 0.480 0.000 0.000 0.080 0.440
#> GSM26841     1  0.5548      0.758 0.580 0.000 0.024 0.036 0.360
#> GSM26842     1  0.5548      0.758 0.580 0.000 0.024 0.036 0.360
#> GSM26843     1  0.5489      0.758 0.580 0.000 0.024 0.032 0.364
#> GSM26844     1  0.5489      0.758 0.580 0.000 0.024 0.032 0.364
#> GSM26845     1  0.1914      0.728 0.932 0.004 0.000 0.032 0.032
#> GSM26846     1  0.3170      0.679 0.856 0.000 0.104 0.036 0.004
#> GSM26847     1  0.3323      0.682 0.844 0.000 0.116 0.036 0.004
#> GSM26848     1  0.3273      0.685 0.848 0.000 0.112 0.036 0.004
#> GSM26849     3  0.5212      0.336 0.420 0.000 0.540 0.036 0.004
#> GSM26850     1  0.3323      0.682 0.844 0.000 0.116 0.036 0.004
#> GSM26851     5  0.5216      0.911 0.000 0.436 0.000 0.044 0.520
#> GSM26852     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26853     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26854     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26855     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26856     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26857     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26858     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26859     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26860     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26861     3  0.0404      0.955 0.012 0.000 0.988 0.000 0.000
#> GSM26862     1  0.4646      0.751 0.788 0.000 0.084 0.064 0.064
#> GSM26863     1  0.3826      0.776 0.832 0.000 0.024 0.052 0.092
#> GSM26864     1  0.5548      0.758 0.580 0.000 0.024 0.036 0.360
#> GSM26865     1  0.3170      0.692 0.856 0.000 0.104 0.036 0.004
#> GSM26866     1  0.5489      0.758 0.580 0.000 0.024 0.032 0.364

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.4258     0.9651 0.008 0.268 0.000 0.016 0.696 0.012
#> GSM26806     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26807     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26808     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26809     2  0.6361     0.4071 0.164 0.576 0.000 0.044 0.200 0.016
#> GSM26810     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26811     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26812     4  0.1957     0.9757 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM26813     2  0.0622     0.9424 0.012 0.980 0.000 0.000 0.000 0.008
#> GSM26814     2  0.0622     0.9424 0.012 0.980 0.000 0.000 0.000 0.008
#> GSM26815     4  0.4254     0.9274 0.068 0.112 0.000 0.776 0.044 0.000
#> GSM26816     5  0.4258     0.9651 0.008 0.268 0.000 0.016 0.696 0.012
#> GSM26817     4  0.4453     0.9187 0.080 0.116 0.000 0.760 0.044 0.000
#> GSM26818     3  0.0922     0.9723 0.004 0.000 0.968 0.000 0.024 0.004
#> GSM26819     2  0.0405     0.9504 0.008 0.988 0.000 0.000 0.004 0.000
#> GSM26820     2  0.0405     0.9504 0.008 0.988 0.000 0.000 0.004 0.000
#> GSM26821     2  0.0000     0.9508 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0405     0.9504 0.008 0.988 0.000 0.000 0.004 0.000
#> GSM26823     2  0.0146     0.9514 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26824     2  0.0000     0.9508 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0405     0.9504 0.008 0.988 0.000 0.000 0.004 0.000
#> GSM26826     2  0.0146     0.9514 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26827     2  0.0146     0.9514 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26828     5  0.3919     0.9677 0.000 0.268 0.000 0.016 0.708 0.008
#> GSM26829     5  0.3919     0.9677 0.000 0.268 0.000 0.016 0.708 0.008
#> GSM26830     2  0.0622     0.9424 0.012 0.980 0.000 0.000 0.000 0.008
#> GSM26831     5  0.4258     0.9651 0.008 0.268 0.000 0.016 0.696 0.012
#> GSM26832     5  0.4406     0.9590 0.016 0.256 0.000 0.028 0.696 0.004
#> GSM26833     5  0.4428     0.9609 0.016 0.260 0.000 0.028 0.692 0.004
#> GSM26834     5  0.4239     0.9654 0.016 0.268 0.000 0.016 0.696 0.004
#> GSM26835     5  0.4239     0.9654 0.016 0.268 0.000 0.016 0.696 0.004
#> GSM26836     6  0.5904     0.2128 0.320 0.000 0.004 0.052 0.072 0.552
#> GSM26837     6  0.6233     0.2814 0.292 0.000 0.024 0.052 0.072 0.560
#> GSM26838     1  0.4667     0.8540 0.664 0.000 0.004 0.016 0.036 0.280
#> GSM26839     6  0.6049    -0.0735 0.388 0.000 0.004 0.052 0.072 0.484
#> GSM26840     1  0.4866     0.5323 0.716 0.000 0.000 0.036 0.100 0.148
#> GSM26841     1  0.3586     0.9114 0.712 0.000 0.004 0.004 0.000 0.280
#> GSM26842     1  0.3724     0.9109 0.708 0.000 0.004 0.004 0.004 0.280
#> GSM26843     1  0.3693     0.9119 0.708 0.000 0.004 0.000 0.008 0.280
#> GSM26844     1  0.3693     0.9119 0.708 0.000 0.004 0.000 0.008 0.280
#> GSM26845     6  0.3436     0.5456 0.052 0.000 0.000 0.032 0.080 0.836
#> GSM26846     6  0.1141     0.6381 0.000 0.000 0.052 0.000 0.000 0.948
#> GSM26847     6  0.1204     0.6400 0.000 0.000 0.056 0.000 0.000 0.944
#> GSM26848     6  0.1204     0.6400 0.000 0.000 0.056 0.000 0.000 0.944
#> GSM26849     6  0.3499     0.3272 0.000 0.000 0.320 0.000 0.000 0.680
#> GSM26850     6  0.1204     0.6400 0.000 0.000 0.056 0.000 0.000 0.944
#> GSM26851     5  0.5046     0.8881 0.044 0.220 0.000 0.032 0.688 0.016
#> GSM26852     3  0.0260     0.9940 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM26853     3  0.0260     0.9940 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM26854     3  0.0000     0.9941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0260     0.9940 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM26856     3  0.0000     0.9941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0260     0.9940 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM26859     3  0.0000     0.9941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0260     0.9940 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM26862     6  0.6120     0.3344 0.264 0.000 0.024 0.052 0.072 0.588
#> GSM26863     6  0.5904     0.2128 0.320 0.000 0.004 0.052 0.072 0.552
#> GSM26864     1  0.3724     0.9109 0.708 0.000 0.004 0.004 0.004 0.280
#> GSM26865     6  0.1285     0.6389 0.004 0.000 0.052 0.000 0.000 0.944
#> GSM26866     1  0.3693     0.9119 0.708 0.000 0.004 0.000 0.008 0.280

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> MAD:kmeans 62  1.14e-12      8.30e-01 2
#> MAD:kmeans 61  2.46e-12      2.21e-04 3
#> MAD:kmeans 62  8.75e-12      2.79e-06 4
#> MAD:kmeans 61  5.90e-11      6.14e-09 5
#> MAD:kmeans 55  4.08e-09      2.17e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 62 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 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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           1.000       1.000         0.5087 0.492   0.492
#> 3 3 1.000           0.976       0.985         0.2478 0.874   0.744
#> 4 4 0.872           0.879       0.940         0.1878 0.884   0.682
#> 5 5 0.930           0.937       0.952         0.0600 0.921   0.700
#> 6 6 0.962           0.958       0.969         0.0446 0.956   0.783

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 5

There is also optional best \(k\) = 2 3 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
#> GSM26805     2  0.0000      1.000 0.000 1.000
#> GSM26806     2  0.0000      1.000 0.000 1.000
#> GSM26807     2  0.0000      1.000 0.000 1.000
#> GSM26808     2  0.0000      1.000 0.000 1.000
#> GSM26809     2  0.0000      1.000 0.000 1.000
#> GSM26810     2  0.0000      1.000 0.000 1.000
#> GSM26811     2  0.0000      1.000 0.000 1.000
#> GSM26812     2  0.0000      1.000 0.000 1.000
#> GSM26813     2  0.0000      1.000 0.000 1.000
#> GSM26814     2  0.0000      1.000 0.000 1.000
#> GSM26815     2  0.0000      1.000 0.000 1.000
#> GSM26816     2  0.0000      1.000 0.000 1.000
#> GSM26817     2  0.0000      1.000 0.000 1.000
#> GSM26818     1  0.0000      1.000 1.000 0.000
#> GSM26819     2  0.0000      1.000 0.000 1.000
#> GSM26820     2  0.0000      1.000 0.000 1.000
#> GSM26821     2  0.0000      1.000 0.000 1.000
#> GSM26822     2  0.0000      1.000 0.000 1.000
#> GSM26823     2  0.0000      1.000 0.000 1.000
#> GSM26824     2  0.0000      1.000 0.000 1.000
#> GSM26825     2  0.0000      1.000 0.000 1.000
#> GSM26826     2  0.0000      1.000 0.000 1.000
#> GSM26827     2  0.0000      1.000 0.000 1.000
#> GSM26828     2  0.0000      1.000 0.000 1.000
#> GSM26829     2  0.0000      1.000 0.000 1.000
#> GSM26830     2  0.0000      1.000 0.000 1.000
#> GSM26831     2  0.0000      1.000 0.000 1.000
#> GSM26832     2  0.0000      1.000 0.000 1.000
#> GSM26833     2  0.0000      1.000 0.000 1.000
#> GSM26834     2  0.0000      1.000 0.000 1.000
#> GSM26835     2  0.0000      1.000 0.000 1.000
#> GSM26836     1  0.0000      1.000 1.000 0.000
#> GSM26837     1  0.0000      1.000 1.000 0.000
#> GSM26838     1  0.0000      1.000 1.000 0.000
#> GSM26839     1  0.0000      1.000 1.000 0.000
#> GSM26840     1  0.0000      1.000 1.000 0.000
#> GSM26841     1  0.0000      1.000 1.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.000
#> GSM26845     1  0.0376      0.996 0.996 0.004
#> GSM26846     1  0.0000      1.000 1.000 0.000
#> GSM26847     1  0.0000      1.000 1.000 0.000
#> GSM26848     1  0.0000      1.000 1.000 0.000
#> GSM26849     1  0.0000      1.000 1.000 0.000
#> GSM26850     1  0.0000      1.000 1.000 0.000
#> GSM26851     2  0.0000      1.000 0.000 1.000
#> GSM26852     1  0.0000      1.000 1.000 0.000
#> GSM26853     1  0.0000      1.000 1.000 0.000
#> GSM26854     1  0.0000      1.000 1.000 0.000
#> GSM26855     1  0.0000      1.000 1.000 0.000
#> GSM26856     1  0.0000      1.000 1.000 0.000
#> GSM26857     1  0.0000      1.000 1.000 0.000
#> GSM26858     1  0.0000      1.000 1.000 0.000
#> GSM26859     1  0.0000      1.000 1.000 0.000
#> GSM26860     1  0.0000      1.000 1.000 0.000
#> GSM26861     1  0.0000      1.000 1.000 0.000
#> GSM26862     1  0.0000      1.000 1.000 0.000
#> GSM26863     1  0.0000      1.000 1.000 0.000
#> GSM26864     1  0.0000      1.000 1.000 0.000
#> GSM26865     1  0.0000      1.000 1.000 0.000
#> GSM26866     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26806     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26807     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26808     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26809     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26810     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26811     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26812     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26813     2  0.0592      0.992 0.000 0.988 0.012
#> GSM26814     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26815     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26816     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26817     2  0.0747      0.992 0.000 0.984 0.016
#> GSM26818     3  0.0237      0.985 0.004 0.000 0.996
#> GSM26819     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26830     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26831     2  0.0000      0.995 0.000 1.000 0.000
#> GSM26832     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26833     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26834     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26835     2  0.0237      0.995 0.000 0.996 0.004
#> GSM26836     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26838     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26840     1  0.0592      0.957 0.988 0.012 0.000
#> GSM26841     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26845     1  0.0747      0.953 0.984 0.016 0.000
#> GSM26846     3  0.1031      0.991 0.024 0.000 0.976
#> GSM26847     1  0.6008      0.407 0.628 0.000 0.372
#> GSM26848     1  0.2066      0.919 0.940 0.000 0.060
#> GSM26849     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26850     3  0.1163      0.987 0.028 0.000 0.972
#> GSM26851     2  0.0592      0.993 0.000 0.988 0.012
#> GSM26852     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26853     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26854     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26855     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26856     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26857     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26858     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26859     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26860     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26861     3  0.0747      0.997 0.016 0.000 0.984
#> GSM26862     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.968 1.000 0.000 0.000
#> GSM26865     1  0.1411      0.941 0.964 0.000 0.036
#> GSM26866     1  0.0000      0.968 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.2469      0.829 0.000 0.892 0.000 0.108
#> GSM26806     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26807     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26808     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26809     2  0.0000      0.846 0.000 1.000 0.000 0.000
#> GSM26810     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26811     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26812     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26813     4  0.4222      0.589 0.000 0.272 0.000 0.728
#> GSM26814     2  0.4961      0.168 0.000 0.552 0.000 0.448
#> GSM26815     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26816     2  0.2469      0.829 0.000 0.892 0.000 0.108
#> GSM26817     4  0.0188      0.917 0.000 0.004 0.000 0.996
#> GSM26818     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26819     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26820     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26821     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26822     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26823     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26824     2  0.2081      0.829 0.000 0.916 0.000 0.084
#> GSM26825     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26826     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26827     2  0.1118      0.857 0.000 0.964 0.000 0.036
#> GSM26828     2  0.2469      0.829 0.000 0.892 0.000 0.108
#> GSM26829     2  0.2469      0.829 0.000 0.892 0.000 0.108
#> GSM26830     2  0.4454      0.534 0.000 0.692 0.000 0.308
#> GSM26831     2  0.2469      0.829 0.000 0.892 0.000 0.108
#> GSM26832     2  0.4164      0.668 0.000 0.736 0.000 0.264
#> GSM26833     4  0.4164      0.614 0.000 0.264 0.000 0.736
#> GSM26834     2  0.4103      0.680 0.000 0.744 0.000 0.256
#> GSM26835     2  0.4103      0.680 0.000 0.744 0.000 0.256
#> GSM26836     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26840     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26845     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26846     3  0.0524      0.989 0.008 0.000 0.988 0.004
#> GSM26847     1  0.4905      0.437 0.632 0.000 0.364 0.004
#> GSM26848     1  0.1902      0.912 0.932 0.000 0.064 0.004
#> GSM26849     3  0.0188      0.995 0.000 0.000 0.996 0.004
#> GSM26850     3  0.0779      0.981 0.016 0.000 0.980 0.004
#> GSM26851     4  0.3311      0.764 0.000 0.172 0.000 0.828
#> GSM26852     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0000      0.968 1.000 0.000 0.000 0.000
#> GSM26865     1  0.1305      0.938 0.960 0.000 0.036 0.004
#> GSM26866     1  0.0000      0.968 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     5  0.2574      0.946 0.000 0.112 0.000 0.012 0.876
#> GSM26806     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26807     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26808     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26809     2  0.1732      0.892 0.000 0.920 0.000 0.000 0.080
#> GSM26810     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26811     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26812     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26813     2  0.2179      0.863 0.000 0.888 0.000 0.112 0.000
#> GSM26814     2  0.1121      0.943 0.000 0.956 0.000 0.044 0.000
#> GSM26815     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26816     5  0.2574      0.946 0.000 0.112 0.000 0.012 0.876
#> GSM26817     4  0.0290      1.000 0.000 0.008 0.000 0.992 0.000
#> GSM26818     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26819     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0290      0.970 0.000 0.992 0.000 0.008 0.000
#> GSM26825     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.974 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.2574      0.946 0.000 0.112 0.000 0.012 0.876
#> GSM26829     5  0.2574      0.946 0.000 0.112 0.000 0.012 0.876
#> GSM26830     2  0.0609      0.963 0.000 0.980 0.000 0.020 0.000
#> GSM26831     5  0.2574      0.946 0.000 0.112 0.000 0.012 0.876
#> GSM26832     5  0.2740      0.944 0.000 0.096 0.000 0.028 0.876
#> GSM26833     5  0.2707      0.870 0.000 0.024 0.000 0.100 0.876
#> GSM26834     5  0.2740      0.944 0.000 0.096 0.000 0.028 0.876
#> GSM26835     5  0.2740      0.944 0.000 0.096 0.000 0.028 0.876
#> GSM26836     1  0.0162      0.950 0.996 0.000 0.000 0.000 0.004
#> GSM26837     1  0.0162      0.950 0.996 0.000 0.000 0.000 0.004
#> GSM26838     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.0162      0.950 0.996 0.000 0.000 0.000 0.004
#> GSM26840     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26841     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26846     3  0.3107      0.880 0.016 0.000 0.852 0.008 0.124
#> GSM26847     1  0.6175      0.341 0.544 0.000 0.324 0.008 0.124
#> GSM26848     1  0.3765      0.821 0.820 0.000 0.048 0.008 0.124
#> GSM26849     3  0.2612      0.891 0.000 0.000 0.868 0.008 0.124
#> GSM26850     3  0.3463      0.866 0.032 0.000 0.836 0.008 0.124
#> GSM26851     5  0.4088      0.601 0.000 0.008 0.000 0.304 0.688
#> GSM26852     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.970 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.0162      0.950 0.996 0.000 0.000 0.000 0.004
#> GSM26863     1  0.0162      0.950 0.996 0.000 0.000 0.000 0.004
#> GSM26864     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000
#> GSM26865     1  0.3380      0.839 0.840 0.000 0.028 0.008 0.124
#> GSM26866     1  0.0000      0.951 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.0458      0.962 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26806     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.2169      0.892 0.008 0.900 0.000 0.000 0.080 0.012
#> GSM26810     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.1549      0.948 0.000 0.936 0.000 0.020 0.000 0.044
#> GSM26814     2  0.1007      0.962 0.000 0.956 0.000 0.000 0.000 0.044
#> GSM26815     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.0458      0.962 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26817     4  0.0146      0.996 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26819     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0146      0.980 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26822     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0146      0.980 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26825     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.980 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.0458      0.962 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26829     5  0.0458      0.962 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26830     2  0.1007      0.962 0.000 0.956 0.000 0.000 0.000 0.044
#> GSM26831     5  0.0458      0.962 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM26832     5  0.0767      0.961 0.000 0.004 0.000 0.012 0.976 0.008
#> GSM26833     5  0.0717      0.957 0.000 0.000 0.000 0.016 0.976 0.008
#> GSM26834     5  0.0767      0.961 0.000 0.004 0.000 0.012 0.976 0.008
#> GSM26835     5  0.0767      0.961 0.000 0.004 0.000 0.012 0.976 0.008
#> GSM26836     1  0.2263      0.922 0.884 0.000 0.000 0.000 0.016 0.100
#> GSM26837     1  0.2358      0.917 0.876 0.000 0.000 0.000 0.016 0.108
#> GSM26838     1  0.0260      0.946 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM26839     1  0.2214      0.924 0.888 0.000 0.000 0.000 0.016 0.096
#> GSM26840     1  0.0363      0.941 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26841     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.1765      0.929 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM26846     6  0.1285      0.914 0.004 0.000 0.052 0.000 0.000 0.944
#> GSM26847     6  0.1528      0.916 0.048 0.000 0.016 0.000 0.000 0.936
#> GSM26848     6  0.1663      0.906 0.088 0.000 0.000 0.000 0.000 0.912
#> GSM26849     6  0.2491      0.815 0.000 0.000 0.164 0.000 0.000 0.836
#> GSM26850     6  0.1528      0.919 0.016 0.000 0.048 0.000 0.000 0.936
#> GSM26851     5  0.3245      0.714 0.000 0.000 0.000 0.228 0.764 0.008
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.2404      0.914 0.872 0.000 0.000 0.000 0.016 0.112
#> GSM26863     1  0.2263      0.922 0.884 0.000 0.000 0.000 0.016 0.100
#> GSM26864     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.2135      0.886 0.128 0.000 0.000 0.000 0.000 0.872
#> GSM26866     1  0.0000      0.947 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n tissue(p) individual(p) k
#> MAD:skmeans 62  1.14e-12      8.30e-01 2
#> MAD:skmeans 61  2.52e-12      2.33e-04 3
#> MAD:skmeans 60  2.18e-11      4.00e-06 4
#> MAD:skmeans 61  6.13e-11      1.62e-08 5
#> MAD:skmeans 62  1.46e-10      2.39e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.993       0.997         0.5059 0.494   0.494
#> 3 3 1.000           0.998       0.999         0.2435 0.841   0.690
#> 4 4 0.773           0.881       0.915         0.1795 0.889   0.701
#> 5 5 0.866           0.893       0.897         0.0724 0.928   0.732
#> 6 6 1.000           0.976       0.988         0.0577 0.942   0.724

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     2   0.000      1.000 0.000 1.000
#> GSM26806     2   0.000      1.000 0.000 1.000
#> GSM26807     2   0.000      1.000 0.000 1.000
#> GSM26808     2   0.000      1.000 0.000 1.000
#> GSM26809     2   0.000      1.000 0.000 1.000
#> GSM26810     2   0.000      1.000 0.000 1.000
#> GSM26811     2   0.000      1.000 0.000 1.000
#> GSM26812     2   0.000      1.000 0.000 1.000
#> GSM26813     2   0.000      1.000 0.000 1.000
#> GSM26814     2   0.000      1.000 0.000 1.000
#> GSM26815     2   0.000      1.000 0.000 1.000
#> GSM26816     2   0.000      1.000 0.000 1.000
#> GSM26817     2   0.000      1.000 0.000 1.000
#> GSM26818     1   0.000      0.992 1.000 0.000
#> GSM26819     2   0.000      1.000 0.000 1.000
#> GSM26820     2   0.000      1.000 0.000 1.000
#> GSM26821     2   0.000      1.000 0.000 1.000
#> GSM26822     2   0.000      1.000 0.000 1.000
#> GSM26823     2   0.000      1.000 0.000 1.000
#> GSM26824     2   0.000      1.000 0.000 1.000
#> GSM26825     2   0.000      1.000 0.000 1.000
#> GSM26826     2   0.000      1.000 0.000 1.000
#> GSM26827     2   0.000      1.000 0.000 1.000
#> GSM26828     2   0.000      1.000 0.000 1.000
#> GSM26829     2   0.000      1.000 0.000 1.000
#> GSM26830     2   0.000      1.000 0.000 1.000
#> GSM26831     2   0.000      1.000 0.000 1.000
#> GSM26832     2   0.000      1.000 0.000 1.000
#> GSM26833     2   0.000      1.000 0.000 1.000
#> GSM26834     2   0.000      1.000 0.000 1.000
#> GSM26835     2   0.000      1.000 0.000 1.000
#> GSM26836     1   0.000      0.992 1.000 0.000
#> GSM26837     1   0.000      0.992 1.000 0.000
#> GSM26838     1   0.000      0.992 1.000 0.000
#> GSM26839     1   0.000      0.992 1.000 0.000
#> GSM26840     2   0.000      1.000 0.000 1.000
#> GSM26841     1   0.000      0.992 1.000 0.000
#> GSM26842     1   0.000      0.992 1.000 0.000
#> GSM26843     1   0.000      0.992 1.000 0.000
#> GSM26844     1   0.000      0.992 1.000 0.000
#> GSM26845     2   0.000      1.000 0.000 1.000
#> GSM26846     1   0.358      0.927 0.932 0.068
#> GSM26847     1   0.000      0.992 1.000 0.000
#> GSM26848     1   0.000      0.992 1.000 0.000
#> GSM26849     1   0.000      0.992 1.000 0.000
#> GSM26850     1   0.605      0.830 0.852 0.148
#> GSM26851     2   0.000      1.000 0.000 1.000
#> GSM26852     1   0.000      0.992 1.000 0.000
#> GSM26853     1   0.000      0.992 1.000 0.000
#> GSM26854     1   0.000      0.992 1.000 0.000
#> GSM26855     1   0.000      0.992 1.000 0.000
#> GSM26856     1   0.000      0.992 1.000 0.000
#> GSM26857     1   0.000      0.992 1.000 0.000
#> GSM26858     1   0.000      0.992 1.000 0.000
#> GSM26859     1   0.000      0.992 1.000 0.000
#> GSM26860     1   0.000      0.992 1.000 0.000
#> GSM26861     1   0.000      0.992 1.000 0.000
#> GSM26862     1   0.000      0.992 1.000 0.000
#> GSM26863     1   0.000      0.992 1.000 0.000
#> GSM26864     1   0.000      0.992 1.000 0.000
#> GSM26865     1   0.000      0.992 1.000 0.000
#> GSM26866     1   0.000      0.992 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26806     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26807     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26808     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26809     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26810     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26811     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26812     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26813     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26815     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26816     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26817     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26819     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26828     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26829     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26830     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26831     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26832     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26833     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26834     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26835     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26836     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26837     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26838     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26840     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26841     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26845     1  0.0424      0.989 0.992 0.008 0.000
#> GSM26846     1  0.1163      0.976 0.972 0.000 0.028
#> GSM26847     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26848     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26849     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26850     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26851     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000
#> GSM26862     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26863     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.995 1.000 0.000 0.000
#> GSM26865     1  0.0424      0.993 0.992 0.000 0.008
#> GSM26866     1  0.0000      0.995 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.821 0.000 1.000 0.000 0.000
#> GSM26806     4  0.3444      0.839 0.000 0.184 0.000 0.816
#> GSM26807     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26808     4  0.1022      0.926 0.000 0.032 0.000 0.968
#> GSM26809     2  0.2973      0.881 0.000 0.856 0.000 0.144
#> GSM26810     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26811     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26812     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26813     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26814     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26815     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26816     2  0.0000      0.821 0.000 1.000 0.000 0.000
#> GSM26817     4  0.0921      0.927 0.000 0.028 0.000 0.972
#> GSM26818     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26819     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26820     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26821     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26822     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26823     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26824     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26825     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26826     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26827     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26828     2  0.0000      0.821 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.821 0.000 1.000 0.000 0.000
#> GSM26830     2  0.3266      0.888 0.000 0.832 0.000 0.168
#> GSM26831     2  0.0000      0.821 0.000 1.000 0.000 0.000
#> GSM26832     2  0.4661      0.239 0.000 0.652 0.000 0.348
#> GSM26833     4  0.3569      0.830 0.000 0.196 0.000 0.804
#> GSM26834     2  0.2814      0.706 0.000 0.868 0.000 0.132
#> GSM26835     2  0.3528      0.615 0.000 0.808 0.000 0.192
#> GSM26836     1  0.0000      0.896 1.000 0.000 0.000 0.000
#> GSM26837     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26838     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26839     1  0.0592      0.898 0.984 0.000 0.000 0.016
#> GSM26840     1  0.2032      0.877 0.936 0.036 0.000 0.028
#> GSM26841     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26842     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26843     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26844     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26845     1  0.2589      0.829 0.884 0.116 0.000 0.000
#> GSM26846     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26847     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26848     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26849     3  0.0921      0.971 0.028 0.000 0.972 0.000
#> GSM26850     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26851     4  0.3569      0.830 0.000 0.196 0.000 0.804
#> GSM26852     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM26862     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26863     1  0.0000      0.896 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0921      0.898 0.972 0.000 0.000 0.028
#> GSM26865     1  0.3569      0.830 0.804 0.000 0.196 0.000
#> GSM26866     1  0.0921      0.898 0.972 0.000 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     5   0.051      0.829 0.000 0.016 0.000 0.000 0.984
#> GSM26806     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26810     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26814     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26815     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26816     5   0.051      0.829 0.000 0.016 0.000 0.000 0.984
#> GSM26817     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26818     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26819     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26820     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26821     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26822     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26823     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26824     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26825     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26826     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26827     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26828     5   0.051      0.829 0.000 0.016 0.000 0.000 0.984
#> GSM26829     5   0.161      0.760 0.000 0.072 0.000 0.000 0.928
#> GSM26830     2   0.351      1.000 0.000 0.748 0.000 0.000 0.252
#> GSM26831     5   0.051      0.829 0.000 0.016 0.000 0.000 0.984
#> GSM26832     5   0.342      0.699 0.000 0.000 0.000 0.240 0.760
#> GSM26833     5   0.361      0.659 0.000 0.000 0.000 0.268 0.732
#> GSM26834     5   0.207      0.838 0.000 0.012 0.000 0.076 0.912
#> GSM26835     5   0.191      0.832 0.000 0.000 0.000 0.092 0.908
#> GSM26836     1   0.029      0.824 0.992 0.008 0.000 0.000 0.000
#> GSM26837     1   0.207      0.803 0.896 0.000 0.104 0.000 0.000
#> GSM26838     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26839     1   0.318      0.819 0.792 0.208 0.000 0.000 0.000
#> GSM26840     1   0.604      0.625 0.572 0.252 0.000 0.000 0.176
#> GSM26841     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26842     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26843     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26844     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26845     1   0.246      0.780 0.880 0.008 0.000 0.000 0.112
#> GSM26846     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26847     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26848     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26849     3   0.399      0.673 0.252 0.000 0.732 0.000 0.016
#> GSM26850     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26851     5   0.361      0.659 0.000 0.000 0.000 0.268 0.732
#> GSM26852     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3   0.000      0.975 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26863     1   0.000      0.823 1.000 0.000 0.000 0.000 0.000
#> GSM26864     1   0.351      0.813 0.748 0.252 0.000 0.000 0.000
#> GSM26865     1   0.246      0.803 0.888 0.000 0.096 0.000 0.016
#> GSM26866     1   0.351      0.813 0.748 0.252 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
#> GSM26805     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26806     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26807     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26808     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26809     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26810     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26811     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26812     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26813     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26815     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26816     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26817     4  0.0000      1.000 0.000 0.00 0.000  1 0.000 0.000
#> GSM26818     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26819     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26828     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26829     5  0.2048      0.857 0.000 0.12 0.000  0 0.880 0.000
#> GSM26830     2  0.0000      1.000 0.000 1.00 0.000  0 0.000 0.000
#> GSM26831     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26832     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26833     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26834     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26835     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26836     6  0.1610      0.906 0.084 0.00 0.000  0 0.000 0.916
#> GSM26837     6  0.1367      0.930 0.044 0.00 0.012  0 0.000 0.944
#> GSM26838     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26839     6  0.3620      0.513 0.352 0.00 0.000  0 0.000 0.648
#> GSM26840     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26841     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26845     6  0.1320      0.926 0.016 0.00 0.000  0 0.036 0.948
#> GSM26846     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26847     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26848     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26849     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26850     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26851     5  0.0000      0.985 0.000 0.00 0.000  0 1.000 0.000
#> GSM26852     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.00 1.000  0 0.000 0.000
#> GSM26862     6  0.0458      0.943 0.016 0.00 0.000  0 0.000 0.984
#> GSM26863     6  0.1204      0.927 0.056 0.00 0.000  0 0.000 0.944
#> GSM26864     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000
#> GSM26865     6  0.0000      0.946 0.000 0.00 0.000  0 0.000 1.000
#> GSM26866     1  0.0000      1.000 1.000 0.00 0.000  0 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

test_to_known_factors(res)
#>          n tissue(p) individual(p) k
#> MAD:pam 62  3.65e-11      8.91e-01 2
#> MAD:pam 62  1.49e-12      1.94e-04 3
#> MAD:pam 61  1.28e-11      1.67e-05 4
#> MAD:pam 62  3.70e-11      1.07e-08 5
#> MAD:pam 62  1.46e-10      7.27e-10 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5087 0.492   0.492
#> 3 3 0.868           0.866       0.912         0.2250 0.874   0.744
#> 4 4 0.825           0.870       0.912         0.1747 0.822   0.558
#> 5 5 0.712           0.623       0.742         0.0698 0.884   0.647
#> 6 6 0.930           0.915       0.947         0.0739 0.873   0.552

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

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
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     1       0          1  1  0
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     1       0          1  1  0
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26806     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26807     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26808     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26809     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26810     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26811     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26812     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26813     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26814     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26815     2  0.0237      0.996 0.004 0.996 0.000
#> GSM26816     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26817     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26818     3  0.6045      0.439 0.380 0.000 0.620
#> GSM26819     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26820     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26821     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26822     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26823     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26824     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26825     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26826     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26827     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26828     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26829     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26830     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26831     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26832     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26833     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26834     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26835     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26836     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26837     3  0.6302     -0.483 0.480 0.000 0.520
#> GSM26838     1  0.4399      0.763 0.812 0.000 0.188
#> GSM26839     1  0.4974      0.761 0.764 0.000 0.236
#> GSM26840     1  0.0000      0.695 1.000 0.000 0.000
#> GSM26841     1  0.3267      0.757 0.884 0.000 0.116
#> GSM26842     1  0.3267      0.757 0.884 0.000 0.116
#> GSM26843     1  0.0000      0.695 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.695 1.000 0.000 0.000
#> GSM26845     3  0.4555      0.690 0.200 0.000 0.800
#> GSM26846     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26847     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26848     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26849     3  0.0892      0.863 0.020 0.000 0.980
#> GSM26850     1  0.6192      0.663 0.580 0.000 0.420
#> GSM26851     2  0.0000      1.000 0.000 1.000 0.000
#> GSM26852     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26853     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26854     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26855     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26856     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26857     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26858     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26859     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26860     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26861     3  0.0000      0.884 0.000 0.000 1.000
#> GSM26862     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26863     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26864     1  0.3267      0.757 0.884 0.000 0.116
#> GSM26865     1  0.6045      0.728 0.620 0.000 0.380
#> GSM26866     1  0.0424      0.701 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     4  0.4382     0.8146 0.000 0.296 0.000 0.704
#> GSM26806     4  0.0000     0.7535 0.000 0.000 0.000 1.000
#> GSM26807     4  0.0000     0.7535 0.000 0.000 0.000 1.000
#> GSM26808     4  0.0000     0.7535 0.000 0.000 0.000 1.000
#> GSM26809     4  0.4535     0.8159 0.004 0.292 0.000 0.704
#> GSM26810     4  0.0000     0.7535 0.000 0.000 0.000 1.000
#> GSM26811     4  0.3219     0.8181 0.000 0.164 0.000 0.836
#> GSM26812     4  0.0000     0.7535 0.000 0.000 0.000 1.000
#> GSM26813     2  0.3764     0.6015 0.000 0.784 0.000 0.216
#> GSM26814     2  0.0592     0.9081 0.000 0.984 0.000 0.016
#> GSM26815     4  0.1211     0.7352 0.000 0.040 0.000 0.960
#> GSM26816     4  0.4382     0.8146 0.000 0.296 0.000 0.704
#> GSM26817     4  0.3356     0.8138 0.000 0.176 0.000 0.824
#> GSM26818     1  0.6104     0.6448 0.664 0.000 0.104 0.232
#> GSM26819     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000     0.9222 0.000 1.000 0.000 0.000
#> GSM26828     4  0.4382     0.8146 0.000 0.296 0.000 0.704
#> GSM26829     4  0.4431     0.8062 0.000 0.304 0.000 0.696
#> GSM26830     2  0.4830     0.0116 0.000 0.608 0.000 0.392
#> GSM26831     4  0.4382     0.8146 0.000 0.296 0.000 0.704
#> GSM26832     4  0.4040     0.8323 0.000 0.248 0.000 0.752
#> GSM26833     4  0.4040     0.8323 0.000 0.248 0.000 0.752
#> GSM26834     4  0.4277     0.8238 0.000 0.280 0.000 0.720
#> GSM26835     4  0.4250     0.8254 0.000 0.276 0.000 0.724
#> GSM26836     1  0.1022     0.9414 0.968 0.000 0.032 0.000
#> GSM26837     1  0.2149     0.9180 0.912 0.000 0.088 0.000
#> GSM26838     1  0.1118     0.9406 0.964 0.000 0.036 0.000
#> GSM26839     1  0.2011     0.9223 0.920 0.000 0.080 0.000
#> GSM26840     1  0.0000     0.9420 1.000 0.000 0.000 0.000
#> GSM26841     1  0.0188     0.9427 0.996 0.000 0.004 0.000
#> GSM26842     1  0.0000     0.9420 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0000     0.9420 1.000 0.000 0.000 0.000
#> GSM26844     1  0.0000     0.9420 1.000 0.000 0.000 0.000
#> GSM26845     1  0.1716     0.9296 0.936 0.000 0.064 0.000
#> GSM26846     1  0.1637     0.9295 0.940 0.000 0.060 0.000
#> GSM26847     1  0.2149     0.9187 0.912 0.000 0.088 0.000
#> GSM26848     1  0.1474     0.9325 0.948 0.000 0.052 0.000
#> GSM26849     1  0.3266     0.8592 0.832 0.000 0.168 0.000
#> GSM26850     1  0.2149     0.9187 0.912 0.000 0.088 0.000
#> GSM26851     4  0.4040     0.8323 0.000 0.248 0.000 0.752
#> GSM26852     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26856     3  0.2647     0.8462 0.120 0.000 0.880 0.000
#> GSM26857     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000     0.9841 0.000 0.000 1.000 0.000
#> GSM26862     1  0.1940     0.9245 0.924 0.000 0.076 0.000
#> GSM26863     1  0.1211     0.9400 0.960 0.000 0.040 0.000
#> GSM26864     1  0.0188     0.9428 0.996 0.000 0.004 0.000
#> GSM26865     1  0.0336     0.9432 0.992 0.000 0.008 0.000
#> GSM26866     1  0.0000     0.9420 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4 p5
#> GSM26805     2  0.3966   0.167646 0.000 0.664 0.000 0.336 NA
#> GSM26806     4  0.0510   0.848501 0.000 0.000 0.000 0.984 NA
#> GSM26807     4  0.0000   0.855985 0.000 0.000 0.000 1.000 NA
#> GSM26808     4  0.0000   0.855985 0.000 0.000 0.000 1.000 NA
#> GSM26809     2  0.3932   0.166844 0.000 0.672 0.000 0.328 NA
#> GSM26810     4  0.0000   0.855985 0.000 0.000 0.000 1.000 NA
#> GSM26811     4  0.2230   0.736297 0.000 0.116 0.000 0.884 NA
#> GSM26812     4  0.0000   0.855985 0.000 0.000 0.000 1.000 NA
#> GSM26813     2  0.4930   0.444989 0.000 0.548 0.000 0.028 NA
#> GSM26814     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26815     4  0.5304   0.497618 0.000 0.384 0.000 0.560 NA
#> GSM26816     2  0.3966   0.167646 0.000 0.664 0.000 0.336 NA
#> GSM26817     4  0.3999   0.609636 0.000 0.344 0.000 0.656 NA
#> GSM26818     1  0.8524   0.415326 0.436 0.032 0.248 0.136 NA
#> GSM26819     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26820     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26821     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26822     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26823     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26824     2  0.4449   0.477977 0.000 0.512 0.000 0.004 NA
#> GSM26825     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26826     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26827     2  0.4450   0.478696 0.000 0.508 0.000 0.004 NA
#> GSM26828     2  0.3966   0.167646 0.000 0.664 0.000 0.336 NA
#> GSM26829     2  0.3684   0.177254 0.000 0.720 0.000 0.280 NA
#> GSM26830     2  0.4885   0.435326 0.000 0.572 0.000 0.028 NA
#> GSM26831     2  0.3966   0.167646 0.000 0.664 0.000 0.336 NA
#> GSM26832     2  0.4161   0.070780 0.000 0.608 0.000 0.392 NA
#> GSM26833     2  0.4161   0.070780 0.000 0.608 0.000 0.392 NA
#> GSM26834     2  0.4074   0.127439 0.000 0.636 0.000 0.364 NA
#> GSM26835     2  0.4074   0.127439 0.000 0.636 0.000 0.364 NA
#> GSM26836     1  0.1608   0.798153 0.928 0.000 0.072 0.000 NA
#> GSM26837     1  0.4609   0.778202 0.744 0.000 0.104 0.000 NA
#> GSM26838     1  0.1818   0.803771 0.932 0.000 0.044 0.000 NA
#> GSM26839     1  0.4571   0.780345 0.736 0.000 0.076 0.000 NA
#> GSM26840     1  0.5156   0.719478 0.620 0.060 0.000 0.000 NA
#> GSM26841     1  0.1341   0.800417 0.944 0.000 0.000 0.000 NA
#> GSM26842     1  0.3480   0.765558 0.752 0.000 0.000 0.000 NA
#> GSM26843     1  0.3508   0.762261 0.748 0.000 0.000 0.000 NA
#> GSM26844     1  0.3508   0.762261 0.748 0.000 0.000 0.000 NA
#> GSM26845     1  0.6323   0.693900 0.652 0.060 0.112 0.004 NA
#> GSM26846     1  0.4624   0.726531 0.744 0.000 0.112 0.000 NA
#> GSM26847     1  0.4591   0.728976 0.748 0.000 0.120 0.000 NA
#> GSM26848     1  0.4541   0.730287 0.752 0.000 0.112 0.000 NA
#> GSM26849     1  0.4073   0.714688 0.752 0.000 0.216 0.000 NA
#> GSM26850     1  0.4679   0.724249 0.740 0.000 0.124 0.000 NA
#> GSM26851     2  0.4249   0.000148 0.000 0.568 0.000 0.432 NA
#> GSM26852     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26853     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26854     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26855     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26856     3  0.1410   0.920290 0.060 0.000 0.940 0.000 NA
#> GSM26857     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26858     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26859     3  0.0579   0.978536 0.008 0.000 0.984 0.000 NA
#> GSM26860     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26861     3  0.0000   0.989709 0.000 0.000 1.000 0.000 NA
#> GSM26862     1  0.1965   0.792265 0.904 0.000 0.096 0.000 NA
#> GSM26863     1  0.1671   0.797203 0.924 0.000 0.076 0.000 NA
#> GSM26864     1  0.3508   0.763033 0.748 0.000 0.000 0.000 NA
#> GSM26865     1  0.2726   0.793606 0.884 0.000 0.052 0.000 NA
#> GSM26866     1  0.3508   0.762261 0.748 0.000 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.0146      0.942 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM26806     4  0.0146      0.984 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM26807     4  0.0146      0.985 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26808     4  0.0146      0.985 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26809     5  0.0000      0.942 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26810     4  0.0146      0.985 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26811     4  0.1082      0.959 0.000 0.040 0.000 0.956 0.004 0.000
#> GSM26812     4  0.0291      0.985 0.000 0.004 0.000 0.992 0.004 0.000
#> GSM26813     2  0.1531      0.912 0.000 0.928 0.000 0.004 0.068 0.000
#> GSM26814     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26815     4  0.0146      0.984 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM26816     5  0.1327      0.913 0.000 0.064 0.000 0.000 0.936 0.000
#> GSM26817     4  0.0865      0.964 0.000 0.036 0.000 0.964 0.000 0.000
#> GSM26818     6  0.2446      0.847 0.000 0.000 0.012 0.124 0.000 0.864
#> GSM26819     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2  0.0146      0.962 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26828     5  0.0146      0.943 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM26829     5  0.1327      0.913 0.000 0.064 0.000 0.000 0.936 0.000
#> GSM26830     2  0.3547      0.585 0.000 0.696 0.000 0.004 0.300 0.000
#> GSM26831     5  0.0000      0.942 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26832     5  0.1267      0.939 0.000 0.000 0.000 0.060 0.940 0.000
#> GSM26833     5  0.3213      0.851 0.000 0.048 0.000 0.132 0.820 0.000
#> GSM26834     5  0.1267      0.939 0.000 0.000 0.000 0.060 0.940 0.000
#> GSM26835     5  0.1267      0.939 0.000 0.000 0.000 0.060 0.940 0.000
#> GSM26836     1  0.3446      0.759 0.692 0.000 0.000 0.000 0.000 0.308
#> GSM26837     1  0.3547      0.761 0.696 0.000 0.004 0.000 0.000 0.300
#> GSM26838     1  0.2762      0.795 0.804 0.000 0.000 0.000 0.000 0.196
#> GSM26839     1  0.3330      0.770 0.716 0.000 0.000 0.000 0.000 0.284
#> GSM26840     6  0.2178      0.842 0.132 0.000 0.000 0.000 0.000 0.868
#> GSM26841     1  0.0363      0.827 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26842     1  0.0000      0.828 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.828 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.828 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.2278      0.841 0.000 0.000 0.004 0.000 0.128 0.868
#> GSM26846     6  0.0000      0.937 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26847     6  0.0000      0.937 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26848     6  0.0146      0.936 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM26849     6  0.0405      0.935 0.004 0.000 0.008 0.000 0.000 0.988
#> GSM26850     6  0.0000      0.937 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM26851     5  0.1267      0.939 0.000 0.000 0.000 0.060 0.940 0.000
#> GSM26852     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.1501      0.916 0.000 0.000 0.924 0.000 0.000 0.076
#> GSM26860     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000      0.991 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.3584      0.756 0.688 0.000 0.004 0.000 0.000 0.308
#> GSM26863     1  0.3446      0.759 0.692 0.000 0.000 0.000 0.000 0.308
#> GSM26864     1  0.0000      0.828 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.0777      0.922 0.024 0.000 0.004 0.000 0.000 0.972
#> GSM26866     1  0.0000      0.828 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> MAD:mclust 62  1.14e-12      8.30e-01 2
#> MAD:mclust 60  6.48e-13      3.53e-04 3
#> MAD:mclust 61  1.51e-11      6.46e-09 4
#> MAD:mclust 37  9.24e-09      1.68e-07 5
#> MAD:mclust 62  1.43e-10      8.15e-13 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.977       0.992         0.5084 0.492   0.492
#> 3 3 0.867           0.874       0.949         0.2514 0.841   0.685
#> 4 4 0.840           0.808       0.911         0.1828 0.859   0.619
#> 5 5 0.786           0.751       0.833         0.0661 0.886   0.587
#> 6 6 0.813           0.731       0.835         0.0383 0.910   0.596

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
#> GSM26805     2   0.000      1.000 0.000 1.000
#> GSM26806     2   0.000      1.000 0.000 1.000
#> GSM26807     2   0.000      1.000 0.000 1.000
#> GSM26808     2   0.000      1.000 0.000 1.000
#> GSM26809     2   0.000      1.000 0.000 1.000
#> GSM26810     2   0.000      1.000 0.000 1.000
#> GSM26811     2   0.000      1.000 0.000 1.000
#> GSM26812     2   0.000      1.000 0.000 1.000
#> GSM26813     2   0.000      1.000 0.000 1.000
#> GSM26814     2   0.000      1.000 0.000 1.000
#> GSM26815     2   0.000      1.000 0.000 1.000
#> GSM26816     2   0.000      1.000 0.000 1.000
#> GSM26817     2   0.000      1.000 0.000 1.000
#> GSM26818     1   0.000      0.984 1.000 0.000
#> GSM26819     2   0.000      1.000 0.000 1.000
#> GSM26820     2   0.000      1.000 0.000 1.000
#> GSM26821     2   0.000      1.000 0.000 1.000
#> GSM26822     2   0.000      1.000 0.000 1.000
#> GSM26823     2   0.000      1.000 0.000 1.000
#> GSM26824     2   0.000      1.000 0.000 1.000
#> GSM26825     2   0.000      1.000 0.000 1.000
#> GSM26826     2   0.000      1.000 0.000 1.000
#> GSM26827     2   0.000      1.000 0.000 1.000
#> GSM26828     2   0.000      1.000 0.000 1.000
#> GSM26829     2   0.000      1.000 0.000 1.000
#> GSM26830     2   0.000      1.000 0.000 1.000
#> GSM26831     2   0.000      1.000 0.000 1.000
#> GSM26832     2   0.000      1.000 0.000 1.000
#> GSM26833     2   0.000      1.000 0.000 1.000
#> GSM26834     2   0.000      1.000 0.000 1.000
#> GSM26835     2   0.000      1.000 0.000 1.000
#> GSM26836     1   0.000      0.984 1.000 0.000
#> GSM26837     1   0.000      0.984 1.000 0.000
#> GSM26838     1   0.000      0.984 1.000 0.000
#> GSM26839     1   0.000      0.984 1.000 0.000
#> GSM26840     1   0.000      0.984 1.000 0.000
#> GSM26841     1   0.000      0.984 1.000 0.000
#> GSM26842     1   0.000      0.984 1.000 0.000
#> GSM26843     1   0.000      0.984 1.000 0.000
#> GSM26844     1   0.000      0.984 1.000 0.000
#> GSM26845     1   0.999      0.062 0.516 0.484
#> GSM26846     1   0.000      0.984 1.000 0.000
#> GSM26847     1   0.000      0.984 1.000 0.000
#> GSM26848     1   0.000      0.984 1.000 0.000
#> GSM26849     1   0.000      0.984 1.000 0.000
#> GSM26850     1   0.000      0.984 1.000 0.000
#> GSM26851     2   0.000      1.000 0.000 1.000
#> GSM26852     1   0.000      0.984 1.000 0.000
#> GSM26853     1   0.000      0.984 1.000 0.000
#> GSM26854     1   0.000      0.984 1.000 0.000
#> GSM26855     1   0.000      0.984 1.000 0.000
#> GSM26856     1   0.000      0.984 1.000 0.000
#> GSM26857     1   0.000      0.984 1.000 0.000
#> GSM26858     1   0.000      0.984 1.000 0.000
#> GSM26859     1   0.000      0.984 1.000 0.000
#> GSM26860     1   0.000      0.984 1.000 0.000
#> GSM26861     1   0.000      0.984 1.000 0.000
#> GSM26862     1   0.000      0.984 1.000 0.000
#> GSM26863     1   0.000      0.984 1.000 0.000
#> GSM26864     1   0.000      0.984 1.000 0.000
#> GSM26865     1   0.000      0.984 1.000 0.000
#> GSM26866     1   0.000      0.984 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     1  0.6244      0.220 0.560 0.440 0.000
#> GSM26806     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26807     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26808     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26809     1  0.3752      0.738 0.856 0.144 0.000
#> GSM26810     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26811     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26812     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26813     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26814     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26815     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26816     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26817     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26818     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26819     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26828     2  0.4002      0.788 0.160 0.840 0.000
#> GSM26829     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26831     2  0.4654      0.712 0.208 0.792 0.000
#> GSM26832     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26833     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26834     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26836     1  0.6244      0.204 0.560 0.000 0.440
#> GSM26837     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26838     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26839     3  0.5560      0.560 0.300 0.000 0.700
#> GSM26840     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26841     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26842     1  0.0892      0.826 0.980 0.000 0.020
#> GSM26843     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26845     1  0.0000      0.835 1.000 0.000 0.000
#> GSM26846     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26847     3  0.0237      0.929 0.004 0.000 0.996
#> GSM26848     3  0.5650      0.534 0.312 0.000 0.688
#> GSM26849     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26850     3  0.0424      0.926 0.008 0.000 0.992
#> GSM26851     2  0.0000      0.985 0.000 1.000 0.000
#> GSM26852     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26853     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26854     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26855     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26856     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26857     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26858     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26859     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26860     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26861     3  0.0000      0.931 0.000 0.000 1.000
#> GSM26862     3  0.4235      0.753 0.176 0.000 0.824
#> GSM26863     1  0.6140      0.310 0.596 0.000 0.404
#> GSM26864     1  0.4887      0.640 0.772 0.000 0.228
#> GSM26865     3  0.5497      0.575 0.292 0.000 0.708
#> GSM26866     1  0.0000      0.835 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     1  0.5994     0.5338 0.636 0.296 0.000 0.068
#> GSM26806     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26807     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26808     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26809     2  0.2281     0.8174 0.096 0.904 0.000 0.000
#> GSM26810     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26811     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26812     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26813     2  0.1940     0.9118 0.000 0.924 0.000 0.076
#> GSM26814     2  0.1867     0.9149 0.000 0.928 0.000 0.072
#> GSM26815     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26816     4  0.3356     0.7820 0.000 0.176 0.000 0.824
#> GSM26817     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26818     3  0.3837     0.6872 0.000 0.000 0.776 0.224
#> GSM26819     2  0.0921     0.9276 0.000 0.972 0.000 0.028
#> GSM26820     2  0.0592     0.9244 0.000 0.984 0.000 0.016
#> GSM26821     2  0.1637     0.9215 0.000 0.940 0.000 0.060
#> GSM26822     2  0.1118     0.9281 0.000 0.964 0.000 0.036
#> GSM26823     2  0.1118     0.9281 0.000 0.964 0.000 0.036
#> GSM26824     2  0.1792     0.9177 0.000 0.932 0.000 0.068
#> GSM26825     2  0.0592     0.9244 0.000 0.984 0.000 0.016
#> GSM26826     2  0.0336     0.9198 0.000 0.992 0.000 0.008
#> GSM26827     2  0.0817     0.9269 0.000 0.976 0.000 0.024
#> GSM26828     2  0.7512     0.1990 0.236 0.496 0.000 0.268
#> GSM26829     2  0.0336     0.9198 0.000 0.992 0.000 0.008
#> GSM26830     2  0.1716     0.9199 0.000 0.936 0.000 0.064
#> GSM26831     4  0.7835    -0.0374 0.336 0.268 0.000 0.396
#> GSM26832     4  0.1557     0.9035 0.000 0.056 0.000 0.944
#> GSM26833     4  0.0188     0.9297 0.000 0.004 0.000 0.996
#> GSM26834     4  0.1557     0.9035 0.000 0.056 0.000 0.944
#> GSM26835     4  0.1792     0.8956 0.000 0.068 0.000 0.932
#> GSM26836     1  0.4222     0.5877 0.728 0.000 0.272 0.000
#> GSM26837     3  0.3219     0.7820 0.164 0.000 0.836 0.000
#> GSM26838     1  0.0000     0.8315 1.000 0.000 0.000 0.000
#> GSM26839     1  0.4843     0.3061 0.604 0.000 0.396 0.000
#> GSM26840     1  0.1637     0.8156 0.940 0.060 0.000 0.000
#> GSM26841     1  0.0000     0.8315 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000     0.8315 1.000 0.000 0.000 0.000
#> GSM26843     1  0.1211     0.8257 0.960 0.040 0.000 0.000
#> GSM26844     1  0.0469     0.8313 0.988 0.012 0.000 0.000
#> GSM26845     1  0.4888     0.2293 0.588 0.412 0.000 0.000
#> GSM26846     3  0.4920     0.6720 0.052 0.192 0.756 0.000
#> GSM26847     3  0.1474     0.8730 0.052 0.000 0.948 0.000
#> GSM26848     3  0.2124     0.8563 0.068 0.008 0.924 0.000
#> GSM26849     3  0.0000     0.8988 0.000 0.000 1.000 0.000
#> GSM26850     3  0.1867     0.8511 0.000 0.072 0.928 0.000
#> GSM26851     4  0.0000     0.9315 0.000 0.000 0.000 1.000
#> GSM26852     3  0.0188     0.8993 0.004 0.000 0.996 0.000
#> GSM26853     3  0.0188     0.8993 0.004 0.000 0.996 0.000
#> GSM26854     3  0.0000     0.8988 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0188     0.8993 0.004 0.000 0.996 0.000
#> GSM26856     3  0.0188     0.8993 0.004 0.000 0.996 0.000
#> GSM26857     3  0.0000     0.8988 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0336     0.8981 0.008 0.000 0.992 0.000
#> GSM26859     3  0.0000     0.8988 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000     0.8988 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0188     0.8993 0.004 0.000 0.996 0.000
#> GSM26862     3  0.4866     0.3216 0.404 0.000 0.596 0.000
#> GSM26863     1  0.3873     0.6518 0.772 0.000 0.228 0.000
#> GSM26864     1  0.1118     0.8198 0.964 0.000 0.036 0.000
#> GSM26865     3  0.4500     0.4990 0.316 0.000 0.684 0.000
#> GSM26866     1  0.1211     0.8252 0.960 0.040 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
#> GSM26805     5  0.3414      0.639 0.024 0.060 0.000 0.056 0.860
#> GSM26806     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM26809     5  0.4015      0.347 0.000 0.348 0.000 0.000 0.652
#> GSM26810     4  0.0290      0.964 0.000 0.000 0.000 0.992 0.008
#> GSM26811     4  0.0290      0.964 0.000 0.000 0.000 0.992 0.008
#> GSM26812     4  0.0000      0.966 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26814     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26815     4  0.0510      0.958 0.000 0.000 0.000 0.984 0.016
#> GSM26816     5  0.4985      0.614 0.000 0.076 0.000 0.244 0.680
#> GSM26817     4  0.0579      0.958 0.000 0.008 0.000 0.984 0.008
#> GSM26818     3  0.1764      0.818 0.012 0.000 0.940 0.036 0.012
#> GSM26819     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26828     5  0.3456      0.655 0.004 0.004 0.000 0.204 0.788
#> GSM26829     2  0.3932      0.491 0.000 0.672 0.000 0.000 0.328
#> GSM26830     2  0.0000      0.970 0.000 1.000 0.000 0.000 0.000
#> GSM26831     5  0.3509      0.656 0.008 0.004 0.000 0.196 0.792
#> GSM26832     5  0.4219      0.434 0.000 0.000 0.000 0.416 0.584
#> GSM26833     4  0.2424      0.820 0.000 0.000 0.000 0.868 0.132
#> GSM26834     5  0.4219      0.429 0.000 0.000 0.000 0.416 0.584
#> GSM26835     5  0.3586      0.619 0.000 0.000 0.000 0.264 0.736
#> GSM26836     1  0.0794      0.791 0.972 0.000 0.028 0.000 0.000
#> GSM26837     1  0.1121      0.784 0.956 0.000 0.044 0.000 0.000
#> GSM26838     1  0.2179      0.760 0.888 0.000 0.000 0.000 0.112
#> GSM26839     1  0.0880      0.789 0.968 0.000 0.032 0.000 0.000
#> GSM26840     5  0.3895      0.103 0.320 0.000 0.000 0.000 0.680
#> GSM26841     1  0.2648      0.738 0.848 0.000 0.000 0.000 0.152
#> GSM26842     1  0.1341      0.784 0.944 0.000 0.000 0.000 0.056
#> GSM26843     5  0.4306     -0.338 0.492 0.000 0.000 0.000 0.508
#> GSM26844     1  0.4138      0.487 0.616 0.000 0.000 0.000 0.384
#> GSM26845     1  0.5982      0.519 0.588 0.120 0.008 0.000 0.284
#> GSM26846     3  0.6224      0.164 0.328 0.108 0.548 0.000 0.016
#> GSM26847     1  0.4562      0.144 0.500 0.000 0.492 0.000 0.008
#> GSM26848     3  0.3241      0.722 0.024 0.000 0.832 0.000 0.144
#> GSM26849     3  0.0404      0.815 0.000 0.000 0.988 0.000 0.012
#> GSM26850     3  0.1983      0.795 0.008 0.008 0.924 0.000 0.060
#> GSM26851     4  0.1544      0.908 0.000 0.000 0.000 0.932 0.068
#> GSM26852     3  0.3177      0.826 0.208 0.000 0.792 0.000 0.000
#> GSM26853     3  0.2929      0.840 0.180 0.000 0.820 0.000 0.000
#> GSM26854     3  0.2471      0.852 0.136 0.000 0.864 0.000 0.000
#> GSM26855     3  0.3039      0.834 0.192 0.000 0.808 0.000 0.000
#> GSM26856     3  0.2516      0.851 0.140 0.000 0.860 0.000 0.000
#> GSM26857     3  0.2424      0.852 0.132 0.000 0.868 0.000 0.000
#> GSM26858     3  0.3177      0.826 0.208 0.000 0.792 0.000 0.000
#> GSM26859     3  0.0451      0.822 0.008 0.000 0.988 0.000 0.004
#> GSM26860     3  0.2074      0.850 0.104 0.000 0.896 0.000 0.000
#> GSM26861     3  0.3143      0.828 0.204 0.000 0.796 0.000 0.000
#> GSM26862     1  0.1608      0.763 0.928 0.000 0.072 0.000 0.000
#> GSM26863     1  0.0609      0.792 0.980 0.000 0.020 0.000 0.000
#> GSM26864     1  0.1168      0.790 0.960 0.000 0.008 0.000 0.032
#> GSM26865     3  0.3734      0.704 0.060 0.000 0.812 0.000 0.128
#> GSM26866     1  0.4294      0.293 0.532 0.000 0.000 0.000 0.468

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.3121     0.7667 0.040 0.008 0.000 0.064 0.864 0.024
#> GSM26806     4  0.0000     0.9477 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     0.9477 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0260     0.9450 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM26809     2  0.7270    -0.1352 0.276 0.324 0.000 0.000 0.308 0.092
#> GSM26810     4  0.0000     0.9477 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0146     0.9462 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM26812     4  0.0000     0.9477 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26814     2  0.0146     0.9430 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26815     4  0.0260     0.9430 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM26816     5  0.3702     0.7883 0.000 0.024 0.000 0.164 0.788 0.024
#> GSM26817     4  0.1760     0.8945 0.000 0.004 0.000 0.928 0.048 0.020
#> GSM26818     3  0.3308     0.7796 0.000 0.000 0.844 0.080 0.032 0.044
#> GSM26819     2  0.0146     0.9430 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26820     2  0.0291     0.9413 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM26821     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0146     0.9430 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26826     2  0.0291     0.9413 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM26827     2  0.0000     0.9433 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.1929     0.7899 0.016 0.004 0.000 0.048 0.924 0.008
#> GSM26829     5  0.3834     0.5442 0.000 0.268 0.000 0.000 0.708 0.024
#> GSM26830     2  0.0146     0.9430 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM26831     5  0.2872     0.7926 0.024 0.004 0.000 0.088 0.868 0.016
#> GSM26832     5  0.3555     0.7614 0.000 0.000 0.000 0.184 0.776 0.040
#> GSM26833     5  0.4569     0.3984 0.000 0.000 0.000 0.396 0.564 0.040
#> GSM26834     5  0.2830     0.7951 0.000 0.000 0.000 0.144 0.836 0.020
#> GSM26835     5  0.2446     0.8095 0.000 0.000 0.000 0.124 0.864 0.012
#> GSM26836     1  0.5548     0.6489 0.504 0.000 0.124 0.000 0.004 0.368
#> GSM26837     1  0.5968     0.5733 0.432 0.000 0.192 0.000 0.004 0.372
#> GSM26838     1  0.4088     0.6960 0.668 0.000 0.020 0.000 0.004 0.308
#> GSM26839     1  0.5510     0.6738 0.540 0.000 0.132 0.000 0.004 0.324
#> GSM26840     1  0.4228     0.2998 0.708 0.000 0.000 0.000 0.228 0.064
#> GSM26841     1  0.3431     0.6981 0.756 0.000 0.016 0.000 0.000 0.228
#> GSM26842     1  0.4280     0.7101 0.708 0.000 0.056 0.000 0.004 0.232
#> GSM26843     1  0.2221     0.5172 0.896 0.000 0.000 0.000 0.072 0.032
#> GSM26844     1  0.2190     0.6049 0.900 0.000 0.000 0.000 0.040 0.060
#> GSM26845     6  0.5092    -0.1862 0.316 0.048 0.000 0.000 0.028 0.608
#> GSM26846     6  0.4753     0.6041 0.012 0.008 0.124 0.000 0.132 0.724
#> GSM26847     6  0.3469     0.3836 0.092 0.000 0.072 0.000 0.012 0.824
#> GSM26848     6  0.5389     0.4396 0.004 0.000 0.116 0.000 0.328 0.552
#> GSM26849     3  0.3838     0.0701 0.000 0.000 0.552 0.000 0.000 0.448
#> GSM26850     6  0.5425     0.4714 0.000 0.000 0.148 0.000 0.300 0.552
#> GSM26851     4  0.4336     0.5872 0.000 0.004 0.000 0.704 0.232 0.060
#> GSM26852     3  0.0909     0.8925 0.012 0.000 0.968 0.000 0.020 0.000
#> GSM26853     3  0.0363     0.8986 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM26854     3  0.0363     0.8998 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM26855     3  0.0603     0.8968 0.004 0.000 0.980 0.000 0.016 0.000
#> GSM26856     3  0.0363     0.8998 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM26857     3  0.0508     0.8990 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM26858     3  0.0909     0.8925 0.012 0.000 0.968 0.000 0.020 0.000
#> GSM26859     3  0.2112     0.8226 0.000 0.000 0.896 0.000 0.016 0.088
#> GSM26860     3  0.0806     0.8931 0.000 0.000 0.972 0.000 0.008 0.020
#> GSM26861     3  0.0806     0.8945 0.008 0.000 0.972 0.000 0.020 0.000
#> GSM26862     1  0.5800     0.5855 0.444 0.000 0.156 0.000 0.004 0.396
#> GSM26863     1  0.5288     0.6773 0.552 0.000 0.100 0.000 0.004 0.344
#> GSM26864     1  0.4757     0.7084 0.688 0.000 0.076 0.000 0.016 0.220
#> GSM26865     6  0.4778     0.2198 0.032 0.000 0.400 0.000 0.012 0.556
#> GSM26866     1  0.1411     0.5561 0.936 0.000 0.004 0.000 0.060 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n tissue(p) individual(p) k
#> MAD:NMF 61  1.90e-12      8.52e-01 2
#> MAD:NMF 59  4.31e-11      5.75e-03 3
#> MAD:NMF 56  9.86e-10      1.28e-05 4
#> MAD:NMF 52  4.69e-09      1.75e-05 5
#> MAD:NMF 53  1.02e-08      4.46e-09 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 62 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.732           0.887       0.922         0.3940 0.535   0.535
#> 3 3 0.658           0.895       0.887         0.3796 0.936   0.880
#> 4 4 0.877           0.959       0.955         0.3192 0.789   0.552
#> 5 5 0.879           0.932       0.952         0.0175 0.989   0.959
#> 6 6 0.835           0.925       0.916         0.0441 0.959   0.834

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
#> GSM26805     1   0.978      0.994 0.588 0.412
#> GSM26806     2   0.000      0.643 0.000 1.000
#> GSM26807     2   0.000      0.643 0.000 1.000
#> GSM26808     2   0.000      0.643 0.000 1.000
#> GSM26809     1   0.973      0.995 0.596 0.404
#> GSM26810     2   0.000      0.643 0.000 1.000
#> GSM26811     2   0.000      0.643 0.000 1.000
#> GSM26812     2   0.000      0.643 0.000 1.000
#> GSM26813     2   0.204      0.589 0.032 0.968
#> GSM26814     2   0.204      0.589 0.032 0.968
#> GSM26815     2   0.000      0.643 0.000 1.000
#> GSM26816     1   0.978      0.994 0.588 0.412
#> GSM26817     2   0.000      0.643 0.000 1.000
#> GSM26818     2   0.861      0.739 0.284 0.716
#> GSM26819     1   0.978      0.994 0.588 0.412
#> GSM26820     1   0.978      0.994 0.588 0.412
#> GSM26821     1   0.978      0.994 0.588 0.412
#> GSM26822     1   0.978      0.994 0.588 0.412
#> GSM26823     1   0.978      0.994 0.588 0.412
#> GSM26824     1   0.978      0.994 0.588 0.412
#> GSM26825     1   0.978      0.994 0.588 0.412
#> GSM26826     1   0.978      0.994 0.588 0.412
#> GSM26827     1   0.978      0.994 0.588 0.412
#> GSM26828     1   0.978      0.994 0.588 0.412
#> GSM26829     1   0.978      0.994 0.588 0.412
#> GSM26830     2   0.204      0.589 0.032 0.968
#> GSM26831     1   0.978      0.994 0.588 0.412
#> GSM26832     1   0.978      0.994 0.588 0.412
#> GSM26833     1   0.978      0.994 0.588 0.412
#> GSM26834     1   0.978      0.994 0.588 0.412
#> GSM26835     1   0.978      0.994 0.588 0.412
#> GSM26836     1   0.973      0.995 0.596 0.404
#> GSM26837     1   0.973      0.995 0.596 0.404
#> GSM26838     1   0.973      0.995 0.596 0.404
#> GSM26839     1   0.973      0.995 0.596 0.404
#> GSM26840     1   0.973      0.995 0.596 0.404
#> GSM26841     1   0.973      0.995 0.596 0.404
#> GSM26842     1   0.973      0.995 0.596 0.404
#> GSM26843     1   0.973      0.995 0.596 0.404
#> GSM26844     1   0.973      0.995 0.596 0.404
#> GSM26845     1   0.973      0.995 0.596 0.404
#> GSM26846     1   0.973      0.995 0.596 0.404
#> GSM26847     1   0.973      0.995 0.596 0.404
#> GSM26848     1   0.973      0.995 0.596 0.404
#> GSM26849     1   0.973      0.995 0.596 0.404
#> GSM26850     1   0.973      0.995 0.596 0.404
#> GSM26851     1   0.978      0.994 0.588 0.412
#> GSM26852     2   0.973      0.756 0.404 0.596
#> GSM26853     2   0.973      0.756 0.404 0.596
#> GSM26854     2   0.973      0.756 0.404 0.596
#> GSM26855     2   0.973      0.756 0.404 0.596
#> GSM26856     2   0.973      0.756 0.404 0.596
#> GSM26857     2   0.973      0.756 0.404 0.596
#> GSM26858     2   0.973      0.756 0.404 0.596
#> GSM26859     2   0.973      0.756 0.404 0.596
#> GSM26860     2   0.973      0.756 0.404 0.596
#> GSM26861     2   0.973      0.756 0.404 0.596
#> GSM26862     1   0.973      0.995 0.596 0.404
#> GSM26863     1   0.973      0.995 0.596 0.404
#> GSM26864     1   0.973      0.995 0.596 0.404
#> GSM26865     1   0.973      0.995 0.596 0.404
#> GSM26866     1   0.973      0.995 0.596 0.404

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     1   0.489      0.867 0.772 0.228 0.000
#> GSM26806     2   0.303      0.963 0.032 0.920 0.048
#> GSM26807     2   0.303      0.963 0.032 0.920 0.048
#> GSM26808     2   0.303      0.963 0.032 0.920 0.048
#> GSM26809     1   0.480      0.867 0.780 0.220 0.000
#> GSM26810     2   0.303      0.963 0.032 0.920 0.048
#> GSM26811     2   0.303      0.963 0.032 0.920 0.048
#> GSM26812     2   0.303      0.963 0.032 0.920 0.048
#> GSM26813     2   0.397      0.933 0.072 0.884 0.044
#> GSM26814     2   0.397      0.933 0.072 0.884 0.044
#> GSM26815     2   0.442      0.813 0.088 0.864 0.048
#> GSM26816     1   0.489      0.867 0.772 0.228 0.000
#> GSM26817     2   0.303      0.963 0.032 0.920 0.048
#> GSM26818     3   0.397      0.868 0.088 0.032 0.880
#> GSM26819     1   0.489      0.867 0.772 0.228 0.000
#> GSM26820     1   0.489      0.867 0.772 0.228 0.000
#> GSM26821     1   0.489      0.867 0.772 0.228 0.000
#> GSM26822     1   0.489      0.867 0.772 0.228 0.000
#> GSM26823     1   0.489      0.867 0.772 0.228 0.000
#> GSM26824     1   0.489      0.867 0.772 0.228 0.000
#> GSM26825     1   0.489      0.867 0.772 0.228 0.000
#> GSM26826     1   0.489      0.867 0.772 0.228 0.000
#> GSM26827     1   0.489      0.867 0.772 0.228 0.000
#> GSM26828     1   0.489      0.867 0.772 0.228 0.000
#> GSM26829     1   0.489      0.867 0.772 0.228 0.000
#> GSM26830     2   0.397      0.933 0.072 0.884 0.044
#> GSM26831     1   0.489      0.867 0.772 0.228 0.000
#> GSM26832     1   0.489      0.867 0.772 0.228 0.000
#> GSM26833     1   0.489      0.867 0.772 0.228 0.000
#> GSM26834     1   0.489      0.867 0.772 0.228 0.000
#> GSM26835     1   0.489      0.867 0.772 0.228 0.000
#> GSM26836     1   0.000      0.850 1.000 0.000 0.000
#> GSM26837     1   0.000      0.850 1.000 0.000 0.000
#> GSM26838     1   0.000      0.850 1.000 0.000 0.000
#> GSM26839     1   0.000      0.850 1.000 0.000 0.000
#> GSM26840     1   0.475      0.867 0.784 0.216 0.000
#> GSM26841     1   0.000      0.850 1.000 0.000 0.000
#> GSM26842     1   0.000      0.850 1.000 0.000 0.000
#> GSM26843     1   0.000      0.850 1.000 0.000 0.000
#> GSM26844     1   0.000      0.850 1.000 0.000 0.000
#> GSM26845     1   0.412      0.862 0.832 0.168 0.000
#> GSM26846     1   0.000      0.850 1.000 0.000 0.000
#> GSM26847     1   0.000      0.850 1.000 0.000 0.000
#> GSM26848     1   0.000      0.850 1.000 0.000 0.000
#> GSM26849     1   0.000      0.850 1.000 0.000 0.000
#> GSM26850     1   0.000      0.850 1.000 0.000 0.000
#> GSM26851     1   0.489      0.867 0.772 0.228 0.000
#> GSM26852     3   0.000      0.988 0.000 0.000 1.000
#> GSM26853     3   0.000      0.988 0.000 0.000 1.000
#> GSM26854     3   0.000      0.988 0.000 0.000 1.000
#> GSM26855     3   0.000      0.988 0.000 0.000 1.000
#> GSM26856     3   0.000      0.988 0.000 0.000 1.000
#> GSM26857     3   0.000      0.988 0.000 0.000 1.000
#> GSM26858     3   0.000      0.988 0.000 0.000 1.000
#> GSM26859     3   0.000      0.988 0.000 0.000 1.000
#> GSM26860     3   0.000      0.988 0.000 0.000 1.000
#> GSM26861     3   0.000      0.988 0.000 0.000 1.000
#> GSM26862     1   0.000      0.850 1.000 0.000 0.000
#> GSM26863     1   0.000      0.850 1.000 0.000 0.000
#> GSM26864     1   0.000      0.850 1.000 0.000 0.000
#> GSM26865     1   0.000      0.850 1.000 0.000 0.000
#> GSM26866     1   0.000      0.850 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2   p3    p4
#> GSM26805     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26806     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26807     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26808     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26809     2  0.0336      0.988 0.008 0.992 0.00 0.000
#> GSM26810     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26811     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26812     4  0.3610      0.952 0.000 0.200 0.00 0.800
#> GSM26813     4  0.4103      0.918 0.000 0.256 0.00 0.744
#> GSM26814     4  0.4103      0.918 0.000 0.256 0.00 0.744
#> GSM26815     4  0.0000      0.708 0.000 0.000 0.00 1.000
#> GSM26816     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26817     4  0.3726      0.947 0.000 0.212 0.00 0.788
#> GSM26818     3  0.2647      0.905 0.000 0.000 0.88 0.120
#> GSM26819     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26820     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26821     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26822     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26823     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26824     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26825     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26826     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26827     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26828     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26829     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26830     4  0.4103      0.918 0.000 0.256 0.00 0.744
#> GSM26831     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26832     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26833     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26834     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26835     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26836     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26837     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26838     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26839     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26840     2  0.0469      0.983 0.012 0.988 0.00 0.000
#> GSM26841     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26842     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26843     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26844     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26845     1  0.4972      0.138 0.544 0.456 0.00 0.000
#> GSM26846     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26847     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26848     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26849     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26850     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26851     2  0.0000      0.999 0.000 1.000 0.00 0.000
#> GSM26852     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26853     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26854     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26855     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26856     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26857     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26858     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26859     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26860     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26861     3  0.0000      0.991 0.000 0.000 1.00 0.000
#> GSM26862     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26863     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26864     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26865     1  0.0000      0.969 1.000 0.000 0.00 0.000
#> GSM26866     1  0.0000      0.969 1.000 0.000 0.00 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
#> GSM26805     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26806     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26807     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26808     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26809     2   0.029     0.9894 0.000 0.992 0.000 0.000 0.008
#> GSM26810     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26811     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26812     4   0.311     0.9251 0.000 0.200 0.000 0.800 0.000
#> GSM26813     4   0.353     0.8772 0.000 0.256 0.000 0.744 0.000
#> GSM26814     4   0.353     0.8772 0.000 0.256 0.000 0.744 0.000
#> GSM26815     4   0.000     0.5313 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26817     4   0.321     0.9184 0.000 0.212 0.000 0.788 0.000
#> GSM26818     3   0.324     0.8044 0.000 0.000 0.816 0.012 0.172
#> GSM26819     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26822     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26825     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26830     4   0.353     0.8772 0.000 0.256 0.000 0.744 0.000
#> GSM26831     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26833     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26834     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26835     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26836     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26837     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26838     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26839     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26840     5   0.285     0.0000 0.000 0.172 0.000 0.000 0.828
#> GSM26841     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1   0.618     0.0741 0.544 0.180 0.000 0.000 0.276
#> GSM26846     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26847     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26848     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26849     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26850     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26851     2   0.000     0.9994 0.000 1.000 0.000 0.000 0.000
#> GSM26852     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3   0.000     0.9829 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26863     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26864     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26865     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000
#> GSM26866     1   0.000     0.9719 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26806     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26807     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26808     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26809     2   0.026     0.9908 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM26810     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26811     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26812     4   0.279     0.9401 0.000 0.200 0.000 0.800 0.000 0.000
#> GSM26813     4   0.317     0.9031 0.000 0.256 0.000 0.744 0.000 0.000
#> GSM26814     4   0.317     0.9031 0.000 0.256 0.000 0.744 0.000 0.000
#> GSM26815     4   0.000     0.5919 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26817     4   0.288     0.9349 0.000 0.212 0.000 0.788 0.000 0.000
#> GSM26818     3   0.367     0.5096 0.000 0.000 0.632 0.000 0.000 0.368
#> GSM26819     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26827     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26829     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26830     4   0.317     0.9031 0.000 0.256 0.000 0.744 0.000 0.000
#> GSM26831     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26832     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26833     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26834     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26835     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26836     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26837     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26838     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26839     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26840     5   0.000     0.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26841     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26842     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26843     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     1   0.407     0.0549 0.544 0.008 0.000 0.000 0.448 0.000
#> GSM26846     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26847     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26848     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26849     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26850     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26851     2   0.000     0.9995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26852     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3   0.000     0.9642 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26863     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26864     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6   0.367     1.0000 0.368 0.000 0.000 0.000 0.000 0.632
#> GSM26866     1   0.000     0.9413 1.000 0.000 0.000 0.000 0.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> ATC:hclust 62  7.91e-01      7.59e-02 2
#> ATC:hclust 62  9.79e-05      4.21e-05 3
#> ATC:hclust 61  7.52e-11      6.47e-06 4
#> ATC:hclust 60  2.28e-11      3.79e-06 5
#> ATC:hclust 60  1.06e-10      7.14e-09 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 62 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.591           0.885       0.907         0.4560 0.494   0.494
#> 3 3 0.773           0.852       0.883         0.3661 0.843   0.695
#> 4 4 0.746           0.909       0.902         0.1348 0.887   0.703
#> 5 5 0.750           0.825       0.843         0.0745 0.950   0.819
#> 6 6 0.817           0.766       0.826         0.0505 0.978   0.910

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
#> GSM26805     2   0.000      0.983 0.000 1.000
#> GSM26806     2   0.295      0.945 0.052 0.948
#> GSM26807     2   0.295      0.945 0.052 0.948
#> GSM26808     2   0.295      0.945 0.052 0.948
#> GSM26809     2   0.000      0.983 0.000 1.000
#> GSM26810     2   0.295      0.945 0.052 0.948
#> GSM26811     2   0.295      0.945 0.052 0.948
#> GSM26812     2   0.295      0.945 0.052 0.948
#> GSM26813     2   0.000      0.983 0.000 1.000
#> GSM26814     2   0.000      0.983 0.000 1.000
#> GSM26815     2   0.295      0.945 0.052 0.948
#> GSM26816     2   0.000      0.983 0.000 1.000
#> GSM26817     2   0.295      0.945 0.052 0.948
#> GSM26818     1   0.000      0.787 1.000 0.000
#> GSM26819     2   0.000      0.983 0.000 1.000
#> GSM26820     2   0.000      0.983 0.000 1.000
#> GSM26821     2   0.000      0.983 0.000 1.000
#> GSM26822     2   0.000      0.983 0.000 1.000
#> GSM26823     2   0.000      0.983 0.000 1.000
#> GSM26824     2   0.000      0.983 0.000 1.000
#> GSM26825     2   0.000      0.983 0.000 1.000
#> GSM26826     2   0.000      0.983 0.000 1.000
#> GSM26827     2   0.000      0.983 0.000 1.000
#> GSM26828     2   0.000      0.983 0.000 1.000
#> GSM26829     2   0.000      0.983 0.000 1.000
#> GSM26830     2   0.000      0.983 0.000 1.000
#> GSM26831     2   0.000      0.983 0.000 1.000
#> GSM26832     2   0.000      0.983 0.000 1.000
#> GSM26833     2   0.000      0.983 0.000 1.000
#> GSM26834     2   0.000      0.983 0.000 1.000
#> GSM26835     2   0.000      0.983 0.000 1.000
#> GSM26836     1   0.917      0.782 0.668 0.332
#> GSM26837     1   0.529      0.790 0.880 0.120
#> GSM26838     1   0.917      0.782 0.668 0.332
#> GSM26839     1   0.833      0.788 0.736 0.264
#> GSM26840     2   0.000      0.983 0.000 1.000
#> GSM26841     1   0.917      0.782 0.668 0.332
#> GSM26842     1   0.917      0.782 0.668 0.332
#> GSM26843     1   0.917      0.782 0.668 0.332
#> GSM26844     1   0.917      0.782 0.668 0.332
#> GSM26845     2   0.000      0.983 0.000 1.000
#> GSM26846     1   0.917      0.782 0.668 0.332
#> GSM26847     1   0.917      0.782 0.668 0.332
#> GSM26848     1   0.917      0.782 0.668 0.332
#> GSM26849     1   0.000      0.787 1.000 0.000
#> GSM26850     1   0.917      0.782 0.668 0.332
#> GSM26851     2   0.000      0.983 0.000 1.000
#> GSM26852     1   0.000      0.787 1.000 0.000
#> GSM26853     1   0.000      0.787 1.000 0.000
#> GSM26854     1   0.000      0.787 1.000 0.000
#> GSM26855     1   0.000      0.787 1.000 0.000
#> GSM26856     1   0.000      0.787 1.000 0.000
#> GSM26857     1   0.000      0.787 1.000 0.000
#> GSM26858     1   0.000      0.787 1.000 0.000
#> GSM26859     1   0.000      0.787 1.000 0.000
#> GSM26860     1   0.000      0.787 1.000 0.000
#> GSM26861     1   0.000      0.787 1.000 0.000
#> GSM26862     1   0.917      0.782 0.668 0.332
#> GSM26863     1   0.917      0.782 0.668 0.332
#> GSM26864     1   0.917      0.782 0.668 0.332
#> GSM26865     1   0.917      0.782 0.668 0.332
#> GSM26866     1   0.917      0.782 0.668 0.332

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26806     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26807     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26808     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26809     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26810     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26811     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26812     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26813     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26814     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26815     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26816     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26817     2  0.5706      0.748 0.000 0.680 0.320
#> GSM26818     3  0.4504      0.804 0.196 0.000 0.804
#> GSM26819     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26821     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26822     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26824     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26825     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26830     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26831     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26832     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26833     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26834     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.921 0.000 1.000 0.000
#> GSM26836     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26838     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26839     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26840     1  0.6026      0.385 0.624 0.376 0.000
#> GSM26841     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26842     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26843     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26844     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26845     1  0.6280      0.191 0.540 0.460 0.000
#> GSM26846     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26847     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26848     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26849     1  0.6244     -0.477 0.560 0.000 0.440
#> GSM26850     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26851     2  0.0237      0.921 0.000 0.996 0.004
#> GSM26852     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26853     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26854     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26855     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26856     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26857     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26858     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26859     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26860     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26861     3  0.5706      0.979 0.320 0.000 0.680
#> GSM26862     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26864     1  0.0237      0.879 0.996 0.004 0.000
#> GSM26865     1  0.0000      0.880 1.000 0.000 0.000
#> GSM26866     1  0.0237      0.879 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26806     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26807     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26808     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26809     2  0.3550      0.890 0.000 0.860 0.096 0.044
#> GSM26810     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26811     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26812     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26813     2  0.0188      0.951 0.000 0.996 0.004 0.000
#> GSM26814     2  0.0188      0.951 0.000 0.996 0.004 0.000
#> GSM26815     4  0.3837      0.999 0.000 0.224 0.000 0.776
#> GSM26816     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26817     4  0.4018      0.996 0.000 0.224 0.004 0.772
#> GSM26818     3  0.4010      0.878 0.064 0.000 0.836 0.100
#> GSM26819     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26820     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26821     2  0.0469      0.950 0.000 0.988 0.012 0.000
#> GSM26822     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26823     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26824     2  0.0469      0.950 0.000 0.988 0.012 0.000
#> GSM26825     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26826     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26827     2  0.0469      0.951 0.000 0.988 0.012 0.000
#> GSM26828     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26829     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26830     2  0.0188      0.951 0.000 0.996 0.004 0.000
#> GSM26831     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26832     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26833     2  0.0336      0.951 0.000 0.992 0.008 0.000
#> GSM26834     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26835     2  0.2081      0.929 0.000 0.916 0.084 0.000
#> GSM26836     1  0.0592      0.906 0.984 0.000 0.000 0.016
#> GSM26837     1  0.0592      0.906 0.984 0.000 0.000 0.016
#> GSM26838     1  0.1302      0.904 0.956 0.000 0.000 0.044
#> GSM26839     1  0.0592      0.906 0.984 0.000 0.000 0.016
#> GSM26840     1  0.7049      0.612 0.676 0.144 0.092 0.088
#> GSM26841     1  0.1118      0.904 0.964 0.000 0.000 0.036
#> GSM26842     1  0.1118      0.904 0.964 0.000 0.000 0.036
#> GSM26843     1  0.0921      0.905 0.972 0.000 0.000 0.028
#> GSM26844     1  0.0921      0.905 0.972 0.000 0.000 0.028
#> GSM26845     1  0.7777      0.314 0.528 0.328 0.088 0.056
#> GSM26846     1  0.2530      0.867 0.888 0.000 0.000 0.112
#> GSM26847     1  0.2469      0.869 0.892 0.000 0.000 0.108
#> GSM26848     1  0.2408      0.868 0.896 0.000 0.000 0.104
#> GSM26849     3  0.7046      0.220 0.432 0.000 0.448 0.120
#> GSM26850     1  0.2408      0.868 0.896 0.000 0.000 0.104
#> GSM26851     2  0.0469      0.952 0.000 0.988 0.012 0.000
#> GSM26852     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26853     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26854     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26855     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26856     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26857     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26858     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26859     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26860     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26861     3  0.2345      0.950 0.100 0.000 0.900 0.000
#> GSM26862     1  0.0592      0.906 0.984 0.000 0.000 0.016
#> GSM26863     1  0.0592      0.906 0.984 0.000 0.000 0.016
#> GSM26864     1  0.0921      0.905 0.972 0.000 0.000 0.028
#> GSM26865     1  0.2408      0.868 0.896 0.000 0.000 0.104
#> GSM26866     1  0.0921      0.905 0.972 0.000 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26806     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26807     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26808     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26809     2  0.3912    0.82272 0.000 0.752 0.000 0.020 0.228
#> GSM26810     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26811     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26812     4  0.2329    0.99523 0.000 0.124 0.000 0.876 0.000
#> GSM26813     2  0.1626    0.87801 0.000 0.940 0.016 0.000 0.044
#> GSM26814     2  0.1626    0.87801 0.000 0.940 0.016 0.000 0.044
#> GSM26815     4  0.2074    0.97006 0.000 0.104 0.000 0.896 0.000
#> GSM26816     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26817     4  0.2488    0.99239 0.000 0.124 0.000 0.872 0.004
#> GSM26818     3  0.4382    0.74588 0.004 0.000 0.760 0.060 0.176
#> GSM26819     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26820     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26821     2  0.1041    0.87631 0.000 0.964 0.004 0.000 0.032
#> GSM26822     2  0.0290    0.88577 0.000 0.992 0.000 0.000 0.008
#> GSM26823     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26824     2  0.1041    0.87631 0.000 0.964 0.004 0.000 0.032
#> GSM26825     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26826     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26827     2  0.0162    0.88688 0.000 0.996 0.000 0.000 0.004
#> GSM26828     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26829     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26830     2  0.1626    0.87801 0.000 0.940 0.016 0.000 0.044
#> GSM26831     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26832     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26833     2  0.2124    0.88088 0.000 0.900 0.004 0.000 0.096
#> GSM26834     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26835     2  0.3336    0.84423 0.000 0.772 0.000 0.000 0.228
#> GSM26836     1  0.3355    0.72619 0.832 0.000 0.000 0.036 0.132
#> GSM26837     1  0.3355    0.72619 0.832 0.000 0.000 0.036 0.132
#> GSM26838     1  0.1830    0.76808 0.932 0.000 0.000 0.040 0.028
#> GSM26839     1  0.3355    0.72619 0.832 0.000 0.000 0.036 0.132
#> GSM26840     1  0.6568    0.03387 0.492 0.100 0.000 0.032 0.376
#> GSM26841     1  0.0162    0.77884 0.996 0.000 0.000 0.004 0.000
#> GSM26842     1  0.0162    0.77884 0.996 0.000 0.000 0.004 0.000
#> GSM26843     1  0.0898    0.76962 0.972 0.000 0.000 0.008 0.020
#> GSM26844     1  0.0898    0.76962 0.972 0.000 0.000 0.008 0.020
#> GSM26845     5  0.7519   -0.00443 0.340 0.252 0.008 0.024 0.376
#> GSM26846     5  0.4227    0.65354 0.420 0.000 0.000 0.000 0.580
#> GSM26847     5  0.4604    0.62187 0.428 0.000 0.000 0.012 0.560
#> GSM26848     5  0.4273    0.66473 0.448 0.000 0.000 0.000 0.552
#> GSM26849     5  0.6697    0.43415 0.188 0.000 0.228 0.028 0.556
#> GSM26850     5  0.4273    0.66473 0.448 0.000 0.000 0.000 0.552
#> GSM26851     2  0.1544    0.88549 0.000 0.932 0.000 0.000 0.068
#> GSM26852     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26853     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26854     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26855     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26856     3  0.0671    0.97669 0.016 0.000 0.980 0.004 0.000
#> GSM26857     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26858     3  0.0671    0.97669 0.016 0.000 0.980 0.004 0.000
#> GSM26859     3  0.0671    0.97669 0.016 0.000 0.980 0.004 0.000
#> GSM26860     3  0.0510    0.97728 0.016 0.000 0.984 0.000 0.000
#> GSM26861     3  0.0671    0.97669 0.016 0.000 0.980 0.004 0.000
#> GSM26862     1  0.3355    0.72619 0.832 0.000 0.000 0.036 0.132
#> GSM26863     1  0.3355    0.72619 0.832 0.000 0.000 0.036 0.132
#> GSM26864     1  0.0404    0.77550 0.988 0.000 0.000 0.000 0.012
#> GSM26865     5  0.4273    0.66473 0.448 0.000 0.000 0.000 0.552
#> GSM26866     1  0.0898    0.76962 0.972 0.000 0.000 0.008 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26806     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26807     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26808     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26809     2  0.3481      0.634 0.000 0.776 0.000 0.000 0.192 0.032
#> GSM26810     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26811     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26812     4  0.0937      0.988 0.000 0.040 0.000 0.960 0.000 0.000
#> GSM26813     2  0.4938      0.679 0.000 0.568 0.000 0.000 0.356 0.076
#> GSM26814     2  0.4938      0.679 0.000 0.568 0.000 0.000 0.356 0.076
#> GSM26815     4  0.0790      0.978 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM26816     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26817     4  0.2471      0.929 0.000 0.040 0.000 0.896 0.044 0.020
#> GSM26818     3  0.5796      0.452 0.004 0.000 0.568 0.012 0.160 0.256
#> GSM26819     2  0.3795      0.736 0.000 0.632 0.000 0.000 0.364 0.004
#> GSM26820     2  0.3795      0.736 0.000 0.632 0.000 0.000 0.364 0.004
#> GSM26821     2  0.4726      0.693 0.000 0.536 0.008 0.000 0.424 0.032
#> GSM26822     2  0.3795      0.736 0.000 0.632 0.000 0.000 0.364 0.004
#> GSM26823     2  0.3672      0.736 0.000 0.632 0.000 0.000 0.368 0.000
#> GSM26824     2  0.4731      0.691 0.000 0.532 0.008 0.000 0.428 0.032
#> GSM26825     2  0.3795      0.736 0.000 0.632 0.000 0.000 0.364 0.004
#> GSM26826     2  0.3659      0.736 0.000 0.636 0.000 0.000 0.364 0.000
#> GSM26827     2  0.3672      0.736 0.000 0.632 0.000 0.000 0.368 0.000
#> GSM26828     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26829     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26830     2  0.4938      0.679 0.000 0.568 0.000 0.000 0.356 0.076
#> GSM26831     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26832     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26833     2  0.4094      0.687 0.000 0.728 0.008 0.000 0.224 0.040
#> GSM26834     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26835     2  0.0000      0.679 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26836     1  0.1700      0.791 0.916 0.000 0.000 0.000 0.004 0.080
#> GSM26837     1  0.1700      0.791 0.916 0.000 0.000 0.000 0.004 0.080
#> GSM26838     1  0.0622      0.790 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM26839     1  0.1700      0.791 0.916 0.000 0.000 0.000 0.004 0.080
#> GSM26840     5  0.7568      0.000 0.296 0.224 0.000 0.008 0.352 0.120
#> GSM26841     1  0.2956      0.783 0.856 0.000 0.000 0.016 0.100 0.028
#> GSM26842     1  0.2956      0.783 0.856 0.000 0.000 0.016 0.100 0.028
#> GSM26843     1  0.3585      0.738 0.792 0.000 0.000 0.004 0.156 0.048
#> GSM26844     1  0.3585      0.738 0.792 0.000 0.000 0.004 0.156 0.048
#> GSM26845     2  0.7860     -0.700 0.188 0.336 0.000 0.012 0.260 0.204
#> GSM26846     6  0.3360      0.875 0.264 0.000 0.000 0.004 0.000 0.732
#> GSM26847     6  0.3741      0.822 0.320 0.000 0.000 0.008 0.000 0.672
#> GSM26848     6  0.3050      0.889 0.236 0.000 0.000 0.000 0.000 0.764
#> GSM26849     6  0.4342      0.613 0.072 0.000 0.128 0.000 0.036 0.764
#> GSM26850     6  0.2996      0.887 0.228 0.000 0.000 0.000 0.000 0.772
#> GSM26851     2  0.4375      0.727 0.000 0.648 0.008 0.000 0.316 0.028
#> GSM26852     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26853     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26854     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26855     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26856     3  0.0520      0.956 0.008 0.000 0.984 0.000 0.008 0.000
#> GSM26857     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26858     3  0.0520      0.956 0.008 0.000 0.984 0.000 0.008 0.000
#> GSM26859     3  0.0520      0.956 0.008 0.000 0.984 0.000 0.008 0.000
#> GSM26860     3  0.0260      0.957 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM26861     3  0.0520      0.956 0.008 0.000 0.984 0.000 0.008 0.000
#> GSM26862     1  0.1700      0.790 0.916 0.000 0.000 0.004 0.000 0.080
#> GSM26863     1  0.1700      0.790 0.916 0.000 0.000 0.004 0.000 0.080
#> GSM26864     1  0.3147      0.779 0.844 0.000 0.000 0.012 0.100 0.044
#> GSM26865     6  0.3050      0.889 0.236 0.000 0.000 0.000 0.000 0.764
#> GSM26866     1  0.3585      0.738 0.792 0.000 0.000 0.004 0.156 0.048

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> ATC:kmeans 62  3.65e-11      8.91e-01 2
#> ATC:kmeans 59  6.65e-12      1.69e-04 3
#> ATC:kmeans 60  2.31e-11      1.88e-06 4
#> ATC:kmeans 59  1.74e-10      1.67e-08 5
#> ATC:kmeans 59  2.99e-11      7.29e-10 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 62 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-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.999       1.000         0.5066 0.494   0.494
#> 3 3 0.993           0.964       0.982         0.2383 0.841   0.690
#> 4 4 0.921           0.914       0.959         0.1689 0.895   0.718
#> 5 5 0.918           0.909       0.949         0.0522 0.963   0.861
#> 6 6 0.839           0.724       0.839         0.0502 0.956   0.808

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3 4

There is also optional best \(k\) = 2 3 4 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM26805     2  0.0000      0.999 0.000 1.000
#> GSM26806     2  0.0000      0.999 0.000 1.000
#> GSM26807     2  0.0000      0.999 0.000 1.000
#> GSM26808     2  0.0000      0.999 0.000 1.000
#> GSM26809     2  0.0000      0.999 0.000 1.000
#> GSM26810     2  0.0000      0.999 0.000 1.000
#> GSM26811     2  0.0000      0.999 0.000 1.000
#> GSM26812     2  0.0000      0.999 0.000 1.000
#> GSM26813     2  0.0000      0.999 0.000 1.000
#> GSM26814     2  0.0000      0.999 0.000 1.000
#> GSM26815     2  0.0000      0.999 0.000 1.000
#> GSM26816     2  0.0000      0.999 0.000 1.000
#> GSM26817     2  0.0000      0.999 0.000 1.000
#> GSM26818     1  0.0000      1.000 1.000 0.000
#> GSM26819     2  0.0000      0.999 0.000 1.000
#> GSM26820     2  0.0000      0.999 0.000 1.000
#> GSM26821     2  0.0000      0.999 0.000 1.000
#> GSM26822     2  0.0000      0.999 0.000 1.000
#> GSM26823     2  0.0000      0.999 0.000 1.000
#> GSM26824     2  0.0000      0.999 0.000 1.000
#> GSM26825     2  0.0000      0.999 0.000 1.000
#> GSM26826     2  0.0000      0.999 0.000 1.000
#> GSM26827     2  0.0000      0.999 0.000 1.000
#> GSM26828     2  0.0000      0.999 0.000 1.000
#> GSM26829     2  0.0000      0.999 0.000 1.000
#> GSM26830     2  0.0000      0.999 0.000 1.000
#> GSM26831     2  0.0000      0.999 0.000 1.000
#> GSM26832     2  0.0000      0.999 0.000 1.000
#> GSM26833     2  0.0000      0.999 0.000 1.000
#> GSM26834     2  0.0000      0.999 0.000 1.000
#> GSM26835     2  0.0000      0.999 0.000 1.000
#> GSM26836     1  0.0000      1.000 1.000 0.000
#> GSM26837     1  0.0000      1.000 1.000 0.000
#> GSM26838     1  0.0000      1.000 1.000 0.000
#> GSM26839     1  0.0000      1.000 1.000 0.000
#> GSM26840     2  0.0376      0.996 0.004 0.996
#> GSM26841     1  0.0000      1.000 1.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.000
#> GSM26845     2  0.1414      0.980 0.020 0.980
#> GSM26846     1  0.0000      1.000 1.000 0.000
#> GSM26847     1  0.0000      1.000 1.000 0.000
#> GSM26848     1  0.0000      1.000 1.000 0.000
#> GSM26849     1  0.0000      1.000 1.000 0.000
#> GSM26850     1  0.0000      1.000 1.000 0.000
#> GSM26851     2  0.0000      0.999 0.000 1.000
#> GSM26852     1  0.0000      1.000 1.000 0.000
#> GSM26853     1  0.0000      1.000 1.000 0.000
#> GSM26854     1  0.0000      1.000 1.000 0.000
#> GSM26855     1  0.0000      1.000 1.000 0.000
#> GSM26856     1  0.0000      1.000 1.000 0.000
#> GSM26857     1  0.0000      1.000 1.000 0.000
#> GSM26858     1  0.0000      1.000 1.000 0.000
#> GSM26859     1  0.0000      1.000 1.000 0.000
#> GSM26860     1  0.0000      1.000 1.000 0.000
#> GSM26861     1  0.0000      1.000 1.000 0.000
#> GSM26862     1  0.0000      1.000 1.000 0.000
#> GSM26863     1  0.0000      1.000 1.000 0.000
#> GSM26864     1  0.0000      1.000 1.000 0.000
#> GSM26865     1  0.0000      1.000 1.000 0.000
#> GSM26866     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26806     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26807     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26808     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26809     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26810     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26811     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26812     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26813     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26814     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26815     2  0.0424      0.994 0.000 0.992 0.008
#> GSM26816     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26817     2  0.0237      0.997 0.000 0.996 0.004
#> GSM26818     3  0.0000      0.995 0.000 0.000 1.000
#> GSM26819     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26821     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26822     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26824     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26825     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26830     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26831     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26832     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26833     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26834     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26836     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26837     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26838     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26839     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26840     1  0.4452      0.746 0.808 0.192 0.000
#> GSM26841     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26842     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26843     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26844     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26845     1  0.4605      0.732 0.796 0.204 0.000
#> GSM26846     1  0.5785      0.542 0.668 0.000 0.332
#> GSM26847     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26848     1  0.2066      0.903 0.940 0.000 0.060
#> GSM26849     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26850     1  0.3482      0.848 0.872 0.000 0.128
#> GSM26851     2  0.0000      0.999 0.000 1.000 0.000
#> GSM26852     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26853     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26854     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26855     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26856     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26857     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26858     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26859     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26860     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26861     3  0.0237      1.000 0.004 0.000 0.996
#> GSM26862     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26863     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26864     1  0.0000      0.938 1.000 0.000 0.000
#> GSM26865     1  0.2878      0.877 0.904 0.000 0.096
#> GSM26866     1  0.0000      0.938 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26806     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26807     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26808     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26809     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26810     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26811     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26812     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26813     4  0.4277      0.598 0.000 0.280 0.000 0.720
#> GSM26814     2  0.3873      0.712 0.000 0.772 0.000 0.228
#> GSM26815     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26816     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26817     4  0.0707      0.959 0.000 0.020 0.000 0.980
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26819     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26824     2  0.3837      0.718 0.000 0.776 0.000 0.224
#> GSM26825     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26830     2  0.3873      0.712 0.000 0.772 0.000 0.228
#> GSM26831     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26833     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26834     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.914 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0188      0.913 0.996 0.000 0.000 0.004
#> GSM26838     1  0.0000      0.914 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0000      0.914 1.000 0.000 0.000 0.000
#> GSM26840     1  0.4053      0.683 0.768 0.228 0.000 0.004
#> GSM26841     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> GSM26842     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> GSM26843     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> GSM26844     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> GSM26845     1  0.4843      0.362 0.604 0.396 0.000 0.000
#> GSM26846     1  0.5203      0.493 0.636 0.000 0.348 0.016
#> GSM26847     1  0.0592      0.909 0.984 0.000 0.000 0.016
#> GSM26848     1  0.2300      0.876 0.920 0.000 0.064 0.016
#> GSM26849     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26850     1  0.3547      0.812 0.840 0.000 0.144 0.016
#> GSM26851     2  0.0000      0.964 0.000 1.000 0.000 0.000
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0188      0.913 0.996 0.000 0.000 0.004
#> GSM26863     1  0.0000      0.914 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0188      0.914 0.996 0.000 0.000 0.004
#> GSM26865     1  0.3108      0.842 0.872 0.000 0.112 0.016
#> GSM26866     1  0.0188      0.914 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26806     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2  0.1043      0.945 0.000 0.960 0.000 0.000 0.040
#> GSM26810     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26813     4  0.4193      0.521 0.000 0.304 0.000 0.684 0.012
#> GSM26814     2  0.3563      0.724 0.000 0.780 0.000 0.208 0.012
#> GSM26815     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26817     4  0.0000      0.943 0.000 0.000 0.000 1.000 0.000
#> GSM26818     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26819     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26820     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.0404      0.938 0.000 0.988 0.000 0.000 0.012
#> GSM26822     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26823     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.3496      0.736 0.000 0.788 0.000 0.200 0.012
#> GSM26825     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26829     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26830     2  0.3563      0.724 0.000 0.780 0.000 0.208 0.012
#> GSM26831     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26832     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26833     2  0.1341      0.943 0.000 0.944 0.000 0.000 0.056
#> GSM26834     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26835     2  0.1270      0.944 0.000 0.948 0.000 0.000 0.052
#> GSM26836     1  0.2280      0.841 0.880 0.000 0.000 0.000 0.120
#> GSM26837     1  0.2424      0.832 0.868 0.000 0.000 0.000 0.132
#> GSM26838     1  0.0510      0.872 0.984 0.000 0.000 0.000 0.016
#> GSM26839     1  0.2230      0.843 0.884 0.000 0.000 0.000 0.116
#> GSM26840     1  0.3596      0.623 0.784 0.200 0.000 0.000 0.016
#> GSM26841     1  0.0162      0.873 0.996 0.000 0.000 0.000 0.004
#> GSM26842     1  0.0162      0.873 0.996 0.000 0.000 0.000 0.004
#> GSM26843     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.4675      0.354 0.600 0.380 0.000 0.000 0.020
#> GSM26846     5  0.1836      0.956 0.036 0.000 0.032 0.000 0.932
#> GSM26847     5  0.1544      0.983 0.068 0.000 0.000 0.000 0.932
#> GSM26848     5  0.1638      0.988 0.064 0.000 0.004 0.000 0.932
#> GSM26849     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26850     5  0.1638      0.988 0.064 0.000 0.004 0.000 0.932
#> GSM26851     2  0.1121      0.944 0.000 0.956 0.000 0.000 0.044
#> GSM26852     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.2377      0.836 0.872 0.000 0.000 0.000 0.128
#> GSM26863     1  0.2230      0.843 0.884 0.000 0.000 0.000 0.116
#> GSM26864     1  0.0404      0.873 0.988 0.000 0.000 0.000 0.012
#> GSM26865     5  0.1638      0.988 0.064 0.000 0.004 0.000 0.932
#> GSM26866     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26806     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     5  0.2738     0.4717 0.000 0.176 0.000 0.000 0.820 0.004
#> GSM26810     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     2  0.6289     0.4520 0.000 0.456 0.000 0.276 0.252 0.016
#> GSM26814     2  0.5126     0.7544 0.000 0.544 0.000 0.052 0.388 0.016
#> GSM26815     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26817     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26818     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26819     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26820     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26821     2  0.3774     0.6642 0.000 0.592 0.000 0.000 0.408 0.000
#> GSM26822     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26823     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26824     2  0.4219     0.7204 0.000 0.592 0.000 0.020 0.388 0.000
#> GSM26825     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26826     5  0.3797     0.0221 0.000 0.420 0.000 0.000 0.580 0.000
#> GSM26827     5  0.3804     0.0129 0.000 0.424 0.000 0.000 0.576 0.000
#> GSM26828     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26829     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26830     2  0.5126     0.7544 0.000 0.544 0.000 0.052 0.388 0.016
#> GSM26831     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26832     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26833     5  0.2632     0.4025 0.000 0.164 0.000 0.000 0.832 0.004
#> GSM26834     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26835     5  0.0000     0.5968 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM26836     1  0.3534     0.7943 0.800 0.076 0.000 0.000 0.000 0.124
#> GSM26837     1  0.3575     0.7912 0.796 0.076 0.000 0.000 0.000 0.128
#> GSM26838     1  0.2277     0.8203 0.892 0.076 0.000 0.000 0.000 0.032
#> GSM26839     1  0.3534     0.7943 0.800 0.076 0.000 0.000 0.000 0.124
#> GSM26840     1  0.4756     0.5447 0.608 0.332 0.000 0.000 0.056 0.004
#> GSM26841     1  0.0547     0.8268 0.980 0.020 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0363     0.8279 0.988 0.012 0.000 0.000 0.000 0.000
#> GSM26843     1  0.1444     0.8150 0.928 0.072 0.000 0.000 0.000 0.000
#> GSM26844     1  0.1444     0.8150 0.928 0.072 0.000 0.000 0.000 0.000
#> GSM26845     1  0.6214     0.4626 0.504 0.316 0.000 0.000 0.140 0.040
#> GSM26846     6  0.0603     0.9709 0.016 0.000 0.004 0.000 0.000 0.980
#> GSM26847     6  0.2420     0.8997 0.040 0.076 0.000 0.000 0.000 0.884
#> GSM26848     6  0.0547     0.9737 0.020 0.000 0.000 0.000 0.000 0.980
#> GSM26849     3  0.0458     0.9842 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM26850     6  0.0547     0.9737 0.020 0.000 0.000 0.000 0.000 0.980
#> GSM26851     5  0.3351     0.3135 0.000 0.288 0.000 0.000 0.712 0.000
#> GSM26852     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000     0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.3534     0.7943 0.800 0.076 0.000 0.000 0.000 0.124
#> GSM26863     1  0.3534     0.7943 0.800 0.076 0.000 0.000 0.000 0.124
#> GSM26864     1  0.0000     0.8288 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26865     6  0.0632     0.9716 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM26866     1  0.1444     0.8150 0.928 0.072 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 tissue(p) individual(p) k
#> ATC:skmeans 62  3.65e-11      8.91e-01 2
#> ATC:skmeans 62  1.49e-12      1.94e-04 3
#> ATC:skmeans 60  2.34e-11      3.12e-06 4
#> ATC:skmeans 61  6.65e-11      1.89e-08 5
#> ATC:skmeans 50  8.13e-09      3.48e-09 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 62 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.994         0.5083 0.492   0.492
#> 3 3 1.000           0.966       0.987         0.2291 0.879   0.755
#> 4 4 1.000           0.945       0.963         0.1546 0.874   0.671
#> 5 5 0.873           0.838       0.879         0.0736 0.946   0.809
#> 6 6 0.869           0.812       0.875         0.0681 0.915   0.654

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3

There is also optional best \(k\) = 2 3 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette  p1  p2
#> GSM26805     2   0.000      1.000 0.0 1.0
#> GSM26806     2   0.000      1.000 0.0 1.0
#> GSM26807     2   0.000      1.000 0.0 1.0
#> GSM26808     2   0.000      1.000 0.0 1.0
#> GSM26809     2   0.000      1.000 0.0 1.0
#> GSM26810     2   0.000      1.000 0.0 1.0
#> GSM26811     2   0.000      1.000 0.0 1.0
#> GSM26812     2   0.000      1.000 0.0 1.0
#> GSM26813     2   0.000      1.000 0.0 1.0
#> GSM26814     2   0.000      1.000 0.0 1.0
#> GSM26815     2   0.000      1.000 0.0 1.0
#> GSM26816     2   0.000      1.000 0.0 1.0
#> GSM26817     2   0.000      1.000 0.0 1.0
#> GSM26818     1   0.000      0.987 1.0 0.0
#> GSM26819     2   0.000      1.000 0.0 1.0
#> GSM26820     2   0.000      1.000 0.0 1.0
#> GSM26821     2   0.000      1.000 0.0 1.0
#> GSM26822     2   0.000      1.000 0.0 1.0
#> GSM26823     2   0.000      1.000 0.0 1.0
#> GSM26824     2   0.000      1.000 0.0 1.0
#> GSM26825     2   0.000      1.000 0.0 1.0
#> GSM26826     2   0.000      1.000 0.0 1.0
#> GSM26827     2   0.000      1.000 0.0 1.0
#> GSM26828     2   0.000      1.000 0.0 1.0
#> GSM26829     2   0.000      1.000 0.0 1.0
#> GSM26830     2   0.000      1.000 0.0 1.0
#> GSM26831     2   0.000      1.000 0.0 1.0
#> GSM26832     2   0.000      1.000 0.0 1.0
#> GSM26833     2   0.000      1.000 0.0 1.0
#> GSM26834     2   0.000      1.000 0.0 1.0
#> GSM26835     2   0.000      1.000 0.0 1.0
#> GSM26836     1   0.000      0.987 1.0 0.0
#> GSM26837     1   0.000      0.987 1.0 0.0
#> GSM26838     1   0.000      0.987 1.0 0.0
#> GSM26839     1   0.000      0.987 1.0 0.0
#> GSM26840     1   0.722      0.758 0.8 0.2
#> GSM26841     1   0.000      0.987 1.0 0.0
#> GSM26842     1   0.000      0.987 1.0 0.0
#> GSM26843     1   0.000      0.987 1.0 0.0
#> GSM26844     1   0.000      0.987 1.0 0.0
#> GSM26845     1   0.722      0.758 0.8 0.2
#> GSM26846     1   0.000      0.987 1.0 0.0
#> GSM26847     1   0.000      0.987 1.0 0.0
#> GSM26848     1   0.000      0.987 1.0 0.0
#> GSM26849     1   0.000      0.987 1.0 0.0
#> GSM26850     1   0.000      0.987 1.0 0.0
#> GSM26851     2   0.000      1.000 0.0 1.0
#> GSM26852     1   0.000      0.987 1.0 0.0
#> GSM26853     1   0.000      0.987 1.0 0.0
#> GSM26854     1   0.000      0.987 1.0 0.0
#> GSM26855     1   0.000      0.987 1.0 0.0
#> GSM26856     1   0.000      0.987 1.0 0.0
#> GSM26857     1   0.000      0.987 1.0 0.0
#> GSM26858     1   0.000      0.987 1.0 0.0
#> GSM26859     1   0.000      0.987 1.0 0.0
#> GSM26860     1   0.000      0.987 1.0 0.0
#> GSM26861     1   0.000      0.987 1.0 0.0
#> GSM26862     1   0.000      0.987 1.0 0.0
#> GSM26863     1   0.000      0.987 1.0 0.0
#> GSM26864     1   0.000      0.987 1.0 0.0
#> GSM26865     1   0.000      0.987 1.0 0.0
#> GSM26866     1   0.000      0.987 1.0 0.0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette  p1  p2  p3
#> GSM26805     2   0.000      1.000 0.0 1.0 0.0
#> GSM26806     2   0.000      1.000 0.0 1.0 0.0
#> GSM26807     2   0.000      1.000 0.0 1.0 0.0
#> GSM26808     2   0.000      1.000 0.0 1.0 0.0
#> GSM26809     2   0.000      1.000 0.0 1.0 0.0
#> GSM26810     2   0.000      1.000 0.0 1.0 0.0
#> GSM26811     2   0.000      1.000 0.0 1.0 0.0
#> GSM26812     2   0.000      1.000 0.0 1.0 0.0
#> GSM26813     2   0.000      1.000 0.0 1.0 0.0
#> GSM26814     2   0.000      1.000 0.0 1.0 0.0
#> GSM26815     2   0.000      1.000 0.0 1.0 0.0
#> GSM26816     2   0.000      1.000 0.0 1.0 0.0
#> GSM26817     2   0.000      1.000 0.0 1.0 0.0
#> GSM26818     3   0.000      0.963 0.0 0.0 1.0
#> GSM26819     2   0.000      1.000 0.0 1.0 0.0
#> GSM26820     2   0.000      1.000 0.0 1.0 0.0
#> GSM26821     2   0.000      1.000 0.0 1.0 0.0
#> GSM26822     2   0.000      1.000 0.0 1.0 0.0
#> GSM26823     2   0.000      1.000 0.0 1.0 0.0
#> GSM26824     2   0.000      1.000 0.0 1.0 0.0
#> GSM26825     2   0.000      1.000 0.0 1.0 0.0
#> GSM26826     2   0.000      1.000 0.0 1.0 0.0
#> GSM26827     2   0.000      1.000 0.0 1.0 0.0
#> GSM26828     2   0.000      1.000 0.0 1.0 0.0
#> GSM26829     2   0.000      1.000 0.0 1.0 0.0
#> GSM26830     2   0.000      1.000 0.0 1.0 0.0
#> GSM26831     2   0.000      1.000 0.0 1.0 0.0
#> GSM26832     2   0.000      1.000 0.0 1.0 0.0
#> GSM26833     2   0.000      1.000 0.0 1.0 0.0
#> GSM26834     2   0.000      1.000 0.0 1.0 0.0
#> GSM26835     2   0.000      1.000 0.0 1.0 0.0
#> GSM26836     1   0.000      0.970 1.0 0.0 0.0
#> GSM26837     1   0.000      0.970 1.0 0.0 0.0
#> GSM26838     1   0.000      0.970 1.0 0.0 0.0
#> GSM26839     1   0.000      0.970 1.0 0.0 0.0
#> GSM26840     1   0.455      0.723 0.8 0.2 0.0
#> GSM26841     1   0.000      0.970 1.0 0.0 0.0
#> GSM26842     1   0.000      0.970 1.0 0.0 0.0
#> GSM26843     1   0.000      0.970 1.0 0.0 0.0
#> GSM26844     1   0.000      0.970 1.0 0.0 0.0
#> GSM26845     1   0.455      0.723 0.8 0.2 0.0
#> GSM26846     1   0.000      0.970 1.0 0.0 0.0
#> GSM26847     1   0.000      0.970 1.0 0.0 0.0
#> GSM26848     1   0.000      0.970 1.0 0.0 0.0
#> GSM26849     3   0.613      0.345 0.4 0.0 0.6
#> GSM26850     1   0.000      0.970 1.0 0.0 0.0
#> GSM26851     2   0.000      1.000 0.0 1.0 0.0
#> GSM26852     3   0.000      0.963 0.0 0.0 1.0
#> GSM26853     3   0.000      0.963 0.0 0.0 1.0
#> GSM26854     3   0.000      0.963 0.0 0.0 1.0
#> GSM26855     3   0.000      0.963 0.0 0.0 1.0
#> GSM26856     3   0.000      0.963 0.0 0.0 1.0
#> GSM26857     3   0.000      0.963 0.0 0.0 1.0
#> GSM26858     3   0.000      0.963 0.0 0.0 1.0
#> GSM26859     3   0.000      0.963 0.0 0.0 1.0
#> GSM26860     3   0.000      0.963 0.0 0.0 1.0
#> GSM26861     3   0.000      0.963 0.0 0.0 1.0
#> GSM26862     1   0.000      0.970 1.0 0.0 0.0
#> GSM26863     1   0.000      0.970 1.0 0.0 0.0
#> GSM26864     1   0.000      0.970 1.0 0.0 0.0
#> GSM26865     1   0.000      0.970 1.0 0.0 0.0
#> GSM26866     1   0.000      0.970 1.0 0.0 0.0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26806     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26807     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26808     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26809     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26810     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26811     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26812     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26813     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26814     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26815     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26816     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26817     4  0.2149      0.967 0.000 0.088 0.000 0.912
#> GSM26818     3  0.2342      0.890 0.008 0.000 0.912 0.080
#> GSM26819     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26820     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26821     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26822     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26823     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26824     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26825     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26830     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26831     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26833     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26834     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM26836     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM26837     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM26838     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26839     1  0.0188      0.951 0.996 0.000 0.000 0.004
#> GSM26840     2  0.1302      0.945 0.000 0.956 0.000 0.044
#> GSM26841     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26842     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26843     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26844     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26845     1  0.4855      0.343 0.600 0.400 0.000 0.000
#> GSM26846     1  0.2011      0.915 0.920 0.000 0.000 0.080
#> GSM26847     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM26848     1  0.2011      0.915 0.920 0.000 0.000 0.080
#> GSM26849     3  0.6299      0.440 0.320 0.000 0.600 0.080
#> GSM26850     1  0.2011      0.915 0.920 0.000 0.000 0.080
#> GSM26851     4  0.4356      0.709 0.000 0.292 0.000 0.708
#> GSM26852     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26856     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26857     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.953 0.000 0.000 1.000 0.000
#> GSM26862     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM26863     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM26864     1  0.0336      0.951 0.992 0.000 0.000 0.008
#> GSM26865     1  0.2011      0.915 0.920 0.000 0.000 0.080
#> GSM26866     1  0.0336      0.951 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26806     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26807     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26808     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26809     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26810     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26811     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26812     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26813     2  0.0162      0.813 0.000 0.996 0.000 0.000 0.004
#> GSM26814     2  0.1965      0.820 0.000 0.904 0.000 0.000 0.096
#> GSM26815     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26816     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26817     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM26818     3  0.3109      0.742 0.000 0.000 0.800 0.000 0.200
#> GSM26819     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26820     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26821     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26822     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26823     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26824     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26825     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26826     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26827     2  0.3913      0.819 0.000 0.676 0.000 0.000 0.324
#> GSM26828     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26830     2  0.3707      0.822 0.000 0.716 0.000 0.000 0.284
#> GSM26831     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26833     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26834     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26835     2  0.0000      0.812 0.000 1.000 0.000 0.000 0.000
#> GSM26836     1  0.1792      0.841 0.916 0.000 0.000 0.000 0.084
#> GSM26837     1  0.1908      0.834 0.908 0.000 0.000 0.000 0.092
#> GSM26838     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> GSM26839     1  0.0880      0.857 0.968 0.000 0.000 0.000 0.032
#> GSM26840     2  0.5287      0.759 0.092 0.648 0.000 0.000 0.260
#> GSM26841     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> GSM26843     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000      0.858 1.000 0.000 0.000 0.000 0.000
#> GSM26845     1  0.5221      0.117 0.552 0.400 0.000 0.000 0.048
#> GSM26846     5  0.3913      0.822 0.324 0.000 0.000 0.000 0.676
#> GSM26847     1  0.1965      0.831 0.904 0.000 0.000 0.000 0.096
#> GSM26848     5  0.3913      0.822 0.324 0.000 0.000 0.000 0.676
#> GSM26849     5  0.3913      0.312 0.000 0.000 0.324 0.000 0.676
#> GSM26850     5  0.3913      0.822 0.324 0.000 0.000 0.000 0.676
#> GSM26851     2  0.4161      0.146 0.000 0.608 0.000 0.392 0.000
#> GSM26852     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26856     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26857     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26860     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.979 0.000 0.000 1.000 0.000 0.000
#> GSM26862     1  0.1792      0.841 0.916 0.000 0.000 0.000 0.084
#> GSM26863     1  0.1792      0.841 0.916 0.000 0.000 0.000 0.084
#> GSM26864     1  0.2690      0.652 0.844 0.000 0.000 0.000 0.156
#> GSM26865     5  0.3913      0.822 0.324 0.000 0.000 0.000 0.676
#> GSM26866     1  0.0794      0.842 0.972 0.000 0.000 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26806     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26807     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26808     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26809     2  0.0363     0.9383 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26810     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26811     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26812     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26813     5  0.2854     0.9076 0.000 0.208 0.000 0.000 0.792 0.000
#> GSM26814     5  0.3547     0.7400 0.000 0.332 0.000 0.000 0.668 0.000
#> GSM26815     4  0.0000     0.9993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM26816     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26817     4  0.0146     0.9950 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM26818     3  0.2793     0.7581 0.000 0.000 0.800 0.000 0.000 0.200
#> GSM26819     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26820     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26822     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26823     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26824     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26825     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0363     0.9383 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM26827     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26828     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26829     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26830     2  0.3647     0.1444 0.000 0.640 0.000 0.000 0.360 0.000
#> GSM26831     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26832     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26833     5  0.2854     0.9076 0.000 0.208 0.000 0.000 0.792 0.000
#> GSM26834     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26835     5  0.2762     0.9152 0.000 0.196 0.000 0.000 0.804 0.000
#> GSM26836     1  0.0790     0.6305 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM26837     1  0.0865     0.6268 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM26838     1  0.2969     0.6432 0.776 0.000 0.000 0.000 0.000 0.224
#> GSM26839     1  0.0000     0.6391 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26840     5  0.6418    -0.0303 0.036 0.244 0.000 0.000 0.492 0.228
#> GSM26841     1  0.5437     0.6203 0.576 0.000 0.000 0.000 0.196 0.228
#> GSM26842     1  0.5437     0.6203 0.576 0.000 0.000 0.000 0.196 0.228
#> GSM26843     1  0.5437     0.6203 0.576 0.000 0.000 0.000 0.196 0.228
#> GSM26844     1  0.5437     0.6203 0.576 0.000 0.000 0.000 0.196 0.228
#> GSM26845     1  0.5866     0.1678 0.576 0.196 0.000 0.000 0.204 0.024
#> GSM26846     6  0.2996     0.8340 0.228 0.000 0.000 0.000 0.000 0.772
#> GSM26847     1  0.0937     0.6224 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM26848     6  0.2969     0.8345 0.224 0.000 0.000 0.000 0.000 0.776
#> GSM26849     6  0.3109     0.8329 0.224 0.000 0.004 0.000 0.000 0.772
#> GSM26850     6  0.2996     0.8340 0.228 0.000 0.000 0.000 0.000 0.772
#> GSM26851     5  0.3110     0.9006 0.000 0.196 0.000 0.012 0.792 0.000
#> GSM26852     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26858     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26859     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26860     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26861     3  0.0000     0.9799 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26862     1  0.0790     0.6305 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM26863     1  0.0790     0.6305 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM26864     6  0.5634    -0.3419 0.336 0.000 0.000 0.000 0.164 0.500
#> GSM26865     6  0.2969     0.8345 0.224 0.000 0.000 0.000 0.000 0.776
#> GSM26866     1  0.5662     0.5708 0.524 0.000 0.000 0.000 0.196 0.280

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)
#> Error in mat[ceiling(1:nr/h_ratio), ceiling(1:nc/w_ratio), drop = FALSE]: subscript out of bounds

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n tissue(p) individual(p) k
#> ATC:pam 62  1.14e-12      8.30e-01 2
#> ATC:pam 61  2.42e-12      8.63e-05 3
#> ATC:pam 60  1.32e-10      4.12e-06 4
#> ATC:pam 59  1.74e-10      3.95e-07 5
#> ATC:pam 58  1.00e-09      2.43e-11 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 62 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 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-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.715           0.850       0.919         0.4442 0.535   0.535
#> 3 3 0.807           0.928       0.958         0.4010 0.611   0.402
#> 4 4 0.844           0.807       0.914         0.1792 0.820   0.558
#> 5 5 0.747           0.770       0.874         0.0372 0.836   0.501
#> 6 6 0.861           0.830       0.891         0.0381 0.934   0.741

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
#> GSM26805     2   0.000      0.899 0.000 1.000
#> GSM26806     1   0.833      0.710 0.736 0.264
#> GSM26807     1   0.833      0.710 0.736 0.264
#> GSM26808     1   0.833      0.710 0.736 0.264
#> GSM26809     2   0.978      0.288 0.412 0.588
#> GSM26810     1   0.833      0.710 0.736 0.264
#> GSM26811     1   0.833      0.710 0.736 0.264
#> GSM26812     1   0.833      0.710 0.736 0.264
#> GSM26813     1   0.850      0.690 0.724 0.276
#> GSM26814     2   0.929      0.480 0.344 0.656
#> GSM26815     1   0.278      0.929 0.952 0.048
#> GSM26816     2   0.000      0.899 0.000 1.000
#> GSM26817     1   0.839      0.704 0.732 0.268
#> GSM26818     1   0.278      0.929 0.952 0.048
#> GSM26819     2   0.000      0.899 0.000 1.000
#> GSM26820     2   0.000      0.899 0.000 1.000
#> GSM26821     2   0.000      0.899 0.000 1.000
#> GSM26822     2   0.871      0.580 0.292 0.708
#> GSM26823     2   0.000      0.899 0.000 1.000
#> GSM26824     2   0.000      0.899 0.000 1.000
#> GSM26825     2   0.000      0.899 0.000 1.000
#> GSM26826     2   0.000      0.899 0.000 1.000
#> GSM26827     2   0.000      0.899 0.000 1.000
#> GSM26828     2   0.000      0.899 0.000 1.000
#> GSM26829     2   0.000      0.899 0.000 1.000
#> GSM26830     2   0.921      0.499 0.336 0.664
#> GSM26831     2   0.000      0.899 0.000 1.000
#> GSM26832     2   0.000      0.899 0.000 1.000
#> GSM26833     2   0.402      0.839 0.080 0.920
#> GSM26834     2   0.000      0.899 0.000 1.000
#> GSM26835     2   0.000      0.899 0.000 1.000
#> GSM26836     1   0.278      0.929 0.952 0.048
#> GSM26837     1   0.278      0.929 0.952 0.048
#> GSM26838     1   0.278      0.929 0.952 0.048
#> GSM26839     1   0.278      0.929 0.952 0.048
#> GSM26840     1   0.278      0.929 0.952 0.048
#> GSM26841     1   0.278      0.929 0.952 0.048
#> GSM26842     1   0.278      0.929 0.952 0.048
#> GSM26843     1   0.278      0.929 0.952 0.048
#> GSM26844     1   0.278      0.929 0.952 0.048
#> GSM26845     1   0.278      0.929 0.952 0.048
#> GSM26846     1   0.278      0.929 0.952 0.048
#> GSM26847     1   0.278      0.929 0.952 0.048
#> GSM26848     1   0.278      0.929 0.952 0.048
#> GSM26849     1   0.278      0.929 0.952 0.048
#> GSM26850     1   0.278      0.929 0.952 0.048
#> GSM26851     2   0.921      0.499 0.336 0.664
#> GSM26852     1   0.000      0.906 1.000 0.000
#> GSM26853     1   0.000      0.906 1.000 0.000
#> GSM26854     1   0.000      0.906 1.000 0.000
#> GSM26855     1   0.000      0.906 1.000 0.000
#> GSM26856     1   0.000      0.906 1.000 0.000
#> GSM26857     1   0.000      0.906 1.000 0.000
#> GSM26858     1   0.000      0.906 1.000 0.000
#> GSM26859     1   0.000      0.906 1.000 0.000
#> GSM26860     1   0.000      0.906 1.000 0.000
#> GSM26861     1   0.000      0.906 1.000 0.000
#> GSM26862     1   0.278      0.929 0.952 0.048
#> GSM26863     1   0.278      0.929 0.952 0.048
#> GSM26864     1   0.278      0.929 0.952 0.048
#> GSM26865     1   0.278      0.929 0.952 0.048
#> GSM26866     1   0.278      0.929 0.952 0.048

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26806     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26807     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26808     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26809     2  0.2448      0.896 0.076 0.924 0.000
#> GSM26810     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26811     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26812     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26813     2  0.4121      0.849 0.168 0.832 0.000
#> GSM26814     2  0.2066      0.903 0.060 0.940 0.000
#> GSM26815     2  0.4750      0.813 0.216 0.784 0.000
#> GSM26816     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26817     2  0.4654      0.822 0.208 0.792 0.000
#> GSM26818     3  0.3879      0.806 0.152 0.000 0.848
#> GSM26819     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26820     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26821     2  0.0424      0.918 0.008 0.992 0.000
#> GSM26822     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26823     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26824     2  0.0747      0.917 0.016 0.984 0.000
#> GSM26825     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26826     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26827     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26828     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26829     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26830     2  0.0747      0.917 0.016 0.984 0.000
#> GSM26831     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26832     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26833     2  0.0747      0.917 0.016 0.984 0.000
#> GSM26834     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26835     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26836     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26837     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26838     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26839     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26840     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26841     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26842     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26843     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26844     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26845     2  0.4750      0.813 0.216 0.784 0.000
#> GSM26846     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26847     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26848     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26849     3  0.4702      0.715 0.212 0.000 0.788
#> GSM26850     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26851     2  0.0000      0.919 0.000 1.000 0.000
#> GSM26852     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26853     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26854     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26855     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26856     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26857     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26858     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26859     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26860     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26861     3  0.0000      0.962 0.000 0.000 1.000
#> GSM26862     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26863     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26864     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26865     1  0.0000      1.000 1.000 0.000 0.000
#> GSM26866     1  0.0000      1.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26806     4  0.0592      0.776 0.000 0.016 0.000 0.984
#> GSM26807     4  0.0921      0.784 0.000 0.028 0.000 0.972
#> GSM26808     4  0.1022      0.786 0.000 0.032 0.000 0.968
#> GSM26809     4  0.7355      0.383 0.172 0.340 0.000 0.488
#> GSM26810     4  0.1022      0.786 0.000 0.032 0.000 0.968
#> GSM26811     4  0.1022      0.786 0.000 0.032 0.000 0.968
#> GSM26812     4  0.1022      0.786 0.000 0.032 0.000 0.968
#> GSM26813     4  0.4522      0.572 0.000 0.320 0.000 0.680
#> GSM26814     4  0.4804      0.471 0.000 0.384 0.000 0.616
#> GSM26815     4  0.3105      0.701 0.120 0.012 0.000 0.868
#> GSM26816     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26817     4  0.1716      0.776 0.000 0.064 0.000 0.936
#> GSM26818     1  0.6049      0.656 0.680 0.000 0.200 0.120
#> GSM26819     2  0.1022      0.841 0.000 0.968 0.000 0.032
#> GSM26820     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26821     2  0.4790      0.217 0.000 0.620 0.000 0.380
#> GSM26822     2  0.4500      0.394 0.000 0.684 0.000 0.316
#> GSM26823     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26824     4  0.4967      0.305 0.000 0.452 0.000 0.548
#> GSM26825     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26826     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26828     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26830     4  0.4888      0.411 0.000 0.412 0.000 0.588
#> GSM26831     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26833     2  0.4981     -0.106 0.000 0.536 0.000 0.464
#> GSM26834     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26835     2  0.0000      0.869 0.000 1.000 0.000 0.000
#> GSM26836     1  0.1022      0.959 0.968 0.000 0.000 0.032
#> GSM26837     1  0.0336      0.960 0.992 0.000 0.000 0.008
#> GSM26838     1  0.1118      0.958 0.964 0.000 0.000 0.036
#> GSM26839     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM26840     1  0.0188      0.959 0.996 0.000 0.000 0.004
#> GSM26841     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM26842     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM26843     1  0.0188      0.959 0.996 0.000 0.000 0.004
#> GSM26844     1  0.0188      0.959 0.996 0.000 0.000 0.004
#> GSM26845     1  0.2485      0.938 0.916 0.004 0.016 0.064
#> GSM26846     1  0.1022      0.958 0.968 0.000 0.000 0.032
#> GSM26847     1  0.1022      0.958 0.968 0.000 0.000 0.032
#> GSM26848     1  0.1489      0.954 0.952 0.000 0.004 0.044
#> GSM26849     1  0.4072      0.847 0.828 0.000 0.120 0.052
#> GSM26850     1  0.1975      0.947 0.936 0.000 0.016 0.048
#> GSM26851     2  0.4999     -0.188 0.000 0.508 0.000 0.492
#> GSM26852     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26853     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26854     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26855     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26856     3  0.3219      0.787 0.164 0.000 0.836 0.000
#> GSM26857     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26858     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26859     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26860     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26861     3  0.0000      0.978 0.000 0.000 1.000 0.000
#> GSM26862     1  0.1474      0.952 0.948 0.000 0.000 0.052
#> GSM26863     1  0.1022      0.959 0.968 0.000 0.000 0.032
#> GSM26864     1  0.0188      0.959 0.996 0.000 0.000 0.004
#> GSM26865     1  0.1576      0.952 0.948 0.000 0.004 0.048
#> GSM26866     1  0.0188      0.959 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM26805     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26806     4  0.2179      0.839 0.000 0.112 0.000 0.888 0.000
#> GSM26807     4  0.2329      0.846 0.000 0.124 0.000 0.876 0.000
#> GSM26808     4  0.2329      0.846 0.000 0.124 0.000 0.876 0.000
#> GSM26809     2  0.3980      0.809 0.056 0.824 0.000 0.028 0.092
#> GSM26810     4  0.2929      0.796 0.000 0.180 0.000 0.820 0.000
#> GSM26811     4  0.2471      0.844 0.000 0.136 0.000 0.864 0.000
#> GSM26812     4  0.2471      0.844 0.000 0.136 0.000 0.864 0.000
#> GSM26813     2  0.4169      0.690 0.000 0.732 0.000 0.240 0.028
#> GSM26814     2  0.3123      0.793 0.000 0.812 0.000 0.184 0.004
#> GSM26815     4  0.3039      0.559 0.000 0.000 0.000 0.808 0.192
#> GSM26816     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26817     2  0.4278      0.205 0.000 0.548 0.000 0.452 0.000
#> GSM26818     4  0.7437      0.152 0.072 0.000 0.264 0.488 0.176
#> GSM26819     2  0.0162      0.918 0.000 0.996 0.000 0.004 0.000
#> GSM26820     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26821     2  0.1410      0.892 0.000 0.940 0.000 0.060 0.000
#> GSM26822     2  0.0609      0.912 0.000 0.980 0.000 0.020 0.000
#> GSM26823     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26824     2  0.2690      0.823 0.000 0.844 0.000 0.156 0.000
#> GSM26825     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26826     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26827     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26828     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26829     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26830     2  0.2852      0.807 0.000 0.828 0.000 0.172 0.000
#> GSM26831     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26832     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26833     2  0.2773      0.814 0.000 0.836 0.000 0.164 0.000
#> GSM26834     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26835     2  0.0000      0.919 0.000 1.000 0.000 0.000 0.000
#> GSM26836     5  0.2813      0.795 0.168 0.000 0.000 0.000 0.832
#> GSM26837     1  0.3563      0.681 0.780 0.000 0.000 0.012 0.208
#> GSM26838     5  0.3642      0.741 0.232 0.000 0.000 0.008 0.760
#> GSM26839     1  0.2179      0.754 0.888 0.000 0.000 0.000 0.112
#> GSM26840     1  0.2020      0.699 0.900 0.000 0.000 0.000 0.100
#> GSM26841     1  0.2690      0.720 0.844 0.000 0.000 0.000 0.156
#> GSM26842     1  0.2377      0.752 0.872 0.000 0.000 0.000 0.128
#> GSM26843     1  0.0000      0.779 1.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0162      0.781 0.996 0.000 0.000 0.000 0.004
#> GSM26845     5  0.7103      0.445 0.052 0.036 0.216 0.100 0.596
#> GSM26846     5  0.2446      0.727 0.044 0.000 0.000 0.056 0.900
#> GSM26847     5  0.3276      0.782 0.132 0.000 0.000 0.032 0.836
#> GSM26848     1  0.6988      0.204 0.464 0.000 0.128 0.044 0.364
#> GSM26849     3  0.5995      0.494 0.116 0.000 0.668 0.048 0.168
#> GSM26850     3  0.7568     -0.191 0.324 0.000 0.356 0.040 0.280
#> GSM26851     2  0.0794      0.909 0.000 0.972 0.000 0.028 0.000
#> GSM26852     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26853     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26854     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0162      0.896 0.000 0.000 0.996 0.004 0.000
#> GSM26856     3  0.0912      0.881 0.016 0.000 0.972 0.000 0.012
#> GSM26857     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26859     3  0.0609      0.887 0.000 0.000 0.980 0.020 0.000
#> GSM26860     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0000      0.899 0.000 0.000 1.000 0.000 0.000
#> GSM26862     5  0.2909      0.799 0.140 0.000 0.000 0.012 0.848
#> GSM26863     5  0.3388      0.776 0.200 0.000 0.000 0.008 0.792
#> GSM26864     1  0.1121      0.782 0.956 0.000 0.000 0.000 0.044
#> GSM26865     1  0.7007      0.218 0.468 0.000 0.132 0.044 0.356
#> GSM26866     1  0.0290      0.782 0.992 0.000 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26806     4  0.0692     0.8745 0.000 0.020 0.000 0.976 0.000 0.004
#> GSM26807     4  0.0547     0.8758 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26808     4  0.0632     0.8748 0.000 0.024 0.000 0.976 0.000 0.000
#> GSM26809     2  0.4225     0.6538 0.020 0.688 0.000 0.016 0.000 0.276
#> GSM26810     4  0.0547     0.8758 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26811     4  0.0632     0.8748 0.000 0.024 0.000 0.976 0.000 0.000
#> GSM26812     4  0.0547     0.8758 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26813     2  0.3852     0.7483 0.000 0.764 0.000 0.180 0.004 0.052
#> GSM26814     2  0.2618     0.8616 0.000 0.860 0.000 0.116 0.000 0.024
#> GSM26815     4  0.3664     0.6514 0.012 0.004 0.000 0.792 0.028 0.164
#> GSM26816     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26817     4  0.3737     0.2957 0.000 0.392 0.000 0.608 0.000 0.000
#> GSM26818     3  0.7126    -0.0047 0.044 0.000 0.376 0.368 0.024 0.188
#> GSM26819     2  0.0146     0.9472 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM26820     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26821     2  0.1152     0.9266 0.000 0.952 0.000 0.044 0.000 0.004
#> GSM26822     2  0.0692     0.9411 0.000 0.976 0.000 0.004 0.000 0.020
#> GSM26823     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26824     2  0.1806     0.8975 0.000 0.908 0.000 0.088 0.000 0.004
#> GSM26825     2  0.0000     0.9482 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM26826     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26827     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26828     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26829     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26830     2  0.2165     0.8798 0.000 0.884 0.000 0.108 0.000 0.008
#> GSM26831     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26832     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26833     2  0.2053     0.8822 0.000 0.888 0.000 0.108 0.000 0.004
#> GSM26834     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26835     2  0.0146     0.9488 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM26836     5  0.1082     0.8396 0.040 0.000 0.000 0.000 0.956 0.004
#> GSM26837     5  0.2122     0.8084 0.076 0.000 0.000 0.000 0.900 0.024
#> GSM26838     5  0.2308     0.8263 0.068 0.000 0.000 0.000 0.892 0.040
#> GSM26839     5  0.4552     0.4109 0.364 0.000 0.000 0.000 0.592 0.044
#> GSM26840     1  0.3198     0.6397 0.740 0.000 0.000 0.000 0.000 0.260
#> GSM26841     1  0.2384     0.8370 0.888 0.000 0.000 0.000 0.064 0.048
#> GSM26842     1  0.2658     0.8278 0.864 0.000 0.000 0.000 0.100 0.036
#> GSM26843     1  0.0000     0.8718 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26844     1  0.0000     0.8718 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM26845     6  0.5231     0.4775 0.048 0.012 0.008 0.008 0.308 0.616
#> GSM26846     5  0.3380     0.7523 0.024 0.000 0.004 0.004 0.804 0.164
#> GSM26847     5  0.2237     0.8016 0.020 0.000 0.000 0.004 0.896 0.080
#> GSM26848     6  0.5877     0.7407 0.248 0.000 0.008 0.004 0.192 0.548
#> GSM26849     6  0.5669     0.4772 0.044 0.000 0.296 0.000 0.080 0.580
#> GSM26850     6  0.5877     0.7407 0.248 0.000 0.008 0.004 0.192 0.548
#> GSM26851     2  0.0806     0.9396 0.000 0.972 0.000 0.008 0.000 0.020
#> GSM26852     3  0.0000     0.9277 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26853     3  0.0000     0.9277 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26854     3  0.0000     0.9277 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26855     3  0.0000     0.9277 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.1088     0.8969 0.024 0.000 0.960 0.000 0.000 0.016
#> GSM26857     3  0.0146     0.9263 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26858     3  0.0146     0.9272 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26859     3  0.0146     0.9272 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26860     3  0.0146     0.9263 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26861     3  0.0146     0.9272 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26862     5  0.1605     0.8424 0.044 0.000 0.000 0.004 0.936 0.016
#> GSM26863     5  0.1461     0.8423 0.044 0.000 0.000 0.000 0.940 0.016
#> GSM26864     1  0.2537     0.8301 0.872 0.000 0.000 0.000 0.096 0.032
#> GSM26865     6  0.5812     0.7314 0.248 0.000 0.008 0.000 0.204 0.540
#> GSM26866     1  0.0146     0.8724 0.996 0.000 0.000 0.000 0.004 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n tissue(p) individual(p) k
#> ATC:mclust 58  5.61e-07      3.48e-03 2
#> ATC:mclust 62  9.16e-12      1.83e-04 3
#> ATC:mclust 54  7.45e-11      9.18e-08 4
#> ATC:mclust 55  2.06e-10      1.02e-06 5
#> ATC:mclust 57  3.10e-10      1.28e-06 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 62 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 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-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.5066 0.494   0.494
#> 3 3 0.772           0.827       0.926         0.2686 0.792   0.603
#> 4 4 0.910           0.916       0.948         0.1702 0.789   0.469
#> 5 5 0.761           0.722       0.862         0.0366 0.884   0.608
#> 6 6 0.781           0.696       0.813         0.0489 0.893   0.582

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2

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
#> GSM26805     2       0          1  0  1
#> GSM26806     2       0          1  0  1
#> GSM26807     2       0          1  0  1
#> GSM26808     2       0          1  0  1
#> GSM26809     2       0          1  0  1
#> GSM26810     2       0          1  0  1
#> GSM26811     2       0          1  0  1
#> GSM26812     2       0          1  0  1
#> GSM26813     2       0          1  0  1
#> GSM26814     2       0          1  0  1
#> GSM26815     2       0          1  0  1
#> GSM26816     2       0          1  0  1
#> GSM26817     2       0          1  0  1
#> GSM26818     1       0          1  1  0
#> GSM26819     2       0          1  0  1
#> GSM26820     2       0          1  0  1
#> GSM26821     2       0          1  0  1
#> GSM26822     2       0          1  0  1
#> GSM26823     2       0          1  0  1
#> GSM26824     2       0          1  0  1
#> GSM26825     2       0          1  0  1
#> GSM26826     2       0          1  0  1
#> GSM26827     2       0          1  0  1
#> GSM26828     2       0          1  0  1
#> GSM26829     2       0          1  0  1
#> GSM26830     2       0          1  0  1
#> GSM26831     2       0          1  0  1
#> GSM26832     2       0          1  0  1
#> GSM26833     2       0          1  0  1
#> GSM26834     2       0          1  0  1
#> GSM26835     2       0          1  0  1
#> GSM26836     1       0          1  1  0
#> GSM26837     1       0          1  1  0
#> GSM26838     1       0          1  1  0
#> GSM26839     1       0          1  1  0
#> GSM26840     2       0          1  0  1
#> GSM26841     1       0          1  1  0
#> GSM26842     1       0          1  1  0
#> GSM26843     1       0          1  1  0
#> GSM26844     1       0          1  1  0
#> GSM26845     2       0          1  0  1
#> GSM26846     1       0          1  1  0
#> GSM26847     1       0          1  1  0
#> GSM26848     1       0          1  1  0
#> GSM26849     1       0          1  1  0
#> GSM26850     1       0          1  1  0
#> GSM26851     2       0          1  0  1
#> GSM26852     1       0          1  1  0
#> GSM26853     1       0          1  1  0
#> GSM26854     1       0          1  1  0
#> GSM26855     1       0          1  1  0
#> GSM26856     1       0          1  1  0
#> GSM26857     1       0          1  1  0
#> GSM26858     1       0          1  1  0
#> GSM26859     1       0          1  1  0
#> GSM26860     1       0          1  1  0
#> GSM26861     1       0          1  1  0
#> GSM26862     1       0          1  1  0
#> GSM26863     1       0          1  1  0
#> GSM26864     1       0          1  1  0
#> GSM26865     1       0          1  1  0
#> GSM26866     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM26805     2  0.3192     0.8448 0.112 0.888 0.000
#> GSM26806     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26807     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26808     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26809     1  0.4346     0.7152 0.816 0.184 0.000
#> GSM26810     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26811     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26812     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26813     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26814     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26815     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26816     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26817     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26818     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26819     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26820     2  0.0237     0.9643 0.004 0.996 0.000
#> GSM26821     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26822     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26823     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26824     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26825     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26826     1  0.6280     0.1976 0.540 0.460 0.000
#> GSM26827     2  0.0892     0.9495 0.020 0.980 0.000
#> GSM26828     1  0.5016     0.6672 0.760 0.240 0.000
#> GSM26829     2  0.4002     0.7777 0.160 0.840 0.000
#> GSM26830     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26831     2  0.6302    -0.0486 0.480 0.520 0.000
#> GSM26832     2  0.0237     0.9643 0.004 0.996 0.000
#> GSM26833     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26834     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26835     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26836     1  0.4121     0.7884 0.832 0.000 0.168
#> GSM26837     3  0.3482     0.7852 0.128 0.000 0.872
#> GSM26838     1  0.0237     0.8115 0.996 0.000 0.004
#> GSM26839     1  0.6079     0.3944 0.612 0.000 0.388
#> GSM26840     1  0.0000     0.8096 1.000 0.000 0.000
#> GSM26841     1  0.1031     0.8167 0.976 0.000 0.024
#> GSM26842     1  0.2625     0.8189 0.916 0.000 0.084
#> GSM26843     1  0.0592     0.8142 0.988 0.000 0.012
#> GSM26844     1  0.2959     0.8167 0.900 0.000 0.100
#> GSM26845     1  0.0000     0.8096 1.000 0.000 0.000
#> GSM26846     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26847     3  0.5363     0.5823 0.276 0.000 0.724
#> GSM26848     3  0.6291     0.0364 0.468 0.000 0.532
#> GSM26849     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26850     3  0.4887     0.6606 0.228 0.000 0.772
#> GSM26851     2  0.0000     0.9673 0.000 1.000 0.000
#> GSM26852     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26853     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26854     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26855     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26856     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26857     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26858     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26859     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26860     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26861     3  0.0000     0.8923 0.000 0.000 1.000
#> GSM26862     1  0.4605     0.7515 0.796 0.000 0.204
#> GSM26863     1  0.4121     0.7884 0.832 0.000 0.168
#> GSM26864     1  0.4235     0.7818 0.824 0.000 0.176
#> GSM26865     3  0.6079     0.3185 0.388 0.000 0.612
#> GSM26866     1  0.3551     0.8068 0.868 0.000 0.132

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM26805     2  0.0000      0.984 0.000 1.000 0.000 0.000
#> GSM26806     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26807     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26808     4  0.1118      0.923 0.000 0.036 0.000 0.964
#> GSM26809     2  0.0000      0.984 0.000 1.000 0.000 0.000
#> GSM26810     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26811     4  0.1118      0.923 0.000 0.036 0.000 0.964
#> GSM26812     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26813     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26814     4  0.1940      0.910 0.000 0.076 0.000 0.924
#> GSM26815     4  0.0592      0.893 0.000 0.000 0.016 0.984
#> GSM26816     2  0.0817      0.981 0.000 0.976 0.000 0.024
#> GSM26817     4  0.1022      0.923 0.000 0.032 0.000 0.968
#> GSM26818     3  0.0592      0.937 0.000 0.000 0.984 0.016
#> GSM26819     2  0.0707      0.984 0.000 0.980 0.000 0.020
#> GSM26820     2  0.0469      0.987 0.000 0.988 0.000 0.012
#> GSM26821     4  0.4877      0.454 0.000 0.408 0.000 0.592
#> GSM26822     2  0.0817      0.981 0.000 0.976 0.000 0.024
#> GSM26823     2  0.0469      0.987 0.000 0.988 0.000 0.012
#> GSM26824     4  0.2011      0.909 0.000 0.080 0.000 0.920
#> GSM26825     2  0.0592      0.986 0.000 0.984 0.000 0.016
#> GSM26826     2  0.0000      0.984 0.000 1.000 0.000 0.000
#> GSM26827     2  0.0336      0.986 0.000 0.992 0.000 0.008
#> GSM26828     2  0.0000      0.984 0.000 1.000 0.000 0.000
#> GSM26829     2  0.0336      0.986 0.000 0.992 0.000 0.008
#> GSM26830     4  0.3311      0.843 0.000 0.172 0.000 0.828
#> GSM26831     2  0.0000      0.984 0.000 1.000 0.000 0.000
#> GSM26832     2  0.0707      0.984 0.000 0.980 0.000 0.020
#> GSM26833     4  0.3356      0.840 0.000 0.176 0.000 0.824
#> GSM26834     2  0.0817      0.981 0.000 0.976 0.000 0.024
#> GSM26835     2  0.0469      0.987 0.000 0.988 0.000 0.012
#> GSM26836     1  0.0469      0.948 0.988 0.000 0.012 0.000
#> GSM26837     1  0.0707      0.946 0.980 0.000 0.020 0.000
#> GSM26838     1  0.0000      0.944 1.000 0.000 0.000 0.000
#> GSM26839     1  0.0592      0.948 0.984 0.000 0.016 0.000
#> GSM26840     2  0.1771      0.934 0.036 0.948 0.004 0.012
#> GSM26841     1  0.0376      0.946 0.992 0.004 0.004 0.000
#> GSM26842     1  0.0188      0.946 0.996 0.000 0.004 0.000
#> GSM26843     1  0.0672      0.946 0.984 0.008 0.008 0.000
#> GSM26844     1  0.0524      0.947 0.988 0.004 0.008 0.000
#> GSM26845     1  0.3455      0.833 0.852 0.132 0.004 0.012
#> GSM26846     1  0.3757      0.821 0.828 0.000 0.152 0.020
#> GSM26847     1  0.0592      0.948 0.984 0.000 0.016 0.000
#> GSM26848     1  0.3668      0.775 0.808 0.004 0.188 0.000
#> GSM26849     3  0.0469      0.956 0.012 0.000 0.988 0.000
#> GSM26850     3  0.0779      0.954 0.016 0.000 0.980 0.004
#> GSM26851     4  0.4134      0.739 0.000 0.260 0.000 0.740
#> GSM26852     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26853     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26854     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26855     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26856     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26857     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26858     3  0.0817      0.954 0.024 0.000 0.976 0.000
#> GSM26859     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26860     3  0.0592      0.959 0.016 0.000 0.984 0.000
#> GSM26861     3  0.0707      0.957 0.020 0.000 0.980 0.000
#> GSM26862     1  0.0592      0.948 0.984 0.000 0.016 0.000
#> GSM26863     1  0.0592      0.948 0.984 0.000 0.016 0.000
#> GSM26864     1  0.0469      0.948 0.988 0.000 0.012 0.000
#> GSM26865     3  0.5132      0.111 0.448 0.004 0.548 0.000
#> GSM26866     1  0.3881      0.791 0.812 0.172 0.016 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
#> GSM26805     2  0.3452      0.536 0.000 0.756 0.000 0.000 0.244
#> GSM26806     4  0.0404      0.910 0.000 0.000 0.000 0.988 0.012
#> GSM26807     4  0.0609      0.924 0.000 0.020 0.000 0.980 0.000
#> GSM26808     4  0.0963      0.920 0.000 0.036 0.000 0.964 0.000
#> GSM26809     5  0.4278      0.233 0.000 0.452 0.000 0.000 0.548
#> GSM26810     4  0.0162      0.919 0.000 0.004 0.000 0.996 0.000
#> GSM26811     4  0.0880      0.922 0.000 0.032 0.000 0.968 0.000
#> GSM26812     4  0.0510      0.924 0.000 0.016 0.000 0.984 0.000
#> GSM26813     2  0.4420      0.275 0.000 0.548 0.000 0.448 0.004
#> GSM26814     2  0.3579      0.628 0.000 0.756 0.000 0.240 0.004
#> GSM26815     4  0.0880      0.892 0.000 0.000 0.000 0.968 0.032
#> GSM26816     2  0.2233      0.737 0.000 0.904 0.000 0.016 0.080
#> GSM26817     4  0.1410      0.902 0.000 0.060 0.000 0.940 0.000
#> GSM26818     3  0.2068      0.900 0.000 0.000 0.904 0.004 0.092
#> GSM26819     2  0.1444      0.756 0.000 0.948 0.000 0.040 0.012
#> GSM26820     2  0.0794      0.758 0.000 0.972 0.000 0.028 0.000
#> GSM26821     2  0.3010      0.685 0.000 0.824 0.000 0.172 0.004
#> GSM26822     2  0.3090      0.699 0.000 0.856 0.000 0.040 0.104
#> GSM26823     2  0.0955      0.758 0.000 0.968 0.000 0.028 0.004
#> GSM26824     2  0.4367      0.343 0.000 0.580 0.000 0.416 0.004
#> GSM26825     2  0.1485      0.754 0.000 0.948 0.000 0.032 0.020
#> GSM26826     2  0.0162      0.754 0.000 0.996 0.000 0.000 0.004
#> GSM26827     2  0.0771      0.758 0.000 0.976 0.000 0.020 0.004
#> GSM26828     2  0.2280      0.698 0.000 0.880 0.000 0.000 0.120
#> GSM26829     2  0.1478      0.733 0.000 0.936 0.000 0.000 0.064
#> GSM26830     2  0.3461      0.643 0.000 0.772 0.000 0.224 0.004
#> GSM26831     2  0.1671      0.728 0.000 0.924 0.000 0.000 0.076
#> GSM26832     2  0.2286      0.711 0.000 0.888 0.000 0.004 0.108
#> GSM26833     2  0.4321      0.452 0.000 0.600 0.000 0.396 0.004
#> GSM26834     2  0.3282      0.622 0.000 0.804 0.000 0.008 0.188
#> GSM26835     2  0.3424      0.538 0.000 0.760 0.000 0.000 0.240
#> GSM26836     1  0.1043      0.798 0.960 0.000 0.000 0.000 0.040
#> GSM26837     1  0.1270      0.797 0.948 0.000 0.000 0.000 0.052
#> GSM26838     1  0.0290      0.800 0.992 0.000 0.000 0.000 0.008
#> GSM26839     1  0.0963      0.795 0.964 0.000 0.000 0.000 0.036
#> GSM26840     5  0.5304      0.495 0.080 0.292 0.000 0.000 0.628
#> GSM26841     1  0.1410      0.786 0.940 0.000 0.000 0.000 0.060
#> GSM26842     1  0.1197      0.790 0.952 0.000 0.000 0.000 0.048
#> GSM26843     1  0.4954      0.322 0.616 0.020 0.012 0.000 0.352
#> GSM26844     1  0.4296      0.555 0.720 0.012 0.012 0.000 0.256
#> GSM26845     1  0.4558      0.552 0.740 0.180 0.000 0.000 0.080
#> GSM26846     1  0.6606      0.495 0.596 0.044 0.120 0.004 0.236
#> GSM26847     1  0.1732      0.784 0.920 0.000 0.000 0.000 0.080
#> GSM26848     1  0.5082      0.618 0.684 0.000 0.096 0.000 0.220
#> GSM26849     3  0.2813      0.845 0.000 0.000 0.832 0.000 0.168
#> GSM26850     3  0.4377      0.773 0.048 0.008 0.760 0.000 0.184
#> GSM26851     4  0.5265      0.470 0.000 0.284 0.000 0.636 0.080
#> GSM26852     3  0.0404      0.951 0.000 0.000 0.988 0.000 0.012
#> GSM26853     3  0.0404      0.951 0.000 0.000 0.988 0.000 0.012
#> GSM26854     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> GSM26855     3  0.0404      0.951 0.000 0.000 0.988 0.000 0.012
#> GSM26856     3  0.0404      0.951 0.000 0.000 0.988 0.000 0.012
#> GSM26857     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> GSM26858     3  0.1608      0.914 0.000 0.000 0.928 0.000 0.072
#> GSM26859     3  0.0162      0.950 0.000 0.000 0.996 0.000 0.004
#> GSM26860     3  0.0000      0.951 0.000 0.000 1.000 0.000 0.000
#> GSM26861     3  0.0510      0.950 0.000 0.000 0.984 0.000 0.016
#> GSM26862     1  0.1197      0.796 0.952 0.000 0.000 0.000 0.048
#> GSM26863     1  0.0290      0.799 0.992 0.000 0.000 0.000 0.008
#> GSM26864     1  0.1608      0.780 0.928 0.000 0.000 0.000 0.072
#> GSM26865     1  0.6465      0.402 0.524 0.004 0.216 0.000 0.256
#> GSM26866     5  0.5559     -0.197 0.448 0.020 0.032 0.000 0.500

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM26805     5  0.3808     0.6957 0.000 0.228 0.000 0.000 0.736 0.036
#> GSM26806     4  0.0260     0.8385 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM26807     4  0.0547     0.8458 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26808     4  0.1080     0.8437 0.000 0.032 0.000 0.960 0.004 0.004
#> GSM26809     5  0.5947     0.2793 0.000 0.312 0.000 0.000 0.448 0.240
#> GSM26810     4  0.0547     0.8458 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26811     4  0.1116     0.8438 0.000 0.028 0.000 0.960 0.004 0.008
#> GSM26812     4  0.0547     0.8458 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM26813     2  0.5177     0.5406 0.000 0.688 0.000 0.148 0.124 0.040
#> GSM26814     2  0.2982     0.7654 0.000 0.856 0.000 0.016 0.096 0.032
#> GSM26815     4  0.0458     0.8259 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM26816     5  0.5172     0.6241 0.000 0.352 0.000 0.056 0.572 0.020
#> GSM26817     4  0.1285     0.8314 0.000 0.052 0.000 0.944 0.004 0.000
#> GSM26818     3  0.3737     0.6891 0.000 0.000 0.780 0.044 0.008 0.168
#> GSM26819     2  0.1003     0.8491 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM26820     2  0.0806     0.8511 0.000 0.972 0.000 0.000 0.008 0.020
#> GSM26821     2  0.1148     0.8489 0.000 0.960 0.000 0.016 0.004 0.020
#> GSM26822     2  0.1633     0.8283 0.000 0.932 0.000 0.000 0.024 0.044
#> GSM26823     2  0.0972     0.8489 0.000 0.964 0.000 0.000 0.028 0.008
#> GSM26824     2  0.1713     0.8234 0.000 0.928 0.000 0.044 0.000 0.028
#> GSM26825     2  0.0806     0.8511 0.000 0.972 0.000 0.000 0.008 0.020
#> GSM26826     2  0.1265     0.8404 0.000 0.948 0.000 0.000 0.044 0.008
#> GSM26827     2  0.0858     0.8508 0.000 0.968 0.000 0.000 0.028 0.004
#> GSM26828     5  0.4684     0.6358 0.000 0.352 0.000 0.000 0.592 0.056
#> GSM26829     2  0.4530     0.0125 0.000 0.600 0.000 0.000 0.356 0.044
#> GSM26830     2  0.1555     0.8431 0.000 0.940 0.000 0.012 0.040 0.008
#> GSM26831     5  0.4212     0.5480 0.000 0.424 0.000 0.000 0.560 0.016
#> GSM26832     5  0.4131     0.6512 0.000 0.356 0.000 0.000 0.624 0.020
#> GSM26833     4  0.6416    -0.2122 0.000 0.304 0.000 0.404 0.276 0.016
#> GSM26834     5  0.4250     0.6953 0.000 0.244 0.000 0.036 0.708 0.012
#> GSM26835     5  0.3558     0.6922 0.000 0.212 0.000 0.000 0.760 0.028
#> GSM26836     1  0.0692     0.8026 0.976 0.000 0.000 0.000 0.004 0.020
#> GSM26837     1  0.0717     0.8032 0.976 0.000 0.000 0.000 0.008 0.016
#> GSM26838     1  0.0547     0.8038 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM26839     1  0.0405     0.8038 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM26840     5  0.4693     0.2604 0.028 0.032 0.000 0.000 0.660 0.280
#> GSM26841     1  0.1196     0.7938 0.952 0.000 0.000 0.000 0.008 0.040
#> GSM26842     1  0.0363     0.8033 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26843     1  0.5296     0.4113 0.572 0.004 0.004 0.000 0.328 0.092
#> GSM26844     1  0.4229     0.5974 0.728 0.000 0.008 0.000 0.208 0.056
#> GSM26845     1  0.4732     0.5333 0.728 0.072 0.000 0.000 0.044 0.156
#> GSM26846     6  0.6277     0.5338 0.240 0.008 0.020 0.000 0.208 0.524
#> GSM26847     1  0.3398     0.5257 0.740 0.000 0.000 0.000 0.008 0.252
#> GSM26848     6  0.6818     0.5883 0.288 0.000 0.116 0.000 0.124 0.472
#> GSM26849     3  0.3852     0.2517 0.000 0.000 0.612 0.000 0.004 0.384
#> GSM26850     6  0.6006     0.4359 0.008 0.008 0.344 0.000 0.148 0.492
#> GSM26851     4  0.6459     0.2727 0.000 0.348 0.000 0.468 0.072 0.112
#> GSM26852     3  0.0260     0.9056 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM26853     3  0.0146     0.9089 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM26854     3  0.0713     0.9055 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM26855     3  0.0000     0.9085 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26856     3  0.0000     0.9085 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM26857     3  0.0547     0.9072 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM26858     3  0.1349     0.8653 0.000 0.000 0.940 0.000 0.004 0.056
#> GSM26859     3  0.1141     0.8895 0.000 0.000 0.948 0.000 0.000 0.052
#> GSM26860     3  0.0790     0.9033 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM26861     3  0.0260     0.9056 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM26862     1  0.0777     0.8010 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM26863     1  0.0363     0.8046 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM26864     1  0.1261     0.7928 0.952 0.000 0.000 0.000 0.024 0.024
#> GSM26865     6  0.6626     0.5517 0.156 0.000 0.300 0.000 0.068 0.476
#> GSM26866     1  0.6402     0.1702 0.396 0.004 0.016 0.000 0.380 0.204

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n tissue(p) individual(p) k
#> ATC:NMF 62  3.65e-11      8.91e-01 2
#> ATC:NMF 57  5.80e-10      6.38e-04 3
#> ATC:NMF 60  1.42e-10      9.34e-05 4
#> ATC:NMF 52  1.84e-10      7.21e-06 5
#> ATC:NMF 53  1.88e-09      5.49e-08 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