cola Report for GDS3356

Date: 2019-12-25 20:44:12 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 51941 rows and 54 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] 51941    54

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
ATC:skmeans 3 1.000 0.953 0.979 **
ATC:mclust 2 1.000 0.971 0.986 **
ATC:NMF 3 0.965 0.948 0.981 ** 2
SD:NMF 2 0.961 0.929 0.974 **
CV:kmeans 3 0.923 0.891 0.944 *
CV:NMF 2 0.922 0.944 0.977 *
MAD:NMF 2 0.922 0.943 0.977 *
ATC:kmeans 2 0.891 0.981 0.989
ATC:pam 4 0.880 0.937 0.970
SD:skmeans 2 0.811 0.904 0.959
ATC:hclust 3 0.795 0.826 0.932
SD:hclust 2 0.769 0.887 0.930
SD:kmeans 3 0.769 0.873 0.919
MAD:kmeans 3 0.700 0.835 0.903
CV:hclust 3 0.656 0.858 0.931
CV:skmeans 2 0.652 0.791 0.913
SD:mclust 2 0.620 0.882 0.941
MAD:mclust 2 0.599 0.807 0.905
CV:pam 2 0.571 0.826 0.919
CV:mclust 2 0.507 0.795 0.903
SD:pam 3 0.504 0.693 0.856
MAD:skmeans 2 0.483 0.808 0.905
MAD:hclust 2 0.358 0.797 0.870
MAD:pam 3 0.260 0.631 0.777

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 0.961           0.929       0.974          0.449 0.547   0.547
#> CV:NMF      2 0.922           0.944       0.977          0.443 0.560   0.560
#> MAD:NMF     2 0.922           0.943       0.977          0.463 0.535   0.535
#> ATC:NMF     2 0.922           0.899       0.964          0.274 0.743   0.743
#> SD:skmeans  2 0.811           0.904       0.959          0.481 0.525   0.525
#> CV:skmeans  2 0.652           0.791       0.913          0.491 0.516   0.516
#> MAD:skmeans 2 0.483           0.808       0.905          0.497 0.525   0.525
#> ATC:skmeans 2 0.717           0.837       0.927          0.499 0.525   0.525
#> SD:mclust   2 0.620           0.882       0.941          0.477 0.516   0.516
#> CV:mclust   2 0.507           0.795       0.903          0.455 0.560   0.560
#> MAD:mclust  2 0.599           0.807       0.905          0.451 0.525   0.525
#> ATC:mclust  2 1.000           0.971       0.986          0.502 0.497   0.497
#> SD:kmeans   2 0.534           0.954       0.943          0.400 0.560   0.560
#> CV:kmeans   2 0.484           0.896       0.883          0.369 0.575   0.575
#> MAD:kmeans  2 0.500           0.924       0.913          0.413 0.560   0.560
#> ATC:kmeans  2 0.891           0.981       0.989          0.445 0.547   0.547
#> SD:pam      2 0.883           0.918       0.964          0.418 0.575   0.575
#> CV:pam      2 0.571           0.826       0.919          0.458 0.560   0.560
#> MAD:pam     2 0.315           0.733       0.850          0.414 0.575   0.575
#> ATC:pam     2 0.418           0.694       0.809          0.434 0.609   0.609
#> SD:hclust   2 0.769           0.887       0.930          0.394 0.609   0.609
#> CV:hclust   2 0.496           0.609       0.815          0.290 0.860   0.860
#> MAD:hclust  2 0.358           0.797       0.870          0.406 0.591   0.591
#> ATC:hclust  2 0.693           0.897       0.938          0.308 0.648   0.648
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.590           0.710       0.869          0.466 0.704   0.496
#> CV:NMF      3 0.551           0.736       0.870          0.487 0.743   0.553
#> MAD:NMF     3 0.504           0.710       0.829          0.404 0.697   0.481
#> ATC:NMF     3 0.965           0.948       0.981          0.988 0.662   0.562
#> SD:skmeans  3 0.559           0.718       0.856          0.398 0.727   0.514
#> CV:skmeans  3 0.417           0.627       0.807          0.371 0.718   0.498
#> MAD:skmeans 3 0.329           0.565       0.764          0.354 0.725   0.511
#> ATC:skmeans 3 1.000           0.953       0.979          0.310 0.793   0.616
#> SD:mclust   3 0.424           0.579       0.740          0.161 0.799   0.667
#> CV:mclust   3 0.697           0.883       0.922          0.158 0.874   0.783
#> MAD:mclust  3 0.383           0.478       0.724          0.192 0.617   0.424
#> ATC:mclust  3 0.557           0.733       0.848          0.189 0.887   0.774
#> SD:kmeans   3 0.769           0.873       0.919          0.406 0.908   0.835
#> CV:kmeans   3 0.923           0.891       0.944          0.471 0.885   0.800
#> MAD:kmeans  3 0.700           0.835       0.903          0.465 0.824   0.686
#> ATC:kmeans  3 0.447           0.646       0.816          0.343 0.704   0.525
#> SD:pam      3 0.504           0.693       0.856          0.522 0.763   0.594
#> CV:pam      3 0.460           0.694       0.825          0.402 0.743   0.550
#> MAD:pam     3 0.260           0.631       0.777          0.497 0.774   0.613
#> ATC:pam     3 0.413           0.641       0.790          0.399 0.704   0.546
#> SD:hclust   3 0.725           0.843       0.924          0.326 0.899   0.835
#> CV:hclust   3 0.656           0.858       0.931          0.781 0.633   0.574
#> MAD:hclust  3 0.399           0.750       0.857          0.305 0.902   0.835
#> ATC:hclust  3 0.795           0.826       0.932          0.354 0.913   0.868
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.576           0.626       0.808         0.1189 0.902   0.722
#> CV:NMF      4 0.502           0.580       0.774         0.1258 0.817   0.527
#> MAD:NMF     4 0.510           0.499       0.703         0.1535 0.820   0.528
#> ATC:NMF     4 0.751           0.837       0.915         0.1304 0.940   0.870
#> SD:skmeans  4 0.511           0.531       0.713         0.1170 0.894   0.690
#> CV:skmeans  4 0.408           0.427       0.678         0.1181 0.928   0.784
#> MAD:skmeans 4 0.340           0.380       0.627         0.1182 0.933   0.796
#> ATC:skmeans 4 0.896           0.905       0.959         0.1348 0.881   0.671
#> SD:mclust   4 0.496           0.614       0.768         0.2385 0.690   0.425
#> CV:mclust   4 0.442           0.434       0.725         0.3161 0.744   0.481
#> MAD:mclust  4 0.421           0.574       0.746         0.2786 0.611   0.285
#> ATC:mclust  4 0.853           0.847       0.918         0.1973 0.837   0.602
#> SD:kmeans   4 0.584           0.560       0.744         0.2072 0.989   0.976
#> CV:kmeans   4 0.556           0.577       0.795         0.2384 0.881   0.746
#> MAD:kmeans  4 0.600           0.606       0.756         0.1553 0.810   0.554
#> ATC:kmeans  4 0.736           0.784       0.881         0.2037 0.764   0.477
#> SD:pam      4 0.466           0.656       0.808         0.0355 1.000   1.000
#> CV:pam      4 0.431           0.624       0.805         0.0574 0.964   0.892
#> MAD:pam     4 0.379           0.572       0.756         0.1067 0.891   0.720
#> ATC:pam     4 0.880           0.937       0.970         0.2260 0.806   0.538
#> SD:hclust   4 0.653           0.784       0.892         0.0497 0.998   0.996
#> CV:hclust   4 0.655           0.801       0.915         0.0662 0.973   0.946
#> MAD:hclust  4 0.464           0.712       0.866         0.0819 0.973   0.946
#> ATC:hclust  4 0.588           0.685       0.842         0.2690 0.948   0.911
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.573           0.536       0.756         0.0731 0.864   0.565
#> CV:NMF      5 0.524           0.466       0.699         0.0698 0.888   0.620
#> MAD:NMF     5 0.582           0.528       0.727         0.0685 0.853   0.509
#> ATC:NMF     5 0.647           0.717       0.849         0.1645 0.829   0.602
#> SD:skmeans  5 0.514           0.426       0.633         0.0618 0.934   0.758
#> CV:skmeans  5 0.466           0.360       0.603         0.0601 0.943   0.801
#> MAD:skmeans 5 0.420           0.362       0.585         0.0616 0.902   0.665
#> ATC:skmeans 5 0.813           0.732       0.851         0.0595 0.915   0.690
#> SD:mclust   5 0.539           0.513       0.714         0.0316 0.747   0.355
#> CV:mclust   5 0.534           0.475       0.692         0.0548 0.841   0.505
#> MAD:mclust  5 0.549           0.680       0.790         0.0721 0.864   0.596
#> ATC:mclust  5 0.896           0.843       0.935         0.0672 0.867   0.583
#> SD:kmeans   5 0.553           0.613       0.764         0.0958 0.771   0.509
#> CV:kmeans   5 0.576           0.558       0.751         0.1036 0.836   0.578
#> MAD:kmeans  5 0.577           0.568       0.735         0.0901 0.876   0.609
#> ATC:kmeans  5 0.736           0.777       0.866         0.0786 0.909   0.688
#> SD:pam      5 0.414           0.566       0.797         0.0181 0.984   0.955
#> CV:pam      5 0.429           0.605       0.789         0.0228 0.979   0.933
#> MAD:pam     5 0.384           0.532       0.760         0.0235 0.944   0.835
#> ATC:pam     5 0.769           0.831       0.911         0.0432 0.975   0.900
#> SD:hclust   5 0.573           0.649       0.834         0.0445 0.983   0.967
#> CV:hclust   5 0.544           0.746       0.857         0.0692 0.974   0.945
#> MAD:hclust  5 0.413           0.627       0.786         0.1177 1.000   1.000
#> ATC:hclust  5 0.535           0.609       0.741         0.0965 0.857   0.742
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.614           0.436       0.663        0.04400 0.937   0.721
#> CV:NMF      6 0.560           0.397       0.630        0.04285 0.920   0.666
#> MAD:NMF     6 0.620           0.430       0.668        0.04456 0.914   0.633
#> ATC:NMF     6 0.593           0.611       0.788        0.04809 0.944   0.820
#> SD:skmeans  6 0.550           0.362       0.577        0.03721 0.894   0.593
#> CV:skmeans  6 0.503           0.290       0.556        0.04076 0.948   0.794
#> MAD:skmeans 6 0.481           0.297       0.532        0.04162 0.925   0.687
#> ATC:skmeans 6 0.778           0.641       0.811        0.03558 0.965   0.838
#> SD:mclust   6 0.592           0.571       0.726        0.09767 0.867   0.549
#> CV:mclust   6 0.580           0.494       0.716        0.04415 0.820   0.438
#> MAD:mclust  6 0.625           0.532       0.773        0.06357 0.936   0.772
#> ATC:mclust  6 0.800           0.705       0.843        0.05302 0.931   0.729
#> SD:kmeans   6 0.593           0.569       0.717        0.06219 0.955   0.820
#> CV:kmeans   6 0.609           0.550       0.755        0.05768 0.955   0.829
#> MAD:kmeans  6 0.605           0.484       0.715        0.05490 0.949   0.792
#> ATC:kmeans  6 0.769           0.618       0.792        0.04478 0.928   0.699
#> SD:pam      6 0.464           0.538       0.777        0.01027 0.976   0.932
#> CV:pam      6 0.489           0.583       0.790        0.02448 0.990   0.966
#> MAD:pam     6 0.373           0.470       0.723        0.03698 0.989   0.965
#> ATC:pam     6 0.922           0.845       0.942        0.00142 0.997   0.988
#> SD:hclust   6 0.544           0.679       0.804        0.04526 0.990   0.979
#> CV:hclust   6 0.509           0.570       0.813        0.06682 0.982   0.959
#> MAD:hclust  6 0.476           0.226       0.683        0.07426 0.930   0.851
#> ATC:hclust  6 0.520           0.588       0.706        0.12389 0.723   0.438

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 development.stage(p) disease.state(p) k
#> SD:NMF      51                0.534            1.000 2
#> CV:NMF      52                0.473            1.000 2
#> MAD:NMF     53                0.565            0.977 2
#> ATC:NMF     50                1.000            0.481 2
#> SD:skmeans  52                0.876            0.739 2
#> CV:skmeans  47                0.923            0.891 2
#> MAD:skmeans 49                0.986            0.752 2
#> ATC:skmeans 46                0.249            0.776 2
#> SD:mclust   54                1.000            0.676 2
#> CV:mclust   49                0.773            0.704 2
#> MAD:mclust  50                1.000            1.000 2
#> ATC:mclust  54                1.000            0.729 2
#> SD:kmeans   54                0.688            0.902 2
#> CV:kmeans   53                0.601            1.000 2
#> MAD:kmeans  54                0.688            0.902 2
#> ATC:kmeans  54                0.290            0.921 2
#> SD:pam      51                0.820            0.854 2
#> CV:pam      51                0.534            0.736 2
#> MAD:pam     50                0.474            0.640 2
#> ATC:pam     49                0.440            1.000 2
#> SD:hclust   51                0.820            1.000 2
#> CV:hclust   37                0.637            1.000 2
#> MAD:hclust  49                0.821            1.000 2
#> ATC:hclust  52                1.000            1.000 2
test_to_known_factors(res_list, k = 3)
#>              n development.stage(p) disease.state(p) k
#> SD:NMF      47               0.0596            0.827 3
#> CV:NMF      47               0.0336            0.989 3
#> MAD:NMF     47               0.1867            0.930 3
#> ATC:NMF     53               0.6664            0.402 3
#> SD:skmeans  48               0.2849            0.817 3
#> CV:skmeans  39               0.3557            0.978 3
#> MAD:skmeans 33               0.5176            0.883 3
#> ATC:skmeans 53               0.2285            0.530 3
#> SD:mclust   42               1.0000            1.000 3
#> CV:mclust   53               0.4535            0.821 3
#> MAD:mclust  27               1.0000            1.000 3
#> ATC:mclust  46               0.6028            0.853 3
#> SD:kmeans   51               0.3941            0.852 3
#> CV:kmeans   51               0.4536            0.828 3
#> MAD:kmeans  53               0.4278            0.921 3
#> ATC:kmeans  40               0.5136            0.202 3
#> SD:pam      43               0.8305            0.462 3
#> CV:pam      47               0.6489            0.923 3
#> MAD:pam     41               0.7405            0.715 3
#> ATC:pam     51               0.7564            0.780 3
#> SD:hclust   51               0.4999            0.859 3
#> CV:hclust   52               0.4594            0.817 3
#> MAD:hclust  48               0.5122            0.697 3
#> ATC:hclust  49               0.7690            0.256 3
test_to_known_factors(res_list, k = 4)
#>              n development.stage(p) disease.state(p) k
#> SD:NMF      41                0.365           0.0222 4
#> CV:NMF      35                0.753           0.6316 4
#> MAD:NMF     32                0.727           0.4362 4
#> ATC:NMF     51                0.464           0.2757 4
#> SD:skmeans  29                0.762           0.4046 4
#> CV:skmeans  19                0.495           0.9755 4
#> MAD:skmeans 16                   NA               NA 4
#> ATC:skmeans 52                0.380           0.4589 4
#> SD:mclust   40                0.537           0.7060 4
#> CV:mclust   36                0.378           0.8991 4
#> MAD:mclust  41                0.574           0.5850 4
#> ATC:mclust  50                0.734           0.6920 4
#> SD:kmeans   35                0.382           0.6150 4
#> CV:kmeans   37                0.397           0.8046 4
#> MAD:kmeans  42                0.311           0.9401 4
#> ATC:kmeans  48                0.989           0.3512 4
#> SD:pam      42                0.928           0.6238 4
#> CV:pam      44                0.740           0.7924 4
#> MAD:pam     37                0.846           0.8144 4
#> ATC:pam     54                0.971           0.7561 4
#> SD:hclust   49                0.183           0.9949 4
#> CV:hclust   51                0.164           0.9126 4
#> MAD:hclust  46                0.201           0.9924 4
#> ATC:hclust  39                0.297           0.3803 4
test_to_known_factors(res_list, k = 5)
#>              n development.stage(p) disease.state(p) k
#> SD:NMF      33                0.707            0.081 5
#> CV:NMF      27                0.773            0.457 5
#> MAD:NMF     34                0.568            0.783 5
#> ATC:NMF     45                0.730            0.606 5
#> SD:skmeans  17                1.000            1.000 5
#> CV:skmeans  15                   NA               NA 5
#> MAD:skmeans 13                   NA               NA 5
#> ATC:skmeans 46                0.228            0.206 5
#> SD:mclust   39                0.492            0.705 5
#> CV:mclust   32                0.501            0.911 5
#> MAD:mclust  49                0.220            0.244 5
#> ATC:mclust  50                0.867            0.593 5
#> SD:kmeans   45                0.627            0.931 5
#> CV:kmeans   38                0.183            0.843 5
#> MAD:kmeans  38                0.135            0.964 5
#> ATC:kmeans  51                0.965            0.474 5
#> SD:pam      37                0.427            0.765 5
#> CV:pam      45                0.461            0.922 5
#> MAD:pam     33                0.327            0.938 5
#> ATC:pam     51                0.966            0.575 5
#> SD:hclust   45                0.108            0.308 5
#> CV:hclust   50                0.308            0.847 5
#> MAD:hclust  42                0.224            0.952 5
#> ATC:hclust  47                0.764            0.525 5
test_to_known_factors(res_list, k = 6)
#>              n development.stage(p) disease.state(p) k
#> SD:NMF      23                0.492            0.120 6
#> CV:NMF      16                0.460            0.227 6
#> MAD:NMF     20                0.927            0.454 6
#> ATC:NMF     40                0.727            0.444 6
#> SD:skmeans  17                1.000            1.000 6
#> CV:skmeans  14                   NA               NA 6
#> MAD:skmeans 11                   NA               NA 6
#> ATC:skmeans 42                0.516            0.406 6
#> SD:mclust   42                0.330            0.753 6
#> CV:mclust   33                0.417            0.360 6
#> MAD:mclust  40                0.440            0.794 6
#> ATC:mclust  38                0.376            0.299 6
#> SD:kmeans   42                0.632            0.753 6
#> CV:kmeans   39                0.422            0.967 6
#> MAD:kmeans  31                0.185            0.895 6
#> ATC:kmeans  40                0.620            0.328 6
#> SD:pam      38                0.721            0.548 6
#> CV:pam      42                0.485            0.952 6
#> MAD:pam     29                0.821            0.348 6
#> ATC:pam     48                0.924            0.665 6
#> SD:hclust   45                0.401            0.940 6
#> CV:hclust   37                0.375            0.814 6
#> MAD:hclust  16                0.120            0.949 6
#> ATC:hclust  41                0.912            0.866 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.769           0.887       0.930         0.3939 0.609   0.609
#> 3 3 0.725           0.843       0.924         0.3262 0.899   0.835
#> 4 4 0.653           0.784       0.892         0.0497 0.998   0.996
#> 5 5 0.573           0.649       0.834         0.0445 0.983   0.967
#> 6 6 0.544           0.679       0.804         0.0453 0.990   0.979

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
#> GSM213078     1  0.0376     0.9363 0.996 0.004
#> GSM213082     2  0.4022     0.9606 0.080 0.920
#> GSM213085     1  0.0938     0.9353 0.988 0.012
#> GSM213088     1  0.0000     0.9363 1.000 0.000
#> GSM213091     1  0.3274     0.9030 0.940 0.060
#> GSM213092     1  0.0938     0.9353 0.988 0.012
#> GSM213096     1  0.0672     0.9361 0.992 0.008
#> GSM213100     1  0.0672     0.9361 0.992 0.008
#> GSM213111     2  0.4690     0.9498 0.100 0.900
#> GSM213117     1  0.0938     0.9341 0.988 0.012
#> GSM213118     1  0.2778     0.9126 0.952 0.048
#> GSM213120     1  0.9954     0.0238 0.540 0.460
#> GSM213122     2  0.4022     0.9606 0.080 0.920
#> GSM213074     1  0.2423     0.9166 0.960 0.040
#> GSM213077     1  0.0376     0.9363 0.996 0.004
#> GSM213083     1  0.0376     0.9363 0.996 0.004
#> GSM213094     1  0.4022     0.8872 0.920 0.080
#> GSM213095     2  0.4431     0.9549 0.092 0.908
#> GSM213102     1  0.0000     0.9363 1.000 0.000
#> GSM213103     1  0.9129     0.4546 0.672 0.328
#> GSM213104     1  0.4161     0.8815 0.916 0.084
#> GSM213107     2  0.4022     0.9606 0.080 0.920
#> GSM213108     2  0.4022     0.9606 0.080 0.920
#> GSM213112     1  0.0938     0.9353 0.988 0.012
#> GSM213114     1  0.4022     0.8854 0.920 0.080
#> GSM213115     2  0.7528     0.8373 0.216 0.784
#> GSM213116     1  0.1184     0.9353 0.984 0.016
#> GSM213119     2  0.4022     0.9606 0.080 0.920
#> GSM213072     1  0.2603     0.9187 0.956 0.044
#> GSM213075     1  0.0938     0.9356 0.988 0.012
#> GSM213076     2  0.7376     0.8424 0.208 0.792
#> GSM213079     1  0.4022     0.8872 0.920 0.080
#> GSM213080     1  0.4161     0.8815 0.916 0.084
#> GSM213081     1  0.1414     0.9315 0.980 0.020
#> GSM213084     1  0.0376     0.9363 0.996 0.004
#> GSM213087     2  0.4022     0.9606 0.080 0.920
#> GSM213089     1  0.0938     0.9324 0.988 0.012
#> GSM213090     1  0.4022     0.8872 0.920 0.080
#> GSM213093     1  0.0000     0.9363 1.000 0.000
#> GSM213097     1  0.0000     0.9363 1.000 0.000
#> GSM213099     1  0.3274     0.9030 0.940 0.060
#> GSM213101     1  0.0376     0.9363 0.996 0.004
#> GSM213105     2  0.4022     0.9606 0.080 0.920
#> GSM213109     1  0.0000     0.9363 1.000 0.000
#> GSM213110     2  0.7528     0.8373 0.216 0.784
#> GSM213113     1  0.1633     0.9293 0.976 0.024
#> GSM213121     2  0.4022     0.9606 0.080 0.920
#> GSM213123     1  0.0938     0.9352 0.988 0.012
#> GSM213125     2  0.4022     0.9606 0.080 0.920
#> GSM213073     1  0.4022     0.8872 0.920 0.080
#> GSM213086     1  0.0938     0.9353 0.988 0.012
#> GSM213098     1  0.1843     0.9270 0.972 0.028
#> GSM213106     1  0.0000     0.9363 1.000 0.000
#> GSM213124     1  0.9686     0.2513 0.604 0.396

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0000     0.9034 1.000 0.000 0.000
#> GSM213082     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213085     1  0.0592     0.9034 0.988 0.000 0.012
#> GSM213088     1  0.1289     0.8999 0.968 0.000 0.032
#> GSM213091     1  0.5325     0.6569 0.748 0.004 0.248
#> GSM213092     1  0.0592     0.9034 0.988 0.000 0.012
#> GSM213096     1  0.0237     0.9032 0.996 0.000 0.004
#> GSM213100     1  0.0237     0.9032 0.996 0.000 0.004
#> GSM213111     2  0.1289     0.9109 0.032 0.968 0.000
#> GSM213117     1  0.1878     0.8929 0.952 0.004 0.044
#> GSM213118     1  0.2116     0.8863 0.948 0.040 0.012
#> GSM213120     1  0.6822     0.0633 0.508 0.480 0.012
#> GSM213122     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213074     1  0.2860     0.8630 0.912 0.004 0.084
#> GSM213077     1  0.0000     0.9034 1.000 0.000 0.000
#> GSM213083     1  0.0000     0.9034 1.000 0.000 0.000
#> GSM213094     3  0.4110     0.8655 0.152 0.004 0.844
#> GSM213095     2  0.0829     0.9225 0.012 0.984 0.004
#> GSM213102     1  0.1163     0.8986 0.972 0.000 0.028
#> GSM213103     1  0.6880     0.5142 0.660 0.304 0.036
#> GSM213104     1  0.4075     0.8364 0.880 0.072 0.048
#> GSM213107     2  0.0237     0.9261 0.004 0.996 0.000
#> GSM213108     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213112     1  0.0592     0.9034 0.988 0.000 0.012
#> GSM213114     1  0.3983     0.8401 0.884 0.068 0.048
#> GSM213115     2  0.5435     0.7032 0.192 0.784 0.024
#> GSM213116     1  0.1878     0.8933 0.952 0.004 0.044
#> GSM213119     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213072     1  0.2400     0.8778 0.932 0.004 0.064
#> GSM213075     1  0.1525     0.9018 0.964 0.004 0.032
#> GSM213076     2  0.4047     0.7684 0.148 0.848 0.004
#> GSM213079     3  0.2261     0.9466 0.068 0.000 0.932
#> GSM213080     1  0.4075     0.8364 0.880 0.072 0.048
#> GSM213081     1  0.1411     0.8917 0.964 0.000 0.036
#> GSM213084     1  0.0000     0.9034 1.000 0.000 0.000
#> GSM213087     2  0.0237     0.9261 0.004 0.996 0.000
#> GSM213089     1  0.2625     0.8676 0.916 0.000 0.084
#> GSM213090     3  0.1643     0.9243 0.044 0.000 0.956
#> GSM213093     1  0.1411     0.8965 0.964 0.000 0.036
#> GSM213097     1  0.1163     0.8986 0.972 0.000 0.028
#> GSM213099     1  0.6386     0.2709 0.584 0.004 0.412
#> GSM213101     1  0.0000     0.9034 1.000 0.000 0.000
#> GSM213105     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213109     1  0.0237     0.9035 0.996 0.000 0.004
#> GSM213110     2  0.5435     0.7032 0.192 0.784 0.024
#> GSM213113     1  0.1765     0.8889 0.956 0.004 0.040
#> GSM213121     2  0.0237     0.9261 0.004 0.996 0.000
#> GSM213123     1  0.1289     0.9028 0.968 0.000 0.032
#> GSM213125     2  0.0424     0.9291 0.008 0.992 0.000
#> GSM213073     3  0.2261     0.9466 0.068 0.000 0.932
#> GSM213086     1  0.0592     0.9034 0.988 0.000 0.012
#> GSM213098     1  0.1950     0.8866 0.952 0.008 0.040
#> GSM213106     1  0.1289     0.8975 0.968 0.000 0.032
#> GSM213124     1  0.6935     0.3711 0.604 0.372 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213082     2  0.1004     0.8748 0.004 0.972 0.000 0.024
#> GSM213085     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213088     1  0.1356     0.8748 0.960 0.000 0.008 0.032
#> GSM213091     1  0.5421     0.6061 0.724 0.000 0.076 0.200
#> GSM213092     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213096     1  0.0469     0.8793 0.988 0.000 0.000 0.012
#> GSM213100     1  0.0469     0.8793 0.988 0.000 0.000 0.012
#> GSM213111     2  0.1510     0.8698 0.028 0.956 0.000 0.016
#> GSM213117     1  0.2125     0.8632 0.932 0.004 0.012 0.052
#> GSM213118     1  0.1913     0.8625 0.940 0.040 0.000 0.020
#> GSM213120     1  0.6551     0.0994 0.492 0.440 0.004 0.064
#> GSM213122     2  0.0779     0.8800 0.004 0.980 0.000 0.016
#> GSM213074     1  0.2741     0.8332 0.892 0.000 0.012 0.096
#> GSM213077     1  0.0336     0.8789 0.992 0.000 0.000 0.008
#> GSM213083     1  0.0336     0.8789 0.992 0.000 0.000 0.008
#> GSM213094     4  0.6630     0.0000 0.136 0.000 0.252 0.612
#> GSM213095     2  0.3166     0.8424 0.000 0.868 0.016 0.116
#> GSM213102     1  0.1545     0.8696 0.952 0.000 0.008 0.040
#> GSM213103     1  0.5990     0.4788 0.644 0.284 0.000 0.072
#> GSM213104     1  0.4215     0.7768 0.824 0.072 0.000 0.104
#> GSM213107     2  0.3351     0.8276 0.000 0.844 0.008 0.148
#> GSM213108     2  0.1004     0.8748 0.004 0.972 0.000 0.024
#> GSM213112     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213114     1  0.4155     0.7806 0.828 0.072 0.000 0.100
#> GSM213115     2  0.4761     0.6426 0.184 0.768 0.000 0.048
#> GSM213116     1  0.1953     0.8677 0.940 0.004 0.012 0.044
#> GSM213119     2  0.1305     0.8783 0.004 0.960 0.000 0.036
#> GSM213072     1  0.2197     0.8512 0.916 0.000 0.004 0.080
#> GSM213075     1  0.1762     0.8763 0.944 0.004 0.004 0.048
#> GSM213076     2  0.4565     0.7098 0.140 0.796 0.000 0.064
#> GSM213079     3  0.1635     0.8523 0.044 0.000 0.948 0.008
#> GSM213080     1  0.4215     0.7768 0.824 0.072 0.000 0.104
#> GSM213081     1  0.2081     0.8476 0.916 0.000 0.000 0.084
#> GSM213084     1  0.0188     0.8785 0.996 0.000 0.000 0.004
#> GSM213087     2  0.1902     0.8693 0.000 0.932 0.004 0.064
#> GSM213089     1  0.2908     0.8376 0.896 0.000 0.040 0.064
#> GSM213090     3  0.2799     0.7828 0.008 0.000 0.884 0.108
#> GSM213093     1  0.1807     0.8682 0.940 0.000 0.008 0.052
#> GSM213097     1  0.1452     0.8711 0.956 0.000 0.008 0.036
#> GSM213099     1  0.6649     0.1554 0.560 0.000 0.100 0.340
#> GSM213101     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213105     2  0.1305     0.8783 0.004 0.960 0.000 0.036
#> GSM213109     1  0.0707     0.8786 0.980 0.000 0.000 0.020
#> GSM213110     2  0.4761     0.6426 0.184 0.768 0.000 0.048
#> GSM213113     1  0.2401     0.8406 0.904 0.004 0.000 0.092
#> GSM213121     2  0.3157     0.8324 0.000 0.852 0.004 0.144
#> GSM213123     1  0.1635     0.8755 0.948 0.000 0.008 0.044
#> GSM213125     2  0.0657     0.8797 0.004 0.984 0.000 0.012
#> GSM213073     3  0.2919     0.8411 0.044 0.000 0.896 0.060
#> GSM213086     1  0.0469     0.8786 0.988 0.000 0.000 0.012
#> GSM213098     1  0.2546     0.8379 0.900 0.008 0.000 0.092
#> GSM213106     1  0.1545     0.8701 0.952 0.000 0.008 0.040
#> GSM213124     1  0.5929     0.3735 0.596 0.356 0.000 0.048

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0510      0.870 0.984 0.000 0.000 0.016 0.000
#> GSM213082     2  0.2389      0.505 0.004 0.880 0.000 0.000 0.116
#> GSM213085     1  0.0451      0.870 0.988 0.000 0.000 0.008 0.004
#> GSM213088     1  0.1282      0.865 0.952 0.000 0.004 0.044 0.000
#> GSM213091     1  0.4067      0.580 0.692 0.000 0.008 0.300 0.000
#> GSM213092     1  0.0451      0.870 0.988 0.000 0.000 0.008 0.004
#> GSM213096     1  0.0771      0.871 0.976 0.000 0.000 0.020 0.004
#> GSM213100     1  0.0771      0.871 0.976 0.000 0.000 0.020 0.004
#> GSM213111     2  0.2450      0.525 0.028 0.896 0.000 0.000 0.076
#> GSM213117     1  0.1928      0.853 0.920 0.004 0.004 0.072 0.000
#> GSM213118     1  0.1756      0.858 0.940 0.036 0.000 0.016 0.008
#> GSM213120     1  0.6677      0.149 0.488 0.356 0.000 0.024 0.132
#> GSM213122     2  0.1041      0.544 0.004 0.964 0.000 0.000 0.032
#> GSM213074     1  0.2707      0.812 0.860 0.000 0.008 0.132 0.000
#> GSM213077     1  0.0404      0.871 0.988 0.000 0.000 0.012 0.000
#> GSM213083     1  0.0404      0.871 0.988 0.000 0.000 0.012 0.000
#> GSM213094     4  0.3493      0.000 0.108 0.000 0.060 0.832 0.000
#> GSM213095     5  0.4560      0.508 0.000 0.484 0.008 0.000 0.508
#> GSM213102     1  0.1430      0.860 0.944 0.000 0.004 0.052 0.000
#> GSM213103     1  0.5927      0.516 0.640 0.248 0.000 0.052 0.060
#> GSM213104     1  0.4405      0.752 0.788 0.052 0.000 0.132 0.028
#> GSM213107     5  0.4294      0.548 0.000 0.468 0.000 0.000 0.532
#> GSM213108     2  0.2389      0.505 0.004 0.880 0.000 0.000 0.116
#> GSM213112     1  0.0451      0.870 0.988 0.000 0.000 0.008 0.004
#> GSM213114     1  0.4320      0.755 0.792 0.052 0.000 0.132 0.024
#> GSM213115     2  0.4979      0.353 0.184 0.732 0.000 0.028 0.056
#> GSM213116     1  0.1798      0.858 0.928 0.004 0.004 0.064 0.000
#> GSM213119     2  0.2011      0.502 0.004 0.908 0.000 0.000 0.088
#> GSM213072     1  0.2074      0.838 0.896 0.000 0.000 0.104 0.000
#> GSM213075     1  0.1892      0.864 0.916 0.000 0.000 0.080 0.004
#> GSM213076     2  0.4950      0.252 0.140 0.732 0.000 0.008 0.120
#> GSM213079     3  0.2813      0.695 0.040 0.000 0.876 0.084 0.000
#> GSM213080     1  0.4405      0.752 0.788 0.052 0.000 0.132 0.028
#> GSM213081     1  0.2280      0.822 0.880 0.000 0.000 0.120 0.000
#> GSM213084     1  0.0290      0.870 0.992 0.000 0.000 0.008 0.000
#> GSM213087     2  0.3177      0.233 0.000 0.792 0.000 0.000 0.208
#> GSM213089     1  0.2286      0.832 0.888 0.000 0.004 0.108 0.000
#> GSM213090     3  0.4421      0.547 0.000 0.000 0.748 0.068 0.184
#> GSM213093     1  0.1831      0.856 0.920 0.000 0.004 0.076 0.000
#> GSM213097     1  0.1357      0.862 0.948 0.000 0.004 0.048 0.000
#> GSM213099     1  0.4437      0.122 0.532 0.000 0.004 0.464 0.000
#> GSM213101     1  0.0510      0.870 0.984 0.000 0.000 0.016 0.000
#> GSM213105     2  0.2011      0.502 0.004 0.908 0.000 0.000 0.088
#> GSM213109     1  0.0880      0.871 0.968 0.000 0.000 0.032 0.000
#> GSM213110     2  0.4979      0.353 0.184 0.732 0.000 0.028 0.056
#> GSM213113     1  0.2536      0.814 0.868 0.004 0.000 0.128 0.000
#> GSM213121     2  0.4306     -0.727 0.000 0.508 0.000 0.000 0.492
#> GSM213123     1  0.1571      0.867 0.936 0.000 0.004 0.060 0.000
#> GSM213125     2  0.1041      0.545 0.004 0.964 0.000 0.000 0.032
#> GSM213073     3  0.5453      0.648 0.040 0.000 0.712 0.088 0.160
#> GSM213086     1  0.0451      0.870 0.988 0.000 0.000 0.008 0.004
#> GSM213098     1  0.2694      0.811 0.864 0.004 0.000 0.128 0.004
#> GSM213106     1  0.1502      0.862 0.940 0.000 0.004 0.056 0.000
#> GSM213124     1  0.5923      0.417 0.592 0.316 0.000 0.032 0.060

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.0458     0.8546 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM213082     2  0.3394     0.6120 0.000 0.752 0.000 0.000 0.236 0.012
#> GSM213085     1  0.0405     0.8554 0.988 0.000 0.004 0.008 0.000 0.000
#> GSM213088     1  0.1075     0.8507 0.952 0.000 0.000 0.048 0.000 0.000
#> GSM213091     1  0.4216     0.5594 0.676 0.000 0.032 0.288 0.000 0.004
#> GSM213092     1  0.0405     0.8554 0.988 0.000 0.004 0.008 0.000 0.000
#> GSM213096     1  0.0692     0.8563 0.976 0.000 0.004 0.020 0.000 0.000
#> GSM213100     1  0.0692     0.8563 0.976 0.000 0.004 0.020 0.000 0.000
#> GSM213111     2  0.3799     0.6272 0.024 0.764 0.000 0.000 0.196 0.016
#> GSM213117     1  0.1843     0.8410 0.912 0.004 0.004 0.080 0.000 0.000
#> GSM213118     1  0.2001     0.8402 0.924 0.028 0.004 0.032 0.012 0.000
#> GSM213120     1  0.7079     0.1481 0.464 0.304 0.008 0.040 0.160 0.024
#> GSM213122     2  0.0458     0.6750 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM213074     1  0.2699     0.8003 0.856 0.000 0.008 0.124 0.000 0.012
#> GSM213077     1  0.0363     0.8554 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM213083     1  0.0363     0.8554 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM213094     4  0.4369     0.0000 0.092 0.000 0.056 0.772 0.000 0.080
#> GSM213095     5  0.2510     0.4416 0.000 0.100 0.000 0.000 0.872 0.028
#> GSM213102     1  0.1204     0.8458 0.944 0.000 0.000 0.056 0.000 0.000
#> GSM213103     1  0.6876     0.4785 0.592 0.184 0.012 0.072 0.052 0.088
#> GSM213104     1  0.4811     0.6888 0.724 0.040 0.004 0.188 0.032 0.012
#> GSM213107     5  0.3163     0.6813 0.000 0.232 0.000 0.004 0.764 0.000
#> GSM213108     2  0.3483     0.6105 0.000 0.748 0.000 0.000 0.236 0.016
#> GSM213112     1  0.0405     0.8554 0.988 0.000 0.004 0.008 0.000 0.000
#> GSM213114     1  0.4716     0.6926 0.728 0.040 0.004 0.188 0.032 0.008
#> GSM213115     2  0.5907     0.5012 0.156 0.672 0.012 0.028 0.040 0.092
#> GSM213116     1  0.1988     0.8426 0.912 0.004 0.008 0.072 0.000 0.004
#> GSM213119     2  0.1700     0.6459 0.000 0.916 0.000 0.000 0.080 0.004
#> GSM213072     1  0.2053     0.8242 0.888 0.000 0.000 0.108 0.000 0.004
#> GSM213075     1  0.2373     0.8403 0.888 0.000 0.000 0.084 0.004 0.024
#> GSM213076     2  0.5458     0.4164 0.136 0.624 0.000 0.008 0.224 0.008
#> GSM213079     3  0.4002     0.6336 0.012 0.000 0.740 0.032 0.000 0.216
#> GSM213080     1  0.4811     0.6888 0.724 0.040 0.004 0.188 0.032 0.012
#> GSM213081     1  0.2848     0.7676 0.816 0.000 0.000 0.176 0.000 0.008
#> GSM213084     1  0.0260     0.8547 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM213087     2  0.3023     0.4627 0.000 0.768 0.000 0.000 0.232 0.000
#> GSM213089     1  0.1957     0.8214 0.888 0.000 0.000 0.112 0.000 0.000
#> GSM213090     6  0.2092     0.0000 0.000 0.000 0.124 0.000 0.000 0.876
#> GSM213093     1  0.1610     0.8425 0.916 0.000 0.000 0.084 0.000 0.000
#> GSM213097     1  0.1141     0.8473 0.948 0.000 0.000 0.052 0.000 0.000
#> GSM213099     1  0.4523     0.0911 0.516 0.000 0.032 0.452 0.000 0.000
#> GSM213101     1  0.0458     0.8546 0.984 0.000 0.000 0.016 0.000 0.000
#> GSM213105     2  0.1700     0.6459 0.000 0.916 0.000 0.000 0.080 0.004
#> GSM213109     1  0.0790     0.8560 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM213110     2  0.5907     0.5012 0.156 0.672 0.012 0.028 0.040 0.092
#> GSM213113     1  0.3056     0.7586 0.804 0.000 0.000 0.184 0.004 0.008
#> GSM213121     5  0.3619     0.6715 0.000 0.316 0.000 0.004 0.680 0.000
#> GSM213123     1  0.1556     0.8464 0.920 0.000 0.000 0.080 0.000 0.000
#> GSM213125     2  0.0632     0.6761 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM213073     3  0.0363     0.6842 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM213086     1  0.0405     0.8554 0.988 0.000 0.004 0.008 0.000 0.000
#> GSM213098     1  0.3166     0.7554 0.800 0.000 0.000 0.184 0.008 0.008
#> GSM213106     1  0.1327     0.8481 0.936 0.000 0.000 0.064 0.000 0.000
#> GSM213124     1  0.6789     0.3958 0.560 0.248 0.012 0.036 0.052 0.092

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

test_to_known_factors(res)
#>            n development.stage(p) disease.state(p) k
#> SD:hclust 51                0.820            1.000 2
#> SD:hclust 51                0.500            0.859 3
#> SD:hclust 49                0.183            0.995 4
#> SD:hclust 45                0.108            0.308 5
#> SD:hclust 45                0.401            0.940 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.534           0.954       0.943         0.4004 0.560   0.560
#> 3 3 0.769           0.873       0.919         0.4061 0.908   0.835
#> 4 4 0.584           0.560       0.744         0.2072 0.989   0.976
#> 5 5 0.553           0.613       0.764         0.0958 0.771   0.509
#> 6 6 0.593           0.569       0.717         0.0622 0.955   0.820

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
#> GSM213078     1  0.0000      0.981 1.000 0.000
#> GSM213082     2  0.5629      0.964 0.132 0.868
#> GSM213085     1  0.0000      0.981 1.000 0.000
#> GSM213088     1  0.0000      0.981 1.000 0.000
#> GSM213091     1  0.1843      0.958 0.972 0.028
#> GSM213092     1  0.0000      0.981 1.000 0.000
#> GSM213096     1  0.0000      0.981 1.000 0.000
#> GSM213100     1  0.0000      0.981 1.000 0.000
#> GSM213111     2  0.5629      0.964 0.132 0.868
#> GSM213117     1  0.0000      0.981 1.000 0.000
#> GSM213118     1  0.0000      0.981 1.000 0.000
#> GSM213120     2  0.5629      0.964 0.132 0.868
#> GSM213122     2  0.5629      0.964 0.132 0.868
#> GSM213074     1  0.0000      0.981 1.000 0.000
#> GSM213077     1  0.0000      0.981 1.000 0.000
#> GSM213083     1  0.0000      0.981 1.000 0.000
#> GSM213094     1  0.5629      0.856 0.868 0.132
#> GSM213095     2  0.1414      0.855 0.020 0.980
#> GSM213102     1  0.0000      0.981 1.000 0.000
#> GSM213103     2  0.8081      0.836 0.248 0.752
#> GSM213104     1  0.0000      0.981 1.000 0.000
#> GSM213107     2  0.5629      0.964 0.132 0.868
#> GSM213108     2  0.5629      0.964 0.132 0.868
#> GSM213112     1  0.0000      0.981 1.000 0.000
#> GSM213114     1  0.0000      0.981 1.000 0.000
#> GSM213115     2  0.5629      0.964 0.132 0.868
#> GSM213116     1  0.0000      0.981 1.000 0.000
#> GSM213119     2  0.5629      0.964 0.132 0.868
#> GSM213072     1  0.0672      0.974 0.992 0.008
#> GSM213075     1  0.0000      0.981 1.000 0.000
#> GSM213076     2  0.5629      0.964 0.132 0.868
#> GSM213079     1  0.5629      0.856 0.868 0.132
#> GSM213080     1  0.0000      0.981 1.000 0.000
#> GSM213081     1  0.0000      0.981 1.000 0.000
#> GSM213084     1  0.0000      0.981 1.000 0.000
#> GSM213087     2  0.5629      0.964 0.132 0.868
#> GSM213089     1  0.0000      0.981 1.000 0.000
#> GSM213090     1  0.5629      0.856 0.868 0.132
#> GSM213093     1  0.0000      0.981 1.000 0.000
#> GSM213097     1  0.0000      0.981 1.000 0.000
#> GSM213099     1  0.1843      0.958 0.972 0.028
#> GSM213101     1  0.0000      0.981 1.000 0.000
#> GSM213105     2  0.5629      0.964 0.132 0.868
#> GSM213109     1  0.0000      0.981 1.000 0.000
#> GSM213110     2  0.5629      0.964 0.132 0.868
#> GSM213113     1  0.0000      0.981 1.000 0.000
#> GSM213121     2  0.5629      0.964 0.132 0.868
#> GSM213123     1  0.0000      0.981 1.000 0.000
#> GSM213125     2  0.5629      0.964 0.132 0.868
#> GSM213073     1  0.5629      0.856 0.868 0.132
#> GSM213086     1  0.0000      0.981 1.000 0.000
#> GSM213098     1  0.0000      0.981 1.000 0.000
#> GSM213106     1  0.0000      0.981 1.000 0.000
#> GSM213124     2  0.9686      0.572 0.396 0.604

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0747      0.904 0.984 0.000 0.016
#> GSM213082     2  0.0237      0.934 0.000 0.996 0.004
#> GSM213085     1  0.1163      0.901 0.972 0.000 0.028
#> GSM213088     1  0.0747      0.904 0.984 0.000 0.016
#> GSM213091     1  0.6026      0.490 0.624 0.000 0.376
#> GSM213092     1  0.1163      0.901 0.972 0.000 0.028
#> GSM213096     1  0.1643      0.892 0.956 0.000 0.044
#> GSM213100     1  0.0424      0.904 0.992 0.000 0.008
#> GSM213111     2  0.0424      0.934 0.000 0.992 0.008
#> GSM213117     1  0.3340      0.868 0.880 0.000 0.120
#> GSM213118     1  0.1411      0.896 0.964 0.000 0.036
#> GSM213120     2  0.1643      0.925 0.000 0.956 0.044
#> GSM213122     2  0.0237      0.934 0.000 0.996 0.004
#> GSM213074     1  0.4702      0.784 0.788 0.000 0.212
#> GSM213077     1  0.0892      0.904 0.980 0.000 0.020
#> GSM213083     1  0.0747      0.904 0.984 0.000 0.016
#> GSM213094     3  0.2711      0.967 0.088 0.000 0.912
#> GSM213095     2  0.1643      0.925 0.000 0.956 0.044
#> GSM213102     1  0.3340      0.868 0.880 0.000 0.120
#> GSM213103     2  0.6858      0.636 0.188 0.728 0.084
#> GSM213104     1  0.2537      0.868 0.920 0.000 0.080
#> GSM213107     2  0.1411      0.926 0.000 0.964 0.036
#> GSM213108     2  0.0592      0.933 0.000 0.988 0.012
#> GSM213112     1  0.1163      0.901 0.972 0.000 0.028
#> GSM213114     1  0.2066      0.883 0.940 0.000 0.060
#> GSM213115     2  0.0000      0.935 0.000 1.000 0.000
#> GSM213116     1  0.3267      0.870 0.884 0.000 0.116
#> GSM213119     2  0.0237      0.934 0.000 0.996 0.004
#> GSM213072     1  0.4346      0.820 0.816 0.000 0.184
#> GSM213075     1  0.4291      0.819 0.820 0.000 0.180
#> GSM213076     2  0.1529      0.926 0.000 0.960 0.040
#> GSM213079     3  0.2356      0.978 0.072 0.000 0.928
#> GSM213080     1  0.2537      0.868 0.920 0.000 0.080
#> GSM213081     1  0.1163      0.900 0.972 0.000 0.028
#> GSM213084     1  0.0592      0.904 0.988 0.000 0.012
#> GSM213087     2  0.0000      0.935 0.000 1.000 0.000
#> GSM213089     1  0.3686      0.855 0.860 0.000 0.140
#> GSM213090     3  0.2066      0.977 0.060 0.000 0.940
#> GSM213093     1  0.3482      0.863 0.872 0.000 0.128
#> GSM213097     1  0.3340      0.868 0.880 0.000 0.120
#> GSM213099     1  0.6026      0.490 0.624 0.000 0.376
#> GSM213101     1  0.0424      0.903 0.992 0.000 0.008
#> GSM213105     2  0.0237      0.934 0.000 0.996 0.004
#> GSM213109     1  0.1411      0.901 0.964 0.000 0.036
#> GSM213110     2  0.0592      0.933 0.000 0.988 0.012
#> GSM213113     1  0.1964      0.896 0.944 0.000 0.056
#> GSM213121     2  0.1411      0.926 0.000 0.964 0.036
#> GSM213123     1  0.1031      0.904 0.976 0.000 0.024
#> GSM213125     2  0.0237      0.934 0.000 0.996 0.004
#> GSM213073     3  0.1964      0.967 0.056 0.000 0.944
#> GSM213086     1  0.1163      0.901 0.972 0.000 0.028
#> GSM213098     1  0.2537      0.878 0.920 0.000 0.080
#> GSM213106     1  0.3340      0.868 0.880 0.000 0.120
#> GSM213124     2  0.7442      0.370 0.316 0.628 0.056

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0921      0.594 0.972 0.000 0.000 0.028
#> GSM213082     2  0.4605      0.758 0.000 0.664 0.000 0.336
#> GSM213085     1  0.3969      0.539 0.804 0.000 0.016 0.180
#> GSM213088     1  0.4382      0.526 0.704 0.000 0.000 0.296
#> GSM213091     1  0.7788      0.166 0.380 0.000 0.244 0.376
#> GSM213092     1  0.3647      0.547 0.832 0.000 0.016 0.152
#> GSM213096     1  0.4019      0.515 0.792 0.000 0.012 0.196
#> GSM213100     1  0.2124      0.582 0.924 0.000 0.008 0.068
#> GSM213111     2  0.4624      0.754 0.000 0.660 0.000 0.340
#> GSM213117     1  0.6123      0.459 0.572 0.000 0.056 0.372
#> GSM213118     1  0.4963      0.527 0.696 0.000 0.020 0.284
#> GSM213120     2  0.2345      0.643 0.000 0.900 0.000 0.100
#> GSM213122     2  0.4222      0.771 0.000 0.728 0.000 0.272
#> GSM213074     1  0.6889      0.374 0.496 0.000 0.108 0.396
#> GSM213077     1  0.0524      0.594 0.988 0.000 0.008 0.004
#> GSM213083     1  0.0592      0.595 0.984 0.000 0.000 0.016
#> GSM213094     3  0.1929      0.945 0.024 0.000 0.940 0.036
#> GSM213095     2  0.2345      0.646 0.000 0.900 0.000 0.100
#> GSM213102     1  0.5986      0.485 0.620 0.000 0.060 0.320
#> GSM213103     2  0.5749      0.125 0.040 0.680 0.012 0.268
#> GSM213104     1  0.7606      0.154 0.564 0.212 0.020 0.204
#> GSM213107     2  0.0469      0.670 0.000 0.988 0.000 0.012
#> GSM213108     2  0.4872      0.749 0.000 0.640 0.004 0.356
#> GSM213112     1  0.3925      0.540 0.808 0.000 0.016 0.176
#> GSM213114     1  0.4163      0.494 0.792 0.000 0.020 0.188
#> GSM213115     2  0.4454      0.765 0.000 0.692 0.000 0.308
#> GSM213116     1  0.6135      0.455 0.568 0.000 0.056 0.376
#> GSM213119     2  0.4222      0.771 0.000 0.728 0.000 0.272
#> GSM213072     1  0.6884      0.375 0.464 0.000 0.104 0.432
#> GSM213075     1  0.6758      0.370 0.504 0.000 0.096 0.400
#> GSM213076     2  0.1940      0.656 0.000 0.924 0.000 0.076
#> GSM213079     3  0.0779      0.967 0.016 0.000 0.980 0.004
#> GSM213080     1  0.6942      0.282 0.640 0.144 0.020 0.196
#> GSM213081     1  0.2928      0.568 0.880 0.000 0.012 0.108
#> GSM213084     1  0.0336      0.595 0.992 0.000 0.000 0.008
#> GSM213087     2  0.4277      0.771 0.000 0.720 0.000 0.280
#> GSM213089     1  0.6264      0.435 0.560 0.000 0.064 0.376
#> GSM213090     3  0.0804      0.965 0.008 0.000 0.980 0.012
#> GSM213093     1  0.5926      0.492 0.632 0.000 0.060 0.308
#> GSM213097     1  0.5883      0.494 0.640 0.000 0.060 0.300
#> GSM213099     1  0.7746      0.185 0.392 0.000 0.232 0.376
#> GSM213101     1  0.1389      0.596 0.952 0.000 0.000 0.048
#> GSM213105     2  0.4222      0.771 0.000 0.728 0.000 0.272
#> GSM213109     1  0.2542      0.592 0.904 0.000 0.012 0.084
#> GSM213110     2  0.4720      0.761 0.000 0.672 0.004 0.324
#> GSM213113     1  0.5991      0.478 0.620 0.020 0.024 0.336
#> GSM213121     2  0.0469      0.670 0.000 0.988 0.000 0.012
#> GSM213123     1  0.4560      0.533 0.700 0.000 0.004 0.296
#> GSM213125     2  0.4164      0.773 0.000 0.736 0.000 0.264
#> GSM213073     3  0.0469      0.955 0.000 0.000 0.988 0.012
#> GSM213086     1  0.3881      0.541 0.812 0.000 0.016 0.172
#> GSM213098     1  0.8042      0.194 0.456 0.168 0.024 0.352
#> GSM213106     1  0.6041      0.472 0.608 0.000 0.060 0.332
#> GSM213124     4  0.6106      0.000 0.112 0.160 0.016 0.712

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.4817      0.643 0.656 0.000 0.000 0.300 0.044
#> GSM213082     2  0.3003      0.573 0.000 0.812 0.000 0.000 0.188
#> GSM213085     1  0.4180      0.708 0.768 0.000 0.012 0.192 0.028
#> GSM213088     4  0.4254      0.650 0.220 0.000 0.000 0.740 0.040
#> GSM213091     4  0.3806      0.634 0.000 0.000 0.104 0.812 0.084
#> GSM213092     1  0.4140      0.712 0.764 0.000 0.008 0.200 0.028
#> GSM213096     1  0.2846      0.714 0.864 0.000 0.008 0.120 0.008
#> GSM213100     1  0.4548      0.686 0.708 0.000 0.008 0.256 0.028
#> GSM213111     2  0.4385      0.359 0.004 0.672 0.012 0.000 0.312
#> GSM213117     4  0.2020      0.777 0.100 0.000 0.000 0.900 0.000
#> GSM213118     1  0.5314      0.587 0.652 0.000 0.016 0.280 0.052
#> GSM213120     5  0.5071      0.604 0.040 0.340 0.000 0.004 0.616
#> GSM213122     2  0.0000      0.694 0.000 1.000 0.000 0.000 0.000
#> GSM213074     4  0.3207      0.756 0.056 0.000 0.024 0.872 0.048
#> GSM213077     1  0.4900      0.652 0.656 0.000 0.004 0.300 0.040
#> GSM213083     1  0.5107      0.633 0.632 0.000 0.004 0.316 0.048
#> GSM213094     3  0.4127      0.872 0.004 0.000 0.796 0.100 0.100
#> GSM213095     5  0.4772      0.594 0.012 0.352 0.012 0.000 0.624
#> GSM213102     4  0.3238      0.748 0.136 0.000 0.000 0.836 0.028
#> GSM213103     5  0.7859      0.350 0.264 0.228 0.020 0.044 0.444
#> GSM213104     1  0.3840      0.477 0.772 0.000 0.012 0.008 0.208
#> GSM213107     2  0.5453     -0.362 0.044 0.528 0.008 0.000 0.420
#> GSM213108     2  0.4090      0.472 0.000 0.716 0.016 0.000 0.268
#> GSM213112     1  0.4180      0.708 0.768 0.000 0.012 0.192 0.028
#> GSM213114     1  0.2756      0.664 0.892 0.000 0.012 0.036 0.060
#> GSM213115     2  0.2455      0.667 0.004 0.896 0.008 0.004 0.088
#> GSM213116     4  0.2124      0.778 0.096 0.000 0.000 0.900 0.004
#> GSM213119     2  0.0510      0.690 0.000 0.984 0.000 0.000 0.016
#> GSM213072     4  0.4128      0.714 0.092 0.000 0.032 0.816 0.060
#> GSM213075     4  0.2790      0.768 0.060 0.000 0.020 0.892 0.028
#> GSM213076     5  0.4674      0.555 0.016 0.416 0.000 0.000 0.568
#> GSM213079     3  0.1282      0.937 0.004 0.000 0.952 0.044 0.000
#> GSM213080     1  0.2701      0.635 0.884 0.000 0.012 0.012 0.092
#> GSM213081     1  0.5182      0.652 0.708 0.000 0.012 0.184 0.096
#> GSM213084     1  0.4728      0.652 0.664 0.000 0.000 0.296 0.040
#> GSM213087     2  0.1282      0.678 0.000 0.952 0.004 0.000 0.044
#> GSM213089     4  0.1818      0.777 0.044 0.000 0.000 0.932 0.024
#> GSM213090     3  0.2209      0.924 0.000 0.000 0.912 0.032 0.056
#> GSM213093     4  0.3445      0.746 0.140 0.000 0.000 0.824 0.036
#> GSM213097     4  0.3691      0.725 0.156 0.000 0.000 0.804 0.040
#> GSM213099     4  0.3639      0.662 0.000 0.000 0.076 0.824 0.100
#> GSM213101     1  0.4687      0.657 0.672 0.000 0.000 0.288 0.040
#> GSM213105     2  0.0510      0.690 0.000 0.984 0.000 0.000 0.016
#> GSM213109     1  0.5242      0.518 0.556 0.000 0.004 0.400 0.040
#> GSM213110     2  0.2880      0.647 0.004 0.864 0.008 0.004 0.120
#> GSM213113     1  0.6120      0.451 0.596 0.000 0.008 0.224 0.172
#> GSM213121     2  0.5396     -0.364 0.040 0.528 0.008 0.000 0.424
#> GSM213123     4  0.4337      0.637 0.204 0.000 0.000 0.744 0.052
#> GSM213125     2  0.0609      0.694 0.000 0.980 0.000 0.000 0.020
#> GSM213073     3  0.1728      0.933 0.004 0.000 0.940 0.036 0.020
#> GSM213086     1  0.4145      0.709 0.772 0.000 0.012 0.188 0.028
#> GSM213098     1  0.6415      0.286 0.540 0.000 0.012 0.152 0.296
#> GSM213106     4  0.3085      0.762 0.116 0.000 0.000 0.852 0.032
#> GSM213124     4  0.8341      0.041 0.108 0.252 0.016 0.420 0.204

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.2520     0.6129 0.872 0.000 0.000 0.108 0.008 0.012
#> GSM213082     2  0.3445     0.5720 0.000 0.732 0.000 0.000 0.260 0.008
#> GSM213085     1  0.4814     0.5208 0.668 0.000 0.000 0.076 0.012 0.244
#> GSM213088     4  0.4473     0.5463 0.396 0.000 0.000 0.576 0.008 0.020
#> GSM213091     4  0.3611     0.5640 0.004 0.000 0.072 0.832 0.052 0.040
#> GSM213092     1  0.4448     0.5585 0.708 0.000 0.000 0.068 0.008 0.216
#> GSM213096     1  0.4002     0.5633 0.736 0.000 0.000 0.036 0.008 0.220
#> GSM213100     1  0.2942     0.6338 0.860 0.000 0.000 0.068 0.008 0.064
#> GSM213111     2  0.4694     0.3223 0.000 0.572 0.000 0.000 0.376 0.052
#> GSM213117     4  0.3852     0.6763 0.180 0.000 0.000 0.764 0.004 0.052
#> GSM213118     1  0.6128     0.0748 0.444 0.000 0.000 0.192 0.012 0.352
#> GSM213120     5  0.5721     0.5979 0.000 0.188 0.000 0.008 0.556 0.248
#> GSM213122     2  0.0363     0.7663 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM213074     4  0.3439     0.6008 0.080 0.000 0.000 0.832 0.020 0.068
#> GSM213077     1  0.1757     0.6415 0.916 0.000 0.000 0.076 0.000 0.008
#> GSM213083     1  0.1958     0.6321 0.896 0.000 0.000 0.100 0.000 0.004
#> GSM213094     3  0.5803     0.6956 0.000 0.000 0.644 0.124 0.100 0.132
#> GSM213095     5  0.3543     0.6367 0.000 0.224 0.000 0.004 0.756 0.016
#> GSM213102     4  0.3547     0.6644 0.300 0.000 0.000 0.696 0.000 0.004
#> GSM213103     6  0.7213     0.0727 0.040 0.120 0.004 0.084 0.232 0.520
#> GSM213104     1  0.5300     0.0263 0.496 0.000 0.000 0.000 0.104 0.400
#> GSM213107     5  0.5673     0.6313 0.000 0.396 0.000 0.004 0.464 0.136
#> GSM213108     2  0.4952     0.4021 0.000 0.584 0.004 0.004 0.352 0.056
#> GSM213112     1  0.4814     0.5208 0.668 0.000 0.000 0.076 0.012 0.244
#> GSM213114     1  0.3969     0.4273 0.668 0.000 0.000 0.000 0.020 0.312
#> GSM213115     2  0.2512     0.7332 0.000 0.880 0.000 0.000 0.060 0.060
#> GSM213116     4  0.3819     0.6764 0.176 0.000 0.000 0.768 0.004 0.052
#> GSM213119     2  0.0405     0.7610 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM213072     4  0.4820     0.4959 0.112 0.000 0.000 0.716 0.028 0.144
#> GSM213075     4  0.3753     0.6297 0.072 0.000 0.000 0.812 0.028 0.088
#> GSM213076     5  0.4388     0.6599 0.000 0.276 0.000 0.000 0.668 0.056
#> GSM213079     3  0.0146     0.8804 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM213080     1  0.4144     0.3480 0.620 0.000 0.000 0.000 0.020 0.360
#> GSM213081     1  0.4913     0.4367 0.684 0.000 0.000 0.072 0.028 0.216
#> GSM213084     1  0.1866     0.6318 0.908 0.000 0.000 0.084 0.000 0.008
#> GSM213087     2  0.1296     0.7402 0.000 0.952 0.000 0.004 0.032 0.012
#> GSM213089     4  0.2323     0.6711 0.084 0.000 0.000 0.892 0.012 0.012
#> GSM213090     3  0.2001     0.8629 0.000 0.000 0.912 0.008 0.068 0.012
#> GSM213093     4  0.4199     0.6553 0.292 0.000 0.000 0.676 0.008 0.024
#> GSM213097     4  0.4365     0.6208 0.332 0.000 0.000 0.636 0.008 0.024
#> GSM213099     4  0.3965     0.5672 0.016 0.000 0.040 0.816 0.052 0.076
#> GSM213101     1  0.2547     0.6158 0.868 0.000 0.000 0.112 0.004 0.016
#> GSM213105     2  0.0405     0.7610 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM213109     1  0.3802     0.5429 0.748 0.000 0.000 0.208 0.000 0.044
#> GSM213110     2  0.3107     0.7119 0.000 0.844 0.004 0.000 0.080 0.072
#> GSM213113     6  0.6558     0.3815 0.252 0.000 0.000 0.124 0.100 0.524
#> GSM213121     5  0.5600     0.6251 0.000 0.412 0.000 0.004 0.460 0.124
#> GSM213123     4  0.5944     0.4844 0.344 0.000 0.000 0.504 0.024 0.128
#> GSM213125     2  0.1007     0.7635 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM213073     3  0.0508     0.8782 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM213086     1  0.4626     0.5403 0.688 0.000 0.000 0.076 0.008 0.228
#> GSM213098     6  0.5882     0.5358 0.172 0.000 0.000 0.088 0.112 0.628
#> GSM213106     4  0.3586     0.6770 0.268 0.000 0.000 0.720 0.000 0.012
#> GSM213124     4  0.8179    -0.1121 0.060 0.180 0.004 0.376 0.112 0.268

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n development.stage(p) disease.state(p) k
#> SD:kmeans 54                0.688            0.902 2
#> SD:kmeans 51                0.394            0.852 3
#> SD:kmeans 35                0.382            0.615 4
#> SD:kmeans 45                0.627            0.931 5
#> SD:kmeans 42                0.632            0.753 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.811           0.904       0.959         0.4814 0.525   0.525
#> 3 3 0.559           0.718       0.856         0.3976 0.727   0.514
#> 4 4 0.511           0.531       0.713         0.1170 0.894   0.690
#> 5 5 0.514           0.426       0.633         0.0618 0.934   0.758
#> 6 6 0.550           0.362       0.577         0.0372 0.894   0.593

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
#> GSM213078     1  0.0000      0.952 1.000 0.000
#> GSM213082     2  0.0000      0.960 0.000 1.000
#> GSM213085     1  0.0672      0.948 0.992 0.008
#> GSM213088     1  0.6148      0.804 0.848 0.152
#> GSM213091     1  0.0000      0.952 1.000 0.000
#> GSM213092     1  0.0000      0.952 1.000 0.000
#> GSM213096     1  0.0000      0.952 1.000 0.000
#> GSM213100     1  0.0000      0.952 1.000 0.000
#> GSM213111     2  0.0000      0.960 0.000 1.000
#> GSM213117     1  0.0000      0.952 1.000 0.000
#> GSM213118     1  0.1843      0.936 0.972 0.028
#> GSM213120     2  0.0000      0.960 0.000 1.000
#> GSM213122     2  0.0000      0.960 0.000 1.000
#> GSM213074     1  0.0000      0.952 1.000 0.000
#> GSM213077     1  0.0000      0.952 1.000 0.000
#> GSM213083     1  0.0000      0.952 1.000 0.000
#> GSM213094     1  0.4815      0.872 0.896 0.104
#> GSM213095     2  0.0000      0.960 0.000 1.000
#> GSM213102     1  0.0000      0.952 1.000 0.000
#> GSM213103     2  0.0000      0.960 0.000 1.000
#> GSM213104     2  0.1414      0.945 0.020 0.980
#> GSM213107     2  0.0000      0.960 0.000 1.000
#> GSM213108     2  0.0000      0.960 0.000 1.000
#> GSM213112     1  0.0376      0.950 0.996 0.004
#> GSM213114     1  0.0938      0.946 0.988 0.012
#> GSM213115     2  0.0000      0.960 0.000 1.000
#> GSM213116     1  0.0000      0.952 1.000 0.000
#> GSM213119     2  0.0000      0.960 0.000 1.000
#> GSM213072     1  0.0376      0.950 0.996 0.004
#> GSM213075     1  0.4161      0.891 0.916 0.084
#> GSM213076     2  0.0000      0.960 0.000 1.000
#> GSM213079     1  0.5737      0.839 0.864 0.136
#> GSM213080     2  0.8608      0.595 0.284 0.716
#> GSM213081     1  0.0000      0.952 1.000 0.000
#> GSM213084     1  0.0000      0.952 1.000 0.000
#> GSM213087     2  0.0000      0.960 0.000 1.000
#> GSM213089     1  0.0000      0.952 1.000 0.000
#> GSM213090     2  0.9608      0.327 0.384 0.616
#> GSM213093     1  0.0000      0.952 1.000 0.000
#> GSM213097     1  0.0000      0.952 1.000 0.000
#> GSM213099     1  0.0376      0.950 0.996 0.004
#> GSM213101     1  0.0000      0.952 1.000 0.000
#> GSM213105     2  0.0000      0.960 0.000 1.000
#> GSM213109     1  0.0000      0.952 1.000 0.000
#> GSM213110     2  0.0000      0.960 0.000 1.000
#> GSM213113     1  0.9170      0.529 0.668 0.332
#> GSM213121     2  0.0000      0.960 0.000 1.000
#> GSM213123     1  0.0000      0.952 1.000 0.000
#> GSM213125     2  0.0000      0.960 0.000 1.000
#> GSM213073     1  0.9732      0.358 0.596 0.404
#> GSM213086     1  0.0000      0.952 1.000 0.000
#> GSM213098     1  0.8016      0.694 0.756 0.244
#> GSM213106     1  0.0000      0.952 1.000 0.000
#> GSM213124     2  0.1633      0.941 0.024 0.976

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.1529     0.7562 0.960 0.000 0.040
#> GSM213082     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213085     1  0.4912     0.6897 0.796 0.008 0.196
#> GSM213088     1  0.7804     0.5026 0.664 0.120 0.216
#> GSM213091     3  0.1031     0.7535 0.024 0.000 0.976
#> GSM213092     1  0.3686     0.7367 0.860 0.000 0.140
#> GSM213096     1  0.1163     0.7582 0.972 0.000 0.028
#> GSM213100     1  0.2165     0.7641 0.936 0.000 0.064
#> GSM213111     2  0.0424     0.9707 0.000 0.992 0.008
#> GSM213117     3  0.6835     0.6182 0.284 0.040 0.676
#> GSM213118     1  0.6904     0.5759 0.684 0.048 0.268
#> GSM213120     2  0.1643     0.9508 0.000 0.956 0.044
#> GSM213122     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213074     3  0.3619     0.7483 0.136 0.000 0.864
#> GSM213077     1  0.3482     0.7438 0.872 0.000 0.128
#> GSM213083     1  0.2796     0.7517 0.908 0.000 0.092
#> GSM213094     3  0.0424     0.7486 0.008 0.000 0.992
#> GSM213095     2  0.1289     0.9602 0.000 0.968 0.032
#> GSM213102     3  0.6286     0.2444 0.464 0.000 0.536
#> GSM213103     2  0.3356     0.9102 0.056 0.908 0.036
#> GSM213104     1  0.7186     0.5402 0.696 0.224 0.080
#> GSM213107     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213108     2  0.1860     0.9458 0.000 0.948 0.052
#> GSM213112     1  0.5178     0.6397 0.744 0.000 0.256
#> GSM213114     1  0.0237     0.7522 0.996 0.000 0.004
#> GSM213115     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213116     3  0.5591     0.6052 0.304 0.000 0.696
#> GSM213119     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213072     3  0.3116     0.7382 0.108 0.000 0.892
#> GSM213075     3  0.6495     0.6850 0.200 0.060 0.740
#> GSM213076     2  0.1163     0.9623 0.000 0.972 0.028
#> GSM213079     3  0.0892     0.7475 0.020 0.000 0.980
#> GSM213080     1  0.3207     0.7238 0.904 0.084 0.012
#> GSM213081     1  0.3941     0.7203 0.844 0.000 0.156
#> GSM213084     1  0.2537     0.7611 0.920 0.000 0.080
#> GSM213087     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213089     3  0.3482     0.7484 0.128 0.000 0.872
#> GSM213090     3  0.3276     0.7186 0.024 0.068 0.908
#> GSM213093     3  0.5785     0.5617 0.332 0.000 0.668
#> GSM213097     1  0.6309    -0.1700 0.500 0.000 0.500
#> GSM213099     3  0.1163     0.7552 0.028 0.000 0.972
#> GSM213101     1  0.1529     0.7576 0.960 0.000 0.040
#> GSM213105     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213109     1  0.5465     0.5569 0.712 0.000 0.288
#> GSM213110     2  0.0592     0.9674 0.012 0.988 0.000
#> GSM213113     3  0.8775     0.1201 0.384 0.116 0.500
#> GSM213121     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213123     1  0.6280     0.0844 0.540 0.000 0.460
#> GSM213125     2  0.0000     0.9728 0.000 1.000 0.000
#> GSM213073     3  0.3276     0.7348 0.068 0.024 0.908
#> GSM213086     1  0.2165     0.7617 0.936 0.000 0.064
#> GSM213098     1  0.8652     0.1910 0.492 0.104 0.404
#> GSM213106     3  0.6675     0.4219 0.404 0.012 0.584
#> GSM213124     2  0.4999     0.8039 0.028 0.820 0.152

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.4994     0.3311 0.520 0.000 0.480 0.000
#> GSM213082     2  0.0712     0.9152 0.004 0.984 0.004 0.008
#> GSM213085     1  0.6539     0.4376 0.652 0.004 0.172 0.172
#> GSM213088     3  0.6964     0.2875 0.240 0.056 0.640 0.064
#> GSM213091     4  0.4453     0.5188 0.012 0.000 0.244 0.744
#> GSM213092     1  0.6102     0.4748 0.672 0.000 0.212 0.116
#> GSM213096     1  0.4321     0.5420 0.796 0.004 0.176 0.024
#> GSM213100     1  0.6055     0.4286 0.576 0.000 0.372 0.052
#> GSM213111     2  0.2360     0.9034 0.004 0.924 0.020 0.052
#> GSM213117     3  0.7080     0.2596 0.128 0.004 0.544 0.324
#> GSM213118     1  0.7799     0.2745 0.536 0.024 0.264 0.176
#> GSM213120     2  0.4372     0.8612 0.040 0.840 0.040 0.080
#> GSM213122     2  0.0188     0.9154 0.004 0.996 0.000 0.000
#> GSM213074     4  0.6465     0.1694 0.072 0.000 0.412 0.516
#> GSM213077     1  0.5773     0.4686 0.620 0.000 0.336 0.044
#> GSM213083     1  0.6334     0.2919 0.484 0.000 0.456 0.060
#> GSM213094     4  0.1637     0.5984 0.000 0.000 0.060 0.940
#> GSM213095     2  0.4288     0.8383 0.020 0.820 0.020 0.140
#> GSM213102     3  0.6110     0.5233 0.144 0.000 0.680 0.176
#> GSM213103     2  0.6510     0.6842 0.180 0.696 0.076 0.048
#> GSM213104     1  0.6967     0.3894 0.684 0.124 0.112 0.080
#> GSM213107     2  0.2170     0.9094 0.016 0.936 0.012 0.036
#> GSM213108     2  0.4129     0.8319 0.008 0.828 0.032 0.132
#> GSM213112     1  0.6742     0.3812 0.608 0.000 0.160 0.232
#> GSM213114     1  0.3538     0.5383 0.832 0.004 0.160 0.004
#> GSM213115     2  0.0000     0.9149 0.000 1.000 0.000 0.000
#> GSM213116     3  0.6928     0.2924 0.136 0.000 0.556 0.308
#> GSM213119     2  0.0188     0.9154 0.004 0.996 0.000 0.000
#> GSM213072     4  0.6585     0.3982 0.104 0.000 0.312 0.584
#> GSM213075     3  0.7946     0.0724 0.072 0.072 0.468 0.388
#> GSM213076     2  0.3159     0.8920 0.012 0.892 0.028 0.068
#> GSM213079     4  0.2124     0.5959 0.028 0.000 0.040 0.932
#> GSM213080     1  0.4747     0.5150 0.780 0.024 0.180 0.016
#> GSM213081     1  0.6702     0.2711 0.512 0.000 0.396 0.092
#> GSM213084     1  0.6090     0.4340 0.564 0.000 0.384 0.052
#> GSM213087     2  0.0188     0.9155 0.004 0.996 0.000 0.000
#> GSM213089     4  0.6631     0.1656 0.048 0.016 0.428 0.508
#> GSM213090     4  0.3991     0.5624 0.064 0.032 0.044 0.860
#> GSM213093     3  0.7184     0.3502 0.144 0.000 0.492 0.364
#> GSM213097     3  0.6545     0.4437 0.216 0.000 0.632 0.152
#> GSM213099     4  0.4855     0.5108 0.020 0.000 0.268 0.712
#> GSM213101     1  0.5161     0.3610 0.520 0.000 0.476 0.004
#> GSM213105     2  0.0000     0.9149 0.000 1.000 0.000 0.000
#> GSM213109     3  0.6995    -0.0438 0.384 0.000 0.496 0.120
#> GSM213110     2  0.1985     0.9021 0.040 0.940 0.004 0.016
#> GSM213113     4  0.8953     0.1062 0.296 0.068 0.220 0.416
#> GSM213121     2  0.1509     0.9123 0.008 0.960 0.012 0.020
#> GSM213123     3  0.7431     0.3304 0.244 0.008 0.552 0.196
#> GSM213125     2  0.0376     0.9150 0.000 0.992 0.004 0.004
#> GSM213073     4  0.4834     0.5279 0.096 0.028 0.064 0.812
#> GSM213086     1  0.5142     0.5224 0.744 0.000 0.192 0.064
#> GSM213098     1  0.8031     0.0375 0.452 0.028 0.152 0.368
#> GSM213106     3  0.6418     0.5201 0.112 0.012 0.672 0.204
#> GSM213124     2  0.7119     0.6183 0.068 0.668 0.132 0.132

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.5988    0.35302 0.508 0.000 0.004 0.388 0.100
#> GSM213082     2  0.2027    0.82412 0.000 0.928 0.024 0.008 0.040
#> GSM213085     1  0.5976    0.23171 0.644 0.000 0.060 0.060 0.236
#> GSM213088     4  0.6765    0.22716 0.200 0.056 0.036 0.632 0.076
#> GSM213091     3  0.5580    0.35117 0.020 0.000 0.620 0.304 0.056
#> GSM213092     1  0.6650    0.26302 0.608 0.000 0.084 0.104 0.204
#> GSM213096     1  0.5074    0.37322 0.724 0.000 0.020 0.076 0.180
#> GSM213100     1  0.5570    0.44249 0.712 0.000 0.048 0.120 0.120
#> GSM213111     2  0.3340    0.81591 0.004 0.860 0.028 0.016 0.092
#> GSM213117     4  0.8787    0.23209 0.164 0.032 0.244 0.396 0.164
#> GSM213118     5  0.7869   -0.00623 0.368 0.012 0.096 0.120 0.404
#> GSM213120     2  0.4782    0.74718 0.000 0.728 0.048 0.016 0.208
#> GSM213122     2  0.0404    0.82726 0.000 0.988 0.000 0.000 0.012
#> GSM213074     3  0.7884    0.03719 0.144 0.000 0.408 0.324 0.124
#> GSM213077     1  0.5216    0.48389 0.720 0.000 0.048 0.184 0.048
#> GSM213083     1  0.5337    0.43359 0.616 0.000 0.016 0.328 0.040
#> GSM213094     3  0.3257    0.52980 0.004 0.000 0.844 0.124 0.028
#> GSM213095     2  0.5809    0.63548 0.000 0.640 0.188 0.008 0.164
#> GSM213102     4  0.6402    0.40259 0.220 0.000 0.096 0.620 0.064
#> GSM213103     2  0.7705    0.09940 0.104 0.412 0.068 0.024 0.392
#> GSM213104     5  0.7351    0.04950 0.380 0.064 0.044 0.048 0.464
#> GSM213107     2  0.3840    0.77375 0.004 0.784 0.016 0.004 0.192
#> GSM213108     2  0.4108    0.76907 0.000 0.804 0.116 0.012 0.068
#> GSM213112     1  0.7079    0.15861 0.548 0.000 0.136 0.076 0.240
#> GSM213114     1  0.5625    0.35798 0.652 0.004 0.004 0.112 0.228
#> GSM213115     2  0.1197    0.82693 0.000 0.952 0.000 0.000 0.048
#> GSM213116     4  0.7894    0.14359 0.136 0.000 0.328 0.404 0.132
#> GSM213119     2  0.0404    0.82691 0.000 0.988 0.000 0.000 0.012
#> GSM213072     3  0.7969    0.22220 0.192 0.000 0.460 0.176 0.172
#> GSM213075     4  0.8118    0.03058 0.084 0.036 0.360 0.408 0.112
#> GSM213076     2  0.5259    0.74112 0.004 0.712 0.080 0.016 0.188
#> GSM213079     3  0.2710    0.53790 0.008 0.000 0.892 0.036 0.064
#> GSM213080     1  0.6870    0.06050 0.464 0.032 0.000 0.136 0.368
#> GSM213081     1  0.7795    0.18648 0.364 0.000 0.068 0.340 0.228
#> GSM213084     1  0.5404    0.49301 0.664 0.000 0.032 0.260 0.044
#> GSM213087     2  0.1571    0.82564 0.000 0.936 0.000 0.004 0.060
#> GSM213089     4  0.7132   -0.05421 0.060 0.008 0.396 0.448 0.088
#> GSM213090     3  0.4697    0.46968 0.040 0.020 0.768 0.012 0.160
#> GSM213093     4  0.6670    0.39002 0.148 0.000 0.208 0.592 0.052
#> GSM213097     4  0.5741    0.42487 0.140 0.000 0.100 0.700 0.060
#> GSM213099     3  0.6118    0.27289 0.052 0.000 0.572 0.328 0.048
#> GSM213101     1  0.5992    0.40627 0.560 0.000 0.008 0.328 0.104
#> GSM213105     2  0.0510    0.82542 0.000 0.984 0.000 0.000 0.016
#> GSM213109     1  0.6878    0.26670 0.496 0.000 0.076 0.352 0.076
#> GSM213110     2  0.3144    0.79967 0.020 0.872 0.004 0.020 0.084
#> GSM213113     5  0.8249    0.14902 0.092 0.036 0.352 0.120 0.400
#> GSM213121     2  0.3087    0.79824 0.000 0.836 0.008 0.004 0.152
#> GSM213123     4  0.7058    0.30560 0.208 0.000 0.096 0.568 0.128
#> GSM213125     2  0.0727    0.82909 0.000 0.980 0.004 0.004 0.012
#> GSM213073     3  0.5233    0.37811 0.052 0.008 0.728 0.032 0.180
#> GSM213086     1  0.6310    0.30451 0.632 0.000 0.052 0.116 0.200
#> GSM213098     5  0.7948    0.36137 0.112 0.040 0.252 0.088 0.508
#> GSM213106     4  0.5670    0.46178 0.096 0.000 0.144 0.704 0.056
#> GSM213124     2  0.8298    0.30130 0.080 0.500 0.092 0.100 0.228

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     5  0.6034     0.0385 0.120 0.000 0.000 0.412 0.440 0.028
#> GSM213082     2  0.2200     0.7781 0.004 0.900 0.012 0.000 0.004 0.080
#> GSM213085     1  0.6077     0.3673 0.620 0.000 0.048 0.040 0.224 0.068
#> GSM213088     4  0.6688     0.2555 0.068 0.028 0.020 0.596 0.208 0.080
#> GSM213091     3  0.5810     0.4449 0.032 0.000 0.616 0.232 0.012 0.108
#> GSM213092     1  0.6220     0.3491 0.612 0.000 0.044 0.084 0.216 0.044
#> GSM213096     1  0.6567     0.2549 0.448 0.004 0.000 0.080 0.372 0.096
#> GSM213100     1  0.6690     0.3590 0.508 0.000 0.012 0.216 0.220 0.044
#> GSM213111     2  0.3492     0.7585 0.004 0.816 0.028 0.000 0.016 0.136
#> GSM213117     4  0.8331     0.0927 0.124 0.004 0.184 0.340 0.064 0.284
#> GSM213118     1  0.8259     0.1135 0.328 0.012 0.060 0.072 0.272 0.256
#> GSM213120     2  0.5453     0.6052 0.012 0.660 0.032 0.012 0.048 0.236
#> GSM213122     2  0.1010     0.7877 0.000 0.960 0.000 0.000 0.004 0.036
#> GSM213074     3  0.7922     0.2157 0.220 0.000 0.384 0.212 0.028 0.156
#> GSM213077     1  0.6974     0.2974 0.412 0.000 0.028 0.288 0.252 0.020
#> GSM213083     1  0.7070     0.2055 0.368 0.000 0.036 0.328 0.252 0.016
#> GSM213094     3  0.3240     0.5188 0.032 0.000 0.856 0.052 0.004 0.056
#> GSM213095     2  0.6057     0.5748 0.032 0.644 0.128 0.000 0.048 0.148
#> GSM213102     4  0.6544     0.3589 0.156 0.000 0.076 0.616 0.060 0.092
#> GSM213103     6  0.7575    -0.0804 0.096 0.340 0.016 0.012 0.144 0.392
#> GSM213104     5  0.5718     0.2798 0.092 0.076 0.024 0.012 0.704 0.092
#> GSM213107     2  0.4105     0.7299 0.004 0.780 0.008 0.004 0.076 0.128
#> GSM213108     2  0.5111     0.6413 0.012 0.716 0.080 0.024 0.008 0.160
#> GSM213112     1  0.7028     0.3443 0.584 0.004 0.092 0.096 0.148 0.076
#> GSM213114     5  0.4677     0.2474 0.144 0.000 0.004 0.116 0.724 0.012
#> GSM213115     2  0.2006     0.7700 0.000 0.904 0.000 0.000 0.016 0.080
#> GSM213116     4  0.8397     0.0200 0.172 0.000 0.216 0.304 0.056 0.252
#> GSM213119     2  0.0632     0.7867 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM213072     3  0.7988     0.2382 0.216 0.000 0.400 0.088 0.068 0.228
#> GSM213075     6  0.8609    -0.3043 0.044 0.044 0.272 0.260 0.080 0.300
#> GSM213076     2  0.5368     0.6563 0.008 0.704 0.064 0.016 0.044 0.164
#> GSM213079     3  0.2783     0.5138 0.044 0.000 0.888 0.028 0.016 0.024
#> GSM213080     5  0.4838     0.3494 0.052 0.048 0.004 0.088 0.768 0.040
#> GSM213081     5  0.7161     0.1406 0.108 0.000 0.044 0.348 0.436 0.064
#> GSM213084     4  0.7117    -0.2535 0.324 0.000 0.020 0.352 0.272 0.032
#> GSM213087     2  0.1779     0.7814 0.000 0.920 0.000 0.000 0.016 0.064
#> GSM213089     3  0.7549     0.1580 0.096 0.000 0.380 0.344 0.032 0.148
#> GSM213090     3  0.4739     0.4576 0.120 0.000 0.744 0.020 0.016 0.100
#> GSM213093     4  0.7268     0.3327 0.116 0.000 0.168 0.544 0.080 0.092
#> GSM213097     4  0.5165     0.3819 0.076 0.000 0.064 0.740 0.080 0.040
#> GSM213099     3  0.6108     0.4650 0.044 0.000 0.608 0.216 0.020 0.112
#> GSM213101     4  0.7043    -0.0781 0.256 0.000 0.004 0.416 0.260 0.064
#> GSM213105     2  0.0790     0.7844 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM213109     1  0.6981     0.2281 0.460 0.000 0.048 0.340 0.104 0.048
#> GSM213110     2  0.4227     0.6882 0.020 0.784 0.004 0.016 0.040 0.136
#> GSM213113     3  0.9175     0.0168 0.200 0.032 0.304 0.100 0.192 0.172
#> GSM213121     2  0.3065     0.7644 0.000 0.844 0.004 0.000 0.052 0.100
#> GSM213123     4  0.7879     0.2218 0.176 0.000 0.084 0.468 0.132 0.140
#> GSM213125     2  0.0632     0.7879 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM213073     3  0.4933     0.4534 0.088 0.004 0.756 0.020 0.072 0.060
#> GSM213086     1  0.6381     0.3033 0.540 0.000 0.016 0.064 0.296 0.084
#> GSM213098     5  0.7973     0.1724 0.120 0.004 0.172 0.056 0.440 0.208
#> GSM213106     4  0.6451     0.3910 0.092 0.000 0.104 0.628 0.048 0.128
#> GSM213124     2  0.7815    -0.2044 0.112 0.396 0.044 0.048 0.044 0.356

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 development.stage(p) disease.state(p) k
#> SD:skmeans 52                0.876            0.739 2
#> SD:skmeans 48                0.285            0.817 3
#> SD:skmeans 29                0.762            0.405 4
#> SD:skmeans 17                1.000            1.000 5
#> SD:skmeans 17                1.000            1.000 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.883           0.918       0.964         0.4180 0.575   0.575
#> 3 3 0.504           0.693       0.856         0.5224 0.763   0.594
#> 4 4 0.466           0.656       0.808         0.0355 1.000   1.000
#> 5 5 0.414           0.566       0.797         0.0181 0.984   0.955
#> 6 6 0.464           0.538       0.777         0.0103 0.976   0.932

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
#> GSM213078     1  0.0000      0.976 1.000 0.000
#> GSM213082     2  0.0000      0.921 0.000 1.000
#> GSM213085     1  0.0000      0.976 1.000 0.000
#> GSM213088     1  0.1414      0.963 0.980 0.020
#> GSM213091     1  0.0000      0.976 1.000 0.000
#> GSM213092     1  0.0000      0.976 1.000 0.000
#> GSM213096     1  0.0000      0.976 1.000 0.000
#> GSM213100     1  0.0000      0.976 1.000 0.000
#> GSM213111     2  0.0000      0.921 0.000 1.000
#> GSM213117     1  0.0000      0.976 1.000 0.000
#> GSM213118     1  0.0000      0.976 1.000 0.000
#> GSM213120     2  0.9522      0.462 0.372 0.628
#> GSM213122     2  0.0000      0.921 0.000 1.000
#> GSM213074     1  0.0000      0.976 1.000 0.000
#> GSM213077     1  0.0000      0.976 1.000 0.000
#> GSM213083     1  0.0000      0.976 1.000 0.000
#> GSM213094     1  0.2948      0.933 0.948 0.052
#> GSM213095     2  0.1414      0.910 0.020 0.980
#> GSM213102     1  0.0672      0.971 0.992 0.008
#> GSM213103     2  0.9815      0.334 0.420 0.580
#> GSM213104     1  0.2603      0.942 0.956 0.044
#> GSM213107     2  0.0000      0.921 0.000 1.000
#> GSM213108     2  0.0000      0.921 0.000 1.000
#> GSM213112     1  0.0672      0.972 0.992 0.008
#> GSM213114     1  0.0000      0.976 1.000 0.000
#> GSM213115     2  0.0000      0.921 0.000 1.000
#> GSM213116     1  0.0000      0.976 1.000 0.000
#> GSM213119     2  0.0000      0.921 0.000 1.000
#> GSM213072     1  0.1633      0.959 0.976 0.024
#> GSM213075     1  0.4298      0.894 0.912 0.088
#> GSM213076     1  0.9286      0.475 0.656 0.344
#> GSM213079     1  0.0000      0.976 1.000 0.000
#> GSM213080     1  0.1414      0.963 0.980 0.020
#> GSM213081     1  0.0000      0.976 1.000 0.000
#> GSM213084     1  0.0000      0.976 1.000 0.000
#> GSM213087     2  0.0000      0.921 0.000 1.000
#> GSM213089     1  0.0000      0.976 1.000 0.000
#> GSM213090     1  0.7376      0.734 0.792 0.208
#> GSM213093     1  0.0000      0.976 1.000 0.000
#> GSM213097     1  0.0000      0.976 1.000 0.000
#> GSM213099     1  0.0000      0.976 1.000 0.000
#> GSM213101     1  0.0000      0.976 1.000 0.000
#> GSM213105     2  0.0000      0.921 0.000 1.000
#> GSM213109     1  0.0000      0.976 1.000 0.000
#> GSM213110     2  0.6343      0.801 0.160 0.840
#> GSM213113     1  0.0000      0.976 1.000 0.000
#> GSM213121     2  0.0000      0.921 0.000 1.000
#> GSM213123     1  0.0000      0.976 1.000 0.000
#> GSM213125     2  0.0000      0.921 0.000 1.000
#> GSM213073     1  0.0376      0.974 0.996 0.004
#> GSM213086     1  0.0000      0.976 1.000 0.000
#> GSM213098     1  0.0000      0.976 1.000 0.000
#> GSM213106     1  0.0000      0.976 1.000 0.000
#> GSM213124     2  0.6343      0.801 0.160 0.840

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1   0.000      0.798 1.000 0.000 0.000
#> GSM213082     2   0.000      0.901 0.000 1.000 0.000
#> GSM213085     3   0.418      0.781 0.172 0.000 0.828
#> GSM213088     1   0.000      0.798 1.000 0.000 0.000
#> GSM213091     1   0.621      0.365 0.572 0.000 0.428
#> GSM213092     3   0.429      0.779 0.180 0.000 0.820
#> GSM213096     1   0.129      0.798 0.968 0.000 0.032
#> GSM213100     1   0.116      0.799 0.972 0.000 0.028
#> GSM213111     2   0.000      0.901 0.000 1.000 0.000
#> GSM213117     1   0.236      0.774 0.928 0.000 0.072
#> GSM213118     3   0.484      0.752 0.224 0.000 0.776
#> GSM213120     2   0.610      0.471 0.348 0.648 0.004
#> GSM213122     2   0.000      0.901 0.000 1.000 0.000
#> GSM213074     1   0.565      0.452 0.688 0.000 0.312
#> GSM213077     1   0.424      0.706 0.824 0.000 0.176
#> GSM213083     1   0.116      0.800 0.972 0.000 0.028
#> GSM213094     3   0.103      0.751 0.024 0.000 0.976
#> GSM213095     3   0.562      0.504 0.000 0.308 0.692
#> GSM213102     1   0.116      0.796 0.972 0.000 0.028
#> GSM213103     2   0.647      0.239 0.444 0.552 0.004
#> GSM213104     3   0.631      0.620 0.328 0.012 0.660
#> GSM213107     2   0.000      0.901 0.000 1.000 0.000
#> GSM213108     2   0.000      0.901 0.000 1.000 0.000
#> GSM213112     3   0.435      0.779 0.184 0.000 0.816
#> GSM213114     1   0.000      0.798 1.000 0.000 0.000
#> GSM213115     2   0.000      0.901 0.000 1.000 0.000
#> GSM213116     1   0.362      0.734 0.864 0.000 0.136
#> GSM213119     2   0.000      0.901 0.000 1.000 0.000
#> GSM213072     1   0.576      0.462 0.672 0.000 0.328
#> GSM213075     1   0.186      0.781 0.948 0.052 0.000
#> GSM213076     1   0.719      0.407 0.608 0.356 0.036
#> GSM213079     3   0.000      0.741 0.000 0.000 1.000
#> GSM213080     1   0.000      0.798 1.000 0.000 0.000
#> GSM213081     1   0.153      0.797 0.960 0.000 0.040
#> GSM213084     1   0.288      0.767 0.904 0.000 0.096
#> GSM213087     2   0.000      0.901 0.000 1.000 0.000
#> GSM213089     1   0.630      0.166 0.520 0.000 0.480
#> GSM213090     3   0.000      0.741 0.000 0.000 1.000
#> GSM213093     1   0.556      0.521 0.700 0.000 0.300
#> GSM213097     1   0.288      0.779 0.904 0.000 0.096
#> GSM213099     1   0.631      0.087 0.512 0.000 0.488
#> GSM213101     1   0.000      0.798 1.000 0.000 0.000
#> GSM213105     2   0.000      0.901 0.000 1.000 0.000
#> GSM213109     1   0.196      0.796 0.944 0.000 0.056
#> GSM213110     2   0.400      0.762 0.160 0.840 0.000
#> GSM213113     3   0.629      0.235 0.468 0.000 0.532
#> GSM213121     2   0.000      0.901 0.000 1.000 0.000
#> GSM213123     1   0.627      0.132 0.548 0.000 0.452
#> GSM213125     2   0.000      0.901 0.000 1.000 0.000
#> GSM213073     3   0.129      0.757 0.032 0.000 0.968
#> GSM213086     3   0.440      0.778 0.188 0.000 0.812
#> GSM213098     3   0.621      0.359 0.428 0.000 0.572
#> GSM213106     1   0.288      0.769 0.904 0.000 0.096
#> GSM213124     2   0.439      0.767 0.148 0.840 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0188    0.78331 0.996 0.000 0.000 0.004
#> GSM213082     2  0.3444    0.83104 0.000 0.816 0.000 0.184
#> GSM213085     3  0.3172    0.73465 0.160 0.000 0.840 0.000
#> GSM213088     1  0.0000    0.78340 1.000 0.000 0.000 0.000
#> GSM213091     1  0.6554    0.33732 0.540 0.000 0.376 0.084
#> GSM213092     3  0.3266    0.73339 0.168 0.000 0.832 0.000
#> GSM213096     1  0.1305    0.78265 0.960 0.000 0.036 0.004
#> GSM213100     1  0.1209    0.78354 0.964 0.000 0.032 0.004
#> GSM213111     2  0.0188    0.84269 0.000 0.996 0.000 0.004
#> GSM213117     1  0.3216    0.74507 0.880 0.000 0.044 0.076
#> GSM213118     3  0.3831    0.71599 0.204 0.000 0.792 0.004
#> GSM213120     2  0.4855    0.45634 0.352 0.644 0.004 0.000
#> GSM213122     2  0.2647    0.83956 0.000 0.880 0.000 0.120
#> GSM213074     1  0.4857    0.41393 0.668 0.000 0.324 0.008
#> GSM213077     1  0.3583    0.69481 0.816 0.000 0.180 0.004
#> GSM213083     1  0.1109    0.78567 0.968 0.000 0.028 0.004
#> GSM213094     3  0.5378    0.51980 0.012 0.000 0.540 0.448
#> GSM213095     3  0.4837    0.46127 0.000 0.348 0.648 0.004
#> GSM213102     1  0.1936    0.77660 0.940 0.000 0.032 0.028
#> GSM213103     2  0.5408    0.25471 0.432 0.556 0.008 0.004
#> GSM213104     3  0.5266    0.58207 0.324 0.016 0.656 0.004
#> GSM213107     2  0.0469    0.84207 0.000 0.988 0.000 0.012
#> GSM213108     2  0.0000    0.84322 0.000 1.000 0.000 0.000
#> GSM213112     3  0.3266    0.73373 0.168 0.000 0.832 0.000
#> GSM213114     1  0.0188    0.78331 0.996 0.000 0.000 0.004
#> GSM213115     2  0.1302    0.84778 0.000 0.956 0.000 0.044
#> GSM213116     1  0.3052    0.72020 0.860 0.000 0.136 0.004
#> GSM213119     2  0.3444    0.83104 0.000 0.816 0.000 0.184
#> GSM213072     1  0.4761    0.44656 0.664 0.000 0.332 0.004
#> GSM213075     1  0.1792    0.76337 0.932 0.068 0.000 0.000
#> GSM213076     1  0.6009    0.34983 0.560 0.400 0.036 0.004
#> GSM213079     3  0.2973    0.66380 0.000 0.000 0.856 0.144
#> GSM213080     1  0.0188    0.78331 0.996 0.000 0.000 0.004
#> GSM213081     1  0.1398    0.78315 0.956 0.000 0.040 0.004
#> GSM213084     1  0.2466    0.75481 0.900 0.000 0.096 0.004
#> GSM213087     2  0.3444    0.83104 0.000 0.816 0.000 0.184
#> GSM213089     1  0.6491    0.16247 0.496 0.000 0.432 0.072
#> GSM213090     3  0.0921    0.69216 0.000 0.000 0.972 0.028
#> GSM213093     1  0.4608    0.51199 0.692 0.000 0.304 0.004
#> GSM213097     1  0.3156    0.76009 0.884 0.000 0.068 0.048
#> GSM213099     1  0.6661   -0.00213 0.460 0.000 0.456 0.084
#> GSM213101     1  0.0000    0.78340 1.000 0.000 0.000 0.000
#> GSM213105     2  0.3444    0.83104 0.000 0.816 0.000 0.184
#> GSM213109     1  0.1743    0.78364 0.940 0.000 0.056 0.004
#> GSM213110     2  0.3266    0.73867 0.168 0.832 0.000 0.000
#> GSM213113     3  0.4977    0.23116 0.460 0.000 0.540 0.000
#> GSM213121     2  0.1389    0.84622 0.000 0.952 0.000 0.048
#> GSM213123     1  0.5543    0.18899 0.556 0.000 0.424 0.020
#> GSM213125     2  0.0817    0.84732 0.000 0.976 0.000 0.024
#> GSM213073     3  0.5367    0.60327 0.032 0.000 0.664 0.304
#> GSM213086     3  0.3356    0.73243 0.176 0.000 0.824 0.000
#> GSM213098     3  0.4877    0.36825 0.408 0.000 0.592 0.000
#> GSM213106     1  0.3320    0.74172 0.876 0.000 0.056 0.068
#> GSM213124     2  0.4075    0.75433 0.128 0.832 0.032 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
#> GSM213078     1  0.0000     0.7725 1.000 0.000 0.000 0.000 0.000
#> GSM213082     2  0.3636     0.7461 0.000 0.728 0.000 0.000 0.272
#> GSM213085     4  0.2773     0.6399 0.164 0.000 0.000 0.836 0.000
#> GSM213088     1  0.0162     0.7729 0.996 0.000 0.000 0.004 0.000
#> GSM213091     1  0.6133     0.3257 0.540 0.000 0.160 0.300 0.000
#> GSM213092     4  0.2929     0.6437 0.180 0.000 0.000 0.820 0.000
#> GSM213096     1  0.1357     0.7698 0.948 0.000 0.000 0.048 0.004
#> GSM213100     1  0.1282     0.7710 0.952 0.000 0.000 0.044 0.004
#> GSM213111     2  0.0162     0.7778 0.000 0.996 0.000 0.000 0.004
#> GSM213117     1  0.2886     0.7332 0.864 0.000 0.116 0.016 0.004
#> GSM213118     4  0.3300     0.6410 0.204 0.000 0.000 0.792 0.004
#> GSM213120     2  0.4298     0.4277 0.352 0.640 0.008 0.000 0.000
#> GSM213122     2  0.2773     0.7704 0.000 0.836 0.000 0.000 0.164
#> GSM213074     1  0.4147     0.4345 0.676 0.000 0.008 0.316 0.000
#> GSM213077     1  0.3039     0.6756 0.808 0.000 0.000 0.192 0.000
#> GSM213083     1  0.0880     0.7753 0.968 0.000 0.000 0.032 0.000
#> GSM213094     3  0.2719     0.0000 0.004 0.000 0.852 0.144 0.000
#> GSM213095     4  0.4227     0.0117 0.000 0.420 0.000 0.580 0.000
#> GSM213102     1  0.2067     0.7639 0.920 0.000 0.048 0.032 0.000
#> GSM213103     2  0.4764     0.2461 0.436 0.548 0.000 0.012 0.004
#> GSM213104     4  0.4859     0.5325 0.364 0.024 0.000 0.608 0.004
#> GSM213107     2  0.0912     0.7769 0.000 0.972 0.016 0.000 0.012
#> GSM213108     2  0.0000     0.7787 0.000 1.000 0.000 0.000 0.000
#> GSM213112     4  0.2929     0.6474 0.180 0.000 0.000 0.820 0.000
#> GSM213114     1  0.0000     0.7725 1.000 0.000 0.000 0.000 0.000
#> GSM213115     2  0.1608     0.7873 0.000 0.928 0.000 0.000 0.072
#> GSM213116     1  0.2798     0.7076 0.852 0.000 0.008 0.140 0.000
#> GSM213119     2  0.3636     0.7461 0.000 0.728 0.000 0.000 0.272
#> GSM213072     1  0.4302     0.4091 0.648 0.000 0.004 0.344 0.004
#> GSM213075     1  0.1704     0.7534 0.928 0.068 0.000 0.004 0.000
#> GSM213076     1  0.5272     0.3015 0.540 0.416 0.000 0.040 0.004
#> GSM213079     4  0.6033    -0.3586 0.000 0.000 0.200 0.580 0.220
#> GSM213080     1  0.0162     0.7736 0.996 0.000 0.000 0.004 0.000
#> GSM213081     1  0.1043     0.7726 0.960 0.000 0.000 0.040 0.000
#> GSM213084     1  0.1965     0.7432 0.904 0.000 0.000 0.096 0.000
#> GSM213087     2  0.3636     0.7461 0.000 0.728 0.000 0.000 0.272
#> GSM213089     1  0.6077     0.1008 0.480 0.000 0.124 0.396 0.000
#> GSM213090     4  0.2889     0.1441 0.000 0.000 0.084 0.872 0.044
#> GSM213093     1  0.4088     0.4796 0.688 0.000 0.008 0.304 0.000
#> GSM213097     1  0.2616     0.7522 0.888 0.000 0.076 0.036 0.000
#> GSM213099     1  0.6321     0.0216 0.464 0.000 0.160 0.376 0.000
#> GSM213101     1  0.0162     0.7729 0.996 0.000 0.000 0.004 0.000
#> GSM213105     2  0.3636     0.7461 0.000 0.728 0.000 0.000 0.272
#> GSM213109     1  0.1341     0.7742 0.944 0.000 0.000 0.056 0.000
#> GSM213110     2  0.2891     0.6911 0.176 0.824 0.000 0.000 0.000
#> GSM213113     4  0.4291     0.2574 0.464 0.000 0.000 0.536 0.000
#> GSM213121     2  0.1626     0.7805 0.000 0.940 0.016 0.000 0.044
#> GSM213123     1  0.4885     0.1614 0.572 0.000 0.028 0.400 0.000
#> GSM213125     2  0.0880     0.7850 0.000 0.968 0.000 0.000 0.032
#> GSM213073     5  0.5772     0.0000 0.004 0.000 0.104 0.300 0.592
#> GSM213086     4  0.3074     0.6458 0.196 0.000 0.000 0.804 0.000
#> GSM213098     4  0.4182     0.4248 0.400 0.000 0.000 0.600 0.000
#> GSM213106     1  0.3051     0.7228 0.852 0.000 0.120 0.028 0.000
#> GSM213124     2  0.3817     0.7186 0.108 0.824 0.012 0.056 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
#> GSM213078     4  0.0260    0.73234 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM213082     2  0.3464    0.68763 0.000 0.688 0.000 0.000 0.312 0.000
#> GSM213085     1  0.2912    0.74195 0.784 0.000 0.000 0.216 0.000 0.000
#> GSM213088     4  0.0260    0.73284 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM213091     4  0.5752    0.19484 0.288 0.000 0.184 0.524 0.000 0.004
#> GSM213092     1  0.3244    0.72671 0.732 0.000 0.000 0.268 0.000 0.000
#> GSM213096     4  0.1753    0.70802 0.084 0.000 0.000 0.912 0.004 0.000
#> GSM213100     4  0.1753    0.70861 0.084 0.000 0.000 0.912 0.004 0.000
#> GSM213111     2  0.0146    0.73189 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM213117     4  0.3548    0.65412 0.048 0.000 0.152 0.796 0.004 0.000
#> GSM213118     1  0.3360    0.73458 0.732 0.000 0.000 0.264 0.004 0.000
#> GSM213120     2  0.4622    0.42300 0.008 0.628 0.020 0.332 0.000 0.012
#> GSM213122     2  0.2697    0.71870 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM213074     4  0.3586    0.46714 0.268 0.000 0.012 0.720 0.000 0.000
#> GSM213077     4  0.2697    0.62925 0.188 0.000 0.000 0.812 0.000 0.000
#> GSM213083     4  0.0937    0.73378 0.040 0.000 0.000 0.960 0.000 0.000
#> GSM213094     3  0.1829    0.00000 0.056 0.000 0.920 0.000 0.000 0.024
#> GSM213095     2  0.3860   -0.01609 0.472 0.528 0.000 0.000 0.000 0.000
#> GSM213102     4  0.2134    0.71953 0.044 0.000 0.052 0.904 0.000 0.000
#> GSM213103     2  0.5271    0.18876 0.052 0.508 0.004 0.424 0.004 0.008
#> GSM213104     1  0.4484    0.56145 0.560 0.012 0.000 0.416 0.004 0.008
#> GSM213107     2  0.1768    0.72903 0.004 0.932 0.020 0.000 0.004 0.040
#> GSM213108     2  0.0000    0.73161 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213112     1  0.2996    0.74402 0.772 0.000 0.000 0.228 0.000 0.000
#> GSM213114     4  0.0260    0.73234 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM213115     2  0.1988    0.73908 0.004 0.912 0.004 0.000 0.072 0.008
#> GSM213116     4  0.2593    0.65690 0.148 0.000 0.008 0.844 0.000 0.000
#> GSM213119     2  0.3464    0.68763 0.000 0.688 0.000 0.000 0.312 0.000
#> GSM213072     4  0.3878    0.28336 0.348 0.000 0.004 0.644 0.004 0.000
#> GSM213075     4  0.1644    0.70950 0.004 0.076 0.000 0.920 0.000 0.000
#> GSM213076     4  0.5037    0.22505 0.064 0.408 0.000 0.524 0.004 0.000
#> GSM213079     5  0.5949    0.00000 0.120 0.000 0.024 0.000 0.472 0.384
#> GSM213080     4  0.0458    0.73429 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM213081     4  0.1007    0.73110 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM213084     4  0.1910    0.69374 0.108 0.000 0.000 0.892 0.000 0.000
#> GSM213087     2  0.3464    0.68763 0.000 0.688 0.000 0.000 0.312 0.000
#> GSM213089     4  0.5626    0.07986 0.344 0.000 0.160 0.496 0.000 0.000
#> GSM213090     1  0.4984   -0.26152 0.676 0.000 0.052 0.000 0.228 0.044
#> GSM213093     4  0.3748    0.38301 0.300 0.000 0.012 0.688 0.000 0.000
#> GSM213097     4  0.2747    0.69988 0.044 0.000 0.096 0.860 0.000 0.000
#> GSM213099     4  0.5831   -0.07806 0.348 0.000 0.196 0.456 0.000 0.000
#> GSM213101     4  0.0260    0.73284 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM213105     2  0.3464    0.68763 0.000 0.688 0.000 0.000 0.312 0.000
#> GSM213109     4  0.1327    0.73316 0.064 0.000 0.000 0.936 0.000 0.000
#> GSM213110     2  0.3025    0.66421 0.004 0.820 0.004 0.164 0.000 0.008
#> GSM213113     1  0.3857    0.44637 0.532 0.000 0.000 0.468 0.000 0.000
#> GSM213121     2  0.2032    0.72890 0.000 0.920 0.020 0.000 0.024 0.036
#> GSM213123     4  0.4482    0.00869 0.384 0.000 0.036 0.580 0.000 0.000
#> GSM213125     2  0.0777    0.73665 0.000 0.972 0.004 0.000 0.024 0.000
#> GSM213073     6  0.2624    0.00000 0.148 0.000 0.004 0.004 0.000 0.844
#> GSM213086     1  0.3330    0.72839 0.716 0.000 0.000 0.284 0.000 0.000
#> GSM213098     1  0.3797    0.55178 0.580 0.000 0.000 0.420 0.000 0.000
#> GSM213106     4  0.2945    0.65712 0.020 0.000 0.156 0.824 0.000 0.000
#> GSM213124     2  0.3671    0.69112 0.072 0.820 0.012 0.088 0.000 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

test_to_known_factors(res)
#>         n development.stage(p) disease.state(p) k
#> SD:pam 51                0.820            0.854 2
#> SD:pam 43                0.831            0.462 3
#> SD:pam 42                0.928            0.624 4
#> SD:pam 37                0.427            0.765 5
#> SD:pam 38                0.721            0.548 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.620           0.882       0.941         0.4766 0.516   0.516
#> 3 3 0.424           0.579       0.740         0.1607 0.799   0.667
#> 4 4 0.496           0.614       0.768         0.2385 0.690   0.425
#> 5 5 0.539           0.513       0.714         0.0316 0.747   0.355
#> 6 6 0.592           0.571       0.726         0.0977 0.867   0.549

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
#> GSM213078     1  0.0000      0.942 1.000 0.000
#> GSM213082     2  0.0000      0.917 0.000 1.000
#> GSM213085     1  0.0000      0.942 1.000 0.000
#> GSM213088     1  0.7528      0.743 0.784 0.216
#> GSM213091     1  0.3274      0.904 0.940 0.060
#> GSM213092     1  0.0000      0.942 1.000 0.000
#> GSM213096     1  0.0000      0.942 1.000 0.000
#> GSM213100     1  0.0000      0.942 1.000 0.000
#> GSM213111     2  0.0000      0.917 0.000 1.000
#> GSM213117     1  0.0000      0.942 1.000 0.000
#> GSM213118     1  0.0938      0.936 0.988 0.012
#> GSM213120     2  0.4815      0.861 0.104 0.896
#> GSM213122     2  0.0000      0.917 0.000 1.000
#> GSM213074     1  0.1633      0.929 0.976 0.024
#> GSM213077     1  0.0000      0.942 1.000 0.000
#> GSM213083     1  0.0000      0.942 1.000 0.000
#> GSM213094     2  0.8499      0.666 0.276 0.724
#> GSM213095     2  0.0000      0.917 0.000 1.000
#> GSM213102     1  0.0000      0.942 1.000 0.000
#> GSM213103     2  0.5519      0.846 0.128 0.872
#> GSM213104     1  0.8713      0.623 0.708 0.292
#> GSM213107     2  0.0000      0.917 0.000 1.000
#> GSM213108     2  0.0000      0.917 0.000 1.000
#> GSM213112     1  0.0000      0.942 1.000 0.000
#> GSM213114     1  0.7602      0.732 0.780 0.220
#> GSM213115     2  0.0000      0.917 0.000 1.000
#> GSM213116     1  0.0000      0.942 1.000 0.000
#> GSM213119     2  0.0000      0.917 0.000 1.000
#> GSM213072     1  0.0000      0.942 1.000 0.000
#> GSM213075     1  0.3114      0.906 0.944 0.056
#> GSM213076     2  0.0000      0.917 0.000 1.000
#> GSM213079     2  0.8144      0.701 0.252 0.748
#> GSM213080     1  0.8144      0.689 0.748 0.252
#> GSM213081     1  0.0000      0.942 1.000 0.000
#> GSM213084     1  0.0000      0.942 1.000 0.000
#> GSM213087     2  0.0000      0.917 0.000 1.000
#> GSM213089     1  0.0000      0.942 1.000 0.000
#> GSM213090     2  0.8016      0.711 0.244 0.756
#> GSM213093     1  0.0000      0.942 1.000 0.000
#> GSM213097     1  0.0000      0.942 1.000 0.000
#> GSM213099     1  0.3879      0.891 0.924 0.076
#> GSM213101     1  0.0000      0.942 1.000 0.000
#> GSM213105     2  0.0000      0.917 0.000 1.000
#> GSM213109     1  0.0000      0.942 1.000 0.000
#> GSM213110     2  0.4815      0.861 0.104 0.896
#> GSM213113     1  0.7815      0.717 0.768 0.232
#> GSM213121     2  0.0000      0.917 0.000 1.000
#> GSM213123     1  0.0376      0.940 0.996 0.004
#> GSM213125     2  0.0000      0.917 0.000 1.000
#> GSM213073     2  0.8016      0.711 0.244 0.756
#> GSM213086     1  0.0000      0.942 1.000 0.000
#> GSM213098     1  0.7815      0.716 0.768 0.232
#> GSM213106     1  0.0000      0.942 1.000 0.000
#> GSM213124     2  0.5629      0.843 0.132 0.868

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM213078     1  0.7091    0.22324 0.560 0.416 NA
#> GSM213082     2  0.3619    0.70640 0.000 0.864 NA
#> GSM213085     1  0.4452    0.58688 0.808 0.192 NA
#> GSM213088     1  0.7748    0.09806 0.500 0.452 NA
#> GSM213091     2  0.7987   -0.00617 0.448 0.492 NA
#> GSM213092     1  0.0592    0.68014 0.988 0.012 NA
#> GSM213096     1  0.2165    0.64635 0.936 0.064 NA
#> GSM213100     1  0.0000    0.68052 1.000 0.000 NA
#> GSM213111     2  0.0000    0.73218 0.000 1.000 NA
#> GSM213117     1  0.6252    0.70734 0.556 0.000 NA
#> GSM213118     1  0.1411    0.67369 0.964 0.036 NA
#> GSM213120     2  0.0000    0.73218 0.000 1.000 NA
#> GSM213122     2  0.3879    0.70032 0.000 0.848 NA
#> GSM213074     1  0.8009    0.68315 0.524 0.064 NA
#> GSM213077     1  0.0000    0.68052 1.000 0.000 NA
#> GSM213083     1  0.2492    0.69064 0.936 0.016 NA
#> GSM213094     2  0.6811    0.56431 0.016 0.580 NA
#> GSM213095     2  0.0000    0.73218 0.000 1.000 NA
#> GSM213102     1  0.6260    0.70677 0.552 0.000 NA
#> GSM213103     2  0.4654    0.58262 0.208 0.792 NA
#> GSM213104     2  0.6140    0.26175 0.404 0.596 NA
#> GSM213107     2  0.0424    0.73211 0.000 0.992 NA
#> GSM213108     2  0.0000    0.73218 0.000 1.000 NA
#> GSM213112     1  0.4399    0.59069 0.812 0.188 NA
#> GSM213114     2  0.6168    0.24761 0.412 0.588 NA
#> GSM213115     2  0.3879    0.70032 0.000 0.848 NA
#> GSM213116     1  0.6252    0.70734 0.556 0.000 NA
#> GSM213119     2  0.3879    0.70032 0.000 0.848 NA
#> GSM213072     1  0.8749    0.45328 0.560 0.300 NA
#> GSM213075     1  0.6280    0.70223 0.540 0.000 NA
#> GSM213076     2  0.0000    0.73218 0.000 1.000 NA
#> GSM213079     2  0.6513    0.57204 0.008 0.592 NA
#> GSM213080     2  0.6140    0.26175 0.404 0.596 NA
#> GSM213081     1  0.0000    0.68052 1.000 0.000 NA
#> GSM213084     1  0.0000    0.68052 1.000 0.000 NA
#> GSM213087     2  0.3619    0.70486 0.000 0.864 NA
#> GSM213089     1  0.6260    0.70659 0.552 0.000 NA
#> GSM213090     2  0.6513    0.57204 0.008 0.592 NA
#> GSM213093     1  0.6260    0.70659 0.552 0.000 NA
#> GSM213097     1  0.6267    0.70562 0.548 0.000 NA
#> GSM213099     1  0.7838    0.07102 0.488 0.460 NA
#> GSM213101     1  0.7192    0.23273 0.560 0.412 NA
#> GSM213105     2  0.3879    0.70032 0.000 0.848 NA
#> GSM213109     1  0.6267    0.70562 0.548 0.000 NA
#> GSM213110     2  0.1170    0.73006 0.008 0.976 NA
#> GSM213113     2  0.6168    0.24761 0.412 0.588 NA
#> GSM213121     2  0.0424    0.73211 0.000 0.992 NA
#> GSM213123     1  0.6737    0.70872 0.600 0.016 NA
#> GSM213125     2  0.3686    0.70349 0.000 0.860 NA
#> GSM213073     2  0.6513    0.57204 0.008 0.592 NA
#> GSM213086     1  0.0000    0.68052 1.000 0.000 NA
#> GSM213098     2  0.6180    0.23862 0.416 0.584 NA
#> GSM213106     1  0.6260    0.70659 0.552 0.000 NA
#> GSM213124     2  0.6783    0.26567 0.396 0.588 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     3  0.7756     0.0101 0.320 0.000 0.428 0.252
#> GSM213082     2  0.5016     0.1782 0.000 0.600 0.396 0.004
#> GSM213085     1  0.3831     0.6716 0.792 0.000 0.204 0.004
#> GSM213088     3  0.7569     0.0935 0.188 0.004 0.492 0.316
#> GSM213091     4  0.7425     0.1509 0.168 0.000 0.412 0.420
#> GSM213092     1  0.1489     0.8529 0.952 0.000 0.044 0.004
#> GSM213096     1  0.2197     0.8218 0.916 0.000 0.080 0.004
#> GSM213100     1  0.0707     0.8574 0.980 0.000 0.000 0.020
#> GSM213111     3  0.4855     0.3144 0.000 0.400 0.600 0.000
#> GSM213117     4  0.3528     0.7989 0.192 0.000 0.000 0.808
#> GSM213118     1  0.1637     0.8464 0.940 0.000 0.060 0.000
#> GSM213120     3  0.3400     0.6317 0.000 0.180 0.820 0.000
#> GSM213122     2  0.1722     0.8218 0.000 0.944 0.048 0.008
#> GSM213074     4  0.4589     0.7743 0.168 0.000 0.048 0.784
#> GSM213077     1  0.0469     0.8610 0.988 0.000 0.000 0.012
#> GSM213083     1  0.4690     0.4309 0.724 0.000 0.016 0.260
#> GSM213094     3  0.4256     0.6329 0.008 0.040 0.824 0.128
#> GSM213095     3  0.3402     0.6433 0.000 0.164 0.832 0.004
#> GSM213102     4  0.3356     0.8034 0.176 0.000 0.000 0.824
#> GSM213103     3  0.2908     0.6737 0.040 0.064 0.896 0.000
#> GSM213104     3  0.3295     0.6759 0.072 0.008 0.884 0.036
#> GSM213107     3  0.3539     0.6409 0.000 0.176 0.820 0.004
#> GSM213108     3  0.5060     0.2891 0.000 0.412 0.584 0.004
#> GSM213112     1  0.4049     0.6579 0.780 0.000 0.212 0.008
#> GSM213114     3  0.3616     0.6700 0.112 0.000 0.852 0.036
#> GSM213115     2  0.1722     0.8218 0.000 0.944 0.048 0.008
#> GSM213116     4  0.3569     0.7906 0.196 0.000 0.000 0.804
#> GSM213119     2  0.1389     0.8226 0.000 0.952 0.048 0.000
#> GSM213072     4  0.7220     0.4602 0.176 0.000 0.292 0.532
#> GSM213075     4  0.3539     0.7990 0.176 0.004 0.000 0.820
#> GSM213076     3  0.3801     0.5977 0.000 0.220 0.780 0.000
#> GSM213079     3  0.4316     0.6277 0.008 0.048 0.824 0.120
#> GSM213080     3  0.3436     0.6753 0.080 0.008 0.876 0.036
#> GSM213081     1  0.0336     0.8602 0.992 0.000 0.000 0.008
#> GSM213084     1  0.0469     0.8610 0.988 0.000 0.000 0.012
#> GSM213087     2  0.4804     0.2851 0.000 0.616 0.384 0.000
#> GSM213089     4  0.3400     0.8026 0.180 0.000 0.000 0.820
#> GSM213090     3  0.4316     0.6277 0.008 0.048 0.824 0.120
#> GSM213093     4  0.3266     0.8026 0.168 0.000 0.000 0.832
#> GSM213097     4  0.3266     0.8026 0.168 0.000 0.000 0.832
#> GSM213099     4  0.7421     0.1878 0.168 0.000 0.400 0.432
#> GSM213101     3  0.7884    -0.1399 0.308 0.000 0.384 0.308
#> GSM213105     2  0.1389     0.8226 0.000 0.952 0.048 0.000
#> GSM213109     4  0.3266     0.8026 0.168 0.000 0.000 0.832
#> GSM213110     3  0.5183     0.2950 0.000 0.408 0.584 0.008
#> GSM213113     3  0.3401     0.6631 0.152 0.008 0.840 0.000
#> GSM213121     3  0.3539     0.6409 0.000 0.176 0.820 0.004
#> GSM213123     4  0.5512     0.2222 0.488 0.000 0.016 0.496
#> GSM213125     2  0.1557     0.8202 0.000 0.944 0.056 0.000
#> GSM213073     3  0.4443     0.6271 0.012 0.048 0.820 0.120
#> GSM213086     1  0.0469     0.8610 0.988 0.000 0.000 0.012
#> GSM213098     3  0.3024     0.6633 0.148 0.000 0.852 0.000
#> GSM213106     4  0.3356     0.8001 0.176 0.000 0.000 0.824
#> GSM213124     3  0.7472     0.4438 0.120 0.244 0.596 0.040

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     4  0.7072    -0.2502 0.288 0.156 0.000 0.508 0.048
#> GSM213082     2  0.3242     0.5510 0.000 0.784 0.000 0.000 0.216
#> GSM213085     1  0.5742     0.5257 0.508 0.088 0.000 0.404 0.000
#> GSM213088     4  0.3509     0.5830 0.008 0.196 0.000 0.792 0.004
#> GSM213091     4  0.2911     0.6574 0.008 0.136 0.004 0.852 0.000
#> GSM213092     1  0.4557     0.5698 0.584 0.012 0.000 0.404 0.000
#> GSM213096     1  0.4416     0.5706 0.668 0.008 0.008 0.316 0.000
#> GSM213100     1  0.5405     0.4831 0.484 0.000 0.000 0.460 0.056
#> GSM213111     2  0.0162     0.4048 0.004 0.996 0.000 0.000 0.000
#> GSM213117     4  0.0000     0.7474 0.000 0.000 0.000 1.000 0.000
#> GSM213118     1  0.4630     0.5729 0.588 0.016 0.000 0.396 0.000
#> GSM213120     2  0.4300     0.0456 0.108 0.792 0.012 0.000 0.088
#> GSM213122     2  0.4101     0.5664 0.000 0.628 0.000 0.000 0.372
#> GSM213074     4  0.0162     0.7481 0.000 0.004 0.000 0.996 0.000
#> GSM213077     1  0.5396     0.5203 0.500 0.000 0.000 0.444 0.056
#> GSM213083     4  0.5322    -0.3104 0.408 0.004 0.000 0.544 0.044
#> GSM213094     3  0.1341     0.8967 0.000 0.056 0.944 0.000 0.000
#> GSM213095     5  0.4958     0.9130 0.012 0.424 0.012 0.000 0.552
#> GSM213102     4  0.0162     0.7466 0.004 0.000 0.000 0.996 0.000
#> GSM213103     2  0.6474    -0.2662 0.356 0.532 0.012 0.076 0.024
#> GSM213104     1  0.4401     0.1577 0.776 0.172 0.012 0.016 0.024
#> GSM213107     5  0.4801     0.9365 0.008 0.396 0.012 0.000 0.584
#> GSM213108     2  0.2230     0.5122 0.000 0.884 0.000 0.000 0.116
#> GSM213112     1  0.5680     0.5023 0.492 0.080 0.000 0.428 0.000
#> GSM213114     1  0.5507     0.3183 0.716 0.164 0.012 0.084 0.024
#> GSM213115     2  0.4225     0.5677 0.004 0.632 0.000 0.000 0.364
#> GSM213116     4  0.0693     0.7433 0.012 0.000 0.000 0.980 0.008
#> GSM213119     2  0.4088     0.5667 0.000 0.632 0.000 0.000 0.368
#> GSM213072     4  0.1965     0.6995 0.000 0.096 0.000 0.904 0.000
#> GSM213075     4  0.0324     0.7444 0.004 0.000 0.000 0.992 0.004
#> GSM213076     2  0.3206     0.1623 0.024 0.856 0.012 0.000 0.108
#> GSM213079     3  0.0000     0.9539 0.000 0.000 1.000 0.000 0.000
#> GSM213080     1  0.5007     0.2268 0.744 0.176 0.012 0.044 0.024
#> GSM213081     1  0.5211     0.5391 0.524 0.000 0.000 0.432 0.044
#> GSM213084     1  0.5450     0.5160 0.496 0.000 0.000 0.444 0.060
#> GSM213087     2  0.3508     0.5559 0.000 0.748 0.000 0.000 0.252
#> GSM213089     4  0.0000     0.7474 0.000 0.000 0.000 1.000 0.000
#> GSM213090     3  0.0000     0.9539 0.000 0.000 1.000 0.000 0.000
#> GSM213093     4  0.0000     0.7474 0.000 0.000 0.000 1.000 0.000
#> GSM213097     4  0.1608     0.7015 0.072 0.000 0.000 0.928 0.000
#> GSM213099     4  0.2909     0.6532 0.012 0.140 0.000 0.848 0.000
#> GSM213101     4  0.6789    -0.0544 0.244 0.152 0.000 0.560 0.044
#> GSM213105     2  0.4088     0.5667 0.000 0.632 0.000 0.000 0.368
#> GSM213109     4  0.1478     0.7102 0.064 0.000 0.000 0.936 0.000
#> GSM213110     2  0.1764     0.3428 0.064 0.928 0.000 0.000 0.008
#> GSM213113     4  0.7071    -0.1454 0.364 0.172 0.012 0.440 0.012
#> GSM213121     5  0.4696     0.9061 0.004 0.400 0.012 0.000 0.584
#> GSM213123     4  0.2329     0.6547 0.124 0.000 0.000 0.876 0.000
#> GSM213125     2  0.4088     0.5667 0.000 0.632 0.000 0.000 0.368
#> GSM213073     3  0.0981     0.9463 0.008 0.008 0.972 0.000 0.012
#> GSM213086     1  0.5389     0.5319 0.508 0.000 0.000 0.436 0.056
#> GSM213098     1  0.6053     0.3732 0.664 0.168 0.012 0.136 0.020
#> GSM213106     4  0.0324     0.7444 0.004 0.000 0.000 0.992 0.004
#> GSM213124     2  0.5757    -0.2377 0.064 0.480 0.000 0.448 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
#> GSM213078     1  0.5307    0.62955 0.664 0.000 0.000 0.176 0.032 0.128
#> GSM213082     2  0.1663    0.74154 0.000 0.912 0.000 0.000 0.000 0.088
#> GSM213085     1  0.5993    0.61772 0.612 0.000 0.000 0.188 0.088 0.112
#> GSM213088     4  0.6743    0.21571 0.284 0.024 0.000 0.464 0.020 0.208
#> GSM213091     4  0.3541    0.60344 0.000 0.000 0.000 0.748 0.232 0.020
#> GSM213092     1  0.3803    0.74196 0.808 0.000 0.000 0.092 0.072 0.028
#> GSM213096     1  0.3413    0.72766 0.836 0.000 0.000 0.068 0.072 0.024
#> GSM213100     1  0.2020    0.76896 0.896 0.000 0.000 0.096 0.008 0.000
#> GSM213111     2  0.4698    0.54670 0.064 0.660 0.000 0.000 0.008 0.268
#> GSM213117     4  0.2191    0.70976 0.120 0.000 0.000 0.876 0.004 0.000
#> GSM213118     1  0.4971    0.64795 0.688 0.000 0.000 0.204 0.072 0.036
#> GSM213120     6  0.6844   -0.00845 0.068 0.360 0.000 0.000 0.180 0.392
#> GSM213122     2  0.0000    0.75708 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213074     4  0.2593    0.67191 0.008 0.000 0.000 0.844 0.148 0.000
#> GSM213077     1  0.1858    0.77056 0.904 0.000 0.000 0.092 0.004 0.000
#> GSM213083     1  0.3406    0.70793 0.792 0.000 0.000 0.180 0.020 0.008
#> GSM213094     3  0.1226    0.93940 0.000 0.000 0.952 0.004 0.040 0.004
#> GSM213095     6  0.0790    0.34196 0.000 0.032 0.000 0.000 0.000 0.968
#> GSM213102     4  0.2632    0.69997 0.164 0.000 0.000 0.832 0.004 0.000
#> GSM213103     6  0.7458   -0.05533 0.176 0.168 0.000 0.000 0.316 0.340
#> GSM213104     5  0.5378    0.66216 0.088 0.000 0.000 0.020 0.592 0.300
#> GSM213107     6  0.1075    0.34328 0.000 0.048 0.000 0.000 0.000 0.952
#> GSM213108     2  0.4545    0.57008 0.064 0.688 0.000 0.000 0.008 0.240
#> GSM213112     1  0.6120    0.59188 0.588 0.000 0.000 0.216 0.084 0.112
#> GSM213114     5  0.5842    0.80637 0.228 0.000 0.000 0.000 0.484 0.288
#> GSM213115     2  0.0146    0.75823 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM213116     4  0.2969    0.65252 0.224 0.000 0.000 0.776 0.000 0.000
#> GSM213119     2  0.0000    0.75708 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213072     4  0.3331    0.68875 0.044 0.000 0.000 0.816 0.136 0.004
#> GSM213075     4  0.1615    0.72248 0.064 0.004 0.000 0.928 0.004 0.000
#> GSM213076     2  0.5471    0.14471 0.064 0.480 0.000 0.000 0.024 0.432
#> GSM213079     3  0.0000    0.95309 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     5  0.5735    0.82314 0.200 0.000 0.000 0.000 0.504 0.296
#> GSM213081     1  0.1753    0.77008 0.912 0.000 0.000 0.084 0.004 0.000
#> GSM213084     1  0.1970    0.76953 0.900 0.000 0.000 0.092 0.008 0.000
#> GSM213087     2  0.1765    0.73620 0.000 0.904 0.000 0.000 0.000 0.096
#> GSM213089     4  0.1719    0.72268 0.060 0.000 0.000 0.924 0.016 0.000
#> GSM213090     3  0.0000    0.95309 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213093     4  0.2234    0.72173 0.124 0.000 0.000 0.872 0.004 0.000
#> GSM213097     4  0.3126    0.62988 0.248 0.000 0.000 0.752 0.000 0.000
#> GSM213099     4  0.3720    0.59326 0.000 0.000 0.000 0.736 0.236 0.028
#> GSM213101     1  0.5393    0.61775 0.652 0.000 0.000 0.188 0.032 0.128
#> GSM213105     2  0.0000    0.75708 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213109     4  0.3126    0.62967 0.248 0.000 0.000 0.752 0.000 0.000
#> GSM213110     2  0.6508    0.23283 0.064 0.508 0.000 0.000 0.160 0.268
#> GSM213113     6  0.7739   -0.32417 0.296 0.008 0.000 0.144 0.252 0.300
#> GSM213121     6  0.2300    0.34985 0.000 0.144 0.000 0.000 0.000 0.856
#> GSM213123     4  0.4984    0.12638 0.392 0.000 0.000 0.552 0.036 0.020
#> GSM213125     2  0.0146    0.75799 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM213073     3  0.1501    0.88731 0.000 0.000 0.924 0.000 0.000 0.076
#> GSM213086     1  0.2001    0.77103 0.900 0.000 0.000 0.092 0.004 0.004
#> GSM213098     1  0.7369   -0.44760 0.312 0.004 0.000 0.088 0.312 0.284
#> GSM213106     4  0.2146    0.72219 0.116 0.000 0.000 0.880 0.004 0.000
#> GSM213124     4  0.8626   -0.37037 0.096 0.192 0.000 0.276 0.160 0.276

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 development.stage(p) disease.state(p) k
#> SD:mclust 54                1.000            0.676 2
#> SD:mclust 42                1.000            1.000 3
#> SD:mclust 40                0.537            0.706 4
#> SD:mclust 39                0.492            0.705 5
#> SD:mclust 42                0.330            0.753 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 51941 rows and 54 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 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-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.961           0.929       0.974         0.4489 0.547   0.547
#> 3 3 0.590           0.710       0.869         0.4662 0.704   0.496
#> 4 4 0.576           0.626       0.808         0.1189 0.902   0.722
#> 5 5 0.573           0.536       0.756         0.0731 0.864   0.565
#> 6 6 0.614           0.436       0.663         0.0440 0.937   0.721

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
#> GSM213078     1   0.000     0.9829 1.000 0.000
#> GSM213082     2   0.000     0.9500 0.000 1.000
#> GSM213085     1   0.000     0.9829 1.000 0.000
#> GSM213088     1   0.494     0.8638 0.892 0.108
#> GSM213091     1   0.000     0.9829 1.000 0.000
#> GSM213092     1   0.000     0.9829 1.000 0.000
#> GSM213096     1   0.000     0.9829 1.000 0.000
#> GSM213100     1   0.000     0.9829 1.000 0.000
#> GSM213111     2   0.000     0.9500 0.000 1.000
#> GSM213117     1   0.000     0.9829 1.000 0.000
#> GSM213118     1   0.000     0.9829 1.000 0.000
#> GSM213120     2   0.000     0.9500 0.000 1.000
#> GSM213122     2   0.000     0.9500 0.000 1.000
#> GSM213074     1   0.000     0.9829 1.000 0.000
#> GSM213077     1   0.000     0.9829 1.000 0.000
#> GSM213083     1   0.000     0.9829 1.000 0.000
#> GSM213094     1   0.000     0.9829 1.000 0.000
#> GSM213095     2   0.000     0.9500 0.000 1.000
#> GSM213102     1   0.000     0.9829 1.000 0.000
#> GSM213103     2   0.118     0.9371 0.016 0.984
#> GSM213104     2   0.921     0.4979 0.336 0.664
#> GSM213107     2   0.000     0.9500 0.000 1.000
#> GSM213108     2   0.000     0.9500 0.000 1.000
#> GSM213112     1   0.000     0.9829 1.000 0.000
#> GSM213114     1   0.000     0.9829 1.000 0.000
#> GSM213115     2   0.000     0.9500 0.000 1.000
#> GSM213116     1   0.000     0.9829 1.000 0.000
#> GSM213119     2   0.000     0.9500 0.000 1.000
#> GSM213072     1   0.000     0.9829 1.000 0.000
#> GSM213075     1   0.000     0.9829 1.000 0.000
#> GSM213076     2   0.000     0.9500 0.000 1.000
#> GSM213079     1   0.000     0.9829 1.000 0.000
#> GSM213080     2   0.998     0.1256 0.472 0.528
#> GSM213081     1   0.000     0.9829 1.000 0.000
#> GSM213084     1   0.000     0.9829 1.000 0.000
#> GSM213087     2   0.000     0.9500 0.000 1.000
#> GSM213089     1   0.000     0.9829 1.000 0.000
#> GSM213090     1   0.000     0.9829 1.000 0.000
#> GSM213093     1   0.000     0.9829 1.000 0.000
#> GSM213097     1   0.000     0.9829 1.000 0.000
#> GSM213099     1   0.000     0.9829 1.000 0.000
#> GSM213101     1   0.000     0.9829 1.000 0.000
#> GSM213105     2   0.000     0.9500 0.000 1.000
#> GSM213109     1   0.000     0.9829 1.000 0.000
#> GSM213110     2   0.000     0.9500 0.000 1.000
#> GSM213113     1   0.000     0.9829 1.000 0.000
#> GSM213121     2   0.000     0.9500 0.000 1.000
#> GSM213123     1   0.000     0.9829 1.000 0.000
#> GSM213125     2   0.000     0.9500 0.000 1.000
#> GSM213073     1   0.000     0.9829 1.000 0.000
#> GSM213086     1   0.000     0.9829 1.000 0.000
#> GSM213098     1   0.000     0.9829 1.000 0.000
#> GSM213106     1   0.000     0.9829 1.000 0.000
#> GSM213124     1   0.994     0.0855 0.544 0.456

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0237     0.7904 0.996 0.000 0.004
#> GSM213082     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213085     1  0.4002     0.7326 0.840 0.000 0.160
#> GSM213088     1  0.2743     0.7741 0.928 0.052 0.020
#> GSM213091     3  0.0892     0.7933 0.020 0.000 0.980
#> GSM213092     1  0.4555     0.6937 0.800 0.000 0.200
#> GSM213096     1  0.0000     0.7886 1.000 0.000 0.000
#> GSM213100     1  0.0592     0.7927 0.988 0.000 0.012
#> GSM213111     2  0.0424     0.9207 0.000 0.992 0.008
#> GSM213117     1  0.5835     0.5301 0.660 0.000 0.340
#> GSM213118     1  0.2165     0.7879 0.936 0.000 0.064
#> GSM213120     2  0.0237     0.9221 0.000 0.996 0.004
#> GSM213122     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213074     3  0.3116     0.7650 0.108 0.000 0.892
#> GSM213077     1  0.3412     0.7618 0.876 0.000 0.124
#> GSM213083     1  0.2711     0.7811 0.912 0.000 0.088
#> GSM213094     3  0.0424     0.7916 0.008 0.000 0.992
#> GSM213095     2  0.3267     0.8481 0.000 0.884 0.116
#> GSM213102     1  0.5968     0.4832 0.636 0.000 0.364
#> GSM213103     2  0.5058     0.6890 0.244 0.756 0.000
#> GSM213104     1  0.6404     0.3236 0.644 0.344 0.012
#> GSM213107     2  0.0424     0.9210 0.000 0.992 0.008
#> GSM213108     2  0.5859     0.5513 0.000 0.656 0.344
#> GSM213112     1  0.6305     0.0292 0.516 0.000 0.484
#> GSM213114     1  0.0237     0.7863 0.996 0.000 0.004
#> GSM213115     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213116     3  0.6267     0.1051 0.452 0.000 0.548
#> GSM213119     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213072     3  0.3551     0.7654 0.132 0.000 0.868
#> GSM213075     3  0.5706     0.5241 0.320 0.000 0.680
#> GSM213076     2  0.0747     0.9177 0.000 0.984 0.016
#> GSM213079     3  0.0424     0.7910 0.008 0.000 0.992
#> GSM213080     1  0.0661     0.7821 0.988 0.004 0.008
#> GSM213081     1  0.0592     0.7926 0.988 0.000 0.012
#> GSM213084     1  0.0892     0.7935 0.980 0.000 0.020
#> GSM213087     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213089     3  0.2261     0.7851 0.068 0.000 0.932
#> GSM213090     3  0.0237     0.7901 0.004 0.000 0.996
#> GSM213093     3  0.5254     0.5845 0.264 0.000 0.736
#> GSM213097     1  0.6295     0.1853 0.528 0.000 0.472
#> GSM213099     3  0.0592     0.7927 0.012 0.000 0.988
#> GSM213101     1  0.0237     0.7904 0.996 0.000 0.004
#> GSM213105     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213109     1  0.5465     0.6137 0.712 0.000 0.288
#> GSM213110     2  0.1643     0.8968 0.044 0.956 0.000
#> GSM213113     3  0.4842     0.6590 0.224 0.000 0.776
#> GSM213121     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213123     3  0.6291     0.1153 0.468 0.000 0.532
#> GSM213125     2  0.0000     0.9230 0.000 1.000 0.000
#> GSM213073     3  0.0424     0.7910 0.008 0.000 0.992
#> GSM213086     1  0.2066     0.7908 0.940 0.000 0.060
#> GSM213098     3  0.5138     0.6044 0.252 0.000 0.748
#> GSM213106     1  0.5926     0.5039 0.644 0.000 0.356
#> GSM213124     2  0.9017     0.3216 0.212 0.560 0.228

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0469      0.739 0.988 0.000 0.012 0.000
#> GSM213082     2  0.0469      0.865 0.000 0.988 0.000 0.012
#> GSM213085     1  0.5535      0.523 0.656 0.000 0.304 0.040
#> GSM213088     1  0.3781      0.696 0.844 0.028 0.004 0.124
#> GSM213091     4  0.0672      0.742 0.008 0.000 0.008 0.984
#> GSM213092     1  0.5787      0.578 0.680 0.000 0.244 0.076
#> GSM213096     1  0.2589      0.694 0.884 0.000 0.116 0.000
#> GSM213100     1  0.0804      0.742 0.980 0.000 0.012 0.008
#> GSM213111     2  0.0188      0.869 0.000 0.996 0.000 0.004
#> GSM213117     1  0.5016      0.409 0.600 0.000 0.004 0.396
#> GSM213118     1  0.3913      0.693 0.824 0.000 0.148 0.028
#> GSM213120     2  0.3725      0.701 0.000 0.812 0.180 0.008
#> GSM213122     2  0.0000      0.870 0.000 1.000 0.000 0.000
#> GSM213074     4  0.3205      0.726 0.104 0.000 0.024 0.872
#> GSM213077     1  0.2224      0.743 0.928 0.000 0.032 0.040
#> GSM213083     1  0.1211      0.745 0.960 0.000 0.000 0.040
#> GSM213094     4  0.1940      0.727 0.000 0.000 0.076 0.924
#> GSM213095     3  0.5227      0.567 0.000 0.256 0.704 0.040
#> GSM213102     1  0.4456      0.574 0.716 0.000 0.004 0.280
#> GSM213103     3  0.7218      0.447 0.120 0.352 0.520 0.008
#> GSM213104     3  0.2799      0.670 0.108 0.008 0.884 0.000
#> GSM213107     3  0.4406      0.566 0.000 0.300 0.700 0.000
#> GSM213108     2  0.4635      0.602 0.000 0.756 0.028 0.216
#> GSM213112     1  0.7669      0.267 0.444 0.000 0.328 0.228
#> GSM213114     1  0.4981      0.112 0.536 0.000 0.464 0.000
#> GSM213115     2  0.0000      0.870 0.000 1.000 0.000 0.000
#> GSM213116     1  0.5151      0.162 0.532 0.000 0.004 0.464
#> GSM213119     2  0.0000      0.870 0.000 1.000 0.000 0.000
#> GSM213072     4  0.4175      0.662 0.200 0.000 0.016 0.784
#> GSM213075     4  0.5093      0.425 0.336 0.008 0.004 0.652
#> GSM213076     2  0.2101      0.830 0.000 0.928 0.060 0.012
#> GSM213079     4  0.3610      0.663 0.000 0.000 0.200 0.800
#> GSM213080     3  0.4454      0.457 0.308 0.000 0.692 0.000
#> GSM213081     1  0.2760      0.691 0.872 0.000 0.128 0.000
#> GSM213084     1  0.1118      0.732 0.964 0.000 0.036 0.000
#> GSM213087     2  0.0469      0.866 0.000 0.988 0.012 0.000
#> GSM213089     4  0.1792      0.736 0.068 0.000 0.000 0.932
#> GSM213090     4  0.3649      0.660 0.000 0.000 0.204 0.796
#> GSM213093     4  0.4194      0.586 0.228 0.000 0.008 0.764
#> GSM213097     1  0.5155      0.243 0.528 0.000 0.004 0.468
#> GSM213099     4  0.0895      0.741 0.004 0.000 0.020 0.976
#> GSM213101     1  0.0657      0.742 0.984 0.000 0.004 0.012
#> GSM213105     2  0.0000      0.870 0.000 1.000 0.000 0.000
#> GSM213109     1  0.3196      0.701 0.856 0.000 0.008 0.136
#> GSM213110     2  0.0921      0.853 0.028 0.972 0.000 0.000
#> GSM213113     4  0.5724      0.326 0.028 0.000 0.424 0.548
#> GSM213121     2  0.3356      0.703 0.000 0.824 0.176 0.000
#> GSM213123     4  0.6374      0.308 0.324 0.000 0.084 0.592
#> GSM213125     2  0.0000      0.870 0.000 1.000 0.000 0.000
#> GSM213073     4  0.4730      0.485 0.000 0.000 0.364 0.636
#> GSM213086     1  0.1733      0.744 0.948 0.000 0.028 0.024
#> GSM213098     3  0.2589      0.636 0.044 0.000 0.912 0.044
#> GSM213106     1  0.5178      0.426 0.600 0.004 0.004 0.392
#> GSM213124     2  0.8348      0.104 0.232 0.468 0.032 0.268

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.1357     0.7383 0.948 0.000 0.000 0.048 0.004
#> GSM213082     2  0.0451     0.8140 0.000 0.988 0.008 0.000 0.004
#> GSM213085     3  0.6488    -0.1115 0.408 0.000 0.472 0.032 0.088
#> GSM213088     1  0.4201     0.3772 0.664 0.008 0.000 0.328 0.000
#> GSM213091     4  0.2516     0.5750 0.000 0.000 0.140 0.860 0.000
#> GSM213092     1  0.6698     0.1838 0.488 0.000 0.364 0.032 0.116
#> GSM213096     1  0.3996     0.7017 0.816 0.000 0.052 0.020 0.112
#> GSM213100     1  0.3746     0.7090 0.840 0.000 0.084 0.040 0.036
#> GSM213111     2  0.0566     0.8141 0.000 0.984 0.000 0.004 0.012
#> GSM213117     4  0.4425     0.6432 0.204 0.000 0.048 0.744 0.004
#> GSM213118     1  0.7418     0.3622 0.496 0.000 0.092 0.136 0.276
#> GSM213120     2  0.6471     0.1629 0.000 0.488 0.000 0.216 0.296
#> GSM213122     2  0.0000     0.8165 0.000 1.000 0.000 0.000 0.000
#> GSM213074     4  0.5968     0.3141 0.084 0.000 0.416 0.492 0.008
#> GSM213077     1  0.3092     0.7310 0.880 0.000 0.036 0.048 0.036
#> GSM213083     1  0.0451     0.7422 0.988 0.000 0.008 0.004 0.000
#> GSM213094     4  0.4009     0.3796 0.000 0.000 0.312 0.684 0.004
#> GSM213095     3  0.6514     0.1387 0.004 0.136 0.528 0.012 0.320
#> GSM213102     1  0.4416     0.3468 0.632 0.000 0.012 0.356 0.000
#> GSM213103     5  0.6635     0.4742 0.140 0.104 0.068 0.028 0.660
#> GSM213104     5  0.1493     0.5866 0.028 0.000 0.024 0.000 0.948
#> GSM213107     5  0.2930     0.5360 0.000 0.164 0.004 0.000 0.832
#> GSM213108     2  0.4506     0.6002 0.000 0.716 0.244 0.036 0.004
#> GSM213112     3  0.5462     0.3765 0.204 0.000 0.688 0.024 0.084
#> GSM213114     1  0.4470     0.3604 0.596 0.000 0.004 0.004 0.396
#> GSM213115     2  0.0324     0.8164 0.000 0.992 0.004 0.000 0.004
#> GSM213116     4  0.4832     0.6379 0.208 0.000 0.064 0.720 0.008
#> GSM213119     2  0.0000     0.8165 0.000 1.000 0.000 0.000 0.000
#> GSM213072     4  0.6526     0.3358 0.160 0.000 0.348 0.484 0.008
#> GSM213075     4  0.5616     0.6102 0.232 0.000 0.112 0.648 0.008
#> GSM213076     2  0.4675     0.6600 0.000 0.760 0.012 0.136 0.092
#> GSM213079     3  0.4584     0.3541 0.000 0.000 0.660 0.312 0.028
#> GSM213080     5  0.4313     0.4426 0.276 0.000 0.008 0.012 0.704
#> GSM213081     1  0.4244     0.6793 0.788 0.000 0.008 0.132 0.072
#> GSM213084     1  0.2095     0.7372 0.928 0.000 0.028 0.020 0.024
#> GSM213087     2  0.0609     0.8110 0.000 0.980 0.000 0.000 0.020
#> GSM213089     4  0.1996     0.6386 0.032 0.000 0.036 0.928 0.004
#> GSM213090     3  0.2270     0.4808 0.000 0.000 0.904 0.076 0.020
#> GSM213093     4  0.4615     0.6439 0.220 0.000 0.052 0.724 0.004
#> GSM213097     4  0.4350     0.3230 0.408 0.000 0.004 0.588 0.000
#> GSM213099     4  0.2536     0.5813 0.004 0.000 0.128 0.868 0.000
#> GSM213101     1  0.1518     0.7427 0.944 0.000 0.004 0.048 0.004
#> GSM213105     2  0.0162     0.8159 0.000 0.996 0.004 0.000 0.000
#> GSM213109     1  0.3191     0.7182 0.860 0.000 0.084 0.052 0.004
#> GSM213110     2  0.1704     0.7759 0.068 0.928 0.004 0.000 0.000
#> GSM213113     5  0.6360     0.0332 0.004 0.000 0.140 0.420 0.436
#> GSM213121     2  0.4101     0.3984 0.000 0.628 0.000 0.000 0.372
#> GSM213123     4  0.4055     0.6421 0.140 0.000 0.012 0.800 0.048
#> GSM213125     2  0.0000     0.8165 0.000 1.000 0.000 0.000 0.000
#> GSM213073     3  0.5974     0.3680 0.000 0.000 0.564 0.292 0.144
#> GSM213086     1  0.5407     0.6206 0.704 0.000 0.192 0.060 0.044
#> GSM213098     5  0.3141     0.5779 0.004 0.000 0.040 0.096 0.860
#> GSM213106     4  0.3967     0.6054 0.264 0.000 0.012 0.724 0.000
#> GSM213124     2  0.8507    -0.1060 0.116 0.336 0.308 0.228 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
#> GSM213078     1  0.1370     0.6355 0.948 0.000 0.004 0.036 0.000 0.012
#> GSM213082     2  0.0909     0.8132 0.000 0.968 0.020 0.012 0.000 0.000
#> GSM213085     6  0.6498    -0.0314 0.212 0.000 0.376 0.000 0.028 0.384
#> GSM213088     1  0.4355     0.3146 0.644 0.004 0.000 0.320 0.000 0.032
#> GSM213091     4  0.3261     0.5585 0.000 0.000 0.072 0.824 0.000 0.104
#> GSM213092     1  0.6825    -0.1465 0.360 0.000 0.312 0.004 0.032 0.292
#> GSM213096     1  0.5108     0.1854 0.552 0.000 0.000 0.000 0.092 0.356
#> GSM213100     1  0.4476     0.3903 0.672 0.000 0.028 0.008 0.008 0.284
#> GSM213111     2  0.1325     0.8108 0.000 0.956 0.004 0.016 0.012 0.012
#> GSM213117     4  0.4945     0.3724 0.068 0.000 0.000 0.584 0.004 0.344
#> GSM213118     6  0.6523     0.3128 0.152 0.000 0.004 0.048 0.312 0.484
#> GSM213120     2  0.6643    -0.0360 0.000 0.392 0.020 0.232 0.348 0.008
#> GSM213122     2  0.0291     0.8175 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM213074     6  0.4999     0.2875 0.036 0.000 0.068 0.216 0.000 0.680
#> GSM213077     1  0.3820     0.6077 0.820 0.000 0.056 0.080 0.008 0.036
#> GSM213083     1  0.0972     0.6355 0.964 0.000 0.008 0.000 0.000 0.028
#> GSM213094     4  0.5366     0.3242 0.000 0.000 0.224 0.604 0.004 0.168
#> GSM213095     3  0.5173     0.4443 0.004 0.096 0.704 0.000 0.144 0.052
#> GSM213102     1  0.5673     0.0255 0.484 0.000 0.004 0.372 0.000 0.140
#> GSM213103     6  0.6067     0.0940 0.096 0.028 0.000 0.008 0.412 0.456
#> GSM213104     5  0.2322     0.5797 0.048 0.000 0.024 0.000 0.904 0.024
#> GSM213107     5  0.2420     0.5322 0.000 0.128 0.004 0.004 0.864 0.000
#> GSM213108     2  0.5497     0.4759 0.004 0.640 0.176 0.020 0.000 0.160
#> GSM213112     3  0.5904     0.0812 0.148 0.000 0.528 0.004 0.012 0.308
#> GSM213114     1  0.4406     0.3628 0.648 0.000 0.004 0.004 0.316 0.028
#> GSM213115     2  0.0777     0.8148 0.000 0.972 0.000 0.000 0.004 0.024
#> GSM213116     4  0.4905     0.2949 0.052 0.000 0.000 0.524 0.004 0.420
#> GSM213119     2  0.0508     0.8168 0.000 0.984 0.000 0.004 0.000 0.012
#> GSM213072     6  0.4862     0.2859 0.068 0.000 0.028 0.216 0.000 0.688
#> GSM213075     4  0.6939     0.1932 0.168 0.000 0.084 0.376 0.000 0.372
#> GSM213076     2  0.6159     0.4860 0.000 0.608 0.056 0.216 0.100 0.020
#> GSM213079     3  0.4883     0.4834 0.000 0.000 0.684 0.212 0.020 0.084
#> GSM213080     5  0.5010     0.2262 0.368 0.000 0.000 0.032 0.572 0.028
#> GSM213081     1  0.5705     0.4858 0.684 0.000 0.040 0.136 0.044 0.096
#> GSM213084     1  0.1465     0.6343 0.948 0.000 0.020 0.004 0.004 0.024
#> GSM213087     2  0.0458     0.8158 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM213089     4  0.2956     0.5862 0.040 0.000 0.000 0.840 0.000 0.120
#> GSM213090     3  0.2890     0.5231 0.008 0.000 0.852 0.016 0.004 0.120
#> GSM213093     4  0.6370     0.4193 0.288 0.000 0.088 0.524 0.000 0.100
#> GSM213097     4  0.4751     0.2468 0.392 0.000 0.004 0.560 0.000 0.044
#> GSM213099     4  0.3047     0.5503 0.000 0.000 0.064 0.848 0.004 0.084
#> GSM213101     1  0.1642     0.6379 0.936 0.000 0.000 0.028 0.004 0.032
#> GSM213105     2  0.0291     0.8174 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM213109     1  0.3893     0.4994 0.744 0.000 0.020 0.016 0.000 0.220
#> GSM213110     2  0.2579     0.7465 0.088 0.876 0.000 0.000 0.004 0.032
#> GSM213113     5  0.7507     0.1092 0.024 0.000 0.136 0.340 0.384 0.116
#> GSM213121     2  0.4124     0.1854 0.000 0.516 0.000 0.004 0.476 0.004
#> GSM213123     4  0.5597     0.5540 0.168 0.000 0.040 0.680 0.032 0.080
#> GSM213125     2  0.0146     0.8168 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM213073     3  0.6091     0.4133 0.000 0.000 0.576 0.248 0.088 0.088
#> GSM213086     6  0.6019    -0.0568 0.424 0.000 0.128 0.004 0.016 0.428
#> GSM213098     5  0.3124     0.5696 0.008 0.000 0.008 0.116 0.844 0.024
#> GSM213106     4  0.4411     0.5598 0.204 0.000 0.004 0.712 0.000 0.080
#> GSM213124     6  0.5716     0.4079 0.036 0.116 0.044 0.108 0.004 0.692

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

test_to_known_factors(res)
#>         n development.stage(p) disease.state(p) k
#> SD:NMF 51               0.5337           1.0000 2
#> SD:NMF 47               0.0596           0.8272 3
#> SD:NMF 41               0.3645           0.0222 4
#> SD:NMF 33               0.7067           0.0810 5
#> SD:NMF 23               0.4921           0.1196 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.496           0.609       0.815         0.2897 0.860   0.860
#> 3 3 0.656           0.858       0.931         0.7814 0.633   0.574
#> 4 4 0.655           0.801       0.915         0.0662 0.973   0.946
#> 5 5 0.544           0.746       0.857         0.0692 0.974   0.945
#> 6 6 0.509           0.570       0.813         0.0668 0.982   0.959

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
#> GSM213078     1  0.0376      0.700 0.996 0.004
#> GSM213082     1  0.9988      0.443 0.520 0.480
#> GSM213085     1  0.0376      0.699 0.996 0.004
#> GSM213088     1  0.0376      0.700 0.996 0.004
#> GSM213091     1  0.8499     -0.255 0.724 0.276
#> GSM213092     1  0.0376      0.700 0.996 0.004
#> GSM213096     1  0.0000      0.698 1.000 0.000
#> GSM213100     1  0.0000      0.698 1.000 0.000
#> GSM213111     1  0.9983      0.446 0.524 0.476
#> GSM213117     1  0.0376      0.700 0.996 0.004
#> GSM213118     1  0.0376      0.699 0.996 0.004
#> GSM213120     1  0.9608      0.490 0.616 0.384
#> GSM213122     1  0.9988      0.443 0.520 0.480
#> GSM213074     1  0.1184      0.679 0.984 0.016
#> GSM213077     1  0.0376      0.695 0.996 0.004
#> GSM213083     1  0.0376      0.695 0.996 0.004
#> GSM213094     2  0.9988      0.997 0.480 0.520
#> GSM213095     1  0.9970      0.450 0.532 0.468
#> GSM213102     1  0.0376      0.695 0.996 0.004
#> GSM213103     1  0.2423      0.688 0.960 0.040
#> GSM213104     1  0.2948      0.684 0.948 0.052
#> GSM213107     1  0.9988      0.443 0.520 0.480
#> GSM213108     1  0.9944      0.457 0.544 0.456
#> GSM213112     1  0.0938      0.699 0.988 0.012
#> GSM213114     1  0.2236      0.691 0.964 0.036
#> GSM213115     1  0.9710      0.487 0.600 0.400
#> GSM213116     1  0.0000      0.698 1.000 0.000
#> GSM213119     1  0.9988      0.443 0.520 0.480
#> GSM213072     1  0.0938      0.685 0.988 0.012
#> GSM213075     1  0.0938      0.697 0.988 0.012
#> GSM213076     1  0.9686      0.488 0.604 0.396
#> GSM213079     2  0.9988      0.997 0.480 0.520
#> GSM213080     1  0.2236      0.691 0.964 0.036
#> GSM213081     1  0.0376      0.700 0.996 0.004
#> GSM213084     1  0.0000      0.698 1.000 0.000
#> GSM213087     1  0.9988      0.443 0.520 0.480
#> GSM213089     1  0.0672      0.698 0.992 0.008
#> GSM213090     2  0.9983      0.992 0.476 0.524
#> GSM213093     1  0.0000      0.698 1.000 0.000
#> GSM213097     1  0.0376      0.695 0.996 0.004
#> GSM213099     1  0.9393     -0.575 0.644 0.356
#> GSM213101     1  0.0376      0.700 0.996 0.004
#> GSM213105     1  0.9988      0.443 0.520 0.480
#> GSM213109     1  0.0376      0.695 0.996 0.004
#> GSM213110     1  0.9661      0.491 0.608 0.392
#> GSM213113     1  0.1843      0.692 0.972 0.028
#> GSM213121     1  0.9988      0.443 0.520 0.480
#> GSM213123     1  0.0376      0.700 0.996 0.004
#> GSM213125     1  0.9988      0.443 0.520 0.480
#> GSM213073     2  0.9988      0.997 0.480 0.520
#> GSM213086     1  0.0376      0.700 0.996 0.004
#> GSM213098     1  0.1414      0.698 0.980 0.020
#> GSM213106     1  0.0672      0.697 0.992 0.008
#> GSM213124     1  0.6438      0.603 0.836 0.164

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0475      0.925 0.992 0.004 0.004
#> GSM213082     2  0.1411      0.902 0.036 0.964 0.000
#> GSM213085     1  0.0829      0.924 0.984 0.004 0.012
#> GSM213088     1  0.0475      0.925 0.992 0.004 0.004
#> GSM213091     1  0.6667      0.326 0.616 0.016 0.368
#> GSM213092     1  0.0829      0.925 0.984 0.004 0.012
#> GSM213096     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213100     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213111     2  0.1860      0.896 0.052 0.948 0.000
#> GSM213117     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213118     1  0.1170      0.922 0.976 0.016 0.008
#> GSM213120     2  0.5202      0.699 0.220 0.772 0.008
#> GSM213122     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213074     1  0.1989      0.904 0.948 0.004 0.048
#> GSM213077     1  0.0424      0.925 0.992 0.000 0.008
#> GSM213083     1  0.0592      0.925 0.988 0.000 0.012
#> GSM213094     3  0.4209      0.898 0.128 0.016 0.856
#> GSM213095     2  0.1832      0.901 0.036 0.956 0.008
#> GSM213102     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213103     1  0.3295      0.858 0.896 0.096 0.008
#> GSM213104     1  0.5247      0.697 0.768 0.224 0.008
#> GSM213107     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213108     2  0.2651      0.888 0.060 0.928 0.012
#> GSM213112     1  0.1585      0.916 0.964 0.028 0.008
#> GSM213114     1  0.4682      0.740 0.804 0.192 0.004
#> GSM213115     2  0.4700      0.764 0.180 0.812 0.008
#> GSM213116     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213119     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213072     1  0.0829      0.922 0.984 0.004 0.012
#> GSM213075     1  0.1015      0.923 0.980 0.012 0.008
#> GSM213076     2  0.4452      0.748 0.192 0.808 0.000
#> GSM213079     3  0.3116      0.930 0.108 0.000 0.892
#> GSM213080     1  0.4682      0.740 0.804 0.192 0.004
#> GSM213081     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213084     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213087     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213089     1  0.0747      0.923 0.984 0.000 0.016
#> GSM213090     3  0.0237      0.841 0.004 0.000 0.996
#> GSM213093     1  0.0592      0.925 0.988 0.000 0.012
#> GSM213097     1  0.0237      0.925 0.996 0.000 0.004
#> GSM213099     1  0.6925      0.011 0.532 0.016 0.452
#> GSM213101     1  0.0475      0.925 0.992 0.004 0.004
#> GSM213105     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213109     1  0.0592      0.925 0.988 0.000 0.012
#> GSM213110     2  0.4808      0.753 0.188 0.804 0.008
#> GSM213113     1  0.3148      0.881 0.916 0.036 0.048
#> GSM213121     2  0.1031      0.904 0.024 0.976 0.000
#> GSM213123     1  0.0661      0.925 0.988 0.008 0.004
#> GSM213125     2  0.0747      0.902 0.016 0.984 0.000
#> GSM213073     3  0.3116      0.930 0.108 0.000 0.892
#> GSM213086     1  0.0661      0.925 0.988 0.004 0.008
#> GSM213098     1  0.2584      0.886 0.928 0.064 0.008
#> GSM213106     1  0.0475      0.924 0.992 0.004 0.004
#> GSM213124     1  0.4915      0.729 0.804 0.184 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0844      0.902 0.980 0.004 0.004 0.012
#> GSM213082     2  0.1059      0.899 0.016 0.972 0.000 0.012
#> GSM213085     1  0.0859      0.904 0.980 0.004 0.008 0.008
#> GSM213088     1  0.1109      0.903 0.968 0.004 0.000 0.028
#> GSM213091     1  0.5396     -0.277 0.524 0.000 0.012 0.464
#> GSM213092     1  0.0712      0.904 0.984 0.004 0.004 0.008
#> GSM213096     1  0.0376      0.902 0.992 0.000 0.004 0.004
#> GSM213100     1  0.0188      0.902 0.996 0.000 0.004 0.000
#> GSM213111     2  0.1724      0.892 0.032 0.948 0.000 0.020
#> GSM213117     1  0.1305      0.901 0.960 0.004 0.000 0.036
#> GSM213118     1  0.1707      0.899 0.952 0.020 0.004 0.024
#> GSM213120     2  0.4887      0.699 0.184 0.772 0.016 0.028
#> GSM213122     2  0.0000      0.899 0.000 1.000 0.000 0.000
#> GSM213074     1  0.2342      0.871 0.912 0.000 0.008 0.080
#> GSM213077     1  0.0524      0.903 0.988 0.000 0.004 0.008
#> GSM213083     1  0.0804      0.903 0.980 0.000 0.008 0.012
#> GSM213094     4  0.2670     -0.294 0.024 0.000 0.072 0.904
#> GSM213095     2  0.1749      0.894 0.012 0.952 0.012 0.024
#> GSM213102     1  0.0895      0.901 0.976 0.000 0.004 0.020
#> GSM213103     1  0.3264      0.822 0.876 0.096 0.004 0.024
#> GSM213104     1  0.5930      0.539 0.700 0.228 0.024 0.048
#> GSM213107     2  0.0592      0.898 0.000 0.984 0.000 0.016
#> GSM213108     2  0.2115      0.886 0.036 0.936 0.004 0.024
#> GSM213112     1  0.1443      0.897 0.960 0.028 0.004 0.008
#> GSM213114     1  0.4114      0.657 0.788 0.200 0.004 0.008
#> GSM213115     2  0.3695      0.756 0.156 0.828 0.000 0.016
#> GSM213116     1  0.1004      0.904 0.972 0.004 0.000 0.024
#> GSM213119     2  0.0000      0.899 0.000 1.000 0.000 0.000
#> GSM213072     1  0.1305      0.899 0.960 0.000 0.004 0.036
#> GSM213075     1  0.2039      0.894 0.940 0.008 0.016 0.036
#> GSM213076     2  0.3958      0.746 0.160 0.816 0.000 0.024
#> GSM213079     3  0.3215      0.871 0.032 0.000 0.876 0.092
#> GSM213080     1  0.4732      0.638 0.768 0.200 0.012 0.020
#> GSM213081     1  0.2002      0.879 0.936 0.000 0.020 0.044
#> GSM213084     1  0.0376      0.902 0.992 0.000 0.004 0.004
#> GSM213087     2  0.0336      0.898 0.000 0.992 0.000 0.008
#> GSM213089     1  0.1211      0.899 0.960 0.000 0.000 0.040
#> GSM213090     3  0.3528      0.753 0.000 0.000 0.808 0.192
#> GSM213093     1  0.1584      0.899 0.952 0.000 0.012 0.036
#> GSM213097     1  0.0895      0.901 0.976 0.000 0.004 0.020
#> GSM213099     4  0.5088      0.218 0.424 0.000 0.004 0.572
#> GSM213101     1  0.0844      0.902 0.980 0.004 0.004 0.012
#> GSM213105     2  0.0000      0.899 0.000 1.000 0.000 0.000
#> GSM213109     1  0.0804      0.903 0.980 0.000 0.008 0.012
#> GSM213110     2  0.3853      0.747 0.160 0.820 0.000 0.020
#> GSM213113     1  0.4520      0.782 0.832 0.032 0.080 0.056
#> GSM213121     2  0.0804      0.900 0.008 0.980 0.000 0.012
#> GSM213123     1  0.0992      0.904 0.976 0.008 0.004 0.012
#> GSM213125     2  0.0000      0.899 0.000 1.000 0.000 0.000
#> GSM213073     3  0.2943      0.869 0.032 0.000 0.892 0.076
#> GSM213086     1  0.0712      0.904 0.984 0.004 0.004 0.008
#> GSM213098     1  0.3777      0.819 0.868 0.060 0.020 0.052
#> GSM213106     1  0.1118      0.900 0.964 0.000 0.000 0.036
#> GSM213124     1  0.4448      0.672 0.784 0.188 0.004 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.1026      0.875 0.968 0.004 0.000 0.004 0.024
#> GSM213082     2  0.3551      0.773 0.008 0.772 0.000 0.000 0.220
#> GSM213085     1  0.0833      0.877 0.976 0.000 0.004 0.004 0.016
#> GSM213088     1  0.1278      0.876 0.960 0.004 0.000 0.020 0.016
#> GSM213091     4  0.4913      0.333 0.488 0.000 0.012 0.492 0.008
#> GSM213092     1  0.0833      0.878 0.976 0.004 0.004 0.000 0.016
#> GSM213096     1  0.0955      0.876 0.968 0.000 0.000 0.004 0.028
#> GSM213100     1  0.0865      0.876 0.972 0.000 0.000 0.004 0.024
#> GSM213111     2  0.3877      0.783 0.024 0.764 0.000 0.000 0.212
#> GSM213117     1  0.1914      0.868 0.932 0.004 0.000 0.032 0.032
#> GSM213118     1  0.2217      0.867 0.920 0.012 0.000 0.024 0.044
#> GSM213120     2  0.6362      0.623 0.136 0.584 0.016 0.004 0.260
#> GSM213122     2  0.0000      0.810 0.000 1.000 0.000 0.000 0.000
#> GSM213074     1  0.2824      0.829 0.880 0.000 0.008 0.088 0.024
#> GSM213077     1  0.0579      0.876 0.984 0.000 0.000 0.008 0.008
#> GSM213083     1  0.0693      0.875 0.980 0.000 0.000 0.012 0.008
#> GSM213094     4  0.2243     -0.409 0.012 0.000 0.056 0.916 0.016
#> GSM213095     2  0.4440      0.731 0.000 0.660 0.012 0.004 0.324
#> GSM213102     1  0.0865      0.874 0.972 0.000 0.000 0.024 0.004
#> GSM213103     1  0.3976      0.766 0.824 0.084 0.000 0.024 0.068
#> GSM213104     1  0.6730      0.335 0.596 0.168 0.016 0.024 0.196
#> GSM213107     2  0.2997      0.771 0.000 0.840 0.000 0.012 0.148
#> GSM213108     2  0.4308      0.761 0.020 0.732 0.004 0.004 0.240
#> GSM213112     1  0.1372      0.874 0.956 0.016 0.000 0.004 0.024
#> GSM213114     1  0.4404      0.594 0.760 0.152 0.000 0.000 0.088
#> GSM213115     2  0.4512      0.699 0.136 0.772 0.000 0.012 0.080
#> GSM213116     1  0.1560      0.873 0.948 0.004 0.000 0.020 0.028
#> GSM213119     2  0.0579      0.809 0.000 0.984 0.000 0.008 0.008
#> GSM213072     1  0.1907      0.863 0.928 0.000 0.000 0.044 0.028
#> GSM213075     1  0.2784      0.852 0.896 0.004 0.012 0.048 0.040
#> GSM213076     2  0.5503      0.680 0.128 0.672 0.000 0.008 0.192
#> GSM213079     3  0.2321      0.949 0.016 0.000 0.916 0.044 0.024
#> GSM213080     1  0.5109      0.564 0.732 0.152 0.008 0.008 0.100
#> GSM213081     1  0.3689      0.761 0.820 0.000 0.016 0.024 0.140
#> GSM213084     1  0.0609      0.877 0.980 0.000 0.000 0.000 0.020
#> GSM213087     2  0.1557      0.804 0.000 0.940 0.000 0.008 0.052
#> GSM213089     1  0.1364      0.873 0.952 0.000 0.000 0.036 0.012
#> GSM213090     5  0.6384      0.000 0.000 0.000 0.388 0.168 0.444
#> GSM213093     1  0.2140      0.869 0.924 0.000 0.012 0.024 0.040
#> GSM213097     1  0.0865      0.874 0.972 0.000 0.000 0.024 0.004
#> GSM213099     4  0.4686      0.504 0.396 0.000 0.012 0.588 0.004
#> GSM213101     1  0.0932      0.875 0.972 0.004 0.000 0.004 0.020
#> GSM213105     2  0.0579      0.809 0.000 0.984 0.000 0.008 0.008
#> GSM213109     1  0.0912      0.876 0.972 0.000 0.000 0.016 0.012
#> GSM213110     2  0.4611      0.690 0.140 0.764 0.000 0.012 0.084
#> GSM213113     1  0.5846      0.544 0.688 0.008 0.092 0.036 0.176
#> GSM213121     2  0.2286      0.794 0.004 0.888 0.000 0.000 0.108
#> GSM213123     1  0.1153      0.878 0.964 0.000 0.004 0.008 0.024
#> GSM213125     2  0.0162      0.811 0.000 0.996 0.000 0.000 0.004
#> GSM213073     3  0.1469      0.950 0.016 0.000 0.948 0.036 0.000
#> GSM213086     1  0.1093      0.877 0.968 0.004 0.004 0.004 0.020
#> GSM213098     1  0.5122      0.632 0.732 0.028 0.024 0.024 0.192
#> GSM213106     1  0.1661      0.868 0.940 0.000 0.000 0.036 0.024
#> GSM213124     1  0.5126      0.616 0.744 0.128 0.004 0.024 0.100

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.1476      0.843 0.948 0.004 0.000 0.028 0.008 0.012
#> GSM213082     2  0.4051     -0.118 0.008 0.560 0.000 0.000 0.000 0.432
#> GSM213085     1  0.1350      0.846 0.952 0.000 0.000 0.020 0.008 0.020
#> GSM213088     1  0.1678      0.845 0.940 0.004 0.004 0.032 0.004 0.016
#> GSM213091     4  0.4698      0.386 0.436 0.000 0.024 0.528 0.000 0.012
#> GSM213092     1  0.1546      0.846 0.944 0.000 0.000 0.020 0.016 0.020
#> GSM213096     1  0.1350      0.844 0.952 0.000 0.000 0.020 0.008 0.020
#> GSM213100     1  0.1262      0.845 0.956 0.000 0.000 0.016 0.008 0.020
#> GSM213111     2  0.4355     -0.200 0.024 0.556 0.000 0.000 0.000 0.420
#> GSM213117     1  0.2144      0.832 0.908 0.000 0.004 0.048 0.000 0.040
#> GSM213118     1  0.2356      0.833 0.900 0.004 0.004 0.048 0.000 0.044
#> GSM213120     6  0.6540      0.237 0.100 0.372 0.012 0.016 0.028 0.472
#> GSM213122     2  0.0458      0.523 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM213074     1  0.3211      0.789 0.848 0.000 0.004 0.096 0.020 0.032
#> GSM213077     1  0.1346      0.846 0.952 0.000 0.000 0.024 0.008 0.016
#> GSM213083     1  0.1296      0.846 0.952 0.000 0.000 0.032 0.004 0.012
#> GSM213094     4  0.3536     -0.347 0.004 0.000 0.048 0.820 0.116 0.012
#> GSM213095     6  0.3426      0.322 0.000 0.220 0.012 0.004 0.000 0.764
#> GSM213102     1  0.1010      0.843 0.960 0.000 0.000 0.036 0.000 0.004
#> GSM213103     1  0.4172      0.734 0.792 0.036 0.004 0.052 0.004 0.112
#> GSM213104     1  0.7497      0.189 0.500 0.096 0.004 0.092 0.072 0.236
#> GSM213107     2  0.4151      0.133 0.000 0.576 0.000 0.008 0.004 0.412
#> GSM213108     2  0.4699     -0.153 0.016 0.528 0.000 0.008 0.008 0.440
#> GSM213112     1  0.1810      0.844 0.932 0.008 0.000 0.020 0.004 0.036
#> GSM213114     1  0.5016      0.564 0.720 0.084 0.000 0.024 0.020 0.152
#> GSM213115     2  0.4802      0.292 0.132 0.724 0.000 0.016 0.008 0.120
#> GSM213116     1  0.2010      0.837 0.920 0.000 0.004 0.036 0.004 0.036
#> GSM213119     2  0.0858      0.523 0.000 0.968 0.000 0.004 0.000 0.028
#> GSM213072     1  0.2288      0.824 0.896 0.000 0.004 0.072 0.000 0.028
#> GSM213075     1  0.2786      0.816 0.876 0.000 0.008 0.076 0.008 0.032
#> GSM213076     2  0.6435     -0.357 0.100 0.468 0.000 0.024 0.032 0.376
#> GSM213079     3  0.1152      0.948 0.004 0.000 0.952 0.000 0.044 0.000
#> GSM213080     1  0.5580      0.516 0.680 0.084 0.000 0.036 0.032 0.168
#> GSM213081     1  0.4866      0.663 0.740 0.000 0.004 0.088 0.068 0.100
#> GSM213084     1  0.1262      0.846 0.956 0.000 0.000 0.020 0.008 0.016
#> GSM213087     2  0.2101      0.489 0.000 0.892 0.000 0.004 0.004 0.100
#> GSM213089     1  0.1578      0.841 0.936 0.000 0.004 0.048 0.000 0.012
#> GSM213090     5  0.2165      0.000 0.000 0.000 0.108 0.008 0.884 0.000
#> GSM213093     1  0.2489      0.830 0.900 0.000 0.016 0.052 0.012 0.020
#> GSM213097     1  0.1010      0.843 0.960 0.000 0.000 0.036 0.000 0.004
#> GSM213099     4  0.4241      0.502 0.348 0.000 0.020 0.628 0.000 0.004
#> GSM213101     1  0.1375      0.843 0.952 0.004 0.000 0.028 0.008 0.008
#> GSM213105     2  0.0692      0.524 0.000 0.976 0.000 0.004 0.000 0.020
#> GSM213109     1  0.0891      0.845 0.968 0.000 0.000 0.024 0.000 0.008
#> GSM213110     2  0.4922      0.284 0.136 0.716 0.000 0.020 0.008 0.120
#> GSM213113     1  0.7191      0.341 0.572 0.004 0.100 0.088 0.104 0.132
#> GSM213121     2  0.3606      0.299 0.004 0.708 0.000 0.004 0.000 0.284
#> GSM213123     1  0.1590      0.848 0.944 0.000 0.008 0.012 0.008 0.028
#> GSM213125     2  0.0713      0.521 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM213073     3  0.0146      0.949 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM213086     1  0.1630      0.845 0.940 0.000 0.000 0.024 0.016 0.020
#> GSM213098     1  0.6011      0.481 0.636 0.000 0.012 0.088 0.092 0.172
#> GSM213106     1  0.2000      0.832 0.916 0.000 0.004 0.048 0.000 0.032
#> GSM213124     1  0.4931      0.604 0.732 0.080 0.000 0.040 0.012 0.136

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n development.stage(p) disease.state(p) k
#> CV:hclust 37                0.637            1.000 2
#> CV:hclust 52                0.459            0.817 3
#> CV:hclust 51                0.164            0.913 4
#> CV:hclust 50                0.308            0.847 5
#> CV:hclust 37                0.375            0.814 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.484           0.896       0.883         0.3687 0.575   0.575
#> 3 3 0.923           0.891       0.944         0.4710 0.885   0.800
#> 4 4 0.556           0.577       0.795         0.2384 0.881   0.746
#> 5 5 0.576           0.558       0.751         0.1036 0.836   0.578
#> 6 6 0.609           0.550       0.755         0.0577 0.955   0.829

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
#> GSM213078     1  0.8081      0.933 0.752 0.248
#> GSM213082     2  0.0672      0.967 0.008 0.992
#> GSM213085     1  0.8081      0.933 0.752 0.248
#> GSM213088     1  0.8081      0.933 0.752 0.248
#> GSM213091     1  0.2603      0.743 0.956 0.044
#> GSM213092     1  0.8081      0.933 0.752 0.248
#> GSM213096     1  0.8081      0.933 0.752 0.248
#> GSM213100     1  0.8081      0.933 0.752 0.248
#> GSM213111     2  0.0672      0.967 0.008 0.992
#> GSM213117     1  0.8081      0.933 0.752 0.248
#> GSM213118     1  0.8081      0.933 0.752 0.248
#> GSM213120     2  0.0672      0.967 0.008 0.992
#> GSM213122     2  0.0672      0.967 0.008 0.992
#> GSM213074     1  0.7139      0.894 0.804 0.196
#> GSM213077     1  0.8081      0.933 0.752 0.248
#> GSM213083     1  0.8081      0.933 0.752 0.248
#> GSM213094     1  0.3431      0.640 0.936 0.064
#> GSM213095     2  0.0672      0.950 0.008 0.992
#> GSM213102     1  0.8081      0.933 0.752 0.248
#> GSM213103     2  0.9129      0.236 0.328 0.672
#> GSM213104     1  0.8081      0.933 0.752 0.248
#> GSM213107     2  0.0672      0.967 0.008 0.992
#> GSM213108     2  0.0938      0.963 0.012 0.988
#> GSM213112     1  0.8081      0.933 0.752 0.248
#> GSM213114     1  0.8081      0.933 0.752 0.248
#> GSM213115     2  0.0672      0.967 0.008 0.992
#> GSM213116     1  0.8081      0.933 0.752 0.248
#> GSM213119     2  0.0672      0.967 0.008 0.992
#> GSM213072     1  0.7056      0.890 0.808 0.192
#> GSM213075     1  0.7950      0.930 0.760 0.240
#> GSM213076     2  0.0672      0.967 0.008 0.992
#> GSM213079     1  0.3431      0.640 0.936 0.064
#> GSM213080     1  0.8081      0.933 0.752 0.248
#> GSM213081     1  0.8016      0.932 0.756 0.244
#> GSM213084     1  0.8081      0.933 0.752 0.248
#> GSM213087     2  0.0672      0.967 0.008 0.992
#> GSM213089     1  0.7950      0.930 0.760 0.240
#> GSM213090     1  0.3431      0.640 0.936 0.064
#> GSM213093     1  0.7950      0.930 0.760 0.240
#> GSM213097     1  0.8081      0.933 0.752 0.248
#> GSM213099     1  0.2778      0.747 0.952 0.048
#> GSM213101     1  0.8081      0.933 0.752 0.248
#> GSM213105     2  0.0672      0.967 0.008 0.992
#> GSM213109     1  0.8016      0.932 0.756 0.244
#> GSM213110     2  0.1633      0.949 0.024 0.976
#> GSM213113     1  0.7883      0.927 0.764 0.236
#> GSM213121     2  0.0672      0.967 0.008 0.992
#> GSM213123     1  0.8081      0.933 0.752 0.248
#> GSM213125     2  0.0672      0.967 0.008 0.992
#> GSM213073     1  0.3431      0.640 0.936 0.064
#> GSM213086     1  0.8081      0.933 0.752 0.248
#> GSM213098     1  0.8081      0.933 0.752 0.248
#> GSM213106     1  0.8081      0.933 0.752 0.248
#> GSM213124     1  0.9427      0.781 0.640 0.360

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0892     0.9481 0.980 0.000 0.020
#> GSM213082     2  0.0747     0.9375 0.000 0.984 0.016
#> GSM213085     1  0.0592     0.9513 0.988 0.000 0.012
#> GSM213088     1  0.1031     0.9489 0.976 0.000 0.024
#> GSM213091     3  0.6286     0.1835 0.464 0.000 0.536
#> GSM213092     1  0.0000     0.9517 1.000 0.000 0.000
#> GSM213096     1  0.0892     0.9481 0.980 0.000 0.020
#> GSM213100     1  0.0237     0.9517 0.996 0.000 0.004
#> GSM213111     2  0.0424     0.9386 0.000 0.992 0.008
#> GSM213117     1  0.1964     0.9304 0.944 0.000 0.056
#> GSM213118     1  0.0424     0.9523 0.992 0.000 0.008
#> GSM213120     2  0.1753     0.9224 0.000 0.952 0.048
#> GSM213122     2  0.0747     0.9375 0.000 0.984 0.016
#> GSM213074     1  0.2537     0.9101 0.920 0.000 0.080
#> GSM213077     1  0.0592     0.9507 0.988 0.000 0.012
#> GSM213083     1  0.0237     0.9515 0.996 0.000 0.004
#> GSM213094     3  0.2448     0.8577 0.076 0.000 0.924
#> GSM213095     2  0.1031     0.9356 0.000 0.976 0.024
#> GSM213102     1  0.1031     0.9474 0.976 0.000 0.024
#> GSM213103     2  0.7979     0.0842 0.440 0.500 0.060
#> GSM213104     1  0.1647     0.9365 0.960 0.004 0.036
#> GSM213107     2  0.1411     0.9335 0.000 0.964 0.036
#> GSM213108     2  0.0892     0.9372 0.000 0.980 0.020
#> GSM213112     1  0.0424     0.9515 0.992 0.000 0.008
#> GSM213114     1  0.1163     0.9447 0.972 0.000 0.028
#> GSM213115     2  0.0592     0.9386 0.000 0.988 0.012
#> GSM213116     1  0.1163     0.9469 0.972 0.000 0.028
#> GSM213119     2  0.1031     0.9366 0.000 0.976 0.024
#> GSM213072     1  0.2066     0.9276 0.940 0.000 0.060
#> GSM213075     1  0.1964     0.9409 0.944 0.000 0.056
#> GSM213076     2  0.1163     0.9360 0.000 0.972 0.028
#> GSM213079     3  0.2448     0.8577 0.076 0.000 0.924
#> GSM213080     1  0.1525     0.9396 0.964 0.004 0.032
#> GSM213081     1  0.1163     0.9491 0.972 0.000 0.028
#> GSM213084     1  0.0892     0.9481 0.980 0.000 0.020
#> GSM213087     2  0.0892     0.9378 0.000 0.980 0.020
#> GSM213089     1  0.1964     0.9304 0.944 0.000 0.056
#> GSM213090     3  0.2356     0.8547 0.072 0.000 0.928
#> GSM213093     1  0.1289     0.9450 0.968 0.000 0.032
#> GSM213097     1  0.0892     0.9487 0.980 0.000 0.020
#> GSM213099     1  0.5678     0.4700 0.684 0.000 0.316
#> GSM213101     1  0.0892     0.9481 0.980 0.000 0.020
#> GSM213105     2  0.1031     0.9366 0.000 0.976 0.024
#> GSM213109     1  0.0237     0.9515 0.996 0.000 0.004
#> GSM213110     2  0.1031     0.9365 0.000 0.976 0.024
#> GSM213113     1  0.2711     0.9140 0.912 0.000 0.088
#> GSM213121     2  0.1289     0.9339 0.000 0.968 0.032
#> GSM213123     1  0.1163     0.9502 0.972 0.000 0.028
#> GSM213125     2  0.0592     0.9379 0.000 0.988 0.012
#> GSM213073     3  0.2261     0.8526 0.068 0.000 0.932
#> GSM213086     1  0.0000     0.9517 1.000 0.000 0.000
#> GSM213098     1  0.1529     0.9455 0.960 0.000 0.040
#> GSM213106     1  0.1529     0.9410 0.960 0.000 0.040
#> GSM213124     1  0.5852     0.6789 0.776 0.180 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.1940     0.6370 0.924 0.000 0.000 0.076
#> GSM213082     2  0.2654     0.8680 0.000 0.888 0.004 0.108
#> GSM213085     1  0.2053     0.6491 0.924 0.000 0.004 0.072
#> GSM213088     1  0.3172     0.6192 0.840 0.000 0.000 0.160
#> GSM213091     4  0.7130     0.2649 0.132 0.000 0.396 0.472
#> GSM213092     1  0.1211     0.6590 0.960 0.000 0.000 0.040
#> GSM213096     1  0.2469     0.6398 0.892 0.000 0.000 0.108
#> GSM213100     1  0.1302     0.6594 0.956 0.000 0.000 0.044
#> GSM213111     2  0.3726     0.8550 0.000 0.788 0.000 0.212
#> GSM213117     1  0.5281    -0.0666 0.528 0.000 0.008 0.464
#> GSM213118     1  0.4585     0.2998 0.668 0.000 0.000 0.332
#> GSM213120     2  0.4950     0.7467 0.000 0.620 0.004 0.376
#> GSM213122     2  0.0188     0.8803 0.000 0.996 0.000 0.004
#> GSM213074     1  0.5695    -0.1659 0.500 0.000 0.024 0.476
#> GSM213077     1  0.0779     0.6547 0.980 0.000 0.004 0.016
#> GSM213083     1  0.0188     0.6575 0.996 0.000 0.000 0.004
#> GSM213094     3  0.1722     0.9586 0.008 0.000 0.944 0.048
#> GSM213095     2  0.4584     0.8138 0.000 0.696 0.004 0.300
#> GSM213102     1  0.3768     0.5499 0.808 0.000 0.008 0.184
#> GSM213103     4  0.6449     0.4208 0.140 0.220 0.000 0.640
#> GSM213104     1  0.4406     0.3038 0.700 0.000 0.000 0.300
#> GSM213107     2  0.3870     0.8358 0.000 0.788 0.004 0.208
#> GSM213108     2  0.3157     0.8630 0.000 0.852 0.004 0.144
#> GSM213112     1  0.2401     0.6381 0.904 0.000 0.004 0.092
#> GSM213114     1  0.2281     0.6262 0.904 0.000 0.000 0.096
#> GSM213115     2  0.1389     0.8782 0.000 0.952 0.000 0.048
#> GSM213116     1  0.5132    -0.0261 0.548 0.000 0.004 0.448
#> GSM213119     2  0.0524     0.8791 0.000 0.988 0.004 0.008
#> GSM213072     1  0.5295    -0.1514 0.504 0.000 0.008 0.488
#> GSM213075     4  0.4967     0.0954 0.452 0.000 0.000 0.548
#> GSM213076     2  0.4331     0.8074 0.000 0.712 0.000 0.288
#> GSM213079     3  0.0376     0.9802 0.004 0.000 0.992 0.004
#> GSM213080     1  0.2530     0.6156 0.888 0.000 0.000 0.112
#> GSM213081     1  0.3444     0.5809 0.816 0.000 0.000 0.184
#> GSM213084     1  0.1792     0.6410 0.932 0.000 0.000 0.068
#> GSM213087     2  0.0779     0.8789 0.000 0.980 0.004 0.016
#> GSM213089     1  0.5277    -0.0767 0.532 0.000 0.008 0.460
#> GSM213090     3  0.0657     0.9763 0.004 0.000 0.984 0.012
#> GSM213093     1  0.4991     0.1185 0.608 0.000 0.004 0.388
#> GSM213097     1  0.3142     0.5957 0.860 0.000 0.008 0.132
#> GSM213099     4  0.7290     0.4229 0.328 0.000 0.168 0.504
#> GSM213101     1  0.1867     0.6396 0.928 0.000 0.000 0.072
#> GSM213105     2  0.0524     0.8791 0.000 0.988 0.004 0.008
#> GSM213109     1  0.1305     0.6579 0.960 0.000 0.004 0.036
#> GSM213110     2  0.1978     0.8742 0.004 0.928 0.000 0.068
#> GSM213113     4  0.5466     0.4615 0.292 0.000 0.040 0.668
#> GSM213121     2  0.3539     0.8497 0.000 0.820 0.004 0.176
#> GSM213123     1  0.4222     0.4868 0.728 0.000 0.000 0.272
#> GSM213125     2  0.0469     0.8809 0.000 0.988 0.000 0.012
#> GSM213073     3  0.0336     0.9781 0.000 0.000 0.992 0.008
#> GSM213086     1  0.1389     0.6571 0.952 0.000 0.000 0.048
#> GSM213098     4  0.4761     0.3196 0.372 0.000 0.000 0.628
#> GSM213106     1  0.5268    -0.0390 0.540 0.000 0.008 0.452
#> GSM213124     4  0.6712     0.4147 0.344 0.104 0.000 0.552

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0798     0.7587 0.976 0.000 0.000 0.016 0.008
#> GSM213082     2  0.3618     0.5948 0.000 0.788 0.004 0.012 0.196
#> GSM213085     1  0.2795     0.7465 0.872 0.000 0.000 0.100 0.028
#> GSM213088     1  0.4193     0.5057 0.720 0.000 0.000 0.256 0.024
#> GSM213091     4  0.5663     0.4620 0.052 0.000 0.208 0.680 0.060
#> GSM213092     1  0.2423     0.7543 0.896 0.000 0.000 0.080 0.024
#> GSM213096     1  0.1668     0.7572 0.940 0.000 0.000 0.032 0.028
#> GSM213100     1  0.1774     0.7646 0.932 0.000 0.000 0.052 0.016
#> GSM213111     2  0.4723     0.0955 0.000 0.536 0.000 0.016 0.448
#> GSM213117     4  0.3706     0.6860 0.236 0.000 0.004 0.756 0.004
#> GSM213118     1  0.5547     0.0491 0.532 0.000 0.004 0.404 0.060
#> GSM213120     5  0.4848     0.2088 0.000 0.304 0.004 0.036 0.656
#> GSM213122     2  0.0510     0.7337 0.000 0.984 0.000 0.000 0.016
#> GSM213074     4  0.4532     0.7020 0.216 0.000 0.012 0.736 0.036
#> GSM213077     1  0.2339     0.7465 0.892 0.000 0.004 0.100 0.004
#> GSM213083     1  0.1697     0.7616 0.932 0.000 0.000 0.060 0.008
#> GSM213094     3  0.3532     0.8840 0.000 0.000 0.832 0.092 0.076
#> GSM213095     5  0.4696     0.0849 0.000 0.400 0.004 0.012 0.584
#> GSM213102     1  0.4908     0.2120 0.560 0.000 0.004 0.416 0.020
#> GSM213103     4  0.8260    -0.1321 0.120 0.196 0.004 0.348 0.332
#> GSM213104     1  0.4946     0.5064 0.700 0.004 0.004 0.056 0.236
#> GSM213107     2  0.4789     0.1683 0.000 0.584 0.000 0.024 0.392
#> GSM213108     2  0.4556     0.4735 0.000 0.680 0.004 0.024 0.292
#> GSM213112     1  0.3051     0.7305 0.852 0.000 0.000 0.120 0.028
#> GSM213114     1  0.1893     0.7383 0.928 0.000 0.000 0.024 0.048
#> GSM213115     2  0.2304     0.7138 0.000 0.908 0.004 0.020 0.068
#> GSM213116     4  0.3870     0.6793 0.260 0.000 0.004 0.732 0.004
#> GSM213119     2  0.0000     0.7331 0.000 1.000 0.000 0.000 0.000
#> GSM213072     4  0.4423     0.6939 0.232 0.000 0.004 0.728 0.036
#> GSM213075     4  0.5409     0.6494 0.252 0.000 0.008 0.656 0.084
#> GSM213076     5  0.4565     0.1090 0.000 0.408 0.000 0.012 0.580
#> GSM213079     3  0.0451     0.9498 0.000 0.000 0.988 0.008 0.004
#> GSM213080     1  0.2504     0.7245 0.900 0.004 0.000 0.032 0.064
#> GSM213081     1  0.6217     0.3772 0.584 0.000 0.008 0.216 0.192
#> GSM213084     1  0.0693     0.7597 0.980 0.000 0.000 0.012 0.008
#> GSM213087     2  0.1124     0.7264 0.000 0.960 0.000 0.004 0.036
#> GSM213089     4  0.4095     0.6984 0.220 0.000 0.004 0.752 0.024
#> GSM213090     3  0.1399     0.9458 0.000 0.000 0.952 0.020 0.028
#> GSM213093     4  0.5539     0.5786 0.324 0.000 0.004 0.596 0.076
#> GSM213097     1  0.4832     0.3594 0.616 0.000 0.004 0.356 0.024
#> GSM213099     4  0.4814     0.6707 0.128 0.000 0.032 0.764 0.076
#> GSM213101     1  0.0898     0.7594 0.972 0.000 0.000 0.020 0.008
#> GSM213105     2  0.0162     0.7333 0.000 0.996 0.000 0.000 0.004
#> GSM213109     1  0.2519     0.7503 0.884 0.000 0.000 0.100 0.016
#> GSM213110     2  0.3269     0.6826 0.024 0.868 0.004 0.024 0.080
#> GSM213113     4  0.6898     0.2323 0.156 0.000 0.024 0.420 0.400
#> GSM213121     2  0.4639     0.2461 0.000 0.612 0.000 0.020 0.368
#> GSM213123     1  0.6068     0.0704 0.516 0.000 0.004 0.368 0.112
#> GSM213125     2  0.1121     0.7291 0.000 0.956 0.000 0.000 0.044
#> GSM213073     3  0.0324     0.9484 0.000 0.000 0.992 0.004 0.004
#> GSM213086     1  0.2653     0.7491 0.880 0.000 0.000 0.096 0.024
#> GSM213098     5  0.6871    -0.3971 0.220 0.000 0.008 0.368 0.404
#> GSM213106     4  0.4142     0.6680 0.252 0.000 0.004 0.728 0.016
#> GSM213124     4  0.6704     0.6186 0.156 0.096 0.004 0.628 0.116

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.1718     0.7115 0.932 0.000 0.000 0.016 0.008 0.044
#> GSM213082     2  0.3622     0.5074 0.000 0.760 0.000 0.004 0.212 0.024
#> GSM213085     1  0.3119     0.7068 0.856 0.000 0.000 0.076 0.032 0.036
#> GSM213088     1  0.4858     0.4164 0.660 0.000 0.000 0.252 0.012 0.076
#> GSM213091     4  0.5554     0.4889 0.004 0.000 0.096 0.676 0.084 0.140
#> GSM213092     1  0.2624     0.7217 0.884 0.000 0.000 0.068 0.020 0.028
#> GSM213096     1  0.2071     0.7157 0.916 0.000 0.000 0.028 0.012 0.044
#> GSM213100     1  0.2375     0.7309 0.896 0.000 0.000 0.068 0.016 0.020
#> GSM213111     5  0.4778     0.4091 0.000 0.464 0.000 0.004 0.492 0.040
#> GSM213117     4  0.2478     0.6484 0.076 0.000 0.000 0.888 0.012 0.024
#> GSM213118     1  0.6102     0.0240 0.464 0.000 0.000 0.384 0.036 0.116
#> GSM213120     5  0.5377     0.5942 0.000 0.216 0.000 0.004 0.604 0.176
#> GSM213122     2  0.0508     0.7238 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM213074     4  0.4262     0.6378 0.072 0.000 0.008 0.792 0.056 0.072
#> GSM213077     1  0.2196     0.7084 0.884 0.000 0.000 0.108 0.004 0.004
#> GSM213083     1  0.1718     0.7289 0.932 0.000 0.000 0.044 0.016 0.008
#> GSM213094     3  0.5654     0.7200 0.000 0.000 0.628 0.040 0.140 0.192
#> GSM213095     5  0.3738     0.6843 0.000 0.280 0.000 0.000 0.704 0.016
#> GSM213102     1  0.4847     0.2495 0.528 0.000 0.000 0.424 0.008 0.040
#> GSM213103     4  0.7867    -0.0443 0.052 0.080 0.000 0.348 0.200 0.320
#> GSM213104     1  0.4328     0.4051 0.708 0.000 0.000 0.000 0.080 0.212
#> GSM213107     5  0.5063     0.4961 0.000 0.432 0.000 0.004 0.500 0.064
#> GSM213108     2  0.4868     0.0953 0.000 0.588 0.000 0.008 0.352 0.052
#> GSM213112     1  0.3714     0.6765 0.816 0.000 0.000 0.096 0.040 0.048
#> GSM213114     1  0.1967     0.6845 0.904 0.000 0.000 0.000 0.012 0.084
#> GSM213115     2  0.2719     0.6832 0.000 0.876 0.000 0.012 0.072 0.040
#> GSM213116     4  0.2933     0.6372 0.092 0.000 0.000 0.860 0.016 0.032
#> GSM213119     2  0.0291     0.7269 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM213072     4  0.4081     0.6300 0.088 0.000 0.000 0.788 0.032 0.092
#> GSM213075     4  0.5006     0.5244 0.100 0.000 0.000 0.668 0.016 0.216
#> GSM213076     5  0.4236     0.6895 0.000 0.308 0.000 0.000 0.656 0.036
#> GSM213079     3  0.0000     0.8826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     1  0.2214     0.6773 0.892 0.000 0.000 0.004 0.012 0.092
#> GSM213081     6  0.5862     0.2710 0.404 0.000 0.000 0.136 0.012 0.448
#> GSM213084     1  0.1320     0.7189 0.948 0.000 0.000 0.016 0.000 0.036
#> GSM213087     2  0.1592     0.7057 0.000 0.940 0.000 0.008 0.032 0.020
#> GSM213089     4  0.2444     0.6387 0.068 0.000 0.000 0.892 0.012 0.028
#> GSM213090     3  0.2445     0.8694 0.000 0.000 0.892 0.008 0.060 0.040
#> GSM213093     4  0.5708     0.3202 0.232 0.000 0.000 0.588 0.020 0.160
#> GSM213097     1  0.4824     0.3430 0.588 0.000 0.000 0.356 0.008 0.048
#> GSM213099     4  0.5053     0.5212 0.028 0.000 0.012 0.708 0.084 0.168
#> GSM213101     1  0.1409     0.7155 0.948 0.000 0.000 0.012 0.008 0.032
#> GSM213105     2  0.0291     0.7269 0.000 0.992 0.000 0.004 0.000 0.004
#> GSM213109     1  0.2736     0.7214 0.876 0.000 0.000 0.076 0.020 0.028
#> GSM213110     2  0.3682     0.6413 0.016 0.824 0.000 0.012 0.092 0.056
#> GSM213113     6  0.6209     0.5157 0.088 0.000 0.012 0.224 0.080 0.596
#> GSM213121     2  0.5117    -0.5662 0.000 0.480 0.000 0.004 0.448 0.068
#> GSM213123     1  0.6338    -0.3592 0.344 0.000 0.000 0.336 0.008 0.312
#> GSM213125     2  0.1007     0.7220 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM213073     3  0.0291     0.8810 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM213086     1  0.2684     0.7203 0.880 0.000 0.000 0.072 0.024 0.024
#> GSM213098     6  0.6064     0.5934 0.132 0.000 0.000 0.192 0.076 0.600
#> GSM213106     4  0.2964     0.6209 0.108 0.000 0.000 0.848 0.004 0.040
#> GSM213124     4  0.6651     0.4687 0.056 0.072 0.000 0.604 0.116 0.152

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n development.stage(p) disease.state(p) k
#> CV:kmeans 53                0.601            1.000 2
#> CV:kmeans 51                0.454            0.828 3
#> CV:kmeans 37                0.397            0.805 4
#> CV:kmeans 38                0.183            0.843 5
#> CV:kmeans 39                0.422            0.967 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 51941 rows and 54 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 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-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.652           0.791       0.913         0.4907 0.516   0.516
#> 3 3 0.417           0.627       0.807         0.3705 0.718   0.498
#> 4 4 0.408           0.427       0.678         0.1181 0.928   0.784
#> 5 5 0.466           0.360       0.603         0.0601 0.943   0.801
#> 6 6 0.503           0.290       0.556         0.0408 0.948   0.794

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM213078     1  0.0000     0.8982 1.000 0.000
#> GSM213082     2  0.0000     0.8993 0.000 1.000
#> GSM213085     1  0.2236     0.8951 0.964 0.036
#> GSM213088     1  0.9323     0.4385 0.652 0.348
#> GSM213091     1  0.4161     0.8649 0.916 0.084
#> GSM213092     1  0.0000     0.8982 1.000 0.000
#> GSM213096     1  0.1184     0.8985 0.984 0.016
#> GSM213100     1  0.0000     0.8982 1.000 0.000
#> GSM213111     2  0.0000     0.8993 0.000 1.000
#> GSM213117     1  0.2948     0.8889 0.948 0.052
#> GSM213118     1  0.5059     0.8406 0.888 0.112
#> GSM213120     2  0.0000     0.8993 0.000 1.000
#> GSM213122     2  0.0000     0.8993 0.000 1.000
#> GSM213074     1  0.1633     0.8979 0.976 0.024
#> GSM213077     1  0.0000     0.8982 1.000 0.000
#> GSM213083     1  0.0000     0.8982 1.000 0.000
#> GSM213094     1  0.8608     0.6250 0.716 0.284
#> GSM213095     2  0.0000     0.8993 0.000 1.000
#> GSM213102     1  0.0000     0.8982 1.000 0.000
#> GSM213103     2  0.2043     0.8805 0.032 0.968
#> GSM213104     2  0.7815     0.6664 0.232 0.768
#> GSM213107     2  0.0000     0.8993 0.000 1.000
#> GSM213108     2  0.0000     0.8993 0.000 1.000
#> GSM213112     1  0.3733     0.8764 0.928 0.072
#> GSM213114     1  0.2603     0.8887 0.956 0.044
#> GSM213115     2  0.0000     0.8993 0.000 1.000
#> GSM213116     1  0.0376     0.8987 0.996 0.004
#> GSM213119     2  0.0000     0.8993 0.000 1.000
#> GSM213072     1  0.2778     0.8894 0.952 0.048
#> GSM213075     1  0.9427     0.4526 0.640 0.360
#> GSM213076     2  0.0000     0.8993 0.000 1.000
#> GSM213079     1  0.9491     0.4502 0.632 0.368
#> GSM213080     2  0.9996     0.0357 0.488 0.512
#> GSM213081     1  0.2603     0.8916 0.956 0.044
#> GSM213084     1  0.0000     0.8982 1.000 0.000
#> GSM213087     2  0.0000     0.8993 0.000 1.000
#> GSM213089     1  0.0938     0.8993 0.988 0.012
#> GSM213090     2  0.9732     0.2543 0.404 0.596
#> GSM213093     1  0.1184     0.8992 0.984 0.016
#> GSM213097     1  0.0000     0.8982 1.000 0.000
#> GSM213099     1  0.4431     0.8608 0.908 0.092
#> GSM213101     1  0.0376     0.8989 0.996 0.004
#> GSM213105     2  0.0000     0.8993 0.000 1.000
#> GSM213109     1  0.0000     0.8982 1.000 0.000
#> GSM213110     2  0.2236     0.8774 0.036 0.964
#> GSM213113     1  0.9996     0.0708 0.512 0.488
#> GSM213121     2  0.0000     0.8993 0.000 1.000
#> GSM213123     1  0.3584     0.8783 0.932 0.068
#> GSM213125     2  0.0000     0.8993 0.000 1.000
#> GSM213073     2  0.9993    -0.0347 0.484 0.516
#> GSM213086     1  0.0000     0.8982 1.000 0.000
#> GSM213098     1  0.9170     0.5336 0.668 0.332
#> GSM213106     1  0.1184     0.8994 0.984 0.016
#> GSM213124     2  0.5059     0.8127 0.112 0.888

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.1289     0.6828 0.968 0.000 0.032
#> GSM213082     2  0.0237     0.9265 0.000 0.996 0.004
#> GSM213085     1  0.7279     0.3162 0.588 0.036 0.376
#> GSM213088     1  0.8689     0.3628 0.588 0.248 0.164
#> GSM213091     3  0.2496     0.6699 0.068 0.004 0.928
#> GSM213092     1  0.4002     0.6735 0.840 0.000 0.160
#> GSM213096     1  0.2066     0.6913 0.940 0.000 0.060
#> GSM213100     1  0.4121     0.6616 0.832 0.000 0.168
#> GSM213111     2  0.1031     0.9207 0.000 0.976 0.024
#> GSM213117     3  0.7442     0.4149 0.348 0.048 0.604
#> GSM213118     1  0.8425     0.2480 0.552 0.100 0.348
#> GSM213120     2  0.3445     0.8723 0.016 0.896 0.088
#> GSM213122     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213074     3  0.5109     0.6195 0.212 0.008 0.780
#> GSM213077     1  0.3340     0.6924 0.880 0.000 0.120
#> GSM213083     1  0.3116     0.6917 0.892 0.000 0.108
#> GSM213094     3  0.1015     0.6619 0.012 0.008 0.980
#> GSM213095     2  0.2796     0.8851 0.000 0.908 0.092
#> GSM213102     1  0.6019     0.5348 0.700 0.012 0.288
#> GSM213103     2  0.6663     0.6956 0.096 0.748 0.156
#> GSM213104     1  0.8900     0.2099 0.512 0.356 0.132
#> GSM213107     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213108     2  0.3425     0.8616 0.004 0.884 0.112
#> GSM213112     1  0.7339     0.2731 0.572 0.036 0.392
#> GSM213114     1  0.1620     0.6823 0.964 0.012 0.024
#> GSM213115     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213116     3  0.6701     0.3100 0.412 0.012 0.576
#> GSM213119     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213072     3  0.4521     0.6450 0.180 0.004 0.816
#> GSM213075     3  0.9040     0.3628 0.320 0.156 0.524
#> GSM213076     2  0.2384     0.9030 0.008 0.936 0.056
#> GSM213079     3  0.1620     0.6627 0.024 0.012 0.964
#> GSM213080     1  0.5455     0.5448 0.776 0.204 0.020
#> GSM213081     1  0.7490     0.2693 0.576 0.044 0.380
#> GSM213084     1  0.3116     0.6927 0.892 0.000 0.108
#> GSM213087     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213089     3  0.5737     0.5647 0.256 0.012 0.732
#> GSM213090     3  0.3434     0.6560 0.032 0.064 0.904
#> GSM213093     3  0.6675     0.2771 0.404 0.012 0.584
#> GSM213097     1  0.5058     0.5986 0.756 0.000 0.244
#> GSM213099     3  0.4413     0.6673 0.124 0.024 0.852
#> GSM213101     1  0.1643     0.6882 0.956 0.000 0.044
#> GSM213105     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213109     1  0.5016     0.6116 0.760 0.000 0.240
#> GSM213110     2  0.2165     0.8902 0.064 0.936 0.000
#> GSM213113     3  0.8835     0.4288 0.244 0.180 0.576
#> GSM213121     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213123     1  0.7245     0.3421 0.596 0.036 0.368
#> GSM213125     2  0.0000     0.9275 0.000 1.000 0.000
#> GSM213073     3  0.3550     0.6512 0.024 0.080 0.896
#> GSM213086     1  0.3412     0.6901 0.876 0.000 0.124
#> GSM213098     3  0.9457     0.2368 0.352 0.188 0.460
#> GSM213106     3  0.7188     0.0871 0.484 0.024 0.492
#> GSM213124     2  0.8375     0.4209 0.132 0.608 0.260

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.3047    0.47387 0.872 0.000 0.012 0.116
#> GSM213082     2  0.1510    0.86157 0.000 0.956 0.028 0.016
#> GSM213085     1  0.8208   -0.00693 0.392 0.012 0.264 0.332
#> GSM213088     1  0.8885    0.01814 0.404 0.156 0.084 0.356
#> GSM213091     3  0.4655    0.45660 0.032 0.000 0.760 0.208
#> GSM213092     1  0.6587    0.32198 0.596 0.000 0.112 0.292
#> GSM213096     1  0.4900    0.44291 0.732 0.000 0.032 0.236
#> GSM213100     1  0.5722    0.42293 0.660 0.004 0.044 0.292
#> GSM213111     2  0.2772    0.85050 0.004 0.908 0.048 0.040
#> GSM213117     4  0.8133    0.31896 0.172 0.032 0.312 0.484
#> GSM213118     4  0.7978   -0.07956 0.404 0.040 0.116 0.440
#> GSM213120     2  0.5659    0.74996 0.028 0.760 0.108 0.104
#> GSM213122     2  0.0895    0.86502 0.000 0.976 0.004 0.020
#> GSM213074     3  0.7065    0.11039 0.128 0.004 0.548 0.320
#> GSM213077     1  0.5448    0.42195 0.724 0.000 0.080 0.196
#> GSM213083     1  0.5662    0.42403 0.692 0.000 0.072 0.236
#> GSM213094     3  0.2737    0.52266 0.008 0.000 0.888 0.104
#> GSM213095     2  0.4713    0.76862 0.004 0.788 0.156 0.052
#> GSM213102     4  0.7629    0.08877 0.416 0.008 0.156 0.420
#> GSM213103     2  0.8356    0.37873 0.132 0.532 0.084 0.252
#> GSM213104     1  0.8712    0.21837 0.528 0.148 0.144 0.180
#> GSM213107     2  0.1492    0.86157 0.004 0.956 0.004 0.036
#> GSM213108     2  0.4401    0.78809 0.000 0.812 0.112 0.076
#> GSM213112     1  0.8210    0.05404 0.420 0.016 0.240 0.324
#> GSM213114     1  0.2676    0.47795 0.896 0.000 0.012 0.092
#> GSM213115     2  0.0592    0.86411 0.000 0.984 0.000 0.016
#> GSM213116     4  0.8007    0.34922 0.216 0.016 0.292 0.476
#> GSM213119     2  0.0376    0.86431 0.000 0.992 0.004 0.004
#> GSM213072     3  0.6988    0.12268 0.120 0.000 0.500 0.380
#> GSM213075     3  0.8897    0.02511 0.192 0.076 0.440 0.292
#> GSM213076     2  0.4713    0.78865 0.012 0.808 0.112 0.068
#> GSM213079     3  0.1771    0.53342 0.012 0.004 0.948 0.036
#> GSM213080     1  0.6275    0.37533 0.700 0.136 0.016 0.148
#> GSM213081     1  0.8121    0.16610 0.520 0.036 0.200 0.244
#> GSM213084     1  0.5172    0.46025 0.744 0.000 0.068 0.188
#> GSM213087     2  0.0336    0.86368 0.000 0.992 0.000 0.008
#> GSM213089     4  0.7830    0.17640 0.156 0.016 0.396 0.432
#> GSM213090     3  0.3538    0.52090 0.004 0.044 0.868 0.084
#> GSM213093     4  0.8458    0.23245 0.252 0.024 0.360 0.364
#> GSM213097     1  0.6817   -0.03723 0.492 0.000 0.100 0.408
#> GSM213099     3  0.5883    0.36017 0.064 0.000 0.648 0.288
#> GSM213101     1  0.3790    0.47089 0.820 0.000 0.016 0.164
#> GSM213105     2  0.0188    0.86392 0.000 0.996 0.000 0.004
#> GSM213109     1  0.6839    0.22771 0.552 0.000 0.120 0.328
#> GSM213110     2  0.4524    0.77719 0.104 0.820 0.012 0.064
#> GSM213113     3  0.8142    0.26369 0.120 0.076 0.548 0.256
#> GSM213121     2  0.1004    0.86433 0.000 0.972 0.004 0.024
#> GSM213123     1  0.8400   -0.04351 0.428 0.036 0.188 0.348
#> GSM213125     2  0.0469    0.86367 0.000 0.988 0.000 0.012
#> GSM213073     3  0.3363    0.52727 0.040 0.020 0.888 0.052
#> GSM213086     1  0.5907    0.37330 0.668 0.000 0.080 0.252
#> GSM213098     3  0.9505   -0.02325 0.240 0.116 0.360 0.284
#> GSM213106     4  0.8035    0.39474 0.244 0.012 0.288 0.456
#> GSM213124     2  0.9086    0.02111 0.092 0.424 0.192 0.292

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.3427     0.4069 0.844 0.000 0.012 0.112 0.032
#> GSM213082     2  0.2522     0.8012 0.000 0.904 0.012 0.028 0.056
#> GSM213085     1  0.7952    -0.1212 0.368 0.000 0.156 0.120 0.356
#> GSM213088     1  0.7648     0.0817 0.412 0.128 0.016 0.384 0.060
#> GSM213091     3  0.5274     0.3903 0.008 0.000 0.664 0.256 0.072
#> GSM213092     1  0.6803     0.1649 0.512 0.000 0.048 0.108 0.332
#> GSM213096     1  0.6001     0.2472 0.616 0.000 0.020 0.108 0.256
#> GSM213100     1  0.7042     0.2201 0.544 0.000 0.080 0.116 0.260
#> GSM213111     2  0.4278     0.7712 0.004 0.816 0.064 0.040 0.076
#> GSM213117     4  0.7523     0.3250 0.084 0.008 0.192 0.532 0.184
#> GSM213118     5  0.7760     0.1152 0.280 0.020 0.060 0.160 0.480
#> GSM213120     2  0.6261     0.6623 0.016 0.672 0.048 0.104 0.160
#> GSM213122     2  0.0693     0.8069 0.000 0.980 0.000 0.008 0.012
#> GSM213074     3  0.7551     0.1770 0.052 0.008 0.484 0.204 0.252
#> GSM213077     1  0.5829     0.3607 0.692 0.000 0.056 0.124 0.128
#> GSM213083     1  0.6229     0.3481 0.656 0.000 0.064 0.148 0.132
#> GSM213094     3  0.3715     0.4893 0.000 0.004 0.824 0.108 0.064
#> GSM213095     2  0.5625     0.6485 0.000 0.676 0.208 0.028 0.088
#> GSM213102     1  0.7745    -0.0271 0.384 0.004 0.076 0.376 0.160
#> GSM213103     2  0.8720    -0.0305 0.096 0.372 0.084 0.104 0.344
#> GSM213104     1  0.9081    -0.1282 0.396 0.124 0.108 0.112 0.260
#> GSM213107     2  0.3380     0.7964 0.012 0.864 0.020 0.020 0.084
#> GSM213108     2  0.5472     0.7195 0.012 0.744 0.096 0.060 0.088
#> GSM213112     5  0.8555     0.0465 0.312 0.012 0.208 0.132 0.336
#> GSM213114     1  0.4270     0.3840 0.788 0.000 0.008 0.124 0.080
#> GSM213115     2  0.1757     0.8049 0.004 0.936 0.000 0.012 0.048
#> GSM213116     4  0.8406     0.2294 0.164 0.004 0.252 0.384 0.196
#> GSM213119     2  0.1041     0.8084 0.000 0.964 0.000 0.004 0.032
#> GSM213072     3  0.7872     0.1085 0.100 0.000 0.412 0.180 0.308
#> GSM213075     3  0.9317    -0.0368 0.128 0.072 0.328 0.228 0.244
#> GSM213076     2  0.5518     0.7199 0.020 0.744 0.088 0.048 0.100
#> GSM213079     3  0.3086     0.4959 0.016 0.000 0.876 0.048 0.060
#> GSM213080     1  0.7248     0.2219 0.592 0.096 0.016 0.140 0.156
#> GSM213081     1  0.8098     0.0690 0.392 0.004 0.168 0.320 0.116
#> GSM213084     1  0.4943     0.3731 0.752 0.000 0.028 0.132 0.088
#> GSM213087     2  0.1365     0.8071 0.004 0.952 0.000 0.004 0.040
#> GSM213089     4  0.7784     0.2200 0.104 0.004 0.300 0.452 0.140
#> GSM213090     3  0.4430     0.4900 0.020 0.016 0.796 0.036 0.132
#> GSM213093     4  0.8423     0.2067 0.212 0.008 0.232 0.400 0.148
#> GSM213097     1  0.6975     0.0710 0.460 0.000 0.076 0.384 0.080
#> GSM213099     3  0.6115     0.2987 0.040 0.000 0.612 0.268 0.080
#> GSM213101     1  0.4895     0.4000 0.756 0.004 0.016 0.128 0.096
#> GSM213105     2  0.0865     0.8064 0.004 0.972 0.000 0.000 0.024
#> GSM213109     1  0.7312     0.2268 0.532 0.000 0.084 0.204 0.180
#> GSM213110     2  0.5743     0.6722 0.096 0.724 0.020 0.044 0.116
#> GSM213113     3  0.8749     0.1121 0.088 0.076 0.428 0.152 0.256
#> GSM213121     2  0.1970     0.8054 0.000 0.924 0.004 0.012 0.060
#> GSM213123     4  0.8738     0.0530 0.308 0.028 0.132 0.352 0.180
#> GSM213125     2  0.0854     0.8082 0.000 0.976 0.012 0.008 0.004
#> GSM213073     3  0.4091     0.4732 0.012 0.000 0.808 0.084 0.096
#> GSM213086     1  0.6776     0.2071 0.536 0.000 0.036 0.144 0.284
#> GSM213098     5  0.9565     0.0570 0.216 0.068 0.240 0.232 0.244
#> GSM213106     4  0.7049     0.2948 0.216 0.008 0.156 0.568 0.052
#> GSM213124     2  0.8617    -0.0064 0.056 0.372 0.084 0.148 0.340

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.3706    0.30681 0.824 0.004 0.000 0.072 0.032 0.068
#> GSM213082     2  0.3759    0.73901 0.004 0.824 0.020 0.020 0.104 0.028
#> GSM213085     6  0.7750    0.27663 0.256 0.008 0.192 0.064 0.048 0.432
#> GSM213088     1  0.7983    0.03169 0.416 0.088 0.032 0.320 0.084 0.060
#> GSM213091     3  0.6219    0.36022 0.012 0.000 0.596 0.220 0.072 0.100
#> GSM213092     6  0.6520    0.11258 0.396 0.000 0.060 0.040 0.048 0.456
#> GSM213096     1  0.6899    0.05352 0.540 0.004 0.024 0.104 0.088 0.240
#> GSM213100     1  0.7341   -0.00759 0.460 0.000 0.048 0.116 0.080 0.296
#> GSM213111     2  0.4513    0.72770 0.008 0.788 0.044 0.028 0.096 0.036
#> GSM213117     4  0.6702    0.25808 0.076 0.012 0.092 0.632 0.080 0.108
#> GSM213118     6  0.8619    0.02774 0.204 0.012 0.052 0.228 0.184 0.320
#> GSM213120     2  0.6121    0.57946 0.008 0.616 0.060 0.040 0.240 0.036
#> GSM213122     2  0.1870    0.75810 0.004 0.928 0.000 0.012 0.044 0.012
#> GSM213074     3  0.7982    0.06103 0.076 0.000 0.340 0.212 0.064 0.308
#> GSM213077     1  0.6409    0.16671 0.588 0.000 0.040 0.124 0.036 0.212
#> GSM213083     1  0.6128    0.17503 0.584 0.000 0.024 0.104 0.032 0.256
#> GSM213094     3  0.4590    0.41660 0.004 0.004 0.752 0.148 0.036 0.056
#> GSM213095     2  0.6591    0.48438 0.000 0.548 0.208 0.012 0.172 0.060
#> GSM213102     4  0.7983    0.01841 0.312 0.004 0.072 0.348 0.056 0.208
#> GSM213103     2  0.9010   -0.11305 0.056 0.304 0.068 0.124 0.292 0.156
#> GSM213104     1  0.9018   -0.04382 0.304 0.100 0.088 0.052 0.292 0.164
#> GSM213107     2  0.3540    0.73543 0.008 0.816 0.016 0.004 0.140 0.016
#> GSM213108     2  0.6591    0.59833 0.008 0.624 0.116 0.044 0.136 0.072
#> GSM213112     6  0.7958    0.27537 0.292 0.020 0.168 0.056 0.056 0.408
#> GSM213114     1  0.4064    0.26681 0.800 0.004 0.004 0.024 0.080 0.088
#> GSM213115     2  0.2658    0.75495 0.004 0.884 0.000 0.016 0.072 0.024
#> GSM213116     4  0.7697    0.21251 0.096 0.004 0.164 0.500 0.076 0.160
#> GSM213119     2  0.0603    0.75662 0.000 0.980 0.000 0.000 0.016 0.004
#> GSM213072     3  0.8341    0.01609 0.076 0.000 0.308 0.292 0.116 0.208
#> GSM213075     3  0.9288   -0.04294 0.108 0.040 0.300 0.188 0.192 0.172
#> GSM213076     2  0.5883    0.62332 0.012 0.632 0.060 0.024 0.240 0.032
#> GSM213079     3  0.3548    0.38146 0.004 0.000 0.836 0.048 0.072 0.040
#> GSM213080     1  0.7338    0.22632 0.556 0.080 0.008 0.084 0.156 0.116
#> GSM213081     1  0.8199    0.03436 0.380 0.008 0.068 0.140 0.292 0.112
#> GSM213084     1  0.6711    0.11915 0.536 0.000 0.032 0.084 0.076 0.272
#> GSM213087     2  0.1728    0.75696 0.000 0.924 0.000 0.004 0.064 0.008
#> GSM213089     4  0.7502    0.13114 0.048 0.000 0.236 0.456 0.068 0.192
#> GSM213090     3  0.3923    0.37591 0.012 0.008 0.824 0.032 0.048 0.076
#> GSM213093     4  0.8727    0.07187 0.172 0.000 0.208 0.264 0.104 0.252
#> GSM213097     1  0.8122    0.03537 0.380 0.012 0.044 0.276 0.096 0.192
#> GSM213099     3  0.7459    0.21508 0.032 0.000 0.460 0.252 0.104 0.152
#> GSM213101     1  0.4857    0.28164 0.748 0.004 0.004 0.084 0.064 0.096
#> GSM213105     2  0.1297    0.75771 0.000 0.948 0.000 0.000 0.040 0.012
#> GSM213109     1  0.6767   -0.07217 0.424 0.000 0.068 0.112 0.012 0.384
#> GSM213110     2  0.6228    0.61404 0.060 0.668 0.016 0.044 0.120 0.092
#> GSM213113     5  0.8057    0.06586 0.056 0.016 0.356 0.108 0.356 0.108
#> GSM213121     2  0.2609    0.75147 0.000 0.868 0.004 0.008 0.112 0.008
#> GSM213123     5  0.8948   -0.05265 0.208 0.012 0.112 0.260 0.268 0.140
#> GSM213125     2  0.1484    0.75906 0.000 0.944 0.004 0.008 0.040 0.004
#> GSM213073     3  0.4451    0.30834 0.008 0.004 0.764 0.040 0.148 0.036
#> GSM213086     1  0.6659   -0.12257 0.456 0.000 0.032 0.076 0.056 0.380
#> GSM213098     5  0.8152    0.23956 0.140 0.036 0.192 0.064 0.476 0.092
#> GSM213106     4  0.6969    0.28301 0.112 0.012 0.116 0.600 0.052 0.108
#> GSM213124     2  0.9507   -0.11262 0.064 0.276 0.104 0.192 0.176 0.188

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n development.stage(p) disease.state(p) k
#> CV:skmeans 47                0.923            0.891 2
#> CV:skmeans 39                0.356            0.978 3
#> CV:skmeans 19                0.495            0.976 4
#> CV:skmeans 15                   NA               NA 5
#> CV:skmeans 14                   NA               NA 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 51941 rows and 54 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 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-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.571           0.826       0.919         0.4577 0.560   0.560
#> 3 3 0.460           0.694       0.825         0.4020 0.743   0.550
#> 4 4 0.431           0.624       0.805         0.0574 0.964   0.892
#> 5 5 0.429           0.605       0.789         0.0228 0.979   0.933
#> 6 6 0.489           0.583       0.790         0.0245 0.990   0.966

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
#> GSM213078     1  0.2236      0.892 0.964 0.036
#> GSM213082     2  0.0000      0.920 0.000 1.000
#> GSM213085     1  0.0938      0.899 0.988 0.012
#> GSM213088     1  0.8386      0.657 0.732 0.268
#> GSM213091     1  0.0938      0.899 0.988 0.012
#> GSM213092     1  0.0000      0.898 1.000 0.000
#> GSM213096     1  0.0376      0.899 0.996 0.004
#> GSM213100     1  0.0000      0.898 1.000 0.000
#> GSM213111     2  0.0000      0.920 0.000 1.000
#> GSM213117     1  0.4690      0.858 0.900 0.100
#> GSM213118     1  0.0000      0.898 1.000 0.000
#> GSM213120     2  0.5519      0.823 0.128 0.872
#> GSM213122     2  0.0000      0.920 0.000 1.000
#> GSM213074     1  0.0000      0.898 1.000 0.000
#> GSM213077     1  0.0000      0.898 1.000 0.000
#> GSM213083     1  0.0376      0.899 0.996 0.004
#> GSM213094     1  0.7883      0.696 0.764 0.236
#> GSM213095     2  0.5519      0.820 0.128 0.872
#> GSM213102     1  0.0672      0.899 0.992 0.008
#> GSM213103     2  0.8207      0.624 0.256 0.744
#> GSM213104     1  0.9988      0.148 0.520 0.480
#> GSM213107     2  0.0000      0.920 0.000 1.000
#> GSM213108     2  0.1843      0.910 0.028 0.972
#> GSM213112     1  0.2236      0.891 0.964 0.036
#> GSM213114     1  0.0376      0.899 0.996 0.004
#> GSM213115     2  0.0000      0.920 0.000 1.000
#> GSM213116     1  0.8327      0.683 0.736 0.264
#> GSM213119     2  0.0000      0.920 0.000 1.000
#> GSM213072     1  0.7883      0.695 0.764 0.236
#> GSM213075     1  0.7950      0.706 0.760 0.240
#> GSM213076     2  0.9833      0.165 0.424 0.576
#> GSM213079     1  0.8267      0.682 0.740 0.260
#> GSM213080     1  0.8608      0.631 0.716 0.284
#> GSM213081     1  0.4161      0.864 0.916 0.084
#> GSM213084     1  0.3431      0.877 0.936 0.064
#> GSM213087     2  0.0000      0.920 0.000 1.000
#> GSM213089     1  0.0376      0.899 0.996 0.004
#> GSM213090     1  0.9522      0.433 0.628 0.372
#> GSM213093     1  0.2948      0.880 0.948 0.052
#> GSM213097     1  0.0000      0.898 1.000 0.000
#> GSM213099     1  0.1633      0.896 0.976 0.024
#> GSM213101     1  0.0672      0.899 0.992 0.008
#> GSM213105     2  0.0000      0.920 0.000 1.000
#> GSM213109     1  0.0000      0.898 1.000 0.000
#> GSM213110     2  0.2236      0.905 0.036 0.964
#> GSM213113     1  0.0938      0.899 0.988 0.012
#> GSM213121     2  0.0000      0.920 0.000 1.000
#> GSM213123     1  0.1184      0.899 0.984 0.016
#> GSM213125     2  0.0000      0.920 0.000 1.000
#> GSM213073     1  0.6343      0.807 0.840 0.160
#> GSM213086     1  0.0000      0.898 1.000 0.000
#> GSM213098     1  0.1633      0.896 0.976 0.024
#> GSM213106     1  0.0000      0.898 1.000 0.000
#> GSM213124     2  0.3879      0.876 0.076 0.924

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0000      0.769 1.000 0.000 0.000
#> GSM213082     2  0.1031      0.903 0.000 0.976 0.024
#> GSM213085     3  0.4399      0.728 0.188 0.000 0.812
#> GSM213088     1  0.1529      0.749 0.960 0.040 0.000
#> GSM213091     1  0.6483      0.164 0.544 0.004 0.452
#> GSM213092     3  0.4504      0.726 0.196 0.000 0.804
#> GSM213096     1  0.1411      0.775 0.964 0.000 0.036
#> GSM213100     1  0.4796      0.700 0.780 0.000 0.220
#> GSM213111     2  0.1482      0.904 0.012 0.968 0.020
#> GSM213117     1  0.5514      0.724 0.800 0.044 0.156
#> GSM213118     3  0.5560      0.633 0.300 0.000 0.700
#> GSM213120     2  0.5111      0.779 0.144 0.820 0.036
#> GSM213122     2  0.1163      0.902 0.000 0.972 0.028
#> GSM213074     3  0.5810      0.643 0.336 0.000 0.664
#> GSM213077     1  0.4121      0.755 0.832 0.000 0.168
#> GSM213083     1  0.3879      0.766 0.848 0.000 0.152
#> GSM213094     3  0.1765      0.690 0.040 0.004 0.956
#> GSM213095     3  0.6577      0.248 0.008 0.420 0.572
#> GSM213102     1  0.4047      0.765 0.848 0.004 0.148
#> GSM213103     2  0.5848      0.633 0.268 0.720 0.012
#> GSM213104     3  0.9517      0.361 0.208 0.320 0.472
#> GSM213107     2  0.0000      0.905 0.000 1.000 0.000
#> GSM213108     2  0.1774      0.896 0.024 0.960 0.016
#> GSM213112     3  0.5008      0.731 0.180 0.016 0.804
#> GSM213114     1  0.2448      0.782 0.924 0.000 0.076
#> GSM213115     2  0.0237      0.905 0.004 0.996 0.000
#> GSM213116     1  0.9151      0.237 0.528 0.180 0.292
#> GSM213119     2  0.0747      0.904 0.000 0.984 0.016
#> GSM213072     3  0.6684      0.574 0.292 0.032 0.676
#> GSM213075     1  0.3039      0.773 0.920 0.044 0.036
#> GSM213076     2  0.7819      0.141 0.440 0.508 0.052
#> GSM213079     3  0.3993      0.652 0.064 0.052 0.884
#> GSM213080     1  0.1411      0.756 0.964 0.036 0.000
#> GSM213081     1  0.3587      0.778 0.892 0.020 0.088
#> GSM213084     1  0.5202      0.601 0.772 0.008 0.220
#> GSM213087     2  0.0747      0.904 0.000 0.984 0.016
#> GSM213089     3  0.5706      0.618 0.320 0.000 0.680
#> GSM213090     3  0.1950      0.690 0.040 0.008 0.952
#> GSM213093     3  0.7699      0.233 0.420 0.048 0.532
#> GSM213097     1  0.3686      0.769 0.860 0.000 0.140
#> GSM213099     3  0.5728      0.692 0.272 0.008 0.720
#> GSM213101     1  0.0747      0.775 0.984 0.000 0.016
#> GSM213105     2  0.1031      0.903 0.000 0.976 0.024
#> GSM213109     1  0.6008      0.356 0.628 0.000 0.372
#> GSM213110     2  0.2261      0.880 0.068 0.932 0.000
#> GSM213113     3  0.5553      0.670 0.272 0.004 0.724
#> GSM213121     2  0.0829      0.905 0.004 0.984 0.012
#> GSM213123     1  0.5268      0.670 0.776 0.012 0.212
#> GSM213125     2  0.0983      0.905 0.004 0.980 0.016
#> GSM213073     3  0.3572      0.675 0.060 0.040 0.900
#> GSM213086     3  0.4399      0.728 0.188 0.000 0.812
#> GSM213098     1  0.4682      0.704 0.804 0.004 0.192
#> GSM213106     1  0.5560      0.596 0.700 0.000 0.300
#> GSM213124     2  0.3587      0.850 0.088 0.892 0.020

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0188     0.7684 0.996 0.000 0.000 0.004
#> GSM213082     2  0.2530     0.8450 0.000 0.888 0.112 0.000
#> GSM213085     4  0.2149     0.6578 0.088 0.000 0.000 0.912
#> GSM213088     1  0.0817     0.7621 0.976 0.024 0.000 0.000
#> GSM213091     4  0.4985    -0.0585 0.468 0.000 0.000 0.532
#> GSM213092     4  0.2530     0.6604 0.112 0.000 0.000 0.888
#> GSM213096     1  0.1970     0.7659 0.932 0.000 0.008 0.060
#> GSM213100     1  0.4539     0.6427 0.720 0.000 0.008 0.272
#> GSM213111     2  0.1151     0.8538 0.008 0.968 0.024 0.000
#> GSM213117     1  0.5208     0.6649 0.736 0.032 0.012 0.220
#> GSM213118     4  0.3908     0.6388 0.212 0.000 0.004 0.784
#> GSM213120     2  0.4078     0.7274 0.132 0.828 0.004 0.036
#> GSM213122     2  0.2704     0.8409 0.000 0.876 0.124 0.000
#> GSM213074     4  0.4655     0.5949 0.312 0.000 0.004 0.684
#> GSM213077     1  0.3610     0.7386 0.800 0.000 0.000 0.200
#> GSM213083     1  0.3448     0.7583 0.828 0.000 0.004 0.168
#> GSM213094     3  0.3945     0.0000 0.004 0.000 0.780 0.216
#> GSM213095     4  0.5884     0.1618 0.004 0.384 0.032 0.580
#> GSM213102     1  0.3819     0.7526 0.816 0.004 0.008 0.172
#> GSM213103     2  0.5366     0.5631 0.240 0.712 0.004 0.044
#> GSM213104     4  0.7373     0.2384 0.184 0.316 0.000 0.500
#> GSM213107     2  0.1211     0.8570 0.000 0.960 0.040 0.000
#> GSM213108     2  0.1394     0.8511 0.016 0.964 0.012 0.008
#> GSM213112     4  0.2530     0.6605 0.100 0.000 0.004 0.896
#> GSM213114     1  0.2216     0.7797 0.908 0.000 0.000 0.092
#> GSM213115     2  0.0188     0.8534 0.000 0.996 0.004 0.000
#> GSM213116     1  0.7816     0.1331 0.476 0.184 0.012 0.328
#> GSM213119     2  0.2345     0.8460 0.000 0.900 0.100 0.000
#> GSM213072     4  0.4639     0.5898 0.228 0.008 0.012 0.752
#> GSM213075     1  0.2408     0.7721 0.920 0.044 0.000 0.036
#> GSM213076     2  0.7068     0.1843 0.396 0.516 0.032 0.056
#> GSM213079     4  0.6278     0.1224 0.040 0.024 0.304 0.632
#> GSM213080     1  0.0895     0.7660 0.976 0.020 0.000 0.004
#> GSM213081     1  0.2741     0.7771 0.892 0.012 0.000 0.096
#> GSM213084     1  0.4123     0.5848 0.772 0.008 0.000 0.220
#> GSM213087     2  0.2345     0.8460 0.000 0.900 0.100 0.000
#> GSM213089     4  0.4511     0.6056 0.268 0.000 0.008 0.724
#> GSM213090     4  0.2924     0.5055 0.016 0.000 0.100 0.884
#> GSM213093     4  0.5453     0.2630 0.388 0.020 0.000 0.592
#> GSM213097     1  0.3266     0.7568 0.832 0.000 0.000 0.168
#> GSM213099     4  0.3852     0.6554 0.192 0.000 0.008 0.800
#> GSM213101     1  0.0707     0.7739 0.980 0.000 0.000 0.020
#> GSM213105     2  0.2589     0.8431 0.000 0.884 0.116 0.000
#> GSM213109     1  0.5039     0.3163 0.592 0.000 0.004 0.404
#> GSM213110     2  0.1716     0.8325 0.064 0.936 0.000 0.000
#> GSM213113     4  0.3400     0.6590 0.180 0.000 0.000 0.820
#> GSM213121     2  0.1022     0.8555 0.000 0.968 0.032 0.000
#> GSM213123     1  0.4122     0.6448 0.760 0.004 0.000 0.236
#> GSM213125     2  0.2011     0.8538 0.000 0.920 0.080 0.000
#> GSM213073     4  0.5642     0.1955 0.020 0.020 0.288 0.672
#> GSM213086     4  0.2149     0.6578 0.088 0.000 0.000 0.912
#> GSM213098     1  0.3870     0.6797 0.788 0.000 0.004 0.208
#> GSM213106     1  0.4836     0.5693 0.672 0.000 0.008 0.320
#> GSM213124     2  0.2730     0.8014 0.088 0.896 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0000     0.7466 1.000 0.000 0.000 0.000 0.000
#> GSM213082     2  0.2966     0.7931 0.000 0.816 0.000 0.000 0.184
#> GSM213085     4  0.1965     0.6563 0.096 0.000 0.000 0.904 0.000
#> GSM213088     1  0.0290     0.7462 0.992 0.008 0.000 0.000 0.000
#> GSM213091     4  0.4294     0.0331 0.468 0.000 0.000 0.532 0.000
#> GSM213092     4  0.2424     0.6631 0.132 0.000 0.000 0.868 0.000
#> GSM213096     1  0.2248     0.7333 0.900 0.000 0.012 0.088 0.000
#> GSM213100     1  0.4173     0.5770 0.688 0.000 0.012 0.300 0.000
#> GSM213111     2  0.1331     0.8146 0.008 0.952 0.000 0.000 0.040
#> GSM213117     1  0.5053     0.5913 0.700 0.028 0.016 0.244 0.012
#> GSM213118     4  0.3398     0.6486 0.216 0.000 0.004 0.780 0.000
#> GSM213120     2  0.3011     0.7084 0.140 0.844 0.000 0.016 0.000
#> GSM213122     2  0.3242     0.7817 0.000 0.784 0.000 0.000 0.216
#> GSM213074     4  0.4135     0.5671 0.340 0.000 0.004 0.656 0.000
#> GSM213077     1  0.3177     0.7086 0.792 0.000 0.000 0.208 0.000
#> GSM213083     1  0.3123     0.7256 0.812 0.000 0.004 0.184 0.000
#> GSM213094     5  0.4678     0.0000 0.000 0.000 0.224 0.064 0.712
#> GSM213095     4  0.5460    -0.0479 0.004 0.420 0.000 0.524 0.052
#> GSM213102     1  0.3575     0.7185 0.800 0.004 0.016 0.180 0.000
#> GSM213103     2  0.4976     0.5147 0.228 0.696 0.004 0.072 0.000
#> GSM213104     4  0.6358     0.2174 0.180 0.328 0.000 0.492 0.000
#> GSM213107     2  0.1270     0.8192 0.000 0.948 0.000 0.000 0.052
#> GSM213108     2  0.1673     0.8166 0.016 0.944 0.000 0.008 0.032
#> GSM213112     4  0.2286     0.6603 0.108 0.000 0.004 0.888 0.000
#> GSM213114     1  0.2020     0.7568 0.900 0.000 0.000 0.100 0.000
#> GSM213115     2  0.0162     0.8139 0.000 0.996 0.000 0.000 0.004
#> GSM213116     1  0.6859     0.0211 0.452 0.184 0.016 0.348 0.000
#> GSM213119     2  0.2852     0.7942 0.000 0.828 0.000 0.000 0.172
#> GSM213072     4  0.4257     0.6176 0.212 0.008 0.012 0.756 0.012
#> GSM213075     1  0.2074     0.7513 0.920 0.044 0.000 0.036 0.000
#> GSM213076     2  0.6571     0.1716 0.376 0.500 0.000 0.072 0.052
#> GSM213079     3  0.3837     0.6453 0.000 0.000 0.692 0.308 0.000
#> GSM213080     1  0.0404     0.7464 0.988 0.012 0.000 0.000 0.000
#> GSM213081     1  0.2248     0.7548 0.900 0.012 0.000 0.088 0.000
#> GSM213084     1  0.3388     0.5983 0.792 0.008 0.000 0.200 0.000
#> GSM213087     2  0.2773     0.7972 0.000 0.836 0.000 0.000 0.164
#> GSM213089     4  0.4380     0.5851 0.288 0.000 0.008 0.692 0.012
#> GSM213090     4  0.5018    -0.0234 0.004 0.000 0.252 0.680 0.064
#> GSM213093     4  0.4640     0.2671 0.400 0.016 0.000 0.584 0.000
#> GSM213097     1  0.2891     0.7292 0.824 0.000 0.000 0.176 0.000
#> GSM213099     4  0.3778     0.6653 0.188 0.000 0.012 0.788 0.012
#> GSM213101     1  0.0404     0.7515 0.988 0.000 0.000 0.012 0.000
#> GSM213105     2  0.3143     0.7864 0.000 0.796 0.000 0.000 0.204
#> GSM213109     1  0.4321     0.2953 0.600 0.000 0.004 0.396 0.000
#> GSM213110     2  0.1341     0.8015 0.056 0.944 0.000 0.000 0.000
#> GSM213113     4  0.2891     0.6786 0.176 0.000 0.000 0.824 0.000
#> GSM213121     2  0.1478     0.8162 0.000 0.936 0.000 0.000 0.064
#> GSM213123     1  0.3521     0.6344 0.764 0.004 0.000 0.232 0.000
#> GSM213125     2  0.2732     0.8061 0.000 0.840 0.000 0.000 0.160
#> GSM213073     3  0.3366     0.6013 0.000 0.004 0.784 0.212 0.000
#> GSM213086     4  0.2020     0.6589 0.100 0.000 0.000 0.900 0.000
#> GSM213098     1  0.3461     0.6330 0.772 0.000 0.004 0.224 0.000
#> GSM213106     1  0.4453     0.5187 0.660 0.000 0.008 0.324 0.008
#> GSM213124     2  0.2130     0.7763 0.080 0.908 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
#> GSM213078     1  0.0000     0.7269 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213082     2  0.2854     0.7782 0.000 0.792 0.000 0.000 0.000 0.208
#> GSM213085     4  0.1327     0.6526 0.064 0.000 0.000 0.936 0.000 0.000
#> GSM213088     1  0.0551     0.7272 0.984 0.008 0.000 0.004 0.000 0.004
#> GSM213091     4  0.3937     0.1613 0.424 0.000 0.000 0.572 0.004 0.000
#> GSM213092     4  0.2219     0.6599 0.136 0.000 0.000 0.864 0.000 0.000
#> GSM213096     1  0.2624     0.6758 0.844 0.000 0.004 0.148 0.004 0.000
#> GSM213100     1  0.4022     0.4561 0.628 0.000 0.008 0.360 0.004 0.000
#> GSM213111     2  0.1554     0.8047 0.008 0.940 0.000 0.004 0.004 0.044
#> GSM213117     1  0.4926     0.4747 0.636 0.024 0.000 0.292 0.048 0.000
#> GSM213118     4  0.2772     0.6619 0.180 0.000 0.004 0.816 0.000 0.000
#> GSM213120     2  0.2933     0.7146 0.124 0.848 0.000 0.016 0.008 0.004
#> GSM213122     2  0.3076     0.7666 0.000 0.760 0.000 0.000 0.000 0.240
#> GSM213074     4  0.3861     0.5189 0.352 0.000 0.000 0.640 0.008 0.000
#> GSM213077     1  0.2854     0.6894 0.792 0.000 0.000 0.208 0.000 0.000
#> GSM213083     1  0.2838     0.7046 0.808 0.000 0.004 0.188 0.000 0.000
#> GSM213094     5  0.2462     0.0000 0.000 0.000 0.096 0.028 0.876 0.000
#> GSM213095     4  0.5058    -0.0296 0.004 0.444 0.000 0.496 0.004 0.052
#> GSM213102     1  0.3437     0.6939 0.788 0.004 0.008 0.188 0.012 0.000
#> GSM213103     2  0.5107     0.4428 0.212 0.652 0.004 0.128 0.004 0.000
#> GSM213104     4  0.5487     0.2287 0.148 0.320 0.000 0.532 0.000 0.000
#> GSM213107     2  0.1285     0.8105 0.000 0.944 0.000 0.004 0.000 0.052
#> GSM213108     2  0.1628     0.8094 0.012 0.940 0.000 0.008 0.004 0.036
#> GSM213112     4  0.1444     0.6537 0.072 0.000 0.000 0.928 0.000 0.000
#> GSM213114     1  0.1863     0.7363 0.896 0.000 0.000 0.104 0.000 0.000
#> GSM213115     2  0.0405     0.8057 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM213116     1  0.6303    -0.0687 0.420 0.176 0.008 0.384 0.012 0.000
#> GSM213119     2  0.2730     0.7802 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM213072     4  0.3502     0.6174 0.192 0.000 0.008 0.780 0.020 0.000
#> GSM213075     1  0.2009     0.7312 0.916 0.040 0.000 0.040 0.004 0.000
#> GSM213076     2  0.6344     0.1912 0.340 0.492 0.000 0.112 0.004 0.052
#> GSM213079     3  0.5131     0.5371 0.000 0.000 0.648 0.204 0.008 0.140
#> GSM213080     1  0.0508     0.7260 0.984 0.012 0.000 0.004 0.000 0.000
#> GSM213081     1  0.2070     0.7323 0.896 0.012 0.000 0.092 0.000 0.000
#> GSM213084     1  0.3073     0.5678 0.788 0.008 0.000 0.204 0.000 0.000
#> GSM213087     2  0.2631     0.7852 0.000 0.820 0.000 0.000 0.000 0.180
#> GSM213089     4  0.4309     0.5406 0.296 0.000 0.000 0.660 0.044 0.000
#> GSM213090     6  0.5465     0.0000 0.000 0.000 0.028 0.228 0.116 0.628
#> GSM213093     4  0.4045     0.1600 0.428 0.008 0.000 0.564 0.000 0.000
#> GSM213097     1  0.2597     0.7091 0.824 0.000 0.000 0.176 0.000 0.000
#> GSM213099     4  0.3542     0.6528 0.160 0.000 0.000 0.788 0.052 0.000
#> GSM213101     1  0.0547     0.7326 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM213105     2  0.2969     0.7729 0.000 0.776 0.000 0.000 0.000 0.224
#> GSM213109     1  0.3890     0.2968 0.596 0.000 0.004 0.400 0.000 0.000
#> GSM213110     2  0.1349     0.7944 0.056 0.940 0.000 0.000 0.004 0.000
#> GSM213113     4  0.2491     0.6786 0.164 0.000 0.000 0.836 0.000 0.000
#> GSM213121     2  0.1732     0.8067 0.000 0.920 0.000 0.004 0.004 0.072
#> GSM213123     1  0.3136     0.6222 0.768 0.004 0.000 0.228 0.000 0.000
#> GSM213125     2  0.2632     0.7959 0.000 0.832 0.000 0.000 0.004 0.164
#> GSM213073     3  0.1700     0.5185 0.000 0.004 0.916 0.080 0.000 0.000
#> GSM213086     4  0.1444     0.6546 0.072 0.000 0.000 0.928 0.000 0.000
#> GSM213098     1  0.3198     0.5694 0.740 0.000 0.000 0.260 0.000 0.000
#> GSM213106     1  0.4018     0.5040 0.656 0.000 0.000 0.324 0.020 0.000
#> GSM213124     2  0.2182     0.7708 0.072 0.904 0.004 0.016 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-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 development.stage(p) disease.state(p) k
#> CV:pam 51                0.534            0.736 2
#> CV:pam 47                0.649            0.923 3
#> CV:pam 44                0.740            0.792 4
#> CV:pam 45                0.461            0.922 5
#> CV:pam 42                0.485            0.952 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.507           0.795       0.903         0.4555 0.560   0.560
#> 3 3 0.697           0.883       0.922         0.1579 0.874   0.783
#> 4 4 0.442           0.434       0.725         0.3161 0.744   0.481
#> 5 5 0.534           0.475       0.692         0.0548 0.841   0.505
#> 6 6 0.580           0.494       0.716         0.0442 0.820   0.438

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
#> GSM213078     1  0.2236      0.871 0.964 0.036
#> GSM213082     2  0.0000      0.910 0.000 1.000
#> GSM213085     1  0.0000      0.876 1.000 0.000
#> GSM213088     1  0.5519      0.824 0.872 0.128
#> GSM213091     1  0.6712      0.790 0.824 0.176
#> GSM213092     1  0.0000      0.876 1.000 0.000
#> GSM213096     1  0.2236      0.871 0.964 0.036
#> GSM213100     1  0.0376      0.876 0.996 0.004
#> GSM213111     2  0.0000      0.910 0.000 1.000
#> GSM213117     1  0.0376      0.876 0.996 0.004
#> GSM213118     1  0.0000      0.876 1.000 0.000
#> GSM213120     2  0.8207      0.641 0.256 0.744
#> GSM213122     2  0.0000      0.910 0.000 1.000
#> GSM213074     1  0.6438      0.801 0.836 0.164
#> GSM213077     1  0.0000      0.876 1.000 0.000
#> GSM213083     1  0.0000      0.876 1.000 0.000
#> GSM213094     1  0.9954      0.345 0.540 0.460
#> GSM213095     2  0.0000      0.910 0.000 1.000
#> GSM213102     1  0.0000      0.876 1.000 0.000
#> GSM213103     2  0.8813      0.565 0.300 0.700
#> GSM213104     1  0.9993      0.122 0.516 0.484
#> GSM213107     2  0.0000      0.910 0.000 1.000
#> GSM213108     2  0.0000      0.910 0.000 1.000
#> GSM213112     1  0.0000      0.876 1.000 0.000
#> GSM213114     1  0.6343      0.804 0.840 0.160
#> GSM213115     2  0.1414      0.898 0.020 0.980
#> GSM213116     1  0.0000      0.876 1.000 0.000
#> GSM213119     2  0.0000      0.910 0.000 1.000
#> GSM213072     1  0.4298      0.849 0.912 0.088
#> GSM213075     1  0.3733      0.858 0.928 0.072
#> GSM213076     2  0.0672      0.906 0.008 0.992
#> GSM213079     1  0.9954      0.345 0.540 0.460
#> GSM213080     1  0.8443      0.674 0.728 0.272
#> GSM213081     1  0.4022      0.855 0.920 0.080
#> GSM213084     1  0.1184      0.874 0.984 0.016
#> GSM213087     2  0.0000      0.910 0.000 1.000
#> GSM213089     1  0.0000      0.876 1.000 0.000
#> GSM213090     1  0.9954      0.345 0.540 0.460
#> GSM213093     1  0.0000      0.876 1.000 0.000
#> GSM213097     1  0.0000      0.876 1.000 0.000
#> GSM213099     1  0.5737      0.819 0.864 0.136
#> GSM213101     1  0.1414      0.874 0.980 0.020
#> GSM213105     2  0.0000      0.910 0.000 1.000
#> GSM213109     1  0.0000      0.876 1.000 0.000
#> GSM213110     2  0.8386      0.621 0.268 0.732
#> GSM213113     1  0.6887      0.783 0.816 0.184
#> GSM213121     2  0.0000      0.910 0.000 1.000
#> GSM213123     1  0.0376      0.876 0.996 0.004
#> GSM213125     2  0.0000      0.910 0.000 1.000
#> GSM213073     1  0.9954      0.345 0.540 0.460
#> GSM213086     1  0.0000      0.876 1.000 0.000
#> GSM213098     1  0.6887      0.783 0.816 0.184
#> GSM213106     1  0.0000      0.876 1.000 0.000
#> GSM213124     2  0.8713      0.579 0.292 0.708

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.2564      0.927 0.936 0.028 0.036
#> GSM213082     2  0.1289      0.847 0.000 0.968 0.032
#> GSM213085     1  0.1482      0.932 0.968 0.020 0.012
#> GSM213088     1  0.2918      0.922 0.924 0.032 0.044
#> GSM213091     1  0.5470      0.837 0.796 0.036 0.168
#> GSM213092     1  0.1031      0.928 0.976 0.000 0.024
#> GSM213096     1  0.2165      0.928 0.936 0.000 0.064
#> GSM213100     1  0.1163      0.928 0.972 0.000 0.028
#> GSM213111     2  0.3482      0.850 0.000 0.872 0.128
#> GSM213117     1  0.0592      0.930 0.988 0.000 0.012
#> GSM213118     1  0.1182      0.931 0.976 0.012 0.012
#> GSM213120     2  0.4731      0.819 0.032 0.840 0.128
#> GSM213122     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213074     1  0.4059      0.880 0.860 0.012 0.128
#> GSM213077     1  0.1031      0.928 0.976 0.000 0.024
#> GSM213083     1  0.1031      0.928 0.976 0.000 0.024
#> GSM213094     3  0.1411      1.000 0.000 0.036 0.964
#> GSM213095     2  0.3482      0.850 0.000 0.872 0.128
#> GSM213102     1  0.0000      0.929 1.000 0.000 0.000
#> GSM213103     2  0.8963      0.144 0.404 0.468 0.128
#> GSM213104     1  0.4848      0.870 0.836 0.036 0.128
#> GSM213107     2  0.3482      0.850 0.000 0.872 0.128
#> GSM213108     2  0.3482      0.850 0.000 0.872 0.128
#> GSM213112     1  0.1482      0.932 0.968 0.020 0.012
#> GSM213114     1  0.4731      0.875 0.840 0.032 0.128
#> GSM213115     2  0.0237      0.841 0.000 0.996 0.004
#> GSM213116     1  0.0424      0.929 0.992 0.000 0.008
#> GSM213119     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213072     1  0.3359      0.907 0.900 0.016 0.084
#> GSM213075     1  0.2651      0.920 0.928 0.012 0.060
#> GSM213076     2  0.3482      0.850 0.000 0.872 0.128
#> GSM213079     3  0.1411      1.000 0.000 0.036 0.964
#> GSM213080     1  0.4799      0.872 0.836 0.032 0.132
#> GSM213081     1  0.3377      0.917 0.896 0.012 0.092
#> GSM213084     1  0.1289      0.929 0.968 0.000 0.032
#> GSM213087     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213089     1  0.0424      0.929 0.992 0.000 0.008
#> GSM213090     3  0.1411      1.000 0.000 0.036 0.964
#> GSM213093     1  0.0424      0.929 0.992 0.000 0.008
#> GSM213097     1  0.0000      0.929 1.000 0.000 0.000
#> GSM213099     1  0.4662      0.877 0.844 0.032 0.124
#> GSM213101     1  0.2056      0.930 0.952 0.024 0.024
#> GSM213105     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213109     1  0.0000      0.929 1.000 0.000 0.000
#> GSM213110     2  0.5656      0.768 0.068 0.804 0.128
#> GSM213113     1  0.4915      0.868 0.832 0.036 0.132
#> GSM213121     2  0.3192      0.852 0.000 0.888 0.112
#> GSM213123     1  0.0424      0.931 0.992 0.000 0.008
#> GSM213125     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213073     3  0.1411      1.000 0.000 0.036 0.964
#> GSM213086     1  0.1031      0.928 0.976 0.000 0.024
#> GSM213098     1  0.4779      0.873 0.840 0.036 0.124
#> GSM213106     1  0.0237      0.929 0.996 0.000 0.004
#> GSM213124     1  0.5174      0.860 0.824 0.048 0.128

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.4245     0.6047 0.832 0.008 0.056 0.104
#> GSM213082     2  0.1867     0.6820 0.000 0.928 0.072 0.000
#> GSM213085     4  0.6171    -0.1740 0.456 0.004 0.040 0.500
#> GSM213088     1  0.8021     0.1368 0.448 0.012 0.224 0.316
#> GSM213091     4  0.4277     0.3514 0.000 0.000 0.280 0.720
#> GSM213092     1  0.4222     0.5615 0.728 0.000 0.000 0.272
#> GSM213096     1  0.2334     0.6022 0.908 0.004 0.000 0.088
#> GSM213100     1  0.3123     0.6086 0.844 0.000 0.000 0.156
#> GSM213111     2  0.6189     0.5628 0.048 0.600 0.344 0.008
#> GSM213117     4  0.2714     0.5980 0.112 0.004 0.000 0.884
#> GSM213118     1  0.6293     0.1505 0.504 0.008 0.040 0.448
#> GSM213120     2  0.6678     0.5196 0.060 0.564 0.360 0.016
#> GSM213122     2  0.0000     0.6866 0.000 1.000 0.000 0.000
#> GSM213074     4  0.3718     0.5337 0.012 0.000 0.168 0.820
#> GSM213077     1  0.4304     0.5514 0.716 0.000 0.000 0.284
#> GSM213083     1  0.4304     0.5507 0.716 0.000 0.000 0.284
#> GSM213094     3  0.0895     0.5623 0.000 0.004 0.976 0.020
#> GSM213095     2  0.6742     0.4736 0.072 0.520 0.400 0.008
#> GSM213102     4  0.4907    -0.0652 0.420 0.000 0.000 0.580
#> GSM213103     3  0.9808     0.3215 0.212 0.204 0.352 0.232
#> GSM213104     1  0.8288    -0.1710 0.412 0.032 0.380 0.176
#> GSM213107     2  0.6382     0.5208 0.052 0.560 0.380 0.008
#> GSM213108     2  0.5936     0.5632 0.040 0.604 0.352 0.004
#> GSM213112     4  0.6177    -0.1887 0.468 0.004 0.040 0.488
#> GSM213114     1  0.6607     0.2992 0.612 0.012 0.296 0.080
#> GSM213115     2  0.0336     0.6887 0.000 0.992 0.008 0.000
#> GSM213116     4  0.2149     0.6119 0.088 0.000 0.000 0.912
#> GSM213119     2  0.0000     0.6866 0.000 1.000 0.000 0.000
#> GSM213072     4  0.2480     0.6060 0.008 0.000 0.088 0.904
#> GSM213075     4  0.5282     0.5721 0.100 0.004 0.136 0.760
#> GSM213076     2  0.6345     0.5547 0.056 0.588 0.348 0.008
#> GSM213079     3  0.0000     0.5654 0.000 0.000 1.000 0.000
#> GSM213080     1  0.7083     0.1669 0.576 0.032 0.320 0.072
#> GSM213081     1  0.4469     0.5791 0.808 0.000 0.080 0.112
#> GSM213084     1  0.2408     0.6072 0.896 0.000 0.000 0.104
#> GSM213087     2  0.0336     0.6890 0.000 0.992 0.008 0.000
#> GSM213089     4  0.1867     0.6118 0.072 0.000 0.000 0.928
#> GSM213090     3  0.0000     0.5654 0.000 0.000 1.000 0.000
#> GSM213093     4  0.2704     0.5916 0.124 0.000 0.000 0.876
#> GSM213097     1  0.4961     0.3282 0.552 0.000 0.000 0.448
#> GSM213099     4  0.3494     0.5451 0.004 0.000 0.172 0.824
#> GSM213101     1  0.4597     0.5972 0.800 0.008 0.044 0.148
#> GSM213105     2  0.0000     0.6866 0.000 1.000 0.000 0.000
#> GSM213109     1  0.4992     0.2689 0.524 0.000 0.000 0.476
#> GSM213110     3  0.9090    -0.0165 0.076 0.356 0.356 0.212
#> GSM213113     3  0.8004     0.1485 0.168 0.020 0.416 0.396
#> GSM213121     2  0.5832     0.5847 0.044 0.640 0.312 0.004
#> GSM213123     4  0.5132     0.0785 0.448 0.000 0.004 0.548
#> GSM213125     2  0.0188     0.6882 0.000 0.996 0.004 0.000
#> GSM213073     3  0.0000     0.5654 0.000 0.000 1.000 0.000
#> GSM213086     1  0.4382     0.5398 0.704 0.000 0.000 0.296
#> GSM213098     3  0.8355     0.0944 0.340 0.016 0.360 0.284
#> GSM213106     4  0.2281     0.6100 0.096 0.000 0.000 0.904
#> GSM213124     4  0.8028    -0.2132 0.076 0.076 0.372 0.476

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.5130    0.64678 0.656 0.000 0.012 0.288 0.044
#> GSM213082     2  0.0963    0.75135 0.000 0.964 0.000 0.000 0.036
#> GSM213085     4  0.5010   -0.18165 0.376 0.000 0.008 0.592 0.024
#> GSM213088     4  0.6541    0.25817 0.244 0.012 0.004 0.560 0.180
#> GSM213091     4  0.6273    0.48330 0.164 0.000 0.060 0.648 0.128
#> GSM213092     1  0.4499    0.53831 0.584 0.000 0.004 0.408 0.004
#> GSM213096     1  0.4535    0.65287 0.684 0.000 0.004 0.288 0.024
#> GSM213100     1  0.3857    0.63601 0.688 0.000 0.000 0.312 0.000
#> GSM213111     2  0.4273   -0.24552 0.000 0.552 0.000 0.000 0.448
#> GSM213117     4  0.0740    0.61317 0.008 0.000 0.004 0.980 0.008
#> GSM213118     4  0.4822   -0.22230 0.416 0.000 0.004 0.564 0.016
#> GSM213120     5  0.4446    0.41748 0.008 0.400 0.000 0.000 0.592
#> GSM213122     2  0.0162    0.76512 0.000 0.996 0.000 0.000 0.004
#> GSM213074     4  0.4871    0.54856 0.128 0.000 0.032 0.760 0.080
#> GSM213077     1  0.4516    0.52421 0.576 0.000 0.004 0.416 0.004
#> GSM213083     1  0.4367    0.52379 0.580 0.000 0.000 0.416 0.004
#> GSM213094     3  0.1990    0.95039 0.008 0.000 0.920 0.004 0.068
#> GSM213095     5  0.3536    0.47299 0.000 0.156 0.032 0.000 0.812
#> GSM213102     4  0.2806    0.52044 0.152 0.000 0.000 0.844 0.004
#> GSM213103     5  0.7255    0.45611 0.204 0.220 0.000 0.060 0.516
#> GSM213104     1  0.5889    0.29529 0.560 0.000 0.016 0.072 0.352
#> GSM213107     5  0.4418    0.27865 0.000 0.332 0.016 0.000 0.652
#> GSM213108     2  0.4714   -0.09634 0.004 0.576 0.012 0.000 0.408
#> GSM213112     4  0.5138   -0.24794 0.396 0.000 0.008 0.568 0.028
#> GSM213114     1  0.5882    0.51771 0.644 0.000 0.016 0.140 0.200
#> GSM213115     2  0.0880    0.75604 0.000 0.968 0.000 0.000 0.032
#> GSM213116     4  0.0404    0.61018 0.012 0.000 0.000 0.988 0.000
#> GSM213119     2  0.0162    0.76512 0.000 0.996 0.000 0.000 0.004
#> GSM213072     4  0.4534    0.54634 0.164 0.000 0.016 0.764 0.056
#> GSM213075     4  0.3570    0.56831 0.048 0.008 0.004 0.844 0.096
#> GSM213076     5  0.4249    0.35807 0.000 0.432 0.000 0.000 0.568
#> GSM213079     3  0.0880    0.97381 0.000 0.000 0.968 0.000 0.032
#> GSM213080     1  0.5519    0.37231 0.624 0.000 0.020 0.052 0.304
#> GSM213081     1  0.5559    0.61303 0.600 0.000 0.004 0.316 0.080
#> GSM213084     1  0.4253    0.64985 0.700 0.000 0.008 0.284 0.008
#> GSM213087     2  0.0290    0.76435 0.000 0.992 0.000 0.000 0.008
#> GSM213089     4  0.0451    0.61284 0.004 0.000 0.000 0.988 0.008
#> GSM213090     3  0.0703    0.97187 0.000 0.000 0.976 0.000 0.024
#> GSM213093     4  0.0609    0.61056 0.020 0.000 0.000 0.980 0.000
#> GSM213097     4  0.4118    0.17067 0.336 0.000 0.000 0.660 0.004
#> GSM213099     4  0.5130    0.52886 0.168 0.000 0.020 0.724 0.088
#> GSM213101     1  0.4726    0.62737 0.644 0.000 0.004 0.328 0.024
#> GSM213105     2  0.0162    0.76512 0.000 0.996 0.000 0.000 0.004
#> GSM213109     4  0.3949    0.28011 0.300 0.000 0.000 0.696 0.004
#> GSM213110     5  0.6121    0.43896 0.060 0.384 0.000 0.032 0.524
#> GSM213113     4  0.7514    0.09588 0.228 0.004 0.040 0.436 0.292
#> GSM213121     2  0.4278   -0.00555 0.000 0.548 0.000 0.000 0.452
#> GSM213123     4  0.4218    0.22720 0.324 0.000 0.004 0.668 0.004
#> GSM213125     2  0.0404    0.76279 0.000 0.988 0.000 0.000 0.012
#> GSM213073     3  0.1341    0.96632 0.000 0.000 0.944 0.000 0.056
#> GSM213086     1  0.4383    0.50548 0.572 0.000 0.000 0.424 0.004
#> GSM213098     1  0.6628    0.42849 0.520 0.000 0.012 0.196 0.272
#> GSM213106     4  0.0566    0.61128 0.012 0.000 0.000 0.984 0.004
#> GSM213124     5  0.6178    0.22271 0.040 0.044 0.004 0.388 0.524

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.2490    0.58577 0.892 0.000 0.000 0.012 0.044 0.052
#> GSM213082     2  0.0935    0.67112 0.000 0.964 0.000 0.000 0.032 0.004
#> GSM213085     1  0.4661    0.44044 0.620 0.000 0.000 0.332 0.036 0.012
#> GSM213088     1  0.6913    0.00792 0.436 0.028 0.000 0.308 0.204 0.024
#> GSM213091     4  0.4829    0.55502 0.044 0.000 0.012 0.744 0.076 0.124
#> GSM213092     1  0.2356    0.63959 0.884 0.000 0.000 0.096 0.004 0.016
#> GSM213096     1  0.1737    0.59608 0.932 0.000 0.000 0.008 0.020 0.040
#> GSM213100     1  0.1370    0.62887 0.948 0.000 0.000 0.036 0.004 0.012
#> GSM213111     2  0.5272    0.38448 0.000 0.596 0.000 0.004 0.276 0.124
#> GSM213117     4  0.2871    0.76384 0.192 0.004 0.000 0.804 0.000 0.000
#> GSM213118     1  0.4370    0.43628 0.640 0.000 0.000 0.324 0.032 0.004
#> GSM213120     2  0.6119    0.08412 0.004 0.432 0.004 0.000 0.360 0.200
#> GSM213122     2  0.0363    0.67246 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM213074     4  0.4093    0.67896 0.076 0.000 0.016 0.804 0.028 0.076
#> GSM213077     1  0.2445    0.63844 0.868 0.000 0.000 0.120 0.004 0.008
#> GSM213083     1  0.2517    0.63901 0.876 0.000 0.000 0.100 0.008 0.016
#> GSM213094     3  0.4920    0.76340 0.004 0.000 0.696 0.024 0.200 0.076
#> GSM213095     6  0.4820    0.67506 0.000 0.088 0.004 0.000 0.256 0.652
#> GSM213102     4  0.4389    0.17749 0.468 0.000 0.000 0.512 0.004 0.016
#> GSM213103     5  0.6879   -0.03520 0.200 0.280 0.000 0.036 0.464 0.020
#> GSM213104     5  0.6293    0.11840 0.348 0.000 0.000 0.080 0.488 0.084
#> GSM213107     6  0.5203    0.73932 0.000 0.184 0.004 0.000 0.180 0.632
#> GSM213108     2  0.4959    0.43568 0.000 0.616 0.000 0.008 0.304 0.072
#> GSM213112     1  0.4661    0.44618 0.620 0.000 0.000 0.332 0.036 0.012
#> GSM213114     1  0.5478    0.14840 0.600 0.000 0.000 0.024 0.276 0.100
#> GSM213115     2  0.1341    0.66742 0.000 0.948 0.000 0.000 0.028 0.024
#> GSM213116     4  0.3073    0.75680 0.204 0.000 0.000 0.788 0.000 0.008
#> GSM213119     2  0.0260    0.67198 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM213072     4  0.3300    0.69602 0.076 0.000 0.000 0.840 0.016 0.068
#> GSM213075     4  0.4924    0.65490 0.184 0.016 0.000 0.696 0.100 0.004
#> GSM213076     2  0.6048    0.08193 0.000 0.460 0.004 0.000 0.288 0.248
#> GSM213079     3  0.0405    0.90710 0.000 0.000 0.988 0.004 0.008 0.000
#> GSM213080     1  0.5652   -0.06334 0.516 0.000 0.000 0.024 0.372 0.088
#> GSM213081     1  0.3947    0.54590 0.788 0.000 0.000 0.084 0.112 0.016
#> GSM213084     1  0.0551    0.61452 0.984 0.000 0.000 0.004 0.004 0.008
#> GSM213087     2  0.0405    0.67281 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM213089     4  0.2915    0.76694 0.184 0.000 0.000 0.808 0.000 0.008
#> GSM213090     3  0.1036    0.90204 0.000 0.000 0.964 0.004 0.008 0.024
#> GSM213093     4  0.3329    0.73718 0.220 0.000 0.000 0.768 0.004 0.008
#> GSM213097     1  0.4187    0.28567 0.624 0.000 0.000 0.356 0.004 0.016
#> GSM213099     4  0.4244    0.61061 0.048 0.000 0.004 0.784 0.056 0.108
#> GSM213101     1  0.3044    0.59111 0.864 0.000 0.000 0.048 0.036 0.052
#> GSM213105     2  0.0260    0.67198 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM213109     1  0.4138    0.22440 0.616 0.000 0.000 0.368 0.004 0.012
#> GSM213110     2  0.6140    0.15896 0.048 0.444 0.000 0.020 0.436 0.052
#> GSM213113     5  0.7426    0.09206 0.292 0.000 0.052 0.308 0.324 0.024
#> GSM213121     6  0.5376    0.49159 0.000 0.408 0.000 0.000 0.112 0.480
#> GSM213123     1  0.4393    0.01178 0.532 0.000 0.000 0.448 0.012 0.008
#> GSM213125     2  0.0603    0.67103 0.000 0.980 0.000 0.000 0.016 0.004
#> GSM213073     3  0.0692    0.90387 0.000 0.000 0.976 0.004 0.020 0.000
#> GSM213086     1  0.2592    0.63634 0.864 0.000 0.000 0.116 0.004 0.016
#> GSM213098     1  0.6094   -0.05458 0.488 0.000 0.000 0.112 0.360 0.040
#> GSM213106     4  0.2933    0.76207 0.200 0.000 0.000 0.796 0.004 0.000
#> GSM213124     5  0.6029    0.13939 0.024 0.052 0.000 0.404 0.484 0.036

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 development.stage(p) disease.state(p) k
#> CV:mclust 49                0.773            0.704 2
#> CV:mclust 53                0.453            0.821 3
#> CV:mclust 36                0.378            0.899 4
#> CV:mclust 32                0.501            0.911 5
#> CV:mclust 33                0.417            0.360 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.922           0.944       0.977         0.4427 0.560   0.560
#> 3 3 0.551           0.736       0.870         0.4869 0.743   0.553
#> 4 4 0.502           0.580       0.774         0.1258 0.817   0.527
#> 5 5 0.524           0.466       0.699         0.0698 0.888   0.620
#> 6 6 0.560           0.397       0.630         0.0429 0.920   0.666

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
#> GSM213078     1  0.0000      0.978 1.000 0.000
#> GSM213082     2  0.0000      0.969 0.000 1.000
#> GSM213085     1  0.0000      0.978 1.000 0.000
#> GSM213088     1  0.6148      0.815 0.848 0.152
#> GSM213091     1  0.0000      0.978 1.000 0.000
#> GSM213092     1  0.0000      0.978 1.000 0.000
#> GSM213096     1  0.0000      0.978 1.000 0.000
#> GSM213100     1  0.0000      0.978 1.000 0.000
#> GSM213111     2  0.0000      0.969 0.000 1.000
#> GSM213117     1  0.0000      0.978 1.000 0.000
#> GSM213118     1  0.0000      0.978 1.000 0.000
#> GSM213120     2  0.0000      0.969 0.000 1.000
#> GSM213122     2  0.0000      0.969 0.000 1.000
#> GSM213074     1  0.0000      0.978 1.000 0.000
#> GSM213077     1  0.0000      0.978 1.000 0.000
#> GSM213083     1  0.0000      0.978 1.000 0.000
#> GSM213094     1  0.0000      0.978 1.000 0.000
#> GSM213095     2  0.0000      0.969 0.000 1.000
#> GSM213102     1  0.0000      0.978 1.000 0.000
#> GSM213103     2  0.4815      0.866 0.104 0.896
#> GSM213104     1  0.9393      0.435 0.644 0.356
#> GSM213107     2  0.0000      0.969 0.000 1.000
#> GSM213108     2  0.0000      0.969 0.000 1.000
#> GSM213112     1  0.0000      0.978 1.000 0.000
#> GSM213114     1  0.0000      0.978 1.000 0.000
#> GSM213115     2  0.0000      0.969 0.000 1.000
#> GSM213116     1  0.0000      0.978 1.000 0.000
#> GSM213119     2  0.0000      0.969 0.000 1.000
#> GSM213072     1  0.0000      0.978 1.000 0.000
#> GSM213075     1  0.0000      0.978 1.000 0.000
#> GSM213076     2  0.0000      0.969 0.000 1.000
#> GSM213079     1  0.0000      0.978 1.000 0.000
#> GSM213080     2  0.9522      0.394 0.372 0.628
#> GSM213081     1  0.0000      0.978 1.000 0.000
#> GSM213084     1  0.0000      0.978 1.000 0.000
#> GSM213087     2  0.0000      0.969 0.000 1.000
#> GSM213089     1  0.0000      0.978 1.000 0.000
#> GSM213090     1  0.0000      0.978 1.000 0.000
#> GSM213093     1  0.0000      0.978 1.000 0.000
#> GSM213097     1  0.0000      0.978 1.000 0.000
#> GSM213099     1  0.0000      0.978 1.000 0.000
#> GSM213101     1  0.0000      0.978 1.000 0.000
#> GSM213105     2  0.0000      0.969 0.000 1.000
#> GSM213109     1  0.0000      0.978 1.000 0.000
#> GSM213110     2  0.0000      0.969 0.000 1.000
#> GSM213113     1  0.0000      0.978 1.000 0.000
#> GSM213121     2  0.0000      0.969 0.000 1.000
#> GSM213123     1  0.0000      0.978 1.000 0.000
#> GSM213125     2  0.0000      0.969 0.000 1.000
#> GSM213073     1  0.0000      0.978 1.000 0.000
#> GSM213086     1  0.0000      0.978 1.000 0.000
#> GSM213098     1  0.0376      0.975 0.996 0.004
#> GSM213106     1  0.0000      0.978 1.000 0.000
#> GSM213124     1  0.7950      0.679 0.760 0.240

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0000     0.8198 1.000 0.000 0.000
#> GSM213082     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213085     1  0.3340     0.7873 0.880 0.000 0.120
#> GSM213088     1  0.5576     0.7395 0.812 0.084 0.104
#> GSM213091     3  0.0237     0.7901 0.004 0.000 0.996
#> GSM213092     1  0.2356     0.8099 0.928 0.000 0.072
#> GSM213096     1  0.0000     0.8198 1.000 0.000 0.000
#> GSM213100     1  0.0237     0.8207 0.996 0.000 0.004
#> GSM213111     2  0.1860     0.9010 0.000 0.948 0.052
#> GSM213117     1  0.6008     0.5045 0.628 0.000 0.372
#> GSM213118     1  0.1964     0.8203 0.944 0.000 0.056
#> GSM213120     2  0.0661     0.9195 0.004 0.988 0.008
#> GSM213122     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213074     3  0.3941     0.7576 0.156 0.000 0.844
#> GSM213077     1  0.3879     0.7650 0.848 0.000 0.152
#> GSM213083     1  0.0592     0.8219 0.988 0.000 0.012
#> GSM213094     3  0.0000     0.7893 0.000 0.000 1.000
#> GSM213095     2  0.3340     0.8447 0.000 0.880 0.120
#> GSM213102     1  0.4654     0.7239 0.792 0.000 0.208
#> GSM213103     2  0.4750     0.7286 0.216 0.784 0.000
#> GSM213104     1  0.5200     0.6450 0.796 0.184 0.020
#> GSM213107     2  0.0237     0.9216 0.000 0.996 0.004
#> GSM213108     2  0.6295     0.2379 0.000 0.528 0.472
#> GSM213112     1  0.6045     0.3841 0.620 0.000 0.380
#> GSM213114     1  0.0000     0.8198 1.000 0.000 0.000
#> GSM213115     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213116     3  0.6295    -0.0441 0.472 0.000 0.528
#> GSM213119     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213072     3  0.5785     0.6149 0.332 0.000 0.668
#> GSM213075     3  0.5560     0.6557 0.300 0.000 0.700
#> GSM213076     2  0.2165     0.8947 0.000 0.936 0.064
#> GSM213079     3  0.1031     0.7901 0.024 0.000 0.976
#> GSM213080     1  0.1015     0.8185 0.980 0.008 0.012
#> GSM213081     1  0.3116     0.7849 0.892 0.000 0.108
#> GSM213084     1  0.0237     0.8206 0.996 0.000 0.004
#> GSM213087     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213089     3  0.3267     0.7685 0.116 0.000 0.884
#> GSM213090     3  0.0000     0.7893 0.000 0.000 1.000
#> GSM213093     3  0.4178     0.7496 0.172 0.000 0.828
#> GSM213097     1  0.6026     0.4985 0.624 0.000 0.376
#> GSM213099     3  0.0237     0.7901 0.004 0.000 0.996
#> GSM213101     1  0.0000     0.8198 1.000 0.000 0.000
#> GSM213105     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213109     1  0.3116     0.8032 0.892 0.000 0.108
#> GSM213110     2  0.4452     0.7611 0.192 0.808 0.000
#> GSM213113     3  0.4178     0.7352 0.172 0.000 0.828
#> GSM213121     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213123     3  0.6274     0.2193 0.456 0.000 0.544
#> GSM213125     2  0.0000     0.9228 0.000 1.000 0.000
#> GSM213073     3  0.1860     0.7855 0.052 0.000 0.948
#> GSM213086     1  0.1643     0.8205 0.956 0.000 0.044
#> GSM213098     3  0.4887     0.7094 0.228 0.000 0.772
#> GSM213106     1  0.6026     0.4962 0.624 0.000 0.376
#> GSM213124     1  0.9820     0.1291 0.428 0.296 0.276

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.1975     0.8025 0.936 0.000 0.016 0.048
#> GSM213082     2  0.0779     0.8648 0.000 0.980 0.004 0.016
#> GSM213085     1  0.4700     0.7562 0.792 0.000 0.124 0.084
#> GSM213088     1  0.6625     0.3787 0.588 0.036 0.036 0.340
#> GSM213091     4  0.3907     0.3348 0.000 0.000 0.232 0.768
#> GSM213092     1  0.3697     0.7883 0.852 0.000 0.100 0.048
#> GSM213096     1  0.1824     0.7926 0.936 0.000 0.060 0.004
#> GSM213100     1  0.2342     0.7999 0.912 0.000 0.008 0.080
#> GSM213111     2  0.1488     0.8616 0.000 0.956 0.032 0.012
#> GSM213117     4  0.4853     0.5577 0.220 0.000 0.036 0.744
#> GSM213118     1  0.4831     0.6978 0.752 0.000 0.040 0.208
#> GSM213120     2  0.2867     0.8349 0.000 0.884 0.104 0.012
#> GSM213122     2  0.0524     0.8673 0.000 0.988 0.004 0.008
#> GSM213074     4  0.3647     0.5400 0.040 0.000 0.108 0.852
#> GSM213077     1  0.3307     0.7807 0.868 0.000 0.028 0.104
#> GSM213083     1  0.2402     0.8002 0.912 0.000 0.012 0.076
#> GSM213094     4  0.4713     0.0598 0.000 0.000 0.360 0.640
#> GSM213095     3  0.5441     0.1329 0.008 0.332 0.644 0.016
#> GSM213102     4  0.5781    -0.1280 0.484 0.000 0.028 0.488
#> GSM213103     2  0.8501     0.3197 0.220 0.480 0.252 0.048
#> GSM213104     3  0.5139     0.1487 0.380 0.004 0.612 0.004
#> GSM213107     2  0.4677     0.6455 0.004 0.680 0.316 0.000
#> GSM213108     4  0.6885     0.0634 0.000 0.436 0.104 0.460
#> GSM213112     1  0.7508     0.3406 0.496 0.000 0.272 0.232
#> GSM213114     1  0.1940     0.7815 0.924 0.000 0.076 0.000
#> GSM213115     2  0.0376     0.8684 0.004 0.992 0.004 0.000
#> GSM213116     4  0.4079     0.5792 0.180 0.000 0.020 0.800
#> GSM213119     2  0.0188     0.8685 0.000 0.996 0.000 0.004
#> GSM213072     4  0.5272     0.5032 0.172 0.000 0.084 0.744
#> GSM213075     4  0.5653     0.4372 0.096 0.000 0.192 0.712
#> GSM213076     2  0.4922     0.7119 0.000 0.736 0.228 0.036
#> GSM213079     3  0.5039     0.3842 0.004 0.000 0.592 0.404
#> GSM213080     1  0.3743     0.7097 0.824 0.000 0.160 0.016
#> GSM213081     1  0.4464     0.6692 0.768 0.000 0.208 0.024
#> GSM213084     1  0.1489     0.7945 0.952 0.000 0.044 0.004
#> GSM213087     2  0.0469     0.8674 0.000 0.988 0.012 0.000
#> GSM213089     4  0.2282     0.5411 0.024 0.000 0.052 0.924
#> GSM213090     3  0.4948     0.3014 0.000 0.000 0.560 0.440
#> GSM213093     4  0.4931     0.5467 0.092 0.000 0.132 0.776
#> GSM213097     4  0.5793     0.2208 0.384 0.000 0.036 0.580
#> GSM213099     4  0.4103     0.2873 0.000 0.000 0.256 0.744
#> GSM213101     1  0.2675     0.7853 0.892 0.000 0.008 0.100
#> GSM213105     2  0.0188     0.8683 0.000 0.996 0.004 0.000
#> GSM213109     1  0.5168     0.6294 0.712 0.000 0.040 0.248
#> GSM213110     2  0.4333     0.6789 0.208 0.776 0.008 0.008
#> GSM213113     3  0.6548     0.4589 0.104 0.000 0.592 0.304
#> GSM213121     2  0.3024     0.8060 0.000 0.852 0.148 0.000
#> GSM213123     4  0.6746     0.3998 0.316 0.000 0.116 0.568
#> GSM213125     2  0.0188     0.8685 0.000 0.996 0.000 0.004
#> GSM213073     3  0.4877     0.4719 0.008 0.000 0.664 0.328
#> GSM213086     1  0.3895     0.7665 0.832 0.000 0.036 0.132
#> GSM213098     3  0.4532     0.4858 0.156 0.000 0.792 0.052
#> GSM213106     4  0.4574     0.5639 0.220 0.000 0.024 0.756
#> GSM213124     4  0.7654     0.4460 0.128 0.176 0.076 0.620

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.1644     0.7143 0.940 0.000 0.008 0.048 0.004
#> GSM213082     2  0.0798     0.7999 0.000 0.976 0.000 0.016 0.008
#> GSM213085     1  0.7355     0.2527 0.452 0.000 0.248 0.040 0.260
#> GSM213088     4  0.5548    -0.0194 0.456 0.016 0.000 0.492 0.036
#> GSM213091     4  0.4823     0.4496 0.000 0.000 0.276 0.672 0.052
#> GSM213092     1  0.5971     0.5492 0.644 0.000 0.168 0.020 0.168
#> GSM213096     1  0.3975     0.6945 0.816 0.000 0.020 0.048 0.116
#> GSM213100     1  0.3495     0.7121 0.852 0.000 0.020 0.048 0.080
#> GSM213111     2  0.2452     0.7698 0.000 0.908 0.012 0.028 0.052
#> GSM213117     4  0.2894     0.5786 0.084 0.000 0.004 0.876 0.036
#> GSM213118     1  0.6044     0.5773 0.624 0.000 0.020 0.128 0.228
#> GSM213120     2  0.5489     0.5636 0.000 0.700 0.024 0.120 0.156
#> GSM213122     2  0.0671     0.8026 0.000 0.980 0.000 0.004 0.016
#> GSM213074     4  0.7392     0.2184 0.040 0.000 0.220 0.424 0.316
#> GSM213077     1  0.4043     0.6405 0.788 0.000 0.012 0.168 0.032
#> GSM213083     1  0.1885     0.7229 0.936 0.000 0.012 0.020 0.032
#> GSM213094     4  0.5215     0.3061 0.000 0.000 0.372 0.576 0.052
#> GSM213095     3  0.6171     0.1206 0.008 0.156 0.580 0.000 0.256
#> GSM213102     1  0.5372     0.1116 0.504 0.000 0.004 0.448 0.044
#> GSM213103     5  0.8615     0.2386 0.188 0.224 0.048 0.100 0.440
#> GSM213104     5  0.6848     0.0364 0.232 0.008 0.316 0.000 0.444
#> GSM213107     5  0.6247    -0.0558 0.000 0.424 0.144 0.000 0.432
#> GSM213108     2  0.7372     0.1827 0.000 0.524 0.092 0.160 0.224
#> GSM213112     3  0.7477     0.1077 0.268 0.000 0.412 0.040 0.280
#> GSM213114     1  0.2959     0.6814 0.864 0.000 0.016 0.008 0.112
#> GSM213115     2  0.0404     0.8030 0.000 0.988 0.000 0.000 0.012
#> GSM213116     4  0.3670     0.5766 0.080 0.000 0.016 0.840 0.064
#> GSM213119     2  0.0451     0.8034 0.000 0.988 0.000 0.004 0.008
#> GSM213072     4  0.7819     0.2837 0.132 0.000 0.168 0.472 0.228
#> GSM213075     4  0.7481     0.3133 0.092 0.000 0.276 0.488 0.144
#> GSM213076     2  0.6793     0.3868 0.000 0.596 0.100 0.100 0.204
#> GSM213079     3  0.2629     0.4871 0.000 0.000 0.860 0.136 0.004
#> GSM213080     1  0.5272     0.4227 0.624 0.004 0.000 0.060 0.312
#> GSM213081     1  0.7412     0.3875 0.540 0.000 0.168 0.160 0.132
#> GSM213084     1  0.2040     0.7130 0.928 0.000 0.032 0.008 0.032
#> GSM213087     2  0.0290     0.8015 0.000 0.992 0.000 0.000 0.008
#> GSM213089     4  0.2769     0.5681 0.024 0.000 0.064 0.892 0.020
#> GSM213090     3  0.4218     0.4453 0.004 0.000 0.760 0.040 0.196
#> GSM213093     4  0.6582     0.4634 0.068 0.000 0.212 0.608 0.112
#> GSM213097     4  0.5813     0.2890 0.344 0.000 0.016 0.572 0.068
#> GSM213099     4  0.4431     0.4753 0.000 0.000 0.216 0.732 0.052
#> GSM213101     1  0.1956     0.7131 0.916 0.000 0.000 0.076 0.008
#> GSM213105     2  0.0000     0.8024 0.000 1.000 0.000 0.000 0.000
#> GSM213109     1  0.5467     0.6467 0.692 0.000 0.020 0.104 0.184
#> GSM213110     2  0.3628     0.5476 0.216 0.772 0.000 0.000 0.012
#> GSM213113     3  0.6981     0.2530 0.032 0.000 0.512 0.256 0.200
#> GSM213121     2  0.4178     0.5067 0.000 0.696 0.008 0.004 0.292
#> GSM213123     4  0.7089     0.4271 0.196 0.000 0.140 0.568 0.096
#> GSM213125     2  0.0324     0.8030 0.000 0.992 0.000 0.004 0.004
#> GSM213073     3  0.4022     0.4542 0.000 0.000 0.796 0.104 0.100
#> GSM213086     1  0.4319     0.6914 0.784 0.000 0.012 0.064 0.140
#> GSM213098     5  0.6735    -0.1330 0.048 0.000 0.412 0.088 0.452
#> GSM213106     4  0.3467     0.5656 0.128 0.000 0.004 0.832 0.036
#> GSM213124     5  0.9113    -0.1050 0.088 0.236 0.072 0.288 0.316

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.3518     0.6015 0.840 0.000 0.008 0.072 0.048 0.032
#> GSM213082     2  0.2082     0.7567 0.000 0.924 0.016 0.024 0.016 0.020
#> GSM213085     6  0.6818    -0.0653 0.360 0.000 0.224 0.004 0.040 0.372
#> GSM213088     4  0.6192     0.2670 0.340 0.008 0.012 0.532 0.052 0.056
#> GSM213091     4  0.5718     0.3387 0.000 0.000 0.276 0.556 0.012 0.156
#> GSM213092     1  0.6780     0.3126 0.540 0.000 0.192 0.024 0.056 0.188
#> GSM213096     1  0.4994     0.4418 0.648 0.000 0.004 0.000 0.120 0.228
#> GSM213100     1  0.4751     0.4703 0.684 0.000 0.020 0.008 0.040 0.248
#> GSM213111     2  0.3938     0.7022 0.000 0.812 0.012 0.052 0.092 0.032
#> GSM213117     4  0.5464     0.4036 0.092 0.000 0.016 0.612 0.008 0.272
#> GSM213118     6  0.6805     0.2060 0.292 0.000 0.004 0.068 0.168 0.468
#> GSM213120     2  0.6988     0.2730 0.008 0.496 0.032 0.212 0.228 0.024
#> GSM213122     2  0.0405     0.7727 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM213074     6  0.5077     0.4085 0.048 0.000 0.128 0.088 0.012 0.724
#> GSM213077     1  0.3682     0.5742 0.796 0.000 0.028 0.156 0.004 0.016
#> GSM213083     1  0.3182     0.6239 0.868 0.000 0.024 0.032 0.032 0.044
#> GSM213094     4  0.6645     0.1385 0.000 0.000 0.364 0.388 0.040 0.208
#> GSM213095     3  0.6495     0.1043 0.024 0.124 0.528 0.000 0.288 0.036
#> GSM213102     4  0.6073     0.1921 0.372 0.000 0.012 0.484 0.016 0.116
#> GSM213103     6  0.7171     0.1737 0.108 0.076 0.016 0.012 0.352 0.436
#> GSM213104     5  0.5579     0.2160 0.256 0.000 0.176 0.000 0.564 0.004
#> GSM213107     5  0.4710     0.2540 0.000 0.276 0.052 0.008 0.660 0.004
#> GSM213108     2  0.6858     0.3686 0.000 0.548 0.136 0.100 0.020 0.196
#> GSM213112     3  0.7468    -0.1762 0.296 0.000 0.312 0.024 0.056 0.312
#> GSM213114     1  0.3469     0.5737 0.792 0.000 0.004 0.012 0.180 0.012
#> GSM213115     2  0.1391     0.7683 0.000 0.944 0.000 0.000 0.016 0.040
#> GSM213116     4  0.5993     0.2446 0.080 0.000 0.020 0.496 0.020 0.384
#> GSM213119     2  0.0810     0.7725 0.000 0.976 0.004 0.004 0.008 0.008
#> GSM213072     6  0.6009     0.4169 0.096 0.000 0.056 0.108 0.068 0.672
#> GSM213075     6  0.7665     0.0792 0.056 0.004 0.236 0.188 0.064 0.452
#> GSM213076     2  0.7145     0.2181 0.004 0.488 0.116 0.140 0.244 0.008
#> GSM213079     3  0.3931     0.3799 0.000 0.000 0.800 0.100 0.064 0.036
#> GSM213080     1  0.5757     0.3181 0.548 0.004 0.008 0.076 0.344 0.020
#> GSM213081     1  0.7759     0.0942 0.436 0.000 0.108 0.240 0.168 0.048
#> GSM213084     1  0.2908     0.6175 0.872 0.000 0.064 0.004 0.044 0.016
#> GSM213087     2  0.1340     0.7652 0.000 0.948 0.000 0.008 0.040 0.004
#> GSM213089     4  0.3523     0.4835 0.016 0.000 0.020 0.812 0.008 0.144
#> GSM213090     3  0.4235     0.4018 0.012 0.000 0.776 0.032 0.036 0.144
#> GSM213093     4  0.7653     0.2635 0.084 0.000 0.196 0.452 0.052 0.216
#> GSM213097     4  0.5355     0.4307 0.240 0.000 0.024 0.656 0.024 0.056
#> GSM213099     4  0.5410     0.4068 0.000 0.000 0.192 0.636 0.020 0.152
#> GSM213101     1  0.3324     0.6091 0.832 0.000 0.000 0.084 0.008 0.076
#> GSM213105     2  0.0405     0.7716 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM213109     1  0.5831     0.3551 0.572 0.000 0.040 0.076 0.008 0.304
#> GSM213110     2  0.4013     0.6108 0.176 0.768 0.000 0.004 0.020 0.032
#> GSM213113     5  0.7803     0.0650 0.032 0.000 0.296 0.196 0.368 0.108
#> GSM213121     2  0.4127     0.3671 0.000 0.588 0.000 0.008 0.400 0.004
#> GSM213123     4  0.7259     0.3459 0.164 0.000 0.104 0.540 0.132 0.060
#> GSM213125     2  0.0291     0.7716 0.000 0.992 0.004 0.000 0.004 0.000
#> GSM213073     3  0.4779     0.2817 0.000 0.000 0.704 0.092 0.184 0.020
#> GSM213086     1  0.5486     0.3849 0.604 0.000 0.024 0.044 0.024 0.304
#> GSM213098     5  0.5626     0.3559 0.004 0.000 0.144 0.104 0.668 0.080
#> GSM213106     4  0.4057     0.5027 0.132 0.000 0.004 0.776 0.008 0.080
#> GSM213124     6  0.5748     0.4297 0.080 0.076 0.060 0.048 0.020 0.716

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 development.stage(p) disease.state(p) k
#> CV:NMF 52               0.4734            1.000 2
#> CV:NMF 47               0.0336            0.989 3
#> CV:NMF 35               0.7532            0.632 4
#> CV:NMF 27               0.7726            0.457 5
#> CV:NMF 16               0.4602            0.227 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.358           0.797       0.870         0.4059 0.591   0.591
#> 3 3 0.399           0.750       0.857         0.3050 0.902   0.835
#> 4 4 0.464           0.712       0.866         0.0819 0.973   0.946
#> 5 5 0.413           0.627       0.786         0.1177 1.000   1.000
#> 6 6 0.476           0.226       0.683         0.0743 0.930   0.851

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
#> GSM213078     1  0.2423      0.872 0.960 0.040
#> GSM213082     2  0.5294      0.903 0.120 0.880
#> GSM213085     1  0.4022      0.864 0.920 0.080
#> GSM213088     1  0.2236      0.872 0.964 0.036
#> GSM213091     1  0.3584      0.829 0.932 0.068
#> GSM213092     1  0.3879      0.865 0.924 0.076
#> GSM213096     1  0.3879      0.866 0.924 0.076
#> GSM213100     1  0.3879      0.866 0.924 0.076
#> GSM213111     2  0.6531      0.882 0.168 0.832
#> GSM213117     1  0.2423      0.871 0.960 0.040
#> GSM213118     1  0.6438      0.793 0.836 0.164
#> GSM213120     2  0.9552      0.526 0.376 0.624
#> GSM213122     2  0.4815      0.904 0.104 0.896
#> GSM213074     1  0.3584      0.829 0.932 0.068
#> GSM213077     1  0.3879      0.866 0.924 0.076
#> GSM213083     1  0.3879      0.866 0.924 0.076
#> GSM213094     1  0.4690      0.803 0.900 0.100
#> GSM213095     2  0.9944      0.299 0.456 0.544
#> GSM213102     1  0.0376      0.866 0.996 0.004
#> GSM213103     1  0.9795      0.220 0.584 0.416
#> GSM213104     1  0.9686      0.327 0.604 0.396
#> GSM213107     2  0.4690      0.903 0.100 0.900
#> GSM213108     2  0.6048      0.892 0.148 0.852
#> GSM213112     1  0.4022      0.864 0.920 0.080
#> GSM213114     1  0.8813      0.582 0.700 0.300
#> GSM213115     2  0.6712      0.875 0.176 0.824
#> GSM213116     1  0.2423      0.871 0.960 0.040
#> GSM213119     2  0.4815      0.904 0.104 0.896
#> GSM213072     1  0.3733      0.831 0.928 0.072
#> GSM213075     1  0.3584      0.851 0.932 0.068
#> GSM213076     2  0.7674      0.812 0.224 0.776
#> GSM213079     1  0.4690      0.803 0.900 0.100
#> GSM213080     1  0.8813      0.582 0.700 0.300
#> GSM213081     1  0.3879      0.869 0.924 0.076
#> GSM213084     1  0.3733      0.867 0.928 0.072
#> GSM213087     2  0.4690      0.903 0.100 0.900
#> GSM213089     1  0.0672      0.868 0.992 0.008
#> GSM213090     1  0.4690      0.803 0.900 0.100
#> GSM213093     1  0.0376      0.866 0.996 0.004
#> GSM213097     1  0.0376      0.866 0.996 0.004
#> GSM213099     1  0.4161      0.817 0.916 0.084
#> GSM213101     1  0.2236      0.872 0.964 0.036
#> GSM213105     2  0.4815      0.904 0.104 0.896
#> GSM213109     1  0.2948      0.871 0.948 0.052
#> GSM213110     2  0.6801      0.872 0.180 0.820
#> GSM213113     1  0.6148      0.813 0.848 0.152
#> GSM213121     2  0.4690      0.903 0.100 0.900
#> GSM213123     1  0.4022      0.868 0.920 0.080
#> GSM213125     2  0.4815      0.904 0.104 0.896
#> GSM213073     1  0.4690      0.803 0.900 0.100
#> GSM213086     1  0.5519      0.830 0.872 0.128
#> GSM213098     1  0.9323      0.469 0.652 0.348
#> GSM213106     1  0.2043      0.871 0.968 0.032
#> GSM213124     1  0.9170      0.455 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
#> GSM213078     1   0.165     0.8143 0.960 0.004 0.036
#> GSM213082     2   0.240     0.8882 0.064 0.932 0.004
#> GSM213085     1   0.195     0.8179 0.952 0.040 0.008
#> GSM213088     1   0.176     0.8132 0.956 0.004 0.040
#> GSM213091     1   0.546     0.6718 0.788 0.028 0.184
#> GSM213092     1   0.183     0.8185 0.956 0.036 0.008
#> GSM213096     1   0.188     0.8173 0.956 0.032 0.012
#> GSM213100     1   0.188     0.8173 0.956 0.032 0.012
#> GSM213111     2   0.377     0.8661 0.104 0.880 0.016
#> GSM213117     1   0.343     0.8067 0.904 0.032 0.064
#> GSM213118     1   0.434     0.7539 0.856 0.120 0.024
#> GSM213120     2   0.663     0.5143 0.336 0.644 0.020
#> GSM213122     2   0.207     0.8897 0.060 0.940 0.000
#> GSM213074     1   0.512     0.6978 0.812 0.028 0.160
#> GSM213077     1   0.153     0.8182 0.964 0.032 0.004
#> GSM213083     1   0.153     0.8182 0.964 0.032 0.004
#> GSM213094     3   0.547     0.7744 0.168 0.036 0.796
#> GSM213095     2   0.816     0.3712 0.084 0.568 0.348
#> GSM213102     1   0.303     0.7896 0.904 0.004 0.092
#> GSM213103     1   0.640     0.2987 0.580 0.416 0.004
#> GSM213104     1   0.731     0.3263 0.580 0.384 0.036
#> GSM213107     2   0.141     0.8762 0.036 0.964 0.000
#> GSM213108     2   0.362     0.8765 0.072 0.896 0.032
#> GSM213112     1   0.212     0.8169 0.948 0.040 0.012
#> GSM213114     1   0.663     0.5583 0.692 0.272 0.036
#> GSM213115     2   0.410     0.8404 0.140 0.852 0.008
#> GSM213116     1   0.337     0.8039 0.904 0.024 0.072
#> GSM213119     2   0.207     0.8897 0.060 0.940 0.000
#> GSM213072     1   0.474     0.7242 0.836 0.028 0.136
#> GSM213075     1   0.421     0.7590 0.856 0.016 0.128
#> GSM213076     2   0.463     0.7874 0.164 0.824 0.012
#> GSM213079     3   0.455     0.9181 0.200 0.000 0.800
#> GSM213080     1   0.663     0.5583 0.692 0.272 0.036
#> GSM213081     1   0.231     0.8137 0.944 0.024 0.032
#> GSM213084     1   0.158     0.8191 0.964 0.028 0.008
#> GSM213087     2   0.153     0.8803 0.040 0.960 0.000
#> GSM213089     1   0.312     0.7851 0.892 0.000 0.108
#> GSM213090     3   0.445     0.9161 0.192 0.000 0.808
#> GSM213093     1   0.295     0.7922 0.908 0.004 0.088
#> GSM213097     1   0.295     0.7908 0.908 0.004 0.088
#> GSM213099     1   0.726    -0.0462 0.528 0.028 0.444
#> GSM213101     1   0.176     0.8132 0.956 0.004 0.040
#> GSM213105     2   0.207     0.8897 0.060 0.940 0.000
#> GSM213109     1   0.164     0.8194 0.964 0.016 0.020
#> GSM213110     2   0.426     0.8390 0.140 0.848 0.012
#> GSM213113     1   0.489     0.7586 0.840 0.112 0.048
#> GSM213121     2   0.153     0.8803 0.040 0.960 0.000
#> GSM213123     1   0.243     0.8199 0.940 0.036 0.024
#> GSM213125     2   0.196     0.8886 0.056 0.944 0.000
#> GSM213073     3   0.465     0.9130 0.208 0.000 0.792
#> GSM213086     1   0.295     0.7911 0.908 0.088 0.004
#> GSM213098     1   0.698     0.4672 0.632 0.336 0.032
#> GSM213106     1   0.116     0.8142 0.972 0.000 0.028
#> GSM213124     1   0.682     0.4590 0.644 0.328 0.028

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.1940     0.7833 0.924 0.000 0.000 0.076
#> GSM213082     2  0.1398     0.8779 0.040 0.956 0.000 0.004
#> GSM213085     1  0.1284     0.7928 0.964 0.024 0.000 0.012
#> GSM213088     1  0.2011     0.7817 0.920 0.000 0.000 0.080
#> GSM213091     1  0.4599     0.5785 0.736 0.000 0.016 0.248
#> GSM213092     1  0.1174     0.7931 0.968 0.020 0.000 0.012
#> GSM213096     1  0.1174     0.7924 0.968 0.020 0.000 0.012
#> GSM213100     1  0.1174     0.7924 0.968 0.020 0.000 0.012
#> GSM213111     2  0.2522     0.8587 0.076 0.908 0.000 0.016
#> GSM213117     1  0.3221     0.7706 0.876 0.020 0.004 0.100
#> GSM213118     1  0.3706     0.7238 0.848 0.112 0.000 0.040
#> GSM213120     2  0.5453     0.4626 0.320 0.648 0.000 0.032
#> GSM213122     2  0.1118     0.8791 0.036 0.964 0.000 0.000
#> GSM213074     1  0.4122     0.6193 0.760 0.000 0.004 0.236
#> GSM213077     1  0.1174     0.7938 0.968 0.020 0.000 0.012
#> GSM213083     1  0.1174     0.7938 0.968 0.020 0.000 0.012
#> GSM213094     4  0.2685    -0.0346 0.044 0.004 0.040 0.912
#> GSM213095     2  0.5467     0.3273 0.008 0.584 0.400 0.008
#> GSM213102     1  0.2814     0.7503 0.868 0.000 0.000 0.132
#> GSM213103     1  0.5435     0.2702 0.564 0.420 0.000 0.016
#> GSM213104     1  0.6153     0.3148 0.576 0.376 0.008 0.040
#> GSM213107     2  0.0524     0.8572 0.004 0.988 0.000 0.008
#> GSM213108     2  0.2497     0.8692 0.040 0.924 0.016 0.020
#> GSM213112     1  0.1406     0.7916 0.960 0.024 0.000 0.016
#> GSM213114     1  0.5543     0.5143 0.696 0.256 0.008 0.040
#> GSM213115     2  0.3142     0.8162 0.132 0.860 0.000 0.008
#> GSM213116     1  0.3113     0.7677 0.876 0.012 0.004 0.108
#> GSM213119     2  0.1118     0.8791 0.036 0.964 0.000 0.000
#> GSM213072     1  0.3908     0.6551 0.784 0.000 0.004 0.212
#> GSM213075     1  0.3852     0.6999 0.808 0.012 0.000 0.180
#> GSM213076     2  0.3730     0.7670 0.144 0.836 0.004 0.016
#> GSM213079     3  0.0336     0.9857 0.008 0.000 0.992 0.000
#> GSM213080     1  0.5543     0.5143 0.696 0.256 0.008 0.040
#> GSM213081     1  0.1675     0.7856 0.948 0.004 0.004 0.044
#> GSM213084     1  0.1182     0.7943 0.968 0.016 0.000 0.016
#> GSM213087     2  0.0524     0.8639 0.008 0.988 0.000 0.004
#> GSM213089     1  0.3249     0.7395 0.852 0.000 0.008 0.140
#> GSM213090     3  0.0000     0.9838 0.000 0.000 1.000 0.000
#> GSM213093     1  0.2921     0.7472 0.860 0.000 0.000 0.140
#> GSM213097     1  0.2868     0.7484 0.864 0.000 0.000 0.136
#> GSM213099     4  0.5236     0.0916 0.432 0.000 0.008 0.560
#> GSM213101     1  0.2011     0.7817 0.920 0.000 0.000 0.080
#> GSM213105     2  0.1118     0.8791 0.036 0.964 0.000 0.000
#> GSM213109     1  0.1256     0.7940 0.964 0.008 0.000 0.028
#> GSM213110     2  0.3271     0.8147 0.132 0.856 0.000 0.012
#> GSM213113     1  0.4208     0.7238 0.840 0.096 0.016 0.048
#> GSM213121     2  0.0672     0.8617 0.008 0.984 0.000 0.008
#> GSM213123     1  0.1936     0.7944 0.940 0.032 0.000 0.028
#> GSM213125     2  0.1022     0.8780 0.032 0.968 0.000 0.000
#> GSM213073     3  0.0804     0.9829 0.008 0.000 0.980 0.012
#> GSM213086     1  0.2198     0.7659 0.920 0.072 0.000 0.008
#> GSM213098     1  0.5929     0.3977 0.620 0.332 0.004 0.044
#> GSM213106     1  0.1716     0.7846 0.936 0.000 0.000 0.064
#> GSM213124     1  0.5755     0.3723 0.624 0.332 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM213078     1  0.3333     0.6734 0.788 0.004 0.000 0.000 NA
#> GSM213082     2  0.1934     0.8205 0.020 0.932 0.000 0.008 NA
#> GSM213085     1  0.1725     0.6975 0.936 0.020 0.000 0.000 NA
#> GSM213088     1  0.3366     0.6713 0.784 0.004 0.000 0.000 NA
#> GSM213091     1  0.6143     0.4322 0.584 0.000 0.012 0.132 NA
#> GSM213092     1  0.1386     0.7025 0.952 0.016 0.000 0.000 NA
#> GSM213096     1  0.1300     0.7027 0.956 0.016 0.000 0.000 NA
#> GSM213100     1  0.1300     0.7027 0.956 0.016 0.000 0.000 NA
#> GSM213111     2  0.3787     0.8057 0.048 0.836 0.000 0.028 NA
#> GSM213117     1  0.4204     0.6681 0.768 0.016 0.004 0.016 NA
#> GSM213118     1  0.4714     0.6398 0.744 0.100 0.000 0.004 NA
#> GSM213120     2  0.5699     0.4799 0.264 0.608 0.000 0.000 NA
#> GSM213122     2  0.0566     0.8220 0.012 0.984 0.000 0.000 NA
#> GSM213074     1  0.5849     0.4603 0.596 0.000 0.004 0.120 NA
#> GSM213077     1  0.1386     0.7029 0.952 0.016 0.000 0.000 NA
#> GSM213083     1  0.1386     0.7029 0.952 0.016 0.000 0.000 NA
#> GSM213094     4  0.1651    -0.0468 0.008 0.000 0.012 0.944 NA
#> GSM213095     2  0.7328     0.1638 0.004 0.432 0.292 0.024 NA
#> GSM213102     1  0.4015     0.6304 0.724 0.004 0.000 0.008 NA
#> GSM213103     1  0.6336     0.2620 0.488 0.376 0.000 0.008 NA
#> GSM213104     1  0.6582     0.2696 0.496 0.280 0.000 0.004 NA
#> GSM213107     2  0.3779     0.7332 0.000 0.752 0.000 0.012 NA
#> GSM213108     2  0.3006     0.8106 0.020 0.888 0.008 0.028 NA
#> GSM213112     1  0.1800     0.6961 0.932 0.020 0.000 0.000 NA
#> GSM213114     1  0.5853     0.4565 0.624 0.184 0.000 0.004 NA
#> GSM213115     2  0.3150     0.7822 0.096 0.864 0.000 0.016 NA
#> GSM213116     1  0.4104     0.6683 0.772 0.012 0.004 0.016 NA
#> GSM213119     2  0.0727     0.8218 0.012 0.980 0.000 0.004 NA
#> GSM213072     1  0.5476     0.5181 0.632 0.000 0.004 0.088 NA
#> GSM213075     1  0.5348     0.5684 0.660 0.016 0.000 0.060 NA
#> GSM213076     2  0.4914     0.7019 0.108 0.712 0.000 0.000 NA
#> GSM213079     3  0.0324     0.9099 0.004 0.000 0.992 0.004 NA
#> GSM213080     1  0.5853     0.4565 0.624 0.184 0.000 0.004 NA
#> GSM213081     1  0.3522     0.6106 0.780 0.004 0.000 0.004 NA
#> GSM213084     1  0.1522     0.7061 0.944 0.012 0.000 0.000 NA
#> GSM213087     2  0.3234     0.7898 0.008 0.836 0.000 0.012 NA
#> GSM213089     1  0.4732     0.6281 0.720 0.004 0.004 0.048 NA
#> GSM213090     3  0.2561     0.8774 0.000 0.000 0.884 0.020 NA
#> GSM213093     1  0.4170     0.6213 0.712 0.004 0.000 0.012 NA
#> GSM213097     1  0.4064     0.6245 0.716 0.004 0.000 0.008 NA
#> GSM213099     4  0.6724     0.2020 0.296 0.000 0.004 0.460 NA
#> GSM213101     1  0.3366     0.6713 0.784 0.004 0.000 0.000 NA
#> GSM213105     2  0.0727     0.8218 0.012 0.980 0.000 0.004 NA
#> GSM213109     1  0.1740     0.7062 0.932 0.012 0.000 0.000 NA
#> GSM213110     2  0.3246     0.7808 0.096 0.860 0.000 0.020 NA
#> GSM213113     1  0.5160     0.5614 0.712 0.072 0.008 0.008 NA
#> GSM213121     2  0.3690     0.7414 0.000 0.764 0.000 0.012 NA
#> GSM213123     1  0.3370     0.6948 0.824 0.028 0.000 0.000 NA
#> GSM213125     2  0.0727     0.8225 0.012 0.980 0.000 0.004 NA
#> GSM213073     3  0.2570     0.8848 0.008 0.000 0.880 0.004 NA
#> GSM213086     1  0.2859     0.6690 0.876 0.056 0.000 0.000 NA
#> GSM213098     1  0.6607     0.3191 0.516 0.236 0.000 0.008 NA
#> GSM213106     1  0.3365     0.6781 0.808 0.004 0.000 0.008 NA
#> GSM213124     1  0.6524     0.3406 0.544 0.312 0.000 0.032 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
#> GSM213078     1  0.3894    -0.1888 0.664 0.004 0.000 0.324 0.008 0.000
#> GSM213082     2  0.3106     0.6317 0.024 0.852 0.000 0.020 0.100 0.004
#> GSM213085     1  0.1180     0.4161 0.960 0.012 0.000 0.016 0.012 0.000
#> GSM213088     1  0.3805    -0.1935 0.664 0.004 0.000 0.328 0.004 0.000
#> GSM213091     4  0.5060     0.8559 0.448 0.000 0.004 0.492 0.004 0.052
#> GSM213092     1  0.1332     0.4130 0.952 0.008 0.000 0.028 0.012 0.000
#> GSM213096     1  0.0972     0.4099 0.964 0.008 0.000 0.028 0.000 0.000
#> GSM213100     1  0.0972     0.4099 0.964 0.008 0.000 0.028 0.000 0.000
#> GSM213111     2  0.4775     0.5312 0.048 0.708 0.000 0.028 0.208 0.008
#> GSM213117     1  0.4286    -0.1862 0.660 0.012 0.000 0.312 0.008 0.008
#> GSM213118     1  0.5531     0.3062 0.684 0.064 0.000 0.160 0.076 0.016
#> GSM213120     2  0.6675     0.1313 0.228 0.500 0.000 0.056 0.212 0.004
#> GSM213122     2  0.1168     0.6570 0.016 0.956 0.000 0.000 0.028 0.000
#> GSM213074     4  0.5147     0.8511 0.464 0.000 0.004 0.476 0.012 0.044
#> GSM213077     1  0.0806     0.4095 0.972 0.008 0.000 0.020 0.000 0.000
#> GSM213083     1  0.0806     0.4095 0.972 0.008 0.000 0.020 0.000 0.000
#> GSM213094     6  0.1700    -0.0793 0.000 0.000 0.004 0.080 0.000 0.916
#> GSM213095     5  0.7696     0.2128 0.008 0.220 0.216 0.104 0.432 0.020
#> GSM213102     1  0.3872    -0.4296 0.604 0.004 0.000 0.392 0.000 0.000
#> GSM213103     1  0.7319     0.0301 0.412 0.288 0.000 0.144 0.152 0.004
#> GSM213104     1  0.6784     0.1262 0.472 0.116 0.000 0.084 0.320 0.008
#> GSM213107     5  0.3706     0.5904 0.000 0.380 0.000 0.000 0.620 0.000
#> GSM213108     2  0.4065     0.5938 0.028 0.784 0.000 0.036 0.144 0.008
#> GSM213112     1  0.1269     0.4163 0.956 0.012 0.000 0.020 0.012 0.000
#> GSM213114     1  0.6021     0.2908 0.604 0.068 0.000 0.088 0.232 0.008
#> GSM213115     2  0.2990     0.6171 0.084 0.860 0.000 0.036 0.020 0.000
#> GSM213116     1  0.4077    -0.1982 0.660 0.012 0.000 0.320 0.000 0.008
#> GSM213119     2  0.1088     0.6548 0.016 0.960 0.000 0.000 0.024 0.000
#> GSM213072     1  0.4492    -0.8452 0.496 0.000 0.000 0.480 0.008 0.016
#> GSM213075     1  0.4691    -0.7056 0.524 0.016 0.000 0.444 0.012 0.004
#> GSM213076     2  0.5852    -0.0320 0.076 0.496 0.000 0.044 0.384 0.000
#> GSM213079     3  0.0146     0.8170 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM213080     1  0.6021     0.2908 0.604 0.068 0.000 0.088 0.232 0.008
#> GSM213081     1  0.5052     0.2888 0.672 0.020 0.000 0.244 0.044 0.020
#> GSM213084     1  0.1588     0.3679 0.924 0.004 0.000 0.072 0.000 0.000
#> GSM213087     2  0.4184    -0.2244 0.016 0.576 0.000 0.000 0.408 0.000
#> GSM213089     1  0.4510    -0.4470 0.600 0.004 0.000 0.368 0.004 0.024
#> GSM213090     3  0.4140     0.7566 0.000 0.000 0.784 0.104 0.076 0.036
#> GSM213093     1  0.4033    -0.4874 0.588 0.004 0.000 0.404 0.000 0.004
#> GSM213097     1  0.3890    -0.4415 0.596 0.004 0.000 0.400 0.000 0.000
#> GSM213099     6  0.6054    -0.1721 0.212 0.000 0.000 0.380 0.004 0.404
#> GSM213101     1  0.3805    -0.1935 0.664 0.004 0.000 0.328 0.004 0.000
#> GSM213105     2  0.1088     0.6548 0.016 0.960 0.000 0.000 0.024 0.000
#> GSM213109     1  0.2377     0.3045 0.868 0.004 0.000 0.124 0.004 0.000
#> GSM213110     2  0.3059     0.6155 0.084 0.856 0.000 0.040 0.020 0.000
#> GSM213113     1  0.5543     0.3158 0.676 0.048 0.000 0.172 0.088 0.016
#> GSM213121     5  0.3890     0.5653 0.004 0.400 0.000 0.000 0.596 0.000
#> GSM213123     1  0.4098     0.2812 0.760 0.016 0.000 0.180 0.040 0.004
#> GSM213125     2  0.1503     0.6600 0.016 0.944 0.000 0.008 0.032 0.000
#> GSM213073     3  0.4576     0.7534 0.004 0.004 0.756 0.096 0.116 0.024
#> GSM213086     1  0.2843     0.4038 0.876 0.032 0.000 0.044 0.048 0.000
#> GSM213098     1  0.6998     0.1914 0.456 0.084 0.000 0.136 0.312 0.012
#> GSM213106     1  0.3684    -0.1508 0.692 0.004 0.000 0.300 0.004 0.000
#> GSM213124     1  0.6817    -0.0436 0.460 0.296 0.000 0.184 0.052 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n development.stage(p) disease.state(p) k
#> MAD:hclust 49                0.821            1.000 2
#> MAD:hclust 48                0.512            0.697 3
#> MAD:hclust 46                0.201            0.992 4
#> MAD:hclust 42                0.224            0.952 5
#> MAD:hclust 16                0.120            0.949 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.500           0.924       0.913         0.4128 0.560   0.560
#> 3 3 0.700           0.835       0.903         0.4648 0.824   0.686
#> 4 4 0.600           0.606       0.756         0.1553 0.810   0.554
#> 5 5 0.577           0.568       0.735         0.0901 0.876   0.609
#> 6 6 0.605           0.484       0.715         0.0549 0.949   0.792

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
#> GSM213078     1  0.0672      0.944 0.992 0.008
#> GSM213082     2  0.6148      0.973 0.152 0.848
#> GSM213085     1  0.0672      0.944 0.992 0.008
#> GSM213088     1  0.1184      0.942 0.984 0.016
#> GSM213091     1  0.5842      0.865 0.860 0.140
#> GSM213092     1  0.0672      0.944 0.992 0.008
#> GSM213096     1  0.0672      0.944 0.992 0.008
#> GSM213100     1  0.0672      0.944 0.992 0.008
#> GSM213111     2  0.6148      0.973 0.152 0.848
#> GSM213117     1  0.0938      0.941 0.988 0.012
#> GSM213118     1  0.0938      0.943 0.988 0.012
#> GSM213120     2  0.6148      0.973 0.152 0.848
#> GSM213122     2  0.6247      0.974 0.156 0.844
#> GSM213074     1  0.5737      0.868 0.864 0.136
#> GSM213077     1  0.0672      0.944 0.992 0.008
#> GSM213083     1  0.0672      0.944 0.992 0.008
#> GSM213094     1  0.6438      0.845 0.836 0.164
#> GSM213095     2  0.5737      0.946 0.136 0.864
#> GSM213102     1  0.0672      0.942 0.992 0.008
#> GSM213103     2  0.6247      0.974 0.156 0.844
#> GSM213104     1  0.5519      0.809 0.872 0.128
#> GSM213107     2  0.6148      0.972 0.152 0.848
#> GSM213108     2  0.6247      0.964 0.156 0.844
#> GSM213112     1  0.0672      0.944 0.992 0.008
#> GSM213114     1  0.0672      0.944 0.992 0.008
#> GSM213115     2  0.6247      0.974 0.156 0.844
#> GSM213116     1  0.0672      0.942 0.992 0.008
#> GSM213119     2  0.6148      0.973 0.152 0.848
#> GSM213072     1  0.5737      0.868 0.864 0.136
#> GSM213075     1  0.4562      0.895 0.904 0.096
#> GSM213076     2  0.6148      0.973 0.152 0.848
#> GSM213079     1  0.6247      0.845 0.844 0.156
#> GSM213080     1  0.5408      0.815 0.876 0.124
#> GSM213081     1  0.0672      0.944 0.992 0.008
#> GSM213084     1  0.0672      0.944 0.992 0.008
#> GSM213087     2  0.6247      0.974 0.156 0.844
#> GSM213089     1  0.1843      0.935 0.972 0.028
#> GSM213090     1  0.6247      0.845 0.844 0.156
#> GSM213093     1  0.0672      0.942 0.992 0.008
#> GSM213097     1  0.0672      0.942 0.992 0.008
#> GSM213099     1  0.5946      0.862 0.856 0.144
#> GSM213101     1  0.0672      0.944 0.992 0.008
#> GSM213105     2  0.6247      0.974 0.156 0.844
#> GSM213109     1  0.0000      0.943 1.000 0.000
#> GSM213110     2  0.6247      0.974 0.156 0.844
#> GSM213113     1  0.1184      0.942 0.984 0.016
#> GSM213121     2  0.6247      0.974 0.156 0.844
#> GSM213123     1  0.0672      0.942 0.992 0.008
#> GSM213125     2  0.6247      0.974 0.156 0.844
#> GSM213073     1  0.6247      0.845 0.844 0.156
#> GSM213086     1  0.0672      0.944 0.992 0.008
#> GSM213098     1  0.1184      0.942 0.984 0.016
#> GSM213106     1  0.1184      0.940 0.984 0.016
#> GSM213124     2  0.9866      0.506 0.432 0.568

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0237      0.880 0.996 0.000 0.004
#> GSM213082     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213085     1  0.1411      0.878 0.964 0.000 0.036
#> GSM213088     1  0.1964      0.867 0.944 0.000 0.056
#> GSM213091     3  0.5859      0.694 0.344 0.000 0.656
#> GSM213092     1  0.1411      0.878 0.964 0.000 0.036
#> GSM213096     1  0.0747      0.878 0.984 0.000 0.016
#> GSM213100     1  0.0237      0.881 0.996 0.000 0.004
#> GSM213111     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213117     1  0.4887      0.683 0.772 0.000 0.228
#> GSM213118     1  0.1753      0.878 0.952 0.000 0.048
#> GSM213120     2  0.1163      0.960 0.000 0.972 0.028
#> GSM213122     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213074     3  0.6008      0.661 0.372 0.000 0.628
#> GSM213077     1  0.0592      0.879 0.988 0.000 0.012
#> GSM213083     1  0.0592      0.881 0.988 0.000 0.012
#> GSM213094     3  0.2796      0.725 0.092 0.000 0.908
#> GSM213095     2  0.3030      0.914 0.004 0.904 0.092
#> GSM213102     1  0.4002      0.782 0.840 0.000 0.160
#> GSM213103     2  0.1529      0.956 0.000 0.960 0.040
#> GSM213104     1  0.3377      0.808 0.896 0.012 0.092
#> GSM213107     2  0.2165      0.943 0.000 0.936 0.064
#> GSM213108     2  0.0747      0.960 0.000 0.984 0.016
#> GSM213112     1  0.1643      0.875 0.956 0.000 0.044
#> GSM213114     1  0.2261      0.845 0.932 0.000 0.068
#> GSM213115     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213116     1  0.4750      0.702 0.784 0.000 0.216
#> GSM213119     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213072     3  0.6095      0.636 0.392 0.000 0.608
#> GSM213075     3  0.6235      0.520 0.436 0.000 0.564
#> GSM213076     2  0.1163      0.960 0.000 0.972 0.028
#> GSM213079     3  0.2448      0.723 0.076 0.000 0.924
#> GSM213080     1  0.3213      0.813 0.900 0.008 0.092
#> GSM213081     1  0.1643      0.881 0.956 0.000 0.044
#> GSM213084     1  0.0237      0.881 0.996 0.000 0.004
#> GSM213087     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213089     1  0.5810      0.405 0.664 0.000 0.336
#> GSM213090     3  0.2356      0.719 0.072 0.000 0.928
#> GSM213093     1  0.4399      0.752 0.812 0.000 0.188
#> GSM213097     1  0.3619      0.809 0.864 0.000 0.136
#> GSM213099     3  0.5835      0.697 0.340 0.000 0.660
#> GSM213101     1  0.0424      0.880 0.992 0.000 0.008
#> GSM213105     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213109     1  0.1411      0.877 0.964 0.000 0.036
#> GSM213110     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213113     1  0.3879      0.835 0.848 0.000 0.152
#> GSM213121     2  0.1753      0.952 0.000 0.952 0.048
#> GSM213123     1  0.2796      0.847 0.908 0.000 0.092
#> GSM213125     2  0.0000      0.967 0.000 1.000 0.000
#> GSM213073     3  0.1860      0.698 0.052 0.000 0.948
#> GSM213086     1  0.0892      0.877 0.980 0.000 0.020
#> GSM213098     1  0.4121      0.818 0.832 0.000 0.168
#> GSM213106     1  0.4702      0.715 0.788 0.000 0.212
#> GSM213124     2  0.6144      0.683 0.132 0.780 0.088

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.5132     0.6546 0.548 0.004 0.000 0.448
#> GSM213082     2  0.0707     0.8500 0.020 0.980 0.000 0.000
#> GSM213085     1  0.5645     0.7213 0.604 0.000 0.032 0.364
#> GSM213088     4  0.3751     0.4693 0.196 0.004 0.000 0.800
#> GSM213091     4  0.3942     0.4776 0.000 0.000 0.236 0.764
#> GSM213092     1  0.5510     0.7229 0.600 0.000 0.024 0.376
#> GSM213096     1  0.5371     0.7218 0.616 0.000 0.020 0.364
#> GSM213100     1  0.5453     0.7215 0.592 0.000 0.020 0.388
#> GSM213111     2  0.2179     0.8424 0.064 0.924 0.012 0.000
#> GSM213117     4  0.2053     0.6224 0.072 0.004 0.000 0.924
#> GSM213118     1  0.5408     0.4719 0.556 0.004 0.008 0.432
#> GSM213120     2  0.4136     0.7936 0.196 0.788 0.016 0.000
#> GSM213122     2  0.0376     0.8536 0.004 0.992 0.004 0.000
#> GSM213074     4  0.4049     0.5105 0.008 0.000 0.212 0.780
#> GSM213077     1  0.5476     0.7125 0.584 0.000 0.020 0.396
#> GSM213083     1  0.5643     0.6824 0.548 0.000 0.024 0.428
#> GSM213094     3  0.4331     0.6714 0.000 0.000 0.712 0.288
#> GSM213095     2  0.7458     0.4821 0.252 0.508 0.240 0.000
#> GSM213102     4  0.2944     0.5825 0.128 0.004 0.000 0.868
#> GSM213103     2  0.4687     0.7679 0.224 0.752 0.020 0.004
#> GSM213104     1  0.1821     0.4426 0.948 0.008 0.012 0.032
#> GSM213107     2  0.5404     0.6861 0.328 0.644 0.028 0.000
#> GSM213108     2  0.1443     0.8470 0.028 0.960 0.008 0.004
#> GSM213112     1  0.5645     0.7222 0.604 0.000 0.032 0.364
#> GSM213114     1  0.3306     0.5621 0.840 0.000 0.004 0.156
#> GSM213115     2  0.0000     0.8534 0.000 1.000 0.000 0.000
#> GSM213116     4  0.1792     0.6233 0.068 0.000 0.000 0.932
#> GSM213119     2  0.0376     0.8536 0.004 0.992 0.004 0.000
#> GSM213072     4  0.3583     0.5551 0.004 0.000 0.180 0.816
#> GSM213075     4  0.3583     0.5550 0.004 0.000 0.180 0.816
#> GSM213076     2  0.4910     0.7417 0.276 0.704 0.020 0.000
#> GSM213079     3  0.1256     0.8976 0.008 0.000 0.964 0.028
#> GSM213080     1  0.2665     0.5019 0.900 0.008 0.004 0.088
#> GSM213081     4  0.5155    -0.4407 0.468 0.004 0.000 0.528
#> GSM213084     1  0.5564     0.6762 0.544 0.000 0.020 0.436
#> GSM213087     2  0.0524     0.8530 0.008 0.988 0.004 0.000
#> GSM213089     4  0.1661     0.6188 0.004 0.000 0.052 0.944
#> GSM213090     3  0.0927     0.8984 0.008 0.000 0.976 0.016
#> GSM213093     4  0.2714     0.5966 0.112 0.004 0.000 0.884
#> GSM213097     4  0.2944     0.5841 0.128 0.004 0.000 0.868
#> GSM213099     4  0.4283     0.4219 0.004 0.000 0.256 0.740
#> GSM213101     1  0.5147     0.6346 0.536 0.004 0.000 0.460
#> GSM213105     2  0.0376     0.8536 0.004 0.992 0.004 0.000
#> GSM213109     4  0.5682    -0.5427 0.456 0.000 0.024 0.520
#> GSM213110     2  0.0000     0.8534 0.000 1.000 0.000 0.000
#> GSM213113     4  0.6152    -0.0132 0.464 0.008 0.032 0.496
#> GSM213121     2  0.4908     0.7251 0.292 0.692 0.016 0.000
#> GSM213123     4  0.4428     0.2426 0.276 0.004 0.000 0.720
#> GSM213125     2  0.0188     0.8536 0.000 0.996 0.004 0.000
#> GSM213073     3  0.0927     0.8917 0.016 0.000 0.976 0.008
#> GSM213086     1  0.5326     0.7228 0.604 0.000 0.016 0.380
#> GSM213098     1  0.4910     0.0734 0.704 0.000 0.020 0.276
#> GSM213106     4  0.1978     0.6229 0.068 0.004 0.000 0.928
#> GSM213124     2  0.5923     0.4506 0.040 0.652 0.012 0.296

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.3517     0.7327 0.840 0.000 0.004 0.084 0.072
#> GSM213082     2  0.3265     0.6557 0.004 0.848 0.016 0.008 0.124
#> GSM213085     1  0.2790     0.7783 0.892 0.000 0.028 0.020 0.060
#> GSM213088     4  0.5583     0.5584 0.336 0.000 0.004 0.584 0.076
#> GSM213091     4  0.4549     0.5992 0.052 0.000 0.060 0.792 0.096
#> GSM213092     1  0.2634     0.7801 0.900 0.000 0.024 0.020 0.056
#> GSM213096     1  0.2005     0.7863 0.924 0.000 0.004 0.016 0.056
#> GSM213100     1  0.1904     0.7854 0.936 0.000 0.020 0.028 0.016
#> GSM213111     2  0.5243     0.3399 0.004 0.644 0.016 0.032 0.304
#> GSM213117     4  0.4241     0.6805 0.264 0.000 0.008 0.716 0.012
#> GSM213118     1  0.5363     0.6208 0.676 0.000 0.004 0.120 0.200
#> GSM213120     5  0.5739     0.0849 0.008 0.468 0.016 0.032 0.476
#> GSM213122     2  0.0486     0.7637 0.004 0.988 0.004 0.000 0.004
#> GSM213074     4  0.4932     0.5959 0.080 0.000 0.048 0.764 0.108
#> GSM213077     1  0.1787     0.7848 0.940 0.000 0.012 0.032 0.016
#> GSM213083     1  0.2522     0.7692 0.904 0.000 0.012 0.056 0.028
#> GSM213094     4  0.6361    -0.3437 0.000 0.004 0.428 0.428 0.140
#> GSM213095     5  0.7237     0.2726 0.008 0.200 0.296 0.024 0.472
#> GSM213102     4  0.4921     0.6245 0.320 0.000 0.004 0.640 0.036
#> GSM213103     2  0.5238     0.0543 0.012 0.576 0.016 0.008 0.388
#> GSM213104     1  0.5387     0.3531 0.524 0.004 0.020 0.016 0.436
#> GSM213107     5  0.4874     0.1994 0.000 0.452 0.016 0.004 0.528
#> GSM213108     2  0.5487     0.4686 0.004 0.676 0.028 0.052 0.240
#> GSM213112     1  0.2790     0.7783 0.892 0.000 0.028 0.020 0.060
#> GSM213114     1  0.4629     0.6427 0.708 0.000 0.012 0.028 0.252
#> GSM213115     2  0.1016     0.7603 0.004 0.972 0.004 0.008 0.012
#> GSM213116     4  0.4434     0.6834 0.248 0.000 0.012 0.720 0.020
#> GSM213119     2  0.0486     0.7637 0.004 0.988 0.004 0.000 0.004
#> GSM213072     4  0.4889     0.6154 0.084 0.000 0.048 0.768 0.100
#> GSM213075     4  0.4146     0.6419 0.072 0.000 0.056 0.820 0.052
#> GSM213076     5  0.5399     0.1723 0.000 0.440 0.016 0.028 0.516
#> GSM213079     3  0.1697     0.9699 0.008 0.000 0.932 0.060 0.000
#> GSM213080     1  0.5527     0.4982 0.592 0.004 0.024 0.028 0.352
#> GSM213081     1  0.6384     0.1631 0.528 0.000 0.020 0.340 0.112
#> GSM213084     1  0.2502     0.7634 0.904 0.000 0.012 0.060 0.024
#> GSM213087     2  0.2095     0.7227 0.000 0.920 0.012 0.008 0.060
#> GSM213089     4  0.3053     0.6938 0.128 0.000 0.008 0.852 0.012
#> GSM213090     3  0.2390     0.9680 0.008 0.000 0.908 0.060 0.024
#> GSM213093     4  0.4956     0.6261 0.312 0.000 0.004 0.644 0.040
#> GSM213097     4  0.5186     0.6086 0.320 0.000 0.004 0.624 0.052
#> GSM213099     4  0.4803     0.5621 0.048 0.000 0.056 0.768 0.128
#> GSM213101     1  0.4044     0.6921 0.800 0.000 0.004 0.120 0.076
#> GSM213105     2  0.0486     0.7637 0.004 0.988 0.004 0.000 0.004
#> GSM213109     1  0.3573     0.7095 0.832 0.000 0.012 0.124 0.032
#> GSM213110     2  0.1016     0.7603 0.004 0.972 0.004 0.008 0.012
#> GSM213113     5  0.7321    -0.0199 0.276 0.000 0.032 0.260 0.432
#> GSM213121     5  0.4891     0.1498 0.000 0.480 0.016 0.004 0.500
#> GSM213123     4  0.6105     0.3977 0.392 0.000 0.008 0.500 0.100
#> GSM213125     2  0.0613     0.7623 0.004 0.984 0.004 0.000 0.008
#> GSM213073     3  0.2026     0.9675 0.012 0.000 0.928 0.044 0.016
#> GSM213086     1  0.2228     0.7832 0.916 0.000 0.008 0.020 0.056
#> GSM213098     5  0.6090     0.2349 0.132 0.000 0.016 0.244 0.608
#> GSM213106     4  0.4775     0.6662 0.268 0.000 0.008 0.688 0.036
#> GSM213124     2  0.6791     0.2515 0.044 0.584 0.016 0.260 0.096

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.3599     0.6781 0.756 0.000 0.000 0.220 0.004 0.020
#> GSM213082     2  0.3514     0.5354 0.000 0.752 0.000 0.000 0.228 0.020
#> GSM213085     1  0.1874     0.7684 0.928 0.000 0.000 0.028 0.016 0.028
#> GSM213088     4  0.3284     0.5748 0.196 0.000 0.000 0.784 0.000 0.020
#> GSM213091     4  0.4903    -0.3557 0.012 0.000 0.032 0.556 0.004 0.396
#> GSM213092     1  0.1930     0.7704 0.924 0.000 0.000 0.036 0.012 0.028
#> GSM213096     1  0.1078     0.7690 0.964 0.000 0.000 0.008 0.012 0.016
#> GSM213100     1  0.1644     0.7710 0.932 0.000 0.000 0.052 0.004 0.012
#> GSM213111     5  0.4784    -0.0329 0.000 0.452 0.008 0.008 0.512 0.020
#> GSM213117     4  0.4222     0.5261 0.100 0.000 0.000 0.764 0.016 0.120
#> GSM213118     1  0.6202     0.4893 0.600 0.000 0.000 0.136 0.120 0.144
#> GSM213120     5  0.4650     0.4548 0.000 0.232 0.004 0.016 0.696 0.052
#> GSM213122     2  0.0291     0.7387 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM213074     4  0.5523    -0.3751 0.040 0.000 0.028 0.516 0.012 0.404
#> GSM213077     1  0.1967     0.7669 0.904 0.000 0.000 0.084 0.000 0.012
#> GSM213083     1  0.2734     0.7407 0.840 0.000 0.000 0.148 0.004 0.008
#> GSM213094     6  0.5958     0.2964 0.000 0.000 0.316 0.160 0.016 0.508
#> GSM213095     5  0.5773     0.3530 0.000 0.108 0.212 0.000 0.620 0.060
#> GSM213102     4  0.2632     0.5933 0.164 0.000 0.000 0.832 0.000 0.004
#> GSM213103     2  0.6789    -0.1535 0.028 0.440 0.004 0.016 0.344 0.168
#> GSM213104     1  0.6204     0.1577 0.436 0.000 0.000 0.008 0.264 0.292
#> GSM213107     5  0.6077     0.3939 0.004 0.248 0.004 0.000 0.488 0.256
#> GSM213108     2  0.5417     0.0707 0.000 0.488 0.008 0.016 0.436 0.052
#> GSM213112     1  0.2102     0.7661 0.920 0.000 0.004 0.020 0.024 0.032
#> GSM213114     1  0.4875     0.5467 0.668 0.000 0.000 0.008 0.100 0.224
#> GSM213115     2  0.1049     0.7353 0.000 0.960 0.000 0.008 0.032 0.000
#> GSM213116     4  0.4301     0.5268 0.120 0.000 0.000 0.740 0.004 0.136
#> GSM213119     2  0.0508     0.7379 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM213072     4  0.5641    -0.3427 0.060 0.000 0.016 0.512 0.016 0.396
#> GSM213075     4  0.4369     0.1398 0.016 0.000 0.016 0.712 0.016 0.240
#> GSM213076     5  0.3559     0.4507 0.000 0.240 0.004 0.000 0.744 0.012
#> GSM213079     3  0.0458     0.9571 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM213080     1  0.5851     0.3630 0.536 0.000 0.000 0.012 0.176 0.276
#> GSM213081     4  0.5952     0.2661 0.320 0.000 0.000 0.528 0.032 0.120
#> GSM213084     1  0.2558     0.7368 0.840 0.000 0.000 0.156 0.000 0.004
#> GSM213087     2  0.2573     0.6701 0.000 0.884 0.000 0.008 0.064 0.044
#> GSM213089     4  0.3713     0.2723 0.032 0.000 0.000 0.744 0.000 0.224
#> GSM213090     3  0.1003     0.9524 0.004 0.000 0.964 0.000 0.028 0.004
#> GSM213093     4  0.2704     0.5960 0.140 0.000 0.000 0.844 0.000 0.016
#> GSM213097     4  0.2768     0.5933 0.156 0.000 0.000 0.832 0.000 0.012
#> GSM213099     6  0.4949     0.1605 0.012 0.000 0.024 0.468 0.008 0.488
#> GSM213101     1  0.3872     0.6171 0.712 0.000 0.000 0.264 0.004 0.020
#> GSM213105     2  0.0508     0.7379 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM213109     1  0.3503     0.7178 0.788 0.000 0.000 0.180 0.012 0.020
#> GSM213110     2  0.0806     0.7345 0.000 0.972 0.000 0.008 0.020 0.000
#> GSM213113     5  0.7085     0.2442 0.132 0.000 0.012 0.264 0.480 0.112
#> GSM213121     5  0.6186     0.3441 0.004 0.304 0.004 0.000 0.448 0.240
#> GSM213123     4  0.5453     0.4787 0.200 0.000 0.000 0.656 0.068 0.076
#> GSM213125     2  0.0806     0.7347 0.000 0.972 0.000 0.000 0.020 0.008
#> GSM213073     3  0.1092     0.9534 0.000 0.000 0.960 0.000 0.020 0.020
#> GSM213086     1  0.2183     0.7672 0.912 0.000 0.000 0.028 0.020 0.040
#> GSM213098     5  0.6557     0.3666 0.108 0.000 0.000 0.128 0.536 0.228
#> GSM213106     4  0.2776     0.5823 0.104 0.000 0.000 0.860 0.004 0.032
#> GSM213124     2  0.7392     0.2203 0.052 0.500 0.004 0.244 0.116 0.084

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n development.stage(p) disease.state(p) k
#> MAD:kmeans 54                0.688            0.902 2
#> MAD:kmeans 53                0.428            0.921 3
#> MAD:kmeans 42                0.311            0.940 4
#> MAD:kmeans 38                0.135            0.964 5
#> MAD:kmeans 31                0.185            0.895 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.483           0.808       0.905         0.4975 0.525   0.525
#> 3 3 0.329           0.565       0.764         0.3544 0.725   0.511
#> 4 4 0.340           0.380       0.627         0.1182 0.933   0.796
#> 5 5 0.420           0.362       0.585         0.0616 0.902   0.665
#> 6 6 0.481           0.297       0.532         0.0416 0.925   0.687

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
#> GSM213078     1  0.0000      0.868 1.000 0.000
#> GSM213082     2  0.0000      0.940 0.000 1.000
#> GSM213085     1  0.3584      0.865 0.932 0.068
#> GSM213088     1  0.9044      0.576 0.680 0.320
#> GSM213091     1  0.1414      0.873 0.980 0.020
#> GSM213092     1  0.0000      0.868 1.000 0.000
#> GSM213096     1  0.4815      0.846 0.896 0.104
#> GSM213100     1  0.0000      0.868 1.000 0.000
#> GSM213111     2  0.0000      0.940 0.000 1.000
#> GSM213117     1  0.6623      0.802 0.828 0.172
#> GSM213118     1  0.9580      0.479 0.620 0.380
#> GSM213120     2  0.0376      0.938 0.004 0.996
#> GSM213122     2  0.0000      0.940 0.000 1.000
#> GSM213074     1  0.1184      0.872 0.984 0.016
#> GSM213077     1  0.0000      0.868 1.000 0.000
#> GSM213083     1  0.0000      0.868 1.000 0.000
#> GSM213094     1  0.6438      0.807 0.836 0.164
#> GSM213095     2  0.0672      0.936 0.008 0.992
#> GSM213102     1  0.1414      0.872 0.980 0.020
#> GSM213103     2  0.2236      0.921 0.036 0.964
#> GSM213104     2  0.6148      0.813 0.152 0.848
#> GSM213107     2  0.0000      0.940 0.000 1.000
#> GSM213108     2  0.2043      0.921 0.032 0.968
#> GSM213112     1  0.5178      0.838 0.884 0.116
#> GSM213114     1  0.8861      0.617 0.696 0.304
#> GSM213115     2  0.0000      0.940 0.000 1.000
#> GSM213116     1  0.1414      0.873 0.980 0.020
#> GSM213119     2  0.0000      0.940 0.000 1.000
#> GSM213072     1  0.2603      0.872 0.956 0.044
#> GSM213075     1  0.9087      0.599 0.676 0.324
#> GSM213076     2  0.0000      0.940 0.000 1.000
#> GSM213079     1  0.4690      0.848 0.900 0.100
#> GSM213080     2  0.6887      0.766 0.184 0.816
#> GSM213081     1  0.4161      0.860 0.916 0.084
#> GSM213084     1  0.0000      0.868 1.000 0.000
#> GSM213087     2  0.0000      0.940 0.000 1.000
#> GSM213089     1  0.4690      0.854 0.900 0.100
#> GSM213090     1  0.9988      0.194 0.520 0.480
#> GSM213093     1  0.2236      0.873 0.964 0.036
#> GSM213097     1  0.1184      0.872 0.984 0.016
#> GSM213099     1  0.2423      0.873 0.960 0.040
#> GSM213101     1  0.2043      0.872 0.968 0.032
#> GSM213105     2  0.0000      0.940 0.000 1.000
#> GSM213109     1  0.0000      0.868 1.000 0.000
#> GSM213110     2  0.1184      0.933 0.016 0.984
#> GSM213113     1  1.0000      0.143 0.504 0.496
#> GSM213121     2  0.0000      0.940 0.000 1.000
#> GSM213123     1  0.5629      0.834 0.868 0.132
#> GSM213125     2  0.0000      0.940 0.000 1.000
#> GSM213073     1  0.9944      0.278 0.544 0.456
#> GSM213086     1  0.1843      0.873 0.972 0.028
#> GSM213098     2  0.9795      0.161 0.416 0.584
#> GSM213106     1  0.3431      0.869 0.936 0.064
#> GSM213124     2  0.6531      0.777 0.168 0.832

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.3340     0.5917 0.880 0.000 0.120
#> GSM213082     2  0.1289     0.9062 0.000 0.968 0.032
#> GSM213085     1  0.6082     0.4496 0.692 0.012 0.296
#> GSM213088     1  0.9269     0.1556 0.508 0.184 0.308
#> GSM213091     3  0.2448     0.5897 0.076 0.000 0.924
#> GSM213092     1  0.5058     0.5385 0.756 0.000 0.244
#> GSM213096     1  0.4324     0.6000 0.860 0.028 0.112
#> GSM213100     1  0.4702     0.5815 0.788 0.000 0.212
#> GSM213111     2  0.1832     0.9036 0.008 0.956 0.036
#> GSM213117     3  0.8677     0.3930 0.280 0.144 0.576
#> GSM213118     1  0.9133     0.2147 0.528 0.176 0.296
#> GSM213120     2  0.3690     0.8649 0.016 0.884 0.100
#> GSM213122     2  0.0237     0.9098 0.004 0.996 0.000
#> GSM213074     3  0.4861     0.5747 0.180 0.012 0.808
#> GSM213077     1  0.3816     0.6068 0.852 0.000 0.148
#> GSM213083     1  0.4291     0.6006 0.820 0.000 0.180
#> GSM213094     3  0.2496     0.5874 0.068 0.004 0.928
#> GSM213095     2  0.4891     0.8279 0.040 0.836 0.124
#> GSM213102     1  0.7080     0.2321 0.564 0.024 0.412
#> GSM213103     2  0.5010     0.8238 0.084 0.840 0.076
#> GSM213104     1  0.8798     0.1954 0.520 0.356 0.124
#> GSM213107     2  0.1170     0.9072 0.016 0.976 0.008
#> GSM213108     2  0.5167     0.7789 0.024 0.804 0.172
#> GSM213112     1  0.7481     0.2958 0.596 0.048 0.356
#> GSM213114     1  0.4194     0.5797 0.876 0.064 0.060
#> GSM213115     2  0.0237     0.9095 0.004 0.996 0.000
#> GSM213116     3  0.6169     0.3413 0.360 0.004 0.636
#> GSM213119     2  0.0237     0.9096 0.000 0.996 0.004
#> GSM213072     3  0.5020     0.5756 0.192 0.012 0.796
#> GSM213075     3  0.8148     0.4905 0.200 0.156 0.644
#> GSM213076     2  0.4256     0.8618 0.036 0.868 0.096
#> GSM213079     3  0.4575     0.5645 0.160 0.012 0.828
#> GSM213080     1  0.6927     0.3592 0.664 0.296 0.040
#> GSM213081     1  0.7337     0.4301 0.644 0.056 0.300
#> GSM213084     1  0.4504     0.5925 0.804 0.000 0.196
#> GSM213087     2  0.0237     0.9096 0.004 0.996 0.000
#> GSM213089     3  0.6756     0.5181 0.232 0.056 0.712
#> GSM213090     3  0.7535     0.4954 0.176 0.132 0.692
#> GSM213093     3  0.6865     0.2777 0.384 0.020 0.596
#> GSM213097     1  0.6682     0.0316 0.504 0.008 0.488
#> GSM213099     3  0.3682     0.5920 0.116 0.008 0.876
#> GSM213101     1  0.5277     0.5703 0.796 0.024 0.180
#> GSM213105     2  0.0000     0.9093 0.000 1.000 0.000
#> GSM213109     1  0.5905     0.4096 0.648 0.000 0.352
#> GSM213110     2  0.4206     0.8461 0.088 0.872 0.040
#> GSM213113     3  0.9916     0.2114 0.316 0.288 0.396
#> GSM213121     2  0.0475     0.9091 0.004 0.992 0.004
#> GSM213123     3  0.8740     0.0578 0.432 0.108 0.460
#> GSM213125     2  0.0000     0.9093 0.000 1.000 0.000
#> GSM213073     3  0.8195     0.4537 0.232 0.136 0.632
#> GSM213086     1  0.4555     0.5861 0.800 0.000 0.200
#> GSM213098     3  0.9721     0.2415 0.284 0.264 0.452
#> GSM213106     3  0.7660     0.3608 0.324 0.064 0.612
#> GSM213124     2  0.8231     0.4553 0.136 0.628 0.236

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.5364     0.3686 0.724 0.012 0.228 0.036
#> GSM213082     2  0.2809     0.8046 0.004 0.904 0.064 0.028
#> GSM213085     1  0.7553     0.2984 0.548 0.012 0.240 0.200
#> GSM213088     3  0.9402     0.1071 0.340 0.128 0.356 0.176
#> GSM213091     4  0.5380     0.4045 0.072 0.004 0.184 0.740
#> GSM213092     1  0.6133     0.3954 0.672 0.000 0.204 0.124
#> GSM213096     1  0.5474     0.4229 0.756 0.020 0.160 0.064
#> GSM213100     1  0.5945     0.4013 0.716 0.008 0.132 0.144
#> GSM213111     2  0.4556     0.7631 0.008 0.816 0.096 0.080
#> GSM213117     3  0.8631    -0.1555 0.152 0.064 0.392 0.392
#> GSM213118     3  0.9121     0.0374 0.332 0.104 0.400 0.164
#> GSM213120     2  0.6222     0.6732 0.024 0.692 0.212 0.072
#> GSM213122     2  0.1256     0.8109 0.000 0.964 0.028 0.008
#> GSM213074     4  0.5906     0.4071 0.148 0.000 0.152 0.700
#> GSM213077     1  0.4483     0.4483 0.808 0.000 0.088 0.104
#> GSM213083     1  0.4669     0.4180 0.796 0.000 0.104 0.100
#> GSM213094     4  0.3417     0.4341 0.060 0.008 0.052 0.880
#> GSM213095     2  0.7712     0.5087 0.040 0.584 0.168 0.208
#> GSM213102     1  0.8431    -0.0889 0.412 0.024 0.280 0.284
#> GSM213103     2  0.7541     0.5371 0.084 0.608 0.232 0.076
#> GSM213104     1  0.8895    -0.0225 0.408 0.184 0.336 0.072
#> GSM213107     2  0.4348     0.7761 0.012 0.820 0.132 0.036
#> GSM213108     2  0.6977     0.5517 0.040 0.640 0.088 0.232
#> GSM213112     1  0.7469     0.2657 0.532 0.004 0.240 0.224
#> GSM213114     1  0.6613     0.3131 0.604 0.044 0.320 0.032
#> GSM213115     2  0.0592     0.8091 0.000 0.984 0.016 0.000
#> GSM213116     4  0.8095     0.1107 0.236 0.012 0.324 0.428
#> GSM213119     2  0.0921     0.8106 0.000 0.972 0.028 0.000
#> GSM213072     4  0.6320     0.3819 0.180 0.000 0.160 0.660
#> GSM213075     4  0.8647     0.1735 0.136 0.112 0.236 0.516
#> GSM213076     2  0.5981     0.7188 0.028 0.724 0.176 0.072
#> GSM213079     4  0.5487     0.3914 0.108 0.008 0.132 0.752
#> GSM213080     1  0.8127     0.0693 0.452 0.204 0.324 0.020
#> GSM213081     1  0.8150     0.0159 0.420 0.020 0.364 0.196
#> GSM213084     1  0.5171     0.4358 0.760 0.000 0.128 0.112
#> GSM213087     2  0.1302     0.8092 0.000 0.956 0.044 0.000
#> GSM213089     4  0.7646     0.3047 0.128 0.036 0.272 0.564
#> GSM213090     4  0.7534     0.2525 0.124 0.076 0.168 0.632
#> GSM213093     4  0.8503     0.0335 0.300 0.024 0.296 0.380
#> GSM213097     1  0.8120    -0.0926 0.404 0.012 0.352 0.232
#> GSM213099     4  0.5339     0.4130 0.100 0.000 0.156 0.744
#> GSM213101     1  0.6291     0.3105 0.640 0.012 0.284 0.064
#> GSM213105     2  0.0817     0.8104 0.000 0.976 0.024 0.000
#> GSM213109     1  0.6792     0.2573 0.588 0.000 0.140 0.272
#> GSM213110     2  0.4371     0.7547 0.064 0.836 0.080 0.020
#> GSM213113     3  0.9335     0.1180 0.144 0.156 0.408 0.292
#> GSM213121     2  0.2124     0.8068 0.000 0.924 0.068 0.008
#> GSM213123     3  0.8692     0.1456 0.300 0.040 0.404 0.256
#> GSM213125     2  0.0657     0.8103 0.000 0.984 0.012 0.004
#> GSM213073     4  0.7999     0.1635 0.140 0.052 0.260 0.548
#> GSM213086     1  0.6991     0.3549 0.592 0.008 0.268 0.132
#> GSM213098     3  0.9586     0.1893 0.204 0.148 0.376 0.272
#> GSM213106     4  0.8465     0.0265 0.232 0.028 0.348 0.392
#> GSM213124     2  0.8650     0.2734 0.088 0.512 0.216 0.184

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.6017     0.2574 0.552 0.000 0.008 0.336 0.104
#> GSM213082     2  0.3735     0.7202 0.000 0.836 0.016 0.072 0.076
#> GSM213085     1  0.6738     0.3359 0.616 0.008 0.112 0.068 0.196
#> GSM213088     4  0.7425     0.2784 0.188 0.128 0.016 0.568 0.100
#> GSM213091     3  0.6216     0.3703 0.036 0.004 0.608 0.272 0.080
#> GSM213092     1  0.6578     0.3667 0.628 0.004 0.092 0.084 0.192
#> GSM213096     1  0.7354     0.2983 0.544 0.024 0.064 0.104 0.264
#> GSM213100     1  0.6809     0.3982 0.608 0.000 0.104 0.148 0.140
#> GSM213111     2  0.4337     0.7041 0.004 0.784 0.048 0.012 0.152
#> GSM213117     4  0.8524     0.1801 0.100 0.044 0.188 0.452 0.216
#> GSM213118     5  0.9243     0.1595 0.236 0.072 0.140 0.188 0.364
#> GSM213120     2  0.5879     0.6308 0.020 0.688 0.044 0.052 0.196
#> GSM213122     2  0.1525     0.7468 0.000 0.948 0.004 0.012 0.036
#> GSM213074     3  0.7342     0.3058 0.116 0.004 0.524 0.264 0.092
#> GSM213077     1  0.4617     0.4645 0.784 0.000 0.048 0.112 0.056
#> GSM213083     1  0.6175     0.4041 0.648 0.000 0.068 0.200 0.084
#> GSM213094     3  0.4012     0.4868 0.044 0.000 0.820 0.104 0.032
#> GSM213095     2  0.8177     0.1964 0.084 0.444 0.252 0.020 0.200
#> GSM213102     4  0.7305     0.3415 0.200 0.012 0.160 0.560 0.068
#> GSM213103     2  0.7073     0.3833 0.036 0.540 0.052 0.060 0.312
#> GSM213104     5  0.8466     0.0850 0.304 0.132 0.084 0.056 0.424
#> GSM213107     2  0.5175     0.6039 0.012 0.664 0.052 0.000 0.272
#> GSM213108     2  0.7697     0.4179 0.040 0.548 0.220 0.080 0.112
#> GSM213112     1  0.7541     0.2669 0.556 0.024 0.180 0.072 0.168
#> GSM213114     1  0.6858     0.1864 0.528 0.032 0.008 0.120 0.312
#> GSM213115     2  0.1885     0.7464 0.000 0.932 0.004 0.020 0.044
#> GSM213116     4  0.8328     0.0262 0.160 0.004 0.316 0.360 0.160
#> GSM213119     2  0.0960     0.7454 0.000 0.972 0.004 0.008 0.016
#> GSM213072     3  0.7661     0.2676 0.124 0.004 0.516 0.204 0.152
#> GSM213075     4  0.8588    -0.0661 0.092 0.068 0.344 0.384 0.112
#> GSM213076     2  0.6655     0.5385 0.008 0.592 0.092 0.052 0.256
#> GSM213079     3  0.4413     0.4613 0.100 0.004 0.804 0.040 0.052
#> GSM213080     1  0.8033    -0.1344 0.372 0.168 0.000 0.124 0.336
#> GSM213081     4  0.8479     0.0413 0.296 0.020 0.084 0.336 0.264
#> GSM213084     1  0.5063     0.4476 0.740 0.000 0.056 0.160 0.044
#> GSM213087     2  0.1857     0.7448 0.000 0.928 0.008 0.004 0.060
#> GSM213089     3  0.7855     0.1260 0.088 0.016 0.396 0.384 0.116
#> GSM213090     3  0.6514     0.3366 0.132 0.044 0.668 0.036 0.120
#> GSM213093     4  0.7324     0.2813 0.144 0.008 0.216 0.552 0.080
#> GSM213097     4  0.6601     0.3525 0.212 0.004 0.100 0.616 0.068
#> GSM213099     3  0.7199     0.3385 0.056 0.016 0.548 0.264 0.116
#> GSM213101     1  0.7460     0.0307 0.408 0.028 0.032 0.408 0.124
#> GSM213105     2  0.0510     0.7435 0.000 0.984 0.000 0.000 0.016
#> GSM213109     1  0.6896     0.3195 0.588 0.000 0.156 0.176 0.080
#> GSM213110     2  0.4641     0.6853 0.052 0.804 0.020 0.044 0.080
#> GSM213113     5  0.9646     0.0654 0.164 0.092 0.252 0.232 0.260
#> GSM213121     2  0.2674     0.7279 0.000 0.856 0.004 0.000 0.140
#> GSM213123     4  0.8812     0.2105 0.240 0.036 0.156 0.400 0.168
#> GSM213125     2  0.0932     0.7462 0.004 0.972 0.000 0.004 0.020
#> GSM213073     3  0.7643     0.2247 0.116 0.036 0.560 0.088 0.200
#> GSM213086     1  0.7427     0.3035 0.528 0.008 0.100 0.108 0.256
#> GSM213098     5  0.8866     0.2543 0.096 0.080 0.228 0.168 0.428
#> GSM213106     4  0.7204     0.2924 0.104 0.016 0.204 0.584 0.092
#> GSM213124     2  0.8982     0.0966 0.104 0.436 0.132 0.120 0.208

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     4   0.651   -0.03959 0.336 0.000 0.008 0.472 0.144 0.040
#> GSM213082     2   0.406    0.66158 0.004 0.812 0.060 0.008 0.048 0.068
#> GSM213085     1   0.565    0.39770 0.692 0.000 0.132 0.040 0.052 0.084
#> GSM213088     4   0.669    0.31828 0.076 0.068 0.016 0.636 0.104 0.100
#> GSM213091     3   0.722    0.01449 0.036 0.004 0.440 0.200 0.032 0.288
#> GSM213092     1   0.549    0.43553 0.724 0.004 0.084 0.056 0.060 0.072
#> GSM213096     1   0.757    0.24395 0.476 0.008 0.032 0.148 0.236 0.100
#> GSM213100     1   0.743    0.33790 0.528 0.008 0.084 0.204 0.068 0.108
#> GSM213111     2   0.570    0.64430 0.020 0.700 0.056 0.016 0.128 0.080
#> GSM213117     6   0.895    0.22701 0.080 0.072 0.136 0.228 0.104 0.380
#> GSM213118     5   0.862    0.14855 0.212 0.032 0.036 0.140 0.336 0.244
#> GSM213120     2   0.721    0.52737 0.024 0.556 0.056 0.048 0.204 0.112
#> GSM213122     2   0.231    0.68560 0.004 0.908 0.000 0.016 0.032 0.040
#> GSM213074     6   0.783   -0.01440 0.136 0.008 0.312 0.148 0.020 0.376
#> GSM213077     1   0.624    0.43159 0.644 0.000 0.048 0.144 0.076 0.088
#> GSM213083     1   0.622    0.32731 0.560 0.004 0.028 0.304 0.044 0.060
#> GSM213094     3   0.553    0.26753 0.032 0.008 0.604 0.044 0.008 0.304
#> GSM213095     2   0.827    0.15461 0.084 0.340 0.320 0.008 0.164 0.084
#> GSM213102     4   0.666    0.21308 0.132 0.008 0.088 0.620 0.044 0.108
#> GSM213103     2   0.778    0.20624 0.032 0.372 0.032 0.048 0.356 0.160
#> GSM213104     5   0.767    0.26682 0.240 0.064 0.088 0.040 0.508 0.060
#> GSM213107     2   0.583    0.47563 0.004 0.528 0.064 0.004 0.364 0.036
#> GSM213108     2   0.738    0.33219 0.032 0.452 0.272 0.012 0.040 0.192
#> GSM213112     1   0.602    0.35818 0.668 0.004 0.128 0.044 0.108 0.048
#> GSM213114     5   0.677   -0.00223 0.400 0.016 0.028 0.128 0.416 0.012
#> GSM213115     2   0.229    0.68557 0.000 0.896 0.000 0.004 0.072 0.028
#> GSM213116     6   0.841    0.19679 0.128 0.004 0.160 0.296 0.080 0.332
#> GSM213119     2   0.146    0.68468 0.000 0.948 0.004 0.004 0.016 0.028
#> GSM213072     3   0.797   -0.05905 0.132 0.004 0.360 0.104 0.060 0.340
#> GSM213075     6   0.876    0.13136 0.060 0.060 0.268 0.264 0.060 0.288
#> GSM213076     2   0.753    0.43324 0.008 0.472 0.132 0.024 0.244 0.120
#> GSM213079     3   0.396    0.37141 0.060 0.004 0.824 0.028 0.024 0.060
#> GSM213080     5   0.654    0.28158 0.228 0.092 0.000 0.116 0.556 0.008
#> GSM213081     4   0.867    0.07899 0.172 0.012 0.108 0.340 0.260 0.108
#> GSM213084     1   0.689    0.34652 0.520 0.000 0.036 0.272 0.076 0.096
#> GSM213087     2   0.280    0.67958 0.000 0.860 0.008 0.004 0.112 0.016
#> GSM213089     6   0.796    0.16491 0.064 0.012 0.264 0.256 0.040 0.364
#> GSM213090     3   0.482    0.33919 0.116 0.008 0.760 0.036 0.020 0.060
#> GSM213093     4   0.756    0.07169 0.116 0.004 0.168 0.512 0.056 0.144
#> GSM213097     4   0.545    0.25695 0.088 0.000 0.076 0.712 0.028 0.096
#> GSM213099     3   0.677    0.00442 0.044 0.000 0.420 0.156 0.012 0.368
#> GSM213101     4   0.711    0.09050 0.296 0.016 0.016 0.488 0.120 0.064
#> GSM213105     2   0.160    0.68670 0.000 0.944 0.008 0.008 0.016 0.024
#> GSM213109     1   0.722    0.27902 0.492 0.000 0.056 0.252 0.052 0.148
#> GSM213110     2   0.495    0.62362 0.040 0.768 0.016 0.040 0.088 0.048
#> GSM213113     5   0.952   -0.02692 0.104 0.064 0.176 0.204 0.268 0.184
#> GSM213121     2   0.473    0.60854 0.008 0.672 0.020 0.000 0.268 0.032
#> GSM213123     4   0.851    0.10973 0.120 0.016 0.116 0.420 0.188 0.140
#> GSM213125     2   0.164    0.68792 0.004 0.944 0.012 0.004 0.012 0.024
#> GSM213073     3   0.557    0.30278 0.052 0.012 0.704 0.036 0.152 0.044
#> GSM213086     1   0.754    0.14381 0.496 0.008 0.044 0.104 0.228 0.120
#> GSM213098     5   0.846    0.20366 0.056 0.052 0.168 0.128 0.452 0.144
#> GSM213106     4   0.775   -0.03134 0.052 0.024 0.124 0.472 0.068 0.260
#> GSM213124     2   0.908    0.09763 0.108 0.344 0.076 0.068 0.168 0.236

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.315           0.733       0.850         0.4137 0.575   0.575
#> 3 3 0.260           0.631       0.777         0.4972 0.774   0.613
#> 4 4 0.379           0.572       0.756         0.1067 0.891   0.720
#> 5 5 0.384           0.532       0.760         0.0235 0.944   0.835
#> 6 6 0.373           0.470       0.723         0.0370 0.989   0.965

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
#> GSM213078     1  0.2043     0.8396 0.968 0.032
#> GSM213082     2  0.9044     0.7886 0.320 0.680
#> GSM213085     1  0.4815     0.8122 0.896 0.104
#> GSM213088     1  0.2603     0.8328 0.956 0.044
#> GSM213091     1  0.3733     0.8285 0.928 0.072
#> GSM213092     1  0.1843     0.8465 0.972 0.028
#> GSM213096     1  0.1184     0.8490 0.984 0.016
#> GSM213100     1  0.0938     0.8495 0.988 0.012
#> GSM213111     2  0.6801     0.7740 0.180 0.820
#> GSM213117     1  0.0376     0.8495 0.996 0.004
#> GSM213118     1  0.6623     0.7325 0.828 0.172
#> GSM213120     2  0.9795     0.6471 0.416 0.584
#> GSM213122     2  0.8909     0.7931 0.308 0.692
#> GSM213074     1  0.0938     0.8506 0.988 0.012
#> GSM213077     1  0.1843     0.8485 0.972 0.028
#> GSM213083     1  0.0672     0.8494 0.992 0.008
#> GSM213094     1  0.9044     0.3751 0.680 0.320
#> GSM213095     2  0.8955     0.7313 0.312 0.688
#> GSM213102     1  0.0376     0.8493 0.996 0.004
#> GSM213103     2  0.9552     0.7284 0.376 0.624
#> GSM213104     1  0.9988     0.2862 0.520 0.480
#> GSM213107     2  0.0000     0.6816 0.000 1.000
#> GSM213108     2  0.9393     0.7527 0.356 0.644
#> GSM213112     1  0.2603     0.8453 0.956 0.044
#> GSM213114     1  0.8386     0.5860 0.732 0.268
#> GSM213115     2  0.3114     0.7119 0.056 0.944
#> GSM213116     1  0.3431     0.8257 0.936 0.064
#> GSM213119     2  0.8763     0.7947 0.296 0.704
#> GSM213072     1  0.4562     0.7901 0.904 0.096
#> GSM213075     1  0.6438     0.6992 0.836 0.164
#> GSM213076     1  0.9710    -0.0224 0.600 0.400
#> GSM213079     1  0.5946     0.7610 0.856 0.144
#> GSM213080     1  0.8713     0.5692 0.708 0.292
#> GSM213081     1  0.8327     0.5950 0.736 0.264
#> GSM213084     1  0.4562     0.8112 0.904 0.096
#> GSM213087     2  0.1633     0.6899 0.024 0.976
#> GSM213089     1  0.1843     0.8495 0.972 0.028
#> GSM213090     1  0.9775     0.0371 0.588 0.412
#> GSM213093     1  0.1414     0.8467 0.980 0.020
#> GSM213097     1  0.0000     0.8490 1.000 0.000
#> GSM213099     1  0.4815     0.7855 0.896 0.104
#> GSM213101     1  0.0000     0.8490 1.000 0.000
#> GSM213105     2  0.8713     0.7961 0.292 0.708
#> GSM213109     1  0.1633     0.8452 0.976 0.024
#> GSM213110     2  0.9248     0.7736 0.340 0.660
#> GSM213113     1  0.0938     0.8512 0.988 0.012
#> GSM213121     2  0.1843     0.6908 0.028 0.972
#> GSM213123     1  0.0376     0.8500 0.996 0.004
#> GSM213125     2  0.7602     0.7918 0.220 0.780
#> GSM213073     1  0.5059     0.8171 0.888 0.112
#> GSM213086     1  0.8713     0.5771 0.708 0.292
#> GSM213098     1  0.1184     0.8516 0.984 0.016
#> GSM213106     1  0.0000     0.8490 1.000 0.000
#> GSM213124     2  0.9815     0.6214 0.420 0.580

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0000      0.741 1.000 0.000 0.000
#> GSM213082     2  0.4291      0.781 0.180 0.820 0.000
#> GSM213085     3  0.3879      0.783 0.152 0.000 0.848
#> GSM213088     1  0.0000      0.741 1.000 0.000 0.000
#> GSM213091     1  0.6057      0.392 0.656 0.004 0.340
#> GSM213092     3  0.4504      0.762 0.196 0.000 0.804
#> GSM213096     1  0.2261      0.737 0.932 0.000 0.068
#> GSM213100     1  0.2066      0.737 0.940 0.000 0.060
#> GSM213111     2  0.5961      0.762 0.136 0.788 0.076
#> GSM213117     1  0.3192      0.726 0.888 0.000 0.112
#> GSM213118     3  0.6307      0.460 0.328 0.012 0.660
#> GSM213120     2  0.7400      0.510 0.412 0.552 0.036
#> GSM213122     2  0.4346      0.779 0.184 0.816 0.000
#> GSM213074     1  0.5291      0.553 0.732 0.000 0.268
#> GSM213077     1  0.6225      0.139 0.568 0.000 0.432
#> GSM213083     1  0.4702      0.639 0.788 0.000 0.212
#> GSM213094     3  0.5466      0.773 0.160 0.040 0.800
#> GSM213095     3  0.5200      0.682 0.020 0.184 0.796
#> GSM213102     1  0.0000      0.741 1.000 0.000 0.000
#> GSM213103     2  0.7726      0.564 0.372 0.572 0.056
#> GSM213104     3  0.8231      0.447 0.136 0.236 0.628
#> GSM213107     2  0.3752      0.648 0.000 0.856 0.144
#> GSM213108     2  0.6228      0.680 0.316 0.672 0.012
#> GSM213112     3  0.3879      0.783 0.152 0.000 0.848
#> GSM213114     1  0.7930      0.445 0.664 0.164 0.172
#> GSM213115     2  0.1267      0.718 0.024 0.972 0.004
#> GSM213116     1  0.3888      0.724 0.888 0.048 0.064
#> GSM213119     2  0.4062      0.781 0.164 0.836 0.000
#> GSM213072     1  0.6422      0.451 0.660 0.016 0.324
#> GSM213075     1  0.3826      0.689 0.868 0.124 0.008
#> GSM213076     1  0.7916      0.282 0.620 0.292 0.088
#> GSM213079     3  0.4099      0.785 0.140 0.008 0.852
#> GSM213080     1  0.7615      0.460 0.688 0.164 0.148
#> GSM213081     1  0.7441      0.479 0.700 0.164 0.136
#> GSM213084     1  0.4799      0.681 0.836 0.032 0.132
#> GSM213087     2  0.1031      0.690 0.000 0.976 0.024
#> GSM213089     1  0.6252      0.128 0.556 0.000 0.444
#> GSM213090     3  0.4779      0.782 0.124 0.036 0.840
#> GSM213093     1  0.5497      0.499 0.708 0.000 0.292
#> GSM213097     1  0.0000      0.741 1.000 0.000 0.000
#> GSM213099     1  0.5371      0.678 0.812 0.048 0.140
#> GSM213101     1  0.0000      0.741 1.000 0.000 0.000
#> GSM213105     2  0.4002      0.782 0.160 0.840 0.000
#> GSM213109     3  0.5810      0.565 0.336 0.000 0.664
#> GSM213110     2  0.5882      0.645 0.348 0.652 0.000
#> GSM213113     1  0.5760      0.450 0.672 0.000 0.328
#> GSM213121     2  0.3983      0.648 0.004 0.852 0.144
#> GSM213123     1  0.2959      0.724 0.900 0.000 0.100
#> GSM213125     2  0.4628      0.751 0.088 0.856 0.056
#> GSM213073     3  0.5216      0.696 0.260 0.000 0.740
#> GSM213086     3  0.5631      0.620 0.064 0.132 0.804
#> GSM213098     1  0.3267      0.726 0.884 0.000 0.116
#> GSM213106     1  0.0592      0.742 0.988 0.000 0.012
#> GSM213124     2  0.8310      0.405 0.420 0.500 0.080

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0707     0.7236 0.980 0.000 0.000 0.020
#> GSM213082     2  0.1256     0.6902 0.028 0.964 0.000 0.008
#> GSM213085     3  0.2976     0.7572 0.120 0.000 0.872 0.008
#> GSM213088     1  0.0469     0.7250 0.988 0.000 0.000 0.012
#> GSM213091     1  0.6106     0.4047 0.604 0.000 0.332 0.064
#> GSM213092     3  0.3583     0.7244 0.180 0.000 0.816 0.004
#> GSM213096     1  0.4824     0.6986 0.780 0.000 0.076 0.144
#> GSM213100     1  0.4586     0.6995 0.796 0.000 0.068 0.136
#> GSM213111     2  0.7080     0.4539 0.100 0.648 0.048 0.204
#> GSM213117     1  0.3182     0.7327 0.876 0.000 0.096 0.028
#> GSM213118     3  0.7171     0.4716 0.212 0.000 0.556 0.232
#> GSM213120     2  0.7136     0.1487 0.444 0.468 0.036 0.052
#> GSM213122     2  0.1004     0.6944 0.024 0.972 0.000 0.004
#> GSM213074     1  0.5339     0.5603 0.688 0.000 0.272 0.040
#> GSM213077     1  0.5292     0.0231 0.512 0.000 0.480 0.008
#> GSM213083     1  0.3982     0.6649 0.776 0.000 0.220 0.004
#> GSM213094     3  0.6415     0.7150 0.116 0.036 0.708 0.140
#> GSM213095     3  0.3870     0.6846 0.008 0.164 0.820 0.008
#> GSM213102     1  0.0000     0.7246 1.000 0.000 0.000 0.000
#> GSM213103     1  0.8939    -0.0113 0.400 0.328 0.068 0.204
#> GSM213104     4  0.6360     0.4421 0.064 0.036 0.212 0.688
#> GSM213107     4  0.4605     0.3430 0.000 0.336 0.000 0.664
#> GSM213108     2  0.4828     0.5406 0.268 0.716 0.008 0.008
#> GSM213112     3  0.3105     0.7573 0.120 0.000 0.868 0.012
#> GSM213114     4  0.5127     0.6044 0.356 0.000 0.012 0.632
#> GSM213115     2  0.0779     0.6912 0.004 0.980 0.000 0.016
#> GSM213116     1  0.3599     0.7265 0.876 0.020 0.040 0.064
#> GSM213119     2  0.0524     0.6912 0.004 0.988 0.000 0.008
#> GSM213072     1  0.6090     0.6123 0.696 0.020 0.216 0.068
#> GSM213075     1  0.4329     0.7067 0.824 0.040 0.012 0.124
#> GSM213076     1  0.6674     0.4079 0.636 0.272 0.044 0.048
#> GSM213079     3  0.2593     0.7000 0.004 0.000 0.892 0.104
#> GSM213080     4  0.4855     0.5942 0.400 0.000 0.000 0.600
#> GSM213081     4  0.4992     0.4486 0.476 0.000 0.000 0.524
#> GSM213084     1  0.5128     0.6499 0.760 0.000 0.148 0.092
#> GSM213087     2  0.1867     0.6413 0.000 0.928 0.000 0.072
#> GSM213089     1  0.4925     0.2757 0.572 0.000 0.428 0.000
#> GSM213090     3  0.1109     0.7186 0.004 0.000 0.968 0.028
#> GSM213093     1  0.5300     0.4866 0.664 0.000 0.308 0.028
#> GSM213097     1  0.0592     0.7240 0.984 0.000 0.000 0.016
#> GSM213099     1  0.4336     0.7154 0.828 0.040 0.116 0.016
#> GSM213101     1  0.0000     0.7246 1.000 0.000 0.000 0.000
#> GSM213105     2  0.0376     0.6914 0.004 0.992 0.000 0.004
#> GSM213109     3  0.4605     0.4739 0.336 0.000 0.664 0.000
#> GSM213110     2  0.5099     0.4061 0.380 0.612 0.000 0.008
#> GSM213113     1  0.4304     0.6049 0.716 0.000 0.284 0.000
#> GSM213121     4  0.4624     0.3363 0.000 0.340 0.000 0.660
#> GSM213123     1  0.2843     0.7297 0.892 0.000 0.088 0.020
#> GSM213125     2  0.1151     0.6844 0.000 0.968 0.008 0.024
#> GSM213073     3  0.3606     0.6872 0.132 0.000 0.844 0.024
#> GSM213086     3  0.6232     0.4161 0.072 0.000 0.596 0.332
#> GSM213098     1  0.5787     0.5899 0.680 0.000 0.076 0.244
#> GSM213106     1  0.0779     0.7295 0.980 0.000 0.016 0.004
#> GSM213124     2  0.7177     0.0537 0.444 0.444 0.104 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
#> GSM213078     4  0.0798     0.6993 0.008 0.000 0.000 0.976 0.016
#> GSM213082     2  0.1646     0.7832 0.004 0.944 0.000 0.020 0.032
#> GSM213085     3  0.3039     0.6007 0.012 0.000 0.836 0.152 0.000
#> GSM213088     4  0.0451     0.7008 0.004 0.000 0.000 0.988 0.008
#> GSM213091     4  0.5866     0.3399 0.032 0.000 0.332 0.584 0.052
#> GSM213092     3  0.3395     0.5686 0.000 0.000 0.764 0.236 0.000
#> GSM213096     4  0.5591     0.6346 0.120 0.000 0.100 0.716 0.064
#> GSM213100     4  0.5204     0.6447 0.096 0.000 0.092 0.748 0.064
#> GSM213111     2  0.6438     0.4812 0.212 0.632 0.052 0.096 0.008
#> GSM213117     4  0.3506     0.6958 0.020 0.004 0.080 0.856 0.040
#> GSM213118     3  0.7246     0.3452 0.216 0.000 0.512 0.216 0.056
#> GSM213120     4  0.6530     0.0412 0.044 0.448 0.040 0.452 0.016
#> GSM213122     2  0.1630     0.7873 0.004 0.944 0.000 0.016 0.036
#> GSM213074     4  0.4695     0.5326 0.016 0.000 0.260 0.700 0.024
#> GSM213077     4  0.4546     0.0747 0.008 0.000 0.460 0.532 0.000
#> GSM213083     4  0.3398     0.6262 0.004 0.000 0.216 0.780 0.000
#> GSM213094     5  0.3366     0.0000 0.000 0.000 0.212 0.004 0.784
#> GSM213095     3  0.3948     0.4370 0.012 0.196 0.776 0.016 0.000
#> GSM213102     4  0.0000     0.7008 0.000 0.000 0.000 1.000 0.000
#> GSM213103     4  0.8706     0.2363 0.204 0.268 0.092 0.392 0.044
#> GSM213104     1  0.5252     0.4777 0.740 0.024 0.160 0.056 0.020
#> GSM213107     1  0.3210     0.4907 0.788 0.212 0.000 0.000 0.000
#> GSM213108     2  0.4619     0.5270 0.012 0.704 0.012 0.264 0.008
#> GSM213112     3  0.3141     0.6004 0.016 0.000 0.832 0.152 0.000
#> GSM213114     1  0.4604     0.6085 0.680 0.000 0.012 0.292 0.016
#> GSM213115     2  0.0898     0.7836 0.020 0.972 0.000 0.000 0.008
#> GSM213116     4  0.3789     0.6926 0.048 0.012 0.040 0.852 0.048
#> GSM213119     2  0.0880     0.7861 0.000 0.968 0.000 0.000 0.032
#> GSM213072     4  0.5910     0.5753 0.048 0.016 0.212 0.676 0.048
#> GSM213075     4  0.3966     0.6911 0.068 0.032 0.012 0.840 0.048
#> GSM213076     4  0.6248     0.5212 0.092 0.220 0.040 0.640 0.008
#> GSM213079     3  0.4210     0.3703 0.096 0.000 0.780 0.000 0.124
#> GSM213080     1  0.3983     0.6091 0.660 0.000 0.000 0.340 0.000
#> GSM213081     1  0.4572     0.4783 0.540 0.000 0.004 0.452 0.004
#> GSM213084     4  0.4507     0.6361 0.044 0.000 0.120 0.788 0.048
#> GSM213087     2  0.1830     0.7511 0.068 0.924 0.000 0.000 0.008
#> GSM213089     4  0.4367     0.2654 0.000 0.000 0.416 0.580 0.004
#> GSM213090     3  0.2871     0.4145 0.088 0.000 0.872 0.000 0.040
#> GSM213093     4  0.4568     0.4777 0.008 0.000 0.288 0.684 0.020
#> GSM213097     4  0.0693     0.7000 0.008 0.000 0.000 0.980 0.012
#> GSM213099     4  0.4362     0.6822 0.004 0.032 0.084 0.808 0.072
#> GSM213101     4  0.0000     0.7008 0.000 0.000 0.000 1.000 0.000
#> GSM213105     2  0.0963     0.7856 0.000 0.964 0.000 0.000 0.036
#> GSM213109     3  0.4074     0.3802 0.000 0.000 0.636 0.364 0.000
#> GSM213110     2  0.4791     0.2054 0.008 0.588 0.000 0.392 0.012
#> GSM213113     4  0.3884     0.5693 0.004 0.000 0.288 0.708 0.000
#> GSM213121     1  0.3366     0.4885 0.784 0.212 0.000 0.000 0.004
#> GSM213123     4  0.2354     0.6933 0.008 0.000 0.076 0.904 0.012
#> GSM213125     2  0.1026     0.7822 0.024 0.968 0.004 0.000 0.004
#> GSM213073     3  0.4637     0.4244 0.032 0.000 0.780 0.108 0.080
#> GSM213086     3  0.5657     0.2459 0.360 0.000 0.560 0.076 0.004
#> GSM213098     4  0.6096     0.5453 0.220 0.000 0.096 0.640 0.044
#> GSM213106     4  0.0671     0.7032 0.000 0.000 0.016 0.980 0.004
#> GSM213124     4  0.6466     0.1155 0.016 0.428 0.100 0.452 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     4  0.1261     0.6589 0.008 0.000 0.028 0.956 0.004 0.004
#> GSM213082     2  0.2055     0.7617 0.000 0.924 0.020 0.020 0.008 0.028
#> GSM213085     1  0.1814     0.4054 0.900 0.000 0.000 0.100 0.000 0.000
#> GSM213088     4  0.0806     0.6616 0.008 0.000 0.020 0.972 0.000 0.000
#> GSM213091     4  0.5921     0.3376 0.316 0.000 0.076 0.560 0.016 0.032
#> GSM213092     1  0.3023     0.3804 0.768 0.000 0.000 0.232 0.000 0.000
#> GSM213096     4  0.6032     0.5253 0.160 0.000 0.132 0.628 0.072 0.008
#> GSM213100     4  0.5864     0.5328 0.160 0.000 0.132 0.644 0.052 0.012
#> GSM213111     2  0.6565     0.4542 0.096 0.584 0.012 0.068 0.224 0.016
#> GSM213117     4  0.3438     0.6502 0.096 0.000 0.020 0.840 0.016 0.028
#> GSM213118     1  0.6682     0.1289 0.560 0.000 0.120 0.160 0.152 0.008
#> GSM213120     4  0.6561     0.0636 0.068 0.412 0.016 0.440 0.056 0.008
#> GSM213122     2  0.1950     0.7655 0.000 0.928 0.020 0.012 0.008 0.032
#> GSM213074     4  0.4405     0.4977 0.260 0.000 0.040 0.688 0.012 0.000
#> GSM213077     4  0.4217     0.0535 0.464 0.000 0.008 0.524 0.004 0.000
#> GSM213083     4  0.3109     0.5839 0.224 0.000 0.000 0.772 0.004 0.000
#> GSM213094     6  0.1444     0.0000 0.072 0.000 0.000 0.000 0.000 0.928
#> GSM213095     1  0.3492     0.1189 0.796 0.172 0.004 0.016 0.012 0.000
#> GSM213102     4  0.0000     0.6634 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213103     4  0.8715     0.1736 0.160 0.248 0.096 0.328 0.160 0.008
#> GSM213104     5  0.4689     0.5578 0.120 0.020 0.056 0.044 0.760 0.000
#> GSM213107     5  0.2135     0.5524 0.000 0.128 0.000 0.000 0.872 0.000
#> GSM213108     2  0.4638     0.5264 0.004 0.684 0.016 0.264 0.020 0.012
#> GSM213112     1  0.1958     0.4053 0.896 0.000 0.004 0.100 0.000 0.000
#> GSM213114     5  0.4070     0.6463 0.004 0.000 0.028 0.248 0.716 0.004
#> GSM213115     2  0.1528     0.7565 0.000 0.944 0.012 0.000 0.028 0.016
#> GSM213116     4  0.3634     0.6509 0.052 0.004 0.052 0.844 0.020 0.028
#> GSM213119     2  0.1257     0.7649 0.000 0.952 0.020 0.000 0.000 0.028
#> GSM213072     4  0.6190     0.4780 0.248 0.020 0.068 0.608 0.032 0.024
#> GSM213075     4  0.4328     0.6430 0.040 0.020 0.088 0.800 0.044 0.008
#> GSM213076     4  0.5830     0.4798 0.048 0.196 0.000 0.624 0.128 0.004
#> GSM213079     3  0.4301     0.4368 0.400 0.000 0.580 0.000 0.004 0.016
#> GSM213080     5  0.3575     0.6473 0.000 0.000 0.008 0.284 0.708 0.000
#> GSM213081     5  0.4776     0.4179 0.012 0.000 0.028 0.448 0.512 0.000
#> GSM213084     4  0.5022     0.5521 0.168 0.000 0.096 0.704 0.024 0.008
#> GSM213087     2  0.1556     0.7252 0.000 0.920 0.000 0.000 0.080 0.000
#> GSM213089     4  0.3944     0.2244 0.428 0.000 0.000 0.568 0.000 0.004
#> GSM213090     3  0.4853     0.4091 0.456 0.000 0.488 0.000 0.056 0.000
#> GSM213093     4  0.4579     0.4238 0.316 0.000 0.032 0.640 0.008 0.004
#> GSM213097     4  0.1180     0.6597 0.008 0.000 0.024 0.960 0.004 0.004
#> GSM213099     4  0.4976     0.6160 0.084 0.032 0.008 0.740 0.012 0.124
#> GSM213101     4  0.0000     0.6634 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213105     2  0.1334     0.7641 0.000 0.948 0.020 0.000 0.000 0.032
#> GSM213109     1  0.3634     0.3235 0.644 0.000 0.000 0.356 0.000 0.000
#> GSM213110     2  0.4969     0.1809 0.000 0.560 0.016 0.392 0.016 0.016
#> GSM213113     4  0.3428     0.5194 0.304 0.000 0.000 0.696 0.000 0.000
#> GSM213121     5  0.2219     0.5463 0.000 0.136 0.000 0.000 0.864 0.000
#> GSM213123     4  0.2485     0.6506 0.084 0.000 0.024 0.884 0.008 0.000
#> GSM213125     2  0.1729     0.7564 0.004 0.936 0.012 0.000 0.036 0.012
#> GSM213073     1  0.5529    -0.2166 0.616 0.000 0.268 0.084 0.020 0.012
#> GSM213086     1  0.5194    -0.0393 0.544 0.000 0.020 0.052 0.384 0.000
#> GSM213098     4  0.5940     0.4811 0.096 0.000 0.076 0.600 0.228 0.000
#> GSM213106     4  0.0692     0.6645 0.020 0.000 0.004 0.976 0.000 0.000
#> GSM213124     4  0.6457     0.1213 0.124 0.396 0.008 0.440 0.020 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 development.stage(p) disease.state(p) k
#> MAD:pam 50                0.474            0.640 2
#> MAD:pam 41                0.740            0.715 3
#> MAD:pam 37                0.846            0.814 4
#> MAD:pam 33                0.327            0.938 5
#> MAD:pam 29                0.821            0.348 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.599           0.807       0.905         0.4511 0.525   0.525
#> 3 3 0.383           0.478       0.724         0.1924 0.617   0.424
#> 4 4 0.421           0.574       0.746         0.2786 0.611   0.285
#> 5 5 0.549           0.680       0.790         0.0721 0.864   0.596
#> 6 6 0.625           0.532       0.773         0.0636 0.936   0.772

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
#> GSM213078     1  0.1843     0.9245 0.972 0.028
#> GSM213082     2  0.0938     0.8503 0.012 0.988
#> GSM213085     1  0.1843     0.9244 0.972 0.028
#> GSM213088     1  0.5629     0.8622 0.868 0.132
#> GSM213091     1  0.4298     0.8950 0.912 0.088
#> GSM213092     1  0.1843     0.9238 0.972 0.028
#> GSM213096     1  0.1633     0.9243 0.976 0.024
#> GSM213100     1  0.1843     0.9238 0.972 0.028
#> GSM213111     2  0.0938     0.8503 0.012 0.988
#> GSM213117     1  0.1184     0.9198 0.984 0.016
#> GSM213118     1  0.1843     0.9245 0.972 0.028
#> GSM213120     2  0.3274     0.8206 0.060 0.940
#> GSM213122     2  0.0376     0.8486 0.004 0.996
#> GSM213074     1  0.5842     0.8451 0.860 0.140
#> GSM213077     1  0.1843     0.9238 0.972 0.028
#> GSM213083     1  0.1843     0.9245 0.972 0.028
#> GSM213094     2  0.9323     0.4942 0.348 0.652
#> GSM213095     2  0.0938     0.8503 0.012 0.988
#> GSM213102     1  0.0376     0.9166 0.996 0.004
#> GSM213103     2  0.9970     0.0135 0.468 0.532
#> GSM213104     1  0.8909     0.6116 0.692 0.308
#> GSM213107     2  0.0938     0.8503 0.012 0.988
#> GSM213108     2  0.2043     0.8411 0.032 0.968
#> GSM213112     1  0.3879     0.9024 0.924 0.076
#> GSM213114     1  0.6887     0.8011 0.816 0.184
#> GSM213115     2  0.0376     0.8486 0.004 0.996
#> GSM213116     1  0.0376     0.9166 0.996 0.004
#> GSM213119     2  0.0376     0.8486 0.004 0.996
#> GSM213072     1  0.1414     0.9228 0.980 0.020
#> GSM213075     1  0.1633     0.9229 0.976 0.024
#> GSM213076     2  0.0938     0.8503 0.012 0.988
#> GSM213079     2  0.9248     0.5111 0.340 0.660
#> GSM213080     1  0.8813     0.6269 0.700 0.300
#> GSM213081     1  0.1843     0.9247 0.972 0.028
#> GSM213084     1  0.1843     0.9238 0.972 0.028
#> GSM213087     2  0.0376     0.8486 0.004 0.996
#> GSM213089     1  0.2236     0.9150 0.964 0.036
#> GSM213090     2  0.9248     0.5111 0.340 0.660
#> GSM213093     1  0.0376     0.9166 0.996 0.004
#> GSM213097     1  0.0376     0.9166 0.996 0.004
#> GSM213099     1  0.5408     0.8686 0.876 0.124
#> GSM213101     1  0.1843     0.9245 0.972 0.028
#> GSM213105     2  0.0376     0.8486 0.004 0.996
#> GSM213109     1  0.0938     0.9208 0.988 0.012
#> GSM213110     2  0.9970     0.0135 0.468 0.532
#> GSM213113     1  0.5629     0.8607 0.868 0.132
#> GSM213121     2  0.0938     0.8503 0.012 0.988
#> GSM213123     1  0.1414     0.9239 0.980 0.020
#> GSM213125     2  0.0376     0.8486 0.004 0.996
#> GSM213073     2  0.9248     0.5111 0.340 0.660
#> GSM213086     1  0.1843     0.9238 0.972 0.028
#> GSM213098     1  0.7056     0.7937 0.808 0.192
#> GSM213106     1  0.0376     0.9166 0.996 0.004
#> GSM213124     1  0.9710     0.3756 0.600 0.400

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     2  0.6509     0.0856 0.472 0.524 0.004
#> GSM213082     2  0.1289     0.7195 0.000 0.968 0.032
#> GSM213085     1  0.9338    -0.4673 0.468 0.172 0.360
#> GSM213088     2  0.6295     0.0936 0.472 0.528 0.000
#> GSM213091     1  0.7158     0.3107 0.596 0.372 0.032
#> GSM213092     3  0.7841     0.8483 0.472 0.052 0.476
#> GSM213096     1  0.8142    -0.8321 0.468 0.068 0.464
#> GSM213100     3  0.6295     0.9382 0.472 0.000 0.528
#> GSM213111     2  0.0237     0.7242 0.000 0.996 0.004
#> GSM213117     1  0.0592     0.4562 0.988 0.012 0.000
#> GSM213118     1  0.8826     0.1505 0.472 0.412 0.116
#> GSM213120     2  0.0237     0.7242 0.000 0.996 0.004
#> GSM213122     2  0.2625     0.7029 0.000 0.916 0.084
#> GSM213074     1  0.6180     0.3506 0.660 0.332 0.008
#> GSM213077     3  0.6295     0.9382 0.472 0.000 0.528
#> GSM213083     1  0.9571    -0.2785 0.472 0.224 0.304
#> GSM213094     2  0.6566     0.5463 0.012 0.612 0.376
#> GSM213095     2  0.1289     0.7195 0.000 0.968 0.032
#> GSM213102     1  0.0000     0.4462 1.000 0.000 0.000
#> GSM213103     2  0.0000     0.7243 0.000 1.000 0.000
#> GSM213104     2  0.6529     0.3389 0.368 0.620 0.012
#> GSM213107     2  0.0237     0.7240 0.000 0.996 0.004
#> GSM213108     2  0.0000     0.7243 0.000 1.000 0.000
#> GSM213112     1  0.9102     0.1321 0.452 0.408 0.140
#> GSM213114     2  0.6566     0.3227 0.376 0.612 0.012
#> GSM213115     2  0.2625     0.7029 0.000 0.916 0.084
#> GSM213116     1  0.0237     0.4518 0.996 0.004 0.000
#> GSM213119     2  0.2625     0.7029 0.000 0.916 0.084
#> GSM213072     1  0.5420     0.3791 0.752 0.240 0.008
#> GSM213075     1  0.2066     0.4611 0.940 0.060 0.000
#> GSM213076     2  0.0000     0.7243 0.000 1.000 0.000
#> GSM213079     2  0.6282     0.5475 0.004 0.612 0.384
#> GSM213080     2  0.6548     0.3312 0.372 0.616 0.012
#> GSM213081     3  0.7841     0.8534 0.468 0.052 0.480
#> GSM213084     3  0.6295     0.9382 0.472 0.000 0.528
#> GSM213087     2  0.2165     0.7090 0.000 0.936 0.064
#> GSM213089     1  0.1411     0.4627 0.964 0.036 0.000
#> GSM213090     2  0.6079     0.5477 0.000 0.612 0.388
#> GSM213093     1  0.0000     0.4462 1.000 0.000 0.000
#> GSM213097     1  0.0592     0.4532 0.988 0.012 0.000
#> GSM213099     2  0.8097     0.2268 0.388 0.540 0.072
#> GSM213101     2  0.6513     0.0723 0.476 0.520 0.004
#> GSM213105     2  0.2625     0.7029 0.000 0.916 0.084
#> GSM213109     1  0.3551     0.4295 0.868 0.132 0.000
#> GSM213110     2  0.0237     0.7242 0.000 0.996 0.004
#> GSM213113     2  0.6540     0.2463 0.408 0.584 0.008
#> GSM213121     2  0.0000     0.7243 0.000 1.000 0.000
#> GSM213123     1  0.3481     0.3754 0.904 0.044 0.052
#> GSM213125     2  0.2625     0.7029 0.000 0.916 0.084
#> GSM213073     2  0.6282     0.5482 0.004 0.612 0.384
#> GSM213086     3  0.6295     0.9382 0.472 0.000 0.528
#> GSM213098     2  0.6451     0.3047 0.384 0.608 0.008
#> GSM213106     1  0.0237     0.4518 0.996 0.004 0.000
#> GSM213124     2  0.5291     0.5081 0.268 0.732 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.5679     0.6228 0.608 0.008 0.020 0.364
#> GSM213082     2  0.4188     0.6192 0.000 0.752 0.004 0.244
#> GSM213085     1  0.5352     0.5995 0.596 0.000 0.016 0.388
#> GSM213088     4  0.3105     0.4744 0.084 0.008 0.020 0.888
#> GSM213091     4  0.4408     0.6792 0.008 0.004 0.232 0.756
#> GSM213092     1  0.3443     0.7041 0.848 0.000 0.016 0.136
#> GSM213096     1  0.3072     0.7039 0.868 0.004 0.004 0.124
#> GSM213100     1  0.1978     0.6877 0.928 0.000 0.004 0.068
#> GSM213111     2  0.5220     0.5635 0.000 0.632 0.016 0.352
#> GSM213117     4  0.5271     0.6812 0.020 0.000 0.340 0.640
#> GSM213118     4  0.5540     0.2060 0.352 0.012 0.012 0.624
#> GSM213120     2  0.5641     0.5464 0.004 0.608 0.024 0.364
#> GSM213122     2  0.0000     0.6365 0.000 1.000 0.000 0.000
#> GSM213074     4  0.4408     0.6817 0.008 0.004 0.232 0.756
#> GSM213077     1  0.1792     0.6868 0.932 0.000 0.000 0.068
#> GSM213083     1  0.5105     0.6758 0.696 0.000 0.028 0.276
#> GSM213094     3  0.4991     0.8992 0.000 0.004 0.608 0.388
#> GSM213095     3  0.7859     0.5324 0.004 0.220 0.400 0.376
#> GSM213102     4  0.6398     0.6525 0.080 0.000 0.344 0.576
#> GSM213103     4  0.5346    -0.1148 0.004 0.272 0.032 0.692
#> GSM213104     1  0.6432     0.3490 0.556 0.020 0.036 0.388
#> GSM213107     2  0.6239     0.4914 0.004 0.568 0.052 0.376
#> GSM213108     2  0.5613     0.5243 0.000 0.592 0.028 0.380
#> GSM213112     1  0.5648     0.5233 0.536 0.004 0.016 0.444
#> GSM213114     1  0.6041     0.4377 0.600 0.012 0.032 0.356
#> GSM213115     2  0.0000     0.6365 0.000 1.000 0.000 0.000
#> GSM213116     4  0.6570     0.6531 0.100 0.000 0.320 0.580
#> GSM213119     2  0.0000     0.6365 0.000 1.000 0.000 0.000
#> GSM213072     4  0.5519     0.6879 0.028 0.004 0.316 0.652
#> GSM213075     4  0.5254     0.6923 0.028 0.000 0.300 0.672
#> GSM213076     2  0.5941     0.5184 0.004 0.584 0.036 0.376
#> GSM213079     3  0.5070     0.9039 0.008 0.000 0.620 0.372
#> GSM213080     1  0.6386     0.3644 0.572 0.020 0.036 0.372
#> GSM213081     1  0.2918     0.6847 0.876 0.008 0.000 0.116
#> GSM213084     1  0.1978     0.6875 0.928 0.000 0.004 0.068
#> GSM213087     2  0.3196     0.6398 0.000 0.856 0.008 0.136
#> GSM213089     4  0.5069     0.6886 0.016 0.000 0.320 0.664
#> GSM213090     3  0.4790     0.9021 0.000 0.000 0.620 0.380
#> GSM213093     4  0.6069     0.6599 0.056 0.000 0.356 0.588
#> GSM213097     4  0.7686     0.4711 0.228 0.000 0.336 0.436
#> GSM213099     4  0.3400     0.5960 0.012 0.004 0.128 0.856
#> GSM213101     1  0.5670     0.6080 0.584 0.008 0.016 0.392
#> GSM213105     2  0.0000     0.6365 0.000 1.000 0.000 0.000
#> GSM213109     1  0.7581     0.1491 0.440 0.000 0.360 0.200
#> GSM213110     4  0.4675     0.0013 0.000 0.244 0.020 0.736
#> GSM213113     4  0.2497     0.4180 0.040 0.016 0.020 0.924
#> GSM213121     2  0.6007     0.5197 0.004 0.584 0.040 0.372
#> GSM213123     4  0.6565     0.5810 0.224 0.000 0.148 0.628
#> GSM213125     2  0.0336     0.6383 0.000 0.992 0.000 0.008
#> GSM213073     3  0.5070     0.9039 0.008 0.000 0.620 0.372
#> GSM213086     1  0.2402     0.6852 0.912 0.000 0.012 0.076
#> GSM213098     4  0.3444     0.3766 0.104 0.012 0.016 0.868
#> GSM213106     4  0.5371     0.6668 0.020 0.000 0.364 0.616
#> GSM213124     4  0.2989     0.3499 0.004 0.100 0.012 0.884

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.6350      0.751 0.692 0.068 0.092 0.112 0.036
#> GSM213082     2  0.2648      0.643 0.000 0.848 0.000 0.000 0.152
#> GSM213085     1  0.5352      0.745 0.708 0.112 0.012 0.164 0.004
#> GSM213088     4  0.5950      0.703 0.088 0.132 0.052 0.708 0.020
#> GSM213091     4  0.4186      0.794 0.008 0.032 0.072 0.824 0.064
#> GSM213092     1  0.2464      0.795 0.892 0.012 0.004 0.092 0.000
#> GSM213096     1  0.2681      0.794 0.896 0.024 0.008 0.068 0.004
#> GSM213100     1  0.2228      0.785 0.912 0.000 0.008 0.068 0.012
#> GSM213111     2  0.0162      0.590 0.000 0.996 0.004 0.000 0.000
#> GSM213117     4  0.1278      0.849 0.020 0.016 0.004 0.960 0.000
#> GSM213118     1  0.5585      0.724 0.688 0.084 0.024 0.200 0.004
#> GSM213120     2  0.1041      0.570 0.000 0.964 0.004 0.000 0.032
#> GSM213122     2  0.3684      0.640 0.000 0.720 0.000 0.000 0.280
#> GSM213074     4  0.4061      0.786 0.000 0.040 0.072 0.824 0.064
#> GSM213077     1  0.1990      0.785 0.920 0.000 0.004 0.068 0.008
#> GSM213083     1  0.4748      0.780 0.784 0.036 0.040 0.124 0.016
#> GSM213094     3  0.4051      0.928 0.004 0.164 0.792 0.008 0.032
#> GSM213095     5  0.5901      0.900 0.000 0.344 0.116 0.000 0.540
#> GSM213102     4  0.2172      0.840 0.076 0.000 0.016 0.908 0.000
#> GSM213103     2  0.3223      0.486 0.012 0.880 0.020 0.044 0.044
#> GSM213104     1  0.6631      0.552 0.644 0.196 0.060 0.036 0.064
#> GSM213107     5  0.5541      0.905 0.000 0.372 0.076 0.000 0.552
#> GSM213108     2  0.2728      0.517 0.000 0.888 0.068 0.004 0.040
#> GSM213112     1  0.6074      0.712 0.656 0.144 0.028 0.168 0.004
#> GSM213114     1  0.5523      0.610 0.708 0.168 0.064 0.000 0.060
#> GSM213115     2  0.3684      0.640 0.000 0.720 0.000 0.000 0.280
#> GSM213116     4  0.2020      0.834 0.100 0.000 0.000 0.900 0.000
#> GSM213119     2  0.3684      0.640 0.000 0.720 0.000 0.000 0.280
#> GSM213072     4  0.3248      0.828 0.032 0.004 0.048 0.876 0.040
#> GSM213075     4  0.1646      0.848 0.020 0.032 0.004 0.944 0.000
#> GSM213076     2  0.1739      0.544 0.004 0.940 0.024 0.000 0.032
#> GSM213079     3  0.2773      0.953 0.000 0.164 0.836 0.000 0.000
#> GSM213080     1  0.5923      0.596 0.688 0.176 0.068 0.008 0.060
#> GSM213081     1  0.3094      0.791 0.868 0.012 0.012 0.100 0.008
#> GSM213084     1  0.2179      0.787 0.912 0.000 0.008 0.072 0.008
#> GSM213087     2  0.3177      0.648 0.000 0.792 0.000 0.000 0.208
#> GSM213089     4  0.1560      0.849 0.020 0.028 0.004 0.948 0.000
#> GSM213090     3  0.2930      0.953 0.000 0.164 0.832 0.000 0.004
#> GSM213093     4  0.1704      0.843 0.068 0.000 0.004 0.928 0.000
#> GSM213097     4  0.3446      0.809 0.116 0.000 0.036 0.840 0.008
#> GSM213099     4  0.5178      0.753 0.008 0.072 0.104 0.760 0.056
#> GSM213101     1  0.7687      0.249 0.452 0.068 0.084 0.360 0.036
#> GSM213105     2  0.3684      0.640 0.000 0.720 0.000 0.000 0.280
#> GSM213109     4  0.2629      0.806 0.136 0.000 0.004 0.860 0.000
#> GSM213110     2  0.2308      0.533 0.004 0.912 0.000 0.048 0.036
#> GSM213113     4  0.7222      0.239 0.248 0.180 0.048 0.520 0.004
#> GSM213121     2  0.5044     -0.559 0.000 0.504 0.032 0.000 0.464
#> GSM213123     4  0.4155      0.717 0.228 0.024 0.004 0.744 0.000
#> GSM213125     2  0.3684      0.640 0.000 0.720 0.000 0.000 0.280
#> GSM213073     3  0.3318      0.914 0.000 0.192 0.800 0.000 0.008
#> GSM213086     1  0.2532      0.785 0.892 0.000 0.008 0.088 0.012
#> GSM213098     1  0.6545      0.638 0.604 0.172 0.044 0.180 0.000
#> GSM213106     4  0.0703      0.846 0.024 0.000 0.000 0.976 0.000
#> GSM213124     2  0.6088     -0.232 0.028 0.480 0.024 0.448 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
#> GSM213078     1  0.7066     0.0604 0.404 0.004 0.008 0.352 0.060 0.172
#> GSM213082     2  0.1218     0.7745 0.000 0.956 0.012 0.000 0.028 0.004
#> GSM213085     1  0.3139     0.7284 0.852 0.000 0.024 0.100 0.012 0.012
#> GSM213088     4  0.6607     0.4310 0.132 0.016 0.024 0.600 0.048 0.180
#> GSM213091     4  0.4566    -0.9177 0.008 0.000 0.020 0.492 0.000 0.480
#> GSM213092     1  0.1850     0.7407 0.924 0.000 0.000 0.052 0.016 0.008
#> GSM213096     1  0.1536     0.7409 0.940 0.000 0.000 0.040 0.016 0.004
#> GSM213100     1  0.1820     0.7402 0.924 0.000 0.000 0.056 0.012 0.008
#> GSM213111     2  0.4177     0.7396 0.000 0.780 0.032 0.000 0.092 0.096
#> GSM213117     4  0.1251     0.5976 0.024 0.000 0.008 0.956 0.000 0.012
#> GSM213118     1  0.4653     0.6866 0.740 0.004 0.012 0.160 0.072 0.012
#> GSM213120     2  0.4833     0.7159 0.004 0.728 0.032 0.000 0.132 0.104
#> GSM213122     2  0.0146     0.7712 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM213074     4  0.4318    -0.8192 0.000 0.000 0.020 0.532 0.000 0.448
#> GSM213077     1  0.1370     0.7374 0.948 0.000 0.000 0.036 0.012 0.004
#> GSM213083     1  0.5276     0.4939 0.648 0.000 0.008 0.228 0.012 0.104
#> GSM213094     3  0.4087     0.5878 0.000 0.004 0.668 0.008 0.008 0.312
#> GSM213095     5  0.3786     0.6778 0.004 0.052 0.172 0.000 0.772 0.000
#> GSM213102     4  0.1686     0.6192 0.064 0.000 0.000 0.924 0.000 0.012
#> GSM213103     2  0.5573     0.6776 0.016 0.684 0.040 0.004 0.152 0.104
#> GSM213104     1  0.6696     0.4260 0.524 0.008 0.024 0.024 0.260 0.160
#> GSM213107     5  0.3953     0.7212 0.000 0.104 0.132 0.000 0.764 0.000
#> GSM213108     2  0.6290     0.5791 0.000 0.628 0.112 0.024 0.096 0.140
#> GSM213112     1  0.3743     0.7243 0.828 0.004 0.028 0.092 0.036 0.012
#> GSM213114     1  0.6224     0.4656 0.568 0.004 0.024 0.016 0.256 0.132
#> GSM213115     2  0.0291     0.7689 0.000 0.992 0.004 0.000 0.004 0.000
#> GSM213116     4  0.2135     0.6003 0.128 0.000 0.000 0.872 0.000 0.000
#> GSM213119     2  0.0146     0.7712 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM213072     4  0.4474    -0.7204 0.024 0.000 0.004 0.560 0.000 0.412
#> GSM213075     4  0.1659     0.5942 0.028 0.000 0.008 0.940 0.004 0.020
#> GSM213076     2  0.5094     0.6935 0.004 0.704 0.040 0.000 0.156 0.096
#> GSM213079     3  0.0146     0.8522 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM213080     1  0.6617     0.4175 0.520 0.008 0.024 0.016 0.264 0.168
#> GSM213081     1  0.3471     0.6547 0.784 0.000 0.000 0.188 0.008 0.020
#> GSM213084     1  0.2195     0.7382 0.904 0.000 0.000 0.068 0.012 0.016
#> GSM213087     2  0.0725     0.7721 0.000 0.976 0.012 0.000 0.012 0.000
#> GSM213089     4  0.1223     0.5739 0.008 0.000 0.012 0.960 0.004 0.016
#> GSM213090     3  0.0146     0.8522 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM213093     4  0.1411     0.6160 0.060 0.000 0.000 0.936 0.000 0.004
#> GSM213097     4  0.3068     0.5942 0.088 0.000 0.000 0.840 0.000 0.072
#> GSM213099     6  0.4982     0.0000 0.008 0.000 0.048 0.456 0.000 0.488
#> GSM213101     4  0.6706     0.3041 0.272 0.004 0.008 0.500 0.044 0.172
#> GSM213105     2  0.0291     0.7689 0.000 0.992 0.004 0.000 0.004 0.000
#> GSM213109     4  0.2800     0.5581 0.112 0.004 0.000 0.860 0.008 0.016
#> GSM213110     2  0.4862     0.7189 0.004 0.732 0.028 0.004 0.128 0.104
#> GSM213113     1  0.7503     0.1802 0.404 0.032 0.064 0.384 0.076 0.040
#> GSM213121     5  0.4809     0.5061 0.000 0.372 0.044 0.000 0.576 0.008
#> GSM213123     4  0.3591     0.4937 0.256 0.000 0.004 0.732 0.004 0.004
#> GSM213125     2  0.0146     0.7711 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM213073     3  0.1371     0.8250 0.000 0.004 0.948 0.004 0.040 0.004
#> GSM213086     1  0.1745     0.7418 0.920 0.000 0.000 0.068 0.012 0.000
#> GSM213098     1  0.6055     0.6486 0.672 0.020 0.036 0.140 0.096 0.036
#> GSM213106     4  0.0713     0.6016 0.028 0.000 0.000 0.972 0.000 0.000
#> GSM213124     2  0.7640     0.1436 0.008 0.412 0.040 0.332 0.096 0.112

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 development.stage(p) disease.state(p) k
#> MAD:mclust 50                1.000            1.000 2
#> MAD:mclust 27                1.000            1.000 3
#> MAD:mclust 41                0.574            0.585 4
#> MAD:mclust 49                0.220            0.244 5
#> MAD:mclust 40                0.440            0.794 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 51941 rows and 54 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 0.922           0.943       0.977         0.4626 0.535   0.535
#> 3 3 0.504           0.710       0.829         0.4041 0.697   0.481
#> 4 4 0.510           0.499       0.703         0.1535 0.820   0.528
#> 5 5 0.582           0.528       0.727         0.0685 0.853   0.509
#> 6 6 0.620           0.430       0.668         0.0446 0.914   0.633

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
#> GSM213078     1  0.0000     0.9830 1.000 0.000
#> GSM213082     2  0.0000     0.9612 0.000 1.000
#> GSM213085     1  0.0000     0.9830 1.000 0.000
#> GSM213088     1  0.5737     0.8402 0.864 0.136
#> GSM213091     1  0.0000     0.9830 1.000 0.000
#> GSM213092     1  0.0000     0.9830 1.000 0.000
#> GSM213096     1  0.0000     0.9830 1.000 0.000
#> GSM213100     1  0.0000     0.9830 1.000 0.000
#> GSM213111     2  0.0000     0.9612 0.000 1.000
#> GSM213117     1  0.0000     0.9830 1.000 0.000
#> GSM213118     1  0.0672     0.9766 0.992 0.008
#> GSM213120     2  0.0000     0.9612 0.000 1.000
#> GSM213122     2  0.0000     0.9612 0.000 1.000
#> GSM213074     1  0.0000     0.9830 1.000 0.000
#> GSM213077     1  0.0000     0.9830 1.000 0.000
#> GSM213083     1  0.0000     0.9830 1.000 0.000
#> GSM213094     1  0.0000     0.9830 1.000 0.000
#> GSM213095     2  0.0000     0.9612 0.000 1.000
#> GSM213102     1  0.0000     0.9830 1.000 0.000
#> GSM213103     2  0.0000     0.9612 0.000 1.000
#> GSM213104     2  0.0672     0.9548 0.008 0.992
#> GSM213107     2  0.0000     0.9612 0.000 1.000
#> GSM213108     2  0.6801     0.7638 0.180 0.820
#> GSM213112     1  0.0000     0.9830 1.000 0.000
#> GSM213114     1  0.6531     0.7980 0.832 0.168
#> GSM213115     2  0.0000     0.9612 0.000 1.000
#> GSM213116     1  0.0000     0.9830 1.000 0.000
#> GSM213119     2  0.0000     0.9612 0.000 1.000
#> GSM213072     1  0.0000     0.9830 1.000 0.000
#> GSM213075     1  0.0000     0.9830 1.000 0.000
#> GSM213076     2  0.0000     0.9612 0.000 1.000
#> GSM213079     1  0.0000     0.9830 1.000 0.000
#> GSM213080     2  0.0000     0.9612 0.000 1.000
#> GSM213081     1  0.0000     0.9830 1.000 0.000
#> GSM213084     1  0.0000     0.9830 1.000 0.000
#> GSM213087     2  0.0000     0.9612 0.000 1.000
#> GSM213089     1  0.0000     0.9830 1.000 0.000
#> GSM213090     1  0.0000     0.9830 1.000 0.000
#> GSM213093     1  0.0000     0.9830 1.000 0.000
#> GSM213097     1  0.0000     0.9830 1.000 0.000
#> GSM213099     1  0.0000     0.9830 1.000 0.000
#> GSM213101     1  0.0000     0.9830 1.000 0.000
#> GSM213105     2  0.0000     0.9612 0.000 1.000
#> GSM213109     1  0.0000     0.9830 1.000 0.000
#> GSM213110     2  0.0000     0.9612 0.000 1.000
#> GSM213113     1  0.2043     0.9551 0.968 0.032
#> GSM213121     2  0.0000     0.9612 0.000 1.000
#> GSM213123     1  0.0000     0.9830 1.000 0.000
#> GSM213125     2  0.0000     0.9612 0.000 1.000
#> GSM213073     1  0.0000     0.9830 1.000 0.000
#> GSM213086     1  0.0000     0.9830 1.000 0.000
#> GSM213098     1  0.7376     0.7387 0.792 0.208
#> GSM213106     1  0.0000     0.9830 1.000 0.000
#> GSM213124     2  0.9996     0.0329 0.488 0.512

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.4346      0.756 0.816 0.000 0.184
#> GSM213082     2  0.1765      0.943 0.004 0.956 0.040
#> GSM213085     1  0.6079      0.603 0.612 0.000 0.388
#> GSM213088     1  0.9303      0.408 0.500 0.184 0.316
#> GSM213091     3  0.0747      0.744 0.016 0.000 0.984
#> GSM213092     1  0.5968      0.658 0.636 0.000 0.364
#> GSM213096     1  0.2878      0.722 0.904 0.000 0.096
#> GSM213100     1  0.5529      0.721 0.704 0.000 0.296
#> GSM213111     2  0.1751      0.950 0.012 0.960 0.028
#> GSM213117     3  0.4047      0.700 0.148 0.004 0.848
#> GSM213118     1  0.4346      0.752 0.816 0.000 0.184
#> GSM213120     2  0.1182      0.954 0.012 0.976 0.012
#> GSM213122     2  0.0829      0.953 0.004 0.984 0.012
#> GSM213074     3  0.1031      0.746 0.024 0.000 0.976
#> GSM213077     1  0.5327      0.743 0.728 0.000 0.272
#> GSM213083     1  0.5905      0.659 0.648 0.000 0.352
#> GSM213094     3  0.0747      0.740 0.016 0.000 0.984
#> GSM213095     2  0.5764      0.846 0.124 0.800 0.076
#> GSM213102     3  0.5588      0.541 0.276 0.004 0.720
#> GSM213103     2  0.2711      0.926 0.088 0.912 0.000
#> GSM213104     1  0.4589      0.527 0.820 0.172 0.008
#> GSM213107     2  0.4605      0.829 0.204 0.796 0.000
#> GSM213108     3  0.6587      0.132 0.008 0.424 0.568
#> GSM213112     1  0.6154      0.534 0.592 0.000 0.408
#> GSM213114     1  0.1337      0.665 0.972 0.012 0.016
#> GSM213115     2  0.0424      0.954 0.008 0.992 0.000
#> GSM213116     3  0.4235      0.681 0.176 0.000 0.824
#> GSM213119     2  0.0592      0.953 0.000 0.988 0.012
#> GSM213072     3  0.2066      0.744 0.060 0.000 0.940
#> GSM213075     3  0.2384      0.739 0.056 0.008 0.936
#> GSM213076     2  0.2313      0.947 0.032 0.944 0.024
#> GSM213079     3  0.2165      0.733 0.064 0.000 0.936
#> GSM213080     1  0.3192      0.591 0.888 0.112 0.000
#> GSM213081     1  0.4291      0.757 0.820 0.000 0.180
#> GSM213084     1  0.5882      0.675 0.652 0.000 0.348
#> GSM213087     2  0.0892      0.953 0.020 0.980 0.000
#> GSM213089     3  0.1643      0.746 0.044 0.000 0.956
#> GSM213090     3  0.2356      0.724 0.072 0.000 0.928
#> GSM213093     3  0.3192      0.726 0.112 0.000 0.888
#> GSM213097     3  0.5404      0.561 0.256 0.004 0.740
#> GSM213099     3  0.0592      0.742 0.012 0.000 0.988
#> GSM213101     1  0.5285      0.737 0.752 0.004 0.244
#> GSM213105     2  0.0237      0.954 0.004 0.996 0.000
#> GSM213109     3  0.5363      0.496 0.276 0.000 0.724
#> GSM213110     2  0.1643      0.945 0.044 0.956 0.000
#> GSM213113     3  0.5236      0.644 0.168 0.028 0.804
#> GSM213121     2  0.1964      0.941 0.056 0.944 0.000
#> GSM213123     3  0.5678      0.455 0.316 0.000 0.684
#> GSM213125     2  0.0424      0.954 0.000 0.992 0.008
#> GSM213073     3  0.5621      0.468 0.308 0.000 0.692
#> GSM213086     1  0.4887      0.757 0.772 0.000 0.228
#> GSM213098     3  0.7575      0.100 0.456 0.040 0.504
#> GSM213106     3  0.4465      0.681 0.176 0.004 0.820
#> GSM213124     3  0.7841      0.257 0.056 0.408 0.536

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.1674     0.5975 0.952 0.004 0.032 0.012
#> GSM213082     2  0.2635     0.7973 0.000 0.904 0.020 0.076
#> GSM213085     1  0.7283     0.0213 0.432 0.000 0.420 0.148
#> GSM213088     1  0.7538     0.3337 0.604 0.156 0.040 0.200
#> GSM213091     4  0.2089     0.7076 0.020 0.000 0.048 0.932
#> GSM213092     1  0.6951     0.2821 0.544 0.000 0.324 0.132
#> GSM213096     1  0.4018     0.4871 0.772 0.000 0.224 0.004
#> GSM213100     1  0.3143     0.5957 0.876 0.000 0.100 0.024
#> GSM213111     2  0.2256     0.8312 0.000 0.924 0.056 0.020
#> GSM213117     4  0.6049     0.5337 0.264 0.036 0.028 0.672
#> GSM213118     3  0.5696    -0.0613 0.484 0.000 0.492 0.024
#> GSM213120     2  0.3176     0.8202 0.000 0.880 0.084 0.036
#> GSM213122     2  0.1598     0.8364 0.004 0.956 0.020 0.020
#> GSM213074     4  0.1975     0.7112 0.048 0.000 0.016 0.936
#> GSM213077     1  0.3881     0.5464 0.812 0.000 0.172 0.016
#> GSM213083     1  0.2500     0.6044 0.916 0.000 0.044 0.040
#> GSM213094     4  0.3123     0.6502 0.000 0.000 0.156 0.844
#> GSM213095     3  0.5653     0.4564 0.000 0.192 0.712 0.096
#> GSM213102     1  0.5497    -0.0873 0.524 0.000 0.016 0.460
#> GSM213103     2  0.4957     0.5890 0.000 0.684 0.300 0.016
#> GSM213104     3  0.4716     0.4727 0.196 0.040 0.764 0.000
#> GSM213107     3  0.5105    -0.0381 0.004 0.432 0.564 0.000
#> GSM213108     4  0.6896     0.4160 0.020 0.300 0.084 0.596
#> GSM213112     3  0.6364     0.3624 0.204 0.000 0.652 0.144
#> GSM213114     1  0.4999    -0.1089 0.508 0.000 0.492 0.000
#> GSM213115     2  0.0657     0.8436 0.004 0.984 0.012 0.000
#> GSM213116     4  0.4720     0.5604 0.264 0.000 0.016 0.720
#> GSM213119     2  0.1510     0.8355 0.000 0.956 0.016 0.028
#> GSM213072     4  0.3679     0.7096 0.084 0.000 0.060 0.856
#> GSM213075     4  0.5144     0.6724 0.108 0.044 0.052 0.796
#> GSM213076     2  0.4387     0.7205 0.000 0.776 0.200 0.024
#> GSM213079     4  0.4606     0.5532 0.012 0.000 0.264 0.724
#> GSM213080     3  0.5517     0.2042 0.412 0.020 0.568 0.000
#> GSM213081     1  0.3279     0.5900 0.872 0.000 0.096 0.032
#> GSM213084     1  0.3778     0.5948 0.848 0.000 0.100 0.052
#> GSM213087     2  0.1118     0.8381 0.000 0.964 0.036 0.000
#> GSM213089     4  0.2021     0.7096 0.056 0.000 0.012 0.932
#> GSM213090     4  0.5003     0.4954 0.016 0.000 0.308 0.676
#> GSM213093     4  0.4869     0.5864 0.260 0.004 0.016 0.720
#> GSM213097     1  0.5760    -0.0315 0.524 0.000 0.028 0.448
#> GSM213099     4  0.2737     0.6842 0.008 0.000 0.104 0.888
#> GSM213101     1  0.2855     0.5850 0.904 0.004 0.040 0.052
#> GSM213105     2  0.0336     0.8436 0.000 0.992 0.008 0.000
#> GSM213109     1  0.6079     0.0753 0.544 0.000 0.048 0.408
#> GSM213110     2  0.1411     0.8392 0.020 0.960 0.020 0.000
#> GSM213113     4  0.6013     0.4060 0.044 0.004 0.352 0.600
#> GSM213121     2  0.3975     0.6859 0.000 0.760 0.240 0.000
#> GSM213123     4  0.6512     0.3786 0.344 0.004 0.076 0.576
#> GSM213125     2  0.0376     0.8438 0.000 0.992 0.004 0.004
#> GSM213073     3  0.5762     0.1647 0.040 0.000 0.608 0.352
#> GSM213086     1  0.4692     0.4894 0.756 0.000 0.212 0.032
#> GSM213098     3  0.4752     0.5186 0.068 0.008 0.800 0.124
#> GSM213106     4  0.6505     0.2549 0.416 0.024 0.032 0.528
#> GSM213124     2  0.8273    -0.0582 0.156 0.444 0.040 0.360

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.1522    0.64248 0.944 0.000 0.000 0.044 0.012
#> GSM213082     2  0.0451    0.76937 0.000 0.988 0.000 0.008 0.004
#> GSM213085     3  0.4842    0.42678 0.264 0.000 0.684 0.004 0.048
#> GSM213088     1  0.5707   -0.05463 0.524 0.052 0.004 0.412 0.008
#> GSM213091     4  0.2351    0.70374 0.000 0.000 0.088 0.896 0.016
#> GSM213092     3  0.5034    0.34606 0.308 0.000 0.648 0.016 0.028
#> GSM213096     1  0.5377    0.58119 0.700 0.000 0.168 0.016 0.116
#> GSM213100     1  0.5597    0.44820 0.616 0.000 0.312 0.032 0.040
#> GSM213111     2  0.2772    0.73262 0.000 0.892 0.012 0.044 0.052
#> GSM213117     4  0.4225    0.71052 0.124 0.008 0.032 0.808 0.028
#> GSM213118     5  0.5313    0.56702 0.200 0.000 0.032 0.064 0.704
#> GSM213120     2  0.6571    0.17691 0.000 0.456 0.012 0.388 0.144
#> GSM213122     2  0.0324    0.76915 0.004 0.992 0.000 0.004 0.000
#> GSM213074     4  0.5798    0.41373 0.032 0.000 0.404 0.528 0.036
#> GSM213077     1  0.4678    0.53611 0.712 0.000 0.224 0.000 0.064
#> GSM213083     1  0.2929    0.62936 0.840 0.000 0.152 0.000 0.008
#> GSM213094     4  0.4902    0.34413 0.000 0.000 0.408 0.564 0.028
#> GSM213095     3  0.5200    0.46871 0.004 0.052 0.668 0.008 0.268
#> GSM213102     4  0.4594    0.49956 0.364 0.000 0.012 0.620 0.004
#> GSM213103     5  0.6223   -0.01744 0.004 0.420 0.040 0.044 0.492
#> GSM213104     5  0.2995    0.60166 0.088 0.008 0.032 0.000 0.872
#> GSM213107     5  0.2890    0.56714 0.000 0.160 0.004 0.000 0.836
#> GSM213108     2  0.6633    0.40146 0.000 0.552 0.252 0.172 0.024
#> GSM213112     3  0.4359    0.55693 0.128 0.000 0.776 0.004 0.092
#> GSM213114     5  0.4494    0.39828 0.380 0.000 0.012 0.000 0.608
#> GSM213115     2  0.0324    0.76876 0.004 0.992 0.000 0.000 0.004
#> GSM213116     4  0.3635    0.72416 0.108 0.000 0.040 0.836 0.016
#> GSM213119     2  0.0740    0.76799 0.008 0.980 0.000 0.008 0.004
#> GSM213072     4  0.5997    0.48281 0.044 0.000 0.348 0.564 0.044
#> GSM213075     4  0.4266    0.70641 0.044 0.008 0.080 0.820 0.048
#> GSM213076     2  0.6370    0.29718 0.000 0.548 0.028 0.100 0.324
#> GSM213079     3  0.4593    0.52180 0.000 0.000 0.736 0.184 0.080
#> GSM213080     5  0.3730    0.55484 0.288 0.000 0.000 0.000 0.712
#> GSM213081     1  0.4748    0.52787 0.728 0.000 0.000 0.172 0.100
#> GSM213084     1  0.4420    0.51004 0.692 0.000 0.280 0.000 0.028
#> GSM213087     2  0.1282    0.75368 0.000 0.952 0.004 0.000 0.044
#> GSM213089     4  0.2748    0.71541 0.016 0.000 0.096 0.880 0.008
#> GSM213090     3  0.3334    0.60050 0.004 0.000 0.852 0.064 0.080
#> GSM213093     4  0.3739    0.71481 0.136 0.000 0.024 0.820 0.020
#> GSM213097     4  0.4275    0.60067 0.288 0.000 0.008 0.696 0.008
#> GSM213099     4  0.3323    0.68520 0.004 0.000 0.116 0.844 0.036
#> GSM213101     1  0.2054    0.63742 0.916 0.004 0.008 0.072 0.000
#> GSM213105     2  0.0324    0.76923 0.004 0.992 0.004 0.000 0.000
#> GSM213109     3  0.6115    0.00633 0.416 0.000 0.496 0.056 0.032
#> GSM213110     2  0.0865    0.76348 0.024 0.972 0.004 0.000 0.000
#> GSM213113     4  0.6507    0.29188 0.012 0.000 0.144 0.496 0.348
#> GSM213121     2  0.4403    0.19529 0.000 0.560 0.004 0.000 0.436
#> GSM213123     4  0.4620    0.66798 0.200 0.000 0.012 0.740 0.048
#> GSM213125     2  0.0451    0.76922 0.000 0.988 0.004 0.000 0.008
#> GSM213073     3  0.6041    0.33513 0.008 0.000 0.544 0.104 0.344
#> GSM213086     1  0.5380    0.57910 0.712 0.000 0.128 0.024 0.136
#> GSM213098     5  0.4735    0.41168 0.012 0.000 0.020 0.300 0.668
#> GSM213106     4  0.3764    0.67545 0.212 0.000 0.008 0.772 0.008
#> GSM213124     2  0.8115    0.24299 0.060 0.460 0.216 0.232 0.032

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.3336     0.5215 0.832 0.004 0.000 0.116 0.012 0.036
#> GSM213082     2  0.0964     0.8367 0.000 0.968 0.016 0.012 0.000 0.004
#> GSM213085     3  0.6734     0.2597 0.260 0.000 0.448 0.004 0.040 0.248
#> GSM213088     4  0.5323     0.1541 0.424 0.016 0.000 0.496 0.000 0.064
#> GSM213091     4  0.4893     0.3524 0.004 0.000 0.096 0.680 0.008 0.212
#> GSM213092     3  0.6413     0.2316 0.308 0.000 0.468 0.004 0.024 0.196
#> GSM213096     1  0.5971     0.4330 0.588 0.000 0.072 0.004 0.076 0.260
#> GSM213100     1  0.5789     0.3759 0.568 0.000 0.204 0.004 0.008 0.216
#> GSM213111     2  0.4435     0.7153 0.000 0.788 0.028 0.040 0.080 0.064
#> GSM213117     4  0.4260     0.2468 0.024 0.004 0.000 0.640 0.000 0.332
#> GSM213118     5  0.5759     0.5038 0.112 0.000 0.004 0.048 0.628 0.208
#> GSM213120     4  0.7171     0.1024 0.000 0.304 0.032 0.440 0.176 0.048
#> GSM213122     2  0.0146     0.8413 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM213074     6  0.4800     0.5155 0.012 0.000 0.104 0.192 0.000 0.692
#> GSM213077     1  0.4663     0.4309 0.692 0.000 0.244 0.008 0.020 0.036
#> GSM213083     1  0.2686     0.5500 0.868 0.000 0.100 0.024 0.000 0.008
#> GSM213094     4  0.6309    -0.0887 0.000 0.000 0.284 0.372 0.008 0.336
#> GSM213095     3  0.4773     0.5306 0.040 0.060 0.764 0.004 0.108 0.024
#> GSM213102     4  0.5505     0.3427 0.240 0.004 0.000 0.580 0.000 0.176
#> GSM213103     5  0.6890     0.3464 0.028 0.140 0.028 0.012 0.500 0.292
#> GSM213104     5  0.2639     0.6240 0.064 0.000 0.048 0.000 0.880 0.008
#> GSM213107     5  0.2339     0.6327 0.000 0.072 0.020 0.012 0.896 0.000
#> GSM213108     2  0.7076     0.1897 0.004 0.500 0.160 0.100 0.008 0.228
#> GSM213112     3  0.6244     0.4193 0.180 0.000 0.564 0.008 0.036 0.212
#> GSM213114     5  0.3976     0.3613 0.380 0.000 0.000 0.004 0.612 0.004
#> GSM213115     2  0.0993     0.8372 0.000 0.964 0.000 0.000 0.012 0.024
#> GSM213116     4  0.5059     0.1400 0.036 0.000 0.012 0.552 0.008 0.392
#> GSM213119     2  0.0405     0.8416 0.008 0.988 0.000 0.000 0.000 0.004
#> GSM213072     6  0.5390     0.4536 0.052 0.000 0.080 0.216 0.000 0.652
#> GSM213075     4  0.6309     0.0692 0.040 0.000 0.136 0.424 0.000 0.400
#> GSM213076     2  0.7995    -0.0828 0.004 0.372 0.140 0.168 0.284 0.032
#> GSM213079     3  0.3870     0.4790 0.008 0.000 0.808 0.060 0.020 0.104
#> GSM213080     5  0.3459     0.5832 0.212 0.000 0.000 0.016 0.768 0.004
#> GSM213081     1  0.6975     0.0844 0.476 0.000 0.032 0.320 0.080 0.092
#> GSM213084     1  0.4142     0.4476 0.704 0.000 0.264 0.008 0.008 0.016
#> GSM213087     2  0.1471     0.8126 0.000 0.932 0.000 0.000 0.064 0.004
#> GSM213089     4  0.4440     0.3336 0.004 0.000 0.032 0.672 0.008 0.284
#> GSM213090     3  0.1710     0.5630 0.012 0.000 0.940 0.020 0.008 0.020
#> GSM213093     4  0.5235     0.4358 0.124 0.000 0.044 0.696 0.004 0.132
#> GSM213097     4  0.4556     0.4209 0.232 0.004 0.004 0.700 0.004 0.056
#> GSM213099     4  0.4747     0.3557 0.000 0.000 0.108 0.692 0.008 0.192
#> GSM213101     1  0.3208     0.5409 0.832 0.000 0.000 0.120 0.008 0.040
#> GSM213105     2  0.0405     0.8415 0.004 0.988 0.000 0.000 0.000 0.008
#> GSM213109     1  0.6925    -0.0617 0.348 0.000 0.304 0.032 0.008 0.308
#> GSM213110     2  0.1074     0.8296 0.012 0.960 0.000 0.000 0.000 0.028
#> GSM213113     4  0.7213     0.1694 0.008 0.000 0.180 0.432 0.284 0.096
#> GSM213121     5  0.4234     0.2570 0.000 0.388 0.004 0.008 0.596 0.004
#> GSM213123     4  0.4755     0.4434 0.100 0.000 0.012 0.756 0.056 0.076
#> GSM213125     2  0.0405     0.8407 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM213073     3  0.5340     0.4053 0.004 0.000 0.684 0.072 0.172 0.068
#> GSM213086     1  0.6625     0.3932 0.564 0.000 0.068 0.032 0.100 0.236
#> GSM213098     5  0.4106     0.5096 0.000 0.000 0.024 0.216 0.736 0.024
#> GSM213106     4  0.4154     0.4416 0.164 0.000 0.000 0.740 0.000 0.096
#> GSM213124     6  0.6009     0.4285 0.028 0.252 0.040 0.076 0.000 0.604

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

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

test_to_known_factors(res)
#>          n development.stage(p) disease.state(p) k
#> MAD:NMF 53                0.565            0.977 2
#> MAD:NMF 47                0.187            0.930 3
#> MAD:NMF 32                0.727            0.436 4
#> MAD:NMF 34                0.568            0.783 5
#> MAD:NMF 20                0.927            0.454 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.693           0.897       0.938         0.3084 0.648   0.648
#> 3 3 0.795           0.826       0.932         0.3540 0.913   0.868
#> 4 4 0.588           0.685       0.842         0.2690 0.948   0.911
#> 5 5 0.535           0.609       0.741         0.0965 0.857   0.742
#> 6 6 0.520           0.588       0.706         0.1239 0.723   0.438

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
#> GSM213078     1  0.0000      0.970 1.000 0.000
#> GSM213082     2  0.8713      0.808 0.292 0.708
#> GSM213085     1  0.0000      0.970 1.000 0.000
#> GSM213088     1  0.0000      0.970 1.000 0.000
#> GSM213091     2  0.9552      0.692 0.376 0.624
#> GSM213092     1  0.0000      0.970 1.000 0.000
#> GSM213096     1  0.0000      0.970 1.000 0.000
#> GSM213100     1  0.0000      0.970 1.000 0.000
#> GSM213111     2  0.8713      0.808 0.292 0.708
#> GSM213117     1  0.0000      0.970 1.000 0.000
#> GSM213118     1  0.0000      0.970 1.000 0.000
#> GSM213120     1  0.0376      0.966 0.996 0.004
#> GSM213122     1  0.0000      0.970 1.000 0.000
#> GSM213074     1  0.0000      0.970 1.000 0.000
#> GSM213077     1  0.0000      0.970 1.000 0.000
#> GSM213083     1  0.0000      0.970 1.000 0.000
#> GSM213094     2  0.4815      0.804 0.104 0.896
#> GSM213095     2  0.0000      0.762 0.000 1.000
#> GSM213102     1  0.0000      0.970 1.000 0.000
#> GSM213103     1  0.0000      0.970 1.000 0.000
#> GSM213104     1  0.0000      0.970 1.000 0.000
#> GSM213107     1  0.9000      0.377 0.684 0.316
#> GSM213108     2  0.8713      0.808 0.292 0.708
#> GSM213112     1  0.0000      0.970 1.000 0.000
#> GSM213114     1  0.0000      0.970 1.000 0.000
#> GSM213115     1  0.0000      0.970 1.000 0.000
#> GSM213116     1  0.0000      0.970 1.000 0.000
#> GSM213119     1  0.0000      0.970 1.000 0.000
#> GSM213072     2  0.9427      0.720 0.360 0.640
#> GSM213075     1  0.0000      0.970 1.000 0.000
#> GSM213076     1  0.7883      0.592 0.764 0.236
#> GSM213079     2  0.0000      0.762 0.000 1.000
#> GSM213080     1  0.0000      0.970 1.000 0.000
#> GSM213081     1  0.0000      0.970 1.000 0.000
#> GSM213084     1  0.0000      0.970 1.000 0.000
#> GSM213087     1  0.0000      0.970 1.000 0.000
#> GSM213089     1  0.0000      0.970 1.000 0.000
#> GSM213090     2  0.4815      0.804 0.104 0.896
#> GSM213093     1  0.0000      0.970 1.000 0.000
#> GSM213097     1  0.0000      0.970 1.000 0.000
#> GSM213099     2  0.8763      0.802 0.296 0.704
#> GSM213101     1  0.0000      0.970 1.000 0.000
#> GSM213105     1  0.0000      0.970 1.000 0.000
#> GSM213109     1  0.0000      0.970 1.000 0.000
#> GSM213110     1  0.0000      0.970 1.000 0.000
#> GSM213113     1  0.1843      0.941 0.972 0.028
#> GSM213121     1  0.9000      0.377 0.684 0.316
#> GSM213123     1  0.1843      0.941 0.972 0.028
#> GSM213125     2  0.8713      0.808 0.292 0.708
#> GSM213073     2  0.0000      0.762 0.000 1.000
#> GSM213086     1  0.0000      0.970 1.000 0.000
#> GSM213098     1  0.1843      0.941 0.972 0.028
#> GSM213106     1  0.0000      0.970 1.000 0.000
#> GSM213124     1  0.0000      0.970 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
#> GSM213078     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213082     2  0.0000      0.659 0.000 1.000 0.000
#> GSM213085     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213088     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213091     2  0.3112      0.615 0.096 0.900 0.004
#> GSM213092     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213096     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213100     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213111     2  0.0000      0.659 0.000 1.000 0.000
#> GSM213117     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213118     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213120     1  0.1289      0.950 0.968 0.032 0.000
#> GSM213122     1  0.0592      0.952 0.988 0.012 0.000
#> GSM213074     1  0.1163      0.950 0.972 0.028 0.000
#> GSM213077     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213083     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213094     2  0.5706      0.179 0.000 0.680 0.320
#> GSM213095     3  0.5760      0.513 0.000 0.328 0.672
#> GSM213102     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213103     1  0.0237      0.955 0.996 0.004 0.000
#> GSM213104     1  0.0892      0.951 0.980 0.020 0.000
#> GSM213107     2  0.6095      0.324 0.392 0.608 0.000
#> GSM213108     2  0.0000      0.659 0.000 1.000 0.000
#> GSM213112     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213114     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213115     1  0.0592      0.952 0.988 0.012 0.000
#> GSM213116     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213119     1  0.0592      0.952 0.988 0.012 0.000
#> GSM213072     2  0.2772      0.630 0.080 0.916 0.004
#> GSM213075     1  0.0237      0.955 0.996 0.004 0.000
#> GSM213076     1  0.6008      0.400 0.628 0.372 0.000
#> GSM213079     3  0.0000      0.818 0.000 0.000 1.000
#> GSM213080     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213081     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213084     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213087     1  0.0592      0.952 0.988 0.012 0.000
#> GSM213089     1  0.1163      0.950 0.972 0.028 0.000
#> GSM213090     2  0.6235     -0.114 0.000 0.564 0.436
#> GSM213093     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213097     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213099     2  0.1620      0.656 0.024 0.964 0.012
#> GSM213101     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213105     1  0.0592      0.952 0.988 0.012 0.000
#> GSM213109     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213110     1  0.0424      0.953 0.992 0.008 0.000
#> GSM213113     1  0.3116      0.903 0.892 0.108 0.000
#> GSM213121     2  0.6095      0.324 0.392 0.608 0.000
#> GSM213123     1  0.3116      0.903 0.892 0.108 0.000
#> GSM213125     2  0.0000      0.659 0.000 1.000 0.000
#> GSM213073     3  0.0000      0.818 0.000 0.000 1.000
#> GSM213086     1  0.2448      0.930 0.924 0.076 0.000
#> GSM213098     1  0.3116      0.903 0.892 0.108 0.000
#> GSM213106     1  0.0000      0.955 1.000 0.000 0.000
#> GSM213124     1  0.1163      0.950 0.972 0.028 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213082     2  0.4877      0.312 0.000 0.592 0.000 0.408
#> GSM213085     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213088     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213091     4  0.5664      0.514 0.076 0.228 0.000 0.696
#> GSM213092     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213096     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213100     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213111     2  0.4877      0.312 0.000 0.592 0.000 0.408
#> GSM213117     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213118     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213120     1  0.2174      0.857 0.928 0.020 0.000 0.052
#> GSM213122     1  0.4866      0.433 0.596 0.404 0.000 0.000
#> GSM213074     1  0.2060      0.857 0.932 0.016 0.000 0.052
#> GSM213077     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213083     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213094     4  0.3528      0.451 0.000 0.000 0.192 0.808
#> GSM213095     3  0.5549      0.355 0.000 0.048 0.672 0.280
#> GSM213102     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213103     1  0.4543      0.556 0.676 0.324 0.000 0.000
#> GSM213104     1  0.3975      0.666 0.760 0.240 0.000 0.000
#> GSM213107     2  0.0000      0.393 0.000 1.000 0.000 0.000
#> GSM213108     2  0.4888      0.303 0.000 0.588 0.000 0.412
#> GSM213112     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213114     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213115     1  0.4866      0.433 0.596 0.404 0.000 0.000
#> GSM213116     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213119     1  0.4866      0.433 0.596 0.404 0.000 0.000
#> GSM213072     4  0.5559      0.526 0.064 0.240 0.000 0.696
#> GSM213075     1  0.0817      0.862 0.976 0.000 0.000 0.024
#> GSM213076     2  0.4193      0.168 0.268 0.732 0.000 0.000
#> GSM213079     3  0.0000      0.780 0.000 0.000 1.000 0.000
#> GSM213080     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213081     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213084     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213087     1  0.4866      0.433 0.596 0.404 0.000 0.000
#> GSM213089     1  0.2060      0.857 0.932 0.016 0.000 0.052
#> GSM213090     4  0.3975      0.261 0.000 0.000 0.240 0.760
#> GSM213093     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213097     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213099     4  0.4228      0.528 0.008 0.232 0.000 0.760
#> GSM213101     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213105     1  0.4866      0.433 0.596 0.404 0.000 0.000
#> GSM213109     1  0.0592      0.863 0.984 0.000 0.000 0.016
#> GSM213110     1  0.1767      0.845 0.944 0.044 0.000 0.012
#> GSM213113     1  0.4022      0.817 0.836 0.068 0.000 0.096
#> GSM213121     2  0.0000      0.393 0.000 1.000 0.000 0.000
#> GSM213123     1  0.4022      0.817 0.836 0.068 0.000 0.096
#> GSM213125     2  0.4877      0.312 0.000 0.592 0.000 0.408
#> GSM213073     3  0.0000      0.780 0.000 0.000 1.000 0.000
#> GSM213086     1  0.3399      0.839 0.868 0.040 0.000 0.092
#> GSM213098     1  0.4022      0.817 0.836 0.068 0.000 0.096
#> GSM213106     1  0.0469      0.863 0.988 0.000 0.000 0.012
#> GSM213124     1  0.2844      0.854 0.900 0.048 0.000 0.052

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213082     5  0.6775      0.708 0.000 0.280 0.000 0.336 0.384
#> GSM213085     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213088     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213091     4  0.2179      0.741 0.100 0.004 0.000 0.896 0.000
#> GSM213092     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213096     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213100     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213111     5  0.6775      0.708 0.000 0.280 0.000 0.336 0.384
#> GSM213117     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213118     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213120     1  0.0324      0.744 0.992 0.004 0.000 0.004 0.000
#> GSM213122     2  0.4262      0.536 0.440 0.560 0.000 0.000 0.000
#> GSM213074     1  0.0000      0.745 1.000 0.000 0.000 0.000 0.000
#> GSM213077     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213083     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213094     4  0.5002      0.489 0.000 0.000 0.132 0.708 0.160
#> GSM213095     3  0.4818      0.561 0.000 0.040 0.672 0.004 0.284
#> GSM213102     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213103     1  0.4302     -0.334 0.520 0.480 0.000 0.000 0.000
#> GSM213104     1  0.4392      0.113 0.612 0.380 0.000 0.000 0.008
#> GSM213107     2  0.4266     -0.290 0.000 0.776 0.000 0.120 0.104
#> GSM213108     5  0.6770      0.704 0.000 0.276 0.000 0.340 0.384
#> GSM213112     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213114     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213115     2  0.4262      0.536 0.440 0.560 0.000 0.000 0.000
#> GSM213116     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213119     2  0.4262      0.536 0.440 0.560 0.000 0.000 0.000
#> GSM213072     4  0.2011      0.752 0.088 0.004 0.000 0.908 0.000
#> GSM213075     1  0.2179      0.738 0.888 0.112 0.000 0.000 0.000
#> GSM213076     2  0.6874      0.330 0.268 0.556 0.000 0.096 0.080
#> GSM213079     3  0.0000      0.819 0.000 0.000 1.000 0.000 0.000
#> GSM213080     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213081     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213084     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213087     2  0.4262      0.536 0.440 0.560 0.000 0.000 0.000
#> GSM213089     1  0.0000      0.745 1.000 0.000 0.000 0.000 0.000
#> GSM213090     5  0.4288     -0.420 0.000 0.000 0.004 0.384 0.612
#> GSM213093     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213097     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213099     4  0.0865      0.726 0.024 0.004 0.000 0.972 0.000
#> GSM213101     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213105     2  0.4262      0.536 0.440 0.560 0.000 0.000 0.000
#> GSM213109     1  0.3274      0.738 0.780 0.220 0.000 0.000 0.000
#> GSM213110     1  0.3242      0.693 0.784 0.216 0.000 0.000 0.000
#> GSM213113     1  0.2179      0.697 0.896 0.004 0.000 0.100 0.000
#> GSM213121     2  0.4266     -0.290 0.000 0.776 0.000 0.120 0.104
#> GSM213123     1  0.2179      0.697 0.896 0.004 0.000 0.100 0.000
#> GSM213125     5  0.6775      0.708 0.000 0.280 0.000 0.336 0.384
#> GSM213073     3  0.0000      0.819 0.000 0.000 1.000 0.000 0.000
#> GSM213086     1  0.1608      0.729 0.928 0.000 0.000 0.072 0.000
#> GSM213098     1  0.2179      0.697 0.896 0.004 0.000 0.100 0.000
#> GSM213106     1  0.3305      0.737 0.776 0.224 0.000 0.000 0.000
#> GSM213124     1  0.0880      0.729 0.968 0.032 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
#> GSM213078     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213082     6  0.5850      0.706 0.000 0.000 0.000 0.200 0.348 0.452
#> GSM213085     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213088     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213091     4  0.3309      0.783 0.172 0.000 0.000 0.800 0.024 0.004
#> GSM213092     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213096     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213100     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213111     6  0.5850      0.706 0.000 0.000 0.000 0.200 0.348 0.452
#> GSM213117     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213118     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213120     1  0.2595      0.663 0.836 0.160 0.000 0.000 0.000 0.004
#> GSM213122     2  0.2750      0.313 0.136 0.844 0.000 0.000 0.020 0.000
#> GSM213074     1  0.2527      0.647 0.832 0.168 0.000 0.000 0.000 0.000
#> GSM213077     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213083     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213094     4  0.3860      0.516 0.000 0.024 0.096 0.808 0.004 0.068
#> GSM213095     3  0.3531      0.538 0.000 0.000 0.672 0.000 0.000 0.328
#> GSM213102     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213103     2  0.3073      0.446 0.204 0.788 0.000 0.000 0.008 0.000
#> GSM213104     2  0.4199      0.256 0.416 0.568 0.000 0.000 0.016 0.000
#> GSM213107     5  0.3810      1.000 0.000 0.428 0.000 0.000 0.572 0.000
#> GSM213108     6  0.5868      0.703 0.000 0.000 0.000 0.204 0.348 0.448
#> GSM213112     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213114     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213115     2  0.2750      0.313 0.136 0.844 0.000 0.000 0.020 0.000
#> GSM213116     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213119     2  0.2750      0.313 0.136 0.844 0.000 0.000 0.020 0.000
#> GSM213072     4  0.3025      0.794 0.156 0.000 0.000 0.820 0.024 0.000
#> GSM213075     1  0.3446      0.210 0.692 0.308 0.000 0.000 0.000 0.000
#> GSM213076     2  0.5976     -0.641 0.228 0.408 0.000 0.000 0.364 0.000
#> GSM213079     3  0.0000      0.815 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213081     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213084     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213087     2  0.2750      0.313 0.136 0.844 0.000 0.000 0.020 0.000
#> GSM213089     1  0.2527      0.647 0.832 0.168 0.000 0.000 0.000 0.000
#> GSM213090     6  0.4829     -0.215 0.000 0.000 0.000 0.056 0.424 0.520
#> GSM213093     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213097     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213099     4  0.2333      0.773 0.092 0.000 0.000 0.884 0.024 0.000
#> GSM213101     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213105     2  0.2750      0.313 0.136 0.844 0.000 0.000 0.020 0.000
#> GSM213109     1  0.4277     -0.124 0.616 0.356 0.000 0.000 0.000 0.028
#> GSM213110     2  0.4262      0.474 0.476 0.508 0.000 0.000 0.016 0.000
#> GSM213113     1  0.0858      0.803 0.968 0.000 0.000 0.028 0.000 0.004
#> GSM213121     5  0.3810      1.000 0.000 0.428 0.000 0.000 0.572 0.000
#> GSM213123     1  0.0858      0.803 0.968 0.000 0.000 0.028 0.000 0.004
#> GSM213125     6  0.5850      0.706 0.000 0.000 0.000 0.200 0.348 0.452
#> GSM213073     3  0.0000      0.815 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213086     1  0.0000      0.835 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213098     1  0.0858      0.803 0.968 0.000 0.000 0.028 0.000 0.004
#> GSM213106     2  0.4460      0.595 0.452 0.520 0.000 0.000 0.000 0.028
#> GSM213124     1  0.3672      0.284 0.688 0.304 0.000 0.000 0.008 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 development.stage(p) disease.state(p) k
#> ATC:hclust 52                1.000            1.000 2
#> ATC:hclust 49                0.769            0.256 3
#> ATC:hclust 39                0.297            0.380 4
#> ATC:hclust 47                0.764            0.525 5
#> ATC:hclust 41                0.912            0.866 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 51941 rows and 54 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.891           0.981       0.989         0.4447 0.547   0.547
#> 3 3 0.447           0.646       0.816         0.3428 0.704   0.525
#> 4 4 0.736           0.784       0.881         0.2037 0.764   0.477
#> 5 5 0.736           0.777       0.866         0.0786 0.909   0.688
#> 6 6 0.769           0.618       0.792         0.0448 0.928   0.699

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
#> GSM213078     1   0.000      1.000 1.000 0.000
#> GSM213082     2   0.000      0.966 0.000 1.000
#> GSM213085     1   0.000      1.000 1.000 0.000
#> GSM213088     1   0.000      1.000 1.000 0.000
#> GSM213091     2   0.574      0.868 0.136 0.864
#> GSM213092     1   0.000      1.000 1.000 0.000
#> GSM213096     1   0.000      1.000 1.000 0.000
#> GSM213100     1   0.000      1.000 1.000 0.000
#> GSM213111     2   0.000      0.966 0.000 1.000
#> GSM213117     1   0.000      1.000 1.000 0.000
#> GSM213118     1   0.000      1.000 1.000 0.000
#> GSM213120     1   0.000      1.000 1.000 0.000
#> GSM213122     1   0.000      1.000 1.000 0.000
#> GSM213074     1   0.000      1.000 1.000 0.000
#> GSM213077     1   0.000      1.000 1.000 0.000
#> GSM213083     1   0.000      1.000 1.000 0.000
#> GSM213094     2   0.000      0.966 0.000 1.000
#> GSM213095     2   0.000      0.966 0.000 1.000
#> GSM213102     1   0.000      1.000 1.000 0.000
#> GSM213103     1   0.000      1.000 1.000 0.000
#> GSM213104     1   0.000      1.000 1.000 0.000
#> GSM213107     2   0.000      0.966 0.000 1.000
#> GSM213108     2   0.000      0.966 0.000 1.000
#> GSM213112     1   0.000      1.000 1.000 0.000
#> GSM213114     1   0.000      1.000 1.000 0.000
#> GSM213115     1   0.000      1.000 1.000 0.000
#> GSM213116     1   0.000      1.000 1.000 0.000
#> GSM213119     1   0.000      1.000 1.000 0.000
#> GSM213072     2   0.000      0.966 0.000 1.000
#> GSM213075     1   0.000      1.000 1.000 0.000
#> GSM213076     2   0.000      0.966 0.000 1.000
#> GSM213079     2   0.000      0.966 0.000 1.000
#> GSM213080     1   0.000      1.000 1.000 0.000
#> GSM213081     1   0.000      1.000 1.000 0.000
#> GSM213084     1   0.000      1.000 1.000 0.000
#> GSM213087     1   0.000      1.000 1.000 0.000
#> GSM213089     1   0.000      1.000 1.000 0.000
#> GSM213090     2   0.000      0.966 0.000 1.000
#> GSM213093     1   0.000      1.000 1.000 0.000
#> GSM213097     1   0.000      1.000 1.000 0.000
#> GSM213099     2   0.000      0.966 0.000 1.000
#> GSM213101     1   0.000      1.000 1.000 0.000
#> GSM213105     1   0.000      1.000 1.000 0.000
#> GSM213109     1   0.000      1.000 1.000 0.000
#> GSM213110     1   0.000      1.000 1.000 0.000
#> GSM213113     2   0.574      0.868 0.136 0.864
#> GSM213121     2   0.000      0.966 0.000 1.000
#> GSM213123     2   0.644      0.835 0.164 0.836
#> GSM213125     2   0.000      0.966 0.000 1.000
#> GSM213073     2   0.000      0.966 0.000 1.000
#> GSM213086     1   0.000      1.000 1.000 0.000
#> GSM213098     2   0.574      0.868 0.136 0.864
#> GSM213106     1   0.000      1.000 1.000 0.000
#> GSM213124     1   0.000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213082     2  0.5363      0.496 0.000 0.724 0.276
#> GSM213085     1  0.6126      0.428 0.600 0.400 0.000
#> GSM213088     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213091     2  0.8265      0.527 0.184 0.636 0.180
#> GSM213092     1  0.6140      0.422 0.596 0.404 0.000
#> GSM213096     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213100     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213111     2  0.5363      0.496 0.000 0.724 0.276
#> GSM213117     1  0.2878      0.777 0.904 0.096 0.000
#> GSM213118     1  0.6154      0.413 0.592 0.408 0.000
#> GSM213120     2  0.0000      0.603 0.000 1.000 0.000
#> GSM213122     2  0.5560      0.533 0.300 0.700 0.000
#> GSM213074     1  0.6180      0.395 0.584 0.416 0.000
#> GSM213077     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213083     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213094     3  0.0000      0.974 0.000 0.000 1.000
#> GSM213095     3  0.0000      0.974 0.000 0.000 1.000
#> GSM213102     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213103     2  0.5810      0.491 0.336 0.664 0.000
#> GSM213104     1  0.6045      0.250 0.620 0.380 0.000
#> GSM213107     2  0.2878      0.583 0.000 0.904 0.096
#> GSM213108     3  0.3116      0.857 0.000 0.108 0.892
#> GSM213112     1  0.6140      0.422 0.596 0.404 0.000
#> GSM213114     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213115     2  0.5810      0.491 0.336 0.664 0.000
#> GSM213116     1  0.3482      0.751 0.872 0.128 0.000
#> GSM213119     2  0.5760      0.503 0.328 0.672 0.000
#> GSM213072     2  0.8263      0.524 0.176 0.636 0.188
#> GSM213075     1  0.6008      0.258 0.628 0.372 0.000
#> GSM213076     2  0.2796      0.584 0.000 0.908 0.092
#> GSM213079     3  0.0000      0.974 0.000 0.000 1.000
#> GSM213080     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213081     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213084     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213087     2  0.5760      0.503 0.328 0.672 0.000
#> GSM213089     2  0.4931      0.500 0.232 0.768 0.000
#> GSM213090     3  0.0000      0.974 0.000 0.000 1.000
#> GSM213093     1  0.1411      0.810 0.964 0.036 0.000
#> GSM213097     1  0.1411      0.810 0.964 0.036 0.000
#> GSM213099     2  0.6274      0.115 0.000 0.544 0.456
#> GSM213101     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213105     2  0.5760      0.503 0.328 0.672 0.000
#> GSM213109     1  0.1289      0.812 0.968 0.032 0.000
#> GSM213110     1  0.0892      0.808 0.980 0.020 0.000
#> GSM213113     2  0.8265      0.527 0.184 0.636 0.180
#> GSM213121     2  0.2878      0.583 0.000 0.904 0.096
#> GSM213123     2  0.8265      0.527 0.184 0.636 0.180
#> GSM213125     2  0.5363      0.496 0.000 0.724 0.276
#> GSM213073     3  0.0000      0.974 0.000 0.000 1.000
#> GSM213086     1  0.6140      0.422 0.596 0.404 0.000
#> GSM213098     2  0.8265      0.527 0.184 0.636 0.180
#> GSM213106     1  0.0000      0.822 1.000 0.000 0.000
#> GSM213124     2  0.5216      0.564 0.260 0.740 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213082     2  0.4941     0.4939 0.000 0.564 0.000 0.436
#> GSM213085     4  0.4874     0.8100 0.180 0.056 0.000 0.764
#> GSM213088     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213091     4  0.0376     0.7720 0.004 0.004 0.000 0.992
#> GSM213092     4  0.4874     0.8100 0.180 0.056 0.000 0.764
#> GSM213096     1  0.0921     0.9354 0.972 0.028 0.000 0.000
#> GSM213100     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213111     2  0.4941     0.4939 0.000 0.564 0.000 0.436
#> GSM213117     4  0.6014     0.5555 0.360 0.052 0.000 0.588
#> GSM213118     4  0.4874     0.8100 0.180 0.056 0.000 0.764
#> GSM213120     2  0.4977     0.4056 0.000 0.540 0.000 0.460
#> GSM213122     2  0.1888     0.7471 0.044 0.940 0.000 0.016
#> GSM213074     4  0.4907     0.8088 0.176 0.060 0.000 0.764
#> GSM213077     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213083     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213094     3  0.0336     0.9425 0.000 0.008 0.992 0.000
#> GSM213095     3  0.0000     0.9432 0.000 0.000 1.000 0.000
#> GSM213102     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213103     2  0.1807     0.7485 0.052 0.940 0.000 0.008
#> GSM213104     2  0.5378     0.0504 0.448 0.540 0.000 0.012
#> GSM213107     2  0.1940     0.7160 0.000 0.924 0.000 0.076
#> GSM213108     3  0.5292     0.6864 0.000 0.060 0.724 0.216
#> GSM213112     4  0.4874     0.8100 0.180 0.056 0.000 0.764
#> GSM213114     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213115     2  0.1807     0.7485 0.052 0.940 0.000 0.008
#> GSM213116     4  0.5434     0.7410 0.252 0.052 0.000 0.696
#> GSM213119     2  0.1807     0.7485 0.052 0.940 0.000 0.008
#> GSM213072     4  0.1004     0.7589 0.004 0.024 0.000 0.972
#> GSM213075     1  0.5842     0.1228 0.520 0.448 0.000 0.032
#> GSM213076     2  0.4679     0.5891 0.000 0.648 0.000 0.352
#> GSM213079     3  0.0000     0.9432 0.000 0.000 1.000 0.000
#> GSM213080     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213081     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213084     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213087     2  0.1807     0.7485 0.052 0.940 0.000 0.008
#> GSM213089     4  0.1824     0.7717 0.004 0.060 0.000 0.936
#> GSM213090     3  0.0336     0.9425 0.000 0.008 0.992 0.000
#> GSM213093     1  0.2411     0.8852 0.920 0.040 0.000 0.040
#> GSM213097     1  0.0524     0.9491 0.988 0.004 0.000 0.008
#> GSM213099     4  0.1489     0.7448 0.000 0.044 0.004 0.952
#> GSM213101     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213105     2  0.1807     0.7485 0.052 0.940 0.000 0.008
#> GSM213109     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213110     1  0.1637     0.9114 0.940 0.060 0.000 0.000
#> GSM213113     4  0.0524     0.7703 0.004 0.008 0.000 0.988
#> GSM213121     2  0.1940     0.7160 0.000 0.924 0.000 0.076
#> GSM213123     4  0.0188     0.7731 0.004 0.000 0.000 0.996
#> GSM213125     2  0.4941     0.4939 0.000 0.564 0.000 0.436
#> GSM213073     3  0.0000     0.9432 0.000 0.000 1.000 0.000
#> GSM213086     4  0.4874     0.8100 0.180 0.056 0.000 0.764
#> GSM213098     4  0.0524     0.7703 0.004 0.008 0.000 0.988
#> GSM213106     1  0.0000     0.9576 1.000 0.000 0.000 0.000
#> GSM213124     2  0.1913     0.7404 0.020 0.940 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0000     0.9183 1.000 0.000 0.000 0.000 0.000
#> GSM213082     5  0.4277     0.9250 0.000 0.156 0.000 0.076 0.768
#> GSM213085     4  0.2079     0.8134 0.064 0.000 0.000 0.916 0.020
#> GSM213088     1  0.0609     0.9172 0.980 0.000 0.000 0.000 0.020
#> GSM213091     4  0.3123     0.7582 0.000 0.004 0.000 0.812 0.184
#> GSM213092     4  0.1764     0.8178 0.064 0.000 0.000 0.928 0.008
#> GSM213096     1  0.2922     0.8647 0.872 0.000 0.000 0.072 0.056
#> GSM213100     1  0.1341     0.9027 0.944 0.000 0.000 0.000 0.056
#> GSM213111     5  0.4277     0.9250 0.000 0.156 0.000 0.076 0.768
#> GSM213117     4  0.3691     0.7439 0.076 0.000 0.000 0.820 0.104
#> GSM213118     4  0.1478     0.8178 0.064 0.000 0.000 0.936 0.000
#> GSM213120     4  0.4805     0.6367 0.000 0.144 0.000 0.728 0.128
#> GSM213122     2  0.0404     0.7547 0.012 0.988 0.000 0.000 0.000
#> GSM213074     4  0.2079     0.8144 0.064 0.000 0.000 0.916 0.020
#> GSM213077     1  0.1341     0.9027 0.944 0.000 0.000 0.000 0.056
#> GSM213083     1  0.0000     0.9183 1.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.1357     0.9682 0.000 0.004 0.948 0.000 0.048
#> GSM213095     3  0.0000     0.9780 0.000 0.000 1.000 0.000 0.000
#> GSM213102     1  0.1043     0.9118 0.960 0.000 0.000 0.000 0.040
#> GSM213103     2  0.0566     0.7540 0.012 0.984 0.000 0.000 0.004
#> GSM213104     2  0.4283     0.6486 0.136 0.780 0.000 0.004 0.080
#> GSM213107     2  0.4297    -0.0568 0.000 0.528 0.000 0.000 0.472
#> GSM213108     5  0.4515     0.6949 0.000 0.004 0.184 0.064 0.748
#> GSM213112     4  0.2079     0.8134 0.064 0.000 0.000 0.916 0.020
#> GSM213114     1  0.0000     0.9183 1.000 0.000 0.000 0.000 0.000
#> GSM213115     2  0.0404     0.7547 0.012 0.988 0.000 0.000 0.000
#> GSM213116     4  0.2859     0.7897 0.068 0.000 0.000 0.876 0.056
#> GSM213119     2  0.0404     0.7547 0.012 0.988 0.000 0.000 0.000
#> GSM213072     4  0.3550     0.7083 0.000 0.004 0.000 0.760 0.236
#> GSM213075     2  0.6097     0.5613 0.132 0.676 0.000 0.088 0.104
#> GSM213076     5  0.4372     0.9091 0.000 0.172 0.000 0.072 0.756
#> GSM213079     3  0.0290     0.9777 0.000 0.000 0.992 0.000 0.008
#> GSM213080     1  0.0162     0.9173 0.996 0.000 0.000 0.000 0.004
#> GSM213081     1  0.0000     0.9183 1.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000     0.9183 1.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.0566     0.7541 0.012 0.984 0.000 0.000 0.004
#> GSM213089     4  0.1768     0.7995 0.000 0.004 0.000 0.924 0.072
#> GSM213090     3  0.1430     0.9673 0.000 0.004 0.944 0.000 0.052
#> GSM213093     1  0.5606     0.5693 0.600 0.000 0.000 0.296 0.104
#> GSM213097     1  0.4734     0.7543 0.728 0.000 0.000 0.176 0.096
#> GSM213099     4  0.4025     0.6263 0.000 0.008 0.000 0.700 0.292
#> GSM213101     1  0.0609     0.9172 0.980 0.000 0.000 0.000 0.020
#> GSM213105     2  0.0566     0.7541 0.012 0.984 0.000 0.000 0.004
#> GSM213109     1  0.4262     0.8061 0.776 0.000 0.000 0.124 0.100
#> GSM213110     2  0.5431     0.1932 0.424 0.516 0.000 0.000 0.060
#> GSM213113     4  0.3123     0.7565 0.000 0.004 0.000 0.812 0.184
#> GSM213121     2  0.4297    -0.0568 0.000 0.528 0.000 0.000 0.472
#> GSM213123     4  0.3010     0.7634 0.000 0.004 0.000 0.824 0.172
#> GSM213125     5  0.4277     0.9250 0.000 0.156 0.000 0.076 0.768
#> GSM213073     3  0.0290     0.9777 0.000 0.000 0.992 0.000 0.008
#> GSM213086     4  0.1764     0.8178 0.064 0.000 0.000 0.928 0.008
#> GSM213098     4  0.3123     0.7565 0.000 0.004 0.000 0.812 0.184
#> GSM213106     1  0.1043     0.9118 0.960 0.000 0.000 0.000 0.040
#> GSM213124     2  0.2358     0.6836 0.000 0.888 0.000 0.104 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
#> GSM213078     1  0.0000     0.8748 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213082     5  0.3772     0.7857 0.000 0.068 0.000 0.160 0.772 0.000
#> GSM213085     6  0.5045    -0.0754 0.020 0.012 0.000 0.464 0.016 0.488
#> GSM213088     1  0.0909     0.8706 0.968 0.000 0.000 0.000 0.012 0.020
#> GSM213091     4  0.1196     0.6194 0.000 0.000 0.000 0.952 0.008 0.040
#> GSM213092     4  0.4533     0.1056 0.020 0.008 0.000 0.540 0.000 0.432
#> GSM213096     1  0.4956     0.2416 0.568 0.012 0.000 0.000 0.048 0.372
#> GSM213100     1  0.2812     0.7944 0.856 0.000 0.000 0.000 0.048 0.096
#> GSM213111     5  0.3772     0.7857 0.000 0.068 0.000 0.160 0.772 0.000
#> GSM213117     6  0.4696     0.2265 0.016 0.012 0.000 0.384 0.008 0.580
#> GSM213118     4  0.4523     0.1173 0.016 0.012 0.000 0.556 0.000 0.416
#> GSM213120     4  0.3763     0.5397 0.000 0.060 0.000 0.768 0.000 0.172
#> GSM213122     2  0.0508     0.8422 0.012 0.984 0.000 0.000 0.000 0.004
#> GSM213074     4  0.4791     0.0924 0.016 0.012 0.000 0.520 0.008 0.444
#> GSM213077     1  0.2629     0.8029 0.868 0.000 0.000 0.000 0.040 0.092
#> GSM213083     1  0.0000     0.8748 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.3660     0.8662 0.000 0.004 0.772 0.000 0.036 0.188
#> GSM213095     3  0.0458     0.9186 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM213102     1  0.1434     0.8597 0.940 0.000 0.000 0.000 0.012 0.048
#> GSM213103     2  0.1225     0.8361 0.012 0.952 0.000 0.000 0.000 0.036
#> GSM213104     2  0.4625     0.7424 0.056 0.744 0.000 0.000 0.064 0.136
#> GSM213107     5  0.5661     0.4218 0.000 0.356 0.000 0.016 0.520 0.108
#> GSM213108     5  0.4094     0.6830 0.000 0.000 0.076 0.120 0.780 0.024
#> GSM213112     4  0.5031     0.0254 0.020 0.012 0.000 0.512 0.016 0.440
#> GSM213114     1  0.0291     0.8732 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM213115     2  0.0363     0.8422 0.012 0.988 0.000 0.000 0.000 0.000
#> GSM213116     6  0.4486     0.2007 0.016 0.012 0.000 0.396 0.000 0.576
#> GSM213119     2  0.0508     0.8417 0.012 0.984 0.000 0.000 0.004 0.000
#> GSM213072     4  0.1333     0.6153 0.000 0.000 0.000 0.944 0.008 0.048
#> GSM213075     2  0.6055     0.6131 0.052 0.620 0.000 0.072 0.032 0.224
#> GSM213076     5  0.5178     0.7663 0.000 0.076 0.000 0.176 0.688 0.060
#> GSM213079     3  0.0000     0.9183 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     1  0.0891     0.8632 0.968 0.000 0.000 0.000 0.008 0.024
#> GSM213081     1  0.0520     0.8739 0.984 0.000 0.000 0.000 0.008 0.008
#> GSM213084     1  0.0000     0.8748 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.0870     0.8381 0.012 0.972 0.000 0.000 0.004 0.012
#> GSM213089     4  0.3493     0.5296 0.000 0.008 0.000 0.756 0.008 0.228
#> GSM213090     3  0.3601     0.8773 0.000 0.008 0.792 0.000 0.040 0.160
#> GSM213093     6  0.5279     0.3294 0.340 0.012 0.000 0.048 0.016 0.584
#> GSM213097     6  0.4397     0.0126 0.452 0.000 0.000 0.008 0.012 0.528
#> GSM213099     4  0.2145     0.5901 0.000 0.000 0.000 0.900 0.028 0.072
#> GSM213101     1  0.0909     0.8706 0.968 0.000 0.000 0.000 0.012 0.020
#> GSM213105     2  0.0870     0.8381 0.012 0.972 0.000 0.000 0.004 0.012
#> GSM213109     1  0.4463     0.0811 0.516 0.000 0.000 0.000 0.028 0.456
#> GSM213110     2  0.5721     0.5529 0.252 0.604 0.000 0.000 0.052 0.092
#> GSM213113     4  0.0146     0.6317 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM213121     5  0.5700     0.4250 0.000 0.356 0.000 0.020 0.520 0.104
#> GSM213123     4  0.0405     0.6317 0.000 0.000 0.000 0.988 0.004 0.008
#> GSM213125     5  0.3772     0.7857 0.000 0.068 0.000 0.160 0.772 0.000
#> GSM213073     3  0.0000     0.9183 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213086     4  0.4533     0.1056 0.020 0.008 0.000 0.540 0.000 0.432
#> GSM213098     4  0.0000     0.6318 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213106     1  0.1367     0.8605 0.944 0.000 0.000 0.000 0.012 0.044
#> GSM213124     2  0.2838     0.7367 0.000 0.808 0.000 0.004 0.000 0.188

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n development.stage(p) disease.state(p) k
#> ATC:kmeans 54                0.290            0.921 2
#> ATC:kmeans 40                0.514            0.202 3
#> ATC:kmeans 48                0.989            0.351 4
#> ATC:kmeans 51                0.965            0.474 5
#> ATC:kmeans 40                0.620            0.328 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.717           0.837       0.927         0.4994 0.525   0.525
#> 3 3 1.000           0.953       0.979         0.3096 0.793   0.616
#> 4 4 0.896           0.905       0.959         0.1348 0.881   0.671
#> 5 5 0.813           0.732       0.851         0.0595 0.915   0.690
#> 6 6 0.778           0.641       0.811         0.0356 0.965   0.838

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
#> GSM213078     1  0.0000      0.869 1.000 0.000
#> GSM213082     2  0.0000      1.000 0.000 1.000
#> GSM213085     1  0.0000      0.869 1.000 0.000
#> GSM213088     1  0.0000      0.869 1.000 0.000
#> GSM213091     2  0.0000      1.000 0.000 1.000
#> GSM213092     1  0.9922      0.245 0.552 0.448
#> GSM213096     1  0.0000      0.869 1.000 0.000
#> GSM213100     1  0.0000      0.869 1.000 0.000
#> GSM213111     2  0.0000      1.000 0.000 1.000
#> GSM213117     1  0.0000      0.869 1.000 0.000
#> GSM213118     1  0.5946      0.758 0.856 0.144
#> GSM213120     2  0.0000      1.000 0.000 1.000
#> GSM213122     1  0.9710      0.448 0.600 0.400
#> GSM213074     1  0.0376      0.866 0.996 0.004
#> GSM213077     1  0.0000      0.869 1.000 0.000
#> GSM213083     1  0.0000      0.869 1.000 0.000
#> GSM213094     2  0.0000      1.000 0.000 1.000
#> GSM213095     2  0.0000      1.000 0.000 1.000
#> GSM213102     1  0.0000      0.869 1.000 0.000
#> GSM213103     1  0.8499      0.636 0.724 0.276
#> GSM213104     1  0.0000      0.869 1.000 0.000
#> GSM213107     2  0.0000      1.000 0.000 1.000
#> GSM213108     2  0.0000      1.000 0.000 1.000
#> GSM213112     1  0.9427      0.451 0.640 0.360
#> GSM213114     1  0.0000      0.869 1.000 0.000
#> GSM213115     1  0.9209      0.556 0.664 0.336
#> GSM213116     1  0.0000      0.869 1.000 0.000
#> GSM213119     1  0.9635      0.473 0.612 0.388
#> GSM213072     2  0.0000      1.000 0.000 1.000
#> GSM213075     1  0.0000      0.869 1.000 0.000
#> GSM213076     2  0.0000      1.000 0.000 1.000
#> GSM213079     2  0.0000      1.000 0.000 1.000
#> GSM213080     1  0.0000      0.869 1.000 0.000
#> GSM213081     1  0.0000      0.869 1.000 0.000
#> GSM213084     1  0.0000      0.869 1.000 0.000
#> GSM213087     1  0.9635      0.473 0.612 0.388
#> GSM213089     2  0.0000      1.000 0.000 1.000
#> GSM213090     2  0.0000      1.000 0.000 1.000
#> GSM213093     1  0.0000      0.869 1.000 0.000
#> GSM213097     1  0.0000      0.869 1.000 0.000
#> GSM213099     2  0.0000      1.000 0.000 1.000
#> GSM213101     1  0.0000      0.869 1.000 0.000
#> GSM213105     1  0.9635      0.473 0.612 0.388
#> GSM213109     1  0.0000      0.869 1.000 0.000
#> GSM213110     1  0.0000      0.869 1.000 0.000
#> GSM213113     2  0.0000      1.000 0.000 1.000
#> GSM213121     2  0.0000      1.000 0.000 1.000
#> GSM213123     2  0.0000      1.000 0.000 1.000
#> GSM213125     2  0.0000      1.000 0.000 1.000
#> GSM213073     2  0.0000      1.000 0.000 1.000
#> GSM213086     1  0.9909      0.256 0.556 0.444
#> GSM213098     2  0.0000      1.000 0.000 1.000
#> GSM213106     1  0.0000      0.869 1.000 0.000
#> GSM213124     1  0.9635      0.473 0.612 0.388

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213082     3  0.0892      0.957 0.000 0.020 0.980
#> GSM213085     1  0.0747      0.984 0.984 0.000 0.016
#> GSM213088     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213091     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213092     1  0.0892      0.982 0.980 0.000 0.020
#> GSM213096     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213100     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213111     3  0.0892      0.957 0.000 0.020 0.980
#> GSM213117     1  0.0000      0.992 1.000 0.000 0.000
#> GSM213118     1  0.0892      0.982 0.980 0.000 0.020
#> GSM213120     3  0.6168      0.257 0.000 0.412 0.588
#> GSM213122     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213074     1  0.0892      0.982 0.980 0.000 0.020
#> GSM213077     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213083     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213094     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213095     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213102     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213103     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213104     2  0.0892      0.945 0.020 0.980 0.000
#> GSM213107     2  0.4555      0.758 0.000 0.800 0.200
#> GSM213108     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213112     1  0.0892      0.982 0.980 0.000 0.020
#> GSM213114     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213115     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213116     1  0.0000      0.992 1.000 0.000 0.000
#> GSM213119     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213072     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213075     2  0.0892      0.945 0.020 0.980 0.000
#> GSM213076     3  0.1163      0.951 0.000 0.028 0.972
#> GSM213079     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213080     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213081     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213084     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213087     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213089     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213090     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213093     1  0.0000      0.992 1.000 0.000 0.000
#> GSM213097     1  0.0000      0.992 1.000 0.000 0.000
#> GSM213099     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213101     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213105     2  0.0000      0.955 0.000 1.000 0.000
#> GSM213109     1  0.0000      0.992 1.000 0.000 0.000
#> GSM213110     2  0.0892      0.945 0.020 0.980 0.000
#> GSM213113     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213121     2  0.4555      0.758 0.000 0.800 0.200
#> GSM213123     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213125     3  0.0892      0.957 0.000 0.020 0.980
#> GSM213073     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213086     1  0.0892      0.982 0.980 0.000 0.020
#> GSM213098     3  0.0000      0.969 0.000 0.000 1.000
#> GSM213106     1  0.0237      0.993 0.996 0.004 0.000
#> GSM213124     2  0.0000      0.955 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213082     3  0.0336      0.922 0.000 0.008 0.992 0.000
#> GSM213085     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213088     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213091     3  0.3610      0.776 0.000 0.000 0.800 0.200
#> GSM213092     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213096     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213100     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213111     3  0.0336      0.922 0.000 0.008 0.992 0.000
#> GSM213117     1  0.1022      0.945 0.968 0.000 0.000 0.032
#> GSM213118     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213120     3  0.4933      0.204 0.000 0.432 0.568 0.000
#> GSM213122     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213074     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213077     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213083     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213094     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213095     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213102     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213103     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213104     2  0.0469      0.924 0.012 0.988 0.000 0.000
#> GSM213107     2  0.3688      0.736 0.000 0.792 0.208 0.000
#> GSM213108     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213112     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213114     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213115     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213116     4  0.0469      0.968 0.012 0.000 0.000 0.988
#> GSM213119     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213072     3  0.2011      0.884 0.000 0.000 0.920 0.080
#> GSM213075     2  0.2589      0.820 0.116 0.884 0.000 0.000
#> GSM213076     3  0.1302      0.900 0.000 0.044 0.956 0.000
#> GSM213079     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213080     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213081     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213084     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213087     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213089     3  0.0707      0.918 0.000 0.000 0.980 0.020
#> GSM213090     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213093     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213097     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213099     3  0.0707      0.918 0.000 0.000 0.980 0.020
#> GSM213101     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213105     2  0.0000      0.933 0.000 1.000 0.000 0.000
#> GSM213109     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213110     1  0.4761      0.383 0.628 0.372 0.000 0.000
#> GSM213113     3  0.3486      0.793 0.000 0.000 0.812 0.188
#> GSM213121     2  0.3610      0.745 0.000 0.800 0.200 0.000
#> GSM213123     4  0.2589      0.853 0.000 0.000 0.116 0.884
#> GSM213125     3  0.0336      0.922 0.000 0.008 0.992 0.000
#> GSM213073     3  0.0000      0.923 0.000 0.000 1.000 0.000
#> GSM213086     4  0.0000      0.978 0.000 0.000 0.000 1.000
#> GSM213098     3  0.3219      0.816 0.000 0.000 0.836 0.164
#> GSM213106     1  0.0000      0.975 1.000 0.000 0.000 0.000
#> GSM213124     2  0.0000      0.933 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213082     2  0.3861     0.5382 0.000 0.728 0.264 0.000 0.008
#> GSM213085     4  0.0162     0.8616 0.004 0.000 0.000 0.996 0.000
#> GSM213088     1  0.0451     0.9752 0.988 0.008 0.000 0.004 0.000
#> GSM213091     3  0.1725     0.6069 0.000 0.020 0.936 0.044 0.000
#> GSM213092     4  0.0162     0.8632 0.000 0.000 0.004 0.996 0.000
#> GSM213096     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213100     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213111     2  0.3783     0.5565 0.000 0.740 0.252 0.000 0.008
#> GSM213117     1  0.3226     0.8680 0.852 0.088 0.000 0.060 0.000
#> GSM213118     4  0.1981     0.8490 0.000 0.048 0.028 0.924 0.000
#> GSM213120     2  0.4648     0.5122 0.000 0.740 0.104 0.000 0.156
#> GSM213122     5  0.0000     0.8910 0.000 0.000 0.000 0.000 1.000
#> GSM213074     4  0.6151     0.6081 0.008 0.156 0.252 0.584 0.000
#> GSM213077     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213083     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.3143     0.6205 0.000 0.204 0.796 0.000 0.000
#> GSM213095     3  0.4192     0.2367 0.000 0.404 0.596 0.000 0.000
#> GSM213102     1  0.0451     0.9752 0.988 0.008 0.000 0.004 0.000
#> GSM213103     5  0.0162     0.8897 0.000 0.004 0.000 0.000 0.996
#> GSM213104     5  0.2927     0.8209 0.060 0.068 0.000 0.000 0.872
#> GSM213107     2  0.5911     0.3676 0.000 0.488 0.104 0.000 0.408
#> GSM213108     2  0.4306    -0.0565 0.000 0.508 0.492 0.000 0.000
#> GSM213112     4  0.0162     0.8632 0.000 0.000 0.004 0.996 0.000
#> GSM213114     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213115     5  0.0000     0.8910 0.000 0.000 0.000 0.000 1.000
#> GSM213116     4  0.3110     0.7993 0.060 0.080 0.000 0.860 0.000
#> GSM213119     5  0.0000     0.8910 0.000 0.000 0.000 0.000 1.000
#> GSM213072     3  0.0771     0.6361 0.000 0.020 0.976 0.004 0.000
#> GSM213075     5  0.4180     0.7563 0.076 0.104 0.016 0.000 0.804
#> GSM213076     2  0.3906     0.5488 0.000 0.744 0.240 0.000 0.016
#> GSM213079     3  0.3395     0.6035 0.000 0.236 0.764 0.000 0.000
#> GSM213080     1  0.0404     0.9713 0.988 0.012 0.000 0.000 0.000
#> GSM213081     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000     0.9771 1.000 0.000 0.000 0.000 0.000
#> GSM213087     5  0.0000     0.8910 0.000 0.000 0.000 0.000 1.000
#> GSM213089     3  0.4510     0.1670 0.000 0.432 0.560 0.008 0.000
#> GSM213090     3  0.3424     0.5996 0.000 0.240 0.760 0.000 0.000
#> GSM213093     1  0.1704     0.9391 0.928 0.068 0.000 0.004 0.000
#> GSM213097     1  0.1704     0.9391 0.928 0.068 0.000 0.004 0.000
#> GSM213099     3  0.0404     0.6424 0.000 0.012 0.988 0.000 0.000
#> GSM213101     1  0.0451     0.9752 0.988 0.008 0.000 0.004 0.000
#> GSM213105     5  0.0000     0.8910 0.000 0.000 0.000 0.000 1.000
#> GSM213109     1  0.1430     0.9439 0.944 0.004 0.000 0.052 0.000
#> GSM213110     5  0.4760     0.3086 0.416 0.020 0.000 0.000 0.564
#> GSM213113     3  0.6332     0.2806 0.000 0.264 0.524 0.212 0.000
#> GSM213121     2  0.5431     0.3233 0.000 0.516 0.060 0.000 0.424
#> GSM213123     4  0.5838     0.3949 0.000 0.112 0.336 0.552 0.000
#> GSM213125     2  0.3756     0.5575 0.000 0.744 0.248 0.000 0.008
#> GSM213073     3  0.3395     0.6035 0.000 0.236 0.764 0.000 0.000
#> GSM213086     4  0.0162     0.8632 0.000 0.000 0.004 0.996 0.000
#> GSM213098     3  0.4069     0.5907 0.000 0.112 0.792 0.096 0.000
#> GSM213106     1  0.0451     0.9752 0.988 0.008 0.000 0.004 0.000
#> GSM213124     5  0.0703     0.8795 0.000 0.024 0.000 0.000 0.976

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213082     5  0.2442      0.584 0.000 0.004 0.144 0.000 0.852 0.000
#> GSM213085     1  0.0508      0.715 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM213088     4  0.1387      0.897 0.000 0.000 0.000 0.932 0.000 0.068
#> GSM213091     3  0.3093      0.470 0.012 0.000 0.816 0.000 0.008 0.164
#> GSM213092     1  0.0000      0.718 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213096     4  0.0146      0.907 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM213100     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213111     5  0.2553      0.595 0.000 0.008 0.144 0.000 0.848 0.000
#> GSM213117     4  0.4500      0.558 0.024 0.000 0.000 0.592 0.008 0.376
#> GSM213118     1  0.4130      0.534 0.716 0.000 0.036 0.000 0.008 0.240
#> GSM213120     5  0.3922      0.522 0.000 0.088 0.044 0.000 0.804 0.064
#> GSM213122     2  0.0291      0.815 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM213074     6  0.5844      0.205 0.252 0.000 0.144 0.016 0.008 0.580
#> GSM213077     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213083     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213094     3  0.2520      0.717 0.000 0.000 0.844 0.000 0.152 0.004
#> GSM213095     3  0.3592      0.532 0.000 0.000 0.656 0.000 0.344 0.000
#> GSM213102     4  0.1714      0.888 0.000 0.000 0.000 0.908 0.000 0.092
#> GSM213103     2  0.1082      0.806 0.000 0.956 0.000 0.000 0.004 0.040
#> GSM213104     2  0.6848      0.414 0.004 0.504 0.000 0.212 0.088 0.192
#> GSM213107     5  0.6056      0.422 0.000 0.272 0.048 0.000 0.556 0.124
#> GSM213108     3  0.3868      0.218 0.000 0.000 0.504 0.000 0.496 0.000
#> GSM213112     1  0.0405      0.717 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM213114     4  0.0260      0.905 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM213115     2  0.0000      0.818 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213116     1  0.5268      0.292 0.564 0.000 0.008 0.064 0.008 0.356
#> GSM213119     2  0.0000      0.818 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213072     3  0.2278      0.549 0.000 0.000 0.868 0.000 0.004 0.128
#> GSM213075     2  0.5015      0.516 0.000 0.616 0.000 0.092 0.004 0.288
#> GSM213076     5  0.3779      0.588 0.000 0.024 0.092 0.000 0.808 0.076
#> GSM213079     3  0.2631      0.717 0.000 0.000 0.820 0.000 0.180 0.000
#> GSM213080     4  0.0632      0.897 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM213081     4  0.0632      0.906 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM213084     4  0.0000      0.908 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM213087     2  0.0000      0.818 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213089     6  0.6369      0.320 0.016 0.000 0.312 0.000 0.252 0.420
#> GSM213090     3  0.2793      0.708 0.000 0.000 0.800 0.000 0.200 0.000
#> GSM213093     4  0.3371      0.722 0.000 0.000 0.000 0.708 0.000 0.292
#> GSM213097     4  0.3351      0.726 0.000 0.000 0.000 0.712 0.000 0.288
#> GSM213099     3  0.2212      0.569 0.000 0.000 0.880 0.000 0.008 0.112
#> GSM213101     4  0.1387      0.897 0.000 0.000 0.000 0.932 0.000 0.068
#> GSM213105     2  0.0000      0.818 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213109     4  0.3125      0.844 0.080 0.000 0.000 0.836 0.000 0.084
#> GSM213110     2  0.4620      0.315 0.000 0.532 0.000 0.428 0.000 0.040
#> GSM213113     5  0.7583     -0.264 0.260 0.000 0.284 0.000 0.300 0.156
#> GSM213121     5  0.5816      0.410 0.000 0.288 0.028 0.000 0.560 0.124
#> GSM213123     1  0.7378     -0.198 0.392 0.000 0.228 0.000 0.140 0.240
#> GSM213125     5  0.2431      0.599 0.000 0.008 0.132 0.000 0.860 0.000
#> GSM213073     3  0.2664      0.716 0.000 0.000 0.816 0.000 0.184 0.000
#> GSM213086     1  0.0000      0.718 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213098     3  0.5053      0.452 0.108 0.000 0.712 0.000 0.060 0.120
#> GSM213106     4  0.1714      0.888 0.000 0.000 0.000 0.908 0.000 0.092
#> GSM213124     2  0.1926      0.777 0.000 0.912 0.000 0.000 0.020 0.068

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 development.stage(p) disease.state(p) k
#> ATC:skmeans 46                0.249            0.776 2
#> ATC:skmeans 53                0.228            0.530 3
#> ATC:skmeans 52                0.380            0.459 4
#> ATC:skmeans 46                0.228            0.206 5
#> ATC:skmeans 42                0.516            0.406 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.418           0.694       0.809        0.43424 0.609   0.609
#> 3 3 0.413           0.641       0.790        0.39914 0.704   0.546
#> 4 4 0.880           0.937       0.970        0.22599 0.806   0.538
#> 5 5 0.769           0.831       0.911        0.04317 0.975   0.900
#> 6 6 0.922           0.845       0.942        0.00142 0.997   0.988

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
#> GSM213078     1  0.9795     0.6882 0.584 0.416
#> GSM213082     2  0.9795     0.9985 0.416 0.584
#> GSM213085     1  0.6438     0.6791 0.836 0.164
#> GSM213088     1  0.9795     0.6882 0.584 0.416
#> GSM213091     1  0.2778     0.5510 0.952 0.048
#> GSM213092     1  0.5294     0.6692 0.880 0.120
#> GSM213096     1  0.9795     0.6882 0.584 0.416
#> GSM213100     1  0.9795     0.6882 0.584 0.416
#> GSM213111     2  0.9795     0.9985 0.416 0.584
#> GSM213117     1  0.0000     0.6172 1.000 0.000
#> GSM213118     1  0.0000     0.6172 1.000 0.000
#> GSM213120     1  0.6712     0.2393 0.824 0.176
#> GSM213122     1  0.0000     0.6172 1.000 0.000
#> GSM213074     1  0.0000     0.6172 1.000 0.000
#> GSM213077     1  0.9795     0.6882 0.584 0.416
#> GSM213083     1  0.9795     0.6882 0.584 0.416
#> GSM213094     2  0.9795     0.9985 0.416 0.584
#> GSM213095     2  0.9795     0.9985 0.416 0.584
#> GSM213102     1  0.9795     0.6882 0.584 0.416
#> GSM213103     1  0.0000     0.6172 1.000 0.000
#> GSM213104     1  0.7299     0.6829 0.796 0.204
#> GSM213107     2  0.9795     0.9985 0.416 0.584
#> GSM213108     2  0.9795     0.9985 0.416 0.584
#> GSM213112     1  0.6438     0.6791 0.836 0.164
#> GSM213114     1  0.9795     0.6882 0.584 0.416
#> GSM213115     1  0.0000     0.6172 1.000 0.000
#> GSM213116     1  0.0000     0.6172 1.000 0.000
#> GSM213119     1  0.0938     0.6028 0.988 0.012
#> GSM213072     1  0.6887     0.2119 0.816 0.184
#> GSM213075     1  0.0000     0.6172 1.000 0.000
#> GSM213076     2  0.9795     0.9985 0.416 0.584
#> GSM213079     2  0.9795     0.9985 0.416 0.584
#> GSM213080     1  0.9795     0.6882 0.584 0.416
#> GSM213081     1  0.9795     0.6882 0.584 0.416
#> GSM213084     1  0.9795     0.6882 0.584 0.416
#> GSM213087     1  0.7528     0.0724 0.784 0.216
#> GSM213089     1  0.0000     0.6172 1.000 0.000
#> GSM213090     2  0.9795     0.9985 0.416 0.584
#> GSM213093     1  0.5408     0.6709 0.876 0.124
#> GSM213097     1  0.9795     0.6882 0.584 0.416
#> GSM213099     2  0.9795     0.9985 0.416 0.584
#> GSM213101     1  0.9795     0.6882 0.584 0.416
#> GSM213105     1  0.7674     0.0356 0.776 0.224
#> GSM213109     1  0.9795     0.6882 0.584 0.416
#> GSM213110     1  0.9795     0.6882 0.584 0.416
#> GSM213113     2  0.9850     0.9804 0.428 0.572
#> GSM213121     2  0.9795     0.9985 0.416 0.584
#> GSM213123     1  0.3584     0.5163 0.932 0.068
#> GSM213125     2  0.9795     0.9985 0.416 0.584
#> GSM213073     2  0.9795     0.9985 0.416 0.584
#> GSM213086     1  0.2423     0.6387 0.960 0.040
#> GSM213098     1  0.7528     0.0836 0.784 0.216
#> GSM213106     1  0.9795     0.6882 0.584 0.416
#> GSM213124     1  0.0000     0.6172 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
#> GSM213078     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213082     3  0.5905      0.573 0.000 0.352 0.648
#> GSM213085     1  0.8386      0.595 0.620 0.224 0.156
#> GSM213088     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213091     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213092     1  0.8436      0.595 0.616 0.224 0.160
#> GSM213096     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213100     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213111     3  0.6008      0.544 0.000 0.372 0.628
#> GSM213117     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213118     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213120     2  0.7759      0.405 0.144 0.676 0.180
#> GSM213122     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213074     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213077     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213083     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213094     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213095     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213102     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213103     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213104     2  0.6280     -0.132 0.460 0.540 0.000
#> GSM213107     2  0.2680      0.766 0.008 0.924 0.068
#> GSM213108     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213112     1  0.8386      0.595 0.620 0.224 0.156
#> GSM213114     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213115     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213116     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213119     2  0.0000      0.839 0.000 1.000 0.000
#> GSM213072     1  0.8984      0.554 0.564 0.224 0.212
#> GSM213075     2  0.2187      0.804 0.028 0.948 0.024
#> GSM213076     2  0.4874      0.647 0.144 0.828 0.028
#> GSM213079     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213080     1  0.4702      0.526 0.788 0.212 0.000
#> GSM213081     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213084     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213087     2  0.0237      0.837 0.000 0.996 0.004
#> GSM213089     1  0.8803      0.570 0.580 0.240 0.180
#> GSM213090     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213093     1  0.8466      0.597 0.616 0.212 0.172
#> GSM213097     1  0.0848      0.609 0.984 0.008 0.008
#> GSM213099     3  0.8063      0.466 0.132 0.224 0.644
#> GSM213101     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213105     2  0.0237      0.837 0.000 0.996 0.004
#> GSM213109     1  0.2165      0.613 0.936 0.064 0.000
#> GSM213110     2  0.4842      0.534 0.224 0.776 0.000
#> GSM213113     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213121     2  0.0829      0.834 0.012 0.984 0.004
#> GSM213123     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213125     3  0.6045      0.537 0.000 0.380 0.620
#> GSM213073     3  0.0000      0.815 0.000 0.000 1.000
#> GSM213086     1  0.8623      0.591 0.600 0.224 0.176
#> GSM213098     1  0.8668      0.590 0.596 0.224 0.180
#> GSM213106     1  0.3752      0.611 0.856 0.144 0.000
#> GSM213124     2  0.0424      0.836 0.008 0.992 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213082     3  0.2831      0.881 0.000 0.004 0.876 0.120
#> GSM213085     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213088     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213091     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213092     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213096     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213100     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213111     3  0.2831      0.881 0.000 0.004 0.876 0.120
#> GSM213117     4  0.0707      0.972 0.000 0.020 0.000 0.980
#> GSM213118     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213120     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213122     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213074     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213077     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213083     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213094     3  0.0000      0.942 0.000 0.000 1.000 0.000
#> GSM213095     3  0.0000      0.942 0.000 0.000 1.000 0.000
#> GSM213102     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213103     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213104     2  0.4304      0.583 0.284 0.716 0.000 0.000
#> GSM213107     2  0.2647      0.849 0.000 0.880 0.000 0.120
#> GSM213108     3  0.0188      0.941 0.000 0.004 0.996 0.000
#> GSM213112     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213114     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213115     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213116     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213119     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213072     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213075     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213076     2  0.3569      0.770 0.000 0.804 0.000 0.196
#> GSM213079     3  0.0000      0.942 0.000 0.000 1.000 0.000
#> GSM213080     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213081     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213084     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213087     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213089     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213090     3  0.0000      0.942 0.000 0.000 1.000 0.000
#> GSM213093     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213097     1  0.4193      0.637 0.732 0.000 0.000 0.268
#> GSM213099     4  0.2125      0.906 0.000 0.004 0.076 0.920
#> GSM213101     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213105     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213109     1  0.0188      0.973 0.996 0.000 0.000 0.004
#> GSM213110     2  0.0188      0.914 0.004 0.996 0.000 0.000
#> GSM213113     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213121     2  0.2647      0.849 0.000 0.880 0.000 0.120
#> GSM213123     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213125     3  0.2888      0.878 0.000 0.004 0.872 0.124
#> GSM213073     3  0.0000      0.942 0.000 0.000 1.000 0.000
#> GSM213086     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213098     4  0.0000      0.993 0.000 0.000 0.000 1.000
#> GSM213106     1  0.0000      0.977 1.000 0.000 0.000 0.000
#> GSM213124     2  0.2714      0.857 0.004 0.884 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
#> GSM213078     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213082     5  0.0290      0.893 0.000 0.000 0.008 0.000 0.992
#> GSM213085     4  0.0000      0.872 0.000 0.000 0.000 1.000 0.000
#> GSM213088     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213091     4  0.2605      0.893 0.000 0.000 0.000 0.852 0.148
#> GSM213092     4  0.0000      0.872 0.000 0.000 0.000 1.000 0.000
#> GSM213096     1  0.2561      0.839 0.856 0.000 0.000 0.144 0.000
#> GSM213100     1  0.2561      0.839 0.856 0.000 0.000 0.144 0.000
#> GSM213111     5  0.0000      0.893 0.000 0.000 0.000 0.000 1.000
#> GSM213117     4  0.0324      0.873 0.004 0.000 0.000 0.992 0.004
#> GSM213118     4  0.0000      0.872 0.000 0.000 0.000 1.000 0.000
#> GSM213120     4  0.2886      0.889 0.000 0.008 0.000 0.844 0.148
#> GSM213122     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213074     4  0.2605      0.893 0.000 0.000 0.000 0.852 0.148
#> GSM213077     1  0.2561      0.839 0.856 0.000 0.000 0.144 0.000
#> GSM213083     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.5158      0.540 0.000 0.000 0.676 0.100 0.224
#> GSM213095     3  0.0609      0.897 0.000 0.000 0.980 0.000 0.020
#> GSM213102     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213103     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213104     2  0.4889      0.588 0.136 0.720 0.000 0.144 0.000
#> GSM213107     2  0.4171      0.329 0.000 0.604 0.000 0.000 0.396
#> GSM213108     5  0.1851      0.844 0.000 0.000 0.088 0.000 0.912
#> GSM213112     4  0.0000      0.872 0.000 0.000 0.000 1.000 0.000
#> GSM213114     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213115     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213116     4  0.2329      0.835 0.124 0.000 0.000 0.876 0.000
#> GSM213119     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213072     4  0.2605      0.893 0.000 0.000 0.000 0.852 0.148
#> GSM213075     2  0.2763      0.711 0.000 0.848 0.000 0.004 0.148
#> GSM213076     5  0.0703      0.887 0.000 0.024 0.000 0.000 0.976
#> GSM213079     3  0.0000      0.893 0.000 0.000 1.000 0.000 0.000
#> GSM213080     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213081     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213089     4  0.2605      0.893 0.000 0.000 0.000 0.852 0.148
#> GSM213090     3  0.0609      0.897 0.000 0.000 0.980 0.000 0.020
#> GSM213093     4  0.2561      0.821 0.144 0.000 0.000 0.856 0.000
#> GSM213097     1  0.4101      0.346 0.628 0.000 0.000 0.372 0.000
#> GSM213099     4  0.3999      0.648 0.000 0.000 0.000 0.656 0.344
#> GSM213101     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213105     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213109     1  0.2773      0.824 0.836 0.000 0.000 0.164 0.000
#> GSM213110     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000
#> GSM213113     4  0.2690      0.888 0.000 0.000 0.000 0.844 0.156
#> GSM213121     2  0.4138      0.358 0.000 0.616 0.000 0.000 0.384
#> GSM213123     4  0.2561      0.893 0.000 0.000 0.000 0.856 0.144
#> GSM213125     5  0.2843      0.761 0.000 0.144 0.008 0.000 0.848
#> GSM213073     3  0.0290      0.897 0.000 0.000 0.992 0.000 0.008
#> GSM213086     4  0.0000      0.872 0.000 0.000 0.000 1.000 0.000
#> GSM213098     4  0.2561      0.893 0.000 0.000 0.000 0.856 0.144
#> GSM213106     1  0.0000      0.916 1.000 0.000 0.000 0.000 0.000
#> GSM213124     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213082     6  0.0260      0.968 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM213085     4  0.0865      0.948 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM213088     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213091     4  0.0260      0.949 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM213092     4  0.0865      0.948 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM213096     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213100     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213111     6  0.0146      0.962 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM213117     4  0.1204      0.940 0.000 0.000 0.000 0.944 0.056 0.000
#> GSM213118     4  0.0260      0.950 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM213120     4  0.1265      0.929 0.000 0.044 0.000 0.948 0.008 0.000
#> GSM213122     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213074     4  0.1204      0.940 0.000 0.000 0.000 0.944 0.056 0.000
#> GSM213077     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213083     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.4791      0.387 0.000 0.000 0.664 0.248 0.008 0.080
#> GSM213095     3  0.3161      0.555 0.000 0.000 0.776 0.000 0.008 0.216
#> GSM213102     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213103     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213104     2  0.3309      0.464 0.280 0.720 0.000 0.000 0.000 0.000
#> GSM213107     2  0.3737      0.382 0.000 0.608 0.000 0.000 0.000 0.392
#> GSM213108     6  0.0260      0.968 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM213112     4  0.0865      0.948 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM213114     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213115     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213116     4  0.1141      0.942 0.000 0.000 0.000 0.948 0.052 0.000
#> GSM213119     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213072     4  0.0972      0.942 0.000 0.000 0.000 0.964 0.008 0.028
#> GSM213075     2  0.1049      0.837 0.000 0.960 0.000 0.032 0.008 0.000
#> GSM213076     6  0.1668      0.886 0.000 0.060 0.000 0.004 0.008 0.928
#> GSM213079     3  0.0000      0.666 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213081     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213089     4  0.1204      0.940 0.000 0.000 0.000 0.944 0.056 0.000
#> GSM213090     5  0.1806      0.000 0.000 0.000 0.088 0.000 0.908 0.004
#> GSM213093     4  0.1285      0.939 0.004 0.000 0.000 0.944 0.052 0.000
#> GSM213097     1  0.4482      0.377 0.628 0.000 0.000 0.324 0.048 0.000
#> GSM213099     4  0.2706      0.796 0.000 0.000 0.000 0.832 0.008 0.160
#> GSM213101     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213105     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213109     1  0.2147      0.855 0.896 0.000 0.000 0.020 0.084 0.000
#> GSM213110     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM213113     4  0.1010      0.947 0.000 0.000 0.000 0.960 0.036 0.004
#> GSM213121     2  0.3706      0.409 0.000 0.620 0.000 0.000 0.000 0.380
#> GSM213123     4  0.0865      0.948 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM213125     6  0.0260      0.968 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM213073     3  0.0146      0.669 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM213086     4  0.0865      0.948 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM213098     4  0.0790      0.949 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM213106     1  0.0000      0.957 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213124     2  0.0146      0.867 0.000 0.996 0.000 0.004 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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

test_to_known_factors(res)
#>          n development.stage(p) disease.state(p) k
#> ATC:pam 49                0.440            1.000 2
#> ATC:pam 51                0.756            0.780 3
#> ATC:pam 54                0.971            0.756 4
#> ATC:pam 51                0.966            0.575 5
#> ATC:pam 48                0.924            0.665 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.971       0.986         0.5017 0.497   0.497
#> 3 3 0.557           0.733       0.848         0.1891 0.887   0.774
#> 4 4 0.853           0.847       0.918         0.1973 0.837   0.602
#> 5 5 0.896           0.843       0.935         0.0672 0.867   0.583
#> 6 6 0.800           0.705       0.843         0.0530 0.931   0.729

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
#> GSM213078     1  0.0000      0.992 1.000 0.000
#> GSM213082     2  0.0000      0.976 0.000 1.000
#> GSM213085     1  0.0000      0.992 1.000 0.000
#> GSM213088     1  0.0000      0.992 1.000 0.000
#> GSM213091     1  0.0000      0.992 1.000 0.000
#> GSM213092     1  0.0000      0.992 1.000 0.000
#> GSM213096     1  0.0000      0.992 1.000 0.000
#> GSM213100     1  0.0000      0.992 1.000 0.000
#> GSM213111     2  0.0000      0.976 0.000 1.000
#> GSM213117     1  0.0000      0.992 1.000 0.000
#> GSM213118     1  0.0000      0.992 1.000 0.000
#> GSM213120     2  0.3584      0.928 0.068 0.932
#> GSM213122     2  0.0000      0.976 0.000 1.000
#> GSM213074     1  0.0000      0.992 1.000 0.000
#> GSM213077     1  0.0000      0.992 1.000 0.000
#> GSM213083     1  0.0000      0.992 1.000 0.000
#> GSM213094     2  0.0000      0.976 0.000 1.000
#> GSM213095     2  0.0000      0.976 0.000 1.000
#> GSM213102     1  0.0000      0.992 1.000 0.000
#> GSM213103     2  0.0000      0.976 0.000 1.000
#> GSM213104     2  0.0000      0.976 0.000 1.000
#> GSM213107     2  0.0000      0.976 0.000 1.000
#> GSM213108     2  0.0000      0.976 0.000 1.000
#> GSM213112     1  0.0000      0.992 1.000 0.000
#> GSM213114     1  0.0000      0.992 1.000 0.000
#> GSM213115     2  0.0000      0.976 0.000 1.000
#> GSM213116     1  0.0000      0.992 1.000 0.000
#> GSM213119     2  0.0000      0.976 0.000 1.000
#> GSM213072     1  0.0000      0.992 1.000 0.000
#> GSM213075     2  0.3733      0.925 0.072 0.928
#> GSM213076     2  0.0000      0.976 0.000 1.000
#> GSM213079     2  0.0000      0.976 0.000 1.000
#> GSM213080     2  0.7815      0.722 0.232 0.768
#> GSM213081     1  0.0000      0.992 1.000 0.000
#> GSM213084     1  0.0000      0.992 1.000 0.000
#> GSM213087     2  0.0000      0.976 0.000 1.000
#> GSM213089     1  0.0376      0.988 0.996 0.004
#> GSM213090     2  0.0000      0.976 0.000 1.000
#> GSM213093     1  0.0000      0.992 1.000 0.000
#> GSM213097     1  0.0000      0.992 1.000 0.000
#> GSM213099     1  0.7745      0.707 0.772 0.228
#> GSM213101     1  0.0000      0.992 1.000 0.000
#> GSM213105     2  0.0000      0.976 0.000 1.000
#> GSM213109     1  0.0000      0.992 1.000 0.000
#> GSM213110     2  0.4939      0.888 0.108 0.892
#> GSM213113     1  0.0000      0.992 1.000 0.000
#> GSM213121     2  0.0000      0.976 0.000 1.000
#> GSM213123     1  0.0000      0.992 1.000 0.000
#> GSM213125     2  0.0000      0.976 0.000 1.000
#> GSM213073     2  0.0000      0.976 0.000 1.000
#> GSM213086     1  0.0000      0.992 1.000 0.000
#> GSM213098     1  0.0000      0.992 1.000 0.000
#> GSM213106     1  0.0000      0.992 1.000 0.000
#> GSM213124     2  0.3274      0.935 0.060 0.940

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM213078     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213082     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213085     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213088     1  0.5905     0.0534 0.648 0.000 0.352
#> GSM213091     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213092     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213096     1  0.7027     0.1896 0.660 0.044 0.296
#> GSM213100     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213111     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213117     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213118     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213120     2  0.0237     0.8822 0.004 0.996 0.000
#> GSM213122     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213074     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213077     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213083     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213094     2  0.5785     0.7639 0.000 0.668 0.332
#> GSM213095     2  0.4796     0.8229 0.000 0.780 0.220
#> GSM213102     1  0.4605     0.4954 0.796 0.000 0.204
#> GSM213103     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213104     2  0.6906     0.7079 0.192 0.724 0.084
#> GSM213107     2  0.2625     0.8733 0.000 0.916 0.084
#> GSM213108     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213112     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213114     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213115     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213116     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213119     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213072     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213075     2  0.5058     0.6479 0.244 0.756 0.000
#> GSM213076     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213079     2  0.5785     0.7639 0.000 0.668 0.332
#> GSM213080     2  0.5254     0.6114 0.264 0.736 0.000
#> GSM213081     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213084     3  0.5785     1.0000 0.332 0.000 0.668
#> GSM213087     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213089     1  0.4605     0.5165 0.796 0.204 0.000
#> GSM213090     2  0.5785     0.7639 0.000 0.668 0.332
#> GSM213093     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213097     1  0.1753     0.7124 0.952 0.000 0.048
#> GSM213099     1  0.6189     0.2860 0.632 0.364 0.004
#> GSM213101     1  0.5905     0.0534 0.648 0.000 0.352
#> GSM213105     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213109     1  0.1860     0.7084 0.948 0.000 0.052
#> GSM213110     2  0.5058     0.6476 0.244 0.756 0.000
#> GSM213113     1  0.6267     0.1626 0.548 0.452 0.000
#> GSM213121     2  0.1411     0.8837 0.000 0.964 0.036
#> GSM213123     1  0.6260     0.1737 0.552 0.448 0.000
#> GSM213125     2  0.0000     0.8830 0.000 1.000 0.000
#> GSM213073     2  0.5785     0.7639 0.000 0.668 0.332
#> GSM213086     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213098     1  0.0000     0.7506 1.000 0.000 0.000
#> GSM213106     1  0.4605     0.4954 0.796 0.000 0.204
#> GSM213124     2  0.0000     0.8830 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.1637      0.884 0.940 0.000 0.000 0.060
#> GSM213082     2  0.1396      0.926 0.004 0.960 0.032 0.004
#> GSM213085     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213088     1  0.3907      0.834 0.768 0.000 0.000 0.232
#> GSM213091     4  0.0000      0.915 0.000 0.000 0.000 1.000
#> GSM213092     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213096     1  0.3873      0.837 0.772 0.000 0.000 0.228
#> GSM213100     1  0.1557      0.884 0.944 0.000 0.000 0.056
#> GSM213111     2  0.1396      0.926 0.004 0.960 0.032 0.004
#> GSM213117     4  0.0469      0.912 0.012 0.000 0.000 0.988
#> GSM213118     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213120     2  0.1209      0.924 0.000 0.964 0.004 0.032
#> GSM213122     2  0.0188      0.932 0.000 0.996 0.004 0.000
#> GSM213074     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213077     1  0.1557      0.884 0.944 0.000 0.000 0.056
#> GSM213083     1  0.1022      0.870 0.968 0.000 0.000 0.032
#> GSM213094     3  0.1302      0.866 0.000 0.044 0.956 0.000
#> GSM213095     3  0.3718      0.787 0.012 0.168 0.820 0.000
#> GSM213102     1  0.3907      0.834 0.768 0.000 0.000 0.232
#> GSM213103     2  0.0000      0.932 0.000 1.000 0.000 0.000
#> GSM213104     2  0.1109      0.921 0.000 0.968 0.004 0.028
#> GSM213107     2  0.1936      0.923 0.028 0.940 0.032 0.000
#> GSM213108     3  0.5330      0.179 0.004 0.476 0.516 0.004
#> GSM213112     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213114     1  0.1022      0.870 0.968 0.000 0.000 0.032
#> GSM213115     2  0.0336      0.931 0.000 0.992 0.008 0.000
#> GSM213116     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213119     2  0.1302      0.910 0.000 0.956 0.044 0.000
#> GSM213072     4  0.0000      0.915 0.000 0.000 0.000 1.000
#> GSM213075     2  0.1109      0.919 0.004 0.968 0.000 0.028
#> GSM213076     2  0.1109      0.928 0.004 0.968 0.028 0.000
#> GSM213079     3  0.1302      0.866 0.000 0.044 0.956 0.000
#> GSM213080     2  0.5686      0.386 0.352 0.616 0.004 0.028
#> GSM213081     1  0.1474      0.883 0.948 0.000 0.000 0.052
#> GSM213084     1  0.1022      0.870 0.968 0.000 0.000 0.032
#> GSM213087     2  0.1767      0.907 0.012 0.944 0.044 0.000
#> GSM213089     4  0.1661      0.877 0.004 0.052 0.000 0.944
#> GSM213090     3  0.1302      0.866 0.000 0.044 0.956 0.000
#> GSM213093     4  0.0592      0.909 0.016 0.000 0.000 0.984
#> GSM213097     4  0.4643      0.351 0.344 0.000 0.000 0.656
#> GSM213099     4  0.4964      0.604 0.000 0.032 0.244 0.724
#> GSM213101     1  0.3907      0.834 0.768 0.000 0.000 0.232
#> GSM213105     2  0.1767      0.907 0.012 0.944 0.044 0.000
#> GSM213109     4  0.4697      0.316 0.356 0.000 0.000 0.644
#> GSM213110     2  0.1443      0.916 0.008 0.960 0.004 0.028
#> GSM213113     4  0.1489      0.879 0.000 0.044 0.004 0.952
#> GSM213121     2  0.1174      0.931 0.012 0.968 0.020 0.000
#> GSM213123     4  0.1489      0.879 0.000 0.044 0.004 0.952
#> GSM213125     2  0.1396      0.926 0.004 0.960 0.032 0.004
#> GSM213073     3  0.1302      0.866 0.000 0.044 0.956 0.000
#> GSM213086     4  0.0188      0.916 0.004 0.000 0.000 0.996
#> GSM213098     4  0.0000      0.915 0.000 0.000 0.000 1.000
#> GSM213106     1  0.3907      0.834 0.768 0.000 0.000 0.232
#> GSM213124     2  0.0188      0.933 0.004 0.996 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
#> GSM213078     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213082     5  0.1197      0.886 0.000 0.048 0.000 0.000 0.952
#> GSM213085     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213088     1  0.1041      0.865 0.964 0.000 0.000 0.004 0.032
#> GSM213091     4  0.0510      0.946 0.000 0.000 0.000 0.984 0.016
#> GSM213092     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213096     1  0.0404      0.868 0.988 0.000 0.000 0.012 0.000
#> GSM213100     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213111     5  0.1197      0.886 0.000 0.048 0.000 0.000 0.952
#> GSM213117     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213118     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213120     4  0.4151      0.440 0.000 0.344 0.000 0.652 0.004
#> GSM213122     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000
#> GSM213074     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213077     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213083     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM213095     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM213102     1  0.1041      0.865 0.964 0.000 0.000 0.004 0.032
#> GSM213103     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000
#> GSM213104     2  0.2471      0.768 0.136 0.864 0.000 0.000 0.000
#> GSM213107     2  0.0162      0.914 0.000 0.996 0.000 0.000 0.004
#> GSM213108     5  0.4697      0.520 0.000 0.032 0.320 0.000 0.648
#> GSM213112     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213114     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213115     2  0.0000      0.915 0.000 1.000 0.000 0.000 0.000
#> GSM213116     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213119     2  0.0162      0.915 0.000 0.996 0.000 0.000 0.004
#> GSM213072     4  0.0510      0.946 0.000 0.000 0.000 0.984 0.016
#> GSM213075     2  0.6202      0.136 0.372 0.484 0.000 0.144 0.000
#> GSM213076     2  0.0880      0.896 0.000 0.968 0.000 0.000 0.032
#> GSM213079     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM213080     1  0.3177      0.679 0.792 0.208 0.000 0.000 0.000
#> GSM213081     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000      0.871 1.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.0162      0.915 0.000 0.996 0.000 0.000 0.004
#> GSM213089     4  0.0162      0.948 0.000 0.000 0.000 0.996 0.004
#> GSM213090     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM213093     4  0.1478      0.882 0.064 0.000 0.000 0.936 0.000
#> GSM213097     1  0.3837      0.555 0.692 0.000 0.000 0.308 0.000
#> GSM213099     4  0.3562      0.727 0.000 0.000 0.196 0.788 0.016
#> GSM213101     1  0.0880      0.865 0.968 0.000 0.000 0.000 0.032
#> GSM213105     2  0.0162      0.915 0.000 0.996 0.000 0.000 0.004
#> GSM213109     1  0.4283      0.239 0.544 0.000 0.000 0.456 0.000
#> GSM213110     1  0.4287      0.114 0.540 0.460 0.000 0.000 0.000
#> GSM213113     4  0.0510      0.946 0.000 0.000 0.000 0.984 0.016
#> GSM213121     2  0.0162      0.914 0.000 0.996 0.000 0.000 0.004
#> GSM213123     4  0.0510      0.946 0.000 0.000 0.000 0.984 0.016
#> GSM213125     5  0.1197      0.886 0.000 0.048 0.000 0.000 0.952
#> GSM213073     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM213086     4  0.0000      0.949 0.000 0.000 0.000 1.000 0.000
#> GSM213098     4  0.0510      0.946 0.000 0.000 0.000 0.984 0.016
#> GSM213106     1  0.1041      0.865 0.964 0.000 0.000 0.004 0.032
#> GSM213124     2  0.0703      0.895 0.000 0.976 0.000 0.024 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM213078     1  0.0000     0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213082     6  0.0972     0.8629 0.000 0.008 0.000 0.028 0.000 0.964
#> GSM213085     4  0.3652     0.4407 0.004 0.000 0.000 0.672 0.324 0.000
#> GSM213088     1  0.2664     0.8091 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM213091     4  0.0146     0.4937 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM213092     4  0.3515     0.4405 0.000 0.000 0.000 0.676 0.324 0.000
#> GSM213096     1  0.4743     0.6404 0.680 0.008 0.000 0.088 0.224 0.000
#> GSM213100     1  0.2178     0.8194 0.868 0.000 0.000 0.000 0.132 0.000
#> GSM213111     6  0.0972     0.8629 0.000 0.008 0.000 0.028 0.000 0.964
#> GSM213117     4  0.3996    -0.3369 0.004 0.000 0.000 0.512 0.484 0.000
#> GSM213118     4  0.3652     0.4407 0.004 0.000 0.000 0.672 0.324 0.000
#> GSM213120     2  0.4188     0.6272 0.000 0.712 0.000 0.236 0.004 0.048
#> GSM213122     2  0.0632     0.9096 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM213074     4  0.3652     0.4407 0.004 0.000 0.000 0.672 0.324 0.000
#> GSM213077     1  0.2178     0.8194 0.868 0.000 0.000 0.000 0.132 0.000
#> GSM213083     1  0.0000     0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213094     3  0.0146     0.9910 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM213095     3  0.0547     0.9757 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM213102     1  0.3563     0.7649 0.664 0.000 0.000 0.000 0.336 0.000
#> GSM213103     2  0.0146     0.9105 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM213104     2  0.0291     0.9102 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM213107     2  0.3009     0.8544 0.000 0.844 0.000 0.004 0.112 0.040
#> GSM213108     6  0.4486     0.3671 0.000 0.004 0.384 0.028 0.000 0.584
#> GSM213112     4  0.3652     0.4407 0.004 0.000 0.000 0.672 0.324 0.000
#> GSM213114     1  0.0146     0.8484 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM213115     2  0.1141     0.9063 0.000 0.948 0.000 0.000 0.052 0.000
#> GSM213116     4  0.3797     0.0606 0.000 0.000 0.000 0.580 0.420 0.000
#> GSM213119     2  0.1984     0.8968 0.000 0.912 0.000 0.000 0.056 0.032
#> GSM213072     4  0.0547     0.4853 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM213075     2  0.0260     0.9101 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM213076     2  0.1644     0.8910 0.000 0.932 0.000 0.012 0.004 0.052
#> GSM213079     3  0.0000     0.9913 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213080     1  0.3615     0.5734 0.700 0.292 0.000 0.000 0.008 0.000
#> GSM213081     1  0.0000     0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213084     1  0.0000     0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM213087     2  0.3094     0.8453 0.000 0.824 0.000 0.000 0.140 0.036
#> GSM213089     4  0.3733     0.4463 0.000 0.008 0.000 0.700 0.288 0.004
#> GSM213090     3  0.0000     0.9913 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM213093     5  0.4123     0.6153 0.012 0.000 0.000 0.420 0.568 0.000
#> GSM213097     5  0.5173     0.8040 0.108 0.000 0.000 0.324 0.568 0.000
#> GSM213099     4  0.3278     0.2863 0.000 0.000 0.152 0.808 0.000 0.040
#> GSM213101     1  0.2664     0.8091 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM213105     2  0.3094     0.8453 0.000 0.824 0.000 0.000 0.140 0.036
#> GSM213109     5  0.5065     0.8218 0.092 0.000 0.000 0.340 0.568 0.000
#> GSM213110     2  0.0622     0.9085 0.012 0.980 0.000 0.000 0.008 0.000
#> GSM213113     4  0.1152     0.4715 0.004 0.000 0.000 0.952 0.000 0.044
#> GSM213121     2  0.3009     0.8544 0.000 0.844 0.000 0.004 0.112 0.040
#> GSM213123     4  0.1007     0.4719 0.000 0.000 0.000 0.956 0.000 0.044
#> GSM213125     6  0.0972     0.8629 0.000 0.008 0.000 0.028 0.000 0.964
#> GSM213073     3  0.0146     0.9910 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM213086     4  0.3515     0.4405 0.000 0.000 0.000 0.676 0.324 0.000
#> GSM213098     4  0.0291     0.4934 0.004 0.000 0.000 0.992 0.000 0.004
#> GSM213106     1  0.3371     0.7852 0.708 0.000 0.000 0.000 0.292 0.000
#> GSM213124     2  0.1155     0.9000 0.000 0.956 0.000 0.036 0.004 0.004

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

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

test_to_known_factors(res)
#>             n development.stage(p) disease.state(p) k
#> ATC:mclust 54                1.000            0.729 2
#> ATC:mclust 46                0.603            0.853 3
#> ATC:mclust 50                0.734            0.692 4
#> ATC:mclust 50                0.867            0.593 5
#> ATC:mclust 38                0.376            0.299 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 51941 rows and 54 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.922           0.899       0.964         0.2744 0.743   0.743
#> 3 3 0.965           0.948       0.981         0.9881 0.662   0.562
#> 4 4 0.751           0.837       0.915         0.1304 0.940   0.870
#> 5 5 0.647           0.717       0.849         0.1645 0.829   0.602
#> 6 6 0.593           0.611       0.788         0.0481 0.944   0.820

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
#> GSM213078     1   0.000     0.9668 1.000 0.000
#> GSM213082     2   0.689     0.7476 0.184 0.816
#> GSM213085     1   0.000     0.9668 1.000 0.000
#> GSM213088     1   0.000     0.9668 1.000 0.000
#> GSM213091     1   0.000     0.9668 1.000 0.000
#> GSM213092     1   0.000     0.9668 1.000 0.000
#> GSM213096     1   0.000     0.9668 1.000 0.000
#> GSM213100     1   0.000     0.9668 1.000 0.000
#> GSM213111     1   0.995     0.0502 0.540 0.460
#> GSM213117     1   0.000     0.9668 1.000 0.000
#> GSM213118     1   0.000     0.9668 1.000 0.000
#> GSM213120     1   0.000     0.9668 1.000 0.000
#> GSM213122     1   0.000     0.9668 1.000 0.000
#> GSM213074     1   0.000     0.9668 1.000 0.000
#> GSM213077     1   0.000     0.9668 1.000 0.000
#> GSM213083     1   0.000     0.9668 1.000 0.000
#> GSM213094     2   0.000     0.9075 0.000 1.000
#> GSM213095     2   0.000     0.9075 0.000 1.000
#> GSM213102     1   0.000     0.9668 1.000 0.000
#> GSM213103     1   0.000     0.9668 1.000 0.000
#> GSM213104     1   0.000     0.9668 1.000 0.000
#> GSM213107     1   0.978     0.2248 0.588 0.412
#> GSM213108     2   0.000     0.9075 0.000 1.000
#> GSM213112     1   0.000     0.9668 1.000 0.000
#> GSM213114     1   0.000     0.9668 1.000 0.000
#> GSM213115     1   0.000     0.9668 1.000 0.000
#> GSM213116     1   0.000     0.9668 1.000 0.000
#> GSM213119     1   0.000     0.9668 1.000 0.000
#> GSM213072     1   0.000     0.9668 1.000 0.000
#> GSM213075     1   0.000     0.9668 1.000 0.000
#> GSM213076     1   0.295     0.9149 0.948 0.052
#> GSM213079     2   0.000     0.9075 0.000 1.000
#> GSM213080     1   0.000     0.9668 1.000 0.000
#> GSM213081     1   0.000     0.9668 1.000 0.000
#> GSM213084     1   0.000     0.9668 1.000 0.000
#> GSM213087     1   0.000     0.9668 1.000 0.000
#> GSM213089     1   0.000     0.9668 1.000 0.000
#> GSM213090     2   0.000     0.9075 0.000 1.000
#> GSM213093     1   0.000     0.9668 1.000 0.000
#> GSM213097     1   0.000     0.9668 1.000 0.000
#> GSM213099     1   0.949     0.3714 0.632 0.368
#> GSM213101     1   0.000     0.9668 1.000 0.000
#> GSM213105     1   0.000     0.9668 1.000 0.000
#> GSM213109     1   0.000     0.9668 1.000 0.000
#> GSM213110     1   0.000     0.9668 1.000 0.000
#> GSM213113     1   0.000     0.9668 1.000 0.000
#> GSM213121     1   0.327     0.9063 0.940 0.060
#> GSM213123     1   0.000     0.9668 1.000 0.000
#> GSM213125     2   0.983     0.2631 0.424 0.576
#> GSM213073     2   0.000     0.9075 0.000 1.000
#> GSM213086     1   0.000     0.9668 1.000 0.000
#> GSM213098     1   0.000     0.9668 1.000 0.000
#> GSM213106     1   0.000     0.9668 1.000 0.000
#> GSM213124     1   0.000     0.9668 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
#> GSM213078     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213082     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213085     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213088     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213091     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213092     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213096     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213100     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213111     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213117     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213118     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213120     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213122     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213074     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213077     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213083     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213094     3  0.0000      0.997 0.000 0.000 1.000
#> GSM213095     3  0.0592      0.988 0.000 0.012 0.988
#> GSM213102     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213103     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213104     2  0.6026      0.358 0.376 0.624 0.000
#> GSM213107     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213108     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213112     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213114     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213115     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213116     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213119     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213072     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213075     1  0.3192      0.857 0.888 0.112 0.000
#> GSM213076     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213079     3  0.0000      0.997 0.000 0.000 1.000
#> GSM213080     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213081     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213084     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213087     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213089     1  0.0747      0.963 0.984 0.016 0.000
#> GSM213090     3  0.0000      0.997 0.000 0.000 1.000
#> GSM213093     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213097     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213099     1  0.5678      0.547 0.684 0.000 0.316
#> GSM213101     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213105     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213109     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213110     1  0.4750      0.711 0.784 0.216 0.000
#> GSM213113     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213121     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213123     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213125     2  0.0000      0.961 0.000 1.000 0.000
#> GSM213073     3  0.0000      0.997 0.000 0.000 1.000
#> GSM213086     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213098     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213106     1  0.0000      0.978 1.000 0.000 0.000
#> GSM213124     2  0.0000      0.961 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM213078     1  0.0921      0.901 0.972 0.000 0.000 0.028
#> GSM213082     2  0.2944      0.867 0.004 0.868 0.000 0.128
#> GSM213085     1  0.0188      0.908 0.996 0.000 0.000 0.004
#> GSM213088     1  0.0336      0.908 0.992 0.000 0.000 0.008
#> GSM213091     1  0.2589      0.851 0.884 0.000 0.000 0.116
#> GSM213092     1  0.0707      0.906 0.980 0.000 0.000 0.020
#> GSM213096     1  0.0817      0.903 0.976 0.000 0.000 0.024
#> GSM213100     1  0.1022      0.899 0.968 0.000 0.000 0.032
#> GSM213111     2  0.1716      0.899 0.000 0.936 0.000 0.064
#> GSM213117     1  0.1867      0.883 0.928 0.000 0.000 0.072
#> GSM213118     1  0.1637      0.889 0.940 0.000 0.000 0.060
#> GSM213120     2  0.3052      0.861 0.004 0.860 0.000 0.136
#> GSM213122     2  0.0000      0.916 0.000 1.000 0.000 0.000
#> GSM213074     1  0.0592      0.907 0.984 0.000 0.000 0.016
#> GSM213077     1  0.1022      0.899 0.968 0.000 0.000 0.032
#> GSM213083     1  0.1022      0.899 0.968 0.000 0.000 0.032
#> GSM213094     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM213095     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM213102     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM213103     2  0.4543      0.573 0.000 0.676 0.000 0.324
#> GSM213104     4  0.4426      0.478 0.096 0.092 0.000 0.812
#> GSM213107     2  0.2921      0.827 0.000 0.860 0.000 0.140
#> GSM213108     2  0.3280      0.863 0.000 0.860 0.016 0.124
#> GSM213112     1  0.0336      0.908 0.992 0.000 0.000 0.008
#> GSM213114     1  0.2530      0.820 0.888 0.000 0.000 0.112
#> GSM213115     2  0.0469      0.916 0.000 0.988 0.000 0.012
#> GSM213116     1  0.1389      0.895 0.952 0.000 0.000 0.048
#> GSM213119     2  0.0592      0.914 0.000 0.984 0.000 0.016
#> GSM213072     1  0.2760      0.841 0.872 0.000 0.000 0.128
#> GSM213075     1  0.5565      0.157 0.624 0.032 0.000 0.344
#> GSM213076     2  0.0469      0.916 0.000 0.988 0.000 0.012
#> GSM213079     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM213080     4  0.4746      0.586 0.368 0.000 0.000 0.632
#> GSM213081     1  0.1557      0.882 0.944 0.000 0.000 0.056
#> GSM213084     1  0.1022      0.899 0.968 0.000 0.000 0.032
#> GSM213087     2  0.0469      0.915 0.000 0.988 0.000 0.012
#> GSM213089     1  0.2805      0.855 0.888 0.012 0.000 0.100
#> GSM213090     4  0.3870      0.209 0.000 0.004 0.208 0.788
#> GSM213093     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM213097     1  0.0469      0.907 0.988 0.000 0.000 0.012
#> GSM213099     1  0.5483      0.676 0.736 0.000 0.136 0.128
#> GSM213101     1  0.0469      0.907 0.988 0.000 0.000 0.012
#> GSM213105     2  0.0188      0.916 0.000 0.996 0.000 0.004
#> GSM213109     1  0.0000      0.908 1.000 0.000 0.000 0.000
#> GSM213110     4  0.6024      0.509 0.416 0.044 0.000 0.540
#> GSM213113     1  0.4511      0.739 0.784 0.040 0.000 0.176
#> GSM213121     2  0.0817      0.911 0.000 0.976 0.000 0.024
#> GSM213123     1  0.4035      0.766 0.804 0.020 0.000 0.176
#> GSM213125     2  0.2760      0.869 0.000 0.872 0.000 0.128
#> GSM213073     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM213086     1  0.0817      0.905 0.976 0.000 0.000 0.024
#> GSM213098     1  0.3266      0.800 0.832 0.000 0.000 0.168
#> GSM213106     1  0.0188      0.908 0.996 0.000 0.000 0.004
#> GSM213124     2  0.0336      0.915 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM213078     1  0.0404     0.8519 0.988 0.000 0.000 0.012 0.000
#> GSM213082     2  0.2448     0.8197 0.000 0.892 0.000 0.088 0.020
#> GSM213085     1  0.0955     0.8579 0.968 0.000 0.000 0.028 0.004
#> GSM213088     1  0.1251     0.8565 0.956 0.000 0.000 0.036 0.008
#> GSM213091     4  0.2561     0.8367 0.144 0.000 0.000 0.856 0.000
#> GSM213092     1  0.1704     0.8445 0.928 0.000 0.000 0.068 0.004
#> GSM213096     1  0.0703     0.8585 0.976 0.000 0.000 0.024 0.000
#> GSM213100     1  0.0579     0.8568 0.984 0.000 0.000 0.008 0.008
#> GSM213111     2  0.1485     0.8436 0.000 0.948 0.000 0.032 0.020
#> GSM213117     4  0.3734     0.7997 0.240 0.004 0.000 0.752 0.004
#> GSM213118     1  0.4403     0.3351 0.608 0.000 0.000 0.384 0.008
#> GSM213120     2  0.4747     0.1447 0.000 0.500 0.000 0.484 0.016
#> GSM213122     2  0.0324     0.8525 0.000 0.992 0.000 0.004 0.004
#> GSM213074     4  0.3398     0.8168 0.216 0.000 0.000 0.780 0.004
#> GSM213077     1  0.0451     0.8574 0.988 0.000 0.000 0.008 0.004
#> GSM213083     1  0.0693     0.8554 0.980 0.000 0.000 0.012 0.008
#> GSM213094     4  0.4354     0.2597 0.000 0.000 0.368 0.624 0.008
#> GSM213095     3  0.1560     0.9297 0.000 0.020 0.948 0.028 0.004
#> GSM213102     1  0.0963     0.8572 0.964 0.000 0.000 0.036 0.000
#> GSM213103     2  0.4323     0.5018 0.012 0.656 0.000 0.000 0.332
#> GSM213104     5  0.4846     0.4519 0.084 0.108 0.000 0.040 0.768
#> GSM213107     2  0.3099     0.7740 0.000 0.848 0.000 0.028 0.124
#> GSM213108     2  0.4338     0.7214 0.000 0.764 0.028 0.188 0.020
#> GSM213112     1  0.1557     0.8513 0.940 0.000 0.000 0.052 0.008
#> GSM213114     1  0.1106     0.8433 0.964 0.000 0.000 0.012 0.024
#> GSM213115     2  0.0609     0.8502 0.000 0.980 0.000 0.000 0.020
#> GSM213116     1  0.4383     0.1935 0.572 0.000 0.000 0.424 0.004
#> GSM213119     2  0.0566     0.8523 0.000 0.984 0.000 0.004 0.012
#> GSM213072     4  0.2886     0.8361 0.148 0.000 0.008 0.844 0.000
#> GSM213075     5  0.6055     0.3773 0.056 0.068 0.000 0.240 0.636
#> GSM213076     2  0.1282     0.8422 0.000 0.952 0.000 0.004 0.044
#> GSM213079     3  0.0000     0.9461 0.000 0.000 1.000 0.000 0.000
#> GSM213080     1  0.4962    -0.0496 0.544 0.016 0.000 0.008 0.432
#> GSM213081     1  0.3578     0.7547 0.820 0.000 0.000 0.048 0.132
#> GSM213084     1  0.0290     0.8551 0.992 0.000 0.000 0.000 0.008
#> GSM213087     2  0.0290     0.8518 0.000 0.992 0.000 0.000 0.008
#> GSM213089     4  0.3445     0.8200 0.140 0.036 0.000 0.824 0.000
#> GSM213090     5  0.4973    -0.1206 0.004 0.000 0.376 0.028 0.592
#> GSM213093     1  0.3123     0.7642 0.828 0.000 0.000 0.160 0.012
#> GSM213097     1  0.3461     0.6832 0.772 0.000 0.000 0.224 0.004
#> GSM213099     4  0.3401     0.7858 0.096 0.000 0.064 0.840 0.000
#> GSM213101     1  0.0566     0.8542 0.984 0.000 0.000 0.012 0.004
#> GSM213105     2  0.0798     0.8508 0.000 0.976 0.000 0.016 0.008
#> GSM213109     1  0.0880     0.8579 0.968 0.000 0.000 0.032 0.000
#> GSM213110     5  0.5995     0.3382 0.384 0.056 0.000 0.028 0.532
#> GSM213113     1  0.4985     0.5028 0.660 0.024 0.000 0.296 0.020
#> GSM213121     2  0.1740     0.8319 0.000 0.932 0.000 0.012 0.056
#> GSM213123     4  0.4141     0.8006 0.196 0.016 0.000 0.768 0.020
#> GSM213125     2  0.1943     0.8357 0.000 0.924 0.000 0.056 0.020
#> GSM213073     3  0.1444     0.9386 0.000 0.000 0.948 0.040 0.012
#> GSM213086     1  0.1544     0.8462 0.932 0.000 0.000 0.068 0.000
#> GSM213098     4  0.4096     0.7635 0.260 0.004 0.000 0.724 0.012
#> GSM213106     1  0.0703     0.8592 0.976 0.000 0.000 0.024 0.000
#> GSM213124     2  0.3916     0.7031 0.012 0.772 0.000 0.204 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
#> GSM213078     1  0.0260     0.8052 0.992 0.000 0.000 0.000 0.000 NA
#> GSM213082     2  0.4237     0.6236 0.000 0.736 0.000 0.144 0.000 NA
#> GSM213085     1  0.2454     0.7893 0.876 0.004 0.000 0.016 0.000 NA
#> GSM213088     1  0.1690     0.8029 0.940 0.004 0.000 0.020 0.016 NA
#> GSM213091     4  0.1297     0.7285 0.040 0.000 0.000 0.948 0.000 NA
#> GSM213092     1  0.4177     0.6967 0.712 0.004 0.000 0.028 0.008 NA
#> GSM213096     1  0.1377     0.8077 0.952 0.004 0.000 0.016 0.004 NA
#> GSM213100     1  0.1053     0.8043 0.964 0.004 0.000 0.000 0.012 NA
#> GSM213111     2  0.2679     0.7060 0.000 0.864 0.000 0.040 0.000 NA
#> GSM213117     4  0.4635     0.6828 0.136 0.020 0.000 0.728 0.000 NA
#> GSM213118     1  0.5390     0.1787 0.500 0.004 0.000 0.396 0.000 NA
#> GSM213120     4  0.4955     0.4308 0.004 0.284 0.000 0.624 0.000 NA
#> GSM213122     2  0.0000     0.7272 0.000 1.000 0.000 0.000 0.000 NA
#> GSM213074     4  0.2362     0.7211 0.080 0.000 0.000 0.892 0.012 NA
#> GSM213077     1  0.0436     0.8062 0.988 0.000 0.000 0.004 0.004 NA
#> GSM213083     1  0.0862     0.8031 0.972 0.000 0.000 0.004 0.016 NA
#> GSM213094     4  0.4575     0.4616 0.000 0.000 0.196 0.720 0.032 NA
#> GSM213095     3  0.4691     0.5775 0.000 0.088 0.744 0.000 0.112 NA
#> GSM213102     1  0.1552     0.8059 0.940 0.004 0.000 0.020 0.000 NA
#> GSM213103     2  0.6978     0.1237 0.136 0.456 0.000 0.008 0.308 NA
#> GSM213104     5  0.4386     0.3687 0.108 0.112 0.012 0.000 0.760 NA
#> GSM213107     2  0.4583     0.4295 0.000 0.616 0.016 0.000 0.344 NA
#> GSM213108     2  0.5704     0.4831 0.000 0.592 0.036 0.264 0.000 NA
#> GSM213112     1  0.3627     0.7632 0.808 0.000 0.000 0.028 0.032 NA
#> GSM213114     1  0.0891     0.8041 0.968 0.000 0.000 0.000 0.024 NA
#> GSM213115     2  0.2849     0.6905 0.084 0.864 0.000 0.000 0.044 NA
#> GSM213116     1  0.5063     0.1297 0.500 0.004 0.000 0.432 0.000 NA
#> GSM213119     2  0.2051     0.7200 0.040 0.916 0.000 0.000 0.036 NA
#> GSM213072     4  0.1492     0.7267 0.036 0.000 0.000 0.940 0.000 NA
#> GSM213075     5  0.6852     0.3691 0.056 0.064 0.000 0.292 0.516 NA
#> GSM213076     2  0.4538     0.5651 0.000 0.696 0.000 0.060 0.232 NA
#> GSM213079     3  0.0725     0.7021 0.000 0.000 0.976 0.012 0.000 NA
#> GSM213080     1  0.5032     0.4198 0.648 0.028 0.000 0.000 0.264 NA
#> GSM213081     1  0.3925     0.7107 0.804 0.004 0.000 0.048 0.108 NA
#> GSM213084     1  0.0291     0.8056 0.992 0.000 0.000 0.000 0.004 NA
#> GSM213087     2  0.1251     0.7268 0.012 0.956 0.000 0.000 0.024 NA
#> GSM213089     4  0.2465     0.7218 0.024 0.024 0.000 0.900 0.004 NA
#> GSM213090     5  0.5661    -0.0601 0.000 0.004 0.320 0.004 0.536 NA
#> GSM213093     1  0.4650     0.6306 0.688 0.000 0.000 0.212 0.004 NA
#> GSM213097     1  0.4792     0.5508 0.644 0.000 0.000 0.260 0.000 NA
#> GSM213099     4  0.1994     0.7087 0.024 0.000 0.016 0.928 0.016 NA
#> GSM213101     1  0.0964     0.8021 0.968 0.004 0.000 0.000 0.012 NA
#> GSM213105     2  0.0964     0.7299 0.012 0.968 0.000 0.000 0.004 NA
#> GSM213109     1  0.2636     0.7841 0.860 0.004 0.000 0.016 0.000 NA
#> GSM213110     1  0.6653     0.1171 0.520 0.088 0.000 0.000 0.208 NA
#> GSM213113     4  0.6543     0.2170 0.336 0.024 0.000 0.384 0.000 NA
#> GSM213121     2  0.3680     0.5958 0.000 0.756 0.008 0.000 0.216 NA
#> GSM213123     4  0.4703     0.6820 0.088 0.020 0.000 0.712 0.000 NA
#> GSM213125     2  0.2979     0.6961 0.000 0.840 0.000 0.044 0.000 NA
#> GSM213073     3  0.3558     0.6345 0.000 0.000 0.736 0.016 0.000 NA
#> GSM213086     1  0.3966     0.7055 0.728 0.000 0.000 0.028 0.008 NA
#> GSM213098     4  0.4692     0.6679 0.152 0.008 0.000 0.716 0.004 NA
#> GSM213106     1  0.1442     0.8028 0.944 0.004 0.000 0.000 0.012 NA
#> GSM213124     2  0.6621     0.4898 0.136 0.604 0.000 0.140 0.048 NA

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 development.stage(p) disease.state(p) k
#> ATC:NMF 50                1.000            0.481 2
#> ATC:NMF 53                0.666            0.402 3
#> ATC:NMF 51                0.464            0.276 4
#> ATC:NMF 45                0.730            0.606 5
#> ATC:NMF 40                0.727            0.444 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