cola Report for GDS1479

Date: 2019-12-25 20:17:11 CET, cola version: 1.3.2

Document is loading...


Summary

All available functions which can be applied to this res_list object:

res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#>   Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#>   Number of partitions are tried for k = 2, 3, 4, 5, 6.
#>   Performed in total 30000 partitions by row resampling.
#> 
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#>  [1] "cola_report"           "collect_classes"       "collect_plots"         "collect_stats"        
#>  [5] "colnames"              "functional_enrichment" "get_anno_col"          "get_anno"             
#>  [9] "get_classes"           "get_matrix"            "get_membership"        "get_stats"            
#> [13] "is_best_k"             "is_stable_k"           "ncol"                  "nrow"                 
#> [17] "rownames"              "show"                  "suggest_best_k"        "test_to_known_factors"
#> [21] "top_rows_heatmap"      "top_rows_overlap"     
#> 
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]

The call of run_all_consensus_partition_methods() was:

#> run_all_consensus_partition_methods(data = mat, mc.cores = 4, anno = anno)

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 21168    60

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:kmeans 3 1.000 0.988 0.995 ** 2
ATC:skmeans 2 1.000 0.992 0.997 **
MAD:skmeans 3 0.949 0.930 0.973 *
SD:NMF 3 0.918 0.876 0.953 *
SD:skmeans 4 0.916 0.876 0.934 * 3
CV:skmeans 4 0.909 0.874 0.936 * 3
ATC:pam 6 0.905 0.796 0.912 * 2,3,4
CV:NMF 3 0.904 0.887 0.956 *
MAD:NMF 3 0.904 0.872 0.951 *
CV:pam 6 0.868 0.884 0.924
ATC:NMF 2 0.867 0.923 0.964
ATC:hclust 3 0.828 0.834 0.939
ATC:mclust 6 0.821 0.856 0.904
CV:kmeans 3 0.813 0.860 0.930
CV:hclust 3 0.784 0.829 0.904
SD:pam 4 0.762 0.823 0.910
MAD:pam 4 0.738 0.808 0.896
SD:hclust 4 0.721 0.796 0.897
SD:kmeans 3 0.700 0.912 0.939
MAD:kmeans 3 0.685 0.895 0.936
CV:mclust 5 0.675 0.770 0.856
MAD:mclust 3 0.594 0.737 0.836
MAD:hclust 2 0.499 0.809 0.893
SD:mclust 3 0.447 0.734 0.862

**: 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.539           0.842       0.924          0.453 0.528   0.528
#> CV:NMF      2 0.710           0.878       0.944          0.472 0.519   0.519
#> MAD:NMF     2 0.752           0.905       0.954          0.481 0.519   0.519
#> ATC:NMF     2 0.867           0.923       0.964          0.502 0.501   0.501
#> SD:skmeans  2 0.622           0.832       0.928          0.496 0.506   0.506
#> CV:skmeans  2 0.649           0.826       0.929          0.497 0.501   0.501
#> MAD:skmeans 2 0.645           0.869       0.938          0.497 0.501   0.501
#> ATC:skmeans 2 1.000           0.992       0.997          0.499 0.501   0.501
#> SD:mclust   2 0.492           0.901       0.892          0.380 0.619   0.619
#> CV:mclust   2 0.417           0.529       0.745          0.429 0.636   0.636
#> MAD:mclust  2 0.363           0.439       0.799          0.420 0.494   0.494
#> ATC:mclust  2 0.721           0.856       0.939          0.467 0.512   0.512
#> SD:kmeans   2 0.439           0.784       0.896          0.426 0.548   0.548
#> CV:kmeans   2 0.420           0.833       0.913          0.454 0.537   0.537
#> MAD:kmeans  2 0.438           0.851       0.923          0.469 0.512   0.512
#> ATC:kmeans  2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:pam      2 0.465           0.739       0.831          0.389 0.655   0.655
#> CV:pam      2 0.345           0.716       0.858          0.441 0.548   0.548
#> MAD:pam     2 0.398           0.775       0.870          0.443 0.573   0.573
#> ATC:pam     2 0.965           0.978       0.989          0.495 0.501   0.501
#> SD:hclust   2 0.404           0.722       0.870          0.395 0.619   0.619
#> CV:hclust   2 0.484           0.761       0.868          0.433 0.619   0.619
#> MAD:hclust  2 0.499           0.809       0.893          0.433 0.573   0.573
#> ATC:hclust  2 0.574           0.790       0.909          0.357 0.675   0.675
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.918           0.876       0.953          0.433 0.702   0.495
#> CV:NMF      3 0.904           0.887       0.956          0.389 0.711   0.498
#> MAD:NMF     3 0.904           0.872       0.951          0.352 0.711   0.502
#> ATC:NMF     3 0.753           0.862       0.922          0.280 0.801   0.623
#> SD:skmeans  3 1.000           0.955       0.983          0.346 0.749   0.538
#> CV:skmeans  3 0.974           0.923       0.974          0.342 0.742   0.527
#> MAD:skmeans 3 0.949           0.930       0.973          0.342 0.734   0.517
#> ATC:skmeans 3 0.790           0.890       0.933          0.156 0.934   0.870
#> SD:mclust   3 0.447           0.734       0.862          0.518 0.572   0.422
#> CV:mclust   3 0.501           0.736       0.821          0.415 0.501   0.325
#> MAD:mclust  3 0.594           0.737       0.836          0.460 0.708   0.480
#> ATC:mclust  3 0.521           0.800       0.885          0.266 0.795   0.639
#> SD:kmeans   3 0.700           0.912       0.939          0.488 0.656   0.446
#> CV:kmeans   3 0.813           0.860       0.930          0.427 0.670   0.458
#> MAD:kmeans  3 0.685           0.895       0.936          0.379 0.675   0.451
#> ATC:kmeans  3 1.000           0.988       0.995          0.234 0.828   0.693
#> SD:pam      3 0.515           0.619       0.816          0.557 0.668   0.533
#> CV:pam      3 0.588           0.660       0.830          0.404 0.712   0.529
#> MAD:pam     3 0.528           0.667       0.822          0.397 0.723   0.555
#> ATC:pam     3 1.000           0.997       0.999          0.172 0.919   0.837
#> SD:hclust   3 0.596           0.751       0.856          0.404 0.643   0.476
#> CV:hclust   3 0.784           0.829       0.904          0.460 0.738   0.576
#> MAD:hclust  3 0.539           0.616       0.763          0.344 0.700   0.503
#> ATC:hclust  3 0.828           0.834       0.939          0.629 0.692   0.559
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.799           0.859       0.923         0.1188 0.896   0.720
#> CV:NMF      4 0.899           0.868       0.932         0.1134 0.898   0.717
#> MAD:NMF     4 0.806           0.828       0.905         0.1246 0.885   0.690
#> ATC:NMF     4 0.565           0.633       0.774         0.1247 0.915   0.783
#> SD:skmeans  4 0.916           0.876       0.934         0.0960 0.940   0.819
#> CV:skmeans  4 0.909           0.874       0.936         0.0995 0.897   0.704
#> MAD:skmeans 4 0.835           0.857       0.914         0.1003 0.916   0.758
#> ATC:skmeans 4 0.813           0.790       0.909         0.0963 0.964   0.919
#> SD:mclust   4 0.650           0.726       0.857         0.1971 0.697   0.413
#> CV:mclust   4 0.638           0.760       0.873         0.1265 0.795   0.528
#> MAD:mclust  4 0.652           0.688       0.814         0.1233 0.884   0.692
#> ATC:mclust  4 0.590           0.792       0.798         0.1383 0.897   0.767
#> SD:kmeans   4 0.712           0.848       0.884         0.1317 0.862   0.646
#> CV:kmeans   4 0.716           0.810       0.866         0.1187 0.903   0.734
#> MAD:kmeans  4 0.721           0.767       0.837         0.1265 0.899   0.723
#> ATC:kmeans  4 0.697           0.723       0.851         0.2396 0.824   0.589
#> SD:pam      4 0.762           0.823       0.910         0.1813 0.710   0.419
#> CV:pam      4 0.662           0.787       0.897         0.1652 0.702   0.376
#> MAD:pam     4 0.738           0.808       0.896         0.1604 0.715   0.405
#> ATC:pam     4 0.976           0.947       0.978         0.2320 0.873   0.697
#> SD:hclust   4 0.721           0.796       0.897         0.2593 0.912   0.778
#> CV:hclust   4 0.884           0.881       0.939         0.0933 0.968   0.911
#> MAD:hclust  4 0.624           0.702       0.819         0.2016 0.863   0.650
#> ATC:hclust  4 0.719           0.611       0.794         0.1557 0.880   0.724
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.716           0.668       0.798         0.0852 0.882   0.604
#> CV:NMF      5 0.732           0.735       0.803         0.0864 0.919   0.705
#> MAD:NMF     5 0.677           0.572       0.789         0.0853 0.914   0.697
#> ATC:NMF     5 0.588           0.549       0.717         0.0600 0.850   0.590
#> SD:skmeans  5 0.780           0.692       0.849         0.0875 0.893   0.637
#> CV:skmeans  5 0.809           0.790       0.861         0.0885 0.909   0.669
#> MAD:skmeans 5 0.793           0.768       0.862         0.0891 0.891   0.622
#> ATC:skmeans 5 0.785           0.776       0.875         0.0655 0.903   0.765
#> SD:mclust   5 0.719           0.709       0.814         0.1235 0.889   0.633
#> CV:mclust   5 0.675           0.770       0.856         0.1310 0.819   0.486
#> MAD:mclust  5 0.657           0.649       0.767         0.1302 0.841   0.516
#> ATC:mclust  5 0.706           0.823       0.870         0.1434 0.770   0.432
#> SD:kmeans   5 0.711           0.660       0.773         0.0899 0.905   0.676
#> CV:kmeans   5 0.706           0.672       0.809         0.0855 0.927   0.745
#> MAD:kmeans  5 0.746           0.763       0.827         0.0845 0.892   0.629
#> ATC:kmeans  5 0.756           0.689       0.845         0.0781 0.856   0.537
#> SD:pam      5 0.758           0.763       0.848         0.1113 0.858   0.534
#> CV:pam      5 0.806           0.842       0.912         0.1042 0.820   0.450
#> MAD:pam     5 0.744           0.764       0.881         0.1097 0.858   0.534
#> ATC:pam     5 0.884           0.838       0.917         0.0576 0.956   0.851
#> SD:hclust   5 0.694           0.535       0.776         0.0973 0.897   0.688
#> CV:hclust   5 0.775           0.524       0.763         0.0968 0.937   0.815
#> MAD:hclust  5 0.720           0.674       0.847         0.0919 0.854   0.575
#> ATC:hclust  5 0.689           0.636       0.805         0.0630 0.944   0.844
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.753           0.646       0.814         0.0385 0.940   0.732
#> CV:NMF      6 0.739           0.717       0.816         0.0351 0.950   0.775
#> MAD:NMF     6 0.760           0.623       0.801         0.0355 0.922   0.676
#> ATC:NMF     6 0.583           0.570       0.726         0.0429 0.941   0.763
#> SD:skmeans  6 0.766           0.705       0.809         0.0405 0.892   0.540
#> CV:skmeans  6 0.781           0.765       0.858         0.0403 0.937   0.700
#> MAD:skmeans 6 0.785           0.790       0.864         0.0395 0.950   0.754
#> ATC:skmeans 6 0.738           0.746       0.886         0.0414 0.968   0.903
#> SD:mclust   6 0.763           0.682       0.823         0.0540 0.864   0.474
#> CV:mclust   6 0.738           0.729       0.831         0.0534 0.893   0.556
#> MAD:mclust  6 0.766           0.709       0.855         0.0511 0.920   0.641
#> ATC:mclust  6 0.821           0.856       0.904         0.0608 0.929   0.694
#> SD:kmeans   6 0.736           0.562       0.744         0.0523 0.880   0.516
#> CV:kmeans   6 0.742           0.603       0.771         0.0499 0.903   0.594
#> MAD:kmeans  6 0.735           0.613       0.749         0.0445 0.964   0.823
#> ATC:kmeans  6 0.736           0.536       0.715         0.0519 0.892   0.552
#> SD:pam      6 0.782           0.734       0.870         0.0363 0.951   0.766
#> CV:pam      6 0.868           0.884       0.924         0.0356 0.949   0.762
#> MAD:pam     6 0.779           0.766       0.870         0.0350 0.923   0.658
#> ATC:pam     6 0.905           0.796       0.912         0.0356 0.937   0.759
#> SD:hclust   6 0.732           0.658       0.752         0.0647 0.876   0.564
#> CV:hclust   6 0.778           0.800       0.853         0.0690 0.849   0.511
#> MAD:hclust  6 0.771           0.764       0.831         0.0809 0.890   0.574
#> ATC:hclust  6 0.700           0.679       0.785         0.0758 0.818   0.484

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 specimen(p) k
#> SD:NMF      58    1.91e-08 2
#> CV:NMF      58    1.91e-08 2
#> MAD:NMF     58    9.22e-08 2
#> ATC:NMF     58    2.56e-05 2
#> SD:skmeans  54    4.79e-07 2
#> CV:skmeans  56    9.33e-07 2
#> MAD:skmeans 57    1.62e-06 2
#> ATC:skmeans 60    2.25e-05 2
#> SD:mclust   60    1.41e-08 2
#> CV:mclust   51    3.55e-04 2
#> MAD:mclust  40    7.83e-07 2
#> ATC:mclust  54    2.22e-07 2
#> SD:kmeans   58    6.58e-09 2
#> CV:kmeans   57    3.27e-08 2
#> MAD:kmeans  57    1.61e-07 2
#> ATC:kmeans  60    9.01e-06 2
#> SD:pam      56    1.35e-07 2
#> CV:pam      57    2.68e-07 2
#> MAD:pam     58    1.09e-08 2
#> ATC:pam     60    2.25e-05 2
#> SD:hclust   55    1.51e-08 2
#> CV:hclust   57    4.54e-08 2
#> MAD:hclust  58    3.57e-09 2
#> ATC:hclust  57    8.16e-06 2
test_to_known_factors(res_list, k = 3)
#>              n specimen(p) k
#> SD:NMF      56    1.09e-10 3
#> CV:NMF      58    4.23e-11 3
#> MAD:NMF     56    1.09e-10 3
#> ATC:NMF     58    7.47e-13 3
#> SD:skmeans  59    7.79e-12 3
#> CV:skmeans  57    6.19e-11 3
#> MAD:skmeans 57    6.19e-11 3
#> ATC:skmeans 60    3.05e-06 3
#> SD:mclust   55    5.84e-06 3
#> CV:mclust   55    6.22e-12 3
#> MAD:mclust  56    5.63e-12 3
#> ATC:mclust  58    4.25e-06 3
#> SD:kmeans   59    7.25e-09 3
#> CV:kmeans   55    2.71e-10 3
#> MAD:kmeans  59    2.18e-08 3
#> ATC:kmeans  60    1.71e-07 3
#> SD:pam      49    5.61e-07 3
#> CV:pam      50    1.71e-06 3
#> MAD:pam     52    8.83e-07 3
#> ATC:pam     60    1.71e-07 3
#> SD:hclust   54    9.33e-11 3
#> CV:hclust   56    4.27e-10 3
#> MAD:hclust  52    1.37e-11 3
#> ATC:hclust  57    3.81e-06 3
test_to_known_factors(res_list, k = 4)
#>              n specimen(p) k
#> SD:NMF      59    7.71e-16 4
#> CV:NMF      57    6.20e-16 4
#> MAD:NMF     54    3.51e-17 4
#> ATC:NMF     47    1.16e-11 4
#> SD:skmeans  57    4.89e-16 4
#> CV:skmeans  55    7.74e-15 4
#> MAD:skmeans 56    3.37e-14 4
#> ATC:skmeans 54    1.71e-06 4
#> SD:mclust   55    8.75e-15 4
#> CV:mclust   55    3.08e-09 4
#> MAD:mclust  46    2.20e-11 4
#> ATC:mclust  59    3.32e-11 4
#> SD:kmeans   60    3.09e-16 4
#> CV:kmeans   57    2.32e-14 4
#> MAD:kmeans  53    1.24e-12 4
#> ATC:kmeans  50    7.67e-10 4
#> SD:pam      55    4.22e-12 4
#> CV:pam      55    8.51e-15 4
#> MAD:pam     60    6.21e-12 4
#> ATC:pam     59    4.91e-09 4
#> SD:hclust   52    2.71e-15 4
#> CV:hclust   56    2.80e-13 4
#> MAD:hclust  56    1.13e-15 4
#> ATC:hclust  38    1.54e-06 4
test_to_known_factors(res_list, k = 5)
#>              n specimen(p) k
#> SD:NMF      50    5.07e-13 5
#> CV:NMF      54    9.85e-13 5
#> MAD:NMF     37    1.24e-12 5
#> ATC:NMF     41    4.21e-10 5
#> SD:skmeans  47    1.60e-16 5
#> CV:skmeans  56    1.81e-20 5
#> MAD:skmeans 56    2.32e-20 5
#> ATC:skmeans 53    2.00e-08 5
#> SD:mclust   53    2.00e-16 5
#> CV:mclust   57    1.13e-16 5
#> MAD:mclust  47    1.22e-16 5
#> ATC:mclust  58    5.63e-16 5
#> SD:kmeans   48    8.46e-17 5
#> CV:kmeans   50    3.63e-18 5
#> MAD:kmeans  57    2.30e-19 5
#> ATC:kmeans  47    2.87e-08 5
#> SD:pam      56    1.21e-14 5
#> CV:pam      55    8.02e-18 5
#> MAD:pam     54    1.94e-14 5
#> ATC:pam     56    3.83e-11 5
#> SD:hclust   44    1.54e-15 5
#> CV:hclust   41    3.09e-10 5
#> MAD:hclust  41    2.10e-14 5
#> ATC:hclust  51    1.16e-07 5
test_to_known_factors(res_list, k = 6)
#>              n specimen(p) k
#> SD:NMF      48    5.21e-15 6
#> CV:NMF      53    2.06e-16 6
#> MAD:NMF     46    1.27e-15 6
#> ATC:NMF     42    5.79e-09 6
#> SD:skmeans  53    6.68e-21 6
#> CV:skmeans  56    1.03e-20 6
#> MAD:skmeans 57    2.48e-21 6
#> ATC:skmeans 52    2.32e-09 6
#> SD:mclust   47    3.04e-16 6
#> CV:mclust   52    2.38e-18 6
#> MAD:mclust  51    7.05e-18 6
#> ATC:mclust  60    6.17e-18 6
#> SD:kmeans   32    1.76e-10 6
#> CV:kmeans   49    3.43e-19 6
#> MAD:kmeans  46    1.13e-17 6
#> ATC:kmeans  40    2.81e-07 6
#> SD:pam      54    6.39e-14 6
#> CV:pam      59    7.49e-15 6
#> MAD:pam     52    7.88e-15 6
#> ATC:pam     49    2.98e-10 6
#> SD:hclust   52    2.61e-19 6
#> CV:hclust   55    3.61e-18 6
#> MAD:hclust  56    1.29e-20 6
#> ATC:hclust  45    3.56e-10 6

Results for each method


SD:hclust

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

res = res_list["SD", "hclust"]
# you can also extract it by
# res = res_list["SD:hclust"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.404           0.722       0.870         0.3947 0.619   0.619
#> 3 3 0.596           0.751       0.856         0.4040 0.643   0.476
#> 4 4 0.721           0.796       0.897         0.2593 0.912   0.778
#> 5 5 0.694           0.535       0.776         0.0973 0.897   0.688
#> 6 6 0.732           0.658       0.752         0.0647 0.876   0.564

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
#> GSM71019     1  0.8608      0.547 0.716 0.284
#> GSM71020     2  0.0000      0.811 0.000 1.000
#> GSM71021     2  0.0000      0.811 0.000 1.000
#> GSM71022     2  0.1414      0.808 0.020 0.980
#> GSM71023     1  0.8608      0.547 0.716 0.284
#> GSM71024     1  0.1633      0.832 0.976 0.024
#> GSM71025     2  0.0000      0.811 0.000 1.000
#> GSM71026     2  0.0000      0.811 0.000 1.000
#> GSM71027     2  0.0000      0.811 0.000 1.000
#> GSM71028     1  0.7602      0.725 0.780 0.220
#> GSM71030     1  0.1633      0.832 0.976 0.024
#> GSM71032     1  0.0000      0.832 1.000 0.000
#> GSM71034     1  0.0000      0.832 1.000 0.000
#> GSM71035     1  0.9933      0.209 0.548 0.452
#> GSM71038     1  0.0000      0.832 1.000 0.000
#> GSM71043     1  0.7602      0.725 0.780 0.220
#> GSM71046     1  0.0000      0.832 1.000 0.000
#> GSM71053     1  0.0000      0.832 1.000 0.000
#> GSM71061     1  0.7745      0.719 0.772 0.228
#> GSM71062     1  0.2236      0.830 0.964 0.036
#> GSM71063     1  0.7602      0.725 0.780 0.220
#> GSM71068     1  0.0376      0.833 0.996 0.004
#> GSM71029     1  0.1414      0.826 0.980 0.020
#> GSM71031     1  0.1843      0.832 0.972 0.028
#> GSM71033     1  0.3733      0.817 0.928 0.072
#> GSM71036     1  0.0000      0.832 1.000 0.000
#> GSM71042     1  0.0000      0.832 1.000 0.000
#> GSM71044     1  0.0000      0.832 1.000 0.000
#> GSM71045     1  0.0376      0.833 0.996 0.004
#> GSM71049     1  0.1414      0.826 0.980 0.020
#> GSM71055     1  0.0000      0.832 1.000 0.000
#> GSM71056     1  0.0000      0.832 1.000 0.000
#> GSM71058     1  0.1843      0.832 0.972 0.028
#> GSM71059     1  0.0000      0.832 1.000 0.000
#> GSM71064     1  0.0000      0.832 1.000 0.000
#> GSM71065     1  0.0376      0.833 0.996 0.004
#> GSM71067     1  0.0000      0.832 1.000 0.000
#> GSM71037     1  0.7745      0.719 0.772 0.228
#> GSM71039     1  0.8327      0.672 0.736 0.264
#> GSM71040     1  0.4939      0.799 0.892 0.108
#> GSM71041     1  0.7745      0.719 0.772 0.228
#> GSM71047     1  0.9996      0.110 0.512 0.488
#> GSM71048     1  0.1414      0.833 0.980 0.020
#> GSM71050     1  0.7745      0.719 0.772 0.228
#> GSM71051     1  0.9996      0.110 0.512 0.488
#> GSM71052     1  0.9996      0.110 0.512 0.488
#> GSM71054     1  0.7745      0.719 0.772 0.228
#> GSM71057     1  0.7745      0.719 0.772 0.228
#> GSM71060     1  0.7745      0.719 0.772 0.228
#> GSM71066     1  0.0000      0.832 1.000 0.000
#> GSM71070     2  0.8661      0.673 0.288 0.712
#> GSM71072     2  0.8207      0.710 0.256 0.744
#> GSM71074     2  0.0000      0.811 0.000 1.000
#> GSM71076     2  0.8661      0.673 0.288 0.712
#> GSM71077     2  0.0000      0.811 0.000 1.000
#> GSM71069     2  0.8661      0.673 0.288 0.712
#> GSM71071     2  0.8207      0.710 0.256 0.744
#> GSM71073     2  0.8207      0.710 0.256 0.744
#> GSM71075     2  0.8661      0.673 0.288 0.712
#> GSM71078     1  0.9983      0.113 0.524 0.476

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     1  0.6398      0.360 0.620 0.008 0.372
#> GSM71020     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71021     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71022     2  0.4750      0.782 0.000 0.784 0.216
#> GSM71023     1  0.6398      0.360 0.620 0.008 0.372
#> GSM71024     1  0.1860      0.894 0.948 0.000 0.052
#> GSM71025     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71026     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71027     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71028     3  0.6299      0.548 0.476 0.000 0.524
#> GSM71030     1  0.1860      0.894 0.948 0.000 0.052
#> GSM71032     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71035     3  0.5502      0.637 0.248 0.008 0.744
#> GSM71038     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71043     3  0.6299      0.548 0.476 0.000 0.524
#> GSM71046     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71061     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71062     1  0.2165      0.884 0.936 0.000 0.064
#> GSM71063     3  0.6299      0.548 0.476 0.000 0.524
#> GSM71068     1  0.1289      0.907 0.968 0.000 0.032
#> GSM71029     1  0.1860      0.886 0.948 0.000 0.052
#> GSM71031     1  0.2165      0.883 0.936 0.000 0.064
#> GSM71033     1  0.3412      0.805 0.876 0.000 0.124
#> GSM71036     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71044     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71045     1  0.0592      0.915 0.988 0.000 0.012
#> GSM71049     1  0.1860      0.886 0.948 0.000 0.052
#> GSM71055     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71058     1  0.2066      0.887 0.940 0.000 0.060
#> GSM71059     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71065     1  0.0892      0.912 0.980 0.000 0.020
#> GSM71067     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71037     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71039     3  0.6225      0.585 0.432 0.000 0.568
#> GSM71040     1  0.5560      0.308 0.700 0.000 0.300
#> GSM71041     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71047     3  0.5860      0.645 0.228 0.024 0.748
#> GSM71048     1  0.1753      0.897 0.952 0.000 0.048
#> GSM71050     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71051     3  0.5860      0.645 0.228 0.024 0.748
#> GSM71052     3  0.5860      0.645 0.228 0.024 0.748
#> GSM71054     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71057     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71060     3  0.6291      0.562 0.468 0.000 0.532
#> GSM71066     1  0.0000      0.918 1.000 0.000 0.000
#> GSM71070     3  0.1399      0.524 0.004 0.028 0.968
#> GSM71072     3  0.1964      0.498 0.000 0.056 0.944
#> GSM71074     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71076     3  0.1399      0.524 0.004 0.028 0.968
#> GSM71077     2  0.0000      0.973 0.000 1.000 0.000
#> GSM71069     3  0.1399      0.524 0.004 0.028 0.968
#> GSM71071     3  0.1964      0.498 0.000 0.056 0.944
#> GSM71073     3  0.1964      0.498 0.000 0.056 0.944
#> GSM71075     3  0.1399      0.524 0.004 0.028 0.968
#> GSM71078     3  0.6264      0.633 0.244 0.032 0.724

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     1  0.7772     0.3745 0.496 0.008 0.236 0.260
#> GSM71020     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71022     2  0.3764     0.6949 0.000 0.784 0.000 0.216
#> GSM71023     1  0.7772     0.3745 0.496 0.008 0.236 0.260
#> GSM71024     1  0.3831     0.7682 0.792 0.000 0.204 0.004
#> GSM71025     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71028     3  0.2313     0.7764 0.032 0.000 0.924 0.044
#> GSM71030     1  0.3870     0.7638 0.788 0.000 0.208 0.004
#> GSM71032     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71035     3  0.4564     0.4620 0.000 0.000 0.672 0.328
#> GSM71038     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71043     3  0.2313     0.7764 0.032 0.000 0.924 0.044
#> GSM71046     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71061     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71062     1  0.3982     0.7499 0.776 0.000 0.220 0.004
#> GSM71063     3  0.2313     0.7764 0.032 0.000 0.924 0.044
#> GSM71068     1  0.3266     0.8054 0.832 0.000 0.168 0.000
#> GSM71029     1  0.2466     0.8692 0.916 0.000 0.056 0.028
#> GSM71031     1  0.3726     0.7931 0.788 0.000 0.212 0.000
#> GSM71033     1  0.4418     0.7833 0.784 0.000 0.184 0.032
#> GSM71036     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71042     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71044     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71045     1  0.1637     0.8859 0.940 0.000 0.060 0.000
#> GSM71049     1  0.2466     0.8692 0.916 0.000 0.056 0.028
#> GSM71055     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71056     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71058     1  0.2814     0.8539 0.868 0.000 0.132 0.000
#> GSM71059     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71064     1  0.1022     0.8885 0.968 0.000 0.032 0.000
#> GSM71065     1  0.1557     0.8870 0.944 0.000 0.056 0.000
#> GSM71067     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71039     3  0.1211     0.7893 0.000 0.000 0.960 0.040
#> GSM71040     3  0.5250     0.0364 0.440 0.000 0.552 0.008
#> GSM71041     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71047     3  0.4830     0.4026 0.000 0.000 0.608 0.392
#> GSM71048     1  0.3649     0.7712 0.796 0.000 0.204 0.000
#> GSM71050     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71051     3  0.4830     0.4026 0.000 0.000 0.608 0.392
#> GSM71052     3  0.4830     0.4026 0.000 0.000 0.608 0.392
#> GSM71054     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71057     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71060     3  0.0188     0.8012 0.000 0.000 0.996 0.004
#> GSM71066     1  0.0000     0.8852 1.000 0.000 0.000 0.000
#> GSM71070     4  0.1211     0.9728 0.000 0.000 0.040 0.960
#> GSM71072     4  0.0188     0.9647 0.000 0.000 0.004 0.996
#> GSM71074     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71076     4  0.1211     0.9728 0.000 0.000 0.040 0.960
#> GSM71077     2  0.0000     0.9653 0.000 1.000 0.000 0.000
#> GSM71069     4  0.1211     0.9728 0.000 0.000 0.040 0.960
#> GSM71071     4  0.0188     0.9647 0.000 0.000 0.004 0.996
#> GSM71073     4  0.0188     0.9647 0.000 0.000 0.004 0.996
#> GSM71075     4  0.1211     0.9728 0.000 0.000 0.040 0.960
#> GSM71078     3  0.4989     0.1246 0.000 0.000 0.528 0.472

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     1  0.7688    0.20728 0.464 0.008 0.060 0.272 0.196
#> GSM71020     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.3242    0.68840 0.000 0.784 0.000 0.216 0.000
#> GSM71023     1  0.7688    0.20728 0.464 0.008 0.060 0.272 0.196
#> GSM71024     5  0.5227   -0.03036 0.448 0.000 0.044 0.000 0.508
#> GSM71025     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71028     5  0.4304   -0.29126 0.000 0.000 0.484 0.000 0.516
#> GSM71030     5  0.5283   -0.02069 0.444 0.000 0.048 0.000 0.508
#> GSM71032     1  0.3816    0.52422 0.696 0.000 0.000 0.000 0.304
#> GSM71034     1  0.3796    0.52588 0.700 0.000 0.000 0.000 0.300
#> GSM71035     3  0.6593    0.29516 0.000 0.000 0.464 0.284 0.252
#> GSM71038     1  0.3816    0.52422 0.696 0.000 0.000 0.000 0.304
#> GSM71043     5  0.4304   -0.29126 0.000 0.000 0.484 0.000 0.516
#> GSM71046     1  0.3796    0.52588 0.700 0.000 0.000 0.000 0.300
#> GSM71053     1  0.3816    0.52422 0.696 0.000 0.000 0.000 0.304
#> GSM71061     3  0.3508    0.58387 0.000 0.000 0.748 0.000 0.252
#> GSM71062     5  0.5271    0.00175 0.432 0.000 0.048 0.000 0.520
#> GSM71063     5  0.4304   -0.29126 0.000 0.000 0.484 0.000 0.516
#> GSM71068     1  0.5399    0.05153 0.496 0.000 0.056 0.000 0.448
#> GSM71029     1  0.2450    0.66299 0.900 0.000 0.000 0.052 0.048
#> GSM71031     1  0.4134    0.50881 0.760 0.000 0.044 0.000 0.196
#> GSM71033     1  0.5013    0.54326 0.756 0.000 0.068 0.052 0.124
#> GSM71036     1  0.0000    0.70750 1.000 0.000 0.000 0.000 0.000
#> GSM71042     1  0.0000    0.70750 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.1270    0.69204 0.948 0.000 0.000 0.000 0.052
#> GSM71045     1  0.1608    0.67926 0.928 0.000 0.000 0.000 0.072
#> GSM71049     1  0.2450    0.66299 0.900 0.000 0.000 0.052 0.048
#> GSM71055     1  0.0000    0.70750 1.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000    0.70750 1.000 0.000 0.000 0.000 0.000
#> GSM71058     1  0.3152    0.61573 0.840 0.000 0.024 0.000 0.136
#> GSM71059     1  0.0000    0.70750 1.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0510    0.70496 0.984 0.000 0.000 0.000 0.016
#> GSM71065     1  0.0963    0.70131 0.964 0.000 0.000 0.000 0.036
#> GSM71067     1  0.3796    0.52588 0.700 0.000 0.000 0.000 0.300
#> GSM71037     3  0.0000    0.66931 0.000 0.000 1.000 0.000 0.000
#> GSM71039     3  0.4572    0.55427 0.000 0.000 0.684 0.036 0.280
#> GSM71040     5  0.6250    0.27944 0.204 0.000 0.256 0.000 0.540
#> GSM71041     3  0.3305    0.59551 0.000 0.000 0.776 0.000 0.224
#> GSM71047     3  0.5925    0.25312 0.000 0.000 0.556 0.316 0.128
#> GSM71048     5  0.5289   -0.04482 0.452 0.000 0.048 0.000 0.500
#> GSM71050     3  0.3508    0.58387 0.000 0.000 0.748 0.000 0.252
#> GSM71051     3  0.5687    0.25594 0.000 0.000 0.580 0.316 0.104
#> GSM71052     3  0.5687    0.25594 0.000 0.000 0.580 0.316 0.104
#> GSM71054     3  0.0000    0.66931 0.000 0.000 1.000 0.000 0.000
#> GSM71057     3  0.0000    0.66931 0.000 0.000 1.000 0.000 0.000
#> GSM71060     3  0.0000    0.66931 0.000 0.000 1.000 0.000 0.000
#> GSM71066     1  0.3796    0.52588 0.700 0.000 0.000 0.000 0.300
#> GSM71070     4  0.1410    0.85469 0.000 0.000 0.000 0.940 0.060
#> GSM71072     4  0.1341    0.83775 0.000 0.000 0.000 0.944 0.056
#> GSM71074     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.1410    0.85469 0.000 0.000 0.000 0.940 0.060
#> GSM71077     2  0.0000    0.96428 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.1410    0.85469 0.000 0.000 0.000 0.940 0.060
#> GSM71071     4  0.1341    0.83775 0.000 0.000 0.000 0.944 0.056
#> GSM71073     4  0.1341    0.83775 0.000 0.000 0.000 0.944 0.056
#> GSM71075     4  0.1410    0.85469 0.000 0.000 0.000 0.940 0.060
#> GSM71078     4  0.6385   -0.11158 0.000 0.000 0.352 0.472 0.176

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     1  0.6050     0.2631 0.596 0.008 0.056 0.276 0.032 0.032
#> GSM71020     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.2912     0.6950 0.000 0.784 0.000 0.216 0.000 0.000
#> GSM71023     1  0.6050     0.2631 0.596 0.008 0.056 0.276 0.032 0.032
#> GSM71024     5  0.5144     0.6534 0.268 0.000 0.044 0.000 0.640 0.048
#> GSM71025     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     3  0.6328     0.5292 0.100 0.000 0.428 0.044 0.008 0.420
#> GSM71030     5  0.5260     0.6498 0.268 0.000 0.048 0.000 0.632 0.052
#> GSM71032     5  0.0363     0.6859 0.012 0.000 0.000 0.000 0.988 0.000
#> GSM71034     5  0.0547     0.6881 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM71035     3  0.6186     0.2987 0.004 0.000 0.404 0.308 0.000 0.284
#> GSM71038     5  0.0363     0.6859 0.012 0.000 0.000 0.000 0.988 0.000
#> GSM71043     3  0.6296     0.5304 0.096 0.000 0.428 0.044 0.008 0.424
#> GSM71046     5  0.0547     0.6881 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM71053     5  0.0363     0.6859 0.012 0.000 0.000 0.000 0.988 0.000
#> GSM71061     3  0.3835     0.6498 0.016 0.000 0.684 0.000 0.000 0.300
#> GSM71062     5  0.5538     0.6496 0.236 0.000 0.048 0.004 0.636 0.076
#> GSM71063     3  0.6296     0.5304 0.096 0.000 0.428 0.044 0.008 0.424
#> GSM71068     5  0.4978     0.6591 0.228 0.000 0.056 0.000 0.676 0.040
#> GSM71029     1  0.4426     0.7270 0.652 0.000 0.000 0.052 0.296 0.000
#> GSM71031     1  0.3089     0.5528 0.856 0.000 0.040 0.000 0.080 0.024
#> GSM71033     1  0.5756     0.6601 0.664 0.000 0.048 0.052 0.188 0.048
#> GSM71036     1  0.3765     0.7332 0.596 0.000 0.000 0.000 0.404 0.000
#> GSM71042     1  0.3847     0.7049 0.544 0.000 0.000 0.000 0.456 0.000
#> GSM71044     1  0.3446     0.7343 0.692 0.000 0.000 0.000 0.308 0.000
#> GSM71045     1  0.3288     0.6932 0.724 0.000 0.000 0.000 0.276 0.000
#> GSM71049     1  0.4426     0.7270 0.652 0.000 0.000 0.052 0.296 0.000
#> GSM71055     1  0.3774     0.7314 0.592 0.000 0.000 0.000 0.408 0.000
#> GSM71056     1  0.3851     0.7006 0.540 0.000 0.000 0.000 0.460 0.000
#> GSM71058     1  0.3121     0.6415 0.824 0.000 0.020 0.000 0.148 0.008
#> GSM71059     1  0.3847     0.7049 0.544 0.000 0.000 0.000 0.456 0.000
#> GSM71064     1  0.3833     0.7159 0.556 0.000 0.000 0.000 0.444 0.000
#> GSM71065     1  0.3515     0.7430 0.676 0.000 0.000 0.000 0.324 0.000
#> GSM71067     5  0.0547     0.6881 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM71037     3  0.0000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     3  0.4732     0.6263 0.016 0.000 0.620 0.036 0.000 0.328
#> GSM71040     5  0.7824     0.0358 0.184 0.000 0.240 0.008 0.324 0.244
#> GSM71041     3  0.3606     0.6528 0.016 0.000 0.728 0.000 0.000 0.256
#> GSM71047     3  0.4222     0.3577 0.008 0.000 0.516 0.004 0.000 0.472
#> GSM71048     5  0.5163     0.6549 0.260 0.000 0.048 0.000 0.644 0.048
#> GSM71050     3  0.3835     0.6498 0.016 0.000 0.684 0.000 0.000 0.300
#> GSM71051     3  0.4076     0.3548 0.004 0.000 0.564 0.004 0.000 0.428
#> GSM71052     3  0.4184     0.3569 0.008 0.000 0.556 0.004 0.000 0.432
#> GSM71054     3  0.0000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0000     0.6390 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71060     3  0.0291     0.6393 0.004 0.000 0.992 0.000 0.000 0.004
#> GSM71066     5  0.0547     0.6881 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM71070     4  0.0363     0.8237 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM71072     4  0.3520     0.7953 0.036 0.000 0.000 0.776 0.000 0.188
#> GSM71074     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0363     0.8237 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM71077     2  0.0000     0.9649 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.0363     0.8237 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM71071     4  0.3520     0.7953 0.036 0.000 0.000 0.776 0.000 0.188
#> GSM71073     4  0.3520     0.7953 0.036 0.000 0.000 0.776 0.000 0.188
#> GSM71075     4  0.0363     0.8237 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM71078     4  0.6565    -0.1537 0.024 0.000 0.348 0.364 0.000 0.264

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:hclust 55    1.51e-08 2
#> SD:hclust 54    9.33e-11 3
#> SD:hclust 52    2.71e-15 4
#> SD:hclust 44    1.54e-15 5
#> SD:hclust 52    2.61e-19 6

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


SD:kmeans

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

res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.439           0.784       0.896         0.4260 0.548   0.548
#> 3 3 0.700           0.912       0.939         0.4882 0.656   0.446
#> 4 4 0.712           0.848       0.884         0.1317 0.862   0.646
#> 5 5 0.711           0.660       0.773         0.0899 0.905   0.676
#> 6 6 0.736           0.562       0.744         0.0523 0.880   0.516

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
#> GSM71019     2  0.9209     0.5928 0.336 0.664
#> GSM71020     2  0.0376     0.8202 0.004 0.996
#> GSM71021     2  0.0376     0.8202 0.004 0.996
#> GSM71022     2  0.0376     0.8202 0.004 0.996
#> GSM71023     2  0.9209     0.5928 0.336 0.664
#> GSM71024     1  0.0000     0.8839 1.000 0.000
#> GSM71025     2  0.0376     0.8202 0.004 0.996
#> GSM71026     2  0.0376     0.8202 0.004 0.996
#> GSM71027     2  0.0376     0.8202 0.004 0.996
#> GSM71028     1  0.6531     0.8122 0.832 0.168
#> GSM71030     1  0.0000     0.8839 1.000 0.000
#> GSM71032     1  0.0000     0.8839 1.000 0.000
#> GSM71034     1  0.0000     0.8839 1.000 0.000
#> GSM71035     1  0.9358     0.4696 0.648 0.352
#> GSM71038     1  0.0000     0.8839 1.000 0.000
#> GSM71043     1  0.6247     0.8208 0.844 0.156
#> GSM71046     1  0.0000     0.8839 1.000 0.000
#> GSM71053     1  0.0000     0.8839 1.000 0.000
#> GSM71061     1  0.6531     0.8122 0.832 0.168
#> GSM71062     1  0.0376     0.8824 0.996 0.004
#> GSM71063     1  0.6247     0.8208 0.844 0.156
#> GSM71068     1  0.0376     0.8824 0.996 0.004
#> GSM71029     1  0.7139     0.6565 0.804 0.196
#> GSM71031     1  0.5842     0.8289 0.860 0.140
#> GSM71033     1  0.6712     0.8042 0.824 0.176
#> GSM71036     1  0.0000     0.8839 1.000 0.000
#> GSM71042     1  0.0000     0.8839 1.000 0.000
#> GSM71044     1  0.0938     0.8774 0.988 0.012
#> GSM71045     1  0.0000     0.8839 1.000 0.000
#> GSM71049     1  0.0938     0.8774 0.988 0.012
#> GSM71055     1  0.0000     0.8839 1.000 0.000
#> GSM71056     1  0.0000     0.8839 1.000 0.000
#> GSM71058     1  0.0000     0.8839 1.000 0.000
#> GSM71059     1  0.0000     0.8839 1.000 0.000
#> GSM71064     1  0.0000     0.8839 1.000 0.000
#> GSM71065     1  0.0000     0.8839 1.000 0.000
#> GSM71067     1  0.0000     0.8839 1.000 0.000
#> GSM71037     1  0.6531     0.8122 0.832 0.168
#> GSM71039     1  0.9170     0.5217 0.668 0.332
#> GSM71040     1  0.5946     0.8279 0.856 0.144
#> GSM71041     1  0.6531     0.8122 0.832 0.168
#> GSM71047     2  0.9248     0.5797 0.340 0.660
#> GSM71048     1  0.0000     0.8839 1.000 0.000
#> GSM71050     1  0.6712     0.8036 0.824 0.176
#> GSM71051     2  0.9209     0.5874 0.336 0.664
#> GSM71052     1  0.9996    -0.0486 0.512 0.488
#> GSM71054     1  0.6531     0.8122 0.832 0.168
#> GSM71057     1  0.6531     0.8122 0.832 0.168
#> GSM71060     1  0.6531     0.8122 0.832 0.168
#> GSM71066     1  0.0000     0.8839 1.000 0.000
#> GSM71070     2  0.9170     0.5936 0.332 0.668
#> GSM71072     2  0.0000     0.8193 0.000 1.000
#> GSM71074     2  0.0376     0.8202 0.004 0.996
#> GSM71076     2  0.0000     0.8193 0.000 1.000
#> GSM71077     2  0.0376     0.8202 0.004 0.996
#> GSM71069     2  0.9358     0.5562 0.352 0.648
#> GSM71071     2  0.0000     0.8193 0.000 1.000
#> GSM71073     2  0.0000     0.8193 0.000 1.000
#> GSM71075     2  0.9248     0.5801 0.340 0.660
#> GSM71078     2  0.9044     0.6074 0.320 0.680

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.0747      0.860 0.000 0.016 0.984
#> GSM71020     2  0.0892      0.926 0.000 0.980 0.020
#> GSM71021     2  0.1031      0.925 0.000 0.976 0.024
#> GSM71022     2  0.1031      0.925 0.000 0.976 0.024
#> GSM71023     3  0.0747      0.860 0.000 0.016 0.984
#> GSM71024     1  0.0237      0.989 0.996 0.000 0.004
#> GSM71025     2  0.1031      0.925 0.000 0.976 0.024
#> GSM71026     2  0.1031      0.925 0.000 0.976 0.024
#> GSM71027     2  0.0892      0.926 0.000 0.980 0.020
#> GSM71028     3  0.3551      0.886 0.132 0.000 0.868
#> GSM71030     1  0.0237      0.989 0.996 0.000 0.004
#> GSM71032     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71034     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71035     3  0.0237      0.867 0.000 0.004 0.996
#> GSM71038     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71043     3  0.3551      0.886 0.132 0.000 0.868
#> GSM71046     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71053     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71061     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71062     1  0.2066      0.931 0.940 0.000 0.060
#> GSM71063     3  0.3551      0.886 0.132 0.000 0.868
#> GSM71068     1  0.0237      0.990 0.996 0.004 0.000
#> GSM71029     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71031     3  0.6168      0.452 0.412 0.000 0.588
#> GSM71033     3  0.4782      0.852 0.164 0.016 0.820
#> GSM71036     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71044     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71045     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71049     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71055     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71058     1  0.1636      0.974 0.964 0.020 0.016
#> GSM71059     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71064     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71065     1  0.0892      0.985 0.980 0.020 0.000
#> GSM71067     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71037     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71039     3  0.0237      0.867 0.000 0.004 0.996
#> GSM71040     3  0.4399      0.833 0.188 0.000 0.812
#> GSM71041     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71047     3  0.0237      0.867 0.000 0.004 0.996
#> GSM71048     1  0.0237      0.989 0.996 0.000 0.004
#> GSM71050     3  0.3551      0.886 0.132 0.000 0.868
#> GSM71051     3  0.0237      0.867 0.000 0.004 0.996
#> GSM71052     3  0.0237      0.867 0.000 0.004 0.996
#> GSM71054     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71057     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71060     3  0.3784      0.886 0.132 0.004 0.864
#> GSM71066     1  0.0000      0.991 1.000 0.000 0.000
#> GSM71070     3  0.0000      0.867 0.000 0.000 1.000
#> GSM71072     2  0.5291      0.780 0.000 0.732 0.268
#> GSM71074     2  0.0892      0.926 0.000 0.980 0.020
#> GSM71076     2  0.5327      0.780 0.000 0.728 0.272
#> GSM71077     2  0.0892      0.926 0.000 0.980 0.020
#> GSM71069     3  0.0747      0.860 0.000 0.016 0.984
#> GSM71071     2  0.5138      0.798 0.000 0.748 0.252
#> GSM71073     2  0.3879      0.871 0.000 0.848 0.152
#> GSM71075     3  0.2625      0.796 0.000 0.084 0.916
#> GSM71078     3  0.0237      0.867 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.5391      0.549 0.012 0.012 0.320 0.656
#> GSM71020     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71023     4  0.4999      0.546 0.000 0.012 0.328 0.660
#> GSM71024     1  0.3937      0.844 0.800 0.000 0.012 0.188
#> GSM71025     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.999 0.000 1.000 0.000 0.000
#> GSM71028     3  0.3048      0.865 0.016 0.000 0.876 0.108
#> GSM71030     1  0.3937      0.844 0.800 0.000 0.012 0.188
#> GSM71032     1  0.3217      0.878 0.860 0.000 0.012 0.128
#> GSM71034     1  0.2741      0.877 0.892 0.000 0.012 0.096
#> GSM71035     3  0.1302      0.912 0.000 0.000 0.956 0.044
#> GSM71038     1  0.3217      0.878 0.860 0.000 0.012 0.128
#> GSM71043     3  0.3390      0.849 0.016 0.000 0.852 0.132
#> GSM71046     1  0.2473      0.879 0.908 0.000 0.012 0.080
#> GSM71053     1  0.3217      0.878 0.860 0.000 0.012 0.128
#> GSM71061     3  0.0937      0.924 0.012 0.000 0.976 0.012
#> GSM71062     1  0.5318      0.788 0.732 0.000 0.072 0.196
#> GSM71063     3  0.3597      0.834 0.016 0.000 0.836 0.148
#> GSM71068     1  0.3895      0.844 0.804 0.000 0.012 0.184
#> GSM71029     1  0.1488      0.877 0.956 0.000 0.012 0.032
#> GSM71031     1  0.6661      0.526 0.604 0.000 0.264 0.132
#> GSM71033     1  0.6672      0.585 0.620 0.000 0.212 0.168
#> GSM71036     1  0.0592      0.883 0.984 0.000 0.000 0.016
#> GSM71042     1  0.0469      0.884 0.988 0.000 0.000 0.012
#> GSM71044     1  0.2329      0.866 0.916 0.000 0.012 0.072
#> GSM71045     1  0.0592      0.884 0.984 0.000 0.000 0.016
#> GSM71049     1  0.1488      0.877 0.956 0.000 0.012 0.032
#> GSM71055     1  0.1042      0.880 0.972 0.000 0.008 0.020
#> GSM71056     1  0.0707      0.886 0.980 0.000 0.000 0.020
#> GSM71058     1  0.5568      0.732 0.728 0.000 0.120 0.152
#> GSM71059     1  0.0188      0.885 0.996 0.000 0.000 0.004
#> GSM71064     1  0.1557      0.876 0.944 0.000 0.000 0.056
#> GSM71065     1  0.2329      0.866 0.916 0.000 0.012 0.072
#> GSM71067     1  0.2542      0.879 0.904 0.000 0.012 0.084
#> GSM71037     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> GSM71039     3  0.1256      0.919 0.008 0.000 0.964 0.028
#> GSM71040     3  0.3708      0.830 0.020 0.000 0.832 0.148
#> GSM71041     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> GSM71047     3  0.2589      0.820 0.000 0.000 0.884 0.116
#> GSM71048     1  0.3937      0.844 0.800 0.000 0.012 0.188
#> GSM71050     3  0.0937      0.924 0.012 0.000 0.976 0.012
#> GSM71051     3  0.2589      0.820 0.000 0.000 0.884 0.116
#> GSM71052     3  0.0592      0.912 0.000 0.000 0.984 0.016
#> GSM71054     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> GSM71057     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> GSM71060     3  0.0469      0.925 0.012 0.000 0.988 0.000
#> GSM71066     1  0.2473      0.879 0.908 0.000 0.012 0.080
#> GSM71070     4  0.3219      0.765 0.000 0.000 0.164 0.836
#> GSM71072     4  0.4776      0.686 0.000 0.244 0.024 0.732
#> GSM71074     2  0.0188      0.997 0.000 0.996 0.004 0.000
#> GSM71076     4  0.4675      0.687 0.000 0.244 0.020 0.736
#> GSM71077     2  0.0188      0.997 0.000 0.996 0.004 0.000
#> GSM71069     4  0.3351      0.770 0.000 0.008 0.148 0.844
#> GSM71071     4  0.4706      0.682 0.000 0.248 0.020 0.732
#> GSM71073     4  0.4482      0.654 0.000 0.264 0.008 0.728
#> GSM71075     4  0.3443      0.774 0.000 0.016 0.136 0.848
#> GSM71078     4  0.4103      0.713 0.000 0.000 0.256 0.744

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.8145     0.4094 0.284 0.012 0.096 0.424 0.184
#> GSM71020     2  0.0000     0.9686 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0404     0.9703 0.000 0.988 0.000 0.012 0.000
#> GSM71022     2  0.0404     0.9703 0.000 0.988 0.000 0.012 0.000
#> GSM71023     4  0.8015     0.4610 0.244 0.012 0.096 0.464 0.184
#> GSM71024     5  0.4651     0.6128 0.208 0.000 0.004 0.060 0.728
#> GSM71025     2  0.0404     0.9703 0.000 0.988 0.000 0.012 0.000
#> GSM71026     2  0.0404     0.9703 0.000 0.988 0.000 0.012 0.000
#> GSM71027     2  0.1410     0.9557 0.000 0.940 0.000 0.000 0.060
#> GSM71028     3  0.5037     0.7273 0.000 0.000 0.684 0.088 0.228
#> GSM71030     5  0.4345     0.5835 0.172 0.000 0.004 0.060 0.764
#> GSM71032     5  0.4449     0.5631 0.484 0.000 0.004 0.000 0.512
#> GSM71034     5  0.4251     0.6121 0.372 0.000 0.004 0.000 0.624
#> GSM71035     3  0.2850     0.8452 0.000 0.000 0.872 0.036 0.092
#> GSM71038     5  0.4449     0.5631 0.484 0.000 0.004 0.000 0.512
#> GSM71043     3  0.4734     0.7470 0.000 0.000 0.704 0.064 0.232
#> GSM71046     5  0.4299     0.5972 0.388 0.000 0.004 0.000 0.608
#> GSM71053     5  0.4449     0.5631 0.484 0.000 0.004 0.000 0.512
#> GSM71061     3  0.2712     0.8468 0.000 0.000 0.880 0.032 0.088
#> GSM71062     5  0.4738     0.5258 0.136 0.000 0.036 0.060 0.768
#> GSM71063     3  0.5674     0.6159 0.000 0.000 0.576 0.100 0.324
#> GSM71068     5  0.4488     0.6017 0.188 0.000 0.004 0.060 0.748
#> GSM71029     1  0.2124     0.5167 0.900 0.000 0.000 0.004 0.096
#> GSM71031     1  0.6736     0.2352 0.552 0.000 0.088 0.068 0.292
#> GSM71033     1  0.4942     0.3325 0.724 0.000 0.064 0.016 0.196
#> GSM71036     1  0.4211     0.3234 0.636 0.000 0.000 0.004 0.360
#> GSM71042     1  0.4211     0.3234 0.636 0.000 0.000 0.004 0.360
#> GSM71044     1  0.0671     0.5067 0.980 0.000 0.000 0.004 0.016
#> GSM71045     1  0.3966     0.3105 0.664 0.000 0.000 0.000 0.336
#> GSM71049     1  0.2124     0.5167 0.900 0.000 0.000 0.004 0.096
#> GSM71055     1  0.4009     0.3932 0.684 0.000 0.000 0.004 0.312
#> GSM71056     1  0.4425    -0.0903 0.544 0.000 0.000 0.004 0.452
#> GSM71058     1  0.4096     0.3666 0.744 0.000 0.020 0.004 0.232
#> GSM71059     1  0.4211     0.3234 0.636 0.000 0.000 0.004 0.360
#> GSM71064     1  0.3741     0.3295 0.732 0.000 0.000 0.004 0.264
#> GSM71065     1  0.0671     0.5067 0.980 0.000 0.000 0.004 0.016
#> GSM71067     5  0.4288     0.6039 0.384 0.000 0.004 0.000 0.612
#> GSM71037     3  0.0880     0.8460 0.000 0.000 0.968 0.000 0.032
#> GSM71039     3  0.2535     0.8499 0.000 0.000 0.892 0.032 0.076
#> GSM71040     3  0.5462     0.6766 0.024 0.000 0.668 0.064 0.244
#> GSM71041     3  0.1205     0.8570 0.000 0.000 0.956 0.004 0.040
#> GSM71047     3  0.3854     0.7591 0.056 0.000 0.836 0.072 0.036
#> GSM71048     5  0.4682     0.6142 0.212 0.000 0.004 0.060 0.724
#> GSM71050     3  0.1965     0.8557 0.000 0.000 0.924 0.024 0.052
#> GSM71051     3  0.3854     0.7591 0.056 0.000 0.836 0.072 0.036
#> GSM71052     3  0.1124     0.8430 0.000 0.000 0.960 0.004 0.036
#> GSM71054     3  0.0880     0.8460 0.000 0.000 0.968 0.000 0.032
#> GSM71057     3  0.0880     0.8460 0.000 0.000 0.968 0.000 0.032
#> GSM71060     3  0.0865     0.8561 0.000 0.000 0.972 0.004 0.024
#> GSM71066     5  0.4288     0.6039 0.384 0.000 0.004 0.000 0.612
#> GSM71070     4  0.1967     0.8031 0.012 0.000 0.020 0.932 0.036
#> GSM71072     4  0.2464     0.7904 0.000 0.092 0.004 0.892 0.012
#> GSM71074     2  0.1792     0.9470 0.000 0.916 0.000 0.000 0.084
#> GSM71076     4  0.2228     0.7909 0.000 0.092 0.004 0.900 0.004
#> GSM71077     2  0.1792     0.9470 0.000 0.916 0.000 0.000 0.084
#> GSM71069     4  0.1787     0.8056 0.012 0.000 0.016 0.940 0.032
#> GSM71071     4  0.2464     0.7904 0.000 0.092 0.004 0.892 0.012
#> GSM71073     4  0.3195     0.7747 0.000 0.100 0.004 0.856 0.040
#> GSM71075     4  0.1787     0.8056 0.012 0.000 0.016 0.940 0.032
#> GSM71078     4  0.2233     0.7753 0.000 0.000 0.080 0.904 0.016

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     1  0.6845     0.1037 0.428 0.004 0.048 0.296 0.000 0.224
#> GSM71020     2  0.0000     0.9662 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0146     0.9668 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71022     2  0.0146     0.9668 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71023     1  0.6888     0.0526 0.408 0.004 0.048 0.312 0.000 0.228
#> GSM71024     5  0.4858     0.4362 0.076 0.000 0.000 0.012 0.660 0.252
#> GSM71025     2  0.0146     0.9668 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71026     2  0.0146     0.9668 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71027     2  0.1765     0.9482 0.024 0.924 0.000 0.000 0.000 0.052
#> GSM71028     6  0.3023     0.6798 0.000 0.000 0.232 0.000 0.000 0.768
#> GSM71030     5  0.5051     0.3991 0.072 0.000 0.000 0.012 0.612 0.304
#> GSM71032     5  0.3861     0.4741 0.168 0.000 0.000 0.008 0.772 0.052
#> GSM71034     5  0.0935     0.5572 0.004 0.000 0.000 0.000 0.964 0.032
#> GSM71035     6  0.4456     0.2455 0.028 0.000 0.448 0.000 0.000 0.524
#> GSM71038     5  0.3827     0.4759 0.164 0.000 0.000 0.008 0.776 0.052
#> GSM71043     6  0.3368     0.6817 0.000 0.000 0.232 0.000 0.012 0.756
#> GSM71046     5  0.0436     0.5568 0.004 0.000 0.000 0.004 0.988 0.004
#> GSM71053     5  0.3861     0.4741 0.168 0.000 0.000 0.008 0.772 0.052
#> GSM71061     6  0.4405     0.1725 0.024 0.000 0.472 0.000 0.000 0.504
#> GSM71062     5  0.5053     0.3517 0.056 0.000 0.000 0.012 0.564 0.368
#> GSM71063     6  0.3488     0.6647 0.000 0.000 0.184 0.000 0.036 0.780
#> GSM71068     5  0.5216     0.4030 0.088 0.000 0.000 0.012 0.600 0.300
#> GSM71029     1  0.4444     0.3978 0.612 0.000 0.000 0.008 0.356 0.024
#> GSM71031     1  0.5448     0.3442 0.532 0.000 0.000 0.012 0.092 0.364
#> GSM71033     1  0.3863     0.5106 0.808 0.000 0.040 0.004 0.040 0.108
#> GSM71036     5  0.4199     0.2381 0.336 0.000 0.000 0.004 0.640 0.020
#> GSM71042     5  0.4018     0.2576 0.324 0.000 0.000 0.000 0.656 0.020
#> GSM71044     1  0.3219     0.4842 0.792 0.000 0.000 0.004 0.192 0.012
#> GSM71045     5  0.4278     0.2217 0.360 0.000 0.000 0.004 0.616 0.020
#> GSM71049     1  0.4444     0.3978 0.612 0.000 0.000 0.008 0.356 0.024
#> GSM71055     5  0.4437    -0.0309 0.436 0.000 0.000 0.004 0.540 0.020
#> GSM71056     5  0.3641     0.3545 0.248 0.000 0.000 0.000 0.732 0.020
#> GSM71058     1  0.4730     0.4504 0.696 0.000 0.000 0.008 0.112 0.184
#> GSM71059     5  0.4018     0.2576 0.324 0.000 0.000 0.000 0.656 0.020
#> GSM71064     1  0.5248    -0.1027 0.492 0.000 0.000 0.008 0.428 0.072
#> GSM71065     1  0.2871     0.4807 0.804 0.000 0.000 0.000 0.192 0.004
#> GSM71067     5  0.0603     0.5589 0.000 0.000 0.000 0.004 0.980 0.016
#> GSM71037     3  0.0790     0.7539 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM71039     3  0.4372    -0.0787 0.024 0.000 0.544 0.000 0.000 0.432
#> GSM71040     6  0.6502     0.4953 0.056 0.000 0.216 0.012 0.160 0.556
#> GSM71041     3  0.3629     0.5041 0.016 0.000 0.724 0.000 0.000 0.260
#> GSM71047     3  0.1480     0.7116 0.040 0.000 0.940 0.000 0.000 0.020
#> GSM71048     5  0.4707     0.4445 0.064 0.000 0.000 0.012 0.672 0.252
#> GSM71050     3  0.4124     0.3142 0.024 0.000 0.644 0.000 0.000 0.332
#> GSM71051     3  0.1092     0.7127 0.020 0.000 0.960 0.000 0.000 0.020
#> GSM71052     3  0.0146     0.7414 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM71054     3  0.0790     0.7539 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM71057     3  0.0713     0.7536 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM71060     3  0.2697     0.6310 0.000 0.000 0.812 0.000 0.000 0.188
#> GSM71066     5  0.0146     0.5556 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM71070     4  0.2571     0.8962 0.060 0.000 0.000 0.876 0.000 0.064
#> GSM71072     4  0.1572     0.9115 0.000 0.028 0.000 0.936 0.000 0.036
#> GSM71074     2  0.2376     0.9348 0.044 0.888 0.000 0.000 0.000 0.068
#> GSM71076     4  0.1788     0.9115 0.040 0.028 0.000 0.928 0.000 0.004
#> GSM71077     2  0.2376     0.9348 0.044 0.888 0.000 0.000 0.000 0.068
#> GSM71069     4  0.2571     0.8962 0.060 0.000 0.000 0.876 0.000 0.064
#> GSM71071     4  0.1572     0.9115 0.000 0.028 0.000 0.936 0.000 0.036
#> GSM71073     4  0.2541     0.8951 0.024 0.032 0.000 0.892 0.000 0.052
#> GSM71075     4  0.2451     0.8958 0.060 0.000 0.000 0.884 0.000 0.056
#> GSM71078     4  0.2262     0.8901 0.008 0.000 0.016 0.896 0.000 0.080

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:kmeans 58    6.58e-09 2
#> SD:kmeans 59    7.25e-09 3
#> SD:kmeans 60    3.09e-16 4
#> SD:kmeans 48    8.46e-17 5
#> SD:kmeans 32    1.76e-10 6

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


SD:skmeans*

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

res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]

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

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

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

collect_plots(res)

plot of chunk SD-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.622           0.832       0.928         0.4962 0.506   0.506
#> 3 3 1.000           0.955       0.983         0.3464 0.749   0.538
#> 4 4 0.916           0.876       0.934         0.0960 0.940   0.819
#> 5 5 0.780           0.692       0.849         0.0875 0.893   0.637
#> 6 6 0.766           0.705       0.809         0.0405 0.892   0.540

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2  0.0000      0.937 0.000 1.000
#> GSM71020     2  0.0000      0.937 0.000 1.000
#> GSM71021     2  0.0000      0.937 0.000 1.000
#> GSM71022     2  0.0000      0.937 0.000 1.000
#> GSM71023     2  0.0000      0.937 0.000 1.000
#> GSM71024     1  0.0000      0.898 1.000 0.000
#> GSM71025     2  0.0000      0.937 0.000 1.000
#> GSM71026     2  0.0000      0.937 0.000 1.000
#> GSM71027     2  0.0000      0.937 0.000 1.000
#> GSM71028     1  0.7219      0.778 0.800 0.200
#> GSM71030     1  0.0000      0.898 1.000 0.000
#> GSM71032     1  0.0000      0.898 1.000 0.000
#> GSM71034     1  0.0000      0.898 1.000 0.000
#> GSM71035     2  0.9710      0.221 0.400 0.600
#> GSM71038     1  0.0000      0.898 1.000 0.000
#> GSM71043     1  0.7219      0.778 0.800 0.200
#> GSM71046     1  0.0000      0.898 1.000 0.000
#> GSM71053     1  0.0000      0.898 1.000 0.000
#> GSM71061     1  0.7219      0.778 0.800 0.200
#> GSM71062     1  0.0000      0.898 1.000 0.000
#> GSM71063     1  0.7219      0.778 0.800 0.200
#> GSM71068     1  0.0000      0.898 1.000 0.000
#> GSM71029     2  0.9710      0.331 0.400 0.600
#> GSM71031     1  0.0000      0.898 1.000 0.000
#> GSM71033     2  0.4431      0.841 0.092 0.908
#> GSM71036     1  0.0000      0.898 1.000 0.000
#> GSM71042     1  0.0000      0.898 1.000 0.000
#> GSM71044     1  0.9710      0.275 0.600 0.400
#> GSM71045     1  0.0000      0.898 1.000 0.000
#> GSM71049     1  0.9710      0.275 0.600 0.400
#> GSM71055     1  0.0000      0.898 1.000 0.000
#> GSM71056     1  0.0000      0.898 1.000 0.000
#> GSM71058     1  0.0000      0.898 1.000 0.000
#> GSM71059     1  0.0000      0.898 1.000 0.000
#> GSM71064     1  0.0000      0.898 1.000 0.000
#> GSM71065     1  0.0000      0.898 1.000 0.000
#> GSM71067     1  0.0000      0.898 1.000 0.000
#> GSM71037     1  0.7219      0.778 0.800 0.200
#> GSM71039     2  0.9710      0.221 0.400 0.600
#> GSM71040     1  0.0376      0.896 0.996 0.004
#> GSM71041     1  0.7219      0.778 0.800 0.200
#> GSM71047     2  0.0000      0.937 0.000 1.000
#> GSM71048     1  0.0000      0.898 1.000 0.000
#> GSM71050     1  0.9686      0.423 0.604 0.396
#> GSM71051     2  0.0000      0.937 0.000 1.000
#> GSM71052     2  0.0000      0.937 0.000 1.000
#> GSM71054     1  0.7219      0.778 0.800 0.200
#> GSM71057     1  0.7219      0.778 0.800 0.200
#> GSM71060     1  0.7219      0.778 0.800 0.200
#> GSM71066     1  0.0000      0.898 1.000 0.000
#> GSM71070     2  0.0000      0.937 0.000 1.000
#> GSM71072     2  0.0000      0.937 0.000 1.000
#> GSM71074     2  0.0000      0.937 0.000 1.000
#> GSM71076     2  0.0000      0.937 0.000 1.000
#> GSM71077     2  0.0000      0.937 0.000 1.000
#> GSM71069     2  0.0000      0.937 0.000 1.000
#> GSM71071     2  0.0000      0.937 0.000 1.000
#> GSM71073     2  0.0000      0.937 0.000 1.000
#> GSM71075     2  0.0000      0.937 0.000 1.000
#> GSM71078     2  0.0000      0.937 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71020     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71022     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71023     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71024     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71025     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71028     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71030     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71032     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71034     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71035     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71038     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71043     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71046     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71053     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71061     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71062     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71063     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71068     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71029     2  0.6302     0.0848 0.480 0.520 0.000
#> GSM71031     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71033     2  0.0592     0.9563 0.012 0.988 0.000
#> GSM71036     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71042     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71044     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71045     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71049     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71055     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71056     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71058     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71059     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71064     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71065     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71067     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71037     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71039     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71040     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71041     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71047     3  0.5291     0.6509 0.000 0.268 0.732
#> GSM71048     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71050     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71051     3  0.5291     0.6509 0.000 0.268 0.732
#> GSM71052     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71054     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71057     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71060     3  0.0000     0.9652 0.000 0.000 1.000
#> GSM71066     1  0.0000     1.0000 1.000 0.000 0.000
#> GSM71070     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71072     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71074     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71076     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71077     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71069     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71071     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71073     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71075     2  0.0000     0.9682 0.000 1.000 0.000
#> GSM71078     3  0.0000     0.9652 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4103      0.561 0.000 0.744 0.000 0.256
#> GSM71024     1  0.0592      0.925 0.984 0.000 0.000 0.016
#> GSM71025     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0707      0.917 0.000 0.000 0.980 0.020
#> GSM71030     1  0.0817      0.922 0.976 0.000 0.000 0.024
#> GSM71032     1  0.0188      0.929 0.996 0.000 0.000 0.004
#> GSM71034     1  0.0188      0.929 0.996 0.000 0.000 0.004
#> GSM71035     3  0.0469      0.919 0.000 0.000 0.988 0.012
#> GSM71038     1  0.0188      0.929 0.996 0.000 0.000 0.004
#> GSM71043     3  0.0895      0.914 0.004 0.000 0.976 0.020
#> GSM71046     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0188      0.929 0.996 0.000 0.000 0.004
#> GSM71061     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71062     1  0.0817      0.922 0.976 0.000 0.000 0.024
#> GSM71063     3  0.4839      0.697 0.044 0.000 0.756 0.200
#> GSM71068     1  0.0817      0.922 0.976 0.000 0.000 0.024
#> GSM71029     2  0.5136      0.625 0.224 0.728 0.000 0.048
#> GSM71031     1  0.3172      0.785 0.840 0.000 0.000 0.160
#> GSM71033     2  0.2282      0.862 0.024 0.924 0.000 0.052
#> GSM71036     1  0.1302      0.925 0.956 0.000 0.000 0.044
#> GSM71042     1  0.1302      0.925 0.956 0.000 0.000 0.044
#> GSM71044     1  0.6111      0.290 0.556 0.392 0.000 0.052
#> GSM71045     1  0.1302      0.925 0.956 0.000 0.000 0.044
#> GSM71049     1  0.6120      0.173 0.520 0.432 0.000 0.048
#> GSM71055     1  0.1389      0.924 0.952 0.000 0.000 0.048
#> GSM71056     1  0.1302      0.925 0.956 0.000 0.000 0.044
#> GSM71058     1  0.1637      0.924 0.940 0.000 0.000 0.060
#> GSM71059     1  0.1302      0.925 0.956 0.000 0.000 0.044
#> GSM71064     1  0.1389      0.925 0.952 0.000 0.000 0.048
#> GSM71065     1  0.1474      0.923 0.948 0.000 0.000 0.052
#> GSM71067     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71039     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71040     3  0.2002      0.883 0.044 0.000 0.936 0.020
#> GSM71041     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71047     3  0.4643      0.478 0.000 0.344 0.656 0.000
#> GSM71048     1  0.0817      0.922 0.976 0.000 0.000 0.024
#> GSM71050     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71051     3  0.6248      0.546 0.000 0.252 0.644 0.104
#> GSM71052     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000      0.925 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000      0.929 1.000 0.000 0.000 0.000
#> GSM71070     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71072     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71074     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71076     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71077     2  0.0000      0.930 0.000 1.000 0.000 0.000
#> GSM71069     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71071     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71073     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71075     4  0.1940      0.985 0.000 0.076 0.000 0.924
#> GSM71078     4  0.1940      0.895 0.000 0.000 0.076 0.924

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.0290    0.97393 0.000 0.992 0.000 0.000 0.008
#> GSM71020     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71023     2  0.2249    0.88237 0.000 0.896 0.000 0.096 0.008
#> GSM71024     5  0.3336    0.51544 0.228 0.000 0.000 0.000 0.772
#> GSM71025     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4403    0.42965 0.000 0.000 0.560 0.004 0.436
#> GSM71030     5  0.2471    0.65439 0.136 0.000 0.000 0.000 0.864
#> GSM71032     1  0.4302    0.28360 0.520 0.000 0.000 0.000 0.480
#> GSM71034     5  0.4171    0.00753 0.396 0.000 0.000 0.000 0.604
#> GSM71035     3  0.3898    0.77860 0.000 0.000 0.804 0.080 0.116
#> GSM71038     1  0.4300    0.28641 0.524 0.000 0.000 0.000 0.476
#> GSM71043     3  0.4410    0.41950 0.000 0.000 0.556 0.004 0.440
#> GSM71046     1  0.4305    0.28139 0.512 0.000 0.000 0.000 0.488
#> GSM71053     1  0.4300    0.28641 0.524 0.000 0.000 0.000 0.476
#> GSM71061     3  0.2338    0.81994 0.000 0.000 0.884 0.004 0.112
#> GSM71062     5  0.2179    0.66451 0.112 0.000 0.000 0.000 0.888
#> GSM71063     5  0.4475    0.26485 0.000 0.000 0.276 0.032 0.692
#> GSM71068     5  0.2230    0.66272 0.116 0.000 0.000 0.000 0.884
#> GSM71029     1  0.4779    0.21486 0.584 0.396 0.000 0.004 0.016
#> GSM71031     5  0.3769    0.50873 0.176 0.000 0.012 0.016 0.796
#> GSM71033     2  0.2463    0.88895 0.100 0.888 0.000 0.004 0.008
#> GSM71036     1  0.1851    0.68078 0.912 0.000 0.000 0.000 0.088
#> GSM71042     1  0.1732    0.68135 0.920 0.000 0.000 0.000 0.080
#> GSM71044     1  0.1329    0.63456 0.956 0.032 0.000 0.004 0.008
#> GSM71045     1  0.2179    0.67261 0.888 0.000 0.000 0.000 0.112
#> GSM71049     1  0.2005    0.62568 0.924 0.056 0.000 0.004 0.016
#> GSM71055     1  0.0880    0.66970 0.968 0.000 0.000 0.000 0.032
#> GSM71056     1  0.1965    0.67936 0.904 0.000 0.000 0.000 0.096
#> GSM71058     1  0.3949    0.32584 0.668 0.000 0.000 0.000 0.332
#> GSM71059     1  0.1732    0.68135 0.920 0.000 0.000 0.000 0.080
#> GSM71064     1  0.1341    0.67706 0.944 0.000 0.000 0.000 0.056
#> GSM71065     1  0.0451    0.65430 0.988 0.000 0.000 0.004 0.008
#> GSM71067     1  0.4307    0.26341 0.504 0.000 0.000 0.000 0.496
#> GSM71037     3  0.0162    0.82896 0.000 0.000 0.996 0.004 0.000
#> GSM71039     3  0.2286    0.82158 0.000 0.000 0.888 0.004 0.108
#> GSM71040     5  0.4101    0.16027 0.000 0.000 0.332 0.004 0.664
#> GSM71041     3  0.1341    0.83170 0.000 0.000 0.944 0.000 0.056
#> GSM71047     3  0.3928    0.51936 0.000 0.296 0.700 0.004 0.000
#> GSM71048     5  0.2424    0.65828 0.132 0.000 0.000 0.000 0.868
#> GSM71050     3  0.2286    0.82158 0.000 0.000 0.888 0.004 0.108
#> GSM71051     3  0.3988    0.58468 0.000 0.252 0.732 0.016 0.000
#> GSM71052     3  0.0162    0.82896 0.000 0.000 0.996 0.004 0.000
#> GSM71054     3  0.0162    0.82896 0.000 0.000 0.996 0.004 0.000
#> GSM71057     3  0.0162    0.82896 0.000 0.000 0.996 0.004 0.000
#> GSM71060     3  0.0963    0.83239 0.000 0.000 0.964 0.000 0.036
#> GSM71066     1  0.4307    0.25215 0.500 0.000 0.000 0.000 0.500
#> GSM71070     4  0.0404    0.98670 0.000 0.012 0.000 0.988 0.000
#> GSM71072     4  0.0404    0.98670 0.000 0.012 0.000 0.988 0.000
#> GSM71074     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.0404    0.98670 0.000 0.012 0.000 0.988 0.000
#> GSM71077     2  0.0000    0.97822 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.0290    0.98410 0.000 0.008 0.000 0.992 0.000
#> GSM71071     4  0.0404    0.98670 0.000 0.012 0.000 0.988 0.000
#> GSM71073     4  0.1732    0.92419 0.000 0.080 0.000 0.920 0.000
#> GSM71075     4  0.0404    0.98670 0.000 0.012 0.000 0.988 0.000
#> GSM71078     4  0.0290    0.97666 0.000 0.000 0.008 0.992 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
#> GSM71019     2  0.1802     0.8988 0.024 0.932 0.000 0.000 0.020 0.024
#> GSM71020     2  0.0000     0.9317 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0146     0.9321 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71022     2  0.0146     0.9321 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71023     2  0.3527     0.8194 0.024 0.836 0.000 0.096 0.020 0.024
#> GSM71024     5  0.2070     0.6827 0.008 0.000 0.000 0.000 0.892 0.100
#> GSM71025     2  0.0146     0.9321 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71026     2  0.0146     0.9321 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71027     2  0.0146     0.9316 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71028     6  0.2454     0.6937 0.000 0.000 0.160 0.000 0.000 0.840
#> GSM71030     5  0.2994     0.6576 0.004 0.000 0.000 0.000 0.788 0.208
#> GSM71032     5  0.3672     0.5783 0.304 0.000 0.000 0.000 0.688 0.008
#> GSM71034     5  0.2263     0.6726 0.100 0.000 0.000 0.000 0.884 0.016
#> GSM71035     6  0.4462     0.6090 0.000 0.000 0.280 0.060 0.000 0.660
#> GSM71038     5  0.3421     0.6104 0.256 0.000 0.000 0.000 0.736 0.008
#> GSM71043     6  0.2558     0.6940 0.000 0.000 0.156 0.000 0.004 0.840
#> GSM71046     5  0.2416     0.6199 0.156 0.000 0.000 0.000 0.844 0.000
#> GSM71053     5  0.3512     0.6074 0.272 0.000 0.000 0.000 0.720 0.008
#> GSM71061     6  0.3659     0.5639 0.000 0.000 0.364 0.000 0.000 0.636
#> GSM71062     5  0.3175     0.6263 0.000 0.000 0.000 0.000 0.744 0.256
#> GSM71063     6  0.2389     0.6529 0.000 0.000 0.060 0.000 0.052 0.888
#> GSM71068     5  0.3290     0.6320 0.004 0.000 0.000 0.000 0.744 0.252
#> GSM71029     1  0.6403     0.4251 0.532 0.248 0.000 0.000 0.156 0.064
#> GSM71031     6  0.5167     0.3209 0.148 0.000 0.000 0.000 0.240 0.612
#> GSM71033     2  0.5609     0.3663 0.408 0.492 0.016 0.000 0.004 0.080
#> GSM71036     1  0.3907     0.6584 0.588 0.000 0.000 0.000 0.408 0.004
#> GSM71042     1  0.3907     0.6578 0.588 0.000 0.000 0.000 0.408 0.004
#> GSM71044     1  0.1984     0.5917 0.912 0.000 0.000 0.000 0.032 0.056
#> GSM71045     1  0.3937     0.6279 0.572 0.000 0.000 0.000 0.424 0.004
#> GSM71049     1  0.4637     0.6334 0.720 0.028 0.000 0.000 0.184 0.068
#> GSM71055     1  0.3468     0.6894 0.712 0.000 0.000 0.000 0.284 0.004
#> GSM71056     1  0.3864     0.5395 0.520 0.000 0.000 0.000 0.480 0.000
#> GSM71058     1  0.4566     0.4919 0.692 0.000 0.004 0.000 0.220 0.084
#> GSM71059     1  0.3915     0.6543 0.584 0.000 0.000 0.000 0.412 0.004
#> GSM71064     1  0.3518     0.6507 0.732 0.000 0.000 0.000 0.256 0.012
#> GSM71065     1  0.2361     0.6345 0.884 0.000 0.000 0.000 0.088 0.028
#> GSM71067     5  0.2135     0.6507 0.128 0.000 0.000 0.000 0.872 0.000
#> GSM71037     3  0.0937     0.7885 0.000 0.000 0.960 0.000 0.000 0.040
#> GSM71039     6  0.3695     0.5416 0.000 0.000 0.376 0.000 0.000 0.624
#> GSM71040     6  0.4086     0.6220 0.000 0.000 0.124 0.000 0.124 0.752
#> GSM71041     3  0.3774    -0.0203 0.000 0.000 0.592 0.000 0.000 0.408
#> GSM71047     3  0.1958     0.7181 0.000 0.100 0.896 0.000 0.000 0.004
#> GSM71048     5  0.2730     0.6649 0.000 0.000 0.000 0.000 0.808 0.192
#> GSM71050     6  0.3789     0.4712 0.000 0.000 0.416 0.000 0.000 0.584
#> GSM71051     3  0.1610     0.7354 0.000 0.084 0.916 0.000 0.000 0.000
#> GSM71052     3  0.0146     0.7903 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM71054     3  0.0865     0.7905 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM71057     3  0.0458     0.7932 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM71060     3  0.3309     0.4274 0.000 0.000 0.720 0.000 0.000 0.280
#> GSM71066     5  0.2520     0.6300 0.152 0.000 0.000 0.000 0.844 0.004
#> GSM71070     4  0.0146     0.9757 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM71072     4  0.0000     0.9766 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71074     2  0.0146     0.9316 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71076     4  0.0000     0.9766 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71077     2  0.0146     0.9316 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71069     4  0.0146     0.9757 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM71071     4  0.0000     0.9766 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71073     4  0.2048     0.8633 0.000 0.120 0.000 0.880 0.000 0.000
#> GSM71075     4  0.0000     0.9766 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71078     4  0.0806     0.9598 0.000 0.000 0.008 0.972 0.000 0.020

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:skmeans 54    4.79e-07 2
#> SD:skmeans 59    7.79e-12 3
#> SD:skmeans 57    4.89e-16 4
#> SD:skmeans 47    1.60e-16 5
#> SD:skmeans 53    6.68e-21 6

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


SD:pam

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

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

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

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

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.465           0.739       0.831         0.3890 0.655   0.655
#> 3 3 0.515           0.619       0.816         0.5566 0.668   0.533
#> 4 4 0.762           0.823       0.910         0.1813 0.710   0.419
#> 5 5 0.758           0.763       0.848         0.1113 0.858   0.534
#> 6 6 0.782           0.734       0.870         0.0363 0.951   0.766

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
#> GSM71019     1  0.8763      0.120 0.704 0.296
#> GSM71020     2  0.8861      0.936 0.304 0.696
#> GSM71021     2  0.8861      0.936 0.304 0.696
#> GSM71022     2  0.8861      0.936 0.304 0.696
#> GSM71023     1  0.8763      0.120 0.704 0.296
#> GSM71024     1  0.0000      0.770 1.000 0.000
#> GSM71025     2  0.8861      0.936 0.304 0.696
#> GSM71026     2  0.8861      0.936 0.304 0.696
#> GSM71027     2  0.8861      0.936 0.304 0.696
#> GSM71028     1  0.0000      0.770 1.000 0.000
#> GSM71030     1  0.0000      0.770 1.000 0.000
#> GSM71032     1  0.8861      0.738 0.696 0.304
#> GSM71034     1  0.8861      0.738 0.696 0.304
#> GSM71035     1  0.0000      0.770 1.000 0.000
#> GSM71038     1  0.8861      0.738 0.696 0.304
#> GSM71043     1  0.0000      0.770 1.000 0.000
#> GSM71046     1  0.8861      0.738 0.696 0.304
#> GSM71053     1  0.8861      0.738 0.696 0.304
#> GSM71061     1  0.0000      0.770 1.000 0.000
#> GSM71062     1  0.4690      0.762 0.900 0.100
#> GSM71063     1  0.0000      0.770 1.000 0.000
#> GSM71068     1  0.8861      0.738 0.696 0.304
#> GSM71029     2  0.9795     -0.371 0.416 0.584
#> GSM71031     1  0.0000      0.770 1.000 0.000
#> GSM71033     1  0.0000      0.770 1.000 0.000
#> GSM71036     1  0.8861      0.738 0.696 0.304
#> GSM71042     1  0.8861      0.738 0.696 0.304
#> GSM71044     1  0.8861      0.738 0.696 0.304
#> GSM71045     1  0.8861      0.738 0.696 0.304
#> GSM71049     1  0.8861      0.738 0.696 0.304
#> GSM71055     1  0.8861      0.738 0.696 0.304
#> GSM71056     1  0.8861      0.738 0.696 0.304
#> GSM71058     1  0.1184      0.770 0.984 0.016
#> GSM71059     1  0.8861      0.738 0.696 0.304
#> GSM71064     1  0.8861      0.738 0.696 0.304
#> GSM71065     1  0.8861      0.738 0.696 0.304
#> GSM71067     1  0.8861      0.738 0.696 0.304
#> GSM71037     1  0.0672      0.770 0.992 0.008
#> GSM71039     1  0.0000      0.770 1.000 0.000
#> GSM71040     1  0.0000      0.770 1.000 0.000
#> GSM71041     1  0.0000      0.770 1.000 0.000
#> GSM71047     1  0.1633      0.746 0.976 0.024
#> GSM71048     1  0.8813      0.738 0.700 0.300
#> GSM71050     1  0.0000      0.770 1.000 0.000
#> GSM71051     1  0.2778      0.718 0.952 0.048
#> GSM71052     1  0.0000      0.770 1.000 0.000
#> GSM71054     1  0.0000      0.770 1.000 0.000
#> GSM71057     1  0.0000      0.770 1.000 0.000
#> GSM71060     1  0.0000      0.770 1.000 0.000
#> GSM71066     1  0.8861      0.738 0.696 0.304
#> GSM71070     1  0.3733      0.682 0.928 0.072
#> GSM71072     2  0.8861      0.936 0.304 0.696
#> GSM71074     2  0.8861      0.936 0.304 0.696
#> GSM71076     2  0.8861      0.936 0.304 0.696
#> GSM71077     2  0.8861      0.936 0.304 0.696
#> GSM71069     1  0.0000      0.770 1.000 0.000
#> GSM71071     2  0.8861      0.936 0.304 0.696
#> GSM71073     2  0.8861      0.936 0.304 0.696
#> GSM71075     1  0.8608      0.163 0.716 0.284
#> GSM71078     1  0.0000      0.770 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
#> GSM71019     3  0.5573     0.5535 0.044 0.160 0.796
#> GSM71020     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71021     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71022     3  0.6299    -0.6860 0.000 0.476 0.524
#> GSM71023     3  0.7948     0.6939 0.080 0.320 0.600
#> GSM71024     1  0.4409     0.7058 0.824 0.172 0.004
#> GSM71025     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71026     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71027     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71028     1  0.8020     0.6121 0.596 0.320 0.084
#> GSM71030     1  0.5656     0.6818 0.712 0.284 0.004
#> GSM71032     1  0.0237     0.7266 0.996 0.004 0.000
#> GSM71034     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71035     3  0.6396     0.7299 0.016 0.320 0.664
#> GSM71038     1  0.0237     0.7266 0.996 0.004 0.000
#> GSM71043     1  0.8020     0.6121 0.596 0.320 0.084
#> GSM71046     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71053     1  0.0237     0.7266 0.996 0.004 0.000
#> GSM71061     1  0.7970     0.6123 0.596 0.324 0.080
#> GSM71062     1  0.5929     0.6685 0.676 0.320 0.004
#> GSM71063     1  0.7285     0.6408 0.632 0.320 0.048
#> GSM71068     1  0.5706     0.6704 0.680 0.320 0.000
#> GSM71029     1  0.6235    -0.0181 0.564 0.000 0.436
#> GSM71031     1  0.5929     0.6685 0.676 0.320 0.004
#> GSM71033     3  0.9713     0.4253 0.240 0.316 0.444
#> GSM71036     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71044     1  0.5988     0.1656 0.632 0.000 0.368
#> GSM71045     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71049     1  0.6235    -0.0181 0.564 0.000 0.436
#> GSM71055     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71056     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71058     1  0.5929     0.6685 0.676 0.320 0.004
#> GSM71059     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71065     1  0.0424     0.7217 0.992 0.000 0.008
#> GSM71067     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71037     1  0.7970     0.6123 0.596 0.324 0.080
#> GSM71039     3  0.7896     0.6636 0.076 0.324 0.600
#> GSM71040     1  0.5929     0.6685 0.676 0.320 0.004
#> GSM71041     1  0.8665     0.5517 0.552 0.324 0.124
#> GSM71047     3  0.5733     0.7379 0.000 0.324 0.676
#> GSM71048     1  0.5706     0.6704 0.680 0.320 0.000
#> GSM71050     3  0.9245     0.4991 0.176 0.320 0.504
#> GSM71051     3  0.5733     0.7379 0.000 0.324 0.676
#> GSM71052     3  0.6129     0.7345 0.008 0.324 0.668
#> GSM71054     1  0.7970     0.6123 0.596 0.324 0.080
#> GSM71057     1  0.9501     0.3954 0.472 0.324 0.204
#> GSM71060     1  0.7970     0.6123 0.596 0.324 0.080
#> GSM71066     1  0.0000     0.7261 1.000 0.000 0.000
#> GSM71070     3  0.5929     0.7379 0.004 0.320 0.676
#> GSM71072     3  0.0000     0.4166 0.000 0.000 1.000
#> GSM71074     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71076     3  0.0000     0.4166 0.000 0.000 1.000
#> GSM71077     2  0.5733     1.0000 0.000 0.676 0.324
#> GSM71069     3  0.5706     0.7381 0.000 0.320 0.680
#> GSM71071     3  0.2066     0.3172 0.000 0.060 0.940
#> GSM71073     3  0.6299    -0.6860 0.000 0.476 0.524
#> GSM71075     3  0.7948     0.6939 0.080 0.320 0.600
#> GSM71078     3  0.5733     0.7379 0.000 0.324 0.676

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.3810      0.772 0.000 0.188 0.008 0.804
#> GSM71020     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71023     4  0.2546      0.883 0.000 0.008 0.092 0.900
#> GSM71024     3  0.5408      0.309 0.488 0.000 0.500 0.012
#> GSM71025     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71028     3  0.2081      0.733 0.000 0.000 0.916 0.084
#> GSM71030     3  0.4961      0.432 0.448 0.000 0.552 0.000
#> GSM71032     1  0.2408      0.844 0.896 0.000 0.104 0.000
#> GSM71034     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71035     4  0.1118      0.929 0.000 0.000 0.036 0.964
#> GSM71038     1  0.3356      0.731 0.824 0.000 0.176 0.000
#> GSM71043     3  0.0817      0.766 0.024 0.000 0.976 0.000
#> GSM71046     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71053     1  0.3837      0.632 0.776 0.000 0.224 0.000
#> GSM71061     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71062     3  0.4855      0.516 0.400 0.000 0.600 0.000
#> GSM71063     3  0.7250      0.503 0.316 0.000 0.516 0.168
#> GSM71068     3  0.4933      0.466 0.432 0.000 0.568 0.000
#> GSM71029     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71031     3  0.6669      0.543 0.332 0.000 0.564 0.104
#> GSM71033     3  0.4094      0.710 0.116 0.056 0.828 0.000
#> GSM71036     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71044     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71045     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71049     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71055     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71058     3  0.4933      0.466 0.432 0.000 0.568 0.000
#> GSM71059     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71065     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71067     1  0.0592      0.945 0.984 0.000 0.016 0.000
#> GSM71037     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71039     3  0.1557      0.747 0.000 0.000 0.944 0.056
#> GSM71040     3  0.4585      0.588 0.332 0.000 0.668 0.000
#> GSM71041     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71047     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71048     3  0.4941      0.458 0.436 0.000 0.564 0.000
#> GSM71050     3  0.2266      0.734 0.004 0.000 0.912 0.084
#> GSM71051     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71052     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000      0.766 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000      0.959 1.000 0.000 0.000 0.000
#> GSM71070     4  0.2216      0.885 0.000 0.000 0.092 0.908
#> GSM71072     4  0.0000      0.946 0.000 0.000 0.000 1.000
#> GSM71074     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71076     4  0.0000      0.946 0.000 0.000 0.000 1.000
#> GSM71077     2  0.0000      0.986 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0000      0.946 0.000 0.000 0.000 1.000
#> GSM71071     4  0.0000      0.946 0.000 0.000 0.000 1.000
#> GSM71073     2  0.2530      0.881 0.000 0.888 0.000 0.112
#> GSM71075     4  0.0000      0.946 0.000 0.000 0.000 1.000
#> GSM71078     4  0.0000      0.946 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.6851   0.701872 0.028 0.148 0.128 0.636 0.060
#> GSM71020     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0510   0.938841 0.000 0.984 0.016 0.000 0.000
#> GSM71023     4  0.5829   0.684238 0.000 0.008 0.156 0.636 0.200
#> GSM71024     5  0.2462   0.731432 0.008 0.000 0.112 0.000 0.880
#> GSM71025     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4574   0.695440 0.000 0.000 0.576 0.012 0.412
#> GSM71030     5  0.0290   0.775924 0.008 0.000 0.000 0.000 0.992
#> GSM71032     5  0.4015   0.526919 0.348 0.000 0.000 0.000 0.652
#> GSM71034     5  0.4300   0.200016 0.476 0.000 0.000 0.000 0.524
#> GSM71035     4  0.4170   0.818191 0.000 0.000 0.140 0.780 0.080
#> GSM71038     5  0.3932   0.557188 0.328 0.000 0.000 0.000 0.672
#> GSM71043     3  0.4242   0.682101 0.000 0.000 0.572 0.000 0.428
#> GSM71046     1  0.4249   0.000564 0.568 0.000 0.000 0.000 0.432
#> GSM71053     5  0.3999   0.535060 0.344 0.000 0.000 0.000 0.656
#> GSM71061     3  0.3143   0.844337 0.000 0.000 0.796 0.000 0.204
#> GSM71062     5  0.0000   0.772950 0.000 0.000 0.000 0.000 1.000
#> GSM71063     5  0.1341   0.742367 0.000 0.000 0.000 0.056 0.944
#> GSM71068     5  0.0000   0.772950 0.000 0.000 0.000 0.000 1.000
#> GSM71029     1  0.0510   0.861045 0.984 0.000 0.016 0.000 0.000
#> GSM71031     5  0.0404   0.772777 0.000 0.000 0.012 0.000 0.988
#> GSM71033     3  0.4573   0.649982 0.044 0.000 0.700 0.000 0.256
#> GSM71036     1  0.2471   0.725005 0.864 0.000 0.000 0.000 0.136
#> GSM71042     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71045     5  0.3508   0.637740 0.252 0.000 0.000 0.000 0.748
#> GSM71049     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71058     5  0.0000   0.772950 0.000 0.000 0.000 0.000 1.000
#> GSM71059     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000   0.873242 1.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.3949   0.551459 0.332 0.000 0.000 0.000 0.668
#> GSM71037     3  0.2377   0.856175 0.000 0.000 0.872 0.000 0.128
#> GSM71039     3  0.4645   0.815339 0.000 0.000 0.724 0.072 0.204
#> GSM71040     5  0.0000   0.772950 0.000 0.000 0.000 0.000 1.000
#> GSM71041     3  0.2891   0.852466 0.000 0.000 0.824 0.000 0.176
#> GSM71047     3  0.0000   0.762479 0.000 0.000 1.000 0.000 0.000
#> GSM71048     5  0.0290   0.775924 0.008 0.000 0.000 0.000 0.992
#> GSM71050     3  0.4383   0.685762 0.000 0.000 0.572 0.004 0.424
#> GSM71051     3  0.0963   0.797531 0.000 0.000 0.964 0.000 0.036
#> GSM71052     3  0.2280   0.852459 0.000 0.000 0.880 0.000 0.120
#> GSM71054     3  0.2377   0.856175 0.000 0.000 0.872 0.000 0.128
#> GSM71057     3  0.2377   0.856175 0.000 0.000 0.872 0.000 0.128
#> GSM71060     3  0.2377   0.856175 0.000 0.000 0.872 0.000 0.128
#> GSM71066     1  0.4291  -0.120105 0.536 0.000 0.000 0.000 0.464
#> GSM71070     4  0.2377   0.859692 0.000 0.000 0.128 0.872 0.000
#> GSM71072     4  0.0000   0.876532 0.000 0.000 0.000 1.000 0.000
#> GSM71074     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.0000   0.876532 0.000 0.000 0.000 1.000 0.000
#> GSM71077     2  0.0000   0.950997 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.2771   0.858072 0.000 0.000 0.128 0.860 0.012
#> GSM71071     4  0.0000   0.876532 0.000 0.000 0.000 1.000 0.000
#> GSM71073     2  0.4114   0.464697 0.000 0.624 0.000 0.376 0.000
#> GSM71075     4  0.0000   0.876532 0.000 0.000 0.000 1.000 0.000
#> GSM71078     4  0.0000   0.876532 0.000 0.000 0.000 1.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
#> GSM71019     6  0.3014     0.6646 0.000 0.184 0.000 0.000 0.012 0.804
#> GSM71020     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.3756     0.2385 0.000 0.600 0.000 0.000 0.000 0.400
#> GSM71023     6  0.2762     0.7005 0.000 0.000 0.000 0.000 0.196 0.804
#> GSM71024     5  0.2357     0.7260 0.000 0.000 0.012 0.000 0.872 0.116
#> GSM71025     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     3  0.5397     0.6730 0.000 0.000 0.584 0.000 0.216 0.200
#> GSM71030     5  0.0363     0.7891 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71032     5  0.3592     0.5517 0.344 0.000 0.000 0.000 0.656 0.000
#> GSM71034     5  0.3828     0.3311 0.440 0.000 0.000 0.000 0.560 0.000
#> GSM71035     3  0.3789     0.5799 0.000 0.000 0.584 0.000 0.000 0.416
#> GSM71038     5  0.3482     0.5924 0.316 0.000 0.000 0.000 0.684 0.000
#> GSM71043     3  0.5395     0.6719 0.000 0.000 0.584 0.000 0.220 0.196
#> GSM71046     1  0.3838    -0.0739 0.552 0.000 0.000 0.000 0.448 0.000
#> GSM71053     5  0.3634     0.5303 0.356 0.000 0.000 0.000 0.644 0.000
#> GSM71061     3  0.5175     0.6967 0.000 0.000 0.620 0.000 0.184 0.196
#> GSM71062     5  0.0000     0.7900 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     5  0.3110     0.6624 0.000 0.000 0.012 0.000 0.792 0.196
#> GSM71068     5  0.0000     0.7900 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71031     5  0.0993     0.7824 0.000 0.000 0.012 0.000 0.964 0.024
#> GSM71033     6  0.0000     0.6936 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM71036     1  0.2048     0.7435 0.880 0.000 0.000 0.000 0.120 0.000
#> GSM71042     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71045     5  0.3014     0.7027 0.184 0.000 0.012 0.000 0.804 0.000
#> GSM71049     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71058     5  0.0363     0.7891 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71059     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000     0.8739 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.3482     0.5924 0.316 0.000 0.000 0.000 0.684 0.000
#> GSM71037     3  0.0000     0.7307 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     3  0.4721     0.7153 0.000 0.000 0.672 0.000 0.116 0.212
#> GSM71040     5  0.0363     0.7891 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71041     3  0.2454     0.7270 0.000 0.000 0.840 0.000 0.160 0.000
#> GSM71047     6  0.3789     0.4413 0.000 0.000 0.416 0.000 0.000 0.584
#> GSM71048     5  0.0363     0.7891 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71050     3  0.5164     0.6638 0.000 0.000 0.584 0.000 0.116 0.300
#> GSM71051     3  0.3126     0.3682 0.000 0.000 0.752 0.000 0.000 0.248
#> GSM71052     3  0.0260     0.7239 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM71054     3  0.0000     0.7307 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0000     0.7307 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71060     3  0.0000     0.7307 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71066     1  0.3862    -0.1748 0.524 0.000 0.000 0.000 0.476 0.000
#> GSM71070     6  0.2762     0.7238 0.000 0.000 0.000 0.196 0.000 0.804
#> GSM71072     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71074     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71077     2  0.0000     0.9340 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     6  0.2762     0.7238 0.000 0.000 0.000 0.196 0.000 0.804
#> GSM71071     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71073     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71075     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71078     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:pam 56    1.35e-07 2
#> SD:pam 49    5.61e-07 3
#> SD:pam 55    4.22e-12 4
#> SD:pam 56    1.21e-14 5
#> SD:pam 54    6.39e-14 6

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


SD:mclust

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

res = res_list["SD", "mclust"]
# you can also extract it by
# res = res_list["SD:mclust"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.492           0.901       0.892          0.380 0.619   0.619
#> 3 3 0.447           0.734       0.862          0.518 0.572   0.422
#> 4 4 0.650           0.726       0.857          0.197 0.697   0.413
#> 5 5 0.719           0.709       0.814          0.124 0.889   0.633
#> 6 6 0.763           0.682       0.823          0.054 0.864   0.474

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
#> GSM71019     1  0.0376      0.907 0.996 0.004
#> GSM71020     2  0.7299      0.982 0.204 0.796
#> GSM71021     2  0.7299      0.982 0.204 0.796
#> GSM71022     2  0.7299      0.982 0.204 0.796
#> GSM71023     1  0.0672      0.903 0.992 0.008
#> GSM71024     1  0.0000      0.906 1.000 0.000
#> GSM71025     2  0.7299      0.982 0.204 0.796
#> GSM71026     2  0.7299      0.982 0.204 0.796
#> GSM71027     2  0.7299      0.982 0.204 0.796
#> GSM71028     1  0.0376      0.907 0.996 0.004
#> GSM71030     1  0.0000      0.906 1.000 0.000
#> GSM71032     1  0.7299      0.830 0.796 0.204
#> GSM71034     1  0.7299      0.830 0.796 0.204
#> GSM71035     1  0.0376      0.907 0.996 0.004
#> GSM71038     1  0.7299      0.830 0.796 0.204
#> GSM71043     1  0.0376      0.907 0.996 0.004
#> GSM71046     1  0.7299      0.830 0.796 0.204
#> GSM71053     1  0.7299      0.830 0.796 0.204
#> GSM71061     1  0.0376      0.907 0.996 0.004
#> GSM71062     1  0.0376      0.907 0.996 0.004
#> GSM71063     1  0.0376      0.907 0.996 0.004
#> GSM71068     1  0.0000      0.906 1.000 0.000
#> GSM71029     1  0.0672      0.904 0.992 0.008
#> GSM71031     1  0.0376      0.907 0.996 0.004
#> GSM71033     1  0.0376      0.907 0.996 0.004
#> GSM71036     1  0.7299      0.830 0.796 0.204
#> GSM71042     1  0.7299      0.830 0.796 0.204
#> GSM71044     1  0.2778      0.891 0.952 0.048
#> GSM71045     1  0.7299      0.830 0.796 0.204
#> GSM71049     1  0.2603      0.893 0.956 0.044
#> GSM71055     1  0.7299      0.830 0.796 0.204
#> GSM71056     1  0.7299      0.830 0.796 0.204
#> GSM71058     1  0.0376      0.907 0.996 0.004
#> GSM71059     1  0.7299      0.830 0.796 0.204
#> GSM71064     1  0.7299      0.830 0.796 0.204
#> GSM71065     1  0.6973      0.836 0.812 0.188
#> GSM71067     1  0.7299      0.830 0.796 0.204
#> GSM71037     1  0.0376      0.907 0.996 0.004
#> GSM71039     1  0.0376      0.907 0.996 0.004
#> GSM71040     1  0.0376      0.907 0.996 0.004
#> GSM71041     1  0.0376      0.907 0.996 0.004
#> GSM71047     1  0.0376      0.907 0.996 0.004
#> GSM71048     1  0.0000      0.906 1.000 0.000
#> GSM71050     1  0.0376      0.907 0.996 0.004
#> GSM71051     1  0.0376      0.907 0.996 0.004
#> GSM71052     1  0.0376      0.907 0.996 0.004
#> GSM71054     1  0.0376      0.907 0.996 0.004
#> GSM71057     1  0.0376      0.907 0.996 0.004
#> GSM71060     1  0.0376      0.907 0.996 0.004
#> GSM71066     1  0.7299      0.830 0.796 0.204
#> GSM71070     2  0.9710      0.678 0.400 0.600
#> GSM71072     2  0.7299      0.982 0.204 0.796
#> GSM71074     2  0.7299      0.982 0.204 0.796
#> GSM71076     2  0.7299      0.982 0.204 0.796
#> GSM71077     2  0.7299      0.982 0.204 0.796
#> GSM71069     2  0.7299      0.982 0.204 0.796
#> GSM71071     2  0.7299      0.982 0.204 0.796
#> GSM71073     2  0.7299      0.982 0.204 0.796
#> GSM71075     2  0.7299      0.982 0.204 0.796
#> GSM71078     1  0.0376      0.907 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.6025     0.7347 0.076 0.140 0.784
#> GSM71020     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71021     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71022     3  0.5560     0.6072 0.000 0.300 0.700
#> GSM71023     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71024     1  0.6299    -0.0531 0.524 0.000 0.476
#> GSM71025     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71026     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71027     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71028     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71030     3  0.6299     0.1681 0.476 0.000 0.524
#> GSM71032     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71034     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71035     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71038     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71043     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71046     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71053     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71061     3  0.3267     0.7258 0.000 0.116 0.884
#> GSM71062     3  0.5859     0.5313 0.344 0.000 0.656
#> GSM71063     3  0.4750     0.7094 0.216 0.000 0.784
#> GSM71068     1  0.5291     0.5815 0.732 0.000 0.268
#> GSM71029     3  0.5733     0.5797 0.324 0.000 0.676
#> GSM71031     3  0.4750     0.7094 0.216 0.000 0.784
#> GSM71033     3  0.4750     0.7094 0.216 0.000 0.784
#> GSM71036     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71044     3  0.6299     0.1999 0.476 0.000 0.524
#> GSM71045     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71049     3  0.6295     0.2119 0.472 0.000 0.528
#> GSM71055     1  0.3619     0.7437 0.864 0.000 0.136
#> GSM71056     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71058     3  0.5016     0.6837 0.240 0.000 0.760
#> GSM71059     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71065     1  0.6225     0.0486 0.568 0.000 0.432
#> GSM71067     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71037     3  0.3267     0.7258 0.000 0.116 0.884
#> GSM71039     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71040     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71041     3  0.3267     0.7258 0.000 0.116 0.884
#> GSM71047     3  0.0592     0.7816 0.000 0.012 0.988
#> GSM71048     1  0.5098     0.6164 0.752 0.000 0.248
#> GSM71050     3  0.0000     0.7842 0.000 0.000 1.000
#> GSM71051     3  0.0592     0.7816 0.000 0.012 0.988
#> GSM71052     3  0.0592     0.7816 0.000 0.012 0.988
#> GSM71054     3  0.3267     0.7258 0.000 0.116 0.884
#> GSM71057     3  0.2537     0.7487 0.000 0.080 0.920
#> GSM71060     3  0.3267     0.7258 0.000 0.116 0.884
#> GSM71066     1  0.0000     0.8713 1.000 0.000 0.000
#> GSM71070     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71072     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71074     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71076     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71077     2  0.3267     1.0000 0.000 0.884 0.116
#> GSM71069     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71071     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71073     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71075     3  0.4750     0.7140 0.000 0.216 0.784
#> GSM71078     3  0.0000     0.7842 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.5167     0.3130 0.340 0.000 0.016 0.644
#> GSM71020     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71022     4  0.4761     0.2918 0.000 0.372 0.000 0.628
#> GSM71023     4  0.0469     0.8314 0.000 0.000 0.012 0.988
#> GSM71024     1  0.3444     0.7629 0.816 0.000 0.000 0.184
#> GSM71025     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71028     3  0.4972     0.5813 0.000 0.000 0.544 0.456
#> GSM71030     1  0.3444     0.7629 0.816 0.000 0.000 0.184
#> GSM71032     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71035     3  0.5000     0.5203 0.000 0.000 0.504 0.496
#> GSM71038     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71043     3  0.4961     0.5919 0.000 0.000 0.552 0.448
#> GSM71046     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71061     3  0.0000     0.5996 0.000 0.000 1.000 0.000
#> GSM71062     1  0.3486     0.7591 0.812 0.000 0.000 0.188
#> GSM71063     3  0.5000     0.5203 0.000 0.000 0.504 0.496
#> GSM71068     1  0.3486     0.7591 0.812 0.000 0.000 0.188
#> GSM71029     1  0.4008     0.6504 0.756 0.000 0.000 0.244
#> GSM71031     1  0.5016     0.4143 0.600 0.000 0.004 0.396
#> GSM71033     1  0.6801     0.0408 0.456 0.000 0.096 0.448
#> GSM71036     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71044     1  0.3975     0.6567 0.760 0.000 0.000 0.240
#> GSM71045     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71049     1  0.3975     0.6567 0.760 0.000 0.000 0.240
#> GSM71055     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71058     1  0.3569     0.7523 0.804 0.000 0.000 0.196
#> GSM71059     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71065     1  0.2281     0.8073 0.904 0.000 0.000 0.096
#> GSM71067     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0000     0.5996 0.000 0.000 1.000 0.000
#> GSM71039     3  0.4855     0.6292 0.000 0.000 0.600 0.400
#> GSM71040     3  0.6233     0.5739 0.060 0.000 0.552 0.388
#> GSM71041     3  0.0000     0.5996 0.000 0.000 1.000 0.000
#> GSM71047     3  0.4933     0.6079 0.000 0.000 0.568 0.432
#> GSM71048     1  0.3400     0.7661 0.820 0.000 0.000 0.180
#> GSM71050     3  0.4830     0.6322 0.000 0.000 0.608 0.392
#> GSM71051     3  0.4925     0.6112 0.000 0.000 0.572 0.428
#> GSM71052     3  0.4925     0.6112 0.000 0.000 0.572 0.428
#> GSM71054     3  0.0000     0.5996 0.000 0.000 1.000 0.000
#> GSM71057     3  0.1022     0.6043 0.000 0.000 0.968 0.032
#> GSM71060     3  0.0000     0.5996 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000     0.8579 1.000 0.000 0.000 0.000
#> GSM71070     4  0.0336     0.8352 0.000 0.000 0.008 0.992
#> GSM71072     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71074     2  0.3649     0.7658 0.000 0.796 0.000 0.204
#> GSM71076     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71077     2  0.0000     0.9668 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71071     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71073     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71075     4  0.0000     0.8408 0.000 0.000 0.000 1.000
#> GSM71078     4  0.3801     0.4003 0.000 0.000 0.220 0.780

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.6618     0.5691 0.088 0.000 0.080 0.596 0.236
#> GSM71020     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71022     4  0.3857     0.5191 0.000 0.312 0.000 0.688 0.000
#> GSM71023     4  0.5411     0.6591 0.064 0.000 0.024 0.676 0.236
#> GSM71024     5  0.4525     0.5721 0.084 0.000 0.012 0.132 0.772
#> GSM71025     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.6183     0.5413 0.000 0.000 0.544 0.180 0.276
#> GSM71030     5  0.3867     0.6517 0.088 0.000 0.012 0.076 0.824
#> GSM71032     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71034     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71035     3  0.5796     0.5459 0.000 0.000 0.588 0.284 0.128
#> GSM71038     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71043     3  0.6092     0.5618 0.000 0.000 0.564 0.180 0.256
#> GSM71046     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71053     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71061     3  0.0290     0.7656 0.000 0.000 0.992 0.000 0.008
#> GSM71062     5  0.3921     0.6211 0.072 0.000 0.024 0.076 0.828
#> GSM71063     3  0.6410     0.4687 0.000 0.000 0.488 0.192 0.320
#> GSM71068     5  0.3922     0.6559 0.092 0.000 0.012 0.076 0.820
#> GSM71029     1  0.0290     0.8050 0.992 0.000 0.000 0.000 0.008
#> GSM71031     3  0.7685     0.4151 0.116 0.000 0.484 0.160 0.240
#> GSM71033     1  0.7885     0.0545 0.432 0.000 0.236 0.096 0.236
#> GSM71036     1  0.0880     0.8177 0.968 0.000 0.000 0.000 0.032
#> GSM71042     1  0.0880     0.8177 0.968 0.000 0.000 0.000 0.032
#> GSM71044     1  0.0290     0.8050 0.992 0.000 0.000 0.000 0.008
#> GSM71045     1  0.3684     0.3974 0.720 0.000 0.000 0.000 0.280
#> GSM71049     1  0.0290     0.8050 0.992 0.000 0.000 0.000 0.008
#> GSM71055     1  0.0794     0.8174 0.972 0.000 0.000 0.000 0.028
#> GSM71056     1  0.0880     0.8177 0.968 0.000 0.000 0.000 0.032
#> GSM71058     1  0.7603     0.1900 0.468 0.000 0.208 0.076 0.248
#> GSM71059     1  0.0880     0.8177 0.968 0.000 0.000 0.000 0.032
#> GSM71064     1  0.0880     0.8177 0.968 0.000 0.000 0.000 0.032
#> GSM71065     1  0.1082     0.8137 0.964 0.000 0.008 0.000 0.028
#> GSM71067     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71037     3  0.0000     0.7644 0.000 0.000 1.000 0.000 0.000
#> GSM71039     3  0.4210     0.7222 0.000 0.000 0.780 0.096 0.124
#> GSM71040     3  0.7068     0.4803 0.044 0.000 0.508 0.168 0.280
#> GSM71041     3  0.0290     0.7656 0.000 0.000 0.992 0.000 0.008
#> GSM71047     3  0.1282     0.7746 0.000 0.000 0.952 0.004 0.044
#> GSM71048     5  0.4179     0.6669 0.112 0.000 0.012 0.076 0.800
#> GSM71050     3  0.3479     0.7420 0.000 0.000 0.836 0.080 0.084
#> GSM71051     3  0.1408     0.7743 0.000 0.000 0.948 0.008 0.044
#> GSM71052     3  0.1282     0.7746 0.000 0.000 0.952 0.004 0.044
#> GSM71054     3  0.0000     0.7644 0.000 0.000 1.000 0.000 0.000
#> GSM71057     3  0.0609     0.7712 0.000 0.000 0.980 0.000 0.020
#> GSM71060     3  0.0290     0.7656 0.000 0.000 0.992 0.000 0.008
#> GSM71066     5  0.3949     0.7244 0.332 0.000 0.000 0.000 0.668
#> GSM71070     4  0.3759     0.7215 0.000 0.000 0.016 0.764 0.220
#> GSM71072     4  0.0000     0.7843 0.000 0.000 0.000 1.000 0.000
#> GSM71074     2  0.0162     0.9950 0.000 0.996 0.000 0.004 0.000
#> GSM71076     4  0.0000     0.7843 0.000 0.000 0.000 1.000 0.000
#> GSM71077     2  0.0000     0.9992 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.1597     0.7918 0.000 0.000 0.012 0.940 0.048
#> GSM71071     4  0.0000     0.7843 0.000 0.000 0.000 1.000 0.000
#> GSM71073     4  0.1121     0.7931 0.000 0.000 0.000 0.956 0.044
#> GSM71075     4  0.2077     0.7891 0.000 0.000 0.008 0.908 0.084
#> GSM71078     4  0.6015    -0.0489 0.000 0.000 0.360 0.516 0.124

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1   p2    p3    p4    p5    p6
#> GSM71019     5  0.5697      0.205 0.388 0.00 0.008 0.036 0.516 0.052
#> GSM71020     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71022     2  0.3828      0.154 0.000 0.56 0.000 0.440 0.000 0.000
#> GSM71023     5  0.4960     -0.155 0.000 0.00 0.004 0.424 0.516 0.056
#> GSM71024     5  0.0405      0.609 0.008 0.00 0.000 0.004 0.988 0.000
#> GSM71025     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71028     6  0.3560      0.901 0.000 0.00 0.020 0.016 0.176 0.788
#> GSM71030     5  0.0405      0.609 0.008 0.00 0.000 0.004 0.988 0.000
#> GSM71032     5  0.4246      0.259 0.452 0.00 0.000 0.000 0.532 0.016
#> GSM71034     5  0.3103      0.540 0.208 0.00 0.000 0.000 0.784 0.008
#> GSM71035     6  0.3766      0.846 0.000 0.00 0.020 0.112 0.064 0.804
#> GSM71038     5  0.4218      0.311 0.428 0.00 0.000 0.000 0.556 0.016
#> GSM71043     6  0.3659      0.897 0.000 0.00 0.028 0.012 0.180 0.780
#> GSM71046     1  0.4256     -0.115 0.520 0.00 0.000 0.000 0.464 0.016
#> GSM71053     5  0.4218      0.311 0.428 0.00 0.000 0.000 0.556 0.016
#> GSM71061     3  0.0146      0.903 0.000 0.00 0.996 0.000 0.000 0.004
#> GSM71062     5  0.0436      0.606 0.004 0.00 0.000 0.004 0.988 0.004
#> GSM71063     6  0.3568      0.893 0.000 0.00 0.012 0.020 0.188 0.780
#> GSM71068     5  0.0508      0.610 0.012 0.00 0.000 0.004 0.984 0.000
#> GSM71029     1  0.3247      0.743 0.808 0.00 0.000 0.000 0.036 0.156
#> GSM71031     5  0.1722      0.575 0.016 0.00 0.008 0.004 0.936 0.036
#> GSM71033     5  0.5459      0.185 0.404 0.00 0.008 0.020 0.516 0.052
#> GSM71036     1  0.0146      0.823 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM71042     1  0.0146      0.823 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM71044     1  0.3247      0.743 0.808 0.00 0.000 0.000 0.036 0.156
#> GSM71045     1  0.3659      0.226 0.636 0.00 0.000 0.000 0.364 0.000
#> GSM71049     1  0.3247      0.743 0.808 0.00 0.000 0.000 0.036 0.156
#> GSM71055     1  0.0914      0.819 0.968 0.00 0.000 0.000 0.016 0.016
#> GSM71056     1  0.0146      0.823 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM71058     5  0.4277      0.198 0.408 0.00 0.008 0.004 0.576 0.004
#> GSM71059     1  0.0146      0.823 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM71064     1  0.0146      0.823 0.996 0.00 0.000 0.000 0.004 0.000
#> GSM71065     1  0.1633      0.806 0.932 0.00 0.000 0.000 0.044 0.024
#> GSM71067     5  0.4076      0.372 0.364 0.00 0.000 0.000 0.620 0.016
#> GSM71037     3  0.0000      0.903 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM71039     3  0.5097      0.214 0.000 0.00 0.544 0.008 0.064 0.384
#> GSM71040     5  0.2641      0.523 0.000 0.00 0.072 0.004 0.876 0.048
#> GSM71041     3  0.0146      0.903 0.000 0.00 0.996 0.000 0.000 0.004
#> GSM71047     3  0.1794      0.884 0.000 0.00 0.924 0.000 0.040 0.036
#> GSM71048     5  0.0777      0.613 0.024 0.00 0.000 0.004 0.972 0.000
#> GSM71050     3  0.2393      0.849 0.000 0.00 0.892 0.004 0.064 0.040
#> GSM71051     3  0.1794      0.884 0.000 0.00 0.924 0.000 0.040 0.036
#> GSM71052     3  0.1794      0.884 0.000 0.00 0.924 0.000 0.040 0.036
#> GSM71054     3  0.0000      0.903 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0260      0.904 0.000 0.00 0.992 0.000 0.000 0.008
#> GSM71060     3  0.0146      0.903 0.000 0.00 0.996 0.000 0.000 0.004
#> GSM71066     5  0.4224      0.304 0.432 0.00 0.000 0.000 0.552 0.016
#> GSM71070     4  0.3521      0.766 0.000 0.00 0.004 0.796 0.156 0.044
#> GSM71072     4  0.0146      0.867 0.000 0.00 0.000 0.996 0.000 0.004
#> GSM71074     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0000      0.866 0.000 0.00 0.000 1.000 0.000 0.000
#> GSM71077     2  0.0000      0.929 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71069     4  0.2318      0.878 0.000 0.00 0.000 0.892 0.064 0.044
#> GSM71071     4  0.0146      0.867 0.000 0.00 0.000 0.996 0.000 0.004
#> GSM71073     4  0.2941      0.863 0.000 0.00 0.004 0.856 0.064 0.076
#> GSM71075     4  0.2376      0.877 0.000 0.00 0.000 0.888 0.068 0.044
#> GSM71078     6  0.3593      0.831 0.000 0.00 0.004 0.132 0.064 0.800

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:mclust 60    1.41e-08 2
#> SD:mclust 55    5.84e-06 3
#> SD:mclust 55    8.75e-15 4
#> SD:mclust 53    2.00e-16 5
#> SD:mclust 47    3.04e-16 6

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


SD:NMF*

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

res = res_list["SD", "NMF"]
# you can also extract it by
# res = res_list["SD:NMF"]

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

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.539           0.842       0.924         0.4531 0.528   0.528
#> 3 3 0.918           0.876       0.953         0.4329 0.702   0.495
#> 4 4 0.799           0.859       0.923         0.1188 0.896   0.720
#> 5 5 0.716           0.668       0.798         0.0852 0.882   0.604
#> 6 6 0.753           0.646       0.814         0.0385 0.940   0.732

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2  0.5059     0.8418 0.112 0.888
#> GSM71020     2  0.0000     0.8791 0.000 1.000
#> GSM71021     2  0.0000     0.8791 0.000 1.000
#> GSM71022     2  0.0000     0.8791 0.000 1.000
#> GSM71023     2  0.8327     0.6986 0.264 0.736
#> GSM71024     1  0.0000     0.9242 1.000 0.000
#> GSM71025     2  0.0000     0.8791 0.000 1.000
#> GSM71026     2  0.0000     0.8791 0.000 1.000
#> GSM71027     2  0.0000     0.8791 0.000 1.000
#> GSM71028     1  0.7219     0.7669 0.800 0.200
#> GSM71030     1  0.0000     0.9242 1.000 0.000
#> GSM71032     1  0.0000     0.9242 1.000 0.000
#> GSM71034     1  0.0000     0.9242 1.000 0.000
#> GSM71035     2  0.9775     0.3676 0.412 0.588
#> GSM71038     1  0.0000     0.9242 1.000 0.000
#> GSM71043     1  0.4562     0.8676 0.904 0.096
#> GSM71046     1  0.0000     0.9242 1.000 0.000
#> GSM71053     1  0.0000     0.9242 1.000 0.000
#> GSM71061     1  0.7139     0.7721 0.804 0.196
#> GSM71062     1  0.0000     0.9242 1.000 0.000
#> GSM71063     1  0.3431     0.8896 0.936 0.064
#> GSM71068     1  0.0000     0.9242 1.000 0.000
#> GSM71029     1  0.0938     0.9167 0.988 0.012
#> GSM71031     1  0.2236     0.9062 0.964 0.036
#> GSM71033     1  0.7139     0.7723 0.804 0.196
#> GSM71036     1  0.0000     0.9242 1.000 0.000
#> GSM71042     1  0.0000     0.9242 1.000 0.000
#> GSM71044     1  0.0000     0.9242 1.000 0.000
#> GSM71045     1  0.0000     0.9242 1.000 0.000
#> GSM71049     1  0.0000     0.9242 1.000 0.000
#> GSM71055     1  0.0000     0.9242 1.000 0.000
#> GSM71056     1  0.0000     0.9242 1.000 0.000
#> GSM71058     1  0.0000     0.9242 1.000 0.000
#> GSM71059     1  0.0000     0.9242 1.000 0.000
#> GSM71064     1  0.0000     0.9242 1.000 0.000
#> GSM71065     1  0.0000     0.9242 1.000 0.000
#> GSM71067     1  0.0000     0.9242 1.000 0.000
#> GSM71037     1  0.6048     0.8248 0.852 0.148
#> GSM71039     1  0.9963     0.0608 0.536 0.464
#> GSM71040     1  0.0000     0.9242 1.000 0.000
#> GSM71041     1  0.5842     0.8320 0.860 0.140
#> GSM71047     2  0.5519     0.8348 0.128 0.872
#> GSM71048     1  0.0000     0.9242 1.000 0.000
#> GSM71050     1  0.8016     0.6964 0.756 0.244
#> GSM71051     2  0.6148     0.8184 0.152 0.848
#> GSM71052     2  0.8499     0.6804 0.276 0.724
#> GSM71054     1  0.7219     0.7669 0.800 0.200
#> GSM71057     1  0.7219     0.7669 0.800 0.200
#> GSM71060     1  0.6148     0.8207 0.848 0.152
#> GSM71066     1  0.0000     0.9242 1.000 0.000
#> GSM71070     2  0.4562     0.8510 0.096 0.904
#> GSM71072     2  0.0000     0.8791 0.000 1.000
#> GSM71074     2  0.0000     0.8791 0.000 1.000
#> GSM71076     2  0.0000     0.8791 0.000 1.000
#> GSM71077     2  0.0000     0.8791 0.000 1.000
#> GSM71069     2  0.8763     0.6481 0.296 0.704
#> GSM71071     2  0.0000     0.8791 0.000 1.000
#> GSM71073     2  0.0000     0.8791 0.000 1.000
#> GSM71075     2  0.8955     0.6203 0.312 0.688
#> GSM71078     2  0.6973     0.7849 0.188 0.812

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0592     0.9265 0.012 0.988 0.000
#> GSM71020     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71022     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71023     2  0.1999     0.9022 0.036 0.952 0.012
#> GSM71024     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71025     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71028     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71030     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71032     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71034     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71035     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71038     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71043     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71046     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71053     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71061     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71062     1  0.0237     0.9690 0.996 0.000 0.004
#> GSM71063     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71068     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71029     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71031     1  0.1289     0.9412 0.968 0.000 0.032
#> GSM71033     1  0.4342     0.8274 0.856 0.024 0.120
#> GSM71036     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71044     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71045     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71049     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71055     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71056     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71058     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71059     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71065     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71067     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71037     3  0.0237     0.9143 0.004 0.000 0.996
#> GSM71039     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71040     1  0.6307     0.0994 0.512 0.000 0.488
#> GSM71041     3  0.0237     0.9143 0.004 0.000 0.996
#> GSM71047     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71048     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71050     3  0.0237     0.9143 0.004 0.000 0.996
#> GSM71051     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71052     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71054     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71057     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71060     3  0.0000     0.9170 0.000 0.000 1.000
#> GSM71066     1  0.0000     0.9723 1.000 0.000 0.000
#> GSM71070     3  0.2066     0.8715 0.000 0.060 0.940
#> GSM71072     3  0.5760     0.5172 0.000 0.328 0.672
#> GSM71074     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71076     3  0.6252     0.2363 0.000 0.444 0.556
#> GSM71077     2  0.0000     0.9346 0.000 1.000 0.000
#> GSM71069     3  0.4654     0.7107 0.000 0.208 0.792
#> GSM71071     3  0.6215     0.2831 0.000 0.428 0.572
#> GSM71073     2  0.2796     0.8536 0.000 0.908 0.092
#> GSM71075     2  0.6822    -0.0924 0.012 0.508 0.480
#> GSM71078     3  0.0000     0.9170 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0188     0.9673 0.000 0.996 0.000 0.004
#> GSM71023     4  0.5292     0.0587 0.008 0.480 0.000 0.512
#> GSM71024     1  0.3688     0.8310 0.792 0.000 0.000 0.208
#> GSM71025     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71028     4  0.4331     0.6286 0.000 0.000 0.288 0.712
#> GSM71030     1  0.4356     0.7274 0.708 0.000 0.000 0.292
#> GSM71032     1  0.1389     0.9156 0.952 0.000 0.000 0.048
#> GSM71034     1  0.2530     0.9032 0.888 0.000 0.000 0.112
#> GSM71035     4  0.4585     0.5516 0.000 0.000 0.332 0.668
#> GSM71038     1  0.1637     0.9152 0.940 0.000 0.000 0.060
#> GSM71043     3  0.4331     0.5162 0.000 0.000 0.712 0.288
#> GSM71046     1  0.2216     0.9095 0.908 0.000 0.000 0.092
#> GSM71053     1  0.2704     0.8980 0.876 0.000 0.000 0.124
#> GSM71061     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71062     1  0.2589     0.9015 0.884 0.000 0.000 0.116
#> GSM71063     4  0.0524     0.8073 0.004 0.000 0.008 0.988
#> GSM71068     1  0.2704     0.8979 0.876 0.000 0.000 0.124
#> GSM71029     1  0.1389     0.9032 0.952 0.048 0.000 0.000
#> GSM71031     1  0.4770     0.5873 0.700 0.000 0.012 0.288
#> GSM71033     1  0.6381     0.5536 0.668 0.164 0.164 0.004
#> GSM71036     1  0.0188     0.9138 0.996 0.000 0.000 0.004
#> GSM71042     1  0.0000     0.9132 1.000 0.000 0.000 0.000
#> GSM71044     1  0.0188     0.9123 0.996 0.000 0.000 0.004
#> GSM71045     1  0.0188     0.9138 0.996 0.000 0.000 0.004
#> GSM71049     1  0.1792     0.9143 0.932 0.000 0.000 0.068
#> GSM71055     1  0.0188     0.9123 0.996 0.000 0.000 0.004
#> GSM71056     1  0.0000     0.9132 1.000 0.000 0.000 0.000
#> GSM71058     1  0.0657     0.9075 0.984 0.000 0.012 0.004
#> GSM71059     1  0.0188     0.9123 0.996 0.000 0.000 0.004
#> GSM71064     1  0.0188     0.9123 0.996 0.000 0.000 0.004
#> GSM71065     1  0.0188     0.9123 0.996 0.000 0.000 0.004
#> GSM71067     1  0.2081     0.9113 0.916 0.000 0.000 0.084
#> GSM71037     3  0.0336     0.9536 0.008 0.000 0.992 0.000
#> GSM71039     3  0.0188     0.9574 0.000 0.000 0.996 0.004
#> GSM71040     3  0.2149     0.8576 0.088 0.000 0.912 0.000
#> GSM71041     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71047     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71048     1  0.2760     0.8956 0.872 0.000 0.000 0.128
#> GSM71050     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71051     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71052     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000     0.9605 0.000 0.000 1.000 0.000
#> GSM71066     1  0.2469     0.9046 0.892 0.000 0.000 0.108
#> GSM71070     4  0.0188     0.8059 0.004 0.000 0.000 0.996
#> GSM71072     4  0.3818     0.7818 0.000 0.108 0.048 0.844
#> GSM71074     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71076     4  0.2530     0.7802 0.000 0.112 0.000 0.888
#> GSM71077     2  0.0000     0.9706 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0188     0.8059 0.004 0.000 0.000 0.996
#> GSM71071     4  0.3123     0.7522 0.000 0.156 0.000 0.844
#> GSM71073     2  0.3982     0.6682 0.000 0.776 0.004 0.220
#> GSM71075     4  0.0188     0.8059 0.004 0.000 0.000 0.996
#> GSM71078     4  0.3444     0.7408 0.000 0.000 0.184 0.816

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.4211     0.4015 0.360 0.636 0.000 0.000 0.004
#> GSM71020     2  0.0000     0.8727 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.1831     0.8770 0.076 0.920 0.000 0.000 0.004
#> GSM71022     2  0.1478     0.8783 0.064 0.936 0.000 0.000 0.000
#> GSM71023     1  0.6334     0.1003 0.548 0.248 0.000 0.200 0.004
#> GSM71024     1  0.4161     0.6270 0.752 0.000 0.000 0.040 0.208
#> GSM71025     2  0.2052     0.8749 0.080 0.912 0.000 0.004 0.004
#> GSM71026     2  0.1831     0.8770 0.076 0.920 0.000 0.000 0.004
#> GSM71027     2  0.0703     0.8682 0.024 0.976 0.000 0.000 0.000
#> GSM71028     4  0.5542     0.2405 0.068 0.000 0.432 0.500 0.000
#> GSM71030     1  0.5159     0.4460 0.692 0.000 0.000 0.144 0.164
#> GSM71032     5  0.2471     0.6550 0.136 0.000 0.000 0.000 0.864
#> GSM71034     1  0.3910     0.6615 0.720 0.000 0.000 0.008 0.272
#> GSM71035     4  0.5013     0.6227 0.080 0.000 0.240 0.680 0.000
#> GSM71038     5  0.3177     0.6174 0.208 0.000 0.000 0.000 0.792
#> GSM71043     3  0.7224     0.3007 0.076 0.000 0.516 0.136 0.272
#> GSM71046     1  0.3966     0.6599 0.664 0.000 0.000 0.000 0.336
#> GSM71053     5  0.3336     0.5957 0.228 0.000 0.000 0.000 0.772
#> GSM71061     3  0.0510     0.9459 0.016 0.000 0.984 0.000 0.000
#> GSM71062     1  0.3949     0.6365 0.696 0.000 0.000 0.004 0.300
#> GSM71063     4  0.4397     0.7012 0.264 0.000 0.004 0.708 0.024
#> GSM71068     5  0.3246     0.6318 0.184 0.000 0.008 0.000 0.808
#> GSM71029     1  0.5606     0.6095 0.548 0.068 0.000 0.004 0.380
#> GSM71031     1  0.5645     0.3318 0.660 0.008 0.000 0.176 0.156
#> GSM71033     5  0.4815     0.4903 0.020 0.136 0.088 0.000 0.756
#> GSM71036     1  0.4321     0.6584 0.600 0.000 0.000 0.004 0.396
#> GSM71042     1  0.4528     0.6159 0.548 0.000 0.000 0.008 0.444
#> GSM71044     5  0.1952     0.6241 0.084 0.000 0.000 0.004 0.912
#> GSM71045     5  0.4211    -0.2059 0.360 0.000 0.000 0.004 0.636
#> GSM71049     1  0.4218     0.6854 0.660 0.008 0.000 0.000 0.332
#> GSM71055     1  0.4555     0.5753 0.520 0.000 0.000 0.008 0.472
#> GSM71056     1  0.4367     0.6448 0.580 0.000 0.000 0.004 0.416
#> GSM71058     5  0.2228     0.6290 0.040 0.000 0.048 0.000 0.912
#> GSM71059     1  0.4557     0.5767 0.516 0.000 0.000 0.008 0.476
#> GSM71064     5  0.1341     0.6457 0.056 0.000 0.000 0.000 0.944
#> GSM71065     5  0.1907     0.6496 0.044 0.000 0.028 0.000 0.928
#> GSM71067     5  0.4306    -0.2733 0.492 0.000 0.000 0.000 0.508
#> GSM71037     3  0.0324     0.9477 0.000 0.000 0.992 0.004 0.004
#> GSM71039     3  0.0703     0.9429 0.024 0.000 0.976 0.000 0.000
#> GSM71040     3  0.0162     0.9478 0.004 0.000 0.996 0.000 0.000
#> GSM71041     3  0.0404     0.9470 0.012 0.000 0.988 0.000 0.000
#> GSM71047     3  0.0898     0.9407 0.020 0.000 0.972 0.000 0.008
#> GSM71048     1  0.4213     0.6871 0.680 0.000 0.000 0.012 0.308
#> GSM71050     3  0.0992     0.9388 0.024 0.000 0.968 0.000 0.008
#> GSM71051     3  0.0162     0.9492 0.000 0.000 0.996 0.000 0.004
#> GSM71052     3  0.0162     0.9492 0.000 0.000 0.996 0.000 0.004
#> GSM71054     3  0.0162     0.9492 0.000 0.000 0.996 0.000 0.004
#> GSM71057     3  0.0162     0.9492 0.000 0.000 0.996 0.000 0.004
#> GSM71060     3  0.0162     0.9492 0.000 0.000 0.996 0.000 0.004
#> GSM71066     1  0.3861     0.6668 0.728 0.000 0.000 0.008 0.264
#> GSM71070     4  0.2852     0.7310 0.172 0.000 0.000 0.828 0.000
#> GSM71072     4  0.1200     0.7779 0.016 0.012 0.008 0.964 0.000
#> GSM71074     2  0.3037     0.8032 0.040 0.860 0.000 0.100 0.000
#> GSM71076     4  0.1106     0.7845 0.024 0.012 0.000 0.964 0.000
#> GSM71077     2  0.2813     0.8167 0.040 0.876 0.000 0.084 0.000
#> GSM71069     4  0.2516     0.7783 0.140 0.000 0.000 0.860 0.000
#> GSM71071     4  0.0898     0.7770 0.008 0.020 0.000 0.972 0.000
#> GSM71073     4  0.5315    -0.0693 0.040 0.456 0.004 0.500 0.000
#> GSM71075     4  0.2127     0.7839 0.108 0.000 0.000 0.892 0.000
#> GSM71078     4  0.2221     0.7850 0.036 0.000 0.052 0.912 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
#> GSM71019     2  0.5105    -0.1098 0.400 0.544 0.020 0.000 0.008 0.028
#> GSM71020     2  0.0000     0.7118 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.2996     0.7134 0.000 0.772 0.000 0.000 0.000 0.228
#> GSM71022     2  0.2883     0.7143 0.000 0.788 0.000 0.000 0.000 0.212
#> GSM71023     1  0.6696    -0.0592 0.584 0.164 0.016 0.032 0.032 0.172
#> GSM71024     1  0.1857     0.7032 0.924 0.000 0.000 0.004 0.028 0.044
#> GSM71025     2  0.3175     0.6996 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM71026     2  0.2941     0.7147 0.000 0.780 0.000 0.000 0.000 0.220
#> GSM71027     2  0.1010     0.7028 0.000 0.960 0.000 0.000 0.004 0.036
#> GSM71028     3  0.5810     0.2502 0.000 0.000 0.540 0.308 0.020 0.132
#> GSM71030     1  0.4202     0.4147 0.752 0.000 0.000 0.032 0.036 0.180
#> GSM71032     5  0.2527     0.7995 0.084 0.000 0.000 0.000 0.876 0.040
#> GSM71034     1  0.1232     0.7323 0.956 0.000 0.000 0.004 0.016 0.024
#> GSM71035     4  0.6010     0.2491 0.000 0.000 0.312 0.492 0.012 0.184
#> GSM71038     5  0.3272     0.7810 0.124 0.000 0.000 0.004 0.824 0.048
#> GSM71043     5  0.7096     0.0136 0.004 0.000 0.360 0.084 0.376 0.176
#> GSM71046     1  0.1313     0.7479 0.952 0.000 0.000 0.004 0.028 0.016
#> GSM71053     5  0.3615     0.7595 0.140 0.000 0.000 0.004 0.796 0.060
#> GSM71061     3  0.2617     0.8747 0.000 0.000 0.876 0.004 0.040 0.080
#> GSM71062     1  0.1401     0.7275 0.948 0.000 0.000 0.004 0.020 0.028
#> GSM71063     4  0.7325     0.1906 0.088 0.000 0.012 0.416 0.204 0.280
#> GSM71068     5  0.4223     0.7664 0.124 0.000 0.024 0.008 0.780 0.064
#> GSM71029     1  0.3383     0.6777 0.828 0.056 0.000 0.000 0.012 0.104
#> GSM71031     6  0.6249     0.0000 0.312 0.004 0.000 0.176 0.020 0.488
#> GSM71033     5  0.2255     0.7804 0.020 0.028 0.036 0.000 0.912 0.004
#> GSM71036     1  0.2542     0.7242 0.876 0.000 0.000 0.000 0.044 0.080
#> GSM71042     1  0.3252     0.6872 0.824 0.000 0.000 0.000 0.068 0.108
#> GSM71044     5  0.3833     0.7360 0.092 0.004 0.000 0.000 0.784 0.120
#> GSM71045     1  0.5475     0.1166 0.536 0.000 0.000 0.000 0.316 0.148
#> GSM71049     1  0.1232     0.7478 0.956 0.004 0.000 0.000 0.016 0.024
#> GSM71055     1  0.3667     0.6499 0.788 0.000 0.000 0.000 0.080 0.132
#> GSM71056     1  0.2856     0.7205 0.856 0.000 0.000 0.000 0.076 0.068
#> GSM71058     5  0.2544     0.7844 0.028 0.004 0.024 0.000 0.896 0.048
#> GSM71059     1  0.3586     0.6597 0.796 0.000 0.000 0.000 0.080 0.124
#> GSM71064     5  0.2282     0.7905 0.088 0.000 0.000 0.000 0.888 0.024
#> GSM71065     5  0.3181     0.7740 0.052 0.000 0.048 0.000 0.856 0.044
#> GSM71067     1  0.2882     0.6781 0.848 0.000 0.000 0.004 0.120 0.028
#> GSM71037     3  0.0858     0.9060 0.000 0.000 0.968 0.000 0.028 0.004
#> GSM71039     3  0.2604     0.8728 0.000 0.000 0.872 0.008 0.020 0.100
#> GSM71040     3  0.0862     0.9056 0.008 0.000 0.972 0.004 0.016 0.000
#> GSM71041     3  0.1168     0.9019 0.000 0.000 0.956 0.000 0.016 0.028
#> GSM71047     3  0.2230     0.8852 0.000 0.000 0.892 0.000 0.024 0.084
#> GSM71048     1  0.0622     0.7485 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM71050     3  0.2715     0.8676 0.000 0.000 0.860 0.004 0.024 0.112
#> GSM71051     3  0.0790     0.9061 0.000 0.000 0.968 0.000 0.032 0.000
#> GSM71052     3  0.0458     0.9084 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM71054     3  0.0632     0.9073 0.000 0.000 0.976 0.000 0.024 0.000
#> GSM71057     3  0.0713     0.9067 0.000 0.000 0.972 0.000 0.028 0.000
#> GSM71060     3  0.0000     0.9082 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71066     1  0.1036     0.7403 0.964 0.000 0.000 0.004 0.008 0.024
#> GSM71070     4  0.5279     0.4778 0.148 0.004 0.000 0.668 0.020 0.160
#> GSM71072     4  0.0865     0.6637 0.000 0.000 0.000 0.964 0.000 0.036
#> GSM71074     2  0.4734     0.4911 0.000 0.672 0.000 0.208 0.000 0.120
#> GSM71076     4  0.1340     0.6674 0.008 0.004 0.000 0.948 0.000 0.040
#> GSM71077     2  0.4085     0.5814 0.000 0.752 0.000 0.128 0.000 0.120
#> GSM71069     4  0.4377     0.5699 0.072 0.000 0.000 0.744 0.020 0.164
#> GSM71071     4  0.0547     0.6664 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM71073     4  0.5009     0.3645 0.000 0.256 0.000 0.624 0.000 0.120
#> GSM71075     4  0.3279     0.6239 0.060 0.000 0.000 0.828 0.004 0.108
#> GSM71078     4  0.2250     0.6471 0.000 0.000 0.064 0.896 0.000 0.040

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> SD:NMF 58    1.91e-08 2
#> SD:NMF 56    1.09e-10 3
#> SD:NMF 59    7.71e-16 4
#> SD:NMF 50    5.07e-13 5
#> SD:NMF 48    5.21e-15 6

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


CV:hclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.484           0.761       0.868         0.4329 0.619   0.619
#> 3 3 0.784           0.829       0.904         0.4597 0.738   0.576
#> 4 4 0.884           0.881       0.939         0.0933 0.968   0.911
#> 5 5 0.775           0.524       0.763         0.0968 0.937   0.815
#> 6 6 0.778           0.800       0.853         0.0690 0.849   0.511

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     1   0.808      0.715 0.752 0.248
#> GSM71020     2   0.000      0.842 0.000 1.000
#> GSM71021     2   0.000      0.842 0.000 1.000
#> GSM71022     2   0.000      0.842 0.000 1.000
#> GSM71023     1   0.808      0.715 0.752 0.248
#> GSM71024     1   0.767      0.843 0.776 0.224
#> GSM71025     2   0.000      0.842 0.000 1.000
#> GSM71026     2   0.000      0.842 0.000 1.000
#> GSM71027     2   0.000      0.842 0.000 1.000
#> GSM71028     1   0.242      0.740 0.960 0.040
#> GSM71030     1   0.767      0.843 0.776 0.224
#> GSM71032     1   0.767      0.843 0.776 0.224
#> GSM71034     1   0.767      0.843 0.776 0.224
#> GSM71035     1   0.373      0.713 0.928 0.072
#> GSM71038     1   0.767      0.843 0.776 0.224
#> GSM71043     1   0.242      0.740 0.960 0.040
#> GSM71046     1   0.767      0.843 0.776 0.224
#> GSM71053     1   0.767      0.843 0.776 0.224
#> GSM71061     1   0.242      0.740 0.960 0.040
#> GSM71062     1   0.760      0.842 0.780 0.220
#> GSM71063     1   0.242      0.740 0.960 0.040
#> GSM71068     1   0.767      0.843 0.776 0.224
#> GSM71029     1   0.767      0.843 0.776 0.224
#> GSM71031     1   0.767      0.843 0.776 0.224
#> GSM71033     1   0.738      0.827 0.792 0.208
#> GSM71036     1   0.767      0.843 0.776 0.224
#> GSM71042     1   0.767      0.843 0.776 0.224
#> GSM71044     1   0.767      0.843 0.776 0.224
#> GSM71045     1   0.767      0.843 0.776 0.224
#> GSM71049     1   0.767      0.843 0.776 0.224
#> GSM71055     1   0.767      0.843 0.776 0.224
#> GSM71056     1   0.767      0.843 0.776 0.224
#> GSM71058     1   0.767      0.843 0.776 0.224
#> GSM71059     1   0.767      0.843 0.776 0.224
#> GSM71064     1   0.767      0.843 0.776 0.224
#> GSM71065     1   0.767      0.843 0.776 0.224
#> GSM71067     1   0.767      0.843 0.776 0.224
#> GSM71037     1   0.242      0.740 0.960 0.040
#> GSM71039     1   0.278      0.734 0.952 0.048
#> GSM71040     1   0.595      0.818 0.856 0.144
#> GSM71041     1   0.242      0.740 0.960 0.040
#> GSM71047     1   0.987     -0.199 0.568 0.432
#> GSM71048     1   0.767      0.843 0.776 0.224
#> GSM71050     1   0.242      0.740 0.960 0.040
#> GSM71051     1   0.987     -0.199 0.568 0.432
#> GSM71052     1   0.985     -0.186 0.572 0.428
#> GSM71054     1   0.242      0.740 0.960 0.040
#> GSM71057     1   0.242      0.740 0.960 0.040
#> GSM71060     1   0.242      0.740 0.960 0.040
#> GSM71066     1   0.767      0.843 0.776 0.224
#> GSM71070     2   0.767      0.832 0.224 0.776
#> GSM71072     2   0.767      0.832 0.224 0.776
#> GSM71074     2   0.000      0.842 0.000 1.000
#> GSM71076     2   0.767      0.832 0.224 0.776
#> GSM71077     2   0.000      0.842 0.000 1.000
#> GSM71069     2   0.767      0.832 0.224 0.776
#> GSM71071     2   0.767      0.832 0.224 0.776
#> GSM71073     2   0.767      0.832 0.224 0.776
#> GSM71075     2   0.767      0.832 0.224 0.776
#> GSM71078     1   0.388      0.709 0.924 0.076

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     1  0.8085      0.535 0.648 0.148 0.204
#> GSM71020     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71021     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71022     2  0.0892      0.810 0.000 0.980 0.020
#> GSM71023     1  0.8085      0.535 0.648 0.148 0.204
#> GSM71024     1  0.1411      0.937 0.964 0.000 0.036
#> GSM71025     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71026     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71027     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71028     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71030     1  0.1411      0.937 0.964 0.000 0.036
#> GSM71032     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71034     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71035     3  0.1877      0.866 0.032 0.012 0.956
#> GSM71038     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71043     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71046     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71053     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71061     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71062     1  0.1529      0.935 0.960 0.000 0.040
#> GSM71063     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71068     1  0.1411      0.937 0.964 0.000 0.036
#> GSM71029     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71031     1  0.1860      0.921 0.948 0.000 0.052
#> GSM71033     1  0.3933      0.848 0.880 0.028 0.092
#> GSM71036     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71044     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71045     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71049     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71055     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71058     1  0.1411      0.929 0.964 0.000 0.036
#> GSM71059     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71065     1  0.0000      0.942 1.000 0.000 0.000
#> GSM71067     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71037     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71039     3  0.1643      0.886 0.044 0.000 0.956
#> GSM71040     1  0.5905      0.473 0.648 0.000 0.352
#> GSM71041     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71047     3  0.7245      0.243 0.036 0.368 0.596
#> GSM71048     1  0.1411      0.937 0.964 0.000 0.036
#> GSM71050     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71051     3  0.7245      0.243 0.036 0.368 0.596
#> GSM71052     3  0.7123      0.260 0.032 0.364 0.604
#> GSM71054     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71057     3  0.1964      0.888 0.056 0.000 0.944
#> GSM71060     3  0.1860      0.892 0.052 0.000 0.948
#> GSM71066     1  0.0892      0.942 0.980 0.000 0.020
#> GSM71070     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71072     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71074     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71076     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71077     2  0.0000      0.813 0.000 1.000 0.000
#> GSM71069     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71071     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71073     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71075     2  0.5678      0.730 0.000 0.684 0.316
#> GSM71078     3  0.2031      0.863 0.032 0.016 0.952

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     1  0.7360      0.553 0.640 0.068 0.108 0.184
#> GSM71020     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71022     2  0.1940      0.907 0.000 0.924 0.000 0.076
#> GSM71023     1  0.7360      0.553 0.640 0.068 0.108 0.184
#> GSM71024     1  0.1389      0.928 0.952 0.000 0.048 0.000
#> GSM71025     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71028     3  0.1890      0.857 0.008 0.000 0.936 0.056
#> GSM71030     1  0.1389      0.928 0.952 0.000 0.048 0.000
#> GSM71032     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71034     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71035     3  0.2281      0.833 0.000 0.000 0.904 0.096
#> GSM71038     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71043     3  0.1890      0.857 0.008 0.000 0.936 0.056
#> GSM71046     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71053     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71061     3  0.0188      0.872 0.004 0.000 0.996 0.000
#> GSM71062     1  0.1474      0.926 0.948 0.000 0.052 0.000
#> GSM71063     3  0.1890      0.857 0.008 0.000 0.936 0.056
#> GSM71068     1  0.1389      0.928 0.952 0.000 0.048 0.000
#> GSM71029     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71031     1  0.1637      0.918 0.940 0.000 0.060 0.000
#> GSM71033     1  0.3328      0.850 0.872 0.024 0.100 0.004
#> GSM71036     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71042     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71044     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71045     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71049     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71055     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71056     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71058     1  0.1302      0.925 0.956 0.000 0.044 0.000
#> GSM71059     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71064     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71065     1  0.0336      0.937 0.992 0.000 0.008 0.000
#> GSM71067     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71037     3  0.0000      0.872 0.000 0.000 1.000 0.000
#> GSM71039     3  0.0336      0.871 0.000 0.000 0.992 0.008
#> GSM71040     1  0.4746      0.463 0.632 0.000 0.368 0.000
#> GSM71041     3  0.0188      0.872 0.004 0.000 0.996 0.000
#> GSM71047     3  0.5364      0.402 0.016 0.000 0.592 0.392
#> GSM71048     1  0.1389      0.928 0.952 0.000 0.048 0.000
#> GSM71050     3  0.0188      0.872 0.004 0.000 0.996 0.000
#> GSM71051     3  0.5364      0.402 0.016 0.000 0.592 0.392
#> GSM71052     3  0.5244      0.416 0.012 0.000 0.600 0.388
#> GSM71054     3  0.0000      0.872 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0469      0.865 0.012 0.000 0.988 0.000
#> GSM71060     3  0.0000      0.872 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0707      0.937 0.980 0.000 0.020 0.000
#> GSM71070     4  0.0188      0.995 0.000 0.000 0.004 0.996
#> GSM71072     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71074     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71076     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71077     2  0.0000      0.988 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71071     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71073     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71075     4  0.0000      0.999 0.000 0.000 0.000 1.000
#> GSM71078     3  0.3837      0.702 0.000 0.000 0.776 0.224

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     1  0.6446      0.334 0.648 0.008 0.092 0.180 0.072
#> GSM71020     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71021     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71022     5  0.5649     -0.607 0.000 0.452 0.000 0.076 0.472
#> GSM71023     1  0.6446      0.334 0.648 0.008 0.092 0.180 0.072
#> GSM71024     1  0.4262      0.581 0.560 0.000 0.000 0.000 0.440
#> GSM71025     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71026     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71027     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71028     2  0.6424     -0.203 0.000 0.472 0.420 0.052 0.056
#> GSM71030     1  0.4262      0.581 0.560 0.000 0.000 0.000 0.440
#> GSM71032     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71034     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71035     2  0.5959     -0.239 0.000 0.464 0.440 0.092 0.004
#> GSM71038     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71043     2  0.6424     -0.203 0.000 0.472 0.420 0.052 0.056
#> GSM71046     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71053     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71061     3  0.1830      0.718 0.000 0.068 0.924 0.000 0.008
#> GSM71062     1  0.4410      0.576 0.556 0.000 0.004 0.000 0.440
#> GSM71063     2  0.6424     -0.203 0.000 0.472 0.420 0.052 0.056
#> GSM71068     1  0.4262      0.581 0.560 0.000 0.000 0.000 0.440
#> GSM71029     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71031     1  0.1668      0.687 0.940 0.000 0.032 0.000 0.028
#> GSM71033     1  0.2824      0.598 0.880 0.008 0.088 0.000 0.024
#> GSM71036     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71045     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71049     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71058     1  0.1281      0.693 0.956 0.000 0.032 0.000 0.012
#> GSM71059     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000      0.711 1.000 0.000 0.000 0.000 0.000
#> GSM71067     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71037     3  0.0703      0.737 0.000 0.000 0.976 0.000 0.024
#> GSM71039     3  0.3439      0.619 0.000 0.188 0.800 0.008 0.004
#> GSM71040     5  0.7100     -0.374 0.284 0.012 0.320 0.000 0.384
#> GSM71041     3  0.1041      0.732 0.000 0.032 0.964 0.000 0.004
#> GSM71047     3  0.5602      0.290 0.016 0.004 0.556 0.388 0.036
#> GSM71048     1  0.4262      0.581 0.560 0.000 0.000 0.000 0.440
#> GSM71050     3  0.1830      0.718 0.000 0.068 0.924 0.000 0.008
#> GSM71051     3  0.5455      0.290 0.016 0.000 0.560 0.388 0.036
#> GSM71052     3  0.5353      0.301 0.012 0.000 0.568 0.384 0.036
#> GSM71054     3  0.0703      0.737 0.000 0.000 0.976 0.000 0.024
#> GSM71057     3  0.1281      0.731 0.012 0.000 0.956 0.000 0.032
#> GSM71060     3  0.0162      0.737 0.000 0.000 0.996 0.000 0.004
#> GSM71066     1  0.4210      0.601 0.588 0.000 0.000 0.000 0.412
#> GSM71070     4  0.0290      0.966 0.000 0.008 0.000 0.992 0.000
#> GSM71072     4  0.1270      0.959 0.000 0.000 0.000 0.948 0.052
#> GSM71074     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71076     4  0.0162      0.969 0.000 0.004 0.000 0.996 0.000
#> GSM71077     2  0.4297      0.313 0.000 0.528 0.000 0.000 0.472
#> GSM71069     4  0.0162      0.969 0.000 0.004 0.000 0.996 0.000
#> GSM71071     4  0.1270      0.959 0.000 0.000 0.000 0.948 0.052
#> GSM71073     4  0.1270      0.959 0.000 0.000 0.000 0.948 0.052
#> GSM71075     4  0.0162      0.969 0.000 0.004 0.000 0.996 0.000
#> GSM71078     3  0.7364      0.167 0.000 0.340 0.436 0.172 0.052

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     1  0.6148      0.513 0.676 0.068 0.096 0.100 0.012 0.048
#> GSM71020     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.1501      0.901 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM71023     1  0.6148      0.513 0.676 0.068 0.096 0.100 0.012 0.048
#> GSM71024     5  0.0806      0.892 0.020 0.000 0.000 0.000 0.972 0.008
#> GSM71025     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.0790      0.841 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM71030     5  0.0909      0.891 0.020 0.000 0.000 0.000 0.968 0.012
#> GSM71032     5  0.1387      0.897 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM71034     5  0.1141      0.903 0.052 0.000 0.000 0.000 0.948 0.000
#> GSM71035     6  0.1334      0.823 0.000 0.000 0.020 0.032 0.000 0.948
#> GSM71038     5  0.1387      0.897 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM71043     6  0.0790      0.841 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM71046     5  0.1204      0.903 0.056 0.000 0.000 0.000 0.944 0.000
#> GSM71053     5  0.1387      0.897 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM71061     3  0.2178      0.714 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM71062     5  0.0914      0.890 0.016 0.000 0.000 0.000 0.968 0.016
#> GSM71063     6  0.0790      0.841 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM71068     5  0.0820      0.892 0.016 0.000 0.000 0.000 0.972 0.012
#> GSM71029     1  0.2340      0.780 0.852 0.000 0.000 0.000 0.148 0.000
#> GSM71031     1  0.4707      0.718 0.588 0.000 0.032 0.000 0.368 0.012
#> GSM71033     1  0.4075      0.734 0.784 0.024 0.096 0.000 0.096 0.000
#> GSM71036     1  0.3563      0.781 0.664 0.000 0.000 0.000 0.336 0.000
#> GSM71042     1  0.3578      0.779 0.660 0.000 0.000 0.000 0.340 0.000
#> GSM71044     1  0.2178      0.776 0.868 0.000 0.000 0.000 0.132 0.000
#> GSM71045     1  0.3531      0.775 0.672 0.000 0.000 0.000 0.328 0.000
#> GSM71049     1  0.2340      0.780 0.852 0.000 0.000 0.000 0.148 0.000
#> GSM71055     1  0.3578      0.779 0.660 0.000 0.000 0.000 0.340 0.000
#> GSM71056     1  0.3578      0.779 0.660 0.000 0.000 0.000 0.340 0.000
#> GSM71058     1  0.4444      0.757 0.644 0.000 0.032 0.000 0.316 0.008
#> GSM71059     1  0.3578      0.779 0.660 0.000 0.000 0.000 0.340 0.000
#> GSM71064     1  0.3371      0.793 0.708 0.000 0.000 0.000 0.292 0.000
#> GSM71065     1  0.2092      0.772 0.876 0.000 0.000 0.000 0.124 0.000
#> GSM71067     5  0.1204      0.903 0.056 0.000 0.000 0.000 0.944 0.000
#> GSM71037     3  0.1151      0.757 0.012 0.000 0.956 0.000 0.000 0.032
#> GSM71039     6  0.4057      0.119 0.000 0.000 0.436 0.008 0.000 0.556
#> GSM71040     5  0.4865      0.427 0.016 0.000 0.288 0.000 0.640 0.056
#> GSM71041     3  0.1714      0.741 0.000 0.000 0.908 0.000 0.000 0.092
#> GSM71047     3  0.4732      0.421 0.020 0.000 0.588 0.368 0.000 0.024
#> GSM71048     5  0.0909      0.891 0.020 0.000 0.000 0.000 0.968 0.012
#> GSM71050     3  0.2178      0.714 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM71051     3  0.5520      0.378 0.076 0.000 0.532 0.368 0.000 0.024
#> GSM71052     3  0.4468      0.435 0.008 0.000 0.604 0.364 0.000 0.024
#> GSM71054     3  0.2106      0.742 0.064 0.000 0.904 0.000 0.000 0.032
#> GSM71057     3  0.0820      0.754 0.012 0.000 0.972 0.000 0.000 0.016
#> GSM71060     3  0.1707      0.754 0.012 0.000 0.928 0.000 0.004 0.056
#> GSM71066     5  0.1204      0.903 0.056 0.000 0.000 0.000 0.944 0.000
#> GSM71070     4  0.1995      0.949 0.036 0.000 0.000 0.912 0.000 0.052
#> GSM71072     4  0.0260      0.936 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM71074     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.1930      0.952 0.036 0.000 0.000 0.916 0.000 0.048
#> GSM71077     2  0.0000      0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.1930      0.952 0.036 0.000 0.000 0.916 0.000 0.048
#> GSM71071     4  0.0260      0.936 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM71073     4  0.0260      0.936 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM71075     4  0.1930      0.952 0.036 0.000 0.000 0.916 0.000 0.048
#> GSM71078     6  0.3432      0.702 0.000 0.000 0.020 0.216 0.000 0.764

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:hclust 57    4.54e-08 2
#> CV:hclust 56    4.27e-10 3
#> CV:hclust 56    2.80e-13 4
#> CV:hclust 41    3.09e-10 5
#> CV:hclust 55    3.61e-18 6

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


CV:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.420           0.833       0.913         0.4541 0.537   0.537
#> 3 3 0.813           0.860       0.930         0.4267 0.670   0.458
#> 4 4 0.716           0.810       0.866         0.1187 0.903   0.734
#> 5 5 0.706           0.672       0.809         0.0855 0.927   0.745
#> 6 6 0.742           0.603       0.771         0.0499 0.903   0.594

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
#> GSM71019     2  0.7139     0.8291 0.196 0.804
#> GSM71020     2  0.1184     0.8924 0.016 0.984
#> GSM71021     2  0.1184     0.8924 0.016 0.984
#> GSM71022     2  0.1184     0.8924 0.016 0.984
#> GSM71023     2  0.7139     0.8291 0.196 0.804
#> GSM71024     1  0.0000     0.8960 1.000 0.000
#> GSM71025     2  0.1184     0.8924 0.016 0.984
#> GSM71026     2  0.1184     0.8924 0.016 0.984
#> GSM71027     2  0.1184     0.8924 0.016 0.984
#> GSM71028     1  0.5946     0.8436 0.856 0.144
#> GSM71030     1  0.0000     0.8960 1.000 0.000
#> GSM71032     1  0.0000     0.8960 1.000 0.000
#> GSM71034     1  0.0000     0.8960 1.000 0.000
#> GSM71035     1  0.9552     0.4480 0.624 0.376
#> GSM71038     1  0.0000     0.8960 1.000 0.000
#> GSM71043     1  0.5946     0.8436 0.856 0.144
#> GSM71046     1  0.0000     0.8960 1.000 0.000
#> GSM71053     1  0.0000     0.8960 1.000 0.000
#> GSM71061     1  0.5946     0.8436 0.856 0.144
#> GSM71062     1  0.0672     0.8932 0.992 0.008
#> GSM71063     1  0.5946     0.8436 0.856 0.144
#> GSM71068     1  0.0672     0.8932 0.992 0.008
#> GSM71029     1  0.9909    -0.0159 0.556 0.444
#> GSM71031     1  0.4815     0.8603 0.896 0.104
#> GSM71033     1  0.9970     0.1032 0.532 0.468
#> GSM71036     1  0.0000     0.8960 1.000 0.000
#> GSM71042     1  0.0000     0.8960 1.000 0.000
#> GSM71044     1  0.0000     0.8960 1.000 0.000
#> GSM71045     1  0.0000     0.8960 1.000 0.000
#> GSM71049     1  0.6623     0.7291 0.828 0.172
#> GSM71055     1  0.0000     0.8960 1.000 0.000
#> GSM71056     1  0.0000     0.8960 1.000 0.000
#> GSM71058     1  0.0000     0.8960 1.000 0.000
#> GSM71059     1  0.0000     0.8960 1.000 0.000
#> GSM71064     1  0.0000     0.8960 1.000 0.000
#> GSM71065     1  0.0000     0.8960 1.000 0.000
#> GSM71067     1  0.0000     0.8960 1.000 0.000
#> GSM71037     1  0.5946     0.8436 0.856 0.144
#> GSM71039     1  0.8081     0.7145 0.752 0.248
#> GSM71040     1  0.4939     0.8615 0.892 0.108
#> GSM71041     1  0.5946     0.8436 0.856 0.144
#> GSM71047     2  0.6887     0.8320 0.184 0.816
#> GSM71048     1  0.0000     0.8960 1.000 0.000
#> GSM71050     1  0.6438     0.8244 0.836 0.164
#> GSM71051     2  0.6887     0.8320 0.184 0.816
#> GSM71052     2  0.6973     0.8270 0.188 0.812
#> GSM71054     1  0.5946     0.8436 0.856 0.144
#> GSM71057     1  0.5946     0.8436 0.856 0.144
#> GSM71060     1  0.5946     0.8436 0.856 0.144
#> GSM71066     1  0.0000     0.8960 1.000 0.000
#> GSM71070     2  0.6801     0.8350 0.180 0.820
#> GSM71072     2  0.0000     0.8897 0.000 1.000
#> GSM71074     2  0.0672     0.8914 0.008 0.992
#> GSM71076     2  0.0000     0.8897 0.000 1.000
#> GSM71077     2  0.1184     0.8924 0.016 0.984
#> GSM71069     2  0.6887     0.8320 0.184 0.816
#> GSM71071     2  0.0000     0.8897 0.000 1.000
#> GSM71073     2  0.0000     0.8897 0.000 1.000
#> GSM71075     2  0.6801     0.8350 0.180 0.820
#> GSM71078     2  0.6887     0.8320 0.184 0.816

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.6566     0.4545 0.016 0.348 0.636
#> GSM71020     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71022     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71023     3  0.6566     0.4545 0.016 0.348 0.636
#> GSM71024     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71025     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71028     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71030     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71032     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71034     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71035     3  0.0000     0.8352 0.000 0.000 1.000
#> GSM71038     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71043     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71046     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71053     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71061     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71062     1  0.2165     0.9170 0.936 0.000 0.064
#> GSM71063     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71068     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71029     1  0.2297     0.9145 0.944 0.020 0.036
#> GSM71031     1  0.6302    -0.0953 0.520 0.000 0.480
#> GSM71033     3  0.7346     0.2867 0.432 0.032 0.536
#> GSM71036     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71044     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71045     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71049     1  0.1289     0.9336 0.968 0.000 0.032
#> GSM71055     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71056     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71058     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71059     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71065     1  0.0000     0.9617 1.000 0.000 0.000
#> GSM71067     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71037     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71039     3  0.0000     0.8352 0.000 0.000 1.000
#> GSM71040     3  0.3038     0.8442 0.104 0.000 0.896
#> GSM71041     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71047     3  0.0747     0.8319 0.016 0.000 0.984
#> GSM71048     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71050     3  0.2625     0.8561 0.084 0.000 0.916
#> GSM71051     3  0.0747     0.8319 0.016 0.000 0.984
#> GSM71052     3  0.0747     0.8319 0.016 0.000 0.984
#> GSM71054     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71057     3  0.2625     0.8561 0.084 0.000 0.916
#> GSM71060     3  0.2711     0.8561 0.088 0.000 0.912
#> GSM71066     1  0.0747     0.9621 0.984 0.000 0.016
#> GSM71070     3  0.5992     0.5885 0.016 0.268 0.716
#> GSM71072     2  0.2878     0.9245 0.000 0.904 0.096
#> GSM71074     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71076     2  0.2878     0.9245 0.000 0.904 0.096
#> GSM71077     2  0.0000     0.9705 0.000 1.000 0.000
#> GSM71069     3  0.4002     0.7273 0.000 0.160 0.840
#> GSM71071     2  0.2878     0.9245 0.000 0.904 0.096
#> GSM71073     2  0.1753     0.9516 0.000 0.952 0.048
#> GSM71075     3  0.6824     0.3100 0.016 0.408 0.576
#> GSM71078     3  0.0000     0.8352 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.5653      0.615 0.000 0.192 0.096 0.712
#> GSM71020     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM71023     4  0.5926      0.628 0.000 0.192 0.116 0.692
#> GSM71024     1  0.2408      0.844 0.896 0.000 0.000 0.104
#> GSM71025     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0188      0.994 0.000 0.996 0.000 0.004
#> GSM71028     3  0.2522      0.882 0.016 0.000 0.908 0.076
#> GSM71030     1  0.2408      0.844 0.896 0.000 0.000 0.104
#> GSM71032     1  0.1118      0.879 0.964 0.000 0.000 0.036
#> GSM71034     1  0.0188      0.879 0.996 0.000 0.000 0.004
#> GSM71035     3  0.0817      0.913 0.000 0.000 0.976 0.024
#> GSM71038     1  0.1022      0.878 0.968 0.000 0.000 0.032
#> GSM71043     3  0.2845      0.875 0.028 0.000 0.896 0.076
#> GSM71046     1  0.0000      0.879 1.000 0.000 0.000 0.000
#> GSM71053     1  0.1022      0.878 0.968 0.000 0.000 0.032
#> GSM71061     3  0.0672      0.917 0.008 0.000 0.984 0.008
#> GSM71062     1  0.3037      0.831 0.880 0.000 0.020 0.100
#> GSM71063     3  0.3523      0.841 0.032 0.000 0.856 0.112
#> GSM71068     1  0.2345      0.844 0.900 0.000 0.000 0.100
#> GSM71029     1  0.4422      0.803 0.736 0.000 0.008 0.256
#> GSM71031     1  0.5900      0.756 0.664 0.000 0.076 0.260
#> GSM71033     4  0.7959     -0.415 0.428 0.084 0.060 0.428
#> GSM71036     1  0.3024      0.875 0.852 0.000 0.000 0.148
#> GSM71042     1  0.3024      0.875 0.852 0.000 0.000 0.148
#> GSM71044     1  0.4049      0.852 0.780 0.000 0.008 0.212
#> GSM71045     1  0.3074      0.875 0.848 0.000 0.000 0.152
#> GSM71049     1  0.4328      0.815 0.748 0.000 0.008 0.244
#> GSM71055     1  0.3208      0.874 0.848 0.000 0.004 0.148
#> GSM71056     1  0.1867      0.886 0.928 0.000 0.000 0.072
#> GSM71058     1  0.4539      0.838 0.720 0.000 0.008 0.272
#> GSM71059     1  0.2281      0.884 0.904 0.000 0.000 0.096
#> GSM71064     1  0.3400      0.869 0.820 0.000 0.000 0.180
#> GSM71065     1  0.4049      0.852 0.780 0.000 0.008 0.212
#> GSM71067     1  0.0000      0.879 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0524      0.917 0.008 0.000 0.988 0.004
#> GSM71039     3  0.0779      0.916 0.004 0.000 0.980 0.016
#> GSM71040     3  0.3464      0.842 0.032 0.000 0.860 0.108
#> GSM71041     3  0.0336      0.918 0.008 0.000 0.992 0.000
#> GSM71047     3  0.4193      0.588 0.000 0.000 0.732 0.268
#> GSM71048     1  0.2408      0.844 0.896 0.000 0.000 0.104
#> GSM71050     3  0.0804      0.917 0.008 0.000 0.980 0.012
#> GSM71051     3  0.4164      0.594 0.000 0.000 0.736 0.264
#> GSM71052     3  0.0336      0.913 0.000 0.000 0.992 0.008
#> GSM71054     3  0.0524      0.917 0.008 0.000 0.988 0.004
#> GSM71057     3  0.0524      0.917 0.008 0.000 0.988 0.004
#> GSM71060     3  0.0336      0.918 0.008 0.000 0.992 0.000
#> GSM71066     1  0.0000      0.879 1.000 0.000 0.000 0.000
#> GSM71070     4  0.5234      0.673 0.000 0.096 0.152 0.752
#> GSM71072     4  0.4585      0.582 0.000 0.332 0.000 0.668
#> GSM71074     2  0.0188      0.996 0.000 0.996 0.004 0.000
#> GSM71076     4  0.4564      0.585 0.000 0.328 0.000 0.672
#> GSM71077     2  0.0188      0.996 0.000 0.996 0.004 0.000
#> GSM71069     4  0.4979      0.657 0.000 0.064 0.176 0.760
#> GSM71071     4  0.4585      0.582 0.000 0.332 0.000 0.668
#> GSM71073     4  0.5016      0.478 0.000 0.396 0.004 0.600
#> GSM71075     4  0.4894      0.677 0.000 0.120 0.100 0.780
#> GSM71078     4  0.4804      0.364 0.000 0.000 0.384 0.616

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.6512    0.35370 0.428 0.096 0.028 0.448 0.000
#> GSM71020     2  0.0000    0.98842 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000    0.98842 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0000    0.98842 0.000 1.000 0.000 0.000 0.000
#> GSM71023     4  0.6488    0.42048 0.396 0.096 0.028 0.480 0.000
#> GSM71024     5  0.3445    0.57710 0.140 0.000 0.000 0.036 0.824
#> GSM71025     2  0.0000    0.98842 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000    0.98842 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0703    0.98159 0.024 0.976 0.000 0.000 0.000
#> GSM71028     3  0.4657    0.78701 0.148 0.000 0.764 0.068 0.020
#> GSM71030     5  0.3649    0.56579 0.152 0.000 0.000 0.040 0.808
#> GSM71032     5  0.2054    0.62565 0.052 0.000 0.000 0.028 0.920
#> GSM71034     5  0.0880    0.63912 0.032 0.000 0.000 0.000 0.968
#> GSM71035     3  0.3390    0.82007 0.100 0.000 0.840 0.060 0.000
#> GSM71038     5  0.1981    0.62690 0.048 0.000 0.000 0.028 0.924
#> GSM71043     3  0.4909    0.77994 0.148 0.000 0.752 0.068 0.032
#> GSM71046     5  0.0324    0.64269 0.004 0.000 0.000 0.004 0.992
#> GSM71053     5  0.1981    0.62690 0.048 0.000 0.000 0.028 0.924
#> GSM71061     3  0.3112    0.82550 0.100 0.000 0.856 0.044 0.000
#> GSM71062     5  0.4897    0.49510 0.172 0.000 0.048 0.036 0.744
#> GSM71063     3  0.6689    0.64326 0.216 0.000 0.600 0.092 0.092
#> GSM71068     5  0.4065    0.54945 0.160 0.000 0.016 0.032 0.792
#> GSM71029     1  0.4551    0.72617 0.616 0.000 0.000 0.016 0.368
#> GSM71031     1  0.5338    0.56403 0.704 0.000 0.040 0.056 0.200
#> GSM71033     1  0.5319    0.59356 0.768 0.052 0.060 0.040 0.080
#> GSM71036     5  0.4114    0.07470 0.376 0.000 0.000 0.000 0.624
#> GSM71042     5  0.4088    0.10399 0.368 0.000 0.000 0.000 0.632
#> GSM71044     1  0.4151    0.72880 0.652 0.000 0.000 0.004 0.344
#> GSM71045     5  0.4299    0.05786 0.388 0.000 0.000 0.004 0.608
#> GSM71049     1  0.4380    0.72108 0.616 0.000 0.000 0.008 0.376
#> GSM71055     5  0.4161    0.00204 0.392 0.000 0.000 0.000 0.608
#> GSM71056     5  0.3336    0.41837 0.228 0.000 0.000 0.000 0.772
#> GSM71058     1  0.4141    0.66581 0.728 0.000 0.000 0.024 0.248
#> GSM71059     5  0.3837    0.26775 0.308 0.000 0.000 0.000 0.692
#> GSM71064     5  0.4817    0.01351 0.404 0.000 0.000 0.024 0.572
#> GSM71065     1  0.4166    0.73040 0.648 0.000 0.000 0.004 0.348
#> GSM71067     5  0.0324    0.64269 0.004 0.000 0.000 0.004 0.992
#> GSM71037     3  0.1597    0.82914 0.048 0.000 0.940 0.012 0.000
#> GSM71039     3  0.2914    0.82880 0.076 0.000 0.872 0.052 0.000
#> GSM71040     3  0.6436    0.63954 0.180 0.000 0.632 0.068 0.120
#> GSM71041     3  0.0566    0.83699 0.004 0.000 0.984 0.012 0.000
#> GSM71047     3  0.4953    0.63574 0.164 0.000 0.712 0.124 0.000
#> GSM71048     5  0.3531    0.57190 0.148 0.000 0.000 0.036 0.816
#> GSM71050     3  0.2438    0.83727 0.040 0.000 0.900 0.060 0.000
#> GSM71051     3  0.4879    0.64260 0.156 0.000 0.720 0.124 0.000
#> GSM71052     3  0.1800    0.82617 0.048 0.000 0.932 0.020 0.000
#> GSM71054     3  0.1597    0.82914 0.048 0.000 0.940 0.012 0.000
#> GSM71057     3  0.1597    0.82914 0.048 0.000 0.940 0.012 0.000
#> GSM71060     3  0.0162    0.83875 0.004 0.000 0.996 0.000 0.000
#> GSM71066     5  0.0162    0.64100 0.004 0.000 0.000 0.000 0.996
#> GSM71070     4  0.1904    0.81162 0.020 0.016 0.028 0.936 0.000
#> GSM71072     4  0.2753    0.79778 0.008 0.136 0.000 0.856 0.000
#> GSM71074     2  0.1043    0.97499 0.040 0.960 0.000 0.000 0.000
#> GSM71076     4  0.2753    0.79828 0.008 0.136 0.000 0.856 0.000
#> GSM71077     2  0.1043    0.97499 0.040 0.960 0.000 0.000 0.000
#> GSM71069     4  0.1721    0.81134 0.020 0.016 0.020 0.944 0.000
#> GSM71071     4  0.2753    0.79778 0.008 0.136 0.000 0.856 0.000
#> GSM71073     4  0.3370    0.77944 0.028 0.148 0.000 0.824 0.000
#> GSM71075     4  0.1865    0.81266 0.032 0.024 0.008 0.936 0.000
#> GSM71078     4  0.2597    0.76711 0.024 0.000 0.092 0.884 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
#> GSM71019     1  0.7187     -0.142 0.436 0.024 0.112 0.332 0.000 0.096
#> GSM71020     2  0.0000      0.972 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71022     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71023     4  0.7218      0.196 0.360 0.024 0.112 0.408 0.000 0.096
#> GSM71024     5  0.4898      0.600 0.072 0.000 0.004 0.032 0.708 0.184
#> GSM71025     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71026     2  0.0146      0.973 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71027     2  0.1218      0.961 0.012 0.956 0.028 0.004 0.000 0.000
#> GSM71028     6  0.1075      0.656 0.000 0.000 0.048 0.000 0.000 0.952
#> GSM71030     5  0.4882      0.598 0.064 0.000 0.004 0.032 0.704 0.196
#> GSM71032     5  0.3276      0.592 0.132 0.000 0.052 0.000 0.816 0.000
#> GSM71034     5  0.0891      0.638 0.008 0.000 0.000 0.000 0.968 0.024
#> GSM71035     6  0.2772      0.599 0.004 0.000 0.180 0.000 0.000 0.816
#> GSM71038     5  0.3062      0.602 0.112 0.000 0.052 0.000 0.836 0.000
#> GSM71043     6  0.1141      0.657 0.000 0.000 0.052 0.000 0.000 0.948
#> GSM71046     5  0.0260      0.631 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM71053     5  0.3062      0.602 0.112 0.000 0.052 0.000 0.836 0.000
#> GSM71061     6  0.2948      0.591 0.008 0.000 0.188 0.000 0.000 0.804
#> GSM71062     5  0.4807      0.581 0.060 0.000 0.000 0.028 0.688 0.224
#> GSM71063     6  0.0767      0.605 0.008 0.000 0.000 0.004 0.012 0.976
#> GSM71068     5  0.4709      0.587 0.060 0.000 0.000 0.024 0.696 0.220
#> GSM71029     1  0.3852      0.637 0.740 0.000 0.032 0.004 0.224 0.000
#> GSM71031     1  0.6108      0.423 0.608 0.000 0.036 0.032 0.096 0.228
#> GSM71033     1  0.3866      0.557 0.820 0.020 0.104 0.012 0.012 0.032
#> GSM71036     1  0.4227      0.343 0.496 0.000 0.008 0.004 0.492 0.000
#> GSM71042     5  0.4095     -0.403 0.480 0.000 0.008 0.000 0.512 0.000
#> GSM71044     1  0.2389      0.644 0.864 0.000 0.008 0.000 0.128 0.000
#> GSM71045     1  0.4158      0.410 0.572 0.000 0.008 0.004 0.416 0.000
#> GSM71049     1  0.3852      0.637 0.740 0.000 0.032 0.004 0.224 0.000
#> GSM71055     1  0.4024      0.508 0.592 0.000 0.004 0.004 0.400 0.000
#> GSM71056     5  0.3984     -0.206 0.396 0.000 0.008 0.000 0.596 0.000
#> GSM71058     1  0.4427      0.568 0.780 0.000 0.044 0.012 0.092 0.072
#> GSM71059     5  0.4086     -0.366 0.464 0.000 0.008 0.000 0.528 0.000
#> GSM71064     1  0.4362      0.394 0.584 0.000 0.028 0.000 0.388 0.000
#> GSM71065     1  0.2389      0.644 0.864 0.000 0.008 0.000 0.128 0.000
#> GSM71067     5  0.0291      0.637 0.000 0.000 0.004 0.000 0.992 0.004
#> GSM71037     3  0.3288      0.790 0.000 0.000 0.724 0.000 0.000 0.276
#> GSM71039     6  0.3298      0.520 0.008 0.000 0.236 0.000 0.000 0.756
#> GSM71040     6  0.5449      0.309 0.060 0.000 0.020 0.028 0.248 0.644
#> GSM71041     3  0.3899      0.603 0.004 0.000 0.592 0.000 0.000 0.404
#> GSM71047     3  0.3847      0.642 0.060 0.000 0.808 0.040 0.000 0.092
#> GSM71048     5  0.4882      0.598 0.064 0.000 0.004 0.032 0.704 0.196
#> GSM71050     6  0.4152     -0.216 0.012 0.000 0.440 0.000 0.000 0.548
#> GSM71051     3  0.3597      0.652 0.048 0.000 0.824 0.036 0.000 0.092
#> GSM71052     3  0.3163      0.777 0.004 0.000 0.764 0.000 0.000 0.232
#> GSM71054     3  0.3288      0.790 0.000 0.000 0.724 0.000 0.000 0.276
#> GSM71057     3  0.3266      0.791 0.000 0.000 0.728 0.000 0.000 0.272
#> GSM71060     3  0.3774      0.598 0.000 0.000 0.592 0.000 0.000 0.408
#> GSM71066     5  0.0508      0.629 0.012 0.000 0.004 0.000 0.984 0.000
#> GSM71070     4  0.1793      0.877 0.040 0.004 0.008 0.932 0.000 0.016
#> GSM71072     4  0.1492      0.877 0.000 0.036 0.024 0.940 0.000 0.000
#> GSM71074     2  0.2060      0.938 0.016 0.900 0.084 0.000 0.000 0.000
#> GSM71076     4  0.1636      0.880 0.024 0.036 0.004 0.936 0.000 0.000
#> GSM71077     2  0.2060      0.938 0.016 0.900 0.084 0.000 0.000 0.000
#> GSM71069     4  0.1793      0.877 0.040 0.004 0.008 0.932 0.000 0.016
#> GSM71071     4  0.1492      0.877 0.000 0.036 0.024 0.940 0.000 0.000
#> GSM71073     4  0.2547      0.851 0.004 0.036 0.080 0.880 0.000 0.000
#> GSM71075     4  0.1699      0.877 0.040 0.004 0.008 0.936 0.000 0.012
#> GSM71078     4  0.1649      0.866 0.000 0.000 0.032 0.932 0.000 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:kmeans 57    3.27e-08 2
#> CV:kmeans 55    2.71e-10 3
#> CV:kmeans 57    2.32e-14 4
#> CV:kmeans 50    3.63e-18 5
#> CV:kmeans 49    3.43e-19 6

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


CV:skmeans*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.649           0.826       0.929         0.4974 0.501   0.501
#> 3 3 0.974           0.923       0.974         0.3423 0.742   0.527
#> 4 4 0.909           0.874       0.936         0.0995 0.897   0.704
#> 5 5 0.809           0.790       0.861         0.0885 0.909   0.669
#> 6 6 0.781           0.765       0.858         0.0403 0.937   0.700

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2   0.000     0.9259 0.000 1.000
#> GSM71020     2   0.000     0.9259 0.000 1.000
#> GSM71021     2   0.000     0.9259 0.000 1.000
#> GSM71022     2   0.000     0.9259 0.000 1.000
#> GSM71023     2   0.000     0.9259 0.000 1.000
#> GSM71024     1   0.000     0.9070 1.000 0.000
#> GSM71025     2   0.000     0.9259 0.000 1.000
#> GSM71026     2   0.000     0.9259 0.000 1.000
#> GSM71027     2   0.000     0.9259 0.000 1.000
#> GSM71028     1   0.722     0.7832 0.800 0.200
#> GSM71030     1   0.000     0.9070 1.000 0.000
#> GSM71032     1   0.000     0.9070 1.000 0.000
#> GSM71034     1   0.000     0.9070 1.000 0.000
#> GSM71035     2   0.999    -0.0996 0.484 0.516
#> GSM71038     1   0.000     0.9070 1.000 0.000
#> GSM71043     1   0.722     0.7832 0.800 0.200
#> GSM71046     1   0.000     0.9070 1.000 0.000
#> GSM71053     1   0.000     0.9070 1.000 0.000
#> GSM71061     1   0.722     0.7832 0.800 0.200
#> GSM71062     1   0.000     0.9070 1.000 0.000
#> GSM71063     1   0.722     0.7832 0.800 0.200
#> GSM71068     1   0.000     0.9070 1.000 0.000
#> GSM71029     2   0.722     0.7028 0.200 0.800
#> GSM71031     1   0.000     0.9070 1.000 0.000
#> GSM71033     2   0.204     0.8973 0.032 0.968
#> GSM71036     1   0.000     0.9070 1.000 0.000
#> GSM71042     1   0.000     0.9070 1.000 0.000
#> GSM71044     1   0.999    -0.0666 0.516 0.484
#> GSM71045     1   0.000     0.9070 1.000 0.000
#> GSM71049     2   0.971     0.3610 0.400 0.600
#> GSM71055     1   0.000     0.9070 1.000 0.000
#> GSM71056     1   0.000     0.9070 1.000 0.000
#> GSM71058     1   0.000     0.9070 1.000 0.000
#> GSM71059     1   0.000     0.9070 1.000 0.000
#> GSM71064     1   0.000     0.9070 1.000 0.000
#> GSM71065     1   0.000     0.9070 1.000 0.000
#> GSM71067     1   0.000     0.9070 1.000 0.000
#> GSM71037     1   0.722     0.7832 0.800 0.200
#> GSM71039     2   1.000    -0.1140 0.488 0.512
#> GSM71040     1   0.000     0.9070 1.000 0.000
#> GSM71041     1   0.722     0.7832 0.800 0.200
#> GSM71047     2   0.000     0.9259 0.000 1.000
#> GSM71048     1   0.000     0.9070 1.000 0.000
#> GSM71050     1   0.943     0.5115 0.640 0.360
#> GSM71051     2   0.000     0.9259 0.000 1.000
#> GSM71052     2   0.000     0.9259 0.000 1.000
#> GSM71054     1   0.722     0.7832 0.800 0.200
#> GSM71057     1   0.722     0.7832 0.800 0.200
#> GSM71060     1   0.722     0.7832 0.800 0.200
#> GSM71066     1   0.000     0.9070 1.000 0.000
#> GSM71070     2   0.000     0.9259 0.000 1.000
#> GSM71072     2   0.000     0.9259 0.000 1.000
#> GSM71074     2   0.000     0.9259 0.000 1.000
#> GSM71076     2   0.000     0.9259 0.000 1.000
#> GSM71077     2   0.000     0.9259 0.000 1.000
#> GSM71069     2   0.000     0.9259 0.000 1.000
#> GSM71071     2   0.000     0.9259 0.000 1.000
#> GSM71073     2   0.000     0.9259 0.000 1.000
#> GSM71075     2   0.000     0.9259 0.000 1.000
#> GSM71078     2   0.000     0.9259 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71020     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71022     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71023     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71024     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71025     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71028     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71030     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71032     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71034     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71035     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71038     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71043     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71046     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71053     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71061     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71062     1  0.0237     0.9870 0.996 0.000 0.004
#> GSM71063     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71068     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71029     2  0.6126     0.3238 0.400 0.600 0.000
#> GSM71031     1  0.0237     0.9870 0.996 0.000 0.004
#> GSM71033     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71036     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71044     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71045     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71049     1  0.4555     0.7343 0.800 0.200 0.000
#> GSM71055     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71056     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71058     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71059     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71065     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71067     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71037     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71039     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71040     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71041     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71047     2  0.6309    -0.0314 0.000 0.504 0.496
#> GSM71048     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71050     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71051     3  0.6302     0.0117 0.000 0.480 0.520
#> GSM71052     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71054     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71057     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71060     3  0.0000     0.9657 0.000 0.000 1.000
#> GSM71066     1  0.0000     0.9903 1.000 0.000 0.000
#> GSM71070     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71072     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71074     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71076     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71077     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71069     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71071     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71073     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71075     2  0.0000     0.9479 0.000 1.000 0.000
#> GSM71078     3  0.0000     0.9657 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4277     0.4581 0.000 0.720 0.000 0.280
#> GSM71024     1  0.0592     0.9644 0.984 0.000 0.000 0.016
#> GSM71025     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0707     0.9331 0.000 0.000 0.980 0.020
#> GSM71030     1  0.0707     0.9629 0.980 0.000 0.000 0.020
#> GSM71032     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0336     0.9668 0.992 0.000 0.000 0.008
#> GSM71035     3  0.1211     0.9143 0.000 0.000 0.960 0.040
#> GSM71038     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71043     3  0.0592     0.9352 0.000 0.000 0.984 0.016
#> GSM71046     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71061     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71062     1  0.2335     0.9113 0.920 0.000 0.060 0.020
#> GSM71063     3  0.3032     0.8350 0.008 0.000 0.868 0.124
#> GSM71068     1  0.0707     0.9629 0.980 0.000 0.000 0.020
#> GSM71029     2  0.4914     0.6597 0.208 0.748 0.000 0.044
#> GSM71031     1  0.3711     0.8342 0.836 0.000 0.024 0.140
#> GSM71033     2  0.1302     0.8129 0.000 0.956 0.000 0.044
#> GSM71036     1  0.1211     0.9642 0.960 0.000 0.000 0.040
#> GSM71042     1  0.1211     0.9642 0.960 0.000 0.000 0.040
#> GSM71044     2  0.5980     0.3571 0.396 0.560 0.000 0.044
#> GSM71045     1  0.1211     0.9642 0.960 0.000 0.000 0.040
#> GSM71049     2  0.5807     0.4757 0.344 0.612 0.000 0.044
#> GSM71055     1  0.1302     0.9625 0.956 0.000 0.000 0.044
#> GSM71056     1  0.1022     0.9657 0.968 0.000 0.000 0.032
#> GSM71058     1  0.1557     0.9619 0.944 0.000 0.000 0.056
#> GSM71059     1  0.1211     0.9642 0.960 0.000 0.000 0.040
#> GSM71064     1  0.1211     0.9642 0.960 0.000 0.000 0.040
#> GSM71065     1  0.1302     0.9625 0.956 0.000 0.000 0.044
#> GSM71067     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71039     3  0.0188     0.9392 0.000 0.000 0.996 0.004
#> GSM71040     3  0.1724     0.9077 0.032 0.000 0.948 0.020
#> GSM71041     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71047     2  0.4843     0.3066 0.000 0.604 0.396 0.000
#> GSM71048     1  0.0707     0.9629 0.980 0.000 0.000 0.020
#> GSM71050     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71051     3  0.6965    -0.0351 0.000 0.428 0.460 0.112
#> GSM71052     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000     0.9406 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000     0.9688 1.000 0.000 0.000 0.000
#> GSM71070     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71072     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71074     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71076     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71077     2  0.0000     0.8367 0.000 1.000 0.000 0.000
#> GSM71069     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71071     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71073     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71075     4  0.1716     0.9877 0.000 0.064 0.000 0.936
#> GSM71078     4  0.1716     0.9152 0.000 0.000 0.064 0.936

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71020     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71023     2  0.1608     0.8478 0.000 0.928 0.000 0.072 0.000
#> GSM71024     5  0.3305     0.7383 0.224 0.000 0.000 0.000 0.776
#> GSM71025     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.3980     0.7142 0.000 0.000 0.708 0.008 0.284
#> GSM71030     5  0.2424     0.7186 0.132 0.000 0.000 0.000 0.868
#> GSM71032     5  0.4210     0.6990 0.412 0.000 0.000 0.000 0.588
#> GSM71034     5  0.3796     0.7347 0.300 0.000 0.000 0.000 0.700
#> GSM71035     3  0.2719     0.8113 0.000 0.000 0.884 0.048 0.068
#> GSM71038     5  0.4201     0.7040 0.408 0.000 0.000 0.000 0.592
#> GSM71043     3  0.3934     0.7205 0.000 0.000 0.716 0.008 0.276
#> GSM71046     5  0.4201     0.7005 0.408 0.000 0.000 0.000 0.592
#> GSM71053     5  0.4201     0.7040 0.408 0.000 0.000 0.000 0.592
#> GSM71061     3  0.1764     0.8265 0.000 0.000 0.928 0.008 0.064
#> GSM71062     5  0.1549     0.6508 0.040 0.000 0.016 0.000 0.944
#> GSM71063     3  0.4473     0.5764 0.000 0.000 0.580 0.008 0.412
#> GSM71068     5  0.2020     0.7010 0.100 0.000 0.000 0.000 0.900
#> GSM71029     2  0.4242     0.2561 0.428 0.572 0.000 0.000 0.000
#> GSM71031     5  0.4600     0.4539 0.180 0.000 0.064 0.008 0.748
#> GSM71033     2  0.1357     0.8773 0.048 0.948 0.000 0.000 0.004
#> GSM71036     1  0.1043     0.9153 0.960 0.000 0.000 0.000 0.040
#> GSM71042     1  0.1043     0.9153 0.960 0.000 0.000 0.000 0.040
#> GSM71044     1  0.0963     0.8733 0.964 0.036 0.000 0.000 0.000
#> GSM71045     1  0.1341     0.9033 0.944 0.000 0.000 0.000 0.056
#> GSM71049     1  0.1851     0.8156 0.912 0.088 0.000 0.000 0.000
#> GSM71055     1  0.0162     0.9075 0.996 0.000 0.000 0.000 0.004
#> GSM71056     1  0.1410     0.8992 0.940 0.000 0.000 0.000 0.060
#> GSM71058     1  0.3336     0.6333 0.772 0.000 0.000 0.000 0.228
#> GSM71059     1  0.1121     0.9132 0.956 0.000 0.000 0.000 0.044
#> GSM71064     1  0.0880     0.9143 0.968 0.000 0.000 0.000 0.032
#> GSM71065     1  0.0000     0.9061 1.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.4182     0.7070 0.400 0.000 0.000 0.000 0.600
#> GSM71037     3  0.1597     0.8126 0.000 0.000 0.940 0.012 0.048
#> GSM71039     3  0.1697     0.8269 0.000 0.000 0.932 0.008 0.060
#> GSM71040     3  0.4403     0.5331 0.000 0.000 0.560 0.004 0.436
#> GSM71041     3  0.0162     0.8263 0.000 0.000 0.996 0.000 0.004
#> GSM71047     2  0.5665     0.1783 0.000 0.520 0.416 0.012 0.052
#> GSM71048     5  0.2280     0.7127 0.120 0.000 0.000 0.000 0.880
#> GSM71050     3  0.1764     0.8265 0.000 0.000 0.928 0.008 0.064
#> GSM71051     3  0.6664    -0.0653 0.000 0.416 0.456 0.076 0.052
#> GSM71052     3  0.1670     0.8110 0.000 0.000 0.936 0.012 0.052
#> GSM71054     3  0.1597     0.8126 0.000 0.000 0.940 0.012 0.048
#> GSM71057     3  0.1597     0.8126 0.000 0.000 0.940 0.012 0.048
#> GSM71060     3  0.0162     0.8263 0.000 0.000 0.996 0.000 0.004
#> GSM71066     5  0.4201     0.7005 0.408 0.000 0.000 0.000 0.592
#> GSM71070     4  0.0609     0.9910 0.000 0.020 0.000 0.980 0.000
#> GSM71072     4  0.0609     0.9910 0.000 0.020 0.000 0.980 0.000
#> GSM71074     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.0609     0.9910 0.000 0.020 0.000 0.980 0.000
#> GSM71077     2  0.0000     0.9077 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.0404     0.9859 0.000 0.012 0.000 0.988 0.000
#> GSM71071     4  0.0609     0.9910 0.000 0.020 0.000 0.980 0.000
#> GSM71073     4  0.1121     0.9711 0.000 0.044 0.000 0.956 0.000
#> GSM71075     4  0.0609     0.9910 0.000 0.020 0.000 0.980 0.000
#> GSM71078     4  0.0510     0.9712 0.000 0.000 0.016 0.984 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
#> GSM71019     2  0.0665     0.9533 0.000 0.980 0.008 0.000 0.008 0.004
#> GSM71020     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71023     2  0.1863     0.9075 0.000 0.924 0.008 0.056 0.008 0.004
#> GSM71024     5  0.1844     0.7575 0.024 0.000 0.004 0.000 0.924 0.048
#> GSM71025     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.0622     0.7203 0.000 0.000 0.008 0.000 0.012 0.980
#> GSM71030     5  0.2062     0.7426 0.008 0.000 0.004 0.000 0.900 0.088
#> GSM71032     5  0.3876     0.6727 0.276 0.000 0.024 0.000 0.700 0.000
#> GSM71034     5  0.2790     0.7679 0.140 0.000 0.000 0.000 0.840 0.020
#> GSM71035     6  0.2450     0.7158 0.000 0.000 0.116 0.016 0.000 0.868
#> GSM71038     5  0.3789     0.6936 0.260 0.000 0.024 0.000 0.716 0.000
#> GSM71043     6  0.0622     0.7203 0.000 0.000 0.008 0.000 0.012 0.980
#> GSM71046     5  0.2969     0.7308 0.224 0.000 0.000 0.000 0.776 0.000
#> GSM71053     5  0.3766     0.6986 0.256 0.000 0.024 0.000 0.720 0.000
#> GSM71061     6  0.2300     0.7106 0.000 0.000 0.144 0.000 0.000 0.856
#> GSM71062     5  0.2300     0.7138 0.000 0.000 0.000 0.000 0.856 0.144
#> GSM71063     6  0.0937     0.7058 0.000 0.000 0.000 0.000 0.040 0.960
#> GSM71068     5  0.2402     0.7209 0.004 0.000 0.000 0.000 0.856 0.140
#> GSM71029     1  0.5383    -0.0346 0.480 0.452 0.036 0.004 0.024 0.004
#> GSM71031     6  0.5678     0.1982 0.096 0.000 0.020 0.000 0.384 0.500
#> GSM71033     2  0.4795     0.6772 0.196 0.708 0.076 0.008 0.004 0.008
#> GSM71036     1  0.2793     0.7435 0.800 0.000 0.000 0.000 0.200 0.000
#> GSM71042     1  0.2854     0.7395 0.792 0.000 0.000 0.000 0.208 0.000
#> GSM71044     1  0.1964     0.7028 0.920 0.000 0.056 0.008 0.012 0.004
#> GSM71045     1  0.3189     0.7195 0.760 0.000 0.004 0.000 0.236 0.000
#> GSM71049     1  0.3707     0.6517 0.816 0.120 0.032 0.004 0.024 0.004
#> GSM71055     1  0.1957     0.7498 0.888 0.000 0.000 0.000 0.112 0.000
#> GSM71056     1  0.3221     0.6871 0.736 0.000 0.000 0.000 0.264 0.000
#> GSM71058     1  0.5214     0.5730 0.668 0.000 0.052 0.004 0.224 0.052
#> GSM71059     1  0.2941     0.7338 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM71064     1  0.3229     0.7336 0.804 0.000 0.020 0.004 0.172 0.000
#> GSM71065     1  0.1950     0.7072 0.924 0.000 0.044 0.008 0.020 0.004
#> GSM71067     5  0.2730     0.7536 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM71037     3  0.2092     0.8963 0.000 0.000 0.876 0.000 0.000 0.124
#> GSM71039     6  0.2527     0.6990 0.000 0.000 0.168 0.000 0.000 0.832
#> GSM71040     6  0.3387     0.6212 0.000 0.000 0.040 0.000 0.164 0.796
#> GSM71041     6  0.3864     0.1538 0.000 0.000 0.480 0.000 0.000 0.520
#> GSM71047     3  0.2624     0.8083 0.000 0.124 0.856 0.000 0.000 0.020
#> GSM71048     5  0.1897     0.7436 0.004 0.000 0.004 0.000 0.908 0.084
#> GSM71050     6  0.2697     0.6861 0.000 0.000 0.188 0.000 0.000 0.812
#> GSM71051     3  0.2237     0.8559 0.000 0.080 0.896 0.004 0.000 0.020
#> GSM71052     3  0.1863     0.9065 0.000 0.000 0.896 0.000 0.000 0.104
#> GSM71054     3  0.2178     0.8880 0.000 0.000 0.868 0.000 0.000 0.132
#> GSM71057     3  0.1814     0.9066 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM71060     6  0.3867     0.1334 0.000 0.000 0.488 0.000 0.000 0.512
#> GSM71066     5  0.2823     0.7474 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71070     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71072     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71074     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71077     2  0.0000     0.9637 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71071     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71073     4  0.1007     0.9583 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM71075     4  0.0260     0.9922 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM71078     4  0.0363     0.9811 0.000 0.000 0.000 0.988 0.000 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:skmeans 56    9.33e-07 2
#> CV:skmeans 57    6.19e-11 3
#> CV:skmeans 55    7.74e-15 4
#> CV:skmeans 56    1.81e-20 5
#> CV:skmeans 56    1.03e-20 6

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


CV:pam

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

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

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

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

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

collect_plots(res)

plot of chunk 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.345           0.716       0.858         0.4410 0.548   0.548
#> 3 3 0.588           0.660       0.830         0.4039 0.712   0.529
#> 4 4 0.662           0.787       0.897         0.1652 0.702   0.376
#> 5 5 0.806           0.842       0.912         0.1042 0.820   0.450
#> 6 6 0.868           0.884       0.924         0.0356 0.949   0.762

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

suggest_best_k(res)
#> [1] 6

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
#> GSM71019     2  0.0000      0.856 0.000 1.000
#> GSM71020     2  0.0000      0.856 0.000 1.000
#> GSM71021     2  0.0000      0.856 0.000 1.000
#> GSM71022     2  0.0000      0.856 0.000 1.000
#> GSM71023     2  0.4939      0.766 0.108 0.892
#> GSM71024     1  0.7219      0.785 0.800 0.200
#> GSM71025     2  0.0000      0.856 0.000 1.000
#> GSM71026     2  0.0000      0.856 0.000 1.000
#> GSM71027     2  0.0000      0.856 0.000 1.000
#> GSM71028     1  0.7219      0.785 0.800 0.200
#> GSM71030     1  0.7219      0.785 0.800 0.200
#> GSM71032     1  0.0000      0.789 1.000 0.000
#> GSM71034     1  0.0000      0.789 1.000 0.000
#> GSM71035     1  0.9710      0.559 0.600 0.400
#> GSM71038     1  0.0000      0.789 1.000 0.000
#> GSM71043     1  0.7219      0.785 0.800 0.200
#> GSM71046     1  0.0000      0.789 1.000 0.000
#> GSM71053     1  0.0000      0.789 1.000 0.000
#> GSM71061     1  0.7219      0.785 0.800 0.200
#> GSM71062     1  0.7139      0.786 0.804 0.196
#> GSM71063     1  0.7219      0.785 0.800 0.200
#> GSM71068     1  0.1414      0.791 0.980 0.020
#> GSM71029     2  0.8955      0.579 0.312 0.688
#> GSM71031     1  0.7219      0.785 0.800 0.200
#> GSM71033     1  0.9732      0.552 0.596 0.404
#> GSM71036     1  0.0000      0.789 1.000 0.000
#> GSM71042     1  0.0000      0.789 1.000 0.000
#> GSM71044     1  0.6801      0.667 0.820 0.180
#> GSM71045     1  0.0000      0.789 1.000 0.000
#> GSM71049     2  0.9129      0.561 0.328 0.672
#> GSM71055     1  0.0000      0.789 1.000 0.000
#> GSM71056     1  0.0000      0.789 1.000 0.000
#> GSM71058     1  0.7219      0.785 0.800 0.200
#> GSM71059     1  0.0000      0.789 1.000 0.000
#> GSM71064     1  0.0000      0.789 1.000 0.000
#> GSM71065     1  0.0376      0.788 0.996 0.004
#> GSM71067     1  0.0000      0.789 1.000 0.000
#> GSM71037     1  0.7219      0.785 0.800 0.200
#> GSM71039     1  0.9710      0.559 0.600 0.400
#> GSM71040     1  0.7219      0.785 0.800 0.200
#> GSM71041     1  0.9460      0.613 0.636 0.364
#> GSM71047     2  0.9993     -0.314 0.484 0.516
#> GSM71048     1  0.0000      0.789 1.000 0.000
#> GSM71050     1  0.9710      0.559 0.600 0.400
#> GSM71051     2  0.9993     -0.314 0.484 0.516
#> GSM71052     1  0.9710      0.559 0.600 0.400
#> GSM71054     1  0.7219      0.785 0.800 0.200
#> GSM71057     1  0.9710      0.559 0.600 0.400
#> GSM71060     1  0.7602      0.771 0.780 0.220
#> GSM71066     1  0.0000      0.789 1.000 0.000
#> GSM71070     2  0.8499      0.479 0.276 0.724
#> GSM71072     2  0.0000      0.856 0.000 1.000
#> GSM71074     2  0.0000      0.856 0.000 1.000
#> GSM71076     2  0.0000      0.856 0.000 1.000
#> GSM71077     2  0.0000      0.856 0.000 1.000
#> GSM71069     1  0.9732      0.551 0.596 0.404
#> GSM71071     2  0.0000      0.856 0.000 1.000
#> GSM71073     2  0.0000      0.856 0.000 1.000
#> GSM71075     2  0.5408      0.748 0.124 0.876
#> GSM71078     1  0.9710      0.559 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
#> GSM71019     3  0.6026      0.321 0.000 0.376 0.624
#> GSM71020     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71021     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71022     2  0.4399      0.764 0.000 0.812 0.188
#> GSM71023     3  0.5406      0.553 0.012 0.224 0.764
#> GSM71024     1  0.5109      0.735 0.780 0.008 0.212
#> GSM71025     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71026     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71027     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71028     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71030     1  0.5864      0.721 0.704 0.008 0.288
#> GSM71032     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71035     3  0.2400      0.651 0.064 0.004 0.932
#> GSM71038     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71043     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71046     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71061     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71062     1  0.6033      0.704 0.660 0.004 0.336
#> GSM71063     1  0.6379      0.677 0.624 0.008 0.368
#> GSM71068     1  0.5706      0.714 0.680 0.000 0.320
#> GSM71029     3  0.6045      0.455 0.380 0.000 0.620
#> GSM71031     1  0.6448      0.701 0.656 0.016 0.328
#> GSM71033     3  0.6354      0.557 0.052 0.204 0.744
#> GSM71036     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71044     3  0.6140      0.448 0.404 0.000 0.596
#> GSM71045     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71049     3  0.6045      0.455 0.380 0.000 0.620
#> GSM71055     1  0.0424      0.759 0.992 0.000 0.008
#> GSM71056     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71058     1  0.6075      0.712 0.676 0.008 0.316
#> GSM71059     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71065     1  0.0424      0.760 0.992 0.000 0.008
#> GSM71067     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71037     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71039     3  0.5926     -0.031 0.356 0.000 0.644
#> GSM71040     1  0.6104      0.696 0.648 0.004 0.348
#> GSM71041     3  0.6305     -0.440 0.484 0.000 0.516
#> GSM71047     3  0.2066      0.664 0.000 0.060 0.940
#> GSM71048     1  0.5650      0.717 0.688 0.000 0.312
#> GSM71050     3  0.2173      0.661 0.048 0.008 0.944
#> GSM71051     3  0.0237      0.675 0.000 0.004 0.996
#> GSM71052     3  0.0000      0.674 0.000 0.000 1.000
#> GSM71054     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71057     3  0.5431      0.225 0.284 0.000 0.716
#> GSM71060     1  0.6045      0.675 0.620 0.000 0.380
#> GSM71066     1  0.0000      0.766 1.000 0.000 0.000
#> GSM71070     3  0.0424      0.675 0.000 0.008 0.992
#> GSM71072     3  0.5859      0.376 0.000 0.344 0.656
#> GSM71074     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71076     3  0.6045      0.320 0.000 0.380 0.620
#> GSM71077     2  0.0237      0.943 0.000 0.996 0.004
#> GSM71069     3  0.1765      0.674 0.004 0.040 0.956
#> GSM71071     3  0.6045      0.320 0.000 0.380 0.620
#> GSM71073     2  0.4399      0.757 0.000 0.812 0.188
#> GSM71075     3  0.3499      0.663 0.028 0.072 0.900
#> GSM71078     3  0.0424      0.675 0.000 0.008 0.992

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.4679      0.465 0.000 0.352 0.000 0.648
#> GSM71020     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71022     2  0.2530      0.823 0.000 0.888 0.000 0.112
#> GSM71023     4  0.4716      0.696 0.000 0.196 0.040 0.764
#> GSM71024     3  0.5746      0.471 0.396 0.000 0.572 0.032
#> GSM71025     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0188      0.833 0.000 0.000 0.996 0.004
#> GSM71030     3  0.4605      0.629 0.336 0.000 0.664 0.000
#> GSM71032     1  0.4040      0.588 0.752 0.000 0.248 0.000
#> GSM71034     1  0.0817      0.862 0.976 0.000 0.024 0.000
#> GSM71035     4  0.3528      0.737 0.000 0.000 0.192 0.808
#> GSM71038     1  0.3837      0.633 0.776 0.000 0.224 0.000
#> GSM71043     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71046     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71053     1  0.4564      0.395 0.672 0.000 0.328 0.000
#> GSM71061     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71062     3  0.3873      0.753 0.228 0.000 0.772 0.000
#> GSM71063     3  0.5756      0.716 0.224 0.000 0.692 0.084
#> GSM71068     3  0.4103      0.729 0.256 0.000 0.744 0.000
#> GSM71029     1  0.2589      0.783 0.884 0.000 0.000 0.116
#> GSM71031     3  0.5579      0.704 0.252 0.000 0.688 0.060
#> GSM71033     1  0.9334      0.112 0.396 0.192 0.296 0.116
#> GSM71036     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71044     1  0.2589      0.783 0.884 0.000 0.000 0.116
#> GSM71045     1  0.0188      0.874 0.996 0.000 0.004 0.000
#> GSM71049     1  0.2589      0.783 0.884 0.000 0.000 0.116
#> GSM71055     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71058     3  0.4500      0.661 0.316 0.000 0.684 0.000
#> GSM71059     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71065     1  0.0000      0.875 1.000 0.000 0.000 0.000
#> GSM71067     1  0.2408      0.795 0.896 0.000 0.104 0.000
#> GSM71037     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71039     3  0.0188      0.833 0.000 0.000 0.996 0.004
#> GSM71040     3  0.3873      0.752 0.228 0.000 0.772 0.000
#> GSM71041     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71047     3  0.4015      0.737 0.000 0.052 0.832 0.116
#> GSM71048     3  0.4500      0.661 0.316 0.000 0.684 0.000
#> GSM71050     3  0.0188      0.833 0.000 0.000 0.996 0.004
#> GSM71051     3  0.2589      0.775 0.000 0.000 0.884 0.116
#> GSM71052     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000      0.834 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0188      0.874 0.996 0.000 0.004 0.000
#> GSM71070     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71072     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71074     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71076     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71077     2  0.0000      0.936 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71071     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71073     2  0.4661      0.494 0.000 0.652 0.000 0.348
#> GSM71075     4  0.0000      0.894 0.000 0.000 0.000 1.000
#> GSM71078     4  0.1557      0.855 0.000 0.000 0.056 0.944

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4   0.803     0.2454 0.236 0.296 0.048 0.400 0.020
#> GSM71020     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2   0.104     0.9520 0.000 0.960 0.040 0.000 0.000
#> GSM71023     4   0.786     0.4374 0.000 0.152 0.228 0.468 0.152
#> GSM71024     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71025     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3   0.300     0.8572 0.000 0.000 0.812 0.000 0.188
#> GSM71030     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71032     5   0.307     0.8125 0.196 0.000 0.000 0.000 0.804
#> GSM71034     5   0.281     0.8322 0.168 0.000 0.000 0.000 0.832
#> GSM71035     4   0.572     0.2430 0.000 0.000 0.352 0.552 0.096
#> GSM71038     5   0.311     0.8091 0.200 0.000 0.000 0.000 0.800
#> GSM71043     3   0.311     0.8454 0.000 0.000 0.800 0.000 0.200
#> GSM71046     5   0.427     0.4049 0.448 0.000 0.000 0.000 0.552
#> GSM71053     5   0.311     0.8091 0.200 0.000 0.000 0.000 0.800
#> GSM71061     3   0.127     0.9216 0.000 0.000 0.948 0.000 0.052
#> GSM71062     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71063     5   0.218     0.7921 0.000 0.000 0.004 0.100 0.896
#> GSM71068     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71029     1   0.120     0.9424 0.952 0.000 0.048 0.000 0.000
#> GSM71031     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71033     3   0.371     0.7599 0.004 0.008 0.768 0.000 0.220
#> GSM71036     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71042     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71045     5   0.202     0.8509 0.100 0.000 0.000 0.000 0.900
#> GSM71049     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71055     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71056     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71058     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71059     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71064     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71065     1   0.000     0.9938 1.000 0.000 0.000 0.000 0.000
#> GSM71067     5   0.269     0.8369 0.156 0.000 0.000 0.000 0.844
#> GSM71037     3   0.127     0.9218 0.000 0.000 0.948 0.000 0.052
#> GSM71039     3   0.196     0.9071 0.000 0.000 0.904 0.000 0.096
#> GSM71040     5   0.088     0.8489 0.000 0.000 0.032 0.000 0.968
#> GSM71041     3   0.127     0.9218 0.000 0.000 0.948 0.000 0.052
#> GSM71047     3   0.000     0.8934 0.000 0.000 1.000 0.000 0.000
#> GSM71048     5   0.000     0.8676 0.000 0.000 0.000 0.000 1.000
#> GSM71050     3   0.297     0.8587 0.000 0.000 0.816 0.000 0.184
#> GSM71051     3   0.000     0.8934 0.000 0.000 1.000 0.000 0.000
#> GSM71052     3   0.000     0.8934 0.000 0.000 1.000 0.000 0.000
#> GSM71054     3   0.120     0.9213 0.000 0.000 0.952 0.000 0.048
#> GSM71057     3   0.120     0.9213 0.000 0.000 0.952 0.000 0.048
#> GSM71060     3   0.127     0.9218 0.000 0.000 0.948 0.000 0.052
#> GSM71066     5   0.356     0.7457 0.260 0.000 0.000 0.000 0.740
#> GSM71070     4   0.120     0.7748 0.000 0.000 0.048 0.952 0.000
#> GSM71072     4   0.000     0.7852 0.000 0.000 0.000 1.000 0.000
#> GSM71074     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4   0.000     0.7852 0.000 0.000 0.000 1.000 0.000
#> GSM71077     2   0.000     0.9933 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4   0.136     0.7741 0.000 0.000 0.048 0.948 0.004
#> GSM71071     4   0.000     0.7852 0.000 0.000 0.000 1.000 0.000
#> GSM71073     4   0.429     0.0525 0.000 0.460 0.000 0.540 0.000
#> GSM71075     4   0.000     0.7852 0.000 0.000 0.000 1.000 0.000
#> GSM71078     4   0.000     0.7852 0.000 0.000 0.000 1.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
#> GSM71019     6  0.2730      0.732 0.000 0.192 0.000 0.000 0.000 0.808
#> GSM71020     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.2969      0.663 0.000 0.776 0.000 0.000 0.000 0.224
#> GSM71023     6  0.2730      0.732 0.000 0.192 0.000 0.000 0.000 0.808
#> GSM71024     5  0.0508      0.877 0.000 0.000 0.012 0.000 0.984 0.004
#> GSM71025     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     3  0.0146      0.882 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM71030     5  0.0508      0.877 0.000 0.000 0.012 0.000 0.984 0.004
#> GSM71032     5  0.2762      0.817 0.196 0.000 0.000 0.000 0.804 0.000
#> GSM71034     5  0.2300      0.849 0.144 0.000 0.000 0.000 0.856 0.000
#> GSM71035     3  0.0000      0.881 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71038     5  0.2793      0.814 0.200 0.000 0.000 0.000 0.800 0.000
#> GSM71043     3  0.0146      0.882 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM71046     5  0.3789      0.469 0.416 0.000 0.000 0.000 0.584 0.000
#> GSM71053     5  0.2793      0.814 0.200 0.000 0.000 0.000 0.800 0.000
#> GSM71061     3  0.0458      0.886 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM71062     5  0.0000      0.877 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     5  0.1444      0.859 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM71068     5  0.0000      0.877 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     1  0.0458      0.981 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM71031     5  0.0508      0.877 0.000 0.000 0.012 0.000 0.984 0.004
#> GSM71033     6  0.2838      0.716 0.000 0.004 0.000 0.000 0.188 0.808
#> GSM71036     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71045     5  0.0858      0.874 0.028 0.000 0.004 0.000 0.968 0.000
#> GSM71049     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71058     5  0.0363      0.877 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71059     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.2378      0.845 0.152 0.000 0.000 0.000 0.848 0.000
#> GSM71037     3  0.3253      0.884 0.000 0.000 0.788 0.000 0.020 0.192
#> GSM71039     3  0.0458      0.886 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM71040     5  0.1007      0.859 0.000 0.000 0.044 0.000 0.956 0.000
#> GSM71041     3  0.3253      0.884 0.000 0.000 0.788 0.000 0.020 0.192
#> GSM71047     6  0.0260      0.754 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM71048     5  0.0363      0.877 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM71050     3  0.0458      0.886 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM71051     6  0.2597      0.564 0.000 0.000 0.176 0.000 0.000 0.824
#> GSM71052     3  0.2941      0.862 0.000 0.000 0.780 0.000 0.000 0.220
#> GSM71054     3  0.3253      0.884 0.000 0.000 0.788 0.000 0.020 0.192
#> GSM71057     3  0.3253      0.884 0.000 0.000 0.788 0.000 0.020 0.192
#> GSM71060     3  0.3253      0.884 0.000 0.000 0.788 0.000 0.020 0.192
#> GSM71066     5  0.2996      0.789 0.228 0.000 0.000 0.000 0.772 0.000
#> GSM71070     6  0.2730      0.736 0.000 0.000 0.000 0.192 0.000 0.808
#> GSM71072     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71074     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71077     2  0.0000      0.963 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     6  0.2730      0.736 0.000 0.000 0.000 0.192 0.000 0.808
#> GSM71071     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71073     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71075     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71078     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:pam 57    2.68e-07 2
#> CV:pam 50    1.71e-06 3
#> CV:pam 55    8.51e-15 4
#> CV:pam 55    8.02e-18 5
#> CV:pam 59    7.49e-15 6

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


CV:mclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.417           0.529       0.745         0.4292 0.636   0.636
#> 3 3 0.501           0.736       0.821         0.4151 0.501   0.325
#> 4 4 0.638           0.760       0.873         0.1265 0.795   0.528
#> 5 5 0.675           0.770       0.856         0.1310 0.819   0.486
#> 6 6 0.738           0.729       0.831         0.0534 0.893   0.556

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2  0.0672      0.586 0.008 0.992
#> GSM71020     2  0.9775      0.597 0.412 0.588
#> GSM71021     2  0.9775      0.597 0.412 0.588
#> GSM71022     2  0.9732      0.600 0.404 0.596
#> GSM71023     2  0.9710      0.601 0.400 0.600
#> GSM71024     2  0.9580     -0.482 0.380 0.620
#> GSM71025     2  0.9775      0.597 0.412 0.588
#> GSM71026     2  0.9775      0.597 0.412 0.588
#> GSM71027     2  0.9775      0.597 0.412 0.588
#> GSM71028     2  0.0000      0.592 0.000 1.000
#> GSM71030     2  0.9580     -0.482 0.380 0.620
#> GSM71032     1  0.9732      1.000 0.596 0.404
#> GSM71034     1  0.9732      1.000 0.596 0.404
#> GSM71035     2  0.3879      0.595 0.076 0.924
#> GSM71038     1  0.9732      1.000 0.596 0.404
#> GSM71043     2  0.0000      0.592 0.000 1.000
#> GSM71046     1  0.9732      1.000 0.596 0.404
#> GSM71053     1  0.9732      1.000 0.596 0.404
#> GSM71061     2  0.0000      0.592 0.000 1.000
#> GSM71062     2  0.7602      0.087 0.220 0.780
#> GSM71063     2  0.0000      0.592 0.000 1.000
#> GSM71068     2  0.9580     -0.482 0.380 0.620
#> GSM71029     2  0.9686     -0.529 0.396 0.604
#> GSM71031     2  0.0672      0.586 0.008 0.992
#> GSM71033     2  0.0672      0.586 0.008 0.992
#> GSM71036     1  0.9732      1.000 0.596 0.404
#> GSM71042     1  0.9732      1.000 0.596 0.404
#> GSM71044     2  0.9833     -0.610 0.424 0.576
#> GSM71045     1  0.9732      1.000 0.596 0.404
#> GSM71049     2  0.9754     -0.564 0.408 0.592
#> GSM71055     1  0.9732      1.000 0.596 0.404
#> GSM71056     1  0.9732      1.000 0.596 0.404
#> GSM71058     2  0.0672      0.586 0.008 0.992
#> GSM71059     1  0.9732      1.000 0.596 0.404
#> GSM71064     1  0.9732      1.000 0.596 0.404
#> GSM71065     2  0.9963     -0.717 0.464 0.536
#> GSM71067     1  0.9732      1.000 0.596 0.404
#> GSM71037     2  0.0000      0.592 0.000 1.000
#> GSM71039     2  0.0000      0.592 0.000 1.000
#> GSM71040     2  0.0000      0.592 0.000 1.000
#> GSM71041     2  0.0000      0.592 0.000 1.000
#> GSM71047     2  0.0000      0.592 0.000 1.000
#> GSM71048     2  0.9580     -0.482 0.380 0.620
#> GSM71050     2  0.0000      0.592 0.000 1.000
#> GSM71051     2  0.0000      0.592 0.000 1.000
#> GSM71052     2  0.0000      0.592 0.000 1.000
#> GSM71054     2  0.0000      0.592 0.000 1.000
#> GSM71057     2  0.0000      0.592 0.000 1.000
#> GSM71060     2  0.0000      0.592 0.000 1.000
#> GSM71066     1  0.9732      1.000 0.596 0.404
#> GSM71070     2  0.9686      0.600 0.396 0.604
#> GSM71072     2  0.9686      0.600 0.396 0.604
#> GSM71074     2  0.9775      0.597 0.412 0.588
#> GSM71076     2  0.9686      0.600 0.396 0.604
#> GSM71077     2  0.9775      0.597 0.412 0.588
#> GSM71069     2  0.9686      0.600 0.396 0.604
#> GSM71071     2  0.9686      0.600 0.396 0.604
#> GSM71073     2  0.9686      0.600 0.396 0.604
#> GSM71075     2  0.9686      0.600 0.396 0.604
#> GSM71078     2  0.9491      0.602 0.368 0.632

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.2796      0.577 0.092 0.908 0.000
#> GSM71020     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71021     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71022     2  0.2625      0.727 0.000 0.916 0.084
#> GSM71023     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71024     1  0.5968      0.612 0.636 0.364 0.000
#> GSM71025     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71026     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71027     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71028     3  0.6286      0.868 0.000 0.464 0.536
#> GSM71030     1  0.5733      0.650 0.676 0.324 0.000
#> GSM71032     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71035     3  0.6286      0.868 0.000 0.464 0.536
#> GSM71038     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71043     3  0.6286      0.868 0.000 0.464 0.536
#> GSM71046     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71061     3  0.5621      0.855 0.000 0.308 0.692
#> GSM71062     1  0.6274      0.481 0.544 0.456 0.000
#> GSM71063     1  0.7996      0.333 0.476 0.464 0.060
#> GSM71068     1  0.5926      0.618 0.644 0.356 0.000
#> GSM71029     1  0.5926      0.605 0.644 0.356 0.000
#> GSM71031     1  0.6286      0.468 0.536 0.464 0.000
#> GSM71033     1  0.6286      0.468 0.536 0.464 0.000
#> GSM71036     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71044     1  0.5529      0.666 0.704 0.296 0.000
#> GSM71045     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71049     1  0.5529      0.666 0.704 0.296 0.000
#> GSM71055     1  0.0424      0.768 0.992 0.008 0.000
#> GSM71056     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71058     1  0.6274      0.483 0.544 0.456 0.000
#> GSM71059     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71065     1  0.4974      0.694 0.764 0.236 0.000
#> GSM71067     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71037     3  0.5621      0.855 0.000 0.308 0.692
#> GSM71039     3  0.6244      0.880 0.000 0.440 0.560
#> GSM71040     3  0.6286      0.868 0.000 0.464 0.536
#> GSM71041     3  0.5621      0.855 0.000 0.308 0.692
#> GSM71047     3  0.6126      0.890 0.000 0.400 0.600
#> GSM71048     1  0.5706      0.653 0.680 0.320 0.000
#> GSM71050     3  0.6280      0.871 0.000 0.460 0.540
#> GSM71051     3  0.6126      0.890 0.000 0.400 0.600
#> GSM71052     3  0.6126      0.890 0.000 0.400 0.600
#> GSM71054     3  0.5621      0.855 0.000 0.308 0.692
#> GSM71057     3  0.5785      0.868 0.000 0.332 0.668
#> GSM71060     3  0.5621      0.855 0.000 0.308 0.692
#> GSM71066     1  0.0000      0.770 1.000 0.000 0.000
#> GSM71070     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71072     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71074     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71076     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71077     2  0.5621      0.721 0.000 0.692 0.308
#> GSM71069     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71071     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71073     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71075     2  0.0000      0.718 0.000 1.000 0.000
#> GSM71078     3  0.6286      0.868 0.000 0.464 0.536

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.4955      0.403 0.344 0.000 0.008 0.648
#> GSM71020     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71022     4  0.4304      0.397 0.000 0.284 0.000 0.716
#> GSM71023     4  0.0336      0.726 0.000 0.000 0.008 0.992
#> GSM71024     1  0.3569      0.759 0.804 0.000 0.000 0.196
#> GSM71025     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71028     4  0.3873      0.702 0.000 0.000 0.228 0.772
#> GSM71030     1  0.3569      0.759 0.804 0.000 0.000 0.196
#> GSM71032     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71035     4  0.3801      0.706 0.000 0.000 0.220 0.780
#> GSM71038     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71043     4  0.3873      0.702 0.000 0.000 0.228 0.772
#> GSM71046     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71061     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM71062     1  0.4086      0.726 0.776 0.000 0.008 0.216
#> GSM71063     4  0.3837      0.704 0.000 0.000 0.224 0.776
#> GSM71068     1  0.3610      0.755 0.800 0.000 0.000 0.200
#> GSM71029     1  0.4948      0.196 0.560 0.000 0.000 0.440
#> GSM71031     4  0.5212      0.246 0.420 0.000 0.008 0.572
#> GSM71033     4  0.5150      0.302 0.396 0.000 0.008 0.596
#> GSM71036     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71044     1  0.3801      0.693 0.780 0.000 0.000 0.220
#> GSM71045     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71049     1  0.4222      0.625 0.728 0.000 0.000 0.272
#> GSM71055     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71058     1  0.3975      0.708 0.760 0.000 0.000 0.240
#> GSM71059     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71065     1  0.2011      0.838 0.920 0.000 0.000 0.080
#> GSM71067     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM71039     4  0.4916      0.545 0.000 0.000 0.424 0.576
#> GSM71040     4  0.7173      0.563 0.216 0.000 0.228 0.556
#> GSM71041     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM71047     4  0.4907      0.550 0.000 0.000 0.420 0.580
#> GSM71048     1  0.3400      0.775 0.820 0.000 0.000 0.180
#> GSM71050     4  0.4925      0.539 0.000 0.000 0.428 0.572
#> GSM71051     4  0.4907      0.550 0.000 0.000 0.420 0.580
#> GSM71052     4  0.4907      0.550 0.000 0.000 0.420 0.580
#> GSM71054     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0592      0.974 0.000 0.000 0.984 0.016
#> GSM71060     3  0.0000      0.995 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000      0.880 1.000 0.000 0.000 0.000
#> GSM71070     4  0.0188      0.725 0.000 0.000 0.004 0.996
#> GSM71072     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71074     2  0.3649      0.756 0.000 0.796 0.000 0.204
#> GSM71076     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71077     2  0.0000      0.962 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71071     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71073     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71075     4  0.0000      0.725 0.000 0.000 0.000 1.000
#> GSM71078     4  0.3801      0.706 0.000 0.000 0.220 0.780

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.2429     0.8439 0.004 0.000 0.020 0.900 0.076
#> GSM71020     2  0.0162     0.9840 0.000 0.996 0.000 0.004 0.000
#> GSM71021     2  0.0000     0.9835 0.000 1.000 0.000 0.000 0.000
#> GSM71022     4  0.3177     0.7029 0.000 0.208 0.000 0.792 0.000
#> GSM71023     4  0.1768     0.8471 0.004 0.000 0.000 0.924 0.072
#> GSM71024     4  0.4522     0.2420 0.008 0.000 0.000 0.552 0.440
#> GSM71025     2  0.0000     0.9835 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9835 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0162     0.9840 0.000 0.996 0.000 0.004 0.000
#> GSM71028     4  0.2873     0.8168 0.000 0.000 0.128 0.856 0.016
#> GSM71030     5  0.3300     0.6898 0.004 0.000 0.000 0.204 0.792
#> GSM71032     5  0.2516     0.8134 0.140 0.000 0.000 0.000 0.860
#> GSM71034     5  0.2329     0.8105 0.124 0.000 0.000 0.000 0.876
#> GSM71035     4  0.2674     0.8097 0.000 0.000 0.140 0.856 0.004
#> GSM71038     5  0.2516     0.8134 0.140 0.000 0.000 0.000 0.860
#> GSM71043     4  0.3013     0.7942 0.000 0.000 0.160 0.832 0.008
#> GSM71046     5  0.2516     0.8134 0.140 0.000 0.000 0.000 0.860
#> GSM71053     5  0.2516     0.8134 0.140 0.000 0.000 0.000 0.860
#> GSM71061     3  0.0000     0.8075 0.000 0.000 1.000 0.000 0.000
#> GSM71062     5  0.3398     0.6699 0.004 0.000 0.000 0.216 0.780
#> GSM71063     4  0.3146     0.8286 0.000 0.000 0.092 0.856 0.052
#> GSM71068     5  0.3300     0.6898 0.004 0.000 0.000 0.204 0.792
#> GSM71029     1  0.2909     0.7193 0.848 0.000 0.000 0.140 0.012
#> GSM71031     4  0.5993     0.6630 0.164 0.000 0.072 0.676 0.088
#> GSM71033     1  0.6651     0.0896 0.472 0.000 0.052 0.400 0.076
#> GSM71036     1  0.1851     0.8062 0.912 0.000 0.000 0.000 0.088
#> GSM71042     1  0.1851     0.8062 0.912 0.000 0.000 0.000 0.088
#> GSM71044     1  0.1386     0.7756 0.952 0.000 0.000 0.032 0.016
#> GSM71045     1  0.3932     0.5344 0.672 0.000 0.000 0.000 0.328
#> GSM71049     1  0.2818     0.7250 0.856 0.000 0.000 0.132 0.012
#> GSM71055     1  0.1732     0.8056 0.920 0.000 0.000 0.000 0.080
#> GSM71056     1  0.2074     0.7968 0.896 0.000 0.000 0.000 0.104
#> GSM71058     1  0.6886     0.2712 0.524 0.000 0.064 0.312 0.100
#> GSM71059     1  0.1851     0.8062 0.912 0.000 0.000 0.000 0.088
#> GSM71064     1  0.1851     0.8062 0.912 0.000 0.000 0.000 0.088
#> GSM71065     1  0.2408     0.8030 0.892 0.000 0.000 0.016 0.092
#> GSM71067     5  0.2424     0.8121 0.132 0.000 0.000 0.000 0.868
#> GSM71037     3  0.0000     0.8075 0.000 0.000 1.000 0.000 0.000
#> GSM71039     3  0.4225     0.5076 0.000 0.000 0.632 0.364 0.004
#> GSM71040     4  0.4910     0.7427 0.016 0.000 0.160 0.740 0.084
#> GSM71041     3  0.0000     0.8075 0.000 0.000 1.000 0.000 0.000
#> GSM71047     3  0.3612     0.7210 0.000 0.000 0.732 0.268 0.000
#> GSM71048     5  0.3300     0.6898 0.004 0.000 0.000 0.204 0.792
#> GSM71050     3  0.3876     0.6105 0.000 0.000 0.684 0.316 0.000
#> GSM71051     3  0.3612     0.7210 0.000 0.000 0.732 0.268 0.000
#> GSM71052     3  0.3534     0.7268 0.000 0.000 0.744 0.256 0.000
#> GSM71054     3  0.0000     0.8075 0.000 0.000 1.000 0.000 0.000
#> GSM71057     3  0.0290     0.8077 0.000 0.000 0.992 0.008 0.000
#> GSM71060     3  0.0000     0.8075 0.000 0.000 1.000 0.000 0.000
#> GSM71066     5  0.2516     0.8134 0.140 0.000 0.000 0.000 0.860
#> GSM71070     4  0.1197     0.8533 0.000 0.000 0.000 0.952 0.048
#> GSM71072     4  0.1484     0.8318 0.008 0.000 0.000 0.944 0.048
#> GSM71074     2  0.1608     0.9159 0.000 0.928 0.000 0.072 0.000
#> GSM71076     4  0.1484     0.8318 0.008 0.000 0.000 0.944 0.048
#> GSM71077     2  0.0162     0.9840 0.000 0.996 0.000 0.004 0.000
#> GSM71069     4  0.0162     0.8525 0.000 0.000 0.000 0.996 0.004
#> GSM71071     4  0.1484     0.8318 0.008 0.000 0.000 0.944 0.048
#> GSM71073     4  0.0510     0.8533 0.000 0.016 0.000 0.984 0.000
#> GSM71075     4  0.0162     0.8525 0.000 0.000 0.000 0.996 0.004
#> GSM71078     4  0.1430     0.8486 0.000 0.000 0.052 0.944 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
#> GSM71019     1  0.5861      0.257 0.504 0.000 0.004 0.056 0.384 0.052
#> GSM71020     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.3659      0.399 0.000 0.636 0.000 0.364 0.000 0.000
#> GSM71023     4  0.5549      0.386 0.040 0.000 0.004 0.524 0.388 0.044
#> GSM71024     5  0.0000      0.688 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71025     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.3212      0.973 0.000 0.000 0.012 0.048 0.100 0.840
#> GSM71030     5  0.0000      0.688 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71032     5  0.3782      0.597 0.360 0.000 0.000 0.000 0.636 0.004
#> GSM71034     5  0.2823      0.659 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71035     6  0.3419      0.963 0.000 0.000 0.012 0.072 0.088 0.828
#> GSM71038     5  0.3782      0.597 0.360 0.000 0.000 0.000 0.636 0.004
#> GSM71043     6  0.3212      0.973 0.000 0.000 0.012 0.048 0.100 0.840
#> GSM71046     5  0.3841      0.562 0.380 0.000 0.000 0.000 0.616 0.004
#> GSM71053     5  0.3782      0.597 0.360 0.000 0.000 0.000 0.636 0.004
#> GSM71061     3  0.0000      0.868 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71062     5  0.0000      0.688 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     6  0.3212      0.973 0.000 0.000 0.012 0.048 0.100 0.840
#> GSM71068     5  0.0000      0.688 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     1  0.2909      0.738 0.828 0.000 0.000 0.012 0.004 0.156
#> GSM71031     5  0.1167      0.658 0.000 0.000 0.012 0.020 0.960 0.008
#> GSM71033     1  0.5861      0.257 0.504 0.000 0.004 0.056 0.384 0.052
#> GSM71036     1  0.0937      0.792 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM71042     1  0.0937      0.792 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM71044     1  0.2700      0.740 0.836 0.000 0.000 0.004 0.004 0.156
#> GSM71045     1  0.3175      0.477 0.744 0.000 0.000 0.000 0.256 0.000
#> GSM71049     1  0.2909      0.738 0.828 0.000 0.000 0.012 0.004 0.156
#> GSM71055     1  0.1549      0.791 0.936 0.000 0.000 0.000 0.044 0.020
#> GSM71056     1  0.0937      0.792 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM71058     5  0.4498     -0.276 0.472 0.000 0.012 0.012 0.504 0.000
#> GSM71059     1  0.0937      0.792 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM71064     1  0.0937      0.792 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM71065     1  0.1074      0.783 0.960 0.000 0.000 0.000 0.012 0.028
#> GSM71067     5  0.3769      0.597 0.356 0.000 0.000 0.000 0.640 0.004
#> GSM71037     3  0.0000      0.868 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     3  0.5794      0.220 0.000 0.000 0.528 0.036 0.088 0.348
#> GSM71040     5  0.3875      0.466 0.000 0.000 0.144 0.008 0.780 0.068
#> GSM71041     3  0.0000      0.868 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71047     3  0.3234      0.817 0.000 0.000 0.848 0.028 0.080 0.044
#> GSM71048     5  0.0146      0.689 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM71050     3  0.2948      0.822 0.000 0.000 0.860 0.012 0.084 0.044
#> GSM71051     3  0.3156      0.821 0.000 0.000 0.852 0.024 0.080 0.044
#> GSM71052     3  0.3156      0.821 0.000 0.000 0.852 0.024 0.080 0.044
#> GSM71054     3  0.0000      0.868 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0146      0.868 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM71060     3  0.0000      0.868 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71066     5  0.3782      0.597 0.360 0.000 0.000 0.000 0.636 0.004
#> GSM71070     4  0.3221      0.792 0.000 0.000 0.000 0.828 0.096 0.076
#> GSM71072     4  0.0000      0.792 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71074     2  0.0146      0.937 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71076     4  0.0000      0.792 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71077     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.2647      0.822 0.000 0.000 0.000 0.868 0.088 0.044
#> GSM71071     4  0.0000      0.792 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71073     4  0.2647      0.822 0.000 0.000 0.000 0.868 0.088 0.044
#> GSM71075     4  0.2647      0.822 0.000 0.000 0.000 0.868 0.088 0.044
#> GSM71078     6  0.3906      0.927 0.000 0.000 0.012 0.112 0.088 0.788

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:mclust 51    3.55e-04 2
#> CV:mclust 55    6.22e-12 3
#> CV:mclust 55    3.08e-09 4
#> CV:mclust 57    1.13e-16 5
#> CV:mclust 52    2.38e-18 6

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


CV:NMF*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.710           0.878       0.944         0.4720 0.519   0.519
#> 3 3 0.904           0.887       0.956         0.3887 0.711   0.498
#> 4 4 0.899           0.868       0.932         0.1134 0.898   0.717
#> 5 5 0.732           0.735       0.803         0.0864 0.919   0.705
#> 6 6 0.739           0.717       0.816         0.0351 0.950   0.775

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
#> GSM71019     2  0.0376     0.9217 0.004 0.996
#> GSM71020     2  0.0000     0.9228 0.000 1.000
#> GSM71021     2  0.0000     0.9228 0.000 1.000
#> GSM71022     2  0.0000     0.9228 0.000 1.000
#> GSM71023     2  0.2948     0.9000 0.052 0.948
#> GSM71024     1  0.0000     0.9435 1.000 0.000
#> GSM71025     2  0.0000     0.9228 0.000 1.000
#> GSM71026     2  0.0000     0.9228 0.000 1.000
#> GSM71027     2  0.0000     0.9228 0.000 1.000
#> GSM71028     1  0.6801     0.7994 0.820 0.180
#> GSM71030     1  0.0000     0.9435 1.000 0.000
#> GSM71032     1  0.0000     0.9435 1.000 0.000
#> GSM71034     1  0.0000     0.9435 1.000 0.000
#> GSM71035     2  0.9710     0.3397 0.400 0.600
#> GSM71038     1  0.0000     0.9435 1.000 0.000
#> GSM71043     1  0.3431     0.9097 0.936 0.064
#> GSM71046     1  0.0000     0.9435 1.000 0.000
#> GSM71053     1  0.0000     0.9435 1.000 0.000
#> GSM71061     1  0.6623     0.8089 0.828 0.172
#> GSM71062     1  0.0000     0.9435 1.000 0.000
#> GSM71063     1  0.4431     0.8885 0.908 0.092
#> GSM71068     1  0.0000     0.9435 1.000 0.000
#> GSM71029     1  0.4562     0.8647 0.904 0.096
#> GSM71031     1  0.2043     0.9288 0.968 0.032
#> GSM71033     1  0.8499     0.6487 0.724 0.276
#> GSM71036     1  0.0000     0.9435 1.000 0.000
#> GSM71042     1  0.0000     0.9435 1.000 0.000
#> GSM71044     1  0.0000     0.9435 1.000 0.000
#> GSM71045     1  0.0000     0.9435 1.000 0.000
#> GSM71049     1  0.0000     0.9435 1.000 0.000
#> GSM71055     1  0.0000     0.9435 1.000 0.000
#> GSM71056     1  0.0000     0.9435 1.000 0.000
#> GSM71058     1  0.0000     0.9435 1.000 0.000
#> GSM71059     1  0.0000     0.9435 1.000 0.000
#> GSM71064     1  0.0000     0.9435 1.000 0.000
#> GSM71065     1  0.0000     0.9435 1.000 0.000
#> GSM71067     1  0.0000     0.9435 1.000 0.000
#> GSM71037     1  0.2778     0.9202 0.952 0.048
#> GSM71039     2  0.9988     0.0621 0.480 0.520
#> GSM71040     1  0.0000     0.9435 1.000 0.000
#> GSM71041     1  0.5294     0.8636 0.880 0.120
#> GSM71047     2  0.1843     0.9129 0.028 0.972
#> GSM71048     1  0.0000     0.9435 1.000 0.000
#> GSM71050     1  0.8861     0.5923 0.696 0.304
#> GSM71051     2  0.3879     0.8824 0.076 0.924
#> GSM71052     2  0.6887     0.7738 0.184 0.816
#> GSM71054     1  0.6973     0.7893 0.812 0.188
#> GSM71057     1  0.7219     0.7731 0.800 0.200
#> GSM71060     1  0.2948     0.9179 0.948 0.052
#> GSM71066     1  0.0000     0.9435 1.000 0.000
#> GSM71070     2  0.0000     0.9228 0.000 1.000
#> GSM71072     2  0.0000     0.9228 0.000 1.000
#> GSM71074     2  0.0000     0.9228 0.000 1.000
#> GSM71076     2  0.0000     0.9228 0.000 1.000
#> GSM71077     2  0.0000     0.9228 0.000 1.000
#> GSM71069     2  0.6438     0.7989 0.164 0.836
#> GSM71071     2  0.0000     0.9228 0.000 1.000
#> GSM71073     2  0.0000     0.9228 0.000 1.000
#> GSM71075     2  0.2043     0.9111 0.032 0.968
#> GSM71078     2  0.5519     0.8369 0.128 0.872

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71020     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71022     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71023     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71024     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71025     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71028     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71030     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71032     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71034     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71035     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71038     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71043     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71046     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71053     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71061     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71062     1  0.0424     0.9789 0.992 0.000 0.008
#> GSM71063     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71068     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71029     1  0.1860     0.9406 0.948 0.052 0.000
#> GSM71031     1  0.2590     0.9104 0.924 0.004 0.072
#> GSM71033     1  0.6313     0.7309 0.768 0.148 0.084
#> GSM71036     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71042     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71044     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71045     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71049     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71055     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71056     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71058     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71059     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71065     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71067     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71037     3  0.0424     0.9057 0.008 0.000 0.992
#> GSM71039     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71040     3  0.6274     0.1078 0.456 0.000 0.544
#> GSM71041     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71047     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71048     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71050     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71051     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71052     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71054     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71057     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71060     3  0.0000     0.9133 0.000 0.000 1.000
#> GSM71066     1  0.0000     0.9855 1.000 0.000 0.000
#> GSM71070     3  0.4702     0.6768 0.000 0.212 0.788
#> GSM71072     3  0.6286     0.0264 0.000 0.464 0.536
#> GSM71074     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71076     2  0.5785     0.5315 0.000 0.668 0.332
#> GSM71077     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71069     3  0.4750     0.6705 0.000 0.216 0.784
#> GSM71071     2  0.5621     0.5787 0.000 0.692 0.308
#> GSM71073     2  0.0000     0.9219 0.000 1.000 0.000
#> GSM71075     2  0.5291     0.6453 0.000 0.732 0.268
#> GSM71078     3  0.0000     0.9133 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0188     0.9519 0.000 0.996 0.000 0.004
#> GSM71023     2  0.4103     0.6679 0.000 0.744 0.000 0.256
#> GSM71024     1  0.3024     0.8773 0.852 0.000 0.000 0.148
#> GSM71025     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71028     4  0.3311     0.7946 0.000 0.000 0.172 0.828
#> GSM71030     1  0.3486     0.8343 0.812 0.000 0.000 0.188
#> GSM71032     1  0.1637     0.9291 0.940 0.000 0.000 0.060
#> GSM71034     1  0.2011     0.9250 0.920 0.000 0.000 0.080
#> GSM71035     4  0.3649     0.7578 0.000 0.000 0.204 0.796
#> GSM71038     1  0.1637     0.9291 0.940 0.000 0.000 0.060
#> GSM71043     3  0.4961     0.0694 0.000 0.000 0.552 0.448
#> GSM71046     1  0.1792     0.9280 0.932 0.000 0.000 0.068
#> GSM71053     1  0.2081     0.9237 0.916 0.000 0.000 0.084
#> GSM71061     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71062     1  0.2081     0.9237 0.916 0.000 0.000 0.084
#> GSM71063     4  0.0336     0.8653 0.000 0.000 0.008 0.992
#> GSM71068     1  0.2216     0.9196 0.908 0.000 0.000 0.092
#> GSM71029     1  0.1940     0.8967 0.924 0.076 0.000 0.000
#> GSM71031     4  0.5865     0.4824 0.340 0.000 0.048 0.612
#> GSM71033     1  0.7932    -0.1484 0.392 0.364 0.240 0.004
#> GSM71036     1  0.0000     0.9244 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000     0.9244 1.000 0.000 0.000 0.000
#> GSM71044     1  0.0188     0.9234 0.996 0.000 0.000 0.004
#> GSM71045     1  0.0469     0.9264 0.988 0.000 0.000 0.012
#> GSM71049     1  0.1716     0.9288 0.936 0.000 0.000 0.064
#> GSM71055     1  0.0188     0.9234 0.996 0.000 0.000 0.004
#> GSM71056     1  0.0000     0.9244 1.000 0.000 0.000 0.000
#> GSM71058     1  0.1004     0.9102 0.972 0.000 0.024 0.004
#> GSM71059     1  0.0188     0.9234 0.996 0.000 0.000 0.004
#> GSM71064     1  0.0188     0.9234 0.996 0.000 0.000 0.004
#> GSM71065     1  0.0188     0.9234 0.996 0.000 0.000 0.004
#> GSM71067     1  0.1716     0.9288 0.936 0.000 0.000 0.064
#> GSM71037     3  0.0779     0.9317 0.016 0.000 0.980 0.004
#> GSM71039     3  0.0188     0.9448 0.000 0.000 0.996 0.004
#> GSM71040     3  0.1940     0.8667 0.076 0.000 0.924 0.000
#> GSM71041     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71047     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71048     1  0.2081     0.9237 0.916 0.000 0.000 0.084
#> GSM71050     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71051     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71052     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000     0.9477 0.000 0.000 1.000 0.000
#> GSM71066     1  0.2011     0.9250 0.920 0.000 0.000 0.080
#> GSM71070     4  0.0188     0.8651 0.000 0.000 0.004 0.996
#> GSM71072     4  0.2882     0.8435 0.000 0.084 0.024 0.892
#> GSM71074     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71076     4  0.2125     0.8453 0.000 0.076 0.004 0.920
#> GSM71077     2  0.0000     0.9543 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0188     0.8651 0.000 0.000 0.004 0.996
#> GSM71071     4  0.2831     0.8172 0.000 0.120 0.004 0.876
#> GSM71073     2  0.3311     0.7775 0.000 0.828 0.000 0.172
#> GSM71075     4  0.0188     0.8624 0.004 0.000 0.000 0.996
#> GSM71078     4  0.2814     0.8265 0.000 0.000 0.132 0.868

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.3304     0.7247 0.016 0.816 0.000 0.000 0.168
#> GSM71020     2  0.0000     0.8506 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.2074     0.8480 0.104 0.896 0.000 0.000 0.000
#> GSM71022     2  0.1410     0.8537 0.060 0.940 0.000 0.000 0.000
#> GSM71023     2  0.6304     0.4578 0.016 0.576 0.000 0.144 0.264
#> GSM71024     5  0.2124     0.7182 0.028 0.000 0.000 0.056 0.916
#> GSM71025     2  0.2074     0.8480 0.104 0.896 0.000 0.000 0.000
#> GSM71026     2  0.2020     0.8488 0.100 0.900 0.000 0.000 0.000
#> GSM71027     2  0.0404     0.8505 0.012 0.988 0.000 0.000 0.000
#> GSM71028     4  0.4599     0.5949 0.040 0.000 0.272 0.688 0.000
#> GSM71030     5  0.4183     0.5457 0.084 0.000 0.000 0.136 0.780
#> GSM71032     1  0.4219     0.6473 0.584 0.000 0.000 0.000 0.416
#> GSM71034     5  0.1197     0.7443 0.048 0.000 0.000 0.000 0.952
#> GSM71035     4  0.3409     0.7630 0.032 0.000 0.144 0.824 0.000
#> GSM71038     1  0.4297     0.6032 0.528 0.000 0.000 0.000 0.472
#> GSM71043     3  0.6889     0.0993 0.384 0.000 0.436 0.156 0.024
#> GSM71046     5  0.1478     0.7559 0.064 0.000 0.000 0.000 0.936
#> GSM71053     1  0.4307     0.5606 0.500 0.000 0.000 0.000 0.500
#> GSM71061     3  0.0510     0.9388 0.016 0.000 0.984 0.000 0.000
#> GSM71062     5  0.1892     0.7139 0.080 0.000 0.004 0.000 0.916
#> GSM71063     4  0.3969     0.7764 0.092 0.000 0.004 0.808 0.096
#> GSM71068     1  0.4713     0.6236 0.544 0.000 0.016 0.000 0.440
#> GSM71029     5  0.4238     0.6247 0.068 0.164 0.000 0.000 0.768
#> GSM71031     4  0.6788     0.1471 0.196 0.004 0.004 0.440 0.356
#> GSM71033     1  0.5197     0.4779 0.712 0.188 0.080 0.000 0.020
#> GSM71036     5  0.2561     0.7409 0.144 0.000 0.000 0.000 0.856
#> GSM71042     5  0.2852     0.7205 0.172 0.000 0.000 0.000 0.828
#> GSM71044     1  0.3949     0.6253 0.668 0.000 0.000 0.000 0.332
#> GSM71045     5  0.3857     0.4972 0.312 0.000 0.000 0.000 0.688
#> GSM71049     5  0.1608     0.7700 0.072 0.000 0.000 0.000 0.928
#> GSM71055     5  0.3305     0.6626 0.224 0.000 0.000 0.000 0.776
#> GSM71056     5  0.2230     0.7629 0.116 0.000 0.000 0.000 0.884
#> GSM71058     1  0.3946     0.6192 0.800 0.000 0.080 0.000 0.120
#> GSM71059     5  0.3074     0.6970 0.196 0.000 0.000 0.000 0.804
#> GSM71064     1  0.3949     0.6370 0.668 0.000 0.000 0.000 0.332
#> GSM71065     1  0.4541     0.6537 0.680 0.000 0.032 0.000 0.288
#> GSM71067     5  0.3561     0.3391 0.260 0.000 0.000 0.000 0.740
#> GSM71037     3  0.0404     0.9395 0.012 0.000 0.988 0.000 0.000
#> GSM71039     3  0.1117     0.9284 0.016 0.000 0.964 0.020 0.000
#> GSM71040     3  0.0671     0.9317 0.004 0.000 0.980 0.000 0.016
#> GSM71041     3  0.0510     0.9370 0.016 0.000 0.984 0.000 0.000
#> GSM71047     3  0.1043     0.9251 0.040 0.000 0.960 0.000 0.000
#> GSM71048     5  0.1197     0.7732 0.048 0.000 0.000 0.000 0.952
#> GSM71050     3  0.1121     0.9273 0.044 0.000 0.956 0.000 0.000
#> GSM71051     3  0.0290     0.9396 0.008 0.000 0.992 0.000 0.000
#> GSM71052     3  0.0000     0.9399 0.000 0.000 1.000 0.000 0.000
#> GSM71054     3  0.0404     0.9395 0.012 0.000 0.988 0.000 0.000
#> GSM71057     3  0.0290     0.9396 0.008 0.000 0.992 0.000 0.000
#> GSM71060     3  0.0000     0.9399 0.000 0.000 1.000 0.000 0.000
#> GSM71066     5  0.0963     0.7502 0.036 0.000 0.000 0.000 0.964
#> GSM71070     4  0.4452     0.7590 0.064 0.040 0.000 0.796 0.100
#> GSM71072     4  0.1197     0.8248 0.048 0.000 0.000 0.952 0.000
#> GSM71074     2  0.2504     0.8243 0.064 0.896 0.000 0.040 0.000
#> GSM71076     4  0.0671     0.8320 0.016 0.004 0.000 0.980 0.000
#> GSM71077     2  0.2171     0.8321 0.064 0.912 0.000 0.024 0.000
#> GSM71069     4  0.1661     0.8308 0.036 0.000 0.000 0.940 0.024
#> GSM71071     4  0.1197     0.8248 0.048 0.000 0.000 0.952 0.000
#> GSM71073     2  0.5107     0.5346 0.064 0.640 0.000 0.296 0.000
#> GSM71075     4  0.1195     0.8326 0.028 0.000 0.000 0.960 0.012
#> GSM71078     4  0.0798     0.8347 0.008 0.000 0.016 0.976 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
#> GSM71019     2  0.5222     0.5509 0.252 0.624 0.004 0.000 0.004 NA
#> GSM71020     2  0.3109     0.7744 0.000 0.772 0.000 0.000 0.004 NA
#> GSM71021     2  0.0547     0.7743 0.000 0.980 0.000 0.000 0.000 NA
#> GSM71022     2  0.1714     0.7847 0.000 0.908 0.000 0.000 0.000 NA
#> GSM71023     1  0.7667    -0.1512 0.412 0.316 0.004 0.072 0.052 NA
#> GSM71024     1  0.2538     0.7931 0.892 0.000 0.000 0.020 0.048 NA
#> GSM71025     2  0.1075     0.7616 0.000 0.952 0.000 0.000 0.000 NA
#> GSM71026     2  0.0000     0.7801 0.000 1.000 0.000 0.000 0.000 NA
#> GSM71027     2  0.3290     0.7684 0.000 0.744 0.000 0.000 0.004 NA
#> GSM71028     3  0.5819    -0.0614 0.000 0.000 0.448 0.428 0.024 NA
#> GSM71030     1  0.4065     0.7220 0.804 0.008 0.000 0.044 0.060 NA
#> GSM71032     5  0.2436     0.8248 0.088 0.000 0.000 0.000 0.880 NA
#> GSM71034     1  0.1577     0.8161 0.940 0.000 0.000 0.008 0.036 NA
#> GSM71035     4  0.5641     0.3453 0.000 0.000 0.288 0.572 0.020 NA
#> GSM71038     5  0.3150     0.8113 0.120 0.000 0.000 0.000 0.828 NA
#> GSM71043     5  0.6307     0.3651 0.000 0.000 0.256 0.068 0.544 NA
#> GSM71046     1  0.1080     0.8290 0.960 0.000 0.000 0.004 0.032 NA
#> GSM71053     5  0.3454     0.7850 0.124 0.000 0.000 0.004 0.812 NA
#> GSM71061     3  0.2237     0.8818 0.000 0.000 0.896 0.000 0.036 NA
#> GSM71062     1  0.1861     0.8115 0.928 0.000 0.000 0.016 0.036 NA
#> GSM71063     4  0.6947     0.3786 0.096 0.004 0.000 0.488 0.232 NA
#> GSM71068     5  0.3338     0.8179 0.108 0.000 0.016 0.004 0.836 NA
#> GSM71029     1  0.3124     0.8128 0.848 0.040 0.000 0.000 0.016 NA
#> GSM71031     4  0.7908     0.2597 0.228 0.176 0.000 0.344 0.016 NA
#> GSM71033     5  0.2505     0.7712 0.000 0.064 0.040 0.000 0.888 NA
#> GSM71036     1  0.2776     0.8146 0.860 0.000 0.000 0.000 0.052 NA
#> GSM71042     1  0.3254     0.8003 0.820 0.000 0.000 0.000 0.056 NA
#> GSM71044     5  0.4525     0.7538 0.140 0.008 0.000 0.000 0.724 NA
#> GSM71045     1  0.5035     0.6061 0.640 0.000 0.000 0.000 0.192 NA
#> GSM71049     1  0.1078     0.8307 0.964 0.016 0.000 0.000 0.012 NA
#> GSM71055     1  0.3570     0.7857 0.792 0.000 0.000 0.000 0.064 NA
#> GSM71056     1  0.2897     0.8133 0.852 0.000 0.000 0.000 0.060 NA
#> GSM71058     5  0.3461     0.8072 0.048 0.024 0.040 0.000 0.852 NA
#> GSM71059     1  0.3532     0.7881 0.796 0.000 0.000 0.000 0.064 NA
#> GSM71064     5  0.3062     0.7985 0.144 0.000 0.000 0.000 0.824 NA
#> GSM71065     5  0.4008     0.7990 0.096 0.000 0.040 0.000 0.796 NA
#> GSM71067     1  0.3752     0.7132 0.776 0.000 0.000 0.004 0.168 NA
#> GSM71037     3  0.0405     0.9092 0.000 0.000 0.988 0.000 0.008 NA
#> GSM71039     3  0.2771     0.8595 0.000 0.000 0.852 0.000 0.032 NA
#> GSM71040     3  0.0260     0.9095 0.000 0.000 0.992 0.000 0.008 NA
#> GSM71041     3  0.0993     0.9051 0.000 0.000 0.964 0.000 0.012 NA
#> GSM71047     3  0.2277     0.8830 0.000 0.000 0.892 0.000 0.032 NA
#> GSM71048     1  0.0551     0.8285 0.984 0.000 0.000 0.004 0.008 NA
#> GSM71050     3  0.2752     0.8631 0.000 0.000 0.856 0.000 0.036 NA
#> GSM71051     3  0.0520     0.9084 0.000 0.000 0.984 0.000 0.008 NA
#> GSM71052     3  0.0146     0.9097 0.000 0.000 0.996 0.000 0.000 NA
#> GSM71054     3  0.0405     0.9092 0.000 0.000 0.988 0.000 0.008 NA
#> GSM71057     3  0.0405     0.9092 0.000 0.000 0.988 0.000 0.008 NA
#> GSM71060     3  0.0146     0.9098 0.000 0.000 0.996 0.000 0.004 NA
#> GSM71066     1  0.0964     0.8247 0.968 0.000 0.000 0.004 0.012 NA
#> GSM71070     4  0.5856     0.5822 0.144 0.028 0.000 0.608 0.008 NA
#> GSM71072     4  0.2219     0.6877 0.000 0.000 0.000 0.864 0.000 NA
#> GSM71074     2  0.5347     0.5793 0.000 0.504 0.000 0.112 0.000 NA
#> GSM71076     4  0.2020     0.6943 0.000 0.008 0.000 0.896 0.000 NA
#> GSM71077     2  0.4868     0.6455 0.000 0.548 0.000 0.052 0.004 NA
#> GSM71069     4  0.3460     0.6775 0.084 0.000 0.000 0.828 0.016 NA
#> GSM71071     4  0.2278     0.6884 0.000 0.004 0.000 0.868 0.000 NA
#> GSM71073     4  0.5738     0.2363 0.000 0.208 0.000 0.508 0.000 NA
#> GSM71075     4  0.2209     0.6966 0.052 0.000 0.000 0.904 0.004 NA
#> GSM71078     4  0.1950     0.6883 0.000 0.000 0.064 0.912 0.000 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> CV:NMF 58    1.91e-08 2
#> CV:NMF 58    4.23e-11 3
#> CV:NMF 57    6.20e-16 4
#> CV:NMF 54    9.85e-13 5
#> CV:NMF 53    2.06e-16 6

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


MAD:hclust

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

res = res_list["MAD", "hclust"]
# you can also extract it by
# res = res_list["MAD:hclust"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.499           0.809       0.893         0.4327 0.573   0.573
#> 3 3 0.539           0.616       0.763         0.3443 0.700   0.503
#> 4 4 0.624           0.702       0.819         0.2016 0.863   0.650
#> 5 5 0.720           0.674       0.847         0.0919 0.854   0.575
#> 6 6 0.771           0.764       0.831         0.0809 0.890   0.574

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     1   0.689      0.803 0.816 0.184
#> GSM71020     2   0.000      0.922 0.000 1.000
#> GSM71021     2   0.000      0.922 0.000 1.000
#> GSM71022     2   0.000      0.922 0.000 1.000
#> GSM71023     1   0.689      0.803 0.816 0.184
#> GSM71024     1   0.327      0.844 0.940 0.060
#> GSM71025     2   0.000      0.922 0.000 1.000
#> GSM71026     2   0.000      0.922 0.000 1.000
#> GSM71027     2   0.000      0.922 0.000 1.000
#> GSM71028     1   0.886      0.712 0.696 0.304
#> GSM71030     1   0.358      0.843 0.932 0.068
#> GSM71032     1   0.000      0.846 1.000 0.000
#> GSM71034     1   0.000      0.846 1.000 0.000
#> GSM71035     2   0.881      0.493 0.300 0.700
#> GSM71038     1   0.000      0.846 1.000 0.000
#> GSM71043     1   0.886      0.712 0.696 0.304
#> GSM71046     1   0.000      0.846 1.000 0.000
#> GSM71053     1   0.000      0.846 1.000 0.000
#> GSM71061     1   0.895      0.703 0.688 0.312
#> GSM71062     1   0.327      0.844 0.940 0.060
#> GSM71063     1   0.886      0.712 0.696 0.304
#> GSM71068     1   0.184      0.846 0.972 0.028
#> GSM71029     1   0.000      0.846 1.000 0.000
#> GSM71031     1   0.625      0.816 0.844 0.156
#> GSM71033     1   0.529      0.829 0.880 0.120
#> GSM71036     1   0.000      0.846 1.000 0.000
#> GSM71042     1   0.000      0.846 1.000 0.000
#> GSM71044     1   0.000      0.846 1.000 0.000
#> GSM71045     1   0.000      0.846 1.000 0.000
#> GSM71049     1   0.000      0.846 1.000 0.000
#> GSM71055     1   0.000      0.846 1.000 0.000
#> GSM71056     1   0.000      0.846 1.000 0.000
#> GSM71058     1   0.563      0.825 0.868 0.132
#> GSM71059     1   0.000      0.846 1.000 0.000
#> GSM71064     1   0.000      0.846 1.000 0.000
#> GSM71065     1   0.000      0.846 1.000 0.000
#> GSM71067     1   0.000      0.846 1.000 0.000
#> GSM71037     1   0.895      0.703 0.688 0.312
#> GSM71039     2   0.909      0.426 0.324 0.676
#> GSM71040     1   0.706      0.797 0.808 0.192
#> GSM71041     1   0.891      0.708 0.692 0.308
#> GSM71047     1   0.943      0.633 0.640 0.360
#> GSM71048     1   0.327      0.844 0.940 0.060
#> GSM71050     1   0.891      0.708 0.692 0.308
#> GSM71051     1   0.943      0.633 0.640 0.360
#> GSM71052     1   0.943      0.633 0.640 0.360
#> GSM71054     1   0.895      0.703 0.688 0.312
#> GSM71057     1   0.895      0.703 0.688 0.312
#> GSM71060     1   0.895      0.703 0.688 0.312
#> GSM71066     1   0.000      0.846 1.000 0.000
#> GSM71070     2   0.118      0.923 0.016 0.984
#> GSM71072     2   0.118      0.923 0.016 0.984
#> GSM71074     2   0.000      0.922 0.000 1.000
#> GSM71076     2   0.118      0.923 0.016 0.984
#> GSM71077     2   0.000      0.922 0.000 1.000
#> GSM71069     2   0.118      0.923 0.016 0.984
#> GSM71071     2   0.118      0.923 0.016 0.984
#> GSM71073     2   0.118      0.923 0.016 0.984
#> GSM71075     2   0.118      0.923 0.016 0.984
#> GSM71078     2   0.876      0.502 0.296 0.704

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.7672   -0.63116 0.468 0.044 0.488
#> GSM71020     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71021     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71022     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71023     3  0.7672   -0.63116 0.468 0.044 0.488
#> GSM71024     1  0.6307    0.77230 0.512 0.000 0.488
#> GSM71025     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71026     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71027     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71028     3  0.0747    0.67408 0.016 0.000 0.984
#> GSM71030     1  0.6309    0.74784 0.500 0.000 0.500
#> GSM71032     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71034     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71035     3  0.7559    0.00343 0.336 0.056 0.608
#> GSM71038     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71043     3  0.0747    0.67408 0.016 0.000 0.984
#> GSM71046     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71053     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71061     3  0.0000    0.68530 0.000 0.000 1.000
#> GSM71062     1  0.6308    0.76521 0.508 0.000 0.492
#> GSM71063     3  0.0747    0.67408 0.016 0.000 0.984
#> GSM71068     1  0.6267    0.82673 0.548 0.000 0.452
#> GSM71029     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71031     3  0.6274   -0.58888 0.456 0.000 0.544
#> GSM71033     1  0.7353    0.74403 0.532 0.032 0.436
#> GSM71036     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71042     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71044     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71045     1  0.5835    0.91610 0.660 0.000 0.340
#> GSM71049     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71055     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71056     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71058     3  0.6307   -0.66544 0.488 0.000 0.512
#> GSM71059     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71064     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71065     1  0.5810    0.91712 0.664 0.000 0.336
#> GSM71067     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71037     3  0.0000    0.68530 0.000 0.000 1.000
#> GSM71039     3  0.7417    0.07222 0.312 0.056 0.632
#> GSM71040     3  0.6008   -0.38305 0.372 0.000 0.628
#> GSM71041     3  0.0237    0.68369 0.004 0.000 0.996
#> GSM71047     3  0.1878    0.66894 0.004 0.044 0.952
#> GSM71048     1  0.6308    0.76521 0.508 0.000 0.492
#> GSM71050     3  0.0237    0.68369 0.004 0.000 0.996
#> GSM71051     3  0.1878    0.66894 0.004 0.044 0.952
#> GSM71052     3  0.1878    0.66894 0.004 0.044 0.952
#> GSM71054     3  0.0000    0.68530 0.000 0.000 1.000
#> GSM71057     3  0.0000    0.68530 0.000 0.000 1.000
#> GSM71060     3  0.0000    0.68530 0.000 0.000 1.000
#> GSM71066     1  0.6008    0.91304 0.628 0.000 0.372
#> GSM71070     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71072     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71074     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71076     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71077     2  0.0000    0.72458 0.000 1.000 0.000
#> GSM71069     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71071     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71073     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71075     2  0.9901    0.59822 0.336 0.392 0.272
#> GSM71078     3  0.8553   -0.14556 0.336 0.112 0.552

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     1  0.6511     0.5318 0.524 0.032 0.420 0.024
#> GSM71020     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0336     0.9916 0.000 0.992 0.000 0.008
#> GSM71023     1  0.6511     0.5318 0.524 0.032 0.420 0.024
#> GSM71024     1  0.3870     0.5814 0.788 0.000 0.208 0.004
#> GSM71025     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71028     3  0.5337     0.5647 0.260 0.000 0.696 0.044
#> GSM71030     1  0.4283     0.5166 0.740 0.000 0.256 0.004
#> GSM71032     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71034     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71035     3  0.4996    -0.0135 0.000 0.000 0.516 0.484
#> GSM71038     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71043     3  0.5337     0.5647 0.260 0.000 0.696 0.044
#> GSM71046     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71053     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71061     3  0.0707     0.7769 0.000 0.000 0.980 0.020
#> GSM71062     1  0.4088     0.5521 0.764 0.000 0.232 0.004
#> GSM71063     3  0.5337     0.5647 0.260 0.000 0.696 0.044
#> GSM71068     1  0.3528     0.5956 0.808 0.000 0.192 0.000
#> GSM71029     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71031     3  0.5295    -0.4929 0.488 0.000 0.504 0.008
#> GSM71033     1  0.5846     0.6086 0.592 0.032 0.372 0.004
#> GSM71036     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71042     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71044     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71045     1  0.4164     0.7244 0.736 0.000 0.264 0.000
#> GSM71049     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71055     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71056     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71058     1  0.5155     0.5123 0.528 0.000 0.468 0.004
#> GSM71059     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71064     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71065     1  0.4134     0.7260 0.740 0.000 0.260 0.000
#> GSM71067     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71037     3  0.0707     0.7769 0.000 0.000 0.980 0.020
#> GSM71039     3  0.4977     0.0719 0.000 0.000 0.540 0.460
#> GSM71040     1  0.5161     0.2739 0.592 0.000 0.400 0.008
#> GSM71041     3  0.0592     0.7751 0.000 0.000 0.984 0.016
#> GSM71047     3  0.1867     0.7616 0.000 0.000 0.928 0.072
#> GSM71048     1  0.4088     0.5521 0.764 0.000 0.232 0.004
#> GSM71050     3  0.0592     0.7751 0.000 0.000 0.984 0.016
#> GSM71051     3  0.1867     0.7616 0.000 0.000 0.928 0.072
#> GSM71052     3  0.1867     0.7616 0.000 0.000 0.928 0.072
#> GSM71054     3  0.0707     0.7769 0.000 0.000 0.980 0.020
#> GSM71057     3  0.0707     0.7769 0.000 0.000 0.980 0.020
#> GSM71060     3  0.0707     0.7769 0.000 0.000 0.980 0.020
#> GSM71066     1  0.1211     0.6901 0.960 0.000 0.040 0.000
#> GSM71070     4  0.0188     0.9451 0.000 0.000 0.004 0.996
#> GSM71072     4  0.0188     0.9438 0.000 0.000 0.004 0.996
#> GSM71074     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71076     4  0.0188     0.9451 0.000 0.000 0.004 0.996
#> GSM71077     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0188     0.9451 0.000 0.000 0.004 0.996
#> GSM71071     4  0.0188     0.9438 0.000 0.000 0.004 0.996
#> GSM71073     4  0.0188     0.9438 0.000 0.000 0.004 0.996
#> GSM71075     4  0.0188     0.9451 0.000 0.000 0.004 0.996
#> GSM71078     4  0.4477     0.5037 0.000 0.000 0.312 0.688

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     1  0.5335      0.532 0.744 0.032 0.100 0.012 0.112
#> GSM71020     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0290      0.991 0.000 0.992 0.000 0.008 0.000
#> GSM71023     1  0.5335      0.532 0.744 0.032 0.100 0.012 0.112
#> GSM71024     5  0.4390      0.370 0.428 0.000 0.004 0.000 0.568
#> GSM71025     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71028     5  0.2890      0.368 0.000 0.000 0.160 0.004 0.836
#> GSM71030     5  0.4276      0.449 0.380 0.000 0.004 0.000 0.616
#> GSM71032     1  0.4045      0.260 0.644 0.000 0.000 0.000 0.356
#> GSM71034     1  0.4030      0.245 0.648 0.000 0.000 0.000 0.352
#> GSM71035     4  0.6539      0.470 0.000 0.000 0.200 0.432 0.368
#> GSM71038     1  0.4045      0.260 0.644 0.000 0.000 0.000 0.356
#> GSM71043     5  0.2890      0.368 0.000 0.000 0.160 0.004 0.836
#> GSM71046     1  0.4030      0.245 0.648 0.000 0.000 0.000 0.352
#> GSM71053     1  0.4045      0.260 0.644 0.000 0.000 0.000 0.356
#> GSM71061     3  0.1544      0.926 0.000 0.000 0.932 0.000 0.068
#> GSM71062     5  0.4341      0.428 0.404 0.000 0.004 0.000 0.592
#> GSM71063     5  0.2890      0.368 0.000 0.000 0.160 0.004 0.836
#> GSM71068     5  0.4437      0.308 0.464 0.000 0.004 0.000 0.532
#> GSM71029     1  0.0510      0.712 0.984 0.000 0.000 0.000 0.016
#> GSM71031     1  0.5013      0.440 0.700 0.000 0.108 0.000 0.192
#> GSM71033     1  0.4144      0.600 0.816 0.032 0.084 0.000 0.068
#> GSM71036     1  0.0510      0.712 0.984 0.000 0.000 0.000 0.016
#> GSM71042     1  0.0609      0.709 0.980 0.000 0.000 0.000 0.020
#> GSM71044     1  0.0794      0.705 0.972 0.000 0.000 0.000 0.028
#> GSM71045     1  0.0566      0.712 0.984 0.000 0.004 0.000 0.012
#> GSM71049     1  0.0510      0.712 0.984 0.000 0.000 0.000 0.016
#> GSM71055     1  0.0510      0.712 0.984 0.000 0.000 0.000 0.016
#> GSM71056     1  0.0609      0.709 0.980 0.000 0.000 0.000 0.020
#> GSM71058     1  0.4569      0.507 0.748 0.000 0.104 0.000 0.148
#> GSM71059     1  0.0609      0.709 0.980 0.000 0.000 0.000 0.020
#> GSM71064     1  0.0703      0.705 0.976 0.000 0.000 0.000 0.024
#> GSM71065     1  0.0880      0.706 0.968 0.000 0.000 0.000 0.032
#> GSM71067     1  0.4030      0.245 0.648 0.000 0.000 0.000 0.352
#> GSM71037     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM71039     4  0.6702      0.414 0.000 0.000 0.248 0.408 0.344
#> GSM71040     5  0.6551      0.371 0.304 0.000 0.228 0.000 0.468
#> GSM71041     3  0.1851      0.918 0.000 0.000 0.912 0.000 0.088
#> GSM71047     3  0.1357      0.932 0.000 0.000 0.948 0.048 0.004
#> GSM71048     5  0.4341      0.428 0.404 0.000 0.004 0.000 0.592
#> GSM71050     3  0.1851      0.918 0.000 0.000 0.912 0.000 0.088
#> GSM71051     3  0.1357      0.932 0.000 0.000 0.948 0.048 0.004
#> GSM71052     3  0.1357      0.932 0.000 0.000 0.948 0.048 0.004
#> GSM71054     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM71057     3  0.0000      0.949 0.000 0.000 1.000 0.000 0.000
#> GSM71060     3  0.0794      0.945 0.000 0.000 0.972 0.000 0.028
#> GSM71066     1  0.4030      0.245 0.648 0.000 0.000 0.000 0.352
#> GSM71070     4  0.1121      0.847 0.000 0.000 0.000 0.956 0.044
#> GSM71072     4  0.0000      0.840 0.000 0.000 0.000 1.000 0.000
#> GSM71074     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.1043      0.847 0.000 0.000 0.000 0.960 0.040
#> GSM71077     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.1121      0.847 0.000 0.000 0.000 0.956 0.044
#> GSM71071     4  0.0000      0.840 0.000 0.000 0.000 1.000 0.000
#> GSM71073     4  0.0162      0.839 0.000 0.000 0.000 0.996 0.004
#> GSM71075     4  0.1121      0.847 0.000 0.000 0.000 0.956 0.044
#> GSM71078     4  0.5066      0.685 0.000 0.000 0.084 0.676 0.240

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     1  0.6708      0.627 0.600 0.032 0.068 0.016 0.092 0.192
#> GSM71020     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.0260      0.991 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM71023     1  0.6708      0.627 0.600 0.032 0.068 0.016 0.092 0.192
#> GSM71024     5  0.3189      0.663 0.020 0.000 0.000 0.000 0.796 0.184
#> GSM71025     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.4002      0.613 0.000 0.000 0.068 0.000 0.188 0.744
#> GSM71030     5  0.3734      0.597 0.020 0.000 0.000 0.000 0.716 0.264
#> GSM71032     5  0.2703      0.727 0.172 0.000 0.000 0.000 0.824 0.004
#> GSM71034     5  0.1863      0.749 0.104 0.000 0.000 0.000 0.896 0.000
#> GSM71035     6  0.5447      0.111 0.000 0.000 0.120 0.420 0.000 0.460
#> GSM71038     5  0.2703      0.727 0.172 0.000 0.000 0.000 0.824 0.004
#> GSM71043     6  0.4002      0.613 0.000 0.000 0.068 0.000 0.188 0.744
#> GSM71046     5  0.1910      0.748 0.108 0.000 0.000 0.000 0.892 0.000
#> GSM71053     5  0.2703      0.727 0.172 0.000 0.000 0.000 0.824 0.004
#> GSM71061     3  0.2431      0.840 0.000 0.000 0.860 0.000 0.008 0.132
#> GSM71062     5  0.3592      0.627 0.020 0.000 0.000 0.000 0.740 0.240
#> GSM71063     6  0.4002      0.613 0.000 0.000 0.068 0.000 0.188 0.744
#> GSM71068     5  0.3511      0.666 0.024 0.000 0.000 0.000 0.760 0.216
#> GSM71029     1  0.3667      0.749 0.788 0.000 0.000 0.000 0.080 0.132
#> GSM71031     1  0.5892      0.659 0.640 0.000 0.080 0.004 0.148 0.128
#> GSM71033     1  0.5913      0.669 0.660 0.032 0.068 0.000 0.076 0.164
#> GSM71036     1  0.2882      0.765 0.812 0.000 0.000 0.000 0.180 0.008
#> GSM71042     1  0.3175      0.733 0.744 0.000 0.000 0.000 0.256 0.000
#> GSM71044     1  0.1261      0.769 0.952 0.000 0.000 0.000 0.024 0.024
#> GSM71045     1  0.2946      0.772 0.812 0.000 0.000 0.000 0.176 0.012
#> GSM71049     1  0.3667      0.749 0.788 0.000 0.000 0.000 0.080 0.132
#> GSM71055     1  0.2664      0.762 0.816 0.000 0.000 0.000 0.184 0.000
#> GSM71056     1  0.3221      0.728 0.736 0.000 0.000 0.000 0.264 0.000
#> GSM71058     1  0.5428      0.689 0.676 0.000 0.080 0.000 0.152 0.092
#> GSM71059     1  0.3175      0.733 0.744 0.000 0.000 0.000 0.256 0.000
#> GSM71064     1  0.2442      0.760 0.852 0.000 0.000 0.000 0.144 0.004
#> GSM71065     1  0.1657      0.773 0.928 0.000 0.000 0.000 0.056 0.016
#> GSM71067     5  0.1910      0.748 0.108 0.000 0.000 0.000 0.892 0.000
#> GSM71037     3  0.0146      0.912 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM71039     6  0.5781      0.147 0.000 0.000 0.176 0.396 0.000 0.428
#> GSM71040     5  0.5785      0.352 0.016 0.000 0.204 0.000 0.572 0.208
#> GSM71041     3  0.2629      0.858 0.000 0.000 0.868 0.000 0.040 0.092
#> GSM71047     3  0.2190      0.881 0.000 0.000 0.900 0.040 0.000 0.060
#> GSM71048     5  0.3592      0.627 0.020 0.000 0.000 0.000 0.740 0.240
#> GSM71050     3  0.2629      0.858 0.000 0.000 0.868 0.000 0.040 0.092
#> GSM71051     3  0.2190      0.881 0.000 0.000 0.900 0.040 0.000 0.060
#> GSM71052     3  0.2190      0.881 0.000 0.000 0.900 0.040 0.000 0.060
#> GSM71054     3  0.0146      0.912 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM71057     3  0.0146      0.912 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM71060     3  0.0858      0.907 0.000 0.000 0.968 0.000 0.004 0.028
#> GSM71066     5  0.1863      0.749 0.104 0.000 0.000 0.000 0.896 0.000
#> GSM71070     4  0.1007      0.899 0.000 0.000 0.000 0.956 0.000 0.044
#> GSM71072     4  0.0935      0.888 0.004 0.000 0.000 0.964 0.000 0.032
#> GSM71074     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0937      0.899 0.000 0.000 0.000 0.960 0.000 0.040
#> GSM71077     2  0.0000      0.999 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.1007      0.899 0.000 0.000 0.000 0.956 0.000 0.044
#> GSM71071     4  0.0935      0.888 0.004 0.000 0.000 0.964 0.000 0.032
#> GSM71073     4  0.1155      0.885 0.004 0.000 0.004 0.956 0.000 0.036
#> GSM71075     4  0.1007      0.899 0.000 0.000 0.000 0.956 0.000 0.044
#> GSM71078     4  0.4705      0.379 0.004 0.000 0.064 0.640 0.000 0.292

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:hclust 58    3.57e-09 2
#> MAD:hclust 52    1.37e-11 3
#> MAD:hclust 56    1.13e-15 4
#> MAD:hclust 41    2.10e-14 5
#> MAD:hclust 56    1.29e-20 6

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


MAD:kmeans

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

res = res_list["MAD", "kmeans"]
# you can also extract it by
# res = res_list["MAD:kmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.438           0.851       0.923         0.4685 0.512   0.512
#> 3 3 0.685           0.895       0.936         0.3791 0.675   0.451
#> 4 4 0.721           0.767       0.837         0.1265 0.899   0.723
#> 5 5 0.746           0.763       0.827         0.0845 0.892   0.629
#> 6 6 0.735           0.613       0.749         0.0445 0.964   0.823

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
#> GSM71019     2  0.5294      0.873 0.120 0.880
#> GSM71020     2  0.0376      0.892 0.004 0.996
#> GSM71021     2  0.0376      0.892 0.004 0.996
#> GSM71022     2  0.0376      0.892 0.004 0.996
#> GSM71023     2  0.5294      0.873 0.120 0.880
#> GSM71024     1  0.0000      0.915 1.000 0.000
#> GSM71025     2  0.0376      0.892 0.004 0.996
#> GSM71026     2  0.0376      0.892 0.004 0.996
#> GSM71027     2  0.0376      0.892 0.004 0.996
#> GSM71028     1  0.6438      0.836 0.836 0.164
#> GSM71030     1  0.0000      0.915 1.000 0.000
#> GSM71032     1  0.0000      0.915 1.000 0.000
#> GSM71034     1  0.0000      0.915 1.000 0.000
#> GSM71035     2  0.9896      0.239 0.440 0.560
#> GSM71038     1  0.0000      0.915 1.000 0.000
#> GSM71043     1  0.6438      0.836 0.836 0.164
#> GSM71046     1  0.0000      0.915 1.000 0.000
#> GSM71053     1  0.0000      0.915 1.000 0.000
#> GSM71061     1  0.6438      0.836 0.836 0.164
#> GSM71062     1  0.0376      0.913 0.996 0.004
#> GSM71063     1  0.6438      0.836 0.836 0.164
#> GSM71068     1  0.0376      0.913 0.996 0.004
#> GSM71029     1  0.9087      0.418 0.676 0.324
#> GSM71031     1  0.6343      0.836 0.840 0.160
#> GSM71033     2  0.7528      0.757 0.216 0.784
#> GSM71036     1  0.0000      0.915 1.000 0.000
#> GSM71042     1  0.0000      0.915 1.000 0.000
#> GSM71044     1  0.0000      0.915 1.000 0.000
#> GSM71045     1  0.0000      0.915 1.000 0.000
#> GSM71049     1  0.5842      0.785 0.860 0.140
#> GSM71055     1  0.0000      0.915 1.000 0.000
#> GSM71056     1  0.0000      0.915 1.000 0.000
#> GSM71058     1  0.0000      0.915 1.000 0.000
#> GSM71059     1  0.0000      0.915 1.000 0.000
#> GSM71064     1  0.0000      0.915 1.000 0.000
#> GSM71065     1  0.0000      0.915 1.000 0.000
#> GSM71067     1  0.0000      0.915 1.000 0.000
#> GSM71037     1  0.6438      0.836 0.836 0.164
#> GSM71039     2  0.9963      0.154 0.464 0.536
#> GSM71040     1  0.5519      0.858 0.872 0.128
#> GSM71041     1  0.6438      0.836 0.836 0.164
#> GSM71047     2  0.5178      0.874 0.116 0.884
#> GSM71048     1  0.0000      0.915 1.000 0.000
#> GSM71050     1  0.7219      0.790 0.800 0.200
#> GSM71051     2  0.5178      0.874 0.116 0.884
#> GSM71052     2  0.5178      0.874 0.116 0.884
#> GSM71054     1  0.6438      0.836 0.836 0.164
#> GSM71057     1  0.6438      0.836 0.836 0.164
#> GSM71060     1  0.6438      0.836 0.836 0.164
#> GSM71066     1  0.0000      0.915 1.000 0.000
#> GSM71070     2  0.5178      0.874 0.116 0.884
#> GSM71072     2  0.0000      0.891 0.000 1.000
#> GSM71074     2  0.0376      0.892 0.004 0.996
#> GSM71076     2  0.0000      0.891 0.000 1.000
#> GSM71077     2  0.0376      0.892 0.004 0.996
#> GSM71069     2  0.5178      0.874 0.116 0.884
#> GSM71071     2  0.0000      0.891 0.000 1.000
#> GSM71073     2  0.0000      0.891 0.000 1.000
#> GSM71075     2  0.5178      0.874 0.116 0.884
#> GSM71078     2  0.4431      0.880 0.092 0.908

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.5397      0.579 0.000 0.280 0.720
#> GSM71020     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71021     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71022     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71023     3  0.5397      0.579 0.000 0.280 0.720
#> GSM71024     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71025     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71026     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71027     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71028     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71030     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71032     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71034     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71035     3  0.0000      0.836 0.000 0.000 1.000
#> GSM71038     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71043     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71046     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71053     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71061     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71062     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71063     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71068     1  0.0237      0.988 0.996 0.004 0.000
#> GSM71029     1  0.1267      0.964 0.972 0.004 0.024
#> GSM71031     3  0.5785      0.596 0.332 0.000 0.668
#> GSM71033     3  0.3910      0.842 0.104 0.020 0.876
#> GSM71036     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71044     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71045     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71049     1  0.1031      0.967 0.976 0.000 0.024
#> GSM71055     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71058     1  0.3826      0.842 0.868 0.008 0.124
#> GSM71059     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71064     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71065     1  0.0424      0.987 0.992 0.008 0.000
#> GSM71067     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71037     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71039     3  0.0000      0.836 0.000 0.000 1.000
#> GSM71040     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71041     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71047     3  0.0237      0.835 0.000 0.004 0.996
#> GSM71048     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71050     3  0.2711      0.859 0.088 0.000 0.912
#> GSM71051     3  0.0237      0.835 0.000 0.004 0.996
#> GSM71052     3  0.0000      0.836 0.000 0.000 1.000
#> GSM71054     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71057     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71060     3  0.3192      0.861 0.112 0.000 0.888
#> GSM71066     1  0.0000      0.989 1.000 0.000 0.000
#> GSM71070     3  0.5098      0.627 0.000 0.248 0.752
#> GSM71072     2  0.3340      0.915 0.000 0.880 0.120
#> GSM71074     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71076     2  0.3340      0.915 0.000 0.880 0.120
#> GSM71077     2  0.0424      0.963 0.000 0.992 0.008
#> GSM71069     3  0.4399      0.697 0.000 0.188 0.812
#> GSM71071     2  0.3340      0.915 0.000 0.880 0.120
#> GSM71073     2  0.2878      0.928 0.000 0.904 0.096
#> GSM71075     3  0.5948      0.411 0.000 0.360 0.640
#> GSM71078     3  0.1964      0.810 0.000 0.056 0.944

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.6876      0.590 0.000 0.140 0.288 0.572
#> GSM71020     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71023     4  0.6968      0.577 0.000 0.140 0.308 0.552
#> GSM71024     1  0.2546      0.813 0.900 0.000 0.008 0.092
#> GSM71025     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71028     3  0.1867      0.848 0.000 0.000 0.928 0.072
#> GSM71030     1  0.2741      0.808 0.892 0.000 0.012 0.096
#> GSM71032     1  0.1635      0.842 0.948 0.000 0.008 0.044
#> GSM71034     1  0.1042      0.840 0.972 0.000 0.008 0.020
#> GSM71035     3  0.0817      0.869 0.000 0.000 0.976 0.024
#> GSM71038     1  0.1635      0.842 0.948 0.000 0.008 0.044
#> GSM71043     3  0.2773      0.829 0.028 0.000 0.900 0.072
#> GSM71046     1  0.0524      0.844 0.988 0.000 0.008 0.004
#> GSM71053     1  0.1635      0.842 0.948 0.000 0.008 0.044
#> GSM71061     3  0.0707      0.872 0.000 0.000 0.980 0.020
#> GSM71062     1  0.2676      0.810 0.896 0.000 0.012 0.092
#> GSM71063     3  0.3404      0.798 0.032 0.000 0.864 0.104
#> GSM71068     1  0.2546      0.812 0.900 0.000 0.008 0.092
#> GSM71029     1  0.4428      0.813 0.720 0.004 0.000 0.276
#> GSM71031     3  0.7746     -0.144 0.376 0.000 0.392 0.232
#> GSM71033     4  0.7103     -0.107 0.040 0.048 0.404 0.508
#> GSM71036     1  0.3764      0.841 0.784 0.000 0.000 0.216
#> GSM71042     1  0.3764      0.841 0.784 0.000 0.000 0.216
#> GSM71044     1  0.4331      0.816 0.712 0.000 0.000 0.288
#> GSM71045     1  0.3801      0.840 0.780 0.000 0.000 0.220
#> GSM71049     1  0.4250      0.816 0.724 0.000 0.000 0.276
#> GSM71055     1  0.3764      0.841 0.784 0.000 0.000 0.216
#> GSM71056     1  0.3024      0.851 0.852 0.000 0.000 0.148
#> GSM71058     1  0.7413      0.550 0.472 0.000 0.176 0.352
#> GSM71059     1  0.3726      0.842 0.788 0.000 0.000 0.212
#> GSM71064     1  0.4103      0.831 0.744 0.000 0.000 0.256
#> GSM71065     1  0.4331      0.816 0.712 0.000 0.000 0.288
#> GSM71067     1  0.0524      0.844 0.988 0.000 0.008 0.004
#> GSM71037     3  0.0336      0.871 0.000 0.000 0.992 0.008
#> GSM71039     3  0.0707      0.870 0.000 0.000 0.980 0.020
#> GSM71040     3  0.3435      0.796 0.036 0.000 0.864 0.100
#> GSM71041     3  0.0592      0.873 0.000 0.000 0.984 0.016
#> GSM71047     3  0.3400      0.679 0.000 0.000 0.820 0.180
#> GSM71048     1  0.2480      0.814 0.904 0.000 0.008 0.088
#> GSM71050     3  0.0592      0.873 0.000 0.000 0.984 0.016
#> GSM71051     3  0.3400      0.679 0.000 0.000 0.820 0.180
#> GSM71052     3  0.0592      0.867 0.000 0.000 0.984 0.016
#> GSM71054     3  0.0336      0.871 0.000 0.000 0.992 0.008
#> GSM71057     3  0.0336      0.871 0.000 0.000 0.992 0.008
#> GSM71060     3  0.0336      0.872 0.000 0.000 0.992 0.008
#> GSM71066     1  0.0524      0.844 0.988 0.000 0.008 0.004
#> GSM71070     4  0.5932      0.666 0.000 0.096 0.224 0.680
#> GSM71072     4  0.4866      0.437 0.000 0.404 0.000 0.596
#> GSM71074     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71076     4  0.4866      0.437 0.000 0.404 0.000 0.596
#> GSM71077     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71069     4  0.5627      0.645 0.000 0.068 0.240 0.692
#> GSM71071     4  0.4866      0.437 0.000 0.404 0.000 0.596
#> GSM71073     4  0.4925      0.392 0.000 0.428 0.000 0.572
#> GSM71075     4  0.5850      0.670 0.000 0.116 0.184 0.700
#> GSM71078     4  0.5060      0.438 0.000 0.004 0.412 0.584

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.7389     0.5910 0.240 0.028 0.088 0.560 0.084
#> GSM71020     2  0.0162     0.9900 0.000 0.996 0.000 0.004 0.000
#> GSM71021     2  0.0162     0.9900 0.000 0.996 0.000 0.004 0.000
#> GSM71022     2  0.0162     0.9900 0.000 0.996 0.000 0.004 0.000
#> GSM71023     4  0.7323     0.6057 0.228 0.028 0.088 0.572 0.084
#> GSM71024     5  0.1605     0.7432 0.012 0.000 0.004 0.040 0.944
#> GSM71025     2  0.0162     0.9900 0.000 0.996 0.000 0.004 0.000
#> GSM71026     2  0.0162     0.9900 0.000 0.996 0.000 0.004 0.000
#> GSM71027     2  0.0566     0.9835 0.012 0.984 0.000 0.004 0.000
#> GSM71028     3  0.4553     0.8226 0.064 0.000 0.788 0.040 0.108
#> GSM71030     5  0.1836     0.7200 0.016 0.000 0.008 0.040 0.936
#> GSM71032     5  0.3789     0.7401 0.224 0.000 0.000 0.016 0.760
#> GSM71034     5  0.2377     0.7693 0.128 0.000 0.000 0.000 0.872
#> GSM71035     3  0.3635     0.8438 0.068 0.000 0.836 0.088 0.008
#> GSM71038     5  0.3759     0.7412 0.220 0.000 0.000 0.016 0.764
#> GSM71043     3  0.4650     0.8177 0.064 0.000 0.780 0.040 0.116
#> GSM71046     5  0.2648     0.7571 0.152 0.000 0.000 0.000 0.848
#> GSM71053     5  0.3789     0.7401 0.224 0.000 0.000 0.016 0.760
#> GSM71061     3  0.2409     0.8734 0.060 0.000 0.908 0.020 0.012
#> GSM71062     5  0.1731     0.7289 0.012 0.000 0.008 0.040 0.940
#> GSM71063     3  0.6009     0.6862 0.064 0.000 0.644 0.060 0.232
#> GSM71068     5  0.1455     0.7444 0.008 0.000 0.008 0.032 0.952
#> GSM71029     1  0.3430     0.6660 0.776 0.000 0.000 0.004 0.220
#> GSM71031     1  0.6398     0.4554 0.592 0.000 0.108 0.040 0.260
#> GSM71033     1  0.5141     0.4672 0.764 0.020 0.104 0.028 0.084
#> GSM71036     1  0.4227     0.5649 0.580 0.000 0.000 0.000 0.420
#> GSM71042     1  0.4242     0.5509 0.572 0.000 0.000 0.000 0.428
#> GSM71044     1  0.2843     0.6540 0.848 0.000 0.000 0.008 0.144
#> GSM71045     1  0.4171     0.5722 0.604 0.000 0.000 0.000 0.396
#> GSM71049     1  0.3430     0.6660 0.776 0.000 0.000 0.004 0.220
#> GSM71055     1  0.4201     0.5803 0.592 0.000 0.000 0.000 0.408
#> GSM71056     5  0.4150     0.0772 0.388 0.000 0.000 0.000 0.612
#> GSM71058     1  0.4708     0.5297 0.732 0.000 0.060 0.008 0.200
#> GSM71059     1  0.4256     0.5337 0.564 0.000 0.000 0.000 0.436
#> GSM71064     1  0.4387     0.5530 0.640 0.000 0.000 0.012 0.348
#> GSM71065     1  0.2886     0.6530 0.844 0.000 0.000 0.008 0.148
#> GSM71067     5  0.2719     0.7639 0.144 0.000 0.000 0.004 0.852
#> GSM71037     3  0.1124     0.8770 0.036 0.000 0.960 0.000 0.004
#> GSM71039     3  0.2193     0.8751 0.060 0.000 0.912 0.028 0.000
#> GSM71040     3  0.4552     0.7751 0.024 0.000 0.760 0.040 0.176
#> GSM71041     3  0.0865     0.8832 0.024 0.000 0.972 0.000 0.004
#> GSM71047     3  0.3985     0.7730 0.120 0.004 0.804 0.072 0.000
#> GSM71048     5  0.1329     0.7499 0.008 0.000 0.004 0.032 0.956
#> GSM71050     3  0.1356     0.8831 0.028 0.000 0.956 0.012 0.004
#> GSM71051     3  0.3985     0.7730 0.120 0.004 0.804 0.072 0.000
#> GSM71052     3  0.1444     0.8724 0.040 0.000 0.948 0.012 0.000
#> GSM71054     3  0.1285     0.8762 0.036 0.000 0.956 0.004 0.004
#> GSM71057     3  0.1285     0.8762 0.036 0.000 0.956 0.004 0.004
#> GSM71060     3  0.0162     0.8817 0.000 0.000 0.996 0.000 0.004
#> GSM71066     5  0.2690     0.7551 0.156 0.000 0.000 0.000 0.844
#> GSM71070     4  0.1997     0.8572 0.012 0.008 0.024 0.936 0.020
#> GSM71072     4  0.2077     0.8501 0.008 0.084 0.000 0.908 0.000
#> GSM71074     2  0.0955     0.9783 0.028 0.968 0.004 0.000 0.000
#> GSM71076     4  0.1952     0.8504 0.004 0.084 0.000 0.912 0.000
#> GSM71077     2  0.0955     0.9783 0.028 0.968 0.004 0.000 0.000
#> GSM71069     4  0.2016     0.8583 0.012 0.012 0.020 0.936 0.020
#> GSM71071     4  0.2077     0.8501 0.008 0.084 0.000 0.908 0.000
#> GSM71073     4  0.2642     0.8420 0.024 0.084 0.004 0.888 0.000
#> GSM71075     4  0.2023     0.8585 0.012 0.016 0.016 0.936 0.020
#> GSM71078     4  0.1830     0.8331 0.008 0.000 0.068 0.924 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
#> GSM71019     4  0.7868     0.3418 0.228 0.012 0.020 0.416 0.116 0.208
#> GSM71020     2  0.0146     0.9620 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0146     0.9629 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71022     2  0.0146     0.9629 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71023     4  0.7722     0.3940 0.192 0.012 0.020 0.452 0.116 0.208
#> GSM71024     5  0.2686     0.7109 0.012 0.000 0.000 0.032 0.876 0.080
#> GSM71025     2  0.0146     0.9629 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71026     2  0.0146     0.9629 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71027     2  0.1926     0.9423 0.020 0.912 0.000 0.000 0.000 0.068
#> GSM71028     6  0.5668     0.8050 0.000 0.000 0.428 0.012 0.108 0.452
#> GSM71030     5  0.2527     0.7085 0.004 0.000 0.000 0.032 0.880 0.084
#> GSM71032     5  0.4828     0.6436 0.156 0.000 0.000 0.000 0.668 0.176
#> GSM71034     5  0.2595     0.7073 0.160 0.000 0.000 0.000 0.836 0.004
#> GSM71035     3  0.4873    -0.3578 0.000 0.000 0.508 0.048 0.004 0.440
#> GSM71038     5  0.4762     0.6466 0.148 0.000 0.000 0.000 0.676 0.176
#> GSM71043     6  0.5695     0.8217 0.000 0.000 0.416 0.012 0.112 0.460
#> GSM71046     5  0.2697     0.6892 0.188 0.000 0.000 0.000 0.812 0.000
#> GSM71053     5  0.4795     0.6456 0.152 0.000 0.000 0.000 0.672 0.176
#> GSM71061     3  0.4026    -0.0768 0.000 0.000 0.612 0.000 0.012 0.376
#> GSM71062     5  0.2277     0.7142 0.000 0.000 0.000 0.032 0.892 0.076
#> GSM71063     6  0.6307     0.7148 0.000 0.000 0.316 0.028 0.184 0.472
#> GSM71068     5  0.2176     0.7160 0.000 0.000 0.000 0.024 0.896 0.080
#> GSM71029     1  0.2956     0.6461 0.848 0.000 0.000 0.000 0.064 0.088
#> GSM71031     1  0.6708     0.4249 0.536 0.000 0.040 0.028 0.220 0.176
#> GSM71033     1  0.6207     0.4391 0.576 0.000 0.072 0.004 0.108 0.240
#> GSM71036     1  0.3489     0.5991 0.708 0.000 0.000 0.000 0.288 0.004
#> GSM71042     1  0.3531     0.5682 0.672 0.000 0.000 0.000 0.328 0.000
#> GSM71044     1  0.3041     0.6384 0.832 0.000 0.000 0.000 0.040 0.128
#> GSM71045     1  0.3541     0.6172 0.728 0.000 0.000 0.000 0.260 0.012
#> GSM71049     1  0.2956     0.6461 0.848 0.000 0.000 0.000 0.064 0.088
#> GSM71055     1  0.3175     0.6246 0.744 0.000 0.000 0.000 0.256 0.000
#> GSM71056     1  0.3851     0.2816 0.540 0.000 0.000 0.000 0.460 0.000
#> GSM71058     1  0.5449     0.5313 0.656 0.000 0.040 0.000 0.168 0.136
#> GSM71059     1  0.3592     0.5497 0.656 0.000 0.000 0.000 0.344 0.000
#> GSM71064     1  0.5229     0.5500 0.604 0.000 0.000 0.000 0.240 0.156
#> GSM71065     1  0.3041     0.6388 0.832 0.000 0.000 0.000 0.040 0.128
#> GSM71067     5  0.2597     0.6969 0.176 0.000 0.000 0.000 0.824 0.000
#> GSM71037     3  0.0000     0.5681 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     3  0.3728     0.1103 0.000 0.000 0.652 0.000 0.004 0.344
#> GSM71040     3  0.6648    -0.5491 0.000 0.000 0.400 0.032 0.296 0.272
#> GSM71041     3  0.3259     0.3968 0.000 0.000 0.772 0.000 0.012 0.216
#> GSM71047     3  0.3238     0.4629 0.036 0.000 0.832 0.012 0.000 0.120
#> GSM71048     5  0.2456     0.7162 0.008 0.000 0.000 0.028 0.888 0.076
#> GSM71050     3  0.3376     0.3826 0.000 0.000 0.764 0.000 0.016 0.220
#> GSM71051     3  0.3238     0.4629 0.036 0.000 0.832 0.012 0.000 0.120
#> GSM71052     3  0.1007     0.5506 0.000 0.000 0.956 0.000 0.000 0.044
#> GSM71054     3  0.0000     0.5681 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0000     0.5681 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71060     3  0.2703     0.4600 0.000 0.000 0.824 0.000 0.004 0.172
#> GSM71066     5  0.2697     0.6892 0.188 0.000 0.000 0.000 0.812 0.000
#> GSM71070     4  0.1003     0.8194 0.004 0.000 0.000 0.964 0.004 0.028
#> GSM71072     4  0.2420     0.8155 0.004 0.032 0.000 0.888 0.000 0.076
#> GSM71074     2  0.2383     0.9306 0.024 0.880 0.000 0.000 0.000 0.096
#> GSM71076     4  0.0790     0.8205 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM71077     2  0.2383     0.9306 0.024 0.880 0.000 0.000 0.000 0.096
#> GSM71069     4  0.1003     0.8194 0.004 0.000 0.000 0.964 0.004 0.028
#> GSM71071     4  0.2420     0.8155 0.004 0.032 0.000 0.888 0.000 0.076
#> GSM71073     4  0.3150     0.7991 0.012 0.036 0.000 0.840 0.000 0.112
#> GSM71075     4  0.1003     0.8194 0.004 0.000 0.000 0.964 0.004 0.028
#> GSM71078     4  0.2630     0.8021 0.004 0.000 0.032 0.872 0.000 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:kmeans 57    1.61e-07 2
#> MAD:kmeans 59    2.18e-08 3
#> MAD:kmeans 53    1.24e-12 4
#> MAD:kmeans 57    2.30e-19 5
#> MAD:kmeans 46    1.13e-17 6

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


MAD:skmeans*

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

res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.645           0.869       0.938         0.4972 0.501   0.501
#> 3 3 0.949           0.930       0.973         0.3423 0.734   0.517
#> 4 4 0.835           0.857       0.914         0.1003 0.916   0.758
#> 5 5 0.793           0.768       0.862         0.0891 0.891   0.622
#> 6 6 0.785           0.790       0.864         0.0395 0.950   0.754

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
#> GSM71019     2   0.000     0.9452 0.000 1.000
#> GSM71020     2   0.000     0.9452 0.000 1.000
#> GSM71021     2   0.000     0.9452 0.000 1.000
#> GSM71022     2   0.000     0.9452 0.000 1.000
#> GSM71023     2   0.000     0.9452 0.000 1.000
#> GSM71024     1   0.000     0.9150 1.000 0.000
#> GSM71025     2   0.000     0.9452 0.000 1.000
#> GSM71026     2   0.000     0.9452 0.000 1.000
#> GSM71027     2   0.000     0.9452 0.000 1.000
#> GSM71028     1   0.722     0.7985 0.800 0.200
#> GSM71030     1   0.000     0.9150 1.000 0.000
#> GSM71032     1   0.000     0.9150 1.000 0.000
#> GSM71034     1   0.000     0.9150 1.000 0.000
#> GSM71035     2   0.722     0.7065 0.200 0.800
#> GSM71038     1   0.000     0.9150 1.000 0.000
#> GSM71043     1   0.722     0.7985 0.800 0.200
#> GSM71046     1   0.000     0.9150 1.000 0.000
#> GSM71053     1   0.000     0.9150 1.000 0.000
#> GSM71061     1   0.722     0.7985 0.800 0.200
#> GSM71062     1   0.000     0.9150 1.000 0.000
#> GSM71063     1   0.722     0.7985 0.800 0.200
#> GSM71068     1   0.000     0.9150 1.000 0.000
#> GSM71029     2   0.939     0.4697 0.356 0.644
#> GSM71031     1   0.416     0.8742 0.916 0.084
#> GSM71033     2   0.000     0.9452 0.000 1.000
#> GSM71036     1   0.000     0.9150 1.000 0.000
#> GSM71042     1   0.000     0.9150 1.000 0.000
#> GSM71044     1   0.722     0.7082 0.800 0.200
#> GSM71045     1   0.000     0.9150 1.000 0.000
#> GSM71049     2   1.000     0.0995 0.488 0.512
#> GSM71055     1   0.000     0.9150 1.000 0.000
#> GSM71056     1   0.000     0.9150 1.000 0.000
#> GSM71058     1   0.000     0.9150 1.000 0.000
#> GSM71059     1   0.000     0.9150 1.000 0.000
#> GSM71064     1   0.000     0.9150 1.000 0.000
#> GSM71065     1   0.000     0.9150 1.000 0.000
#> GSM71067     1   0.000     0.9150 1.000 0.000
#> GSM71037     1   0.722     0.7985 0.800 0.200
#> GSM71039     2   0.722     0.7065 0.200 0.800
#> GSM71040     1   0.000     0.9150 1.000 0.000
#> GSM71041     1   0.722     0.7985 0.800 0.200
#> GSM71047     2   0.000     0.9452 0.000 1.000
#> GSM71048     1   0.000     0.9150 1.000 0.000
#> GSM71050     1   0.966     0.4504 0.608 0.392
#> GSM71051     2   0.000     0.9452 0.000 1.000
#> GSM71052     2   0.000     0.9452 0.000 1.000
#> GSM71054     1   0.722     0.7985 0.800 0.200
#> GSM71057     1   0.722     0.7985 0.800 0.200
#> GSM71060     1   0.722     0.7985 0.800 0.200
#> GSM71066     1   0.000     0.9150 1.000 0.000
#> GSM71070     2   0.000     0.9452 0.000 1.000
#> GSM71072     2   0.000     0.9452 0.000 1.000
#> GSM71074     2   0.000     0.9452 0.000 1.000
#> GSM71076     2   0.000     0.9452 0.000 1.000
#> GSM71077     2   0.000     0.9452 0.000 1.000
#> GSM71069     2   0.000     0.9452 0.000 1.000
#> GSM71071     2   0.000     0.9452 0.000 1.000
#> GSM71073     2   0.000     0.9452 0.000 1.000
#> GSM71075     2   0.000     0.9452 0.000 1.000
#> GSM71078     2   0.000     0.9452 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71020     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71021     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71022     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71023     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71024     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71025     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71026     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71027     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71028     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71030     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71032     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71035     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71038     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71043     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71046     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71061     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71062     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71063     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71068     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71029     1  0.6252      0.200 0.556 0.444 0.000
#> GSM71031     1  0.4931      0.801 0.828 0.140 0.032
#> GSM71033     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71036     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71044     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71045     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71049     1  0.3686      0.824 0.860 0.140 0.000
#> GSM71055     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71058     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71059     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71065     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71067     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71037     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71039     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71040     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71041     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71047     2  0.6215      0.297 0.000 0.572 0.428
#> GSM71048     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71050     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71051     2  0.6215      0.297 0.000 0.572 0.428
#> GSM71052     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71054     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71057     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71060     3  0.0000      0.999 0.000 0.000 1.000
#> GSM71066     1  0.0000      0.967 1.000 0.000 0.000
#> GSM71070     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71072     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71074     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71076     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71077     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71069     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71071     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71073     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71075     2  0.0000      0.954 0.000 1.000 0.000
#> GSM71078     3  0.0747      0.983 0.000 0.016 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4855     0.0648 0.000 0.600 0.000 0.400
#> GSM71024     1  0.0592     0.9078 0.984 0.000 0.000 0.016
#> GSM71025     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0707     0.9650 0.000 0.000 0.980 0.020
#> GSM71030     1  0.0707     0.9066 0.980 0.000 0.000 0.020
#> GSM71032     1  0.0188     0.9110 0.996 0.000 0.000 0.004
#> GSM71034     1  0.0469     0.9086 0.988 0.000 0.000 0.012
#> GSM71035     3  0.2081     0.9056 0.000 0.000 0.916 0.084
#> GSM71038     1  0.0188     0.9110 0.996 0.000 0.000 0.004
#> GSM71043     3  0.0707     0.9650 0.000 0.000 0.980 0.020
#> GSM71046     1  0.0000     0.9109 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0188     0.9110 0.996 0.000 0.000 0.004
#> GSM71061     3  0.0000     0.9719 0.000 0.000 1.000 0.000
#> GSM71062     1  0.0707     0.9066 0.980 0.000 0.000 0.020
#> GSM71063     3  0.3080     0.8878 0.024 0.000 0.880 0.096
#> GSM71068     1  0.0707     0.9066 0.980 0.000 0.000 0.020
#> GSM71029     2  0.5775     0.5630 0.212 0.696 0.000 0.092
#> GSM71031     1  0.5636     0.6500 0.700 0.004 0.060 0.236
#> GSM71033     2  0.1867     0.8009 0.000 0.928 0.000 0.072
#> GSM71036     1  0.2216     0.9013 0.908 0.000 0.000 0.092
#> GSM71042     1  0.2216     0.9013 0.908 0.000 0.000 0.092
#> GSM71044     1  0.6708     0.3122 0.528 0.376 0.000 0.096
#> GSM71045     1  0.2216     0.9013 0.908 0.000 0.000 0.092
#> GSM71049     1  0.6668     0.3047 0.528 0.380 0.000 0.092
#> GSM71055     1  0.2216     0.9013 0.908 0.000 0.000 0.092
#> GSM71056     1  0.1716     0.9058 0.936 0.000 0.000 0.064
#> GSM71058     1  0.2408     0.9004 0.896 0.000 0.000 0.104
#> GSM71059     1  0.2216     0.9013 0.908 0.000 0.000 0.092
#> GSM71064     1  0.2281     0.9006 0.904 0.000 0.000 0.096
#> GSM71065     1  0.2281     0.9006 0.904 0.000 0.000 0.096
#> GSM71067     1  0.0000     0.9109 1.000 0.000 0.000 0.000
#> GSM71037     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71039     3  0.0188     0.9708 0.000 0.000 0.996 0.004
#> GSM71040     3  0.2522     0.8991 0.076 0.000 0.908 0.016
#> GSM71041     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71047     2  0.4781     0.5190 0.000 0.660 0.336 0.004
#> GSM71048     1  0.0707     0.9066 0.980 0.000 0.000 0.020
#> GSM71050     3  0.0000     0.9719 0.000 0.000 1.000 0.000
#> GSM71051     2  0.5403     0.4805 0.000 0.628 0.348 0.024
#> GSM71052     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71054     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71057     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71060     3  0.0188     0.9722 0.000 0.000 0.996 0.004
#> GSM71066     1  0.0000     0.9109 1.000 0.000 0.000 0.000
#> GSM71070     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71072     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71074     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71076     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71077     2  0.0000     0.8538 0.000 1.000 0.000 0.000
#> GSM71069     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71071     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71073     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71075     4  0.2647     0.9757 0.000 0.120 0.000 0.880
#> GSM71078     4  0.2773     0.8350 0.000 0.004 0.116 0.880

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71020     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71023     2  0.3636      0.560 0.000 0.728 0.000 0.272 0.000
#> GSM71024     5  0.3039      0.693 0.192 0.000 0.000 0.000 0.808
#> GSM71025     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4040      0.729 0.000 0.000 0.712 0.012 0.276
#> GSM71030     5  0.2516      0.688 0.140 0.000 0.000 0.000 0.860
#> GSM71032     5  0.4227      0.615 0.420 0.000 0.000 0.000 0.580
#> GSM71034     5  0.3661      0.682 0.276 0.000 0.000 0.000 0.724
#> GSM71035     3  0.4402      0.722 0.000 0.000 0.740 0.204 0.056
#> GSM71038     5  0.4227      0.615 0.420 0.000 0.000 0.000 0.580
#> GSM71043     3  0.3992      0.737 0.000 0.000 0.720 0.012 0.268
#> GSM71046     5  0.4219      0.614 0.416 0.000 0.000 0.000 0.584
#> GSM71053     5  0.4227      0.615 0.420 0.000 0.000 0.000 0.580
#> GSM71061     3  0.1740      0.868 0.000 0.000 0.932 0.012 0.056
#> GSM71062     5  0.2179      0.678 0.112 0.000 0.000 0.000 0.888
#> GSM71063     3  0.5010      0.552 0.000 0.000 0.572 0.036 0.392
#> GSM71068     5  0.2074      0.677 0.104 0.000 0.000 0.000 0.896
#> GSM71029     1  0.4003      0.550 0.704 0.288 0.000 0.000 0.008
#> GSM71031     5  0.5557      0.242 0.308 0.000 0.048 0.024 0.620
#> GSM71033     2  0.1121      0.860 0.044 0.956 0.000 0.000 0.000
#> GSM71036     1  0.1043      0.888 0.960 0.000 0.000 0.000 0.040
#> GSM71042     1  0.0963      0.890 0.964 0.000 0.000 0.000 0.036
#> GSM71044     1  0.1251      0.862 0.956 0.036 0.000 0.000 0.008
#> GSM71045     1  0.1121      0.885 0.956 0.000 0.000 0.000 0.044
#> GSM71049     1  0.1809      0.848 0.928 0.060 0.000 0.000 0.012
#> GSM71055     1  0.0609      0.891 0.980 0.000 0.000 0.000 0.020
#> GSM71056     1  0.1792      0.838 0.916 0.000 0.000 0.000 0.084
#> GSM71058     1  0.2732      0.714 0.840 0.000 0.000 0.000 0.160
#> GSM71059     1  0.1043      0.888 0.960 0.000 0.000 0.000 0.040
#> GSM71064     1  0.0609      0.887 0.980 0.000 0.000 0.000 0.020
#> GSM71065     1  0.0290      0.884 0.992 0.000 0.000 0.000 0.008
#> GSM71067     5  0.4182      0.630 0.400 0.000 0.000 0.000 0.600
#> GSM71037     3  0.1430      0.857 0.000 0.000 0.944 0.004 0.052
#> GSM71039     3  0.1670      0.869 0.000 0.000 0.936 0.012 0.052
#> GSM71040     5  0.4307     -0.432 0.000 0.000 0.496 0.000 0.504
#> GSM71041     3  0.0566      0.871 0.000 0.000 0.984 0.004 0.012
#> GSM71047     2  0.5455      0.301 0.000 0.528 0.416 0.004 0.052
#> GSM71048     5  0.2230      0.680 0.116 0.000 0.000 0.000 0.884
#> GSM71050     3  0.1557      0.869 0.000 0.000 0.940 0.008 0.052
#> GSM71051     2  0.5577      0.276 0.000 0.516 0.424 0.008 0.052
#> GSM71052     3  0.1430      0.857 0.000 0.000 0.944 0.004 0.052
#> GSM71054     3  0.1430      0.857 0.000 0.000 0.944 0.004 0.052
#> GSM71057     3  0.1430      0.857 0.000 0.000 0.944 0.004 0.052
#> GSM71060     3  0.0162      0.871 0.000 0.000 0.996 0.000 0.004
#> GSM71066     5  0.4201      0.623 0.408 0.000 0.000 0.000 0.592
#> GSM71070     4  0.0510      0.993 0.000 0.016 0.000 0.984 0.000
#> GSM71072     4  0.0510      0.993 0.000 0.016 0.000 0.984 0.000
#> GSM71074     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.0510      0.993 0.000 0.016 0.000 0.984 0.000
#> GSM71077     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.0404      0.990 0.000 0.012 0.000 0.988 0.000
#> GSM71071     4  0.0510      0.993 0.000 0.016 0.000 0.984 0.000
#> GSM71073     4  0.1043      0.971 0.000 0.040 0.000 0.960 0.000
#> GSM71075     4  0.0510      0.993 0.000 0.016 0.000 0.984 0.000
#> GSM71078     4  0.0162      0.979 0.000 0.000 0.004 0.996 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
#> GSM71019     2  0.0862     0.9414 0.000 0.972 0.016 0.000 0.008 0.004
#> GSM71020     2  0.0000     0.9562 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9562 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.0000     0.9562 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71023     2  0.3098     0.8119 0.000 0.832 0.016 0.140 0.008 0.004
#> GSM71024     5  0.1194     0.7620 0.032 0.000 0.004 0.000 0.956 0.008
#> GSM71025     2  0.0000     0.9562 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9562 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0146     0.9555 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71028     6  0.1007     0.7736 0.000 0.000 0.000 0.000 0.044 0.956
#> GSM71030     5  0.1624     0.7557 0.020 0.000 0.004 0.000 0.936 0.040
#> GSM71032     5  0.4131     0.6733 0.272 0.000 0.040 0.000 0.688 0.000
#> GSM71034     5  0.2048     0.7594 0.120 0.000 0.000 0.000 0.880 0.000
#> GSM71035     6  0.1951     0.7527 0.000 0.000 0.016 0.076 0.000 0.908
#> GSM71038     5  0.3999     0.6818 0.272 0.000 0.032 0.000 0.696 0.000
#> GSM71043     6  0.1007     0.7736 0.000 0.000 0.000 0.000 0.044 0.956
#> GSM71046     5  0.3151     0.7041 0.252 0.000 0.000 0.000 0.748 0.000
#> GSM71053     5  0.4089     0.6807 0.264 0.000 0.040 0.000 0.696 0.000
#> GSM71061     6  0.1910     0.7682 0.000 0.000 0.108 0.000 0.000 0.892
#> GSM71062     5  0.1219     0.7474 0.004 0.000 0.000 0.000 0.948 0.048
#> GSM71063     6  0.1858     0.7498 0.000 0.000 0.000 0.012 0.076 0.912
#> GSM71068     5  0.1528     0.7482 0.016 0.000 0.000 0.000 0.936 0.048
#> GSM71029     1  0.5428     0.6146 0.684 0.192 0.064 0.004 0.036 0.020
#> GSM71031     5  0.6120    -0.0698 0.204 0.000 0.008 0.000 0.404 0.384
#> GSM71033     2  0.4706     0.7440 0.108 0.756 0.096 0.004 0.016 0.020
#> GSM71036     1  0.2520     0.8158 0.844 0.000 0.004 0.000 0.152 0.000
#> GSM71042     1  0.2260     0.8195 0.860 0.000 0.000 0.000 0.140 0.000
#> GSM71044     1  0.2840     0.7661 0.868 0.000 0.092 0.004 0.016 0.020
#> GSM71045     1  0.2416     0.8104 0.844 0.000 0.000 0.000 0.156 0.000
#> GSM71049     1  0.4087     0.7563 0.816 0.056 0.064 0.004 0.040 0.020
#> GSM71055     1  0.1908     0.8241 0.900 0.000 0.004 0.000 0.096 0.000
#> GSM71056     1  0.3314     0.7220 0.764 0.000 0.012 0.000 0.224 0.000
#> GSM71058     1  0.4055     0.7341 0.780 0.000 0.064 0.000 0.132 0.024
#> GSM71059     1  0.2340     0.8163 0.852 0.000 0.000 0.000 0.148 0.000
#> GSM71064     1  0.2660     0.8050 0.868 0.000 0.048 0.000 0.084 0.000
#> GSM71065     1  0.2362     0.7787 0.892 0.000 0.080 0.000 0.012 0.016
#> GSM71067     5  0.2912     0.7303 0.216 0.000 0.000 0.000 0.784 0.000
#> GSM71037     3  0.2416     0.8957 0.000 0.000 0.844 0.000 0.000 0.156
#> GSM71039     6  0.1863     0.7689 0.000 0.000 0.104 0.000 0.000 0.896
#> GSM71040     6  0.3923     0.4299 0.000 0.000 0.008 0.000 0.372 0.620
#> GSM71041     6  0.3330     0.5848 0.000 0.000 0.284 0.000 0.000 0.716
#> GSM71047     3  0.2942     0.8048 0.000 0.132 0.836 0.000 0.000 0.032
#> GSM71048     5  0.1036     0.7569 0.008 0.000 0.004 0.000 0.964 0.024
#> GSM71050     6  0.2416     0.7410 0.000 0.000 0.156 0.000 0.000 0.844
#> GSM71051     3  0.2798     0.8244 0.000 0.112 0.852 0.000 0.000 0.036
#> GSM71052     3  0.2340     0.8974 0.000 0.000 0.852 0.000 0.000 0.148
#> GSM71054     3  0.2491     0.8878 0.000 0.000 0.836 0.000 0.000 0.164
#> GSM71057     3  0.2378     0.8976 0.000 0.000 0.848 0.000 0.000 0.152
#> GSM71060     6  0.3864     0.0442 0.000 0.000 0.480 0.000 0.000 0.520
#> GSM71066     5  0.3126     0.7080 0.248 0.000 0.000 0.000 0.752 0.000
#> GSM71070     4  0.0291     0.9818 0.000 0.004 0.004 0.992 0.000 0.000
#> GSM71072     4  0.0405     0.9823 0.000 0.004 0.008 0.988 0.000 0.000
#> GSM71074     2  0.0146     0.9555 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71076     4  0.0146     0.9832 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM71077     2  0.0146     0.9555 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM71069     4  0.0146     0.9832 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM71071     4  0.0405     0.9823 0.000 0.004 0.008 0.988 0.000 0.000
#> GSM71073     4  0.1812     0.9093 0.000 0.080 0.008 0.912 0.000 0.000
#> GSM71075     4  0.0146     0.9832 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM71078     4  0.0520     0.9775 0.000 0.000 0.008 0.984 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:skmeans 57    1.62e-06 2
#> MAD:skmeans 57    6.19e-11 3
#> MAD:skmeans 56    3.37e-14 4
#> MAD:skmeans 56    2.32e-20 5
#> MAD:skmeans 57    2.48e-21 6

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


MAD:pam

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.398           0.775       0.870          0.443 0.573   0.573
#> 3 3 0.528           0.667       0.822          0.397 0.723   0.555
#> 4 4 0.738           0.808       0.896          0.160 0.715   0.405
#> 5 5 0.744           0.764       0.881          0.110 0.858   0.534
#> 6 6 0.779           0.766       0.870          0.035 0.923   0.658

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
#> GSM71019     2   0.000     0.9311 0.000 1.000
#> GSM71020     2   0.000     0.9311 0.000 1.000
#> GSM71021     2   0.000     0.9311 0.000 1.000
#> GSM71022     2   0.000     0.9311 0.000 1.000
#> GSM71023     2   0.141     0.9151 0.020 0.980
#> GSM71024     1   0.722     0.7996 0.800 0.200
#> GSM71025     2   0.000     0.9311 0.000 1.000
#> GSM71026     2   0.000     0.9311 0.000 1.000
#> GSM71027     2   0.000     0.9311 0.000 1.000
#> GSM71028     1   0.722     0.7996 0.800 0.200
#> GSM71030     1   0.722     0.7996 0.800 0.200
#> GSM71032     1   0.000     0.8009 1.000 0.000
#> GSM71034     1   0.000     0.8009 1.000 0.000
#> GSM71035     1   0.952     0.6377 0.628 0.372
#> GSM71038     1   0.000     0.8009 1.000 0.000
#> GSM71043     1   0.722     0.7996 0.800 0.200
#> GSM71046     1   0.000     0.8009 1.000 0.000
#> GSM71053     1   0.000     0.8009 1.000 0.000
#> GSM71061     1   0.722     0.7996 0.800 0.200
#> GSM71062     1   0.722     0.7996 0.800 0.200
#> GSM71063     1   0.722     0.7996 0.800 0.200
#> GSM71068     1   0.000     0.8009 1.000 0.000
#> GSM71029     2   0.839     0.6314 0.268 0.732
#> GSM71031     1   0.722     0.7996 0.800 0.200
#> GSM71033     1   0.973     0.5890 0.596 0.404
#> GSM71036     1   0.000     0.8009 1.000 0.000
#> GSM71042     1   0.000     0.8009 1.000 0.000
#> GSM71044     1   0.311     0.7798 0.944 0.056
#> GSM71045     1   0.000     0.8009 1.000 0.000
#> GSM71049     1   0.990     0.0612 0.560 0.440
#> GSM71055     1   0.000     0.8009 1.000 0.000
#> GSM71056     1   0.000     0.8009 1.000 0.000
#> GSM71058     1   0.722     0.7996 0.800 0.200
#> GSM71059     1   0.000     0.8009 1.000 0.000
#> GSM71064     1   0.000     0.8009 1.000 0.000
#> GSM71065     1   0.000     0.8009 1.000 0.000
#> GSM71067     1   0.000     0.8009 1.000 0.000
#> GSM71037     1   0.722     0.7996 0.800 0.200
#> GSM71039     1   0.946     0.6475 0.636 0.364
#> GSM71040     1   0.722     0.7996 0.800 0.200
#> GSM71041     1   0.886     0.7166 0.696 0.304
#> GSM71047     1   0.983     0.5562 0.576 0.424
#> GSM71048     1   0.000     0.8009 1.000 0.000
#> GSM71050     1   0.946     0.6475 0.636 0.364
#> GSM71051     1   0.985     0.5483 0.572 0.428
#> GSM71052     1   0.955     0.6334 0.624 0.376
#> GSM71054     1   0.722     0.7996 0.800 0.200
#> GSM71057     1   0.891     0.7125 0.692 0.308
#> GSM71060     1   0.753     0.7900 0.784 0.216
#> GSM71066     1   0.000     0.8009 1.000 0.000
#> GSM71070     2   0.767     0.6039 0.224 0.776
#> GSM71072     2   0.000     0.9311 0.000 1.000
#> GSM71074     2   0.000     0.9311 0.000 1.000
#> GSM71076     2   0.000     0.9311 0.000 1.000
#> GSM71077     2   0.000     0.9311 0.000 1.000
#> GSM71069     2   0.921     0.2614 0.336 0.664
#> GSM71071     2   0.000     0.9311 0.000 1.000
#> GSM71073     2   0.000     0.9311 0.000 1.000
#> GSM71075     2   0.327     0.8751 0.060 0.940
#> GSM71078     1   0.985     0.5483 0.572 0.428

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3   0.624      0.240 0.000 0.440 0.560
#> GSM71020     2   0.000      0.988 0.000 1.000 0.000
#> GSM71021     2   0.000      0.988 0.000 1.000 0.000
#> GSM71022     2   0.141      0.958 0.000 0.964 0.036
#> GSM71023     3   0.621      0.578 0.036 0.228 0.736
#> GSM71024     1   0.543      0.718 0.716 0.000 0.284
#> GSM71025     2   0.000      0.988 0.000 1.000 0.000
#> GSM71026     2   0.000      0.988 0.000 1.000 0.000
#> GSM71027     2   0.000      0.988 0.000 1.000 0.000
#> GSM71028     1   0.626      0.582 0.552 0.000 0.448
#> GSM71030     1   0.543      0.718 0.716 0.000 0.284
#> GSM71032     1   0.196      0.747 0.944 0.000 0.056
#> GSM71034     1   0.000      0.740 1.000 0.000 0.000
#> GSM71035     3   0.129      0.691 0.032 0.000 0.968
#> GSM71038     1   0.175      0.746 0.952 0.000 0.048
#> GSM71043     1   0.626      0.582 0.552 0.000 0.448
#> GSM71046     1   0.000      0.740 1.000 0.000 0.000
#> GSM71053     1   0.207      0.747 0.940 0.000 0.060
#> GSM71061     1   0.626      0.582 0.552 0.000 0.448
#> GSM71062     1   0.553      0.714 0.704 0.000 0.296
#> GSM71063     1   0.613      0.631 0.600 0.000 0.400
#> GSM71068     1   0.553      0.714 0.704 0.000 0.296
#> GSM71029     3   0.651      0.344 0.472 0.004 0.524
#> GSM71031     1   0.565      0.704 0.688 0.000 0.312
#> GSM71033     3   0.412      0.697 0.040 0.084 0.876
#> GSM71036     1   0.000      0.740 1.000 0.000 0.000
#> GSM71042     1   0.000      0.740 1.000 0.000 0.000
#> GSM71044     1   0.510      0.362 0.752 0.000 0.248
#> GSM71045     1   0.000      0.740 1.000 0.000 0.000
#> GSM71049     3   0.630      0.345 0.472 0.000 0.528
#> GSM71055     1   0.000      0.740 1.000 0.000 0.000
#> GSM71056     1   0.000      0.740 1.000 0.000 0.000
#> GSM71058     1   0.556      0.711 0.700 0.000 0.300
#> GSM71059     1   0.000      0.740 1.000 0.000 0.000
#> GSM71064     1   0.000      0.740 1.000 0.000 0.000
#> GSM71065     1   0.000      0.740 1.000 0.000 0.000
#> GSM71067     1   0.103      0.744 0.976 0.000 0.024
#> GSM71037     1   0.626      0.582 0.552 0.000 0.448
#> GSM71039     3   0.186      0.673 0.052 0.000 0.948
#> GSM71040     1   0.565      0.704 0.688 0.000 0.312
#> GSM71041     1   0.630      0.518 0.516 0.000 0.484
#> GSM71047     3   0.148      0.704 0.020 0.012 0.968
#> GSM71048     1   0.543      0.718 0.716 0.000 0.284
#> GSM71050     3   0.236      0.651 0.072 0.000 0.928
#> GSM71051     3   0.132      0.703 0.020 0.008 0.972
#> GSM71052     3   0.116      0.694 0.028 0.000 0.972
#> GSM71054     1   0.626      0.582 0.552 0.000 0.448
#> GSM71057     3   0.630     -0.484 0.480 0.000 0.520
#> GSM71060     1   0.626      0.582 0.552 0.000 0.448
#> GSM71066     1   0.000      0.740 1.000 0.000 0.000
#> GSM71070     3   0.129      0.703 0.000 0.032 0.968
#> GSM71072     3   0.586      0.419 0.000 0.344 0.656
#> GSM71074     2   0.000      0.988 0.000 1.000 0.000
#> GSM71076     3   0.619      0.285 0.000 0.420 0.580
#> GSM71077     2   0.000      0.988 0.000 1.000 0.000
#> GSM71069     3   0.275      0.699 0.012 0.064 0.924
#> GSM71071     3   0.631      0.108 0.000 0.492 0.508
#> GSM71073     2   0.153      0.955 0.000 0.960 0.040
#> GSM71075     3   0.621      0.636 0.136 0.088 0.776
#> GSM71078     3   0.355      0.658 0.000 0.132 0.868

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.4391      0.704 0.000 0.252 0.008 0.740
#> GSM71020     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71023     4  0.5416      0.755 0.000 0.148 0.112 0.740
#> GSM71024     3  0.6532      0.547 0.336 0.000 0.572 0.092
#> GSM71025     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71030     3  0.6454      0.539 0.344 0.000 0.572 0.084
#> GSM71032     1  0.4327      0.657 0.768 0.000 0.216 0.016
#> GSM71034     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71035     4  0.2149      0.912 0.000 0.000 0.088 0.912
#> GSM71038     1  0.3873      0.651 0.772 0.000 0.228 0.000
#> GSM71043     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71046     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71053     1  0.4222      0.554 0.728 0.000 0.272 0.000
#> GSM71061     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71062     3  0.6423      0.552 0.336 0.000 0.580 0.084
#> GSM71063     3  0.5717      0.565 0.324 0.000 0.632 0.044
#> GSM71068     3  0.6423      0.552 0.336 0.000 0.580 0.084
#> GSM71029     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71031     3  0.6532      0.547 0.336 0.000 0.572 0.092
#> GSM71033     3  0.3229      0.719 0.000 0.072 0.880 0.048
#> GSM71036     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71044     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71045     1  0.2081      0.869 0.916 0.000 0.000 0.084
#> GSM71049     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71055     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71058     3  0.6423      0.552 0.336 0.000 0.580 0.084
#> GSM71059     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71065     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71067     1  0.2197      0.860 0.916 0.000 0.080 0.004
#> GSM71037     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71039     3  0.2469      0.668 0.000 0.000 0.892 0.108
#> GSM71040     3  0.6423      0.552 0.336 0.000 0.580 0.084
#> GSM71041     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71047     3  0.0188      0.768 0.000 0.004 0.996 0.000
#> GSM71048     3  0.6454      0.539 0.344 0.000 0.572 0.084
#> GSM71050     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71051     3  0.2216      0.691 0.000 0.000 0.908 0.092
#> GSM71052     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71054     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71060     3  0.0000      0.770 0.000 0.000 1.000 0.000
#> GSM71066     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM71070     4  0.2081      0.914 0.000 0.000 0.084 0.916
#> GSM71072     4  0.2081      0.914 0.000 0.000 0.084 0.916
#> GSM71074     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71076     4  0.2413      0.888 0.000 0.064 0.020 0.916
#> GSM71077     2  0.0000      0.976 0.000 1.000 0.000 0.000
#> GSM71069     4  0.2081      0.914 0.000 0.000 0.084 0.916
#> GSM71071     4  0.2483      0.897 0.000 0.052 0.032 0.916
#> GSM71073     2  0.3356      0.772 0.000 0.824 0.000 0.176
#> GSM71075     4  0.0000      0.863 0.000 0.000 0.000 1.000
#> GSM71078     4  0.2081      0.914 0.000 0.000 0.084 0.916

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.5355     0.6612 0.000 0.220 0.120 0.660 0.000
#> GSM71020     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.1792     0.8752 0.000 0.916 0.084 0.000 0.000
#> GSM71023     4  0.5927     0.6928 0.000 0.160 0.152 0.660 0.028
#> GSM71024     5  0.0000     0.8177 0.000 0.000 0.000 0.000 1.000
#> GSM71025     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4307     0.4132 0.000 0.000 0.504 0.000 0.496
#> GSM71030     5  0.0000     0.8177 0.000 0.000 0.000 0.000 1.000
#> GSM71032     5  0.2648     0.7703 0.152 0.000 0.000 0.000 0.848
#> GSM71034     5  0.4045     0.4787 0.356 0.000 0.000 0.000 0.644
#> GSM71035     4  0.2974     0.8210 0.000 0.000 0.052 0.868 0.080
#> GSM71038     5  0.3109     0.7340 0.200 0.000 0.000 0.000 0.800
#> GSM71043     3  0.4307     0.4132 0.000 0.000 0.504 0.000 0.496
#> GSM71046     1  0.4302    -0.0894 0.520 0.000 0.000 0.000 0.480
#> GSM71053     5  0.3109     0.7340 0.200 0.000 0.000 0.000 0.800
#> GSM71061     3  0.3305     0.7925 0.000 0.000 0.776 0.000 0.224
#> GSM71062     5  0.0000     0.8177 0.000 0.000 0.000 0.000 1.000
#> GSM71063     5  0.3242     0.6351 0.000 0.000 0.000 0.216 0.784
#> GSM71068     5  0.0000     0.8177 0.000 0.000 0.000 0.000 1.000
#> GSM71029     1  0.1792     0.8012 0.916 0.000 0.084 0.000 0.000
#> GSM71031     5  0.0609     0.8077 0.000 0.000 0.020 0.000 0.980
#> GSM71033     3  0.4556     0.7287 0.080 0.028 0.784 0.000 0.108
#> GSM71036     1  0.2127     0.7709 0.892 0.000 0.000 0.000 0.108
#> GSM71042     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71045     5  0.4219     0.2200 0.416 0.000 0.000 0.000 0.584
#> GSM71049     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71058     5  0.3670     0.6926 0.112 0.000 0.068 0.000 0.820
#> GSM71059     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000     0.8687 1.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.3210     0.7200 0.212 0.000 0.000 0.000 0.788
#> GSM71037     3  0.1908     0.8405 0.000 0.000 0.908 0.000 0.092
#> GSM71039     3  0.4766     0.7704 0.000 0.000 0.732 0.136 0.132
#> GSM71040     5  0.0794     0.8041 0.000 0.000 0.028 0.000 0.972
#> GSM71041     3  0.2648     0.8310 0.000 0.000 0.848 0.000 0.152
#> GSM71047     3  0.0000     0.7843 0.000 0.000 1.000 0.000 0.000
#> GSM71048     5  0.0000     0.8177 0.000 0.000 0.000 0.000 1.000
#> GSM71050     3  0.3752     0.7407 0.000 0.000 0.708 0.000 0.292
#> GSM71051     3  0.0609     0.7767 0.000 0.000 0.980 0.020 0.000
#> GSM71052     3  0.1043     0.8168 0.000 0.000 0.960 0.000 0.040
#> GSM71054     3  0.1908     0.8405 0.000 0.000 0.908 0.000 0.092
#> GSM71057     3  0.1908     0.8405 0.000 0.000 0.908 0.000 0.092
#> GSM71060     3  0.2230     0.8356 0.000 0.000 0.884 0.000 0.116
#> GSM71066     1  0.4304    -0.1030 0.516 0.000 0.000 0.000 0.484
#> GSM71070     4  0.1908     0.8748 0.000 0.000 0.092 0.908 0.000
#> GSM71072     4  0.0000     0.8937 0.000 0.000 0.000 1.000 0.000
#> GSM71074     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71076     4  0.0000     0.8937 0.000 0.000 0.000 1.000 0.000
#> GSM71077     2  0.0000     0.9448 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.1908     0.8748 0.000 0.000 0.092 0.908 0.000
#> GSM71071     4  0.0000     0.8937 0.000 0.000 0.000 1.000 0.000
#> GSM71073     2  0.3983     0.5238 0.000 0.660 0.000 0.340 0.000
#> GSM71075     4  0.0000     0.8937 0.000 0.000 0.000 1.000 0.000
#> GSM71078     4  0.0000     0.8937 0.000 0.000 0.000 1.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
#> GSM71019     6  0.2631     0.7362 0.000 0.180 0.000 0.000 0.000 0.820
#> GSM71020     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.3547     0.4001 0.000 0.668 0.000 0.000 0.000 0.332
#> GSM71023     6  0.2631     0.7362 0.000 0.180 0.000 0.000 0.000 0.820
#> GSM71024     5  0.1745     0.7730 0.000 0.000 0.056 0.000 0.924 0.020
#> GSM71025     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     3  0.5744     0.4161 0.000 0.000 0.476 0.000 0.344 0.180
#> GSM71030     5  0.1657     0.7731 0.000 0.000 0.056 0.000 0.928 0.016
#> GSM71032     5  0.2340     0.7778 0.148 0.000 0.000 0.000 0.852 0.000
#> GSM71034     5  0.3198     0.7041 0.260 0.000 0.000 0.000 0.740 0.000
#> GSM71035     3  0.5224     0.5668 0.000 0.000 0.588 0.132 0.000 0.280
#> GSM71038     5  0.2793     0.7547 0.200 0.000 0.000 0.000 0.800 0.000
#> GSM71043     3  0.5744     0.4161 0.000 0.000 0.476 0.000 0.344 0.180
#> GSM71046     5  0.3823     0.4294 0.436 0.000 0.000 0.000 0.564 0.000
#> GSM71053     5  0.2793     0.7547 0.200 0.000 0.000 0.000 0.800 0.000
#> GSM71061     3  0.4952     0.6328 0.000 0.000 0.652 0.000 0.168 0.180
#> GSM71062     5  0.0000     0.7798 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     5  0.3803     0.6645 0.000 0.000 0.056 0.000 0.760 0.184
#> GSM71068     5  0.0000     0.7798 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71031     5  0.1657     0.7731 0.000 0.000 0.056 0.000 0.928 0.016
#> GSM71033     6  0.0260     0.7019 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM71036     1  0.1765     0.8622 0.904 0.000 0.000 0.000 0.096 0.000
#> GSM71042     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71045     5  0.4131     0.3700 0.384 0.000 0.016 0.000 0.600 0.000
#> GSM71049     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71055     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71058     5  0.3961     0.6526 0.124 0.000 0.112 0.000 0.764 0.000
#> GSM71059     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.0000     0.9862 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71067     5  0.2762     0.7571 0.196 0.000 0.000 0.000 0.804 0.000
#> GSM71037     3  0.0000     0.7095 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     3  0.3898     0.6375 0.000 0.000 0.684 0.000 0.020 0.296
#> GSM71040     5  0.1204     0.7701 0.000 0.000 0.056 0.000 0.944 0.000
#> GSM71041     3  0.1387     0.7077 0.000 0.000 0.932 0.000 0.068 0.000
#> GSM71047     6  0.3717     0.4699 0.000 0.000 0.384 0.000 0.000 0.616
#> GSM71048     5  0.1204     0.7701 0.000 0.000 0.056 0.000 0.944 0.000
#> GSM71050     3  0.4049     0.6118 0.000 0.000 0.648 0.000 0.020 0.332
#> GSM71051     3  0.3756    -0.0567 0.000 0.000 0.600 0.000 0.000 0.400
#> GSM71052     3  0.0865     0.6777 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM71054     3  0.0000     0.7095 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0000     0.7095 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71060     3  0.0000     0.7095 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71066     5  0.3817     0.4383 0.432 0.000 0.000 0.000 0.568 0.000
#> GSM71070     6  0.2631     0.7409 0.000 0.000 0.000 0.180 0.000 0.820
#> GSM71072     4  0.0000     0.9965 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71074     2  0.0260     0.9350 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM71076     4  0.0260     0.9930 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM71077     2  0.0000     0.9419 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     6  0.2762     0.7302 0.000 0.000 0.000 0.196 0.000 0.804
#> GSM71071     4  0.0000     0.9965 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71073     4  0.0000     0.9965 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM71075     4  0.0260     0.9930 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM71078     4  0.0000     0.9965 0.000 0.000 0.000 1.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:pam 58    1.09e-08 2
#> MAD:pam 52    8.83e-07 3
#> MAD:pam 60    6.21e-12 4
#> MAD:pam 54    1.94e-14 5
#> MAD:pam 52    7.88e-15 6

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


MAD:mclust

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

res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.363           0.439       0.799         0.4203 0.494   0.494
#> 3 3 0.594           0.737       0.836         0.4604 0.708   0.480
#> 4 4 0.652           0.688       0.814         0.1233 0.884   0.692
#> 5 5 0.657           0.649       0.767         0.1302 0.841   0.516
#> 6 6 0.766           0.709       0.855         0.0511 0.920   0.641

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
#> GSM71019     2  1.0000    -0.1078 0.500 0.500
#> GSM71020     2  0.0000     0.6867 0.000 1.000
#> GSM71021     2  0.0000     0.6867 0.000 1.000
#> GSM71022     2  0.0000     0.6867 0.000 1.000
#> GSM71023     2  0.0938     0.6800 0.012 0.988
#> GSM71024     1  0.7815     0.6280 0.768 0.232
#> GSM71025     2  0.0000     0.6867 0.000 1.000
#> GSM71026     2  0.0000     0.6867 0.000 1.000
#> GSM71027     2  0.0000     0.6867 0.000 1.000
#> GSM71028     1  1.0000     0.0449 0.500 0.500
#> GSM71030     1  0.7815     0.6280 0.768 0.232
#> GSM71032     1  0.0000     0.6828 1.000 0.000
#> GSM71034     1  0.0000     0.6828 1.000 0.000
#> GSM71035     2  0.9580     0.2027 0.380 0.620
#> GSM71038     1  0.0000     0.6828 1.000 0.000
#> GSM71043     1  1.0000     0.0449 0.500 0.500
#> GSM71046     1  0.0000     0.6828 1.000 0.000
#> GSM71053     1  0.0000     0.6828 1.000 0.000
#> GSM71061     1  1.0000     0.0449 0.500 0.500
#> GSM71062     1  0.7815     0.6280 0.768 0.232
#> GSM71063     1  1.0000     0.0449 0.500 0.500
#> GSM71068     1  0.7528     0.6360 0.784 0.216
#> GSM71029     1  0.7815     0.6280 0.768 0.232
#> GSM71031     2  1.0000    -0.1078 0.500 0.500
#> GSM71033     2  1.0000    -0.1078 0.500 0.500
#> GSM71036     1  0.0000     0.6828 1.000 0.000
#> GSM71042     1  0.0000     0.6828 1.000 0.000
#> GSM71044     1  0.7815     0.6280 0.768 0.232
#> GSM71045     1  0.0376     0.6828 0.996 0.004
#> GSM71049     1  0.7815     0.6280 0.768 0.232
#> GSM71055     1  0.0000     0.6828 1.000 0.000
#> GSM71056     1  0.0000     0.6828 1.000 0.000
#> GSM71058     1  1.0000     0.0449 0.500 0.500
#> GSM71059     1  0.0000     0.6828 1.000 0.000
#> GSM71064     1  0.1414     0.6810 0.980 0.020
#> GSM71065     1  0.7745     0.6305 0.772 0.228
#> GSM71067     1  0.0000     0.6828 1.000 0.000
#> GSM71037     2  1.0000    -0.1078 0.500 0.500
#> GSM71039     2  1.0000    -0.1078 0.500 0.500
#> GSM71040     1  1.0000     0.0449 0.500 0.500
#> GSM71041     2  1.0000    -0.1078 0.500 0.500
#> GSM71047     1  1.0000     0.0449 0.500 0.500
#> GSM71048     1  0.7453     0.6375 0.788 0.212
#> GSM71050     2  1.0000    -0.1078 0.500 0.500
#> GSM71051     1  1.0000     0.0449 0.500 0.500
#> GSM71052     2  1.0000    -0.1078 0.500 0.500
#> GSM71054     2  1.0000    -0.1078 0.500 0.500
#> GSM71057     1  1.0000     0.0449 0.500 0.500
#> GSM71060     2  1.0000    -0.1078 0.500 0.500
#> GSM71066     1  0.0000     0.6828 1.000 0.000
#> GSM71070     2  0.0000     0.6867 0.000 1.000
#> GSM71072     2  0.0000     0.6867 0.000 1.000
#> GSM71074     2  0.0000     0.6867 0.000 1.000
#> GSM71076     2  0.0000     0.6867 0.000 1.000
#> GSM71077     2  0.0000     0.6867 0.000 1.000
#> GSM71069     2  0.0000     0.6867 0.000 1.000
#> GSM71071     2  0.0000     0.6867 0.000 1.000
#> GSM71073     2  0.0000     0.6867 0.000 1.000
#> GSM71075     2  0.0000     0.6867 0.000 1.000
#> GSM71078     2  0.5178     0.5997 0.116 0.884

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2   0.624      0.578 0.000 0.560 0.440
#> GSM71020     2   0.000      0.650 0.000 1.000 0.000
#> GSM71021     2   0.000      0.650 0.000 1.000 0.000
#> GSM71022     2   0.553      0.613 0.000 0.704 0.296
#> GSM71023     2   0.624      0.578 0.000 0.560 0.440
#> GSM71024     1   0.745      0.574 0.636 0.060 0.304
#> GSM71025     2   0.000      0.650 0.000 1.000 0.000
#> GSM71026     2   0.000      0.650 0.000 1.000 0.000
#> GSM71027     2   0.000      0.650 0.000 1.000 0.000
#> GSM71028     3   0.207      0.952 0.000 0.060 0.940
#> GSM71030     1   0.767      0.516 0.600 0.060 0.340
#> GSM71032     1   0.000      0.799 1.000 0.000 0.000
#> GSM71034     1   0.000      0.799 1.000 0.000 0.000
#> GSM71035     3   0.207      0.952 0.000 0.060 0.940
#> GSM71038     1   0.000      0.799 1.000 0.000 0.000
#> GSM71043     3   0.207      0.952 0.000 0.060 0.940
#> GSM71046     1   0.000      0.799 1.000 0.000 0.000
#> GSM71053     1   0.000      0.799 1.000 0.000 0.000
#> GSM71061     3   0.000      0.940 0.000 0.000 1.000
#> GSM71062     1   0.776      0.474 0.580 0.060 0.360
#> GSM71063     3   0.230      0.948 0.004 0.060 0.936
#> GSM71068     1   0.649      0.684 0.740 0.060 0.200
#> GSM71029     1   0.680      0.583 0.660 0.032 0.308
#> GSM71031     1   0.798      0.291 0.500 0.060 0.440
#> GSM71033     1   0.798      0.291 0.500 0.060 0.440
#> GSM71036     1   0.000      0.799 1.000 0.000 0.000
#> GSM71042     1   0.000      0.799 1.000 0.000 0.000
#> GSM71044     1   0.541      0.729 0.796 0.032 0.172
#> GSM71045     1   0.000      0.799 1.000 0.000 0.000
#> GSM71049     1   0.547      0.727 0.792 0.032 0.176
#> GSM71055     1   0.000      0.799 1.000 0.000 0.000
#> GSM71056     1   0.000      0.799 1.000 0.000 0.000
#> GSM71058     1   0.798      0.280 0.496 0.060 0.444
#> GSM71059     1   0.000      0.799 1.000 0.000 0.000
#> GSM71064     1   0.000      0.799 1.000 0.000 0.000
#> GSM71065     1   0.522      0.731 0.800 0.024 0.176
#> GSM71067     1   0.000      0.799 1.000 0.000 0.000
#> GSM71037     3   0.000      0.940 0.000 0.000 1.000
#> GSM71039     3   0.207      0.952 0.000 0.060 0.940
#> GSM71040     3   0.207      0.952 0.000 0.060 0.940
#> GSM71041     3   0.000      0.940 0.000 0.000 1.000
#> GSM71047     3   0.129      0.954 0.000 0.032 0.968
#> GSM71048     1   0.624      0.701 0.760 0.060 0.180
#> GSM71050     3   0.207      0.952 0.000 0.060 0.940
#> GSM71051     3   0.129      0.954 0.000 0.032 0.968
#> GSM71052     3   0.129      0.954 0.000 0.032 0.968
#> GSM71054     3   0.000      0.940 0.000 0.000 1.000
#> GSM71057     3   0.000      0.940 0.000 0.000 1.000
#> GSM71060     3   0.000      0.940 0.000 0.000 1.000
#> GSM71066     1   0.000      0.799 1.000 0.000 0.000
#> GSM71070     2   0.624      0.578 0.000 0.560 0.440
#> GSM71072     2   0.624      0.578 0.000 0.560 0.440
#> GSM71074     2   0.000      0.650 0.000 1.000 0.000
#> GSM71076     2   0.624      0.578 0.000 0.560 0.440
#> GSM71077     2   0.000      0.650 0.000 1.000 0.000
#> GSM71069     2   0.624      0.578 0.000 0.560 0.440
#> GSM71071     2   0.624      0.578 0.000 0.560 0.440
#> GSM71073     2   0.624      0.578 0.000 0.560 0.440
#> GSM71075     2   0.624      0.578 0.000 0.560 0.440
#> GSM71078     3   0.207      0.952 0.000 0.060 0.940

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     3  0.6583    -0.2437 0.176 0.000 0.632 0.192
#> GSM71020     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71022     4  0.7550     0.6698 0.000 0.204 0.332 0.464
#> GSM71023     3  0.4985    -0.8279 0.000 0.000 0.532 0.468
#> GSM71024     1  0.2408     0.8771 0.896 0.000 0.104 0.000
#> GSM71025     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0336     0.5192 0.000 0.000 0.992 0.008
#> GSM71030     1  0.2647     0.8630 0.880 0.000 0.120 0.000
#> GSM71032     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71035     3  0.1716     0.4380 0.000 0.000 0.936 0.064
#> GSM71038     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71043     3  0.0336     0.5192 0.000 0.000 0.992 0.008
#> GSM71046     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71061     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71062     1  0.2760     0.8554 0.872 0.000 0.128 0.000
#> GSM71063     3  0.0188     0.5150 0.000 0.000 0.996 0.004
#> GSM71068     1  0.2408     0.8771 0.896 0.000 0.104 0.000
#> GSM71029     1  0.4252     0.6521 0.744 0.000 0.252 0.004
#> GSM71031     3  0.4776     0.0632 0.376 0.000 0.624 0.000
#> GSM71033     3  0.4855     0.0645 0.352 0.000 0.644 0.004
#> GSM71036     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71044     1  0.3257     0.8100 0.844 0.000 0.152 0.004
#> GSM71045     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71049     1  0.3668     0.7616 0.808 0.000 0.188 0.004
#> GSM71055     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71056     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71058     1  0.3649     0.7718 0.796 0.000 0.204 0.000
#> GSM71059     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71064     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71065     1  0.1302     0.9102 0.956 0.000 0.044 0.000
#> GSM71067     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71037     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71039     3  0.0188     0.5219 0.000 0.000 0.996 0.004
#> GSM71040     3  0.3494     0.4532 0.172 0.000 0.824 0.004
#> GSM71041     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71047     3  0.0188     0.5219 0.000 0.000 0.996 0.004
#> GSM71048     1  0.2149     0.8879 0.912 0.000 0.088 0.000
#> GSM71050     3  0.0336     0.5234 0.000 0.000 0.992 0.008
#> GSM71051     3  0.0188     0.5219 0.000 0.000 0.996 0.004
#> GSM71052     3  0.0188     0.5219 0.000 0.000 0.996 0.004
#> GSM71054     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71057     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71060     3  0.4961     0.4796 0.000 0.000 0.552 0.448
#> GSM71066     1  0.0000     0.9264 1.000 0.000 0.000 0.000
#> GSM71070     4  0.5000     0.8736 0.000 0.000 0.496 0.504
#> GSM71072     4  0.4961     0.9328 0.000 0.000 0.448 0.552
#> GSM71074     2  0.6690     0.2275 0.000 0.548 0.100 0.352
#> GSM71076     4  0.4961     0.9328 0.000 0.000 0.448 0.552
#> GSM71077     2  0.0000     0.9236 0.000 1.000 0.000 0.000
#> GSM71069     4  0.4972     0.9328 0.000 0.000 0.456 0.544
#> GSM71071     4  0.4961     0.9328 0.000 0.000 0.448 0.552
#> GSM71073     4  0.4972     0.9328 0.000 0.000 0.456 0.544
#> GSM71075     4  0.4972     0.9328 0.000 0.000 0.456 0.544
#> GSM71078     3  0.3486     0.1198 0.000 0.000 0.812 0.188

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.0162     0.6854 0.004 0.000 0.000 0.996 0.000
#> GSM71020     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71022     4  0.3857     0.4438 0.000 0.312 0.000 0.688 0.000
#> GSM71023     4  0.0000     0.6866 0.000 0.000 0.000 1.000 0.000
#> GSM71024     5  0.5600     0.7160 0.116 0.000 0.000 0.268 0.616
#> GSM71025     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4481     0.3916 0.000 0.000 0.576 0.416 0.008
#> GSM71030     5  0.5423     0.7414 0.112 0.000 0.000 0.244 0.644
#> GSM71032     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71034     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71035     3  0.6497     0.0360 0.000 0.000 0.420 0.392 0.188
#> GSM71038     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71043     3  0.4436     0.4213 0.000 0.000 0.596 0.396 0.008
#> GSM71046     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71053     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71061     3  0.0290     0.6701 0.000 0.000 0.992 0.000 0.008
#> GSM71062     5  0.5182     0.7692 0.112 0.000 0.000 0.208 0.680
#> GSM71063     4  0.4562    -0.3135 0.000 0.000 0.492 0.500 0.008
#> GSM71068     5  0.5210     0.7745 0.120 0.000 0.000 0.200 0.680
#> GSM71029     1  0.3209     0.7013 0.812 0.000 0.000 0.180 0.008
#> GSM71031     4  0.6194    -0.2170 0.140 0.000 0.388 0.472 0.000
#> GSM71033     4  0.6451     0.1574 0.068 0.000 0.212 0.620 0.100
#> GSM71036     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71042     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71044     1  0.1830     0.8225 0.924 0.000 0.000 0.068 0.008
#> GSM71045     1  0.1608     0.7947 0.928 0.000 0.000 0.000 0.072
#> GSM71049     1  0.2563     0.7758 0.872 0.000 0.000 0.120 0.008
#> GSM71055     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71056     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71058     1  0.6836    -0.0694 0.428 0.000 0.288 0.280 0.004
#> GSM71059     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71064     1  0.0162     0.8661 0.996 0.000 0.000 0.000 0.004
#> GSM71065     1  0.0162     0.8632 0.996 0.000 0.000 0.004 0.000
#> GSM71067     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71037     3  0.2127     0.6648 0.000 0.000 0.892 0.000 0.108
#> GSM71039     3  0.3421     0.6125 0.000 0.000 0.788 0.204 0.008
#> GSM71040     3  0.4380     0.4501 0.000 0.000 0.616 0.376 0.008
#> GSM71041     3  0.0000     0.6709 0.000 0.000 1.000 0.000 0.000
#> GSM71047     3  0.5901     0.3057 0.000 0.000 0.496 0.400 0.104
#> GSM71048     5  0.5210     0.7745 0.120 0.000 0.000 0.200 0.680
#> GSM71050     3  0.3622     0.6569 0.000 0.000 0.816 0.136 0.048
#> GSM71051     3  0.5906     0.2966 0.000 0.000 0.492 0.404 0.104
#> GSM71052     3  0.5717     0.4511 0.000 0.000 0.572 0.324 0.104
#> GSM71054     3  0.2127     0.6648 0.000 0.000 0.892 0.000 0.108
#> GSM71057     3  0.2127     0.6648 0.000 0.000 0.892 0.000 0.108
#> GSM71060     3  0.0290     0.6701 0.000 0.000 0.992 0.000 0.008
#> GSM71066     5  0.3876     0.8203 0.316 0.000 0.000 0.000 0.684
#> GSM71070     4  0.0000     0.6866 0.000 0.000 0.000 1.000 0.000
#> GSM71072     4  0.3039     0.6941 0.000 0.000 0.000 0.808 0.192
#> GSM71074     2  0.4227     0.2764 0.000 0.580 0.000 0.420 0.000
#> GSM71076     4  0.2929     0.6996 0.000 0.000 0.000 0.820 0.180
#> GSM71077     2  0.0000     0.9231 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.2929     0.6996 0.000 0.000 0.000 0.820 0.180
#> GSM71071     4  0.3039     0.6941 0.000 0.000 0.000 0.808 0.192
#> GSM71073     4  0.2929     0.6996 0.000 0.000 0.000 0.820 0.180
#> GSM71075     4  0.0000     0.6866 0.000 0.000 0.000 1.000 0.000
#> GSM71078     4  0.5136     0.5909 0.000 0.000 0.128 0.692 0.180

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     5  0.6555     -0.207 0.320 0.000 0.000 0.328 0.332 0.020
#> GSM71020     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     4  0.3833      0.229 0.000 0.444 0.000 0.556 0.000 0.000
#> GSM71023     4  0.3053      0.716 0.000 0.000 0.000 0.812 0.168 0.020
#> GSM71024     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71025     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.2288      0.690 0.000 0.000 0.016 0.016 0.068 0.900
#> GSM71030     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71032     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71034     5  0.2730      0.793 0.192 0.000 0.000 0.000 0.808 0.000
#> GSM71035     6  0.4147      0.443 0.000 0.000 0.000 0.436 0.012 0.552
#> GSM71038     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71043     6  0.2478      0.683 0.000 0.000 0.024 0.012 0.076 0.888
#> GSM71046     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71053     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71061     3  0.1858      0.758 0.000 0.000 0.912 0.000 0.012 0.076
#> GSM71062     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     6  0.1982      0.687 0.000 0.000 0.004 0.016 0.068 0.912
#> GSM71068     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     1  0.1462      0.854 0.936 0.000 0.000 0.008 0.000 0.056
#> GSM71031     5  0.5318      0.472 0.200 0.000 0.020 0.092 0.672 0.016
#> GSM71033     1  0.6356      0.121 0.504 0.000 0.016 0.308 0.152 0.020
#> GSM71036     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71042     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.1349      0.856 0.940 0.000 0.000 0.004 0.000 0.056
#> GSM71045     1  0.2793      0.616 0.800 0.000 0.000 0.000 0.200 0.000
#> GSM71049     1  0.1349      0.856 0.940 0.000 0.000 0.004 0.000 0.056
#> GSM71055     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71056     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71058     1  0.4591      0.427 0.592 0.000 0.020 0.016 0.372 0.000
#> GSM71059     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71064     1  0.0000      0.869 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM71065     1  0.1204      0.841 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM71067     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71037     3  0.0000      0.769 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71039     6  0.5621      0.505 0.000 0.000 0.116 0.292 0.020 0.572
#> GSM71040     3  0.4637      0.313 0.000 0.000 0.556 0.008 0.408 0.028
#> GSM71041     3  0.1524      0.765 0.000 0.000 0.932 0.000 0.008 0.060
#> GSM71047     3  0.3867      0.522 0.000 0.000 0.688 0.296 0.012 0.004
#> GSM71048     5  0.0000      0.761 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71050     3  0.2828      0.741 0.000 0.000 0.868 0.012 0.040 0.080
#> GSM71051     3  0.3867      0.522 0.000 0.000 0.688 0.296 0.012 0.004
#> GSM71052     3  0.3867      0.522 0.000 0.000 0.688 0.296 0.012 0.004
#> GSM71054     3  0.0000      0.769 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71057     3  0.0000      0.769 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM71060     3  0.1524      0.765 0.000 0.000 0.932 0.000 0.008 0.060
#> GSM71066     5  0.2823      0.792 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM71070     4  0.2950      0.735 0.000 0.000 0.000 0.828 0.148 0.024
#> GSM71072     4  0.0713      0.801 0.000 0.000 0.000 0.972 0.000 0.028
#> GSM71074     2  0.3288      0.454 0.000 0.724 0.000 0.276 0.000 0.000
#> GSM71076     4  0.0603      0.806 0.000 0.000 0.000 0.980 0.004 0.016
#> GSM71077     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.0993      0.809 0.000 0.000 0.000 0.964 0.012 0.024
#> GSM71071     4  0.0713      0.801 0.000 0.000 0.000 0.972 0.000 0.028
#> GSM71073     4  0.1364      0.805 0.000 0.020 0.000 0.952 0.012 0.016
#> GSM71075     4  0.2771      0.768 0.000 0.000 0.000 0.852 0.116 0.032
#> GSM71078     6  0.4169      0.411 0.000 0.000 0.000 0.456 0.012 0.532

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:mclust 40    7.83e-07 2
#> MAD:mclust 56    5.63e-12 3
#> MAD:mclust 46    2.20e-11 4
#> MAD:mclust 47    1.22e-16 5
#> MAD:mclust 51    7.05e-18 6

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


MAD:NMF*

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

res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.752           0.905       0.954         0.4811 0.519   0.519
#> 3 3 0.904           0.872       0.951         0.3522 0.711   0.502
#> 4 4 0.806           0.828       0.905         0.1246 0.885   0.690
#> 5 5 0.677           0.572       0.789         0.0853 0.914   0.697
#> 6 6 0.760           0.623       0.801         0.0355 0.922   0.676

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
#> GSM71019     2  0.0376      0.964 0.004 0.996
#> GSM71020     2  0.0000      0.965 0.000 1.000
#> GSM71021     2  0.0000      0.965 0.000 1.000
#> GSM71022     2  0.0000      0.965 0.000 1.000
#> GSM71023     2  0.0376      0.964 0.004 0.996
#> GSM71024     1  0.0000      0.940 1.000 0.000
#> GSM71025     2  0.0000      0.965 0.000 1.000
#> GSM71026     2  0.0000      0.965 0.000 1.000
#> GSM71027     2  0.0000      0.965 0.000 1.000
#> GSM71028     1  0.7056      0.803 0.808 0.192
#> GSM71030     1  0.0000      0.940 1.000 0.000
#> GSM71032     1  0.0000      0.940 1.000 0.000
#> GSM71034     1  0.0000      0.940 1.000 0.000
#> GSM71035     2  0.7815      0.668 0.232 0.768
#> GSM71038     1  0.0000      0.940 1.000 0.000
#> GSM71043     1  0.5519      0.864 0.872 0.128
#> GSM71046     1  0.0000      0.940 1.000 0.000
#> GSM71053     1  0.0000      0.940 1.000 0.000
#> GSM71061     1  0.6887      0.812 0.816 0.184
#> GSM71062     1  0.0000      0.940 1.000 0.000
#> GSM71063     1  0.6247      0.840 0.844 0.156
#> GSM71068     1  0.0000      0.940 1.000 0.000
#> GSM71029     1  0.0376      0.938 0.996 0.004
#> GSM71031     1  0.4562      0.889 0.904 0.096
#> GSM71033     1  0.8713      0.652 0.708 0.292
#> GSM71036     1  0.0000      0.940 1.000 0.000
#> GSM71042     1  0.0000      0.940 1.000 0.000
#> GSM71044     1  0.0000      0.940 1.000 0.000
#> GSM71045     1  0.0000      0.940 1.000 0.000
#> GSM71049     1  0.0000      0.940 1.000 0.000
#> GSM71055     1  0.0000      0.940 1.000 0.000
#> GSM71056     1  0.0000      0.940 1.000 0.000
#> GSM71058     1  0.0000      0.940 1.000 0.000
#> GSM71059     1  0.0000      0.940 1.000 0.000
#> GSM71064     1  0.0000      0.940 1.000 0.000
#> GSM71065     1  0.0000      0.940 1.000 0.000
#> GSM71067     1  0.0000      0.940 1.000 0.000
#> GSM71037     1  0.3879      0.902 0.924 0.076
#> GSM71039     2  0.9552      0.331 0.376 0.624
#> GSM71040     1  0.0000      0.940 1.000 0.000
#> GSM71041     1  0.4939      0.880 0.892 0.108
#> GSM71047     2  0.0376      0.964 0.004 0.996
#> GSM71048     1  0.0000      0.940 1.000 0.000
#> GSM71050     1  0.9608      0.454 0.616 0.384
#> GSM71051     2  0.0376      0.964 0.004 0.996
#> GSM71052     2  0.0938      0.958 0.012 0.988
#> GSM71054     1  0.7056      0.803 0.808 0.192
#> GSM71057     1  0.6887      0.812 0.816 0.184
#> GSM71060     1  0.3274      0.911 0.940 0.060
#> GSM71066     1  0.0000      0.940 1.000 0.000
#> GSM71070     2  0.0000      0.965 0.000 1.000
#> GSM71072     2  0.0000      0.965 0.000 1.000
#> GSM71074     2  0.0000      0.965 0.000 1.000
#> GSM71076     2  0.0000      0.965 0.000 1.000
#> GSM71077     2  0.0000      0.965 0.000 1.000
#> GSM71069     2  0.1843      0.945 0.028 0.972
#> GSM71071     2  0.0000      0.965 0.000 1.000
#> GSM71073     2  0.0000      0.965 0.000 1.000
#> GSM71075     2  0.1843      0.945 0.028 0.972
#> GSM71078     2  0.0000      0.965 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71020     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71021     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71022     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71023     2  0.0237      0.938 0.000 0.996 0.004
#> GSM71024     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71025     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71026     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71027     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71028     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71030     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71032     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71035     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71038     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71043     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71046     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71061     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71062     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71063     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71068     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71029     1  0.0747      0.957 0.984 0.016 0.000
#> GSM71031     1  0.2945      0.879 0.908 0.088 0.004
#> GSM71033     1  0.5688      0.757 0.788 0.044 0.168
#> GSM71036     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71042     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71044     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71045     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71049     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71055     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71056     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71058     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71059     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71064     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71065     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71067     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71037     3  0.1289      0.878 0.032 0.000 0.968
#> GSM71039     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71040     1  0.6204      0.311 0.576 0.000 0.424
#> GSM71041     3  0.0237      0.905 0.004 0.000 0.996
#> GSM71047     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71048     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71050     3  0.0237      0.905 0.004 0.000 0.996
#> GSM71051     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71052     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71054     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71057     3  0.0000      0.907 0.000 0.000 1.000
#> GSM71060     3  0.0237      0.905 0.004 0.000 0.996
#> GSM71066     1  0.0000      0.970 1.000 0.000 0.000
#> GSM71070     3  0.4178      0.759 0.000 0.172 0.828
#> GSM71072     3  0.5835      0.507 0.000 0.340 0.660
#> GSM71074     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71076     3  0.6204      0.314 0.000 0.424 0.576
#> GSM71077     2  0.0000      0.941 0.000 1.000 0.000
#> GSM71069     3  0.4654      0.717 0.000 0.208 0.792
#> GSM71071     3  0.6274      0.220 0.000 0.456 0.544
#> GSM71073     2  0.2165      0.882 0.000 0.936 0.064
#> GSM71075     2  0.6309     -0.166 0.000 0.504 0.496
#> GSM71078     3  0.0000      0.907 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4134      0.609 0.000 0.740 0.000 0.260
#> GSM71024     1  0.4972      0.401 0.544 0.000 0.000 0.456
#> GSM71025     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71028     4  0.4877      0.455 0.000 0.000 0.408 0.592
#> GSM71030     4  0.4304      0.357 0.284 0.000 0.000 0.716
#> GSM71032     1  0.2081      0.894 0.916 0.000 0.000 0.084
#> GSM71034     1  0.2973      0.875 0.856 0.000 0.000 0.144
#> GSM71035     4  0.4972      0.358 0.000 0.000 0.456 0.544
#> GSM71038     1  0.2149      0.893 0.912 0.000 0.000 0.088
#> GSM71043     4  0.4888      0.437 0.000 0.000 0.412 0.588
#> GSM71046     1  0.2647      0.883 0.880 0.000 0.000 0.120
#> GSM71053     1  0.3123      0.867 0.844 0.000 0.000 0.156
#> GSM71061     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71062     1  0.2921      0.874 0.860 0.000 0.000 0.140
#> GSM71063     4  0.0336      0.720 0.000 0.000 0.008 0.992
#> GSM71068     1  0.3569      0.836 0.804 0.000 0.000 0.196
#> GSM71029     1  0.1557      0.882 0.944 0.056 0.000 0.000
#> GSM71031     1  0.1296      0.885 0.964 0.028 0.004 0.004
#> GSM71033     1  0.7270      0.338 0.560 0.192 0.244 0.004
#> GSM71036     1  0.0000      0.896 1.000 0.000 0.000 0.000
#> GSM71042     1  0.0188      0.895 0.996 0.000 0.000 0.004
#> GSM71044     1  0.0376      0.894 0.992 0.000 0.004 0.004
#> GSM71045     1  0.0000      0.896 1.000 0.000 0.000 0.000
#> GSM71049     1  0.1792      0.895 0.932 0.000 0.000 0.068
#> GSM71055     1  0.0376      0.894 0.992 0.000 0.004 0.004
#> GSM71056     1  0.0188      0.895 0.996 0.000 0.000 0.004
#> GSM71058     1  0.1902      0.857 0.932 0.000 0.064 0.004
#> GSM71059     1  0.0188      0.895 0.996 0.000 0.000 0.004
#> GSM71064     1  0.0524      0.893 0.988 0.000 0.008 0.004
#> GSM71065     1  0.0524      0.893 0.988 0.000 0.008 0.004
#> GSM71067     1  0.2647      0.883 0.880 0.000 0.000 0.120
#> GSM71037     3  0.0376      0.980 0.004 0.000 0.992 0.004
#> GSM71039     3  0.0469      0.980 0.000 0.000 0.988 0.012
#> GSM71040     3  0.1637      0.905 0.060 0.000 0.940 0.000
#> GSM71041     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71047     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM71048     1  0.3123      0.866 0.844 0.000 0.000 0.156
#> GSM71050     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71051     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71052     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71054     3  0.0000      0.986 0.000 0.000 1.000 0.000
#> GSM71057     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM71060     3  0.0188      0.987 0.000 0.000 0.996 0.004
#> GSM71066     1  0.3024      0.870 0.852 0.000 0.000 0.148
#> GSM71070     4  0.0376      0.719 0.000 0.004 0.004 0.992
#> GSM71072     4  0.4808      0.592 0.000 0.236 0.028 0.736
#> GSM71074     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71076     4  0.3494      0.643 0.000 0.172 0.004 0.824
#> GSM71077     2  0.0000      0.959 0.000 1.000 0.000 0.000
#> GSM71069     4  0.0524      0.719 0.000 0.008 0.004 0.988
#> GSM71071     4  0.4608      0.504 0.000 0.304 0.004 0.692
#> GSM71073     2  0.2610      0.865 0.000 0.900 0.012 0.088
#> GSM71075     4  0.0804      0.714 0.012 0.008 0.000 0.980
#> GSM71078     4  0.4585      0.558 0.000 0.000 0.332 0.668

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.3246     0.6881 0.184 0.808 0.000 0.000 0.008
#> GSM71020     2  0.0510     0.8445 0.000 0.984 0.000 0.000 0.016
#> GSM71021     2  0.1557     0.8436 0.000 0.940 0.000 0.008 0.052
#> GSM71022     2  0.1041     0.8458 0.000 0.964 0.000 0.004 0.032
#> GSM71023     2  0.6463     0.5008 0.048 0.616 0.000 0.192 0.144
#> GSM71024     1  0.6125     0.2576 0.500 0.000 0.000 0.136 0.364
#> GSM71025     2  0.1670     0.8430 0.000 0.936 0.000 0.012 0.052
#> GSM71026     2  0.1197     0.8445 0.000 0.952 0.000 0.000 0.048
#> GSM71027     2  0.1121     0.8404 0.000 0.956 0.000 0.000 0.044
#> GSM71028     4  0.4562     0.0942 0.000 0.000 0.496 0.496 0.008
#> GSM71030     5  0.6728    -0.0945 0.252 0.000 0.000 0.368 0.380
#> GSM71032     5  0.4288     0.3738 0.384 0.000 0.004 0.000 0.612
#> GSM71034     1  0.4768     0.3929 0.592 0.000 0.000 0.024 0.384
#> GSM71035     4  0.4430     0.4528 0.000 0.000 0.360 0.628 0.012
#> GSM71038     5  0.3906     0.4408 0.292 0.000 0.004 0.000 0.704
#> GSM71043     3  0.6422     0.0139 0.000 0.000 0.492 0.308 0.200
#> GSM71046     1  0.4003     0.4637 0.704 0.000 0.000 0.008 0.288
#> GSM71053     5  0.3177     0.4080 0.208 0.000 0.000 0.000 0.792
#> GSM71061     3  0.0162     0.9417 0.000 0.000 0.996 0.000 0.004
#> GSM71062     1  0.4930     0.3809 0.580 0.000 0.000 0.032 0.388
#> GSM71063     4  0.4356     0.5615 0.000 0.000 0.012 0.648 0.340
#> GSM71068     5  0.4385     0.4474 0.312 0.000 0.004 0.012 0.672
#> GSM71029     1  0.3123     0.4688 0.812 0.184 0.000 0.000 0.004
#> GSM71031     1  0.5629     0.3765 0.716 0.068 0.004 0.144 0.068
#> GSM71033     5  0.7940     0.3145 0.160 0.164 0.216 0.000 0.460
#> GSM71036     1  0.0510     0.5706 0.984 0.000 0.000 0.000 0.016
#> GSM71042     1  0.0000     0.5663 1.000 0.000 0.000 0.000 0.000
#> GSM71044     1  0.4101    -0.0738 0.628 0.000 0.000 0.000 0.372
#> GSM71045     1  0.2074     0.4756 0.896 0.000 0.000 0.000 0.104
#> GSM71049     1  0.3218     0.5608 0.856 0.020 0.000 0.016 0.108
#> GSM71055     1  0.0290     0.5632 0.992 0.000 0.000 0.000 0.008
#> GSM71056     1  0.2516     0.5355 0.860 0.000 0.000 0.000 0.140
#> GSM71058     5  0.6754     0.2901 0.356 0.008 0.196 0.000 0.440
#> GSM71059     1  0.0510     0.5621 0.984 0.000 0.000 0.000 0.016
#> GSM71064     1  0.4464    -0.1518 0.584 0.000 0.008 0.000 0.408
#> GSM71065     1  0.5111    -0.1989 0.552 0.000 0.040 0.000 0.408
#> GSM71067     1  0.4294     0.0944 0.532 0.000 0.000 0.000 0.468
#> GSM71037     3  0.0290     0.9405 0.000 0.000 0.992 0.000 0.008
#> GSM71039     3  0.1082     0.9221 0.000 0.000 0.964 0.028 0.008
#> GSM71040     3  0.0579     0.9348 0.008 0.000 0.984 0.000 0.008
#> GSM71041     3  0.0798     0.9334 0.000 0.000 0.976 0.008 0.016
#> GSM71047     3  0.0880     0.9296 0.000 0.000 0.968 0.000 0.032
#> GSM71048     1  0.3883     0.5357 0.780 0.000 0.000 0.036 0.184
#> GSM71050     3  0.0693     0.9357 0.000 0.000 0.980 0.008 0.012
#> GSM71051     3  0.0290     0.9405 0.000 0.000 0.992 0.000 0.008
#> GSM71052     3  0.0162     0.9402 0.000 0.000 0.996 0.004 0.000
#> GSM71054     3  0.0162     0.9417 0.000 0.000 0.996 0.000 0.004
#> GSM71057     3  0.0162     0.9417 0.000 0.000 0.996 0.000 0.004
#> GSM71060     3  0.0162     0.9417 0.000 0.000 0.996 0.000 0.004
#> GSM71066     1  0.4654     0.4260 0.628 0.000 0.000 0.024 0.348
#> GSM71070     4  0.3906     0.5992 0.000 0.004 0.000 0.704 0.292
#> GSM71072     4  0.1872     0.7132 0.000 0.052 0.000 0.928 0.020
#> GSM71074     2  0.2914     0.8135 0.000 0.872 0.000 0.052 0.076
#> GSM71076     4  0.1648     0.7323 0.000 0.040 0.000 0.940 0.020
#> GSM71077     2  0.2554     0.8229 0.000 0.892 0.000 0.036 0.072
#> GSM71069     4  0.2773     0.7104 0.000 0.000 0.000 0.836 0.164
#> GSM71071     4  0.2110     0.7013 0.000 0.072 0.000 0.912 0.016
#> GSM71073     2  0.5987     0.1798 0.000 0.460 0.008 0.448 0.084
#> GSM71075     4  0.1908     0.7324 0.000 0.000 0.000 0.908 0.092
#> GSM71078     4  0.3053     0.6957 0.000 0.000 0.164 0.828 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
#> GSM71019     2  0.4956    -0.2608 0.004 0.592 0.000 0.000 0.332 0.072
#> GSM71020     2  0.3175     0.5515 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM71021     2  0.0260     0.5995 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM71022     2  0.1471     0.6080 0.000 0.932 0.000 0.004 0.000 0.064
#> GSM71023     6  0.6903     0.0000 0.016 0.320 0.012 0.012 0.224 0.416
#> GSM71024     5  0.4185     0.5714 0.024 0.000 0.000 0.024 0.724 0.228
#> GSM71025     2  0.0405     0.5971 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM71026     2  0.0260     0.6041 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM71027     2  0.3601     0.5134 0.004 0.684 0.000 0.000 0.000 0.312
#> GSM71028     3  0.4419     0.4290 0.004 0.000 0.652 0.304 0.000 0.040
#> GSM71030     5  0.6157     0.1857 0.032 0.000 0.000 0.152 0.508 0.308
#> GSM71032     1  0.3045     0.8590 0.840 0.000 0.000 0.000 0.060 0.100
#> GSM71034     5  0.2778     0.6645 0.008 0.000 0.000 0.000 0.824 0.168
#> GSM71035     4  0.5020     0.0889 0.004 0.000 0.436 0.500 0.000 0.060
#> GSM71038     1  0.3699     0.8421 0.796 0.000 0.000 0.004 0.088 0.112
#> GSM71043     3  0.7704    -0.0244 0.220 0.000 0.376 0.188 0.008 0.208
#> GSM71046     5  0.3578     0.6884 0.052 0.000 0.000 0.000 0.784 0.164
#> GSM71053     1  0.4184     0.8031 0.752 0.000 0.000 0.004 0.120 0.124
#> GSM71061     3  0.0692     0.8929 0.004 0.000 0.976 0.000 0.000 0.020
#> GSM71062     5  0.3099     0.6569 0.008 0.000 0.000 0.008 0.808 0.176
#> GSM71063     4  0.6614     0.3252 0.100 0.000 0.008 0.452 0.072 0.368
#> GSM71068     1  0.4520     0.8356 0.760 0.000 0.028 0.008 0.084 0.120
#> GSM71029     5  0.2339     0.6643 0.012 0.072 0.000 0.000 0.896 0.020
#> GSM71031     5  0.7151     0.2001 0.040 0.184 0.000 0.136 0.536 0.104
#> GSM71033     1  0.3229     0.8166 0.852 0.040 0.044 0.000 0.000 0.064
#> GSM71036     5  0.1779     0.7009 0.064 0.000 0.000 0.000 0.920 0.016
#> GSM71042     5  0.2282     0.6910 0.088 0.000 0.000 0.000 0.888 0.024
#> GSM71044     1  0.3109     0.8086 0.848 0.008 0.000 0.000 0.076 0.068
#> GSM71045     5  0.4552     0.4846 0.288 0.000 0.000 0.000 0.648 0.064
#> GSM71049     5  0.2915     0.6948 0.020 0.036 0.000 0.004 0.872 0.068
#> GSM71055     5  0.3285     0.6595 0.116 0.000 0.000 0.000 0.820 0.064
#> GSM71056     5  0.2930     0.6938 0.124 0.000 0.000 0.000 0.840 0.036
#> GSM71058     1  0.1579     0.8522 0.944 0.008 0.024 0.000 0.020 0.004
#> GSM71059     5  0.3123     0.6670 0.112 0.000 0.000 0.000 0.832 0.056
#> GSM71064     1  0.1411     0.8526 0.936 0.000 0.000 0.000 0.060 0.004
#> GSM71065     1  0.2701     0.8309 0.884 0.000 0.044 0.000 0.044 0.028
#> GSM71067     5  0.5411     0.4483 0.260 0.000 0.000 0.000 0.572 0.168
#> GSM71037     3  0.0717     0.8949 0.016 0.000 0.976 0.000 0.000 0.008
#> GSM71039     3  0.1562     0.8750 0.004 0.000 0.940 0.032 0.000 0.024
#> GSM71040     3  0.0363     0.8974 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM71041     3  0.0935     0.8900 0.004 0.000 0.964 0.000 0.000 0.032
#> GSM71047     3  0.1923     0.8686 0.016 0.004 0.916 0.000 0.000 0.064
#> GSM71048     5  0.2402     0.6917 0.012 0.000 0.000 0.000 0.868 0.120
#> GSM71050     3  0.1152     0.8865 0.004 0.000 0.952 0.000 0.000 0.044
#> GSM71051     3  0.0622     0.8958 0.012 0.000 0.980 0.000 0.000 0.008
#> GSM71052     3  0.0405     0.8973 0.008 0.000 0.988 0.000 0.000 0.004
#> GSM71054     3  0.0508     0.8965 0.012 0.000 0.984 0.000 0.000 0.004
#> GSM71057     3  0.0717     0.8949 0.016 0.000 0.976 0.000 0.000 0.008
#> GSM71060     3  0.0146     0.8971 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM71066     5  0.3065     0.6588 0.008 0.000 0.000 0.008 0.812 0.172
#> GSM71070     4  0.5440     0.3816 0.004 0.008 0.004 0.564 0.080 0.340
#> GSM71072     4  0.1485     0.6646 0.000 0.028 0.004 0.944 0.000 0.024
#> GSM71074     2  0.5330     0.3201 0.000 0.496 0.000 0.108 0.000 0.396
#> GSM71076     4  0.1225     0.6679 0.000 0.012 0.000 0.952 0.000 0.036
#> GSM71077     2  0.5096     0.3791 0.004 0.536 0.000 0.072 0.000 0.388
#> GSM71069     4  0.4257     0.5842 0.008 0.000 0.000 0.728 0.060 0.204
#> GSM71071     4  0.1552     0.6627 0.000 0.036 0.004 0.940 0.000 0.020
#> GSM71073     4  0.5467     0.1660 0.000 0.112 0.008 0.548 0.000 0.332
#> GSM71075     4  0.2865     0.6481 0.004 0.004 0.000 0.852 0.020 0.120
#> GSM71078     4  0.2531     0.6350 0.000 0.000 0.132 0.856 0.000 0.012

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> MAD:NMF 58    9.22e-08 2
#> MAD:NMF 56    1.09e-10 3
#> MAD:NMF 54    3.51e-17 4
#> MAD:NMF 37    1.24e-12 5
#> MAD:NMF 46    1.27e-15 6

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


ATC:hclust

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

res = res_list["ATC", "hclust"]
# you can also extract it by
# res = res_list["ATC:hclust"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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.574           0.790       0.909         0.3570 0.675   0.675
#> 3 3 0.828           0.834       0.939         0.6294 0.692   0.559
#> 4 4 0.719           0.611       0.794         0.1557 0.880   0.724
#> 5 5 0.689           0.636       0.805         0.0630 0.944   0.844
#> 6 6 0.700           0.679       0.785         0.0758 0.818   0.484

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
#> GSM71019     1  0.9286      0.548 0.656 0.344
#> GSM71020     2  0.0000      0.872 0.000 1.000
#> GSM71021     2  0.0000      0.872 0.000 1.000
#> GSM71022     2  0.0000      0.872 0.000 1.000
#> GSM71023     1  0.9286      0.548 0.656 0.344
#> GSM71024     1  0.0000      0.887 1.000 0.000
#> GSM71025     2  0.0000      0.872 0.000 1.000
#> GSM71026     2  0.0000      0.872 0.000 1.000
#> GSM71027     2  0.0000      0.872 0.000 1.000
#> GSM71028     1  0.0000      0.887 1.000 0.000
#> GSM71030     1  0.0000      0.887 1.000 0.000
#> GSM71032     1  0.0000      0.887 1.000 0.000
#> GSM71034     1  0.0000      0.887 1.000 0.000
#> GSM71035     1  0.0000      0.887 1.000 0.000
#> GSM71038     1  0.0000      0.887 1.000 0.000
#> GSM71043     1  0.0000      0.887 1.000 0.000
#> GSM71046     1  0.0000      0.887 1.000 0.000
#> GSM71053     1  0.0000      0.887 1.000 0.000
#> GSM71061     1  0.0000      0.887 1.000 0.000
#> GSM71062     1  0.0000      0.887 1.000 0.000
#> GSM71063     1  0.0000      0.887 1.000 0.000
#> GSM71068     1  0.0000      0.887 1.000 0.000
#> GSM71029     1  0.9323      0.540 0.652 0.348
#> GSM71031     1  0.0000      0.887 1.000 0.000
#> GSM71033     1  0.9286      0.548 0.656 0.344
#> GSM71036     1  0.1843      0.872 0.972 0.028
#> GSM71042     1  0.0000      0.887 1.000 0.000
#> GSM71044     1  0.9286      0.548 0.656 0.344
#> GSM71045     1  0.0000      0.887 1.000 0.000
#> GSM71049     1  0.9286      0.548 0.656 0.344
#> GSM71055     1  0.6712      0.764 0.824 0.176
#> GSM71056     1  0.6048      0.787 0.852 0.148
#> GSM71058     1  0.0000      0.887 1.000 0.000
#> GSM71059     1  0.0000      0.887 1.000 0.000
#> GSM71064     1  0.0000      0.887 1.000 0.000
#> GSM71065     1  0.6801      0.760 0.820 0.180
#> GSM71067     1  0.0000      0.887 1.000 0.000
#> GSM71037     1  0.0000      0.887 1.000 0.000
#> GSM71039     1  0.0000      0.887 1.000 0.000
#> GSM71040     1  0.0000      0.887 1.000 0.000
#> GSM71041     1  0.0000      0.887 1.000 0.000
#> GSM71047     1  0.9286      0.548 0.656 0.344
#> GSM71048     1  0.0000      0.887 1.000 0.000
#> GSM71050     1  0.0000      0.887 1.000 0.000
#> GSM71051     1  0.9286      0.548 0.656 0.344
#> GSM71052     1  0.6531      0.771 0.832 0.168
#> GSM71054     1  0.0000      0.887 1.000 0.000
#> GSM71057     1  0.0000      0.887 1.000 0.000
#> GSM71060     1  0.0000      0.887 1.000 0.000
#> GSM71066     1  0.0000      0.887 1.000 0.000
#> GSM71070     1  0.9286      0.548 0.656 0.344
#> GSM71072     2  0.9580      0.342 0.380 0.620
#> GSM71074     2  0.0000      0.872 0.000 1.000
#> GSM71076     2  0.9580      0.342 0.380 0.620
#> GSM71077     2  0.0000      0.872 0.000 1.000
#> GSM71069     1  0.7056      0.747 0.808 0.192
#> GSM71071     2  0.9580      0.342 0.380 0.620
#> GSM71073     2  0.0000      0.872 0.000 1.000
#> GSM71075     1  0.9286      0.548 0.656 0.344
#> GSM71078     1  0.0672      0.883 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71020     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71021     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71022     2  0.5859     0.5102 0.000 0.656 0.344
#> GSM71023     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71024     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71025     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71026     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71027     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71028     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71030     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71032     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71034     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71035     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71038     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71043     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71046     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71053     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71061     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71062     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71063     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71068     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71029     3  0.0237     0.8134 0.000 0.004 0.996
#> GSM71031     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71033     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71036     1  0.6008     0.3580 0.628 0.000 0.372
#> GSM71042     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71044     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71045     1  0.0892     0.9484 0.980 0.000 0.020
#> GSM71049     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71055     3  0.6295     0.1192 0.472 0.000 0.528
#> GSM71056     1  0.6309    -0.0787 0.504 0.000 0.496
#> GSM71058     1  0.0892     0.9484 0.980 0.000 0.020
#> GSM71059     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71064     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71065     3  0.5291     0.5740 0.268 0.000 0.732
#> GSM71067     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71037     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71039     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71040     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71041     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71047     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71048     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71050     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71051     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71052     3  0.5058     0.6022 0.244 0.000 0.756
#> GSM71054     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71057     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71060     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71066     1  0.0000     0.9660 1.000 0.000 0.000
#> GSM71070     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71072     3  0.5363     0.5019 0.000 0.276 0.724
#> GSM71074     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71076     3  0.5363     0.5019 0.000 0.276 0.724
#> GSM71077     2  0.0000     0.9034 0.000 1.000 0.000
#> GSM71069     3  0.3879     0.6933 0.152 0.000 0.848
#> GSM71071     3  0.5363     0.5019 0.000 0.276 0.724
#> GSM71073     2  0.5859     0.5102 0.000 0.656 0.344
#> GSM71075     3  0.0000     0.8159 0.000 0.000 1.000
#> GSM71078     1  0.3038     0.8568 0.896 0.000 0.104

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.4994      0.379 0.000 0.000 0.480 0.520
#> GSM71020     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71022     4  0.4936     -0.100 0.000 0.372 0.004 0.624
#> GSM71023     4  0.4994      0.379 0.000 0.000 0.480 0.520
#> GSM71024     1  0.1557      0.856 0.944 0.000 0.056 0.000
#> GSM71025     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71028     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71030     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71032     1  0.1557      0.856 0.944 0.000 0.056 0.000
#> GSM71034     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71035     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71038     1  0.1389      0.859 0.952 0.000 0.048 0.000
#> GSM71043     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71046     1  0.0707      0.863 0.980 0.000 0.020 0.000
#> GSM71053     1  0.1557      0.856 0.944 0.000 0.056 0.000
#> GSM71061     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71062     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71063     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71068     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71029     4  0.4967      0.401 0.000 0.000 0.452 0.548
#> GSM71031     1  0.4103      0.782 0.744 0.000 0.256 0.000
#> GSM71033     3  0.5000     -0.464 0.000 0.000 0.500 0.500
#> GSM71036     3  0.3444      0.349 0.184 0.000 0.816 0.000
#> GSM71042     1  0.4356      0.764 0.708 0.000 0.292 0.000
#> GSM71044     3  0.4999     -0.455 0.000 0.000 0.508 0.492
#> GSM71045     1  0.4817      0.649 0.612 0.000 0.388 0.000
#> GSM71049     4  0.4972      0.398 0.000 0.000 0.456 0.544
#> GSM71055     3  0.1109      0.383 0.028 0.000 0.968 0.004
#> GSM71056     3  0.1637      0.391 0.060 0.000 0.940 0.000
#> GSM71058     1  0.4817      0.649 0.612 0.000 0.388 0.000
#> GSM71059     1  0.4356      0.764 0.708 0.000 0.292 0.000
#> GSM71064     1  0.4356      0.764 0.708 0.000 0.292 0.000
#> GSM71065     3  0.3400      0.239 0.000 0.000 0.820 0.180
#> GSM71067     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71037     1  0.4072      0.783 0.748 0.000 0.252 0.000
#> GSM71039     1  0.4103      0.782 0.744 0.000 0.256 0.000
#> GSM71040     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71041     1  0.4331      0.767 0.712 0.000 0.288 0.000
#> GSM71047     4  0.4996      0.373 0.000 0.000 0.484 0.516
#> GSM71048     1  0.0707      0.863 0.980 0.000 0.020 0.000
#> GSM71050     1  0.4331      0.767 0.712 0.000 0.288 0.000
#> GSM71051     4  0.5000      0.347 0.000 0.000 0.500 0.500
#> GSM71052     3  0.4711      0.186 0.024 0.000 0.740 0.236
#> GSM71054     1  0.4072      0.783 0.748 0.000 0.252 0.000
#> GSM71057     1  0.4331      0.767 0.712 0.000 0.288 0.000
#> GSM71060     1  0.0000      0.862 1.000 0.000 0.000 0.000
#> GSM71066     1  0.0707      0.863 0.980 0.000 0.020 0.000
#> GSM71070     4  0.4304      0.429 0.000 0.000 0.284 0.716
#> GSM71072     4  0.0188      0.439 0.000 0.000 0.004 0.996
#> GSM71074     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71076     4  0.0188      0.439 0.000 0.000 0.004 0.996
#> GSM71077     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM71069     3  0.4830     -0.162 0.000 0.000 0.608 0.392
#> GSM71071     4  0.0188      0.439 0.000 0.000 0.004 0.996
#> GSM71073     4  0.4936     -0.100 0.000 0.372 0.004 0.624
#> GSM71075     4  0.4972      0.385 0.000 0.000 0.456 0.544
#> GSM71078     3  0.4972     -0.410 0.456 0.000 0.544 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
#> GSM71019     3  0.0898     0.7279 0.020 0.00 0.972 0.008 0.000
#> GSM71020     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71021     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71022     4  0.3445     0.4974 0.036 0.14 0.000 0.824 0.000
#> GSM71023     3  0.0898     0.7279 0.020 0.00 0.972 0.008 0.000
#> GSM71024     5  0.0963     0.7133 0.036 0.00 0.000 0.000 0.964
#> GSM71025     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71026     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71027     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71028     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71030     5  0.2690     0.7145 0.156 0.00 0.000 0.000 0.844
#> GSM71032     5  0.0963     0.7133 0.036 0.00 0.000 0.000 0.964
#> GSM71034     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71035     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71038     5  0.0794     0.7158 0.028 0.00 0.000 0.000 0.972
#> GSM71043     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71046     5  0.0162     0.7219 0.004 0.00 0.000 0.000 0.996
#> GSM71053     5  0.0963     0.7133 0.036 0.00 0.000 0.000 0.964
#> GSM71061     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71062     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71063     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71068     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71029     3  0.4640     0.5181 0.256 0.00 0.696 0.048 0.000
#> GSM71031     5  0.3684     0.5621 0.280 0.00 0.000 0.000 0.720
#> GSM71033     3  0.0963     0.7288 0.036 0.00 0.964 0.000 0.000
#> GSM71036     1  0.6119     0.5803 0.544 0.00 0.296 0.000 0.160
#> GSM71042     5  0.3876     0.5286 0.316 0.00 0.000 0.000 0.684
#> GSM71044     3  0.3684     0.5558 0.280 0.00 0.720 0.000 0.000
#> GSM71045     5  0.4210     0.3120 0.412 0.00 0.000 0.000 0.588
#> GSM71049     3  0.3844     0.6296 0.164 0.00 0.792 0.044 0.000
#> GSM71055     1  0.4811     0.4304 0.528 0.00 0.452 0.000 0.020
#> GSM71056     1  0.5256     0.5062 0.532 0.00 0.420 0.000 0.048
#> GSM71058     5  0.4210     0.3120 0.412 0.00 0.000 0.000 0.588
#> GSM71059     5  0.3876     0.5286 0.316 0.00 0.000 0.000 0.684
#> GSM71064     5  0.3876     0.5286 0.316 0.00 0.000 0.000 0.684
#> GSM71065     3  0.4473     0.2172 0.324 0.00 0.656 0.000 0.020
#> GSM71067     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71037     5  0.3661     0.5648 0.276 0.00 0.000 0.000 0.724
#> GSM71039     5  0.3684     0.5621 0.280 0.00 0.000 0.000 0.720
#> GSM71040     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71041     5  0.3857     0.5342 0.312 0.00 0.000 0.000 0.688
#> GSM71047     3  0.0162     0.7261 0.000 0.00 0.996 0.004 0.000
#> GSM71048     5  0.0000     0.7216 0.000 0.00 0.000 0.000 1.000
#> GSM71050     5  0.3857     0.5342 0.312 0.00 0.000 0.000 0.688
#> GSM71051     3  0.0963     0.7288 0.036 0.00 0.964 0.000 0.000
#> GSM71052     3  0.4576     0.3257 0.268 0.00 0.692 0.000 0.040
#> GSM71054     5  0.3661     0.5648 0.276 0.00 0.000 0.000 0.724
#> GSM71057     5  0.3857     0.5342 0.312 0.00 0.000 0.000 0.688
#> GSM71060     5  0.2732     0.7140 0.160 0.00 0.000 0.000 0.840
#> GSM71066     5  0.0000     0.7216 0.000 0.00 0.000 0.000 1.000
#> GSM71070     3  0.4151     0.2520 0.004 0.00 0.652 0.344 0.000
#> GSM71072     4  0.4060     0.5728 0.000 0.00 0.360 0.640 0.000
#> GSM71074     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71076     4  0.4060     0.5728 0.000 0.00 0.360 0.640 0.000
#> GSM71077     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000
#> GSM71069     3  0.5342     0.5349 0.156 0.00 0.672 0.172 0.000
#> GSM71071     4  0.4060     0.5728 0.000 0.00 0.360 0.640 0.000
#> GSM71073     4  0.3445     0.4974 0.036 0.14 0.000 0.824 0.000
#> GSM71075     3  0.3010     0.5956 0.004 0.00 0.824 0.172 0.000
#> GSM71078     1  0.5350    -0.0222 0.488 0.00 0.052 0.000 0.460

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM71019     1  0.3719      0.316 0.728  0 0.000 0.248 0.000 0.024
#> GSM71020     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71022     4  0.5855      0.331 0.000  0 0.200 0.448 0.000 0.352
#> GSM71023     1  0.3743      0.318 0.724  0 0.000 0.252 0.000 0.024
#> GSM71024     5  0.3547      0.527 0.000  0 0.332 0.000 0.668 0.000
#> GSM71025     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71028     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71030     5  0.0458      0.834 0.000  0 0.016 0.000 0.984 0.000
#> GSM71032     5  0.3547      0.527 0.000  0 0.332 0.000 0.668 0.000
#> GSM71034     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71035     5  0.0146      0.839 0.000  0 0.004 0.000 0.996 0.000
#> GSM71038     5  0.3515      0.540 0.000  0 0.324 0.000 0.676 0.000
#> GSM71043     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71046     5  0.3101      0.656 0.000  0 0.244 0.000 0.756 0.000
#> GSM71053     5  0.3547      0.527 0.000  0 0.332 0.000 0.668 0.000
#> GSM71061     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71062     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71063     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71068     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71029     6  0.5142      0.852 0.304  0 0.000 0.112 0.000 0.584
#> GSM71031     3  0.3151      0.902 0.000  0 0.748 0.000 0.252 0.000
#> GSM71033     1  0.4030      0.168 0.756  0 0.000 0.104 0.000 0.140
#> GSM71036     1  0.3867      0.131 0.512  0 0.488 0.000 0.000 0.000
#> GSM71042     3  0.2912      0.921 0.000  0 0.784 0.000 0.216 0.000
#> GSM71044     6  0.4593      0.845 0.324  0 0.000 0.056 0.000 0.620
#> GSM71045     3  0.3845      0.846 0.088  0 0.772 0.000 0.140 0.000
#> GSM71049     6  0.5360      0.730 0.436  0 0.000 0.108 0.000 0.456
#> GSM71055     1  0.3547      0.410 0.668  0 0.332 0.000 0.000 0.000
#> GSM71056     1  0.3659      0.397 0.636  0 0.364 0.000 0.000 0.000
#> GSM71058     3  0.3845      0.846 0.088  0 0.772 0.000 0.140 0.000
#> GSM71059     3  0.2912      0.921 0.000  0 0.784 0.000 0.216 0.000
#> GSM71064     3  0.2912      0.921 0.000  0 0.784 0.000 0.216 0.000
#> GSM71065     1  0.2135      0.428 0.872  0 0.128 0.000 0.000 0.000
#> GSM71067     5  0.0146      0.839 0.000  0 0.004 0.000 0.996 0.000
#> GSM71037     3  0.3175      0.899 0.000  0 0.744 0.000 0.256 0.000
#> GSM71039     3  0.3151      0.902 0.000  0 0.748 0.000 0.252 0.000
#> GSM71040     5  0.0146      0.839 0.000  0 0.004 0.000 0.996 0.000
#> GSM71041     3  0.2941      0.921 0.000  0 0.780 0.000 0.220 0.000
#> GSM71047     1  0.3240      0.341 0.752  0 0.000 0.244 0.000 0.004
#> GSM71048     5  0.3126      0.651 0.000  0 0.248 0.000 0.752 0.000
#> GSM71050     3  0.2941      0.921 0.000  0 0.780 0.000 0.220 0.000
#> GSM71051     1  0.4030      0.168 0.756  0 0.000 0.104 0.000 0.140
#> GSM71052     1  0.1908      0.419 0.900  0 0.096 0.004 0.000 0.000
#> GSM71054     3  0.3175      0.899 0.000  0 0.744 0.000 0.256 0.000
#> GSM71057     3  0.2941      0.921 0.000  0 0.780 0.000 0.220 0.000
#> GSM71060     5  0.0000      0.840 0.000  0 0.000 0.000 1.000 0.000
#> GSM71066     5  0.3126      0.651 0.000  0 0.248 0.000 0.752 0.000
#> GSM71070     4  0.4065      0.248 0.300  0 0.000 0.672 0.000 0.028
#> GSM71072     4  0.0790      0.577 0.032  0 0.000 0.968 0.000 0.000
#> GSM71074     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0790      0.577 0.032  0 0.000 0.968 0.000 0.000
#> GSM71077     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM71069     1  0.4490      0.181 0.616  0 0.008 0.348 0.000 0.028
#> GSM71071     4  0.0790      0.577 0.032  0 0.000 0.968 0.000 0.000
#> GSM71073     4  0.5855      0.331 0.000  0 0.200 0.448 0.000 0.352
#> GSM71075     4  0.4471     -0.164 0.472  0 0.000 0.500 0.000 0.028
#> GSM71078     3  0.4832      0.610 0.228  0 0.684 0.000 0.060 0.028

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> ATC:hclust 57    8.16e-06 2
#> ATC:hclust 57    3.81e-06 3
#> ATC:hclust 38    1.54e-06 4
#> ATC:hclust 51    1.16e-07 5
#> ATC:hclust 45    3.56e-10 6

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


ATC:kmeans**

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

res = res_list["ATC", "kmeans"]
# you can also extract it by
# res = res_list["ATC:kmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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 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-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 1.000           0.988       0.995         0.2335 0.828   0.693
#> 4 4 0.697           0.723       0.851         0.2396 0.824   0.589
#> 5 5 0.756           0.689       0.845         0.0781 0.856   0.537
#> 6 6 0.736           0.536       0.715         0.0519 0.892   0.552

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette p1 p2
#> GSM71019     2       0          1  0  1
#> GSM71020     2       0          1  0  1
#> GSM71021     2       0          1  0  1
#> GSM71022     2       0          1  0  1
#> GSM71023     2       0          1  0  1
#> GSM71024     1       0          1  1  0
#> GSM71025     2       0          1  0  1
#> GSM71026     2       0          1  0  1
#> GSM71027     2       0          1  0  1
#> GSM71028     1       0          1  1  0
#> GSM71030     1       0          1  1  0
#> GSM71032     1       0          1  1  0
#> GSM71034     1       0          1  1  0
#> GSM71035     1       0          1  1  0
#> GSM71038     1       0          1  1  0
#> GSM71043     1       0          1  1  0
#> GSM71046     1       0          1  1  0
#> GSM71053     1       0          1  1  0
#> GSM71061     1       0          1  1  0
#> GSM71062     1       0          1  1  0
#> GSM71063     1       0          1  1  0
#> GSM71068     1       0          1  1  0
#> GSM71029     2       0          1  0  1
#> GSM71031     1       0          1  1  0
#> GSM71033     2       0          1  0  1
#> GSM71036     1       0          1  1  0
#> GSM71042     1       0          1  1  0
#> GSM71044     2       0          1  0  1
#> GSM71045     1       0          1  1  0
#> GSM71049     2       0          1  0  1
#> GSM71055     1       0          1  1  0
#> GSM71056     1       0          1  1  0
#> GSM71058     1       0          1  1  0
#> GSM71059     1       0          1  1  0
#> GSM71064     1       0          1  1  0
#> GSM71065     1       0          1  1  0
#> GSM71067     1       0          1  1  0
#> GSM71037     1       0          1  1  0
#> GSM71039     1       0          1  1  0
#> GSM71040     1       0          1  1  0
#> GSM71041     1       0          1  1  0
#> GSM71047     2       0          1  0  1
#> GSM71048     1       0          1  1  0
#> GSM71050     1       0          1  1  0
#> GSM71051     2       0          1  0  1
#> GSM71052     1       0          1  1  0
#> GSM71054     1       0          1  1  0
#> GSM71057     1       0          1  1  0
#> GSM71060     1       0          1  1  0
#> GSM71066     1       0          1  1  0
#> GSM71070     2       0          1  0  1
#> GSM71072     2       0          1  0  1
#> GSM71074     2       0          1  0  1
#> GSM71076     2       0          1  0  1
#> GSM71077     2       0          1  0  1
#> GSM71069     1       0          1  1  0
#> GSM71071     2       0          1  0  1
#> GSM71073     2       0          1  0  1
#> GSM71075     2       0          1  0  1
#> GSM71078     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1  p2    p3
#> GSM71019     3   0.000      0.988 0.000 0.0 1.000
#> GSM71020     2   0.000      1.000 0.000 1.0 0.000
#> GSM71021     2   0.000      1.000 0.000 1.0 0.000
#> GSM71022     2   0.000      1.000 0.000 1.0 0.000
#> GSM71023     3   0.000      0.988 0.000 0.0 1.000
#> GSM71024     1   0.000      0.996 1.000 0.0 0.000
#> GSM71025     2   0.000      1.000 0.000 1.0 0.000
#> GSM71026     2   0.000      1.000 0.000 1.0 0.000
#> GSM71027     2   0.000      1.000 0.000 1.0 0.000
#> GSM71028     1   0.000      0.996 1.000 0.0 0.000
#> GSM71030     1   0.000      0.996 1.000 0.0 0.000
#> GSM71032     1   0.000      0.996 1.000 0.0 0.000
#> GSM71034     1   0.000      0.996 1.000 0.0 0.000
#> GSM71035     1   0.000      0.996 1.000 0.0 0.000
#> GSM71038     1   0.000      0.996 1.000 0.0 0.000
#> GSM71043     1   0.000      0.996 1.000 0.0 0.000
#> GSM71046     1   0.000      0.996 1.000 0.0 0.000
#> GSM71053     1   0.000      0.996 1.000 0.0 0.000
#> GSM71061     1   0.000      0.996 1.000 0.0 0.000
#> GSM71062     1   0.000      0.996 1.000 0.0 0.000
#> GSM71063     1   0.000      0.996 1.000 0.0 0.000
#> GSM71068     1   0.000      0.996 1.000 0.0 0.000
#> GSM71029     3   0.000      0.988 0.000 0.0 1.000
#> GSM71031     1   0.000      0.996 1.000 0.0 0.000
#> GSM71033     3   0.000      0.988 0.000 0.0 1.000
#> GSM71036     1   0.207      0.933 0.940 0.0 0.060
#> GSM71042     1   0.000      0.996 1.000 0.0 0.000
#> GSM71044     3   0.000      0.988 0.000 0.0 1.000
#> GSM71045     1   0.000      0.996 1.000 0.0 0.000
#> GSM71049     3   0.000      0.988 0.000 0.0 1.000
#> GSM71055     3   0.000      0.988 0.000 0.0 1.000
#> GSM71056     1   0.216      0.928 0.936 0.0 0.064
#> GSM71058     1   0.000      0.996 1.000 0.0 0.000
#> GSM71059     1   0.000      0.996 1.000 0.0 0.000
#> GSM71064     1   0.000      0.996 1.000 0.0 0.000
#> GSM71065     3   0.000      0.988 0.000 0.0 1.000
#> GSM71067     1   0.000      0.996 1.000 0.0 0.000
#> GSM71037     1   0.000      0.996 1.000 0.0 0.000
#> GSM71039     1   0.000      0.996 1.000 0.0 0.000
#> GSM71040     1   0.000      0.996 1.000 0.0 0.000
#> GSM71041     1   0.000      0.996 1.000 0.0 0.000
#> GSM71047     3   0.000      0.988 0.000 0.0 1.000
#> GSM71048     1   0.000      0.996 1.000 0.0 0.000
#> GSM71050     1   0.000      0.996 1.000 0.0 0.000
#> GSM71051     3   0.000      0.988 0.000 0.0 1.000
#> GSM71052     3   0.000      0.988 0.000 0.0 1.000
#> GSM71054     1   0.000      0.996 1.000 0.0 0.000
#> GSM71057     1   0.000      0.996 1.000 0.0 0.000
#> GSM71060     1   0.000      0.996 1.000 0.0 0.000
#> GSM71066     1   0.000      0.996 1.000 0.0 0.000
#> GSM71070     3   0.000      0.988 0.000 0.0 1.000
#> GSM71072     3   0.000      0.988 0.000 0.0 1.000
#> GSM71074     2   0.000      1.000 0.000 1.0 0.000
#> GSM71076     3   0.000      0.988 0.000 0.0 1.000
#> GSM71077     2   0.000      1.000 0.000 1.0 0.000
#> GSM71069     3   0.000      0.988 0.000 0.0 1.000
#> GSM71071     3   0.000      0.988 0.000 0.0 1.000
#> GSM71073     3   0.455      0.749 0.000 0.2 0.800
#> GSM71075     3   0.000      0.988 0.000 0.0 1.000
#> GSM71078     1   0.000      0.996 1.000 0.0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     4  0.0817     0.8934 0.024 0.000 0.000 0.976
#> GSM71020     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71022     2  0.2466     0.9164 0.096 0.900 0.000 0.004
#> GSM71023     4  0.0000     0.8933 0.000 0.000 0.000 1.000
#> GSM71024     3  0.5000    -0.1826 0.500 0.000 0.500 0.000
#> GSM71025     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71028     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71030     3  0.0707     0.7891 0.020 0.000 0.980 0.000
#> GSM71032     3  0.5000    -0.1826 0.500 0.000 0.500 0.000
#> GSM71034     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71035     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71038     3  0.4977    -0.0445 0.460 0.000 0.540 0.000
#> GSM71043     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71046     3  0.0707     0.7891 0.020 0.000 0.980 0.000
#> GSM71053     3  0.5000    -0.1826 0.500 0.000 0.500 0.000
#> GSM71061     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71062     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71063     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71068     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71029     4  0.1118     0.8943 0.036 0.000 0.000 0.964
#> GSM71031     1  0.4406     0.6794 0.700 0.000 0.300 0.000
#> GSM71033     4  0.1211     0.8909 0.040 0.000 0.000 0.960
#> GSM71036     1  0.2281     0.7118 0.904 0.000 0.000 0.096
#> GSM71042     1  0.2704     0.8064 0.876 0.000 0.124 0.000
#> GSM71044     4  0.1211     0.8909 0.040 0.000 0.000 0.960
#> GSM71045     1  0.2704     0.8064 0.876 0.000 0.124 0.000
#> GSM71049     4  0.0921     0.8929 0.028 0.000 0.000 0.972
#> GSM71055     1  0.3356     0.6249 0.824 0.000 0.000 0.176
#> GSM71056     1  0.2281     0.7118 0.904 0.000 0.000 0.096
#> GSM71058     1  0.2704     0.8064 0.876 0.000 0.124 0.000
#> GSM71059     1  0.3975     0.7501 0.760 0.000 0.240 0.000
#> GSM71064     1  0.3569     0.7859 0.804 0.000 0.196 0.000
#> GSM71065     4  0.4916     0.4571 0.424 0.000 0.000 0.576
#> GSM71067     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71037     1  0.4761     0.5475 0.628 0.000 0.372 0.000
#> GSM71039     1  0.4888     0.4413 0.588 0.000 0.412 0.000
#> GSM71040     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71041     1  0.4830     0.4902 0.608 0.000 0.392 0.000
#> GSM71047     4  0.0336     0.8941 0.008 0.000 0.000 0.992
#> GSM71048     3  0.4977    -0.0445 0.460 0.000 0.540 0.000
#> GSM71050     1  0.2814     0.8057 0.868 0.000 0.132 0.000
#> GSM71051     4  0.1211     0.8909 0.040 0.000 0.000 0.960
#> GSM71052     4  0.4916     0.4571 0.424 0.000 0.000 0.576
#> GSM71054     3  0.4331     0.4439 0.288 0.000 0.712 0.000
#> GSM71057     1  0.3610     0.7835 0.800 0.000 0.200 0.000
#> GSM71060     3  0.0000     0.7979 0.000 0.000 1.000 0.000
#> GSM71066     3  0.0707     0.7891 0.020 0.000 0.980 0.000
#> GSM71070     4  0.2149     0.8665 0.088 0.000 0.000 0.912
#> GSM71072     4  0.2281     0.8629 0.096 0.000 0.000 0.904
#> GSM71074     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71076     4  0.2281     0.8629 0.096 0.000 0.000 0.904
#> GSM71077     2  0.0000     0.9887 0.000 1.000 0.000 0.000
#> GSM71069     4  0.2589     0.8325 0.116 0.000 0.000 0.884
#> GSM71071     4  0.2281     0.8629 0.096 0.000 0.000 0.904
#> GSM71073     4  0.4022     0.8079 0.096 0.068 0.000 0.836
#> GSM71075     4  0.0000     0.8933 0.000 0.000 0.000 1.000
#> GSM71078     1  0.2704     0.8064 0.876 0.000 0.124 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
#> GSM71019     4  0.4262      0.378 0.440 0.000 0.000 0.560 0.000
#> GSM71020     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.3274      0.776 0.000 0.780 0.000 0.220 0.000
#> GSM71023     4  0.3452      0.642 0.244 0.000 0.000 0.756 0.000
#> GSM71024     3  0.4031      0.734 0.044 0.000 0.772 0.000 0.184
#> GSM71025     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.965 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0609      0.963 0.020 0.980 0.000 0.000 0.000
#> GSM71028     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71030     5  0.5119      0.383 0.048 0.000 0.360 0.000 0.592
#> GSM71032     3  0.3958      0.742 0.044 0.000 0.780 0.000 0.176
#> GSM71034     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71035     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71038     3  0.4066      0.730 0.044 0.000 0.768 0.000 0.188
#> GSM71043     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71046     5  0.5056      0.386 0.044 0.000 0.360 0.000 0.596
#> GSM71053     3  0.4031      0.734 0.044 0.000 0.772 0.000 0.184
#> GSM71061     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71062     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71063     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71068     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71029     4  0.4273      0.365 0.448 0.000 0.000 0.552 0.000
#> GSM71031     3  0.1638      0.836 0.004 0.000 0.932 0.000 0.064
#> GSM71033     1  0.4150      0.144 0.612 0.000 0.000 0.388 0.000
#> GSM71036     3  0.4256      0.248 0.436 0.000 0.564 0.000 0.000
#> GSM71042     3  0.0404      0.823 0.012 0.000 0.988 0.000 0.000
#> GSM71044     1  0.4150      0.144 0.612 0.000 0.000 0.388 0.000
#> GSM71045     3  0.0404      0.823 0.012 0.000 0.988 0.000 0.000
#> GSM71049     4  0.4307      0.214 0.496 0.000 0.000 0.504 0.000
#> GSM71055     1  0.2612      0.581 0.868 0.000 0.124 0.008 0.000
#> GSM71056     3  0.4256      0.248 0.436 0.000 0.564 0.000 0.000
#> GSM71058     3  0.0510      0.822 0.016 0.000 0.984 0.000 0.000
#> GSM71059     3  0.1628      0.838 0.008 0.000 0.936 0.000 0.056
#> GSM71064     3  0.1331      0.837 0.008 0.000 0.952 0.000 0.040
#> GSM71065     1  0.2625      0.589 0.876 0.000 0.108 0.016 0.000
#> GSM71067     5  0.1121      0.853 0.044 0.000 0.000 0.000 0.956
#> GSM71037     3  0.1768      0.834 0.004 0.000 0.924 0.000 0.072
#> GSM71039     3  0.1768      0.834 0.004 0.000 0.924 0.000 0.072
#> GSM71040     5  0.1544      0.834 0.000 0.000 0.068 0.000 0.932
#> GSM71041     3  0.1704      0.835 0.004 0.000 0.928 0.000 0.068
#> GSM71047     4  0.3932      0.559 0.328 0.000 0.000 0.672 0.000
#> GSM71048     3  0.4066      0.730 0.044 0.000 0.768 0.000 0.188
#> GSM71050     3  0.0162      0.824 0.004 0.000 0.996 0.000 0.000
#> GSM71051     1  0.4150      0.144 0.612 0.000 0.000 0.388 0.000
#> GSM71052     1  0.2573      0.589 0.880 0.000 0.104 0.016 0.000
#> GSM71054     3  0.2536      0.800 0.004 0.000 0.868 0.000 0.128
#> GSM71057     3  0.1205      0.837 0.004 0.000 0.956 0.000 0.040
#> GSM71060     5  0.0000      0.874 0.000 0.000 0.000 0.000 1.000
#> GSM71066     5  0.5167      0.264 0.044 0.000 0.404 0.000 0.552
#> GSM71070     4  0.2605      0.672 0.148 0.000 0.000 0.852 0.000
#> GSM71072     4  0.0510      0.663 0.016 0.000 0.000 0.984 0.000
#> GSM71074     2  0.0609      0.963 0.020 0.980 0.000 0.000 0.000
#> GSM71076     4  0.0000      0.657 0.000 0.000 0.000 1.000 0.000
#> GSM71077     2  0.0609      0.963 0.020 0.980 0.000 0.000 0.000
#> GSM71069     1  0.4965      0.336 0.644 0.000 0.052 0.304 0.000
#> GSM71071     4  0.0000      0.657 0.000 0.000 0.000 1.000 0.000
#> GSM71073     4  0.0290      0.650 0.000 0.008 0.000 0.992 0.000
#> GSM71075     4  0.3210      0.654 0.212 0.000 0.000 0.788 0.000
#> GSM71078     3  0.3857      0.498 0.312 0.000 0.688 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
#> GSM71019     4  0.4677     0.4723 0.328 0.000 0.044 0.620 0.008 0.000
#> GSM71020     2  0.0146     0.9292 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71021     2  0.0000     0.9293 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.5404     0.5953 0.000 0.636 0.196 0.148 0.020 0.000
#> GSM71023     4  0.3827     0.6186 0.124 0.000 0.040 0.800 0.036 0.000
#> GSM71024     5  0.3887     0.4878 0.004 0.000 0.104 0.000 0.780 0.112
#> GSM71025     2  0.0000     0.9293 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0146     0.9292 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM71027     2  0.1716     0.9219 0.000 0.932 0.036 0.000 0.028 0.004
#> GSM71028     6  0.0260     0.9338 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM71030     5  0.4040     0.4347 0.000 0.000 0.032 0.000 0.688 0.280
#> GSM71032     5  0.3908     0.4826 0.008 0.000 0.104 0.000 0.784 0.104
#> GSM71034     6  0.0363     0.9332 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM71035     6  0.0363     0.9320 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM71038     5  0.3120     0.5081 0.008 0.000 0.040 0.000 0.840 0.112
#> GSM71043     6  0.0260     0.9338 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM71046     5  0.3371     0.4438 0.000 0.000 0.000 0.000 0.708 0.292
#> GSM71053     5  0.3996     0.4864 0.008 0.000 0.104 0.000 0.776 0.112
#> GSM71061     6  0.0260     0.9338 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM71062     6  0.0363     0.9332 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM71063     6  0.0260     0.9338 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM71068     6  0.0363     0.9332 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM71029     4  0.4939     0.4554 0.336 0.000 0.048 0.600 0.016 0.000
#> GSM71031     5  0.4406    -0.5775 0.000 0.000 0.476 0.000 0.500 0.024
#> GSM71033     1  0.4773    -0.0966 0.548 0.000 0.044 0.404 0.004 0.000
#> GSM71036     1  0.5083     0.1565 0.580 0.000 0.320 0.000 0.100 0.000
#> GSM71042     3  0.3938     0.7495 0.016 0.000 0.660 0.000 0.324 0.000
#> GSM71044     1  0.4773    -0.0966 0.548 0.000 0.044 0.404 0.004 0.000
#> GSM71045     3  0.3938     0.7495 0.016 0.000 0.660 0.000 0.324 0.000
#> GSM71049     4  0.5094     0.3264 0.400 0.000 0.048 0.536 0.016 0.000
#> GSM71055     1  0.1556     0.5212 0.920 0.000 0.080 0.000 0.000 0.000
#> GSM71056     1  0.5081     0.1710 0.588 0.000 0.308 0.000 0.104 0.000
#> GSM71058     3  0.3938     0.7495 0.016 0.000 0.660 0.000 0.324 0.000
#> GSM71059     3  0.4532     0.5981 0.004 0.000 0.508 0.000 0.464 0.024
#> GSM71064     3  0.4427     0.6697 0.004 0.000 0.548 0.000 0.428 0.020
#> GSM71065     1  0.1285     0.5178 0.944 0.000 0.052 0.004 0.000 0.000
#> GSM71067     6  0.3351     0.6041 0.000 0.000 0.000 0.000 0.288 0.712
#> GSM71037     5  0.4401    -0.5541 0.000 0.000 0.464 0.000 0.512 0.024
#> GSM71039     5  0.4396    -0.5377 0.000 0.000 0.456 0.000 0.520 0.024
#> GSM71040     6  0.3717     0.5744 0.000 0.000 0.016 0.000 0.276 0.708
#> GSM71041     3  0.4385     0.6349 0.000 0.000 0.532 0.000 0.444 0.024
#> GSM71047     4  0.4557     0.5604 0.220 0.000 0.040 0.708 0.032 0.000
#> GSM71048     5  0.2003     0.5095 0.000 0.000 0.000 0.000 0.884 0.116
#> GSM71050     3  0.3945     0.7353 0.008 0.000 0.612 0.000 0.380 0.000
#> GSM71051     1  0.4792    -0.1227 0.536 0.000 0.044 0.416 0.004 0.000
#> GSM71052     1  0.2045     0.5067 0.920 0.000 0.028 0.024 0.028 0.000
#> GSM71054     5  0.4523    -0.5191 0.000 0.000 0.452 0.000 0.516 0.032
#> GSM71057     3  0.4219     0.7007 0.000 0.000 0.592 0.000 0.388 0.020
#> GSM71060     6  0.0260     0.9338 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM71066     5  0.3244     0.4901 0.000 0.000 0.000 0.000 0.732 0.268
#> GSM71070     4  0.2933     0.6433 0.068 0.000 0.028 0.868 0.036 0.000
#> GSM71072     4  0.2531     0.6266 0.000 0.000 0.132 0.856 0.012 0.000
#> GSM71074     2  0.1713     0.9215 0.000 0.928 0.044 0.000 0.028 0.000
#> GSM71076     4  0.3200     0.6029 0.000 0.000 0.196 0.788 0.016 0.000
#> GSM71077     2  0.1713     0.9215 0.000 0.928 0.044 0.000 0.028 0.000
#> GSM71069     1  0.4504     0.2715 0.648 0.000 0.012 0.308 0.032 0.000
#> GSM71071     4  0.3200     0.6029 0.000 0.000 0.196 0.788 0.016 0.000
#> GSM71073     4  0.3284     0.6010 0.000 0.000 0.196 0.784 0.020 0.000
#> GSM71075     4  0.3042     0.6230 0.128 0.000 0.004 0.836 0.032 0.000
#> GSM71078     3  0.5885     0.2922 0.348 0.000 0.444 0.000 0.208 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

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

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

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

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> ATC:kmeans 60    9.01e-06 2
#> ATC:kmeans 60    1.71e-07 3
#> ATC:kmeans 50    7.67e-10 4
#> ATC:kmeans 47    2.87e-08 5
#> ATC:kmeans 40    2.81e-07 6

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


ATC:skmeans**

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

res = res_list["ATC", "skmeans"]
# you can also extract it by
# res = res_list["ATC:skmeans"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 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 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-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.997         0.4989 0.501   0.501
#> 3 3 0.790           0.890       0.933         0.1562 0.934   0.870
#> 4 4 0.813           0.790       0.909         0.0963 0.964   0.919
#> 5 5 0.785           0.776       0.875         0.0655 0.903   0.765
#> 6 6 0.738           0.746       0.886         0.0414 0.968   0.903

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
#> GSM71019     2   0.000      0.992 0.000 1.000
#> GSM71020     2   0.000      0.992 0.000 1.000
#> GSM71021     2   0.000      0.992 0.000 1.000
#> GSM71022     2   0.000      0.992 0.000 1.000
#> GSM71023     2   0.000      0.992 0.000 1.000
#> GSM71024     1   0.000      1.000 1.000 0.000
#> GSM71025     2   0.000      0.992 0.000 1.000
#> GSM71026     2   0.000      0.992 0.000 1.000
#> GSM71027     2   0.000      0.992 0.000 1.000
#> GSM71028     1   0.000      1.000 1.000 0.000
#> GSM71030     1   0.000      1.000 1.000 0.000
#> GSM71032     1   0.000      1.000 1.000 0.000
#> GSM71034     1   0.000      1.000 1.000 0.000
#> GSM71035     1   0.000      1.000 1.000 0.000
#> GSM71038     1   0.000      1.000 1.000 0.000
#> GSM71043     1   0.000      1.000 1.000 0.000
#> GSM71046     1   0.000      1.000 1.000 0.000
#> GSM71053     1   0.000      1.000 1.000 0.000
#> GSM71061     1   0.000      1.000 1.000 0.000
#> GSM71062     1   0.000      1.000 1.000 0.000
#> GSM71063     1   0.000      1.000 1.000 0.000
#> GSM71068     1   0.000      1.000 1.000 0.000
#> GSM71029     2   0.000      0.992 0.000 1.000
#> GSM71031     1   0.000      1.000 1.000 0.000
#> GSM71033     2   0.000      0.992 0.000 1.000
#> GSM71036     1   0.000      1.000 1.000 0.000
#> GSM71042     1   0.000      1.000 1.000 0.000
#> GSM71044     2   0.000      0.992 0.000 1.000
#> GSM71045     1   0.000      1.000 1.000 0.000
#> GSM71049     2   0.000      0.992 0.000 1.000
#> GSM71055     2   0.738      0.737 0.208 0.792
#> GSM71056     1   0.000      1.000 1.000 0.000
#> GSM71058     1   0.000      1.000 1.000 0.000
#> GSM71059     1   0.000      1.000 1.000 0.000
#> GSM71064     1   0.000      1.000 1.000 0.000
#> GSM71065     2   0.000      0.992 0.000 1.000
#> GSM71067     1   0.000      1.000 1.000 0.000
#> GSM71037     1   0.000      1.000 1.000 0.000
#> GSM71039     1   0.000      1.000 1.000 0.000
#> GSM71040     1   0.000      1.000 1.000 0.000
#> GSM71041     1   0.000      1.000 1.000 0.000
#> GSM71047     2   0.000      0.992 0.000 1.000
#> GSM71048     1   0.000      1.000 1.000 0.000
#> GSM71050     1   0.000      1.000 1.000 0.000
#> GSM71051     2   0.000      0.992 0.000 1.000
#> GSM71052     2   0.000      0.992 0.000 1.000
#> GSM71054     1   0.000      1.000 1.000 0.000
#> GSM71057     1   0.000      1.000 1.000 0.000
#> GSM71060     1   0.000      1.000 1.000 0.000
#> GSM71066     1   0.000      1.000 1.000 0.000
#> GSM71070     2   0.000      0.992 0.000 1.000
#> GSM71072     2   0.000      0.992 0.000 1.000
#> GSM71074     2   0.000      0.992 0.000 1.000
#> GSM71076     2   0.000      0.992 0.000 1.000
#> GSM71077     2   0.000      0.992 0.000 1.000
#> GSM71069     2   0.000      0.992 0.000 1.000
#> GSM71071     2   0.000      0.992 0.000 1.000
#> GSM71073     2   0.000      0.992 0.000 1.000
#> GSM71075     2   0.000      0.992 0.000 1.000
#> GSM71078     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
#> GSM71019     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71020     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71021     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71022     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71023     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71024     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71025     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71026     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71027     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71028     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71030     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71032     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71034     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71035     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71038     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71043     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71046     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71053     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71061     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71062     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71063     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71068     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71029     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71031     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71033     2  0.5016      0.835 0.000 0.760 0.240
#> GSM71036     3  0.5678      0.618 0.316 0.000 0.684
#> GSM71042     1  0.4178      0.772 0.828 0.000 0.172
#> GSM71044     2  0.5733      0.745 0.000 0.676 0.324
#> GSM71045     1  0.4178      0.772 0.828 0.000 0.172
#> GSM71049     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71055     3  0.1289      0.653 0.000 0.032 0.968
#> GSM71056     3  0.5926      0.555 0.356 0.000 0.644
#> GSM71058     1  0.4178      0.772 0.828 0.000 0.172
#> GSM71059     1  0.4178      0.772 0.828 0.000 0.172
#> GSM71064     1  0.4178      0.772 0.828 0.000 0.172
#> GSM71065     3  0.1289      0.653 0.000 0.032 0.968
#> GSM71067     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71037     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71039     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71040     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71041     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71047     2  0.0424      0.882 0.000 0.992 0.008
#> GSM71048     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71050     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71051     2  0.4399      0.875 0.000 0.812 0.188
#> GSM71052     2  0.5016      0.684 0.000 0.760 0.240
#> GSM71054     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71057     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71060     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71066     1  0.0000      0.965 1.000 0.000 0.000
#> GSM71070     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71072     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71074     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71076     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71077     2  0.3551      0.905 0.000 0.868 0.132
#> GSM71069     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71071     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71073     2  0.0424      0.882 0.000 0.992 0.008
#> GSM71075     2  0.1289      0.875 0.000 0.968 0.032
#> GSM71078     1  0.0000      0.965 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71020     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71021     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71022     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4948     0.0974 0.000 0.560 0.000 0.440
#> GSM71024     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71025     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71026     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71027     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71028     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71030     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71032     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71034     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71035     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71038     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71043     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71046     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71053     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71061     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71062     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71063     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71068     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71029     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71031     1  0.1716     0.8863 0.936 0.000 0.064 0.000
#> GSM71033     2  0.1637     0.8090 0.000 0.940 0.000 0.060
#> GSM71036     3  0.1389     0.7116 0.048 0.000 0.952 0.000
#> GSM71042     1  0.4713     0.5194 0.640 0.000 0.360 0.000
#> GSM71044     2  0.3266     0.7400 0.000 0.868 0.024 0.108
#> GSM71045     1  0.4679     0.5336 0.648 0.000 0.352 0.000
#> GSM71049     2  0.0188     0.8467 0.000 0.996 0.000 0.004
#> GSM71055     3  0.2593     0.6990 0.000 0.004 0.892 0.104
#> GSM71056     3  0.3024     0.6606 0.148 0.000 0.852 0.000
#> GSM71058     1  0.4746     0.5039 0.632 0.000 0.368 0.000
#> GSM71059     1  0.4697     0.5268 0.644 0.000 0.356 0.000
#> GSM71064     1  0.4697     0.5268 0.644 0.000 0.356 0.000
#> GSM71065     3  0.6308     0.4543 0.000 0.232 0.648 0.120
#> GSM71067     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71037     1  0.0817     0.9174 0.976 0.000 0.024 0.000
#> GSM71039     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71040     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71041     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71047     2  0.2011     0.7973 0.000 0.920 0.000 0.080
#> GSM71048     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71050     1  0.0188     0.9298 0.996 0.000 0.004 0.000
#> GSM71051     2  0.1211     0.8239 0.000 0.960 0.000 0.040
#> GSM71052     2  0.6727     0.0773 0.000 0.496 0.092 0.412
#> GSM71054     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71057     1  0.0817     0.9174 0.976 0.000 0.024 0.000
#> GSM71060     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71066     1  0.0000     0.9320 1.000 0.000 0.000 0.000
#> GSM71070     4  0.3444     0.9381 0.000 0.184 0.000 0.816
#> GSM71072     2  0.4431     0.4898 0.000 0.696 0.000 0.304
#> GSM71074     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71076     2  0.4996    -0.0929 0.000 0.516 0.000 0.484
#> GSM71077     2  0.0000     0.8486 0.000 1.000 0.000 0.000
#> GSM71069     4  0.2814     0.9259 0.000 0.132 0.000 0.868
#> GSM71071     2  0.4431     0.4898 0.000 0.696 0.000 0.304
#> GSM71073     2  0.1940     0.8017 0.000 0.924 0.000 0.076
#> GSM71075     4  0.3219     0.9543 0.000 0.164 0.000 0.836
#> GSM71078     1  0.0921     0.9116 0.972 0.000 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71020     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71022     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71023     2  0.4138     0.4754 0.000 0.616 0.000 0.384 0.000
#> GSM71024     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71025     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71028     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71030     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71032     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71034     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71035     5  0.0609     0.9236 0.000 0.000 0.020 0.000 0.980
#> GSM71038     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71043     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71046     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71053     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71061     5  0.0510     0.9258 0.000 0.000 0.016 0.000 0.984
#> GSM71062     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71063     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71068     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71029     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71031     5  0.4570     0.0686 0.348 0.000 0.020 0.000 0.632
#> GSM71033     2  0.2690     0.7325 0.000 0.844 0.156 0.000 0.000
#> GSM71036     1  0.2141    -0.0884 0.916 0.000 0.064 0.004 0.016
#> GSM71042     1  0.4161     0.7474 0.608 0.000 0.000 0.000 0.392
#> GSM71044     2  0.4171     0.2594 0.000 0.604 0.396 0.000 0.000
#> GSM71045     1  0.4101     0.7542 0.628 0.000 0.000 0.000 0.372
#> GSM71049     2  0.0290     0.8645 0.000 0.992 0.008 0.000 0.000
#> GSM71055     3  0.4147     0.5378 0.316 0.008 0.676 0.000 0.000
#> GSM71056     1  0.5996     0.0523 0.572 0.000 0.128 0.004 0.296
#> GSM71058     1  0.4114     0.7546 0.624 0.000 0.000 0.000 0.376
#> GSM71059     1  0.4161     0.7474 0.608 0.000 0.000 0.000 0.392
#> GSM71064     1  0.4161     0.7474 0.608 0.000 0.000 0.000 0.392
#> GSM71065     3  0.3980     0.5874 0.128 0.076 0.796 0.000 0.000
#> GSM71067     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71037     5  0.3513     0.6624 0.180 0.000 0.020 0.000 0.800
#> GSM71039     5  0.2270     0.8495 0.076 0.000 0.020 0.000 0.904
#> GSM71040     5  0.0510     0.9258 0.000 0.000 0.016 0.000 0.984
#> GSM71041     5  0.0510     0.9258 0.000 0.000 0.016 0.000 0.984
#> GSM71047     2  0.1892     0.8251 0.000 0.916 0.004 0.080 0.000
#> GSM71048     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71050     5  0.1943     0.8725 0.056 0.000 0.020 0.000 0.924
#> GSM71051     2  0.1341     0.8342 0.000 0.944 0.056 0.000 0.000
#> GSM71052     3  0.7233     0.1795 0.048 0.236 0.500 0.216 0.000
#> GSM71054     5  0.2208     0.8543 0.072 0.000 0.020 0.000 0.908
#> GSM71057     5  0.2969     0.7688 0.128 0.000 0.020 0.000 0.852
#> GSM71060     5  0.0609     0.9236 0.000 0.000 0.020 0.000 0.980
#> GSM71066     5  0.0000     0.9323 0.000 0.000 0.000 0.000 1.000
#> GSM71070     4  0.0880     0.9592 0.000 0.032 0.000 0.968 0.000
#> GSM71072     2  0.3774     0.6220 0.000 0.704 0.000 0.296 0.000
#> GSM71074     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71076     2  0.4182     0.4424 0.000 0.600 0.000 0.400 0.000
#> GSM71077     2  0.0000     0.8682 0.000 1.000 0.000 0.000 0.000
#> GSM71069     4  0.0324     0.9442 0.000 0.004 0.004 0.992 0.000
#> GSM71071     2  0.3661     0.6474 0.000 0.724 0.000 0.276 0.000
#> GSM71073     2  0.1121     0.8487 0.000 0.956 0.000 0.044 0.000
#> GSM71075     4  0.0703     0.9675 0.000 0.024 0.000 0.976 0.000
#> GSM71078     5  0.3546     0.7281 0.004 0.000 0.116 0.048 0.832

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     2  0.0146     0.8991 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71020     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     2  0.0146     0.8991 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM71023     2  0.3531     0.5760 0.000 0.672 0.000 0.328 0.000 0.000
#> GSM71024     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71025     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71030     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71032     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71034     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71035     5  0.0777     0.9010 0.004 0.000 0.024 0.000 0.972 0.000
#> GSM71038     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71043     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71046     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71053     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71061     5  0.0777     0.9010 0.004 0.000 0.024 0.000 0.972 0.000
#> GSM71062     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71063     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71068     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71029     2  0.0508     0.8929 0.000 0.984 0.004 0.000 0.000 0.012
#> GSM71031     1  0.4488     0.4106 0.548 0.000 0.032 0.000 0.420 0.000
#> GSM71033     2  0.3364     0.6640 0.000 0.780 0.024 0.000 0.000 0.196
#> GSM71036     1  0.4313    -0.0295 0.728 0.000 0.148 0.000 0.000 0.124
#> GSM71042     1  0.3050     0.7322 0.764 0.000 0.000 0.000 0.236 0.000
#> GSM71044     6  0.4250     0.0574 0.000 0.456 0.016 0.000 0.000 0.528
#> GSM71045     1  0.3050     0.7320 0.764 0.000 0.000 0.000 0.236 0.000
#> GSM71049     2  0.1196     0.8744 0.000 0.952 0.008 0.000 0.000 0.040
#> GSM71055     6  0.2733     0.2274 0.080 0.000 0.056 0.000 0.000 0.864
#> GSM71056     1  0.7596    -0.2246 0.336 0.000 0.256 0.000 0.228 0.180
#> GSM71058     1  0.2969     0.7245 0.776 0.000 0.000 0.000 0.224 0.000
#> GSM71059     1  0.3076     0.7307 0.760 0.000 0.000 0.000 0.240 0.000
#> GSM71064     1  0.3050     0.7322 0.764 0.000 0.000 0.000 0.236 0.000
#> GSM71065     6  0.1429     0.2272 0.004 0.004 0.052 0.000 0.000 0.940
#> GSM71067     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71037     5  0.4332     0.3708 0.316 0.000 0.040 0.000 0.644 0.000
#> GSM71039     5  0.3555     0.6816 0.184 0.000 0.040 0.000 0.776 0.000
#> GSM71040     5  0.0972     0.8978 0.008 0.000 0.028 0.000 0.964 0.000
#> GSM71041     5  0.0972     0.8977 0.008 0.000 0.028 0.000 0.964 0.000
#> GSM71047     2  0.1152     0.8830 0.000 0.952 0.004 0.044 0.000 0.000
#> GSM71048     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71050     5  0.3278     0.7322 0.152 0.000 0.040 0.000 0.808 0.000
#> GSM71051     2  0.2724     0.7988 0.000 0.864 0.084 0.000 0.000 0.052
#> GSM71052     3  0.4007     0.0000 0.000 0.064 0.800 0.056 0.000 0.080
#> GSM71054     5  0.3456     0.7010 0.172 0.000 0.040 0.000 0.788 0.000
#> GSM71057     5  0.4085     0.5364 0.252 0.000 0.044 0.000 0.704 0.000
#> GSM71060     5  0.1010     0.8952 0.004 0.000 0.036 0.000 0.960 0.000
#> GSM71066     5  0.0000     0.9127 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM71070     4  0.0713     0.9460 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM71072     2  0.2491     0.7910 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM71074     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71076     2  0.3607     0.5485 0.000 0.652 0.000 0.348 0.000 0.000
#> GSM71077     2  0.0000     0.8996 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71069     4  0.0547     0.9228 0.000 0.000 0.020 0.980 0.000 0.000
#> GSM71071     2  0.2378     0.8023 0.000 0.848 0.000 0.152 0.000 0.000
#> GSM71073     2  0.1007     0.8843 0.000 0.956 0.000 0.044 0.000 0.000
#> GSM71075     4  0.0692     0.9556 0.000 0.020 0.004 0.976 0.000 0.000
#> GSM71078     5  0.3780     0.5921 0.004 0.000 0.248 0.020 0.728 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> ATC:skmeans 60    2.25e-05 2
#> ATC:skmeans 60    3.05e-06 3
#> ATC:skmeans 54    1.71e-06 4
#> ATC:skmeans 53    2.00e-08 5
#> ATC:skmeans 52    2.32e-09 6

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


ATC:pam*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.965           0.978       0.989         0.4955 0.501   0.501
#> 3 3 1.000           0.997       0.999         0.1717 0.919   0.837
#> 4 4 0.976           0.947       0.978         0.2320 0.873   0.697
#> 5 5 0.884           0.838       0.917         0.0576 0.956   0.851
#> 6 6 0.905           0.796       0.912         0.0356 0.937   0.759

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2   0.000      0.973 0.000 1.000
#> GSM71020     2   0.000      0.973 0.000 1.000
#> GSM71021     2   0.000      0.973 0.000 1.000
#> GSM71022     2   0.000      0.973 0.000 1.000
#> GSM71023     2   0.000      0.973 0.000 1.000
#> GSM71024     1   0.000      1.000 1.000 0.000
#> GSM71025     2   0.000      0.973 0.000 1.000
#> GSM71026     2   0.000      0.973 0.000 1.000
#> GSM71027     2   0.000      0.973 0.000 1.000
#> GSM71028     1   0.000      1.000 1.000 0.000
#> GSM71030     1   0.000      1.000 1.000 0.000
#> GSM71032     1   0.000      1.000 1.000 0.000
#> GSM71034     1   0.000      1.000 1.000 0.000
#> GSM71035     1   0.000      1.000 1.000 0.000
#> GSM71038     1   0.000      1.000 1.000 0.000
#> GSM71043     1   0.000      1.000 1.000 0.000
#> GSM71046     1   0.000      1.000 1.000 0.000
#> GSM71053     1   0.000      1.000 1.000 0.000
#> GSM71061     1   0.000      1.000 1.000 0.000
#> GSM71062     1   0.000      1.000 1.000 0.000
#> GSM71063     1   0.000      1.000 1.000 0.000
#> GSM71068     1   0.000      1.000 1.000 0.000
#> GSM71029     2   0.000      0.973 0.000 1.000
#> GSM71031     1   0.000      1.000 1.000 0.000
#> GSM71033     2   0.000      0.973 0.000 1.000
#> GSM71036     1   0.000      1.000 1.000 0.000
#> GSM71042     1   0.000      1.000 1.000 0.000
#> GSM71044     2   0.000      0.973 0.000 1.000
#> GSM71045     1   0.000      1.000 1.000 0.000
#> GSM71049     2   0.000      0.973 0.000 1.000
#> GSM71055     2   0.689      0.800 0.184 0.816
#> GSM71056     1   0.000      1.000 1.000 0.000
#> GSM71058     1   0.000      1.000 1.000 0.000
#> GSM71059     1   0.000      1.000 1.000 0.000
#> GSM71064     1   0.000      1.000 1.000 0.000
#> GSM71065     2   0.680      0.805 0.180 0.820
#> GSM71067     1   0.000      1.000 1.000 0.000
#> GSM71037     1   0.000      1.000 1.000 0.000
#> GSM71039     1   0.000      1.000 1.000 0.000
#> GSM71040     1   0.000      1.000 1.000 0.000
#> GSM71041     1   0.000      1.000 1.000 0.000
#> GSM71047     2   0.000      0.973 0.000 1.000
#> GSM71048     1   0.000      1.000 1.000 0.000
#> GSM71050     1   0.000      1.000 1.000 0.000
#> GSM71051     2   0.000      0.973 0.000 1.000
#> GSM71052     2   0.680      0.805 0.180 0.820
#> GSM71054     1   0.000      1.000 1.000 0.000
#> GSM71057     1   0.000      1.000 1.000 0.000
#> GSM71060     1   0.000      1.000 1.000 0.000
#> GSM71066     1   0.000      1.000 1.000 0.000
#> GSM71070     2   0.000      0.973 0.000 1.000
#> GSM71072     2   0.000      0.973 0.000 1.000
#> GSM71074     2   0.000      0.973 0.000 1.000
#> GSM71076     2   0.000      0.973 0.000 1.000
#> GSM71077     2   0.000      0.973 0.000 1.000
#> GSM71069     2   0.552      0.863 0.128 0.872
#> GSM71071     2   0.000      0.973 0.000 1.000
#> GSM71073     2   0.000      0.973 0.000 1.000
#> GSM71075     2   0.000      0.973 0.000 1.000
#> GSM71078     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
#> GSM71019     3   0.000      0.994 0.000  0 1.000
#> GSM71020     2   0.000      1.000 0.000  1 0.000
#> GSM71021     2   0.000      1.000 0.000  1 0.000
#> GSM71022     2   0.000      1.000 0.000  1 0.000
#> GSM71023     3   0.000      0.994 0.000  0 1.000
#> GSM71024     1   0.000      1.000 1.000  0 0.000
#> GSM71025     2   0.000      1.000 0.000  1 0.000
#> GSM71026     2   0.000      1.000 0.000  1 0.000
#> GSM71027     2   0.000      1.000 0.000  1 0.000
#> GSM71028     1   0.000      1.000 1.000  0 0.000
#> GSM71030     1   0.000      1.000 1.000  0 0.000
#> GSM71032     1   0.000      1.000 1.000  0 0.000
#> GSM71034     1   0.000      1.000 1.000  0 0.000
#> GSM71035     1   0.000      1.000 1.000  0 0.000
#> GSM71038     1   0.000      1.000 1.000  0 0.000
#> GSM71043     1   0.000      1.000 1.000  0 0.000
#> GSM71046     1   0.000      1.000 1.000  0 0.000
#> GSM71053     1   0.000      1.000 1.000  0 0.000
#> GSM71061     1   0.000      1.000 1.000  0 0.000
#> GSM71062     1   0.000      1.000 1.000  0 0.000
#> GSM71063     1   0.000      1.000 1.000  0 0.000
#> GSM71068     1   0.000      1.000 1.000  0 0.000
#> GSM71029     3   0.000      0.994 0.000  0 1.000
#> GSM71031     1   0.000      1.000 1.000  0 0.000
#> GSM71033     3   0.000      0.994 0.000  0 1.000
#> GSM71036     1   0.000      1.000 1.000  0 0.000
#> GSM71042     1   0.000      1.000 1.000  0 0.000
#> GSM71044     3   0.000      0.994 0.000  0 1.000
#> GSM71045     1   0.000      1.000 1.000  0 0.000
#> GSM71049     3   0.000      0.994 0.000  0 1.000
#> GSM71055     3   0.226      0.900 0.068  0 0.932
#> GSM71056     1   0.000      1.000 1.000  0 0.000
#> GSM71058     1   0.000      1.000 1.000  0 0.000
#> GSM71059     1   0.000      1.000 1.000  0 0.000
#> GSM71064     1   0.000      1.000 1.000  0 0.000
#> GSM71065     3   0.000      0.994 0.000  0 1.000
#> GSM71067     1   0.000      1.000 1.000  0 0.000
#> GSM71037     1   0.000      1.000 1.000  0 0.000
#> GSM71039     1   0.000      1.000 1.000  0 0.000
#> GSM71040     1   0.000      1.000 1.000  0 0.000
#> GSM71041     1   0.000      1.000 1.000  0 0.000
#> GSM71047     3   0.000      0.994 0.000  0 1.000
#> GSM71048     1   0.000      1.000 1.000  0 0.000
#> GSM71050     1   0.000      1.000 1.000  0 0.000
#> GSM71051     3   0.000      0.994 0.000  0 1.000
#> GSM71052     3   0.000      0.994 0.000  0 1.000
#> GSM71054     1   0.000      1.000 1.000  0 0.000
#> GSM71057     1   0.000      1.000 1.000  0 0.000
#> GSM71060     1   0.000      1.000 1.000  0 0.000
#> GSM71066     1   0.000      1.000 1.000  0 0.000
#> GSM71070     3   0.000      0.994 0.000  0 1.000
#> GSM71072     3   0.000      0.994 0.000  0 1.000
#> GSM71074     2   0.000      1.000 0.000  1 0.000
#> GSM71076     3   0.000      0.994 0.000  0 1.000
#> GSM71077     2   0.000      1.000 0.000  1 0.000
#> GSM71069     3   0.000      0.994 0.000  0 1.000
#> GSM71071     3   0.000      0.994 0.000  0 1.000
#> GSM71073     3   0.000      0.994 0.000  0 1.000
#> GSM71075     3   0.000      0.994 0.000  0 1.000
#> GSM71078     1   0.000      1.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1 p2    p3    p4
#> GSM71019     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71020     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71022     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71023     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71024     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71025     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71028     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71030     1  0.0592      0.946 0.984  0 0.016 0.000
#> GSM71032     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71034     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71035     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71038     1  0.1022      0.933 0.968  0 0.032 0.000
#> GSM71043     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71046     1  0.4193      0.657 0.732  0 0.268 0.000
#> GSM71053     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71061     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71062     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71063     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71068     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71029     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71031     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71033     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71036     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71042     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71044     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71045     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71049     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71055     4  0.3266      0.778 0.168  0 0.000 0.832
#> GSM71056     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71058     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71059     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71064     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71065     4  0.0188      0.979 0.004  0 0.000 0.996
#> GSM71067     1  0.4985      0.197 0.532  0 0.468 0.000
#> GSM71037     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71039     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71040     1  0.4193      0.657 0.732  0 0.268 0.000
#> GSM71041     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71047     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71048     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71050     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71051     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71052     4  0.1474      0.933 0.052  0 0.000 0.948
#> GSM71054     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71057     1  0.0000      0.954 1.000  0 0.000 0.000
#> GSM71060     3  0.0000      1.000 0.000  0 1.000 0.000
#> GSM71066     1  0.0188      0.954 0.996  0 0.004 0.000
#> GSM71070     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71072     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71074     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71076     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71077     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM71069     4  0.1022      0.953 0.032  0 0.000 0.968
#> GSM71071     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71073     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71075     4  0.0000      0.982 0.000  0 0.000 1.000
#> GSM71078     1  0.0000      0.954 1.000  0 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
#> GSM71019     1  0.3707      0.754 0.716 0.00 0.000 0.284 0.000
#> GSM71020     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71021     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71022     2  0.2732      0.821 0.000 0.84 0.000 0.160 0.000
#> GSM71023     1  0.3730      0.750 0.712 0.00 0.000 0.288 0.000
#> GSM71024     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71025     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71026     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71027     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71028     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71030     5  0.0290      0.944 0.000 0.00 0.008 0.000 0.992
#> GSM71032     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71034     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71035     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71038     5  0.0609      0.937 0.000 0.00 0.020 0.000 0.980
#> GSM71043     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71046     5  0.1965      0.878 0.000 0.00 0.096 0.000 0.904
#> GSM71053     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71061     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71062     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71063     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71068     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71029     1  0.3707      0.754 0.716 0.00 0.000 0.284 0.000
#> GSM71031     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71033     1  0.3395      0.773 0.764 0.00 0.000 0.236 0.000
#> GSM71036     5  0.3707      0.673 0.284 0.00 0.000 0.000 0.716
#> GSM71042     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71044     1  0.1851      0.699 0.912 0.00 0.000 0.088 0.000
#> GSM71045     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71049     1  0.3480      0.770 0.752 0.00 0.000 0.248 0.000
#> GSM71055     1  0.0000      0.638 1.000 0.00 0.000 0.000 0.000
#> GSM71056     5  0.3707      0.673 0.284 0.00 0.000 0.000 0.716
#> GSM71058     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71059     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71064     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71065     1  0.0000      0.638 1.000 0.00 0.000 0.000 0.000
#> GSM71067     5  0.3796      0.612 0.000 0.00 0.300 0.000 0.700
#> GSM71037     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71039     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71040     5  0.1965      0.878 0.000 0.00 0.096 0.000 0.904
#> GSM71041     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71047     1  0.3730      0.750 0.712 0.00 0.000 0.288 0.000
#> GSM71048     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71050     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71051     1  0.3395      0.773 0.764 0.00 0.000 0.236 0.000
#> GSM71052     1  0.2905      0.477 0.868 0.00 0.000 0.096 0.036
#> GSM71054     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71057     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71060     3  0.0000      1.000 0.000 0.00 1.000 0.000 0.000
#> GSM71066     5  0.0000      0.949 0.000 0.00 0.000 0.000 1.000
#> GSM71070     4  0.0703      0.665 0.024 0.00 0.000 0.976 0.000
#> GSM71072     4  0.1965      0.701 0.096 0.00 0.000 0.904 0.000
#> GSM71074     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71076     4  0.1965      0.701 0.096 0.00 0.000 0.904 0.000
#> GSM71077     2  0.0000      0.977 0.000 1.00 0.000 0.000 0.000
#> GSM71069     4  0.4262      0.314 0.440 0.00 0.000 0.560 0.000
#> GSM71071     4  0.1965      0.701 0.096 0.00 0.000 0.904 0.000
#> GSM71073     4  0.4305     -0.303 0.488 0.00 0.000 0.512 0.000
#> GSM71075     4  0.3274      0.495 0.220 0.00 0.000 0.780 0.000
#> GSM71078     5  0.2653      0.858 0.024 0.00 0.000 0.096 0.880

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1   p2    p3    p4    p5    p6
#> GSM71019     1  0.0000     0.8207 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM71020     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71022     4  0.3851     0.1160 0.000 0.46 0.000 0.540 0.000 0.000
#> GSM71023     1  0.0632     0.8127 0.976 0.00 0.024 0.000 0.000 0.000
#> GSM71024     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71025     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71028     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71030     5  0.0146     0.9560 0.000 0.00 0.000 0.000 0.996 0.004
#> GSM71032     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71034     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71035     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71038     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71043     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71046     5  0.0713     0.9325 0.000 0.00 0.000 0.000 0.972 0.028
#> GSM71053     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71061     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71062     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71063     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71068     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71029     1  0.0692     0.8219 0.976 0.00 0.020 0.004 0.000 0.000
#> GSM71031     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71033     1  0.1444     0.7885 0.928 0.00 0.072 0.000 0.000 0.000
#> GSM71036     3  0.3797     0.3585 0.000 0.00 0.580 0.000 0.420 0.000
#> GSM71042     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71044     1  0.3838     0.0102 0.552 0.00 0.448 0.000 0.000 0.000
#> GSM71045     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71049     1  0.0632     0.8214 0.976 0.00 0.024 0.000 0.000 0.000
#> GSM71055     3  0.3797     0.1269 0.420 0.00 0.580 0.000 0.000 0.000
#> GSM71056     3  0.3797     0.3585 0.000 0.00 0.580 0.000 0.420 0.000
#> GSM71058     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71059     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71064     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71065     3  0.3797     0.1269 0.420 0.00 0.580 0.000 0.000 0.000
#> GSM71067     5  0.3050     0.6353 0.000 0.00 0.000 0.000 0.764 0.236
#> GSM71037     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71039     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71040     5  0.0713     0.9325 0.000 0.00 0.000 0.000 0.972 0.028
#> GSM71041     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71047     1  0.0632     0.8127 0.976 0.00 0.024 0.000 0.000 0.000
#> GSM71048     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71050     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71051     1  0.0865     0.8180 0.964 0.00 0.036 0.000 0.000 0.000
#> GSM71052     3  0.0790     0.3334 0.032 0.00 0.968 0.000 0.000 0.000
#> GSM71054     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71057     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71060     6  0.0000     1.0000 0.000 0.00 0.000 0.000 0.000 1.000
#> GSM71066     5  0.0000     0.9594 0.000 0.00 0.000 0.000 1.000 0.000
#> GSM71070     4  0.5681     0.3337 0.156 0.00 0.420 0.424 0.000 0.000
#> GSM71072     4  0.2482     0.6857 0.148 0.00 0.004 0.848 0.000 0.000
#> GSM71074     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71076     4  0.0632     0.7536 0.024 0.00 0.000 0.976 0.000 0.000
#> GSM71077     2  0.0000     1.0000 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM71069     3  0.3265     0.1094 0.248 0.00 0.748 0.004 0.000 0.000
#> GSM71071     4  0.0632     0.7536 0.024 0.00 0.000 0.976 0.000 0.000
#> GSM71073     4  0.0146     0.7439 0.004 0.00 0.000 0.996 0.000 0.000
#> GSM71075     1  0.3930     0.2985 0.576 0.00 0.420 0.004 0.000 0.000
#> GSM71078     5  0.3810     0.2252 0.000 0.00 0.428 0.000 0.572 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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

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

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

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

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> ATC:pam 60    2.25e-05 2
#> ATC:pam 60    1.71e-07 3
#> ATC:pam 59    4.91e-09 4
#> ATC:pam 56    3.83e-11 5
#> ATC:pam 49    2.98e-10 6

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


ATC:mclust

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

res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]

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

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.721           0.856       0.939         0.4674 0.512   0.512
#> 3 3 0.521           0.800       0.885         0.2660 0.795   0.639
#> 4 4 0.590           0.792       0.798         0.1383 0.897   0.767
#> 5 5 0.706           0.823       0.870         0.1434 0.770   0.432
#> 6 6 0.821           0.856       0.904         0.0608 0.929   0.694

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

suggest_best_k(res)
#> [1] 6

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
#> GSM71019     2  0.7453     0.7305 0.212 0.788
#> GSM71020     2  0.0672     0.8845 0.008 0.992
#> GSM71021     2  0.0672     0.8845 0.008 0.992
#> GSM71022     2  0.0672     0.8845 0.008 0.992
#> GSM71023     2  0.0672     0.8845 0.008 0.992
#> GSM71024     1  0.1184     0.9504 0.984 0.016
#> GSM71025     2  0.0672     0.8845 0.008 0.992
#> GSM71026     2  0.0672     0.8845 0.008 0.992
#> GSM71027     2  0.0672     0.8845 0.008 0.992
#> GSM71028     1  0.0000     0.9643 1.000 0.000
#> GSM71030     1  0.0672     0.9589 0.992 0.008
#> GSM71032     1  0.0672     0.9589 0.992 0.008
#> GSM71034     1  0.0000     0.9643 1.000 0.000
#> GSM71035     1  0.0000     0.9643 1.000 0.000
#> GSM71038     1  0.0672     0.9589 0.992 0.008
#> GSM71043     1  0.0000     0.9643 1.000 0.000
#> GSM71046     1  0.0672     0.9589 0.992 0.008
#> GSM71053     1  0.0376     0.9613 0.996 0.004
#> GSM71061     1  0.0000     0.9643 1.000 0.000
#> GSM71062     1  0.0000     0.9643 1.000 0.000
#> GSM71063     1  0.0000     0.9643 1.000 0.000
#> GSM71068     1  0.0000     0.9643 1.000 0.000
#> GSM71029     2  0.7950     0.7007 0.240 0.760
#> GSM71031     1  0.0000     0.9643 1.000 0.000
#> GSM71033     2  0.9909     0.3381 0.444 0.556
#> GSM71036     1  0.0000     0.9643 1.000 0.000
#> GSM71042     1  0.0000     0.9643 1.000 0.000
#> GSM71044     1  0.9963    -0.0749 0.536 0.464
#> GSM71045     1  0.0000     0.9643 1.000 0.000
#> GSM71049     2  0.8144     0.6874 0.252 0.748
#> GSM71055     1  0.0000     0.9643 1.000 0.000
#> GSM71056     1  0.7376     0.6822 0.792 0.208
#> GSM71058     1  0.0000     0.9643 1.000 0.000
#> GSM71059     1  0.0000     0.9643 1.000 0.000
#> GSM71064     1  0.0000     0.9643 1.000 0.000
#> GSM71065     1  0.8813     0.4838 0.700 0.300
#> GSM71067     1  0.0672     0.9589 0.992 0.008
#> GSM71037     1  0.0000     0.9643 1.000 0.000
#> GSM71039     1  0.0000     0.9643 1.000 0.000
#> GSM71040     1  0.0000     0.9643 1.000 0.000
#> GSM71041     1  0.0000     0.9643 1.000 0.000
#> GSM71047     2  0.0672     0.8845 0.008 0.992
#> GSM71048     1  0.0000     0.9643 1.000 0.000
#> GSM71050     1  0.0938     0.9545 0.988 0.012
#> GSM71051     2  0.9909     0.3381 0.444 0.556
#> GSM71052     2  0.9909     0.3381 0.444 0.556
#> GSM71054     1  0.0000     0.9643 1.000 0.000
#> GSM71057     1  0.0000     0.9643 1.000 0.000
#> GSM71060     1  0.0000     0.9643 1.000 0.000
#> GSM71066     1  0.0672     0.9589 0.992 0.008
#> GSM71070     2  0.0672     0.8845 0.008 0.992
#> GSM71072     2  0.0672     0.8845 0.008 0.992
#> GSM71074     2  0.0672     0.8845 0.008 0.992
#> GSM71076     2  0.0672     0.8845 0.008 0.992
#> GSM71077     2  0.0672     0.8845 0.008 0.992
#> GSM71069     2  0.0672     0.8845 0.008 0.992
#> GSM71071     2  0.0672     0.8845 0.008 0.992
#> GSM71073     2  0.0672     0.8845 0.008 0.992
#> GSM71075     2  0.0672     0.8845 0.008 0.992
#> GSM71078     2  0.9896     0.3477 0.440 0.560

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>          class entropy silhouette    p1    p2    p3
#> GSM71019     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71020     2  0.0237      0.881 0.000 0.996 0.004
#> GSM71021     2  0.0237      0.881 0.000 0.996 0.004
#> GSM71022     2  0.5058      0.777 0.000 0.756 0.244
#> GSM71023     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71024     1  0.4605      0.818 0.796 0.000 0.204
#> GSM71025     2  0.0237      0.881 0.000 0.996 0.004
#> GSM71026     2  0.0237      0.881 0.000 0.996 0.004
#> GSM71027     2  0.0237      0.881 0.000 0.996 0.004
#> GSM71028     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71030     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71032     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71034     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71035     1  0.3482      0.736 0.872 0.000 0.128
#> GSM71038     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71043     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71046     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71053     1  0.4452      0.827 0.808 0.000 0.192
#> GSM71061     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71062     1  0.4178      0.838 0.828 0.000 0.172
#> GSM71063     1  0.0237      0.831 0.996 0.000 0.004
#> GSM71068     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71029     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71031     1  0.0237      0.830 0.996 0.004 0.000
#> GSM71033     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71036     1  0.6209      0.560 0.628 0.004 0.368
#> GSM71042     1  0.4465      0.837 0.820 0.004 0.176
#> GSM71044     3  0.3752      0.788 0.144 0.000 0.856
#> GSM71045     1  0.4465      0.837 0.820 0.004 0.176
#> GSM71049     3  0.3686      0.791 0.140 0.000 0.860
#> GSM71055     3  0.5254      0.607 0.264 0.000 0.736
#> GSM71056     1  0.6154      0.481 0.592 0.000 0.408
#> GSM71058     1  0.0475      0.831 0.992 0.004 0.004
#> GSM71059     1  0.4465      0.837 0.820 0.004 0.176
#> GSM71064     1  0.4465      0.837 0.820 0.004 0.176
#> GSM71065     3  0.3752      0.788 0.144 0.000 0.856
#> GSM71067     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71037     1  0.0237      0.830 0.996 0.004 0.000
#> GSM71039     1  0.0475      0.828 0.992 0.004 0.004
#> GSM71040     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71041     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71047     3  0.2165      0.801 0.000 0.064 0.936
#> GSM71048     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71050     1  0.4235      0.690 0.824 0.000 0.176
#> GSM71051     3  0.4805      0.625 0.176 0.012 0.812
#> GSM71052     1  0.6737      0.258 0.600 0.016 0.384
#> GSM71054     1  0.0237      0.830 0.996 0.004 0.000
#> GSM71057     1  0.3482      0.736 0.872 0.000 0.128
#> GSM71060     1  0.0000      0.830 1.000 0.000 0.000
#> GSM71066     1  0.4235      0.837 0.824 0.000 0.176
#> GSM71070     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71072     2  0.4931      0.790 0.000 0.768 0.232
#> GSM71074     2  0.2165      0.879 0.000 0.936 0.064
#> GSM71076     3  0.3752      0.752 0.000 0.144 0.856
#> GSM71077     2  0.2165      0.879 0.000 0.936 0.064
#> GSM71069     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71071     2  0.4931      0.790 0.000 0.768 0.232
#> GSM71073     2  0.4887      0.793 0.000 0.772 0.228
#> GSM71075     3  0.0000      0.871 0.000 0.000 1.000
#> GSM71078     1  0.5633      0.623 0.768 0.024 0.208

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     1  0.5678      0.470 0.524 0.024 0.000 0.452
#> GSM71020     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> GSM71021     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> GSM71022     4  0.1474      0.957 0.000 0.052 0.000 0.948
#> GSM71023     4  0.1151      0.961 0.008 0.024 0.000 0.968
#> GSM71024     3  0.6130      0.725 0.400 0.052 0.548 0.000
#> GSM71025     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> GSM71026     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> GSM71027     2  0.1637      0.933 0.000 0.940 0.000 0.060
#> GSM71028     3  0.0188      0.734 0.004 0.000 0.996 0.000
#> GSM71030     3  0.6243      0.727 0.392 0.060 0.548 0.000
#> GSM71032     3  0.6243      0.727 0.392 0.060 0.548 0.000
#> GSM71034     3  0.4842      0.715 0.192 0.048 0.760 0.000
#> GSM71035     3  0.2021      0.747 0.040 0.000 0.936 0.024
#> GSM71038     3  0.6243      0.727 0.392 0.060 0.548 0.000
#> GSM71043     3  0.0188      0.734 0.004 0.000 0.996 0.000
#> GSM71046     3  0.6243      0.727 0.392 0.060 0.548 0.000
#> GSM71053     3  0.6130      0.725 0.400 0.052 0.548 0.000
#> GSM71061     3  0.0188      0.734 0.004 0.000 0.996 0.000
#> GSM71062     3  0.0469      0.736 0.012 0.000 0.988 0.000
#> GSM71063     3  0.0188      0.734 0.004 0.000 0.996 0.000
#> GSM71068     3  0.2759      0.741 0.052 0.044 0.904 0.000
#> GSM71029     1  0.3873      0.819 0.772 0.000 0.000 0.228
#> GSM71031     3  0.3123      0.781 0.156 0.000 0.844 0.000
#> GSM71033     1  0.4372      0.790 0.728 0.000 0.004 0.268
#> GSM71036     1  0.1174      0.686 0.968 0.000 0.012 0.020
#> GSM71042     3  0.5137      0.714 0.452 0.000 0.544 0.004
#> GSM71044     1  0.4472      0.822 0.760 0.000 0.020 0.220
#> GSM71045     3  0.5097      0.726 0.428 0.000 0.568 0.004
#> GSM71049     1  0.4194      0.821 0.764 0.000 0.008 0.228
#> GSM71055     1  0.3591      0.817 0.824 0.000 0.008 0.168
#> GSM71056     1  0.2329      0.714 0.916 0.000 0.012 0.072
#> GSM71058     3  0.4819      0.758 0.344 0.000 0.652 0.004
#> GSM71059     3  0.5137      0.714 0.452 0.000 0.544 0.004
#> GSM71064     3  0.5137      0.714 0.452 0.000 0.544 0.004
#> GSM71065     1  0.3591      0.817 0.824 0.000 0.008 0.168
#> GSM71067     3  0.5520      0.683 0.244 0.060 0.696 0.000
#> GSM71037     3  0.3401      0.782 0.152 0.000 0.840 0.008
#> GSM71039     3  0.3910      0.779 0.156 0.000 0.820 0.024
#> GSM71040     3  0.3024      0.782 0.148 0.000 0.852 0.000
#> GSM71041     3  0.3123      0.783 0.156 0.000 0.844 0.000
#> GSM71047     4  0.0927      0.945 0.016 0.008 0.000 0.976
#> GSM71048     3  0.6091      0.747 0.344 0.060 0.596 0.000
#> GSM71050     3  0.3910      0.779 0.156 0.000 0.820 0.024
#> GSM71051     1  0.6836      0.586 0.580 0.000 0.140 0.280
#> GSM71052     3  0.4158      0.629 0.008 0.000 0.768 0.224
#> GSM71054     3  0.3910      0.779 0.156 0.000 0.820 0.024
#> GSM71057     3  0.3862      0.780 0.152 0.000 0.824 0.024
#> GSM71060     3  0.0188      0.734 0.004 0.000 0.996 0.000
#> GSM71066     3  0.6243      0.727 0.392 0.060 0.548 0.000
#> GSM71070     4  0.1004      0.962 0.004 0.024 0.000 0.972
#> GSM71072     4  0.1389      0.951 0.000 0.048 0.000 0.952
#> GSM71074     2  0.3907      0.801 0.000 0.768 0.000 0.232
#> GSM71076     4  0.1576      0.959 0.004 0.048 0.000 0.948
#> GSM71077     2  0.3907      0.801 0.000 0.768 0.000 0.232
#> GSM71069     4  0.1151      0.961 0.008 0.024 0.000 0.968
#> GSM71071     4  0.1389      0.951 0.000 0.048 0.000 0.952
#> GSM71073     4  0.1389      0.951 0.000 0.048 0.000 0.952
#> GSM71075     4  0.1004      0.962 0.004 0.024 0.000 0.972
#> GSM71078     3  0.6310      0.715 0.152 0.000 0.660 0.188

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.4305     -0.236 0.488 0.000 0.000 0.512 0.000
#> GSM71020     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM71022     4  0.1502      0.899 0.004 0.000 0.000 0.940 0.056
#> GSM71023     4  0.0510      0.899 0.016 0.000 0.000 0.984 0.000
#> GSM71024     5  0.2588      0.927 0.000 0.000 0.060 0.048 0.892
#> GSM71025     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM71028     3  0.4021      0.816 0.000 0.000 0.780 0.052 0.168
#> GSM71030     5  0.1732      0.957 0.000 0.000 0.080 0.000 0.920
#> GSM71032     5  0.1478      0.969 0.000 0.000 0.064 0.000 0.936
#> GSM71034     3  0.5216      0.332 0.000 0.000 0.520 0.044 0.436
#> GSM71035     3  0.4231      0.832 0.012 0.000 0.792 0.064 0.132
#> GSM71038     5  0.1341      0.971 0.000 0.000 0.056 0.000 0.944
#> GSM71043     3  0.4021      0.816 0.000 0.000 0.780 0.052 0.168
#> GSM71046     5  0.1410      0.970 0.000 0.000 0.060 0.000 0.940
#> GSM71053     5  0.2520      0.929 0.000 0.000 0.056 0.048 0.896
#> GSM71061     3  0.2230      0.837 0.000 0.000 0.884 0.000 0.116
#> GSM71062     3  0.4021      0.816 0.000 0.000 0.780 0.052 0.168
#> GSM71063     3  0.4021      0.816 0.000 0.000 0.780 0.052 0.168
#> GSM71068     3  0.4925      0.615 0.000 0.000 0.632 0.044 0.324
#> GSM71029     1  0.3612      0.670 0.732 0.000 0.000 0.268 0.000
#> GSM71031     3  0.1568      0.808 0.020 0.000 0.944 0.000 0.036
#> GSM71033     1  0.2068      0.806 0.904 0.000 0.004 0.092 0.000
#> GSM71036     1  0.0324      0.810 0.992 0.000 0.004 0.000 0.004
#> GSM71042     1  0.3771      0.779 0.796 0.000 0.164 0.000 0.040
#> GSM71044     1  0.1124      0.811 0.960 0.000 0.000 0.036 0.004
#> GSM71045     1  0.2927      0.800 0.868 0.000 0.092 0.000 0.040
#> GSM71049     1  0.3366      0.683 0.768 0.000 0.000 0.232 0.000
#> GSM71055     1  0.0451      0.811 0.988 0.000 0.008 0.000 0.004
#> GSM71056     1  0.3582      0.688 0.768 0.000 0.000 0.224 0.008
#> GSM71058     1  0.3565      0.788 0.816 0.000 0.144 0.000 0.040
#> GSM71059     1  0.3848      0.775 0.788 0.000 0.172 0.000 0.040
#> GSM71064     1  0.3848      0.775 0.788 0.000 0.172 0.000 0.040
#> GSM71065     1  0.1329      0.818 0.956 0.000 0.032 0.008 0.004
#> GSM71067     5  0.1544      0.965 0.000 0.000 0.068 0.000 0.932
#> GSM71037     3  0.1205      0.805 0.004 0.000 0.956 0.000 0.040
#> GSM71039     3  0.0963      0.806 0.000 0.000 0.964 0.000 0.036
#> GSM71040     3  0.2471      0.836 0.000 0.000 0.864 0.000 0.136
#> GSM71041     3  0.4290      0.830 0.012 0.000 0.780 0.052 0.156
#> GSM71047     4  0.0566      0.899 0.012 0.000 0.004 0.984 0.000
#> GSM71048     5  0.1571      0.971 0.000 0.000 0.060 0.004 0.936
#> GSM71050     3  0.2844      0.830 0.028 0.000 0.876 0.004 0.092
#> GSM71051     1  0.4475      0.649 0.692 0.000 0.032 0.276 0.000
#> GSM71052     3  0.5764      0.650 0.136 0.000 0.672 0.168 0.024
#> GSM71054     3  0.0963      0.806 0.000 0.000 0.964 0.000 0.036
#> GSM71057     3  0.2522      0.832 0.012 0.000 0.880 0.000 0.108
#> GSM71060     3  0.2179      0.837 0.000 0.000 0.888 0.000 0.112
#> GSM71066     5  0.1478      0.970 0.000 0.000 0.064 0.000 0.936
#> GSM71070     4  0.0404      0.900 0.012 0.000 0.000 0.988 0.000
#> GSM71072     4  0.1341      0.899 0.000 0.000 0.000 0.944 0.056
#> GSM71074     4  0.2329      0.838 0.000 0.124 0.000 0.876 0.000
#> GSM71076     4  0.1341      0.899 0.000 0.000 0.000 0.944 0.056
#> GSM71077     4  0.2424      0.831 0.000 0.132 0.000 0.868 0.000
#> GSM71069     4  0.0404      0.900 0.012 0.000 0.000 0.988 0.000
#> GSM71071     4  0.1341      0.899 0.000 0.000 0.000 0.944 0.056
#> GSM71073     4  0.1341      0.899 0.000 0.000 0.000 0.944 0.056
#> GSM71075     4  0.0404      0.900 0.012 0.000 0.000 0.988 0.000
#> GSM71078     3  0.5537      0.763 0.020 0.000 0.688 0.176 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
#> GSM71019     4  0.2597      0.775 0.176 0.000 0.000 0.824 0.000 0.000
#> GSM71020     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71021     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71022     4  0.1116      0.906 0.000 0.000 0.004 0.960 0.008 0.028
#> GSM71023     4  0.1007      0.910 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM71024     5  0.0260      0.967 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM71025     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71026     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71027     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM71028     6  0.1890      0.876 0.000 0.000 0.060 0.000 0.024 0.916
#> GSM71030     5  0.1957      0.860 0.000 0.000 0.112 0.000 0.888 0.000
#> GSM71032     5  0.0260      0.967 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM71034     6  0.4712      0.578 0.000 0.000 0.060 0.000 0.344 0.596
#> GSM71035     3  0.3620      0.635 0.000 0.000 0.736 0.008 0.008 0.248
#> GSM71038     5  0.0260      0.967 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM71043     6  0.1890      0.876 0.000 0.000 0.060 0.000 0.024 0.916
#> GSM71046     5  0.0291      0.964 0.000 0.000 0.004 0.000 0.992 0.004
#> GSM71053     5  0.0405      0.964 0.000 0.000 0.008 0.004 0.988 0.000
#> GSM71061     3  0.2282      0.857 0.000 0.000 0.888 0.000 0.024 0.088
#> GSM71062     6  0.1890      0.876 0.000 0.000 0.060 0.000 0.024 0.916
#> GSM71063     6  0.1890      0.876 0.000 0.000 0.060 0.000 0.024 0.916
#> GSM71068     6  0.4173      0.750 0.000 0.000 0.060 0.000 0.228 0.712
#> GSM71029     1  0.3151      0.679 0.748 0.000 0.000 0.252 0.000 0.000
#> GSM71031     3  0.0260      0.919 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM71033     1  0.1863      0.799 0.896 0.000 0.000 0.104 0.000 0.000
#> GSM71036     1  0.0146      0.803 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM71042     1  0.4038      0.744 0.768 0.000 0.160 0.000 0.016 0.056
#> GSM71044     1  0.1075      0.802 0.952 0.000 0.000 0.048 0.000 0.000
#> GSM71045     1  0.2763      0.788 0.876 0.000 0.072 0.000 0.028 0.024
#> GSM71049     1  0.2941      0.696 0.780 0.000 0.000 0.220 0.000 0.000
#> GSM71055     1  0.0146      0.803 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM71056     1  0.2994      0.710 0.788 0.000 0.000 0.208 0.004 0.000
#> GSM71058     1  0.4110      0.744 0.772 0.000 0.148 0.000 0.028 0.052
#> GSM71059     1  0.4169      0.742 0.768 0.000 0.148 0.000 0.028 0.056
#> GSM71064     1  0.4169      0.742 0.768 0.000 0.148 0.000 0.028 0.056
#> GSM71065     1  0.0790      0.805 0.968 0.000 0.032 0.000 0.000 0.000
#> GSM71067     5  0.0405      0.960 0.000 0.000 0.008 0.000 0.988 0.004
#> GSM71037     3  0.1257      0.914 0.000 0.000 0.952 0.000 0.028 0.020
#> GSM71039     3  0.1257      0.914 0.000 0.000 0.952 0.000 0.028 0.020
#> GSM71040     3  0.0632      0.920 0.000 0.000 0.976 0.000 0.024 0.000
#> GSM71041     3  0.3296      0.770 0.020 0.000 0.796 0.000 0.180 0.004
#> GSM71047     4  0.0937      0.910 0.040 0.000 0.000 0.960 0.000 0.000
#> GSM71048     5  0.0260      0.967 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM71050     3  0.0260      0.917 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM71051     1  0.3515      0.588 0.676 0.000 0.000 0.324 0.000 0.000
#> GSM71052     4  0.4992      0.545 0.116 0.000 0.260 0.624 0.000 0.000
#> GSM71054     3  0.0632      0.920 0.000 0.000 0.976 0.000 0.024 0.000
#> GSM71057     3  0.0363      0.919 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM71060     3  0.1480      0.901 0.000 0.000 0.940 0.000 0.020 0.040
#> GSM71066     5  0.1444      0.909 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM71070     4  0.1007      0.910 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM71072     4  0.1261      0.907 0.004 0.000 0.004 0.956 0.008 0.028
#> GSM71074     4  0.1663      0.881 0.000 0.088 0.000 0.912 0.000 0.000
#> GSM71076     4  0.1476      0.909 0.012 0.000 0.004 0.948 0.008 0.028
#> GSM71077     4  0.2378      0.831 0.000 0.152 0.000 0.848 0.000 0.000
#> GSM71069     4  0.1007      0.910 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM71071     4  0.1116      0.906 0.000 0.000 0.004 0.960 0.008 0.028
#> GSM71073     4  0.1180      0.906 0.000 0.004 0.004 0.960 0.008 0.024
#> GSM71075     4  0.1007      0.910 0.044 0.000 0.000 0.956 0.000 0.000
#> GSM71078     4  0.2639      0.873 0.048 0.000 0.064 0.880 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

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

plot of chunk tab-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 specimen(p) k
#> ATC:mclust 54    2.22e-07 2
#> ATC:mclust 58    4.25e-06 3
#> ATC:mclust 59    3.32e-11 4
#> ATC:mclust 58    5.63e-16 5
#> ATC:mclust 60    6.17e-18 6

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


ATC:NMF

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

res = res_list["ATC", "NMF"]
# you can also extract it by
# res = res_list["ATC:NMF"]

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.867           0.923       0.964         0.5023 0.501   0.501
#> 3 3 0.753           0.862       0.922         0.2804 0.801   0.623
#> 4 4 0.565           0.633       0.774         0.1247 0.915   0.783
#> 5 5 0.588           0.549       0.717         0.0600 0.850   0.590
#> 6 6 0.583           0.570       0.726         0.0429 0.941   0.763

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>          class entropy silhouette    p1    p2
#> GSM71019     2  0.0000      1.000 0.000 1.000
#> GSM71020     2  0.0000      1.000 0.000 1.000
#> GSM71021     2  0.0000      1.000 0.000 1.000
#> GSM71022     2  0.0000      1.000 0.000 1.000
#> GSM71023     2  0.0000      1.000 0.000 1.000
#> GSM71024     1  0.1633      0.923 0.976 0.024
#> GSM71025     2  0.0000      1.000 0.000 1.000
#> GSM71026     2  0.0000      1.000 0.000 1.000
#> GSM71027     2  0.0000      1.000 0.000 1.000
#> GSM71028     1  0.0000      0.935 1.000 0.000
#> GSM71030     1  0.0000      0.935 1.000 0.000
#> GSM71032     1  0.0376      0.933 0.996 0.004
#> GSM71034     1  0.0000      0.935 1.000 0.000
#> GSM71035     1  0.0000      0.935 1.000 0.000
#> GSM71038     1  0.0000      0.935 1.000 0.000
#> GSM71043     1  0.0000      0.935 1.000 0.000
#> GSM71046     1  0.0000      0.935 1.000 0.000
#> GSM71053     1  0.0938      0.930 0.988 0.012
#> GSM71061     1  0.0000      0.935 1.000 0.000
#> GSM71062     1  0.0000      0.935 1.000 0.000
#> GSM71063     1  0.0000      0.935 1.000 0.000
#> GSM71068     1  0.0000      0.935 1.000 0.000
#> GSM71029     2  0.0000      1.000 0.000 1.000
#> GSM71031     1  0.0000      0.935 1.000 0.000
#> GSM71033     2  0.0000      1.000 0.000 1.000
#> GSM71036     1  0.9996      0.183 0.512 0.488
#> GSM71042     1  0.7299      0.766 0.796 0.204
#> GSM71044     2  0.0000      1.000 0.000 1.000
#> GSM71045     1  0.6148      0.820 0.848 0.152
#> GSM71049     2  0.0000      1.000 0.000 1.000
#> GSM71055     2  0.0000      1.000 0.000 1.000
#> GSM71056     1  0.9754      0.413 0.592 0.408
#> GSM71058     1  0.8081      0.710 0.752 0.248
#> GSM71059     1  0.0000      0.935 1.000 0.000
#> GSM71064     1  0.0938      0.930 0.988 0.012
#> GSM71065     2  0.0000      1.000 0.000 1.000
#> GSM71067     1  0.0000      0.935 1.000 0.000
#> GSM71037     1  0.0000      0.935 1.000 0.000
#> GSM71039     1  0.0000      0.935 1.000 0.000
#> GSM71040     1  0.0000      0.935 1.000 0.000
#> GSM71041     1  0.0672      0.932 0.992 0.008
#> GSM71047     2  0.0000      1.000 0.000 1.000
#> GSM71048     1  0.0000      0.935 1.000 0.000
#> GSM71050     1  0.7299      0.766 0.796 0.204
#> GSM71051     2  0.0000      1.000 0.000 1.000
#> GSM71052     2  0.0000      1.000 0.000 1.000
#> GSM71054     1  0.0000      0.935 1.000 0.000
#> GSM71057     1  0.2043      0.918 0.968 0.032
#> GSM71060     1  0.0000      0.935 1.000 0.000
#> GSM71066     1  0.0000      0.935 1.000 0.000
#> GSM71070     2  0.0000      1.000 0.000 1.000
#> GSM71072     2  0.0000      1.000 0.000 1.000
#> GSM71074     2  0.0000      1.000 0.000 1.000
#> GSM71076     2  0.0000      1.000 0.000 1.000
#> GSM71077     2  0.0000      1.000 0.000 1.000
#> GSM71069     2  0.0672      0.991 0.008 0.992
#> GSM71071     2  0.0000      1.000 0.000 1.000
#> GSM71073     2  0.0000      1.000 0.000 1.000
#> GSM71075     2  0.0000      1.000 0.000 1.000
#> GSM71078     1  0.9170      0.575 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
#> GSM71019     2  0.2959      0.891 0.100 0.900 0.000
#> GSM71020     2  0.3267      0.887 0.116 0.884 0.000
#> GSM71021     2  0.3686      0.877 0.140 0.860 0.000
#> GSM71022     2  0.1860      0.894 0.052 0.948 0.000
#> GSM71023     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71024     3  0.2261      0.894 0.000 0.068 0.932
#> GSM71025     2  0.3879      0.870 0.152 0.848 0.000
#> GSM71026     2  0.3686      0.877 0.140 0.860 0.000
#> GSM71027     2  0.3482      0.882 0.128 0.872 0.000
#> GSM71028     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71030     3  0.0592      0.945 0.012 0.000 0.988
#> GSM71032     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71034     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71035     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71038     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71043     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71046     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71053     3  0.0892      0.937 0.000 0.020 0.980
#> GSM71061     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71062     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71063     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71068     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71029     2  0.4702      0.817 0.212 0.788 0.000
#> GSM71031     1  0.5497      0.641 0.708 0.000 0.292
#> GSM71033     1  0.4121      0.649 0.832 0.168 0.000
#> GSM71036     1  0.1529      0.876 0.960 0.000 0.040
#> GSM71042     1  0.2796      0.885 0.908 0.000 0.092
#> GSM71044     1  0.0000      0.855 1.000 0.000 0.000
#> GSM71045     1  0.3412      0.872 0.876 0.000 0.124
#> GSM71049     2  0.5650      0.694 0.312 0.688 0.000
#> GSM71055     1  0.0000      0.855 1.000 0.000 0.000
#> GSM71056     3  0.5791      0.733 0.060 0.148 0.792
#> GSM71058     1  0.2711      0.886 0.912 0.000 0.088
#> GSM71059     1  0.4062      0.834 0.836 0.000 0.164
#> GSM71064     1  0.3340      0.874 0.880 0.000 0.120
#> GSM71065     1  0.0000      0.855 1.000 0.000 0.000
#> GSM71067     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71037     3  0.5016      0.677 0.240 0.000 0.760
#> GSM71039     3  0.5733      0.501 0.324 0.000 0.676
#> GSM71040     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71041     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71047     2  0.1860      0.894 0.052 0.948 0.000
#> GSM71048     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71050     3  0.3886      0.854 0.096 0.024 0.880
#> GSM71051     2  0.6252      0.433 0.444 0.556 0.000
#> GSM71052     2  0.3886      0.885 0.096 0.880 0.024
#> GSM71054     3  0.2537      0.891 0.080 0.000 0.920
#> GSM71057     3  0.0592      0.945 0.012 0.000 0.988
#> GSM71060     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71066     3  0.0000      0.952 0.000 0.000 1.000
#> GSM71070     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71072     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71074     2  0.2537      0.893 0.080 0.920 0.000
#> GSM71076     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71077     2  0.2878      0.891 0.096 0.904 0.000
#> GSM71069     2  0.0237      0.885 0.000 0.996 0.004
#> GSM71071     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71073     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71075     2  0.0000      0.887 0.000 1.000 0.000
#> GSM71078     2  0.6045      0.310 0.000 0.620 0.380

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>          class entropy silhouette    p1    p2    p3    p4
#> GSM71019     2  0.3933     0.7833 0.008 0.792 0.000 0.200
#> GSM71020     2  0.0376     0.8266 0.004 0.992 0.000 0.004
#> GSM71021     2  0.1151     0.8220 0.008 0.968 0.000 0.024
#> GSM71022     2  0.0000     0.8268 0.000 1.000 0.000 0.000
#> GSM71023     2  0.4250     0.7399 0.000 0.724 0.000 0.276
#> GSM71024     3  0.6979     0.3270 0.108 0.004 0.528 0.360
#> GSM71025     2  0.1798     0.8154 0.016 0.944 0.000 0.040
#> GSM71026     2  0.1042     0.8228 0.008 0.972 0.000 0.020
#> GSM71027     2  0.1584     0.8186 0.012 0.952 0.000 0.036
#> GSM71028     3  0.1792     0.7228 0.000 0.000 0.932 0.068
#> GSM71030     3  0.5110     0.4208 0.352 0.000 0.636 0.012
#> GSM71032     1  0.6988     0.1725 0.500 0.000 0.380 0.120
#> GSM71034     3  0.2593     0.6962 0.104 0.000 0.892 0.004
#> GSM71035     3  0.3400     0.6845 0.000 0.000 0.820 0.180
#> GSM71038     3  0.6634     0.4775 0.212 0.000 0.624 0.164
#> GSM71043     3  0.0592     0.7267 0.000 0.000 0.984 0.016
#> GSM71046     3  0.4868     0.5682 0.256 0.000 0.720 0.024
#> GSM71053     3  0.7660     0.1540 0.180 0.004 0.420 0.396
#> GSM71061     3  0.2647     0.7095 0.000 0.000 0.880 0.120
#> GSM71062     3  0.1824     0.7139 0.060 0.000 0.936 0.004
#> GSM71063     3  0.0524     0.7263 0.004 0.000 0.988 0.008
#> GSM71068     3  0.2125     0.7090 0.076 0.000 0.920 0.004
#> GSM71029     2  0.5426     0.6052 0.232 0.708 0.000 0.060
#> GSM71031     1  0.6933     0.4993 0.584 0.000 0.172 0.244
#> GSM71033     1  0.7220     0.4676 0.532 0.176 0.000 0.292
#> GSM71036     1  0.2565     0.7264 0.912 0.000 0.032 0.056
#> GSM71042     1  0.2670     0.7174 0.904 0.000 0.072 0.024
#> GSM71044     1  0.4072     0.6652 0.748 0.000 0.000 0.252
#> GSM71045     1  0.2376     0.7196 0.916 0.000 0.068 0.016
#> GSM71049     1  0.7426     0.0921 0.452 0.376 0.000 0.172
#> GSM71055     1  0.2281     0.7175 0.904 0.000 0.000 0.096
#> GSM71056     1  0.8872     0.3876 0.460 0.076 0.216 0.248
#> GSM71058     1  0.4155     0.6775 0.756 0.000 0.004 0.240
#> GSM71059     1  0.3257     0.6650 0.844 0.000 0.152 0.004
#> GSM71064     1  0.2610     0.7148 0.900 0.000 0.088 0.012
#> GSM71065     1  0.2847     0.7207 0.896 0.004 0.016 0.084
#> GSM71067     3  0.4163     0.6340 0.188 0.000 0.792 0.020
#> GSM71037     3  0.6506     0.4801 0.240 0.000 0.628 0.132
#> GSM71039     3  0.7101     0.4009 0.136 0.000 0.504 0.360
#> GSM71040     3  0.1913     0.7278 0.020 0.000 0.940 0.040
#> GSM71041     3  0.2466     0.7168 0.004 0.000 0.900 0.096
#> GSM71047     2  0.0817     0.8254 0.000 0.976 0.000 0.024
#> GSM71048     3  0.2999     0.6818 0.132 0.000 0.864 0.004
#> GSM71050     3  0.6551     0.5603 0.052 0.032 0.636 0.280
#> GSM71051     2  0.7501     0.2453 0.156 0.504 0.008 0.332
#> GSM71052     2  0.6133     0.5426 0.000 0.644 0.088 0.268
#> GSM71054     3  0.6308     0.5492 0.136 0.000 0.656 0.208
#> GSM71057     3  0.4426     0.6606 0.024 0.000 0.772 0.204
#> GSM71060     3  0.2216     0.7185 0.000 0.000 0.908 0.092
#> GSM71066     3  0.3945     0.6269 0.216 0.000 0.780 0.004
#> GSM71070     2  0.4830     0.6637 0.000 0.608 0.000 0.392
#> GSM71072     2  0.2973     0.8062 0.000 0.856 0.000 0.144
#> GSM71074     2  0.0188     0.8272 0.000 0.996 0.000 0.004
#> GSM71076     2  0.4522     0.7231 0.000 0.680 0.000 0.320
#> GSM71077     2  0.0376     0.8268 0.004 0.992 0.000 0.004
#> GSM71069     2  0.5360     0.6259 0.000 0.552 0.012 0.436
#> GSM71071     2  0.2345     0.8164 0.000 0.900 0.000 0.100
#> GSM71073     2  0.0592     0.8277 0.000 0.984 0.000 0.016
#> GSM71075     2  0.4817     0.6661 0.000 0.612 0.000 0.388
#> GSM71078     3  0.7516     0.2106 0.000 0.328 0.472 0.200

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>          class entropy silhouette    p1    p2    p3    p4    p5
#> GSM71019     4  0.5535     0.4234 0.064 0.256 0.024 0.656 0.000
#> GSM71020     2  0.3934     0.8976 0.000 0.716 0.008 0.276 0.000
#> GSM71021     2  0.4216     0.8937 0.012 0.720 0.008 0.260 0.000
#> GSM71022     2  0.4298     0.8387 0.000 0.640 0.008 0.352 0.000
#> GSM71023     4  0.2162     0.6838 0.008 0.064 0.012 0.916 0.000
#> GSM71024     5  0.4859     0.6331 0.084 0.008 0.020 0.120 0.768
#> GSM71025     2  0.4164     0.8873 0.012 0.728 0.008 0.252 0.000
#> GSM71026     2  0.3809     0.8949 0.000 0.736 0.008 0.256 0.000
#> GSM71027     2  0.3990     0.8760 0.012 0.740 0.004 0.244 0.000
#> GSM71028     5  0.1608     0.7151 0.000 0.000 0.072 0.000 0.928
#> GSM71030     5  0.4799     0.3425 0.428 0.004 0.008 0.004 0.556
#> GSM71032     5  0.5786     0.4813 0.320 0.036 0.016 0.020 0.608
#> GSM71034     5  0.1121     0.7306 0.044 0.000 0.000 0.000 0.956
#> GSM71035     5  0.4267     0.5504 0.000 0.004 0.232 0.028 0.736
#> GSM71038     5  0.5059     0.6232 0.196 0.028 0.016 0.028 0.732
#> GSM71043     5  0.1197     0.7219 0.000 0.000 0.048 0.000 0.952
#> GSM71046     5  0.4102     0.6230 0.236 0.008 0.008 0.004 0.744
#> GSM71053     5  0.5630     0.6223 0.132 0.048 0.016 0.076 0.728
#> GSM71061     5  0.2813     0.6521 0.000 0.000 0.168 0.000 0.832
#> GSM71062     5  0.0865     0.7316 0.024 0.000 0.004 0.000 0.972
#> GSM71063     5  0.1197     0.7219 0.000 0.000 0.048 0.000 0.952
#> GSM71068     5  0.0865     0.7317 0.024 0.004 0.000 0.000 0.972
#> GSM71029     1  0.8351     0.1029 0.324 0.244 0.140 0.292 0.000
#> GSM71031     1  0.7295     0.0554 0.432 0.036 0.324 0.000 0.208
#> GSM71033     1  0.7342     0.2002 0.432 0.140 0.364 0.064 0.000
#> GSM71036     1  0.5319     0.5845 0.716 0.080 0.180 0.012 0.012
#> GSM71042     1  0.2577     0.5994 0.908 0.016 0.032 0.004 0.040
#> GSM71044     1  0.5091     0.4795 0.584 0.044 0.372 0.000 0.000
#> GSM71045     1  0.3346     0.6049 0.848 0.008 0.108 0.000 0.036
#> GSM71049     1  0.7690     0.3411 0.440 0.148 0.100 0.312 0.000
#> GSM71055     1  0.4560     0.5971 0.772 0.080 0.136 0.008 0.004
#> GSM71056     1  0.8652     0.3063 0.392 0.148 0.076 0.316 0.068
#> GSM71058     1  0.4892     0.4421 0.568 0.020 0.408 0.000 0.004
#> GSM71059     1  0.3080     0.5574 0.852 0.004 0.020 0.000 0.124
#> GSM71064     1  0.3277     0.5943 0.856 0.004 0.068 0.000 0.072
#> GSM71065     1  0.2045     0.6108 0.932 0.020 0.032 0.012 0.004
#> GSM71067     5  0.2955     0.7028 0.116 0.008 0.008 0.004 0.864
#> GSM71037     5  0.6346    -0.2221 0.160 0.000 0.404 0.000 0.436
#> GSM71039     3  0.4740     0.4072 0.076 0.004 0.744 0.004 0.172
#> GSM71040     5  0.1544     0.7178 0.000 0.000 0.068 0.000 0.932
#> GSM71041     5  0.2732     0.6606 0.000 0.000 0.160 0.000 0.840
#> GSM71047     4  0.4430     0.5256 0.000 0.256 0.036 0.708 0.000
#> GSM71048     5  0.1679     0.7312 0.048 0.004 0.004 0.004 0.940
#> GSM71050     5  0.5598     0.1601 0.008 0.028 0.400 0.016 0.548
#> GSM71051     3  0.6467     0.2685 0.084 0.236 0.608 0.072 0.000
#> GSM71052     3  0.7122     0.1424 0.020 0.092 0.524 0.316 0.048
#> GSM71054     5  0.5496    -0.1567 0.052 0.004 0.472 0.000 0.472
#> GSM71057     3  0.7953     0.1618 0.092 0.084 0.416 0.036 0.372
#> GSM71060     5  0.2536     0.6803 0.004 0.000 0.128 0.000 0.868
#> GSM71066     5  0.2020     0.7182 0.100 0.000 0.000 0.000 0.900
#> GSM71070     4  0.1365     0.6674 0.004 0.040 0.004 0.952 0.000
#> GSM71072     4  0.3635     0.5341 0.000 0.248 0.004 0.748 0.000
#> GSM71074     2  0.4251     0.8749 0.000 0.672 0.012 0.316 0.000
#> GSM71076     4  0.3010     0.6374 0.000 0.172 0.004 0.824 0.000
#> GSM71077     2  0.3980     0.8936 0.000 0.708 0.008 0.284 0.000
#> GSM71069     4  0.2840     0.6686 0.004 0.052 0.052 0.888 0.004
#> GSM71071     4  0.4252     0.2607 0.000 0.340 0.008 0.652 0.000
#> GSM71073     2  0.4610     0.6299 0.000 0.556 0.012 0.432 0.000
#> GSM71075     4  0.0960     0.6772 0.004 0.016 0.008 0.972 0.000
#> GSM71078     4  0.6589     0.2567 0.000 0.048 0.216 0.596 0.140

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>          class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM71019     4  0.7082      0.161 0.072 0.356 0.004 0.368 0.000 0.200
#> GSM71020     2  0.1219      0.873 0.000 0.948 0.004 0.000 0.000 0.048
#> GSM71021     2  0.1340      0.873 0.004 0.948 0.008 0.000 0.000 0.040
#> GSM71022     2  0.2272      0.836 0.000 0.900 0.004 0.056 0.000 0.040
#> GSM71023     4  0.4371      0.628 0.000 0.168 0.004 0.728 0.000 0.100
#> GSM71024     5  0.4117      0.646 0.064 0.000 0.000 0.156 0.764 0.016
#> GSM71025     2  0.2518      0.834 0.016 0.880 0.000 0.012 0.000 0.092
#> GSM71026     2  0.1615      0.869 0.004 0.928 0.004 0.000 0.000 0.064
#> GSM71027     2  0.1769      0.862 0.004 0.924 0.012 0.000 0.000 0.060
#> GSM71028     5  0.2048      0.695 0.000 0.000 0.120 0.000 0.880 0.000
#> GSM71030     5  0.5903      0.253 0.360 0.000 0.008 0.020 0.512 0.100
#> GSM71032     5  0.4763      0.593 0.212 0.000 0.000 0.044 0.700 0.044
#> GSM71034     5  0.0777      0.745 0.024 0.000 0.000 0.000 0.972 0.004
#> GSM71035     5  0.5610      0.182 0.004 0.000 0.340 0.048 0.560 0.048
#> GSM71038     5  0.4167      0.669 0.140 0.000 0.000 0.056 0.772 0.032
#> GSM71043     5  0.1863      0.705 0.000 0.000 0.104 0.000 0.896 0.000
#> GSM71046     5  0.3121      0.672 0.192 0.000 0.000 0.004 0.796 0.008
#> GSM71053     5  0.4055      0.682 0.100 0.000 0.000 0.068 0.792 0.040
#> GSM71061     5  0.3309      0.508 0.000 0.000 0.280 0.000 0.720 0.000
#> GSM71062     5  0.0520      0.743 0.008 0.000 0.008 0.000 0.984 0.000
#> GSM71063     5  0.1501      0.719 0.000 0.000 0.076 0.000 0.924 0.000
#> GSM71068     5  0.0767      0.745 0.012 0.000 0.008 0.004 0.976 0.000
#> GSM71029     6  0.8255      0.531 0.176 0.228 0.072 0.144 0.000 0.380
#> GSM71031     1  0.6350      0.226 0.464 0.000 0.376 0.004 0.100 0.056
#> GSM71033     1  0.7071      0.250 0.416 0.148 0.340 0.008 0.000 0.088
#> GSM71036     1  0.5762      0.323 0.628 0.004 0.124 0.044 0.000 0.200
#> GSM71042     1  0.4298      0.526 0.792 0.012 0.028 0.004 0.084 0.080
#> GSM71044     1  0.5492      0.423 0.592 0.008 0.272 0.004 0.000 0.124
#> GSM71045     1  0.2744      0.570 0.876 0.000 0.060 0.000 0.052 0.012
#> GSM71049     6  0.6763      0.627 0.260 0.028 0.016 0.232 0.000 0.464
#> GSM71055     1  0.5426      0.151 0.628 0.008 0.060 0.036 0.000 0.268
#> GSM71056     6  0.7584      0.531 0.248 0.016 0.036 0.292 0.028 0.380
#> GSM71058     1  0.5148      0.371 0.508 0.000 0.424 0.000 0.012 0.056
#> GSM71059     1  0.3816      0.520 0.800 0.004 0.016 0.004 0.140 0.036
#> GSM71064     1  0.3968      0.566 0.804 0.000 0.060 0.004 0.096 0.036
#> GSM71065     1  0.2228      0.527 0.912 0.000 0.004 0.016 0.024 0.044
#> GSM71067     5  0.2149      0.727 0.104 0.000 0.000 0.004 0.888 0.004
#> GSM71037     3  0.5818      0.488 0.176 0.000 0.560 0.000 0.248 0.016
#> GSM71039     3  0.4310      0.487 0.024 0.000 0.792 0.028 0.080 0.076
#> GSM71040     5  0.2877      0.650 0.012 0.000 0.168 0.000 0.820 0.000
#> GSM71041     5  0.3244      0.524 0.000 0.000 0.268 0.000 0.732 0.000
#> GSM71047     4  0.5559      0.516 0.000 0.384 0.060 0.520 0.000 0.036
#> GSM71048     5  0.1577      0.744 0.036 0.000 0.000 0.016 0.940 0.008
#> GSM71050     3  0.4791      0.281 0.000 0.024 0.552 0.004 0.408 0.012
#> GSM71051     3  0.5644      0.203 0.052 0.256 0.624 0.012 0.000 0.056
#> GSM71052     3  0.5656      0.368 0.012 0.172 0.664 0.120 0.020 0.012
#> GSM71054     3  0.4720      0.535 0.060 0.000 0.628 0.000 0.308 0.004
#> GSM71057     3  0.7566      0.463 0.148 0.012 0.508 0.048 0.200 0.084
#> GSM71060     5  0.3445      0.528 0.008 0.000 0.260 0.000 0.732 0.000
#> GSM71066     5  0.1908      0.734 0.096 0.000 0.000 0.000 0.900 0.004
#> GSM71070     4  0.2492      0.625 0.004 0.100 0.000 0.876 0.000 0.020
#> GSM71072     4  0.4386      0.614 0.000 0.348 0.004 0.620 0.000 0.028
#> GSM71074     2  0.1845      0.843 0.000 0.920 0.000 0.052 0.000 0.028
#> GSM71076     4  0.3448      0.681 0.000 0.280 0.000 0.716 0.000 0.004
#> GSM71077     2  0.1176      0.868 0.000 0.956 0.000 0.024 0.000 0.020
#> GSM71069     4  0.3304      0.670 0.000 0.140 0.004 0.816 0.000 0.040
#> GSM71071     4  0.4746      0.494 0.000 0.424 0.004 0.532 0.000 0.040
#> GSM71073     2  0.3925      0.475 0.000 0.724 0.000 0.236 0.000 0.040
#> GSM71075     4  0.2715      0.644 0.004 0.112 0.000 0.860 0.000 0.024
#> GSM71078     4  0.6786      0.400 0.004 0.092 0.232 0.556 0.024 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-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)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 3, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 4, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 5, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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

get_signatures(res, k = 6, scale_rows = FALSE)
#> Error: The width or height of the raster image is zero, maybe you forget to turn off the
#> previous graphic device or it was corrupted. Run `dev.off()` to close it.

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 specimen(p) k
#> ATC:NMF 58    2.56e-05 2
#> ATC:NMF 58    7.47e-13 3
#> ATC:NMF 47    1.16e-11 4
#> ATC:NMF 41    4.21e-10 5
#> ATC:NMF 42    5.79e-09 6

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

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