cola Report for GDS2415

Date: 2019-12-25 20:17:15 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 17209 rows and 59 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] 17209    59

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
ATC:kmeans 2 1.000 0.956 0.983 **
ATC:pam 2 1.000 0.959 0.985 **
CV:mclust 3 0.954 0.924 0.947 **
ATC:mclust 5 0.917 0.860 0.943 *
ATC:skmeans 2 0.897 0.929 0.970
MAD:pam 5 0.849 0.833 0.930
CV:skmeans 3 0.846 0.903 0.954
MAD:mclust 5 0.829 0.817 0.901
CV:pam 2 0.802 0.905 0.962
CV:kmeans 3 0.794 0.884 0.931
SD:pam 5 0.786 0.781 0.910
MAD:skmeans 3 0.747 0.819 0.919
SD:mclust 5 0.720 0.697 0.856
SD:skmeans 4 0.710 0.785 0.893
ATC:hclust 2 0.628 0.693 0.886
ATC:NMF 3 0.626 0.701 0.886
SD:NMF 4 0.608 0.735 0.830
MAD:kmeans 2 0.574 0.784 0.897
CV:hclust 2 0.504 0.814 0.903
SD:kmeans 2 0.488 0.662 0.865
MAD:NMF 2 0.486 0.864 0.896
CV:NMF 2 0.453 0.695 0.870
MAD:hclust 2 0.395 0.798 0.883
SD:hclust 2 0.231 0.719 0.834

**: 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.367           0.710       0.819          0.487 0.492   0.492
#> CV:NMF      2 0.453           0.695       0.870          0.488 0.492   0.492
#> MAD:NMF     2 0.486           0.864       0.896          0.494 0.493   0.493
#> ATC:NMF     2 0.711           0.863       0.934          0.381 0.583   0.583
#> SD:skmeans  2 0.537           0.650       0.874          0.507 0.492   0.492
#> CV:skmeans  2 0.633           0.820       0.923          0.503 0.495   0.495
#> MAD:skmeans 2 0.578           0.741       0.887          0.507 0.493   0.493
#> ATC:skmeans 2 0.897           0.929       0.970          0.500 0.503   0.503
#> SD:mclust   2 0.251           0.648       0.801          0.407 0.614   0.614
#> CV:mclust   2 0.349           0.610       0.832          0.405 0.583   0.583
#> MAD:mclust  2 0.219           0.678       0.769          0.457 0.544   0.544
#> ATC:mclust  2 0.569           0.823       0.929          0.235 0.842   0.842
#> SD:kmeans   2 0.488           0.662       0.865          0.501 0.493   0.493
#> CV:kmeans   2 0.635           0.783       0.900          0.486 0.499   0.499
#> MAD:kmeans  2 0.574           0.784       0.897          0.502 0.503   0.503
#> ATC:kmeans  2 1.000           0.956       0.983          0.488 0.516   0.516
#> SD:pam      2 0.311           0.521       0.816          0.403 0.614   0.614
#> CV:pam      2 0.802           0.905       0.962          0.462 0.544   0.544
#> MAD:pam     2 0.224           0.183       0.628          0.433 0.534   0.534
#> ATC:pam     2 1.000           0.959       0.985          0.490 0.509   0.509
#> SD:hclust   2 0.231           0.719       0.834          0.454 0.516   0.516
#> CV:hclust   2 0.504           0.814       0.903          0.454 0.534   0.534
#> MAD:hclust  2 0.395           0.798       0.883          0.455 0.544   0.544
#> ATC:hclust  2 0.628           0.693       0.886          0.470 0.524   0.524
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.427           0.619       0.770          0.371 0.681   0.438
#> CV:NMF      3 0.489           0.725       0.860          0.307 0.749   0.537
#> MAD:NMF     3 0.492           0.733       0.839          0.356 0.695   0.456
#> ATC:NMF     3 0.626           0.701       0.886          0.529 0.786   0.643
#> SD:skmeans  3 0.593           0.503       0.781          0.319 0.739   0.543
#> CV:skmeans  3 0.846           0.903       0.954          0.304 0.696   0.466
#> MAD:skmeans 3 0.747           0.819       0.919          0.327 0.750   0.532
#> ATC:skmeans 3 0.743           0.800       0.875          0.251 0.811   0.637
#> SD:mclust   3 0.473           0.590       0.817          0.516 0.663   0.482
#> CV:mclust   3 0.954           0.924       0.947          0.586 0.684   0.496
#> MAD:mclust  3 0.384           0.610       0.769          0.344 0.821   0.685
#> ATC:mclust  3 0.286           0.245       0.628          1.508 0.476   0.426
#> SD:kmeans   3 0.458           0.593       0.794          0.307 0.704   0.476
#> CV:kmeans   3 0.794           0.884       0.931          0.338 0.730   0.518
#> MAD:kmeans  3 0.461           0.626       0.806          0.322 0.658   0.419
#> ATC:kmeans  3 0.707           0.844       0.905          0.362 0.711   0.489
#> SD:pam      3 0.619           0.625       0.847          0.415 0.783   0.662
#> CV:pam      3 0.682           0.813       0.901          0.359 0.820   0.669
#> MAD:pam     3 0.626           0.714       0.849          0.391 0.609   0.410
#> ATC:pam     3 0.864           0.861       0.948          0.304 0.695   0.483
#> SD:hclust   3 0.386           0.671       0.775          0.388 0.743   0.533
#> CV:hclust   3 0.662           0.809       0.895          0.409 0.741   0.552
#> MAD:hclust  3 0.499           0.776       0.849          0.431 0.745   0.548
#> ATC:hclust  3 0.546           0.755       0.828          0.359 0.707   0.487
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.608           0.735       0.830         0.1185 0.812   0.505
#> CV:NMF      4 0.401           0.516       0.691         0.1387 0.824   0.550
#> MAD:NMF     4 0.600           0.720       0.806         0.1167 0.833   0.553
#> ATC:NMF     4 0.473           0.560       0.785         0.1738 0.841   0.638
#> SD:skmeans  4 0.710           0.785       0.893         0.1168 0.819   0.559
#> CV:skmeans  4 0.852           0.871       0.939         0.1303 0.857   0.616
#> MAD:skmeans 4 0.692           0.712       0.865         0.1124 0.848   0.581
#> ATC:skmeans 4 0.813           0.819       0.924         0.1045 0.822   0.572
#> SD:mclust   4 0.469           0.503       0.778         0.1481 0.742   0.420
#> CV:mclust   4 0.745           0.818       0.848         0.1033 0.889   0.708
#> MAD:mclust  4 0.527           0.637       0.807         0.1668 0.679   0.370
#> ATC:mclust  4 0.700           0.760       0.868         0.2643 0.732   0.447
#> SD:kmeans   4 0.607           0.681       0.823         0.1292 0.798   0.490
#> CV:kmeans   4 0.690           0.662       0.780         0.1294 0.850   0.597
#> MAD:kmeans  4 0.582           0.633       0.813         0.1212 0.843   0.580
#> ATC:kmeans  4 0.654           0.719       0.788         0.1178 0.880   0.654
#> SD:pam      4 0.708           0.787       0.892         0.2358 0.802   0.583
#> CV:pam      4 0.662           0.700       0.855         0.0809 0.879   0.707
#> MAD:pam     4 0.718           0.832       0.900         0.2104 0.827   0.587
#> ATC:pam     4 0.647           0.669       0.840         0.1212 0.899   0.730
#> SD:hclust   4 0.519           0.573       0.752         0.1361 0.957   0.873
#> CV:hclust   4 0.641           0.741       0.814         0.1162 0.910   0.754
#> MAD:hclust  4 0.579           0.711       0.800         0.0981 0.964   0.895
#> ATC:hclust  4 0.580           0.695       0.804         0.1224 0.936   0.802
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.658           0.639       0.805         0.0599 0.933   0.746
#> CV:NMF      5 0.452           0.439       0.678         0.0737 0.821   0.461
#> MAD:NMF     5 0.664           0.670       0.811         0.0562 0.950   0.810
#> ATC:NMF     5 0.442           0.373       0.694         0.0871 0.937   0.818
#> SD:skmeans  5 0.657           0.555       0.767         0.0728 0.876   0.561
#> CV:skmeans  5 0.758           0.683       0.802         0.0595 0.959   0.850
#> MAD:skmeans 5 0.674           0.605       0.766         0.0703 0.859   0.522
#> ATC:skmeans 5 0.791           0.852       0.887         0.0429 0.926   0.763
#> SD:mclust   5 0.720           0.697       0.856         0.0803 0.842   0.526
#> CV:mclust   5 0.775           0.752       0.851         0.0876 0.935   0.785
#> MAD:mclust  5 0.829           0.817       0.901         0.0874 0.883   0.625
#> ATC:mclust  5 0.917           0.860       0.943         0.0766 0.870   0.545
#> SD:kmeans   5 0.641           0.481       0.691         0.0721 0.901   0.638
#> CV:kmeans   5 0.703           0.573       0.750         0.0755 0.910   0.680
#> MAD:kmeans  5 0.644           0.450       0.652         0.0713 0.907   0.669
#> ATC:kmeans  5 0.658           0.579       0.692         0.0629 1.000   1.000
#> SD:pam      5 0.786           0.781       0.910         0.1146 0.888   0.639
#> CV:pam      5 0.636           0.623       0.762         0.1228 0.845   0.572
#> MAD:pam     5 0.849           0.833       0.930         0.0867 0.901   0.651
#> ATC:pam     5 0.860           0.807       0.924         0.0808 0.886   0.628
#> SD:hclust   5 0.572           0.509       0.730         0.0775 0.904   0.697
#> CV:hclust   5 0.679           0.710       0.820         0.0664 0.955   0.838
#> MAD:hclust  5 0.617           0.619       0.757         0.0779 0.905   0.703
#> ATC:hclust  5 0.632           0.603       0.764         0.0630 0.901   0.671
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.655           0.482       0.716         0.0393 0.896   0.598
#> CV:NMF      6 0.521           0.395       0.623         0.0408 0.888   0.553
#> MAD:NMF     6 0.649           0.507       0.740         0.0391 0.944   0.768
#> ATC:NMF     6 0.479           0.435       0.636         0.0424 0.944   0.823
#> SD:skmeans  6 0.678           0.509       0.725         0.0448 0.935   0.688
#> CV:skmeans  6 0.739           0.534       0.720         0.0392 0.899   0.635
#> MAD:skmeans 6 0.700           0.542       0.759         0.0446 0.904   0.576
#> ATC:skmeans 6 0.831           0.842       0.896         0.0337 0.991   0.965
#> SD:mclust   6 0.705           0.559       0.785         0.0769 0.859   0.476
#> CV:mclust   6 0.806           0.699       0.846         0.0748 0.884   0.564
#> MAD:mclust  6 0.788           0.716       0.816         0.0606 0.944   0.745
#> ATC:mclust  6 0.843           0.804       0.912         0.0224 0.950   0.768
#> SD:kmeans   6 0.667           0.558       0.749         0.0418 0.915   0.632
#> CV:kmeans   6 0.683           0.563       0.712         0.0463 0.875   0.532
#> MAD:kmeans  6 0.683           0.554       0.696         0.0407 0.892   0.563
#> ATC:kmeans  6 0.706           0.598       0.738         0.0427 0.828   0.419
#> SD:pam      6 0.784           0.785       0.887         0.0368 0.961   0.820
#> CV:pam      6 0.702           0.760       0.845         0.0600 0.926   0.689
#> MAD:pam     6 0.846           0.815       0.902         0.0316 0.965   0.834
#> ATC:pam     6 0.873           0.856       0.927         0.0609 0.853   0.463
#> SD:hclust   6 0.627           0.532       0.699         0.0534 0.885   0.570
#> CV:hclust   6 0.712           0.611       0.788         0.0446 0.924   0.707
#> MAD:hclust  6 0.673           0.685       0.788         0.0611 0.932   0.712
#> ATC:hclust  6 0.676           0.654       0.759         0.0483 0.905   0.637

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 disease.state(p) specimen(p) k
#> SD:NMF      58           0.7783       0.299 2
#> CV:NMF      48           1.0000       1.000 2
#> MAD:NMF     58           0.7783       0.299 2
#> ATC:NMF     56           1.0000       0.854 2
#> SD:skmeans  42           0.1959       0.129 2
#> CV:skmeans  49           0.8363       0.468 2
#> MAD:skmeans 45           0.1683       0.145 2
#> ATC:skmeans 56           0.5626       0.318 2
#> SD:mclust   53           0.1752       1.000 2
#> CV:mclust   41           0.0692       0.617 2
#> MAD:mclust  58           0.4573       1.000 2
#> ATC:mclust  53           0.3249       0.738 2
#> SD:kmeans   43           0.1502       0.146 2
#> CV:kmeans   52           0.9132       0.567 2
#> MAD:kmeans  54           0.1755       0.246 2
#> ATC:kmeans  57           0.6664       0.402 2
#> SD:pam      32           0.5032       1.000 2
#> CV:pam      57           1.0000       0.700 2
#> MAD:pam      0               NA          NA 2
#> ATC:pam     57           0.6664       0.402 2
#> SD:hclust   54           1.0000       0.713 2
#> CV:hclust   54           1.0000       0.699 2
#> MAD:hclust  54           1.0000       0.610 2
#> ATC:hclust  45           1.0000       0.675 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) specimen(p) k
#> SD:NMF      49          0.20082       0.126 3
#> CV:NMF      53          0.12288       0.217 3
#> MAD:NMF     54          0.31690       0.188 3
#> ATC:NMF     47          0.04984       0.220 3
#> SD:skmeans  43          0.00283       0.302 3
#> CV:skmeans  57          0.06974       0.262 3
#> MAD:skmeans 53          0.23331       0.171 3
#> ATC:skmeans 53          0.25971       0.419 3
#> SD:mclust   41          0.08799       0.431 3
#> CV:mclust   58          0.10430       0.355 3
#> MAD:mclust  47          0.07645       0.575 3
#> ATC:mclust  29          1.00000       1.000 3
#> SD:kmeans   41          0.01581       0.263 3
#> CV:kmeans   56          0.10325       0.405 3
#> MAD:kmeans  51          0.16779       0.252 3
#> ATC:kmeans  57          0.93000       0.516 3
#> SD:pam      44          0.01500       0.827 3
#> CV:pam      56          0.23776       0.411 3
#> MAD:pam     54          0.00286       0.677 3
#> ATC:pam     53          0.42471       0.157 3
#> SD:hclust   47          0.11161       0.194 3
#> CV:hclust   54          0.16428       0.333 3
#> MAD:hclust  56          0.15106       0.177 3
#> ATC:hclust  51          0.76150       0.392 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) specimen(p) k
#> SD:NMF      53          0.01395       0.306 4
#> CV:NMF      44          0.24887       0.992 4
#> MAD:NMF     51          0.00239       0.320 4
#> ATC:NMF     43          0.33043       0.665 4
#> SD:skmeans  56          0.00530       0.249 4
#> CV:skmeans  56          0.14766       0.697 4
#> MAD:skmeans 53          0.01834       0.285 4
#> ATC:skmeans 51          0.20447       0.421 4
#> SD:mclust   39          0.00689       0.187 4
#> CV:mclust   56          0.20813       0.373 4
#> MAD:mclust  47          0.02422       0.446 4
#> ATC:mclust  51          0.13970       0.425 4
#> SD:kmeans   49          0.02034       0.353 4
#> CV:kmeans   48          0.20824       0.586 4
#> MAD:kmeans  49          0.06572       0.127 4
#> ATC:kmeans  53          0.55553       0.588 4
#> SD:pam      54          0.00831       0.419 4
#> CV:pam      51          0.27543       0.801 4
#> MAD:pam     56          0.03049       0.332 4
#> ATC:pam     49          0.26909       0.311 4
#> SD:hclust   44          0.17095       0.429 4
#> CV:hclust   54          0.23142       0.215 4
#> MAD:hclust  53          0.27719       0.378 4
#> ATC:hclust  45          0.70405       0.435 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) specimen(p) k
#> SD:NMF      49          0.04613      0.2670 5
#> CV:NMF      29          0.00535      0.4177 5
#> MAD:NMF     50          0.01015      0.2645 5
#> ATC:NMF     23          0.15132      0.8113 5
#> SD:skmeans  39          0.01905      0.4615 5
#> CV:skmeans  51          0.25312      0.6276 5
#> MAD:skmeans 45          0.00669      0.5665 5
#> ATC:skmeans 55          0.41176      0.6884 5
#> SD:mclust   49          0.14885      0.6020 5
#> CV:mclust   53          0.08373      0.6348 5
#> MAD:mclust  56          0.15770      0.5686 5
#> ATC:mclust  54          0.14289      0.1676 5
#> SD:kmeans   32          0.01414      0.4465 5
#> CV:kmeans   43          0.23882      0.4138 5
#> MAD:kmeans  35          0.08006      0.0218 5
#> ATC:kmeans  49          0.40417      0.3665 5
#> SD:pam      52          0.04739      0.3046 5
#> CV:pam      47          0.07121      0.7144 5
#> MAD:pam     53          0.15548      0.5616 5
#> ATC:pam     53          0.05764      0.2668 5
#> SD:hclust   38          0.31665      0.5597 5
#> CV:hclust   53          0.16880      0.0750 5
#> MAD:hclust  42          0.48669      0.1636 5
#> ATC:hclust  41          0.79051      0.6650 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) specimen(p) k
#> SD:NMF      38          0.06174      0.1286 6
#> CV:NMF      23          0.00638      0.0558 6
#> MAD:NMF     38          0.01317      0.1085 6
#> ATC:NMF     21          0.35464      0.8858 6
#> SD:skmeans  34          0.02061      0.0168 6
#> CV:skmeans  39          0.38588      0.6324 6
#> MAD:skmeans 38          0.01668      0.0942 6
#> ATC:skmeans 55          0.52037      0.6252 6
#> SD:mclust   39          0.03389      0.6479 6
#> CV:mclust   48          0.08709      0.2328 6
#> MAD:mclust  54          0.17980      0.1101 6
#> ATC:mclust  52          0.08807      0.2008 6
#> SD:kmeans   42          0.01870      0.0895 6
#> CV:kmeans   37          0.08576      0.2991 6
#> MAD:kmeans  40          0.01184      0.0595 6
#> ATC:kmeans  46          0.16994      0.5912 6
#> SD:pam      54          0.11488      0.3386 6
#> CV:pam      55          0.04053      0.5000 6
#> MAD:pam     55          0.19700      0.6693 6
#> ATC:pam     58          0.13827      0.5340 6
#> SD:hclust   39          0.10269      0.5210 6
#> CV:hclust   39          0.11504      0.3458 6
#> MAD:hclust  51          0.03818      0.5755 6
#> ATC:hclust  47          0.18081      0.7447 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.231           0.719       0.834         0.4541 0.516   0.516
#> 3 3 0.386           0.671       0.775         0.3881 0.743   0.533
#> 4 4 0.519           0.573       0.752         0.1361 0.957   0.873
#> 5 5 0.572           0.509       0.730         0.0775 0.904   0.697
#> 6 6 0.627           0.532       0.699         0.0534 0.885   0.570

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
#> GSM110395     2  0.5946     0.8232 0.144 0.856
#> GSM110396     1  0.5519     0.7827 0.872 0.128
#> GSM110397     1  0.4939     0.7775 0.892 0.108
#> GSM110398     2  0.1184     0.8501 0.016 0.984
#> GSM110399     2  0.2236     0.8484 0.036 0.964
#> GSM110400     2  0.6247     0.8132 0.156 0.844
#> GSM110401     1  0.4431     0.7762 0.908 0.092
#> GSM110406     2  0.2236     0.8484 0.036 0.964
#> GSM110407     1  0.5178     0.7798 0.884 0.116
#> GSM110409     1  0.9522     0.6408 0.628 0.372
#> GSM110410     2  0.0000     0.8517 0.000 1.000
#> GSM110413     2  0.0000     0.8517 0.000 1.000
#> GSM110414     2  0.4431     0.8212 0.092 0.908
#> GSM110415     2  0.6438     0.8101 0.164 0.836
#> GSM110416     2  0.8555     0.7068 0.280 0.720
#> GSM110418     2  0.8555     0.7068 0.280 0.720
#> GSM110419     2  0.8207     0.7230 0.256 0.744
#> GSM110420     1  0.9988    -0.0500 0.520 0.480
#> GSM110421     2  0.0000     0.8517 0.000 1.000
#> GSM110423     2  0.6247     0.8132 0.156 0.844
#> GSM110424     2  0.0000     0.8517 0.000 1.000
#> GSM110425     2  0.8207     0.7230 0.256 0.744
#> GSM110427     2  0.6048     0.8212 0.148 0.852
#> GSM110428     1  0.7219     0.7120 0.800 0.200
#> GSM110430     1  0.4431     0.7762 0.908 0.092
#> GSM110431     1  0.6887     0.7341 0.816 0.184
#> GSM110432     2  0.8207     0.7230 0.256 0.744
#> GSM110434     2  0.1414     0.8516 0.020 0.980
#> GSM110435     1  0.5842     0.7313 0.860 0.140
#> GSM110437     1  0.4431     0.7762 0.908 0.092
#> GSM110438     1  0.8608     0.5787 0.716 0.284
#> GSM110388     1  0.9963     0.4970 0.536 0.464
#> GSM110392     2  0.9963    -0.1146 0.464 0.536
#> GSM110394     1  0.5294     0.7796 0.880 0.120
#> GSM110402     2  0.8499     0.7120 0.276 0.724
#> GSM110411     1  0.9954     0.5028 0.540 0.460
#> GSM110412     2  0.1414     0.8407 0.020 0.980
#> GSM110417     1  0.5737     0.7736 0.864 0.136
#> GSM110422     2  0.1843     0.8512 0.028 0.972
#> GSM110426     1  0.5178     0.7765 0.884 0.116
#> GSM110429     2  0.1843     0.8512 0.028 0.972
#> GSM110433     2  0.0000     0.8517 0.000 1.000
#> GSM110436     2  0.6048     0.8188 0.148 0.852
#> GSM110440     1  0.5519     0.7521 0.872 0.128
#> GSM110441     2  0.0000     0.8517 0.000 1.000
#> GSM110444     1  0.9954     0.5028 0.540 0.460
#> GSM110445     1  0.7674     0.7530 0.776 0.224
#> GSM110446     1  1.0000     0.0675 0.500 0.500
#> GSM110449     2  0.0000     0.8517 0.000 1.000
#> GSM110451     2  0.8144     0.7275 0.252 0.748
#> GSM110391     2  0.0000     0.8517 0.000 1.000
#> GSM110439     2  0.0672     0.8517 0.008 0.992
#> GSM110442     2  0.0376     0.8522 0.004 0.996
#> GSM110443     2  0.9635     0.2558 0.388 0.612
#> GSM110447     2  0.8661     0.6866 0.288 0.712
#> GSM110448     1  0.9954     0.5028 0.540 0.460
#> GSM110450     1  0.5059     0.7825 0.888 0.112
#> GSM110452     2  0.0000     0.8517 0.000 1.000
#> GSM110453     2  0.1843     0.8512 0.028 0.972

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     3  0.6102     0.6195 0.008 0.320 0.672
#> GSM110396     1  0.4256     0.7138 0.868 0.036 0.096
#> GSM110397     1  0.2261     0.7059 0.932 0.000 0.068
#> GSM110398     2  0.1182     0.8453 0.012 0.976 0.012
#> GSM110399     2  0.2550     0.8410 0.024 0.936 0.040
#> GSM110400     3  0.4842     0.7418 0.000 0.224 0.776
#> GSM110401     1  0.2537     0.7127 0.920 0.000 0.080
#> GSM110406     2  0.2550     0.8410 0.024 0.936 0.040
#> GSM110407     1  0.4002     0.6805 0.840 0.000 0.160
#> GSM110409     1  0.6975     0.5184 0.616 0.356 0.028
#> GSM110410     2  0.3340     0.8377 0.000 0.880 0.120
#> GSM110413     2  0.1015     0.8419 0.012 0.980 0.008
#> GSM110414     3  0.5797     0.6510 0.008 0.280 0.712
#> GSM110415     3  0.5360     0.7539 0.012 0.220 0.768
#> GSM110416     3  0.7297     0.8110 0.108 0.188 0.704
#> GSM110418     3  0.7297     0.8110 0.108 0.188 0.704
#> GSM110419     3  0.7899     0.8055 0.144 0.192 0.664
#> GSM110420     3  0.4002     0.5184 0.160 0.000 0.840
#> GSM110421     2  0.1482     0.8401 0.012 0.968 0.020
#> GSM110423     3  0.4842     0.7418 0.000 0.224 0.776
#> GSM110424     2  0.3340     0.8377 0.000 0.880 0.120
#> GSM110425     3  0.7899     0.8055 0.144 0.192 0.664
#> GSM110427     2  0.6483     0.3662 0.008 0.600 0.392
#> GSM110428     1  0.6745     0.3605 0.560 0.012 0.428
#> GSM110430     1  0.2537     0.7127 0.920 0.000 0.080
#> GSM110431     1  0.6095     0.4263 0.608 0.000 0.392
#> GSM110432     3  0.8113     0.8018 0.144 0.212 0.644
#> GSM110434     2  0.2955     0.8468 0.008 0.912 0.080
#> GSM110435     1  0.5650     0.5420 0.688 0.000 0.312
#> GSM110437     1  0.2537     0.7127 0.920 0.000 0.080
#> GSM110438     3  0.6168    -0.0115 0.412 0.000 0.588
#> GSM110388     1  0.7015     0.4369 0.584 0.392 0.024
#> GSM110392     1  0.9724     0.0392 0.436 0.328 0.236
#> GSM110394     1  0.4062     0.6781 0.836 0.000 0.164
#> GSM110402     3  0.7228     0.8115 0.104 0.188 0.708
#> GSM110411     1  0.7001     0.4423 0.588 0.388 0.024
#> GSM110412     2  0.2564     0.8315 0.028 0.936 0.036
#> GSM110417     1  0.1905     0.7031 0.956 0.016 0.028
#> GSM110422     2  0.4602     0.8175 0.016 0.832 0.152
#> GSM110426     1  0.1964     0.7033 0.944 0.000 0.056
#> GSM110429     2  0.4602     0.8175 0.016 0.832 0.152
#> GSM110433     2  0.1482     0.8401 0.012 0.968 0.020
#> GSM110436     2  0.6386     0.3128 0.004 0.584 0.412
#> GSM110440     1  0.5580     0.5991 0.736 0.008 0.256
#> GSM110441     2  0.1860     0.8507 0.000 0.948 0.052
#> GSM110444     1  0.7001     0.4423 0.588 0.388 0.024
#> GSM110445     1  0.5285     0.6822 0.812 0.148 0.040
#> GSM110446     3  0.6180     0.4256 0.260 0.024 0.716
#> GSM110449     2  0.0747     0.8506 0.000 0.984 0.016
#> GSM110451     3  0.8058     0.8023 0.140 0.212 0.648
#> GSM110391     2  0.1482     0.8401 0.012 0.968 0.020
#> GSM110439     2  0.3826     0.8349 0.008 0.868 0.124
#> GSM110442     2  0.3573     0.8383 0.004 0.876 0.120
#> GSM110443     2  0.8817     0.1103 0.380 0.500 0.120
#> GSM110447     3  0.8052     0.7937 0.152 0.196 0.652
#> GSM110448     1  0.7001     0.4423 0.588 0.388 0.024
#> GSM110450     1  0.3752     0.7130 0.884 0.020 0.096
#> GSM110452     2  0.0747     0.8506 0.000 0.984 0.016
#> GSM110453     2  0.4602     0.8175 0.016 0.832 0.152

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     3  0.4764     0.5813 0.008 0.136 0.796 0.060
#> GSM110396     1  0.2923     0.5947 0.908 0.020 0.036 0.036
#> GSM110397     1  0.3581     0.5909 0.852 0.000 0.032 0.116
#> GSM110398     2  0.1297     0.7966 0.016 0.964 0.000 0.020
#> GSM110399     2  0.2936     0.7962 0.032 0.908 0.024 0.036
#> GSM110400     3  0.2142     0.7010 0.000 0.016 0.928 0.056
#> GSM110401     1  0.0817     0.5983 0.976 0.000 0.024 0.000
#> GSM110406     2  0.2936     0.7962 0.032 0.908 0.024 0.036
#> GSM110407     1  0.3157     0.5306 0.852 0.000 0.144 0.004
#> GSM110409     1  0.5797     0.4193 0.624 0.340 0.012 0.024
#> GSM110410     2  0.3828     0.7960 0.000 0.848 0.084 0.068
#> GSM110413     2  0.2334     0.7700 0.000 0.908 0.004 0.088
#> GSM110414     3  0.3542     0.6456 0.000 0.060 0.864 0.076
#> GSM110415     3  0.2563     0.7092 0.012 0.012 0.916 0.060
#> GSM110416     3  0.2300     0.7024 0.048 0.000 0.924 0.028
#> GSM110418     3  0.2300     0.7024 0.048 0.000 0.924 0.028
#> GSM110419     3  0.2654     0.6853 0.108 0.000 0.888 0.004
#> GSM110420     4  0.6148     0.4950 0.048 0.000 0.468 0.484
#> GSM110421     2  0.4262     0.6758 0.000 0.756 0.008 0.236
#> GSM110423     3  0.2142     0.7010 0.000 0.016 0.928 0.056
#> GSM110424     2  0.3894     0.7951 0.000 0.844 0.088 0.068
#> GSM110425     3  0.2654     0.6853 0.108 0.000 0.888 0.004
#> GSM110427     2  0.6848     0.1695 0.008 0.472 0.444 0.076
#> GSM110428     1  0.7708    -0.1596 0.508 0.008 0.256 0.228
#> GSM110430     1  0.0817     0.5983 0.976 0.000 0.024 0.000
#> GSM110431     1  0.7028    -0.0228 0.576 0.000 0.196 0.228
#> GSM110432     3  0.3917     0.6722 0.108 0.044 0.844 0.004
#> GSM110434     2  0.3705     0.8035 0.016 0.868 0.076 0.040
#> GSM110435     1  0.5773     0.2265 0.620 0.000 0.336 0.044
#> GSM110437     1  0.0817     0.5983 0.976 0.000 0.024 0.000
#> GSM110438     4  0.7884     0.4861 0.356 0.000 0.284 0.360
#> GSM110388     1  0.7463     0.3964 0.440 0.176 0.000 0.384
#> GSM110392     1  0.9222    -0.0254 0.404 0.288 0.096 0.212
#> GSM110394     1  0.3208     0.5266 0.848 0.000 0.148 0.004
#> GSM110402     3  0.2197     0.7050 0.048 0.000 0.928 0.024
#> GSM110411     1  0.7436     0.3989 0.444 0.172 0.000 0.384
#> GSM110412     2  0.5010     0.6412 0.000 0.700 0.024 0.276
#> GSM110417     1  0.3672     0.5848 0.824 0.000 0.012 0.164
#> GSM110422     2  0.5500     0.7699 0.024 0.768 0.112 0.096
#> GSM110426     1  0.3760     0.5857 0.836 0.000 0.028 0.136
#> GSM110429     2  0.5608     0.7639 0.024 0.760 0.120 0.096
#> GSM110433     2  0.4262     0.6758 0.000 0.756 0.008 0.236
#> GSM110436     3  0.6725    -0.2131 0.004 0.456 0.464 0.076
#> GSM110440     1  0.5378     0.3571 0.696 0.004 0.264 0.036
#> GSM110441     2  0.1929     0.8072 0.000 0.940 0.024 0.036
#> GSM110444     1  0.7436     0.3989 0.444 0.172 0.000 0.384
#> GSM110445     1  0.3560     0.5641 0.844 0.140 0.004 0.012
#> GSM110446     4  0.7670     0.6318 0.192 0.008 0.300 0.500
#> GSM110449     2  0.0779     0.8028 0.000 0.980 0.016 0.004
#> GSM110451     3  0.3857     0.6757 0.104 0.044 0.848 0.004
#> GSM110391     2  0.4262     0.6758 0.000 0.756 0.008 0.236
#> GSM110439     2  0.4425     0.7929 0.008 0.824 0.092 0.076
#> GSM110442     2  0.4131     0.7941 0.004 0.836 0.096 0.064
#> GSM110443     2  0.7623     0.1686 0.420 0.460 0.072 0.048
#> GSM110447     3  0.3519     0.6493 0.120 0.004 0.856 0.020
#> GSM110448     1  0.7436     0.3989 0.444 0.172 0.000 0.384
#> GSM110450     1  0.2392     0.5912 0.924 0.016 0.052 0.008
#> GSM110452     2  0.0779     0.8028 0.000 0.980 0.016 0.004
#> GSM110453     2  0.5386     0.7742 0.024 0.776 0.104 0.096

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     3   0.334    0.61760 0.000 0.172 0.812 0.016 0.000
#> GSM110396     1   0.275    0.59382 0.900 0.032 0.012 0.008 0.048
#> GSM110397     1   0.554    0.39874 0.604 0.000 0.004 0.312 0.080
#> GSM110398     2   0.493    0.52157 0.000 0.652 0.000 0.296 0.052
#> GSM110399     2   0.596    0.54727 0.012 0.628 0.024 0.276 0.060
#> GSM110400     3   0.104    0.73057 0.000 0.040 0.960 0.000 0.000
#> GSM110401     1   0.000    0.60883 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2   0.596    0.54727 0.012 0.628 0.024 0.276 0.060
#> GSM110407     1   0.306    0.55774 0.864 0.000 0.068 0.000 0.068
#> GSM110409     1   0.595    0.34923 0.612 0.300 0.012 0.024 0.052
#> GSM110410     2   0.209    0.68884 0.000 0.924 0.048 0.020 0.008
#> GSM110413     2   0.559    0.33149 0.000 0.548 0.000 0.372 0.080
#> GSM110414     3   0.261    0.69256 0.000 0.056 0.896 0.004 0.044
#> GSM110415     3   0.157    0.73889 0.008 0.032 0.948 0.000 0.012
#> GSM110416     3   0.426    0.71764 0.044 0.000 0.744 0.000 0.212
#> GSM110418     3   0.426    0.71764 0.044 0.000 0.744 0.000 0.212
#> GSM110419     3   0.427    0.74827 0.116 0.000 0.776 0.000 0.108
#> GSM110420     5   0.341    0.62033 0.024 0.000 0.160 0.000 0.816
#> GSM110421     4   0.541    0.08864 0.000 0.408 0.000 0.532 0.060
#> GSM110423     3   0.104    0.73057 0.000 0.040 0.960 0.000 0.000
#> GSM110424     2   0.196    0.68915 0.000 0.928 0.048 0.020 0.004
#> GSM110425     3   0.427    0.74827 0.116 0.000 0.776 0.000 0.108
#> GSM110427     2   0.419    0.37340 0.000 0.596 0.404 0.000 0.000
#> GSM110428     1   0.657   -0.13303 0.508 0.008 0.152 0.004 0.328
#> GSM110430     1   0.000    0.60883 1.000 0.000 0.000 0.000 0.000
#> GSM110431     1   0.537   -0.00327 0.584 0.000 0.068 0.000 0.348
#> GSM110432     3   0.539    0.73296 0.116 0.048 0.728 0.000 0.108
#> GSM110434     2   0.241    0.68447 0.004 0.912 0.008 0.024 0.052
#> GSM110435     1   0.573    0.28144 0.616 0.000 0.148 0.000 0.236
#> GSM110437     1   0.000    0.60883 1.000 0.000 0.000 0.000 0.000
#> GSM110438     5   0.570    0.42762 0.352 0.000 0.072 0.008 0.568
#> GSM110388     4   0.385    0.50014 0.220 0.020 0.000 0.760 0.000
#> GSM110392     1   0.859   -0.07623 0.352 0.316 0.020 0.124 0.188
#> GSM110394     1   0.312    0.55499 0.860 0.000 0.068 0.000 0.072
#> GSM110402     3   0.423    0.71993 0.044 0.000 0.748 0.000 0.208
#> GSM110411     4   0.376    0.49991 0.220 0.016 0.000 0.764 0.000
#> GSM110412     2   0.569    0.02462 0.000 0.504 0.008 0.428 0.060
#> GSM110417     1   0.550    0.32890 0.556 0.000 0.004 0.380 0.060
#> GSM110422     2   0.266    0.68834 0.004 0.892 0.064 0.000 0.040
#> GSM110426     1   0.563    0.37284 0.580 0.000 0.004 0.336 0.080
#> GSM110429     2   0.279    0.68573 0.004 0.884 0.072 0.000 0.040
#> GSM110433     4   0.541    0.08864 0.000 0.408 0.000 0.532 0.060
#> GSM110436     2   0.423    0.33521 0.000 0.576 0.424 0.000 0.000
#> GSM110440     1   0.525    0.40137 0.696 0.008 0.108 0.000 0.188
#> GSM110441     2   0.458    0.57178 0.000 0.696 0.032 0.268 0.004
#> GSM110444     4   0.376    0.49991 0.220 0.016 0.000 0.764 0.000
#> GSM110445     1   0.345    0.54508 0.836 0.120 0.000 0.040 0.004
#> GSM110446     5   0.446    0.64355 0.176 0.020 0.040 0.000 0.764
#> GSM110449     2   0.344    0.64731 0.000 0.828 0.004 0.140 0.028
#> GSM110451     3   0.534    0.73527 0.112 0.048 0.732 0.000 0.108
#> GSM110391     4   0.541    0.08864 0.000 0.408 0.000 0.532 0.060
#> GSM110439     2   0.136    0.69411 0.000 0.948 0.048 0.004 0.000
#> GSM110442     2   0.191    0.69457 0.000 0.932 0.036 0.028 0.004
#> GSM110443     2   0.670    0.09406 0.408 0.476 0.012 0.060 0.044
#> GSM110447     3   0.518    0.68403 0.120 0.008 0.708 0.000 0.164
#> GSM110448     4   0.376    0.49991 0.220 0.016 0.000 0.764 0.000
#> GSM110450     1   0.190    0.60172 0.940 0.008 0.016 0.024 0.012
#> GSM110452     2   0.344    0.64731 0.000 0.828 0.004 0.140 0.028
#> GSM110453     2   0.253    0.68945 0.004 0.900 0.056 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     3  0.5132     0.6134 0.000 0.184 0.684 0.000 0.040 0.092
#> GSM110396     1  0.2720     0.6037 0.892 0.056 0.012 0.008 0.016 0.016
#> GSM110397     4  0.5464     0.5646 0.232 0.000 0.008 0.636 0.020 0.104
#> GSM110398     5  0.4366     0.5070 0.000 0.324 0.004 0.024 0.644 0.004
#> GSM110399     5  0.4499     0.4992 0.008 0.344 0.012 0.000 0.624 0.012
#> GSM110400     3  0.3576     0.7138 0.000 0.084 0.812 0.000 0.008 0.096
#> GSM110401     1  0.0146     0.6219 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110406     5  0.4499     0.4992 0.008 0.344 0.012 0.000 0.624 0.012
#> GSM110407     1  0.2812     0.5866 0.860 0.000 0.108 0.004 0.004 0.024
#> GSM110409     1  0.5393     0.3569 0.604 0.280 0.012 0.004 0.100 0.000
#> GSM110410     2  0.2009     0.6583 0.000 0.904 0.000 0.004 0.084 0.008
#> GSM110413     5  0.3381     0.4859 0.000 0.148 0.000 0.040 0.808 0.004
#> GSM110414     3  0.4682     0.6770 0.000 0.088 0.748 0.000 0.068 0.096
#> GSM110415     3  0.3707     0.7210 0.008 0.076 0.808 0.000 0.004 0.104
#> GSM110416     3  0.2909     0.6898 0.028 0.000 0.836 0.000 0.000 0.136
#> GSM110418     3  0.2909     0.6898 0.028 0.000 0.836 0.000 0.000 0.136
#> GSM110419     3  0.2212     0.7347 0.112 0.008 0.880 0.000 0.000 0.000
#> GSM110420     6  0.2883     0.6379 0.000 0.000 0.212 0.000 0.000 0.788
#> GSM110421     5  0.5633     0.2593 0.000 0.272 0.000 0.196 0.532 0.000
#> GSM110423     3  0.3576     0.7138 0.000 0.084 0.812 0.000 0.008 0.096
#> GSM110424     2  0.1897     0.6601 0.000 0.908 0.000 0.004 0.084 0.004
#> GSM110425     3  0.2212     0.7347 0.112 0.008 0.880 0.000 0.000 0.000
#> GSM110427     2  0.5225     0.4353 0.000 0.620 0.272 0.000 0.016 0.092
#> GSM110428     1  0.5921     0.0526 0.508 0.004 0.184 0.004 0.000 0.300
#> GSM110430     1  0.0146     0.6219 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110431     1  0.5240     0.1752 0.584 0.000 0.132 0.000 0.000 0.284
#> GSM110432     3  0.3123     0.7207 0.112 0.056 0.832 0.000 0.000 0.000
#> GSM110434     2  0.2170     0.5837 0.000 0.888 0.012 0.000 0.100 0.000
#> GSM110435     1  0.5259     0.2909 0.600 0.000 0.240 0.000 0.000 0.160
#> GSM110437     1  0.0291     0.6214 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM110438     6  0.6162     0.3670 0.336 0.000 0.188 0.016 0.000 0.460
#> GSM110388     4  0.3025     0.7414 0.024 0.000 0.000 0.820 0.156 0.000
#> GSM110392     1  0.8296    -0.0509 0.340 0.308 0.020 0.140 0.032 0.160
#> GSM110394     1  0.2890     0.5842 0.856 0.000 0.108 0.004 0.004 0.028
#> GSM110402     3  0.3050     0.6922 0.028 0.004 0.832 0.000 0.000 0.136
#> GSM110411     4  0.2988     0.7447 0.024 0.000 0.000 0.824 0.152 0.000
#> GSM110412     2  0.6267    -0.1203 0.000 0.380 0.008 0.256 0.356 0.000
#> GSM110417     4  0.4789     0.6136 0.184 0.000 0.004 0.708 0.016 0.088
#> GSM110422     2  0.0951     0.6804 0.000 0.968 0.020 0.000 0.004 0.008
#> GSM110426     4  0.5319     0.5882 0.208 0.000 0.008 0.660 0.020 0.104
#> GSM110429     2  0.1116     0.6791 0.000 0.960 0.028 0.000 0.004 0.008
#> GSM110433     5  0.5633     0.2593 0.000 0.272 0.000 0.196 0.532 0.000
#> GSM110436     2  0.5311     0.4190 0.000 0.600 0.292 0.000 0.016 0.092
#> GSM110440     1  0.4956     0.4269 0.684 0.008 0.180 0.000 0.004 0.124
#> GSM110441     5  0.3942     0.4552 0.000 0.368 0.000 0.004 0.624 0.004
#> GSM110444     4  0.2988     0.7447 0.024 0.000 0.000 0.824 0.152 0.000
#> GSM110445     1  0.3362     0.5521 0.840 0.088 0.004 0.016 0.052 0.000
#> GSM110446     6  0.5304     0.6264 0.156 0.048 0.104 0.000 0.004 0.688
#> GSM110449     5  0.4428     0.3154 0.000 0.452 0.004 0.012 0.528 0.004
#> GSM110451     3  0.3078     0.7237 0.108 0.056 0.836 0.000 0.000 0.000
#> GSM110391     5  0.5633     0.2593 0.000 0.272 0.000 0.196 0.532 0.000
#> GSM110439     2  0.1340     0.6759 0.000 0.948 0.008 0.004 0.040 0.000
#> GSM110442     2  0.3194     0.5520 0.000 0.808 0.000 0.020 0.168 0.004
#> GSM110443     1  0.7014     0.0790 0.404 0.352 0.012 0.028 0.192 0.012
#> GSM110447     3  0.4144     0.6703 0.108 0.012 0.776 0.000 0.004 0.100
#> GSM110448     4  0.2988     0.7447 0.024 0.000 0.000 0.824 0.152 0.000
#> GSM110450     1  0.1590     0.6215 0.944 0.008 0.028 0.012 0.008 0.000
#> GSM110452     5  0.4428     0.3154 0.000 0.452 0.004 0.012 0.528 0.004
#> GSM110453     2  0.0881     0.6763 0.000 0.972 0.012 0.000 0.008 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> SD:hclust 54            1.000       0.713 2
#> SD:hclust 47            0.112       0.194 3
#> SD:hclust 44            0.171       0.429 4
#> SD:hclust 38            0.317       0.560 5
#> SD:hclust 39            0.103       0.521 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.488           0.662       0.865         0.5014 0.493   0.493
#> 3 3 0.458           0.593       0.794         0.3071 0.704   0.476
#> 4 4 0.607           0.681       0.823         0.1292 0.798   0.490
#> 5 5 0.641           0.481       0.691         0.0721 0.901   0.638
#> 6 6 0.667           0.558       0.749         0.0418 0.915   0.632

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
#> GSM110395     2  0.8763      0.592 0.296 0.704
#> GSM110396     1  0.1184      0.820 0.984 0.016
#> GSM110397     1  0.1184      0.820 0.984 0.016
#> GSM110398     2  0.8327      0.488 0.264 0.736
#> GSM110399     2  0.1633      0.823 0.024 0.976
#> GSM110400     2  0.9635      0.458 0.388 0.612
#> GSM110401     1  0.1184      0.820 0.984 0.016
#> GSM110406     2  0.1633      0.823 0.024 0.976
#> GSM110407     1  0.0376      0.822 0.996 0.004
#> GSM110409     1  0.0376      0.822 0.996 0.004
#> GSM110410     2  0.0000      0.823 0.000 1.000
#> GSM110413     2  0.0000      0.823 0.000 1.000
#> GSM110414     2  0.1184      0.821 0.016 0.984
#> GSM110415     1  0.9996     -0.213 0.512 0.488
#> GSM110416     1  0.0376      0.822 0.996 0.004
#> GSM110418     1  0.0376      0.822 0.996 0.004
#> GSM110419     1  0.9996     -0.213 0.512 0.488
#> GSM110420     1  0.0376      0.822 0.996 0.004
#> GSM110421     2  0.0376      0.821 0.004 0.996
#> GSM110423     2  1.0000      0.209 0.496 0.504
#> GSM110424     2  0.0000      0.823 0.000 1.000
#> GSM110425     2  1.0000      0.209 0.496 0.504
#> GSM110427     2  0.2423      0.818 0.040 0.960
#> GSM110428     1  0.0376      0.822 0.996 0.004
#> GSM110430     1  0.1184      0.820 0.984 0.016
#> GSM110431     1  0.0376      0.822 0.996 0.004
#> GSM110432     2  0.9661      0.450 0.392 0.608
#> GSM110434     2  0.1633      0.823 0.024 0.976
#> GSM110435     1  0.0376      0.822 0.996 0.004
#> GSM110437     1  0.1184      0.820 0.984 0.016
#> GSM110438     1  0.0376      0.822 0.996 0.004
#> GSM110388     1  0.9732      0.386 0.596 0.404
#> GSM110392     1  0.9209      0.500 0.664 0.336
#> GSM110394     1  0.0376      0.822 0.996 0.004
#> GSM110402     2  1.0000      0.209 0.496 0.504
#> GSM110411     1  0.9795      0.363 0.584 0.416
#> GSM110412     2  0.0000      0.823 0.000 1.000
#> GSM110417     1  0.6623      0.695 0.828 0.172
#> GSM110422     2  0.2423      0.818 0.040 0.960
#> GSM110426     1  0.2423      0.806 0.960 0.040
#> GSM110429     2  0.5946      0.751 0.144 0.856
#> GSM110433     2  0.0000      0.823 0.000 1.000
#> GSM110436     2  0.9608      0.464 0.384 0.616
#> GSM110440     1  0.0000      0.821 1.000 0.000
#> GSM110441     2  0.0000      0.823 0.000 1.000
#> GSM110444     2  0.5946      0.700 0.144 0.856
#> GSM110445     1  0.9635      0.395 0.612 0.388
#> GSM110446     1  0.0376      0.822 0.996 0.004
#> GSM110449     2  0.0376      0.821 0.004 0.996
#> GSM110451     2  0.9635      0.458 0.388 0.612
#> GSM110391     2  0.0000      0.823 0.000 1.000
#> GSM110439     2  0.0938      0.824 0.012 0.988
#> GSM110442     2  0.0000      0.823 0.000 1.000
#> GSM110443     2  0.5294      0.766 0.120 0.880
#> GSM110447     1  0.9996     -0.213 0.512 0.488
#> GSM110448     1  0.9661      0.406 0.608 0.392
#> GSM110450     1  0.1184      0.820 0.984 0.016
#> GSM110452     2  0.0938      0.824 0.012 0.988
#> GSM110453     2  0.0938      0.824 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     2  0.3619     0.7328 0.000 0.864 0.136
#> GSM110396     1  0.6779     0.4706 0.544 0.012 0.444
#> GSM110397     1  0.6154     0.4927 0.592 0.000 0.408
#> GSM110398     2  0.4805     0.7660 0.176 0.812 0.012
#> GSM110399     2  0.1860     0.8448 0.052 0.948 0.000
#> GSM110400     3  0.4887     0.6376 0.000 0.228 0.772
#> GSM110401     1  0.6483     0.4672 0.544 0.004 0.452
#> GSM110406     2  0.1989     0.8466 0.048 0.948 0.004
#> GSM110407     3  0.6529     0.0152 0.368 0.012 0.620
#> GSM110409     3  0.8619    -0.1402 0.368 0.108 0.524
#> GSM110410     2  0.0747     0.8527 0.016 0.984 0.000
#> GSM110413     2  0.3340     0.8178 0.120 0.880 0.000
#> GSM110414     2  0.9032     0.2300 0.148 0.512 0.340
#> GSM110415     3  0.4128     0.6858 0.012 0.132 0.856
#> GSM110416     3  0.0747     0.6614 0.016 0.000 0.984
#> GSM110418     3  0.0747     0.6614 0.016 0.000 0.984
#> GSM110419     3  0.3816     0.6868 0.000 0.148 0.852
#> GSM110420     3  0.0892     0.6598 0.020 0.000 0.980
#> GSM110421     2  0.6079     0.6023 0.388 0.612 0.000
#> GSM110423     3  0.3879     0.6854 0.000 0.152 0.848
#> GSM110424     2  0.0747     0.8527 0.016 0.984 0.000
#> GSM110425     3  0.3879     0.6854 0.000 0.152 0.848
#> GSM110427     2  0.0892     0.8415 0.000 0.980 0.020
#> GSM110428     3  0.0000     0.6616 0.000 0.000 1.000
#> GSM110430     1  0.6483     0.4672 0.544 0.004 0.452
#> GSM110431     3  0.5254     0.3197 0.264 0.000 0.736
#> GSM110432     3  0.4796     0.6444 0.000 0.220 0.780
#> GSM110434     2  0.0000     0.8507 0.000 1.000 0.000
#> GSM110435     3  0.5254     0.3197 0.264 0.000 0.736
#> GSM110437     1  0.6274     0.4624 0.544 0.000 0.456
#> GSM110438     3  0.1753     0.6441 0.048 0.000 0.952
#> GSM110388     1  0.2066     0.5770 0.940 0.060 0.000
#> GSM110392     3  0.9760     0.1905 0.276 0.280 0.444
#> GSM110394     3  0.5098     0.3472 0.248 0.000 0.752
#> GSM110402     3  0.4047     0.6874 0.004 0.148 0.848
#> GSM110411     1  0.2066     0.5770 0.940 0.060 0.000
#> GSM110412     2  0.8637     0.4017 0.448 0.452 0.100
#> GSM110417     1  0.3425     0.6006 0.884 0.004 0.112
#> GSM110422     2  0.0237     0.8492 0.000 0.996 0.004
#> GSM110426     1  0.4291     0.5960 0.820 0.000 0.180
#> GSM110429     2  0.2165     0.8095 0.000 0.936 0.064
#> GSM110433     2  0.5968     0.6287 0.364 0.636 0.000
#> GSM110436     3  0.6204     0.3379 0.000 0.424 0.576
#> GSM110440     3  0.6274    -0.2825 0.456 0.000 0.544
#> GSM110441     2  0.3116     0.8245 0.108 0.892 0.000
#> GSM110444     1  0.4452     0.3577 0.808 0.192 0.000
#> GSM110445     1  0.8173     0.4481 0.600 0.300 0.100
#> GSM110446     3  0.1860     0.6413 0.052 0.000 0.948
#> GSM110449     2  0.3482     0.8129 0.128 0.872 0.000
#> GSM110451     3  0.5497     0.5774 0.000 0.292 0.708
#> GSM110391     2  0.6079     0.6023 0.388 0.612 0.000
#> GSM110439     2  0.0424     0.8526 0.008 0.992 0.000
#> GSM110442     2  0.0424     0.8526 0.008 0.992 0.000
#> GSM110443     2  0.3349     0.8173 0.108 0.888 0.004
#> GSM110447     3  0.3752     0.6870 0.000 0.144 0.856
#> GSM110448     1  0.2066     0.5770 0.940 0.060 0.000
#> GSM110450     1  0.6483     0.4672 0.544 0.004 0.452
#> GSM110452     2  0.0424     0.8526 0.008 0.992 0.000
#> GSM110453     2  0.0000     0.8507 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4747     0.7107 0.024 0.780 0.180 0.016
#> GSM110396     1  0.3888     0.7460 0.860 0.016 0.052 0.072
#> GSM110397     1  0.4224     0.6730 0.812 0.000 0.044 0.144
#> GSM110398     2  0.4127     0.7617 0.052 0.824 0.000 0.124
#> GSM110399     2  0.1543     0.8702 0.008 0.956 0.004 0.032
#> GSM110400     3  0.2297     0.8404 0.024 0.032 0.932 0.012
#> GSM110401     1  0.3721     0.7493 0.864 0.008 0.056 0.072
#> GSM110406     2  0.2432     0.8659 0.024 0.928 0.020 0.028
#> GSM110407     1  0.4835     0.6801 0.756 0.004 0.208 0.032
#> GSM110409     1  0.5197     0.6638 0.780 0.144 0.044 0.032
#> GSM110410     2  0.2924     0.8478 0.036 0.900 0.004 0.060
#> GSM110413     2  0.5358     0.6510 0.052 0.724 0.004 0.220
#> GSM110414     3  0.5942     0.6241 0.048 0.060 0.740 0.152
#> GSM110415     3  0.0564     0.8557 0.004 0.004 0.988 0.004
#> GSM110416     3  0.3279     0.8073 0.096 0.000 0.872 0.032
#> GSM110418     3  0.3464     0.7997 0.108 0.000 0.860 0.032
#> GSM110419     3  0.1722     0.8563 0.048 0.008 0.944 0.000
#> GSM110420     3  0.3464     0.7997 0.108 0.000 0.860 0.032
#> GSM110421     4  0.6079     0.2079 0.048 0.408 0.000 0.544
#> GSM110423     3  0.1059     0.8557 0.016 0.012 0.972 0.000
#> GSM110424     2  0.3104     0.8434 0.044 0.892 0.004 0.060
#> GSM110425     3  0.1284     0.8541 0.024 0.012 0.964 0.000
#> GSM110427     2  0.3238     0.8199 0.020 0.880 0.092 0.008
#> GSM110428     3  0.1576     0.8539 0.048 0.000 0.948 0.004
#> GSM110430     1  0.3721     0.7493 0.864 0.008 0.056 0.072
#> GSM110431     1  0.5269     0.4818 0.620 0.000 0.364 0.016
#> GSM110432     3  0.2613     0.8314 0.024 0.052 0.916 0.008
#> GSM110434     2  0.0524     0.8749 0.000 0.988 0.008 0.004
#> GSM110435     1  0.5599     0.4815 0.616 0.000 0.352 0.032
#> GSM110437     1  0.3877     0.7453 0.852 0.004 0.072 0.072
#> GSM110438     3  0.4964     0.6224 0.244 0.000 0.724 0.032
#> GSM110388     4  0.3113     0.5865 0.108 0.012 0.004 0.876
#> GSM110392     4  0.9453    -0.0273 0.252 0.104 0.296 0.348
#> GSM110394     1  0.5203     0.4843 0.636 0.000 0.348 0.016
#> GSM110402     3  0.1767     0.8515 0.044 0.012 0.944 0.000
#> GSM110411     4  0.2730     0.5957 0.088 0.016 0.000 0.896
#> GSM110412     4  0.4694     0.5988 0.044 0.084 0.048 0.824
#> GSM110417     4  0.4964     0.1305 0.380 0.000 0.004 0.616
#> GSM110422     2  0.0895     0.8741 0.000 0.976 0.020 0.004
#> GSM110426     1  0.5859     0.0659 0.496 0.000 0.032 0.472
#> GSM110429     2  0.3854     0.7596 0.012 0.828 0.152 0.008
#> GSM110433     4  0.6120     0.1389 0.048 0.432 0.000 0.520
#> GSM110436     3  0.4260     0.7224 0.020 0.180 0.796 0.004
#> GSM110440     1  0.2918     0.7345 0.876 0.000 0.116 0.008
#> GSM110441     2  0.3266     0.8301 0.040 0.876 0.000 0.084
#> GSM110444     4  0.2214     0.6093 0.044 0.028 0.000 0.928
#> GSM110445     1  0.5200     0.5950 0.744 0.184 0.000 0.072
#> GSM110446     3  0.5511     0.4579 0.332 0.000 0.636 0.032
#> GSM110449     2  0.2976     0.8108 0.008 0.872 0.000 0.120
#> GSM110451     3  0.4265     0.7478 0.024 0.148 0.816 0.012
#> GSM110391     4  0.6079     0.2079 0.048 0.408 0.000 0.544
#> GSM110439     2  0.0376     0.8766 0.000 0.992 0.004 0.004
#> GSM110442     2  0.0564     0.8769 0.004 0.988 0.004 0.004
#> GSM110443     2  0.4218     0.7089 0.184 0.796 0.008 0.012
#> GSM110447     3  0.0657     0.8561 0.004 0.012 0.984 0.000
#> GSM110448     4  0.3102     0.5755 0.116 0.008 0.004 0.872
#> GSM110450     1  0.3948     0.7452 0.852 0.008 0.068 0.072
#> GSM110452     2  0.0376     0.8766 0.000 0.992 0.004 0.004
#> GSM110453     2  0.0524     0.8769 0.000 0.988 0.004 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     5  0.6077     0.0309 0.032 0.436 0.052 0.000 0.480
#> GSM110396     1  0.0566     0.7748 0.984 0.000 0.000 0.004 0.012
#> GSM110397     1  0.6635     0.5215 0.608 0.000 0.188 0.140 0.064
#> GSM110398     2  0.4927     0.6778 0.060 0.756 0.000 0.044 0.140
#> GSM110399     2  0.4230     0.6969 0.008 0.764 0.000 0.036 0.192
#> GSM110400     5  0.5000    -0.0584 0.016 0.008 0.476 0.000 0.500
#> GSM110401     1  0.0613     0.7797 0.984 0.000 0.008 0.004 0.004
#> GSM110406     2  0.5138     0.6508 0.028 0.684 0.000 0.036 0.252
#> GSM110407     1  0.4036     0.7165 0.788 0.000 0.144 0.000 0.068
#> GSM110409     1  0.4156     0.7345 0.820 0.056 0.060 0.000 0.064
#> GSM110410     2  0.3421     0.6601 0.000 0.788 0.000 0.008 0.204
#> GSM110413     5  0.5922    -0.4881 0.000 0.420 0.000 0.104 0.476
#> GSM110414     5  0.4799     0.2256 0.000 0.008 0.260 0.040 0.692
#> GSM110415     3  0.4313     0.3939 0.008 0.000 0.636 0.000 0.356
#> GSM110416     3  0.0510     0.5279 0.000 0.000 0.984 0.000 0.016
#> GSM110418     3  0.0000     0.5279 0.000 0.000 1.000 0.000 0.000
#> GSM110419     3  0.4774     0.3796 0.028 0.000 0.612 0.000 0.360
#> GSM110420     3  0.0162     0.5270 0.000 0.000 0.996 0.000 0.004
#> GSM110421     4  0.6468     0.3837 0.000 0.188 0.000 0.452 0.360
#> GSM110423     3  0.4367     0.3686 0.008 0.000 0.620 0.000 0.372
#> GSM110424     2  0.3612     0.6481 0.000 0.764 0.000 0.008 0.228
#> GSM110425     3  0.4494     0.3490 0.012 0.000 0.608 0.000 0.380
#> GSM110427     2  0.4668     0.2019 0.008 0.600 0.008 0.000 0.384
#> GSM110428     3  0.4787     0.3736 0.028 0.000 0.608 0.000 0.364
#> GSM110430     1  0.0613     0.7797 0.984 0.000 0.008 0.004 0.004
#> GSM110431     1  0.4648     0.3819 0.524 0.000 0.464 0.000 0.012
#> GSM110432     5  0.6323     0.1729 0.028 0.080 0.400 0.000 0.492
#> GSM110434     2  0.0566     0.7469 0.004 0.984 0.000 0.000 0.012
#> GSM110435     3  0.4252    -0.1033 0.340 0.000 0.652 0.000 0.008
#> GSM110437     1  0.1153     0.7764 0.964 0.000 0.024 0.004 0.008
#> GSM110438     3  0.1764     0.5029 0.064 0.000 0.928 0.000 0.008
#> GSM110388     4  0.1502     0.6507 0.056 0.000 0.000 0.940 0.004
#> GSM110392     3  0.8574    -0.1079 0.140 0.064 0.428 0.284 0.084
#> GSM110394     1  0.4723     0.4006 0.536 0.000 0.448 0.000 0.016
#> GSM110402     3  0.4201     0.4191 0.008 0.000 0.664 0.000 0.328
#> GSM110411     4  0.1557     0.6771 0.008 0.000 0.000 0.940 0.052
#> GSM110412     4  0.3462     0.6406 0.000 0.012 0.000 0.792 0.196
#> GSM110417     4  0.4846     0.4370 0.244 0.000 0.004 0.696 0.056
#> GSM110422     2  0.2286     0.7068 0.004 0.888 0.000 0.000 0.108
#> GSM110426     4  0.6760     0.2665 0.272 0.000 0.108 0.560 0.060
#> GSM110429     2  0.4651     0.0470 0.004 0.560 0.008 0.000 0.428
#> GSM110433     4  0.6715     0.2647 0.000 0.248 0.000 0.392 0.360
#> GSM110436     5  0.6844     0.3812 0.016 0.216 0.276 0.000 0.492
#> GSM110440     1  0.3618     0.7300 0.788 0.000 0.196 0.004 0.012
#> GSM110441     2  0.4990     0.5541 0.000 0.628 0.000 0.048 0.324
#> GSM110444     4  0.1628     0.6772 0.008 0.000 0.000 0.936 0.056
#> GSM110445     1  0.4326     0.6145 0.772 0.164 0.000 0.008 0.056
#> GSM110446     3  0.2879     0.4633 0.100 0.000 0.868 0.000 0.032
#> GSM110449     2  0.3914     0.6896 0.000 0.788 0.000 0.048 0.164
#> GSM110451     5  0.6801     0.3562 0.020 0.176 0.308 0.000 0.496
#> GSM110391     4  0.6468     0.3837 0.000 0.188 0.000 0.452 0.360
#> GSM110439     2  0.0000     0.7487 0.000 1.000 0.000 0.000 0.000
#> GSM110442     2  0.0290     0.7482 0.000 0.992 0.000 0.000 0.008
#> GSM110443     2  0.5551     0.4753 0.284 0.612 0.000 0.000 0.104
#> GSM110447     3  0.4354     0.3779 0.008 0.000 0.624 0.000 0.368
#> GSM110448     4  0.1478     0.6456 0.064 0.000 0.000 0.936 0.000
#> GSM110450     1  0.0451     0.7759 0.988 0.000 0.000 0.004 0.008
#> GSM110452     2  0.0000     0.7487 0.000 1.000 0.000 0.000 0.000
#> GSM110453     2  0.0404     0.7484 0.000 0.988 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     3  0.4724     0.2717 0.004 0.328 0.628 0.004 0.020 0.016
#> GSM110396     1  0.0972     0.7518 0.964 0.000 0.000 0.008 0.000 0.028
#> GSM110397     1  0.5893     0.1696 0.424 0.000 0.000 0.372 0.000 0.204
#> GSM110398     2  0.6252     0.4926 0.052 0.640 0.012 0.028 0.172 0.096
#> GSM110399     2  0.5407     0.5557 0.000 0.688 0.068 0.012 0.168 0.064
#> GSM110400     3  0.0551     0.7270 0.000 0.004 0.984 0.000 0.004 0.008
#> GSM110401     1  0.0551     0.7538 0.984 0.000 0.000 0.008 0.004 0.004
#> GSM110406     2  0.6778     0.4969 0.016 0.568 0.180 0.012 0.164 0.060
#> GSM110407     1  0.3687     0.6937 0.812 0.000 0.108 0.012 0.004 0.064
#> GSM110409     1  0.3893     0.7074 0.824 0.072 0.036 0.012 0.004 0.052
#> GSM110410     2  0.4659     0.3549 0.000 0.644 0.008 0.004 0.304 0.040
#> GSM110413     5  0.3953     0.4677 0.000 0.160 0.040 0.000 0.776 0.024
#> GSM110414     3  0.4284     0.5913 0.000 0.008 0.720 0.000 0.216 0.056
#> GSM110415     3  0.2631     0.6999 0.000 0.000 0.820 0.000 0.000 0.180
#> GSM110416     6  0.3309     0.7257 0.000 0.000 0.280 0.000 0.000 0.720
#> GSM110418     6  0.3221     0.7431 0.000 0.000 0.264 0.000 0.000 0.736
#> GSM110419     3  0.3204     0.6937 0.032 0.000 0.820 0.004 0.000 0.144
#> GSM110420     6  0.3398     0.7515 0.000 0.000 0.252 0.008 0.000 0.740
#> GSM110421     5  0.2558     0.6000 0.000 0.028 0.000 0.104 0.868 0.000
#> GSM110423     3  0.2378     0.7213 0.000 0.000 0.848 0.000 0.000 0.152
#> GSM110424     2  0.4872     0.3015 0.000 0.608 0.012 0.004 0.336 0.040
#> GSM110425     3  0.2219     0.7278 0.000 0.000 0.864 0.000 0.000 0.136
#> GSM110427     2  0.4381     0.1454 0.000 0.524 0.456 0.000 0.016 0.004
#> GSM110428     3  0.3242     0.7048 0.032 0.000 0.816 0.004 0.000 0.148
#> GSM110430     1  0.0665     0.7537 0.980 0.000 0.000 0.008 0.004 0.008
#> GSM110431     1  0.4932     0.3203 0.556 0.000 0.072 0.000 0.000 0.372
#> GSM110432     3  0.2296     0.6998 0.004 0.084 0.896 0.004 0.004 0.008
#> GSM110434     2  0.0665     0.6726 0.000 0.980 0.004 0.000 0.008 0.008
#> GSM110435     6  0.4278     0.5457 0.212 0.000 0.076 0.000 0.000 0.712
#> GSM110437     1  0.1138     0.7509 0.960 0.000 0.000 0.012 0.004 0.024
#> GSM110438     6  0.4397     0.7619 0.072 0.000 0.188 0.012 0.000 0.728
#> GSM110388     4  0.3245     0.7197 0.016 0.000 0.000 0.796 0.184 0.004
#> GSM110392     6  0.7720     0.0733 0.084 0.052 0.084 0.372 0.020 0.388
#> GSM110394     1  0.5249     0.3486 0.556 0.000 0.096 0.004 0.000 0.344
#> GSM110402     3  0.3351     0.5382 0.000 0.000 0.712 0.000 0.000 0.288
#> GSM110411     4  0.3652     0.6153 0.000 0.000 0.000 0.672 0.324 0.004
#> GSM110412     5  0.4662    -0.2331 0.000 0.004 0.016 0.420 0.548 0.012
#> GSM110417     4  0.3062     0.6130 0.112 0.000 0.000 0.836 0.000 0.052
#> GSM110422     2  0.2214     0.6486 0.000 0.892 0.092 0.000 0.012 0.004
#> GSM110426     4  0.3595     0.5853 0.120 0.000 0.000 0.796 0.000 0.084
#> GSM110429     2  0.4195     0.1742 0.000 0.548 0.440 0.000 0.008 0.004
#> GSM110433     5  0.2609     0.6038 0.000 0.036 0.000 0.096 0.868 0.000
#> GSM110436     3  0.3469     0.6397 0.004 0.180 0.792 0.000 0.012 0.012
#> GSM110440     1  0.3459     0.6334 0.768 0.000 0.016 0.004 0.000 0.212
#> GSM110441     5  0.5200    -0.2205 0.000 0.444 0.004 0.000 0.476 0.076
#> GSM110444     4  0.3652     0.6154 0.000 0.000 0.000 0.672 0.324 0.004
#> GSM110445     1  0.6299     0.4299 0.616 0.196 0.000 0.044 0.052 0.092
#> GSM110446     6  0.4238     0.7622 0.072 0.000 0.168 0.012 0.000 0.748
#> GSM110449     2  0.5317     0.4860 0.000 0.648 0.000 0.028 0.216 0.108
#> GSM110451     3  0.3018     0.6653 0.004 0.148 0.832 0.004 0.004 0.008
#> GSM110391     5  0.2701     0.5981 0.000 0.028 0.000 0.104 0.864 0.004
#> GSM110439     2  0.0870     0.6701 0.000 0.972 0.004 0.000 0.012 0.012
#> GSM110442     2  0.2308     0.6578 0.000 0.904 0.008 0.004 0.056 0.028
#> GSM110443     2  0.7168     0.4422 0.220 0.560 0.044 0.036 0.056 0.084
#> GSM110447     3  0.2879     0.7093 0.004 0.000 0.816 0.000 0.004 0.176
#> GSM110448     4  0.3104     0.7204 0.016 0.000 0.000 0.800 0.184 0.000
#> GSM110450     1  0.1078     0.7507 0.964 0.000 0.000 0.016 0.012 0.008
#> GSM110452     2  0.1390     0.6672 0.000 0.948 0.004 0.000 0.016 0.032
#> GSM110453     2  0.0767     0.6724 0.000 0.976 0.004 0.000 0.012 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> SD:kmeans 43           0.1502      0.1459 2
#> SD:kmeans 41           0.0158      0.2626 3
#> SD:kmeans 49           0.0203      0.3533 4
#> SD:kmeans 32           0.0141      0.4465 5
#> SD:kmeans 42           0.0187      0.0895 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 17209 rows and 59 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.537           0.650       0.874         0.5075 0.492   0.492
#> 3 3 0.593           0.503       0.781         0.3187 0.739   0.543
#> 4 4 0.710           0.785       0.893         0.1168 0.819   0.559
#> 5 5 0.657           0.555       0.767         0.0728 0.876   0.561
#> 6 6 0.678           0.509       0.725         0.0448 0.935   0.688

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
#> GSM110395     2   0.753      0.594 0.216 0.784
#> GSM110396     1   0.000      0.816 1.000 0.000
#> GSM110397     1   0.000      0.816 1.000 0.000
#> GSM110398     2   0.975      0.244 0.408 0.592
#> GSM110399     2   0.000      0.837 0.000 1.000
#> GSM110400     2   0.973      0.228 0.404 0.596
#> GSM110401     1   0.000      0.816 1.000 0.000
#> GSM110406     2   0.000      0.837 0.000 1.000
#> GSM110407     1   0.000      0.816 1.000 0.000
#> GSM110409     1   0.000      0.816 1.000 0.000
#> GSM110410     2   0.000      0.837 0.000 1.000
#> GSM110413     2   0.000      0.837 0.000 1.000
#> GSM110414     2   0.000      0.837 0.000 1.000
#> GSM110415     1   0.975      0.298 0.592 0.408
#> GSM110416     1   0.000      0.816 1.000 0.000
#> GSM110418     1   0.000      0.816 1.000 0.000
#> GSM110419     1   0.971      0.313 0.600 0.400
#> GSM110420     1   0.000      0.816 1.000 0.000
#> GSM110421     2   0.000      0.837 0.000 1.000
#> GSM110423     1   0.983      0.262 0.576 0.424
#> GSM110424     2   0.000      0.837 0.000 1.000
#> GSM110425     1   0.983      0.262 0.576 0.424
#> GSM110427     2   0.000      0.837 0.000 1.000
#> GSM110428     1   0.000      0.816 1.000 0.000
#> GSM110430     1   0.000      0.816 1.000 0.000
#> GSM110431     1   0.000      0.816 1.000 0.000
#> GSM110432     2   0.988      0.135 0.436 0.564
#> GSM110434     2   0.000      0.837 0.000 1.000
#> GSM110435     1   0.000      0.816 1.000 0.000
#> GSM110437     1   0.000      0.816 1.000 0.000
#> GSM110438     1   0.000      0.816 1.000 0.000
#> GSM110388     1   0.990      0.138 0.560 0.440
#> GSM110392     1   0.966      0.257 0.608 0.392
#> GSM110394     1   0.000      0.816 1.000 0.000
#> GSM110402     1   0.983      0.262 0.576 0.424
#> GSM110411     2   0.983      0.209 0.424 0.576
#> GSM110412     2   0.000      0.837 0.000 1.000
#> GSM110417     1   0.662      0.642 0.828 0.172
#> GSM110422     2   0.000      0.837 0.000 1.000
#> GSM110426     1   0.000      0.816 1.000 0.000
#> GSM110429     2   0.000      0.837 0.000 1.000
#> GSM110433     2   0.000      0.837 0.000 1.000
#> GSM110436     2   0.969      0.248 0.396 0.604
#> GSM110440     1   0.000      0.816 1.000 0.000
#> GSM110441     2   0.000      0.837 0.000 1.000
#> GSM110444     2   0.983      0.209 0.424 0.576
#> GSM110445     2   0.987      0.190 0.432 0.568
#> GSM110446     1   0.000      0.816 1.000 0.000
#> GSM110449     2   0.000      0.837 0.000 1.000
#> GSM110451     2   0.971      0.238 0.400 0.600
#> GSM110391     2   0.000      0.837 0.000 1.000
#> GSM110439     2   0.000      0.837 0.000 1.000
#> GSM110442     2   0.000      0.837 0.000 1.000
#> GSM110443     2   0.000      0.837 0.000 1.000
#> GSM110447     1   0.975      0.298 0.592 0.408
#> GSM110448     1   0.980      0.201 0.584 0.416
#> GSM110450     1   0.000      0.816 1.000 0.000
#> GSM110452     2   0.000      0.837 0.000 1.000
#> GSM110453     2   0.000      0.837 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
#> GSM110395     2  0.1337      0.889 0.016 0.972 0.012
#> GSM110396     3  0.5948     -0.465 0.360 0.000 0.640
#> GSM110397     3  0.5785     -0.396 0.332 0.000 0.668
#> GSM110398     2  0.6128      0.654 0.084 0.780 0.136
#> GSM110399     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110400     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110401     3  0.5785     -0.396 0.332 0.000 0.668
#> GSM110406     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110407     3  0.2165      0.148 0.064 0.000 0.936
#> GSM110409     3  0.7999     -0.313 0.148 0.196 0.656
#> GSM110410     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110413     2  0.4399      0.804 0.188 0.812 0.000
#> GSM110414     1  0.7533     -0.208 0.668 0.244 0.088
#> GSM110415     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110416     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110418     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110419     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110420     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110421     2  0.4504      0.798 0.196 0.804 0.000
#> GSM110423     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110424     2  0.4504      0.798 0.196 0.804 0.000
#> GSM110425     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110427     2  0.0592      0.898 0.012 0.988 0.000
#> GSM110428     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110430     3  0.5785     -0.396 0.332 0.000 0.668
#> GSM110431     3  0.0000      0.255 0.000 0.000 1.000
#> GSM110432     3  0.6804      0.570 0.460 0.012 0.528
#> GSM110434     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110435     3  0.0000      0.255 0.000 0.000 1.000
#> GSM110437     3  0.5785     -0.396 0.332 0.000 0.668
#> GSM110438     3  0.5621      0.507 0.308 0.000 0.692
#> GSM110388     1  0.6931      0.770 0.528 0.016 0.456
#> GSM110392     1  0.5553      0.507 0.724 0.004 0.272
#> GSM110394     3  0.0592      0.269 0.012 0.000 0.988
#> GSM110402     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110411     1  0.6931      0.770 0.528 0.016 0.456
#> GSM110412     2  0.6095      0.559 0.392 0.608 0.000
#> GSM110417     1  0.6295      0.758 0.528 0.000 0.472
#> GSM110422     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110426     1  0.6295      0.758 0.528 0.000 0.472
#> GSM110429     2  0.1289      0.887 0.032 0.968 0.000
#> GSM110433     2  0.4504      0.798 0.196 0.804 0.000
#> GSM110436     3  0.9147      0.474 0.412 0.144 0.444
#> GSM110440     3  0.4974     -0.226 0.236 0.000 0.764
#> GSM110441     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110444     1  0.7627      0.746 0.528 0.044 0.428
#> GSM110445     3  0.9497     -0.557 0.332 0.200 0.468
#> GSM110446     3  0.4555      0.434 0.200 0.000 0.800
#> GSM110449     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110451     3  0.7940      0.544 0.416 0.060 0.524
#> GSM110391     2  0.4504      0.798 0.196 0.804 0.000
#> GSM110439     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110442     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110443     2  0.4645      0.738 0.176 0.816 0.008
#> GSM110447     3  0.6295      0.575 0.472 0.000 0.528
#> GSM110448     1  0.6931      0.770 0.528 0.016 0.456
#> GSM110450     3  0.5785     -0.396 0.332 0.000 0.668
#> GSM110452     2  0.0000      0.904 0.000 1.000 0.000
#> GSM110453     2  0.0000      0.904 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.2216      0.832 0.000 0.908 0.092 0.000
#> GSM110396     1  0.0469      0.847 0.988 0.000 0.000 0.012
#> GSM110397     1  0.0817      0.845 0.976 0.000 0.000 0.024
#> GSM110398     2  0.4849      0.727 0.064 0.772 0.000 0.164
#> GSM110399     2  0.0921      0.876 0.000 0.972 0.000 0.028
#> GSM110400     3  0.0188      0.920 0.000 0.004 0.996 0.000
#> GSM110401     1  0.0469      0.847 0.988 0.000 0.000 0.012
#> GSM110406     2  0.1284      0.878 0.000 0.964 0.012 0.024
#> GSM110407     1  0.3219      0.806 0.836 0.000 0.164 0.000
#> GSM110409     1  0.2647      0.782 0.880 0.120 0.000 0.000
#> GSM110410     2  0.0817      0.878 0.000 0.976 0.000 0.024
#> GSM110413     2  0.4103      0.681 0.000 0.744 0.000 0.256
#> GSM110414     3  0.3893      0.704 0.000 0.008 0.796 0.196
#> GSM110415     3  0.0592      0.922 0.016 0.000 0.984 0.000
#> GSM110416     3  0.1452      0.913 0.036 0.000 0.956 0.008
#> GSM110418     3  0.1706      0.909 0.036 0.000 0.948 0.016
#> GSM110419     3  0.0376      0.922 0.004 0.000 0.992 0.004
#> GSM110420     3  0.2060      0.898 0.052 0.000 0.932 0.016
#> GSM110421     4  0.4830      0.212 0.000 0.392 0.000 0.608
#> GSM110423     3  0.0000      0.921 0.000 0.000 1.000 0.000
#> GSM110424     2  0.3356      0.756 0.000 0.824 0.000 0.176
#> GSM110425     3  0.0000      0.921 0.000 0.000 1.000 0.000
#> GSM110427     2  0.1389      0.864 0.000 0.952 0.048 0.000
#> GSM110428     3  0.3810      0.730 0.188 0.000 0.804 0.008
#> GSM110430     1  0.0469      0.847 0.988 0.000 0.000 0.012
#> GSM110431     1  0.4630      0.715 0.732 0.000 0.252 0.016
#> GSM110432     3  0.1557      0.894 0.000 0.056 0.944 0.000
#> GSM110434     2  0.0000      0.880 0.000 1.000 0.000 0.000
#> GSM110435     1  0.4364      0.751 0.764 0.000 0.220 0.016
#> GSM110437     1  0.0469      0.847 0.988 0.000 0.000 0.012
#> GSM110438     1  0.5298      0.524 0.612 0.000 0.372 0.016
#> GSM110388     4  0.0592      0.802 0.016 0.000 0.000 0.984
#> GSM110392     4  0.5533      0.677 0.140 0.032 0.064 0.764
#> GSM110394     1  0.4690      0.705 0.724 0.000 0.260 0.016
#> GSM110402     3  0.0817      0.920 0.024 0.000 0.976 0.000
#> GSM110411     4  0.0592      0.802 0.016 0.000 0.000 0.984
#> GSM110412     4  0.1004      0.792 0.000 0.024 0.004 0.972
#> GSM110417     4  0.3266      0.705 0.168 0.000 0.000 0.832
#> GSM110422     2  0.0000      0.880 0.000 1.000 0.000 0.000
#> GSM110426     4  0.4193      0.591 0.268 0.000 0.000 0.732
#> GSM110429     2  0.1867      0.846 0.000 0.928 0.072 0.000
#> GSM110433     2  0.4989      0.159 0.000 0.528 0.000 0.472
#> GSM110436     3  0.2973      0.822 0.000 0.144 0.856 0.000
#> GSM110440     1  0.0804      0.847 0.980 0.000 0.012 0.008
#> GSM110441     2  0.1792      0.863 0.000 0.932 0.000 0.068
#> GSM110444     4  0.0672      0.802 0.008 0.008 0.000 0.984
#> GSM110445     1  0.2179      0.809 0.924 0.064 0.000 0.012
#> GSM110446     1  0.3695      0.791 0.828 0.000 0.156 0.016
#> GSM110449     2  0.2704      0.818 0.000 0.876 0.000 0.124
#> GSM110451     3  0.2868      0.830 0.000 0.136 0.864 0.000
#> GSM110391     4  0.4898      0.135 0.000 0.416 0.000 0.584
#> GSM110439     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> GSM110442     2  0.0188      0.880 0.000 0.996 0.000 0.004
#> GSM110443     2  0.4773      0.596 0.280 0.708 0.008 0.004
#> GSM110447     3  0.0592      0.922 0.016 0.000 0.984 0.000
#> GSM110448     4  0.0921      0.798 0.028 0.000 0.000 0.972
#> GSM110450     1  0.1059      0.842 0.972 0.000 0.016 0.012
#> GSM110452     2  0.0000      0.880 0.000 1.000 0.000 0.000
#> GSM110453     2  0.0000      0.880 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     5  0.4060     0.2504 0.000 0.360 0.000 0.000 0.640
#> GSM110396     1  0.0162     0.8424 0.996 0.000 0.000 0.000 0.004
#> GSM110397     1  0.5508     0.3777 0.604 0.000 0.316 0.076 0.004
#> GSM110398     2  0.6207     0.6127 0.132 0.656 0.000 0.060 0.152
#> GSM110399     2  0.3462     0.7457 0.000 0.792 0.000 0.012 0.196
#> GSM110400     5  0.3452     0.5743 0.000 0.000 0.244 0.000 0.756
#> GSM110401     1  0.0000     0.8424 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.4876     0.5419 0.012 0.544 0.000 0.008 0.436
#> GSM110407     1  0.3169     0.7377 0.856 0.000 0.060 0.000 0.084
#> GSM110409     1  0.1970     0.8055 0.924 0.060 0.004 0.000 0.012
#> GSM110410     2  0.1597     0.7618 0.000 0.940 0.000 0.012 0.048
#> GSM110413     2  0.5956     0.5608 0.000 0.592 0.000 0.196 0.212
#> GSM110414     5  0.6037     0.4746 0.000 0.012 0.232 0.144 0.612
#> GSM110415     3  0.3561     0.3561 0.000 0.000 0.740 0.000 0.260
#> GSM110416     3  0.1121     0.5750 0.000 0.000 0.956 0.000 0.044
#> GSM110418     3  0.0000     0.5924 0.000 0.000 1.000 0.000 0.000
#> GSM110419     5  0.4561     0.2277 0.008 0.000 0.488 0.000 0.504
#> GSM110420     3  0.0000     0.5924 0.000 0.000 1.000 0.000 0.000
#> GSM110421     4  0.6343     0.0449 0.000 0.332 0.000 0.492 0.176
#> GSM110423     5  0.4291     0.3143 0.000 0.000 0.464 0.000 0.536
#> GSM110424     2  0.3593     0.7114 0.000 0.824 0.000 0.116 0.060
#> GSM110425     5  0.4219     0.3980 0.000 0.000 0.416 0.000 0.584
#> GSM110427     5  0.4182     0.2420 0.000 0.400 0.000 0.000 0.600
#> GSM110428     3  0.6645     0.2413 0.244 0.000 0.440 0.000 0.316
#> GSM110430     1  0.0000     0.8424 1.000 0.000 0.000 0.000 0.000
#> GSM110431     3  0.4559     0.0885 0.480 0.000 0.512 0.000 0.008
#> GSM110432     5  0.3760     0.6029 0.000 0.028 0.188 0.000 0.784
#> GSM110434     2  0.1270     0.7524 0.000 0.948 0.000 0.000 0.052
#> GSM110435     3  0.4264     0.2916 0.376 0.000 0.620 0.000 0.004
#> GSM110437     1  0.0162     0.8418 0.996 0.000 0.004 0.000 0.000
#> GSM110438     3  0.3010     0.5783 0.172 0.000 0.824 0.000 0.004
#> GSM110388     4  0.0451     0.7962 0.008 0.000 0.004 0.988 0.000
#> GSM110392     4  0.5745     0.6150 0.084 0.024 0.180 0.696 0.016
#> GSM110394     3  0.4979     0.0641 0.480 0.000 0.492 0.000 0.028
#> GSM110402     3  0.3424     0.3855 0.000 0.000 0.760 0.000 0.240
#> GSM110411     4  0.0000     0.7968 0.000 0.000 0.000 1.000 0.000
#> GSM110412     4  0.0000     0.7968 0.000 0.000 0.000 1.000 0.000
#> GSM110417     4  0.2017     0.7613 0.080 0.000 0.008 0.912 0.000
#> GSM110422     2  0.3305     0.5828 0.000 0.776 0.000 0.000 0.224
#> GSM110426     4  0.4320     0.6755 0.096 0.000 0.120 0.780 0.004
#> GSM110429     5  0.4341     0.3219 0.000 0.404 0.004 0.000 0.592
#> GSM110433     2  0.6383     0.3223 0.000 0.488 0.000 0.328 0.184
#> GSM110436     5  0.4226     0.6181 0.000 0.140 0.084 0.000 0.776
#> GSM110440     1  0.4251     0.2525 0.624 0.000 0.372 0.000 0.004
#> GSM110441     2  0.3513     0.7340 0.000 0.800 0.000 0.020 0.180
#> GSM110444     4  0.0000     0.7968 0.000 0.000 0.000 1.000 0.000
#> GSM110445     1  0.2707     0.7501 0.876 0.100 0.000 0.000 0.024
#> GSM110446     3  0.3333     0.5351 0.208 0.000 0.788 0.000 0.004
#> GSM110449     2  0.3454     0.7345 0.000 0.816 0.000 0.028 0.156
#> GSM110451     5  0.4247     0.6186 0.000 0.132 0.092 0.000 0.776
#> GSM110391     4  0.6445    -0.0658 0.000 0.360 0.000 0.456 0.184
#> GSM110439     2  0.0703     0.7618 0.000 0.976 0.000 0.000 0.024
#> GSM110442     2  0.0880     0.7638 0.000 0.968 0.000 0.000 0.032
#> GSM110443     2  0.5365     0.2760 0.416 0.528 0.000 0.000 0.056
#> GSM110447     3  0.3796     0.2841 0.000 0.000 0.700 0.000 0.300
#> GSM110448     4  0.0566     0.7955 0.012 0.000 0.004 0.984 0.000
#> GSM110450     1  0.0162     0.8424 0.996 0.000 0.000 0.000 0.004
#> GSM110452     2  0.0703     0.7618 0.000 0.976 0.000 0.000 0.024
#> GSM110453     2  0.1043     0.7590 0.000 0.960 0.000 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     6  0.5383     0.3213 0.000 0.184 0.000 0.000 0.232 0.584
#> GSM110396     1  0.1524     0.7367 0.932 0.000 0.000 0.008 0.060 0.000
#> GSM110397     1  0.6795     0.4053 0.500 0.000 0.236 0.156 0.108 0.000
#> GSM110398     2  0.5763     0.2396 0.072 0.552 0.000 0.008 0.336 0.032
#> GSM110399     2  0.4776     0.2692 0.004 0.588 0.000 0.000 0.356 0.052
#> GSM110400     6  0.3020     0.5170 0.000 0.000 0.076 0.000 0.080 0.844
#> GSM110401     1  0.0146     0.7396 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110406     5  0.6447     0.0565 0.024 0.240 0.000 0.000 0.436 0.300
#> GSM110407     1  0.3852     0.6659 0.804 0.000 0.048 0.000 0.040 0.108
#> GSM110409     1  0.3331     0.7045 0.852 0.064 0.028 0.000 0.048 0.008
#> GSM110410     2  0.3126     0.4489 0.000 0.752 0.000 0.000 0.248 0.000
#> GSM110413     5  0.5165     0.6184 0.000 0.204 0.000 0.144 0.644 0.008
#> GSM110414     6  0.6230     0.3313 0.000 0.000 0.100 0.076 0.284 0.540
#> GSM110415     3  0.5320     0.2964 0.000 0.000 0.532 0.000 0.116 0.352
#> GSM110416     3  0.1970     0.6459 0.000 0.000 0.912 0.000 0.028 0.060
#> GSM110418     3  0.0713     0.6592 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM110419     6  0.5195     0.0805 0.016 0.000 0.352 0.000 0.064 0.568
#> GSM110420     3  0.0632     0.6589 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM110421     5  0.5160     0.6584 0.000 0.108 0.000 0.320 0.572 0.000
#> GSM110423     6  0.5004     0.1375 0.000 0.000 0.348 0.000 0.084 0.568
#> GSM110424     2  0.4593     0.1707 0.000 0.604 0.000 0.040 0.352 0.004
#> GSM110425     6  0.4681     0.2949 0.004 0.000 0.256 0.000 0.076 0.664
#> GSM110427     6  0.4938     0.2836 0.000 0.356 0.000 0.000 0.076 0.568
#> GSM110428     3  0.6850     0.2048 0.252 0.000 0.364 0.000 0.048 0.336
#> GSM110430     1  0.0260     0.7396 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM110431     1  0.5309     0.1870 0.476 0.000 0.452 0.000 0.032 0.040
#> GSM110432     6  0.2326     0.5646 0.004 0.028 0.020 0.000 0.040 0.908
#> GSM110434     2  0.2201     0.6238 0.000 0.900 0.000 0.000 0.052 0.048
#> GSM110435     3  0.3629     0.2977 0.276 0.000 0.712 0.000 0.012 0.000
#> GSM110437     1  0.1138     0.7374 0.960 0.000 0.004 0.012 0.024 0.000
#> GSM110438     3  0.2958     0.6001 0.088 0.000 0.864 0.004 0.024 0.020
#> GSM110388     4  0.0291     0.8568 0.004 0.000 0.000 0.992 0.004 0.000
#> GSM110392     4  0.6004     0.6491 0.032 0.020 0.180 0.640 0.120 0.008
#> GSM110394     1  0.5479     0.2724 0.508 0.000 0.404 0.000 0.032 0.056
#> GSM110402     3  0.4481     0.4309 0.000 0.000 0.648 0.000 0.056 0.296
#> GSM110411     4  0.0632     0.8503 0.000 0.000 0.000 0.976 0.024 0.000
#> GSM110412     4  0.2006     0.7752 0.000 0.000 0.000 0.892 0.104 0.004
#> GSM110417     4  0.2742     0.8140 0.044 0.000 0.008 0.872 0.076 0.000
#> GSM110422     2  0.4033     0.4704 0.000 0.724 0.000 0.000 0.052 0.224
#> GSM110426     4  0.4244     0.7632 0.048 0.000 0.076 0.780 0.096 0.000
#> GSM110429     6  0.4783     0.1803 0.000 0.428 0.000 0.000 0.052 0.520
#> GSM110433     5  0.5283     0.6805 0.000 0.148 0.000 0.264 0.588 0.000
#> GSM110436     6  0.4000     0.5582 0.000 0.184 0.004 0.000 0.060 0.752
#> GSM110440     1  0.4847     0.5176 0.636 0.000 0.280 0.004 0.080 0.000
#> GSM110441     5  0.4256     0.2099 0.000 0.420 0.000 0.012 0.564 0.004
#> GSM110444     4  0.0790     0.8461 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM110445     1  0.5431     0.4898 0.688 0.184 0.016 0.008 0.072 0.032
#> GSM110446     3  0.2650     0.5991 0.072 0.000 0.880 0.004 0.040 0.004
#> GSM110449     2  0.4359     0.3198 0.000 0.652 0.000 0.008 0.312 0.028
#> GSM110451     6  0.2904     0.5791 0.000 0.112 0.008 0.000 0.028 0.852
#> GSM110391     5  0.5199     0.6759 0.000 0.120 0.000 0.300 0.580 0.000
#> GSM110439     2  0.0692     0.6450 0.000 0.976 0.000 0.000 0.020 0.004
#> GSM110442     2  0.1686     0.6326 0.000 0.924 0.000 0.000 0.064 0.012
#> GSM110443     2  0.6700     0.2628 0.324 0.480 0.020 0.000 0.132 0.044
#> GSM110447     3  0.5624     0.1780 0.000 0.000 0.456 0.000 0.148 0.396
#> GSM110448     4  0.0146     0.8568 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM110450     1  0.1644     0.7366 0.932 0.000 0.004 0.012 0.052 0.000
#> GSM110452     2  0.1003     0.6464 0.000 0.964 0.000 0.000 0.016 0.020
#> GSM110453     2  0.1320     0.6427 0.000 0.948 0.000 0.000 0.036 0.016

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> SD:skmeans 42          0.19593      0.1285 2
#> SD:skmeans 43          0.00283      0.3024 3
#> SD:skmeans 56          0.00530      0.2489 4
#> SD:skmeans 39          0.01905      0.4615 5
#> SD:skmeans 34          0.02061      0.0168 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 17209 rows and 59 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-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.311           0.521       0.816         0.4031 0.614   0.614
#> 3 3 0.619           0.625       0.847         0.4153 0.783   0.662
#> 4 4 0.708           0.787       0.892         0.2358 0.802   0.583
#> 5 5 0.786           0.781       0.910         0.1146 0.888   0.639
#> 6 6 0.784           0.785       0.887         0.0368 0.961   0.820

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
#> GSM110395     2  0.0000     0.7602 0.000 1.000
#> GSM110396     1  0.9983     0.4382 0.524 0.476
#> GSM110397     1  0.0000     0.5326 1.000 0.000
#> GSM110398     2  0.9044     0.0636 0.320 0.680
#> GSM110399     2  0.0000     0.7602 0.000 1.000
#> GSM110400     2  0.0000     0.7602 0.000 1.000
#> GSM110401     1  0.9983     0.4382 0.524 0.476
#> GSM110406     2  0.0000     0.7602 0.000 1.000
#> GSM110407     2  0.9977    -0.3804 0.472 0.528
#> GSM110409     2  0.9248    -0.0132 0.340 0.660
#> GSM110410     2  0.0000     0.7602 0.000 1.000
#> GSM110413     2  0.0000     0.7602 0.000 1.000
#> GSM110414     2  0.0000     0.7602 0.000 1.000
#> GSM110415     2  0.4562     0.6819 0.096 0.904
#> GSM110416     2  0.8081     0.4927 0.248 0.752
#> GSM110418     2  0.8081     0.4927 0.248 0.752
#> GSM110419     2  0.0000     0.7602 0.000 1.000
#> GSM110420     2  0.8081     0.4927 0.248 0.752
#> GSM110421     2  0.9775     0.1741 0.412 0.588
#> GSM110423     2  0.4562     0.6819 0.096 0.904
#> GSM110424     2  0.6438     0.5768 0.164 0.836
#> GSM110425     2  0.0000     0.7602 0.000 1.000
#> GSM110427     2  0.0000     0.7602 0.000 1.000
#> GSM110428     2  0.6148     0.5904 0.152 0.848
#> GSM110430     1  0.9983     0.4382 0.524 0.476
#> GSM110431     1  0.9775     0.4574 0.588 0.412
#> GSM110432     2  0.0000     0.7602 0.000 1.000
#> GSM110434     2  0.0000     0.7602 0.000 1.000
#> GSM110435     1  0.9970     0.3475 0.532 0.468
#> GSM110437     1  0.9754     0.4618 0.592 0.408
#> GSM110438     2  0.8081     0.4927 0.248 0.752
#> GSM110388     1  0.8081     0.4541 0.752 0.248
#> GSM110392     2  0.9522     0.3107 0.372 0.628
#> GSM110394     2  0.8861     0.2400 0.304 0.696
#> GSM110402     2  0.1414     0.7481 0.020 0.980
#> GSM110411     1  0.8081     0.4541 0.752 0.248
#> GSM110412     2  0.9998     0.0814 0.492 0.508
#> GSM110417     1  0.4022     0.5417 0.920 0.080
#> GSM110422     2  0.0000     0.7602 0.000 1.000
#> GSM110426     1  0.0000     0.5326 1.000 0.000
#> GSM110429     2  0.0000     0.7602 0.000 1.000
#> GSM110433     2  0.9775     0.1741 0.412 0.588
#> GSM110436     2  0.0000     0.7602 0.000 1.000
#> GSM110440     1  0.9775     0.4574 0.588 0.412
#> GSM110441     2  0.0000     0.7602 0.000 1.000
#> GSM110444     2  0.9775     0.1741 0.412 0.588
#> GSM110445     2  0.9286    -0.0255 0.344 0.656
#> GSM110446     2  0.8081     0.4927 0.248 0.752
#> GSM110449     1  0.9963     0.0851 0.536 0.464
#> GSM110451     2  0.0000     0.7602 0.000 1.000
#> GSM110391     2  0.9775     0.1741 0.412 0.588
#> GSM110439     2  0.0000     0.7602 0.000 1.000
#> GSM110442     2  0.0672     0.7547 0.008 0.992
#> GSM110443     2  0.0000     0.7602 0.000 1.000
#> GSM110447     2  0.1414     0.7481 0.020 0.980
#> GSM110448     1  0.4690     0.5278 0.900 0.100
#> GSM110450     1  0.9998     0.4089 0.508 0.492
#> GSM110452     2  0.0000     0.7602 0.000 1.000
#> GSM110453     2  0.0000     0.7602 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
#> GSM110395     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110396     1  0.6307     0.4932 0.512 0.488 0.000
#> GSM110397     1  0.0237     0.5282 0.996 0.000 0.004
#> GSM110398     2  0.6295    -0.4578 0.472 0.528 0.000
#> GSM110399     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110400     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110401     1  0.6260     0.5641 0.552 0.448 0.000
#> GSM110406     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110407     2  0.6286    -0.4387 0.464 0.536 0.000
#> GSM110409     1  0.6267     0.5593 0.548 0.452 0.000
#> GSM110410     2  0.0237     0.7705 0.004 0.996 0.000
#> GSM110413     2  0.0237     0.7705 0.004 0.996 0.000
#> GSM110414     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110415     2  0.7152     0.3191 0.444 0.532 0.024
#> GSM110416     2  0.7159     0.3146 0.448 0.528 0.024
#> GSM110418     2  0.7164     0.3093 0.452 0.524 0.024
#> GSM110419     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110420     2  0.7164     0.3093 0.452 0.524 0.024
#> GSM110421     3  0.1031     0.9172 0.000 0.024 0.976
#> GSM110423     2  0.6180     0.5220 0.260 0.716 0.024
#> GSM110424     2  0.0237     0.7705 0.004 0.996 0.000
#> GSM110425     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110427     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110428     2  0.0237     0.7695 0.004 0.996 0.000
#> GSM110430     1  0.6260     0.5641 0.552 0.448 0.000
#> GSM110431     1  0.1753     0.5404 0.952 0.048 0.000
#> GSM110432     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110434     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110435     1  0.5053     0.4471 0.812 0.164 0.024
#> GSM110437     1  0.0424     0.5356 0.992 0.008 0.000
#> GSM110438     2  0.7164     0.3093 0.452 0.524 0.024
#> GSM110388     3  0.1031     0.9104 0.024 0.000 0.976
#> GSM110392     2  0.7849     0.4550 0.248 0.648 0.104
#> GSM110394     2  0.5331     0.4568 0.184 0.792 0.024
#> GSM110402     2  0.6126     0.4407 0.352 0.644 0.004
#> GSM110411     3  0.1170     0.9142 0.016 0.008 0.976
#> GSM110412     3  0.1031     0.9172 0.000 0.024 0.976
#> GSM110417     3  0.1031     0.9104 0.024 0.000 0.976
#> GSM110422     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110426     3  0.1031     0.8901 0.024 0.000 0.976
#> GSM110429     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110433     3  0.1031     0.9172 0.000 0.024 0.976
#> GSM110436     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110440     1  0.0237     0.5324 0.996 0.004 0.000
#> GSM110441     2  0.0661     0.7638 0.004 0.988 0.008
#> GSM110444     3  0.1031     0.9172 0.000 0.024 0.976
#> GSM110445     1  0.6476     0.5567 0.548 0.448 0.004
#> GSM110446     2  0.7164     0.3093 0.452 0.524 0.024
#> GSM110449     3  0.6809     0.0429 0.012 0.464 0.524
#> GSM110451     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110391     3  0.1031     0.9172 0.000 0.024 0.976
#> GSM110439     2  0.0237     0.7705 0.004 0.996 0.000
#> GSM110442     2  0.0237     0.7705 0.004 0.996 0.000
#> GSM110443     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110447     2  0.5760     0.4697 0.328 0.672 0.000
#> GSM110448     3  0.1031     0.9104 0.024 0.000 0.976
#> GSM110450     1  0.6260     0.5641 0.552 0.448 0.000
#> GSM110452     2  0.0000     0.7723 0.000 1.000 0.000
#> GSM110453     2  0.0237     0.7705 0.004 0.996 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110396     1  0.4585      0.670 0.668 0.332 0.000 0.000
#> GSM110397     1  0.4989      0.159 0.528 0.000 0.472 0.000
#> GSM110398     1  0.4456      0.581 0.716 0.280 0.004 0.000
#> GSM110399     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110400     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110401     1  0.2973      0.763 0.856 0.144 0.000 0.000
#> GSM110406     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110407     1  0.4933      0.501 0.568 0.432 0.000 0.000
#> GSM110409     1  0.3801      0.749 0.780 0.220 0.000 0.000
#> GSM110410     2  0.3208      0.823 0.148 0.848 0.004 0.000
#> GSM110413     2  0.2773      0.841 0.116 0.880 0.004 0.000
#> GSM110414     2  0.1978      0.864 0.068 0.928 0.004 0.000
#> GSM110415     3  0.2125      0.859 0.004 0.076 0.920 0.000
#> GSM110416     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110418     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110419     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110420     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110421     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110423     3  0.2011      0.860 0.000 0.080 0.920 0.000
#> GSM110424     2  0.2958      0.839 0.116 0.876 0.004 0.004
#> GSM110425     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110427     2  0.0000      0.885 0.000 1.000 0.000 0.000
#> GSM110428     2  0.0469      0.881 0.012 0.988 0.000 0.000
#> GSM110430     1  0.3024      0.764 0.852 0.148 0.000 0.000
#> GSM110431     3  0.3764      0.716 0.172 0.012 0.816 0.000
#> GSM110432     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110434     2  0.0469      0.885 0.012 0.988 0.000 0.000
#> GSM110435     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110437     1  0.3074      0.657 0.848 0.000 0.152 0.000
#> GSM110438     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110388     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110392     3  0.4622      0.758 0.004 0.060 0.800 0.136
#> GSM110394     2  0.5028      0.276 0.004 0.596 0.400 0.000
#> GSM110402     2  0.4967      0.249 0.000 0.548 0.452 0.000
#> GSM110411     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110412     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110417     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110422     2  0.0469      0.885 0.012 0.988 0.000 0.000
#> GSM110426     4  0.4967      0.137 0.000 0.000 0.452 0.548
#> GSM110429     2  0.0469      0.885 0.012 0.988 0.000 0.000
#> GSM110433     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110436     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110440     1  0.4399      0.619 0.768 0.020 0.212 0.000
#> GSM110441     2  0.3216      0.834 0.124 0.864 0.004 0.008
#> GSM110444     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110445     1  0.0592      0.698 0.984 0.016 0.000 0.000
#> GSM110446     3  0.0188      0.923 0.000 0.004 0.996 0.000
#> GSM110449     4  0.5589      0.631 0.192 0.080 0.004 0.724
#> GSM110451     2  0.0188      0.885 0.004 0.996 0.000 0.000
#> GSM110391     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110439     2  0.3257      0.821 0.152 0.844 0.004 0.000
#> GSM110442     2  0.3257      0.821 0.152 0.844 0.004 0.000
#> GSM110443     2  0.0336      0.885 0.008 0.992 0.000 0.000
#> GSM110447     2  0.4855      0.378 0.000 0.600 0.400 0.000
#> GSM110448     4  0.0000      0.922 0.000 0.000 0.000 1.000
#> GSM110450     1  0.3024      0.764 0.852 0.148 0.000 0.000
#> GSM110452     2  0.1118      0.877 0.036 0.964 0.000 0.000
#> GSM110453     2  0.3208      0.823 0.148 0.848 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0703     0.8931 0.000 0.976 0.000 0.000 0.024
#> GSM110396     1  0.3508     0.6619 0.748 0.252 0.000 0.000 0.000
#> GSM110397     1  0.4300     0.1398 0.524 0.000 0.476 0.000 0.000
#> GSM110398     5  0.3019     0.7815 0.088 0.048 0.000 0.000 0.864
#> GSM110399     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110400     2  0.0404     0.8995 0.000 0.988 0.000 0.000 0.012
#> GSM110401     1  0.0000     0.8173 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.1121     0.8837 0.000 0.956 0.000 0.000 0.044
#> GSM110407     1  0.4060     0.4794 0.640 0.360 0.000 0.000 0.000
#> GSM110409     1  0.2424     0.7500 0.868 0.132 0.000 0.000 0.000
#> GSM110410     5  0.0880     0.8589 0.000 0.032 0.000 0.000 0.968
#> GSM110413     5  0.0404     0.8558 0.000 0.012 0.000 0.000 0.988
#> GSM110414     2  0.2377     0.8005 0.000 0.872 0.000 0.000 0.128
#> GSM110415     3  0.2329     0.8019 0.000 0.124 0.876 0.000 0.000
#> GSM110416     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110419     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110420     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110421     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110423     3  0.0290     0.9229 0.000 0.008 0.992 0.000 0.000
#> GSM110424     5  0.0955     0.8602 0.000 0.028 0.000 0.004 0.968
#> GSM110425     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110427     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110428     2  0.0162     0.9024 0.004 0.996 0.000 0.000 0.000
#> GSM110430     1  0.0000     0.8173 1.000 0.000 0.000 0.000 0.000
#> GSM110431     3  0.3343     0.7173 0.172 0.016 0.812 0.000 0.000
#> GSM110432     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110434     2  0.0162     0.9030 0.000 0.996 0.000 0.000 0.004
#> GSM110435     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110437     1  0.0000     0.8173 1.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110388     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110392     3  0.3318     0.7053 0.000 0.008 0.800 0.192 0.000
#> GSM110394     2  0.4182     0.3177 0.000 0.600 0.400 0.000 0.000
#> GSM110402     2  0.4542     0.2133 0.000 0.536 0.456 0.000 0.008
#> GSM110411     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110412     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110417     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110422     2  0.0162     0.9028 0.000 0.996 0.000 0.000 0.004
#> GSM110426     4  0.4278     0.1775 0.000 0.000 0.452 0.548 0.000
#> GSM110429     2  0.0162     0.9030 0.000 0.996 0.000 0.000 0.004
#> GSM110433     5  0.4300    -0.0429 0.000 0.000 0.000 0.476 0.524
#> GSM110436     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110440     1  0.2674     0.7370 0.856 0.004 0.140 0.000 0.000
#> GSM110441     5  0.0290     0.8552 0.000 0.008 0.000 0.000 0.992
#> GSM110444     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110445     1  0.0000     0.8173 1.000 0.000 0.000 0.000 0.000
#> GSM110446     3  0.0000     0.9282 0.000 0.000 1.000 0.000 0.000
#> GSM110449     5  0.0609     0.8495 0.000 0.000 0.000 0.020 0.980
#> GSM110451     2  0.0000     0.9036 0.000 1.000 0.000 0.000 0.000
#> GSM110391     4  0.3424     0.6412 0.000 0.000 0.000 0.760 0.240
#> GSM110439     5  0.0703     0.8599 0.000 0.024 0.000 0.000 0.976
#> GSM110442     5  0.3143     0.7186 0.000 0.204 0.000 0.000 0.796
#> GSM110443     2  0.2171     0.8474 0.064 0.912 0.000 0.000 0.024
#> GSM110447     2  0.4350     0.3374 0.000 0.588 0.408 0.000 0.004
#> GSM110448     4  0.0000     0.9026 0.000 0.000 0.000 1.000 0.000
#> GSM110450     1  0.0162     0.8170 0.996 0.004 0.000 0.000 0.000
#> GSM110452     2  0.0404     0.8997 0.000 0.988 0.000 0.000 0.012
#> GSM110453     5  0.3003     0.7408 0.000 0.188 0.000 0.000 0.812

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.0993      0.890 0.000 0.964 0.000 0.000 0.024 0.012
#> GSM110396     6  0.3862      0.783 0.132 0.096 0.000 0.000 0.000 0.772
#> GSM110397     1  0.3991      0.111 0.524 0.000 0.472 0.000 0.000 0.004
#> GSM110398     5  0.4640      0.715 0.088 0.020 0.000 0.000 0.720 0.172
#> GSM110399     2  0.0260      0.898 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM110400     2  0.0508      0.898 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM110401     1  0.0000      0.860 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.1367      0.883 0.000 0.944 0.000 0.000 0.044 0.012
#> GSM110407     6  0.3878      0.785 0.116 0.112 0.000 0.000 0.000 0.772
#> GSM110409     1  0.3396      0.696 0.812 0.116 0.000 0.000 0.000 0.072
#> GSM110410     5  0.0858      0.816 0.000 0.028 0.000 0.000 0.968 0.004
#> GSM110413     5  0.1492      0.809 0.000 0.036 0.000 0.000 0.940 0.024
#> GSM110414     2  0.2651      0.832 0.000 0.860 0.000 0.000 0.112 0.028
#> GSM110415     3  0.2527      0.797 0.000 0.108 0.868 0.000 0.000 0.024
#> GSM110416     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     2  0.0146      0.900 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110420     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     4  0.0458      0.891 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM110423     3  0.0622      0.918 0.000 0.008 0.980 0.000 0.000 0.012
#> GSM110424     5  0.1418      0.815 0.000 0.024 0.000 0.000 0.944 0.032
#> GSM110425     2  0.0146      0.900 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110427     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110428     2  0.0260      0.899 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM110430     1  0.0000      0.860 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     6  0.3348      0.743 0.000 0.016 0.216 0.000 0.000 0.768
#> GSM110432     2  0.0146      0.900 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110434     2  0.1863      0.859 0.000 0.896 0.000 0.000 0.000 0.104
#> GSM110435     6  0.3244      0.683 0.000 0.000 0.268 0.000 0.000 0.732
#> GSM110437     1  0.0000      0.860 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110388     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110392     3  0.3231      0.713 0.000 0.008 0.800 0.180 0.000 0.012
#> GSM110394     6  0.2996      0.711 0.000 0.228 0.000 0.000 0.000 0.772
#> GSM110402     2  0.4080      0.260 0.000 0.536 0.456 0.000 0.008 0.000
#> GSM110411     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110412     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110417     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110422     2  0.0291      0.899 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM110426     4  0.3843      0.183 0.000 0.000 0.452 0.548 0.000 0.000
#> GSM110429     2  0.1814      0.861 0.000 0.900 0.000 0.000 0.000 0.100
#> GSM110433     5  0.4250      0.047 0.000 0.000 0.000 0.456 0.528 0.016
#> GSM110436     2  0.0547      0.896 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM110440     6  0.3530      0.756 0.152 0.000 0.056 0.000 0.000 0.792
#> GSM110441     5  0.0622      0.812 0.000 0.008 0.000 0.000 0.980 0.012
#> GSM110444     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110445     1  0.0000      0.860 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110446     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110449     5  0.2199      0.796 0.000 0.000 0.000 0.020 0.892 0.088
#> GSM110451     2  0.0146      0.900 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110391     4  0.3534      0.612 0.000 0.000 0.000 0.740 0.244 0.016
#> GSM110439     5  0.2199      0.805 0.000 0.020 0.000 0.000 0.892 0.088
#> GSM110442     5  0.3043      0.679 0.000 0.200 0.000 0.000 0.792 0.008
#> GSM110443     2  0.2510      0.857 0.060 0.892 0.000 0.000 0.024 0.024
#> GSM110447     2  0.4417      0.407 0.000 0.588 0.384 0.000 0.004 0.024
#> GSM110448     4  0.0000      0.900 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110450     1  0.0146      0.857 0.996 0.004 0.000 0.000 0.000 0.000
#> GSM110452     2  0.3422      0.769 0.000 0.788 0.000 0.000 0.036 0.176
#> GSM110453     5  0.4269      0.677 0.000 0.184 0.000 0.000 0.724 0.092

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) specimen(p) k
#> SD:pam 32          0.50320       1.000 2
#> SD:pam 44          0.01500       0.827 3
#> SD:pam 54          0.00831       0.419 4
#> SD:pam 52          0.04739       0.305 5
#> SD:pam 54          0.11488       0.339 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 17209 rows and 59 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-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.251           0.648       0.801         0.4072 0.614   0.614
#> 3 3 0.473           0.590       0.817         0.5157 0.663   0.482
#> 4 4 0.469           0.503       0.778         0.1481 0.742   0.420
#> 5 5 0.720           0.697       0.856         0.0803 0.842   0.526
#> 6 6 0.705           0.559       0.785         0.0769 0.859   0.476

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
#> GSM110395     2  0.0672     0.7577 0.008 0.992
#> GSM110396     2  0.4298     0.7485 0.088 0.912
#> GSM110397     1  0.8386     0.8005 0.732 0.268
#> GSM110398     2  0.0672     0.7554 0.008 0.992
#> GSM110399     2  0.3733     0.7422 0.072 0.928
#> GSM110400     2  0.3274     0.7703 0.060 0.940
#> GSM110401     2  0.4298     0.7485 0.088 0.912
#> GSM110406     2  0.3584     0.7444 0.068 0.932
#> GSM110407     2  0.8386     0.7080 0.268 0.732
#> GSM110409     2  0.4298     0.7485 0.088 0.912
#> GSM110410     2  0.9552    -0.2487 0.376 0.624
#> GSM110413     2  0.3733     0.7415 0.072 0.928
#> GSM110414     1  0.9983     0.6320 0.524 0.476
#> GSM110415     1  0.9933     0.6013 0.548 0.452
#> GSM110416     2  0.9248     0.6431 0.340 0.660
#> GSM110418     1  0.9795    -0.0466 0.584 0.416
#> GSM110419     2  0.6973     0.7349 0.188 0.812
#> GSM110420     1  0.9686     0.0323 0.604 0.396
#> GSM110421     1  0.9087     0.7998 0.676 0.324
#> GSM110423     2  0.7674     0.7121 0.224 0.776
#> GSM110424     2  1.0000    -0.5921 0.496 0.504
#> GSM110425     2  0.6801     0.7355 0.180 0.820
#> GSM110427     2  0.0938     0.7557 0.012 0.988
#> GSM110428     2  0.8386     0.7080 0.268 0.732
#> GSM110430     2  0.4298     0.7485 0.088 0.912
#> GSM110431     2  0.8386     0.7080 0.268 0.732
#> GSM110432     2  0.6801     0.7355 0.180 0.820
#> GSM110434     2  0.3733     0.7422 0.072 0.928
#> GSM110435     2  0.8386     0.7080 0.268 0.732
#> GSM110437     2  0.4298     0.7485 0.088 0.912
#> GSM110438     2  0.8386     0.7080 0.268 0.732
#> GSM110388     1  0.8016     0.8086 0.756 0.244
#> GSM110392     2  0.9833    -0.4164 0.424 0.576
#> GSM110394     2  0.8386     0.7080 0.268 0.732
#> GSM110402     2  0.6801     0.7355 0.180 0.820
#> GSM110411     1  0.8144     0.8101 0.748 0.252
#> GSM110412     1  0.9170     0.8027 0.668 0.332
#> GSM110417     1  0.8016     0.8086 0.756 0.244
#> GSM110422     2  0.0672     0.7577 0.008 0.992
#> GSM110426     1  0.8144     0.8054 0.748 0.252
#> GSM110429     2  0.0672     0.7577 0.008 0.992
#> GSM110433     1  0.9087     0.7998 0.676 0.324
#> GSM110436     2  0.3431     0.7704 0.064 0.936
#> GSM110440     2  0.8267     0.7133 0.260 0.740
#> GSM110441     2  0.3733     0.7422 0.072 0.928
#> GSM110444     1  0.9170     0.8027 0.668 0.332
#> GSM110445     2  0.4431     0.7474 0.092 0.908
#> GSM110446     2  0.8207     0.7156 0.256 0.744
#> GSM110449     2  0.1184     0.7536 0.016 0.984
#> GSM110451     2  0.6247     0.7474 0.156 0.844
#> GSM110391     1  0.9087     0.7998 0.676 0.324
#> GSM110439     2  0.3733     0.7422 0.072 0.928
#> GSM110442     2  0.3733     0.7422 0.072 0.928
#> GSM110443     2  0.0000     0.7578 0.000 1.000
#> GSM110447     2  0.9977    -0.0240 0.472 0.528
#> GSM110448     1  0.8016     0.8086 0.756 0.244
#> GSM110450     2  0.7219     0.7400 0.200 0.800
#> GSM110452     2  0.3733     0.7422 0.072 0.928
#> GSM110453     2  0.3733     0.7422 0.072 0.928

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     2  0.7353    0.08481 0.032 0.532 0.436
#> GSM110396     2  0.6936    0.62308 0.064 0.704 0.232
#> GSM110397     1  0.6326    0.53327 0.688 0.020 0.292
#> GSM110398     2  0.2384    0.75576 0.056 0.936 0.008
#> GSM110399     2  0.0237    0.75838 0.000 0.996 0.004
#> GSM110400     3  0.0661    0.63723 0.004 0.008 0.988
#> GSM110401     2  0.6283    0.66994 0.064 0.760 0.176
#> GSM110406     2  0.0424    0.76022 0.000 0.992 0.008
#> GSM110407     2  0.6927    0.59310 0.060 0.700 0.240
#> GSM110409     2  0.6297    0.67026 0.060 0.756 0.184
#> GSM110410     3  0.7670    0.28768 0.068 0.312 0.620
#> GSM110413     2  0.3038    0.71566 0.000 0.896 0.104
#> GSM110414     1  0.6936    0.17928 0.524 0.016 0.460
#> GSM110415     3  0.4887    0.45898 0.228 0.000 0.772
#> GSM110416     3  0.0661    0.63682 0.008 0.004 0.988
#> GSM110418     3  0.0661    0.63682 0.008 0.004 0.988
#> GSM110419     3  0.6180    0.31453 0.000 0.416 0.584
#> GSM110420     3  0.0661    0.63682 0.008 0.004 0.988
#> GSM110421     1  0.1170    0.90922 0.976 0.016 0.008
#> GSM110423     3  0.0475    0.63728 0.004 0.004 0.992
#> GSM110424     3  0.8868    0.26951 0.172 0.260 0.568
#> GSM110425     3  0.0475    0.63728 0.004 0.004 0.992
#> GSM110427     2  0.7099    0.21637 0.028 0.588 0.384
#> GSM110428     3  0.6204    0.29205 0.000 0.424 0.576
#> GSM110430     2  0.6283    0.66994 0.064 0.760 0.176
#> GSM110431     3  0.6421    0.28718 0.004 0.424 0.572
#> GSM110432     3  0.6267    0.24787 0.000 0.452 0.548
#> GSM110434     2  0.0424    0.76022 0.000 0.992 0.008
#> GSM110435     3  0.6516    0.17207 0.004 0.480 0.516
#> GSM110437     2  0.6283    0.66994 0.064 0.760 0.176
#> GSM110438     3  0.6168    0.33304 0.000 0.412 0.588
#> GSM110388     1  0.0000    0.91396 1.000 0.000 0.000
#> GSM110392     3  0.5096    0.54024 0.080 0.084 0.836
#> GSM110394     3  0.6513    0.18260 0.004 0.476 0.520
#> GSM110402     3  0.0661    0.63729 0.004 0.008 0.988
#> GSM110411     1  0.0000    0.91396 1.000 0.000 0.000
#> GSM110412     1  0.0848    0.91175 0.984 0.008 0.008
#> GSM110417     1  0.0000    0.91396 1.000 0.000 0.000
#> GSM110422     2  0.6570    0.37845 0.028 0.680 0.292
#> GSM110426     1  0.0000    0.91396 1.000 0.000 0.000
#> GSM110429     2  0.6381    0.28037 0.012 0.648 0.340
#> GSM110433     1  0.1315    0.90681 0.972 0.020 0.008
#> GSM110436     3  0.5621    0.44879 0.000 0.308 0.692
#> GSM110440     3  0.7489   -0.00518 0.036 0.468 0.496
#> GSM110441     2  0.3038    0.71566 0.000 0.896 0.104
#> GSM110444     1  0.0237    0.91352 0.996 0.004 0.000
#> GSM110445     2  0.2902    0.75517 0.064 0.920 0.016
#> GSM110446     3  0.4121    0.57871 0.000 0.168 0.832
#> GSM110449     2  0.3896    0.74222 0.060 0.888 0.052
#> GSM110451     3  0.6225    0.28364 0.000 0.432 0.568
#> GSM110391     1  0.1170    0.90922 0.976 0.016 0.008
#> GSM110439     2  0.0424    0.75910 0.000 0.992 0.008
#> GSM110442     2  0.2448    0.73290 0.000 0.924 0.076
#> GSM110443     2  0.2703    0.75744 0.056 0.928 0.016
#> GSM110447     3  0.0892    0.62822 0.020 0.000 0.980
#> GSM110448     1  0.0000    0.91396 1.000 0.000 0.000
#> GSM110450     2  0.6976    0.62198 0.064 0.700 0.236
#> GSM110452     2  0.0424    0.75910 0.000 0.992 0.008
#> GSM110453     2  0.0747    0.76102 0.000 0.984 0.016

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.3610     0.4708 0.000 0.800 0.200 0.000
#> GSM110396     1  0.4963     0.4669 0.696 0.284 0.020 0.000
#> GSM110397     1  0.6997     0.2641 0.572 0.008 0.116 0.304
#> GSM110398     2  0.4454     0.4066 0.308 0.692 0.000 0.000
#> GSM110399     2  0.2973     0.5966 0.144 0.856 0.000 0.000
#> GSM110400     3  0.3486     0.6607 0.000 0.188 0.812 0.000
#> GSM110401     1  0.0000     0.7227 1.000 0.000 0.000 0.000
#> GSM110406     2  0.4819     0.3231 0.344 0.652 0.004 0.000
#> GSM110407     1  0.3852     0.6092 0.800 0.008 0.192 0.000
#> GSM110409     1  0.3610     0.6361 0.800 0.200 0.000 0.000
#> GSM110410     2  0.4382     0.3631 0.000 0.704 0.296 0.000
#> GSM110413     2  0.2149     0.6259 0.088 0.912 0.000 0.000
#> GSM110414     3  0.7498     0.0585 0.000 0.216 0.492 0.292
#> GSM110415     3  0.2675     0.6672 0.000 0.008 0.892 0.100
#> GSM110416     3  0.0000     0.7166 0.000 0.000 1.000 0.000
#> GSM110418     3  0.0000     0.7166 0.000 0.000 1.000 0.000
#> GSM110419     3  0.4843     0.4190 0.000 0.396 0.604 0.000
#> GSM110420     3  0.0000     0.7166 0.000 0.000 1.000 0.000
#> GSM110421     4  0.4804     0.5554 0.000 0.384 0.000 0.616
#> GSM110423     3  0.0000     0.7166 0.000 0.000 1.000 0.000
#> GSM110424     2  0.6446     0.2479 0.000 0.584 0.328 0.088
#> GSM110425     3  0.0000     0.7166 0.000 0.000 1.000 0.000
#> GSM110427     2  0.1022     0.6212 0.000 0.968 0.032 0.000
#> GSM110428     3  0.4843     0.4190 0.000 0.396 0.604 0.000
#> GSM110430     1  0.0000     0.7227 1.000 0.000 0.000 0.000
#> GSM110431     2  0.7684    -0.1844 0.216 0.396 0.388 0.000
#> GSM110432     2  0.5060     0.0511 0.004 0.584 0.412 0.000
#> GSM110434     2  0.2868     0.6050 0.136 0.864 0.000 0.000
#> GSM110435     2  0.7700    -0.1811 0.220 0.396 0.384 0.000
#> GSM110437     1  0.0000     0.7227 1.000 0.000 0.000 0.000
#> GSM110438     3  0.6600     0.3807 0.084 0.396 0.520 0.000
#> GSM110388     4  0.0000     0.7713 0.000 0.000 0.000 1.000
#> GSM110392     3  0.6574     0.5085 0.092 0.196 0.680 0.032
#> GSM110394     2  0.7684    -0.1839 0.216 0.396 0.388 0.000
#> GSM110402     3  0.4103     0.6054 0.000 0.256 0.744 0.000
#> GSM110411     4  0.0000     0.7713 0.000 0.000 0.000 1.000
#> GSM110412     4  0.3873     0.6812 0.000 0.228 0.000 0.772
#> GSM110417     4  0.0000     0.7713 0.000 0.000 0.000 1.000
#> GSM110422     2  0.0672     0.6233 0.008 0.984 0.008 0.000
#> GSM110426     4  0.1637     0.7269 0.060 0.000 0.000 0.940
#> GSM110429     2  0.2675     0.5814 0.008 0.892 0.100 0.000
#> GSM110433     4  0.5112     0.5489 0.000 0.384 0.008 0.608
#> GSM110436     2  0.4898     0.0655 0.000 0.584 0.416 0.000
#> GSM110440     2  0.7743    -0.1083 0.368 0.400 0.232 0.000
#> GSM110441     2  0.2011     0.6287 0.080 0.920 0.000 0.000
#> GSM110444     4  0.0000     0.7713 0.000 0.000 0.000 1.000
#> GSM110445     1  0.3311     0.6527 0.828 0.172 0.000 0.000
#> GSM110446     3  0.7349     0.3704 0.164 0.364 0.472 0.000
#> GSM110449     2  0.2469     0.6202 0.108 0.892 0.000 0.000
#> GSM110451     2  0.4843     0.1040 0.000 0.604 0.396 0.000
#> GSM110391     4  0.4804     0.5554 0.000 0.384 0.000 0.616
#> GSM110439     2  0.1716     0.6319 0.064 0.936 0.000 0.000
#> GSM110442     2  0.1716     0.6318 0.064 0.936 0.000 0.000
#> GSM110443     2  0.3486     0.5618 0.188 0.812 0.000 0.000
#> GSM110447     3  0.0469     0.7142 0.000 0.012 0.988 0.000
#> GSM110448     4  0.0000     0.7713 0.000 0.000 0.000 1.000
#> GSM110450     1  0.7212     0.2320 0.516 0.324 0.160 0.000
#> GSM110452     2  0.2149     0.6279 0.088 0.912 0.000 0.000
#> GSM110453     2  0.2408     0.6229 0.104 0.896 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
#> GSM110395     2  0.3916    0.62864 0.000 0.732 0.256 0.000 0.012
#> GSM110396     1  0.1357    0.79230 0.948 0.048 0.004 0.000 0.000
#> GSM110397     4  0.4929    0.55233 0.312 0.008 0.032 0.648 0.000
#> GSM110398     2  0.3305    0.68657 0.224 0.776 0.000 0.000 0.000
#> GSM110399     2  0.0451    0.87539 0.004 0.988 0.008 0.000 0.000
#> GSM110400     3  0.1444    0.69740 0.000 0.040 0.948 0.000 0.012
#> GSM110401     1  0.0000    0.79257 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0579    0.87455 0.008 0.984 0.008 0.000 0.000
#> GSM110407     1  0.4364    0.59380 0.736 0.048 0.216 0.000 0.000
#> GSM110409     1  0.3456    0.73252 0.800 0.184 0.016 0.000 0.000
#> GSM110410     5  0.5470    0.59993 0.000 0.272 0.080 0.008 0.640
#> GSM110413     2  0.2852    0.73828 0.000 0.828 0.000 0.000 0.172
#> GSM110414     5  0.2642    0.82092 0.000 0.008 0.104 0.008 0.880
#> GSM110415     3  0.1369    0.70435 0.000 0.008 0.956 0.008 0.028
#> GSM110416     3  0.0794    0.71000 0.000 0.000 0.972 0.000 0.028
#> GSM110418     3  0.0794    0.71000 0.000 0.000 0.972 0.000 0.028
#> GSM110419     3  0.4489    0.21127 0.008 0.420 0.572 0.000 0.000
#> GSM110420     3  0.0955    0.70938 0.000 0.000 0.968 0.004 0.028
#> GSM110421     5  0.1341    0.86974 0.000 0.000 0.000 0.056 0.944
#> GSM110423     3  0.0794    0.71000 0.000 0.000 0.972 0.000 0.028
#> GSM110424     5  0.2824    0.84479 0.000 0.024 0.088 0.008 0.880
#> GSM110425     3  0.0794    0.71000 0.000 0.000 0.972 0.000 0.028
#> GSM110427     2  0.2046    0.85324 0.000 0.916 0.068 0.000 0.016
#> GSM110428     3  0.5467    0.27744 0.384 0.068 0.548 0.000 0.000
#> GSM110430     1  0.0000    0.79257 1.000 0.000 0.000 0.000 0.000
#> GSM110431     3  0.5467    0.27744 0.384 0.068 0.548 0.000 0.000
#> GSM110432     2  0.4310    0.34953 0.000 0.604 0.392 0.000 0.004
#> GSM110434     2  0.0290    0.87560 0.000 0.992 0.008 0.000 0.000
#> GSM110435     3  0.5527    0.26149 0.388 0.072 0.540 0.000 0.000
#> GSM110437     1  0.0000    0.79257 1.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.5357    0.38738 0.344 0.068 0.588 0.000 0.000
#> GSM110388     4  0.0000    0.93657 0.000 0.000 0.000 1.000 0.000
#> GSM110392     3  0.5101    0.52812 0.172 0.072 0.732 0.004 0.020
#> GSM110394     3  0.5535    0.25090 0.392 0.072 0.536 0.000 0.000
#> GSM110402     3  0.1197    0.69413 0.000 0.048 0.952 0.000 0.000
#> GSM110411     4  0.0000    0.93657 0.000 0.000 0.000 1.000 0.000
#> GSM110412     5  0.2597    0.85836 0.000 0.000 0.024 0.092 0.884
#> GSM110417     4  0.0000    0.93657 0.000 0.000 0.000 1.000 0.000
#> GSM110422     2  0.1704    0.85620 0.000 0.928 0.068 0.000 0.004
#> GSM110426     4  0.0162    0.93396 0.004 0.000 0.000 0.996 0.000
#> GSM110429     2  0.1942    0.85444 0.000 0.920 0.068 0.000 0.012
#> GSM110433     5  0.1341    0.86974 0.000 0.000 0.000 0.056 0.944
#> GSM110436     3  0.4582    0.17312 0.000 0.416 0.572 0.000 0.012
#> GSM110440     1  0.5622    0.00767 0.508 0.076 0.416 0.000 0.000
#> GSM110441     2  0.0290    0.87042 0.000 0.992 0.000 0.000 0.008
#> GSM110444     4  0.0000    0.93657 0.000 0.000 0.000 1.000 0.000
#> GSM110445     1  0.2690    0.73013 0.844 0.156 0.000 0.000 0.000
#> GSM110446     3  0.4923    0.50073 0.252 0.068 0.680 0.000 0.000
#> GSM110449     2  0.1894    0.83151 0.072 0.920 0.000 0.000 0.008
#> GSM110451     2  0.4588    0.36423 0.000 0.604 0.380 0.000 0.016
#> GSM110391     5  0.1341    0.86974 0.000 0.000 0.000 0.056 0.944
#> GSM110439     2  0.0290    0.87560 0.000 0.992 0.008 0.000 0.000
#> GSM110442     2  0.0000    0.87211 0.000 1.000 0.000 0.000 0.000
#> GSM110443     2  0.1211    0.86990 0.024 0.960 0.016 0.000 0.000
#> GSM110447     3  0.1082    0.70608 0.000 0.008 0.964 0.000 0.028
#> GSM110448     4  0.0000    0.93657 0.000 0.000 0.000 1.000 0.000
#> GSM110450     1  0.3442    0.75230 0.836 0.104 0.060 0.000 0.000
#> GSM110452     2  0.0290    0.87560 0.000 0.992 0.008 0.000 0.000
#> GSM110453     2  0.0290    0.87560 0.000 0.992 0.008 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
#> GSM110395     2  0.1682     0.5656 0.000 0.928 0.020 0.000 0.000 0.052
#> GSM110396     1  0.3136     0.5474 0.768 0.004 0.000 0.000 0.000 0.228
#> GSM110397     4  0.3724     0.7254 0.188 0.000 0.028 0.772 0.000 0.012
#> GSM110398     6  0.3658     0.4512 0.216 0.032 0.000 0.000 0.000 0.752
#> GSM110399     6  0.3717     0.2696 0.000 0.384 0.000 0.000 0.000 0.616
#> GSM110400     3  0.3789     0.4570 0.000 0.416 0.584 0.000 0.000 0.000
#> GSM110401     1  0.2762     0.5600 0.804 0.000 0.000 0.000 0.000 0.196
#> GSM110406     2  0.4086    -0.1078 0.008 0.528 0.000 0.000 0.000 0.464
#> GSM110407     1  0.4244     0.5685 0.720 0.000 0.200 0.000 0.000 0.080
#> GSM110409     1  0.1806     0.5918 0.908 0.004 0.000 0.000 0.000 0.088
#> GSM110410     5  0.5144     0.3952 0.000 0.192 0.012 0.000 0.656 0.140
#> GSM110413     6  0.5279     0.4596 0.000 0.200 0.000 0.000 0.196 0.604
#> GSM110414     5  0.3955     0.3948 0.000 0.008 0.384 0.000 0.608 0.000
#> GSM110415     3  0.1124     0.8109 0.000 0.008 0.956 0.000 0.036 0.000
#> GSM110416     3  0.0000     0.8346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000     0.8346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     2  0.4887     0.2022 0.088 0.612 0.300 0.000 0.000 0.000
#> GSM110420     3  0.0000     0.8346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     5  0.0000     0.8431 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110423     3  0.0260     0.8352 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM110424     5  0.0508     0.8393 0.000 0.004 0.012 0.000 0.984 0.000
#> GSM110425     3  0.0260     0.8352 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM110427     2  0.0820     0.5723 0.000 0.972 0.012 0.000 0.000 0.016
#> GSM110428     1  0.5465     0.5093 0.572 0.208 0.220 0.000 0.000 0.000
#> GSM110430     1  0.2762     0.5600 0.804 0.000 0.000 0.000 0.000 0.196
#> GSM110431     1  0.5395     0.5178 0.584 0.196 0.220 0.000 0.000 0.000
#> GSM110432     2  0.1075     0.5606 0.000 0.952 0.048 0.000 0.000 0.000
#> GSM110434     2  0.3828     0.1669 0.000 0.560 0.000 0.000 0.000 0.440
#> GSM110435     1  0.5303     0.5306 0.600 0.196 0.204 0.000 0.000 0.000
#> GSM110437     1  0.2854     0.5569 0.792 0.000 0.000 0.000 0.000 0.208
#> GSM110438     1  0.5815     0.1128 0.472 0.200 0.328 0.000 0.000 0.000
#> GSM110388     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110392     3  0.6239     0.1469 0.368 0.016 0.420 0.000 0.196 0.000
#> GSM110394     1  0.5373     0.5214 0.588 0.196 0.216 0.000 0.000 0.000
#> GSM110402     3  0.3342     0.6057 0.012 0.228 0.760 0.000 0.000 0.000
#> GSM110411     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110412     5  0.1471     0.8112 0.000 0.000 0.004 0.064 0.932 0.000
#> GSM110417     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110422     2  0.1196     0.5676 0.000 0.952 0.008 0.000 0.000 0.040
#> GSM110426     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110429     2  0.0260     0.5704 0.000 0.992 0.008 0.000 0.000 0.000
#> GSM110433     5  0.0000     0.8431 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110436     2  0.2941     0.4038 0.000 0.780 0.220 0.000 0.000 0.000
#> GSM110440     1  0.4613     0.5653 0.688 0.196 0.116 0.000 0.000 0.000
#> GSM110441     6  0.2996     0.5347 0.000 0.228 0.000 0.000 0.000 0.772
#> GSM110444     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110445     1  0.3923     0.3709 0.620 0.008 0.000 0.000 0.000 0.372
#> GSM110446     1  0.5852     0.0123 0.440 0.196 0.364 0.000 0.000 0.000
#> GSM110449     6  0.1334     0.5938 0.020 0.032 0.000 0.000 0.000 0.948
#> GSM110451     2  0.0937     0.5623 0.000 0.960 0.040 0.000 0.000 0.000
#> GSM110391     5  0.0000     0.8431 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110439     2  0.3828     0.1669 0.000 0.560 0.000 0.000 0.000 0.440
#> GSM110442     2  0.3838     0.1435 0.000 0.552 0.000 0.000 0.000 0.448
#> GSM110443     6  0.4455     0.4862 0.080 0.232 0.000 0.000 0.000 0.688
#> GSM110447     3  0.0260     0.8352 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM110448     4  0.0000     0.9582 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110450     1  0.3023     0.4845 0.784 0.004 0.000 0.000 0.000 0.212
#> GSM110452     2  0.3828     0.1669 0.000 0.560 0.000 0.000 0.000 0.440
#> GSM110453     2  0.3828     0.1669 0.000 0.560 0.000 0.000 0.000 0.440

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> SD:mclust 53          0.17524       1.000 2
#> SD:mclust 41          0.08799       0.431 3
#> SD:mclust 39          0.00689       0.187 4
#> SD:mclust 49          0.14885       0.602 5
#> SD:mclust 39          0.03389       0.648 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 17209 rows and 59 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 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-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.367           0.710       0.819         0.4870 0.492   0.492
#> 3 3 0.427           0.619       0.770         0.3712 0.681   0.438
#> 4 4 0.608           0.735       0.830         0.1185 0.812   0.505
#> 5 5 0.658           0.639       0.805         0.0599 0.933   0.746
#> 6 6 0.655           0.482       0.716         0.0393 0.896   0.598

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
#> GSM110395     2  0.9710     0.8050 0.400 0.600
#> GSM110396     1  0.8081     0.7142 0.752 0.248
#> GSM110397     1  0.9710     0.6312 0.600 0.400
#> GSM110398     1  0.7219     0.7332 0.800 0.200
#> GSM110399     2  0.9732     0.8013 0.404 0.596
#> GSM110400     2  0.9710     0.8050 0.400 0.600
#> GSM110401     1  0.6973     0.7370 0.812 0.188
#> GSM110406     2  0.9710     0.8050 0.400 0.600
#> GSM110407     1  0.0000     0.7498 1.000 0.000
#> GSM110409     1  0.0000     0.7498 1.000 0.000
#> GSM110410     2  0.6887     0.7084 0.184 0.816
#> GSM110413     2  0.0000     0.5857 0.000 1.000
#> GSM110414     2  0.7299     0.7194 0.204 0.796
#> GSM110415     2  0.9427     0.7745 0.360 0.640
#> GSM110416     1  0.0938     0.7373 0.988 0.012
#> GSM110418     1  0.0000     0.7498 1.000 0.000
#> GSM110419     1  0.3274     0.6732 0.940 0.060
#> GSM110420     1  0.0000     0.7498 1.000 0.000
#> GSM110421     2  0.0000     0.5857 0.000 1.000
#> GSM110423     2  0.9710     0.8050 0.400 0.600
#> GSM110424     2  0.3733     0.6374 0.072 0.928
#> GSM110425     2  0.9710     0.8050 0.400 0.600
#> GSM110427     2  0.9710     0.8050 0.400 0.600
#> GSM110428     1  0.0000     0.7498 1.000 0.000
#> GSM110430     1  0.5059     0.7508 0.888 0.112
#> GSM110431     1  0.0000     0.7498 1.000 0.000
#> GSM110432     2  0.9732     0.8013 0.404 0.596
#> GSM110434     2  0.9710     0.8050 0.400 0.600
#> GSM110435     1  0.0000     0.7498 1.000 0.000
#> GSM110437     1  0.5737     0.7480 0.864 0.136
#> GSM110438     1  0.0000     0.7498 1.000 0.000
#> GSM110388     1  0.9710     0.6312 0.600 0.400
#> GSM110392     1  0.9491     0.6405 0.632 0.368
#> GSM110394     1  0.0000     0.7498 1.000 0.000
#> GSM110402     2  0.9732     0.8013 0.404 0.596
#> GSM110411     1  0.9710     0.6312 0.600 0.400
#> GSM110412     2  0.0000     0.5857 0.000 1.000
#> GSM110417     1  0.9710     0.6312 0.600 0.400
#> GSM110422     2  0.9710     0.8050 0.400 0.600
#> GSM110426     1  0.9710     0.6312 0.600 0.400
#> GSM110429     2  0.9710     0.8050 0.400 0.600
#> GSM110433     2  0.0000     0.5857 0.000 1.000
#> GSM110436     2  0.9710     0.8050 0.400 0.600
#> GSM110440     1  0.0938     0.7521 0.988 0.012
#> GSM110441     2  0.0000     0.5857 0.000 1.000
#> GSM110444     1  0.9977     0.5705 0.528 0.472
#> GSM110445     1  0.7139     0.7348 0.804 0.196
#> GSM110446     1  0.0000     0.7498 1.000 0.000
#> GSM110449     2  0.2423     0.5402 0.040 0.960
#> GSM110451     2  0.9710     0.8050 0.400 0.600
#> GSM110391     2  0.0000     0.5857 0.000 1.000
#> GSM110439     2  0.9710     0.8050 0.400 0.600
#> GSM110442     2  0.8144     0.7464 0.252 0.748
#> GSM110443     1  0.8813    -0.0561 0.700 0.300
#> GSM110447     2  0.9427     0.7915 0.360 0.640
#> GSM110448     1  0.9710     0.6312 0.600 0.400
#> GSM110450     1  0.0672     0.7516 0.992 0.008
#> GSM110452     2  0.9710     0.8050 0.400 0.600
#> GSM110453     2  0.9710     0.8050 0.400 0.600

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     2  0.6724      0.499 0.012 0.568 0.420
#> GSM110396     1  0.0661      0.717 0.988 0.004 0.008
#> GSM110397     1  0.4291      0.709 0.840 0.152 0.008
#> GSM110398     1  0.0424      0.715 0.992 0.008 0.000
#> GSM110399     2  0.7785      0.434 0.420 0.528 0.052
#> GSM110400     3  0.5216      0.456 0.000 0.260 0.740
#> GSM110401     1  0.1411      0.711 0.964 0.000 0.036
#> GSM110406     2  0.8760      0.548 0.176 0.584 0.240
#> GSM110407     1  0.6215      0.184 0.572 0.000 0.428
#> GSM110409     1  0.4654      0.553 0.792 0.000 0.208
#> GSM110410     2  0.5111      0.712 0.036 0.820 0.144
#> GSM110413     2  0.2165      0.685 0.000 0.936 0.064
#> GSM110414     2  0.6215      0.460 0.000 0.572 0.428
#> GSM110415     3  0.1753      0.757 0.000 0.048 0.952
#> GSM110416     3  0.0475      0.781 0.004 0.004 0.992
#> GSM110418     3  0.0475      0.781 0.004 0.004 0.992
#> GSM110419     3  0.1860      0.774 0.052 0.000 0.948
#> GSM110420     3  0.1031      0.781 0.024 0.000 0.976
#> GSM110421     2  0.1163      0.634 0.028 0.972 0.000
#> GSM110423     3  0.1163      0.770 0.000 0.028 0.972
#> GSM110424     2  0.2537      0.700 0.000 0.920 0.080
#> GSM110425     3  0.0747      0.776 0.000 0.016 0.984
#> GSM110427     2  0.6111      0.518 0.000 0.604 0.396
#> GSM110428     3  0.2066      0.770 0.060 0.000 0.940
#> GSM110430     1  0.1529      0.708 0.960 0.000 0.040
#> GSM110431     3  0.5327      0.569 0.272 0.000 0.728
#> GSM110432     3  0.1031      0.781 0.024 0.000 0.976
#> GSM110434     2  0.9588      0.518 0.240 0.476 0.284
#> GSM110435     3  0.5810      0.544 0.336 0.000 0.664
#> GSM110437     1  0.1529      0.708 0.960 0.000 0.040
#> GSM110438     3  0.5859      0.533 0.344 0.000 0.656
#> GSM110388     1  0.5926      0.639 0.644 0.356 0.000
#> GSM110392     3  0.8918      0.306 0.160 0.288 0.552
#> GSM110394     3  0.4235      0.692 0.176 0.000 0.824
#> GSM110402     3  0.0000      0.780 0.000 0.000 1.000
#> GSM110411     1  0.5968      0.633 0.636 0.364 0.000
#> GSM110412     2  0.0661      0.653 0.008 0.988 0.004
#> GSM110417     1  0.5905      0.642 0.648 0.352 0.000
#> GSM110422     2  0.8907      0.623 0.168 0.560 0.272
#> GSM110426     1  0.6104      0.645 0.648 0.348 0.004
#> GSM110429     3  0.7622      0.144 0.060 0.332 0.608
#> GSM110433     2  0.0000      0.656 0.000 1.000 0.000
#> GSM110436     3  0.5859      0.219 0.000 0.344 0.656
#> GSM110440     1  0.5621      0.497 0.692 0.000 0.308
#> GSM110441     2  0.2063      0.674 0.044 0.948 0.008
#> GSM110444     1  0.6008      0.626 0.628 0.372 0.000
#> GSM110445     1  0.0424      0.715 0.992 0.000 0.008
#> GSM110446     3  0.5968      0.501 0.364 0.000 0.636
#> GSM110449     1  0.5397      0.598 0.720 0.280 0.000
#> GSM110451     3  0.3038      0.702 0.000 0.104 0.896
#> GSM110391     2  0.1129      0.644 0.020 0.976 0.004
#> GSM110439     2  0.8600      0.674 0.212 0.604 0.184
#> GSM110442     2  0.7944      0.697 0.196 0.660 0.144
#> GSM110443     1  0.7485      0.419 0.696 0.172 0.132
#> GSM110447     3  0.1289      0.768 0.000 0.032 0.968
#> GSM110448     1  0.5926      0.639 0.644 0.356 0.000
#> GSM110450     1  0.5098      0.575 0.752 0.000 0.248
#> GSM110452     2  0.8647      0.673 0.208 0.600 0.192
#> GSM110453     2  0.8148      0.691 0.200 0.644 0.156

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.5798     0.6291 0.112 0.704 0.184 0.000
#> GSM110396     1  0.2002     0.8300 0.936 0.020 0.000 0.044
#> GSM110397     4  0.5138     0.4050 0.392 0.008 0.000 0.600
#> GSM110398     1  0.2480     0.8136 0.904 0.088 0.000 0.008
#> GSM110399     1  0.4605     0.5876 0.664 0.336 0.000 0.000
#> GSM110400     3  0.2441     0.8349 0.004 0.020 0.920 0.056
#> GSM110401     1  0.1443     0.8533 0.960 0.008 0.028 0.004
#> GSM110406     1  0.5593     0.7070 0.708 0.212 0.080 0.000
#> GSM110407     1  0.3450     0.7977 0.836 0.008 0.156 0.000
#> GSM110409     1  0.1975     0.8581 0.936 0.048 0.016 0.000
#> GSM110410     2  0.0927     0.7900 0.016 0.976 0.000 0.008
#> GSM110413     2  0.6245     0.5028 0.012 0.632 0.056 0.300
#> GSM110414     3  0.7019     0.4046 0.004 0.184 0.596 0.216
#> GSM110415     3  0.2452     0.8168 0.004 0.004 0.908 0.084
#> GSM110416     3  0.0564     0.8623 0.004 0.004 0.988 0.004
#> GSM110418     3  0.0564     0.8623 0.004 0.004 0.988 0.004
#> GSM110419     3  0.2216     0.8514 0.092 0.000 0.908 0.000
#> GSM110420     3  0.1576     0.8629 0.048 0.000 0.948 0.004
#> GSM110421     4  0.3751     0.6311 0.004 0.196 0.000 0.800
#> GSM110423     3  0.0188     0.8618 0.000 0.004 0.996 0.000
#> GSM110424     2  0.4568     0.6648 0.004 0.772 0.024 0.200
#> GSM110425     3  0.0336     0.8638 0.008 0.000 0.992 0.000
#> GSM110427     2  0.4175     0.6995 0.008 0.792 0.192 0.008
#> GSM110428     3  0.2266     0.8545 0.084 0.004 0.912 0.000
#> GSM110430     1  0.1082     0.8539 0.972 0.004 0.020 0.004
#> GSM110431     3  0.2868     0.8306 0.136 0.000 0.864 0.000
#> GSM110432     3  0.4477     0.8114 0.108 0.084 0.808 0.000
#> GSM110434     2  0.3577     0.7017 0.156 0.832 0.012 0.000
#> GSM110435     3  0.3157     0.8291 0.144 0.004 0.852 0.000
#> GSM110437     1  0.1114     0.8523 0.972 0.008 0.016 0.004
#> GSM110438     3  0.3172     0.8201 0.160 0.000 0.840 0.000
#> GSM110388     4  0.2345     0.8072 0.100 0.000 0.000 0.900
#> GSM110392     4  0.7863     0.0998 0.040 0.104 0.412 0.444
#> GSM110394     3  0.4331     0.6382 0.288 0.000 0.712 0.000
#> GSM110402     3  0.1109     0.8646 0.028 0.004 0.968 0.000
#> GSM110411     4  0.0592     0.8114 0.016 0.000 0.000 0.984
#> GSM110412     4  0.0992     0.7989 0.004 0.008 0.012 0.976
#> GSM110417     4  0.2345     0.8064 0.100 0.000 0.000 0.900
#> GSM110422     2  0.2342     0.7730 0.008 0.912 0.080 0.000
#> GSM110426     4  0.2949     0.8061 0.088 0.000 0.024 0.888
#> GSM110429     2  0.4485     0.5792 0.012 0.740 0.248 0.000
#> GSM110433     2  0.5666     0.1974 0.004 0.520 0.016 0.460
#> GSM110436     3  0.5112     0.4451 0.008 0.340 0.648 0.004
#> GSM110440     1  0.4980     0.7337 0.756 0.004 0.196 0.044
#> GSM110441     2  0.1488     0.7853 0.012 0.956 0.000 0.032
#> GSM110444     4  0.0524     0.8082 0.008 0.004 0.000 0.988
#> GSM110445     1  0.1807     0.8481 0.940 0.052 0.000 0.008
#> GSM110446     3  0.3972     0.7776 0.204 0.008 0.788 0.000
#> GSM110449     2  0.6887     0.3501 0.308 0.560 0.000 0.132
#> GSM110451     3  0.4057     0.7578 0.028 0.160 0.812 0.000
#> GSM110391     4  0.3289     0.7036 0.004 0.140 0.004 0.852
#> GSM110439     2  0.1211     0.7895 0.040 0.960 0.000 0.000
#> GSM110442     2  0.0592     0.7908 0.016 0.984 0.000 0.000
#> GSM110443     1  0.3881     0.7911 0.812 0.172 0.016 0.000
#> GSM110447     3  0.1575     0.8484 0.004 0.012 0.956 0.028
#> GSM110448     4  0.1792     0.8144 0.068 0.000 0.000 0.932
#> GSM110450     1  0.3350     0.8231 0.864 0.016 0.116 0.004
#> GSM110452     2  0.1302     0.7888 0.044 0.956 0.000 0.000
#> GSM110453     2  0.0469     0.7905 0.012 0.988 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
#> GSM110395     5  0.7348    0.11776 0.316 0.224 0.036 0.000 0.424
#> GSM110396     1  0.3152    0.73561 0.840 0.000 0.000 0.024 0.136
#> GSM110397     4  0.3485    0.60744 0.124 0.000 0.000 0.828 0.048
#> GSM110398     1  0.5519    0.63134 0.712 0.128 0.000 0.120 0.040
#> GSM110399     1  0.4078    0.70660 0.784 0.148 0.000 0.000 0.068
#> GSM110400     3  0.4585    0.39263 0.020 0.000 0.628 0.000 0.352
#> GSM110401     1  0.2124    0.74341 0.900 0.000 0.004 0.000 0.096
#> GSM110406     1  0.3975    0.67998 0.744 0.008 0.008 0.000 0.240
#> GSM110407     1  0.3803    0.71685 0.804 0.000 0.056 0.000 0.140
#> GSM110409     1  0.2769    0.74197 0.888 0.076 0.004 0.004 0.028
#> GSM110410     2  0.0955    0.81522 0.000 0.968 0.000 0.004 0.028
#> GSM110413     5  0.2270    0.50452 0.076 0.000 0.000 0.020 0.904
#> GSM110414     5  0.5247    0.24124 0.000 0.012 0.400 0.028 0.560
#> GSM110415     3  0.0693    0.85244 0.000 0.000 0.980 0.012 0.008
#> GSM110416     3  0.0000    0.85799 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000    0.85799 0.000 0.000 1.000 0.000 0.000
#> GSM110419     3  0.1444    0.85059 0.040 0.000 0.948 0.000 0.012
#> GSM110420     3  0.0162    0.85814 0.000 0.000 0.996 0.004 0.000
#> GSM110421     5  0.5104    0.52442 0.000 0.116 0.000 0.192 0.692
#> GSM110423     3  0.0162    0.85797 0.000 0.004 0.996 0.000 0.000
#> GSM110424     2  0.5106    0.61677 0.000 0.736 0.024 0.136 0.104
#> GSM110425     3  0.0404    0.85804 0.012 0.000 0.988 0.000 0.000
#> GSM110427     2  0.5462    0.59502 0.024 0.704 0.140 0.000 0.132
#> GSM110428     3  0.3319    0.77106 0.160 0.000 0.820 0.000 0.020
#> GSM110430     1  0.1012    0.74755 0.968 0.000 0.000 0.020 0.012
#> GSM110431     3  0.3081    0.78344 0.156 0.000 0.832 0.000 0.012
#> GSM110432     3  0.4652    0.69605 0.188 0.012 0.744 0.000 0.056
#> GSM110434     2  0.2389    0.75265 0.116 0.880 0.000 0.000 0.004
#> GSM110435     3  0.1082    0.85656 0.028 0.000 0.964 0.000 0.008
#> GSM110437     1  0.4415    0.67932 0.776 0.020 0.000 0.156 0.048
#> GSM110438     3  0.3150    0.80812 0.096 0.000 0.864 0.024 0.016
#> GSM110388     4  0.0451    0.72880 0.004 0.000 0.000 0.988 0.008
#> GSM110392     4  0.5008    0.48902 0.016 0.248 0.020 0.700 0.016
#> GSM110394     1  0.4549    0.07105 0.528 0.000 0.464 0.000 0.008
#> GSM110402     3  0.0290    0.85831 0.000 0.000 0.992 0.000 0.008
#> GSM110411     4  0.3424    0.58967 0.000 0.000 0.000 0.760 0.240
#> GSM110412     4  0.4449    0.13215 0.000 0.000 0.004 0.512 0.484
#> GSM110417     4  0.1469    0.73055 0.016 0.000 0.000 0.948 0.036
#> GSM110422     2  0.1492    0.81178 0.008 0.948 0.040 0.000 0.004
#> GSM110426     4  0.0960    0.72974 0.008 0.000 0.004 0.972 0.016
#> GSM110429     2  0.2623    0.76354 0.004 0.884 0.096 0.000 0.016
#> GSM110433     5  0.5115    0.53426 0.000 0.136 0.000 0.168 0.696
#> GSM110436     3  0.5594   -0.00378 0.004 0.444 0.492 0.000 0.060
#> GSM110440     1  0.5267    0.64599 0.716 0.000 0.108 0.156 0.020
#> GSM110441     2  0.4452   -0.08843 0.004 0.500 0.000 0.000 0.496
#> GSM110444     4  0.4268    0.25541 0.000 0.000 0.000 0.556 0.444
#> GSM110445     1  0.3738    0.72215 0.844 0.052 0.000 0.064 0.040
#> GSM110446     3  0.4775    0.74303 0.100 0.024 0.788 0.068 0.020
#> GSM110449     2  0.4665    0.65466 0.056 0.756 0.000 0.168 0.020
#> GSM110451     3  0.3344    0.79037 0.028 0.104 0.852 0.000 0.016
#> GSM110391     5  0.4028    0.50284 0.000 0.040 0.000 0.192 0.768
#> GSM110439     2  0.0510    0.81912 0.016 0.984 0.000 0.000 0.000
#> GSM110442     2  0.0404    0.81938 0.000 0.988 0.000 0.000 0.012
#> GSM110443     1  0.6252   -0.02026 0.444 0.436 0.000 0.008 0.112
#> GSM110447     3  0.1569    0.84148 0.000 0.008 0.948 0.012 0.032
#> GSM110448     4  0.1197    0.72475 0.000 0.000 0.000 0.952 0.048
#> GSM110450     1  0.2681    0.73762 0.876 0.000 0.012 0.004 0.108
#> GSM110452     2  0.0609    0.81836 0.020 0.980 0.000 0.000 0.000
#> GSM110453     2  0.0671    0.81932 0.004 0.980 0.000 0.000 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
#> GSM110395     1  0.8079    -0.2306 0.348 0.144 0.036 0.000 0.236 0.236
#> GSM110396     1  0.2974     0.6416 0.872 0.004 0.000 0.052 0.028 0.044
#> GSM110397     4  0.1913     0.6560 0.012 0.000 0.000 0.908 0.000 0.080
#> GSM110398     2  0.7500     0.0415 0.252 0.388 0.000 0.100 0.012 0.248
#> GSM110399     1  0.5326     0.1700 0.500 0.404 0.000 0.000 0.004 0.092
#> GSM110400     3  0.3598     0.6536 0.004 0.000 0.804 0.000 0.112 0.080
#> GSM110401     1  0.0405     0.6453 0.988 0.000 0.000 0.008 0.000 0.004
#> GSM110406     1  0.3307     0.6089 0.808 0.000 0.000 0.000 0.044 0.148
#> GSM110407     1  0.1926     0.6394 0.912 0.000 0.020 0.000 0.000 0.068
#> GSM110409     1  0.6077     0.5208 0.608 0.144 0.016 0.020 0.008 0.204
#> GSM110410     2  0.3220     0.5217 0.000 0.840 0.004 0.004 0.056 0.096
#> GSM110413     5  0.4313     0.4124 0.116 0.016 0.000 0.000 0.756 0.112
#> GSM110414     3  0.6126    -0.0817 0.000 0.008 0.456 0.004 0.348 0.184
#> GSM110415     3  0.1065     0.7353 0.000 0.000 0.964 0.008 0.008 0.020
#> GSM110416     3  0.0260     0.7377 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM110418     3  0.0777     0.7373 0.000 0.000 0.972 0.004 0.000 0.024
#> GSM110419     3  0.1644     0.7344 0.040 0.000 0.932 0.000 0.000 0.028
#> GSM110420     3  0.1088     0.7368 0.000 0.000 0.960 0.016 0.000 0.024
#> GSM110421     5  0.2604     0.6355 0.000 0.024 0.000 0.056 0.888 0.032
#> GSM110423     3  0.0858     0.7349 0.000 0.004 0.968 0.000 0.000 0.028
#> GSM110424     6  0.7262     0.3610 0.000 0.344 0.008 0.096 0.172 0.380
#> GSM110425     3  0.1668     0.7241 0.004 0.000 0.928 0.000 0.008 0.060
#> GSM110427     2  0.7999    -0.6540 0.024 0.352 0.188 0.000 0.196 0.240
#> GSM110428     1  0.6298     0.1384 0.428 0.000 0.328 0.004 0.008 0.232
#> GSM110430     1  0.2499     0.6427 0.880 0.000 0.000 0.072 0.000 0.048
#> GSM110431     3  0.4292     0.4566 0.340 0.000 0.628 0.000 0.000 0.032
#> GSM110432     3  0.6856     0.2792 0.296 0.020 0.468 0.000 0.040 0.176
#> GSM110434     2  0.2222     0.6224 0.012 0.896 0.008 0.000 0.000 0.084
#> GSM110435     3  0.3255     0.6892 0.036 0.004 0.828 0.004 0.000 0.128
#> GSM110437     1  0.5862     0.4576 0.508 0.004 0.000 0.276 0.000 0.212
#> GSM110438     3  0.5333     0.6029 0.056 0.028 0.704 0.052 0.000 0.160
#> GSM110388     4  0.3936     0.5344 0.000 0.000 0.004 0.700 0.276 0.020
#> GSM110392     4  0.4875     0.5024 0.004 0.224 0.004 0.684 0.008 0.076
#> GSM110394     3  0.4254     0.3547 0.404 0.000 0.576 0.000 0.000 0.020
#> GSM110402     3  0.0551     0.7391 0.004 0.000 0.984 0.000 0.004 0.008
#> GSM110411     5  0.3915     0.2930 0.000 0.000 0.000 0.412 0.584 0.004
#> GSM110412     5  0.3647     0.4060 0.000 0.000 0.000 0.360 0.640 0.000
#> GSM110417     4  0.2998     0.7031 0.008 0.000 0.000 0.856 0.072 0.064
#> GSM110422     2  0.2089     0.6141 0.000 0.916 0.044 0.000 0.020 0.020
#> GSM110426     4  0.2162     0.7123 0.000 0.000 0.004 0.896 0.088 0.012
#> GSM110429     2  0.1500     0.6114 0.000 0.936 0.052 0.000 0.000 0.012
#> GSM110433     5  0.1719     0.6152 0.000 0.056 0.000 0.008 0.928 0.008
#> GSM110436     6  0.7986     0.4805 0.008 0.276 0.252 0.008 0.156 0.300
#> GSM110440     1  0.5883     0.5152 0.580 0.000 0.064 0.272 0.000 0.084
#> GSM110441     2  0.6651    -0.2833 0.004 0.444 0.000 0.032 0.280 0.240
#> GSM110444     5  0.3804     0.2800 0.000 0.000 0.000 0.424 0.576 0.000
#> GSM110445     1  0.6203     0.5301 0.552 0.044 0.000 0.196 0.000 0.208
#> GSM110446     3  0.5429     0.5753 0.028 0.032 0.676 0.064 0.000 0.200
#> GSM110449     2  0.5381     0.4386 0.004 0.632 0.000 0.192 0.008 0.164
#> GSM110451     3  0.5722     0.5197 0.024 0.092 0.684 0.000 0.080 0.120
#> GSM110391     5  0.1218     0.6350 0.000 0.004 0.000 0.012 0.956 0.028
#> GSM110439     2  0.1728     0.6314 0.000 0.924 0.000 0.008 0.004 0.064
#> GSM110442     2  0.4057     0.4733 0.004 0.788 0.000 0.060 0.024 0.124
#> GSM110443     1  0.7012     0.3446 0.476 0.224 0.000 0.164 0.000 0.136
#> GSM110447     3  0.5728     0.2801 0.004 0.004 0.576 0.020 0.096 0.300
#> GSM110448     4  0.3266     0.5571 0.000 0.000 0.000 0.728 0.272 0.000
#> GSM110450     1  0.5267     0.5649 0.648 0.008 0.004 0.160 0.000 0.180
#> GSM110452     2  0.1434     0.6338 0.000 0.940 0.000 0.000 0.012 0.048
#> GSM110453     2  0.0291     0.6210 0.000 0.992 0.000 0.000 0.004 0.004

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) specimen(p) k
#> SD:NMF 58           0.7783       0.299 2
#> SD:NMF 49           0.2008       0.126 3
#> SD:NMF 53           0.0140       0.306 4
#> SD:NMF 49           0.0461       0.267 5
#> SD:NMF 38           0.0617       0.129 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.504           0.814       0.903         0.4542 0.534   0.534
#> 3 3 0.662           0.809       0.895         0.4093 0.741   0.552
#> 4 4 0.641           0.741       0.814         0.1162 0.910   0.754
#> 5 5 0.679           0.710       0.820         0.0664 0.955   0.838
#> 6 6 0.712           0.611       0.788         0.0446 0.924   0.707

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
#> GSM110395     2   0.469     0.8902 0.100 0.900
#> GSM110396     1   0.000     0.9029 1.000 0.000
#> GSM110397     1   0.000     0.9029 1.000 0.000
#> GSM110398     2   0.994     0.1030 0.456 0.544
#> GSM110399     2   0.388     0.8919 0.076 0.924
#> GSM110400     2   0.574     0.8745 0.136 0.864
#> GSM110401     1   0.000     0.9029 1.000 0.000
#> GSM110406     2   0.388     0.8919 0.076 0.924
#> GSM110407     1   0.000     0.9029 1.000 0.000
#> GSM110409     1   0.000     0.9029 1.000 0.000
#> GSM110410     2   0.000     0.8804 0.000 1.000
#> GSM110413     2   0.141     0.8834 0.020 0.980
#> GSM110414     2   0.000     0.8804 0.000 1.000
#> GSM110415     2   0.697     0.8390 0.188 0.812
#> GSM110416     2   0.697     0.8390 0.188 0.812
#> GSM110418     2   0.697     0.8390 0.188 0.812
#> GSM110419     2   0.634     0.8616 0.160 0.840
#> GSM110420     2   0.753     0.8101 0.216 0.784
#> GSM110421     2   0.343     0.8923 0.064 0.936
#> GSM110423     2   0.574     0.8745 0.136 0.864
#> GSM110424     2   0.000     0.8804 0.000 1.000
#> GSM110425     2   0.574     0.8745 0.136 0.864
#> GSM110427     2   0.141     0.8834 0.020 0.980
#> GSM110428     1   0.327     0.8717 0.940 0.060
#> GSM110430     1   0.000     0.9029 1.000 0.000
#> GSM110431     1   0.000     0.9029 1.000 0.000
#> GSM110432     2   0.541     0.8833 0.124 0.876
#> GSM110434     2   0.506     0.8876 0.112 0.888
#> GSM110435     1   0.000     0.9029 1.000 0.000
#> GSM110437     1   0.000     0.9029 1.000 0.000
#> GSM110438     1   0.988     0.1040 0.564 0.436
#> GSM110388     1   0.295     0.8791 0.948 0.052
#> GSM110392     2   1.000     0.0734 0.492 0.508
#> GSM110394     1   0.000     0.9029 1.000 0.000
#> GSM110402     2   0.615     0.8668 0.152 0.848
#> GSM110411     1   0.990     0.1140 0.560 0.440
#> GSM110412     2   0.697     0.8328 0.188 0.812
#> GSM110417     1   0.000     0.9029 1.000 0.000
#> GSM110422     2   0.141     0.8834 0.020 0.980
#> GSM110426     1   0.000     0.9029 1.000 0.000
#> GSM110429     2   0.541     0.8833 0.124 0.876
#> GSM110433     2   0.000     0.8804 0.000 1.000
#> GSM110436     2   0.141     0.8834 0.020 0.980
#> GSM110440     1   0.000     0.9029 1.000 0.000
#> GSM110441     2   0.000     0.8804 0.000 1.000
#> GSM110444     1   0.990     0.1140 0.560 0.440
#> GSM110445     1   0.388     0.8605 0.924 0.076
#> GSM110446     2   0.714     0.8314 0.196 0.804
#> GSM110449     2   0.388     0.8919 0.076 0.924
#> GSM110451     2   0.541     0.8833 0.124 0.876
#> GSM110391     2   0.000     0.8804 0.000 1.000
#> GSM110439     2   0.000     0.8804 0.000 1.000
#> GSM110442     2   0.358     0.8920 0.068 0.932
#> GSM110443     2   0.358     0.8920 0.068 0.932
#> GSM110447     2   0.615     0.8668 0.152 0.848
#> GSM110448     1   0.260     0.8839 0.956 0.044
#> GSM110450     1   0.388     0.8605 0.924 0.076
#> GSM110452     2   0.141     0.8834 0.020 0.980
#> GSM110453     2   0.000     0.8804 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
#> GSM110395     2  0.2625      0.835 0.000 0.916 0.084
#> GSM110396     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110397     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110398     2  0.8157      0.316 0.384 0.540 0.076
#> GSM110399     2  0.2682      0.841 0.004 0.920 0.076
#> GSM110400     3  0.1753      0.934 0.000 0.048 0.952
#> GSM110401     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110406     2  0.2682      0.841 0.004 0.920 0.076
#> GSM110407     1  0.2537      0.895 0.920 0.000 0.080
#> GSM110409     1  0.2537      0.895 0.920 0.000 0.080
#> GSM110410     2  0.1031      0.839 0.000 0.976 0.024
#> GSM110413     2  0.0000      0.843 0.000 1.000 0.000
#> GSM110414     3  0.5016      0.742 0.000 0.240 0.760
#> GSM110415     3  0.0424      0.930 0.008 0.000 0.992
#> GSM110416     3  0.0424      0.930 0.008 0.000 0.992
#> GSM110418     3  0.0424      0.930 0.008 0.000 0.992
#> GSM110419     3  0.1031      0.938 0.000 0.024 0.976
#> GSM110420     3  0.4002      0.792 0.160 0.000 0.840
#> GSM110421     2  0.1964      0.845 0.000 0.944 0.056
#> GSM110423     3  0.1753      0.934 0.000 0.048 0.952
#> GSM110424     2  0.1031      0.839 0.000 0.976 0.024
#> GSM110425     3  0.1753      0.934 0.000 0.048 0.952
#> GSM110427     2  0.0000      0.843 0.000 1.000 0.000
#> GSM110428     1  0.6119      0.804 0.772 0.064 0.164
#> GSM110430     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110431     1  0.0892      0.911 0.980 0.020 0.000
#> GSM110432     2  0.3551      0.809 0.000 0.868 0.132
#> GSM110434     2  0.3193      0.827 0.004 0.896 0.100
#> GSM110435     1  0.1482      0.913 0.968 0.020 0.012
#> GSM110437     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110438     2  0.9485      0.127 0.388 0.428 0.184
#> GSM110388     1  0.5692      0.812 0.784 0.040 0.176
#> GSM110392     2  0.8973      0.297 0.364 0.500 0.136
#> GSM110394     1  0.1482      0.913 0.968 0.020 0.012
#> GSM110402     3  0.1289      0.938 0.000 0.032 0.968
#> GSM110411     2  0.9481      0.138 0.384 0.432 0.184
#> GSM110412     2  0.5564      0.770 0.064 0.808 0.128
#> GSM110417     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.843 0.000 1.000 0.000
#> GSM110426     1  0.0000      0.914 1.000 0.000 0.000
#> GSM110429     2  0.3482      0.811 0.000 0.872 0.128
#> GSM110433     2  0.1031      0.839 0.000 0.976 0.024
#> GSM110436     2  0.0000      0.843 0.000 1.000 0.000
#> GSM110440     1  0.1482      0.913 0.968 0.020 0.012
#> GSM110441     2  0.0892      0.840 0.000 0.980 0.020
#> GSM110444     2  0.9481      0.138 0.384 0.432 0.184
#> GSM110445     1  0.6203      0.788 0.760 0.056 0.184
#> GSM110446     3  0.1031      0.922 0.024 0.000 0.976
#> GSM110449     2  0.2682      0.841 0.004 0.920 0.076
#> GSM110451     2  0.3551      0.809 0.000 0.868 0.132
#> GSM110391     2  0.0892      0.840 0.000 0.980 0.020
#> GSM110439     2  0.0892      0.840 0.000 0.980 0.020
#> GSM110442     2  0.2301      0.845 0.004 0.936 0.060
#> GSM110443     2  0.2301      0.845 0.004 0.936 0.060
#> GSM110447     3  0.1289      0.938 0.000 0.032 0.968
#> GSM110448     1  0.5470      0.821 0.796 0.036 0.168
#> GSM110450     1  0.6203      0.788 0.760 0.056 0.184
#> GSM110452     2  0.0424      0.845 0.000 0.992 0.008
#> GSM110453     2  0.1031      0.839 0.000 0.976 0.024

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.6108      0.651 0.000 0.528 0.048 0.424
#> GSM110396     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> GSM110397     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> GSM110398     2  0.3024      0.392 0.072 0.896 0.012 0.020
#> GSM110399     2  0.5174      0.668 0.000 0.620 0.012 0.368
#> GSM110400     3  0.1913      0.927 0.000 0.040 0.940 0.020
#> GSM110401     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> GSM110406     2  0.5174      0.668 0.000 0.620 0.012 0.368
#> GSM110407     1  0.2623      0.855 0.908 0.028 0.064 0.000
#> GSM110409     1  0.2623      0.855 0.908 0.028 0.064 0.000
#> GSM110410     4  0.0336      0.862 0.000 0.008 0.000 0.992
#> GSM110413     2  0.4985      0.585 0.000 0.532 0.000 0.468
#> GSM110414     3  0.4008      0.741 0.000 0.000 0.756 0.244
#> GSM110415     3  0.0469      0.927 0.000 0.012 0.988 0.000
#> GSM110416     3  0.0469      0.927 0.000 0.012 0.988 0.000
#> GSM110418     3  0.0469      0.927 0.000 0.012 0.988 0.000
#> GSM110419     3  0.1356      0.932 0.000 0.032 0.960 0.008
#> GSM110420     3  0.4530      0.785 0.124 0.056 0.812 0.008
#> GSM110421     2  0.5050      0.650 0.000 0.588 0.004 0.408
#> GSM110423     3  0.1913      0.927 0.000 0.040 0.940 0.020
#> GSM110424     4  0.0592      0.866 0.000 0.016 0.000 0.984
#> GSM110425     3  0.1913      0.927 0.000 0.040 0.940 0.020
#> GSM110427     2  0.4994      0.573 0.000 0.520 0.000 0.480
#> GSM110428     1  0.6353      0.731 0.652 0.208 0.140 0.000
#> GSM110430     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> GSM110431     1  0.2281      0.856 0.904 0.096 0.000 0.000
#> GSM110432     2  0.6758      0.637 0.000 0.504 0.096 0.400
#> GSM110434     2  0.6270      0.658 0.000 0.536 0.060 0.404
#> GSM110435     1  0.3037      0.857 0.880 0.100 0.020 0.000
#> GSM110437     1  0.0000      0.868 1.000 0.000 0.000 0.000
#> GSM110438     2  0.4656      0.337 0.056 0.784 0.160 0.000
#> GSM110388     1  0.7175      0.526 0.460 0.404 0.136 0.000
#> GSM110392     2  0.4461      0.400 0.048 0.832 0.092 0.028
#> GSM110394     1  0.3037      0.857 0.880 0.100 0.020 0.000
#> GSM110402     3  0.1488      0.933 0.000 0.032 0.956 0.012
#> GSM110411     2  0.5054      0.347 0.072 0.784 0.132 0.012
#> GSM110412     2  0.6563      0.613 0.004 0.584 0.084 0.328
#> GSM110417     1  0.0707      0.869 0.980 0.020 0.000 0.000
#> GSM110422     2  0.4994      0.573 0.000 0.520 0.000 0.480
#> GSM110426     1  0.0469      0.869 0.988 0.012 0.000 0.000
#> GSM110429     2  0.6775      0.628 0.000 0.492 0.096 0.412
#> GSM110433     4  0.0469      0.866 0.000 0.012 0.000 0.988
#> GSM110436     2  0.4994      0.573 0.000 0.520 0.000 0.480
#> GSM110440     1  0.3037      0.857 0.880 0.100 0.020 0.000
#> GSM110441     4  0.3528      0.720 0.000 0.192 0.000 0.808
#> GSM110444     2  0.5054      0.347 0.072 0.784 0.132 0.012
#> GSM110445     1  0.5770      0.734 0.712 0.148 0.140 0.000
#> GSM110446     3  0.2602      0.895 0.008 0.076 0.908 0.008
#> GSM110449     2  0.5174      0.668 0.000 0.620 0.012 0.368
#> GSM110451     2  0.6758      0.637 0.000 0.504 0.096 0.400
#> GSM110391     4  0.3266      0.768 0.000 0.168 0.000 0.832
#> GSM110439     4  0.2921      0.804 0.000 0.140 0.000 0.860
#> GSM110442     2  0.4978      0.663 0.000 0.612 0.004 0.384
#> GSM110443     2  0.4978      0.663 0.000 0.612 0.004 0.384
#> GSM110447     3  0.1488      0.933 0.000 0.032 0.956 0.012
#> GSM110448     1  0.6432      0.698 0.636 0.236 0.128 0.000
#> GSM110450     1  0.5770      0.734 0.712 0.148 0.140 0.000
#> GSM110452     2  0.4961      0.613 0.000 0.552 0.000 0.448
#> GSM110453     4  0.0469      0.866 0.000 0.012 0.000 0.988

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.2304      0.818 0.000 0.908 0.048 0.000 0.044
#> GSM110396     1  0.0510      0.794 0.984 0.000 0.000 0.016 0.000
#> GSM110397     1  0.0404      0.792 0.988 0.000 0.000 0.012 0.000
#> GSM110398     2  0.4986     -0.437 0.012 0.532 0.012 0.444 0.000
#> GSM110399     2  0.1012      0.814 0.000 0.968 0.012 0.020 0.000
#> GSM110400     3  0.1628      0.879 0.000 0.056 0.936 0.000 0.008
#> GSM110401     1  0.2813      0.737 0.832 0.000 0.000 0.168 0.000
#> GSM110406     2  0.1012      0.814 0.000 0.968 0.012 0.020 0.000
#> GSM110407     1  0.2782      0.781 0.880 0.000 0.048 0.072 0.000
#> GSM110409     1  0.2782      0.781 0.880 0.000 0.048 0.072 0.000
#> GSM110410     5  0.2179      0.869 0.000 0.112 0.000 0.000 0.888
#> GSM110413     2  0.1792      0.805 0.000 0.916 0.000 0.000 0.084
#> GSM110414     3  0.3452      0.697 0.000 0.000 0.756 0.000 0.244
#> GSM110415     3  0.0404      0.879 0.000 0.012 0.988 0.000 0.000
#> GSM110416     3  0.0404      0.879 0.000 0.012 0.988 0.000 0.000
#> GSM110418     3  0.0404      0.879 0.000 0.012 0.988 0.000 0.000
#> GSM110419     3  0.1043      0.885 0.000 0.040 0.960 0.000 0.000
#> GSM110420     3  0.6764      0.559 0.060 0.000 0.564 0.264 0.112
#> GSM110421     2  0.0609      0.824 0.000 0.980 0.000 0.000 0.020
#> GSM110423     3  0.1628      0.879 0.000 0.056 0.936 0.000 0.008
#> GSM110424     5  0.2280      0.873 0.000 0.120 0.000 0.000 0.880
#> GSM110425     3  0.1628      0.879 0.000 0.056 0.936 0.000 0.008
#> GSM110427     2  0.1908      0.803 0.000 0.908 0.000 0.000 0.092
#> GSM110428     1  0.6100      0.550 0.628 0.028 0.120 0.224 0.000
#> GSM110430     1  0.2813      0.737 0.832 0.000 0.000 0.168 0.000
#> GSM110431     1  0.2127      0.773 0.892 0.000 0.000 0.108 0.000
#> GSM110432     2  0.2685      0.787 0.000 0.880 0.092 0.000 0.028
#> GSM110434     2  0.2390      0.810 0.000 0.908 0.060 0.008 0.024
#> GSM110435     1  0.2921      0.769 0.856 0.000 0.020 0.124 0.000
#> GSM110437     1  0.2813      0.737 0.832 0.000 0.000 0.168 0.000
#> GSM110438     4  0.6171      0.585 0.000 0.372 0.140 0.488 0.000
#> GSM110388     4  0.5978     -0.155 0.400 0.020 0.064 0.516 0.000
#> GSM110392     2  0.6018     -0.454 0.000 0.480 0.088 0.424 0.008
#> GSM110394     1  0.2921      0.769 0.856 0.000 0.020 0.124 0.000
#> GSM110402     3  0.1197      0.885 0.000 0.048 0.952 0.000 0.000
#> GSM110411     4  0.5736      0.640 0.012 0.392 0.060 0.536 0.000
#> GSM110412     2  0.4034      0.654 0.000 0.812 0.080 0.096 0.012
#> GSM110417     1  0.0963      0.793 0.964 0.000 0.000 0.036 0.000
#> GSM110422     2  0.1908      0.803 0.000 0.908 0.000 0.000 0.092
#> GSM110426     1  0.0703      0.794 0.976 0.000 0.000 0.024 0.000
#> GSM110429     2  0.2927      0.785 0.000 0.868 0.092 0.000 0.040
#> GSM110433     5  0.2230      0.873 0.000 0.116 0.000 0.000 0.884
#> GSM110436     2  0.1908      0.803 0.000 0.908 0.000 0.000 0.092
#> GSM110440     1  0.2921      0.769 0.856 0.000 0.020 0.124 0.000
#> GSM110441     5  0.3983      0.754 0.000 0.340 0.000 0.000 0.660
#> GSM110444     4  0.5736      0.640 0.012 0.392 0.060 0.536 0.000
#> GSM110445     1  0.6107      0.425 0.508 0.024 0.068 0.400 0.000
#> GSM110446     3  0.5447      0.619 0.000 0.000 0.640 0.248 0.112
#> GSM110449     2  0.0912      0.817 0.000 0.972 0.012 0.016 0.000
#> GSM110451     2  0.2685      0.787 0.000 0.880 0.092 0.000 0.028
#> GSM110391     5  0.3837      0.800 0.000 0.308 0.000 0.000 0.692
#> GSM110439     5  0.3661      0.828 0.000 0.276 0.000 0.000 0.724
#> GSM110442     2  0.0162      0.823 0.000 0.996 0.000 0.004 0.000
#> GSM110443     2  0.0162      0.823 0.000 0.996 0.000 0.004 0.000
#> GSM110447     3  0.1197      0.885 0.000 0.048 0.952 0.000 0.000
#> GSM110448     1  0.5717      0.378 0.576 0.016 0.060 0.348 0.000
#> GSM110450     1  0.6107      0.425 0.508 0.024 0.068 0.400 0.000
#> GSM110452     2  0.1410      0.815 0.000 0.940 0.000 0.000 0.060
#> GSM110453     5  0.2230      0.873 0.000 0.116 0.000 0.000 0.884

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.2675      0.830 0.000 0.876 0.076 0.000 0.040 0.008
#> GSM110396     1  0.3843     -0.369 0.548 0.000 0.000 0.452 0.000 0.000
#> GSM110397     4  0.5449      0.312 0.436 0.000 0.000 0.464 0.008 0.092
#> GSM110398     2  0.5590      0.284 0.000 0.512 0.000 0.328 0.000 0.160
#> GSM110399     2  0.0777      0.838 0.000 0.972 0.000 0.024 0.000 0.004
#> GSM110400     3  0.0603      0.913 0.000 0.016 0.980 0.000 0.000 0.004
#> GSM110401     1  0.0000      0.618 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0858      0.838 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM110407     4  0.4184      0.265 0.432 0.000 0.008 0.556 0.000 0.004
#> GSM110409     4  0.4184      0.265 0.432 0.000 0.008 0.556 0.000 0.004
#> GSM110410     5  0.0260      0.816 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM110413     2  0.1858      0.818 0.000 0.904 0.000 0.004 0.092 0.000
#> GSM110414     3  0.3276      0.537 0.000 0.000 0.764 0.004 0.228 0.004
#> GSM110415     3  0.0993      0.903 0.000 0.000 0.964 0.024 0.000 0.012
#> GSM110416     3  0.0993      0.903 0.000 0.000 0.964 0.024 0.000 0.012
#> GSM110418     3  0.0993      0.903 0.000 0.000 0.964 0.024 0.000 0.012
#> GSM110419     3  0.0665      0.919 0.000 0.008 0.980 0.008 0.000 0.004
#> GSM110420     6  0.3841      0.808 0.000 0.000 0.256 0.028 0.000 0.716
#> GSM110421     2  0.0922      0.843 0.000 0.968 0.000 0.004 0.024 0.004
#> GSM110423     3  0.0603      0.913 0.000 0.016 0.980 0.000 0.000 0.004
#> GSM110424     5  0.0458      0.821 0.000 0.016 0.000 0.000 0.984 0.000
#> GSM110425     3  0.0603      0.913 0.000 0.016 0.980 0.000 0.000 0.004
#> GSM110427     2  0.2051      0.819 0.000 0.896 0.000 0.004 0.096 0.004
#> GSM110428     4  0.4483      0.331 0.160 0.008 0.064 0.748 0.000 0.020
#> GSM110430     1  0.0000      0.618 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     4  0.3930      0.378 0.420 0.000 0.000 0.576 0.004 0.000
#> GSM110432     2  0.3043      0.805 0.000 0.836 0.132 0.000 0.024 0.008
#> GSM110434     2  0.2709      0.827 0.000 0.876 0.088 0.008 0.020 0.008
#> GSM110435     4  0.3976      0.399 0.380 0.000 0.004 0.612 0.004 0.000
#> GSM110437     1  0.0000      0.618 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     4  0.6933     -0.155 0.000 0.332 0.084 0.412 0.000 0.172
#> GSM110388     4  0.3872      0.181 0.032 0.004 0.012 0.772 0.000 0.180
#> GSM110392     2  0.7092      0.255 0.000 0.416 0.116 0.308 0.000 0.160
#> GSM110394     4  0.3996      0.395 0.388 0.000 0.004 0.604 0.004 0.000
#> GSM110402     3  0.0622      0.921 0.000 0.012 0.980 0.008 0.000 0.000
#> GSM110411     4  0.5890     -0.142 0.000 0.372 0.004 0.448 0.000 0.176
#> GSM110412     2  0.4470      0.733 0.000 0.752 0.108 0.120 0.008 0.012
#> GSM110417     4  0.5548      0.329 0.424 0.000 0.000 0.464 0.008 0.104
#> GSM110422     2  0.2051      0.819 0.000 0.896 0.000 0.004 0.096 0.004
#> GSM110426     4  0.5443      0.328 0.424 0.000 0.000 0.476 0.008 0.092
#> GSM110429     2  0.3266      0.802 0.000 0.824 0.132 0.000 0.036 0.008
#> GSM110433     5  0.0363      0.821 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM110436     2  0.2051      0.819 0.000 0.896 0.000 0.004 0.096 0.004
#> GSM110440     4  0.3976      0.399 0.380 0.000 0.004 0.612 0.004 0.000
#> GSM110441     5  0.3601      0.654 0.000 0.312 0.000 0.004 0.684 0.000
#> GSM110444     4  0.5890     -0.142 0.000 0.372 0.004 0.448 0.000 0.176
#> GSM110445     1  0.4639      0.455 0.664 0.012 0.008 0.284 0.000 0.032
#> GSM110446     6  0.5147      0.791 0.000 0.000 0.328 0.104 0.000 0.568
#> GSM110449     2  0.0717      0.840 0.000 0.976 0.000 0.016 0.000 0.008
#> GSM110451     2  0.3043      0.805 0.000 0.836 0.132 0.000 0.024 0.008
#> GSM110391     5  0.3265      0.728 0.000 0.248 0.000 0.004 0.748 0.000
#> GSM110439     5  0.2703      0.779 0.000 0.172 0.000 0.004 0.824 0.000
#> GSM110442     2  0.0000      0.844 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110443     2  0.0000      0.844 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110447     3  0.0622      0.921 0.000 0.012 0.980 0.008 0.000 0.000
#> GSM110448     4  0.3458      0.244 0.044 0.000 0.012 0.816 0.000 0.128
#> GSM110450     1  0.4639      0.455 0.664 0.012 0.008 0.284 0.000 0.032
#> GSM110452     2  0.1471      0.831 0.000 0.932 0.000 0.004 0.064 0.000
#> GSM110453     5  0.0363      0.821 0.000 0.012 0.000 0.000 0.988 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> CV:hclust 54            1.000       0.699 2
#> CV:hclust 54            0.164       0.333 3
#> CV:hclust 54            0.231       0.215 4
#> CV:hclust 53            0.169       0.075 5
#> CV:hclust 39            0.115       0.346 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 17209 rows and 59 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.635           0.783       0.900         0.4864 0.499   0.499
#> 3 3 0.794           0.884       0.931         0.3376 0.730   0.518
#> 4 4 0.690           0.662       0.780         0.1294 0.850   0.597
#> 5 5 0.703           0.573       0.750         0.0755 0.910   0.680
#> 6 6 0.683           0.563       0.712         0.0463 0.875   0.532

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
#> GSM110395     2  0.3431      0.892 0.064 0.936
#> GSM110396     1  0.0376      0.869 0.996 0.004
#> GSM110397     1  0.0000      0.868 1.000 0.000
#> GSM110398     1  0.9286      0.507 0.656 0.344
#> GSM110399     1  0.9732      0.396 0.596 0.404
#> GSM110400     2  0.0376      0.876 0.004 0.996
#> GSM110401     1  0.0376      0.869 0.996 0.004
#> GSM110406     1  0.9710      0.405 0.600 0.400
#> GSM110407     1  0.0376      0.869 0.996 0.004
#> GSM110409     1  0.0376      0.869 0.996 0.004
#> GSM110410     2  0.0000      0.876 0.000 1.000
#> GSM110413     2  0.5629      0.836 0.132 0.868
#> GSM110414     2  0.0376      0.876 0.004 0.996
#> GSM110415     2  0.0376      0.876 0.004 0.996
#> GSM110416     2  0.8608      0.553 0.284 0.716
#> GSM110418     2  0.8909      0.511 0.308 0.692
#> GSM110419     2  0.0376      0.876 0.004 0.996
#> GSM110420     2  0.9686      0.321 0.396 0.604
#> GSM110421     2  0.3431      0.892 0.064 0.936
#> GSM110423     2  0.0376      0.876 0.004 0.996
#> GSM110424     2  0.3431      0.892 0.064 0.936
#> GSM110425     2  0.0376      0.876 0.004 0.996
#> GSM110427     2  0.3431      0.892 0.064 0.936
#> GSM110428     1  0.0376      0.869 0.996 0.004
#> GSM110430     1  0.0376      0.869 0.996 0.004
#> GSM110431     1  0.0000      0.868 1.000 0.000
#> GSM110432     2  0.3431      0.892 0.064 0.936
#> GSM110434     2  0.5629      0.836 0.132 0.868
#> GSM110435     1  0.0000      0.868 1.000 0.000
#> GSM110437     1  0.0376      0.869 0.996 0.004
#> GSM110438     1  0.3274      0.823 0.940 0.060
#> GSM110388     1  0.0376      0.869 0.996 0.004
#> GSM110392     2  0.9866      0.148 0.432 0.568
#> GSM110394     1  0.0000      0.868 1.000 0.000
#> GSM110402     2  0.0376      0.876 0.004 0.996
#> GSM110411     1  0.8016      0.647 0.756 0.244
#> GSM110412     2  0.3431      0.892 0.064 0.936
#> GSM110417     1  0.0000      0.868 1.000 0.000
#> GSM110422     2  0.3431      0.892 0.064 0.936
#> GSM110426     1  0.0000      0.868 1.000 0.000
#> GSM110429     2  0.3431      0.892 0.064 0.936
#> GSM110433     2  0.0000      0.876 0.000 1.000
#> GSM110436     2  0.3431      0.892 0.064 0.936
#> GSM110440     1  0.0000      0.868 1.000 0.000
#> GSM110441     2  0.3431      0.892 0.064 0.936
#> GSM110444     1  0.9833      0.344 0.576 0.424
#> GSM110445     1  0.0376      0.869 0.996 0.004
#> GSM110446     2  0.8909      0.511 0.308 0.692
#> GSM110449     1  0.9732      0.396 0.596 0.404
#> GSM110451     2  0.3431      0.892 0.064 0.936
#> GSM110391     2  0.3431      0.892 0.064 0.936
#> GSM110439     2  0.3431      0.892 0.064 0.936
#> GSM110442     2  0.5629      0.836 0.132 0.868
#> GSM110443     1  0.9710      0.405 0.600 0.400
#> GSM110447     2  0.0376      0.876 0.004 0.996
#> GSM110448     1  0.0376      0.869 0.996 0.004
#> GSM110450     1  0.0376      0.869 0.996 0.004
#> GSM110452     2  0.5629      0.836 0.132 0.868
#> GSM110453     2  0.3431      0.892 0.064 0.936

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     2  0.2356      0.926 0.000 0.928 0.072
#> GSM110396     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110397     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110398     1  0.8828      0.464 0.580 0.228 0.192
#> GSM110399     2  0.4164      0.889 0.008 0.848 0.144
#> GSM110400     3  0.0892      0.932 0.000 0.020 0.980
#> GSM110401     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110406     2  0.3454      0.916 0.008 0.888 0.104
#> GSM110407     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110409     1  0.0424      0.912 0.992 0.000 0.008
#> GSM110410     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110413     2  0.0237      0.930 0.000 0.996 0.004
#> GSM110414     3  0.4750      0.775 0.000 0.216 0.784
#> GSM110415     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110416     3  0.2998      0.905 0.068 0.016 0.916
#> GSM110418     3  0.2998      0.905 0.068 0.016 0.916
#> GSM110419     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110420     3  0.5115      0.771 0.188 0.016 0.796
#> GSM110421     2  0.2356      0.926 0.000 0.928 0.072
#> GSM110423     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110424     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110425     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110427     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110428     1  0.3551      0.807 0.868 0.000 0.132
#> GSM110430     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110431     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110432     2  0.4399      0.847 0.000 0.812 0.188
#> GSM110434     2  0.2537      0.924 0.000 0.920 0.080
#> GSM110435     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110437     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110438     1  0.6379      0.476 0.624 0.008 0.368
#> GSM110388     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110392     2  0.4915      0.847 0.012 0.804 0.184
#> GSM110394     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110402     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110411     1  0.8794      0.470 0.584 0.224 0.192
#> GSM110412     2  0.4346      0.850 0.000 0.816 0.184
#> GSM110417     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110426     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110429     2  0.2878      0.918 0.000 0.904 0.096
#> GSM110433     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110436     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110440     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110441     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110444     2  0.4915      0.847 0.012 0.804 0.184
#> GSM110445     1  0.4235      0.778 0.824 0.000 0.176
#> GSM110446     3  0.3183      0.898 0.076 0.016 0.908
#> GSM110449     2  0.3532      0.914 0.008 0.884 0.108
#> GSM110451     2  0.2796      0.920 0.000 0.908 0.092
#> GSM110391     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110439     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110442     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110443     2  0.3454      0.916 0.008 0.888 0.104
#> GSM110447     3  0.0747      0.934 0.000 0.016 0.984
#> GSM110448     1  0.0000      0.913 1.000 0.000 0.000
#> GSM110450     1  0.0747      0.911 0.984 0.000 0.016
#> GSM110452     2  0.0000      0.932 0.000 1.000 0.000
#> GSM110453     2  0.0000      0.932 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4941     0.1673 0.000 0.564 0.000 0.436
#> GSM110396     1  0.3486     0.8605 0.812 0.000 0.000 0.188
#> GSM110397     1  0.0000     0.8826 1.000 0.000 0.000 0.000
#> GSM110398     4  0.3429     0.5035 0.064 0.056 0.004 0.876
#> GSM110399     4  0.4356     0.5764 0.000 0.292 0.000 0.708
#> GSM110400     3  0.1557     0.9192 0.000 0.000 0.944 0.056
#> GSM110401     1  0.3486     0.8605 0.812 0.000 0.000 0.188
#> GSM110406     4  0.4356     0.5764 0.000 0.292 0.000 0.708
#> GSM110407     1  0.4579     0.8615 0.768 0.000 0.032 0.200
#> GSM110409     1  0.4540     0.8629 0.772 0.000 0.032 0.196
#> GSM110410     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110413     2  0.4304     0.5116 0.000 0.716 0.000 0.284
#> GSM110414     3  0.3528     0.7744 0.000 0.192 0.808 0.000
#> GSM110415     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110416     3  0.1637     0.9129 0.000 0.000 0.940 0.060
#> GSM110418     3  0.1637     0.9129 0.000 0.000 0.940 0.060
#> GSM110419     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110420     3  0.4673     0.7804 0.132 0.000 0.792 0.076
#> GSM110421     2  0.4933     0.1808 0.000 0.568 0.000 0.432
#> GSM110423     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110424     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110425     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110427     2  0.1867     0.6933 0.000 0.928 0.000 0.072
#> GSM110428     1  0.4996     0.7122 0.752 0.000 0.192 0.056
#> GSM110430     1  0.3486     0.8605 0.812 0.000 0.000 0.188
#> GSM110431     1  0.0188     0.8826 0.996 0.000 0.000 0.004
#> GSM110432     2  0.6130     0.0340 0.000 0.512 0.048 0.440
#> GSM110434     4  0.4972     0.1576 0.000 0.456 0.000 0.544
#> GSM110435     1  0.1488     0.8816 0.956 0.000 0.032 0.012
#> GSM110437     1  0.3486     0.8605 0.812 0.000 0.000 0.188
#> GSM110438     4  0.7347     0.2879 0.244 0.000 0.228 0.528
#> GSM110388     1  0.4244     0.7712 0.800 0.000 0.032 0.168
#> GSM110392     4  0.5172     0.5757 0.000 0.260 0.036 0.704
#> GSM110394     1  0.1488     0.8816 0.956 0.000 0.032 0.012
#> GSM110402     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110411     4  0.4026     0.5064 0.092 0.048 0.012 0.848
#> GSM110412     4  0.6120     0.2016 0.000 0.432 0.048 0.520
#> GSM110417     1  0.0592     0.8800 0.984 0.000 0.000 0.016
#> GSM110422     2  0.4103     0.5559 0.000 0.744 0.000 0.256
#> GSM110426     1  0.0592     0.8800 0.984 0.000 0.000 0.016
#> GSM110429     2  0.5182     0.4547 0.000 0.684 0.028 0.288
#> GSM110433     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110436     2  0.1867     0.6933 0.000 0.928 0.000 0.072
#> GSM110440     1  0.1488     0.8816 0.956 0.000 0.032 0.012
#> GSM110441     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110444     4  0.4606     0.5875 0.000 0.264 0.012 0.724
#> GSM110445     4  0.5576    -0.4347 0.444 0.000 0.020 0.536
#> GSM110446     3  0.1940     0.9074 0.000 0.000 0.924 0.076
#> GSM110449     4  0.4304     0.5833 0.000 0.284 0.000 0.716
#> GSM110451     2  0.5691     0.2133 0.000 0.564 0.028 0.408
#> GSM110391     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110439     2  0.0000     0.7034 0.000 1.000 0.000 0.000
#> GSM110442     4  0.4994     0.0877 0.000 0.480 0.000 0.520
#> GSM110443     4  0.4277     0.5851 0.000 0.280 0.000 0.720
#> GSM110447     3  0.1022     0.9368 0.000 0.000 0.968 0.032
#> GSM110448     1  0.1833     0.8783 0.944 0.000 0.032 0.024
#> GSM110450     1  0.4764     0.8520 0.748 0.000 0.032 0.220
#> GSM110452     2  0.4564     0.4485 0.000 0.672 0.000 0.328
#> GSM110453     2  0.0000     0.7034 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.6080     0.4362 0.000 0.560 0.000 0.168 0.272
#> GSM110396     1  0.4287     0.5448 0.540 0.000 0.000 0.460 0.000
#> GSM110397     1  0.2136     0.6462 0.904 0.008 0.000 0.088 0.000
#> GSM110398     2  0.3402     0.4036 0.008 0.804 0.000 0.184 0.004
#> GSM110399     2  0.2520     0.5618 0.000 0.896 0.000 0.056 0.048
#> GSM110400     3  0.1106     0.8515 0.000 0.024 0.964 0.012 0.000
#> GSM110401     1  0.4297     0.5437 0.528 0.000 0.000 0.472 0.000
#> GSM110406     2  0.1197     0.5810 0.000 0.952 0.000 0.000 0.048
#> GSM110407     1  0.4438     0.5449 0.608 0.004 0.004 0.384 0.000
#> GSM110409     1  0.4438     0.5451 0.608 0.004 0.004 0.384 0.000
#> GSM110410     5  0.0000     0.7744 0.000 0.000 0.000 0.000 1.000
#> GSM110413     2  0.4980     0.2997 0.000 0.584 0.000 0.036 0.380
#> GSM110414     3  0.3462     0.7080 0.000 0.000 0.792 0.012 0.196
#> GSM110415     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110416     3  0.4596     0.7831 0.044 0.028 0.764 0.164 0.000
#> GSM110418     3  0.4596     0.7831 0.044 0.028 0.764 0.164 0.000
#> GSM110419     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110420     3  0.5604     0.7314 0.084 0.036 0.688 0.192 0.000
#> GSM110421     2  0.5087     0.4810 0.000 0.644 0.000 0.064 0.292
#> GSM110423     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110424     5  0.0000     0.7744 0.000 0.000 0.000 0.000 1.000
#> GSM110425     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110427     5  0.5379     0.5168 0.000 0.168 0.000 0.164 0.668
#> GSM110428     1  0.5497     0.2910 0.720 0.084 0.060 0.136 0.000
#> GSM110430     1  0.4297     0.5437 0.528 0.000 0.000 0.472 0.000
#> GSM110431     1  0.1908     0.6502 0.908 0.000 0.000 0.092 0.000
#> GSM110432     2  0.8008     0.3134 0.000 0.428 0.136 0.172 0.264
#> GSM110434     2  0.4946     0.5932 0.000 0.712 0.000 0.168 0.120
#> GSM110435     1  0.0451     0.6396 0.988 0.004 0.008 0.000 0.000
#> GSM110437     1  0.4297     0.5437 0.528 0.000 0.000 0.472 0.000
#> GSM110438     4  0.7791     0.1595 0.344 0.184 0.084 0.388 0.000
#> GSM110388     1  0.4010     0.3634 0.784 0.056 0.000 0.160 0.000
#> GSM110392     2  0.6461     0.4668 0.000 0.584 0.104 0.268 0.044
#> GSM110394     1  0.0833     0.6451 0.976 0.004 0.004 0.016 0.000
#> GSM110402     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110411     2  0.3399     0.4259 0.020 0.812 0.000 0.168 0.000
#> GSM110412     2  0.8064     0.4171 0.000 0.424 0.136 0.248 0.192
#> GSM110417     1  0.2130     0.6437 0.908 0.012 0.000 0.080 0.000
#> GSM110422     5  0.6269     0.1128 0.000 0.324 0.000 0.168 0.508
#> GSM110426     1  0.2189     0.6431 0.904 0.012 0.000 0.084 0.000
#> GSM110429     5  0.7926     0.0762 0.000 0.264 0.128 0.168 0.440
#> GSM110433     5  0.0000     0.7744 0.000 0.000 0.000 0.000 1.000
#> GSM110436     5  0.5379     0.5168 0.000 0.168 0.000 0.164 0.668
#> GSM110440     1  0.0451     0.6396 0.988 0.004 0.008 0.000 0.000
#> GSM110441     5  0.1251     0.7468 0.000 0.036 0.000 0.008 0.956
#> GSM110444     2  0.3681     0.5135 0.000 0.808 0.000 0.148 0.044
#> GSM110445     4  0.6495     0.0539 0.204 0.328 0.000 0.468 0.000
#> GSM110446     3  0.5292     0.7513 0.064 0.036 0.712 0.188 0.000
#> GSM110449     2  0.3130     0.5370 0.000 0.856 0.000 0.096 0.048
#> GSM110451     2  0.8057     0.1650 0.000 0.372 0.128 0.168 0.332
#> GSM110391     5  0.0290     0.7724 0.000 0.000 0.000 0.008 0.992
#> GSM110439     5  0.0000     0.7744 0.000 0.000 0.000 0.000 1.000
#> GSM110442     2  0.3409     0.5999 0.000 0.824 0.000 0.032 0.144
#> GSM110443     2  0.2782     0.5532 0.000 0.880 0.000 0.072 0.048
#> GSM110447     3  0.0290     0.8730 0.000 0.008 0.992 0.000 0.000
#> GSM110448     1  0.1195     0.6366 0.960 0.012 0.000 0.028 0.000
#> GSM110450     1  0.4507     0.5295 0.580 0.004 0.004 0.412 0.000
#> GSM110452     2  0.6282     0.2120 0.000 0.476 0.000 0.156 0.368
#> GSM110453     5  0.0000     0.7744 0.000 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.2135    0.46716 0.000 0.872 0.000 0.000 0.128 0.000
#> GSM110396     1  0.0146    0.80291 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110397     6  0.3620    0.71103 0.352 0.000 0.000 0.000 0.000 0.648
#> GSM110398     4  0.4323    0.59675 0.004 0.376 0.000 0.600 0.000 0.020
#> GSM110399     2  0.4051   -0.39996 0.000 0.560 0.000 0.432 0.008 0.000
#> GSM110400     3  0.0725    0.85686 0.000 0.012 0.976 0.012 0.000 0.000
#> GSM110401     1  0.0547    0.80338 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM110406     2  0.3955   -0.28768 0.000 0.608 0.000 0.384 0.008 0.000
#> GSM110407     1  0.2985    0.72057 0.844 0.000 0.000 0.100 0.000 0.056
#> GSM110409     1  0.3183    0.70383 0.828 0.000 0.000 0.112 0.000 0.060
#> GSM110410     5  0.0363    0.95398 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM110413     2  0.6095    0.21021 0.000 0.508 0.000 0.256 0.220 0.016
#> GSM110414     3  0.4169    0.71409 0.000 0.000 0.756 0.032 0.176 0.036
#> GSM110415     3  0.0520    0.86378 0.000 0.008 0.984 0.008 0.000 0.000
#> GSM110416     3  0.4601    0.77480 0.000 0.008 0.716 0.140 0.000 0.136
#> GSM110418     3  0.4638    0.77276 0.000 0.008 0.712 0.140 0.000 0.140
#> GSM110419     3  0.0146    0.86501 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM110420     3  0.5461    0.70112 0.004 0.000 0.592 0.196 0.000 0.208
#> GSM110421     2  0.5808    0.32748 0.000 0.568 0.000 0.212 0.204 0.016
#> GSM110423     3  0.0146    0.86472 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM110424     5  0.0363    0.95398 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM110425     3  0.0146    0.86472 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM110427     2  0.4181    0.10067 0.000 0.512 0.000 0.000 0.476 0.012
#> GSM110428     6  0.7631    0.36396 0.244 0.108 0.016 0.256 0.000 0.376
#> GSM110430     1  0.0547    0.80338 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM110431     6  0.5181    0.65546 0.428 0.000 0.000 0.088 0.000 0.484
#> GSM110432     2  0.5715    0.45731 0.000 0.628 0.152 0.012 0.188 0.020
#> GSM110434     2  0.1794    0.37388 0.000 0.924 0.000 0.040 0.036 0.000
#> GSM110435     6  0.5279    0.70552 0.324 0.000 0.000 0.120 0.000 0.556
#> GSM110437     1  0.0547    0.80338 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM110438     4  0.6488   -0.01505 0.000 0.168 0.044 0.452 0.000 0.336
#> GSM110388     6  0.5155    0.42568 0.124 0.000 0.000 0.280 0.000 0.596
#> GSM110392     2  0.6185   -0.16950 0.000 0.532 0.104 0.300 0.000 0.064
#> GSM110394     6  0.5300    0.67452 0.376 0.000 0.000 0.108 0.000 0.516
#> GSM110402     3  0.0146    0.86501 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM110411     4  0.4809    0.61422 0.000 0.328 0.000 0.600 0.000 0.072
#> GSM110412     2  0.7811    0.15648 0.000 0.452 0.148 0.228 0.096 0.076
#> GSM110417     6  0.3699    0.71593 0.336 0.000 0.000 0.004 0.000 0.660
#> GSM110422     2  0.4044    0.42120 0.000 0.668 0.000 0.008 0.312 0.012
#> GSM110426     6  0.3699    0.71593 0.336 0.000 0.000 0.004 0.000 0.660
#> GSM110429     2  0.5956    0.37444 0.000 0.556 0.128 0.012 0.288 0.016
#> GSM110433     5  0.0291    0.94431 0.000 0.000 0.000 0.004 0.992 0.004
#> GSM110436     2  0.4551    0.17973 0.000 0.536 0.000 0.012 0.436 0.016
#> GSM110440     6  0.5291    0.70622 0.328 0.000 0.000 0.120 0.000 0.552
#> GSM110441     5  0.2631    0.82112 0.000 0.128 0.000 0.004 0.856 0.012
#> GSM110444     4  0.4913    0.60603 0.000 0.364 0.000 0.564 0.000 0.072
#> GSM110445     1  0.5304    0.44166 0.632 0.096 0.000 0.248 0.000 0.024
#> GSM110446     3  0.5327    0.70360 0.000 0.000 0.596 0.208 0.000 0.196
#> GSM110449     4  0.4097    0.40253 0.000 0.492 0.000 0.500 0.008 0.000
#> GSM110451     2  0.5117    0.48094 0.000 0.672 0.088 0.008 0.216 0.016
#> GSM110391     5  0.1605    0.91223 0.000 0.044 0.000 0.004 0.936 0.016
#> GSM110439     5  0.0363    0.95398 0.000 0.012 0.000 0.000 0.988 0.000
#> GSM110442     2  0.4098   -0.00931 0.000 0.676 0.000 0.292 0.032 0.000
#> GSM110443     2  0.3868   -0.52560 0.000 0.508 0.000 0.492 0.000 0.000
#> GSM110447     3  0.0146    0.86472 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM110448     6  0.4020    0.70673 0.276 0.000 0.000 0.032 0.000 0.692
#> GSM110450     1  0.2647    0.75503 0.868 0.000 0.000 0.088 0.000 0.044
#> GSM110452     2  0.3825    0.43921 0.000 0.768 0.000 0.072 0.160 0.000
#> GSM110453     5  0.0363    0.95398 0.000 0.012 0.000 0.000 0.988 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> CV:kmeans 52           0.9132       0.567 2
#> CV:kmeans 56           0.1033       0.405 3
#> CV:kmeans 48           0.2082       0.586 4
#> CV:kmeans 43           0.2388       0.414 5
#> CV:kmeans 37           0.0858       0.299 6

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


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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.633           0.820       0.923         0.5030 0.495   0.495
#> 3 3 0.846           0.903       0.954         0.3037 0.696   0.466
#> 4 4 0.852           0.871       0.939         0.1303 0.857   0.616
#> 5 5 0.758           0.683       0.802         0.0595 0.959   0.850
#> 6 6 0.739           0.534       0.720         0.0392 0.899   0.635

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
#> GSM110395     2   0.000      0.925 0.000 1.000
#> GSM110396     1   0.000      0.885 1.000 0.000
#> GSM110397     1   0.000      0.885 1.000 0.000
#> GSM110398     1   0.722      0.720 0.800 0.200
#> GSM110399     1   0.971      0.468 0.600 0.400
#> GSM110400     2   0.000      0.925 0.000 1.000
#> GSM110401     1   0.000      0.885 1.000 0.000
#> GSM110406     1   0.971      0.468 0.600 0.400
#> GSM110407     1   0.000      0.885 1.000 0.000
#> GSM110409     1   0.000      0.885 1.000 0.000
#> GSM110410     2   0.000      0.925 0.000 1.000
#> GSM110413     2   0.000      0.925 0.000 1.000
#> GSM110414     2   0.000      0.925 0.000 1.000
#> GSM110415     2   0.722      0.719 0.200 0.800
#> GSM110416     2   0.971      0.399 0.400 0.600
#> GSM110418     2   0.971      0.399 0.400 0.600
#> GSM110419     2   0.644      0.763 0.164 0.836
#> GSM110420     2   0.971      0.399 0.400 0.600
#> GSM110421     2   0.000      0.925 0.000 1.000
#> GSM110423     2   0.000      0.925 0.000 1.000
#> GSM110424     2   0.000      0.925 0.000 1.000
#> GSM110425     2   0.000      0.925 0.000 1.000
#> GSM110427     2   0.000      0.925 0.000 1.000
#> GSM110428     1   0.000      0.885 1.000 0.000
#> GSM110430     1   0.000      0.885 1.000 0.000
#> GSM110431     1   0.000      0.885 1.000 0.000
#> GSM110432     2   0.000      0.925 0.000 1.000
#> GSM110434     2   0.000      0.925 0.000 1.000
#> GSM110435     1   0.000      0.885 1.000 0.000
#> GSM110437     1   0.000      0.885 1.000 0.000
#> GSM110438     1   0.000      0.885 1.000 0.000
#> GSM110388     1   0.000      0.885 1.000 0.000
#> GSM110392     1   0.971      0.468 0.600 0.400
#> GSM110394     1   0.000      0.885 1.000 0.000
#> GSM110402     2   0.000      0.925 0.000 1.000
#> GSM110411     1   0.000      0.885 1.000 0.000
#> GSM110412     2   0.000      0.925 0.000 1.000
#> GSM110417     1   0.000      0.885 1.000 0.000
#> GSM110422     2   0.000      0.925 0.000 1.000
#> GSM110426     1   0.000      0.885 1.000 0.000
#> GSM110429     2   0.000      0.925 0.000 1.000
#> GSM110433     2   0.000      0.925 0.000 1.000
#> GSM110436     2   0.000      0.925 0.000 1.000
#> GSM110440     1   0.000      0.885 1.000 0.000
#> GSM110441     2   0.000      0.925 0.000 1.000
#> GSM110444     1   0.971      0.468 0.600 0.400
#> GSM110445     1   0.000      0.885 1.000 0.000
#> GSM110446     2   0.971      0.399 0.400 0.600
#> GSM110449     1   0.971      0.468 0.600 0.400
#> GSM110451     2   0.000      0.925 0.000 1.000
#> GSM110391     2   0.000      0.925 0.000 1.000
#> GSM110439     2   0.000      0.925 0.000 1.000
#> GSM110442     2   0.000      0.925 0.000 1.000
#> GSM110443     1   0.971      0.468 0.600 0.400
#> GSM110447     2   0.000      0.925 0.000 1.000
#> GSM110448     1   0.000      0.885 1.000 0.000
#> GSM110450     1   0.000      0.885 1.000 0.000
#> GSM110452     2   0.000      0.925 0.000 1.000
#> GSM110453     2   0.000      0.925 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110396     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110397     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110398     1  0.4834      0.710 0.792 0.204 0.004
#> GSM110399     2  0.4784      0.762 0.200 0.796 0.004
#> GSM110400     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110401     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110406     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110407     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110409     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110410     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110413     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110414     3  0.0592      0.899 0.000 0.012 0.988
#> GSM110415     3  0.0237      0.901 0.004 0.000 0.996
#> GSM110416     3  0.1529      0.888 0.040 0.000 0.960
#> GSM110418     3  0.4399      0.796 0.188 0.000 0.812
#> GSM110419     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110420     3  0.4555      0.786 0.200 0.000 0.800
#> GSM110421     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110423     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110424     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110425     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110427     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110428     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110430     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110431     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110432     3  0.3752      0.788 0.000 0.144 0.856
#> GSM110434     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110435     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110437     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110438     3  0.6291      0.252 0.468 0.000 0.532
#> GSM110388     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110392     2  0.1170      0.935 0.016 0.976 0.008
#> GSM110394     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110402     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110411     1  0.2301      0.909 0.936 0.060 0.004
#> GSM110412     2  0.1529      0.922 0.000 0.960 0.040
#> GSM110417     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110426     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110429     2  0.1411      0.925 0.000 0.964 0.036
#> GSM110433     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110436     2  0.1411      0.925 0.000 0.964 0.036
#> GSM110440     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110441     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110444     2  0.6228      0.446 0.372 0.624 0.004
#> GSM110445     1  0.0237      0.977 0.996 0.000 0.004
#> GSM110446     3  0.4555      0.786 0.200 0.000 0.800
#> GSM110449     2  0.4733      0.767 0.196 0.800 0.004
#> GSM110451     2  0.1411      0.925 0.000 0.964 0.036
#> GSM110391     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110439     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110442     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110443     2  0.4931      0.747 0.212 0.784 0.004
#> GSM110447     3  0.0237      0.902 0.000 0.004 0.996
#> GSM110448     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110450     1  0.0000      0.981 1.000 0.000 0.000
#> GSM110452     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110453     2  0.0000      0.945 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0188     0.9036 0.000 0.996 0.000 0.004
#> GSM110396     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110397     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110398     4  0.1004     0.9134 0.004 0.024 0.000 0.972
#> GSM110399     4  0.1118     0.9177 0.000 0.036 0.000 0.964
#> GSM110400     3  0.1452     0.9038 0.000 0.036 0.956 0.008
#> GSM110401     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110406     4  0.1118     0.9177 0.000 0.036 0.000 0.964
#> GSM110407     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110409     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110410     2  0.0000     0.9039 0.000 1.000 0.000 0.000
#> GSM110413     2  0.4522     0.5345 0.000 0.680 0.000 0.320
#> GSM110414     3  0.2737     0.8416 0.000 0.104 0.888 0.008
#> GSM110415     3  0.0000     0.9242 0.000 0.000 1.000 0.000
#> GSM110416     3  0.0657     0.9209 0.004 0.000 0.984 0.012
#> GSM110418     3  0.3105     0.8504 0.120 0.000 0.868 0.012
#> GSM110419     3  0.0188     0.9233 0.000 0.000 0.996 0.004
#> GSM110420     3  0.3852     0.8022 0.180 0.000 0.808 0.012
#> GSM110421     2  0.0921     0.8933 0.000 0.972 0.000 0.028
#> GSM110423     3  0.0336     0.9249 0.000 0.000 0.992 0.008
#> GSM110424     2  0.0000     0.9039 0.000 1.000 0.000 0.000
#> GSM110425     3  0.0336     0.9249 0.000 0.000 0.992 0.008
#> GSM110427     2  0.0188     0.9036 0.000 0.996 0.000 0.004
#> GSM110428     1  0.0779     0.9622 0.980 0.000 0.004 0.016
#> GSM110430     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110431     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110432     2  0.5268     0.3176 0.000 0.592 0.396 0.012
#> GSM110434     2  0.3266     0.7700 0.000 0.832 0.000 0.168
#> GSM110435     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110437     1  0.0336     0.9719 0.992 0.000 0.000 0.008
#> GSM110438     1  0.5075     0.4178 0.644 0.000 0.344 0.012
#> GSM110388     1  0.0188     0.9714 0.996 0.000 0.000 0.004
#> GSM110392     4  0.4250     0.6156 0.000 0.276 0.000 0.724
#> GSM110394     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110402     3  0.0336     0.9249 0.000 0.000 0.992 0.008
#> GSM110411     4  0.1118     0.8913 0.036 0.000 0.000 0.964
#> GSM110412     2  0.0779     0.8967 0.000 0.980 0.004 0.016
#> GSM110417     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110422     2  0.0188     0.9036 0.000 0.996 0.000 0.004
#> GSM110426     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110429     2  0.0657     0.9001 0.000 0.984 0.004 0.012
#> GSM110433     2  0.0000     0.9039 0.000 1.000 0.000 0.000
#> GSM110436     2  0.0657     0.9001 0.000 0.984 0.004 0.012
#> GSM110440     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110441     2  0.1211     0.8862 0.000 0.960 0.000 0.040
#> GSM110444     4  0.2466     0.8811 0.004 0.096 0.000 0.900
#> GSM110445     4  0.2973     0.7944 0.144 0.000 0.000 0.856
#> GSM110446     3  0.3852     0.8022 0.180 0.000 0.808 0.012
#> GSM110449     4  0.1118     0.9166 0.000 0.036 0.000 0.964
#> GSM110451     2  0.0657     0.9001 0.000 0.984 0.004 0.012
#> GSM110391     2  0.0336     0.9016 0.000 0.992 0.000 0.008
#> GSM110439     2  0.0000     0.9039 0.000 1.000 0.000 0.000
#> GSM110442     2  0.4989     0.0872 0.000 0.528 0.000 0.472
#> GSM110443     4  0.1637     0.9091 0.000 0.060 0.000 0.940
#> GSM110447     3  0.0336     0.9249 0.000 0.000 0.992 0.008
#> GSM110448     1  0.0000     0.9728 1.000 0.000 0.000 0.000
#> GSM110450     1  0.0592     0.9665 0.984 0.000 0.000 0.016
#> GSM110452     2  0.2814     0.8081 0.000 0.868 0.000 0.132
#> GSM110453     2  0.0000     0.9039 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.4125      0.686 0.000 0.772 0.000 0.172 0.056
#> GSM110396     1  0.1544      0.833 0.932 0.000 0.000 0.000 0.068
#> GSM110397     1  0.2389      0.812 0.880 0.000 0.000 0.116 0.004
#> GSM110398     5  0.2756      0.671 0.060 0.012 0.000 0.036 0.892
#> GSM110399     5  0.1862      0.710 0.004 0.048 0.000 0.016 0.932
#> GSM110400     3  0.0566      0.891 0.000 0.004 0.984 0.012 0.000
#> GSM110401     1  0.1544      0.833 0.932 0.000 0.000 0.000 0.068
#> GSM110406     5  0.2349      0.706 0.004 0.084 0.000 0.012 0.900
#> GSM110407     1  0.1704      0.834 0.928 0.000 0.000 0.004 0.068
#> GSM110409     1  0.1704      0.834 0.928 0.000 0.000 0.004 0.068
#> GSM110410     2  0.3913      0.696 0.000 0.676 0.000 0.324 0.000
#> GSM110413     2  0.6674      0.417 0.000 0.436 0.000 0.260 0.304
#> GSM110414     3  0.1012      0.880 0.000 0.020 0.968 0.012 0.000
#> GSM110415     3  0.1410      0.892 0.000 0.000 0.940 0.060 0.000
#> GSM110416     3  0.3010      0.834 0.004 0.000 0.824 0.172 0.000
#> GSM110418     3  0.3527      0.820 0.024 0.000 0.804 0.172 0.000
#> GSM110419     3  0.1410      0.892 0.000 0.000 0.940 0.060 0.000
#> GSM110420     3  0.3810      0.806 0.040 0.000 0.792 0.168 0.000
#> GSM110421     2  0.5434      0.652 0.000 0.588 0.000 0.336 0.076
#> GSM110423     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> GSM110424     2  0.3932      0.694 0.000 0.672 0.000 0.328 0.000
#> GSM110425     3  0.0000      0.898 0.000 0.000 1.000 0.000 0.000
#> GSM110427     2  0.0000      0.675 0.000 1.000 0.000 0.000 0.000
#> GSM110428     1  0.3317      0.720 0.840 0.000 0.000 0.116 0.044
#> GSM110430     1  0.1478      0.836 0.936 0.000 0.000 0.000 0.064
#> GSM110431     1  0.1908      0.827 0.908 0.000 0.000 0.092 0.000
#> GSM110432     2  0.4552      0.430 0.000 0.696 0.264 0.040 0.000
#> GSM110434     2  0.4024      0.522 0.000 0.752 0.000 0.028 0.220
#> GSM110435     1  0.2127      0.820 0.892 0.000 0.000 0.108 0.000
#> GSM110437     1  0.1478      0.836 0.936 0.000 0.000 0.000 0.064
#> GSM110438     4  0.6794      0.000 0.336 0.000 0.164 0.480 0.020
#> GSM110388     1  0.3764      0.728 0.800 0.000 0.000 0.156 0.044
#> GSM110392     2  0.7645     -0.189 0.008 0.340 0.028 0.336 0.288
#> GSM110394     1  0.1502      0.835 0.940 0.000 0.000 0.056 0.004
#> GSM110402     3  0.0162      0.898 0.000 0.000 0.996 0.004 0.000
#> GSM110411     5  0.4756      0.508 0.044 0.000 0.000 0.288 0.668
#> GSM110412     2  0.6092      0.395 0.000 0.480 0.044 0.436 0.040
#> GSM110417     1  0.2674      0.792 0.856 0.000 0.000 0.140 0.004
#> GSM110422     2  0.0609      0.670 0.000 0.980 0.000 0.020 0.000
#> GSM110426     1  0.2629      0.795 0.860 0.000 0.000 0.136 0.004
#> GSM110429     2  0.1981      0.651 0.000 0.924 0.048 0.028 0.000
#> GSM110433     2  0.3999      0.690 0.000 0.656 0.000 0.344 0.000
#> GSM110436     2  0.1907      0.653 0.000 0.928 0.044 0.028 0.000
#> GSM110440     1  0.2074      0.822 0.896 0.000 0.000 0.104 0.000
#> GSM110441     2  0.5815      0.631 0.000 0.540 0.000 0.356 0.104
#> GSM110444     5  0.6203      0.463 0.032 0.072 0.000 0.352 0.544
#> GSM110445     5  0.4118      0.276 0.336 0.000 0.000 0.004 0.660
#> GSM110446     3  0.3944      0.795 0.052 0.000 0.788 0.160 0.000
#> GSM110449     5  0.1626      0.705 0.000 0.016 0.000 0.044 0.940
#> GSM110451     2  0.1915      0.654 0.000 0.928 0.040 0.032 0.000
#> GSM110391     2  0.4030      0.688 0.000 0.648 0.000 0.352 0.000
#> GSM110439     2  0.3857      0.699 0.000 0.688 0.000 0.312 0.000
#> GSM110442     5  0.6267     -0.168 0.000 0.404 0.000 0.148 0.448
#> GSM110443     5  0.2784      0.701 0.004 0.108 0.000 0.016 0.872
#> GSM110447     3  0.0162      0.896 0.000 0.000 0.996 0.004 0.000
#> GSM110448     1  0.2964      0.801 0.856 0.000 0.000 0.120 0.024
#> GSM110450     1  0.1608      0.830 0.928 0.000 0.000 0.000 0.072
#> GSM110452     2  0.4210      0.527 0.000 0.740 0.000 0.036 0.224
#> GSM110453     2  0.3895      0.697 0.000 0.680 0.000 0.320 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
#> GSM110395     2  0.4927     0.2919 0.000 0.648 0.000 0.104 0.244 0.004
#> GSM110396     1  0.0146     0.7186 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110397     1  0.3986     0.6123 0.608 0.000 0.000 0.004 0.004 0.384
#> GSM110398     4  0.4597     0.4772 0.168 0.000 0.000 0.732 0.036 0.064
#> GSM110399     4  0.1816     0.6725 0.048 0.004 0.000 0.928 0.016 0.004
#> GSM110400     3  0.1219     0.8667 0.000 0.048 0.948 0.000 0.000 0.004
#> GSM110401     1  0.0405     0.7175 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM110406     4  0.3250     0.6853 0.052 0.048 0.000 0.860 0.028 0.012
#> GSM110407     1  0.0405     0.7175 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM110409     1  0.0405     0.7175 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM110410     5  0.4456     0.3253 0.000 0.448 0.000 0.028 0.524 0.000
#> GSM110413     4  0.6330    -0.0459 0.000 0.252 0.000 0.440 0.292 0.016
#> GSM110414     3  0.1141     0.8584 0.000 0.052 0.948 0.000 0.000 0.000
#> GSM110415     3  0.1267     0.8754 0.000 0.000 0.940 0.000 0.000 0.060
#> GSM110416     3  0.3109     0.7941 0.000 0.000 0.772 0.000 0.004 0.224
#> GSM110418     3  0.3276     0.7880 0.004 0.000 0.764 0.000 0.004 0.228
#> GSM110419     3  0.0858     0.8806 0.000 0.000 0.968 0.000 0.004 0.028
#> GSM110420     3  0.3384     0.7854 0.008 0.000 0.760 0.000 0.004 0.228
#> GSM110421     5  0.6116     0.2769 0.000 0.312 0.000 0.136 0.516 0.036
#> GSM110423     3  0.0146     0.8811 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM110424     5  0.4509     0.3374 0.000 0.436 0.000 0.032 0.532 0.000
#> GSM110425     3  0.0260     0.8810 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM110427     2  0.1461     0.6837 0.000 0.940 0.000 0.016 0.044 0.000
#> GSM110428     1  0.2378     0.6437 0.848 0.000 0.000 0.000 0.000 0.152
#> GSM110430     1  0.0291     0.7185 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM110431     1  0.3390     0.6677 0.704 0.000 0.000 0.000 0.000 0.296
#> GSM110432     2  0.3002     0.5873 0.000 0.836 0.136 0.000 0.008 0.020
#> GSM110434     2  0.5218     0.4264 0.000 0.592 0.000 0.312 0.084 0.012
#> GSM110435     1  0.3819     0.6259 0.624 0.000 0.000 0.000 0.004 0.372
#> GSM110437     1  0.0405     0.7175 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM110438     6  0.5303     0.0000 0.076 0.004 0.080 0.016 0.100 0.724
#> GSM110388     1  0.4876     0.5471 0.596 0.000 0.000 0.036 0.020 0.348
#> GSM110392     5  0.7670    -0.2741 0.004 0.164 0.012 0.136 0.372 0.312
#> GSM110394     1  0.2823     0.6963 0.796 0.000 0.000 0.000 0.000 0.204
#> GSM110402     3  0.0291     0.8819 0.000 0.004 0.992 0.000 0.000 0.004
#> GSM110411     5  0.7010    -0.3168 0.068 0.000 0.000 0.320 0.376 0.236
#> GSM110412     5  0.6474    -0.1394 0.000 0.236 0.008 0.028 0.504 0.224
#> GSM110417     1  0.4006     0.6026 0.600 0.000 0.000 0.004 0.004 0.392
#> GSM110422     2  0.0862     0.7079 0.000 0.972 0.000 0.016 0.008 0.004
#> GSM110426     1  0.4006     0.6034 0.600 0.000 0.000 0.004 0.004 0.392
#> GSM110429     2  0.1003     0.7156 0.000 0.964 0.028 0.000 0.004 0.004
#> GSM110433     5  0.4830     0.3521 0.000 0.412 0.000 0.040 0.540 0.008
#> GSM110436     2  0.1116     0.7161 0.000 0.960 0.028 0.000 0.008 0.004
#> GSM110440     1  0.3782     0.6350 0.636 0.000 0.000 0.000 0.004 0.360
#> GSM110441     5  0.5313     0.3354 0.000 0.324 0.000 0.124 0.552 0.000
#> GSM110444     5  0.6432    -0.2784 0.016 0.004 0.000 0.268 0.448 0.264
#> GSM110445     1  0.4962    -0.1212 0.488 0.000 0.000 0.460 0.012 0.040
#> GSM110446     3  0.3599     0.7800 0.020 0.000 0.756 0.000 0.004 0.220
#> GSM110449     4  0.1757     0.6667 0.008 0.000 0.000 0.928 0.052 0.012
#> GSM110451     2  0.0993     0.7148 0.000 0.964 0.024 0.000 0.000 0.012
#> GSM110391     5  0.5072     0.3597 0.000 0.372 0.000 0.064 0.556 0.008
#> GSM110439     5  0.4591     0.2954 0.000 0.464 0.000 0.036 0.500 0.000
#> GSM110442     4  0.6119     0.2255 0.000 0.256 0.000 0.524 0.196 0.024
#> GSM110443     4  0.3704     0.6786 0.064 0.036 0.000 0.836 0.040 0.024
#> GSM110447     3  0.0260     0.8810 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM110448     1  0.4153     0.6249 0.640 0.000 0.000 0.012 0.008 0.340
#> GSM110450     1  0.0508     0.7155 0.984 0.000 0.000 0.004 0.000 0.012
#> GSM110452     2  0.5223     0.3949 0.000 0.576 0.000 0.328 0.088 0.008
#> GSM110453     5  0.4589     0.3028 0.000 0.460 0.000 0.036 0.504 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> CV:skmeans 49           0.8363       0.468 2
#> CV:skmeans 57           0.0697       0.262 3
#> CV:skmeans 56           0.1477       0.697 4
#> CV:skmeans 51           0.2531       0.628 5
#> CV:skmeans 39           0.3859       0.632 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.802           0.905       0.962         0.4621 0.544   0.544
#> 3 3 0.682           0.813       0.901         0.3590 0.820   0.669
#> 4 4 0.662           0.700       0.855         0.0809 0.879   0.707
#> 5 5 0.636           0.623       0.762         0.1228 0.845   0.572
#> 6 6 0.702           0.760       0.845         0.0600 0.926   0.689

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
#> GSM110395     2   0.000     0.9593 0.000 1.000
#> GSM110396     1   0.000     0.9524 1.000 0.000
#> GSM110397     1   0.000     0.9524 1.000 0.000
#> GSM110398     1   0.714     0.7465 0.804 0.196
#> GSM110399     2   0.000     0.9593 0.000 1.000
#> GSM110400     2   0.000     0.9593 0.000 1.000
#> GSM110401     1   0.000     0.9524 1.000 0.000
#> GSM110406     2   0.204     0.9324 0.032 0.968
#> GSM110407     1   0.000     0.9524 1.000 0.000
#> GSM110409     1   0.000     0.9524 1.000 0.000
#> GSM110410     2   0.000     0.9593 0.000 1.000
#> GSM110413     2   0.000     0.9593 0.000 1.000
#> GSM110414     2   0.000     0.9593 0.000 1.000
#> GSM110415     2   0.000     0.9593 0.000 1.000
#> GSM110416     2   0.722     0.7518 0.200 0.800
#> GSM110418     2   0.722     0.7518 0.200 0.800
#> GSM110419     2   0.000     0.9593 0.000 1.000
#> GSM110420     2   0.753     0.7303 0.216 0.784
#> GSM110421     2   0.000     0.9593 0.000 1.000
#> GSM110423     2   0.000     0.9593 0.000 1.000
#> GSM110424     2   0.000     0.9593 0.000 1.000
#> GSM110425     2   0.000     0.9593 0.000 1.000
#> GSM110427     2   0.000     0.9593 0.000 1.000
#> GSM110428     1   0.985     0.1904 0.572 0.428
#> GSM110430     1   0.000     0.9524 1.000 0.000
#> GSM110431     1   0.000     0.9524 1.000 0.000
#> GSM110432     2   0.000     0.9593 0.000 1.000
#> GSM110434     2   0.000     0.9593 0.000 1.000
#> GSM110435     1   0.000     0.9524 1.000 0.000
#> GSM110437     1   0.000     0.9524 1.000 0.000
#> GSM110438     2   0.494     0.8580 0.108 0.892
#> GSM110388     1   0.000     0.9524 1.000 0.000
#> GSM110392     2   0.000     0.9593 0.000 1.000
#> GSM110394     1   0.000     0.9524 1.000 0.000
#> GSM110402     2   0.000     0.9593 0.000 1.000
#> GSM110411     1   0.738     0.7302 0.792 0.208
#> GSM110412     2   0.000     0.9593 0.000 1.000
#> GSM110417     1   0.000     0.9524 1.000 0.000
#> GSM110422     2   0.000     0.9593 0.000 1.000
#> GSM110426     1   0.000     0.9524 1.000 0.000
#> GSM110429     2   0.000     0.9593 0.000 1.000
#> GSM110433     2   0.000     0.9593 0.000 1.000
#> GSM110436     2   0.000     0.9593 0.000 1.000
#> GSM110440     1   0.000     0.9524 1.000 0.000
#> GSM110441     2   0.000     0.9593 0.000 1.000
#> GSM110444     2   0.000     0.9593 0.000 1.000
#> GSM110445     1   0.000     0.9524 1.000 0.000
#> GSM110446     2   0.722     0.7518 0.200 0.800
#> GSM110449     2   0.995     0.0761 0.460 0.540
#> GSM110451     2   0.000     0.9593 0.000 1.000
#> GSM110391     2   0.000     0.9593 0.000 1.000
#> GSM110439     2   0.000     0.9593 0.000 1.000
#> GSM110442     2   0.000     0.9593 0.000 1.000
#> GSM110443     2   0.000     0.9593 0.000 1.000
#> GSM110447     2   0.000     0.9593 0.000 1.000
#> GSM110448     1   0.000     0.9524 1.000 0.000
#> GSM110450     1   0.000     0.9524 1.000 0.000
#> GSM110452     2   0.000     0.9593 0.000 1.000
#> GSM110453     2   0.000     0.9593 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
#> GSM110395     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110396     1  0.0237     0.9140 0.996 0.000 0.004
#> GSM110397     1  0.1031     0.9124 0.976 0.000 0.024
#> GSM110398     1  0.5277     0.6893 0.796 0.180 0.024
#> GSM110399     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110400     2  0.6308    -0.2419 0.000 0.508 0.492
#> GSM110401     1  0.0237     0.9136 0.996 0.000 0.004
#> GSM110406     2  0.2313     0.8825 0.032 0.944 0.024
#> GSM110407     1  0.0237     0.9140 0.996 0.000 0.004
#> GSM110409     1  0.0000     0.9136 1.000 0.000 0.000
#> GSM110410     2  0.3116     0.8439 0.000 0.892 0.108
#> GSM110413     2  0.0424     0.9017 0.000 0.992 0.008
#> GSM110414     3  0.6008     0.5570 0.000 0.372 0.628
#> GSM110415     3  0.3619     0.8362 0.000 0.136 0.864
#> GSM110416     3  0.3619     0.7641 0.136 0.000 0.864
#> GSM110418     3  0.3619     0.7641 0.136 0.000 0.864
#> GSM110419     3  0.3941     0.8370 0.000 0.156 0.844
#> GSM110420     3  0.3551     0.7634 0.132 0.000 0.868
#> GSM110421     2  0.0000     0.9042 0.000 1.000 0.000
#> GSM110423     3  0.4121     0.8329 0.000 0.168 0.832
#> GSM110424     2  0.3116     0.8439 0.000 0.892 0.108
#> GSM110425     3  0.4235     0.8268 0.000 0.176 0.824
#> GSM110427     2  0.0000     0.9042 0.000 1.000 0.000
#> GSM110428     1  0.8138     0.0361 0.480 0.452 0.068
#> GSM110430     1  0.0000     0.9136 1.000 0.000 0.000
#> GSM110431     1  0.1031     0.9124 0.976 0.000 0.024
#> GSM110432     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110434     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110435     1  0.2878     0.8744 0.904 0.000 0.096
#> GSM110437     1  0.0237     0.9136 0.996 0.000 0.004
#> GSM110438     2  0.5625     0.7324 0.116 0.808 0.076
#> GSM110388     1  0.1643     0.9014 0.956 0.000 0.044
#> GSM110392     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110394     1  0.1163     0.9121 0.972 0.000 0.028
#> GSM110402     3  0.4062     0.8351 0.000 0.164 0.836
#> GSM110411     1  0.5633     0.6511 0.768 0.208 0.024
#> GSM110412     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110417     1  0.1031     0.9124 0.976 0.000 0.024
#> GSM110422     2  0.0000     0.9042 0.000 1.000 0.000
#> GSM110426     1  0.1643     0.9088 0.956 0.000 0.044
#> GSM110429     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110433     2  0.3116     0.8439 0.000 0.892 0.108
#> GSM110436     2  0.0000     0.9042 0.000 1.000 0.000
#> GSM110440     1  0.2356     0.8951 0.928 0.000 0.072
#> GSM110441     2  0.1860     0.8807 0.000 0.948 0.052
#> GSM110444     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110445     1  0.1031     0.9011 0.976 0.000 0.024
#> GSM110446     3  0.3619     0.7641 0.136 0.000 0.864
#> GSM110449     2  0.7174     0.0507 0.460 0.516 0.024
#> GSM110451     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110391     2  0.1289     0.8912 0.000 0.968 0.032
#> GSM110439     2  0.3116     0.8439 0.000 0.892 0.108
#> GSM110442     2  0.0892     0.9050 0.000 0.980 0.020
#> GSM110443     2  0.1031     0.9048 0.000 0.976 0.024
#> GSM110447     3  0.5882     0.6055 0.000 0.348 0.652
#> GSM110448     1  0.1753     0.9057 0.952 0.000 0.048
#> GSM110450     1  0.0592     0.9093 0.988 0.000 0.012
#> GSM110452     2  0.0000     0.9042 0.000 1.000 0.000
#> GSM110453     2  0.3116     0.8439 0.000 0.892 0.108

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0469     0.8601 0.000 0.988 0.012 0.000
#> GSM110396     4  0.5000     0.2839 0.496 0.000 0.000 0.504
#> GSM110397     1  0.4585     0.4230 0.668 0.000 0.000 0.332
#> GSM110398     2  0.6014     0.0460 0.020 0.488 0.012 0.480
#> GSM110399     2  0.0657     0.8602 0.004 0.984 0.012 0.000
#> GSM110400     2  0.4994    -0.1714 0.000 0.520 0.480 0.000
#> GSM110401     1  0.0188     0.7997 0.996 0.000 0.000 0.004
#> GSM110406     2  0.1488     0.8450 0.000 0.956 0.012 0.032
#> GSM110407     4  0.4998     0.3018 0.488 0.000 0.000 0.512
#> GSM110409     1  0.4996    -0.4025 0.516 0.000 0.000 0.484
#> GSM110410     2  0.4057     0.7651 0.000 0.812 0.028 0.160
#> GSM110413     2  0.0469     0.8585 0.000 0.988 0.000 0.012
#> GSM110414     3  0.5543     0.5250 0.000 0.360 0.612 0.028
#> GSM110415     3  0.0921     0.7996 0.000 0.028 0.972 0.000
#> GSM110416     3  0.1211     0.7834 0.000 0.000 0.960 0.040
#> GSM110418     3  0.1211     0.7834 0.000 0.000 0.960 0.040
#> GSM110419     3  0.2149     0.8090 0.000 0.088 0.912 0.000
#> GSM110420     3  0.1211     0.7834 0.000 0.000 0.960 0.040
#> GSM110421     2  0.0188     0.8600 0.000 0.996 0.000 0.004
#> GSM110423     3  0.3356     0.7758 0.000 0.176 0.824 0.000
#> GSM110424     2  0.4057     0.7651 0.000 0.812 0.028 0.160
#> GSM110425     3  0.3486     0.7670 0.000 0.188 0.812 0.000
#> GSM110427     2  0.0000     0.8602 0.000 1.000 0.000 0.000
#> GSM110428     2  0.5941     0.6409 0.008 0.712 0.172 0.108
#> GSM110430     1  0.0188     0.7997 0.996 0.000 0.000 0.004
#> GSM110431     4  0.3486     0.7167 0.188 0.000 0.000 0.812
#> GSM110432     2  0.0469     0.8601 0.000 0.988 0.012 0.000
#> GSM110434     2  0.0469     0.8601 0.000 0.988 0.012 0.000
#> GSM110435     4  0.3450     0.7506 0.008 0.000 0.156 0.836
#> GSM110437     1  0.0188     0.7997 0.996 0.000 0.000 0.004
#> GSM110438     2  0.4088     0.7371 0.008 0.808 0.172 0.012
#> GSM110388     4  0.4663     0.7532 0.064 0.000 0.148 0.788
#> GSM110392     2  0.0657     0.8598 0.000 0.984 0.012 0.004
#> GSM110394     4  0.3597     0.7520 0.148 0.000 0.016 0.836
#> GSM110402     3  0.2530     0.8052 0.000 0.112 0.888 0.000
#> GSM110411     2  0.5576     0.0825 0.004 0.500 0.012 0.484
#> GSM110412     2  0.0657     0.8598 0.000 0.984 0.012 0.004
#> GSM110417     1  0.3024     0.6945 0.852 0.000 0.000 0.148
#> GSM110422     2  0.0000     0.8602 0.000 1.000 0.000 0.000
#> GSM110426     4  0.3996     0.7745 0.104 0.000 0.060 0.836
#> GSM110429     2  0.0469     0.8601 0.000 0.988 0.012 0.000
#> GSM110433     2  0.4057     0.7651 0.000 0.812 0.028 0.160
#> GSM110436     2  0.0000     0.8602 0.000 1.000 0.000 0.000
#> GSM110440     4  0.3450     0.7506 0.008 0.000 0.156 0.836
#> GSM110441     2  0.2179     0.8330 0.000 0.924 0.012 0.064
#> GSM110444     2  0.0657     0.8598 0.000 0.984 0.012 0.004
#> GSM110445     1  0.0804     0.7916 0.980 0.000 0.008 0.012
#> GSM110446     3  0.1211     0.7834 0.000 0.000 0.960 0.040
#> GSM110449     2  0.5482     0.2878 0.004 0.572 0.012 0.412
#> GSM110451     2  0.0469     0.8601 0.000 0.988 0.012 0.000
#> GSM110391     2  0.1767     0.8417 0.000 0.944 0.012 0.044
#> GSM110439     2  0.4057     0.7651 0.000 0.812 0.028 0.160
#> GSM110442     2  0.0336     0.8606 0.000 0.992 0.008 0.000
#> GSM110443     2  0.0657     0.8598 0.000 0.984 0.012 0.004
#> GSM110447     3  0.4761     0.5348 0.000 0.372 0.628 0.000
#> GSM110448     4  0.3972     0.7777 0.080 0.000 0.080 0.840
#> GSM110450     1  0.0469     0.7956 0.988 0.000 0.000 0.012
#> GSM110452     2  0.0000     0.8602 0.000 1.000 0.000 0.000
#> GSM110453     2  0.4057     0.7651 0.000 0.812 0.028 0.160

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0290     0.7379 0.000 0.992 0.008 0.000 0.000
#> GSM110396     1  0.3274     0.6274 0.780 0.000 0.000 0.000 0.220
#> GSM110397     5  0.4138     0.5639 0.384 0.000 0.000 0.000 0.616
#> GSM110398     4  0.5883     0.5636 0.000 0.108 0.000 0.524 0.368
#> GSM110399     2  0.1830     0.6966 0.000 0.924 0.008 0.000 0.068
#> GSM110400     2  0.4305    -0.2291 0.000 0.512 0.488 0.000 0.000
#> GSM110401     1  0.0000     0.7228 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0693     0.7338 0.000 0.980 0.008 0.000 0.012
#> GSM110407     1  0.3491     0.6173 0.768 0.000 0.004 0.000 0.228
#> GSM110409     1  0.3857     0.6256 0.688 0.000 0.000 0.000 0.312
#> GSM110410     2  0.4235     0.4932 0.000 0.576 0.000 0.424 0.000
#> GSM110413     2  0.1544     0.6743 0.000 0.932 0.000 0.068 0.000
#> GSM110414     3  0.4941     0.5683 0.000 0.328 0.628 0.044 0.000
#> GSM110415     3  0.1282     0.8017 0.000 0.004 0.952 0.044 0.000
#> GSM110416     3  0.1408     0.7991 0.000 0.000 0.948 0.044 0.008
#> GSM110418     3  0.1408     0.7991 0.000 0.000 0.948 0.044 0.008
#> GSM110419     3  0.1732     0.8112 0.000 0.080 0.920 0.000 0.000
#> GSM110420     3  0.1408     0.7991 0.000 0.000 0.948 0.044 0.008
#> GSM110421     2  0.3837     0.0363 0.000 0.692 0.000 0.308 0.000
#> GSM110423     3  0.2929     0.7725 0.000 0.180 0.820 0.000 0.000
#> GSM110424     2  0.4235     0.4932 0.000 0.576 0.000 0.424 0.000
#> GSM110425     3  0.3039     0.7621 0.000 0.192 0.808 0.000 0.000
#> GSM110427     2  0.0000     0.7381 0.000 1.000 0.000 0.000 0.000
#> GSM110428     2  0.4800     0.5256 0.000 0.716 0.196 0.000 0.088
#> GSM110430     1  0.0000     0.7228 1.000 0.000 0.000 0.000 0.000
#> GSM110431     5  0.3231     0.8254 0.196 0.000 0.004 0.000 0.800
#> GSM110432     2  0.0290     0.7379 0.000 0.992 0.008 0.000 0.000
#> GSM110434     2  0.0290     0.7379 0.000 0.992 0.008 0.000 0.000
#> GSM110435     5  0.3098     0.7578 0.016 0.000 0.148 0.000 0.836
#> GSM110437     1  0.0000     0.7228 1.000 0.000 0.000 0.000 0.000
#> GSM110438     2  0.5597     0.4352 0.000 0.668 0.196 0.124 0.012
#> GSM110388     4  0.4731     0.3820 0.016 0.000 0.000 0.528 0.456
#> GSM110392     4  0.4294     0.5611 0.000 0.468 0.000 0.532 0.000
#> GSM110394     5  0.3039     0.8429 0.152 0.000 0.012 0.000 0.836
#> GSM110402     3  0.2127     0.8072 0.000 0.108 0.892 0.000 0.000
#> GSM110411     4  0.5949     0.5833 0.000 0.120 0.000 0.532 0.348
#> GSM110412     4  0.4294     0.5611 0.000 0.468 0.000 0.532 0.000
#> GSM110417     1  0.6106     0.1662 0.564 0.000 0.004 0.288 0.144
#> GSM110422     2  0.0000     0.7381 0.000 1.000 0.000 0.000 0.000
#> GSM110426     5  0.3912     0.8436 0.144 0.000 0.028 0.020 0.808
#> GSM110429     2  0.0290     0.7379 0.000 0.992 0.008 0.000 0.000
#> GSM110433     2  0.4235     0.4932 0.000 0.576 0.000 0.424 0.000
#> GSM110436     2  0.0000     0.7381 0.000 1.000 0.000 0.000 0.000
#> GSM110440     5  0.3464     0.8364 0.096 0.000 0.068 0.000 0.836
#> GSM110441     4  0.4088     0.1318 0.000 0.368 0.000 0.632 0.000
#> GSM110444     4  0.4294     0.5611 0.000 0.468 0.000 0.532 0.000
#> GSM110445     1  0.3282     0.6987 0.804 0.000 0.000 0.008 0.188
#> GSM110446     3  0.1408     0.7991 0.000 0.000 0.948 0.044 0.008
#> GSM110449     4  0.6253     0.6337 0.000 0.188 0.000 0.532 0.280
#> GSM110451     2  0.0290     0.7379 0.000 0.992 0.008 0.000 0.000
#> GSM110391     4  0.4219     0.5506 0.000 0.416 0.000 0.584 0.000
#> GSM110439     2  0.4235     0.4932 0.000 0.576 0.000 0.424 0.000
#> GSM110442     2  0.0290     0.7353 0.000 0.992 0.000 0.008 0.000
#> GSM110443     4  0.5670     0.6167 0.000 0.388 0.000 0.528 0.084
#> GSM110447     3  0.4015     0.5748 0.000 0.348 0.652 0.000 0.000
#> GSM110448     4  0.4589     0.3566 0.004 0.000 0.004 0.520 0.472
#> GSM110450     1  0.3282     0.6987 0.804 0.000 0.000 0.008 0.188
#> GSM110452     2  0.0000     0.7381 0.000 1.000 0.000 0.000 0.000
#> GSM110453     2  0.4235     0.4932 0.000 0.576 0.000 0.424 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
#> GSM110395     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110396     1  0.2454     0.7423 0.840 0.000 0.000 0.000 0.000 0.160
#> GSM110397     6  0.3076     0.7324 0.240 0.000 0.000 0.000 0.000 0.760
#> GSM110398     4  0.2420     0.7363 0.000 0.040 0.000 0.884 0.000 0.076
#> GSM110399     2  0.1444     0.8360 0.000 0.928 0.000 0.072 0.000 0.000
#> GSM110400     3  0.6126     0.4107 0.000 0.428 0.432 0.076 0.064 0.000
#> GSM110401     1  0.0000     0.7826 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110407     1  0.3266     0.6505 0.728 0.000 0.000 0.000 0.000 0.272
#> GSM110409     1  0.2474     0.7743 0.880 0.000 0.000 0.040 0.000 0.080
#> GSM110410     5  0.1814     0.9603 0.000 0.100 0.000 0.000 0.900 0.000
#> GSM110413     2  0.1524     0.8409 0.000 0.932 0.000 0.060 0.008 0.000
#> GSM110414     3  0.6861     0.6383 0.000 0.268 0.476 0.108 0.148 0.000
#> GSM110415     3  0.0000     0.7135 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110416     3  0.0000     0.7135 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000     0.7135 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     3  0.5152     0.7395 0.000 0.084 0.708 0.108 0.100 0.000
#> GSM110420     3  0.0000     0.7135 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     2  0.3659     0.1561 0.000 0.636 0.000 0.364 0.000 0.000
#> GSM110423     3  0.6080     0.7202 0.000 0.188 0.604 0.108 0.100 0.000
#> GSM110424     5  0.1814     0.9603 0.000 0.100 0.000 0.000 0.900 0.000
#> GSM110425     3  0.6155     0.7138 0.000 0.200 0.592 0.108 0.100 0.000
#> GSM110427     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110428     2  0.3925     0.6169 0.000 0.744 0.200 0.000 0.000 0.056
#> GSM110430     1  0.0000     0.7826 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     6  0.2730     0.7821 0.192 0.000 0.000 0.000 0.000 0.808
#> GSM110432     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110434     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110435     6  0.0000     0.8973 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110437     1  0.0000     0.7826 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     2  0.5100     0.4335 0.000 0.600 0.284 0.116 0.000 0.000
#> GSM110388     4  0.2070     0.6966 0.008 0.000 0.000 0.892 0.000 0.100
#> GSM110392     4  0.3446     0.7302 0.000 0.308 0.000 0.692 0.000 0.000
#> GSM110394     6  0.0000     0.8973 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110402     3  0.5201     0.7429 0.000 0.108 0.704 0.096 0.092 0.000
#> GSM110411     4  0.2308     0.7393 0.000 0.040 0.000 0.892 0.000 0.068
#> GSM110412     4  0.3482     0.7210 0.000 0.316 0.000 0.684 0.000 0.000
#> GSM110417     1  0.5779     0.0511 0.452 0.000 0.000 0.368 0.000 0.180
#> GSM110422     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110426     6  0.0547     0.8844 0.000 0.000 0.000 0.020 0.000 0.980
#> GSM110429     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110433     5  0.1814     0.9603 0.000 0.100 0.000 0.000 0.900 0.000
#> GSM110436     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110440     6  0.0000     0.8973 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110441     5  0.3161     0.7987 0.000 0.216 0.000 0.008 0.776 0.000
#> GSM110444     4  0.3446     0.7302 0.000 0.308 0.000 0.692 0.000 0.000
#> GSM110445     1  0.2933     0.7432 0.796 0.000 0.000 0.200 0.000 0.004
#> GSM110446     3  0.0000     0.7135 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110449     4  0.2199     0.7580 0.000 0.088 0.000 0.892 0.000 0.020
#> GSM110451     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110391     4  0.4517     0.7071 0.000 0.292 0.000 0.648 0.060 0.000
#> GSM110439     5  0.1814     0.9603 0.000 0.100 0.000 0.000 0.900 0.000
#> GSM110442     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110443     4  0.2883     0.7817 0.000 0.212 0.000 0.788 0.000 0.000
#> GSM110447     3  0.6590     0.6279 0.000 0.300 0.492 0.108 0.100 0.000
#> GSM110448     4  0.3482     0.5511 0.000 0.000 0.000 0.684 0.000 0.316
#> GSM110450     1  0.2933     0.7432 0.796 0.000 0.000 0.200 0.000 0.004
#> GSM110452     2  0.0000     0.9019 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110453     5  0.1814     0.9603 0.000 0.100 0.000 0.000 0.900 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) specimen(p) k
#> CV:pam 57           1.0000       0.700 2
#> CV:pam 56           0.2378       0.411 3
#> CV:pam 51           0.2754       0.801 4
#> CV:pam 47           0.0712       0.714 5
#> CV:pam 55           0.0405       0.500 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 17209 rows and 59 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 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-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.349           0.610       0.832         0.4048 0.583   0.583
#> 3 3 0.954           0.924       0.947         0.5863 0.684   0.496
#> 4 4 0.745           0.818       0.848         0.1033 0.889   0.708
#> 5 5 0.775           0.752       0.851         0.0876 0.935   0.785
#> 6 6 0.806           0.699       0.846         0.0748 0.884   0.564

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
#> GSM110395     2  0.0000    0.79185 0.000 1.000
#> GSM110396     2  0.9732    0.41526 0.404 0.596
#> GSM110397     1  0.9933   -0.00676 0.548 0.452
#> GSM110398     2  0.0376    0.79166 0.004 0.996
#> GSM110399     2  0.0000    0.79185 0.000 1.000
#> GSM110400     1  0.7602    0.68480 0.780 0.220
#> GSM110401     2  0.9732    0.41526 0.404 0.596
#> GSM110406     2  0.0376    0.79166 0.004 0.996
#> GSM110407     2  0.9732    0.41526 0.404 0.596
#> GSM110409     2  0.9732    0.41526 0.404 0.596
#> GSM110410     2  0.0938    0.78999 0.012 0.988
#> GSM110413     2  0.0000    0.79185 0.000 1.000
#> GSM110414     1  0.6712    0.70124 0.824 0.176
#> GSM110415     1  0.6887    0.70512 0.816 0.184
#> GSM110416     1  0.1414    0.67531 0.980 0.020
#> GSM110418     1  0.1414    0.67531 0.980 0.020
#> GSM110419     1  0.7219    0.69853 0.800 0.200
#> GSM110420     1  0.1414    0.67531 0.980 0.020
#> GSM110421     2  0.0376    0.79166 0.004 0.996
#> GSM110423     1  0.6887    0.70512 0.816 0.184
#> GSM110424     2  0.0938    0.78999 0.012 0.988
#> GSM110425     1  0.6887    0.70512 0.816 0.184
#> GSM110427     2  0.0672    0.79144 0.008 0.992
#> GSM110428     2  0.9732    0.41526 0.404 0.596
#> GSM110430     2  0.9732    0.41526 0.404 0.596
#> GSM110431     1  0.9963   -0.01067 0.536 0.464
#> GSM110432     2  0.7950    0.55564 0.240 0.760
#> GSM110434     2  0.0000    0.79185 0.000 1.000
#> GSM110435     1  0.9963   -0.01067 0.536 0.464
#> GSM110437     2  0.9732    0.41526 0.404 0.596
#> GSM110438     1  0.9996   -0.11121 0.512 0.488
#> GSM110388     2  0.9815    0.40474 0.420 0.580
#> GSM110392     2  0.2778    0.77049 0.048 0.952
#> GSM110394     2  0.9795    0.38591 0.416 0.584
#> GSM110402     1  0.6887    0.70512 0.816 0.184
#> GSM110411     2  0.0938    0.78999 0.012 0.988
#> GSM110412     2  0.1184    0.78982 0.016 0.984
#> GSM110417     2  0.9850    0.38583 0.428 0.572
#> GSM110422     2  0.0376    0.78924 0.004 0.996
#> GSM110426     2  0.9815    0.40474 0.420 0.580
#> GSM110429     2  0.0672    0.79144 0.008 0.992
#> GSM110433     2  0.0938    0.78999 0.012 0.988
#> GSM110436     2  0.0672    0.79144 0.008 0.992
#> GSM110440     1  0.9963   -0.01067 0.536 0.464
#> GSM110441     2  0.0000    0.79185 0.000 1.000
#> GSM110444     2  0.1414    0.78837 0.020 0.980
#> GSM110445     2  0.7376    0.64326 0.208 0.792
#> GSM110446     1  0.2236    0.67423 0.964 0.036
#> GSM110449     2  0.0938    0.78999 0.012 0.988
#> GSM110451     2  0.0672    0.79144 0.008 0.992
#> GSM110391     2  0.0938    0.78999 0.012 0.988
#> GSM110439     2  0.0000    0.79185 0.000 1.000
#> GSM110442     2  0.0000    0.79185 0.000 1.000
#> GSM110443     2  0.0000    0.79185 0.000 1.000
#> GSM110447     1  0.6887    0.70512 0.816 0.184
#> GSM110448     2  0.9815    0.40474 0.420 0.580
#> GSM110450     2  0.9686    0.42770 0.396 0.604
#> GSM110452     2  0.0000    0.79185 0.000 1.000
#> GSM110453     2  0.0000    0.79185 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
#> GSM110395     2  0.0475      0.957 0.004 0.992 0.004
#> GSM110396     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110397     1  0.1964      0.910 0.944 0.000 0.056
#> GSM110398     2  0.6140      0.206 0.404 0.596 0.000
#> GSM110399     2  0.0000      0.958 0.000 1.000 0.000
#> GSM110400     3  0.2280      0.953 0.008 0.052 0.940
#> GSM110401     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110406     2  0.0000      0.958 0.000 1.000 0.000
#> GSM110407     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110409     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110410     2  0.2297      0.941 0.036 0.944 0.020
#> GSM110413     2  0.0237      0.958 0.000 0.996 0.004
#> GSM110414     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110415     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110416     3  0.1163      0.970 0.028 0.000 0.972
#> GSM110418     3  0.1267      0.974 0.024 0.004 0.972
#> GSM110419     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110420     3  0.1753      0.960 0.048 0.000 0.952
#> GSM110421     2  0.1289      0.953 0.032 0.968 0.000
#> GSM110423     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110424     2  0.2297      0.941 0.036 0.944 0.020
#> GSM110425     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110427     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110428     1  0.5507      0.834 0.808 0.056 0.136
#> GSM110430     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110431     1  0.2173      0.915 0.944 0.008 0.048
#> GSM110432     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110434     2  0.0475      0.957 0.004 0.992 0.004
#> GSM110435     1  0.2066      0.908 0.940 0.000 0.060
#> GSM110437     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110438     1  0.5536      0.772 0.776 0.024 0.200
#> GSM110388     1  0.1267      0.911 0.972 0.004 0.024
#> GSM110392     2  0.2550      0.939 0.040 0.936 0.024
#> GSM110394     1  0.1964      0.925 0.944 0.056 0.000
#> GSM110402     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110411     1  0.5551      0.727 0.768 0.212 0.020
#> GSM110412     2  0.2550      0.939 0.040 0.936 0.024
#> GSM110417     1  0.1163      0.911 0.972 0.000 0.028
#> GSM110422     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110426     1  0.1163      0.911 0.972 0.000 0.028
#> GSM110429     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110433     2  0.1411      0.951 0.036 0.964 0.000
#> GSM110436     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110440     1  0.2066      0.908 0.940 0.000 0.060
#> GSM110441     2  0.1163      0.954 0.028 0.972 0.000
#> GSM110444     2  0.2414      0.941 0.040 0.940 0.020
#> GSM110445     1  0.4452      0.818 0.808 0.192 0.000
#> GSM110446     3  0.1163      0.970 0.028 0.000 0.972
#> GSM110449     2  0.1411      0.951 0.036 0.964 0.000
#> GSM110451     2  0.0829      0.956 0.004 0.984 0.012
#> GSM110391     2  0.2297      0.941 0.036 0.944 0.020
#> GSM110439     2  0.1411      0.951 0.036 0.964 0.000
#> GSM110442     2  0.0000      0.958 0.000 1.000 0.000
#> GSM110443     2  0.0000      0.958 0.000 1.000 0.000
#> GSM110447     3  0.1267      0.983 0.004 0.024 0.972
#> GSM110448     1  0.1267      0.911 0.972 0.004 0.024
#> GSM110450     1  0.2165      0.927 0.936 0.064 0.000
#> GSM110452     2  0.0237      0.958 0.000 0.996 0.004
#> GSM110453     2  0.0000      0.958 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4417      0.734 0.044 0.796 0.000 0.160
#> GSM110396     1  0.0376      0.896 0.992 0.004 0.000 0.004
#> GSM110397     1  0.3726      0.853 0.788 0.000 0.000 0.212
#> GSM110398     2  0.4134      0.357 0.260 0.740 0.000 0.000
#> GSM110399     2  0.1297      0.763 0.020 0.964 0.000 0.016
#> GSM110400     3  0.2632      0.900 0.048 0.008 0.916 0.028
#> GSM110401     1  0.0376      0.896 0.992 0.004 0.000 0.004
#> GSM110406     2  0.2814      0.695 0.132 0.868 0.000 0.000
#> GSM110407     1  0.0895      0.892 0.976 0.004 0.000 0.020
#> GSM110409     1  0.0895      0.892 0.976 0.004 0.000 0.020
#> GSM110410     4  0.4936      0.988 0.000 0.372 0.004 0.624
#> GSM110413     2  0.0000      0.756 0.000 1.000 0.000 0.000
#> GSM110414     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM110415     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM110416     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM110418     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM110419     3  0.0188      0.982 0.004 0.000 0.996 0.000
#> GSM110420     3  0.1576      0.943 0.004 0.000 0.948 0.048
#> GSM110421     2  0.0376      0.755 0.000 0.992 0.004 0.004
#> GSM110423     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM110424     4  0.4936      0.988 0.000 0.372 0.004 0.624
#> GSM110425     3  0.0188      0.983 0.000 0.000 0.996 0.004
#> GSM110427     2  0.4589      0.729 0.048 0.784 0.000 0.168
#> GSM110428     1  0.3027      0.865 0.888 0.004 0.088 0.020
#> GSM110430     1  0.0376      0.896 0.992 0.004 0.000 0.004
#> GSM110431     1  0.1890      0.885 0.936 0.000 0.056 0.008
#> GSM110432     2  0.6431      0.658 0.048 0.704 0.076 0.172
#> GSM110434     2  0.4017      0.744 0.044 0.828 0.000 0.128
#> GSM110435     1  0.3768      0.815 0.808 0.000 0.184 0.008
#> GSM110437     1  0.0188      0.896 0.996 0.004 0.000 0.000
#> GSM110438     2  0.7491      0.280 0.268 0.500 0.232 0.000
#> GSM110388     1  0.4323      0.847 0.776 0.020 0.000 0.204
#> GSM110392     2  0.2053      0.739 0.000 0.924 0.072 0.004
#> GSM110394     1  0.1722      0.887 0.944 0.000 0.048 0.008
#> GSM110402     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM110411     2  0.5683      0.115 0.452 0.528 0.008 0.012
#> GSM110412     2  0.2311      0.737 0.004 0.916 0.076 0.004
#> GSM110417     1  0.3726      0.853 0.788 0.000 0.000 0.212
#> GSM110422     2  0.4589      0.729 0.048 0.784 0.000 0.168
#> GSM110426     1  0.3726      0.853 0.788 0.000 0.000 0.212
#> GSM110429     2  0.6086      0.681 0.048 0.724 0.056 0.172
#> GSM110433     4  0.4936      0.988 0.000 0.372 0.004 0.624
#> GSM110436     2  0.5686      0.701 0.048 0.744 0.036 0.172
#> GSM110440     1  0.2976      0.860 0.872 0.000 0.120 0.008
#> GSM110441     2  0.0376      0.755 0.000 0.992 0.004 0.004
#> GSM110444     2  0.0895      0.753 0.000 0.976 0.020 0.004
#> GSM110445     1  0.3907      0.677 0.768 0.232 0.000 0.000
#> GSM110446     3  0.0336      0.980 0.008 0.000 0.992 0.000
#> GSM110449     2  0.0188      0.754 0.000 0.996 0.004 0.000
#> GSM110451     2  0.4814      0.725 0.048 0.776 0.004 0.172
#> GSM110391     4  0.5138      0.962 0.000 0.392 0.008 0.600
#> GSM110439     2  0.0376      0.755 0.000 0.992 0.004 0.004
#> GSM110442     2  0.0000      0.756 0.000 1.000 0.000 0.000
#> GSM110443     2  0.0000      0.756 0.000 1.000 0.000 0.000
#> GSM110447     3  0.0000      0.984 0.000 0.000 1.000 0.000
#> GSM110448     1  0.3726      0.853 0.788 0.000 0.000 0.212
#> GSM110450     1  0.1042      0.891 0.972 0.008 0.000 0.020
#> GSM110452     2  0.0707      0.761 0.000 0.980 0.000 0.020
#> GSM110453     4  0.4790      0.981 0.000 0.380 0.000 0.620

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0000      0.722 0.000 1.000 0.000 0.000 0.000
#> GSM110396     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM110397     4  0.0000      0.695 0.000 0.000 0.000 1.000 0.000
#> GSM110398     2  0.4321      0.633 0.004 0.600 0.000 0.000 0.396
#> GSM110399     2  0.2439      0.724 0.004 0.876 0.000 0.000 0.120
#> GSM110400     3  0.3109      0.721 0.000 0.200 0.800 0.000 0.000
#> GSM110401     1  0.0794      0.895 0.972 0.028 0.000 0.000 0.000
#> GSM110406     2  0.1041      0.725 0.004 0.964 0.000 0.000 0.032
#> GSM110407     1  0.1469      0.880 0.948 0.036 0.000 0.016 0.000
#> GSM110409     4  0.4958      0.496 0.400 0.032 0.000 0.568 0.000
#> GSM110410     5  0.0000      0.967 0.000 0.000 0.000 0.000 1.000
#> GSM110413     2  0.3048      0.715 0.004 0.820 0.000 0.000 0.176
#> GSM110414     3  0.0162      0.969 0.000 0.000 0.996 0.000 0.004
#> GSM110415     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110416     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110419     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110420     3  0.0880      0.943 0.000 0.000 0.968 0.032 0.000
#> GSM110421     2  0.4256      0.606 0.000 0.564 0.000 0.000 0.436
#> GSM110423     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110424     5  0.0000      0.967 0.000 0.000 0.000 0.000 1.000
#> GSM110425     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110427     2  0.0404      0.722 0.000 0.988 0.000 0.000 0.012
#> GSM110428     4  0.6202      0.424 0.356 0.148 0.000 0.496 0.000
#> GSM110430     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM110431     4  0.4390      0.500 0.428 0.004 0.000 0.568 0.000
#> GSM110432     2  0.0290      0.722 0.000 0.992 0.000 0.000 0.008
#> GSM110434     2  0.0000      0.722 0.000 1.000 0.000 0.000 0.000
#> GSM110435     4  0.5835      0.580 0.120 0.000 0.312 0.568 0.000
#> GSM110437     1  0.0000      0.897 1.000 0.000 0.000 0.000 0.000
#> GSM110438     4  0.4958      0.458 0.032 0.000 0.400 0.568 0.000
#> GSM110388     4  0.0000      0.695 0.000 0.000 0.000 1.000 0.000
#> GSM110392     2  0.4958      0.606 0.000 0.568 0.032 0.000 0.400
#> GSM110394     4  0.4390      0.500 0.428 0.004 0.000 0.568 0.000
#> GSM110402     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110411     2  0.4497      0.610 0.000 0.568 0.000 0.008 0.424
#> GSM110412     2  0.4958      0.606 0.000 0.568 0.032 0.000 0.400
#> GSM110417     4  0.0000      0.695 0.000 0.000 0.000 1.000 0.000
#> GSM110422     2  0.0404      0.722 0.000 0.988 0.000 0.000 0.012
#> GSM110426     4  0.0000      0.695 0.000 0.000 0.000 1.000 0.000
#> GSM110429     2  0.0404      0.722 0.000 0.988 0.000 0.000 0.012
#> GSM110433     5  0.0000      0.967 0.000 0.000 0.000 0.000 1.000
#> GSM110436     2  0.0404      0.722 0.000 0.988 0.000 0.000 0.012
#> GSM110440     4  0.5785      0.575 0.112 0.000 0.320 0.568 0.000
#> GSM110441     2  0.4268      0.602 0.000 0.556 0.000 0.000 0.444
#> GSM110444     2  0.4893      0.607 0.000 0.568 0.028 0.000 0.404
#> GSM110445     1  0.4229      0.409 0.704 0.020 0.000 0.000 0.276
#> GSM110446     3  0.0162      0.969 0.004 0.000 0.996 0.000 0.000
#> GSM110449     2  0.4249      0.607 0.000 0.568 0.000 0.000 0.432
#> GSM110451     2  0.0404      0.722 0.000 0.988 0.000 0.000 0.012
#> GSM110391     5  0.0000      0.967 0.000 0.000 0.000 0.000 1.000
#> GSM110439     2  0.4268      0.602 0.000 0.556 0.000 0.000 0.444
#> GSM110442     2  0.4196      0.654 0.004 0.640 0.000 0.000 0.356
#> GSM110443     2  0.3766      0.689 0.004 0.728 0.000 0.000 0.268
#> GSM110447     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000
#> GSM110448     4  0.0000      0.695 0.000 0.000 0.000 1.000 0.000
#> GSM110450     1  0.0880      0.892 0.968 0.032 0.000 0.000 0.000
#> GSM110452     2  0.1041      0.725 0.004 0.964 0.000 0.000 0.032
#> GSM110453     5  0.1851      0.860 0.000 0.088 0.000 0.000 0.912

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.2527     0.8388 0.000 0.832 0.000 0.168 0.000 0.000
#> GSM110396     1  0.0146     0.7556 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110397     6  0.0000     0.6662 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110398     4  0.0146     0.6838 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM110399     4  0.0632     0.6800 0.000 0.024 0.000 0.976 0.000 0.000
#> GSM110400     3  0.2793     0.7325 0.000 0.200 0.800 0.000 0.000 0.000
#> GSM110401     1  0.0000     0.7549 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     4  0.3563     0.3802 0.000 0.336 0.000 0.664 0.000 0.000
#> GSM110407     1  0.0146     0.7556 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110409     1  0.4603     0.1879 0.544 0.040 0.000 0.000 0.000 0.416
#> GSM110410     5  0.0713     0.9028 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM110413     4  0.1444     0.6653 0.000 0.072 0.000 0.928 0.000 0.000
#> GSM110414     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110415     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110416     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110420     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     4  0.3298     0.6542 0.000 0.008 0.000 0.756 0.236 0.000
#> GSM110423     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110424     5  0.0713     0.9028 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM110425     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110427     2  0.0937     0.9652 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM110428     6  0.6564     0.1714 0.264 0.292 0.000 0.000 0.028 0.416
#> GSM110430     1  0.0000     0.7549 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.5219     0.1473 0.516 0.040 0.000 0.000 0.028 0.416
#> GSM110432     2  0.0937     0.9652 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM110434     4  0.3843     0.0945 0.000 0.452 0.000 0.548 0.000 0.000
#> GSM110435     6  0.7215     0.3089 0.264 0.040 0.252 0.000 0.028 0.416
#> GSM110437     1  0.0000     0.7549 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     6  0.6924     0.3618 0.144 0.040 0.372 0.000 0.028 0.416
#> GSM110388     6  0.0000     0.6662 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110392     4  0.3426     0.6355 0.000 0.004 0.000 0.720 0.276 0.000
#> GSM110394     1  0.5219     0.1473 0.516 0.040 0.000 0.000 0.028 0.416
#> GSM110402     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110411     4  0.3586     0.6351 0.000 0.000 0.000 0.720 0.268 0.012
#> GSM110412     4  0.3629     0.6334 0.000 0.012 0.000 0.712 0.276 0.000
#> GSM110417     6  0.0000     0.6662 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110422     2  0.1610     0.9348 0.000 0.916 0.000 0.084 0.000 0.000
#> GSM110426     6  0.0000     0.6662 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110429     2  0.0937     0.9652 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM110433     5  0.0713     0.9028 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM110436     2  0.0937     0.9652 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM110440     6  0.7162     0.3483 0.232 0.040 0.268 0.000 0.028 0.432
#> GSM110441     4  0.3847     0.5297 0.000 0.008 0.000 0.644 0.348 0.000
#> GSM110444     4  0.3288     0.6350 0.000 0.000 0.000 0.724 0.276 0.000
#> GSM110445     4  0.3995     0.0236 0.480 0.000 0.000 0.516 0.000 0.004
#> GSM110446     3  0.0146     0.9735 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM110449     4  0.3244     0.6390 0.000 0.000 0.000 0.732 0.268 0.000
#> GSM110451     2  0.0937     0.9652 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM110391     5  0.0713     0.9028 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM110439     5  0.2794     0.8078 0.000 0.060 0.000 0.080 0.860 0.000
#> GSM110442     4  0.0146     0.6840 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM110443     4  0.0146     0.6830 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM110447     3  0.0000     0.9775 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110448     6  0.0000     0.6662 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110450     1  0.0146     0.7556 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110452     4  0.3620     0.3114 0.000 0.352 0.000 0.648 0.000 0.000
#> GSM110453     5  0.3405     0.6136 0.000 0.004 0.000 0.272 0.724 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) specimen(p) k
#> CV:mclust 41           0.0692       0.617 2
#> CV:mclust 58           0.1043       0.355 3
#> CV:mclust 56           0.2081       0.373 4
#> CV:mclust 53           0.0837       0.635 5
#> CV:mclust 48           0.0871       0.233 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.453           0.695       0.870         0.4881 0.492   0.492
#> 3 3 0.489           0.725       0.860         0.3073 0.749   0.537
#> 4 4 0.401           0.516       0.691         0.1387 0.824   0.550
#> 5 5 0.452           0.439       0.678         0.0737 0.821   0.461
#> 6 6 0.521           0.395       0.623         0.0408 0.888   0.553

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
#> GSM110395     2  0.9491      0.268 0.368 0.632
#> GSM110396     1  0.0000      0.806 1.000 0.000
#> GSM110397     1  0.0000      0.806 1.000 0.000
#> GSM110398     1  0.7376      0.707 0.792 0.208
#> GSM110399     1  0.9686      0.498 0.604 0.396
#> GSM110400     2  0.0000      0.846 0.000 1.000
#> GSM110401     1  0.0000      0.806 1.000 0.000
#> GSM110406     1  0.9710      0.491 0.600 0.400
#> GSM110407     1  0.0000      0.806 1.000 0.000
#> GSM110409     1  0.0376      0.805 0.996 0.004
#> GSM110410     2  0.0000      0.846 0.000 1.000
#> GSM110413     1  0.9896      0.398 0.560 0.440
#> GSM110414     2  0.0000      0.846 0.000 1.000
#> GSM110415     2  0.0672      0.841 0.008 0.992
#> GSM110416     2  0.7219      0.658 0.200 0.800
#> GSM110418     2  0.8955      0.509 0.312 0.688
#> GSM110419     2  0.0000      0.846 0.000 1.000
#> GSM110420     2  0.9710      0.351 0.400 0.600
#> GSM110421     2  0.9491      0.268 0.368 0.632
#> GSM110423     2  0.0000      0.846 0.000 1.000
#> GSM110424     2  0.0000      0.846 0.000 1.000
#> GSM110425     2  0.0000      0.846 0.000 1.000
#> GSM110427     2  0.0000      0.846 0.000 1.000
#> GSM110428     1  0.0000      0.806 1.000 0.000
#> GSM110430     1  0.0000      0.806 1.000 0.000
#> GSM110431     1  0.0000      0.806 1.000 0.000
#> GSM110432     2  0.7139      0.651 0.196 0.804
#> GSM110434     1  0.9866      0.419 0.568 0.432
#> GSM110435     1  0.0000      0.806 1.000 0.000
#> GSM110437     1  0.0000      0.806 1.000 0.000
#> GSM110438     1  0.1633      0.799 0.976 0.024
#> GSM110388     1  0.0376      0.805 0.996 0.004
#> GSM110392     1  0.9710      0.491 0.600 0.400
#> GSM110394     1  0.0000      0.806 1.000 0.000
#> GSM110402     2  0.0000      0.846 0.000 1.000
#> GSM110411     1  0.7219      0.713 0.800 0.200
#> GSM110412     2  0.9209      0.361 0.336 0.664
#> GSM110417     1  0.0000      0.806 1.000 0.000
#> GSM110422     2  0.3431      0.802 0.064 0.936
#> GSM110426     1  0.0000      0.806 1.000 0.000
#> GSM110429     2  0.0000      0.846 0.000 1.000
#> GSM110433     2  0.0000      0.846 0.000 1.000
#> GSM110436     2  0.0000      0.846 0.000 1.000
#> GSM110440     1  0.0000      0.806 1.000 0.000
#> GSM110441     2  0.7299      0.638 0.204 0.796
#> GSM110444     1  0.9608      0.517 0.616 0.384
#> GSM110445     1  0.7219      0.713 0.800 0.200
#> GSM110446     2  0.8327      0.580 0.264 0.736
#> GSM110449     1  0.9661      0.505 0.608 0.392
#> GSM110451     2  0.2236      0.824 0.036 0.964
#> GSM110391     2  0.0000      0.846 0.000 1.000
#> GSM110439     2  0.0000      0.846 0.000 1.000
#> GSM110442     1  0.9815      0.448 0.580 0.420
#> GSM110443     1  0.9491      0.539 0.632 0.368
#> GSM110447     2  0.0000      0.846 0.000 1.000
#> GSM110448     1  0.0000      0.806 1.000 0.000
#> GSM110450     1  0.5842      0.749 0.860 0.140
#> GSM110452     2  0.9983     -0.165 0.476 0.524
#> GSM110453     2  0.0000      0.846 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
#> GSM110395     2  0.1643      0.870 0.044 0.956 0.000
#> GSM110396     1  0.1964      0.786 0.944 0.000 0.056
#> GSM110397     3  0.6079      0.439 0.388 0.000 0.612
#> GSM110398     1  0.4178      0.784 0.828 0.172 0.000
#> GSM110399     1  0.5397      0.706 0.720 0.280 0.000
#> GSM110400     2  0.4796      0.659 0.000 0.780 0.220
#> GSM110401     1  0.1753      0.786 0.952 0.000 0.048
#> GSM110406     1  0.5291      0.721 0.732 0.268 0.000
#> GSM110407     1  0.4504      0.755 0.804 0.000 0.196
#> GSM110409     1  0.4733      0.756 0.800 0.004 0.196
#> GSM110410     2  0.0000      0.889 0.000 1.000 0.000
#> GSM110413     2  0.5024      0.662 0.220 0.776 0.004
#> GSM110414     2  0.5397      0.565 0.000 0.720 0.280
#> GSM110415     3  0.1525      0.782 0.004 0.032 0.964
#> GSM110416     3  0.0237      0.775 0.004 0.000 0.996
#> GSM110418     3  0.0000      0.776 0.000 0.000 1.000
#> GSM110419     3  0.3412      0.757 0.000 0.124 0.876
#> GSM110420     3  0.0237      0.775 0.004 0.000 0.996
#> GSM110421     2  0.0475      0.889 0.004 0.992 0.004
#> GSM110423     3  0.2537      0.777 0.000 0.080 0.920
#> GSM110424     2  0.0237      0.889 0.000 0.996 0.004
#> GSM110425     3  0.4452      0.700 0.000 0.192 0.808
#> GSM110427     2  0.0237      0.889 0.000 0.996 0.004
#> GSM110428     1  0.4555      0.753 0.800 0.000 0.200
#> GSM110430     1  0.1411      0.788 0.964 0.000 0.036
#> GSM110431     1  0.6180      0.172 0.584 0.000 0.416
#> GSM110432     2  0.3590      0.831 0.028 0.896 0.076
#> GSM110434     2  0.6168      0.135 0.412 0.588 0.000
#> GSM110435     3  0.5058      0.542 0.244 0.000 0.756
#> GSM110437     1  0.1643      0.786 0.956 0.000 0.044
#> GSM110438     3  0.7293      0.134 0.476 0.028 0.496
#> GSM110388     1  0.0237      0.788 0.996 0.000 0.004
#> GSM110392     1  0.6168      0.449 0.588 0.412 0.000
#> GSM110394     1  0.4654      0.750 0.792 0.000 0.208
#> GSM110402     3  0.3686      0.745 0.000 0.140 0.860
#> GSM110411     1  0.4110      0.787 0.844 0.152 0.004
#> GSM110412     2  0.2200      0.865 0.056 0.940 0.004
#> GSM110417     1  0.1289      0.782 0.968 0.000 0.032
#> GSM110422     2  0.0000      0.889 0.000 1.000 0.000
#> GSM110426     1  0.1289      0.783 0.968 0.000 0.032
#> GSM110429     2  0.0424      0.887 0.000 0.992 0.008
#> GSM110433     2  0.0237      0.889 0.000 0.996 0.004
#> GSM110436     2  0.0592      0.886 0.000 0.988 0.012
#> GSM110440     1  0.5835      0.546 0.660 0.000 0.340
#> GSM110441     2  0.0237      0.889 0.004 0.996 0.000
#> GSM110444     1  0.5722      0.663 0.704 0.292 0.004
#> GSM110445     1  0.4178      0.784 0.828 0.172 0.000
#> GSM110446     3  0.3879      0.719 0.152 0.000 0.848
#> GSM110449     1  0.4702      0.761 0.788 0.212 0.000
#> GSM110451     2  0.1643      0.863 0.000 0.956 0.044
#> GSM110391     2  0.0983      0.883 0.016 0.980 0.004
#> GSM110439     2  0.0000      0.889 0.000 1.000 0.000
#> GSM110442     2  0.5327      0.558 0.272 0.728 0.000
#> GSM110443     1  0.4654      0.767 0.792 0.208 0.000
#> GSM110447     3  0.6286      0.119 0.000 0.464 0.536
#> GSM110448     1  0.0000      0.787 1.000 0.000 0.000
#> GSM110450     1  0.4209      0.798 0.860 0.120 0.020
#> GSM110452     2  0.2878      0.827 0.096 0.904 0.000
#> GSM110453     2  0.0000      0.889 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4548     0.5704 0.044 0.804 0.008 0.144
#> GSM110396     1  0.1936     0.6852 0.940 0.028 0.032 0.000
#> GSM110397     1  0.5613     0.5752 0.724 0.000 0.156 0.120
#> GSM110398     1  0.4900     0.5983 0.732 0.236 0.000 0.032
#> GSM110399     1  0.5597     0.2187 0.516 0.464 0.000 0.020
#> GSM110400     3  0.7844    -0.1268 0.000 0.288 0.404 0.308
#> GSM110401     1  0.2466     0.6719 0.900 0.096 0.004 0.000
#> GSM110406     2  0.4163     0.5198 0.220 0.772 0.004 0.004
#> GSM110407     1  0.6648     0.5242 0.612 0.248 0.140 0.000
#> GSM110409     1  0.6219     0.5293 0.640 0.264 0.096 0.000
#> GSM110410     4  0.4948     0.6062 0.000 0.440 0.000 0.560
#> GSM110413     2  0.6583    -0.2506 0.084 0.528 0.000 0.388
#> GSM110414     4  0.7088     0.4746 0.000 0.228 0.204 0.568
#> GSM110415     3  0.4761     0.5764 0.000 0.000 0.628 0.372
#> GSM110416     3  0.0000     0.7153 0.000 0.000 1.000 0.000
#> GSM110418     3  0.0336     0.7150 0.000 0.000 0.992 0.008
#> GSM110419     3  0.6346     0.5614 0.000 0.152 0.656 0.192
#> GSM110420     3  0.1576     0.7036 0.004 0.000 0.948 0.048
#> GSM110421     4  0.5576     0.5005 0.020 0.444 0.000 0.536
#> GSM110423     3  0.2300     0.7120 0.000 0.064 0.920 0.016
#> GSM110424     4  0.4500     0.7365 0.000 0.316 0.000 0.684
#> GSM110425     3  0.3243     0.7044 0.000 0.088 0.876 0.036
#> GSM110427     2  0.4049     0.4087 0.000 0.780 0.008 0.212
#> GSM110428     2  0.7847    -0.0377 0.316 0.464 0.212 0.008
#> GSM110430     1  0.0524     0.6859 0.988 0.008 0.004 0.000
#> GSM110431     1  0.7754     0.0600 0.428 0.176 0.388 0.008
#> GSM110432     2  0.3158     0.5942 0.020 0.880 0.096 0.004
#> GSM110434     2  0.1940     0.6177 0.076 0.924 0.000 0.000
#> GSM110435     3  0.3908     0.5203 0.212 0.000 0.784 0.004
#> GSM110437     1  0.1191     0.6874 0.968 0.004 0.004 0.024
#> GSM110438     3  0.7818     0.4265 0.212 0.276 0.500 0.012
#> GSM110388     1  0.4699     0.6544 0.676 0.000 0.004 0.320
#> GSM110392     2  0.4071     0.6080 0.064 0.832 0.000 0.104
#> GSM110394     1  0.7474     0.4345 0.500 0.280 0.220 0.000
#> GSM110402     3  0.7020     0.3984 0.000 0.136 0.532 0.332
#> GSM110411     1  0.5624     0.6507 0.668 0.052 0.000 0.280
#> GSM110412     4  0.5449     0.5321 0.032 0.288 0.004 0.676
#> GSM110417     1  0.4770     0.6531 0.700 0.000 0.012 0.288
#> GSM110422     2  0.0927     0.6258 0.000 0.976 0.008 0.016
#> GSM110426     1  0.4720     0.6629 0.720 0.000 0.016 0.264
#> GSM110429     2  0.3088     0.6059 0.000 0.888 0.060 0.052
#> GSM110433     4  0.4304     0.7391 0.000 0.284 0.000 0.716
#> GSM110436     2  0.4046     0.5543 0.000 0.828 0.048 0.124
#> GSM110440     1  0.5642     0.6193 0.704 0.004 0.228 0.064
#> GSM110441     4  0.5384     0.7158 0.028 0.324 0.000 0.648
#> GSM110444     1  0.6785     0.5002 0.540 0.108 0.000 0.352
#> GSM110445     1  0.4018     0.6214 0.772 0.224 0.000 0.004
#> GSM110446     3  0.5138     0.6407 0.180 0.020 0.764 0.036
#> GSM110449     1  0.6970     0.4834 0.576 0.256 0.000 0.168
#> GSM110451     2  0.2761     0.6090 0.012 0.908 0.064 0.016
#> GSM110391     4  0.3688     0.7018 0.000 0.208 0.000 0.792
#> GSM110439     2  0.4790    -0.1459 0.000 0.620 0.000 0.380
#> GSM110442     2  0.4808     0.3587 0.028 0.736 0.000 0.236
#> GSM110443     2  0.4328     0.4780 0.244 0.748 0.000 0.008
#> GSM110447     3  0.6320     0.5236 0.000 0.180 0.660 0.160
#> GSM110448     1  0.4746     0.6521 0.688 0.000 0.008 0.304
#> GSM110450     1  0.4283     0.5852 0.740 0.256 0.000 0.004
#> GSM110452     2  0.2214     0.6231 0.028 0.928 0.000 0.044
#> GSM110453     2  0.4776    -0.1213 0.000 0.624 0.000 0.376

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2   0.578     0.5223 0.084 0.640 0.004 0.016 0.256
#> GSM110396     1   0.338     0.6137 0.864 0.004 0.052 0.064 0.016
#> GSM110397     4   0.614     0.4375 0.272 0.000 0.132 0.584 0.012
#> GSM110398     1   0.715     0.3320 0.460 0.324 0.000 0.180 0.036
#> GSM110399     1   0.535     0.5711 0.688 0.228 0.000 0.040 0.044
#> GSM110400     3   0.611     0.1881 0.000 0.108 0.444 0.004 0.444
#> GSM110401     1   0.249     0.6074 0.896 0.020 0.004 0.080 0.000
#> GSM110406     1   0.592     0.4238 0.600 0.256 0.000 0.004 0.140
#> GSM110407     1   0.304     0.6309 0.888 0.032 0.052 0.012 0.016
#> GSM110409     1   0.325     0.6420 0.864 0.092 0.028 0.008 0.008
#> GSM110410     2   0.468     0.3796 0.000 0.620 0.000 0.024 0.356
#> GSM110413     5   0.709     0.0540 0.340 0.240 0.000 0.016 0.404
#> GSM110414     5   0.411     0.4136 0.000 0.068 0.116 0.012 0.804
#> GSM110415     3   0.482     0.3884 0.000 0.000 0.632 0.036 0.332
#> GSM110416     3   0.215     0.5897 0.004 0.004 0.916 0.008 0.068
#> GSM110418     3   0.141     0.5868 0.000 0.008 0.948 0.044 0.000
#> GSM110419     5   0.487    -0.1692 0.000 0.024 0.436 0.000 0.540
#> GSM110420     3   0.157     0.5809 0.000 0.000 0.936 0.060 0.004
#> GSM110421     2   0.681     0.2017 0.004 0.412 0.000 0.236 0.348
#> GSM110423     3   0.428     0.5663 0.000 0.084 0.788 0.008 0.120
#> GSM110424     2   0.514     0.3971 0.000 0.624 0.000 0.060 0.316
#> GSM110425     3   0.563     0.4018 0.000 0.060 0.600 0.016 0.324
#> GSM110427     2   0.450     0.5328 0.012 0.708 0.004 0.012 0.264
#> GSM110428     1   0.827     0.3235 0.504 0.208 0.084 0.064 0.140
#> GSM110430     1   0.284     0.5800 0.868 0.000 0.004 0.112 0.016
#> GSM110431     1   0.622     0.4011 0.628 0.048 0.256 0.056 0.012
#> GSM110432     2   0.713     0.4206 0.076 0.600 0.048 0.060 0.216
#> GSM110434     2   0.540     0.4181 0.224 0.692 0.004 0.040 0.040
#> GSM110435     3   0.549    -0.2569 0.476 0.000 0.476 0.032 0.016
#> GSM110437     1   0.475     0.1645 0.636 0.004 0.004 0.340 0.016
#> GSM110438     2   0.845    -0.0412 0.052 0.376 0.212 0.312 0.048
#> GSM110388     4   0.329     0.7695 0.140 0.000 0.008 0.836 0.016
#> GSM110392     2   0.365     0.5524 0.000 0.808 0.000 0.152 0.040
#> GSM110394     1   0.510     0.5905 0.724 0.032 0.204 0.028 0.012
#> GSM110402     5   0.601     0.0257 0.000 0.092 0.384 0.008 0.516
#> GSM110411     4   0.613     0.6749 0.160 0.060 0.004 0.672 0.104
#> GSM110412     2   0.702     0.1868 0.008 0.404 0.004 0.360 0.224
#> GSM110417     4   0.293     0.7687 0.152 0.000 0.008 0.840 0.000
#> GSM110422     2   0.194     0.5953 0.020 0.924 0.000 0.000 0.056
#> GSM110426     4   0.352     0.7471 0.116 0.008 0.032 0.840 0.004
#> GSM110429     2   0.405     0.5746 0.020 0.816 0.016 0.020 0.128
#> GSM110433     5   0.413     0.3707 0.000 0.180 0.000 0.052 0.768
#> GSM110436     2   0.414     0.5461 0.008 0.776 0.008 0.020 0.188
#> GSM110440     1   0.607     0.5036 0.612 0.000 0.264 0.096 0.028
#> GSM110441     5   0.642     0.3167 0.104 0.248 0.000 0.048 0.600
#> GSM110444     4   0.655     0.5413 0.112 0.072 0.000 0.616 0.200
#> GSM110445     1   0.553     0.5841 0.696 0.180 0.000 0.092 0.032
#> GSM110446     3   0.583     0.4709 0.116 0.060 0.704 0.116 0.004
#> GSM110449     1   0.849     0.0821 0.336 0.244 0.000 0.208 0.212
#> GSM110451     2   0.643     0.4822 0.072 0.648 0.020 0.056 0.204
#> GSM110391     5   0.500     0.4200 0.004 0.092 0.000 0.196 0.708
#> GSM110439     2   0.413     0.4829 0.008 0.720 0.000 0.008 0.264
#> GSM110442     2   0.331     0.5644 0.012 0.844 0.000 0.020 0.124
#> GSM110443     2   0.398     0.5147 0.160 0.796 0.000 0.016 0.028
#> GSM110447     3   0.546     0.3152 0.000 0.048 0.552 0.008 0.392
#> GSM110448     4   0.384     0.7421 0.196 0.000 0.008 0.780 0.016
#> GSM110450     1   0.545     0.5789 0.724 0.088 0.000 0.056 0.132
#> GSM110452     2   0.271     0.5851 0.036 0.892 0.000 0.008 0.064
#> GSM110453     2   0.440     0.4082 0.004 0.648 0.000 0.008 0.340

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.6713   -0.34532 0.116 0.404 0.000 0.000 0.092 0.388
#> GSM110396     1  0.4060    0.73201 0.820 0.004 0.036 0.056 0.056 0.028
#> GSM110397     4  0.7566    0.34974 0.136 0.000 0.128 0.500 0.060 0.176
#> GSM110398     1  0.6472    0.20108 0.424 0.424 0.000 0.084 0.020 0.048
#> GSM110399     1  0.5126    0.63801 0.700 0.188 0.000 0.016 0.060 0.036
#> GSM110400     5  0.6470   -0.21521 0.000 0.028 0.376 0.000 0.392 0.204
#> GSM110401     1  0.1624    0.72501 0.936 0.000 0.000 0.044 0.012 0.008
#> GSM110406     1  0.5388    0.52168 0.664 0.104 0.000 0.008 0.028 0.196
#> GSM110407     1  0.1793    0.72158 0.932 0.000 0.016 0.004 0.008 0.040
#> GSM110409     1  0.2484    0.72618 0.904 0.044 0.016 0.004 0.008 0.024
#> GSM110410     2  0.3351    0.47819 0.000 0.800 0.000 0.000 0.160 0.040
#> GSM110413     5  0.8456    0.23025 0.144 0.212 0.000 0.076 0.316 0.252
#> GSM110414     5  0.4426    0.38499 0.000 0.096 0.044 0.000 0.764 0.096
#> GSM110415     3  0.4446    0.38772 0.000 0.000 0.588 0.020 0.384 0.008
#> GSM110416     3  0.2056    0.59820 0.000 0.000 0.904 0.004 0.080 0.012
#> GSM110418     3  0.0551    0.59539 0.000 0.000 0.984 0.004 0.004 0.008
#> GSM110419     5  0.6121   -0.00861 0.000 0.036 0.312 0.004 0.528 0.120
#> GSM110420     3  0.1096    0.58500 0.000 0.004 0.964 0.004 0.008 0.020
#> GSM110421     4  0.7323    0.11782 0.004 0.172 0.000 0.380 0.120 0.324
#> GSM110423     3  0.5262    0.52137 0.000 0.032 0.672 0.000 0.148 0.148
#> GSM110424     2  0.4632    0.38105 0.000 0.668 0.000 0.004 0.256 0.072
#> GSM110425     3  0.6600    0.23345 0.004 0.032 0.452 0.000 0.296 0.216
#> GSM110427     6  0.4883    0.24754 0.004 0.456 0.000 0.000 0.048 0.492
#> GSM110428     6  0.5761   -0.11272 0.416 0.016 0.064 0.004 0.012 0.488
#> GSM110430     1  0.2282    0.72057 0.900 0.000 0.000 0.068 0.012 0.020
#> GSM110431     1  0.5802    0.51175 0.604 0.000 0.220 0.016 0.012 0.148
#> GSM110432     6  0.6177    0.42669 0.104 0.252 0.028 0.004 0.024 0.588
#> GSM110434     2  0.4212    0.33578 0.264 0.688 0.000 0.000 0.000 0.048
#> GSM110435     1  0.5530    0.39829 0.496 0.000 0.412 0.004 0.016 0.072
#> GSM110437     1  0.5412    0.49938 0.644 0.004 0.000 0.240 0.048 0.064
#> GSM110438     6  0.8479    0.05769 0.020 0.284 0.152 0.204 0.032 0.308
#> GSM110388     4  0.3041    0.66450 0.040 0.004 0.000 0.864 0.072 0.020
#> GSM110392     2  0.5524    0.15258 0.004 0.616 0.000 0.112 0.020 0.248
#> GSM110394     1  0.4351    0.69168 0.748 0.000 0.184 0.012 0.020 0.036
#> GSM110402     5  0.4976    0.12912 0.000 0.072 0.252 0.000 0.656 0.020
#> GSM110411     4  0.4421    0.63565 0.028 0.028 0.000 0.768 0.032 0.144
#> GSM110412     4  0.5907    0.31106 0.000 0.112 0.000 0.504 0.028 0.356
#> GSM110417     4  0.2151    0.66419 0.032 0.000 0.004 0.916 0.036 0.012
#> GSM110422     2  0.4015    0.11169 0.008 0.656 0.000 0.008 0.000 0.328
#> GSM110426     4  0.2332    0.66630 0.020 0.000 0.004 0.908 0.036 0.032
#> GSM110429     2  0.4009    0.04133 0.008 0.632 0.000 0.004 0.000 0.356
#> GSM110433     5  0.6784    0.40943 0.000 0.248 0.000 0.088 0.488 0.176
#> GSM110436     6  0.4428    0.30446 0.000 0.440 0.004 0.008 0.008 0.540
#> GSM110440     1  0.6811    0.63802 0.596 0.008 0.168 0.044 0.108 0.076
#> GSM110441     5  0.6132    0.20202 0.116 0.308 0.004 0.012 0.540 0.020
#> GSM110444     4  0.4880    0.59313 0.024 0.028 0.000 0.716 0.040 0.192
#> GSM110445     1  0.5437    0.65479 0.696 0.160 0.000 0.028 0.068 0.048
#> GSM110446     3  0.7029    0.33253 0.040 0.144 0.584 0.044 0.032 0.156
#> GSM110449     2  0.7909   -0.01899 0.264 0.356 0.000 0.040 0.244 0.096
#> GSM110451     6  0.4856    0.41977 0.052 0.348 0.000 0.000 0.008 0.592
#> GSM110391     5  0.7085    0.34130 0.000 0.156 0.000 0.216 0.468 0.160
#> GSM110439     2  0.2772    0.50573 0.004 0.868 0.000 0.004 0.092 0.032
#> GSM110442     2  0.2528    0.49769 0.012 0.900 0.000 0.016 0.032 0.040
#> GSM110443     2  0.4639    0.35932 0.240 0.696 0.000 0.008 0.020 0.036
#> GSM110447     3  0.6787    0.11102 0.000 0.064 0.400 0.000 0.360 0.176
#> GSM110448     4  0.3225    0.66258 0.064 0.000 0.000 0.852 0.048 0.036
#> GSM110450     1  0.4414    0.63957 0.736 0.028 0.000 0.052 0.000 0.184
#> GSM110452     2  0.2994    0.46342 0.064 0.852 0.000 0.000 0.004 0.080
#> GSM110453     2  0.2714    0.49863 0.004 0.848 0.000 0.000 0.136 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-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) specimen(p) k
#> CV:NMF 48          1.00000      1.0000 2
#> CV:NMF 53          0.12288      0.2167 3
#> CV:NMF 44          0.24887      0.9920 4
#> CV:NMF 29          0.00535      0.4177 5
#> CV:NMF 23          0.00638      0.0558 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 17209 rows and 59 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.395           0.798       0.883         0.4553 0.544   0.544
#> 3 3 0.499           0.776       0.849         0.4312 0.745   0.548
#> 4 4 0.579           0.711       0.800         0.0981 0.964   0.895
#> 5 5 0.617           0.619       0.757         0.0779 0.905   0.703
#> 6 6 0.673           0.685       0.788         0.0611 0.932   0.712

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
#> GSM110395     2  0.5294    0.86431 0.120 0.880
#> GSM110396     1  0.4939    0.85350 0.892 0.108
#> GSM110397     1  0.2423    0.86082 0.960 0.040
#> GSM110398     2  0.0376    0.88028 0.004 0.996
#> GSM110399     2  0.1843    0.87700 0.028 0.972
#> GSM110400     2  0.5408    0.86134 0.124 0.876
#> GSM110401     1  0.1843    0.85762 0.972 0.028
#> GSM110406     2  0.1843    0.87700 0.028 0.972
#> GSM110407     1  0.2043    0.85223 0.968 0.032
#> GSM110409     1  0.7139    0.81029 0.804 0.196
#> GSM110410     2  0.0000    0.87955 0.000 1.000
#> GSM110413     2  0.0376    0.88036 0.004 0.996
#> GSM110414     2  0.1843    0.87490 0.028 0.972
#> GSM110415     2  0.5519    0.86028 0.128 0.872
#> GSM110416     2  0.6887    0.82342 0.184 0.816
#> GSM110418     2  0.6887    0.82342 0.184 0.816
#> GSM110419     2  0.6048    0.85026 0.148 0.852
#> GSM110420     2  0.9686    0.48397 0.396 0.604
#> GSM110421     2  0.0000    0.87955 0.000 1.000
#> GSM110423     2  0.5519    0.86028 0.128 0.872
#> GSM110424     2  0.0000    0.87955 0.000 1.000
#> GSM110425     2  0.6148    0.84777 0.152 0.848
#> GSM110427     2  0.5178    0.86402 0.116 0.884
#> GSM110428     1  0.6148    0.79873 0.848 0.152
#> GSM110430     1  0.1843    0.85762 0.972 0.028
#> GSM110431     1  0.5408    0.80748 0.876 0.124
#> GSM110432     2  0.6048    0.85026 0.148 0.852
#> GSM110434     2  0.0376    0.88028 0.004 0.996
#> GSM110435     1  0.4298    0.83704 0.912 0.088
#> GSM110437     1  0.1843    0.85762 0.972 0.028
#> GSM110438     1  0.9686    0.23091 0.604 0.396
#> GSM110388     1  0.9248    0.66361 0.660 0.340
#> GSM110392     2  0.9993   -0.00977 0.484 0.516
#> GSM110394     1  0.2236    0.85173 0.964 0.036
#> GSM110402     2  0.6247    0.84524 0.156 0.844
#> GSM110411     1  0.8555    0.72455 0.720 0.280
#> GSM110412     2  0.2043    0.86576 0.032 0.968
#> GSM110417     1  0.4298    0.84844 0.912 0.088
#> GSM110422     2  0.0938    0.88107 0.012 0.988
#> GSM110426     1  0.4022    0.85698 0.920 0.080
#> GSM110429     2  0.0938    0.88107 0.012 0.988
#> GSM110433     2  0.0000    0.87955 0.000 1.000
#> GSM110436     2  0.5408    0.86134 0.124 0.876
#> GSM110440     1  0.4022    0.85548 0.920 0.080
#> GSM110441     2  0.0000    0.87955 0.000 1.000
#> GSM110444     1  0.8555    0.72455 0.720 0.280
#> GSM110445     2  0.9710    0.33490 0.400 0.600
#> GSM110446     2  0.9686    0.48397 0.396 0.604
#> GSM110449     2  0.0000    0.87955 0.000 1.000
#> GSM110451     2  0.6048    0.85026 0.148 0.852
#> GSM110391     2  0.0000    0.87955 0.000 1.000
#> GSM110439     2  0.0000    0.87955 0.000 1.000
#> GSM110442     2  0.0000    0.87955 0.000 1.000
#> GSM110443     2  0.8763    0.57913 0.296 0.704
#> GSM110447     2  0.6247    0.84382 0.156 0.844
#> GSM110448     1  0.8555    0.72455 0.720 0.280
#> GSM110450     1  0.3274    0.86149 0.940 0.060
#> GSM110452     2  0.0000    0.87955 0.000 1.000
#> GSM110453     2  0.0938    0.88107 0.012 0.988

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     3  0.5585    0.78409 0.024 0.204 0.772
#> GSM110396     1  0.3590    0.79769 0.896 0.076 0.028
#> GSM110397     1  0.3619    0.80592 0.864 0.000 0.136
#> GSM110398     2  0.0424    0.89010 0.000 0.992 0.008
#> GSM110399     2  0.1315    0.88656 0.020 0.972 0.008
#> GSM110400     3  0.4209    0.87112 0.020 0.120 0.860
#> GSM110401     1  0.2537    0.80883 0.920 0.000 0.080
#> GSM110406     2  0.1315    0.88656 0.020 0.972 0.008
#> GSM110407     1  0.4002    0.78213 0.840 0.000 0.160
#> GSM110409     1  0.4733    0.72999 0.800 0.196 0.004
#> GSM110410     2  0.2261    0.89095 0.000 0.932 0.068
#> GSM110413     2  0.0829    0.89236 0.012 0.984 0.004
#> GSM110414     3  0.5366    0.77404 0.016 0.208 0.776
#> GSM110415     3  0.4136    0.87307 0.020 0.116 0.864
#> GSM110416     3  0.4137    0.86347 0.032 0.096 0.872
#> GSM110418     3  0.4137    0.86347 0.032 0.096 0.872
#> GSM110419     3  0.3618    0.87950 0.012 0.104 0.884
#> GSM110420     3  0.4452    0.61836 0.192 0.000 0.808
#> GSM110421     2  0.1877    0.89434 0.012 0.956 0.032
#> GSM110423     3  0.4136    0.87307 0.020 0.116 0.864
#> GSM110424     2  0.2261    0.89095 0.000 0.932 0.068
#> GSM110425     3  0.3539    0.87877 0.012 0.100 0.888
#> GSM110427     2  0.6195    0.61385 0.020 0.704 0.276
#> GSM110428     1  0.6096    0.66960 0.704 0.016 0.280
#> GSM110430     1  0.2537    0.80883 0.920 0.000 0.080
#> GSM110431     1  0.5497    0.67404 0.708 0.000 0.292
#> GSM110432     3  0.3618    0.87950 0.012 0.104 0.884
#> GSM110434     2  0.2261    0.89167 0.000 0.932 0.068
#> GSM110435     1  0.5138    0.72448 0.748 0.000 0.252
#> GSM110437     1  0.2796    0.80802 0.908 0.000 0.092
#> GSM110438     3  0.6421    0.00609 0.424 0.004 0.572
#> GSM110388     1  0.6964    0.63229 0.684 0.264 0.052
#> GSM110392     1  0.9100    0.24070 0.516 0.160 0.324
#> GSM110394     1  0.4121    0.77874 0.832 0.000 0.168
#> GSM110402     3  0.3112    0.87421 0.004 0.096 0.900
#> GSM110411     1  0.6258    0.69329 0.752 0.196 0.052
#> GSM110412     2  0.2564    0.86398 0.036 0.936 0.028
#> GSM110417     1  0.2229    0.78995 0.944 0.012 0.044
#> GSM110422     2  0.2860    0.88257 0.004 0.912 0.084
#> GSM110426     1  0.2590    0.80034 0.924 0.004 0.072
#> GSM110429     2  0.3030    0.87644 0.004 0.904 0.092
#> GSM110433     2  0.1877    0.89434 0.012 0.956 0.032
#> GSM110436     2  0.6294    0.59159 0.020 0.692 0.288
#> GSM110440     1  0.4399    0.77155 0.812 0.000 0.188
#> GSM110441     2  0.0424    0.89373 0.000 0.992 0.008
#> GSM110444     1  0.6258    0.69329 0.752 0.196 0.052
#> GSM110445     2  0.7263    0.25681 0.400 0.568 0.032
#> GSM110446     3  0.4452    0.61836 0.192 0.000 0.808
#> GSM110449     2  0.0592    0.89180 0.000 0.988 0.012
#> GSM110451     3  0.3618    0.87950 0.012 0.104 0.884
#> GSM110391     2  0.2031    0.89359 0.016 0.952 0.032
#> GSM110439     2  0.2261    0.89095 0.000 0.932 0.068
#> GSM110442     2  0.2261    0.89095 0.000 0.932 0.068
#> GSM110443     2  0.6852    0.51557 0.300 0.664 0.036
#> GSM110447     3  0.4887    0.85484 0.060 0.096 0.844
#> GSM110448     1  0.6258    0.69329 0.752 0.196 0.052
#> GSM110450     1  0.3850    0.80984 0.884 0.028 0.088
#> GSM110452     2  0.0747    0.89537 0.000 0.984 0.016
#> GSM110453     2  0.2682    0.88691 0.004 0.920 0.076

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     3  0.3200    0.77865 0.012 0.096 0.880 0.012
#> GSM110396     1  0.3081    0.69590 0.900 0.044 0.016 0.040
#> GSM110397     1  0.3427    0.69206 0.860 0.000 0.028 0.112
#> GSM110398     2  0.3610    0.79892 0.000 0.800 0.000 0.200
#> GSM110399     2  0.4458    0.79389 0.016 0.780 0.008 0.196
#> GSM110400     3  0.0804    0.90954 0.008 0.012 0.980 0.000
#> GSM110401     1  0.0921    0.70996 0.972 0.000 0.028 0.000
#> GSM110406     2  0.4458    0.79389 0.016 0.780 0.008 0.196
#> GSM110407     1  0.2704    0.67720 0.876 0.000 0.124 0.000
#> GSM110409     1  0.4332    0.62503 0.800 0.160 0.000 0.040
#> GSM110410     2  0.2222    0.80321 0.000 0.924 0.060 0.016
#> GSM110413     2  0.3668    0.79758 0.000 0.808 0.004 0.188
#> GSM110414     3  0.2965    0.78331 0.000 0.072 0.892 0.036
#> GSM110415     3  0.0672    0.91140 0.008 0.008 0.984 0.000
#> GSM110416     3  0.2529    0.87131 0.048 0.008 0.920 0.024
#> GSM110418     3  0.2529    0.87131 0.048 0.008 0.920 0.024
#> GSM110419     3  0.1488    0.91931 0.032 0.012 0.956 0.000
#> GSM110420     4  0.7239    1.00000 0.156 0.000 0.344 0.500
#> GSM110421     2  0.3545    0.80040 0.000 0.828 0.008 0.164
#> GSM110423     3  0.0672    0.91140 0.008 0.008 0.984 0.000
#> GSM110424     2  0.2222    0.80321 0.000 0.924 0.060 0.016
#> GSM110425     3  0.1356    0.91785 0.032 0.008 0.960 0.000
#> GSM110427     2  0.5695    0.48439 0.008 0.624 0.344 0.024
#> GSM110428     1  0.6075    0.51753 0.680 0.000 0.192 0.128
#> GSM110430     1  0.0921    0.70996 0.972 0.000 0.028 0.000
#> GSM110431     1  0.5719    0.54799 0.716 0.000 0.152 0.132
#> GSM110432     3  0.1488    0.91931 0.032 0.012 0.956 0.000
#> GSM110434     2  0.2840    0.80344 0.000 0.900 0.056 0.044
#> GSM110435     1  0.5050    0.57379 0.756 0.000 0.176 0.068
#> GSM110437     1  0.0895    0.70687 0.976 0.000 0.020 0.004
#> GSM110438     1  0.7845   -0.48258 0.400 0.000 0.280 0.320
#> GSM110388     1  0.6564    0.52311 0.536 0.084 0.000 0.380
#> GSM110392     1  0.8759    0.00997 0.432 0.080 0.148 0.340
#> GSM110394     1  0.2944    0.67343 0.868 0.000 0.128 0.004
#> GSM110402     3  0.1635    0.90112 0.044 0.008 0.948 0.000
#> GSM110411     1  0.6205    0.56675 0.596 0.048 0.008 0.348
#> GSM110412     2  0.5085    0.75603 0.008 0.716 0.020 0.256
#> GSM110417     1  0.3937    0.68330 0.800 0.000 0.012 0.188
#> GSM110422     2  0.3542    0.79439 0.000 0.864 0.076 0.060
#> GSM110426     1  0.3757    0.69053 0.828 0.000 0.020 0.152
#> GSM110429     2  0.3996    0.78089 0.000 0.836 0.104 0.060
#> GSM110433     2  0.3545    0.80040 0.000 0.828 0.008 0.164
#> GSM110436     2  0.5546    0.46720 0.008 0.620 0.356 0.016
#> GSM110440     1  0.3758    0.66523 0.848 0.000 0.104 0.048
#> GSM110441     2  0.3355    0.80478 0.000 0.836 0.004 0.160
#> GSM110444     1  0.6205    0.56675 0.596 0.048 0.008 0.348
#> GSM110445     2  0.7614    0.25214 0.412 0.436 0.012 0.140
#> GSM110446     4  0.7239    1.00000 0.156 0.000 0.344 0.500
#> GSM110449     2  0.3757    0.80761 0.000 0.828 0.020 0.152
#> GSM110451     3  0.1488    0.91931 0.032 0.012 0.956 0.000
#> GSM110391     2  0.3591    0.79890 0.000 0.824 0.008 0.168
#> GSM110439     2  0.1824    0.80617 0.000 0.936 0.060 0.004
#> GSM110442     2  0.1902    0.80658 0.000 0.932 0.064 0.004
#> GSM110443     2  0.7950    0.49021 0.304 0.516 0.036 0.144
#> GSM110447     3  0.2860    0.84784 0.100 0.008 0.888 0.004
#> GSM110448     1  0.6205    0.56675 0.596 0.048 0.008 0.348
#> GSM110450     1  0.2165    0.71220 0.936 0.008 0.032 0.024
#> GSM110452     2  0.3552    0.81406 0.000 0.848 0.024 0.128
#> GSM110453     2  0.3071    0.79984 0.000 0.888 0.068 0.044

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     3  0.2452      0.807 0.004 0.084 0.896 0.000 0.016
#> GSM110396     1  0.2797      0.673 0.896 0.020 0.016 0.008 0.060
#> GSM110397     1  0.4375      0.630 0.768 0.004 0.000 0.156 0.072
#> GSM110398     5  0.3774      0.695 0.000 0.296 0.000 0.000 0.704
#> GSM110399     5  0.4382      0.703 0.020 0.276 0.004 0.000 0.700
#> GSM110400     3  0.0162      0.893 0.000 0.004 0.996 0.000 0.000
#> GSM110401     1  0.0703      0.689 0.976 0.000 0.024 0.000 0.000
#> GSM110406     5  0.4382      0.703 0.020 0.276 0.004 0.000 0.700
#> GSM110407     1  0.2927      0.668 0.872 0.000 0.060 0.068 0.000
#> GSM110409     1  0.3906      0.602 0.800 0.132 0.000 0.000 0.068
#> GSM110410     2  0.0865      0.669 0.000 0.972 0.024 0.000 0.004
#> GSM110413     5  0.4009      0.647 0.004 0.312 0.000 0.000 0.684
#> GSM110414     3  0.2446      0.815 0.000 0.056 0.900 0.000 0.044
#> GSM110415     3  0.0000      0.895 0.000 0.000 1.000 0.000 0.000
#> GSM110416     3  0.3016      0.860 0.020 0.000 0.848 0.132 0.000
#> GSM110418     3  0.3016      0.860 0.020 0.000 0.848 0.132 0.000
#> GSM110419     3  0.1862      0.913 0.016 0.004 0.932 0.048 0.000
#> GSM110420     4  0.2707      0.667 0.024 0.000 0.100 0.876 0.000
#> GSM110421     2  0.4029      0.420 0.000 0.680 0.000 0.004 0.316
#> GSM110423     3  0.0000      0.895 0.000 0.000 1.000 0.000 0.000
#> GSM110424     2  0.0865      0.669 0.000 0.972 0.024 0.000 0.004
#> GSM110425     3  0.1701      0.912 0.016 0.000 0.936 0.048 0.000
#> GSM110427     2  0.4147      0.469 0.000 0.676 0.316 0.000 0.008
#> GSM110428     1  0.5605      0.449 0.640 0.000 0.168 0.192 0.000
#> GSM110430     1  0.0703      0.689 0.976 0.000 0.024 0.000 0.000
#> GSM110431     1  0.4890      0.488 0.680 0.000 0.064 0.256 0.000
#> GSM110432     3  0.1862      0.913 0.016 0.004 0.932 0.048 0.000
#> GSM110434     2  0.3326      0.602 0.000 0.824 0.024 0.000 0.152
#> GSM110435     1  0.4757      0.551 0.716 0.000 0.080 0.204 0.000
#> GSM110437     1  0.0880      0.687 0.968 0.000 0.000 0.032 0.000
#> GSM110438     4  0.5863      0.435 0.316 0.000 0.096 0.580 0.008
#> GSM110388     1  0.6644      0.420 0.488 0.060 0.000 0.068 0.384
#> GSM110392     4  0.8199      0.176 0.352 0.080 0.028 0.392 0.148
#> GSM110394     1  0.3051      0.666 0.864 0.000 0.060 0.076 0.000
#> GSM110402     3  0.2616      0.886 0.020 0.000 0.880 0.100 0.000
#> GSM110411     1  0.6530      0.449 0.508 0.024 0.000 0.116 0.352
#> GSM110412     2  0.4387      0.382 0.000 0.640 0.000 0.012 0.348
#> GSM110417     1  0.4994      0.623 0.720 0.004 0.000 0.124 0.152
#> GSM110422     2  0.2632      0.650 0.000 0.888 0.040 0.000 0.072
#> GSM110426     1  0.4677      0.613 0.740 0.004 0.000 0.176 0.080
#> GSM110429     2  0.3119      0.642 0.000 0.860 0.068 0.000 0.072
#> GSM110433     2  0.4029      0.420 0.000 0.680 0.000 0.004 0.316
#> GSM110436     2  0.3932      0.461 0.000 0.672 0.328 0.000 0.000
#> GSM110440     1  0.3779      0.645 0.804 0.000 0.052 0.144 0.000
#> GSM110441     5  0.4196      0.642 0.000 0.356 0.004 0.000 0.640
#> GSM110444     1  0.6530      0.449 0.508 0.024 0.000 0.116 0.352
#> GSM110445     5  0.6498      0.347 0.408 0.132 0.012 0.000 0.448
#> GSM110446     4  0.2707      0.667 0.024 0.000 0.100 0.876 0.000
#> GSM110449     5  0.4249      0.588 0.000 0.432 0.000 0.000 0.568
#> GSM110451     3  0.1862      0.913 0.016 0.004 0.932 0.048 0.000
#> GSM110391     2  0.4232      0.419 0.000 0.676 0.000 0.012 0.312
#> GSM110439     2  0.1893      0.661 0.000 0.928 0.024 0.000 0.048
#> GSM110442     2  0.2036      0.656 0.000 0.920 0.024 0.000 0.056
#> GSM110443     5  0.6920      0.464 0.300 0.216 0.016 0.000 0.468
#> GSM110447     3  0.3055      0.870 0.064 0.000 0.864 0.072 0.000
#> GSM110448     1  0.6530      0.449 0.508 0.024 0.000 0.116 0.352
#> GSM110450     1  0.1668      0.689 0.940 0.000 0.028 0.000 0.032
#> GSM110452     2  0.4307     -0.514 0.000 0.504 0.000 0.000 0.496
#> GSM110453     2  0.3085      0.639 0.000 0.852 0.032 0.000 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
#> GSM110395     3  0.2263      0.805 0.004 0.060 0.900 0.000 0.036 0.000
#> GSM110396     1  0.2222      0.781 0.896 0.000 0.008 0.012 0.084 0.000
#> GSM110397     4  0.6191      0.365 0.420 0.024 0.000 0.436 0.012 0.108
#> GSM110398     5  0.1958      0.751 0.000 0.100 0.000 0.004 0.896 0.000
#> GSM110399     5  0.2006      0.753 0.016 0.080 0.000 0.000 0.904 0.000
#> GSM110400     3  0.0000      0.880 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110401     1  0.0547      0.807 0.980 0.000 0.020 0.000 0.000 0.000
#> GSM110406     5  0.2006      0.753 0.016 0.080 0.000 0.000 0.904 0.000
#> GSM110407     1  0.2728      0.806 0.860 0.000 0.040 0.000 0.000 0.100
#> GSM110409     1  0.3563      0.701 0.800 0.092 0.000 0.000 0.108 0.000
#> GSM110410     2  0.0891      0.701 0.000 0.968 0.024 0.000 0.008 0.000
#> GSM110413     5  0.3061      0.662 0.004 0.168 0.000 0.008 0.816 0.004
#> GSM110414     3  0.2288      0.825 0.000 0.048 0.904 0.004 0.040 0.004
#> GSM110415     3  0.0146      0.881 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM110416     3  0.2762      0.826 0.000 0.000 0.804 0.000 0.000 0.196
#> GSM110418     3  0.2762      0.826 0.000 0.000 0.804 0.000 0.000 0.196
#> GSM110419     3  0.1444      0.901 0.000 0.000 0.928 0.000 0.000 0.072
#> GSM110420     6  0.0865      0.838 0.000 0.000 0.036 0.000 0.000 0.964
#> GSM110421     2  0.5203      0.444 0.000 0.580 0.000 0.100 0.316 0.004
#> GSM110423     3  0.0146      0.881 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM110424     2  0.0993      0.701 0.000 0.964 0.024 0.000 0.012 0.000
#> GSM110425     3  0.1501      0.900 0.000 0.000 0.924 0.000 0.000 0.076
#> GSM110427     2  0.3741      0.546 0.000 0.672 0.320 0.000 0.008 0.000
#> GSM110428     1  0.5390      0.594 0.624 0.000 0.164 0.012 0.000 0.200
#> GSM110430     1  0.0547      0.807 0.980 0.000 0.020 0.000 0.000 0.000
#> GSM110431     1  0.4229      0.657 0.668 0.000 0.040 0.000 0.000 0.292
#> GSM110432     3  0.1444      0.901 0.000 0.000 0.928 0.000 0.000 0.072
#> GSM110434     2  0.3539      0.628 0.000 0.756 0.024 0.000 0.220 0.000
#> GSM110435     1  0.4089      0.677 0.696 0.000 0.040 0.000 0.000 0.264
#> GSM110437     1  0.1074      0.798 0.960 0.000 0.000 0.000 0.012 0.028
#> GSM110438     6  0.5721      0.623 0.136 0.000 0.044 0.164 0.008 0.648
#> GSM110388     4  0.2622      0.604 0.040 0.024 0.000 0.896 0.012 0.028
#> GSM110392     4  0.7326     -0.160 0.152 0.072 0.008 0.412 0.016 0.340
#> GSM110394     1  0.2822      0.803 0.852 0.000 0.040 0.000 0.000 0.108
#> GSM110402     3  0.2491      0.855 0.000 0.000 0.836 0.000 0.000 0.164
#> GSM110411     4  0.0858      0.641 0.028 0.000 0.000 0.968 0.004 0.000
#> GSM110412     2  0.6342      0.442 0.012 0.544 0.000 0.224 0.192 0.028
#> GSM110417     4  0.4575      0.515 0.324 0.024 0.000 0.636 0.008 0.008
#> GSM110422     2  0.2930      0.682 0.000 0.840 0.036 0.000 0.124 0.000
#> GSM110426     4  0.5882      0.454 0.368 0.024 0.000 0.516 0.012 0.080
#> GSM110429     2  0.3384      0.675 0.000 0.812 0.068 0.000 0.120 0.000
#> GSM110433     2  0.5203      0.444 0.000 0.580 0.000 0.100 0.316 0.004
#> GSM110436     2  0.3547      0.534 0.000 0.668 0.332 0.000 0.000 0.000
#> GSM110440     1  0.3806      0.772 0.780 0.000 0.032 0.020 0.000 0.168
#> GSM110441     5  0.3567      0.680 0.000 0.252 0.004 0.004 0.736 0.004
#> GSM110444     4  0.0858      0.641 0.028 0.000 0.000 0.968 0.004 0.000
#> GSM110445     5  0.5047      0.438 0.332 0.000 0.004 0.080 0.584 0.000
#> GSM110446     6  0.0865      0.838 0.000 0.000 0.036 0.000 0.000 0.964
#> GSM110449     5  0.3383      0.704 0.000 0.268 0.000 0.004 0.728 0.000
#> GSM110451     3  0.1444      0.901 0.000 0.000 0.928 0.000 0.000 0.072
#> GSM110391     2  0.5992      0.445 0.012 0.560 0.000 0.104 0.296 0.028
#> GSM110439     2  0.2383      0.684 0.000 0.880 0.024 0.000 0.096 0.000
#> GSM110442     2  0.2669      0.675 0.000 0.864 0.024 0.004 0.108 0.000
#> GSM110443     5  0.5883      0.540 0.224 0.064 0.008 0.084 0.620 0.000
#> GSM110447     3  0.3258      0.855 0.040 0.000 0.840 0.020 0.000 0.100
#> GSM110448     4  0.0858      0.641 0.028 0.000 0.000 0.968 0.004 0.000
#> GSM110450     1  0.2042      0.793 0.920 0.000 0.024 0.024 0.032 0.000
#> GSM110452     5  0.3714      0.619 0.000 0.340 0.000 0.004 0.656 0.000
#> GSM110453     2  0.3409      0.665 0.000 0.780 0.028 0.000 0.192 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> MAD:hclust 54           1.0000       0.610 2
#> MAD:hclust 56           0.1511       0.177 3
#> MAD:hclust 53           0.2772       0.378 4
#> MAD:hclust 42           0.4867       0.164 5
#> MAD:hclust 51           0.0382       0.575 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.574           0.784       0.897         0.5018 0.503   0.503
#> 3 3 0.461           0.626       0.806         0.3216 0.658   0.419
#> 4 4 0.582           0.633       0.813         0.1212 0.843   0.580
#> 5 5 0.644           0.450       0.652         0.0713 0.907   0.669
#> 6 6 0.683           0.554       0.696         0.0407 0.892   0.563

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
#> GSM110395     2  0.7299      0.737 0.204 0.796
#> GSM110396     1  0.0376      0.897 0.996 0.004
#> GSM110397     1  0.0376      0.897 0.996 0.004
#> GSM110398     1  0.9963      0.273 0.536 0.464
#> GSM110399     2  0.0672      0.858 0.008 0.992
#> GSM110400     2  0.8499      0.667 0.276 0.724
#> GSM110401     1  0.0376      0.897 0.996 0.004
#> GSM110406     2  0.0376      0.859 0.004 0.996
#> GSM110407     1  0.0376      0.897 0.996 0.004
#> GSM110409     1  0.0672      0.897 0.992 0.008
#> GSM110410     2  0.0000      0.859 0.000 1.000
#> GSM110413     2  0.0672      0.858 0.008 0.992
#> GSM110414     2  0.0376      0.858 0.004 0.996
#> GSM110415     2  0.9580      0.538 0.380 0.620
#> GSM110416     1  0.0672      0.896 0.992 0.008
#> GSM110418     1  0.0672      0.896 0.992 0.008
#> GSM110419     2  0.9710      0.502 0.400 0.600
#> GSM110420     1  0.0672      0.896 0.992 0.008
#> GSM110421     2  0.0672      0.858 0.008 0.992
#> GSM110423     2  0.9552      0.545 0.376 0.624
#> GSM110424     2  0.0376      0.859 0.004 0.996
#> GSM110425     2  0.9552      0.545 0.376 0.624
#> GSM110427     2  0.0376      0.858 0.004 0.996
#> GSM110428     1  0.0672      0.896 0.992 0.008
#> GSM110430     1  0.0376      0.897 0.996 0.004
#> GSM110431     1  0.0672      0.896 0.992 0.008
#> GSM110432     2  0.9460      0.560 0.364 0.636
#> GSM110434     2  0.0000      0.859 0.000 1.000
#> GSM110435     1  0.0672      0.896 0.992 0.008
#> GSM110437     1  0.0376      0.897 0.996 0.004
#> GSM110438     1  0.0672      0.896 0.992 0.008
#> GSM110388     1  0.9460      0.492 0.636 0.364
#> GSM110392     2  0.8386      0.561 0.268 0.732
#> GSM110394     1  0.0672      0.896 0.992 0.008
#> GSM110402     2  0.9552      0.545 0.376 0.624
#> GSM110411     1  0.9552      0.471 0.624 0.376
#> GSM110412     2  0.0672      0.858 0.008 0.992
#> GSM110417     1  0.0672      0.895 0.992 0.008
#> GSM110422     2  0.0376      0.858 0.004 0.996
#> GSM110426     1  0.0376      0.897 0.996 0.004
#> GSM110429     2  0.0672      0.857 0.008 0.992
#> GSM110433     2  0.0672      0.858 0.008 0.992
#> GSM110436     2  0.7299      0.737 0.204 0.796
#> GSM110440     1  0.0000      0.897 1.000 0.000
#> GSM110441     2  0.0672      0.858 0.008 0.992
#> GSM110444     2  0.0672      0.858 0.008 0.992
#> GSM110445     1  0.9460      0.492 0.636 0.364
#> GSM110446     1  0.0672      0.896 0.992 0.008
#> GSM110449     2  0.0672      0.858 0.008 0.992
#> GSM110451     2  0.7299      0.737 0.204 0.796
#> GSM110391     2  0.0672      0.858 0.008 0.992
#> GSM110439     2  0.0000      0.859 0.000 1.000
#> GSM110442     2  0.0672      0.858 0.008 0.992
#> GSM110443     2  0.0672      0.858 0.008 0.992
#> GSM110447     2  0.9552      0.545 0.376 0.624
#> GSM110448     1  0.9460      0.492 0.636 0.364
#> GSM110450     1  0.0376      0.897 0.996 0.004
#> GSM110452     2  0.0000      0.859 0.000 1.000
#> GSM110453     2  0.0000      0.859 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
#> GSM110395     2  0.3551     0.7320 0.000 0.868 0.132
#> GSM110396     1  0.5958     0.7271 0.692 0.008 0.300
#> GSM110397     1  0.5497     0.7302 0.708 0.000 0.292
#> GSM110398     2  0.5905     0.5816 0.352 0.648 0.000
#> GSM110399     2  0.3551     0.8287 0.132 0.868 0.000
#> GSM110400     3  0.4796     0.6903 0.000 0.220 0.780
#> GSM110401     1  0.5621     0.7268 0.692 0.000 0.308
#> GSM110406     2  0.3454     0.8408 0.104 0.888 0.008
#> GSM110407     3  0.6308    -0.3943 0.492 0.000 0.508
#> GSM110409     1  0.6950     0.5469 0.572 0.020 0.408
#> GSM110410     2  0.0592     0.8493 0.012 0.988 0.000
#> GSM110413     2  0.4178     0.8177 0.172 0.828 0.000
#> GSM110414     2  0.8384     0.0885 0.088 0.520 0.392
#> GSM110415     3  0.4235     0.7064 0.000 0.176 0.824
#> GSM110416     3  0.0000     0.6547 0.000 0.000 1.000
#> GSM110418     3  0.0424     0.6513 0.008 0.000 0.992
#> GSM110419     3  0.4291     0.7078 0.000 0.180 0.820
#> GSM110420     3  0.0424     0.6513 0.008 0.000 0.992
#> GSM110421     2  0.5138     0.7804 0.252 0.748 0.000
#> GSM110423     3  0.4399     0.7069 0.000 0.188 0.812
#> GSM110424     2  0.1031     0.8484 0.024 0.976 0.000
#> GSM110425     3  0.4399     0.7069 0.000 0.188 0.812
#> GSM110427     2  0.1163     0.8320 0.000 0.972 0.028
#> GSM110428     3  0.0592     0.6528 0.012 0.000 0.988
#> GSM110430     1  0.5621     0.7268 0.692 0.000 0.308
#> GSM110431     3  0.6192    -0.1935 0.420 0.000 0.580
#> GSM110432     3  0.4750     0.6930 0.000 0.216 0.784
#> GSM110434     2  0.0000     0.8487 0.000 1.000 0.000
#> GSM110435     3  0.6111    -0.1226 0.396 0.000 0.604
#> GSM110437     1  0.5621     0.7268 0.692 0.000 0.308
#> GSM110438     3  0.1411     0.6303 0.036 0.000 0.964
#> GSM110388     1  0.2845     0.6224 0.920 0.068 0.012
#> GSM110392     3  0.9659     0.3459 0.284 0.252 0.464
#> GSM110394     3  0.6154    -0.1566 0.408 0.000 0.592
#> GSM110402     3  0.4399     0.7069 0.000 0.188 0.812
#> GSM110411     1  0.2845     0.6224 0.920 0.068 0.012
#> GSM110412     2  0.8192     0.6555 0.220 0.636 0.144
#> GSM110417     1  0.3941     0.7056 0.844 0.000 0.156
#> GSM110422     2  0.0237     0.8469 0.000 0.996 0.004
#> GSM110426     1  0.5016     0.7265 0.760 0.000 0.240
#> GSM110429     2  0.3340     0.7446 0.000 0.880 0.120
#> GSM110433     2  0.5098     0.7828 0.248 0.752 0.000
#> GSM110436     3  0.6299     0.2363 0.000 0.476 0.524
#> GSM110440     1  0.5882     0.6756 0.652 0.000 0.348
#> GSM110441     2  0.3941     0.8206 0.156 0.844 0.000
#> GSM110444     1  0.6470    -0.0634 0.632 0.356 0.012
#> GSM110445     1  0.4228     0.6229 0.844 0.148 0.008
#> GSM110446     3  0.1411     0.6303 0.036 0.000 0.964
#> GSM110449     2  0.4399     0.8016 0.188 0.812 0.000
#> GSM110451     3  0.5760     0.5729 0.000 0.328 0.672
#> GSM110391     2  0.5138     0.7804 0.252 0.748 0.000
#> GSM110439     2  0.0000     0.8487 0.000 1.000 0.000
#> GSM110442     2  0.0000     0.8487 0.000 1.000 0.000
#> GSM110443     2  0.3752     0.8278 0.144 0.856 0.000
#> GSM110447     3  0.4291     0.7070 0.000 0.180 0.820
#> GSM110448     1  0.2804     0.6294 0.924 0.060 0.016
#> GSM110450     1  0.5621     0.7268 0.692 0.000 0.308
#> GSM110452     2  0.0000     0.8487 0.000 1.000 0.000
#> GSM110453     2  0.0000     0.8487 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4548      0.625 0.008 0.752 0.232 0.008
#> GSM110396     1  0.2773      0.783 0.880 0.004 0.000 0.116
#> GSM110397     1  0.2796      0.774 0.892 0.000 0.016 0.092
#> GSM110398     2  0.5898      0.446 0.056 0.628 0.000 0.316
#> GSM110399     2  0.3932      0.731 0.008 0.832 0.020 0.140
#> GSM110400     3  0.2302      0.792 0.008 0.060 0.924 0.008
#> GSM110401     1  0.2773      0.785 0.880 0.000 0.004 0.116
#> GSM110406     2  0.4360      0.731 0.012 0.816 0.032 0.140
#> GSM110407     1  0.3978      0.744 0.836 0.000 0.108 0.056
#> GSM110409     1  0.3648      0.751 0.868 0.068 0.008 0.056
#> GSM110410     2  0.2174      0.778 0.000 0.928 0.020 0.052
#> GSM110413     2  0.5130      0.499 0.000 0.652 0.016 0.332
#> GSM110414     3  0.4784      0.676 0.000 0.100 0.788 0.112
#> GSM110415     3  0.0469      0.817 0.012 0.000 0.988 0.000
#> GSM110416     3  0.4104      0.745 0.164 0.000 0.808 0.028
#> GSM110418     3  0.4104      0.745 0.164 0.000 0.808 0.028
#> GSM110419     3  0.1209      0.818 0.032 0.004 0.964 0.000
#> GSM110420     3  0.4149      0.741 0.168 0.000 0.804 0.028
#> GSM110421     4  0.5296     -0.195 0.000 0.492 0.008 0.500
#> GSM110423     3  0.1174      0.817 0.012 0.020 0.968 0.000
#> GSM110424     2  0.2563      0.770 0.000 0.908 0.020 0.072
#> GSM110425     3  0.1174      0.817 0.012 0.020 0.968 0.000
#> GSM110427     2  0.3391      0.713 0.004 0.844 0.148 0.004
#> GSM110428     3  0.2542      0.795 0.084 0.000 0.904 0.012
#> GSM110430     1  0.2773      0.785 0.880 0.000 0.004 0.116
#> GSM110431     1  0.4485      0.652 0.772 0.000 0.200 0.028
#> GSM110432     3  0.2456      0.788 0.008 0.068 0.916 0.008
#> GSM110434     2  0.0817      0.790 0.000 0.976 0.024 0.000
#> GSM110435     1  0.4840      0.595 0.732 0.000 0.240 0.028
#> GSM110437     1  0.2918      0.786 0.876 0.000 0.008 0.116
#> GSM110438     3  0.4993      0.637 0.260 0.000 0.712 0.028
#> GSM110388     4  0.2988      0.575 0.112 0.012 0.000 0.876
#> GSM110392     3  0.8677      0.277 0.136 0.096 0.488 0.280
#> GSM110394     1  0.4485      0.649 0.772 0.000 0.200 0.028
#> GSM110402     3  0.1109      0.817 0.028 0.004 0.968 0.000
#> GSM110411     4  0.2198      0.596 0.072 0.008 0.000 0.920
#> GSM110412     4  0.6260      0.412 0.000 0.144 0.192 0.664
#> GSM110417     4  0.5143     -0.179 0.456 0.000 0.004 0.540
#> GSM110422     2  0.1902      0.775 0.000 0.932 0.064 0.004
#> GSM110426     1  0.5366      0.209 0.548 0.000 0.012 0.440
#> GSM110429     2  0.4368      0.606 0.004 0.748 0.244 0.004
#> GSM110433     2  0.5290      0.118 0.000 0.516 0.008 0.476
#> GSM110436     3  0.4923      0.542 0.008 0.304 0.684 0.004
#> GSM110440     1  0.1109      0.770 0.968 0.000 0.028 0.004
#> GSM110441     2  0.3725      0.695 0.000 0.812 0.008 0.180
#> GSM110444     4  0.1677      0.603 0.040 0.012 0.000 0.948
#> GSM110445     1  0.5495      0.656 0.728 0.096 0.000 0.176
#> GSM110446     3  0.5442      0.524 0.336 0.000 0.636 0.028
#> GSM110449     2  0.4277      0.590 0.000 0.720 0.000 0.280
#> GSM110451     3  0.4856      0.587 0.008 0.272 0.712 0.008
#> GSM110391     4  0.5296     -0.195 0.000 0.492 0.008 0.500
#> GSM110439     2  0.1004      0.790 0.000 0.972 0.024 0.004
#> GSM110442     2  0.1004      0.790 0.000 0.972 0.024 0.004
#> GSM110443     2  0.4298      0.732 0.092 0.840 0.036 0.032
#> GSM110447     3  0.1174      0.817 0.012 0.020 0.968 0.000
#> GSM110448     4  0.3626      0.480 0.184 0.004 0.000 0.812
#> GSM110450     1  0.2918      0.784 0.876 0.000 0.008 0.116
#> GSM110452     2  0.1004      0.790 0.000 0.972 0.024 0.004
#> GSM110453     2  0.0817      0.790 0.000 0.976 0.024 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.6109     0.1831 0.004 0.480 0.044 0.032 0.440
#> GSM110396     1  0.0324     0.8238 0.992 0.004 0.000 0.000 0.004
#> GSM110397     1  0.4500     0.7400 0.784 0.000 0.100 0.020 0.096
#> GSM110398     2  0.6810     0.3359 0.072 0.556 0.000 0.276 0.096
#> GSM110399     2  0.5925     0.4822 0.012 0.624 0.000 0.232 0.132
#> GSM110400     3  0.4838     0.2814 0.004 0.008 0.524 0.004 0.460
#> GSM110401     1  0.0162     0.8275 0.996 0.000 0.004 0.000 0.000
#> GSM110406     2  0.6657     0.4486 0.012 0.520 0.000 0.252 0.216
#> GSM110407     1  0.2964     0.7941 0.856 0.000 0.120 0.000 0.024
#> GSM110409     1  0.2609     0.8132 0.896 0.008 0.068 0.000 0.028
#> GSM110410     2  0.3530     0.5541 0.000 0.784 0.000 0.204 0.012
#> GSM110413     4  0.5233     0.0814 0.000 0.288 0.000 0.636 0.076
#> GSM110414     5  0.6876    -0.1481 0.000 0.012 0.336 0.208 0.444
#> GSM110415     3  0.3999     0.5300 0.000 0.000 0.656 0.000 0.344
#> GSM110416     3  0.0324     0.5627 0.004 0.000 0.992 0.000 0.004
#> GSM110418     3  0.0324     0.5627 0.004 0.000 0.992 0.000 0.004
#> GSM110419     3  0.3928     0.5665 0.004 0.000 0.700 0.000 0.296
#> GSM110420     3  0.0671     0.5548 0.016 0.000 0.980 0.000 0.004
#> GSM110421     4  0.2966     0.4048 0.000 0.184 0.000 0.816 0.000
#> GSM110423     3  0.4045     0.5172 0.000 0.000 0.644 0.000 0.356
#> GSM110424     2  0.3563     0.5519 0.000 0.780 0.000 0.208 0.012
#> GSM110425     3  0.4060     0.5143 0.000 0.000 0.640 0.000 0.360
#> GSM110427     2  0.4927     0.3423 0.004 0.616 0.016 0.008 0.356
#> GSM110428     3  0.3928     0.5641 0.004 0.000 0.700 0.000 0.296
#> GSM110430     1  0.0162     0.8275 0.996 0.000 0.004 0.000 0.000
#> GSM110431     1  0.4640     0.5492 0.584 0.000 0.400 0.000 0.016
#> GSM110432     5  0.5843    -0.2943 0.004 0.068 0.456 0.004 0.468
#> GSM110434     2  0.0510     0.6695 0.000 0.984 0.000 0.000 0.016
#> GSM110435     3  0.4811    -0.4043 0.452 0.000 0.528 0.000 0.020
#> GSM110437     1  0.0693     0.8271 0.980 0.000 0.008 0.000 0.012
#> GSM110438     3  0.1981     0.5224 0.064 0.000 0.920 0.000 0.016
#> GSM110388     4  0.5583     0.4815 0.072 0.000 0.000 0.504 0.424
#> GSM110392     3  0.8995    -0.0606 0.096 0.092 0.360 0.136 0.316
#> GSM110394     1  0.4658     0.5361 0.576 0.000 0.408 0.000 0.016
#> GSM110402     3  0.3838     0.5691 0.004 0.000 0.716 0.000 0.280
#> GSM110411     4  0.4930     0.5248 0.032 0.000 0.000 0.580 0.388
#> GSM110412     4  0.5460     0.4547 0.000 0.024 0.040 0.620 0.316
#> GSM110417     5  0.6691    -0.2591 0.360 0.000 0.000 0.240 0.400
#> GSM110422     2  0.2843     0.6339 0.000 0.848 0.000 0.008 0.144
#> GSM110426     5  0.7332    -0.2313 0.352 0.000 0.036 0.208 0.404
#> GSM110429     2  0.5097     0.1866 0.004 0.548 0.016 0.008 0.424
#> GSM110433     4  0.3366     0.3354 0.000 0.232 0.000 0.768 0.000
#> GSM110436     5  0.6797     0.1784 0.004 0.348 0.180 0.008 0.460
#> GSM110440     1  0.3513     0.7706 0.800 0.000 0.180 0.000 0.020
#> GSM110441     2  0.5296     0.1961 0.000 0.480 0.000 0.472 0.048
#> GSM110444     4  0.4757     0.5300 0.024 0.000 0.000 0.596 0.380
#> GSM110445     1  0.4594     0.6341 0.764 0.116 0.000 0.008 0.112
#> GSM110446     3  0.2300     0.5120 0.072 0.000 0.904 0.000 0.024
#> GSM110449     2  0.5394     0.4041 0.000 0.628 0.000 0.280 0.092
#> GSM110451     5  0.6855     0.1408 0.004 0.292 0.240 0.004 0.460
#> GSM110391     4  0.2966     0.4048 0.000 0.184 0.000 0.816 0.000
#> GSM110439     2  0.0000     0.6694 0.000 1.000 0.000 0.000 0.000
#> GSM110442     2  0.0000     0.6694 0.000 1.000 0.000 0.000 0.000
#> GSM110443     2  0.5386     0.5343 0.168 0.680 0.000 0.004 0.148
#> GSM110447     3  0.4030     0.5230 0.000 0.000 0.648 0.000 0.352
#> GSM110448     4  0.5673     0.4741 0.080 0.000 0.000 0.500 0.420
#> GSM110450     1  0.0324     0.8272 0.992 0.000 0.004 0.000 0.004
#> GSM110452     2  0.0000     0.6694 0.000 1.000 0.000 0.000 0.000
#> GSM110453     2  0.0566     0.6694 0.000 0.984 0.000 0.004 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     3  0.6868     0.2806 0.000 0.304 0.476 0.028 0.040 0.152
#> GSM110396     1  0.1251     0.7821 0.956 0.000 0.000 0.012 0.008 0.024
#> GSM110397     1  0.6278     0.4197 0.520 0.000 0.000 0.248 0.036 0.196
#> GSM110398     2  0.7267     0.1276 0.056 0.436 0.000 0.048 0.328 0.132
#> GSM110399     2  0.6717     0.2376 0.016 0.452 0.000 0.028 0.316 0.188
#> GSM110400     3  0.2946     0.6661 0.000 0.024 0.848 0.004 0.004 0.120
#> GSM110401     1  0.0520     0.7830 0.984 0.000 0.000 0.008 0.008 0.000
#> GSM110406     2  0.7950     0.1684 0.020 0.344 0.068 0.028 0.324 0.216
#> GSM110407     1  0.2596     0.7668 0.892 0.000 0.024 0.016 0.008 0.060
#> GSM110409     1  0.2512     0.7745 0.900 0.020 0.000 0.012 0.020 0.048
#> GSM110410     2  0.4273     0.4003 0.000 0.696 0.000 0.012 0.260 0.032
#> GSM110413     5  0.3305     0.6239 0.000 0.108 0.000 0.012 0.832 0.048
#> GSM110414     3  0.4657     0.5513 0.000 0.004 0.684 0.000 0.220 0.092
#> GSM110415     3  0.1075     0.6369 0.000 0.000 0.952 0.000 0.000 0.048
#> GSM110416     6  0.3833     0.8205 0.000 0.000 0.444 0.000 0.000 0.556
#> GSM110418     6  0.3804     0.8447 0.000 0.000 0.424 0.000 0.000 0.576
#> GSM110419     3  0.2718     0.5738 0.020 0.000 0.880 0.020 0.004 0.076
#> GSM110420     6  0.3782     0.8509 0.000 0.000 0.412 0.000 0.000 0.588
#> GSM110421     5  0.2672     0.7023 0.000 0.052 0.000 0.080 0.868 0.000
#> GSM110423     3  0.0146     0.6629 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM110424     2  0.4678     0.3253 0.000 0.640 0.000 0.012 0.304 0.044
#> GSM110425     3  0.0000     0.6643 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110427     2  0.5716     0.3541 0.000 0.612 0.228 0.016 0.012 0.132
#> GSM110428     3  0.2978     0.5715 0.032 0.000 0.868 0.016 0.008 0.076
#> GSM110430     1  0.0767     0.7826 0.976 0.000 0.000 0.008 0.012 0.004
#> GSM110431     1  0.5623     0.3830 0.568 0.000 0.116 0.004 0.012 0.300
#> GSM110432     3  0.4536     0.6472 0.004 0.064 0.768 0.028 0.012 0.124
#> GSM110434     2  0.1448     0.6165 0.000 0.948 0.000 0.012 0.016 0.024
#> GSM110435     6  0.5645     0.4594 0.252 0.000 0.160 0.000 0.012 0.576
#> GSM110437     1  0.1173     0.7827 0.960 0.000 0.000 0.008 0.016 0.016
#> GSM110438     6  0.4333     0.8514 0.028 0.000 0.376 0.000 0.000 0.596
#> GSM110388     4  0.2942     0.6926 0.032 0.000 0.000 0.836 0.132 0.000
#> GSM110392     4  0.7333     0.0659 0.016 0.052 0.164 0.416 0.016 0.336
#> GSM110394     1  0.5728     0.4010 0.576 0.000 0.112 0.008 0.016 0.288
#> GSM110402     3  0.1957     0.5331 0.000 0.000 0.888 0.000 0.000 0.112
#> GSM110411     4  0.3411     0.6329 0.004 0.000 0.000 0.756 0.232 0.008
#> GSM110412     5  0.6548    -0.1973 0.000 0.008 0.148 0.396 0.412 0.036
#> GSM110417     4  0.3917     0.6307 0.124 0.000 0.000 0.792 0.024 0.060
#> GSM110422     2  0.3110     0.5781 0.000 0.848 0.012 0.016 0.012 0.112
#> GSM110426     4  0.4160     0.6233 0.112 0.000 0.000 0.776 0.024 0.088
#> GSM110429     2  0.5893     0.2717 0.000 0.576 0.264 0.016 0.012 0.132
#> GSM110433     5  0.2912     0.7077 0.000 0.076 0.000 0.072 0.852 0.000
#> GSM110436     3  0.5801     0.4492 0.000 0.268 0.572 0.012 0.008 0.140
#> GSM110440     1  0.3939     0.6716 0.756 0.000 0.020 0.008 0.012 0.204
#> GSM110441     5  0.5156     0.2043 0.000 0.320 0.000 0.012 0.592 0.076
#> GSM110444     4  0.3512     0.6152 0.004 0.000 0.000 0.740 0.248 0.008
#> GSM110445     1  0.6316     0.4453 0.620 0.128 0.000 0.032 0.060 0.160
#> GSM110446     6  0.4238     0.8344 0.028 0.000 0.344 0.000 0.000 0.628
#> GSM110449     2  0.6198     0.1633 0.000 0.496 0.000 0.044 0.336 0.124
#> GSM110451     3  0.5728     0.5597 0.000 0.204 0.632 0.028 0.012 0.124
#> GSM110391     5  0.2724     0.7003 0.000 0.052 0.000 0.084 0.864 0.000
#> GSM110439     2  0.1003     0.6138 0.000 0.964 0.000 0.004 0.028 0.004
#> GSM110442     2  0.1257     0.6147 0.000 0.952 0.000 0.000 0.028 0.020
#> GSM110443     2  0.7080     0.3978 0.160 0.512 0.000 0.036 0.064 0.228
#> GSM110447     3  0.1204     0.6400 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM110448     4  0.2930     0.6949 0.036 0.000 0.000 0.840 0.124 0.000
#> GSM110450     1  0.0862     0.7812 0.972 0.000 0.000 0.004 0.008 0.016
#> GSM110452     2  0.0777     0.6159 0.000 0.972 0.000 0.000 0.024 0.004
#> GSM110453     2  0.1138     0.6173 0.000 0.960 0.000 0.004 0.024 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-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> MAD:kmeans 54           0.1755      0.2458 2
#> MAD:kmeans 51           0.1678      0.2521 3
#> MAD:kmeans 49           0.0657      0.1270 4
#> MAD:kmeans 35           0.0801      0.0218 5
#> MAD:kmeans 40           0.0118      0.0595 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 17209 rows and 59 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.578           0.741       0.887         0.5070 0.493   0.493
#> 3 3 0.747           0.819       0.919         0.3274 0.750   0.532
#> 4 4 0.692           0.712       0.865         0.1124 0.848   0.581
#> 5 5 0.674           0.605       0.766         0.0703 0.859   0.522
#> 6 6 0.700           0.542       0.759         0.0446 0.904   0.576

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
#> GSM110395     2  0.7219     0.7132 0.200 0.800
#> GSM110396     1  0.0000     0.8521 1.000 0.000
#> GSM110397     1  0.0000     0.8521 1.000 0.000
#> GSM110398     1  0.9732     0.4622 0.596 0.404
#> GSM110399     2  0.0000     0.8529 0.000 1.000
#> GSM110400     2  0.9710     0.4872 0.400 0.600
#> GSM110401     1  0.0000     0.8521 1.000 0.000
#> GSM110406     2  0.0000     0.8529 0.000 1.000
#> GSM110407     1  0.0000     0.8521 1.000 0.000
#> GSM110409     1  0.0000     0.8521 1.000 0.000
#> GSM110410     2  0.0000     0.8529 0.000 1.000
#> GSM110413     2  0.0000     0.8529 0.000 1.000
#> GSM110414     2  0.0000     0.8529 0.000 1.000
#> GSM110415     2  0.9775     0.4653 0.412 0.588
#> GSM110416     1  0.0000     0.8521 1.000 0.000
#> GSM110418     1  0.0000     0.8521 1.000 0.000
#> GSM110419     1  0.9710     0.0544 0.600 0.400
#> GSM110420     1  0.0000     0.8521 1.000 0.000
#> GSM110421     2  0.0000     0.8529 0.000 1.000
#> GSM110423     2  0.9710     0.4872 0.400 0.600
#> GSM110424     2  0.0000     0.8529 0.000 1.000
#> GSM110425     2  0.9710     0.4872 0.400 0.600
#> GSM110427     2  0.0000     0.8529 0.000 1.000
#> GSM110428     1  0.0000     0.8521 1.000 0.000
#> GSM110430     1  0.0000     0.8521 1.000 0.000
#> GSM110431     1  0.0000     0.8521 1.000 0.000
#> GSM110432     2  0.9710     0.4872 0.400 0.600
#> GSM110434     2  0.0000     0.8529 0.000 1.000
#> GSM110435     1  0.0000     0.8521 1.000 0.000
#> GSM110437     1  0.0000     0.8521 1.000 0.000
#> GSM110438     1  0.0000     0.8521 1.000 0.000
#> GSM110388     1  0.9710     0.4690 0.600 0.400
#> GSM110392     1  0.9323     0.5333 0.652 0.348
#> GSM110394     1  0.0000     0.8521 1.000 0.000
#> GSM110402     2  0.9732     0.4805 0.404 0.596
#> GSM110411     1  0.9710     0.4690 0.600 0.400
#> GSM110412     2  0.0000     0.8529 0.000 1.000
#> GSM110417     1  0.0938     0.8443 0.988 0.012
#> GSM110422     2  0.0000     0.8529 0.000 1.000
#> GSM110426     1  0.0000     0.8521 1.000 0.000
#> GSM110429     2  0.0000     0.8529 0.000 1.000
#> GSM110433     2  0.0000     0.8529 0.000 1.000
#> GSM110436     2  0.7219     0.7132 0.200 0.800
#> GSM110440     1  0.0000     0.8521 1.000 0.000
#> GSM110441     2  0.0000     0.8529 0.000 1.000
#> GSM110444     1  0.9833     0.4251 0.576 0.424
#> GSM110445     1  0.9710     0.4690 0.600 0.400
#> GSM110446     1  0.0000     0.8521 1.000 0.000
#> GSM110449     2  0.0000     0.8529 0.000 1.000
#> GSM110451     2  0.8608     0.6290 0.284 0.716
#> GSM110391     2  0.0000     0.8529 0.000 1.000
#> GSM110439     2  0.0000     0.8529 0.000 1.000
#> GSM110442     2  0.0000     0.8529 0.000 1.000
#> GSM110443     2  0.0000     0.8529 0.000 1.000
#> GSM110447     2  0.9732     0.4805 0.404 0.596
#> GSM110448     1  0.9710     0.4690 0.600 0.400
#> GSM110450     1  0.0000     0.8521 1.000 0.000
#> GSM110452     2  0.0000     0.8529 0.000 1.000
#> GSM110453     2  0.0000     0.8529 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
#> GSM110395     2  0.3412      0.840 0.000 0.876 0.124
#> GSM110396     1  0.0000      0.826 1.000 0.000 0.000
#> GSM110397     1  0.1163      0.828 0.972 0.000 0.028
#> GSM110398     1  0.6302      0.123 0.520 0.480 0.000
#> GSM110399     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110400     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110401     1  0.1163      0.828 0.972 0.000 0.028
#> GSM110406     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110407     1  0.5497      0.613 0.708 0.000 0.292
#> GSM110409     1  0.4748      0.754 0.832 0.024 0.144
#> GSM110410     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110413     2  0.0592      0.966 0.012 0.988 0.000
#> GSM110414     3  0.7129      0.309 0.028 0.392 0.580
#> GSM110415     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110416     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110418     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110419     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110420     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110421     2  0.1163      0.959 0.028 0.972 0.000
#> GSM110423     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110424     2  0.1031      0.961 0.024 0.976 0.000
#> GSM110425     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110427     2  0.0237      0.968 0.000 0.996 0.004
#> GSM110428     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110430     1  0.1163      0.828 0.972 0.000 0.028
#> GSM110431     1  0.6295      0.290 0.528 0.000 0.472
#> GSM110432     3  0.0237      0.917 0.000 0.004 0.996
#> GSM110434     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110435     1  0.6295      0.290 0.528 0.000 0.472
#> GSM110437     1  0.1163      0.828 0.972 0.000 0.028
#> GSM110438     3  0.0747      0.906 0.016 0.000 0.984
#> GSM110388     1  0.0892      0.823 0.980 0.020 0.000
#> GSM110392     1  0.6421      0.212 0.572 0.004 0.424
#> GSM110394     1  0.6295      0.290 0.528 0.000 0.472
#> GSM110402     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110411     1  0.0747      0.824 0.984 0.016 0.000
#> GSM110412     2  0.3983      0.893 0.068 0.884 0.048
#> GSM110417     1  0.0000      0.826 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110426     1  0.0000      0.826 1.000 0.000 0.000
#> GSM110429     2  0.1163      0.952 0.000 0.972 0.028
#> GSM110433     2  0.1163      0.959 0.028 0.972 0.000
#> GSM110436     3  0.5431      0.615 0.000 0.284 0.716
#> GSM110440     1  0.3941      0.755 0.844 0.000 0.156
#> GSM110441     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110444     1  0.1529      0.811 0.960 0.040 0.000
#> GSM110445     1  0.1163      0.822 0.972 0.028 0.000
#> GSM110446     3  0.3412      0.775 0.124 0.000 0.876
#> GSM110449     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110451     3  0.4121      0.763 0.000 0.168 0.832
#> GSM110391     2  0.1163      0.959 0.028 0.972 0.000
#> GSM110439     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110442     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110443     2  0.4504      0.763 0.196 0.804 0.000
#> GSM110447     3  0.0000      0.919 0.000 0.000 1.000
#> GSM110448     1  0.0592      0.825 0.988 0.012 0.000
#> GSM110450     1  0.1163      0.828 0.972 0.000 0.028
#> GSM110452     2  0.0000      0.970 0.000 1.000 0.000
#> GSM110453     2  0.0000      0.970 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.3292      0.738 0.004 0.868 0.112 0.016
#> GSM110396     1  0.1118      0.859 0.964 0.000 0.000 0.036
#> GSM110397     1  0.0921      0.864 0.972 0.000 0.000 0.028
#> GSM110398     2  0.5659      0.527 0.032 0.600 0.000 0.368
#> GSM110399     2  0.3801      0.716 0.000 0.780 0.000 0.220
#> GSM110400     3  0.0592      0.894 0.000 0.016 0.984 0.000
#> GSM110401     1  0.0921      0.864 0.972 0.000 0.000 0.028
#> GSM110406     2  0.3973      0.730 0.004 0.792 0.004 0.200
#> GSM110407     1  0.1305      0.856 0.960 0.000 0.036 0.004
#> GSM110409     1  0.0657      0.862 0.984 0.012 0.000 0.004
#> GSM110410     2  0.0592      0.810 0.000 0.984 0.000 0.016
#> GSM110413     2  0.4679      0.593 0.000 0.648 0.000 0.352
#> GSM110414     3  0.3787      0.765 0.000 0.036 0.840 0.124
#> GSM110415     3  0.0000      0.899 0.000 0.000 1.000 0.000
#> GSM110416     3  0.1302      0.894 0.044 0.000 0.956 0.000
#> GSM110418     3  0.1302      0.894 0.044 0.000 0.956 0.000
#> GSM110419     3  0.1118      0.897 0.036 0.000 0.964 0.000
#> GSM110420     3  0.1389      0.892 0.048 0.000 0.952 0.000
#> GSM110421     4  0.4972     -0.269 0.000 0.456 0.000 0.544
#> GSM110423     3  0.0000      0.899 0.000 0.000 1.000 0.000
#> GSM110424     2  0.2216      0.777 0.000 0.908 0.000 0.092
#> GSM110425     3  0.0000      0.899 0.000 0.000 1.000 0.000
#> GSM110427     2  0.1118      0.794 0.000 0.964 0.036 0.000
#> GSM110428     3  0.3649      0.723 0.204 0.000 0.796 0.000
#> GSM110430     1  0.0921      0.864 0.972 0.000 0.000 0.028
#> GSM110431     1  0.3024      0.795 0.852 0.000 0.148 0.000
#> GSM110432     3  0.2011      0.857 0.000 0.080 0.920 0.000
#> GSM110434     2  0.0000      0.809 0.000 1.000 0.000 0.000
#> GSM110435     1  0.3024      0.795 0.852 0.000 0.148 0.000
#> GSM110437     1  0.0921      0.864 0.972 0.000 0.000 0.028
#> GSM110438     1  0.4989      0.200 0.528 0.000 0.472 0.000
#> GSM110388     4  0.2469      0.668 0.108 0.000 0.000 0.892
#> GSM110392     4  0.6901      0.547 0.056 0.180 0.092 0.672
#> GSM110394     1  0.3024      0.795 0.852 0.000 0.148 0.000
#> GSM110402     3  0.0921      0.898 0.028 0.000 0.972 0.000
#> GSM110411     4  0.0188      0.660 0.004 0.000 0.000 0.996
#> GSM110412     4  0.2329      0.642 0.000 0.072 0.012 0.916
#> GSM110417     4  0.4661      0.407 0.348 0.000 0.000 0.652
#> GSM110422     2  0.0000      0.809 0.000 1.000 0.000 0.000
#> GSM110426     4  0.4804      0.349 0.384 0.000 0.000 0.616
#> GSM110429     2  0.2408      0.737 0.000 0.896 0.104 0.000
#> GSM110433     2  0.4996      0.328 0.000 0.516 0.000 0.484
#> GSM110436     3  0.4382      0.634 0.000 0.296 0.704 0.000
#> GSM110440     1  0.0524      0.864 0.988 0.000 0.008 0.004
#> GSM110441     2  0.4250      0.675 0.000 0.724 0.000 0.276
#> GSM110444     4  0.0000      0.658 0.000 0.000 0.000 1.000
#> GSM110445     1  0.2131      0.835 0.932 0.032 0.000 0.036
#> GSM110446     1  0.4277      0.628 0.720 0.000 0.280 0.000
#> GSM110449     2  0.4624      0.605 0.000 0.660 0.000 0.340
#> GSM110451     3  0.4277      0.655 0.000 0.280 0.720 0.000
#> GSM110391     4  0.4977     -0.280 0.000 0.460 0.000 0.540
#> GSM110439     2  0.0188      0.810 0.000 0.996 0.000 0.004
#> GSM110442     2  0.0469      0.810 0.000 0.988 0.000 0.012
#> GSM110443     2  0.3300      0.700 0.144 0.848 0.000 0.008
#> GSM110447     3  0.0336      0.900 0.008 0.000 0.992 0.000
#> GSM110448     4  0.3444      0.616 0.184 0.000 0.000 0.816
#> GSM110450     1  0.0921      0.864 0.972 0.000 0.000 0.028
#> GSM110452     2  0.0336      0.810 0.000 0.992 0.000 0.008
#> GSM110453     2  0.0000      0.809 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     5  0.3807      0.467 0.000 0.240 0.012 0.000 0.748
#> GSM110396     1  0.0162      0.860 0.996 0.000 0.000 0.004 0.000
#> GSM110397     1  0.3983      0.751 0.784 0.000 0.164 0.052 0.000
#> GSM110398     2  0.3847      0.621 0.088 0.828 0.000 0.068 0.016
#> GSM110399     2  0.1774      0.669 0.000 0.932 0.000 0.016 0.052
#> GSM110400     5  0.4608      0.233 0.000 0.008 0.336 0.012 0.644
#> GSM110401     1  0.0000      0.862 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.4467      0.501 0.016 0.716 0.000 0.016 0.252
#> GSM110407     1  0.1082      0.854 0.964 0.000 0.028 0.000 0.008
#> GSM110409     1  0.0798      0.858 0.976 0.008 0.016 0.000 0.000
#> GSM110410     2  0.4422      0.618 0.000 0.664 0.004 0.012 0.320
#> GSM110413     2  0.3170      0.648 0.000 0.856 0.004 0.104 0.036
#> GSM110414     5  0.6254      0.269 0.000 0.076 0.280 0.048 0.596
#> GSM110415     3  0.3391      0.612 0.000 0.000 0.800 0.012 0.188
#> GSM110416     3  0.0486      0.657 0.004 0.000 0.988 0.004 0.004
#> GSM110418     3  0.0324      0.657 0.004 0.000 0.992 0.004 0.000
#> GSM110419     3  0.4194      0.547 0.004 0.000 0.708 0.012 0.276
#> GSM110420     3  0.0324      0.657 0.004 0.000 0.992 0.004 0.000
#> GSM110421     2  0.4768      0.493 0.000 0.672 0.004 0.288 0.036
#> GSM110423     3  0.4655      0.166 0.000 0.000 0.512 0.012 0.476
#> GSM110424     2  0.5059      0.624 0.000 0.652 0.004 0.052 0.292
#> GSM110425     3  0.4656      0.162 0.000 0.000 0.508 0.012 0.480
#> GSM110427     5  0.2848      0.490 0.000 0.156 0.004 0.000 0.840
#> GSM110428     3  0.5960      0.485 0.264 0.000 0.592 0.004 0.140
#> GSM110430     1  0.0000      0.862 1.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.4196      0.523 0.640 0.000 0.356 0.004 0.000
#> GSM110432     5  0.4070      0.412 0.000 0.004 0.256 0.012 0.728
#> GSM110434     2  0.4045      0.570 0.000 0.644 0.000 0.000 0.356
#> GSM110435     3  0.4440     -0.229 0.468 0.000 0.528 0.004 0.000
#> GSM110437     1  0.0000      0.862 1.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.2848      0.566 0.156 0.000 0.840 0.004 0.000
#> GSM110388     4  0.1041      0.911 0.032 0.004 0.000 0.964 0.000
#> GSM110392     4  0.4518      0.790 0.024 0.016 0.164 0.776 0.020
#> GSM110394     1  0.3999      0.547 0.656 0.000 0.344 0.000 0.000
#> GSM110402     3  0.3399      0.623 0.004 0.000 0.812 0.012 0.172
#> GSM110411     4  0.0703      0.904 0.000 0.024 0.000 0.976 0.000
#> GSM110412     4  0.1202      0.896 0.000 0.032 0.004 0.960 0.004
#> GSM110417     4  0.2561      0.848 0.144 0.000 0.000 0.856 0.000
#> GSM110422     5  0.4262     -0.236 0.000 0.440 0.000 0.000 0.560
#> GSM110426     4  0.3601      0.831 0.128 0.000 0.052 0.820 0.000
#> GSM110429     5  0.1965      0.597 0.000 0.096 0.000 0.000 0.904
#> GSM110433     2  0.3764      0.630 0.000 0.808 0.004 0.148 0.040
#> GSM110436     5  0.1571      0.632 0.000 0.004 0.060 0.000 0.936
#> GSM110440     1  0.3274      0.722 0.780 0.000 0.220 0.000 0.000
#> GSM110441     2  0.1996      0.668 0.000 0.928 0.004 0.032 0.036
#> GSM110444     4  0.0703      0.904 0.000 0.024 0.000 0.976 0.000
#> GSM110445     1  0.2570      0.771 0.880 0.108 0.000 0.008 0.004
#> GSM110446     3  0.3671      0.430 0.236 0.000 0.756 0.008 0.000
#> GSM110449     2  0.1408      0.671 0.000 0.948 0.000 0.044 0.008
#> GSM110451     5  0.1792      0.621 0.000 0.000 0.084 0.000 0.916
#> GSM110391     2  0.4747      0.499 0.000 0.676 0.004 0.284 0.036
#> GSM110439     2  0.3895      0.608 0.000 0.680 0.000 0.000 0.320
#> GSM110442     2  0.3895      0.608 0.000 0.680 0.000 0.000 0.320
#> GSM110443     2  0.6815      0.337 0.280 0.436 0.000 0.004 0.280
#> GSM110447     3  0.4217      0.545 0.004 0.000 0.704 0.012 0.280
#> GSM110448     4  0.1041      0.911 0.032 0.004 0.000 0.964 0.000
#> GSM110450     1  0.0000      0.862 1.000 0.000 0.000 0.000 0.000
#> GSM110452     2  0.3932      0.601 0.000 0.672 0.000 0.000 0.328
#> GSM110453     2  0.3895      0.608 0.000 0.680 0.000 0.000 0.320

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     6  0.5781    0.12263 0.000 0.232 0.000 0.000 0.264 0.504
#> GSM110396     1  0.0363    0.82000 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM110397     1  0.4902    0.63008 0.672 0.000 0.172 0.152 0.004 0.000
#> GSM110398     5  0.6253    0.42897 0.056 0.372 0.000 0.024 0.496 0.052
#> GSM110399     5  0.5042    0.41768 0.000 0.412 0.000 0.004 0.520 0.064
#> GSM110400     6  0.2604    0.57396 0.000 0.008 0.076 0.000 0.036 0.880
#> GSM110401     1  0.0291    0.82044 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM110406     5  0.5747    0.43667 0.012 0.204 0.000 0.000 0.568 0.216
#> GSM110407     1  0.2172    0.79675 0.912 0.000 0.024 0.000 0.020 0.044
#> GSM110409     1  0.1198    0.81579 0.960 0.012 0.004 0.000 0.020 0.004
#> GSM110410     2  0.2969    0.50328 0.000 0.776 0.000 0.000 0.224 0.000
#> GSM110413     5  0.3027    0.69431 0.000 0.148 0.000 0.028 0.824 0.000
#> GSM110414     6  0.5884    0.40287 0.000 0.008 0.100 0.032 0.284 0.576
#> GSM110415     3  0.4818    0.25441 0.000 0.000 0.572 0.004 0.052 0.372
#> GSM110416     3  0.1682    0.63595 0.000 0.000 0.928 0.000 0.020 0.052
#> GSM110418     3  0.0603    0.64920 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM110419     6  0.4857    0.00118 0.004 0.000 0.424 0.000 0.048 0.524
#> GSM110420     3  0.0363    0.64960 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM110421     5  0.4010    0.67094 0.000 0.084 0.000 0.148 0.764 0.004
#> GSM110423     6  0.4424    0.31816 0.000 0.000 0.324 0.000 0.044 0.632
#> GSM110424     2  0.3684    0.34177 0.000 0.664 0.000 0.004 0.332 0.000
#> GSM110425     6  0.4146    0.37270 0.000 0.000 0.288 0.000 0.036 0.676
#> GSM110427     2  0.4620    0.17632 0.000 0.532 0.000 0.000 0.040 0.428
#> GSM110428     3  0.6767    0.29146 0.256 0.000 0.448 0.000 0.056 0.240
#> GSM110430     1  0.0291    0.82044 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM110431     1  0.4649    0.48856 0.616 0.000 0.340 0.000 0.020 0.024
#> GSM110432     6  0.3154    0.58252 0.000 0.072 0.068 0.000 0.012 0.848
#> GSM110434     2  0.0993    0.63297 0.000 0.964 0.000 0.000 0.024 0.012
#> GSM110435     3  0.3833    0.19174 0.344 0.000 0.648 0.000 0.008 0.000
#> GSM110437     1  0.0436    0.82083 0.988 0.000 0.000 0.004 0.004 0.004
#> GSM110438     3  0.2377    0.62925 0.084 0.000 0.892 0.008 0.008 0.008
#> GSM110388     4  0.1204    0.87058 0.000 0.000 0.000 0.944 0.056 0.000
#> GSM110392     4  0.6011    0.60489 0.016 0.060 0.212 0.644 0.032 0.036
#> GSM110394     1  0.4686    0.52898 0.636 0.000 0.312 0.000 0.020 0.032
#> GSM110402     3  0.4344    0.38690 0.000 0.000 0.652 0.000 0.044 0.304
#> GSM110411     4  0.1327    0.86926 0.000 0.000 0.000 0.936 0.064 0.000
#> GSM110412     4  0.3110    0.74780 0.000 0.000 0.000 0.792 0.196 0.012
#> GSM110417     4  0.1327    0.83285 0.064 0.000 0.000 0.936 0.000 0.000
#> GSM110422     2  0.3470    0.55938 0.000 0.772 0.000 0.000 0.028 0.200
#> GSM110426     4  0.2680    0.79898 0.076 0.000 0.056 0.868 0.000 0.000
#> GSM110429     2  0.4517    0.12954 0.000 0.524 0.000 0.000 0.032 0.444
#> GSM110433     5  0.3867    0.69483 0.000 0.128 0.000 0.088 0.780 0.004
#> GSM110436     6  0.3993    0.36049 0.000 0.300 0.000 0.000 0.024 0.676
#> GSM110440     1  0.3679    0.70124 0.772 0.000 0.192 0.024 0.012 0.000
#> GSM110441     5  0.3390    0.60077 0.000 0.296 0.000 0.000 0.704 0.000
#> GSM110444     4  0.1444    0.86656 0.000 0.000 0.000 0.928 0.072 0.000
#> GSM110445     1  0.5941    0.53608 0.668 0.124 0.008 0.012 0.092 0.096
#> GSM110446     3  0.2401    0.62410 0.060 0.000 0.900 0.004 0.016 0.020
#> GSM110449     2  0.5188   -0.40859 0.000 0.496 0.000 0.016 0.436 0.052
#> GSM110451     6  0.3633    0.45013 0.000 0.252 0.004 0.000 0.012 0.732
#> GSM110391     5  0.3867    0.68332 0.000 0.088 0.000 0.128 0.780 0.004
#> GSM110439     2  0.0790    0.63225 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM110442     2  0.1411    0.62813 0.000 0.936 0.000 0.000 0.060 0.004
#> GSM110443     2  0.6803    0.29888 0.200 0.548 0.008 0.004 0.136 0.104
#> GSM110447     3  0.5116    0.04220 0.000 0.000 0.488 0.012 0.052 0.448
#> GSM110448     4  0.1075    0.87045 0.000 0.000 0.000 0.952 0.048 0.000
#> GSM110450     1  0.1346    0.81102 0.952 0.000 0.000 0.008 0.016 0.024
#> GSM110452     2  0.0858    0.63686 0.000 0.968 0.000 0.000 0.028 0.004
#> GSM110453     2  0.1152    0.63392 0.000 0.952 0.000 0.000 0.044 0.004

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n disease.state(p) specimen(p) k
#> MAD:skmeans 45          0.16833      0.1452 2
#> MAD:skmeans 53          0.23331      0.1707 3
#> MAD:skmeans 53          0.01834      0.2847 4
#> MAD:skmeans 45          0.00669      0.5665 5
#> MAD:skmeans 38          0.01668      0.0942 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 17209 rows and 59 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.224           0.183       0.628         0.4330 0.534   0.534
#> 3 3 0.626           0.714       0.849         0.3910 0.609   0.410
#> 4 4 0.718           0.832       0.900         0.2104 0.827   0.587
#> 5 5 0.849           0.833       0.930         0.0867 0.901   0.651
#> 6 6 0.846           0.815       0.902         0.0316 0.965   0.834

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
#> GSM110395     2   0.925    0.13402 0.340 0.660
#> GSM110396     2   0.871    0.14503 0.292 0.708
#> GSM110397     1   0.925   -0.05485 0.660 0.340
#> GSM110398     1   0.969    0.13485 0.604 0.396
#> GSM110399     2   0.925    0.13402 0.340 0.660
#> GSM110400     2   0.925    0.13402 0.340 0.660
#> GSM110401     2   0.850    0.15778 0.276 0.724
#> GSM110406     2   0.925    0.13402 0.340 0.660
#> GSM110407     2   0.833    0.16231 0.264 0.736
#> GSM110409     1   0.969    0.13485 0.604 0.396
#> GSM110410     2   0.925    0.13402 0.340 0.660
#> GSM110413     2   0.961   -0.02011 0.384 0.616
#> GSM110414     2   0.925    0.13402 0.340 0.660
#> GSM110415     1   0.998    0.02593 0.524 0.476
#> GSM110416     2   0.689    0.19559 0.184 0.816
#> GSM110418     2   0.689    0.19559 0.184 0.816
#> GSM110419     2   0.925    0.13402 0.340 0.660
#> GSM110420     2   0.689    0.19559 0.184 0.816
#> GSM110421     1   0.992    0.44010 0.552 0.448
#> GSM110423     1   0.998    0.02593 0.524 0.476
#> GSM110424     1   0.994    0.43017 0.544 0.456
#> GSM110425     2   0.925    0.13402 0.340 0.660
#> GSM110427     2   0.925    0.13402 0.340 0.660
#> GSM110428     2   0.000    0.14062 0.000 1.000
#> GSM110430     2   0.850    0.15778 0.276 0.724
#> GSM110431     2   0.992    0.16771 0.448 0.552
#> GSM110432     2   0.925    0.13402 0.340 0.660
#> GSM110434     2   0.925    0.13402 0.340 0.660
#> GSM110435     2   0.990    0.17000 0.440 0.560
#> GSM110437     2   0.994    0.16388 0.456 0.544
#> GSM110438     2   0.689    0.19559 0.184 0.816
#> GSM110388     1   0.689    0.33279 0.816 0.184
#> GSM110392     1   0.833    0.30435 0.736 0.264
#> GSM110394     2   0.952    0.17964 0.372 0.628
#> GSM110402     1   0.999    0.02404 0.520 0.480
#> GSM110411     1   0.689    0.33279 0.816 0.184
#> GSM110412     1   0.981    0.42869 0.580 0.420
#> GSM110417     2   0.998   -0.03855 0.476 0.524
#> GSM110422     2   0.925    0.13402 0.340 0.660
#> GSM110426     1   0.925   -0.05485 0.660 0.340
#> GSM110429     2   0.925    0.13402 0.340 0.660
#> GSM110433     1   0.992    0.44010 0.552 0.448
#> GSM110436     2   0.925    0.13402 0.340 0.660
#> GSM110440     2   0.993    0.16602 0.452 0.548
#> GSM110441     1   0.992    0.44010 0.552 0.448
#> GSM110444     1   0.992    0.44010 0.552 0.448
#> GSM110445     1   0.881    0.25802 0.700 0.300
#> GSM110446     2   0.689    0.19559 0.184 0.816
#> GSM110449     1   0.990    0.44001 0.560 0.440
#> GSM110451     2   0.925    0.13402 0.340 0.660
#> GSM110391     1   0.992    0.44010 0.552 0.448
#> GSM110439     2   0.925    0.13402 0.340 0.660
#> GSM110442     1   0.995    0.42403 0.540 0.460
#> GSM110443     2   0.925    0.13402 0.340 0.660
#> GSM110447     2   0.985    0.00103 0.428 0.572
#> GSM110448     1   0.881    0.20484 0.700 0.300
#> GSM110450     2   0.855    0.15507 0.280 0.720
#> GSM110452     2   0.925    0.13402 0.340 0.660
#> GSM110453     2   0.925    0.13402 0.340 0.660

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110396     1  0.8231      0.668 0.636 0.156 0.208
#> GSM110397     1  0.1031      0.625 0.976 0.024 0.000
#> GSM110398     1  0.7656      0.648 0.572 0.052 0.376
#> GSM110399     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110400     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110401     1  0.6553      0.737 0.656 0.020 0.324
#> GSM110406     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110407     1  0.6026      0.701 0.624 0.000 0.376
#> GSM110409     1  0.5882      0.725 0.652 0.000 0.348
#> GSM110410     3  0.1031      0.804 0.024 0.000 0.976
#> GSM110413     2  0.7145      0.266 0.024 0.536 0.440
#> GSM110414     3  0.1031      0.804 0.024 0.000 0.976
#> GSM110415     3  0.7190      0.560 0.320 0.044 0.636
#> GSM110416     3  0.7190      0.560 0.320 0.044 0.636
#> GSM110418     3  0.7214      0.556 0.324 0.044 0.632
#> GSM110419     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110420     3  0.7284      0.542 0.336 0.044 0.620
#> GSM110421     2  0.1643      0.883 0.000 0.956 0.044
#> GSM110423     3  0.6699      0.615 0.256 0.044 0.700
#> GSM110424     3  0.2663      0.770 0.024 0.044 0.932
#> GSM110425     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110427     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110428     3  0.0424      0.813 0.000 0.008 0.992
#> GSM110430     1  0.5859      0.727 0.656 0.000 0.344
#> GSM110431     1  0.1643      0.651 0.956 0.000 0.044
#> GSM110432     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110434     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110435     1  0.6585      0.395 0.712 0.044 0.244
#> GSM110437     1  0.1031      0.646 0.976 0.000 0.024
#> GSM110438     3  0.7284      0.542 0.336 0.044 0.620
#> GSM110388     2  0.1643      0.862 0.044 0.956 0.000
#> GSM110392     3  0.8690      0.436 0.132 0.308 0.560
#> GSM110394     3  0.7657     -0.166 0.448 0.044 0.508
#> GSM110402     3  0.6962      0.571 0.316 0.036 0.648
#> GSM110411     2  0.1919      0.877 0.020 0.956 0.024
#> GSM110412     2  0.1643      0.883 0.000 0.956 0.044
#> GSM110417     2  0.1643      0.862 0.044 0.956 0.000
#> GSM110422     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110426     2  0.0747      0.846 0.016 0.984 0.000
#> GSM110429     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110433     2  0.1643      0.883 0.000 0.956 0.044
#> GSM110436     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110440     1  0.1529      0.650 0.960 0.000 0.040
#> GSM110441     2  0.6994      0.403 0.028 0.612 0.360
#> GSM110444     2  0.1643      0.883 0.000 0.956 0.044
#> GSM110445     1  0.6501      0.721 0.664 0.020 0.316
#> GSM110446     3  0.7284      0.542 0.336 0.044 0.620
#> GSM110449     2  0.2903      0.868 0.028 0.924 0.048
#> GSM110451     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110391     2  0.1643      0.883 0.000 0.956 0.044
#> GSM110439     3  0.1163      0.801 0.028 0.000 0.972
#> GSM110442     3  0.2050      0.788 0.028 0.020 0.952
#> GSM110443     3  0.0237      0.815 0.004 0.000 0.996
#> GSM110447     3  0.4842      0.669 0.224 0.000 0.776
#> GSM110448     2  0.1643      0.862 0.044 0.956 0.000
#> GSM110450     1  0.7590      0.725 0.652 0.080 0.268
#> GSM110452     3  0.0000      0.817 0.000 0.000 1.000
#> GSM110453     3  0.1031      0.804 0.024 0.000 0.976

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110396     1  0.3508      0.867 0.848 0.136 0.004 0.012
#> GSM110397     1  0.3726      0.737 0.788 0.000 0.212 0.000
#> GSM110398     1  0.4692      0.722 0.816 0.112 0.036 0.036
#> GSM110399     2  0.0188      0.930 0.004 0.996 0.000 0.000
#> GSM110400     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110401     1  0.2530      0.876 0.888 0.112 0.000 0.000
#> GSM110406     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110407     1  0.3831      0.819 0.792 0.204 0.004 0.000
#> GSM110409     1  0.3311      0.849 0.828 0.172 0.000 0.000
#> GSM110410     2  0.3616      0.854 0.112 0.852 0.036 0.000
#> GSM110413     4  0.7022      0.584 0.100 0.216 0.040 0.644
#> GSM110414     2  0.2722      0.889 0.064 0.904 0.032 0.000
#> GSM110415     3  0.2081      0.811 0.000 0.084 0.916 0.000
#> GSM110416     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110418     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110419     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110420     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110421     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110423     3  0.1389      0.833 0.000 0.048 0.952 0.000
#> GSM110424     2  0.5669      0.774 0.100 0.764 0.036 0.100
#> GSM110425     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110427     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110428     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110430     1  0.2530      0.876 0.888 0.112 0.000 0.000
#> GSM110431     3  0.5673      0.251 0.372 0.032 0.596 0.000
#> GSM110432     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110434     2  0.0592      0.927 0.016 0.984 0.000 0.000
#> GSM110435     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110437     1  0.2530      0.819 0.888 0.000 0.112 0.000
#> GSM110438     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110388     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110392     3  0.4188      0.639 0.000 0.004 0.752 0.244
#> GSM110394     3  0.4072      0.649 0.000 0.252 0.748 0.000
#> GSM110402     3  0.4304      0.588 0.000 0.284 0.716 0.000
#> GSM110411     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110412     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110417     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110422     2  0.0376      0.931 0.004 0.992 0.004 0.000
#> GSM110426     3  0.4916      0.301 0.000 0.000 0.576 0.424
#> GSM110429     2  0.0188      0.930 0.004 0.996 0.000 0.000
#> GSM110433     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110436     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110440     1  0.3441      0.819 0.856 0.024 0.120 0.000
#> GSM110441     4  0.5292      0.771 0.120 0.060 0.036 0.784
#> GSM110444     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110445     1  0.0000      0.821 1.000 0.000 0.000 0.000
#> GSM110446     3  0.1118      0.837 0.000 0.036 0.964 0.000
#> GSM110449     4  0.4057      0.820 0.120 0.008 0.036 0.836
#> GSM110451     2  0.0188      0.931 0.000 0.996 0.004 0.000
#> GSM110391     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110439     2  0.3731      0.849 0.120 0.844 0.036 0.000
#> GSM110442     2  0.3731      0.849 0.120 0.844 0.036 0.000
#> GSM110443     2  0.0469      0.928 0.012 0.988 0.000 0.000
#> GSM110447     2  0.4661      0.451 0.000 0.652 0.348 0.000
#> GSM110448     4  0.0000      0.927 0.000 0.000 0.000 1.000
#> GSM110450     1  0.2714      0.876 0.884 0.112 0.000 0.004
#> GSM110452     2  0.1452      0.916 0.036 0.956 0.008 0.000
#> GSM110453     2  0.3616      0.854 0.112 0.852 0.036 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
#> GSM110395     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110396     1  0.1628      0.900 0.936 0.056 0.000 0.008 0.000
#> GSM110397     1  0.3508      0.678 0.748 0.000 0.252 0.000 0.000
#> GSM110398     5  0.0000      0.849 0.000 0.000 0.000 0.000 1.000
#> GSM110399     2  0.0290      0.958 0.000 0.992 0.000 0.000 0.008
#> GSM110400     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110401     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0162      0.958 0.000 0.996 0.000 0.000 0.004
#> GSM110407     1  0.2179      0.858 0.888 0.112 0.000 0.000 0.000
#> GSM110409     1  0.2471      0.822 0.864 0.136 0.000 0.000 0.000
#> GSM110410     5  0.0162      0.849 0.000 0.004 0.000 0.000 0.996
#> GSM110413     5  0.0609      0.842 0.000 0.020 0.000 0.000 0.980
#> GSM110414     2  0.2280      0.841 0.000 0.880 0.000 0.000 0.120
#> GSM110415     3  0.1851      0.795 0.000 0.088 0.912 0.000 0.000
#> GSM110416     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110419     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110420     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110421     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110423     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110424     5  0.0771      0.842 0.000 0.004 0.000 0.020 0.976
#> GSM110425     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110427     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110428     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110430     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM110431     3  0.4088      0.299 0.368 0.000 0.632 0.000 0.000
#> GSM110432     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110434     2  0.0703      0.947 0.000 0.976 0.000 0.000 0.024
#> GSM110435     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110437     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110388     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110392     3  0.3700      0.618 0.000 0.008 0.752 0.240 0.000
#> GSM110394     3  0.3534      0.643 0.000 0.256 0.744 0.000 0.000
#> GSM110402     3  0.3480      0.618 0.000 0.248 0.752 0.000 0.000
#> GSM110411     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110412     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110417     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110422     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110426     3  0.4235      0.253 0.000 0.000 0.576 0.424 0.000
#> GSM110429     2  0.0290      0.958 0.000 0.992 0.000 0.000 0.008
#> GSM110433     5  0.4045      0.427 0.000 0.000 0.000 0.356 0.644
#> GSM110436     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110440     1  0.1410      0.895 0.940 0.000 0.060 0.000 0.000
#> GSM110441     5  0.0000      0.849 0.000 0.000 0.000 0.000 1.000
#> GSM110444     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110445     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM110446     3  0.0000      0.839 0.000 0.000 1.000 0.000 0.000
#> GSM110449     5  0.0162      0.848 0.000 0.000 0.000 0.004 0.996
#> GSM110451     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000
#> GSM110391     5  0.4262      0.228 0.000 0.000 0.000 0.440 0.560
#> GSM110439     5  0.0162      0.849 0.000 0.004 0.000 0.000 0.996
#> GSM110442     5  0.3983      0.430 0.000 0.340 0.000 0.000 0.660
#> GSM110443     2  0.0290      0.958 0.000 0.992 0.000 0.000 0.008
#> GSM110447     2  0.4171      0.332 0.000 0.604 0.396 0.000 0.000
#> GSM110448     4  0.0000      1.000 0.000 0.000 0.000 1.000 0.000
#> GSM110450     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM110452     2  0.1270      0.924 0.000 0.948 0.000 0.000 0.052
#> GSM110453     5  0.1851      0.791 0.000 0.088 0.000 0.000 0.912

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110396     6  0.3627      0.815 0.136 0.056 0.000 0.008 0.000 0.800
#> GSM110397     1  0.3151      0.624 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM110398     5  0.2219      0.786 0.000 0.000 0.000 0.000 0.864 0.136
#> GSM110399     2  0.0935      0.925 0.000 0.964 0.000 0.000 0.004 0.032
#> GSM110400     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110401     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0146      0.936 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM110407     6  0.3435      0.815 0.136 0.060 0.000 0.000 0.000 0.804
#> GSM110409     1  0.4745      0.528 0.644 0.088 0.000 0.000 0.000 0.268
#> GSM110410     5  0.0692      0.811 0.000 0.004 0.000 0.000 0.976 0.020
#> GSM110413     5  0.1605      0.806 0.000 0.016 0.000 0.012 0.940 0.032
#> GSM110414     2  0.2398      0.855 0.000 0.876 0.000 0.000 0.104 0.020
#> GSM110415     3  0.1806      0.778 0.000 0.088 0.908 0.000 0.000 0.004
#> GSM110416     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110420     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     4  0.0632      0.975 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM110423     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110424     5  0.1485      0.807 0.000 0.004 0.000 0.028 0.944 0.024
#> GSM110425     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110427     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110428     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110430     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     6  0.2762      0.783 0.000 0.000 0.196 0.000 0.000 0.804
#> GSM110432     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110434     2  0.2923      0.847 0.000 0.848 0.000 0.000 0.052 0.100
#> GSM110435     6  0.2793      0.780 0.000 0.000 0.200 0.000 0.000 0.800
#> GSM110437     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110388     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110392     3  0.3323      0.630 0.000 0.008 0.752 0.240 0.000 0.000
#> GSM110394     6  0.2762      0.724 0.000 0.196 0.000 0.000 0.000 0.804
#> GSM110402     3  0.3126      0.547 0.000 0.248 0.752 0.000 0.000 0.000
#> GSM110411     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110412     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110417     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110426     3  0.3804      0.262 0.000 0.000 0.576 0.424 0.000 0.000
#> GSM110429     2  0.1285      0.915 0.000 0.944 0.000 0.000 0.004 0.052
#> GSM110433     5  0.4234      0.500 0.000 0.000 0.000 0.324 0.644 0.032
#> GSM110436     2  0.0146      0.937 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110440     6  0.3356      0.807 0.140 0.000 0.052 0.000 0.000 0.808
#> GSM110441     5  0.0632      0.810 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM110444     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110445     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110446     3  0.0000      0.846 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110449     5  0.1152      0.808 0.000 0.000 0.000 0.004 0.952 0.044
#> GSM110451     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM110391     5  0.4468      0.321 0.000 0.000 0.000 0.408 0.560 0.032
#> GSM110439     5  0.1531      0.804 0.000 0.004 0.000 0.000 0.928 0.068
#> GSM110442     5  0.4224      0.382 0.000 0.340 0.000 0.000 0.632 0.028
#> GSM110443     2  0.1219      0.918 0.000 0.948 0.000 0.000 0.004 0.048
#> GSM110447     2  0.3872      0.378 0.000 0.604 0.392 0.000 0.000 0.004
#> GSM110448     4  0.0000      0.996 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110450     1  0.0000      0.885 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110452     2  0.3394      0.809 0.000 0.804 0.000 0.000 0.052 0.144
#> GSM110453     5  0.3423      0.739 0.000 0.088 0.000 0.000 0.812 0.100

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) specimen(p) k
#> MAD:pam  0               NA          NA 2
#> MAD:pam 54          0.00286       0.677 3
#> MAD:pam 56          0.03049       0.332 4
#> MAD:pam 53          0.15548       0.562 5
#> MAD:pam 55          0.19700       0.669 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 17209 rows and 59 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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.219           0.678       0.769         0.4566 0.544   0.544
#> 3 3 0.384           0.610       0.769         0.3442 0.821   0.685
#> 4 4 0.527           0.637       0.807         0.1668 0.679   0.370
#> 5 5 0.829           0.817       0.901         0.0874 0.883   0.625
#> 6 6 0.788           0.716       0.816         0.0606 0.944   0.745

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
#> GSM110395     2  0.2043      0.729 0.032 0.968
#> GSM110396     2  0.7950      0.673 0.240 0.760
#> GSM110397     1  0.7453      0.715 0.788 0.212
#> GSM110398     2  0.1843      0.726 0.028 0.972
#> GSM110399     2  0.0000      0.721 0.000 1.000
#> GSM110400     2  0.5408      0.722 0.124 0.876
#> GSM110401     2  0.7950      0.673 0.240 0.760
#> GSM110406     2  0.0672      0.724 0.008 0.992
#> GSM110407     2  0.9775      0.618 0.412 0.588
#> GSM110409     2  0.7950      0.673 0.240 0.760
#> GSM110410     1  0.9983      0.707 0.524 0.476
#> GSM110413     2  0.2603      0.673 0.044 0.956
#> GSM110414     1  0.9815      0.730 0.580 0.420
#> GSM110415     1  0.8763      0.648 0.704 0.296
#> GSM110416     1  0.5178      0.462 0.884 0.116
#> GSM110418     1  0.4022      0.512 0.920 0.080
#> GSM110419     2  0.8499      0.670 0.276 0.724
#> GSM110420     1  0.4022      0.512 0.920 0.080
#> GSM110421     1  0.9909      0.732 0.556 0.444
#> GSM110423     2  0.9608      0.514 0.384 0.616
#> GSM110424     1  0.9922      0.731 0.552 0.448
#> GSM110425     2  0.8955      0.628 0.312 0.688
#> GSM110427     2  0.1414      0.725 0.020 0.980
#> GSM110428     2  0.9909      0.605 0.444 0.556
#> GSM110430     2  0.7950      0.673 0.240 0.760
#> GSM110431     2  0.9909      0.605 0.444 0.556
#> GSM110432     2  0.8144      0.671 0.252 0.748
#> GSM110434     2  0.0000      0.721 0.000 1.000
#> GSM110435     2  0.9909      0.605 0.444 0.556
#> GSM110437     2  0.7950      0.673 0.240 0.760
#> GSM110438     2  0.9909      0.605 0.444 0.556
#> GSM110388     1  0.7815      0.727 0.768 0.232
#> GSM110392     1  0.9795      0.738 0.584 0.416
#> GSM110394     2  0.9909      0.605 0.444 0.556
#> GSM110402     2  0.8267      0.670 0.260 0.740
#> GSM110411     1  0.7815      0.727 0.768 0.232
#> GSM110412     1  0.9795      0.743 0.584 0.416
#> GSM110417     1  0.7299      0.718 0.796 0.204
#> GSM110422     2  0.1414      0.725 0.020 0.980
#> GSM110426     1  0.7299      0.718 0.796 0.204
#> GSM110429     2  0.2603      0.731 0.044 0.956
#> GSM110433     1  0.9909      0.732 0.556 0.444
#> GSM110436     2  0.3114      0.732 0.056 0.944
#> GSM110440     2  0.9635      0.630 0.388 0.612
#> GSM110441     2  0.2603      0.673 0.044 0.956
#> GSM110444     1  0.9795      0.743 0.584 0.416
#> GSM110445     2  0.7453      0.672 0.212 0.788
#> GSM110446     2  0.9909      0.605 0.444 0.556
#> GSM110449     2  0.2778      0.668 0.048 0.952
#> GSM110451     2  0.6148      0.714 0.152 0.848
#> GSM110391     1  0.9909      0.732 0.556 0.444
#> GSM110439     2  0.0000      0.721 0.000 1.000
#> GSM110442     2  0.0376      0.718 0.004 0.996
#> GSM110443     2  0.1414      0.725 0.020 0.980
#> GSM110447     1  0.9286      0.639 0.656 0.344
#> GSM110448     1  0.7674      0.725 0.776 0.224
#> GSM110450     2  0.8016      0.673 0.244 0.756
#> GSM110452     2  0.0000      0.721 0.000 1.000
#> GSM110453     2  0.0000      0.721 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
#> GSM110395     2  0.6405     0.6230 0.172 0.756 0.072
#> GSM110396     2  0.1129     0.5897 0.004 0.976 0.020
#> GSM110397     1  0.6738     0.5146 0.624 0.356 0.020
#> GSM110398     2  0.8734     0.6408 0.168 0.584 0.248
#> GSM110399     2  0.8748     0.6441 0.172 0.584 0.244
#> GSM110400     3  0.6452     0.7853 0.036 0.252 0.712
#> GSM110401     2  0.0237     0.5932 0.000 0.996 0.004
#> GSM110406     2  0.8683     0.6505 0.172 0.592 0.236
#> GSM110407     2  0.1647     0.5907 0.004 0.960 0.036
#> GSM110409     2  0.0892     0.5933 0.000 0.980 0.020
#> GSM110410     3  0.4784     0.2584 0.200 0.004 0.796
#> GSM110413     2  0.8976     0.6427 0.172 0.552 0.276
#> GSM110414     1  0.5948     0.4302 0.640 0.000 0.360
#> GSM110415     3  0.9151     0.5208 0.292 0.180 0.528
#> GSM110416     3  0.5541     0.8076 0.008 0.252 0.740
#> GSM110418     3  0.5659     0.8074 0.012 0.248 0.740
#> GSM110419     2  0.5591     0.3922 0.000 0.696 0.304
#> GSM110420     3  0.5541     0.8076 0.008 0.252 0.740
#> GSM110421     1  0.4235     0.6736 0.824 0.000 0.176
#> GSM110423     3  0.5365     0.8063 0.004 0.252 0.744
#> GSM110424     3  0.5882    -0.0146 0.348 0.000 0.652
#> GSM110425     3  0.5138     0.8039 0.000 0.252 0.748
#> GSM110427     2  0.9153     0.6230 0.172 0.520 0.308
#> GSM110428     2  0.5560     0.3998 0.000 0.700 0.300
#> GSM110430     2  0.0237     0.5932 0.000 0.996 0.004
#> GSM110431     2  0.4842     0.4595 0.000 0.776 0.224
#> GSM110432     2  0.6264     0.4585 0.028 0.716 0.256
#> GSM110434     2  0.8748     0.6488 0.172 0.584 0.244
#> GSM110435     2  0.5363     0.4306 0.000 0.724 0.276
#> GSM110437     2  0.0237     0.5932 0.000 0.996 0.004
#> GSM110438     2  0.5706     0.3391 0.000 0.680 0.320
#> GSM110388     1  0.4178     0.7470 0.828 0.172 0.000
#> GSM110392     3  0.6372     0.7422 0.084 0.152 0.764
#> GSM110394     2  0.5098     0.4561 0.000 0.752 0.248
#> GSM110402     3  0.5138     0.8039 0.000 0.252 0.748
#> GSM110411     1  0.4178     0.7470 0.828 0.172 0.000
#> GSM110412     1  0.0237     0.7373 0.996 0.000 0.004
#> GSM110417     1  0.4178     0.7470 0.828 0.172 0.000
#> GSM110422     2  0.9025     0.6346 0.172 0.544 0.284
#> GSM110426     1  0.4654     0.7217 0.792 0.208 0.000
#> GSM110429     2  0.9048     0.6321 0.172 0.540 0.288
#> GSM110433     1  0.4750     0.6434 0.784 0.000 0.216
#> GSM110436     2  0.8334     0.4213 0.136 0.616 0.248
#> GSM110440     2  0.4808     0.3945 0.008 0.804 0.188
#> GSM110441     2  0.8976     0.6427 0.172 0.552 0.276
#> GSM110444     1  0.0237     0.7373 0.996 0.000 0.004
#> GSM110445     2  0.5016     0.6042 0.000 0.760 0.240
#> GSM110446     3  0.6062     0.6181 0.000 0.384 0.616
#> GSM110449     2  0.8883     0.6434 0.176 0.568 0.256
#> GSM110451     2  0.7333     0.5567 0.136 0.708 0.156
#> GSM110391     1  0.4452     0.6629 0.808 0.000 0.192
#> GSM110439     2  0.8868     0.6454 0.172 0.568 0.260
#> GSM110442     2  0.8976     0.6438 0.172 0.552 0.276
#> GSM110443     2  0.8171     0.6669 0.172 0.644 0.184
#> GSM110447     3  0.6511     0.7714 0.072 0.180 0.748
#> GSM110448     1  0.4178     0.7470 0.828 0.172 0.000
#> GSM110450     2  0.1031     0.5891 0.000 0.976 0.024
#> GSM110452     2  0.8748     0.6484 0.172 0.584 0.244
#> GSM110453     2  0.8386     0.6643 0.172 0.624 0.204

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.3831      0.522 0.004 0.792 0.204 0.000
#> GSM110396     1  0.1792      0.728 0.932 0.068 0.000 0.000
#> GSM110397     1  0.4769      0.395 0.684 0.000 0.008 0.308
#> GSM110398     2  0.4356      0.651 0.292 0.708 0.000 0.000
#> GSM110399     2  0.4040      0.680 0.248 0.752 0.000 0.000
#> GSM110400     3  0.4040      0.719 0.000 0.248 0.752 0.000
#> GSM110401     1  0.0000      0.724 1.000 0.000 0.000 0.000
#> GSM110406     2  0.4040      0.684 0.248 0.752 0.000 0.000
#> GSM110407     1  0.3486      0.655 0.812 0.000 0.188 0.000
#> GSM110409     1  0.0592      0.726 0.984 0.000 0.016 0.000
#> GSM110410     2  0.4121      0.665 0.000 0.796 0.184 0.020
#> GSM110413     2  0.2011      0.731 0.080 0.920 0.000 0.000
#> GSM110414     2  0.6729      0.367 0.012 0.492 0.436 0.060
#> GSM110415     3  0.1411      0.782 0.020 0.000 0.960 0.020
#> GSM110416     3  0.0336      0.804 0.000 0.008 0.992 0.000
#> GSM110418     3  0.0336      0.804 0.000 0.008 0.992 0.000
#> GSM110419     3  0.4483      0.694 0.004 0.284 0.712 0.000
#> GSM110420     3  0.0336      0.804 0.000 0.008 0.992 0.000
#> GSM110421     2  0.5466      0.253 0.000 0.548 0.016 0.436
#> GSM110423     3  0.0336      0.804 0.000 0.008 0.992 0.000
#> GSM110424     2  0.6123      0.574 0.000 0.676 0.192 0.132
#> GSM110425     3  0.0336      0.804 0.000 0.008 0.992 0.000
#> GSM110427     2  0.0921      0.714 0.000 0.972 0.028 0.000
#> GSM110428     3  0.4621      0.691 0.008 0.284 0.708 0.000
#> GSM110430     1  0.0000      0.724 1.000 0.000 0.000 0.000
#> GSM110431     1  0.7503      0.431 0.496 0.276 0.228 0.000
#> GSM110432     2  0.4950      0.127 0.004 0.620 0.376 0.000
#> GSM110434     2  0.4054      0.716 0.188 0.796 0.016 0.000
#> GSM110435     1  0.7676      0.359 0.460 0.276 0.264 0.000
#> GSM110437     1  0.0000      0.724 1.000 0.000 0.000 0.000
#> GSM110438     3  0.6444      0.636 0.104 0.284 0.612 0.000
#> GSM110388     4  0.0000      0.877 0.000 0.000 0.000 1.000
#> GSM110392     3  0.6374      0.584 0.052 0.128 0.720 0.100
#> GSM110394     1  0.7547      0.418 0.488 0.276 0.236 0.000
#> GSM110402     3  0.3942      0.734 0.000 0.236 0.764 0.000
#> GSM110411     4  0.0000      0.877 0.000 0.000 0.000 1.000
#> GSM110412     4  0.5510     -0.222 0.000 0.480 0.016 0.504
#> GSM110417     4  0.0000      0.877 0.000 0.000 0.000 1.000
#> GSM110422     2  0.1004      0.714 0.004 0.972 0.024 0.000
#> GSM110426     4  0.1209      0.848 0.032 0.000 0.004 0.964
#> GSM110429     2  0.1209      0.711 0.004 0.964 0.032 0.000
#> GSM110433     2  0.5069      0.465 0.000 0.664 0.016 0.320
#> GSM110436     2  0.4605      0.291 0.000 0.664 0.336 0.000
#> GSM110440     1  0.6971      0.509 0.568 0.276 0.156 0.000
#> GSM110441     2  0.1637      0.731 0.060 0.940 0.000 0.000
#> GSM110444     4  0.0000      0.877 0.000 0.000 0.000 1.000
#> GSM110445     1  0.0707      0.718 0.980 0.020 0.000 0.000
#> GSM110446     3  0.6262      0.652 0.092 0.280 0.628 0.000
#> GSM110449     2  0.3972      0.705 0.204 0.788 0.008 0.000
#> GSM110451     2  0.4741      0.277 0.004 0.668 0.328 0.000
#> GSM110391     2  0.5427      0.299 0.000 0.568 0.016 0.416
#> GSM110439     2  0.0469      0.724 0.012 0.988 0.000 0.000
#> GSM110442     2  0.0921      0.728 0.028 0.972 0.000 0.000
#> GSM110443     2  0.4193      0.669 0.268 0.732 0.000 0.000
#> GSM110447     3  0.1042      0.794 0.020 0.008 0.972 0.000
#> GSM110448     4  0.0000      0.877 0.000 0.000 0.000 1.000
#> GSM110450     1  0.3219      0.702 0.836 0.164 0.000 0.000
#> GSM110452     2  0.2973      0.725 0.144 0.856 0.000 0.000
#> GSM110453     2  0.4012      0.716 0.184 0.800 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.3196      0.773 0.004 0.804 0.192 0.000 0.000
#> GSM110396     1  0.1124      0.776 0.960 0.036 0.000 0.004 0.000
#> GSM110397     4  0.3496      0.753 0.200 0.000 0.012 0.788 0.000
#> GSM110398     2  0.2011      0.845 0.088 0.908 0.000 0.004 0.000
#> GSM110399     2  0.0324      0.890 0.004 0.992 0.000 0.004 0.000
#> GSM110400     3  0.1547      0.864 0.004 0.032 0.948 0.000 0.016
#> GSM110401     1  0.0162      0.778 0.996 0.004 0.000 0.000 0.000
#> GSM110406     2  0.0451      0.888 0.008 0.988 0.000 0.004 0.000
#> GSM110407     1  0.2929      0.732 0.840 0.008 0.152 0.000 0.000
#> GSM110409     1  0.0609      0.778 0.980 0.020 0.000 0.000 0.000
#> GSM110410     5  0.1117      0.951 0.000 0.020 0.016 0.000 0.964
#> GSM110413     2  0.2011      0.842 0.004 0.908 0.000 0.000 0.088
#> GSM110414     5  0.0566      0.956 0.004 0.000 0.012 0.000 0.984
#> GSM110415     3  0.1124      0.896 0.004 0.000 0.960 0.000 0.036
#> GSM110416     3  0.0880      0.898 0.000 0.000 0.968 0.000 0.032
#> GSM110418     3  0.0880      0.898 0.000 0.000 0.968 0.000 0.032
#> GSM110419     2  0.4973      0.190 0.020 0.496 0.480 0.004 0.000
#> GSM110420     3  0.0880      0.898 0.000 0.000 0.968 0.000 0.032
#> GSM110421     5  0.0880      0.974 0.000 0.000 0.000 0.032 0.968
#> GSM110423     3  0.0880      0.898 0.000 0.000 0.968 0.000 0.032
#> GSM110424     5  0.0693      0.968 0.000 0.000 0.008 0.012 0.980
#> GSM110425     3  0.0880      0.898 0.000 0.000 0.968 0.000 0.032
#> GSM110427     2  0.1124      0.881 0.004 0.960 0.036 0.000 0.000
#> GSM110428     1  0.4689      0.554 0.592 0.008 0.392 0.008 0.000
#> GSM110430     1  0.0162      0.778 0.996 0.004 0.000 0.000 0.000
#> GSM110431     1  0.4679      0.560 0.596 0.008 0.388 0.008 0.000
#> GSM110432     2  0.3826      0.720 0.004 0.752 0.236 0.008 0.000
#> GSM110434     2  0.0324      0.890 0.004 0.992 0.000 0.004 0.000
#> GSM110435     1  0.4709      0.541 0.584 0.008 0.400 0.008 0.000
#> GSM110437     1  0.0162      0.778 0.996 0.004 0.000 0.000 0.000
#> GSM110438     3  0.4416      0.492 0.316 0.008 0.668 0.008 0.000
#> GSM110388     4  0.0290      0.960 0.000 0.000 0.000 0.992 0.008
#> GSM110392     3  0.5020      0.705 0.140 0.044 0.764 0.024 0.028
#> GSM110394     1  0.4620      0.583 0.616 0.008 0.368 0.008 0.000
#> GSM110402     3  0.0324      0.872 0.004 0.004 0.992 0.000 0.000
#> GSM110411     4  0.0290      0.960 0.000 0.000 0.000 0.992 0.008
#> GSM110412     5  0.1205      0.971 0.000 0.000 0.004 0.040 0.956
#> GSM110417     4  0.0290      0.960 0.000 0.000 0.000 0.992 0.008
#> GSM110422     2  0.1124      0.881 0.004 0.960 0.036 0.000 0.000
#> GSM110426     4  0.0451      0.957 0.000 0.000 0.004 0.988 0.008
#> GSM110429     2  0.1124      0.881 0.004 0.960 0.036 0.000 0.000
#> GSM110433     5  0.0880      0.974 0.000 0.000 0.000 0.032 0.968
#> GSM110436     2  0.4331      0.448 0.004 0.596 0.400 0.000 0.000
#> GSM110440     1  0.4434      0.577 0.640 0.008 0.348 0.004 0.000
#> GSM110441     2  0.0162      0.890 0.004 0.996 0.000 0.000 0.000
#> GSM110444     4  0.0290      0.960 0.000 0.000 0.000 0.992 0.008
#> GSM110445     1  0.0963      0.770 0.964 0.036 0.000 0.000 0.000
#> GSM110446     3  0.4057      0.626 0.252 0.008 0.732 0.008 0.000
#> GSM110449     2  0.0162      0.890 0.004 0.996 0.000 0.000 0.000
#> GSM110451     2  0.3797      0.725 0.004 0.756 0.232 0.008 0.000
#> GSM110391     5  0.0880      0.974 0.000 0.000 0.000 0.032 0.968
#> GSM110439     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000
#> GSM110442     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000
#> GSM110443     2  0.0324      0.890 0.004 0.992 0.000 0.004 0.000
#> GSM110447     3  0.1041      0.897 0.004 0.000 0.964 0.000 0.032
#> GSM110448     4  0.0290      0.960 0.000 0.000 0.000 0.992 0.008
#> GSM110450     1  0.1205      0.775 0.956 0.040 0.000 0.004 0.000
#> GSM110452     2  0.0162      0.890 0.004 0.996 0.000 0.000 0.000
#> GSM110453     2  0.0324      0.890 0.004 0.992 0.004 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
#> GSM110395     2  0.3348      0.723 0.000 0.768 0.016 0.000 0.000 0.216
#> GSM110396     1  0.1663      0.776 0.912 0.088 0.000 0.000 0.000 0.000
#> GSM110397     4  0.3499      0.739 0.196 0.008 0.012 0.780 0.000 0.004
#> GSM110398     6  0.2362      0.516 0.136 0.004 0.000 0.000 0.000 0.860
#> GSM110399     6  0.3136      0.655 0.004 0.228 0.000 0.000 0.000 0.768
#> GSM110400     3  0.4155      0.415 0.000 0.364 0.616 0.000 0.000 0.020
#> GSM110401     1  0.0405      0.773 0.988 0.008 0.000 0.000 0.000 0.004
#> GSM110406     6  0.3512      0.639 0.008 0.272 0.000 0.000 0.000 0.720
#> GSM110407     1  0.0937      0.775 0.960 0.000 0.040 0.000 0.000 0.000
#> GSM110409     1  0.0000      0.774 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110410     5  0.0767      0.979 0.000 0.004 0.012 0.000 0.976 0.008
#> GSM110413     6  0.2632      0.452 0.000 0.004 0.000 0.000 0.164 0.832
#> GSM110414     5  0.1536      0.950 0.000 0.016 0.040 0.004 0.940 0.000
#> GSM110415     3  0.1549      0.805 0.000 0.020 0.936 0.000 0.044 0.000
#> GSM110416     3  0.0000      0.825 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000      0.825 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     2  0.3797     -0.175 0.000 0.580 0.420 0.000 0.000 0.000
#> GSM110420     3  0.0000      0.825 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     5  0.0000      0.982 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110423     3  0.0547      0.825 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM110424     5  0.0508      0.981 0.000 0.000 0.012 0.000 0.984 0.004
#> GSM110425     3  0.0547      0.825 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM110427     2  0.2964      0.738 0.000 0.792 0.004 0.000 0.000 0.204
#> GSM110428     1  0.5781      0.574 0.504 0.232 0.264 0.000 0.000 0.000
#> GSM110430     1  0.0405      0.773 0.988 0.008 0.000 0.000 0.000 0.004
#> GSM110431     1  0.5614      0.610 0.540 0.204 0.256 0.000 0.000 0.000
#> GSM110432     2  0.3352      0.741 0.000 0.792 0.032 0.000 0.000 0.176
#> GSM110434     6  0.4056      0.545 0.004 0.416 0.000 0.000 0.004 0.576
#> GSM110435     1  0.5327      0.661 0.596 0.208 0.196 0.000 0.000 0.000
#> GSM110437     1  0.0520      0.772 0.984 0.008 0.000 0.000 0.000 0.008
#> GSM110438     3  0.5817      0.208 0.312 0.208 0.480 0.000 0.000 0.000
#> GSM110388     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110392     3  0.4427      0.685 0.152 0.012 0.768 0.036 0.020 0.012
#> GSM110394     1  0.5601      0.618 0.544 0.208 0.248 0.000 0.000 0.000
#> GSM110402     3  0.1814      0.796 0.000 0.100 0.900 0.000 0.000 0.000
#> GSM110411     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110412     5  0.0520      0.981 0.000 0.000 0.008 0.008 0.984 0.000
#> GSM110417     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110422     2  0.2912      0.713 0.000 0.784 0.000 0.000 0.000 0.216
#> GSM110426     4  0.0260      0.952 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM110429     2  0.2762      0.741 0.000 0.804 0.000 0.000 0.000 0.196
#> GSM110433     5  0.0000      0.982 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110436     2  0.3588      0.612 0.000 0.788 0.152 0.000 0.000 0.060
#> GSM110440     1  0.5022      0.669 0.640 0.204 0.156 0.000 0.000 0.000
#> GSM110441     6  0.0520      0.584 0.000 0.008 0.000 0.000 0.008 0.984
#> GSM110444     4  0.0146      0.957 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM110445     1  0.2912      0.606 0.784 0.000 0.000 0.000 0.000 0.216
#> GSM110446     3  0.5817      0.224 0.312 0.208 0.480 0.000 0.000 0.000
#> GSM110449     6  0.0000      0.581 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110451     2  0.3189      0.748 0.000 0.796 0.020 0.000 0.000 0.184
#> GSM110391     5  0.0000      0.982 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110439     6  0.3797      0.545 0.000 0.420 0.000 0.000 0.000 0.580
#> GSM110442     6  0.3899      0.560 0.000 0.404 0.000 0.000 0.004 0.592
#> GSM110443     6  0.3314      0.653 0.004 0.256 0.000 0.000 0.000 0.740
#> GSM110447     3  0.0692      0.825 0.004 0.020 0.976 0.000 0.000 0.000
#> GSM110448     4  0.0000      0.959 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110450     1  0.2743      0.759 0.828 0.164 0.000 0.000 0.000 0.008
#> GSM110452     6  0.3923      0.551 0.004 0.416 0.000 0.000 0.000 0.580
#> GSM110453     6  0.4041      0.558 0.004 0.408 0.000 0.000 0.004 0.584

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> MAD:mclust 58           0.4573       1.000 2
#> MAD:mclust 47           0.0765       0.575 3
#> MAD:mclust 47           0.0242       0.446 4
#> MAD:mclust 56           0.1577       0.569 5
#> MAD:mclust 54           0.1798       0.110 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.486           0.864       0.896         0.4937 0.493   0.493
#> 3 3 0.492           0.733       0.839         0.3564 0.695   0.456
#> 4 4 0.600           0.720       0.806         0.1167 0.833   0.553
#> 5 5 0.664           0.670       0.811         0.0562 0.950   0.810
#> 6 6 0.649           0.507       0.740         0.0391 0.944   0.768

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
#> GSM110395     2  0.0000      0.914 0.000 1.000
#> GSM110396     1  0.3274      0.861 0.940 0.060
#> GSM110397     1  0.0000      0.831 1.000 0.000
#> GSM110398     1  0.2603      0.854 0.956 0.044
#> GSM110399     2  0.0000      0.914 0.000 1.000
#> GSM110400     2  0.0000      0.914 0.000 1.000
#> GSM110401     1  0.7139      0.896 0.804 0.196
#> GSM110406     2  0.0000      0.914 0.000 1.000
#> GSM110407     1  0.7219      0.896 0.800 0.200
#> GSM110409     1  0.7219      0.896 0.800 0.200
#> GSM110410     2  0.5946      0.845 0.144 0.856
#> GSM110413     2  0.5408      0.857 0.124 0.876
#> GSM110414     2  0.0376      0.912 0.004 0.996
#> GSM110415     2  0.2603      0.876 0.044 0.956
#> GSM110416     1  0.8661      0.809 0.712 0.288
#> GSM110418     1  0.7376      0.891 0.792 0.208
#> GSM110419     1  0.9044      0.768 0.680 0.320
#> GSM110420     1  0.7219      0.896 0.800 0.200
#> GSM110421     2  0.7219      0.805 0.200 0.800
#> GSM110423     2  0.0000      0.914 0.000 1.000
#> GSM110424     2  0.7219      0.805 0.200 0.800
#> GSM110425     2  0.0000      0.914 0.000 1.000
#> GSM110427     2  0.0000      0.914 0.000 1.000
#> GSM110428     1  0.7219      0.896 0.800 0.200
#> GSM110430     1  0.7219      0.896 0.800 0.200
#> GSM110431     1  0.7219      0.896 0.800 0.200
#> GSM110432     2  0.0000      0.914 0.000 1.000
#> GSM110434     2  0.0000      0.914 0.000 1.000
#> GSM110435     1  0.7219      0.896 0.800 0.200
#> GSM110437     1  0.7056      0.896 0.808 0.192
#> GSM110438     1  0.7219      0.896 0.800 0.200
#> GSM110388     1  0.0000      0.831 1.000 0.000
#> GSM110392     1  0.4298      0.779 0.912 0.088
#> GSM110394     1  0.7219      0.896 0.800 0.200
#> GSM110402     2  0.0376      0.911 0.004 0.996
#> GSM110411     1  0.0000      0.831 1.000 0.000
#> GSM110412     2  0.7219      0.805 0.200 0.800
#> GSM110417     1  0.0000      0.831 1.000 0.000
#> GSM110422     2  0.0000      0.914 0.000 1.000
#> GSM110426     1  0.0000      0.831 1.000 0.000
#> GSM110429     2  0.0000      0.914 0.000 1.000
#> GSM110433     2  0.7219      0.805 0.200 0.800
#> GSM110436     2  0.0000      0.914 0.000 1.000
#> GSM110440     1  0.6887      0.895 0.816 0.184
#> GSM110441     2  0.6712      0.823 0.176 0.824
#> GSM110444     1  0.3584      0.796 0.932 0.068
#> GSM110445     1  0.4815      0.876 0.896 0.104
#> GSM110446     1  0.7219      0.896 0.800 0.200
#> GSM110449     2  0.9170      0.674 0.332 0.668
#> GSM110451     2  0.0000      0.914 0.000 1.000
#> GSM110391     2  0.7219      0.805 0.200 0.800
#> GSM110439     2  0.0000      0.914 0.000 1.000
#> GSM110442     2  0.4022      0.880 0.080 0.920
#> GSM110443     2  0.8555      0.462 0.280 0.720
#> GSM110447     2  0.0938      0.909 0.012 0.988
#> GSM110448     1  0.0000      0.831 1.000 0.000
#> GSM110450     1  0.7219      0.896 0.800 0.200
#> GSM110452     2  0.0000      0.914 0.000 1.000
#> GSM110453     2  0.0000      0.914 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
#> GSM110395     2  0.4842      0.751 0.000 0.776 0.224
#> GSM110396     1  0.4811      0.834 0.828 0.148 0.024
#> GSM110397     1  0.1636      0.822 0.964 0.016 0.020
#> GSM110398     1  0.4645      0.829 0.816 0.176 0.008
#> GSM110399     2  0.4679      0.631 0.148 0.832 0.020
#> GSM110400     3  0.5760      0.344 0.000 0.328 0.672
#> GSM110401     1  0.5412      0.827 0.796 0.172 0.032
#> GSM110406     2  0.3148      0.771 0.036 0.916 0.048
#> GSM110407     1  0.9183      0.370 0.484 0.156 0.360
#> GSM110409     1  0.8392      0.668 0.624 0.176 0.200
#> GSM110410     2  0.5047      0.790 0.036 0.824 0.140
#> GSM110413     2  0.5173      0.789 0.036 0.816 0.148
#> GSM110414     2  0.5178      0.719 0.000 0.744 0.256
#> GSM110415     3  0.1031      0.832 0.000 0.024 0.976
#> GSM110416     3  0.0424      0.837 0.000 0.008 0.992
#> GSM110418     3  0.0424      0.837 0.000 0.008 0.992
#> GSM110419     3  0.2625      0.821 0.000 0.084 0.916
#> GSM110420     3  0.1163      0.840 0.000 0.028 0.972
#> GSM110421     2  0.4399      0.778 0.188 0.812 0.000
#> GSM110423     3  0.0747      0.835 0.000 0.016 0.984
#> GSM110424     2  0.5344      0.800 0.092 0.824 0.084
#> GSM110425     3  0.0747      0.835 0.000 0.016 0.984
#> GSM110427     2  0.4931      0.744 0.000 0.768 0.232
#> GSM110428     3  0.1031      0.840 0.000 0.024 0.976
#> GSM110430     1  0.5348      0.827 0.796 0.176 0.028
#> GSM110431     3  0.7104      0.630 0.136 0.140 0.724
#> GSM110432     3  0.2165      0.834 0.000 0.064 0.936
#> GSM110434     2  0.3644      0.718 0.004 0.872 0.124
#> GSM110435     3  0.4749      0.763 0.012 0.172 0.816
#> GSM110437     1  0.5467      0.826 0.792 0.176 0.032
#> GSM110438     3  0.4409      0.768 0.004 0.172 0.824
#> GSM110388     1  0.0237      0.815 0.996 0.004 0.000
#> GSM110392     3  0.5536      0.663 0.236 0.012 0.752
#> GSM110394     3  0.5558      0.742 0.048 0.152 0.800
#> GSM110402     3  0.0892      0.839 0.000 0.020 0.980
#> GSM110411     1  0.0592      0.813 0.988 0.012 0.000
#> GSM110412     2  0.4399      0.778 0.188 0.812 0.000
#> GSM110417     1  0.0592      0.813 0.988 0.012 0.000
#> GSM110422     2  0.4504      0.757 0.000 0.804 0.196
#> GSM110426     1  0.1182      0.812 0.976 0.012 0.012
#> GSM110429     2  0.6302      0.261 0.000 0.520 0.480
#> GSM110433     2  0.5053      0.790 0.164 0.812 0.024
#> GSM110436     3  0.6286     -0.156 0.000 0.464 0.536
#> GSM110440     1  0.7447      0.751 0.700 0.140 0.160
#> GSM110441     2  0.5119      0.796 0.152 0.816 0.032
#> GSM110444     1  0.0747      0.811 0.984 0.016 0.000
#> GSM110445     1  0.4953      0.829 0.808 0.176 0.016
#> GSM110446     3  0.4645      0.763 0.008 0.176 0.816
#> GSM110449     1  0.3941      0.685 0.844 0.156 0.000
#> GSM110451     3  0.3816      0.721 0.000 0.148 0.852
#> GSM110391     2  0.4452      0.776 0.192 0.808 0.000
#> GSM110439     2  0.1170      0.775 0.008 0.976 0.016
#> GSM110442     2  0.4121      0.807 0.108 0.868 0.024
#> GSM110443     2  0.8938      0.102 0.284 0.552 0.164
#> GSM110447     3  0.0892      0.834 0.000 0.020 0.980
#> GSM110448     1  0.0424      0.814 0.992 0.008 0.000
#> GSM110450     1  0.6809      0.793 0.740 0.156 0.104
#> GSM110452     2  0.1182      0.775 0.012 0.976 0.012
#> GSM110453     2  0.1525      0.785 0.004 0.964 0.032

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4499      0.721 0.072 0.804 0.124 0.000
#> GSM110396     1  0.2466      0.819 0.900 0.000 0.004 0.096
#> GSM110397     4  0.5064      0.432 0.360 0.004 0.004 0.632
#> GSM110398     1  0.3497      0.793 0.860 0.104 0.000 0.036
#> GSM110399     1  0.4103      0.694 0.744 0.256 0.000 0.000
#> GSM110400     3  0.4233      0.709 0.008 0.044 0.828 0.120
#> GSM110401     1  0.1510      0.863 0.956 0.000 0.028 0.016
#> GSM110406     1  0.4797      0.689 0.720 0.260 0.020 0.000
#> GSM110407     1  0.2647      0.821 0.880 0.000 0.120 0.000
#> GSM110409     1  0.0927      0.864 0.976 0.008 0.016 0.000
#> GSM110410     2  0.0188      0.815 0.000 0.996 0.004 0.000
#> GSM110413     2  0.6543      0.564 0.012 0.640 0.092 0.256
#> GSM110414     3  0.7635      0.173 0.008 0.272 0.516 0.204
#> GSM110415     3  0.2010      0.781 0.008 0.012 0.940 0.040
#> GSM110416     3  0.1847      0.816 0.052 0.004 0.940 0.004
#> GSM110418     3  0.1492      0.815 0.036 0.004 0.956 0.004
#> GSM110419     3  0.2345      0.805 0.100 0.000 0.900 0.000
#> GSM110420     3  0.2480      0.809 0.088 0.000 0.904 0.008
#> GSM110421     4  0.5420      0.468 0.008 0.276 0.028 0.688
#> GSM110423     3  0.0817      0.803 0.000 0.024 0.976 0.000
#> GSM110424     2  0.5485      0.683 0.008 0.744 0.080 0.168
#> GSM110425     3  0.0592      0.812 0.016 0.000 0.984 0.000
#> GSM110427     2  0.2796      0.785 0.008 0.892 0.096 0.004
#> GSM110428     3  0.2647      0.802 0.120 0.000 0.880 0.000
#> GSM110430     1  0.1598      0.861 0.956 0.004 0.020 0.020
#> GSM110431     3  0.2973      0.789 0.144 0.000 0.856 0.000
#> GSM110432     3  0.6115      0.679 0.172 0.148 0.680 0.000
#> GSM110434     2  0.2867      0.770 0.104 0.884 0.012 0.000
#> GSM110435     3  0.2973      0.794 0.144 0.000 0.856 0.000
#> GSM110437     1  0.1339      0.863 0.964 0.004 0.024 0.008
#> GSM110438     3  0.3355      0.784 0.160 0.004 0.836 0.000
#> GSM110388     4  0.1716      0.828 0.064 0.000 0.000 0.936
#> GSM110392     3  0.6063      0.470 0.008 0.048 0.628 0.316
#> GSM110394     3  0.4925      0.319 0.428 0.000 0.572 0.000
#> GSM110402     3  0.1743      0.815 0.056 0.004 0.940 0.000
#> GSM110411     4  0.0336      0.823 0.008 0.000 0.000 0.992
#> GSM110412     4  0.3344      0.761 0.008 0.024 0.092 0.876
#> GSM110417     4  0.2868      0.781 0.136 0.000 0.000 0.864
#> GSM110422     2  0.1059      0.815 0.016 0.972 0.012 0.000
#> GSM110426     4  0.3745      0.791 0.088 0.000 0.060 0.852
#> GSM110429     2  0.3768      0.663 0.008 0.808 0.184 0.000
#> GSM110433     2  0.6751      0.440 0.008 0.576 0.088 0.328
#> GSM110436     3  0.5400      0.217 0.008 0.428 0.560 0.004
#> GSM110440     1  0.5376      0.723 0.736 0.000 0.176 0.088
#> GSM110441     2  0.2530      0.771 0.000 0.888 0.000 0.112
#> GSM110444     4  0.0188      0.822 0.004 0.000 0.000 0.996
#> GSM110445     1  0.1706      0.847 0.948 0.016 0.000 0.036
#> GSM110446     3  0.3583      0.775 0.180 0.004 0.816 0.000
#> GSM110449     2  0.7464      0.204 0.328 0.480 0.000 0.192
#> GSM110451     3  0.5599      0.507 0.040 0.316 0.644 0.000
#> GSM110391     4  0.4712      0.683 0.008 0.132 0.060 0.800
#> GSM110439     2  0.0895      0.814 0.020 0.976 0.004 0.000
#> GSM110442     2  0.0376      0.815 0.004 0.992 0.004 0.000
#> GSM110443     1  0.3105      0.817 0.868 0.120 0.012 0.000
#> GSM110447     3  0.1139      0.796 0.008 0.012 0.972 0.008
#> GSM110448     4  0.1792      0.828 0.068 0.000 0.000 0.932
#> GSM110450     1  0.2401      0.841 0.904 0.000 0.092 0.004
#> GSM110452     2  0.0707      0.813 0.020 0.980 0.000 0.000
#> GSM110453     2  0.0779      0.815 0.016 0.980 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     5  0.6650     0.3866 0.144 0.336 0.020 0.000 0.500
#> GSM110396     1  0.4221     0.7385 0.732 0.000 0.000 0.032 0.236
#> GSM110397     4  0.3421     0.6774 0.152 0.000 0.008 0.824 0.016
#> GSM110398     1  0.4775     0.6609 0.768 0.104 0.000 0.100 0.028
#> GSM110399     1  0.3875     0.7398 0.804 0.124 0.000 0.000 0.072
#> GSM110400     3  0.4516     0.3347 0.004 0.004 0.576 0.000 0.416
#> GSM110401     1  0.2338     0.7766 0.884 0.000 0.004 0.000 0.112
#> GSM110406     1  0.4585     0.6038 0.592 0.008 0.004 0.000 0.396
#> GSM110407     1  0.3863     0.7309 0.740 0.000 0.012 0.000 0.248
#> GSM110409     1  0.1314     0.7765 0.960 0.012 0.012 0.000 0.016
#> GSM110410     2  0.0162     0.8093 0.000 0.996 0.000 0.000 0.004
#> GSM110413     5  0.1372     0.5551 0.024 0.016 0.000 0.004 0.956
#> GSM110414     3  0.5411     0.1016 0.004 0.020 0.492 0.016 0.468
#> GSM110415     3  0.0960     0.8325 0.004 0.000 0.972 0.016 0.008
#> GSM110416     3  0.0162     0.8353 0.000 0.000 0.996 0.004 0.000
#> GSM110418     3  0.0324     0.8349 0.004 0.000 0.992 0.004 0.000
#> GSM110419     3  0.1195     0.8314 0.028 0.000 0.960 0.000 0.012
#> GSM110420     3  0.0290     0.8354 0.000 0.000 0.992 0.008 0.000
#> GSM110421     5  0.6139     0.6381 0.000 0.260 0.000 0.184 0.556
#> GSM110423     3  0.0854     0.8334 0.004 0.012 0.976 0.000 0.008
#> GSM110424     2  0.4652     0.5726 0.004 0.768 0.008 0.116 0.104
#> GSM110425     3  0.0290     0.8352 0.000 0.000 0.992 0.000 0.008
#> GSM110427     2  0.3033     0.7202 0.000 0.864 0.052 0.000 0.084
#> GSM110428     3  0.2561     0.8024 0.096 0.000 0.884 0.000 0.020
#> GSM110430     1  0.0867     0.7778 0.976 0.000 0.008 0.008 0.008
#> GSM110431     3  0.2707     0.7848 0.132 0.000 0.860 0.000 0.008
#> GSM110432     3  0.4373     0.7016 0.176 0.008 0.764 0.000 0.052
#> GSM110434     2  0.2929     0.6876 0.152 0.840 0.000 0.000 0.008
#> GSM110435     3  0.1059     0.8341 0.020 0.004 0.968 0.000 0.008
#> GSM110437     1  0.3077     0.7405 0.864 0.000 0.008 0.100 0.028
#> GSM110438     3  0.2172     0.8067 0.076 0.000 0.908 0.000 0.016
#> GSM110388     4  0.0162     0.8154 0.000 0.000 0.000 0.996 0.004
#> GSM110392     4  0.4430     0.6597 0.020 0.132 0.036 0.796 0.016
#> GSM110394     3  0.4473     0.3171 0.412 0.000 0.580 0.000 0.008
#> GSM110402     3  0.0162     0.8353 0.000 0.000 0.996 0.004 0.000
#> GSM110411     4  0.2377     0.7559 0.000 0.000 0.000 0.872 0.128
#> GSM110412     4  0.4262     0.5543 0.004 0.000 0.012 0.696 0.288
#> GSM110417     4  0.0404     0.8152 0.000 0.000 0.000 0.988 0.012
#> GSM110422     2  0.0510     0.8070 0.000 0.984 0.016 0.000 0.000
#> GSM110426     4  0.0162     0.8137 0.000 0.000 0.004 0.996 0.000
#> GSM110429     2  0.2338     0.7090 0.000 0.884 0.112 0.000 0.004
#> GSM110433     5  0.5987     0.6134 0.000 0.304 0.000 0.140 0.556
#> GSM110436     3  0.5111     0.0881 0.000 0.464 0.500 0.000 0.036
#> GSM110440     1  0.6027     0.4712 0.600 0.000 0.124 0.264 0.012
#> GSM110441     2  0.4403    -0.2237 0.000 0.560 0.000 0.004 0.436
#> GSM110444     4  0.4074     0.4067 0.000 0.000 0.000 0.636 0.364
#> GSM110445     1  0.1872     0.7694 0.928 0.000 0.000 0.052 0.020
#> GSM110446     3  0.3216     0.7743 0.116 0.000 0.852 0.012 0.020
#> GSM110449     2  0.5361     0.5096 0.104 0.680 0.000 0.208 0.008
#> GSM110451     3  0.3842     0.7251 0.028 0.156 0.804 0.000 0.012
#> GSM110391     5  0.4281     0.5646 0.000 0.056 0.004 0.172 0.768
#> GSM110439     2  0.0000     0.8099 0.000 1.000 0.000 0.000 0.000
#> GSM110442     2  0.0290     0.8097 0.000 0.992 0.000 0.000 0.008
#> GSM110443     1  0.6204     0.3116 0.524 0.336 0.000 0.004 0.136
#> GSM110447     3  0.0902     0.8337 0.004 0.004 0.976 0.008 0.008
#> GSM110448     4  0.0290     0.8158 0.000 0.000 0.000 0.992 0.008
#> GSM110450     1  0.3205     0.7609 0.816 0.000 0.004 0.004 0.176
#> GSM110452     2  0.0898     0.8032 0.020 0.972 0.000 0.000 0.008
#> GSM110453     2  0.0000     0.8099 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     5  0.7695     0.2624 0.264 0.184 0.028 0.000 0.408 0.116
#> GSM110396     1  0.3185     0.4876 0.848 0.000 0.000 0.016 0.060 0.076
#> GSM110397     4  0.2838     0.6881 0.028 0.000 0.000 0.852 0.004 0.116
#> GSM110398     6  0.7632     0.0000 0.264 0.260 0.000 0.092 0.020 0.364
#> GSM110399     1  0.5753    -0.2560 0.512 0.376 0.000 0.000 0.044 0.068
#> GSM110400     3  0.4420     0.5660 0.008 0.004 0.700 0.000 0.244 0.044
#> GSM110401     1  0.1218     0.5151 0.956 0.000 0.000 0.012 0.004 0.028
#> GSM110406     1  0.5033     0.4207 0.684 0.020 0.000 0.000 0.164 0.132
#> GSM110407     1  0.1838     0.5206 0.928 0.000 0.012 0.000 0.020 0.040
#> GSM110409     1  0.4668     0.2402 0.668 0.040 0.008 0.004 0.004 0.276
#> GSM110410     2  0.2058     0.6532 0.000 0.908 0.000 0.000 0.056 0.036
#> GSM110413     5  0.3555     0.5828 0.104 0.016 0.000 0.004 0.824 0.052
#> GSM110414     5  0.5199    -0.0753 0.000 0.016 0.464 0.000 0.468 0.052
#> GSM110415     3  0.1078     0.7732 0.000 0.000 0.964 0.012 0.016 0.008
#> GSM110416     3  0.0000     0.7744 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0622     0.7748 0.000 0.000 0.980 0.008 0.000 0.012
#> GSM110419     3  0.1932     0.7727 0.040 0.000 0.924 0.000 0.016 0.020
#> GSM110420     3  0.1053     0.7747 0.004 0.000 0.964 0.012 0.000 0.020
#> GSM110421     5  0.4007     0.5877 0.000 0.068 0.000 0.108 0.792 0.032
#> GSM110423     3  0.0717     0.7727 0.000 0.000 0.976 0.000 0.008 0.016
#> GSM110424     2  0.6407     0.3763 0.000 0.520 0.016 0.032 0.296 0.136
#> GSM110425     3  0.1801     0.7608 0.004 0.000 0.924 0.000 0.016 0.056
#> GSM110427     2  0.6243     0.2799 0.000 0.524 0.060 0.000 0.300 0.116
#> GSM110428     1  0.6934     0.1393 0.408 0.000 0.328 0.008 0.048 0.208
#> GSM110430     1  0.2709     0.4647 0.848 0.000 0.000 0.020 0.000 0.132
#> GSM110431     3  0.4587     0.5019 0.316 0.000 0.632 0.000 0.004 0.048
#> GSM110432     3  0.7828     0.2363 0.256 0.040 0.412 0.000 0.164 0.128
#> GSM110434     2  0.2565     0.5729 0.016 0.872 0.008 0.000 0.000 0.104
#> GSM110435     3  0.3302     0.7283 0.028 0.008 0.824 0.004 0.000 0.136
#> GSM110437     1  0.5375     0.1409 0.564 0.004 0.004 0.100 0.000 0.328
#> GSM110438     3  0.4303     0.6833 0.052 0.012 0.756 0.012 0.000 0.168
#> GSM110388     4  0.2201     0.7927 0.000 0.000 0.000 0.900 0.052 0.048
#> GSM110392     4  0.4327     0.6116 0.000 0.152 0.004 0.760 0.024 0.060
#> GSM110394     3  0.3684     0.5167 0.332 0.000 0.664 0.000 0.000 0.004
#> GSM110402     3  0.0405     0.7759 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM110411     4  0.3956     0.6936 0.000 0.000 0.000 0.712 0.252 0.036
#> GSM110412     4  0.4490     0.5044 0.000 0.000 0.008 0.596 0.372 0.024
#> GSM110417     4  0.1562     0.7874 0.004 0.000 0.000 0.940 0.024 0.032
#> GSM110422     2  0.1894     0.6480 0.004 0.928 0.040 0.000 0.012 0.016
#> GSM110426     4  0.0935     0.7844 0.000 0.000 0.004 0.964 0.000 0.032
#> GSM110429     2  0.2239     0.6404 0.000 0.908 0.048 0.000 0.020 0.024
#> GSM110433     5  0.3572     0.6137 0.000 0.100 0.000 0.060 0.820 0.020
#> GSM110436     2  0.7414     0.0504 0.000 0.384 0.204 0.000 0.260 0.152
#> GSM110440     1  0.5982     0.3407 0.612 0.000 0.120 0.216 0.016 0.036
#> GSM110441     2  0.5788     0.1764 0.000 0.464 0.004 0.012 0.412 0.108
#> GSM110444     4  0.3758     0.6711 0.000 0.000 0.000 0.700 0.284 0.016
#> GSM110445     1  0.5059     0.2724 0.652 0.028 0.000 0.052 0.004 0.264
#> GSM110446     3  0.5157     0.6039 0.036 0.020 0.680 0.040 0.000 0.224
#> GSM110449     2  0.5785     0.2295 0.020 0.632 0.000 0.096 0.032 0.220
#> GSM110451     3  0.7291     0.3251 0.036 0.176 0.512 0.000 0.172 0.104
#> GSM110391     5  0.3840     0.5703 0.000 0.028 0.004 0.088 0.812 0.068
#> GSM110439     2  0.1010     0.6469 0.000 0.960 0.000 0.000 0.004 0.036
#> GSM110442     2  0.3497     0.6322 0.004 0.832 0.000 0.016 0.076 0.072
#> GSM110443     1  0.7026     0.1849 0.484 0.240 0.000 0.052 0.024 0.200
#> GSM110447     3  0.4917     0.5643 0.000 0.004 0.700 0.016 0.172 0.108
#> GSM110448     4  0.1285     0.7974 0.000 0.000 0.000 0.944 0.052 0.004
#> GSM110450     1  0.4601     0.4764 0.720 0.004 0.000 0.068 0.016 0.192
#> GSM110452     2  0.1606     0.6335 0.004 0.932 0.000 0.000 0.008 0.056
#> GSM110453     2  0.0260     0.6577 0.000 0.992 0.000 0.000 0.008 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

plot of chunk tab-MAD-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-MAD-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-MAD-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-MAD-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-MAD-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-MAD-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) specimen(p) k
#> MAD:NMF 58          0.77828       0.299 2
#> MAD:NMF 54          0.31690       0.188 3
#> MAD:NMF 51          0.00239       0.320 4
#> MAD:NMF 50          0.01015       0.264 5
#> MAD:NMF 38          0.01317       0.108 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 17209 rows and 59 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 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-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.628           0.693       0.886         0.4695 0.524   0.524
#> 3 3 0.546           0.755       0.828         0.3594 0.707   0.487
#> 4 4 0.580           0.695       0.804         0.1224 0.936   0.802
#> 5 5 0.632           0.603       0.764         0.0630 0.901   0.671
#> 6 6 0.676           0.654       0.759         0.0483 0.905   0.637

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
#> GSM110395     2  0.0000     0.8496 0.000 1.000
#> GSM110396     1  0.0000     0.8665 1.000 0.000
#> GSM110397     1  0.0000     0.8665 1.000 0.000
#> GSM110398     1  0.9833     0.2123 0.576 0.424
#> GSM110399     2  0.9922     0.2168 0.448 0.552
#> GSM110400     2  0.0000     0.8496 0.000 1.000
#> GSM110401     1  0.0000     0.8665 1.000 0.000
#> GSM110406     2  0.9922     0.2168 0.448 0.552
#> GSM110407     1  0.0376     0.8671 0.996 0.004
#> GSM110409     1  0.0376     0.8671 0.996 0.004
#> GSM110410     2  0.0000     0.8496 0.000 1.000
#> GSM110413     2  0.0000     0.8496 0.000 1.000
#> GSM110414     2  0.0000     0.8496 0.000 1.000
#> GSM110415     2  0.4161     0.8009 0.084 0.916
#> GSM110416     2  0.9988     0.0848 0.480 0.520
#> GSM110418     2  0.9988     0.0848 0.480 0.520
#> GSM110419     2  0.4161     0.8009 0.084 0.916
#> GSM110420     1  0.9754     0.2444 0.592 0.408
#> GSM110421     2  0.0000     0.8496 0.000 1.000
#> GSM110423     2  0.0000     0.8496 0.000 1.000
#> GSM110424     2  0.0000     0.8496 0.000 1.000
#> GSM110425     2  0.0000     0.8496 0.000 1.000
#> GSM110427     2  0.0000     0.8496 0.000 1.000
#> GSM110428     1  0.9775     0.2486 0.588 0.412
#> GSM110430     1  0.0000     0.8665 1.000 0.000
#> GSM110431     1  0.0000     0.8665 1.000 0.000
#> GSM110432     2  0.3431     0.8160 0.064 0.936
#> GSM110434     2  0.0000     0.8496 0.000 1.000
#> GSM110435     1  0.0376     0.8671 0.996 0.004
#> GSM110437     1  0.0000     0.8665 1.000 0.000
#> GSM110438     1  0.9775     0.2486 0.588 0.412
#> GSM110388     1  0.0376     0.8671 0.996 0.004
#> GSM110392     2  0.9922     0.2168 0.448 0.552
#> GSM110394     1  0.0376     0.8671 0.996 0.004
#> GSM110402     2  0.2603     0.8289 0.044 0.956
#> GSM110411     1  0.9833     0.2123 0.576 0.424
#> GSM110412     2  0.2778     0.8267 0.048 0.952
#> GSM110417     1  0.0000     0.8665 1.000 0.000
#> GSM110422     2  0.0000     0.8496 0.000 1.000
#> GSM110426     1  0.0000     0.8665 1.000 0.000
#> GSM110429     2  0.0000     0.8496 0.000 1.000
#> GSM110433     2  0.0000     0.8496 0.000 1.000
#> GSM110436     2  0.0000     0.8496 0.000 1.000
#> GSM110440     1  0.0376     0.8671 0.996 0.004
#> GSM110441     2  0.0000     0.8496 0.000 1.000
#> GSM110444     2  0.9922     0.2168 0.448 0.552
#> GSM110445     1  0.5294     0.7629 0.880 0.120
#> GSM110446     2  0.9996     0.0550 0.488 0.512
#> GSM110449     2  0.9922     0.2168 0.448 0.552
#> GSM110451     2  0.0000     0.8496 0.000 1.000
#> GSM110391     2  0.0000     0.8496 0.000 1.000
#> GSM110439     2  0.0000     0.8496 0.000 1.000
#> GSM110442     2  0.0000     0.8496 0.000 1.000
#> GSM110443     2  0.9922     0.2168 0.448 0.552
#> GSM110447     2  0.2603     0.8290 0.044 0.956
#> GSM110448     1  0.0376     0.8671 0.996 0.004
#> GSM110450     1  0.0672     0.8646 0.992 0.008
#> GSM110452     2  0.0000     0.8496 0.000 1.000
#> GSM110453     2  0.0000     0.8496 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
#> GSM110395     2   0.196      0.931 0.000 0.944 0.056
#> GSM110396     1   0.000      0.919 1.000 0.000 0.000
#> GSM110397     1   0.216      0.896 0.936 0.000 0.064
#> GSM110398     3   0.665      0.591 0.240 0.048 0.712
#> GSM110399     3   0.803      0.680 0.172 0.172 0.656
#> GSM110400     3   0.631      0.117 0.000 0.496 0.504
#> GSM110401     1   0.216      0.896 0.936 0.000 0.064
#> GSM110406     3   0.803      0.680 0.172 0.172 0.656
#> GSM110407     1   0.216      0.919 0.936 0.000 0.064
#> GSM110409     1   0.216      0.919 0.936 0.000 0.064
#> GSM110410     2   0.000      0.924 0.000 1.000 0.000
#> GSM110413     2   0.175      0.936 0.000 0.952 0.048
#> GSM110414     2   0.000      0.924 0.000 1.000 0.000
#> GSM110415     3   0.581      0.470 0.000 0.336 0.664
#> GSM110416     3   0.341      0.578 0.124 0.000 0.876
#> GSM110418     3   0.341      0.578 0.124 0.000 0.876
#> GSM110419     3   0.581      0.470 0.000 0.336 0.664
#> GSM110420     3   0.546      0.357 0.288 0.000 0.712
#> GSM110421     2   0.196      0.931 0.000 0.944 0.056
#> GSM110423     3   0.631      0.117 0.000 0.496 0.504
#> GSM110424     2   0.000      0.924 0.000 1.000 0.000
#> GSM110425     3   0.631      0.117 0.000 0.496 0.504
#> GSM110427     2   0.000      0.924 0.000 1.000 0.000
#> GSM110428     3   0.676      0.578 0.252 0.048 0.700
#> GSM110430     1   0.216      0.896 0.936 0.000 0.064
#> GSM110431     1   0.216      0.896 0.936 0.000 0.064
#> GSM110432     2   0.525      0.596 0.000 0.736 0.264
#> GSM110434     2   0.196      0.931 0.000 0.944 0.056
#> GSM110435     1   0.207      0.921 0.940 0.000 0.060
#> GSM110437     1   0.216      0.896 0.936 0.000 0.064
#> GSM110438     3   0.676      0.578 0.252 0.048 0.700
#> GSM110388     1   0.288      0.897 0.904 0.000 0.096
#> GSM110392     3   0.803      0.680 0.172 0.172 0.656
#> GSM110394     1   0.207      0.921 0.940 0.000 0.060
#> GSM110402     3   0.610      0.377 0.000 0.392 0.608
#> GSM110411     3   0.665      0.591 0.240 0.048 0.712
#> GSM110412     2   0.502      0.649 0.000 0.760 0.240
#> GSM110417     1   0.000      0.919 1.000 0.000 0.000
#> GSM110422     2   0.175      0.936 0.000 0.952 0.048
#> GSM110426     1   0.000      0.919 1.000 0.000 0.000
#> GSM110429     2   0.296      0.882 0.000 0.900 0.100
#> GSM110433     2   0.000      0.924 0.000 1.000 0.000
#> GSM110436     2   0.000      0.924 0.000 1.000 0.000
#> GSM110440     1   0.207      0.921 0.940 0.000 0.060
#> GSM110441     2   0.175      0.936 0.000 0.952 0.048
#> GSM110444     3   0.803      0.680 0.172 0.172 0.656
#> GSM110445     1   0.522      0.652 0.740 0.000 0.260
#> GSM110446     3   0.355      0.571 0.132 0.000 0.868
#> GSM110449     3   0.803      0.680 0.172 0.172 0.656
#> GSM110451     2   0.175      0.936 0.000 0.952 0.048
#> GSM110391     2   0.175      0.936 0.000 0.952 0.048
#> GSM110439     2   0.000      0.924 0.000 1.000 0.000
#> GSM110442     2   0.175      0.936 0.000 0.952 0.048
#> GSM110443     3   0.803      0.680 0.172 0.172 0.656
#> GSM110447     3   0.624      0.281 0.000 0.440 0.560
#> GSM110448     1   0.226      0.917 0.932 0.000 0.068
#> GSM110450     1   0.296      0.893 0.900 0.000 0.100
#> GSM110452     2   0.175      0.936 0.000 0.952 0.048
#> GSM110453     2   0.000      0.924 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.3172      0.833 0.000 0.840 0.000 0.160
#> GSM110396     1  0.2530      0.857 0.888 0.000 0.112 0.000
#> GSM110397     1  0.4040      0.813 0.752 0.000 0.248 0.000
#> GSM110398     4  0.4591      0.689 0.116 0.000 0.084 0.800
#> GSM110399     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110400     3  0.7859      0.447 0.000 0.352 0.376 0.272
#> GSM110401     1  0.4040      0.813 0.752 0.000 0.248 0.000
#> GSM110406     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110407     1  0.0376      0.858 0.992 0.000 0.004 0.004
#> GSM110409     1  0.0376      0.858 0.992 0.000 0.004 0.004
#> GSM110410     2  0.1118      0.805 0.000 0.964 0.036 0.000
#> GSM110413     2  0.2973      0.842 0.000 0.856 0.000 0.144
#> GSM110414     2  0.1118      0.805 0.000 0.964 0.036 0.000
#> GSM110415     3  0.7589      0.463 0.000 0.196 0.404 0.400
#> GSM110416     3  0.5948      0.380 0.144 0.000 0.696 0.160
#> GSM110418     3  0.5948      0.380 0.144 0.000 0.696 0.160
#> GSM110419     3  0.7589      0.463 0.000 0.196 0.404 0.400
#> GSM110420     3  0.4605      0.312 0.336 0.000 0.664 0.000
#> GSM110421     2  0.3172      0.833 0.000 0.840 0.000 0.160
#> GSM110423     3  0.7859      0.447 0.000 0.352 0.376 0.272
#> GSM110424     2  0.1118      0.805 0.000 0.964 0.036 0.000
#> GSM110425     3  0.7859      0.447 0.000 0.352 0.376 0.272
#> GSM110427     2  0.1118      0.805 0.000 0.964 0.036 0.000
#> GSM110428     4  0.4992      0.665 0.132 0.000 0.096 0.772
#> GSM110430     1  0.4040      0.813 0.752 0.000 0.248 0.000
#> GSM110431     1  0.4040      0.813 0.752 0.000 0.248 0.000
#> GSM110432     2  0.4941      0.378 0.000 0.564 0.000 0.436
#> GSM110434     2  0.3172      0.833 0.000 0.840 0.000 0.160
#> GSM110435     1  0.0188      0.859 0.996 0.000 0.000 0.004
#> GSM110437     1  0.4040      0.813 0.752 0.000 0.248 0.000
#> GSM110438     4  0.4992      0.665 0.132 0.000 0.096 0.772
#> GSM110388     1  0.1388      0.842 0.960 0.000 0.028 0.012
#> GSM110392     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110394     1  0.0188      0.859 0.996 0.000 0.000 0.004
#> GSM110402     3  0.7800      0.480 0.000 0.248 0.376 0.376
#> GSM110411     4  0.4591      0.689 0.116 0.000 0.084 0.800
#> GSM110412     2  0.4888      0.416 0.000 0.588 0.000 0.412
#> GSM110417     1  0.2530      0.857 0.888 0.000 0.112 0.000
#> GSM110422     2  0.2469      0.839 0.000 0.892 0.000 0.108
#> GSM110426     1  0.2469      0.857 0.892 0.000 0.108 0.000
#> GSM110429     2  0.3726      0.751 0.000 0.788 0.000 0.212
#> GSM110433     2  0.1118      0.805 0.000 0.964 0.036 0.000
#> GSM110436     2  0.1004      0.809 0.000 0.972 0.024 0.004
#> GSM110440     1  0.0188      0.859 0.996 0.000 0.000 0.004
#> GSM110441     2  0.3105      0.842 0.000 0.856 0.004 0.140
#> GSM110444     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110445     1  0.6180      0.406 0.624 0.000 0.080 0.296
#> GSM110446     3  0.5650      0.361 0.180 0.000 0.716 0.104
#> GSM110449     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110451     2  0.2973      0.842 0.000 0.856 0.000 0.144
#> GSM110391     2  0.2973      0.842 0.000 0.856 0.000 0.144
#> GSM110439     2  0.1305      0.807 0.000 0.960 0.036 0.004
#> GSM110442     2  0.3074      0.838 0.000 0.848 0.000 0.152
#> GSM110443     4  0.0000      0.764 0.000 0.000 0.000 1.000
#> GSM110447     4  0.7871     -0.541 0.000 0.284 0.332 0.384
#> GSM110448     1  0.0469      0.856 0.988 0.000 0.000 0.012
#> GSM110450     1  0.4365      0.664 0.784 0.000 0.028 0.188
#> GSM110452     2  0.2973      0.842 0.000 0.856 0.000 0.144
#> GSM110453     2  0.1118      0.805 0.000 0.964 0.036 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
#> GSM110395     2  0.0963      0.656 0.000 0.964 0.000 0.036 0.000
#> GSM110396     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM110397     1  0.3653      0.774 0.828 0.000 0.036 0.012 0.124
#> GSM110398     4  0.3115      0.779 0.000 0.012 0.108 0.860 0.020
#> GSM110399     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110400     2  0.6952     -0.135 0.000 0.456 0.364 0.148 0.032
#> GSM110401     1  0.3653      0.774 0.828 0.000 0.036 0.012 0.124
#> GSM110406     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110407     1  0.3044      0.828 0.840 0.000 0.148 0.004 0.008
#> GSM110409     1  0.3044      0.828 0.840 0.000 0.148 0.004 0.008
#> GSM110410     5  0.3999      0.987 0.000 0.344 0.000 0.000 0.656
#> GSM110413     2  0.1082      0.653 0.000 0.964 0.000 0.028 0.008
#> GSM110414     5  0.3913      0.962 0.000 0.324 0.000 0.000 0.676
#> GSM110415     3  0.7442      0.379 0.000 0.272 0.368 0.328 0.032
#> GSM110416     3  0.4871      0.496 0.000 0.000 0.704 0.212 0.084
#> GSM110418     3  0.4871      0.496 0.000 0.000 0.704 0.212 0.084
#> GSM110419     3  0.7442      0.379 0.000 0.272 0.368 0.328 0.032
#> GSM110420     3  0.5032      0.359 0.128 0.000 0.704 0.000 0.168
#> GSM110421     2  0.0963      0.656 0.000 0.964 0.000 0.036 0.000
#> GSM110423     2  0.6952     -0.135 0.000 0.456 0.364 0.148 0.032
#> GSM110424     2  0.4138     -0.285 0.000 0.616 0.000 0.000 0.384
#> GSM110425     2  0.6952     -0.135 0.000 0.456 0.364 0.148 0.032
#> GSM110427     2  0.3612      0.131 0.000 0.732 0.000 0.000 0.268
#> GSM110428     4  0.3431      0.751 0.000 0.008 0.144 0.828 0.020
#> GSM110430     1  0.3653      0.774 0.828 0.000 0.036 0.012 0.124
#> GSM110431     1  0.3653      0.774 0.828 0.000 0.036 0.012 0.124
#> GSM110432     2  0.3876      0.463 0.000 0.684 0.000 0.316 0.000
#> GSM110434     2  0.0963      0.656 0.000 0.964 0.000 0.036 0.000
#> GSM110435     1  0.2921      0.828 0.844 0.000 0.148 0.004 0.004
#> GSM110437     1  0.3653      0.774 0.828 0.000 0.036 0.012 0.124
#> GSM110438     4  0.3431      0.751 0.000 0.008 0.144 0.828 0.020
#> GSM110388     1  0.3437      0.813 0.808 0.000 0.176 0.004 0.012
#> GSM110392     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110394     1  0.2921      0.828 0.844 0.000 0.148 0.004 0.004
#> GSM110402     3  0.7420      0.235 0.000 0.348 0.364 0.256 0.032
#> GSM110411     4  0.3115      0.779 0.000 0.012 0.108 0.860 0.020
#> GSM110412     2  0.3752      0.492 0.000 0.708 0.000 0.292 0.000
#> GSM110417     1  0.0000      0.826 1.000 0.000 0.000 0.000 0.000
#> GSM110422     2  0.0609      0.619 0.000 0.980 0.000 0.000 0.020
#> GSM110426     1  0.0162      0.826 0.996 0.000 0.004 0.000 0.000
#> GSM110429     2  0.1851      0.620 0.000 0.912 0.000 0.088 0.000
#> GSM110433     5  0.3999      0.987 0.000 0.344 0.000 0.000 0.656
#> GSM110436     2  0.3177      0.286 0.000 0.792 0.000 0.000 0.208
#> GSM110440     1  0.2921      0.828 0.844 0.000 0.148 0.004 0.004
#> GSM110441     2  0.1668      0.637 0.000 0.940 0.000 0.028 0.032
#> GSM110444     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110445     1  0.6532      0.303 0.500 0.000 0.124 0.356 0.020
#> GSM110446     3  0.5271      0.440 0.000 0.000 0.680 0.152 0.168
#> GSM110449     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110451     2  0.1082      0.653 0.000 0.964 0.000 0.028 0.008
#> GSM110391     2  0.1082      0.653 0.000 0.964 0.000 0.028 0.008
#> GSM110439     2  0.3586      0.145 0.000 0.736 0.000 0.000 0.264
#> GSM110442     2  0.1251      0.655 0.000 0.956 0.000 0.036 0.008
#> GSM110443     4  0.1792      0.851 0.000 0.084 0.000 0.916 0.000
#> GSM110447     2  0.7229     -0.277 0.000 0.384 0.332 0.264 0.020
#> GSM110448     1  0.3006      0.826 0.836 0.000 0.156 0.004 0.004
#> GSM110450     1  0.5949      0.644 0.632 0.000 0.176 0.180 0.012
#> GSM110452     2  0.1195      0.651 0.000 0.960 0.000 0.028 0.012
#> GSM110453     5  0.3999      0.987 0.000 0.344 0.000 0.000 0.656

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.1124     0.7980 0.000 0.956 0.008 0.036 0.000 0.000
#> GSM110396     1  0.3515     0.1165 0.676 0.000 0.000 0.000 0.000 0.324
#> GSM110397     6  0.3547     1.0000 0.332 0.000 0.000 0.000 0.000 0.668
#> GSM110398     4  0.3499     0.7386 0.004 0.000 0.264 0.728 0.004 0.000
#> GSM110399     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110400     3  0.5353     0.4929 0.000 0.420 0.472 0.108 0.000 0.000
#> GSM110401     6  0.3547     1.0000 0.332 0.000 0.000 0.000 0.000 0.668
#> GSM110406     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110407     1  0.0146     0.7783 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110409     1  0.0146     0.7783 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM110410     5  0.5720     0.7767 0.000 0.180 0.000 0.000 0.488 0.332
#> GSM110413     2  0.0713     0.8024 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM110414     5  0.6070     0.7623 0.000 0.160 0.020 0.000 0.488 0.332
#> GSM110415     3  0.5784     0.5992 0.000 0.236 0.504 0.260 0.000 0.000
#> GSM110416     3  0.5002     0.2615 0.000 0.000 0.636 0.136 0.228 0.000
#> GSM110418     3  0.5002     0.2615 0.000 0.000 0.636 0.136 0.228 0.000
#> GSM110419     3  0.5784     0.5992 0.000 0.236 0.504 0.260 0.000 0.000
#> GSM110420     5  0.5764    -0.0813 0.228 0.000 0.264 0.000 0.508 0.000
#> GSM110421     2  0.1124     0.7980 0.000 0.956 0.008 0.036 0.000 0.000
#> GSM110423     3  0.5353     0.4929 0.000 0.420 0.472 0.108 0.000 0.000
#> GSM110424     2  0.5779    -0.1052 0.000 0.488 0.000 0.000 0.312 0.200
#> GSM110425     3  0.5353     0.4929 0.000 0.420 0.472 0.108 0.000 0.000
#> GSM110427     2  0.3221     0.5603 0.000 0.736 0.000 0.000 0.264 0.000
#> GSM110428     4  0.3997     0.7165 0.004 0.000 0.288 0.688 0.020 0.000
#> GSM110430     6  0.3547     1.0000 0.332 0.000 0.000 0.000 0.000 0.668
#> GSM110431     6  0.3547     1.0000 0.332 0.000 0.000 0.000 0.000 0.668
#> GSM110432     2  0.3923     0.3384 0.000 0.620 0.008 0.372 0.000 0.000
#> GSM110434     2  0.1124     0.7980 0.000 0.956 0.008 0.036 0.000 0.000
#> GSM110435     1  0.0291     0.7780 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM110437     6  0.3547     1.0000 0.332 0.000 0.000 0.000 0.000 0.668
#> GSM110438     4  0.3997     0.7165 0.004 0.000 0.288 0.688 0.020 0.000
#> GSM110388     1  0.1668     0.7462 0.928 0.000 0.060 0.008 0.004 0.000
#> GSM110392     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110394     1  0.0291     0.7780 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM110402     3  0.5886     0.5790 0.000 0.292 0.472 0.236 0.000 0.000
#> GSM110411     4  0.3499     0.7386 0.004 0.000 0.264 0.728 0.004 0.000
#> GSM110412     2  0.3847     0.3735 0.000 0.644 0.008 0.348 0.000 0.000
#> GSM110417     1  0.2697     0.5641 0.812 0.000 0.000 0.000 0.000 0.188
#> GSM110422     2  0.0363     0.7852 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM110426     1  0.2697     0.5646 0.812 0.000 0.000 0.000 0.000 0.188
#> GSM110429     2  0.2134     0.7143 0.000 0.904 0.052 0.044 0.000 0.000
#> GSM110433     5  0.5720     0.7767 0.000 0.180 0.000 0.000 0.488 0.332
#> GSM110436     2  0.2793     0.6435 0.000 0.800 0.000 0.000 0.200 0.000
#> GSM110440     1  0.0291     0.7780 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM110441     2  0.1341     0.7984 0.000 0.948 0.000 0.028 0.024 0.000
#> GSM110444     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110445     1  0.5900     0.2756 0.500 0.000 0.276 0.220 0.004 0.000
#> GSM110446     3  0.4089    -0.0728 0.000 0.000 0.524 0.008 0.468 0.000
#> GSM110449     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110451     2  0.0713     0.8024 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM110391     2  0.0713     0.8024 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM110439     2  0.3198     0.5676 0.000 0.740 0.000 0.000 0.260 0.000
#> GSM110442     2  0.1204     0.7924 0.000 0.944 0.000 0.056 0.000 0.000
#> GSM110443     4  0.0713     0.8153 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM110447     3  0.6112     0.5045 0.000 0.320 0.372 0.308 0.000 0.000
#> GSM110448     1  0.0665     0.7753 0.980 0.000 0.008 0.008 0.000 0.004
#> GSM110450     1  0.3628     0.5643 0.776 0.000 0.036 0.184 0.004 0.000
#> GSM110452     2  0.0858     0.8026 0.000 0.968 0.000 0.028 0.004 0.000
#> GSM110453     5  0.5720     0.7767 0.000 0.180 0.000 0.000 0.488 0.332

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> ATC:hclust 45            1.000       0.675 2
#> ATC:hclust 51            0.762       0.392 3
#> ATC:hclust 45            0.704       0.435 4
#> ATC:hclust 41            0.791       0.665 5
#> ATC:hclust 47            0.181       0.745 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-kmeans-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.956       0.983         0.4879 0.516   0.516
#> 3 3 0.707           0.844       0.905         0.3619 0.711   0.489
#> 4 4 0.654           0.719       0.788         0.1178 0.880   0.654
#> 5 5 0.658           0.579       0.692         0.0629 1.000   1.000
#> 6 6 0.706           0.598       0.738         0.0427 0.828   0.419

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
#> GSM110395     2   0.000      0.976 0.000 1.000
#> GSM110396     1   0.000      0.990 1.000 0.000
#> GSM110397     1   0.000      0.990 1.000 0.000
#> GSM110398     1   0.000      0.990 1.000 0.000
#> GSM110399     2   0.000      0.976 0.000 1.000
#> GSM110400     2   0.000      0.976 0.000 1.000
#> GSM110401     1   0.000      0.990 1.000 0.000
#> GSM110406     2   0.000      0.976 0.000 1.000
#> GSM110407     1   0.000      0.990 1.000 0.000
#> GSM110409     1   0.000      0.990 1.000 0.000
#> GSM110410     2   0.000      0.976 0.000 1.000
#> GSM110413     2   0.000      0.976 0.000 1.000
#> GSM110414     2   0.000      0.976 0.000 1.000
#> GSM110415     2   0.000      0.976 0.000 1.000
#> GSM110416     2   0.971      0.338 0.400 0.600
#> GSM110418     2   0.971      0.338 0.400 0.600
#> GSM110419     2   0.000      0.976 0.000 1.000
#> GSM110420     1   0.000      0.990 1.000 0.000
#> GSM110421     2   0.000      0.976 0.000 1.000
#> GSM110423     2   0.000      0.976 0.000 1.000
#> GSM110424     2   0.000      0.976 0.000 1.000
#> GSM110425     2   0.000      0.976 0.000 1.000
#> GSM110427     2   0.000      0.976 0.000 1.000
#> GSM110428     1   0.000      0.990 1.000 0.000
#> GSM110430     1   0.000      0.990 1.000 0.000
#> GSM110431     1   0.000      0.990 1.000 0.000
#> GSM110432     2   0.000      0.976 0.000 1.000
#> GSM110434     2   0.000      0.976 0.000 1.000
#> GSM110435     1   0.000      0.990 1.000 0.000
#> GSM110437     1   0.000      0.990 1.000 0.000
#> GSM110438     1   0.000      0.990 1.000 0.000
#> GSM110388     1   0.000      0.990 1.000 0.000
#> GSM110392     2   0.000      0.976 0.000 1.000
#> GSM110394     1   0.000      0.990 1.000 0.000
#> GSM110402     2   0.000      0.976 0.000 1.000
#> GSM110411     1   0.000      0.990 1.000 0.000
#> GSM110412     2   0.000      0.976 0.000 1.000
#> GSM110417     1   0.000      0.990 1.000 0.000
#> GSM110422     2   0.000      0.976 0.000 1.000
#> GSM110426     1   0.000      0.990 1.000 0.000
#> GSM110429     2   0.000      0.976 0.000 1.000
#> GSM110433     2   0.000      0.976 0.000 1.000
#> GSM110436     2   0.000      0.976 0.000 1.000
#> GSM110440     1   0.000      0.990 1.000 0.000
#> GSM110441     2   0.000      0.976 0.000 1.000
#> GSM110444     2   0.000      0.976 0.000 1.000
#> GSM110445     1   0.000      0.990 1.000 0.000
#> GSM110446     1   0.730      0.732 0.796 0.204
#> GSM110449     2   0.000      0.976 0.000 1.000
#> GSM110451     2   0.000      0.976 0.000 1.000
#> GSM110391     2   0.000      0.976 0.000 1.000
#> GSM110439     2   0.000      0.976 0.000 1.000
#> GSM110442     2   0.000      0.976 0.000 1.000
#> GSM110443     2   0.000      0.976 0.000 1.000
#> GSM110447     2   0.000      0.976 0.000 1.000
#> GSM110448     1   0.000      0.990 1.000 0.000
#> GSM110450     1   0.000      0.990 1.000 0.000
#> GSM110452     2   0.000      0.976 0.000 1.000
#> GSM110453     2   0.000      0.976 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
#> GSM110395     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110396     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110397     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110398     3  0.4974      0.660 0.236 0.000 0.764
#> GSM110399     3  0.5178      0.768 0.000 0.256 0.744
#> GSM110400     2  0.4974      0.727 0.000 0.764 0.236
#> GSM110401     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110406     3  0.5291      0.764 0.000 0.268 0.732
#> GSM110407     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110409     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110410     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110413     2  0.0424      0.940 0.000 0.992 0.008
#> GSM110414     2  0.4750      0.745 0.000 0.784 0.216
#> GSM110415     3  0.1643      0.781 0.000 0.044 0.956
#> GSM110416     3  0.0424      0.772 0.000 0.008 0.992
#> GSM110418     3  0.0424      0.772 0.000 0.008 0.992
#> GSM110419     3  0.1643      0.781 0.000 0.044 0.956
#> GSM110420     3  0.6359      0.224 0.364 0.008 0.628
#> GSM110421     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110423     2  0.4974      0.727 0.000 0.764 0.236
#> GSM110424     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110425     2  0.4974      0.727 0.000 0.764 0.236
#> GSM110427     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110428     3  0.4931      0.665 0.232 0.000 0.768
#> GSM110430     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110431     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110432     3  0.5327      0.762 0.000 0.272 0.728
#> GSM110434     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110435     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110437     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110438     3  0.4702      0.681 0.212 0.000 0.788
#> GSM110388     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110392     3  0.5291      0.764 0.000 0.268 0.732
#> GSM110394     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110402     3  0.3551      0.735 0.000 0.132 0.868
#> GSM110411     3  0.4974      0.660 0.236 0.000 0.764
#> GSM110412     3  0.5327      0.762 0.000 0.272 0.728
#> GSM110417     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110422     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110426     1  0.0000      0.954 1.000 0.000 0.000
#> GSM110429     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110433     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110436     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110440     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110441     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110444     3  0.5178      0.768 0.000 0.256 0.744
#> GSM110445     1  0.6140      0.254 0.596 0.000 0.404
#> GSM110446     3  0.0424      0.772 0.000 0.008 0.992
#> GSM110449     3  0.5291      0.764 0.000 0.268 0.732
#> GSM110451     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110391     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110439     2  0.0000      0.945 0.000 1.000 0.000
#> GSM110442     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110443     3  0.5291      0.764 0.000 0.268 0.732
#> GSM110447     3  0.3752      0.733 0.000 0.144 0.856
#> GSM110448     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110450     1  0.1411      0.954 0.964 0.000 0.036
#> GSM110452     2  0.0237      0.944 0.000 0.996 0.004
#> GSM110453     2  0.0000      0.945 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.4955      0.702 0.000 0.648 0.344 0.008
#> GSM110396     1  0.1398      0.878 0.956 0.000 0.040 0.004
#> GSM110397     1  0.1302      0.877 0.956 0.000 0.044 0.000
#> GSM110398     4  0.1042      0.698 0.020 0.000 0.008 0.972
#> GSM110399     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110400     3  0.3311      0.539 0.000 0.172 0.828 0.000
#> GSM110401     1  0.1398      0.878 0.956 0.000 0.040 0.004
#> GSM110406     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110407     1  0.3734      0.879 0.848 0.000 0.044 0.108
#> GSM110409     1  0.4798      0.842 0.768 0.000 0.052 0.180
#> GSM110410     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110413     2  0.3831      0.793 0.000 0.792 0.204 0.004
#> GSM110414     2  0.3726      0.534 0.000 0.788 0.212 0.000
#> GSM110415     3  0.4175      0.556 0.000 0.012 0.776 0.212
#> GSM110416     3  0.4955      0.433 0.000 0.000 0.556 0.444
#> GSM110418     3  0.4972      0.429 0.000 0.000 0.544 0.456
#> GSM110419     3  0.4262      0.535 0.000 0.008 0.756 0.236
#> GSM110420     3  0.7085      0.361 0.232 0.000 0.568 0.200
#> GSM110421     2  0.4819      0.704 0.000 0.652 0.344 0.004
#> GSM110423     3  0.3400      0.527 0.000 0.180 0.820 0.000
#> GSM110424     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110425     3  0.3400      0.527 0.000 0.180 0.820 0.000
#> GSM110427     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110428     4  0.1833      0.669 0.024 0.000 0.032 0.944
#> GSM110430     1  0.1398      0.878 0.956 0.000 0.040 0.004
#> GSM110431     1  0.1302      0.877 0.956 0.000 0.044 0.000
#> GSM110432     4  0.6668      0.393 0.000 0.092 0.380 0.528
#> GSM110434     2  0.4955      0.702 0.000 0.648 0.344 0.008
#> GSM110435     1  0.3978      0.877 0.836 0.000 0.056 0.108
#> GSM110437     1  0.1398      0.878 0.956 0.000 0.040 0.004
#> GSM110438     4  0.1109      0.682 0.004 0.000 0.028 0.968
#> GSM110388     1  0.4756      0.842 0.772 0.000 0.052 0.176
#> GSM110392     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110394     1  0.3978      0.877 0.836 0.000 0.056 0.108
#> GSM110402     3  0.2871      0.612 0.000 0.032 0.896 0.072
#> GSM110411     4  0.1042      0.698 0.020 0.000 0.008 0.972
#> GSM110412     4  0.6668      0.393 0.000 0.092 0.380 0.528
#> GSM110417     1  0.0000      0.883 1.000 0.000 0.000 0.000
#> GSM110422     2  0.3074      0.805 0.000 0.848 0.152 0.000
#> GSM110426     1  0.0188      0.883 0.996 0.000 0.004 0.000
#> GSM110429     2  0.4585      0.715 0.000 0.668 0.332 0.000
#> GSM110433     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110436     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110440     1  0.3978      0.877 0.836 0.000 0.056 0.108
#> GSM110441     2  0.3668      0.798 0.000 0.808 0.188 0.004
#> GSM110444     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110445     4  0.3758      0.567 0.104 0.000 0.048 0.848
#> GSM110446     3  0.4933      0.408 0.000 0.000 0.568 0.432
#> GSM110449     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110451     2  0.4643      0.707 0.000 0.656 0.344 0.000
#> GSM110391     2  0.3074      0.805 0.000 0.848 0.152 0.000
#> GSM110439     2  0.0000      0.789 0.000 1.000 0.000 0.000
#> GSM110442     2  0.4955      0.702 0.000 0.648 0.344 0.008
#> GSM110443     4  0.4139      0.764 0.000 0.024 0.176 0.800
#> GSM110447     3  0.4100      0.601 0.000 0.092 0.832 0.076
#> GSM110448     1  0.4532      0.855 0.792 0.000 0.052 0.156
#> GSM110450     1  0.4798      0.842 0.768 0.000 0.052 0.180
#> GSM110452     2  0.3123      0.805 0.000 0.844 0.156 0.000
#> GSM110453     2  0.0000      0.789 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM110395     2  0.5819   0.500500 0.000 0.612 0.188 0.200 NA
#> GSM110396     1  0.4410   0.718262 0.556 0.000 0.004 0.000 NA
#> GSM110397     1  0.4278   0.715391 0.548 0.000 0.000 0.000 NA
#> GSM110398     4  0.5104   0.616132 0.128 0.000 0.104 0.740 NA
#> GSM110399     4  0.0290   0.686431 0.000 0.000 0.008 0.992 NA
#> GSM110400     3  0.5051   0.477153 0.000 0.248 0.684 0.060 NA
#> GSM110401     1  0.4278   0.715391 0.548 0.000 0.000 0.000 NA
#> GSM110406     4  0.0510   0.682115 0.000 0.000 0.016 0.984 NA
#> GSM110407     1  0.0000   0.757307 1.000 0.000 0.000 0.000 NA
#> GSM110409     1  0.2344   0.709699 0.904 0.000 0.064 0.000 NA
#> GSM110410     2  0.4161   0.514485 0.000 0.608 0.000 0.000 NA
#> GSM110413     2  0.4662   0.565287 0.000 0.736 0.096 0.168 NA
#> GSM110414     2  0.6363   0.308811 0.000 0.444 0.164 0.000 NA
#> GSM110415     3  0.3607   0.576390 0.000 0.000 0.752 0.244 NA
#> GSM110416     3  0.5144   0.502876 0.000 0.000 0.692 0.176 NA
#> GSM110418     3  0.5451   0.500260 0.012 0.000 0.688 0.168 NA
#> GSM110419     3  0.3741   0.561900 0.000 0.000 0.732 0.264 NA
#> GSM110420     3  0.6320   0.379683 0.316 0.000 0.540 0.012 NA
#> GSM110421     2  0.5763   0.506425 0.000 0.620 0.188 0.192 NA
#> GSM110423     3  0.5051   0.477153 0.000 0.248 0.684 0.060 NA
#> GSM110424     2  0.4161   0.514485 0.000 0.608 0.000 0.000 NA
#> GSM110425     3  0.5051   0.477153 0.000 0.248 0.684 0.060 NA
#> GSM110427     2  0.3752   0.548746 0.000 0.708 0.000 0.000 NA
#> GSM110428     4  0.5692   0.586994 0.156 0.000 0.124 0.688 NA
#> GSM110430     1  0.4278   0.715391 0.548 0.000 0.000 0.000 NA
#> GSM110431     1  0.4410   0.718262 0.556 0.000 0.004 0.000 NA
#> GSM110432     4  0.6333   0.064758 0.000 0.288 0.196 0.516 NA
#> GSM110434     2  0.5817   0.500789 0.000 0.612 0.184 0.204 NA
#> GSM110435     1  0.0000   0.757307 1.000 0.000 0.000 0.000 NA
#> GSM110437     1  0.4278   0.715391 0.548 0.000 0.000 0.000 NA
#> GSM110438     4  0.5655   0.589718 0.152 0.000 0.124 0.692 NA
#> GSM110388     1  0.2344   0.709699 0.904 0.000 0.064 0.000 NA
#> GSM110392     4  0.0290   0.686431 0.000 0.000 0.008 0.992 NA
#> GSM110394     1  0.0000   0.757307 1.000 0.000 0.000 0.000 NA
#> GSM110402     3  0.3445   0.605041 0.000 0.036 0.824 0.140 NA
#> GSM110411     4  0.5104   0.616132 0.128 0.000 0.104 0.740 NA
#> GSM110412     4  0.6410  -0.000943 0.000 0.304 0.200 0.496 NA
#> GSM110417     1  0.3689   0.752595 0.740 0.000 0.004 0.000 NA
#> GSM110422     2  0.1851   0.587772 0.000 0.912 0.088 0.000 NA
#> GSM110426     1  0.3635   0.753678 0.748 0.000 0.004 0.000 NA
#> GSM110429     2  0.4571   0.535349 0.000 0.736 0.188 0.076 NA
#> GSM110433     2  0.4161   0.514485 0.000 0.608 0.000 0.000 NA
#> GSM110436     2  0.3586   0.554728 0.000 0.736 0.000 0.000 NA
#> GSM110440     1  0.0000   0.757307 1.000 0.000 0.000 0.000 NA
#> GSM110441     2  0.4573   0.568711 0.000 0.744 0.092 0.164 NA
#> GSM110444     4  0.0162   0.684749 0.000 0.000 0.004 0.996 NA
#> GSM110445     4  0.6480   0.420702 0.348 0.000 0.104 0.520 NA
#> GSM110446     3  0.6448   0.465087 0.080 0.000 0.640 0.148 NA
#> GSM110449     4  0.0290   0.686431 0.000 0.000 0.008 0.992 NA
#> GSM110451     2  0.5640   0.513966 0.000 0.636 0.188 0.176 NA
#> GSM110391     2  0.1851   0.587772 0.000 0.912 0.088 0.000 NA
#> GSM110439     2  0.3586   0.552779 0.000 0.736 0.000 0.000 NA
#> GSM110442     2  0.5731   0.511235 0.000 0.624 0.180 0.196 NA
#> GSM110443     4  0.0609   0.679321 0.000 0.000 0.020 0.980 NA
#> GSM110447     3  0.5847   0.458498 0.000 0.172 0.624 0.200 NA
#> GSM110448     1  0.1571   0.728218 0.936 0.000 0.060 0.000 NA
#> GSM110450     1  0.2344   0.709699 0.904 0.000 0.064 0.000 NA
#> GSM110452     2  0.4010   0.583178 0.000 0.796 0.088 0.116 NA
#> GSM110453     2  0.4161   0.514485 0.000 0.608 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.0458      0.661 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM110396     6  0.1865      0.785 0.040 0.000 0.040 0.000 0.000 0.920
#> GSM110397     6  0.0717      0.805 0.008 0.000 0.000 0.000 0.016 0.976
#> GSM110398     4  0.3842      0.701 0.156 0.000 0.076 0.768 0.000 0.000
#> GSM110399     4  0.2135      0.809 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM110400     2  0.7575     -0.191 0.152 0.368 0.360 0.048 0.072 0.000
#> GSM110401     6  0.0000      0.807 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110406     4  0.2178      0.806 0.000 0.132 0.000 0.868 0.000 0.000
#> GSM110407     1  0.4206      0.704 0.624 0.000 0.012 0.008 0.000 0.356
#> GSM110409     1  0.3566      0.725 0.744 0.000 0.000 0.020 0.000 0.236
#> GSM110410     5  0.1753      0.874 0.000 0.084 0.004 0.000 0.912 0.000
#> GSM110413     2  0.3801      0.590 0.028 0.828 0.040 0.028 0.076 0.000
#> GSM110414     5  0.3748      0.644 0.120 0.016 0.012 0.040 0.812 0.000
#> GSM110415     3  0.7273      0.573 0.152 0.076 0.520 0.196 0.056 0.000
#> GSM110416     3  0.2875      0.645 0.052 0.000 0.852 0.096 0.000 0.000
#> GSM110418     3  0.2888      0.646 0.056 0.000 0.852 0.092 0.000 0.000
#> GSM110419     3  0.7392      0.575 0.152 0.076 0.496 0.220 0.056 0.000
#> GSM110420     3  0.4186      0.495 0.192 0.000 0.728 0.000 0.000 0.080
#> GSM110421     2  0.0363      0.661 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM110423     2  0.7575     -0.191 0.152 0.368 0.360 0.048 0.072 0.000
#> GSM110424     5  0.1610      0.873 0.000 0.084 0.000 0.000 0.916 0.000
#> GSM110425     2  0.7575     -0.191 0.152 0.368 0.360 0.048 0.072 0.000
#> GSM110427     5  0.4125      0.803 0.024 0.208 0.028 0.000 0.740 0.000
#> GSM110428     4  0.4729      0.639 0.196 0.000 0.128 0.676 0.000 0.000
#> GSM110430     6  0.0000      0.807 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110431     6  0.1528      0.796 0.048 0.000 0.000 0.000 0.016 0.936
#> GSM110432     2  0.5083      0.421 0.024 0.640 0.068 0.268 0.000 0.000
#> GSM110434     2  0.0547      0.660 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM110435     1  0.4102      0.699 0.628 0.000 0.012 0.000 0.004 0.356
#> GSM110437     6  0.0000      0.807 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM110438     4  0.4701      0.643 0.192 0.000 0.128 0.680 0.000 0.000
#> GSM110388     1  0.3860      0.718 0.728 0.000 0.000 0.036 0.000 0.236
#> GSM110392     4  0.2278      0.808 0.004 0.128 0.000 0.868 0.000 0.000
#> GSM110394     1  0.4102      0.699 0.628 0.000 0.012 0.000 0.004 0.356
#> GSM110402     3  0.7963      0.399 0.152 0.192 0.440 0.152 0.064 0.000
#> GSM110411     4  0.3946      0.694 0.168 0.000 0.076 0.756 0.000 0.000
#> GSM110412     2  0.4661      0.474 0.024 0.688 0.048 0.240 0.000 0.000
#> GSM110417     6  0.4938      0.172 0.348 0.000 0.040 0.000 0.020 0.592
#> GSM110422     2  0.4186      0.483 0.024 0.752 0.044 0.000 0.180 0.000
#> GSM110426     6  0.4949      0.156 0.352 0.000 0.040 0.000 0.020 0.588
#> GSM110429     2  0.2356      0.601 0.016 0.884 0.000 0.004 0.096 0.000
#> GSM110433     5  0.1753      0.874 0.000 0.084 0.004 0.000 0.912 0.000
#> GSM110436     5  0.4527      0.774 0.024 0.228 0.044 0.000 0.704 0.000
#> GSM110440     1  0.4102      0.699 0.628 0.000 0.012 0.000 0.004 0.356
#> GSM110441     2  0.3782      0.589 0.036 0.828 0.032 0.024 0.080 0.000
#> GSM110444     4  0.2135      0.809 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM110445     1  0.5071     -0.228 0.480 0.000 0.076 0.444 0.000 0.000
#> GSM110446     3  0.3534      0.621 0.124 0.000 0.800 0.076 0.000 0.000
#> GSM110449     4  0.2135      0.809 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM110451     2  0.0622      0.657 0.012 0.980 0.000 0.000 0.008 0.000
#> GSM110391     2  0.4348      0.470 0.028 0.732 0.040 0.000 0.200 0.000
#> GSM110439     5  0.4364      0.809 0.044 0.184 0.032 0.000 0.740 0.000
#> GSM110442     2  0.0717      0.660 0.000 0.976 0.008 0.016 0.000 0.000
#> GSM110443     4  0.2135      0.809 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM110447     2  0.8150     -0.263 0.152 0.328 0.324 0.132 0.064 0.000
#> GSM110448     1  0.3528      0.728 0.700 0.000 0.000 0.000 0.004 0.296
#> GSM110450     1  0.3925      0.715 0.724 0.000 0.000 0.040 0.000 0.236
#> GSM110452     2  0.3794      0.566 0.024 0.812 0.044 0.008 0.112 0.000
#> GSM110453     5  0.1753      0.874 0.000 0.084 0.004 0.000 0.912 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)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> ATC:kmeans 57            0.666       0.402 2
#> ATC:kmeans 57            0.930       0.516 3
#> ATC:kmeans 53            0.556       0.588 4
#> ATC:kmeans 49            0.404       0.366 5
#> ATC:kmeans 46            0.170       0.591 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 17209 rows and 59 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 0.897           0.929       0.970         0.4998 0.503   0.503
#> 3 3 0.743           0.800       0.875         0.2512 0.811   0.637
#> 4 4 0.813           0.819       0.924         0.1045 0.822   0.572
#> 5 5 0.791           0.852       0.887         0.0429 0.926   0.763
#> 6 6 0.831           0.842       0.896         0.0337 0.991   0.965

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
#> GSM110395     2  0.0000      0.963 0.000 1.000
#> GSM110396     1  0.0000      0.974 1.000 0.000
#> GSM110397     1  0.0000      0.974 1.000 0.000
#> GSM110398     1  0.0000      0.974 1.000 0.000
#> GSM110399     2  0.9358      0.488 0.352 0.648
#> GSM110400     2  0.0000      0.963 0.000 1.000
#> GSM110401     1  0.0000      0.974 1.000 0.000
#> GSM110406     2  0.0000      0.963 0.000 1.000
#> GSM110407     1  0.0000      0.974 1.000 0.000
#> GSM110409     1  0.0000      0.974 1.000 0.000
#> GSM110410     2  0.0000      0.963 0.000 1.000
#> GSM110413     2  0.0000      0.963 0.000 1.000
#> GSM110414     2  0.0000      0.963 0.000 1.000
#> GSM110415     2  0.0000      0.963 0.000 1.000
#> GSM110416     1  0.9552      0.403 0.624 0.376
#> GSM110418     1  0.7299      0.732 0.796 0.204
#> GSM110419     2  0.0000      0.963 0.000 1.000
#> GSM110420     1  0.0000      0.974 1.000 0.000
#> GSM110421     2  0.0000      0.963 0.000 1.000
#> GSM110423     2  0.0000      0.963 0.000 1.000
#> GSM110424     2  0.0000      0.963 0.000 1.000
#> GSM110425     2  0.0000      0.963 0.000 1.000
#> GSM110427     2  0.0000      0.963 0.000 1.000
#> GSM110428     1  0.0000      0.974 1.000 0.000
#> GSM110430     1  0.0000      0.974 1.000 0.000
#> GSM110431     1  0.0000      0.974 1.000 0.000
#> GSM110432     2  0.0000      0.963 0.000 1.000
#> GSM110434     2  0.0000      0.963 0.000 1.000
#> GSM110435     1  0.0000      0.974 1.000 0.000
#> GSM110437     1  0.0000      0.974 1.000 0.000
#> GSM110438     1  0.0000      0.974 1.000 0.000
#> GSM110388     1  0.0000      0.974 1.000 0.000
#> GSM110392     2  0.0672      0.956 0.008 0.992
#> GSM110394     1  0.0000      0.974 1.000 0.000
#> GSM110402     2  0.0000      0.963 0.000 1.000
#> GSM110411     1  0.0000      0.974 1.000 0.000
#> GSM110412     2  0.0000      0.963 0.000 1.000
#> GSM110417     1  0.0000      0.974 1.000 0.000
#> GSM110422     2  0.0000      0.963 0.000 1.000
#> GSM110426     1  0.0000      0.974 1.000 0.000
#> GSM110429     2  0.0000      0.963 0.000 1.000
#> GSM110433     2  0.0000      0.963 0.000 1.000
#> GSM110436     2  0.0000      0.963 0.000 1.000
#> GSM110440     1  0.0000      0.974 1.000 0.000
#> GSM110441     2  0.0000      0.963 0.000 1.000
#> GSM110444     2  0.9710      0.375 0.400 0.600
#> GSM110445     1  0.0000      0.974 1.000 0.000
#> GSM110446     1  0.0000      0.974 1.000 0.000
#> GSM110449     2  0.7299      0.744 0.204 0.796
#> GSM110451     2  0.0000      0.963 0.000 1.000
#> GSM110391     2  0.0000      0.963 0.000 1.000
#> GSM110439     2  0.0000      0.963 0.000 1.000
#> GSM110442     2  0.0000      0.963 0.000 1.000
#> GSM110443     2  0.7299      0.744 0.204 0.796
#> GSM110447     2  0.0000      0.963 0.000 1.000
#> GSM110448     1  0.0000      0.974 1.000 0.000
#> GSM110450     1  0.0000      0.974 1.000 0.000
#> GSM110452     2  0.0000      0.963 0.000 1.000
#> GSM110453     2  0.0000      0.963 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
#> GSM110395     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110396     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110397     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110398     1  0.4465      0.788 0.820 0.176 0.004
#> GSM110399     2  0.1031      0.591 0.000 0.976 0.024
#> GSM110400     3  0.2165      0.669 0.000 0.064 0.936
#> GSM110401     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110406     2  0.3116      0.674 0.000 0.892 0.108
#> GSM110407     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110409     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110410     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110413     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110414     3  0.5254      0.168 0.000 0.264 0.736
#> GSM110415     3  0.0237      0.679 0.000 0.004 0.996
#> GSM110416     3  0.5859      0.441 0.344 0.000 0.656
#> GSM110418     3  0.6026      0.410 0.376 0.000 0.624
#> GSM110419     3  0.0237      0.679 0.000 0.004 0.996
#> GSM110420     3  0.6026      0.410 0.376 0.000 0.624
#> GSM110421     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110423     3  0.2165      0.669 0.000 0.064 0.936
#> GSM110424     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110425     3  0.2165      0.669 0.000 0.064 0.936
#> GSM110427     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110428     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110430     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110431     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110432     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110434     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110435     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110437     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110438     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110388     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110392     2  0.0237      0.569 0.000 0.996 0.004
#> GSM110394     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110402     3  0.2165      0.669 0.000 0.064 0.936
#> GSM110411     1  0.3193      0.879 0.896 0.100 0.004
#> GSM110412     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110417     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110422     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110426     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110429     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110433     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110436     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110440     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110441     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110444     2  0.6345     -0.139 0.400 0.596 0.004
#> GSM110445     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110446     3  0.6026      0.410 0.376 0.000 0.624
#> GSM110449     2  0.0747      0.583 0.000 0.984 0.016
#> GSM110451     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110391     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110439     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110442     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110443     2  0.0000      0.574 0.000 1.000 0.000
#> GSM110447     3  0.2625      0.641 0.000 0.084 0.916
#> GSM110448     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110450     1  0.0000      0.984 1.000 0.000 0.000
#> GSM110452     2  0.5810      0.875 0.000 0.664 0.336
#> GSM110453     2  0.5810      0.875 0.000 0.664 0.336

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110396     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110397     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110398     4  0.4936      0.467 0.372 0.000 0.004 0.624
#> GSM110399     4  0.2983      0.762 0.000 0.068 0.040 0.892
#> GSM110400     2  0.4855      0.362 0.000 0.600 0.400 0.000
#> GSM110401     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110406     4  0.3681      0.647 0.000 0.176 0.008 0.816
#> GSM110407     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110409     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110410     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110413     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110414     2  0.4855      0.362 0.000 0.600 0.400 0.000
#> GSM110415     3  0.1118      0.739 0.000 0.036 0.964 0.000
#> GSM110416     3  0.1389      0.748 0.048 0.000 0.952 0.000
#> GSM110418     3  0.3610      0.742 0.200 0.000 0.800 0.000
#> GSM110419     3  0.1118      0.739 0.000 0.036 0.964 0.000
#> GSM110420     3  0.3610      0.742 0.200 0.000 0.800 0.000
#> GSM110421     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110423     2  0.4855      0.362 0.000 0.600 0.400 0.000
#> GSM110424     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110425     2  0.4855      0.362 0.000 0.600 0.400 0.000
#> GSM110427     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110428     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110430     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110431     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110432     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110434     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110435     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110437     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110438     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110388     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110392     4  0.0336      0.776 0.000 0.008 0.000 0.992
#> GSM110394     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110402     3  0.4855      0.193 0.000 0.400 0.600 0.000
#> GSM110411     4  0.5004      0.425 0.392 0.000 0.004 0.604
#> GSM110412     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110417     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110422     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110426     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110429     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110433     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110436     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110440     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110441     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110444     4  0.0376      0.773 0.000 0.004 0.004 0.992
#> GSM110445     1  0.3569      0.711 0.804 0.000 0.000 0.196
#> GSM110446     3  0.3610      0.742 0.200 0.000 0.800 0.000
#> GSM110449     4  0.2565      0.769 0.000 0.056 0.032 0.912
#> GSM110451     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110391     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110439     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110442     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110443     4  0.0336      0.776 0.000 0.008 0.000 0.992
#> GSM110447     2  0.4855      0.362 0.000 0.600 0.400 0.000
#> GSM110448     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110450     1  0.0000      0.987 1.000 0.000 0.000 0.000
#> GSM110452     2  0.0000      0.900 0.000 1.000 0.000 0.000
#> GSM110453     2  0.0000      0.900 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110396     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110397     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110398     4  0.4873     0.5261 0.244 0.000 0.000 0.688 0.068
#> GSM110399     4  0.4735     0.6654 0.000 0.008 0.012 0.608 0.372
#> GSM110400     3  0.4030     0.7733 0.000 0.352 0.648 0.000 0.000
#> GSM110401     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110406     4  0.6618     0.4409 0.000 0.264 0.004 0.492 0.240
#> GSM110407     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110409     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110410     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110413     2  0.0566     0.9788 0.000 0.984 0.000 0.004 0.012
#> GSM110414     3  0.4297     0.6016 0.000 0.472 0.528 0.000 0.000
#> GSM110415     3  0.0404     0.2348 0.000 0.012 0.988 0.000 0.000
#> GSM110416     5  0.5103     0.7414 0.036 0.000 0.452 0.000 0.512
#> GSM110418     5  0.6245     0.9129 0.168 0.000 0.316 0.000 0.516
#> GSM110419     3  0.0566     0.2289 0.000 0.012 0.984 0.000 0.004
#> GSM110420     5  0.6275     0.9133 0.176 0.000 0.308 0.000 0.516
#> GSM110421     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110423     3  0.4045     0.7742 0.000 0.356 0.644 0.000 0.000
#> GSM110424     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110425     3  0.4045     0.7742 0.000 0.356 0.644 0.000 0.000
#> GSM110427     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110428     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110430     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110432     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110434     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110435     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110437     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110438     1  0.4434    -0.0242 0.536 0.000 0.000 0.004 0.460
#> GSM110388     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110392     4  0.3257     0.6697 0.000 0.028 0.004 0.844 0.124
#> GSM110394     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110402     3  0.3707     0.7164 0.000 0.284 0.716 0.000 0.000
#> GSM110411     4  0.4354     0.5079 0.256 0.000 0.000 0.712 0.032
#> GSM110412     2  0.0324     0.9891 0.000 0.992 0.000 0.004 0.004
#> GSM110417     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110422     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110426     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110429     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110433     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110436     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110440     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110441     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110444     4  0.0290     0.6855 0.000 0.000 0.000 0.992 0.008
#> GSM110445     1  0.2462     0.8196 0.880 0.000 0.000 0.112 0.008
#> GSM110446     5  0.6275     0.9133 0.176 0.000 0.308 0.000 0.516
#> GSM110449     4  0.4804     0.6677 0.000 0.016 0.008 0.612 0.364
#> GSM110451     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110391     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110439     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110442     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110443     4  0.2853     0.7023 0.000 0.040 0.004 0.880 0.076
#> GSM110447     3  0.4182     0.7392 0.000 0.400 0.600 0.000 0.000
#> GSM110448     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110450     1  0.0000     0.9623 1.000 0.000 0.000 0.000 0.000
#> GSM110452     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000
#> GSM110453     2  0.0000     0.9983 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.0363     0.9670 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM110396     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110397     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110398     4  0.4879     0.5317 0.096 0.000 0.000 0.732 0.096 0.076
#> GSM110399     6  0.3215     0.6068 0.000 0.004 0.000 0.240 0.000 0.756
#> GSM110400     3  0.2941     0.7978 0.000 0.220 0.780 0.000 0.000 0.000
#> GSM110401     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110406     6  0.6172     0.3080 0.000 0.232 0.000 0.328 0.008 0.432
#> GSM110407     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110409     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110410     2  0.0547     0.9631 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM110413     2  0.1663     0.9071 0.000 0.912 0.000 0.000 0.000 0.088
#> GSM110414     3  0.3756     0.6211 0.000 0.400 0.600 0.000 0.000 0.000
#> GSM110415     3  0.1007     0.5473 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM110416     5  0.2872     0.8346 0.024 0.000 0.140 0.000 0.836 0.000
#> GSM110418     5  0.3045     0.9322 0.100 0.000 0.060 0.000 0.840 0.000
#> GSM110419     3  0.1007     0.5473 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM110420     5  0.3227     0.9321 0.116 0.000 0.060 0.000 0.824 0.000
#> GSM110421     2  0.0458     0.9669 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM110423     3  0.2969     0.7980 0.000 0.224 0.776 0.000 0.000 0.000
#> GSM110424     2  0.0547     0.9631 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM110425     3  0.2996     0.7965 0.000 0.228 0.772 0.000 0.000 0.000
#> GSM110427     2  0.0713     0.9651 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM110428     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110430     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110432     2  0.1124     0.9587 0.000 0.956 0.008 0.000 0.000 0.036
#> GSM110434     2  0.0713     0.9650 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM110435     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110437     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110438     1  0.5852    -0.0689 0.484 0.000 0.004 0.012 0.380 0.120
#> GSM110388     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110392     4  0.5456     0.4413 0.000 0.012 0.024 0.612 0.064 0.288
#> GSM110394     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110402     3  0.2902     0.7851 0.000 0.196 0.800 0.000 0.004 0.000
#> GSM110411     4  0.3860     0.5732 0.108 0.000 0.000 0.788 0.096 0.008
#> GSM110412     2  0.1462     0.9440 0.000 0.936 0.000 0.000 0.008 0.056
#> GSM110417     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110422     2  0.0865     0.9627 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM110426     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110429     2  0.0865     0.9627 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM110433     2  0.0632     0.9616 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM110436     2  0.0865     0.9627 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM110440     1  0.0146     0.9613 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110441     2  0.1141     0.9434 0.000 0.948 0.000 0.000 0.000 0.052
#> GSM110444     4  0.0146     0.6043 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM110445     1  0.1908     0.8560 0.900 0.000 0.000 0.096 0.004 0.000
#> GSM110446     5  0.3227     0.9318 0.116 0.000 0.060 0.000 0.824 0.000
#> GSM110449     6  0.3215     0.6066 0.000 0.004 0.000 0.240 0.000 0.756
#> GSM110451     2  0.0865     0.9627 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM110391     2  0.0713     0.9600 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM110439     2  0.0547     0.9631 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM110442     2  0.0146     0.9665 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM110443     4  0.3997     0.4986 0.000 0.016 0.020 0.772 0.016 0.176
#> GSM110447     3  0.3620     0.6861 0.000 0.352 0.648 0.000 0.000 0.000
#> GSM110448     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110450     1  0.0000     0.9615 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM110452     2  0.0790     0.9639 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM110453     2  0.0547     0.9631 0.000 0.980 0.000 0.000 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-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n disease.state(p) specimen(p) k
#> ATC:skmeans 56            0.563       0.318 2
#> ATC:skmeans 53            0.260       0.419 3
#> ATC:skmeans 51            0.204       0.421 4
#> ATC:skmeans 55            0.412       0.688 5
#> ATC:skmeans 55            0.520       0.625 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-pam-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.959       0.985         0.4905 0.509   0.509
#> 3 3 0.864           0.861       0.948         0.3036 0.695   0.483
#> 4 4 0.647           0.669       0.840         0.1212 0.899   0.730
#> 5 5 0.860           0.807       0.924         0.0808 0.886   0.628
#> 6 6 0.873           0.856       0.927         0.0609 0.853   0.463

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
#> GSM110395     2  0.0000      0.988 0.000 1.000
#> GSM110396     1  0.0000      0.979 1.000 0.000
#> GSM110397     1  0.0000      0.979 1.000 0.000
#> GSM110398     1  0.0376      0.977 0.996 0.004
#> GSM110399     2  0.0000      0.988 0.000 1.000
#> GSM110400     2  0.0000      0.988 0.000 1.000
#> GSM110401     1  0.0000      0.979 1.000 0.000
#> GSM110406     2  0.0000      0.988 0.000 1.000
#> GSM110407     1  0.0000      0.979 1.000 0.000
#> GSM110409     1  0.0000      0.979 1.000 0.000
#> GSM110410     2  0.0000      0.988 0.000 1.000
#> GSM110413     2  0.0000      0.988 0.000 1.000
#> GSM110414     2  0.0000      0.988 0.000 1.000
#> GSM110415     2  0.0000      0.988 0.000 1.000
#> GSM110416     2  0.9710      0.306 0.400 0.600
#> GSM110418     1  0.9896      0.196 0.560 0.440
#> GSM110419     2  0.0000      0.988 0.000 1.000
#> GSM110420     1  0.0376      0.977 0.996 0.004
#> GSM110421     2  0.0000      0.988 0.000 1.000
#> GSM110423     2  0.0000      0.988 0.000 1.000
#> GSM110424     2  0.0000      0.988 0.000 1.000
#> GSM110425     2  0.0000      0.988 0.000 1.000
#> GSM110427     2  0.0000      0.988 0.000 1.000
#> GSM110428     1  0.0376      0.977 0.996 0.004
#> GSM110430     1  0.0000      0.979 1.000 0.000
#> GSM110431     1  0.0000      0.979 1.000 0.000
#> GSM110432     2  0.0000      0.988 0.000 1.000
#> GSM110434     2  0.0000      0.988 0.000 1.000
#> GSM110435     1  0.0000      0.979 1.000 0.000
#> GSM110437     1  0.0000      0.979 1.000 0.000
#> GSM110438     1  0.0376      0.977 0.996 0.004
#> GSM110388     1  0.0000      0.979 1.000 0.000
#> GSM110392     2  0.0000      0.988 0.000 1.000
#> GSM110394     1  0.0000      0.979 1.000 0.000
#> GSM110402     2  0.0000      0.988 0.000 1.000
#> GSM110411     1  0.0376      0.977 0.996 0.004
#> GSM110412     2  0.0000      0.988 0.000 1.000
#> GSM110417     1  0.0000      0.979 1.000 0.000
#> GSM110422     2  0.0000      0.988 0.000 1.000
#> GSM110426     1  0.0000      0.979 1.000 0.000
#> GSM110429     2  0.0000      0.988 0.000 1.000
#> GSM110433     2  0.0000      0.988 0.000 1.000
#> GSM110436     2  0.0000      0.988 0.000 1.000
#> GSM110440     1  0.0000      0.979 1.000 0.000
#> GSM110441     2  0.0000      0.988 0.000 1.000
#> GSM110444     2  0.0000      0.988 0.000 1.000
#> GSM110445     1  0.0000      0.979 1.000 0.000
#> GSM110446     1  0.0672      0.974 0.992 0.008
#> GSM110449     2  0.0000      0.988 0.000 1.000
#> GSM110451     2  0.0000      0.988 0.000 1.000
#> GSM110391     2  0.0000      0.988 0.000 1.000
#> GSM110439     2  0.0000      0.988 0.000 1.000
#> GSM110442     2  0.0000      0.988 0.000 1.000
#> GSM110443     2  0.0000      0.988 0.000 1.000
#> GSM110447     2  0.0000      0.988 0.000 1.000
#> GSM110448     1  0.0000      0.979 1.000 0.000
#> GSM110450     1  0.0000      0.979 1.000 0.000
#> GSM110452     2  0.0000      0.988 0.000 1.000
#> GSM110453     2  0.0000      0.988 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM110395     3   0.000      0.913 0.000 0.000 1.000
#> GSM110396     1   0.000      0.969 1.000 0.000 0.000
#> GSM110397     1   0.000      0.969 1.000 0.000 0.000
#> GSM110398     3   0.611      0.350 0.396 0.000 0.604
#> GSM110399     3   0.000      0.913 0.000 0.000 1.000
#> GSM110400     3   0.000      0.913 0.000 0.000 1.000
#> GSM110401     1   0.000      0.969 1.000 0.000 0.000
#> GSM110406     3   0.000      0.913 0.000 0.000 1.000
#> GSM110407     1   0.000      0.969 1.000 0.000 0.000
#> GSM110409     1   0.000      0.969 1.000 0.000 0.000
#> GSM110410     2   0.000      0.940 0.000 1.000 0.000
#> GSM110413     3   0.000      0.913 0.000 0.000 1.000
#> GSM110414     2   0.000      0.940 0.000 1.000 0.000
#> GSM110415     3   0.000      0.913 0.000 0.000 1.000
#> GSM110416     3   0.000      0.913 0.000 0.000 1.000
#> GSM110418     3   0.164      0.880 0.044 0.000 0.956
#> GSM110419     3   0.000      0.913 0.000 0.000 1.000
#> GSM110420     3   0.620      0.291 0.424 0.000 0.576
#> GSM110421     3   0.000      0.913 0.000 0.000 1.000
#> GSM110423     3   0.000      0.913 0.000 0.000 1.000
#> GSM110424     2   0.000      0.940 0.000 1.000 0.000
#> GSM110425     3   0.000      0.913 0.000 0.000 1.000
#> GSM110427     2   0.000      0.940 0.000 1.000 0.000
#> GSM110428     1   0.619      0.179 0.580 0.000 0.420
#> GSM110430     1   0.000      0.969 1.000 0.000 0.000
#> GSM110431     1   0.000      0.969 1.000 0.000 0.000
#> GSM110432     3   0.000      0.913 0.000 0.000 1.000
#> GSM110434     3   0.000      0.913 0.000 0.000 1.000
#> GSM110435     1   0.000      0.969 1.000 0.000 0.000
#> GSM110437     1   0.000      0.969 1.000 0.000 0.000
#> GSM110438     3   0.455      0.726 0.200 0.000 0.800
#> GSM110388     1   0.000      0.969 1.000 0.000 0.000
#> GSM110392     3   0.000      0.913 0.000 0.000 1.000
#> GSM110394     1   0.000      0.969 1.000 0.000 0.000
#> GSM110402     3   0.000      0.913 0.000 0.000 1.000
#> GSM110411     3   0.506      0.655 0.244 0.000 0.756
#> GSM110412     3   0.000      0.913 0.000 0.000 1.000
#> GSM110417     1   0.000      0.969 1.000 0.000 0.000
#> GSM110422     2   0.129      0.925 0.000 0.968 0.032
#> GSM110426     1   0.000      0.969 1.000 0.000 0.000
#> GSM110429     2   0.625      0.216 0.000 0.556 0.444
#> GSM110433     2   0.000      0.940 0.000 1.000 0.000
#> GSM110436     2   0.000      0.940 0.000 1.000 0.000
#> GSM110440     1   0.000      0.969 1.000 0.000 0.000
#> GSM110441     3   0.617      0.278 0.000 0.412 0.588
#> GSM110444     3   0.000      0.913 0.000 0.000 1.000
#> GSM110445     1   0.000      0.969 1.000 0.000 0.000
#> GSM110446     3   0.603      0.414 0.376 0.000 0.624
#> GSM110449     3   0.000      0.913 0.000 0.000 1.000
#> GSM110451     3   0.000      0.913 0.000 0.000 1.000
#> GSM110391     2   0.226      0.894 0.000 0.932 0.068
#> GSM110439     2   0.000      0.940 0.000 1.000 0.000
#> GSM110442     3   0.000      0.913 0.000 0.000 1.000
#> GSM110443     3   0.000      0.913 0.000 0.000 1.000
#> GSM110447     3   0.000      0.913 0.000 0.000 1.000
#> GSM110448     1   0.000      0.969 1.000 0.000 0.000
#> GSM110450     1   0.000      0.969 1.000 0.000 0.000
#> GSM110452     2   0.141      0.922 0.000 0.964 0.036
#> GSM110453     2   0.000      0.940 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110396     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110397     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110398     4  0.4624    0.23041 0.340 0.000 0.000 0.660
#> GSM110399     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110400     4  0.2593    0.80295 0.000 0.104 0.004 0.892
#> GSM110401     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110406     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110407     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110409     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110410     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110413     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110414     2  0.0376    0.88708 0.000 0.992 0.004 0.004
#> GSM110415     3  0.4855    0.51110 0.000 0.000 0.600 0.400
#> GSM110416     3  0.4855    0.51110 0.000 0.000 0.600 0.400
#> GSM110418     3  0.6855    0.61363 0.200 0.000 0.600 0.200
#> GSM110419     4  0.4907   -0.09425 0.000 0.000 0.420 0.580
#> GSM110420     3  0.4855    0.40850 0.400 0.000 0.600 0.000
#> GSM110421     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110423     4  0.4348    0.58851 0.000 0.024 0.196 0.780
#> GSM110424     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110425     4  0.2593    0.80295 0.000 0.104 0.004 0.892
#> GSM110427     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110428     1  0.4907    0.08376 0.580 0.000 0.000 0.420
#> GSM110430     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110431     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110432     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110434     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110435     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110437     1  0.5028    0.64177 0.596 0.004 0.400 0.000
#> GSM110438     4  0.7523   -0.27819 0.400 0.000 0.184 0.416
#> GSM110388     1  0.0188    0.79060 0.996 0.000 0.000 0.004
#> GSM110392     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110394     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110402     3  0.4967    0.39863 0.000 0.000 0.548 0.452
#> GSM110411     4  0.4679    0.23191 0.352 0.000 0.000 0.648
#> GSM110412     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110417     1  0.0188    0.79205 0.996 0.004 0.000 0.000
#> GSM110422     2  0.0592    0.88498 0.000 0.984 0.000 0.016
#> GSM110426     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110429     2  0.4925    0.10224 0.000 0.572 0.000 0.428
#> GSM110433     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110436     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110440     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110441     2  0.4994    0.00754 0.000 0.520 0.000 0.480
#> GSM110444     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110445     1  0.0188    0.79060 0.996 0.000 0.000 0.004
#> GSM110446     3  0.4855    0.40850 0.400 0.000 0.600 0.000
#> GSM110449     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110451     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110391     2  0.1302    0.86177 0.000 0.956 0.000 0.044
#> GSM110439     2  0.0188    0.89026 0.000 0.996 0.000 0.004
#> GSM110442     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110443     4  0.0000    0.76600 0.000 0.000 0.000 1.000
#> GSM110447     4  0.2469    0.80405 0.000 0.108 0.000 0.892
#> GSM110448     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110450     1  0.0000    0.79314 1.000 0.000 0.000 0.000
#> GSM110452     2  0.0707    0.88263 0.000 0.980 0.000 0.020
#> GSM110453     2  0.0188    0.89026 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110396     1  0.2230      0.819 0.884 0.000 0.000 0.116 0.000
#> GSM110397     1  0.0000      0.898 1.000 0.000 0.000 0.000 0.000
#> GSM110398     4  0.5490      0.590 0.000 0.148 0.200 0.652 0.000
#> GSM110399     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110400     2  0.0703      0.905 0.000 0.976 0.024 0.000 0.000
#> GSM110401     1  0.0000      0.898 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110407     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110409     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110410     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000
#> GSM110413     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110414     5  0.0703      0.907 0.000 0.000 0.024 0.000 0.976
#> GSM110415     3  0.3109      0.633 0.000 0.200 0.800 0.000 0.000
#> GSM110416     3  0.0000      0.686 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000      0.686 0.000 0.000 1.000 0.000 0.000
#> GSM110419     2  0.4182      0.155 0.000 0.600 0.400 0.000 0.000
#> GSM110420     3  0.3143      0.559 0.000 0.000 0.796 0.204 0.000
#> GSM110421     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110423     2  0.3177      0.652 0.000 0.792 0.208 0.000 0.000
#> GSM110424     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000
#> GSM110425     2  0.0703      0.905 0.000 0.976 0.024 0.000 0.000
#> GSM110427     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000
#> GSM110428     4  0.3177      0.790 0.000 0.000 0.208 0.792 0.000
#> GSM110430     1  0.0000      0.898 1.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.0000      0.898 1.000 0.000 0.000 0.000 0.000
#> GSM110432     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110434     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110435     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110437     1  0.0000      0.898 1.000 0.000 0.000 0.000 0.000
#> GSM110438     3  0.4779      0.337 0.000 0.388 0.588 0.024 0.000
#> GSM110388     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110392     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110394     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110402     3  0.4278      0.195 0.000 0.452 0.548 0.000 0.000
#> GSM110411     4  0.3266      0.794 0.000 0.004 0.200 0.796 0.000
#> GSM110412     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110417     1  0.4182      0.427 0.600 0.000 0.000 0.400 0.000
#> GSM110422     5  0.0880      0.913 0.000 0.032 0.000 0.000 0.968
#> GSM110426     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110429     5  0.4268      0.171 0.000 0.444 0.000 0.000 0.556
#> GSM110433     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000
#> GSM110436     5  0.0880      0.913 0.000 0.032 0.000 0.000 0.968
#> GSM110440     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110441     2  0.4210      0.215 0.000 0.588 0.000 0.000 0.412
#> GSM110444     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110445     4  0.3109      0.797 0.000 0.000 0.200 0.800 0.000
#> GSM110446     3  0.0000      0.686 0.000 0.000 1.000 0.000 0.000
#> GSM110449     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110451     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110391     5  0.1544      0.878 0.000 0.068 0.000 0.000 0.932
#> GSM110439     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000
#> GSM110442     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110443     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110447     2  0.0000      0.925 0.000 1.000 0.000 0.000 0.000
#> GSM110448     4  0.0000      0.910 0.000 0.000 0.000 1.000 0.000
#> GSM110450     4  0.0794      0.900 0.000 0.000 0.028 0.972 0.000
#> GSM110452     5  0.0963      0.910 0.000 0.036 0.000 0.000 0.964
#> GSM110453     5  0.0000      0.921 0.000 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5   p6
#> GSM110395     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110396     6  0.2048      0.815 0.120 0.000 0.000 0.000 0.000 0.88
#> GSM110397     6  0.0000      0.897 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM110398     4  0.3470      0.748 0.028 0.000 0.200 0.772 0.000 0.00
#> GSM110399     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110400     2  0.0363      0.906 0.000 0.988 0.000 0.012 0.000 0.00
#> GSM110401     6  0.0000      0.897 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM110406     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110407     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110409     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110410     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.00
#> GSM110413     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110414     5  0.0713      0.961 0.000 0.028 0.000 0.000 0.972 0.00
#> GSM110415     3  0.2933      0.735 0.000 0.004 0.796 0.200 0.000 0.00
#> GSM110416     3  0.0000      0.778 0.000 0.000 1.000 0.000 0.000 0.00
#> GSM110418     3  0.0000      0.778 0.000 0.000 1.000 0.000 0.000 0.00
#> GSM110419     3  0.3141      0.733 0.000 0.012 0.788 0.200 0.000 0.00
#> GSM110420     3  0.2996      0.647 0.228 0.000 0.772 0.000 0.000 0.00
#> GSM110421     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110423     2  0.2454      0.748 0.000 0.840 0.160 0.000 0.000 0.00
#> GSM110424     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.00
#> GSM110425     2  0.0000      0.907 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM110427     5  0.0937      0.942 0.000 0.040 0.000 0.000 0.960 0.00
#> GSM110428     1  0.2996      0.733 0.772 0.000 0.228 0.000 0.000 0.00
#> GSM110430     6  0.0000      0.897 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM110431     6  0.0000      0.897 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM110432     2  0.3151      0.741 0.000 0.748 0.000 0.252 0.000 0.00
#> GSM110434     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110435     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110437     6  0.0000      0.897 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM110438     4  0.3151      0.724 0.000 0.000 0.252 0.748 0.000 0.00
#> GSM110388     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110392     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110394     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110402     3  0.5461      0.538 0.000 0.228 0.572 0.200 0.000 0.00
#> GSM110411     4  0.3470      0.748 0.028 0.000 0.200 0.772 0.000 0.00
#> GSM110412     2  0.3446      0.673 0.000 0.692 0.000 0.308 0.000 0.00
#> GSM110417     6  0.3756      0.401 0.400 0.000 0.000 0.000 0.000 0.60
#> GSM110422     2  0.0713      0.909 0.000 0.972 0.000 0.000 0.028 0.00
#> GSM110426     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110429     2  0.0713      0.909 0.000 0.972 0.000 0.000 0.028 0.00
#> GSM110433     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.00
#> GSM110436     2  0.0713      0.909 0.000 0.972 0.000 0.000 0.028 0.00
#> GSM110440     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110441     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110444     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110445     1  0.3470      0.738 0.772 0.000 0.200 0.028 0.000 0.00
#> GSM110446     3  0.0000      0.778 0.000 0.000 1.000 0.000 0.000 0.00
#> GSM110449     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110451     2  0.0713      0.914 0.000 0.972 0.000 0.028 0.000 0.00
#> GSM110391     2  0.0713      0.909 0.000 0.972 0.000 0.000 0.028 0.00
#> GSM110439     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.00
#> GSM110442     2  0.2996      0.763 0.000 0.772 0.000 0.228 0.000 0.00
#> GSM110443     4  0.0000      0.885 0.000 0.000 0.000 1.000 0.000 0.00
#> GSM110447     2  0.2823      0.763 0.000 0.796 0.000 0.204 0.000 0.00
#> GSM110448     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000 0.00
#> GSM110450     1  0.0713      0.927 0.972 0.000 0.028 0.000 0.000 0.00
#> GSM110452     2  0.0713      0.909 0.000 0.972 0.000 0.000 0.028 0.00
#> GSM110453     5  0.0000      0.985 0.000 0.000 0.000 0.000 1.000 0.00

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) specimen(p) k
#> ATC:pam 57           0.6664       0.402 2
#> ATC:pam 53           0.4247       0.157 3
#> ATC:pam 49           0.2691       0.311 4
#> ATC:pam 53           0.0576       0.267 5
#> ATC:pam 58           0.1383       0.534 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.569           0.823       0.929         0.2346 0.842   0.842
#> 3 3 0.286           0.245       0.628         1.5081 0.476   0.426
#> 4 4 0.700           0.760       0.868         0.2643 0.732   0.447
#> 5 5 0.917           0.860       0.943         0.0766 0.870   0.545
#> 6 6 0.843           0.804       0.912         0.0224 0.950   0.768

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
#> GSM110395     2  0.9996    -0.0756 0.488 0.512
#> GSM110396     2  0.4690     0.8379 0.100 0.900
#> GSM110397     2  0.4815     0.8355 0.104 0.896
#> GSM110398     2  0.0000     0.9194 0.000 1.000
#> GSM110399     2  0.0000     0.9194 0.000 1.000
#> GSM110400     2  0.0672     0.9165 0.008 0.992
#> GSM110401     2  0.4690     0.8379 0.100 0.900
#> GSM110406     2  0.0672     0.9145 0.008 0.992
#> GSM110407     2  0.0000     0.9194 0.000 1.000
#> GSM110409     2  0.0000     0.9194 0.000 1.000
#> GSM110410     2  0.0000     0.9194 0.000 1.000
#> GSM110413     2  0.0000     0.9194 0.000 1.000
#> GSM110414     2  0.0672     0.9165 0.008 0.992
#> GSM110415     2  0.0672     0.9165 0.008 0.992
#> GSM110416     2  0.0672     0.9165 0.008 0.992
#> GSM110418     2  0.0672     0.9165 0.008 0.992
#> GSM110419     2  0.0672     0.9165 0.008 0.992
#> GSM110420     2  0.0672     0.9165 0.008 0.992
#> GSM110421     2  0.9286     0.4030 0.344 0.656
#> GSM110423     2  0.0672     0.9165 0.008 0.992
#> GSM110424     2  0.0000     0.9194 0.000 1.000
#> GSM110425     2  0.0672     0.9165 0.008 0.992
#> GSM110427     1  0.4939     0.9861 0.892 0.108
#> GSM110428     2  0.0000     0.9194 0.000 1.000
#> GSM110430     2  0.4690     0.8379 0.100 0.900
#> GSM110431     2  0.0000     0.9194 0.000 1.000
#> GSM110432     2  1.0000    -0.1201 0.500 0.500
#> GSM110434     2  0.9248     0.4132 0.340 0.660
#> GSM110435     2  0.0000     0.9194 0.000 1.000
#> GSM110437     2  0.4690     0.8379 0.100 0.900
#> GSM110438     2  0.0000     0.9194 0.000 1.000
#> GSM110388     2  0.0000     0.9194 0.000 1.000
#> GSM110392     2  0.0000     0.9194 0.000 1.000
#> GSM110394     2  0.0000     0.9194 0.000 1.000
#> GSM110402     2  0.0672     0.9165 0.008 0.992
#> GSM110411     2  0.0000     0.9194 0.000 1.000
#> GSM110412     2  1.0000    -0.1201 0.500 0.500
#> GSM110417     2  0.4690     0.8379 0.100 0.900
#> GSM110422     1  0.4939     0.9861 0.892 0.108
#> GSM110426     2  0.0000     0.9194 0.000 1.000
#> GSM110429     1  0.6148     0.9414 0.848 0.152
#> GSM110433     2  0.0000     0.9194 0.000 1.000
#> GSM110436     1  0.4939     0.9861 0.892 0.108
#> GSM110440     2  0.0000     0.9194 0.000 1.000
#> GSM110441     2  0.0000     0.9194 0.000 1.000
#> GSM110444     2  0.0000     0.9194 0.000 1.000
#> GSM110445     2  0.0000     0.9194 0.000 1.000
#> GSM110446     2  0.0672     0.9165 0.008 0.992
#> GSM110449     2  0.0000     0.9194 0.000 1.000
#> GSM110451     1  0.4939     0.9861 0.892 0.108
#> GSM110391     2  0.0000     0.9194 0.000 1.000
#> GSM110439     2  0.0000     0.9194 0.000 1.000
#> GSM110442     2  0.8016     0.6167 0.244 0.756
#> GSM110443     2  0.0000     0.9194 0.000 1.000
#> GSM110447     2  0.0000     0.9194 0.000 1.000
#> GSM110448     2  0.0000     0.9194 0.000 1.000
#> GSM110450     2  0.0000     0.9194 0.000 1.000
#> GSM110452     2  1.0000    -0.1201 0.500 0.500
#> GSM110453     2  0.0000     0.9194 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
#> GSM110395     2   0.649     0.6265 0.004 0.540 0.456
#> GSM110396     1   0.746    -0.0500 0.524 0.036 0.440
#> GSM110397     1   0.703    -0.0445 0.540 0.020 0.440
#> GSM110398     2   0.314     0.5835 0.068 0.912 0.020
#> GSM110399     2   0.441     0.5628 0.140 0.844 0.016
#> GSM110400     1   0.618     0.1234 0.660 0.332 0.008
#> GSM110401     1   0.746    -0.0500 0.524 0.036 0.440
#> GSM110406     2   0.621     0.6104 0.048 0.752 0.200
#> GSM110407     1   0.893    -0.2543 0.456 0.124 0.420
#> GSM110409     1   0.893    -0.2543 0.456 0.124 0.420
#> GSM110410     2   0.752     0.2753 0.260 0.660 0.080
#> GSM110413     2   0.419     0.5900 0.060 0.876 0.064
#> GSM110414     1   0.711     0.0672 0.680 0.260 0.060
#> GSM110415     1   0.566     0.1194 0.740 0.248 0.012
#> GSM110416     1   0.470     0.1022 0.788 0.212 0.000
#> GSM110418     1   0.553     0.1174 0.704 0.296 0.000
#> GSM110419     1   0.556     0.1261 0.700 0.300 0.000
#> GSM110420     1   0.587     0.0894 0.760 0.208 0.032
#> GSM110421     2   0.809     0.6271 0.076 0.560 0.364
#> GSM110423     1   0.618     0.1234 0.660 0.332 0.008
#> GSM110424     2   0.446     0.5798 0.056 0.864 0.080
#> GSM110425     1   0.618     0.1234 0.660 0.332 0.008
#> GSM110427     2   0.630     0.6217 0.000 0.528 0.472
#> GSM110428     2   0.680    -0.0222 0.308 0.660 0.032
#> GSM110430     1   0.746    -0.0500 0.524 0.036 0.440
#> GSM110431     1   0.873    -0.2367 0.472 0.108 0.420
#> GSM110432     2   0.680     0.6232 0.012 0.528 0.460
#> GSM110434     2   0.613     0.6353 0.004 0.644 0.352
#> GSM110435     1   0.867    -0.3014 0.508 0.108 0.384
#> GSM110437     1   0.746    -0.0500 0.524 0.036 0.440
#> GSM110438     3   0.999     0.6916 0.316 0.336 0.348
#> GSM110388     1   0.995    -0.7690 0.368 0.284 0.348
#> GSM110392     2   0.220     0.6064 0.056 0.940 0.004
#> GSM110394     1   0.862    -0.3512 0.536 0.112 0.352
#> GSM110402     1   0.576     0.1267 0.716 0.276 0.008
#> GSM110411     2   0.406     0.5209 0.112 0.868 0.020
#> GSM110412     2   0.649     0.6265 0.004 0.540 0.456
#> GSM110417     1   0.726    -0.0471 0.532 0.028 0.440
#> GSM110422     2   0.630     0.6188 0.000 0.520 0.480
#> GSM110426     1   0.873    -0.2367 0.472 0.108 0.420
#> GSM110429     2   0.651     0.6191 0.004 0.520 0.476
#> GSM110433     2   0.526     0.5527 0.092 0.828 0.080
#> GSM110436     2   0.630     0.6205 0.000 0.524 0.476
#> GSM110440     1   0.972    -0.6850 0.424 0.228 0.348
#> GSM110441     2   0.598     0.5377 0.132 0.788 0.080
#> GSM110444     2   0.264     0.6003 0.048 0.932 0.020
#> GSM110445     3   0.997     0.6920 0.320 0.308 0.372
#> GSM110446     1   0.543     0.1124 0.716 0.284 0.000
#> GSM110449     2   0.355     0.5762 0.132 0.868 0.000
#> GSM110451     2   0.630     0.6188 0.000 0.520 0.480
#> GSM110391     2   0.409     0.5885 0.056 0.880 0.064
#> GSM110439     2   0.526     0.5527 0.092 0.828 0.080
#> GSM110442     2   0.640     0.6388 0.012 0.644 0.344
#> GSM110443     2   0.230     0.6011 0.060 0.936 0.004
#> GSM110447     1   0.643     0.0693 0.612 0.380 0.008
#> GSM110448     1   0.995    -0.7690 0.368 0.284 0.348
#> GSM110450     1   0.962    -0.4641 0.440 0.212 0.348
#> GSM110452     2   0.650     0.6250 0.004 0.536 0.460
#> GSM110453     2   0.475     0.5754 0.068 0.852 0.080

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.0000      0.838 0.000 1.000 0.000 0.000
#> GSM110396     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110397     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110398     4  0.6928      0.650 0.184 0.204 0.004 0.608
#> GSM110399     4  0.3519      0.679 0.016 0.128 0.004 0.852
#> GSM110400     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110401     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110406     4  0.6700      0.576 0.112 0.316 0.000 0.572
#> GSM110407     1  0.0188      0.932 0.996 0.000 0.004 0.000
#> GSM110409     1  0.0188      0.932 0.996 0.000 0.004 0.000
#> GSM110410     2  0.5105      0.198 0.000 0.564 0.004 0.432
#> GSM110413     4  0.5925      0.686 0.100 0.196 0.004 0.700
#> GSM110414     3  0.4933      0.399 0.000 0.000 0.568 0.432
#> GSM110415     3  0.0188      0.954 0.004 0.000 0.996 0.000
#> GSM110416     3  0.0188      0.954 0.004 0.000 0.996 0.000
#> GSM110418     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110419     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110420     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110421     2  0.4579      0.384 0.004 0.720 0.004 0.272
#> GSM110423     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110424     4  0.4279      0.559 0.012 0.204 0.004 0.780
#> GSM110425     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110427     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> GSM110428     2  0.5050      0.205 0.408 0.588 0.004 0.000
#> GSM110430     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110431     1  0.1970      0.905 0.932 0.060 0.008 0.000
#> GSM110432     2  0.0000      0.838 0.000 1.000 0.000 0.000
#> GSM110434     2  0.0844      0.823 0.012 0.980 0.004 0.004
#> GSM110435     1  0.2216      0.887 0.908 0.000 0.092 0.000
#> GSM110437     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110438     1  0.4632      0.550 0.688 0.308 0.004 0.000
#> GSM110388     1  0.2076      0.914 0.932 0.008 0.004 0.056
#> GSM110392     4  0.6969      0.347 0.112 0.436 0.000 0.452
#> GSM110394     1  0.2623      0.900 0.908 0.000 0.028 0.064
#> GSM110402     3  0.0188      0.954 0.004 0.000 0.996 0.000
#> GSM110411     4  0.7150      0.628 0.212 0.204 0.004 0.580
#> GSM110412     2  0.0000      0.838 0.000 1.000 0.000 0.000
#> GSM110417     1  0.0000      0.932 1.000 0.000 0.000 0.000
#> GSM110422     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> GSM110426     1  0.2644      0.897 0.908 0.032 0.060 0.000
#> GSM110429     2  0.0592      0.832 0.000 0.984 0.016 0.000
#> GSM110433     4  0.3831      0.551 0.000 0.204 0.004 0.792
#> GSM110436     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> GSM110440     1  0.2401      0.892 0.904 0.000 0.004 0.092
#> GSM110441     4  0.0188      0.631 0.000 0.000 0.004 0.996
#> GSM110444     4  0.6083      0.676 0.112 0.216 0.000 0.672
#> GSM110445     4  0.5345      0.403 0.404 0.008 0.004 0.584
#> GSM110446     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM110449     4  0.5099      0.684 0.048 0.200 0.004 0.748
#> GSM110451     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> GSM110391     4  0.5750      0.566 0.052 0.272 0.004 0.672
#> GSM110439     4  0.3908      0.554 0.000 0.212 0.004 0.784
#> GSM110442     2  0.0000      0.838 0.000 1.000 0.000 0.000
#> GSM110443     4  0.6175      0.679 0.108 0.212 0.004 0.676
#> GSM110447     2  0.5028      0.326 0.000 0.596 0.400 0.004
#> GSM110448     1  0.2796      0.888 0.892 0.008 0.004 0.096
#> GSM110450     1  0.0895      0.921 0.976 0.020 0.004 0.000
#> GSM110452     2  0.0188      0.839 0.000 0.996 0.004 0.000
#> GSM110453     4  0.4220      0.497 0.000 0.248 0.004 0.748

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110396     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110397     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110398     4  0.0579      0.829 0.008 0.008 0.000 0.984 0.000
#> GSM110399     4  0.1732      0.788 0.000 0.000 0.000 0.920 0.080
#> GSM110400     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110401     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110406     2  0.4210      0.266 0.000 0.588 0.000 0.412 0.000
#> GSM110407     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110409     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110410     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110413     4  0.3487      0.653 0.000 0.008 0.000 0.780 0.212
#> GSM110414     5  0.0510      0.979 0.000 0.000 0.016 0.000 0.984
#> GSM110415     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110416     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110418     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110419     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110420     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110421     2  0.0703      0.890 0.000 0.976 0.000 0.000 0.024
#> GSM110423     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110424     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110425     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110427     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110428     1  0.4235      0.229 0.576 0.424 0.000 0.000 0.000
#> GSM110430     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110431     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110432     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110434     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110435     1  0.0290      0.941 0.992 0.000 0.000 0.008 0.000
#> GSM110437     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110438     2  0.4367      0.217 0.416 0.580 0.000 0.004 0.000
#> GSM110388     4  0.3774      0.577 0.296 0.000 0.000 0.704 0.000
#> GSM110392     4  0.4201      0.275 0.000 0.408 0.000 0.592 0.000
#> GSM110394     1  0.0290      0.941 0.992 0.000 0.000 0.008 0.000
#> GSM110402     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110411     4  0.0579      0.829 0.008 0.008 0.000 0.984 0.000
#> GSM110412     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110417     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110422     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110426     1  0.0000      0.945 1.000 0.000 0.000 0.000 0.000
#> GSM110429     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110433     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110436     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110440     1  0.0510      0.935 0.984 0.000 0.000 0.016 0.000
#> GSM110441     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110444     4  0.0290      0.827 0.000 0.008 0.000 0.992 0.000
#> GSM110445     4  0.0963      0.821 0.036 0.000 0.000 0.964 0.000
#> GSM110446     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM110449     4  0.0566      0.825 0.000 0.004 0.000 0.984 0.012
#> GSM110451     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110391     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110439     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996
#> GSM110442     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110443     4  0.0613      0.828 0.004 0.008 0.000 0.984 0.004
#> GSM110447     2  0.3480      0.636 0.000 0.752 0.248 0.000 0.000
#> GSM110448     4  0.4268      0.273 0.444 0.000 0.000 0.556 0.000
#> GSM110450     1  0.2929      0.728 0.820 0.000 0.000 0.180 0.000
#> GSM110452     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM110453     5  0.0162      0.997 0.000 0.000 0.000 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM110395     2  0.0363      0.894 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM110396     1  0.0790      0.836 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM110397     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM110398     4  0.0000      0.855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110399     4  0.2664      0.641 0.000 0.000 0.000 0.816 0.184 0.000
#> GSM110400     3  0.0363      0.937 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM110401     1  0.0790      0.836 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM110406     2  0.3789      0.233 0.000 0.584 0.000 0.416 0.000 0.000
#> GSM110407     1  0.0790      0.836 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM110409     1  0.0458      0.833 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM110410     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110413     5  0.3854      0.102 0.000 0.000 0.000 0.464 0.536 0.000
#> GSM110414     5  0.3013      0.774 0.000 0.000 0.088 0.000 0.844 0.068
#> GSM110415     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110416     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110418     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110419     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110420     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110421     2  0.3056      0.712 0.000 0.804 0.004 0.008 0.184 0.000
#> GSM110423     3  0.0363      0.937 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM110424     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110425     3  0.0790      0.920 0.000 0.032 0.968 0.000 0.000 0.000
#> GSM110427     2  0.1714      0.889 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM110428     1  0.3820      0.454 0.660 0.332 0.000 0.004 0.000 0.004
#> GSM110430     1  0.0790      0.836 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM110431     1  0.0146      0.836 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110432     2  0.0405      0.893 0.000 0.988 0.008 0.004 0.000 0.000
#> GSM110434     2  0.0363      0.894 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM110435     1  0.2823      0.698 0.796 0.000 0.000 0.000 0.000 0.204
#> GSM110437     1  0.0790      0.836 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM110438     1  0.3850      0.440 0.652 0.340 0.000 0.004 0.000 0.004
#> GSM110388     6  0.3563      0.937 0.108 0.000 0.000 0.092 0.000 0.800
#> GSM110392     4  0.3695      0.400 0.000 0.376 0.000 0.624 0.000 0.000
#> GSM110394     1  0.2823      0.698 0.796 0.000 0.000 0.000 0.000 0.204
#> GSM110402     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110411     4  0.0000      0.855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110412     2  0.0363      0.894 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM110417     1  0.1141      0.823 0.948 0.000 0.000 0.000 0.000 0.052
#> GSM110422     2  0.1714      0.889 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM110426     1  0.0146      0.836 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM110429     2  0.1714      0.889 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM110433     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110436     2  0.1714      0.889 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM110440     1  0.3922      0.486 0.664 0.000 0.000 0.016 0.000 0.320
#> GSM110441     5  0.0260      0.904 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM110444     4  0.0000      0.855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM110445     4  0.2170      0.718 0.100 0.000 0.000 0.888 0.000 0.012
#> GSM110446     3  0.0000      0.943 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM110449     4  0.0146      0.853 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM110451     2  0.1714      0.889 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM110391     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110439     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM110442     2  0.0363      0.894 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM110443     4  0.0146      0.853 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM110447     3  0.3684      0.371 0.000 0.372 0.628 0.000 0.000 0.000
#> GSM110448     6  0.3416      0.939 0.140 0.000 0.000 0.056 0.000 0.804
#> GSM110450     1  0.3450      0.664 0.780 0.000 0.000 0.188 0.000 0.032
#> GSM110452     2  0.0713      0.896 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM110453     5  0.0000      0.907 0.000 0.000 0.000 0.000 1.000 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-mclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-mclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-mclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-mclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-mclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-mclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-mclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-mclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-mclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-mclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-mclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) specimen(p) k
#> ATC:mclust 53           0.3249       0.738 2
#> ATC:mclust 29           1.0000       1.000 3
#> ATC:mclust 51           0.1397       0.425 4
#> ATC:mclust 54           0.1429       0.168 5
#> ATC:mclust 52           0.0881       0.201 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 17209 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.711           0.863       0.934         0.3805 0.583   0.583
#> 3 3 0.626           0.701       0.886         0.5289 0.786   0.643
#> 4 4 0.473           0.560       0.785         0.1738 0.841   0.638
#> 5 5 0.442           0.373       0.694         0.0871 0.937   0.818
#> 6 6 0.479           0.435       0.636         0.0424 0.944   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
#> GSM110395     2  0.0000      0.963 0.000 1.000
#> GSM110396     1  0.0000      0.813 1.000 0.000
#> GSM110397     1  0.0000      0.813 1.000 0.000
#> GSM110398     2  0.9635      0.144 0.388 0.612
#> GSM110399     2  0.0000      0.963 0.000 1.000
#> GSM110400     2  0.0000      0.963 0.000 1.000
#> GSM110401     1  0.0000      0.813 1.000 0.000
#> GSM110406     2  0.0000      0.963 0.000 1.000
#> GSM110407     1  0.7219      0.794 0.800 0.200
#> GSM110409     1  0.9552      0.609 0.624 0.376
#> GSM110410     2  0.0000      0.963 0.000 1.000
#> GSM110413     2  0.0000      0.963 0.000 1.000
#> GSM110414     2  0.0000      0.963 0.000 1.000
#> GSM110415     2  0.0000      0.963 0.000 1.000
#> GSM110416     2  0.0000      0.963 0.000 1.000
#> GSM110418     2  0.0000      0.963 0.000 1.000
#> GSM110419     2  0.0000      0.963 0.000 1.000
#> GSM110420     2  0.0000      0.963 0.000 1.000
#> GSM110421     2  0.0000      0.963 0.000 1.000
#> GSM110423     2  0.0000      0.963 0.000 1.000
#> GSM110424     2  0.0000      0.963 0.000 1.000
#> GSM110425     2  0.0000      0.963 0.000 1.000
#> GSM110427     2  0.0000      0.963 0.000 1.000
#> GSM110428     2  0.9393      0.264 0.356 0.644
#> GSM110430     1  0.0000      0.813 1.000 0.000
#> GSM110431     1  0.0000      0.813 1.000 0.000
#> GSM110432     2  0.0000      0.963 0.000 1.000
#> GSM110434     2  0.0000      0.963 0.000 1.000
#> GSM110435     1  0.8267      0.755 0.740 0.260
#> GSM110437     1  0.0000      0.813 1.000 0.000
#> GSM110438     2  0.4562      0.843 0.096 0.904
#> GSM110388     1  0.9710      0.562 0.600 0.400
#> GSM110392     2  0.0000      0.963 0.000 1.000
#> GSM110394     1  0.7674      0.782 0.776 0.224
#> GSM110402     2  0.0000      0.963 0.000 1.000
#> GSM110411     2  0.9286      0.304 0.344 0.656
#> GSM110412     2  0.0000      0.963 0.000 1.000
#> GSM110417     1  0.0938      0.814 0.988 0.012
#> GSM110422     2  0.0000      0.963 0.000 1.000
#> GSM110426     1  0.2603      0.815 0.956 0.044
#> GSM110429     2  0.0000      0.963 0.000 1.000
#> GSM110433     2  0.0000      0.963 0.000 1.000
#> GSM110436     2  0.0000      0.963 0.000 1.000
#> GSM110440     1  0.7219      0.794 0.800 0.200
#> GSM110441     2  0.0000      0.963 0.000 1.000
#> GSM110444     2  0.0000      0.963 0.000 1.000
#> GSM110445     1  0.9710      0.562 0.600 0.400
#> GSM110446     2  0.0000      0.963 0.000 1.000
#> GSM110449     2  0.0000      0.963 0.000 1.000
#> GSM110451     2  0.0000      0.963 0.000 1.000
#> GSM110391     2  0.0000      0.963 0.000 1.000
#> GSM110439     2  0.0000      0.963 0.000 1.000
#> GSM110442     2  0.0000      0.963 0.000 1.000
#> GSM110443     2  0.0000      0.963 0.000 1.000
#> GSM110447     2  0.0000      0.963 0.000 1.000
#> GSM110448     1  0.7950      0.772 0.760 0.240
#> GSM110450     1  0.9552      0.609 0.624 0.376
#> GSM110452     2  0.0000      0.963 0.000 1.000
#> GSM110453     2  0.0000      0.963 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
#> GSM110395     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110396     1  0.0237     0.7441 0.996 0.000 0.004
#> GSM110397     1  0.0237     0.7428 0.996 0.000 0.004
#> GSM110398     2  0.5882     0.3683 0.348 0.652 0.000
#> GSM110399     2  0.0424     0.9113 0.000 0.992 0.008
#> GSM110400     3  0.6252     0.2223 0.000 0.444 0.556
#> GSM110401     1  0.0000     0.7446 1.000 0.000 0.000
#> GSM110406     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110407     1  0.4452     0.6394 0.808 0.192 0.000
#> GSM110409     1  0.4931     0.5990 0.768 0.000 0.232
#> GSM110410     2  0.0592     0.9095 0.000 0.988 0.012
#> GSM110413     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110414     2  0.3619     0.7894 0.000 0.864 0.136
#> GSM110415     3  0.0237     0.7162 0.000 0.004 0.996
#> GSM110416     3  0.0000     0.7154 0.000 0.000 1.000
#> GSM110418     3  0.0000     0.7154 0.000 0.000 1.000
#> GSM110419     3  0.2878     0.6840 0.000 0.096 0.904
#> GSM110420     3  0.0000     0.7154 0.000 0.000 1.000
#> GSM110421     2  0.1031     0.8984 0.000 0.976 0.024
#> GSM110423     3  0.6291     0.1247 0.000 0.468 0.532
#> GSM110424     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110425     2  0.6079     0.3352 0.000 0.612 0.388
#> GSM110427     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110428     2  0.6520    -0.1174 0.488 0.508 0.004
#> GSM110430     1  0.0000     0.7446 1.000 0.000 0.000
#> GSM110431     1  0.2625     0.7074 0.916 0.000 0.084
#> GSM110432     2  0.0424     0.9122 0.000 0.992 0.008
#> GSM110434     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110435     3  0.2261     0.6746 0.068 0.000 0.932
#> GSM110437     1  0.0000     0.7446 1.000 0.000 0.000
#> GSM110438     2  0.7272     0.5829 0.096 0.700 0.204
#> GSM110388     1  0.6126     0.4060 0.600 0.400 0.000
#> GSM110392     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110394     3  0.6192     0.0516 0.420 0.000 0.580
#> GSM110402     3  0.4291     0.6167 0.000 0.180 0.820
#> GSM110411     2  0.5706     0.4409 0.320 0.680 0.000
#> GSM110412     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110417     1  0.0000     0.7446 1.000 0.000 0.000
#> GSM110422     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110426     3  0.6291    -0.1058 0.468 0.000 0.532
#> GSM110429     2  0.0747     0.9067 0.000 0.984 0.016
#> GSM110433     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110436     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110440     1  0.6079     0.3743 0.612 0.000 0.388
#> GSM110441     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110444     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110445     1  0.6204     0.3478 0.576 0.424 0.000
#> GSM110446     3  0.0892     0.7149 0.000 0.020 0.980
#> GSM110449     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110451     2  0.0237     0.9142 0.000 0.996 0.004
#> GSM110391     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110439     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110442     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110443     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110447     2  0.4654     0.6982 0.000 0.792 0.208
#> GSM110448     1  0.4555     0.6281 0.800 0.000 0.200
#> GSM110450     1  0.5948     0.4851 0.640 0.360 0.000
#> GSM110452     2  0.0000     0.9163 0.000 1.000 0.000
#> GSM110453     2  0.0000     0.9163 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM110395     2  0.1022     0.7427 0.000 0.968 0.000 0.032
#> GSM110396     1  0.1109     0.7439 0.968 0.000 0.004 0.028
#> GSM110397     1  0.0927     0.7387 0.976 0.000 0.008 0.016
#> GSM110398     2  0.6611    -0.0366 0.456 0.464 0.000 0.080
#> GSM110399     4  0.4919     0.5119 0.152 0.076 0.000 0.772
#> GSM110400     4  0.7834     0.2945 0.000 0.276 0.320 0.404
#> GSM110401     1  0.0188     0.7432 0.996 0.000 0.000 0.004
#> GSM110406     2  0.1256     0.7443 0.008 0.964 0.000 0.028
#> GSM110407     1  0.3710     0.6445 0.804 0.192 0.000 0.004
#> GSM110409     1  0.4837     0.7157 0.796 0.008 0.076 0.120
#> GSM110410     2  0.4898     0.1763 0.000 0.584 0.000 0.416
#> GSM110413     2  0.4431     0.5087 0.000 0.696 0.000 0.304
#> GSM110414     4  0.3123     0.7063 0.000 0.156 0.000 0.844
#> GSM110415     3  0.4889     0.4964 0.000 0.004 0.636 0.360
#> GSM110416     3  0.2402     0.7051 0.000 0.012 0.912 0.076
#> GSM110418     3  0.0469     0.7133 0.000 0.012 0.988 0.000
#> GSM110419     3  0.7414    -0.1975 0.000 0.172 0.460 0.368
#> GSM110420     3  0.0469     0.7156 0.000 0.000 0.988 0.012
#> GSM110421     2  0.3649     0.6369 0.000 0.796 0.000 0.204
#> GSM110423     2  0.6265     0.1318 0.000 0.500 0.444 0.056
#> GSM110424     2  0.3764     0.6203 0.000 0.784 0.000 0.216
#> GSM110425     2  0.5865     0.2271 0.000 0.552 0.412 0.036
#> GSM110427     2  0.0336     0.7431 0.000 0.992 0.000 0.008
#> GSM110428     2  0.2513     0.7029 0.036 0.924 0.024 0.016
#> GSM110430     1  0.0000     0.7436 1.000 0.000 0.000 0.000
#> GSM110431     1  0.3636     0.6831 0.820 0.000 0.172 0.008
#> GSM110432     2  0.0336     0.7429 0.000 0.992 0.000 0.008
#> GSM110434     2  0.1557     0.7373 0.000 0.944 0.000 0.056
#> GSM110435     3  0.6784    -0.0136 0.368 0.000 0.528 0.104
#> GSM110437     1  0.0000     0.7436 1.000 0.000 0.000 0.000
#> GSM110438     2  0.2883     0.7071 0.028 0.908 0.048 0.016
#> GSM110388     1  0.6071     0.4468 0.504 0.044 0.000 0.452
#> GSM110392     2  0.1940     0.7330 0.000 0.924 0.000 0.076
#> GSM110394     1  0.6936     0.4811 0.564 0.000 0.292 0.144
#> GSM110402     4  0.7216     0.5335 0.000 0.208 0.244 0.548
#> GSM110411     2  0.6170     0.1409 0.420 0.528 0.000 0.052
#> GSM110412     2  0.0707     0.7437 0.000 0.980 0.000 0.020
#> GSM110417     1  0.0336     0.7433 0.992 0.000 0.000 0.008
#> GSM110422     2  0.0000     0.7411 0.000 1.000 0.000 0.000
#> GSM110426     1  0.4933     0.4071 0.568 0.000 0.432 0.000
#> GSM110429     2  0.0927     0.7312 0.000 0.976 0.016 0.008
#> GSM110433     4  0.4406     0.6215 0.000 0.300 0.000 0.700
#> GSM110436     2  0.0000     0.7411 0.000 1.000 0.000 0.000
#> GSM110440     1  0.5745     0.6552 0.656 0.000 0.056 0.288
#> GSM110441     4  0.2814     0.7006 0.000 0.132 0.000 0.868
#> GSM110444     2  0.6969     0.2893 0.192 0.584 0.000 0.224
#> GSM110445     1  0.6531     0.5370 0.636 0.160 0.000 0.204
#> GSM110446     3  0.1042     0.7074 0.000 0.020 0.972 0.008
#> GSM110449     4  0.4507     0.7121 0.044 0.168 0.000 0.788
#> GSM110451     2  0.0336     0.7387 0.000 0.992 0.008 0.000
#> GSM110391     4  0.4564     0.5623 0.000 0.328 0.000 0.672
#> GSM110439     2  0.4961     0.0907 0.000 0.552 0.000 0.448
#> GSM110442     2  0.1302     0.7411 0.000 0.956 0.000 0.044
#> GSM110443     2  0.3401     0.6779 0.008 0.840 0.000 0.152
#> GSM110447     2  0.5700     0.0870 0.000 0.560 0.028 0.412
#> GSM110448     1  0.5334     0.6043 0.588 0.004 0.008 0.400
#> GSM110450     1  0.5038     0.4294 0.652 0.336 0.000 0.012
#> GSM110452     2  0.0469     0.7432 0.000 0.988 0.000 0.012
#> GSM110453     2  0.3649     0.6332 0.000 0.796 0.000 0.204

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM110395     2  0.2451     0.5050 0.000 0.904 0.004 0.036 0.056
#> GSM110396     1  0.3278     0.7007 0.860 0.000 0.020 0.092 0.028
#> GSM110397     1  0.1341     0.6931 0.944 0.000 0.000 0.056 0.000
#> GSM110398     2  0.8103    -0.4367 0.324 0.324 0.000 0.256 0.096
#> GSM110399     5  0.4752     0.4398 0.104 0.032 0.000 0.092 0.772
#> GSM110400     2  0.7773    -0.0180 0.000 0.444 0.124 0.136 0.296
#> GSM110401     1  0.0510     0.7143 0.984 0.000 0.000 0.016 0.000
#> GSM110406     2  0.4875     0.3578 0.064 0.760 0.000 0.136 0.040
#> GSM110407     1  0.3909     0.6957 0.760 0.024 0.000 0.216 0.000
#> GSM110409     1  0.5917     0.6683 0.680 0.000 0.104 0.160 0.056
#> GSM110410     2  0.5347     0.0444 0.000 0.528 0.004 0.044 0.424
#> GSM110413     2  0.6158    -0.0183 0.000 0.452 0.000 0.132 0.416
#> GSM110414     5  0.4113     0.5752 0.000 0.076 0.000 0.140 0.784
#> GSM110415     3  0.4866     0.3072 0.000 0.004 0.580 0.020 0.396
#> GSM110416     3  0.2299     0.7171 0.000 0.004 0.912 0.032 0.052
#> GSM110418     3  0.0451     0.7253 0.000 0.004 0.988 0.008 0.000
#> GSM110419     5  0.6929     0.3088 0.000 0.192 0.372 0.016 0.420
#> GSM110420     3  0.1522     0.7274 0.000 0.000 0.944 0.044 0.012
#> GSM110421     2  0.5555     0.4142 0.000 0.644 0.000 0.152 0.204
#> GSM110423     2  0.6915     0.2931 0.000 0.576 0.208 0.144 0.072
#> GSM110424     2  0.5572     0.2655 0.000 0.628 0.000 0.124 0.248
#> GSM110425     2  0.6430     0.3720 0.000 0.636 0.180 0.100 0.084
#> GSM110427     2  0.1560     0.5024 0.000 0.948 0.004 0.028 0.020
#> GSM110428     2  0.5122     0.2830 0.092 0.736 0.028 0.144 0.000
#> GSM110430     1  0.0404     0.7142 0.988 0.000 0.000 0.012 0.000
#> GSM110431     1  0.3890     0.6016 0.736 0.000 0.252 0.012 0.000
#> GSM110432     2  0.3614     0.4963 0.000 0.852 0.048 0.052 0.048
#> GSM110434     2  0.2221     0.4939 0.000 0.912 0.000 0.036 0.052
#> GSM110435     3  0.5700    -0.2834 0.456 0.000 0.472 0.004 0.068
#> GSM110437     1  0.0000     0.7126 1.000 0.000 0.000 0.000 0.000
#> GSM110438     2  0.6666    -0.5604 0.032 0.468 0.072 0.416 0.012
#> GSM110388     1  0.6768     0.5453 0.520 0.000 0.020 0.196 0.264
#> GSM110392     2  0.5365    -0.4502 0.000 0.528 0.000 0.416 0.056
#> GSM110394     1  0.7924     0.4634 0.468 0.000 0.184 0.172 0.176
#> GSM110402     5  0.7115     0.5271 0.000 0.140 0.200 0.096 0.564
#> GSM110411     4  0.7332     0.0000 0.144 0.376 0.000 0.420 0.060
#> GSM110412     2  0.3821     0.2800 0.000 0.764 0.000 0.216 0.020
#> GSM110417     1  0.4171     0.6962 0.764 0.004 0.012 0.204 0.016
#> GSM110422     2  0.1608     0.4830 0.000 0.928 0.000 0.072 0.000
#> GSM110426     1  0.4278     0.3085 0.548 0.000 0.452 0.000 0.000
#> GSM110429     2  0.3801     0.4702 0.000 0.820 0.036 0.128 0.016
#> GSM110433     5  0.4227     0.5170 0.000 0.292 0.000 0.016 0.692
#> GSM110436     2  0.1121     0.4753 0.000 0.956 0.000 0.044 0.000
#> GSM110440     1  0.5336     0.6292 0.632 0.000 0.052 0.012 0.304
#> GSM110441     5  0.2962     0.6078 0.000 0.084 0.000 0.048 0.868
#> GSM110444     2  0.7281    -0.5816 0.044 0.424 0.000 0.360 0.172
#> GSM110445     1  0.7187     0.4210 0.568 0.128 0.000 0.144 0.160
#> GSM110446     3  0.2787     0.6966 0.000 0.004 0.856 0.136 0.004
#> GSM110449     5  0.4232     0.6182 0.020 0.152 0.000 0.040 0.788
#> GSM110451     2  0.2227     0.4933 0.000 0.916 0.032 0.048 0.004
#> GSM110391     5  0.5029     0.4827 0.000 0.292 0.000 0.060 0.648
#> GSM110439     5  0.6173     0.1089 0.000 0.396 0.000 0.136 0.468
#> GSM110442     2  0.3804     0.4108 0.000 0.796 0.000 0.160 0.044
#> GSM110443     2  0.5572    -0.0737 0.004 0.612 0.000 0.296 0.088
#> GSM110447     2  0.6539    -0.0165 0.000 0.464 0.028 0.100 0.408
#> GSM110448     1  0.5173     0.5743 0.568 0.000 0.020 0.016 0.396
#> GSM110450     1  0.5305     0.4393 0.672 0.196 0.000 0.132 0.000
#> GSM110452     2  0.1965     0.4427 0.000 0.904 0.000 0.096 0.000
#> GSM110453     2  0.4800     0.3995 0.000 0.716 0.000 0.088 0.196

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM110395     2  0.3156     0.4506 0.000 0.852 0.000 0.080 0.024 NA
#> GSM110396     1  0.3452     0.7083 0.820 0.000 0.012 0.020 0.012 NA
#> GSM110397     1  0.2151     0.6926 0.912 0.000 0.016 0.024 0.000 NA
#> GSM110398     4  0.7707     0.3059 0.176 0.328 0.000 0.372 0.048 NA
#> GSM110399     5  0.4494     0.4695 0.024 0.020 0.000 0.064 0.768 NA
#> GSM110400     2  0.6825     0.1947 0.000 0.456 0.044 0.008 0.264 NA
#> GSM110401     1  0.0547     0.7094 0.980 0.000 0.000 0.000 0.000 NA
#> GSM110406     2  0.6416     0.2122 0.032 0.588 0.000 0.196 0.040 NA
#> GSM110407     1  0.4717     0.6779 0.728 0.036 0.000 0.152 0.000 NA
#> GSM110409     1  0.5814     0.6884 0.656 0.000 0.044 0.104 0.024 NA
#> GSM110410     2  0.5130    -0.0266 0.000 0.496 0.004 0.028 0.448 NA
#> GSM110413     2  0.7159     0.0305 0.000 0.388 0.000 0.252 0.272 NA
#> GSM110414     5  0.4738     0.5846 0.000 0.084 0.004 0.132 0.740 NA
#> GSM110415     3  0.6004     0.2544 0.000 0.020 0.488 0.020 0.392 NA
#> GSM110416     3  0.2542     0.8073 0.000 0.020 0.884 0.000 0.016 NA
#> GSM110418     3  0.2382     0.8087 0.000 0.024 0.904 0.020 0.004 NA
#> GSM110419     5  0.7060     0.3723 0.000 0.264 0.204 0.020 0.460 NA
#> GSM110420     3  0.0405     0.8151 0.000 0.000 0.988 0.004 0.000 NA
#> GSM110421     2  0.6507     0.3732 0.000 0.568 0.004 0.112 0.188 NA
#> GSM110423     2  0.6640     0.3301 0.000 0.512 0.072 0.016 0.100 NA
#> GSM110424     2  0.5223     0.2882 0.000 0.576 0.000 0.088 0.328 NA
#> GSM110425     2  0.6713     0.3836 0.000 0.584 0.080 0.036 0.168 NA
#> GSM110427     2  0.2675     0.4937 0.000 0.876 0.000 0.008 0.040 NA
#> GSM110428     2  0.6264    -0.0387 0.164 0.608 0.008 0.120 0.000 NA
#> GSM110430     1  0.1572     0.7115 0.936 0.000 0.000 0.028 0.000 NA
#> GSM110431     1  0.3916     0.6644 0.752 0.000 0.196 0.004 0.000 NA
#> GSM110432     2  0.4070     0.4771 0.000 0.764 0.000 0.020 0.048 NA
#> GSM110434     2  0.3396     0.4352 0.000 0.840 0.000 0.076 0.044 NA
#> GSM110435     1  0.6141     0.5427 0.568 0.000 0.280 0.012 0.056 NA
#> GSM110437     1  0.0777     0.7071 0.972 0.000 0.000 0.004 0.000 NA
#> GSM110438     4  0.6452     0.4845 0.016 0.372 0.116 0.468 0.008 NA
#> GSM110388     1  0.7042     0.3892 0.380 0.008 0.012 0.364 0.204 NA
#> GSM110392     4  0.4513     0.4605 0.004 0.440 0.000 0.532 0.024 NA
#> GSM110394     1  0.7513     0.5151 0.432 0.004 0.096 0.028 0.140 NA
#> GSM110402     5  0.7021     0.4517 0.000 0.144 0.208 0.104 0.524 NA
#> GSM110411     4  0.6029     0.5436 0.112 0.352 0.000 0.504 0.004 NA
#> GSM110412     2  0.3519     0.1680 0.000 0.744 0.004 0.244 0.004 NA
#> GSM110417     1  0.4849     0.6432 0.668 0.000 0.044 0.260 0.004 NA
#> GSM110422     2  0.2731     0.4592 0.000 0.876 0.000 0.044 0.012 NA
#> GSM110426     1  0.5369     0.4600 0.540 0.000 0.376 0.028 0.000 NA
#> GSM110429     2  0.4391     0.4361 0.000 0.700 0.004 0.024 0.020 NA
#> GSM110433     5  0.4008     0.4550 0.000 0.308 0.000 0.016 0.672 NA
#> GSM110436     2  0.1615     0.4353 0.000 0.928 0.000 0.064 0.004 NA
#> GSM110440     1  0.6172     0.6110 0.572 0.000 0.020 0.060 0.280 NA
#> GSM110441     5  0.2384     0.6030 0.000 0.040 0.000 0.056 0.896 NA
#> GSM110444     2  0.6269    -0.4297 0.036 0.448 0.000 0.408 0.096 NA
#> GSM110445     1  0.7204     0.4348 0.524 0.112 0.000 0.216 0.100 NA
#> GSM110446     3  0.1780     0.7984 0.000 0.000 0.924 0.048 0.000 NA
#> GSM110449     5  0.5039     0.5970 0.012 0.152 0.000 0.072 0.720 NA
#> GSM110451     2  0.3212     0.4558 0.000 0.844 0.008 0.036 0.008 NA
#> GSM110391     5  0.6178     0.2813 0.000 0.320 0.000 0.160 0.492 NA
#> GSM110439     5  0.5483     0.4729 0.000 0.276 0.000 0.108 0.596 NA
#> GSM110442     2  0.4789     0.3329 0.000 0.712 0.000 0.184 0.064 NA
#> GSM110443     2  0.5360    -0.1985 0.008 0.584 0.000 0.328 0.064 NA
#> GSM110447     2  0.6480     0.0108 0.000 0.456 0.016 0.124 0.372 NA
#> GSM110448     1  0.6090     0.5560 0.500 0.000 0.000 0.060 0.356 NA
#> GSM110450     1  0.5926     0.4771 0.604 0.152 0.004 0.208 0.004 NA
#> GSM110452     2  0.2288     0.3875 0.000 0.876 0.000 0.116 0.004 NA
#> GSM110453     2  0.4870     0.2560 0.000 0.584 0.000 0.060 0.352 NA

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) specimen(p) k
#> ATC:NMF 56           1.0000       0.854 2
#> ATC:NMF 47           0.0498       0.220 3
#> ATC:NMF 43           0.3304       0.665 4
#> ATC:NMF 23           0.1513       0.811 5
#> ATC:NMF 21           0.3546       0.886 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