cola Report for GDS2190

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

Document is loading...


Summary

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

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

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

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:hclust 2 1.000 0.989 0.994 **
ATC:kmeans 2 1.000 0.999 0.999 **
ATC:skmeans 2 1.000 0.994 0.997 **
ATC:pam 2 1.000 1.000 1.000 **
CV:skmeans 2 0.932 0.908 0.965 *
ATC:NMF 2 0.900 0.923 0.970
MAD:NMF 3 0.842 0.871 0.944
CV:pam 2 0.837 0.905 0.961
MAD:pam 2 0.835 0.893 0.956
ATC:mclust 3 0.803 0.877 0.897
SD:NMF 2 0.800 0.845 0.942
CV:kmeans 2 0.779 0.847 0.940
MAD:skmeans 2 0.774 0.865 0.947
SD:kmeans 2 0.750 0.840 0.940
SD:pam 2 0.745 0.893 0.954
SD:skmeans 2 0.745 0.867 0.947
MAD:kmeans 2 0.744 0.822 0.930
CV:NMF 2 0.742 0.828 0.933
SD:hclust 2 0.553 0.767 0.903
MAD:hclust 2 0.524 0.814 0.905
CV:hclust 2 0.436 0.805 0.902
MAD:mclust 2 0.407 0.828 0.893
CV:mclust 2 0.380 0.867 0.893
SD:mclust 2 0.350 0.772 0.817

**: 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.800           0.845       0.942          0.472 0.531   0.531
#> CV:NMF      2 0.742           0.828       0.933          0.480 0.515   0.515
#> MAD:NMF     2 0.771           0.853       0.941          0.486 0.508   0.508
#> ATC:NMF     2 0.900           0.923       0.970          0.485 0.515   0.515
#> SD:skmeans  2 0.745           0.867       0.947          0.502 0.495   0.495
#> CV:skmeans  2 0.932           0.908       0.965          0.503 0.503   0.503
#> MAD:skmeans 2 0.774           0.865       0.947          0.503 0.495   0.495
#> ATC:skmeans 2 1.000           0.994       0.997          0.492 0.508   0.508
#> SD:mclust   2 0.350           0.772       0.817          0.446 0.508   0.508
#> CV:mclust   2 0.380           0.867       0.893          0.391 0.577   0.577
#> MAD:mclust  2 0.407           0.828       0.893          0.420 0.541   0.541
#> ATC:mclust  2 0.393           0.895       0.869          0.383 0.552   0.552
#> SD:kmeans   2 0.750           0.840       0.940          0.450 0.564   0.564
#> CV:kmeans   2 0.779           0.847       0.940          0.459 0.552   0.552
#> MAD:kmeans  2 0.744           0.822       0.930          0.462 0.522   0.522
#> ATC:kmeans  2 1.000           0.999       0.999          0.449 0.552   0.552
#> SD:pam      2 0.745           0.893       0.954          0.479 0.515   0.515
#> CV:pam      2 0.837           0.905       0.961          0.493 0.515   0.515
#> MAD:pam     2 0.835           0.893       0.956          0.487 0.515   0.515
#> ATC:pam     2 1.000           1.000       1.000          0.437 0.564   0.564
#> SD:hclust   2 0.553           0.767       0.903          0.429 0.577   0.577
#> CV:hclust   2 0.436           0.805       0.902          0.445 0.541   0.541
#> MAD:hclust  2 0.524           0.814       0.905          0.454 0.541   0.541
#> ATC:hclust  2 1.000           0.989       0.994          0.444 0.552   0.552
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.772           0.849       0.937         0.2879 0.812   0.658
#> CV:NMF      3 0.672           0.781       0.911         0.2879 0.789   0.616
#> MAD:NMF     3 0.842           0.871       0.944         0.2824 0.776   0.590
#> ATC:NMF     3 0.663           0.790       0.884         0.3198 0.779   0.592
#> SD:skmeans  3 0.610           0.804       0.895         0.3040 0.773   0.577
#> CV:skmeans  3 0.596           0.503       0.772         0.3135 0.731   0.514
#> MAD:skmeans 3 0.626           0.642       0.722         0.3120 0.721   0.500
#> ATC:skmeans 3 0.798           0.891       0.934         0.3461 0.760   0.554
#> SD:mclust   3 0.416           0.754       0.832         0.0939 0.730   0.594
#> CV:mclust   3 0.424           0.770       0.850         0.3604 0.826   0.714
#> MAD:mclust  3 0.434           0.660       0.755         0.2529 0.915   0.849
#> ATC:mclust  3 0.803           0.877       0.897         0.4546 0.885   0.792
#> SD:kmeans   3 0.491           0.636       0.820         0.3286 0.783   0.639
#> CV:kmeans   3 0.524           0.442       0.659         0.3374 0.798   0.654
#> MAD:kmeans  3 0.459           0.534       0.680         0.3359 0.781   0.634
#> ATC:kmeans  3 0.598           0.306       0.753         0.3853 0.978   0.960
#> SD:pam      3 0.557           0.773       0.857         0.3295 0.671   0.444
#> CV:pam      3 0.544           0.778       0.852         0.3069 0.692   0.467
#> MAD:pam     3 0.581           0.787       0.882         0.3462 0.661   0.432
#> ATC:pam     3 0.748           0.858       0.934         0.5231 0.773   0.597
#> SD:hclust   3 0.479           0.640       0.718         0.2713 0.936   0.892
#> CV:hclust   3 0.428           0.753       0.829         0.1964 0.940   0.889
#> MAD:hclust  3 0.462           0.769       0.852         0.2187 0.940   0.889
#> ATC:hclust  3 0.777           0.877       0.916         0.4646 0.770   0.584
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.595           0.674       0.832         0.1746 0.790   0.511
#> CV:NMF      4 0.598           0.657       0.829         0.1606 0.798   0.525
#> MAD:NMF     4 0.596           0.595       0.825         0.1536 0.842   0.601
#> ATC:NMF     4 0.586           0.469       0.724         0.1505 0.871   0.659
#> SD:skmeans  4 0.653           0.643       0.828         0.1270 0.879   0.672
#> CV:skmeans  4 0.753           0.842       0.894         0.1294 0.802   0.489
#> MAD:skmeans 4 0.566           0.545       0.770         0.1168 0.848   0.599
#> ATC:skmeans 4 0.757           0.862       0.886         0.0890 0.938   0.816
#> SD:mclust   4 0.534           0.723       0.858         0.3291 0.770   0.585
#> CV:mclust   4 0.581           0.645       0.827         0.1521 0.897   0.795
#> MAD:mclust  4 0.731           0.695       0.867         0.2827 0.789   0.599
#> ATC:mclust  4 0.624           0.646       0.790         0.1928 0.964   0.917
#> SD:kmeans   4 0.570           0.437       0.733         0.2023 0.812   0.583
#> CV:kmeans   4 0.636           0.779       0.853         0.1865 0.725   0.426
#> MAD:kmeans  4 0.610           0.675       0.825         0.1851 0.736   0.465
#> ATC:kmeans  4 0.688           0.832       0.806         0.1592 0.671   0.408
#> SD:pam      4 0.512           0.636       0.819         0.0907 0.832   0.582
#> CV:pam      4 0.691           0.785       0.830         0.0822 0.908   0.745
#> MAD:pam     4 0.510           0.663       0.774         0.0852 0.885   0.698
#> ATC:pam     4 0.705           0.703       0.847         0.0964 0.819   0.534
#> SD:hclust   4 0.450           0.651       0.770         0.2391 0.628   0.373
#> CV:hclust   4 0.541           0.728       0.841         0.3180 0.729   0.479
#> MAD:hclust  4 0.517           0.747       0.827         0.2709 0.782   0.547
#> ATC:hclust  4 0.683           0.753       0.858         0.0768 0.950   0.846
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.702           0.696       0.860         0.0817 0.914   0.708
#> CV:NMF      5 0.703           0.719       0.865         0.0792 0.869   0.578
#> MAD:NMF     5 0.731           0.749       0.861         0.0805 0.901   0.674
#> ATC:NMF     5 0.642           0.640       0.809         0.0725 0.865   0.563
#> SD:skmeans  5 0.737           0.645       0.841         0.0720 0.880   0.603
#> CV:skmeans  5 0.725           0.699       0.848         0.0640 0.934   0.741
#> MAD:skmeans 5 0.720           0.641       0.832         0.0751 0.864   0.548
#> ATC:skmeans 5 0.840           0.785       0.897         0.0696 0.913   0.711
#> SD:mclust   5 0.523           0.641       0.787         0.1186 0.913   0.746
#> CV:mclust   5 0.703           0.724       0.836         0.2232 0.745   0.457
#> MAD:mclust  5 0.636           0.547       0.798         0.1045 0.889   0.697
#> ATC:mclust  5 0.776           0.809       0.899         0.0704 0.881   0.715
#> SD:kmeans   5 0.577           0.470       0.708         0.0824 0.840   0.537
#> CV:kmeans   5 0.650           0.654       0.771         0.0769 0.885   0.614
#> MAD:kmeans  5 0.614           0.532       0.729         0.0746 0.921   0.719
#> ATC:kmeans  5 0.721           0.769       0.819         0.0820 0.958   0.833
#> SD:pam      5 0.639           0.653       0.822         0.1181 0.814   0.463
#> CV:pam      5 0.737           0.691       0.835         0.1107 0.826   0.485
#> MAD:pam     5 0.760           0.798       0.879         0.1028 0.843   0.529
#> ATC:pam     5 0.875           0.830       0.930         0.0654 0.920   0.714
#> SD:hclust   5 0.551           0.483       0.746         0.1003 0.863   0.584
#> CV:hclust   5 0.645           0.660       0.767         0.0730 0.941   0.798
#> MAD:hclust  5 0.552           0.690       0.717         0.0709 0.985   0.942
#> ATC:hclust  5 0.834           0.748       0.834         0.0816 0.919   0.719
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.618           0.553       0.759         0.0454 0.893   0.604
#> CV:NMF      6 0.654           0.603       0.768         0.0481 0.926   0.690
#> MAD:NMF     6 0.607           0.539       0.738         0.0436 0.928   0.717
#> ATC:NMF     6 0.595           0.536       0.724         0.0356 0.940   0.735
#> SD:skmeans  6 0.760           0.651       0.818         0.0452 0.913   0.637
#> CV:skmeans  6 0.782           0.756       0.855         0.0398 0.958   0.803
#> MAD:skmeans 6 0.767           0.643       0.820         0.0431 0.921   0.645
#> ATC:skmeans 6 0.793           0.690       0.843         0.0441 0.937   0.740
#> SD:mclust   6 0.596           0.520       0.749         0.0735 0.876   0.600
#> CV:mclust   6 0.672           0.636       0.733         0.0697 0.923   0.697
#> MAD:mclust  6 0.641           0.441       0.688         0.0662 0.854   0.521
#> ATC:mclust  6 0.672           0.670       0.811         0.0976 0.862   0.581
#> SD:kmeans   6 0.638           0.577       0.713         0.0518 0.870   0.514
#> CV:kmeans   6 0.668           0.532       0.747         0.0453 0.952   0.791
#> MAD:kmeans  6 0.662           0.627       0.731         0.0489 0.892   0.554
#> ATC:kmeans  6 0.750           0.605       0.754         0.0495 0.943   0.739
#> SD:pam      6 0.696           0.559       0.806         0.0394 0.970   0.864
#> CV:pam      6 0.679           0.606       0.789         0.0414 0.973   0.873
#> MAD:pam     6 0.730           0.644       0.798         0.0354 0.967   0.844
#> ATC:pam     6 0.859           0.795       0.912         0.0591 0.911   0.635
#> SD:hclust   6 0.607           0.633       0.777         0.0699 0.879   0.584
#> CV:hclust   6 0.678           0.644       0.819         0.0504 0.938   0.757
#> MAD:hclust  6 0.644           0.674       0.759         0.0509 0.951   0.801
#> ATC:hclust  6 0.829           0.610       0.811         0.0625 0.940   0.753

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) k
#> SD:NMF      55           0.2178 2
#> CV:NMF      53           0.1454 2
#> MAD:NMF     55           0.1371 2
#> ATC:NMF     58           0.0681 2
#> SD:skmeans  56           0.1135 2
#> CV:skmeans  56           0.0559 2
#> MAD:skmeans 55           0.0858 2
#> ATC:skmeans 61           0.0285 2
#> SD:mclust   56           0.1895 2
#> CV:mclust   59           0.1336 2
#> MAD:mclust  57           0.1375 2
#> ATC:mclust  61           0.1461 2
#> SD:kmeans   53           0.1126 2
#> CV:kmeans   54           0.1016 2
#> MAD:kmeans  52           0.0913 2
#> ATC:kmeans  61           0.1461 2
#> SD:pam      58           0.1073 2
#> CV:pam      59           0.0988 2
#> MAD:pam     57           0.0838 2
#> ATC:pam     61           0.2332 2
#> SD:hclust   51           0.1368 2
#> CV:hclust   58           0.1158 2
#> MAD:hclust  58           0.1158 2
#> ATC:hclust  61           0.1461 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) k
#> SD:NMF      58          0.09535 3
#> CV:NMF      54          0.06152 3
#> MAD:NMF     58          0.03616 3
#> ATC:NMF     56          0.25437 3
#> SD:skmeans  56          0.06364 3
#> CV:skmeans  32          0.00922 3
#> MAD:skmeans 56          0.03824 3
#> ATC:skmeans 59          0.13503 3
#> SD:mclust   55          0.04420 3
#> CV:mclust   59          0.36045 3
#> MAD:mclust  45          0.00780 3
#> ATC:mclust  58          0.20122 3
#> SD:kmeans   47          0.04246 3
#> CV:kmeans   39          0.99110 3
#> MAD:kmeans  47          0.01684 3
#> ATC:kmeans  18               NA 3
#> SD:pam      56          0.02045 3
#> CV:pam      58          0.07213 3
#> MAD:pam     53          0.06363 3
#> ATC:pam     57          0.04885 3
#> SD:hclust   47          0.04064 3
#> CV:hclust   55          0.01648 3
#> MAD:hclust  59          0.01690 3
#> ATC:hclust  58          0.03078 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) k
#> SD:NMF      46          0.04025 4
#> CV:NMF      47          0.01339 4
#> MAD:NMF     43          0.01883 4
#> ATC:NMF     32          0.18618 4
#> SD:skmeans  44          0.06401 4
#> CV:skmeans  59          0.09529 4
#> MAD:skmeans 37          0.01133 4
#> ATC:skmeans 61          0.24058 4
#> SD:mclust   51          0.05518 4
#> CV:mclust   43          0.03781 4
#> MAD:mclust  48          0.05212 4
#> ATC:mclust  56          0.13233 4
#> SD:kmeans   34          0.04374 4
#> CV:kmeans   56          0.02774 4
#> MAD:kmeans  50          0.01610 4
#> ATC:kmeans  58          0.09875 4
#> SD:pam      51          0.00342 4
#> CV:pam      58          0.00891 4
#> MAD:pam     53          0.00858 4
#> ATC:pam     51          0.11101 4
#> SD:hclust   50          0.02888 4
#> CV:hclust   54          0.05688 4
#> MAD:hclust  61          0.02795 4
#> ATC:hclust  53          0.01012 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) k
#> SD:NMF      51          0.06176 5
#> CV:NMF      52          0.05402 5
#> MAD:NMF     52          0.08222 5
#> ATC:NMF     48          0.21001 5
#> SD:skmeans  44          0.02958 5
#> CV:skmeans  50          0.04082 5
#> MAD:skmeans 44          0.03643 5
#> ATC:skmeans 54          0.24359 5
#> SD:mclust   50          0.04639 5
#> CV:mclust   51          0.09016 5
#> MAD:mclust  46          0.01201 5
#> ATC:mclust  56          0.03796 5
#> SD:kmeans   29          0.00580 5
#> CV:kmeans   49          0.08456 5
#> MAD:kmeans  38          0.01573 5
#> ATC:kmeans  58          0.00857 5
#> SD:pam      51          0.00815 5
#> CV:pam      54          0.00595 5
#> MAD:pam     59          0.03362 5
#> ATC:pam     56          0.22979 5
#> SD:hclust   41          0.06656 5
#> CV:hclust   50          0.05589 5
#> MAD:hclust  55          0.09880 5
#> ATC:hclust  54          0.01872 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) k
#> SD:NMF      36           0.1556 6
#> CV:NMF      48           0.0435 6
#> MAD:NMF     39           0.3170 6
#> ATC:NMF     37           0.0936 6
#> SD:skmeans  49           0.0226 6
#> CV:skmeans  55           0.0137 6
#> MAD:skmeans 47           0.0393 6
#> ATC:skmeans 49           0.0765 6
#> SD:mclust   39           0.0185 6
#> CV:mclust   49           0.0885 6
#> MAD:mclust  27           0.0212 6
#> ATC:mclust  49           0.0729 6
#> SD:kmeans   47           0.0498 6
#> CV:kmeans   43           0.0313 6
#> MAD:kmeans  49           0.0227 6
#> ATC:kmeans  48           0.0455 6
#> SD:pam      33           0.0123 6
#> CV:pam      47           0.0163 6
#> MAD:pam     48           0.1388 6
#> ATC:pam     56           0.0617 6
#> SD:hclust   47           0.2231 6
#> CV:hclust   40           0.1218 6
#> MAD:hclust  55           0.1336 6
#> ATC:hclust  48           0.0224 6

Results for each method


SD:hclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.553           0.767       0.903         0.4289 0.577   0.577
#> 3 3 0.479           0.640       0.718         0.2713 0.936   0.892
#> 4 4 0.450           0.651       0.770         0.2391 0.628   0.373
#> 5 5 0.551           0.483       0.746         0.1003 0.863   0.584
#> 6 6 0.607           0.633       0.777         0.0699 0.879   0.584

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
#> GSM123212     1  0.9427     0.3460 0.640 0.360
#> GSM123213     2  0.7674     0.7693 0.224 0.776
#> GSM123214     2  0.6801     0.8085 0.180 0.820
#> GSM123215     2  0.6801     0.8085 0.180 0.820
#> GSM123216     1  0.0000     0.8873 1.000 0.000
#> GSM123217     1  0.0000     0.8873 1.000 0.000
#> GSM123218     1  0.3733     0.8443 0.928 0.072
#> GSM123219     1  0.1184     0.8822 0.984 0.016
#> GSM123220     1  0.0000     0.8873 1.000 0.000
#> GSM123221     1  0.0000     0.8873 1.000 0.000
#> GSM123222     1  0.0376     0.8860 0.996 0.004
#> GSM123223     2  0.0938     0.8553 0.012 0.988
#> GSM123224     1  0.0000     0.8873 1.000 0.000
#> GSM123225     1  0.0000     0.8873 1.000 0.000
#> GSM123226     1  0.0000     0.8873 1.000 0.000
#> GSM123227     1  0.3274     0.8532 0.940 0.060
#> GSM123228     1  0.0000     0.8873 1.000 0.000
#> GSM123229     1  0.0672     0.8853 0.992 0.008
#> GSM123230     1  0.0000     0.8873 1.000 0.000
#> GSM123231     1  0.3733     0.8443 0.928 0.072
#> GSM123232     1  0.0000     0.8873 1.000 0.000
#> GSM123233     1  0.9993    -0.0509 0.516 0.484
#> GSM123234     1  0.0000     0.8873 1.000 0.000
#> GSM123235     1  0.1843     0.8773 0.972 0.028
#> GSM123236     1  0.9170     0.4421 0.668 0.332
#> GSM123237     1  0.0000     0.8873 1.000 0.000
#> GSM123238     1  0.9427     0.3460 0.640 0.360
#> GSM123239     2  0.8909     0.6142 0.308 0.692
#> GSM123240     1  0.0000     0.8873 1.000 0.000
#> GSM123241     1  0.0000     0.8873 1.000 0.000
#> GSM123242     2  0.7674     0.7693 0.224 0.776
#> GSM123182     2  0.9775     0.3886 0.412 0.588
#> GSM123183     1  0.9427     0.3460 0.640 0.360
#> GSM123184     2  0.6801     0.8085 0.180 0.820
#> GSM123185     1  0.9993    -0.0509 0.516 0.484
#> GSM123186     1  0.1184     0.8822 0.984 0.016
#> GSM123187     2  0.7674     0.7693 0.224 0.776
#> GSM123188     1  0.0000     0.8873 1.000 0.000
#> GSM123189     1  0.2043     0.8743 0.968 0.032
#> GSM123190     1  0.3733     0.8443 0.928 0.072
#> GSM123191     1  0.1414     0.8806 0.980 0.020
#> GSM123192     1  0.0000     0.8873 1.000 0.000
#> GSM123193     1  0.0000     0.8873 1.000 0.000
#> GSM123194     1  0.1633     0.8783 0.976 0.024
#> GSM123195     2  0.0000     0.8528 0.000 1.000
#> GSM123196     1  0.0672     0.8853 0.992 0.008
#> GSM123197     1  0.9427     0.3460 0.640 0.360
#> GSM123198     2  0.1843     0.8557 0.028 0.972
#> GSM123199     1  0.0000     0.8873 1.000 0.000
#> GSM123200     2  0.0000     0.8528 0.000 1.000
#> GSM123201     1  0.9170     0.4421 0.668 0.332
#> GSM123202     2  0.4562     0.8350 0.096 0.904
#> GSM123203     1  0.0000     0.8873 1.000 0.000
#> GSM123204     2  0.0000     0.8528 0.000 1.000
#> GSM123205     2  0.0000     0.8528 0.000 1.000
#> GSM123206     2  0.0000     0.8528 0.000 1.000
#> GSM123207     1  0.9170     0.4421 0.668 0.332
#> GSM123208     2  0.0000     0.8528 0.000 1.000
#> GSM123209     2  0.2423     0.8553 0.040 0.960
#> GSM123210     1  0.0000     0.8873 1.000 0.000
#> GSM123211     1  0.0000     0.8873 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM123212     1  0.7328      0.312 0.612 0.344 NA
#> GSM123213     2  0.5356      0.523 0.196 0.784 NA
#> GSM123214     2  0.9264      0.383 0.156 0.432 NA
#> GSM123215     2  0.9264      0.383 0.156 0.432 NA
#> GSM123216     1  0.1267      0.779 0.972 0.004 NA
#> GSM123217     1  0.1585      0.781 0.964 0.008 NA
#> GSM123218     1  0.7058      0.727 0.708 0.080 NA
#> GSM123219     1  0.2176      0.791 0.948 0.020 NA
#> GSM123220     1  0.0983      0.792 0.980 0.004 NA
#> GSM123221     1  0.1267      0.779 0.972 0.004 NA
#> GSM123222     1  0.4931      0.773 0.784 0.004 NA
#> GSM123223     2  0.6548      0.705 0.012 0.616 NA
#> GSM123224     1  0.0983      0.792 0.980 0.004 NA
#> GSM123225     1  0.1267      0.779 0.972 0.004 NA
#> GSM123226     1  0.5109      0.771 0.780 0.008 NA
#> GSM123227     1  0.6810      0.736 0.720 0.068 NA
#> GSM123228     1  0.5109      0.771 0.780 0.008 NA
#> GSM123229     1  0.5268      0.769 0.776 0.012 NA
#> GSM123230     1  0.4931      0.771 0.784 0.004 NA
#> GSM123231     1  0.7058      0.727 0.708 0.080 NA
#> GSM123232     1  0.3752      0.784 0.856 0.000 NA
#> GSM123233     2  0.9756      0.142 0.332 0.428 NA
#> GSM123234     1  0.4931      0.771 0.784 0.004 NA
#> GSM123235     1  0.6034      0.761 0.752 0.036 NA
#> GSM123236     1  0.9601      0.258 0.456 0.328 NA
#> GSM123237     1  0.1453      0.793 0.968 0.008 NA
#> GSM123238     1  0.7328      0.312 0.612 0.344 NA
#> GSM123239     2  0.9509      0.493 0.200 0.464 NA
#> GSM123240     1  0.1267      0.779 0.972 0.004 NA
#> GSM123241     1  0.0983      0.792 0.980 0.004 NA
#> GSM123242     2  0.5356      0.523 0.196 0.784 NA
#> GSM123182     2  0.6969      0.200 0.380 0.596 NA
#> GSM123183     1  0.7328      0.312 0.612 0.344 NA
#> GSM123184     2  0.9264      0.383 0.156 0.432 NA
#> GSM123185     2  0.9756      0.142 0.332 0.428 NA
#> GSM123186     1  0.2176      0.791 0.948 0.020 NA
#> GSM123187     2  0.5356      0.523 0.196 0.784 NA
#> GSM123188     1  0.1453      0.793 0.968 0.008 NA
#> GSM123189     1  0.6142      0.758 0.748 0.040 NA
#> GSM123190     1  0.7058      0.727 0.708 0.080 NA
#> GSM123191     1  0.2903      0.789 0.924 0.028 NA
#> GSM123192     1  0.1453      0.779 0.968 0.008 NA
#> GSM123193     1  0.1585      0.781 0.964 0.008 NA
#> GSM123194     1  0.3028      0.787 0.920 0.032 NA
#> GSM123195     2  0.6045      0.706 0.000 0.620 NA
#> GSM123196     1  0.5268      0.769 0.776 0.012 NA
#> GSM123197     1  0.7328      0.312 0.612 0.344 NA
#> GSM123198     2  0.6434      0.701 0.008 0.612 NA
#> GSM123199     1  0.3752      0.784 0.856 0.000 NA
#> GSM123200     2  0.6045      0.706 0.000 0.620 NA
#> GSM123201     1  0.9601      0.258 0.456 0.328 NA
#> GSM123202     2  0.8034      0.669 0.080 0.584 NA
#> GSM123203     1  0.3816      0.784 0.852 0.000 NA
#> GSM123204     2  0.6045      0.706 0.000 0.620 NA
#> GSM123205     2  0.6045      0.706 0.000 0.620 NA
#> GSM123206     2  0.6045      0.706 0.000 0.620 NA
#> GSM123207     1  0.9601      0.258 0.456 0.328 NA
#> GSM123208     2  0.6045      0.706 0.000 0.620 NA
#> GSM123209     2  0.6721      0.698 0.016 0.604 NA
#> GSM123210     1  0.0983      0.792 0.980 0.004 NA
#> GSM123211     1  0.1267      0.779 0.972 0.004 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.6271      0.479 0.452 0.000 0.056 0.492
#> GSM123213     4  0.7508      0.445 0.012 0.204 0.228 0.556
#> GSM123214     4  0.0000      0.559 0.000 0.000 0.000 1.000
#> GSM123215     4  0.0000      0.559 0.000 0.000 0.000 1.000
#> GSM123216     1  0.0188      0.805 0.996 0.000 0.004 0.000
#> GSM123217     1  0.2814      0.792 0.868 0.000 0.132 0.000
#> GSM123218     3  0.4360      0.666 0.248 0.008 0.744 0.000
#> GSM123219     1  0.3801      0.726 0.780 0.000 0.220 0.000
#> GSM123220     1  0.2216      0.823 0.908 0.000 0.092 0.000
#> GSM123221     1  0.1474      0.764 0.948 0.000 0.052 0.000
#> GSM123222     3  0.4907      0.535 0.420 0.000 0.580 0.000
#> GSM123223     2  0.0707      0.908 0.000 0.980 0.000 0.020
#> GSM123224     1  0.1940      0.825 0.924 0.000 0.076 0.000
#> GSM123225     1  0.0000      0.807 1.000 0.000 0.000 0.000
#> GSM123226     3  0.4776      0.555 0.376 0.000 0.624 0.000
#> GSM123227     3  0.4250      0.657 0.276 0.000 0.724 0.000
#> GSM123228     3  0.4776      0.555 0.376 0.000 0.624 0.000
#> GSM123229     3  0.4661      0.620 0.348 0.000 0.652 0.000
#> GSM123230     3  0.4933      0.518 0.432 0.000 0.568 0.000
#> GSM123231     3  0.4360      0.666 0.248 0.008 0.744 0.000
#> GSM123232     1  0.3975      0.640 0.760 0.000 0.240 0.000
#> GSM123233     3  0.5221      0.261 0.000 0.208 0.732 0.060
#> GSM123234     3  0.4916      0.529 0.424 0.000 0.576 0.000
#> GSM123235     3  0.4277      0.651 0.280 0.000 0.720 0.000
#> GSM123236     3  0.5351      0.539 0.104 0.152 0.744 0.000
#> GSM123237     1  0.2704      0.814 0.876 0.000 0.124 0.000
#> GSM123238     4  0.6271      0.479 0.452 0.000 0.056 0.492
#> GSM123239     3  0.5294     -0.342 0.008 0.484 0.508 0.000
#> GSM123240     1  0.0000      0.807 1.000 0.000 0.000 0.000
#> GSM123241     1  0.2081      0.825 0.916 0.000 0.084 0.000
#> GSM123242     4  0.7508      0.445 0.012 0.204 0.228 0.556
#> GSM123182     4  0.8613      0.493 0.152 0.140 0.168 0.540
#> GSM123183     4  0.6271      0.479 0.452 0.000 0.056 0.492
#> GSM123184     4  0.0000      0.559 0.000 0.000 0.000 1.000
#> GSM123185     3  0.5221      0.261 0.000 0.208 0.732 0.060
#> GSM123186     1  0.3801      0.726 0.780 0.000 0.220 0.000
#> GSM123187     4  0.7508      0.445 0.012 0.204 0.228 0.556
#> GSM123188     1  0.2704      0.814 0.876 0.000 0.124 0.000
#> GSM123189     3  0.4331      0.649 0.288 0.000 0.712 0.000
#> GSM123190     3  0.4360      0.666 0.248 0.008 0.744 0.000
#> GSM123191     1  0.4277      0.630 0.720 0.000 0.280 0.000
#> GSM123192     1  0.0592      0.808 0.984 0.000 0.016 0.000
#> GSM123193     1  0.2814      0.792 0.868 0.000 0.132 0.000
#> GSM123194     1  0.4277      0.630 0.720 0.000 0.280 0.000
#> GSM123195     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123196     3  0.4661      0.620 0.348 0.000 0.652 0.000
#> GSM123197     4  0.6271      0.479 0.452 0.000 0.056 0.492
#> GSM123198     2  0.3726      0.763 0.000 0.788 0.212 0.000
#> GSM123199     1  0.4008      0.637 0.756 0.000 0.244 0.000
#> GSM123200     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123201     3  0.5351      0.539 0.104 0.152 0.744 0.000
#> GSM123202     2  0.3074      0.817 0.000 0.848 0.152 0.000
#> GSM123203     1  0.4072      0.616 0.748 0.000 0.252 0.000
#> GSM123204     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123207     3  0.5351      0.539 0.104 0.152 0.744 0.000
#> GSM123208     2  0.0000      0.921 0.000 1.000 0.000 0.000
#> GSM123209     2  0.3982      0.751 0.004 0.776 0.220 0.000
#> GSM123210     1  0.2011      0.825 0.920 0.000 0.080 0.000
#> GSM123211     1  0.1474      0.764 0.948 0.000 0.052 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
#> GSM123212     1  0.6244     0.0712 0.496 0.000 0.000 0.156 0.348
#> GSM123213     4  0.5465     0.5732 0.008 0.000 0.048 0.552 0.392
#> GSM123214     4  0.0000     0.6528 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000     0.6528 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.2006     0.6230 0.916 0.000 0.072 0.000 0.012
#> GSM123217     1  0.3579     0.5866 0.756 0.000 0.240 0.000 0.004
#> GSM123218     3  0.1851     0.5813 0.000 0.000 0.912 0.000 0.088
#> GSM123219     1  0.4397     0.4550 0.564 0.000 0.432 0.000 0.004
#> GSM123220     1  0.4101     0.4974 0.628 0.000 0.372 0.000 0.000
#> GSM123221     1  0.1357     0.6157 0.948 0.000 0.048 0.000 0.004
#> GSM123222     3  0.4355     0.5407 0.224 0.000 0.732 0.000 0.044
#> GSM123223     2  0.0609     0.8467 0.000 0.980 0.000 0.020 0.000
#> GSM123224     1  0.3796     0.5404 0.700 0.000 0.300 0.000 0.000
#> GSM123225     1  0.2249     0.6267 0.896 0.000 0.096 0.000 0.008
#> GSM123226     3  0.2654     0.6171 0.064 0.000 0.888 0.000 0.048
#> GSM123227     3  0.2411     0.5878 0.008 0.000 0.884 0.000 0.108
#> GSM123228     3  0.2654     0.6171 0.064 0.000 0.888 0.000 0.048
#> GSM123229     3  0.2069     0.6223 0.076 0.000 0.912 0.000 0.012
#> GSM123230     3  0.3690     0.5532 0.224 0.000 0.764 0.000 0.012
#> GSM123231     3  0.1851     0.5813 0.000 0.000 0.912 0.000 0.088
#> GSM123232     3  0.4738    -0.1686 0.464 0.000 0.520 0.000 0.016
#> GSM123233     5  0.4088     0.7165 0.000 0.000 0.368 0.000 0.632
#> GSM123234     3  0.4210     0.5465 0.224 0.000 0.740 0.000 0.036
#> GSM123235     3  0.1270     0.5992 0.000 0.000 0.948 0.000 0.052
#> GSM123236     3  0.4321    -0.2735 0.004 0.000 0.600 0.000 0.396
#> GSM123237     1  0.4268     0.5441 0.648 0.000 0.344 0.000 0.008
#> GSM123238     1  0.6244     0.0712 0.496 0.000 0.000 0.156 0.348
#> GSM123239     5  0.6598     0.3887 0.000 0.324 0.228 0.000 0.448
#> GSM123240     1  0.2074     0.6253 0.896 0.000 0.104 0.000 0.000
#> GSM123241     1  0.4126     0.4981 0.620 0.000 0.380 0.000 0.000
#> GSM123242     4  0.5465     0.5732 0.008 0.000 0.048 0.552 0.392
#> GSM123182     4  0.6691     0.4090 0.020 0.000 0.228 0.540 0.212
#> GSM123183     1  0.6244     0.0712 0.496 0.000 0.000 0.156 0.348
#> GSM123184     4  0.0000     0.6528 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.4088     0.7165 0.000 0.000 0.368 0.000 0.632
#> GSM123186     1  0.4397     0.4550 0.564 0.000 0.432 0.000 0.004
#> GSM123187     4  0.5465     0.5732 0.008 0.000 0.048 0.552 0.392
#> GSM123188     1  0.4268     0.5441 0.648 0.000 0.344 0.000 0.008
#> GSM123189     3  0.1197     0.6056 0.000 0.000 0.952 0.000 0.048
#> GSM123190     3  0.1851     0.5813 0.000 0.000 0.912 0.000 0.088
#> GSM123191     1  0.4747     0.3424 0.496 0.000 0.488 0.000 0.016
#> GSM123192     1  0.2189     0.6244 0.904 0.000 0.084 0.000 0.012
#> GSM123193     1  0.3579     0.5866 0.756 0.000 0.240 0.000 0.004
#> GSM123194     1  0.4829     0.3472 0.496 0.000 0.484 0.000 0.020
#> GSM123195     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.2069     0.6223 0.076 0.000 0.912 0.000 0.012
#> GSM123197     1  0.6244     0.0712 0.496 0.000 0.000 0.156 0.348
#> GSM123198     2  0.4798     0.2637 0.000 0.580 0.024 0.000 0.396
#> GSM123199     3  0.4735    -0.1605 0.460 0.000 0.524 0.000 0.016
#> GSM123200     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123201     3  0.4321    -0.2735 0.004 0.000 0.600 0.000 0.396
#> GSM123202     2  0.3477     0.7216 0.000 0.832 0.056 0.000 0.112
#> GSM123203     3  0.4727    -0.1299 0.452 0.000 0.532 0.000 0.016
#> GSM123204     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123207     3  0.4321    -0.2735 0.004 0.000 0.600 0.000 0.396
#> GSM123208     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.5097     0.2374 0.004 0.568 0.032 0.000 0.396
#> GSM123210     1  0.4060     0.5114 0.640 0.000 0.360 0.000 0.000
#> GSM123211     1  0.1357     0.6157 0.948 0.000 0.048 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     6  0.0713      1.000 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM123213     4  0.4579      0.615 0.000 0.000 0.020 0.564 0.404 0.012
#> GSM123214     4  0.0363      0.670 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM123215     4  0.0363      0.670 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM123216     1  0.3023      0.645 0.784 0.000 0.004 0.000 0.000 0.212
#> GSM123217     1  0.4666      0.628 0.688 0.000 0.168 0.000 0.000 0.144
#> GSM123218     3  0.1856      0.635 0.048 0.000 0.920 0.000 0.032 0.000
#> GSM123219     1  0.4200      0.464 0.592 0.000 0.392 0.004 0.000 0.012
#> GSM123220     1  0.2858      0.654 0.864 0.000 0.092 0.000 0.028 0.016
#> GSM123221     1  0.3101      0.630 0.756 0.000 0.000 0.000 0.000 0.244
#> GSM123222     3  0.7143      0.446 0.140 0.000 0.436 0.000 0.268 0.156
#> GSM123223     2  0.0547      0.856 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123224     1  0.4008      0.668 0.792 0.000 0.092 0.000 0.028 0.088
#> GSM123225     1  0.2805      0.662 0.812 0.000 0.004 0.000 0.000 0.184
#> GSM123226     3  0.6370      0.359 0.268 0.000 0.368 0.000 0.352 0.012
#> GSM123227     3  0.5288      0.248 0.068 0.000 0.496 0.000 0.424 0.012
#> GSM123228     3  0.6370      0.359 0.268 0.000 0.368 0.000 0.352 0.012
#> GSM123229     3  0.3943      0.664 0.156 0.000 0.776 0.000 0.016 0.052
#> GSM123230     3  0.5326      0.593 0.140 0.000 0.668 0.000 0.036 0.156
#> GSM123231     3  0.1856      0.635 0.048 0.000 0.920 0.000 0.032 0.000
#> GSM123232     1  0.4232      0.485 0.732 0.000 0.100 0.000 0.168 0.000
#> GSM123233     5  0.1745      0.615 0.000 0.000 0.056 0.000 0.924 0.020
#> GSM123234     3  0.6898      0.512 0.140 0.000 0.500 0.000 0.204 0.156
#> GSM123235     3  0.2833      0.646 0.148 0.000 0.836 0.000 0.012 0.004
#> GSM123236     5  0.3853      0.674 0.044 0.000 0.196 0.004 0.756 0.000
#> GSM123237     1  0.2094      0.677 0.908 0.000 0.064 0.004 0.024 0.000
#> GSM123238     6  0.0713      1.000 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM123239     5  0.6024      0.248 0.028 0.324 0.136 0.000 0.512 0.000
#> GSM123240     1  0.2562      0.669 0.828 0.000 0.000 0.000 0.000 0.172
#> GSM123241     1  0.2309      0.654 0.888 0.000 0.084 0.000 0.028 0.000
#> GSM123242     4  0.4579      0.615 0.000 0.000 0.020 0.564 0.404 0.012
#> GSM123182     4  0.6162      0.546 0.020 0.000 0.216 0.548 0.208 0.008
#> GSM123183     6  0.0713      1.000 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM123184     4  0.0363      0.670 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM123185     5  0.1829      0.595 0.000 0.000 0.056 0.000 0.920 0.024
#> GSM123186     1  0.4200      0.464 0.592 0.000 0.392 0.004 0.000 0.012
#> GSM123187     4  0.4579      0.615 0.000 0.000 0.020 0.564 0.404 0.012
#> GSM123188     1  0.2094      0.677 0.908 0.000 0.064 0.004 0.024 0.000
#> GSM123189     3  0.1082      0.624 0.040 0.000 0.956 0.000 0.004 0.000
#> GSM123190     3  0.1856      0.635 0.048 0.000 0.920 0.000 0.032 0.000
#> GSM123191     1  0.4625      0.393 0.612 0.000 0.348 0.008 0.028 0.004
#> GSM123192     1  0.3483      0.648 0.764 0.000 0.024 0.000 0.000 0.212
#> GSM123193     1  0.4666      0.628 0.688 0.000 0.168 0.000 0.000 0.144
#> GSM123194     1  0.4656      0.371 0.544 0.000 0.420 0.008 0.028 0.000
#> GSM123195     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.3943      0.664 0.156 0.000 0.776 0.000 0.016 0.052
#> GSM123197     6  0.0713      1.000 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM123198     2  0.4495      0.339 0.000 0.580 0.028 0.004 0.388 0.000
#> GSM123199     1  0.4276      0.483 0.728 0.000 0.104 0.000 0.168 0.000
#> GSM123200     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.3853      0.674 0.044 0.000 0.196 0.004 0.756 0.000
#> GSM123202     2  0.3172      0.748 0.000 0.832 0.092 0.000 0.076 0.000
#> GSM123203     1  0.4361      0.466 0.720 0.000 0.112 0.000 0.168 0.000
#> GSM123204     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123206     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.3853      0.674 0.044 0.000 0.196 0.004 0.756 0.000
#> GSM123208     2  0.0000      0.868 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.4727      0.318 0.000 0.568 0.036 0.008 0.388 0.000
#> GSM123210     1  0.2703      0.660 0.876 0.000 0.080 0.000 0.028 0.016
#> GSM123211     1  0.3101      0.630 0.756 0.000 0.000 0.000 0.000 0.244

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) k
#> SD:hclust 51           0.1368 2
#> SD:hclust 47           0.0406 3
#> SD:hclust 50           0.0289 4
#> SD:hclust 41           0.0666 5
#> SD:hclust 47           0.2231 6

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


SD:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.750           0.840       0.940         0.4500 0.564   0.564
#> 3 3 0.491           0.636       0.820         0.3286 0.783   0.639
#> 4 4 0.570           0.437       0.733         0.2023 0.812   0.583
#> 5 5 0.577           0.470       0.708         0.0824 0.840   0.537
#> 6 6 0.638           0.577       0.713         0.0518 0.870   0.514

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
#> GSM123212     1  0.9896      0.217 0.560 0.440
#> GSM123213     2  0.0376      0.925 0.004 0.996
#> GSM123214     2  0.0376      0.925 0.004 0.996
#> GSM123215     2  0.0376      0.925 0.004 0.996
#> GSM123216     1  0.0000      0.932 1.000 0.000
#> GSM123217     1  0.0000      0.932 1.000 0.000
#> GSM123218     1  0.4690      0.836 0.900 0.100
#> GSM123219     1  0.0000      0.932 1.000 0.000
#> GSM123220     1  0.0000      0.932 1.000 0.000
#> GSM123221     1  0.0000      0.932 1.000 0.000
#> GSM123222     1  0.0000      0.932 1.000 0.000
#> GSM123223     2  0.0000      0.926 0.000 1.000
#> GSM123224     1  0.0000      0.932 1.000 0.000
#> GSM123225     1  0.0000      0.932 1.000 0.000
#> GSM123226     1  0.0000      0.932 1.000 0.000
#> GSM123227     1  0.0000      0.932 1.000 0.000
#> GSM123228     1  0.0000      0.932 1.000 0.000
#> GSM123229     1  0.0000      0.932 1.000 0.000
#> GSM123230     1  0.0000      0.932 1.000 0.000
#> GSM123231     1  0.9686      0.295 0.604 0.396
#> GSM123232     1  0.0000      0.932 1.000 0.000
#> GSM123233     2  0.9427      0.438 0.360 0.640
#> GSM123234     1  0.0000      0.932 1.000 0.000
#> GSM123235     1  0.0000      0.932 1.000 0.000
#> GSM123236     1  0.0938      0.922 0.988 0.012
#> GSM123237     1  0.0000      0.932 1.000 0.000
#> GSM123238     1  0.2778      0.890 0.952 0.048
#> GSM123239     2  0.9393      0.445 0.356 0.644
#> GSM123240     1  0.0000      0.932 1.000 0.000
#> GSM123241     1  0.0000      0.932 1.000 0.000
#> GSM123242     2  0.0376      0.925 0.004 0.996
#> GSM123182     1  0.9775      0.250 0.588 0.412
#> GSM123183     1  0.9850      0.251 0.572 0.428
#> GSM123184     2  0.0376      0.925 0.004 0.996
#> GSM123185     2  0.9896      0.222 0.440 0.560
#> GSM123186     1  0.0000      0.932 1.000 0.000
#> GSM123187     2  0.0376      0.925 0.004 0.996
#> GSM123188     1  0.0000      0.932 1.000 0.000
#> GSM123189     1  0.0000      0.932 1.000 0.000
#> GSM123190     1  0.9775      0.250 0.588 0.412
#> GSM123191     1  0.0000      0.932 1.000 0.000
#> GSM123192     1  0.0000      0.932 1.000 0.000
#> GSM123193     1  0.0000      0.932 1.000 0.000
#> GSM123194     1  0.0000      0.932 1.000 0.000
#> GSM123195     2  0.0000      0.926 0.000 1.000
#> GSM123196     1  0.0000      0.932 1.000 0.000
#> GSM123197     1  0.7528      0.685 0.784 0.216
#> GSM123198     2  0.0000      0.926 0.000 1.000
#> GSM123199     1  0.0000      0.932 1.000 0.000
#> GSM123200     2  0.0000      0.926 0.000 1.000
#> GSM123201     1  0.0000      0.932 1.000 0.000
#> GSM123202     2  0.0000      0.926 0.000 1.000
#> GSM123203     1  0.0000      0.932 1.000 0.000
#> GSM123204     2  0.0000      0.926 0.000 1.000
#> GSM123205     2  0.0000      0.926 0.000 1.000
#> GSM123206     2  0.0000      0.926 0.000 1.000
#> GSM123207     1  0.0376      0.929 0.996 0.004
#> GSM123208     2  0.0000      0.926 0.000 1.000
#> GSM123209     2  0.0000      0.926 0.000 1.000
#> GSM123210     1  0.0000      0.932 1.000 0.000
#> GSM123211     1  0.0000      0.932 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.5212    0.56205 0.108 0.064 0.828
#> GSM123213     3  0.5859    0.37864 0.000 0.344 0.656
#> GSM123214     3  0.5650    0.42499 0.000 0.312 0.688
#> GSM123215     3  0.5650    0.42499 0.000 0.312 0.688
#> GSM123216     1  0.4235    0.73882 0.824 0.000 0.176
#> GSM123217     1  0.4002    0.75013 0.840 0.000 0.160
#> GSM123218     1  0.6976    0.58978 0.700 0.064 0.236
#> GSM123219     1  0.6252    0.54520 0.556 0.000 0.444
#> GSM123220     1  0.3752    0.75430 0.856 0.000 0.144
#> GSM123221     1  0.4062    0.74356 0.836 0.000 0.164
#> GSM123222     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123223     2  0.1289    0.81666 0.000 0.968 0.032
#> GSM123224     1  0.4002    0.74658 0.840 0.000 0.160
#> GSM123225     1  0.4121    0.74424 0.832 0.000 0.168
#> GSM123226     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123227     1  0.4121    0.71709 0.832 0.000 0.168
#> GSM123228     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123229     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123230     1  0.0237    0.78484 0.996 0.000 0.004
#> GSM123231     1  0.8231    0.48352 0.628 0.136 0.236
#> GSM123232     1  0.1860    0.77993 0.948 0.000 0.052
#> GSM123233     2  0.9696   -0.01826 0.388 0.396 0.216
#> GSM123234     1  0.1643    0.77634 0.956 0.000 0.044
#> GSM123235     1  0.2878    0.75657 0.904 0.000 0.096
#> GSM123236     1  0.6254    0.65551 0.756 0.056 0.188
#> GSM123237     1  0.3816    0.75263 0.852 0.000 0.148
#> GSM123238     3  0.6267    0.18049 0.452 0.000 0.548
#> GSM123239     2  0.7441    0.50874 0.164 0.700 0.136
#> GSM123240     1  0.4062    0.74356 0.836 0.000 0.164
#> GSM123241     1  0.3752    0.75430 0.856 0.000 0.144
#> GSM123242     3  0.5058    0.44078 0.000 0.244 0.756
#> GSM123182     3  0.6339    0.21699 0.360 0.008 0.632
#> GSM123183     3  0.4994    0.56194 0.112 0.052 0.836
#> GSM123184     3  0.5650    0.42499 0.000 0.312 0.688
#> GSM123185     1  0.8586    0.17101 0.520 0.104 0.376
#> GSM123186     3  0.4931    0.38735 0.232 0.000 0.768
#> GSM123187     2  0.6079    0.24654 0.000 0.612 0.388
#> GSM123188     1  0.3816    0.75297 0.852 0.000 0.148
#> GSM123189     1  0.5678    0.56900 0.684 0.000 0.316
#> GSM123190     1  0.7844    0.52314 0.652 0.108 0.240
#> GSM123191     1  0.4346    0.71079 0.816 0.000 0.184
#> GSM123192     3  0.6308    0.00114 0.492 0.000 0.508
#> GSM123193     1  0.4178    0.74192 0.828 0.000 0.172
#> GSM123194     1  0.4750    0.68533 0.784 0.000 0.216
#> GSM123195     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123196     1  0.1643    0.77634 0.956 0.000 0.044
#> GSM123197     3  0.7424    0.38330 0.364 0.044 0.592
#> GSM123198     2  0.0424    0.83574 0.000 0.992 0.008
#> GSM123199     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123200     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123201     1  0.4121    0.71709 0.832 0.000 0.168
#> GSM123202     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123203     1  0.0000    0.78535 1.000 0.000 0.000
#> GSM123204     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123205     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123206     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123207     1  0.5988    0.67417 0.776 0.056 0.168
#> GSM123208     2  0.0000    0.83983 0.000 1.000 0.000
#> GSM123209     2  0.2625    0.77225 0.000 0.916 0.084
#> GSM123210     1  0.3816    0.75276 0.852 0.000 0.148
#> GSM123211     1  0.4121    0.74190 0.832 0.000 0.168

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.5775     0.5945 0.028 0.012 0.316 0.644
#> GSM123213     3  0.6583    -0.5640 0.000 0.084 0.528 0.388
#> GSM123214     4  0.6599     0.5760 0.000 0.080 0.432 0.488
#> GSM123215     4  0.6599     0.5760 0.000 0.080 0.432 0.488
#> GSM123216     1  0.5000     0.4709 0.500 0.000 0.000 0.500
#> GSM123217     1  0.5060     0.5283 0.584 0.000 0.004 0.412
#> GSM123218     3  0.4888     0.6783 0.412 0.000 0.588 0.000
#> GSM123219     3  0.7392     0.2715 0.172 0.000 0.472 0.356
#> GSM123220     1  0.4679     0.5433 0.648 0.000 0.000 0.352
#> GSM123221     1  0.5000     0.4781 0.504 0.000 0.000 0.496
#> GSM123222     1  0.1174     0.4225 0.968 0.000 0.012 0.020
#> GSM123223     2  0.1557     0.8840 0.000 0.944 0.056 0.000
#> GSM123224     1  0.4972     0.5050 0.544 0.000 0.000 0.456
#> GSM123225     1  0.4996     0.4877 0.516 0.000 0.000 0.484
#> GSM123226     1  0.0469     0.4330 0.988 0.000 0.012 0.000
#> GSM123227     1  0.5000    -0.6692 0.500 0.000 0.500 0.000
#> GSM123228     1  0.0188     0.4368 0.996 0.000 0.000 0.004
#> GSM123229     1  0.2179     0.4089 0.924 0.000 0.064 0.012
#> GSM123230     1  0.1284     0.4242 0.964 0.000 0.024 0.012
#> GSM123231     3  0.5172     0.6820 0.404 0.008 0.588 0.000
#> GSM123232     1  0.4431     0.5414 0.696 0.000 0.000 0.304
#> GSM123233     3  0.7324     0.6518 0.356 0.064 0.536 0.044
#> GSM123234     1  0.4535    -0.1434 0.744 0.000 0.240 0.016
#> GSM123235     1  0.5050    -0.4712 0.588 0.000 0.408 0.004
#> GSM123236     3  0.4999     0.6377 0.492 0.000 0.508 0.000
#> GSM123237     1  0.4898     0.5277 0.584 0.000 0.000 0.416
#> GSM123238     4  0.7425     0.2496 0.280 0.000 0.212 0.508
#> GSM123239     3  0.7631     0.5984 0.320 0.224 0.456 0.000
#> GSM123240     1  0.4998     0.4819 0.512 0.000 0.000 0.488
#> GSM123241     1  0.4920     0.5412 0.628 0.000 0.004 0.368
#> GSM123242     4  0.6277     0.5593 0.000 0.056 0.468 0.476
#> GSM123182     3  0.6436     0.6424 0.292 0.000 0.608 0.100
#> GSM123183     4  0.4914     0.5961 0.000 0.012 0.312 0.676
#> GSM123184     4  0.6599     0.5760 0.000 0.080 0.432 0.488
#> GSM123185     3  0.6755     0.6523 0.360 0.008 0.552 0.080
#> GSM123186     4  0.6507    -0.1679 0.072 0.000 0.464 0.464
#> GSM123187     3  0.5444     0.0554 0.000 0.264 0.688 0.048
#> GSM123188     1  0.4855     0.5349 0.600 0.000 0.000 0.400
#> GSM123189     3  0.6875     0.6501 0.368 0.000 0.520 0.112
#> GSM123190     3  0.4866     0.6799 0.404 0.000 0.596 0.000
#> GSM123191     1  0.5921    -0.5303 0.516 0.000 0.448 0.036
#> GSM123192     4  0.5060    -0.4309 0.412 0.000 0.004 0.584
#> GSM123193     1  0.5506     0.4848 0.512 0.000 0.016 0.472
#> GSM123194     3  0.6079     0.6437 0.408 0.000 0.544 0.048
#> GSM123195     2  0.0000     0.9264 0.000 1.000 0.000 0.000
#> GSM123196     1  0.4313    -0.0856 0.736 0.000 0.260 0.004
#> GSM123197     4  0.8120     0.3965 0.288 0.008 0.304 0.400
#> GSM123198     2  0.2530     0.8518 0.000 0.896 0.100 0.004
#> GSM123199     1  0.0188     0.4368 0.996 0.000 0.000 0.004
#> GSM123200     2  0.0000     0.9264 0.000 1.000 0.000 0.000
#> GSM123201     1  0.5168    -0.6639 0.504 0.000 0.492 0.004
#> GSM123202     2  0.0000     0.9264 0.000 1.000 0.000 0.000
#> GSM123203     1  0.1637     0.4792 0.940 0.000 0.000 0.060
#> GSM123204     2  0.0524     0.9234 0.000 0.988 0.008 0.004
#> GSM123205     2  0.0524     0.9234 0.000 0.988 0.008 0.004
#> GSM123206     2  0.0000     0.9264 0.000 1.000 0.000 0.000
#> GSM123207     3  0.5296     0.6302 0.496 0.000 0.496 0.008
#> GSM123208     2  0.0000     0.9264 0.000 1.000 0.000 0.000
#> GSM123209     2  0.4761     0.3801 0.000 0.628 0.372 0.000
#> GSM123210     1  0.4866     0.5342 0.596 0.000 0.000 0.404
#> GSM123211     1  0.4999     0.4806 0.508 0.000 0.000 0.492

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.5056     0.6451 0.044 0.000 0.360 0.596 0.000
#> GSM123213     4  0.3951     0.6846 0.000 0.032 0.020 0.808 0.140
#> GSM123214     4  0.0609     0.7672 0.000 0.020 0.000 0.980 0.000
#> GSM123215     4  0.0609     0.7672 0.000 0.020 0.000 0.980 0.000
#> GSM123216     1  0.2694     0.6096 0.864 0.000 0.128 0.004 0.004
#> GSM123217     1  0.2124     0.5897 0.900 0.000 0.096 0.000 0.004
#> GSM123218     5  0.4453     0.2422 0.008 0.000 0.324 0.008 0.660
#> GSM123219     3  0.7615     0.3039 0.256 0.000 0.384 0.048 0.312
#> GSM123220     1  0.1808     0.6371 0.936 0.000 0.040 0.004 0.020
#> GSM123221     1  0.3318     0.5900 0.800 0.000 0.192 0.008 0.000
#> GSM123222     1  0.6352     0.3482 0.524 0.000 0.168 0.004 0.304
#> GSM123223     2  0.2352     0.8191 0.000 0.896 0.008 0.092 0.004
#> GSM123224     1  0.2393     0.6430 0.900 0.000 0.080 0.004 0.016
#> GSM123225     1  0.2339     0.6215 0.892 0.000 0.100 0.004 0.004
#> GSM123226     1  0.6461     0.3133 0.524 0.000 0.260 0.004 0.212
#> GSM123227     5  0.2233     0.4708 0.016 0.000 0.080 0.000 0.904
#> GSM123228     1  0.6109     0.3412 0.532 0.000 0.148 0.000 0.320
#> GSM123229     1  0.6270     0.1864 0.496 0.000 0.364 0.004 0.136
#> GSM123230     1  0.6581     0.2825 0.500 0.000 0.264 0.004 0.232
#> GSM123231     5  0.4505     0.2443 0.004 0.004 0.328 0.008 0.656
#> GSM123232     1  0.3754     0.5849 0.816 0.000 0.100 0.000 0.084
#> GSM123233     5  0.3806     0.4746 0.004 0.024 0.020 0.128 0.824
#> GSM123234     5  0.6525    -0.0290 0.260 0.000 0.224 0.004 0.512
#> GSM123235     3  0.6467     0.1497 0.176 0.000 0.496 0.004 0.324
#> GSM123236     5  0.0833     0.4910 0.016 0.000 0.004 0.004 0.976
#> GSM123237     1  0.0798     0.6411 0.976 0.000 0.016 0.000 0.008
#> GSM123238     1  0.6804    -0.1940 0.372 0.000 0.304 0.324 0.000
#> GSM123239     5  0.2970     0.4461 0.000 0.168 0.000 0.004 0.828
#> GSM123240     1  0.2488     0.6156 0.872 0.000 0.124 0.004 0.000
#> GSM123241     1  0.1808     0.6371 0.936 0.000 0.040 0.004 0.020
#> GSM123242     4  0.3107     0.7124 0.000 0.008 0.016 0.852 0.124
#> GSM123182     5  0.6559    -0.0509 0.012 0.000 0.332 0.156 0.500
#> GSM123183     4  0.4639     0.6627 0.024 0.000 0.344 0.632 0.000
#> GSM123184     4  0.0609     0.7672 0.000 0.020 0.000 0.980 0.000
#> GSM123185     5  0.3449     0.4724 0.004 0.008 0.016 0.140 0.832
#> GSM123186     3  0.7962     0.2971 0.252 0.000 0.416 0.100 0.232
#> GSM123187     5  0.7553     0.1564 0.000 0.184 0.072 0.284 0.460
#> GSM123188     1  0.0693     0.6409 0.980 0.000 0.012 0.000 0.008
#> GSM123189     3  0.6176     0.0959 0.040 0.000 0.504 0.052 0.404
#> GSM123190     5  0.4092     0.3070 0.004 0.004 0.252 0.008 0.732
#> GSM123191     5  0.6519    -0.3651 0.192 0.000 0.400 0.000 0.408
#> GSM123192     1  0.4686     0.3141 0.588 0.000 0.396 0.012 0.004
#> GSM123193     1  0.4182     0.3757 0.644 0.000 0.352 0.000 0.004
#> GSM123194     5  0.6510    -0.2958 0.168 0.000 0.372 0.004 0.456
#> GSM123195     2  0.0000     0.8938 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.6717     0.1734 0.288 0.000 0.464 0.004 0.244
#> GSM123197     4  0.6956     0.4145 0.240 0.000 0.308 0.440 0.012
#> GSM123198     2  0.4252     0.7246 0.000 0.768 0.052 0.004 0.176
#> GSM123199     1  0.6008     0.3736 0.560 0.000 0.148 0.000 0.292
#> GSM123200     2  0.0000     0.8938 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.2927     0.4512 0.068 0.000 0.060 0.000 0.872
#> GSM123202     2  0.0162     0.8928 0.000 0.996 0.000 0.000 0.004
#> GSM123203     1  0.5834     0.3985 0.588 0.000 0.136 0.000 0.276
#> GSM123204     2  0.0794     0.8870 0.000 0.972 0.028 0.000 0.000
#> GSM123205     2  0.1430     0.8776 0.000 0.944 0.052 0.004 0.000
#> GSM123206     2  0.0000     0.8938 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.2929     0.4673 0.068 0.000 0.044 0.008 0.880
#> GSM123208     2  0.0000     0.8938 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.5492     0.2409 0.000 0.536 0.056 0.004 0.404
#> GSM123210     1  0.1195     0.6446 0.960 0.000 0.028 0.000 0.012
#> GSM123211     1  0.3491     0.5637 0.768 0.000 0.228 0.004 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
#> GSM123212     4  0.6752     0.6474 0.136 0.000 0.220 0.544 0.016 0.084
#> GSM123213     4  0.4238     0.6092 0.000 0.000 0.048 0.736 0.200 0.016
#> GSM123214     4  0.0405     0.7300 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM123215     4  0.0260     0.7311 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM123216     1  0.0551     0.6560 0.984 0.000 0.004 0.000 0.004 0.008
#> GSM123217     1  0.4358     0.6066 0.732 0.000 0.176 0.000 0.008 0.084
#> GSM123218     6  0.5334     0.3356 0.000 0.000 0.120 0.000 0.344 0.536
#> GSM123219     6  0.4072     0.6419 0.188 0.000 0.004 0.012 0.040 0.756
#> GSM123220     1  0.3809     0.5237 0.716 0.000 0.264 0.000 0.012 0.008
#> GSM123221     1  0.2669     0.6012 0.864 0.000 0.108 0.004 0.000 0.024
#> GSM123222     3  0.6291     0.6286 0.256 0.000 0.456 0.000 0.272 0.016
#> GSM123223     2  0.2611     0.8073 0.000 0.876 0.008 0.096 0.016 0.004
#> GSM123224     1  0.2520     0.6202 0.844 0.000 0.152 0.000 0.004 0.000
#> GSM123225     1  0.0862     0.6578 0.972 0.000 0.016 0.000 0.004 0.008
#> GSM123226     3  0.6235     0.6191 0.244 0.000 0.564 0.000 0.096 0.096
#> GSM123227     5  0.3522     0.6252 0.000 0.000 0.128 0.000 0.800 0.072
#> GSM123228     3  0.6175     0.6110 0.256 0.000 0.472 0.000 0.260 0.012
#> GSM123229     3  0.6487     0.5377 0.236 0.000 0.460 0.000 0.032 0.272
#> GSM123230     3  0.6682     0.6336 0.256 0.000 0.508 0.000 0.116 0.120
#> GSM123231     6  0.5367     0.3321 0.000 0.000 0.124 0.000 0.344 0.532
#> GSM123232     1  0.4962    -0.0686 0.516 0.000 0.428 0.000 0.048 0.008
#> GSM123233     5  0.2463     0.7119 0.000 0.000 0.020 0.068 0.892 0.020
#> GSM123234     3  0.5898     0.4602 0.092 0.000 0.488 0.000 0.384 0.036
#> GSM123235     3  0.6034     0.2229 0.044 0.000 0.452 0.000 0.092 0.412
#> GSM123236     5  0.2030     0.7096 0.000 0.000 0.028 0.000 0.908 0.064
#> GSM123237     1  0.3354     0.6159 0.792 0.000 0.184 0.000 0.008 0.016
#> GSM123238     1  0.7033    -0.2419 0.444 0.000 0.216 0.272 0.012 0.056
#> GSM123239     5  0.2545     0.7064 0.000 0.068 0.020 0.000 0.888 0.024
#> GSM123240     1  0.0436     0.6567 0.988 0.000 0.004 0.000 0.004 0.004
#> GSM123241     1  0.3668     0.5346 0.728 0.000 0.256 0.000 0.008 0.008
#> GSM123242     4  0.4055     0.6297 0.000 0.000 0.044 0.756 0.184 0.016
#> GSM123182     6  0.4718     0.4962 0.008 0.000 0.008 0.048 0.268 0.668
#> GSM123183     4  0.6510     0.6551 0.128 0.000 0.220 0.568 0.016 0.068
#> GSM123184     4  0.0260     0.7311 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM123185     5  0.2944     0.6931 0.000 0.000 0.028 0.092 0.860 0.020
#> GSM123186     6  0.4444     0.5965 0.192 0.000 0.028 0.020 0.020 0.740
#> GSM123187     5  0.7602     0.3117 0.000 0.064 0.132 0.144 0.500 0.160
#> GSM123188     1  0.3354     0.6149 0.792 0.000 0.184 0.000 0.008 0.016
#> GSM123189     6  0.2911     0.6165 0.012 0.000 0.028 0.012 0.076 0.872
#> GSM123190     6  0.5290     0.1850 0.000 0.000 0.100 0.000 0.428 0.472
#> GSM123191     6  0.4461     0.6560 0.160 0.000 0.032 0.000 0.064 0.744
#> GSM123192     1  0.4990     0.3060 0.616 0.000 0.072 0.004 0.004 0.304
#> GSM123193     1  0.4378     0.3055 0.600 0.000 0.032 0.000 0.000 0.368
#> GSM123194     6  0.4536     0.6536 0.148 0.000 0.016 0.000 0.104 0.732
#> GSM123195     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.6526     0.4299 0.140 0.000 0.456 0.000 0.060 0.344
#> GSM123197     4  0.7813     0.5183 0.200 0.000 0.292 0.380 0.056 0.072
#> GSM123198     2  0.6122     0.3150 0.000 0.520 0.140 0.000 0.304 0.036
#> GSM123199     3  0.6109     0.5921 0.296 0.000 0.480 0.000 0.212 0.012
#> GSM123200     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.2538     0.6790 0.000 0.000 0.124 0.000 0.860 0.016
#> GSM123202     2  0.0405     0.8919 0.000 0.988 0.004 0.000 0.008 0.000
#> GSM123203     3  0.6111     0.5801 0.304 0.000 0.476 0.000 0.208 0.012
#> GSM123204     2  0.1773     0.8738 0.000 0.932 0.036 0.000 0.016 0.016
#> GSM123205     2  0.3629     0.7984 0.000 0.804 0.140 0.000 0.024 0.032
#> GSM123206     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1500     0.7236 0.000 0.000 0.052 0.000 0.936 0.012
#> GSM123208     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     5  0.6935     0.0964 0.000 0.356 0.116 0.000 0.404 0.124
#> GSM123210     1  0.3212     0.5953 0.800 0.000 0.180 0.000 0.004 0.016
#> GSM123211     1  0.2931     0.5933 0.860 0.000 0.088 0.004 0.004 0.044

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) k
#> SD:kmeans 53           0.1126 2
#> SD:kmeans 47           0.0425 3
#> SD:kmeans 34           0.0437 4
#> SD:kmeans 29           0.0058 5
#> SD:kmeans 47           0.0498 6

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


SD:skmeans

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

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

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

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

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.745           0.867       0.947         0.5019 0.495   0.495
#> 3 3 0.610           0.804       0.895         0.3040 0.773   0.577
#> 4 4 0.653           0.643       0.828         0.1270 0.879   0.672
#> 5 5 0.737           0.645       0.841         0.0720 0.880   0.603
#> 6 6 0.760           0.651       0.818         0.0452 0.913   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
#> GSM123212     2  0.8909      0.562 0.308 0.692
#> GSM123213     2  0.0000      0.915 0.000 1.000
#> GSM123214     2  0.0000      0.915 0.000 1.000
#> GSM123215     2  0.0000      0.915 0.000 1.000
#> GSM123216     1  0.0000      0.960 1.000 0.000
#> GSM123217     1  0.0000      0.960 1.000 0.000
#> GSM123218     2  0.9850      0.266 0.428 0.572
#> GSM123219     1  0.0376      0.957 0.996 0.004
#> GSM123220     1  0.0000      0.960 1.000 0.000
#> GSM123221     1  0.0000      0.960 1.000 0.000
#> GSM123222     1  0.0000      0.960 1.000 0.000
#> GSM123223     2  0.0000      0.915 0.000 1.000
#> GSM123224     1  0.0000      0.960 1.000 0.000
#> GSM123225     1  0.0000      0.960 1.000 0.000
#> GSM123226     1  0.0000      0.960 1.000 0.000
#> GSM123227     1  0.5842      0.814 0.860 0.140
#> GSM123228     1  0.0000      0.960 1.000 0.000
#> GSM123229     1  0.0000      0.960 1.000 0.000
#> GSM123230     1  0.0000      0.960 1.000 0.000
#> GSM123231     2  0.9710      0.342 0.400 0.600
#> GSM123232     1  0.0000      0.960 1.000 0.000
#> GSM123233     2  0.0000      0.915 0.000 1.000
#> GSM123234     1  0.0000      0.960 1.000 0.000
#> GSM123235     1  0.0000      0.960 1.000 0.000
#> GSM123236     2  0.6801      0.739 0.180 0.820
#> GSM123237     1  0.0000      0.960 1.000 0.000
#> GSM123238     1  0.7219      0.717 0.800 0.200
#> GSM123239     2  0.0000      0.915 0.000 1.000
#> GSM123240     1  0.0000      0.960 1.000 0.000
#> GSM123241     1  0.0000      0.960 1.000 0.000
#> GSM123242     2  0.0000      0.915 0.000 1.000
#> GSM123182     2  0.0000      0.915 0.000 1.000
#> GSM123183     2  0.9710      0.369 0.400 0.600
#> GSM123184     2  0.0000      0.915 0.000 1.000
#> GSM123185     2  0.0000      0.915 0.000 1.000
#> GSM123186     1  0.9881      0.162 0.564 0.436
#> GSM123187     2  0.0000      0.915 0.000 1.000
#> GSM123188     1  0.0000      0.960 1.000 0.000
#> GSM123189     1  0.4815      0.861 0.896 0.104
#> GSM123190     2  0.0000      0.915 0.000 1.000
#> GSM123191     1  0.0000      0.960 1.000 0.000
#> GSM123192     1  0.0000      0.960 1.000 0.000
#> GSM123193     1  0.0000      0.960 1.000 0.000
#> GSM123194     1  0.3733      0.895 0.928 0.072
#> GSM123195     2  0.0000      0.915 0.000 1.000
#> GSM123196     1  0.0000      0.960 1.000 0.000
#> GSM123197     2  0.9710      0.369 0.400 0.600
#> GSM123198     2  0.0000      0.915 0.000 1.000
#> GSM123199     1  0.0000      0.960 1.000 0.000
#> GSM123200     2  0.0000      0.915 0.000 1.000
#> GSM123201     1  0.6801      0.756 0.820 0.180
#> GSM123202     2  0.0000      0.915 0.000 1.000
#> GSM123203     1  0.0000      0.960 1.000 0.000
#> GSM123204     2  0.0000      0.915 0.000 1.000
#> GSM123205     2  0.0000      0.915 0.000 1.000
#> GSM123206     2  0.0000      0.915 0.000 1.000
#> GSM123207     2  0.0000      0.915 0.000 1.000
#> GSM123208     2  0.0000      0.915 0.000 1.000
#> GSM123209     2  0.0000      0.915 0.000 1.000
#> GSM123210     1  0.0000      0.960 1.000 0.000
#> GSM123211     1  0.0000      0.960 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.1170     0.8179 0.008 0.976 0.016
#> GSM123213     2  0.6154     0.1114 0.000 0.592 0.408
#> GSM123214     2  0.1289     0.8139 0.000 0.968 0.032
#> GSM123215     2  0.1289     0.8139 0.000 0.968 0.032
#> GSM123216     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123217     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123218     3  0.1453     0.8539 0.008 0.024 0.968
#> GSM123219     2  0.4033     0.7813 0.136 0.856 0.008
#> GSM123220     1  0.0000     0.8894 1.000 0.000 0.000
#> GSM123221     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123222     1  0.3482     0.8622 0.872 0.000 0.128
#> GSM123223     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123224     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123225     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123226     1  0.3551     0.8605 0.868 0.000 0.132
#> GSM123227     3  0.5111     0.6649 0.168 0.024 0.808
#> GSM123228     1  0.3551     0.8605 0.868 0.000 0.132
#> GSM123229     1  0.3551     0.8605 0.868 0.000 0.132
#> GSM123230     1  0.3551     0.8605 0.868 0.000 0.132
#> GSM123231     3  0.1453     0.8539 0.008 0.024 0.968
#> GSM123232     1  0.0892     0.8873 0.980 0.000 0.020
#> GSM123233     3  0.0000     0.8693 0.000 0.000 1.000
#> GSM123234     1  0.3619     0.8578 0.864 0.000 0.136
#> GSM123235     1  0.3619     0.8578 0.864 0.000 0.136
#> GSM123236     3  0.1453     0.8539 0.008 0.024 0.968
#> GSM123237     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123238     1  0.6274    -0.0591 0.544 0.456 0.000
#> GSM123239     3  0.0000     0.8693 0.000 0.000 1.000
#> GSM123240     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123241     1  0.0237     0.8899 0.996 0.004 0.000
#> GSM123242     2  0.1289     0.8139 0.000 0.968 0.032
#> GSM123182     2  0.3998     0.7984 0.056 0.884 0.060
#> GSM123183     2  0.1031     0.8186 0.024 0.976 0.000
#> GSM123184     2  0.1289     0.8139 0.000 0.968 0.032
#> GSM123185     3  0.0000     0.8693 0.000 0.000 1.000
#> GSM123186     2  0.3965     0.7843 0.132 0.860 0.008
#> GSM123187     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123188     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123189     2  0.8173     0.4658 0.264 0.620 0.116
#> GSM123190     3  0.1964     0.8706 0.000 0.056 0.944
#> GSM123191     1  0.3116     0.8012 0.892 0.108 0.000
#> GSM123192     2  0.4121     0.7667 0.168 0.832 0.000
#> GSM123193     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123194     1  0.7353     0.1827 0.568 0.396 0.036
#> GSM123195     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123196     1  0.3551     0.8605 0.868 0.000 0.132
#> GSM123197     2  0.5948     0.3821 0.360 0.640 0.000
#> GSM123198     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123199     1  0.3412     0.8636 0.876 0.000 0.124
#> GSM123200     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123201     3  0.4121     0.7505 0.108 0.024 0.868
#> GSM123202     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123203     1  0.3267     0.8659 0.884 0.000 0.116
#> GSM123204     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123205     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123206     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123207     3  0.0000     0.8693 0.000 0.000 1.000
#> GSM123208     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123209     3  0.3752     0.8866 0.000 0.144 0.856
#> GSM123210     1  0.0424     0.8902 0.992 0.008 0.000
#> GSM123211     1  0.0424     0.8902 0.992 0.008 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.0804      0.802 0.012 0.008 0.000 0.980
#> GSM123213     4  0.2760      0.712 0.000 0.128 0.000 0.872
#> GSM123214     4  0.0672      0.804 0.000 0.008 0.008 0.984
#> GSM123215     4  0.0672      0.804 0.000 0.008 0.008 0.984
#> GSM123216     1  0.0672      0.805 0.984 0.000 0.008 0.008
#> GSM123217     1  0.3024      0.695 0.852 0.000 0.148 0.000
#> GSM123218     3  0.4539      0.444 0.008 0.272 0.720 0.000
#> GSM123219     3  0.6835      0.189 0.136 0.000 0.576 0.288
#> GSM123220     1  0.0817      0.808 0.976 0.000 0.024 0.000
#> GSM123221     1  0.0592      0.806 0.984 0.000 0.000 0.016
#> GSM123222     1  0.3822      0.745 0.836 0.016 0.140 0.008
#> GSM123223     2  0.2647      0.768 0.000 0.880 0.000 0.120
#> GSM123224     1  0.0188      0.809 0.996 0.000 0.004 0.000
#> GSM123225     1  0.0524      0.806 0.988 0.000 0.004 0.008
#> GSM123226     1  0.5038      0.553 0.652 0.012 0.336 0.000
#> GSM123227     3  0.3472      0.573 0.024 0.100 0.868 0.008
#> GSM123228     1  0.4114      0.742 0.812 0.016 0.164 0.008
#> GSM123229     1  0.4643      0.479 0.656 0.000 0.344 0.000
#> GSM123230     1  0.5189      0.458 0.616 0.012 0.372 0.000
#> GSM123231     3  0.4477      0.378 0.000 0.312 0.688 0.000
#> GSM123232     1  0.2676      0.786 0.896 0.012 0.092 0.000
#> GSM123233     2  0.5411      0.523 0.000 0.656 0.312 0.032
#> GSM123234     1  0.5807      0.177 0.492 0.016 0.484 0.008
#> GSM123235     3  0.5099      0.102 0.380 0.008 0.612 0.000
#> GSM123236     2  0.5220      0.354 0.000 0.568 0.424 0.008
#> GSM123237     1  0.0921      0.806 0.972 0.000 0.028 0.000
#> GSM123238     4  0.4776      0.381 0.376 0.000 0.000 0.624
#> GSM123239     2  0.0336      0.838 0.000 0.992 0.000 0.008
#> GSM123240     1  0.0524      0.806 0.988 0.000 0.004 0.008
#> GSM123241     1  0.0817      0.808 0.976 0.000 0.024 0.000
#> GSM123242     4  0.0672      0.804 0.000 0.008 0.008 0.984
#> GSM123182     4  0.5030      0.507 0.004 0.004 0.352 0.640
#> GSM123183     4  0.0804      0.802 0.012 0.008 0.000 0.980
#> GSM123184     4  0.0672      0.804 0.000 0.008 0.008 0.984
#> GSM123185     2  0.7640      0.250 0.000 0.456 0.316 0.228
#> GSM123186     4  0.5558      0.487 0.028 0.000 0.364 0.608
#> GSM123187     2  0.0817      0.848 0.000 0.976 0.000 0.024
#> GSM123188     1  0.0921      0.806 0.972 0.000 0.028 0.000
#> GSM123189     3  0.4477      0.513 0.084 0.000 0.808 0.108
#> GSM123190     2  0.4981      0.172 0.000 0.536 0.464 0.000
#> GSM123191     3  0.5126      0.131 0.444 0.000 0.552 0.004
#> GSM123192     4  0.7054      0.426 0.232 0.000 0.196 0.572
#> GSM123193     1  0.4194      0.569 0.764 0.000 0.228 0.008
#> GSM123194     3  0.5524      0.484 0.276 0.000 0.676 0.048
#> GSM123195     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123196     1  0.4989      0.147 0.528 0.000 0.472 0.000
#> GSM123197     4  0.2742      0.754 0.084 0.008 0.008 0.900
#> GSM123198     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123199     1  0.3923      0.753 0.828 0.016 0.148 0.008
#> GSM123200     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123201     3  0.5793      0.415 0.056 0.248 0.688 0.008
#> GSM123202     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123203     1  0.3755      0.757 0.836 0.012 0.144 0.008
#> GSM123204     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123205     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123206     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123207     2  0.3681      0.716 0.000 0.816 0.176 0.008
#> GSM123208     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123209     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM123210     1  0.0000      0.809 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0524      0.806 0.988 0.000 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
#> GSM123212     4  0.1278     0.8846 0.020 0.000 0.004 0.960 0.016
#> GSM123213     4  0.0609     0.8914 0.000 0.020 0.000 0.980 0.000
#> GSM123214     4  0.0798     0.8975 0.000 0.008 0.016 0.976 0.000
#> GSM123215     4  0.0798     0.8975 0.000 0.008 0.016 0.976 0.000
#> GSM123216     1  0.0854     0.7545 0.976 0.000 0.008 0.012 0.004
#> GSM123217     1  0.3409     0.6502 0.824 0.000 0.144 0.000 0.032
#> GSM123218     3  0.5013     0.4661 0.000 0.084 0.684 0.000 0.232
#> GSM123219     3  0.1399     0.6476 0.028 0.000 0.952 0.020 0.000
#> GSM123220     1  0.1331     0.7510 0.952 0.000 0.008 0.000 0.040
#> GSM123221     1  0.1356     0.7463 0.956 0.000 0.004 0.028 0.012
#> GSM123222     1  0.4911     0.0907 0.504 0.000 0.008 0.012 0.476
#> GSM123223     2  0.1121     0.9070 0.000 0.956 0.000 0.044 0.000
#> GSM123224     1  0.0324     0.7559 0.992 0.000 0.000 0.004 0.004
#> GSM123225     1  0.0854     0.7545 0.976 0.000 0.008 0.012 0.004
#> GSM123226     1  0.6282     0.4161 0.536 0.000 0.248 0.000 0.216
#> GSM123227     5  0.0898     0.7151 0.000 0.008 0.020 0.000 0.972
#> GSM123228     5  0.4440    -0.1859 0.468 0.000 0.004 0.000 0.528
#> GSM123229     1  0.5486     0.3075 0.572 0.000 0.352 0.000 0.076
#> GSM123230     1  0.6280     0.3530 0.540 0.000 0.164 0.004 0.292
#> GSM123231     3  0.5866     0.3826 0.000 0.248 0.596 0.000 0.156
#> GSM123232     1  0.3231     0.6585 0.800 0.000 0.004 0.000 0.196
#> GSM123233     5  0.4468     0.6152 0.000 0.240 0.000 0.044 0.716
#> GSM123234     5  0.3632     0.6369 0.152 0.000 0.016 0.016 0.816
#> GSM123235     3  0.5775     0.3221 0.264 0.000 0.600 0.000 0.136
#> GSM123236     5  0.2470     0.7142 0.000 0.104 0.012 0.000 0.884
#> GSM123237     1  0.1364     0.7513 0.952 0.000 0.012 0.000 0.036
#> GSM123238     4  0.4688     0.3680 0.364 0.000 0.004 0.616 0.016
#> GSM123239     2  0.0404     0.9388 0.000 0.988 0.000 0.000 0.012
#> GSM123240     1  0.0854     0.7545 0.976 0.000 0.008 0.012 0.004
#> GSM123241     1  0.1364     0.7513 0.952 0.000 0.012 0.000 0.036
#> GSM123242     4  0.0798     0.8975 0.000 0.008 0.016 0.976 0.000
#> GSM123182     3  0.5377     0.1071 0.008 0.000 0.540 0.412 0.040
#> GSM123183     4  0.1278     0.8846 0.020 0.000 0.004 0.960 0.016
#> GSM123184     4  0.0798     0.8975 0.000 0.008 0.016 0.976 0.000
#> GSM123185     5  0.4615     0.5867 0.000 0.048 0.000 0.252 0.700
#> GSM123186     3  0.4757     0.1769 0.024 0.000 0.596 0.380 0.000
#> GSM123187     2  0.0404     0.9380 0.000 0.988 0.000 0.012 0.000
#> GSM123188     1  0.1251     0.7517 0.956 0.000 0.008 0.000 0.036
#> GSM123189     3  0.0324     0.6493 0.004 0.000 0.992 0.004 0.000
#> GSM123190     2  0.6486     0.0863 0.000 0.472 0.324 0.000 0.204
#> GSM123191     3  0.0955     0.6479 0.028 0.000 0.968 0.000 0.004
#> GSM123192     1  0.6733    -0.0195 0.444 0.000 0.356 0.192 0.008
#> GSM123193     1  0.4276     0.2834 0.616 0.000 0.380 0.000 0.004
#> GSM123194     3  0.1281     0.6477 0.032 0.000 0.956 0.000 0.012
#> GSM123195     2  0.0162     0.9440 0.000 0.996 0.000 0.004 0.000
#> GSM123196     3  0.5658     0.0675 0.408 0.000 0.512 0.000 0.080
#> GSM123197     4  0.2067     0.8603 0.044 0.000 0.004 0.924 0.028
#> GSM123198     2  0.0290     0.9406 0.000 0.992 0.000 0.000 0.008
#> GSM123199     1  0.4392     0.4183 0.612 0.000 0.008 0.000 0.380
#> GSM123200     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0727     0.7190 0.004 0.012 0.004 0.000 0.980
#> GSM123202     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123203     1  0.4313     0.4538 0.636 0.000 0.008 0.000 0.356
#> GSM123204     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.2516     0.7072 0.000 0.140 0.000 0.000 0.860
#> GSM123208     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.0000     0.9463 0.000 1.000 0.000 0.000 0.000
#> GSM123210     1  0.0000     0.7559 1.000 0.000 0.000 0.000 0.000
#> GSM123211     1  0.1059     0.7506 0.968 0.000 0.004 0.020 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.3166     0.8160 0.000 0.000 0.184 0.800 0.008 0.008
#> GSM123213     4  0.0291     0.8557 0.000 0.000 0.004 0.992 0.004 0.000
#> GSM123214     4  0.0146     0.8561 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM123215     4  0.0000     0.8572 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123216     1  0.2474     0.7247 0.880 0.000 0.080 0.000 0.000 0.040
#> GSM123217     1  0.2921     0.6451 0.828 0.000 0.008 0.000 0.008 0.156
#> GSM123218     3  0.6090     0.2003 0.000 0.012 0.484 0.000 0.208 0.296
#> GSM123219     6  0.0363     0.7403 0.012 0.000 0.000 0.000 0.000 0.988
#> GSM123220     1  0.1285     0.7143 0.944 0.000 0.052 0.000 0.004 0.000
#> GSM123221     1  0.3219     0.6523 0.792 0.000 0.192 0.000 0.004 0.012
#> GSM123222     5  0.6012    -0.0221 0.364 0.000 0.240 0.000 0.396 0.000
#> GSM123223     2  0.1219     0.8953 0.000 0.948 0.000 0.048 0.004 0.000
#> GSM123224     1  0.1501     0.7332 0.924 0.000 0.076 0.000 0.000 0.000
#> GSM123225     1  0.2060     0.7306 0.900 0.000 0.084 0.000 0.000 0.016
#> GSM123226     3  0.4875     0.3364 0.400 0.000 0.544 0.000 0.052 0.004
#> GSM123227     5  0.0653     0.7274 0.004 0.000 0.012 0.000 0.980 0.004
#> GSM123228     1  0.5902     0.0277 0.440 0.000 0.212 0.000 0.348 0.000
#> GSM123229     3  0.3920     0.6114 0.216 0.000 0.736 0.000 0.000 0.048
#> GSM123230     3  0.4747     0.4004 0.324 0.000 0.608 0.000 0.068 0.000
#> GSM123231     3  0.6760     0.2263 0.000 0.140 0.492 0.000 0.104 0.264
#> GSM123232     1  0.3588     0.5756 0.788 0.000 0.152 0.000 0.060 0.000
#> GSM123233     5  0.4154     0.6413 0.000 0.112 0.000 0.144 0.744 0.000
#> GSM123234     5  0.4955     0.4573 0.096 0.000 0.296 0.000 0.608 0.000
#> GSM123235     3  0.4764     0.5934 0.168 0.000 0.696 0.000 0.008 0.128
#> GSM123236     5  0.0717     0.7255 0.000 0.016 0.008 0.000 0.976 0.000
#> GSM123237     1  0.1078     0.7305 0.964 0.000 0.012 0.000 0.008 0.016
#> GSM123238     4  0.5752     0.5716 0.184 0.000 0.232 0.572 0.004 0.008
#> GSM123239     2  0.0937     0.9068 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM123240     1  0.2060     0.7306 0.900 0.000 0.084 0.000 0.000 0.016
#> GSM123241     1  0.1471     0.7068 0.932 0.000 0.064 0.000 0.004 0.000
#> GSM123242     4  0.0291     0.8557 0.000 0.000 0.004 0.992 0.004 0.000
#> GSM123182     6  0.4014     0.6012 0.000 0.000 0.000 0.240 0.044 0.716
#> GSM123183     4  0.3166     0.8160 0.000 0.000 0.184 0.800 0.008 0.008
#> GSM123184     4  0.0000     0.8572 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123185     5  0.3468     0.6060 0.000 0.008 0.000 0.264 0.728 0.000
#> GSM123186     6  0.1949     0.7235 0.004 0.000 0.004 0.088 0.000 0.904
#> GSM123187     2  0.0837     0.9204 0.000 0.972 0.004 0.020 0.004 0.000
#> GSM123188     1  0.0976     0.7310 0.968 0.000 0.008 0.000 0.008 0.016
#> GSM123189     6  0.2631     0.6143 0.000 0.000 0.180 0.000 0.000 0.820
#> GSM123190     2  0.7595    -0.2042 0.000 0.328 0.264 0.000 0.236 0.172
#> GSM123191     6  0.3608     0.5119 0.012 0.000 0.272 0.000 0.000 0.716
#> GSM123192     6  0.5424     0.4415 0.268 0.000 0.100 0.016 0.004 0.612
#> GSM123193     1  0.4593    -0.0873 0.492 0.000 0.036 0.000 0.000 0.472
#> GSM123194     6  0.0405     0.7396 0.004 0.000 0.008 0.000 0.000 0.988
#> GSM123195     2  0.0146     0.9317 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123196     3  0.4243     0.6143 0.164 0.000 0.732 0.000 0.000 0.104
#> GSM123197     4  0.3927     0.7809 0.020 0.000 0.216 0.748 0.008 0.008
#> GSM123198     2  0.0405     0.9290 0.000 0.988 0.004 0.000 0.008 0.000
#> GSM123199     1  0.5529     0.2384 0.560 0.000 0.228 0.000 0.212 0.000
#> GSM123200     2  0.0000     0.9330 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.0603     0.7275 0.004 0.000 0.016 0.000 0.980 0.000
#> GSM123202     2  0.0000     0.9330 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123203     1  0.5348     0.2871 0.592 0.000 0.216 0.000 0.192 0.000
#> GSM123204     2  0.0000     0.9330 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0146     0.9324 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9330 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1007     0.7241 0.000 0.044 0.000 0.000 0.956 0.000
#> GSM123208     2  0.0000     0.9330 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.0146     0.9324 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM123210     1  0.1349     0.7356 0.940 0.000 0.056 0.000 0.000 0.004
#> GSM123211     1  0.2830     0.6938 0.836 0.000 0.144 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-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) k
#> SD:skmeans 56           0.1135 2
#> SD:skmeans 56           0.0636 3
#> SD:skmeans 44           0.0640 4
#> SD:skmeans 44           0.0296 5
#> SD:skmeans 49           0.0226 6

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


SD:pam

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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 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-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.745           0.893       0.954         0.4794 0.515   0.515
#> 3 3 0.557           0.773       0.857         0.3295 0.671   0.444
#> 4 4 0.512           0.636       0.819         0.0907 0.832   0.582
#> 5 5 0.639           0.653       0.822         0.1181 0.814   0.463
#> 6 6 0.696           0.559       0.806         0.0394 0.970   0.864

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
#> GSM123212     2  0.8955      0.602 0.312 0.688
#> GSM123213     2  0.0000      0.927 0.000 1.000
#> GSM123214     2  0.0000      0.927 0.000 1.000
#> GSM123215     2  0.0000      0.927 0.000 1.000
#> GSM123216     1  0.0000      0.961 1.000 0.000
#> GSM123217     1  0.0000      0.961 1.000 0.000
#> GSM123218     1  0.7219      0.720 0.800 0.200
#> GSM123219     1  0.0000      0.961 1.000 0.000
#> GSM123220     1  0.0000      0.961 1.000 0.000
#> GSM123221     1  0.0000      0.961 1.000 0.000
#> GSM123222     1  0.0000      0.961 1.000 0.000
#> GSM123223     2  0.0000      0.927 0.000 1.000
#> GSM123224     1  0.0000      0.961 1.000 0.000
#> GSM123225     1  0.0000      0.961 1.000 0.000
#> GSM123226     1  0.0000      0.961 1.000 0.000
#> GSM123227     1  0.0000      0.961 1.000 0.000
#> GSM123228     1  0.0000      0.961 1.000 0.000
#> GSM123229     1  0.0000      0.961 1.000 0.000
#> GSM123230     1  0.0000      0.961 1.000 0.000
#> GSM123231     1  0.9710      0.286 0.600 0.400
#> GSM123232     1  0.0000      0.961 1.000 0.000
#> GSM123233     2  0.0000      0.927 0.000 1.000
#> GSM123234     1  0.0000      0.961 1.000 0.000
#> GSM123235     1  0.0000      0.961 1.000 0.000
#> GSM123236     2  0.9661      0.399 0.392 0.608
#> GSM123237     1  0.0000      0.961 1.000 0.000
#> GSM123238     1  0.0000      0.961 1.000 0.000
#> GSM123239     2  0.6148      0.827 0.152 0.848
#> GSM123240     1  0.0000      0.961 1.000 0.000
#> GSM123241     1  0.0000      0.961 1.000 0.000
#> GSM123242     2  0.0938      0.923 0.012 0.988
#> GSM123182     2  0.6247      0.824 0.156 0.844
#> GSM123183     2  0.7528      0.729 0.216 0.784
#> GSM123184     2  0.0000      0.927 0.000 1.000
#> GSM123185     2  0.0938      0.923 0.012 0.988
#> GSM123186     1  0.7453      0.690 0.788 0.212
#> GSM123187     2  0.0938      0.923 0.012 0.988
#> GSM123188     1  0.0000      0.961 1.000 0.000
#> GSM123189     1  0.0000      0.961 1.000 0.000
#> GSM123190     1  0.9710      0.286 0.600 0.400
#> GSM123191     1  0.0938      0.951 0.988 0.012
#> GSM123192     1  0.0000      0.961 1.000 0.000
#> GSM123193     1  0.0000      0.961 1.000 0.000
#> GSM123194     1  0.1184      0.948 0.984 0.016
#> GSM123195     2  0.0000      0.927 0.000 1.000
#> GSM123196     1  0.0000      0.961 1.000 0.000
#> GSM123197     1  0.0000      0.961 1.000 0.000
#> GSM123198     2  0.0000      0.927 0.000 1.000
#> GSM123199     1  0.0000      0.961 1.000 0.000
#> GSM123200     2  0.0000      0.927 0.000 1.000
#> GSM123201     1  0.0000      0.961 1.000 0.000
#> GSM123202     2  0.0000      0.927 0.000 1.000
#> GSM123203     1  0.0000      0.961 1.000 0.000
#> GSM123204     2  0.0000      0.927 0.000 1.000
#> GSM123205     2  0.0000      0.927 0.000 1.000
#> GSM123206     2  0.0000      0.927 0.000 1.000
#> GSM123207     2  0.6343      0.820 0.160 0.840
#> GSM123208     2  0.0000      0.927 0.000 1.000
#> GSM123209     2  0.6247      0.824 0.156 0.844
#> GSM123210     1  0.0000      0.961 1.000 0.000
#> GSM123211     1  0.0000      0.961 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.4399     0.7885 0.188 0.000 0.812
#> GSM123213     2  0.3879     0.9639 0.000 0.848 0.152
#> GSM123214     2  0.0237     0.8761 0.000 0.996 0.004
#> GSM123215     2  0.0237     0.8761 0.000 0.996 0.004
#> GSM123216     1  0.1964     0.8176 0.944 0.000 0.056
#> GSM123217     1  0.2261     0.8137 0.932 0.000 0.068
#> GSM123218     3  0.2096     0.8111 0.004 0.052 0.944
#> GSM123219     3  0.3879     0.7856 0.152 0.000 0.848
#> GSM123220     1  0.0424     0.8325 0.992 0.000 0.008
#> GSM123221     1  0.5178     0.6179 0.744 0.000 0.256
#> GSM123222     1  0.5363     0.5849 0.724 0.000 0.276
#> GSM123223     2  0.3879     0.9639 0.000 0.848 0.152
#> GSM123224     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123225     1  0.1753     0.8195 0.952 0.000 0.048
#> GSM123226     1  0.5327     0.6290 0.728 0.000 0.272
#> GSM123227     3  0.6008     0.3671 0.372 0.000 0.628
#> GSM123228     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123229     1  0.6308    -0.0676 0.508 0.000 0.492
#> GSM123230     1  0.5431     0.5712 0.716 0.000 0.284
#> GSM123231     3  0.2096     0.8111 0.004 0.052 0.944
#> GSM123232     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123233     2  0.4047     0.9615 0.004 0.848 0.148
#> GSM123234     1  0.5431     0.5712 0.716 0.000 0.284
#> GSM123235     3  0.4605     0.7783 0.204 0.000 0.796
#> GSM123236     3  0.2280     0.8102 0.008 0.052 0.940
#> GSM123237     1  0.5859     0.4214 0.656 0.000 0.344
#> GSM123238     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123239     3  0.1964     0.8081 0.000 0.056 0.944
#> GSM123240     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123241     1  0.2448     0.8165 0.924 0.000 0.076
#> GSM123242     3  0.1860     0.8085 0.000 0.052 0.948
#> GSM123182     3  0.2096     0.8111 0.004 0.052 0.944
#> GSM123183     3  0.5598     0.7621 0.052 0.148 0.800
#> GSM123184     2  0.0237     0.8761 0.000 0.996 0.004
#> GSM123185     3  0.2096     0.8111 0.004 0.052 0.944
#> GSM123186     3  0.3879     0.7856 0.152 0.000 0.848
#> GSM123187     3  0.2096     0.8111 0.004 0.052 0.944
#> GSM123188     1  0.1860     0.8175 0.948 0.000 0.052
#> GSM123189     3  0.3879     0.7856 0.152 0.000 0.848
#> GSM123190     3  0.2879     0.8056 0.024 0.052 0.924
#> GSM123191     3  0.4504     0.7848 0.196 0.000 0.804
#> GSM123192     3  0.3941     0.7835 0.156 0.000 0.844
#> GSM123193     1  0.6225     0.2246 0.568 0.000 0.432
#> GSM123194     3  0.3686     0.7926 0.140 0.000 0.860
#> GSM123195     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123196     3  0.4605     0.7783 0.204 0.000 0.796
#> GSM123197     3  0.4605     0.7783 0.204 0.000 0.796
#> GSM123198     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123199     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123200     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123201     3  0.6204     0.3453 0.424 0.000 0.576
#> GSM123202     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123203     1  0.0000     0.8337 1.000 0.000 0.000
#> GSM123204     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123205     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123206     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123207     3  0.5363     0.5617 0.276 0.000 0.724
#> GSM123208     2  0.3816     0.9650 0.000 0.852 0.148
#> GSM123209     3  0.1964     0.8081 0.000 0.056 0.944
#> GSM123210     1  0.0237     0.8331 0.996 0.000 0.004
#> GSM123211     1  0.0237     0.8331 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.6881     0.4759 0.172 0.000 0.236 0.592
#> GSM123213     4  0.7795     0.2214 0.000 0.252 0.344 0.404
#> GSM123214     4  0.1716     0.7233 0.000 0.064 0.000 0.936
#> GSM123215     4  0.1716     0.7233 0.000 0.064 0.000 0.936
#> GSM123216     1  0.3356     0.7099 0.824 0.000 0.176 0.000
#> GSM123217     1  0.4222     0.6275 0.728 0.000 0.272 0.000
#> GSM123218     3  0.3806     0.7044 0.020 0.156 0.824 0.000
#> GSM123219     3  0.1022     0.6991 0.032 0.000 0.968 0.000
#> GSM123220     1  0.1022     0.7898 0.968 0.000 0.032 0.000
#> GSM123221     1  0.4360     0.5561 0.744 0.000 0.248 0.008
#> GSM123222     1  0.4594     0.5135 0.712 0.000 0.280 0.008
#> GSM123223     2  0.4770     0.4861 0.000 0.700 0.012 0.288
#> GSM123224     1  0.0000     0.7954 1.000 0.000 0.000 0.000
#> GSM123225     1  0.2081     0.7639 0.916 0.000 0.084 0.000
#> GSM123226     1  0.4933     0.3627 0.568 0.000 0.432 0.000
#> GSM123227     3  0.5906     0.3654 0.292 0.000 0.644 0.064
#> GSM123228     1  0.0592     0.7932 0.984 0.000 0.016 0.000
#> GSM123229     3  0.4972     0.1771 0.456 0.000 0.544 0.000
#> GSM123230     1  0.4511     0.5183 0.724 0.000 0.268 0.008
#> GSM123231     3  0.3806     0.7044 0.020 0.156 0.824 0.000
#> GSM123232     1  0.0000     0.7954 1.000 0.000 0.000 0.000
#> GSM123233     3  0.6556     0.6010 0.108 0.244 0.640 0.008
#> GSM123234     1  0.4621     0.5055 0.708 0.000 0.284 0.008
#> GSM123235     3  0.3486     0.6881 0.188 0.000 0.812 0.000
#> GSM123236     3  0.5276     0.6697 0.008 0.188 0.748 0.056
#> GSM123237     3  0.5000    -0.1686 0.496 0.000 0.504 0.000
#> GSM123238     1  0.0336     0.7945 0.992 0.000 0.000 0.008
#> GSM123239     3  0.5623     0.6655 0.020 0.188 0.736 0.056
#> GSM123240     1  0.0000     0.7954 1.000 0.000 0.000 0.000
#> GSM123241     1  0.4222     0.6341 0.728 0.000 0.272 0.000
#> GSM123242     4  0.4163     0.5420 0.000 0.188 0.020 0.792
#> GSM123182     3  0.3123     0.6971 0.000 0.156 0.844 0.000
#> GSM123183     4  0.1902     0.7102 0.004 0.000 0.064 0.932
#> GSM123184     4  0.1716     0.7233 0.000 0.064 0.000 0.936
#> GSM123185     3  0.7047     0.6258 0.108 0.188 0.656 0.048
#> GSM123186     3  0.1022     0.6991 0.032 0.000 0.968 0.000
#> GSM123187     3  0.3486     0.6860 0.000 0.188 0.812 0.000
#> GSM123188     1  0.3907     0.6645 0.768 0.000 0.232 0.000
#> GSM123189     3  0.1022     0.6991 0.032 0.000 0.968 0.000
#> GSM123190     3  0.5708     0.6935 0.032 0.168 0.744 0.056
#> GSM123191     3  0.3486     0.6881 0.188 0.000 0.812 0.000
#> GSM123192     3  0.1211     0.6979 0.040 0.000 0.960 0.000
#> GSM123193     3  0.4855     0.0894 0.400 0.000 0.600 0.000
#> GSM123194     3  0.0921     0.6988 0.028 0.000 0.972 0.000
#> GSM123195     2  0.0000     0.9118 0.000 1.000 0.000 0.000
#> GSM123196     3  0.3486     0.6881 0.188 0.000 0.812 0.000
#> GSM123197     3  0.4621     0.5836 0.284 0.000 0.708 0.008
#> GSM123198     2  0.3919     0.7695 0.000 0.840 0.104 0.056
#> GSM123199     1  0.0336     0.7945 0.992 0.000 0.000 0.008
#> GSM123200     2  0.0000     0.9118 0.000 1.000 0.000 0.000
#> GSM123201     3  0.6389     0.2139 0.448 0.000 0.488 0.064
#> GSM123202     2  0.0921     0.8990 0.000 0.972 0.028 0.000
#> GSM123203     1  0.0336     0.7945 0.992 0.000 0.000 0.008
#> GSM123204     2  0.0000     0.9118 0.000 1.000 0.000 0.000
#> GSM123205     2  0.2142     0.8645 0.000 0.928 0.016 0.056
#> GSM123206     2  0.0000     0.9118 0.000 1.000 0.000 0.000
#> GSM123207     1  0.7517    -0.2487 0.460 0.048 0.428 0.064
#> GSM123208     2  0.0000     0.9118 0.000 1.000 0.000 0.000
#> GSM123209     3  0.4720     0.6748 0.000 0.188 0.768 0.044
#> GSM123210     1  0.0469     0.7947 0.988 0.000 0.012 0.000
#> GSM123211     1  0.0188     0.7955 0.996 0.000 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
#> GSM123212     4  0.6072     0.4536 0.008 0.000 0.232 0.600 0.160
#> GSM123213     3  0.6157    -0.0769 0.000 0.000 0.496 0.364 0.140
#> GSM123214     4  0.0000     0.8519 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000     0.8519 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0000     0.7535 1.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0000     0.7535 1.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0703     0.7611 0.000 0.000 0.976 0.000 0.024
#> GSM123219     3  0.2732     0.7579 0.160 0.000 0.840 0.000 0.000
#> GSM123220     1  0.2605     0.7791 0.852 0.000 0.000 0.000 0.148
#> GSM123221     5  0.4758     0.5741 0.276 0.000 0.048 0.000 0.676
#> GSM123222     5  0.3561     0.6027 0.260 0.000 0.000 0.000 0.740
#> GSM123223     2  0.6414     0.3340 0.000 0.548 0.160 0.280 0.012
#> GSM123224     1  0.2732     0.7745 0.840 0.000 0.000 0.000 0.160
#> GSM123225     1  0.1671     0.7791 0.924 0.000 0.000 0.000 0.076
#> GSM123226     1  0.5360     0.1912 0.556 0.000 0.384 0.000 0.060
#> GSM123227     5  0.2852     0.5585 0.172 0.000 0.000 0.000 0.828
#> GSM123228     1  0.2516     0.7762 0.860 0.000 0.000 0.000 0.140
#> GSM123229     3  0.5899     0.3334 0.248 0.000 0.592 0.000 0.160
#> GSM123230     5  0.4800     0.5753 0.272 0.000 0.052 0.000 0.676
#> GSM123231     3  0.0162     0.7652 0.000 0.000 0.996 0.000 0.004
#> GSM123232     1  0.2732     0.7745 0.840 0.000 0.000 0.000 0.160
#> GSM123233     5  0.2732     0.5259 0.000 0.000 0.160 0.000 0.840
#> GSM123234     5  0.1270     0.6737 0.052 0.000 0.000 0.000 0.948
#> GSM123235     3  0.2890     0.7184 0.004 0.000 0.836 0.000 0.160
#> GSM123236     3  0.3932     0.4796 0.000 0.000 0.672 0.000 0.328
#> GSM123237     1  0.3970     0.5177 0.744 0.000 0.236 0.000 0.020
#> GSM123238     5  0.3913     0.5435 0.324 0.000 0.000 0.000 0.676
#> GSM123239     5  0.4060     0.2613 0.000 0.000 0.360 0.000 0.640
#> GSM123240     1  0.2732     0.7745 0.840 0.000 0.000 0.000 0.160
#> GSM123241     1  0.1310     0.7585 0.956 0.000 0.024 0.000 0.020
#> GSM123242     4  0.3409     0.6962 0.000 0.000 0.160 0.816 0.024
#> GSM123182     3  0.0000     0.7654 0.000 0.000 1.000 0.000 0.000
#> GSM123183     4  0.0162     0.8503 0.000 0.000 0.000 0.996 0.004
#> GSM123184     4  0.0000     0.8519 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.3395     0.5217 0.000 0.000 0.236 0.000 0.764
#> GSM123186     3  0.2732     0.7579 0.160 0.000 0.840 0.000 0.000
#> GSM123187     3  0.0510     0.7622 0.000 0.000 0.984 0.000 0.016
#> GSM123188     1  0.0609     0.7630 0.980 0.000 0.000 0.000 0.020
#> GSM123189     3  0.2732     0.7579 0.160 0.000 0.840 0.000 0.000
#> GSM123190     3  0.3210     0.6294 0.000 0.000 0.788 0.000 0.212
#> GSM123191     3  0.2890     0.7184 0.004 0.000 0.836 0.000 0.160
#> GSM123192     3  0.2813     0.7558 0.168 0.000 0.832 0.000 0.000
#> GSM123193     1  0.4114     0.2050 0.624 0.000 0.376 0.000 0.000
#> GSM123194     3  0.2848     0.7583 0.156 0.000 0.840 0.000 0.004
#> GSM123195     2  0.0000     0.8270 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.2890     0.7184 0.004 0.000 0.836 0.000 0.160
#> GSM123197     5  0.4127     0.4520 0.008 0.000 0.312 0.000 0.680
#> GSM123198     2  0.6442     0.4135 0.000 0.480 0.196 0.000 0.324
#> GSM123199     5  0.3913     0.5435 0.324 0.000 0.000 0.000 0.676
#> GSM123200     2  0.0000     0.8270 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0404     0.6606 0.012 0.000 0.000 0.000 0.988
#> GSM123202     2  0.4428     0.6828 0.000 0.756 0.160 0.000 0.084
#> GSM123203     5  0.3913     0.5435 0.324 0.000 0.000 0.000 0.676
#> GSM123204     2  0.0000     0.8270 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.1341     0.8038 0.000 0.944 0.000 0.000 0.056
#> GSM123206     2  0.0000     0.8270 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.0609     0.6449 0.000 0.000 0.020 0.000 0.980
#> GSM123208     2  0.0000     0.8270 0.000 1.000 0.000 0.000 0.000
#> GSM123209     3  0.1792     0.7323 0.000 0.000 0.916 0.000 0.084
#> GSM123210     1  0.2732     0.7745 0.840 0.000 0.000 0.000 0.160
#> GSM123211     1  0.2773     0.7710 0.836 0.000 0.000 0.000 0.164

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.7548    0.22875 0.012 0.000 0.180 0.368 0.124 0.316
#> GSM123213     6  0.3078    0.13569 0.000 0.000 0.012 0.192 0.000 0.796
#> GSM123214     4  0.0000    0.66937 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123215     4  0.0000    0.66937 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123216     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.1462    0.80156 0.000 0.000 0.936 0.000 0.008 0.056
#> GSM123219     3  0.0000    0.81745 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123220     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123221     5  0.5634    0.37186 0.348 0.000 0.160 0.000 0.492 0.000
#> GSM123222     5  0.4985    0.49323 0.240 0.000 0.036 0.000 0.668 0.056
#> GSM123223     2  0.3923    0.23953 0.000 0.580 0.000 0.004 0.000 0.416
#> GSM123224     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123226     1  0.4938    0.36834 0.580 0.000 0.340 0.000 0.080 0.000
#> GSM123227     5  0.0777    0.45428 0.000 0.000 0.024 0.000 0.972 0.004
#> GSM123228     1  0.1663    0.83501 0.912 0.000 0.000 0.000 0.088 0.000
#> GSM123229     3  0.5224    0.41339 0.228 0.000 0.608 0.000 0.164 0.000
#> GSM123230     5  0.3975    0.49188 0.244 0.000 0.040 0.000 0.716 0.000
#> GSM123231     3  0.1957    0.77568 0.000 0.000 0.888 0.000 0.000 0.112
#> GSM123232     1  0.1556    0.83931 0.920 0.000 0.000 0.000 0.080 0.000
#> GSM123233     5  0.3198    0.18106 0.000 0.000 0.000 0.000 0.740 0.260
#> GSM123234     5  0.2258    0.47251 0.044 0.000 0.000 0.000 0.896 0.060
#> GSM123235     3  0.2191    0.78124 0.004 0.000 0.876 0.000 0.120 0.000
#> GSM123236     5  0.6010   -0.23373 0.000 0.000 0.312 0.000 0.428 0.260
#> GSM123237     1  0.3315    0.66571 0.780 0.000 0.200 0.000 0.020 0.000
#> GSM123238     5  0.5768    0.33703 0.196 0.000 0.000 0.000 0.488 0.316
#> GSM123239     5  0.4278   -0.08294 0.000 0.000 0.032 0.000 0.632 0.336
#> GSM123240     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.1176    0.86382 0.956 0.000 0.024 0.000 0.020 0.000
#> GSM123242     4  0.4642    0.04371 0.000 0.000 0.052 0.592 0.000 0.356
#> GSM123182     3  0.0000    0.81745 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123183     4  0.3619    0.49248 0.000 0.000 0.000 0.680 0.004 0.316
#> GSM123184     4  0.0000    0.66937 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123185     5  0.4378    0.00394 0.000 0.000 0.032 0.000 0.600 0.368
#> GSM123186     3  0.0000    0.81745 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123187     3  0.3789    0.38192 0.000 0.000 0.584 0.000 0.000 0.416
#> GSM123188     1  0.0000    0.87972 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0000    0.81745 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123190     3  0.5279    0.29765 0.000 0.000 0.548 0.000 0.336 0.116
#> GSM123191     3  0.2053    0.78503 0.004 0.000 0.888 0.000 0.108 0.000
#> GSM123192     3  0.0603    0.81475 0.016 0.000 0.980 0.000 0.004 0.000
#> GSM123193     1  0.3672    0.43806 0.632 0.000 0.368 0.000 0.000 0.000
#> GSM123194     3  0.0000    0.81745 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123195     2  0.0000    0.76383 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.2170    0.78430 0.012 0.000 0.888 0.000 0.100 0.000
#> GSM123197     5  0.5834    0.22834 0.004 0.000 0.184 0.000 0.496 0.316
#> GSM123198     6  0.3499    0.31573 0.000 0.000 0.000 0.000 0.320 0.680
#> GSM123199     5  0.3937    0.26570 0.424 0.000 0.004 0.000 0.572 0.000
#> GSM123200     2  0.0000    0.76383 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.1327    0.45427 0.000 0.000 0.000 0.000 0.936 0.064
#> GSM123202     2  0.4700    0.03929 0.000 0.500 0.000 0.000 0.044 0.456
#> GSM123203     5  0.3810    0.25961 0.428 0.000 0.000 0.000 0.572 0.000
#> GSM123204     2  0.2823    0.67075 0.000 0.796 0.000 0.000 0.000 0.204
#> GSM123205     2  0.4067    0.60392 0.000 0.700 0.000 0.000 0.040 0.260
#> GSM123206     2  0.0000    0.76383 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1556    0.44442 0.000 0.000 0.000 0.000 0.920 0.080
#> GSM123208     2  0.0000    0.76383 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     3  0.4282    0.33746 0.000 0.000 0.560 0.000 0.020 0.420
#> GSM123210     1  0.1714    0.79008 0.908 0.000 0.000 0.000 0.092 0.000
#> GSM123211     1  0.0146    0.87773 0.996 0.000 0.000 0.000 0.004 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) k
#> SD:pam 58          0.10728 2
#> SD:pam 56          0.02045 3
#> SD:pam 51          0.00342 4
#> SD:pam 51          0.00815 5
#> SD:pam 33          0.01228 6

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


SD:mclust

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

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

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

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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.350           0.772       0.817         0.4465 0.508   0.508
#> 3 3 0.416           0.754       0.832         0.0939 0.730   0.594
#> 4 4 0.534           0.723       0.858         0.3291 0.770   0.585
#> 5 5 0.523           0.641       0.787         0.1186 0.913   0.746
#> 6 6 0.596           0.520       0.749         0.0735 0.876   0.600

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
#> GSM123212     2  0.6623      0.797 0.172 0.828
#> GSM123213     2  0.4562      0.863 0.096 0.904
#> GSM123214     2  0.2603      0.876 0.044 0.956
#> GSM123215     2  0.2603      0.876 0.044 0.956
#> GSM123216     1  0.5519      0.832 0.872 0.128
#> GSM123217     1  0.4161      0.837 0.916 0.084
#> GSM123218     1  0.9170      0.638 0.668 0.332
#> GSM123219     1  0.8386      0.719 0.732 0.268
#> GSM123220     1  0.0000      0.820 1.000 0.000
#> GSM123221     1  0.4161      0.837 0.916 0.084
#> GSM123222     1  0.0000      0.820 1.000 0.000
#> GSM123223     2  0.3114      0.878 0.056 0.944
#> GSM123224     1  0.0938      0.824 0.988 0.012
#> GSM123225     1  0.4298      0.838 0.912 0.088
#> GSM123226     1  0.5294      0.834 0.880 0.120
#> GSM123227     1  0.9608      0.521 0.616 0.384
#> GSM123228     1  0.5946      0.825 0.856 0.144
#> GSM123229     1  0.0000      0.820 1.000 0.000
#> GSM123230     1  0.0000      0.820 1.000 0.000
#> GSM123231     2  0.9580      0.382 0.380 0.620
#> GSM123232     1  0.0000      0.820 1.000 0.000
#> GSM123233     2  0.5059      0.853 0.112 0.888
#> GSM123234     1  0.4562      0.833 0.904 0.096
#> GSM123235     1  0.8016      0.747 0.756 0.244
#> GSM123236     1  0.9170      0.638 0.668 0.332
#> GSM123237     1  0.0000      0.820 1.000 0.000
#> GSM123238     1  0.9922      0.173 0.552 0.448
#> GSM123239     2  0.4022      0.871 0.080 0.920
#> GSM123240     1  0.5408      0.833 0.876 0.124
#> GSM123241     1  0.2603      0.827 0.956 0.044
#> GSM123242     2  0.5178      0.851 0.116 0.884
#> GSM123182     2  0.9491      0.409 0.368 0.632
#> GSM123183     2  0.6712      0.786 0.176 0.824
#> GSM123184     2  0.2603      0.876 0.044 0.956
#> GSM123185     2  0.7674      0.730 0.224 0.776
#> GSM123186     1  0.9044      0.670 0.680 0.320
#> GSM123187     2  0.3114      0.878 0.056 0.944
#> GSM123188     1  0.0000      0.820 1.000 0.000
#> GSM123189     1  0.8386      0.719 0.732 0.268
#> GSM123190     2  0.9491      0.420 0.368 0.632
#> GSM123191     1  0.5737      0.825 0.864 0.136
#> GSM123192     1  0.7883      0.761 0.764 0.236
#> GSM123193     1  0.5737      0.833 0.864 0.136
#> GSM123194     1  0.8386      0.719 0.732 0.268
#> GSM123195     2  0.1414      0.865 0.020 0.980
#> GSM123196     1  0.3733      0.835 0.928 0.072
#> GSM123197     2  0.9393      0.474 0.356 0.644
#> GSM123198     2  0.2778      0.877 0.048 0.952
#> GSM123199     1  0.0000      0.820 1.000 0.000
#> GSM123200     2  0.1414      0.865 0.020 0.980
#> GSM123201     1  0.9087      0.651 0.676 0.324
#> GSM123202     2  0.2948      0.878 0.052 0.948
#> GSM123203     1  0.0000      0.820 1.000 0.000
#> GSM123204     2  0.1414      0.865 0.020 0.980
#> GSM123205     2  0.1414      0.865 0.020 0.980
#> GSM123206     2  0.1414      0.865 0.020 0.980
#> GSM123207     1  0.9129      0.645 0.672 0.328
#> GSM123208     2  0.1414      0.865 0.020 0.980
#> GSM123209     2  0.2948      0.878 0.052 0.948
#> GSM123210     1  0.0000      0.820 1.000 0.000
#> GSM123211     1  0.5842      0.827 0.860 0.140

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.8157      0.493 0.412 0.072 0.516
#> GSM123213     3  0.7741      0.497 0.068 0.324 0.608
#> GSM123214     3  0.5851      0.701 0.068 0.140 0.792
#> GSM123215     3  0.5974      0.700 0.068 0.148 0.784
#> GSM123216     1  0.1031      0.843 0.976 0.000 0.024
#> GSM123217     1  0.1031      0.847 0.976 0.000 0.024
#> GSM123218     1  0.4930      0.799 0.836 0.044 0.120
#> GSM123219     1  0.3918      0.815 0.856 0.004 0.140
#> GSM123220     1  0.3359      0.824 0.900 0.016 0.084
#> GSM123221     1  0.2229      0.843 0.944 0.012 0.044
#> GSM123222     1  0.2625      0.833 0.916 0.000 0.084
#> GSM123223     2  0.5656      0.686 0.068 0.804 0.128
#> GSM123224     1  0.2959      0.825 0.900 0.000 0.100
#> GSM123225     1  0.0237      0.845 0.996 0.000 0.004
#> GSM123226     1  0.2703      0.839 0.928 0.016 0.056
#> GSM123227     1  0.3918      0.819 0.868 0.012 0.120
#> GSM123228     1  0.2599      0.838 0.932 0.016 0.052
#> GSM123229     1  0.2711      0.830 0.912 0.000 0.088
#> GSM123230     1  0.2959      0.825 0.900 0.000 0.100
#> GSM123231     1  0.5137      0.792 0.832 0.064 0.104
#> GSM123232     1  0.2860      0.831 0.912 0.004 0.084
#> GSM123233     1  0.8700      0.252 0.552 0.320 0.128
#> GSM123234     1  0.1878      0.846 0.952 0.004 0.044
#> GSM123235     1  0.3686      0.820 0.860 0.000 0.140
#> GSM123236     1  0.3888      0.813 0.888 0.064 0.048
#> GSM123237     1  0.3445      0.825 0.896 0.016 0.088
#> GSM123238     1  0.6482      0.505 0.716 0.040 0.244
#> GSM123239     1  0.7366      0.286 0.564 0.400 0.036
#> GSM123240     1  0.2066      0.840 0.940 0.000 0.060
#> GSM123241     1  0.3359      0.824 0.900 0.016 0.084
#> GSM123242     3  0.8230      0.666 0.224 0.144 0.632
#> GSM123182     1  0.5158      0.725 0.764 0.004 0.232
#> GSM123183     3  0.8104      0.640 0.280 0.104 0.616
#> GSM123184     3  0.5974      0.700 0.068 0.148 0.784
#> GSM123185     1  0.7960      0.508 0.656 0.208 0.136
#> GSM123186     1  0.3918      0.815 0.856 0.004 0.140
#> GSM123187     1  0.7310      0.438 0.628 0.324 0.048
#> GSM123188     1  0.3359      0.824 0.900 0.016 0.084
#> GSM123189     1  0.3918      0.815 0.856 0.004 0.140
#> GSM123190     1  0.4902      0.784 0.844 0.092 0.064
#> GSM123191     1  0.3192      0.827 0.888 0.000 0.112
#> GSM123192     1  0.2448      0.837 0.924 0.000 0.076
#> GSM123193     1  0.3038      0.831 0.896 0.000 0.104
#> GSM123194     1  0.3686      0.815 0.860 0.000 0.140
#> GSM123195     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123196     1  0.2066      0.845 0.940 0.000 0.060
#> GSM123197     1  0.5094      0.735 0.824 0.040 0.136
#> GSM123198     2  0.3530      0.790 0.068 0.900 0.032
#> GSM123199     1  0.3359      0.824 0.900 0.016 0.084
#> GSM123200     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123201     1  0.1411      0.840 0.964 0.000 0.036
#> GSM123202     2  0.3649      0.785 0.068 0.896 0.036
#> GSM123203     1  0.2959      0.825 0.900 0.000 0.100
#> GSM123204     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123205     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123206     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123207     1  0.3921      0.808 0.884 0.080 0.036
#> GSM123208     2  0.0892      0.854 0.020 0.980 0.000
#> GSM123209     2  0.7084      0.184 0.336 0.628 0.036
#> GSM123210     1  0.2959      0.825 0.900 0.000 0.100
#> GSM123211     1  0.2339      0.843 0.940 0.012 0.048

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.5527      0.697 0.104 0.000 0.168 0.728
#> GSM123213     4  0.7375      0.563 0.020 0.172 0.216 0.592
#> GSM123214     4  0.0921      0.772 0.000 0.000 0.028 0.972
#> GSM123215     4  0.1004      0.772 0.000 0.004 0.024 0.972
#> GSM123216     1  0.2149      0.820 0.912 0.000 0.088 0.000
#> GSM123217     1  0.1211      0.846 0.960 0.000 0.040 0.000
#> GSM123218     3  0.4008      0.673 0.244 0.000 0.756 0.000
#> GSM123219     1  0.5204      0.271 0.612 0.000 0.376 0.012
#> GSM123220     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123221     1  0.2542      0.815 0.904 0.000 0.084 0.012
#> GSM123222     1  0.1209      0.849 0.964 0.000 0.032 0.004
#> GSM123223     2  0.1151      0.912 0.008 0.968 0.024 0.000
#> GSM123224     1  0.0524      0.854 0.988 0.000 0.008 0.004
#> GSM123225     1  0.1302      0.846 0.956 0.000 0.044 0.000
#> GSM123226     1  0.0469      0.853 0.988 0.000 0.012 0.000
#> GSM123227     3  0.2704      0.758 0.124 0.000 0.876 0.000
#> GSM123228     1  0.0469      0.853 0.988 0.000 0.012 0.000
#> GSM123229     1  0.0336      0.854 0.992 0.000 0.008 0.000
#> GSM123230     1  0.0188      0.851 0.996 0.000 0.004 0.000
#> GSM123231     3  0.3266      0.718 0.168 0.000 0.832 0.000
#> GSM123232     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123233     3  0.5820      0.617 0.108 0.192 0.700 0.000
#> GSM123234     1  0.4936      0.220 0.624 0.000 0.372 0.004
#> GSM123235     1  0.4992      0.047 0.524 0.000 0.476 0.000
#> GSM123236     3  0.2814      0.762 0.132 0.000 0.868 0.000
#> GSM123237     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123238     1  0.6404      0.406 0.608 0.000 0.096 0.296
#> GSM123239     3  0.4843      0.705 0.104 0.112 0.784 0.000
#> GSM123240     1  0.0804      0.853 0.980 0.000 0.012 0.008
#> GSM123241     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123242     4  0.5613      0.442 0.028 0.000 0.380 0.592
#> GSM123182     3  0.3324      0.756 0.136 0.000 0.852 0.012
#> GSM123183     4  0.4282      0.754 0.060 0.000 0.124 0.816
#> GSM123184     4  0.1004      0.772 0.000 0.004 0.024 0.972
#> GSM123185     3  0.4374      0.740 0.120 0.068 0.812 0.000
#> GSM123186     1  0.5231      0.268 0.604 0.000 0.384 0.012
#> GSM123187     3  0.7936      0.550 0.100 0.152 0.604 0.144
#> GSM123188     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123189     3  0.5366      0.359 0.440 0.000 0.548 0.012
#> GSM123190     3  0.3975      0.738 0.240 0.000 0.760 0.000
#> GSM123191     1  0.4730      0.314 0.636 0.000 0.364 0.000
#> GSM123192     1  0.2469      0.813 0.892 0.000 0.108 0.000
#> GSM123193     1  0.2149      0.817 0.912 0.000 0.088 0.000
#> GSM123194     3  0.4989      0.270 0.472 0.000 0.528 0.000
#> GSM123195     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123196     1  0.2345      0.816 0.900 0.000 0.100 0.000
#> GSM123197     1  0.5708      0.619 0.716 0.000 0.124 0.160
#> GSM123198     2  0.0927      0.915 0.008 0.976 0.016 0.000
#> GSM123199     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123200     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123201     3  0.3486      0.759 0.188 0.000 0.812 0.000
#> GSM123202     2  0.1042      0.912 0.008 0.972 0.020 0.000
#> GSM123203     1  0.0188      0.852 0.996 0.000 0.000 0.004
#> GSM123204     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123207     3  0.3791      0.748 0.200 0.000 0.796 0.004
#> GSM123208     2  0.0000      0.928 0.000 1.000 0.000 0.000
#> GSM123209     2  0.6075      0.302 0.076 0.636 0.288 0.000
#> GSM123210     1  0.0000      0.853 1.000 0.000 0.000 0.000
#> GSM123211     1  0.1510      0.841 0.956 0.000 0.028 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4   0.440     0.6288 0.044 0.000 0.056 0.800 0.100
#> GSM123213     4   0.792     0.0694 0.000 0.072 0.308 0.344 0.276
#> GSM123214     3   0.321     1.0000 0.000 0.000 0.788 0.212 0.000
#> GSM123215     3   0.321     1.0000 0.000 0.000 0.788 0.212 0.000
#> GSM123216     1   0.276     0.7900 0.848 0.000 0.000 0.004 0.148
#> GSM123217     1   0.297     0.7682 0.816 0.000 0.000 0.000 0.184
#> GSM123218     5   0.468     0.5394 0.060 0.000 0.212 0.004 0.724
#> GSM123219     1   0.566     0.4803 0.572 0.000 0.000 0.096 0.332
#> GSM123220     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123221     1   0.493     0.7027 0.696 0.000 0.000 0.220 0.084
#> GSM123222     1   0.412     0.7693 0.780 0.000 0.000 0.152 0.068
#> GSM123223     2   0.234     0.8671 0.000 0.912 0.052 0.028 0.008
#> GSM123224     1   0.324     0.7581 0.784 0.000 0.000 0.216 0.000
#> GSM123225     1   0.323     0.8053 0.852 0.000 0.000 0.088 0.060
#> GSM123226     1   0.051     0.8023 0.984 0.000 0.000 0.000 0.016
#> GSM123227     5   0.127     0.5922 0.052 0.000 0.000 0.000 0.948
#> GSM123228     1   0.148     0.7768 0.936 0.000 0.000 0.000 0.064
#> GSM123229     1   0.313     0.7922 0.856 0.000 0.000 0.048 0.096
#> GSM123230     1   0.292     0.8020 0.856 0.000 0.000 0.124 0.020
#> GSM123231     5   0.440     0.5432 0.052 0.000 0.212 0.000 0.736
#> GSM123232     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123233     5   0.413     0.5012 0.000 0.172 0.000 0.056 0.772
#> GSM123234     5   0.609     0.0631 0.416 0.000 0.000 0.124 0.460
#> GSM123235     1   0.699     0.1355 0.500 0.000 0.212 0.028 0.260
#> GSM123236     5   0.263     0.5959 0.136 0.004 0.000 0.000 0.860
#> GSM123237     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123238     4   0.361     0.5691 0.112 0.000 0.000 0.824 0.064
#> GSM123239     5   0.379     0.5334 0.020 0.180 0.008 0.000 0.792
#> GSM123240     1   0.351     0.7305 0.748 0.000 0.000 0.252 0.000
#> GSM123241     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123242     5   0.794    -0.2829 0.076 0.000 0.304 0.268 0.352
#> GSM123182     5   0.196     0.5184 0.000 0.000 0.000 0.096 0.904
#> GSM123183     4   0.463     0.5251 0.004 0.000 0.144 0.752 0.100
#> GSM123184     3   0.321     1.0000 0.000 0.000 0.788 0.212 0.000
#> GSM123185     5   0.382     0.5792 0.048 0.056 0.000 0.056 0.840
#> GSM123186     4   0.487     0.4350 0.036 0.000 0.000 0.620 0.344
#> GSM123187     5   0.622     0.2775 0.000 0.196 0.004 0.232 0.568
#> GSM123188     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123189     5   0.579     0.0700 0.384 0.000 0.000 0.096 0.520
#> GSM123190     5   0.420     0.5714 0.068 0.000 0.160 0.000 0.772
#> GSM123191     1   0.322     0.7730 0.848 0.000 0.000 0.044 0.108
#> GSM123192     1   0.629     0.0884 0.452 0.000 0.000 0.396 0.152
#> GSM123193     1   0.407     0.7491 0.768 0.000 0.000 0.044 0.188
#> GSM123194     5   0.545     0.0654 0.400 0.000 0.000 0.064 0.536
#> GSM123195     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123196     1   0.509     0.6011 0.692 0.000 0.196 0.000 0.112
#> GSM123197     4   0.425     0.6406 0.080 0.000 0.000 0.772 0.148
#> GSM123198     2   0.185     0.8747 0.000 0.912 0.000 0.000 0.088
#> GSM123199     1   0.000     0.8061 1.000 0.000 0.000 0.000 0.000
#> GSM123200     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5   0.300     0.5720 0.188 0.000 0.000 0.000 0.812
#> GSM123202     2   0.191     0.8711 0.000 0.908 0.000 0.000 0.092
#> GSM123203     1   0.273     0.7963 0.868 0.000 0.000 0.116 0.016
#> GSM123204     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5   0.413     0.5471 0.096 0.004 0.000 0.104 0.796
#> GSM123208     2   0.000     0.9215 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2   0.440     0.5520 0.004 0.708 0.024 0.000 0.264
#> GSM123210     1   0.315     0.8052 0.856 0.000 0.000 0.092 0.052
#> GSM123211     1   0.426     0.4637 0.564 0.000 0.000 0.436 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
#> GSM123212     6  0.3144     0.5193 0.004 0.000 0.016 0.172 0.000 0.808
#> GSM123213     4  0.7435     0.5008 0.004 0.028 0.172 0.484 0.096 0.216
#> GSM123214     4  0.0713     0.7121 0.000 0.000 0.000 0.972 0.028 0.000
#> GSM123215     4  0.0000     0.7179 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123216     1  0.3700     0.7212 0.800 0.000 0.024 0.000 0.036 0.140
#> GSM123217     1  0.1829     0.7927 0.928 0.000 0.036 0.000 0.028 0.008
#> GSM123218     3  0.3083     0.4525 0.040 0.000 0.828 0.000 0.132 0.000
#> GSM123219     1  0.5072     0.1457 0.480 0.000 0.028 0.000 0.464 0.028
#> GSM123220     1  0.0291     0.7944 0.992 0.000 0.004 0.000 0.000 0.004
#> GSM123221     1  0.3547     0.5531 0.668 0.000 0.000 0.000 0.000 0.332
#> GSM123222     1  0.2784     0.7689 0.848 0.000 0.028 0.000 0.000 0.124
#> GSM123223     2  0.5222     0.5315 0.000 0.676 0.060 0.196 0.068 0.000
#> GSM123224     1  0.1958     0.7808 0.896 0.000 0.004 0.000 0.000 0.100
#> GSM123225     1  0.2480     0.7721 0.872 0.000 0.024 0.000 0.000 0.104
#> GSM123226     1  0.2706     0.7481 0.852 0.000 0.024 0.000 0.000 0.124
#> GSM123227     5  0.4928    -0.2872 0.076 0.000 0.352 0.000 0.572 0.000
#> GSM123228     1  0.4393     0.6839 0.764 0.000 0.052 0.000 0.060 0.124
#> GSM123229     1  0.1588     0.7907 0.924 0.000 0.004 0.000 0.000 0.072
#> GSM123230     1  0.3679     0.7413 0.772 0.000 0.052 0.000 0.000 0.176
#> GSM123231     3  0.3278     0.4695 0.040 0.000 0.808 0.000 0.152 0.000
#> GSM123232     1  0.2146     0.7552 0.880 0.000 0.004 0.000 0.000 0.116
#> GSM123233     5  0.5879    -0.0869 0.000 0.044 0.252 0.000 0.584 0.120
#> GSM123234     1  0.7231     0.1553 0.412 0.000 0.120 0.000 0.204 0.264
#> GSM123235     3  0.5067     0.2510 0.268 0.000 0.612 0.000 0.120 0.000
#> GSM123236     3  0.4941     0.1899 0.064 0.000 0.492 0.000 0.444 0.000
#> GSM123237     1  0.0547     0.7942 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM123238     6  0.4499     0.5502 0.140 0.000 0.000 0.152 0.000 0.708
#> GSM123239     3  0.5292     0.3889 0.008 0.100 0.580 0.000 0.312 0.000
#> GSM123240     1  0.3023     0.7111 0.784 0.000 0.004 0.000 0.000 0.212
#> GSM123241     1  0.0146     0.7947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM123242     4  0.7293     0.5003 0.016 0.000 0.204 0.484 0.156 0.140
#> GSM123182     5  0.1204     0.0779 0.000 0.000 0.056 0.000 0.944 0.000
#> GSM123183     6  0.3273     0.4790 0.004 0.000 0.008 0.212 0.000 0.776
#> GSM123184     4  0.0000     0.7179 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123185     5  0.6040    -0.0781 0.016 0.028 0.252 0.000 0.584 0.120
#> GSM123186     5  0.5883    -0.2779 0.172 0.000 0.000 0.004 0.436 0.388
#> GSM123187     3  0.7106     0.2779 0.004 0.100 0.476 0.248 0.168 0.004
#> GSM123188     1  0.0146     0.7947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM123189     5  0.5254     0.0678 0.392 0.000 0.100 0.000 0.508 0.000
#> GSM123190     3  0.3858     0.4730 0.044 0.000 0.740 0.000 0.216 0.000
#> GSM123191     1  0.3890     0.6312 0.752 0.000 0.036 0.000 0.204 0.008
#> GSM123192     6  0.6247     0.2981 0.340 0.000 0.024 0.000 0.176 0.460
#> GSM123193     1  0.5251     0.5670 0.664 0.000 0.036 0.000 0.204 0.096
#> GSM123194     5  0.5583     0.0533 0.412 0.000 0.140 0.000 0.448 0.000
#> GSM123195     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     1  0.3103     0.6586 0.784 0.000 0.208 0.000 0.000 0.008
#> GSM123197     6  0.3508     0.5352 0.020 0.000 0.012 0.152 0.008 0.808
#> GSM123198     2  0.2491     0.7663 0.000 0.836 0.164 0.000 0.000 0.000
#> GSM123199     1  0.2234     0.7500 0.872 0.000 0.004 0.000 0.000 0.124
#> GSM123200     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.5435    -0.3076 0.104 0.000 0.404 0.000 0.488 0.004
#> GSM123202     2  0.3088     0.7327 0.000 0.808 0.172 0.000 0.020 0.000
#> GSM123203     1  0.1866     0.7903 0.908 0.000 0.008 0.000 0.000 0.084
#> GSM123204     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     3  0.5940     0.1624 0.076 0.000 0.452 0.000 0.424 0.048
#> GSM123208     2  0.0000     0.9011 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     3  0.5043     0.2138 0.004 0.384 0.544 0.000 0.068 0.000
#> GSM123210     1  0.1588     0.7912 0.924 0.000 0.004 0.000 0.000 0.072
#> GSM123211     6  0.3890     0.2444 0.400 0.000 0.004 0.000 0.000 0.596

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) k
#> SD:mclust 56           0.1895 2
#> SD:mclust 55           0.0442 3
#> SD:mclust 51           0.0552 4
#> SD:mclust 50           0.0464 5
#> SD:mclust 39           0.0185 6

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


SD:NMF

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

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

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

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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.800           0.845       0.942         0.4718 0.531   0.531
#> 3 3 0.772           0.849       0.937         0.2879 0.812   0.658
#> 4 4 0.595           0.674       0.832         0.1746 0.790   0.511
#> 5 5 0.702           0.696       0.860         0.0817 0.914   0.708
#> 6 6 0.618           0.553       0.759         0.0454 0.893   0.604

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
#> GSM123212     1  0.9686     0.3243 0.604 0.396
#> GSM123213     2  0.0000     0.9235 0.000 1.000
#> GSM123214     2  0.0000     0.9235 0.000 1.000
#> GSM123215     2  0.0672     0.9190 0.008 0.992
#> GSM123216     1  0.0000     0.9393 1.000 0.000
#> GSM123217     1  0.0000     0.9393 1.000 0.000
#> GSM123218     1  0.8144     0.6310 0.748 0.252
#> GSM123219     1  0.0000     0.9393 1.000 0.000
#> GSM123220     1  0.0000     0.9393 1.000 0.000
#> GSM123221     1  0.0000     0.9393 1.000 0.000
#> GSM123222     1  0.0000     0.9393 1.000 0.000
#> GSM123223     2  0.0000     0.9235 0.000 1.000
#> GSM123224     1  0.0000     0.9393 1.000 0.000
#> GSM123225     1  0.0000     0.9393 1.000 0.000
#> GSM123226     1  0.0000     0.9393 1.000 0.000
#> GSM123227     1  0.4022     0.8698 0.920 0.080
#> GSM123228     1  0.0000     0.9393 1.000 0.000
#> GSM123229     1  0.0000     0.9393 1.000 0.000
#> GSM123230     1  0.0000     0.9393 1.000 0.000
#> GSM123231     2  0.9933     0.1861 0.452 0.548
#> GSM123232     1  0.0000     0.9393 1.000 0.000
#> GSM123233     2  0.0000     0.9235 0.000 1.000
#> GSM123234     1  0.0000     0.9393 1.000 0.000
#> GSM123235     1  0.0000     0.9393 1.000 0.000
#> GSM123236     2  0.9580     0.3812 0.380 0.620
#> GSM123237     1  0.0000     0.9393 1.000 0.000
#> GSM123238     1  0.0000     0.9393 1.000 0.000
#> GSM123239     2  0.0000     0.9235 0.000 1.000
#> GSM123240     1  0.0000     0.9393 1.000 0.000
#> GSM123241     1  0.0000     0.9393 1.000 0.000
#> GSM123242     2  0.1843     0.9058 0.028 0.972
#> GSM123182     1  0.9933     0.1187 0.548 0.452
#> GSM123183     1  0.6712     0.7550 0.824 0.176
#> GSM123184     2  0.2603     0.8925 0.044 0.956
#> GSM123185     2  0.9996     0.0576 0.488 0.512
#> GSM123186     1  0.0376     0.9363 0.996 0.004
#> GSM123187     2  0.0000     0.9235 0.000 1.000
#> GSM123188     1  0.0000     0.9393 1.000 0.000
#> GSM123189     1  0.0000     0.9393 1.000 0.000
#> GSM123190     2  0.3274     0.8770 0.060 0.940
#> GSM123191     1  0.0000     0.9393 1.000 0.000
#> GSM123192     1  0.0000     0.9393 1.000 0.000
#> GSM123193     1  0.0000     0.9393 1.000 0.000
#> GSM123194     1  0.0000     0.9393 1.000 0.000
#> GSM123195     2  0.0000     0.9235 0.000 1.000
#> GSM123196     1  0.0000     0.9393 1.000 0.000
#> GSM123197     1  0.5629     0.8133 0.868 0.132
#> GSM123198     2  0.0000     0.9235 0.000 1.000
#> GSM123199     1  0.0000     0.9393 1.000 0.000
#> GSM123200     2  0.0000     0.9235 0.000 1.000
#> GSM123201     1  0.4161     0.8656 0.916 0.084
#> GSM123202     2  0.0000     0.9235 0.000 1.000
#> GSM123203     1  0.0000     0.9393 1.000 0.000
#> GSM123204     2  0.0000     0.9235 0.000 1.000
#> GSM123205     2  0.0000     0.9235 0.000 1.000
#> GSM123206     2  0.0000     0.9235 0.000 1.000
#> GSM123207     1  0.9998    -0.0239 0.508 0.492
#> GSM123208     2  0.0000     0.9235 0.000 1.000
#> GSM123209     2  0.0000     0.9235 0.000 1.000
#> GSM123210     1  0.0000     0.9393 1.000 0.000
#> GSM123211     1  0.0000     0.9393 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0475      0.850 0.004 0.992 0.004
#> GSM123213     2  0.0237      0.850 0.000 0.996 0.004
#> GSM123214     2  0.0237      0.850 0.000 0.996 0.004
#> GSM123215     2  0.0237      0.850 0.000 0.996 0.004
#> GSM123216     1  0.0747      0.940 0.984 0.016 0.000
#> GSM123217     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123218     1  0.5098      0.652 0.752 0.000 0.248
#> GSM123219     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123220     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123221     1  0.0892      0.937 0.980 0.020 0.000
#> GSM123222     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123223     3  0.3941      0.774 0.000 0.156 0.844
#> GSM123224     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123225     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123226     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123227     1  0.4121      0.772 0.832 0.000 0.168
#> GSM123228     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123229     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123230     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123231     3  0.4887      0.678 0.228 0.000 0.772
#> GSM123232     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123233     3  0.0592      0.903 0.012 0.000 0.988
#> GSM123234     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123235     1  0.0237      0.946 0.996 0.000 0.004
#> GSM123236     3  0.4452      0.724 0.192 0.000 0.808
#> GSM123237     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123238     2  0.5859      0.566 0.344 0.656 0.000
#> GSM123239     3  0.0237      0.906 0.004 0.000 0.996
#> GSM123240     1  0.0892      0.937 0.980 0.020 0.000
#> GSM123241     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123242     2  0.0237      0.850 0.000 0.996 0.004
#> GSM123182     2  0.2878      0.791 0.096 0.904 0.000
#> GSM123183     2  0.0237      0.850 0.004 0.996 0.000
#> GSM123184     2  0.0237      0.850 0.000 0.996 0.004
#> GSM123185     3  0.9149      0.169 0.416 0.144 0.440
#> GSM123186     2  0.1411      0.839 0.036 0.964 0.000
#> GSM123187     3  0.2537      0.851 0.000 0.080 0.920
#> GSM123188     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123189     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123190     3  0.0747      0.900 0.016 0.000 0.984
#> GSM123191     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123192     2  0.5859      0.566 0.344 0.656 0.000
#> GSM123193     1  0.0592      0.943 0.988 0.012 0.000
#> GSM123194     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123195     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123196     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123197     2  0.6168      0.421 0.412 0.588 0.000
#> GSM123198     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123199     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123200     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123201     1  0.4452      0.743 0.808 0.000 0.192
#> GSM123202     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123203     1  0.0000      0.948 1.000 0.000 0.000
#> GSM123204     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123205     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123206     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123207     1  0.6274      0.108 0.544 0.000 0.456
#> GSM123208     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123209     3  0.0000      0.908 0.000 0.000 1.000
#> GSM123210     1  0.0237      0.948 0.996 0.004 0.000
#> GSM123211     1  0.3816      0.779 0.852 0.148 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.1722     0.7976 0.048 0.008 0.000 0.944
#> GSM123213     4  0.1706     0.7870 0.000 0.036 0.016 0.948
#> GSM123214     4  0.0000     0.8119 0.000 0.000 0.000 1.000
#> GSM123215     4  0.0000     0.8119 0.000 0.000 0.000 1.000
#> GSM123216     1  0.0336     0.8557 0.992 0.000 0.000 0.008
#> GSM123217     1  0.3942     0.6661 0.764 0.000 0.236 0.000
#> GSM123218     3  0.6356     0.4329 0.308 0.088 0.604 0.000
#> GSM123219     3  0.5781     0.3197 0.380 0.000 0.584 0.036
#> GSM123220     1  0.1022     0.8580 0.968 0.000 0.032 0.000
#> GSM123221     1  0.2300     0.8110 0.920 0.000 0.064 0.016
#> GSM123222     1  0.3400     0.6999 0.820 0.000 0.180 0.000
#> GSM123223     2  0.3610     0.7541 0.000 0.800 0.000 0.200
#> GSM123224     1  0.0000     0.8570 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0000     0.8570 1.000 0.000 0.000 0.000
#> GSM123226     1  0.3837     0.6927 0.776 0.000 0.224 0.000
#> GSM123227     3  0.4840     0.5703 0.240 0.028 0.732 0.000
#> GSM123228     3  0.4972     0.2788 0.456 0.000 0.544 0.000
#> GSM123229     1  0.1557     0.8503 0.944 0.000 0.056 0.000
#> GSM123230     1  0.2973     0.7608 0.856 0.000 0.144 0.000
#> GSM123231     3  0.4122     0.3878 0.004 0.236 0.760 0.000
#> GSM123232     1  0.0188     0.8574 0.996 0.000 0.004 0.000
#> GSM123233     3  0.4990     0.2874 0.008 0.352 0.640 0.000
#> GSM123234     3  0.5673     0.2490 0.448 0.024 0.528 0.000
#> GSM123235     1  0.4284     0.7026 0.764 0.012 0.224 0.000
#> GSM123236     3  0.6160     0.4169 0.072 0.316 0.612 0.000
#> GSM123237     1  0.1302     0.8496 0.956 0.000 0.044 0.000
#> GSM123238     4  0.5798     0.1882 0.464 0.008 0.016 0.512
#> GSM123239     2  0.2281     0.8760 0.000 0.904 0.096 0.000
#> GSM123240     1  0.0188     0.8565 0.996 0.000 0.000 0.004
#> GSM123241     1  0.1557     0.8464 0.944 0.000 0.056 0.000
#> GSM123242     4  0.0188     0.8101 0.000 0.004 0.000 0.996
#> GSM123182     3  0.5266     0.2809 0.016 0.004 0.656 0.324
#> GSM123183     4  0.0921     0.8083 0.028 0.000 0.000 0.972
#> GSM123184     4  0.0000     0.8119 0.000 0.000 0.000 1.000
#> GSM123185     3  0.7068     0.4481 0.052 0.188 0.656 0.104
#> GSM123186     4  0.6548     0.4087 0.104 0.000 0.304 0.592
#> GSM123187     2  0.3351     0.7739 0.000 0.844 0.008 0.148
#> GSM123188     1  0.0188     0.8579 0.996 0.000 0.004 0.000
#> GSM123189     3  0.4585     0.4266 0.332 0.000 0.668 0.000
#> GSM123190     3  0.5105    -0.0229 0.004 0.432 0.564 0.000
#> GSM123191     1  0.4331     0.6036 0.712 0.000 0.288 0.000
#> GSM123192     4  0.4584     0.5187 0.300 0.000 0.004 0.696
#> GSM123193     1  0.4098     0.6970 0.784 0.000 0.204 0.012
#> GSM123194     3  0.4535     0.5010 0.292 0.004 0.704 0.000
#> GSM123195     2  0.2081     0.8776 0.000 0.916 0.084 0.000
#> GSM123196     1  0.3123     0.7897 0.844 0.000 0.156 0.000
#> GSM123197     1  0.6771     0.1887 0.576 0.028 0.052 0.344
#> GSM123198     2  0.0469     0.8891 0.000 0.988 0.012 0.000
#> GSM123199     1  0.1389     0.8459 0.952 0.000 0.048 0.000
#> GSM123200     2  0.0921     0.8912 0.000 0.972 0.028 0.000
#> GSM123201     3  0.6635     0.5557 0.228 0.152 0.620 0.000
#> GSM123202     2  0.0188     0.8904 0.000 0.996 0.004 0.000
#> GSM123203     1  0.1211     0.8475 0.960 0.000 0.040 0.000
#> GSM123204     2  0.0817     0.8911 0.000 0.976 0.024 0.000
#> GSM123205     2  0.0188     0.8884 0.000 0.996 0.004 0.000
#> GSM123206     2  0.2266     0.8777 0.000 0.912 0.084 0.004
#> GSM123207     2  0.6466     0.3001 0.092 0.588 0.320 0.000
#> GSM123208     2  0.2408     0.8663 0.000 0.896 0.104 0.000
#> GSM123209     2  0.0336     0.8885 0.000 0.992 0.008 0.000
#> GSM123210     1  0.0000     0.8570 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0921     0.8476 0.972 0.000 0.000 0.028

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.0404     0.8544 0.012 0.000 0.000 0.988 0.000
#> GSM123213     4  0.1041     0.8417 0.000 0.004 0.000 0.964 0.032
#> GSM123214     4  0.0000     0.8568 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000     0.8568 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0290     0.8082 0.992 0.000 0.008 0.000 0.000
#> GSM123217     1  0.4109     0.5108 0.700 0.000 0.288 0.000 0.012
#> GSM123218     3  0.1518     0.7194 0.004 0.004 0.944 0.000 0.048
#> GSM123219     3  0.3749     0.7368 0.108 0.000 0.828 0.052 0.012
#> GSM123220     1  0.1205     0.7998 0.956 0.000 0.040 0.000 0.004
#> GSM123221     1  0.1410     0.7785 0.940 0.000 0.000 0.000 0.060
#> GSM123222     1  0.4297     0.0760 0.528 0.000 0.000 0.000 0.472
#> GSM123223     2  0.2471     0.8435 0.000 0.864 0.000 0.136 0.000
#> GSM123224     1  0.0000     0.8080 1.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.0290     0.8082 0.992 0.000 0.008 0.000 0.000
#> GSM123226     1  0.4367     0.3398 0.620 0.000 0.372 0.000 0.008
#> GSM123227     5  0.3863     0.6798 0.012 0.000 0.248 0.000 0.740
#> GSM123228     5  0.4237     0.7052 0.152 0.000 0.076 0.000 0.772
#> GSM123229     1  0.2338     0.7470 0.884 0.000 0.112 0.000 0.004
#> GSM123230     1  0.4341     0.3711 0.628 0.000 0.008 0.000 0.364
#> GSM123231     3  0.2238     0.7148 0.004 0.064 0.912 0.000 0.020
#> GSM123232     1  0.0290     0.8079 0.992 0.000 0.000 0.000 0.008
#> GSM123233     5  0.0693     0.8297 0.000 0.012 0.008 0.000 0.980
#> GSM123234     5  0.2536     0.7734 0.128 0.000 0.004 0.000 0.868
#> GSM123235     1  0.6162    -0.1013 0.436 0.132 0.432 0.000 0.000
#> GSM123236     5  0.2763     0.7947 0.000 0.004 0.148 0.000 0.848
#> GSM123237     1  0.0880     0.8029 0.968 0.000 0.032 0.000 0.000
#> GSM123238     1  0.3659     0.6226 0.768 0.000 0.000 0.220 0.012
#> GSM123239     2  0.2209     0.8950 0.000 0.912 0.056 0.000 0.032
#> GSM123240     1  0.0162     0.8082 0.996 0.000 0.004 0.000 0.000
#> GSM123241     1  0.1270     0.7916 0.948 0.000 0.052 0.000 0.000
#> GSM123242     4  0.0404     0.8545 0.000 0.000 0.000 0.988 0.012
#> GSM123182     4  0.6360    -0.0738 0.000 0.000 0.388 0.448 0.164
#> GSM123183     4  0.0404     0.8545 0.012 0.000 0.000 0.988 0.000
#> GSM123184     4  0.0000     0.8568 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.0902     0.8320 0.004 0.004 0.008 0.008 0.976
#> GSM123186     3  0.5869     0.0209 0.052 0.020 0.468 0.460 0.000
#> GSM123187     2  0.5140     0.7521 0.000 0.720 0.016 0.168 0.096
#> GSM123188     1  0.0404     0.8081 0.988 0.000 0.012 0.000 0.000
#> GSM123189     3  0.2535     0.7466 0.076 0.000 0.892 0.000 0.032
#> GSM123190     3  0.1484     0.7185 0.000 0.008 0.944 0.000 0.048
#> GSM123191     3  0.4425     0.0713 0.452 0.004 0.544 0.000 0.000
#> GSM123192     4  0.4127     0.4237 0.312 0.000 0.008 0.680 0.000
#> GSM123193     1  0.3949     0.4519 0.668 0.000 0.332 0.000 0.000
#> GSM123194     3  0.3155     0.7303 0.128 0.008 0.848 0.000 0.016
#> GSM123195     2  0.0609     0.9117 0.000 0.980 0.020 0.000 0.000
#> GSM123196     1  0.4410     0.1691 0.556 0.000 0.440 0.000 0.004
#> GSM123197     1  0.4461     0.6555 0.784 0.136 0.000 0.032 0.048
#> GSM123198     2  0.4971     0.7576 0.000 0.712 0.144 0.000 0.144
#> GSM123199     1  0.0451     0.8076 0.988 0.000 0.004 0.000 0.008
#> GSM123200     2  0.0324     0.9130 0.000 0.992 0.004 0.000 0.004
#> GSM123201     5  0.1329     0.8345 0.008 0.004 0.032 0.000 0.956
#> GSM123202     2  0.0703     0.9128 0.000 0.976 0.024 0.000 0.000
#> GSM123203     1  0.0290     0.8084 0.992 0.000 0.000 0.000 0.008
#> GSM123204     2  0.1121     0.9102 0.000 0.956 0.000 0.000 0.044
#> GSM123205     2  0.2773     0.8727 0.000 0.868 0.020 0.000 0.112
#> GSM123206     2  0.0000     0.9126 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.4057     0.6633 0.020 0.176 0.020 0.000 0.784
#> GSM123208     2  0.1270     0.9048 0.000 0.948 0.052 0.000 0.000
#> GSM123209     2  0.2074     0.9070 0.000 0.920 0.044 0.000 0.036
#> GSM123210     1  0.0000     0.8080 1.000 0.000 0.000 0.000 0.000
#> GSM123211     1  0.0162     0.8082 0.996 0.000 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
#> GSM123212     4  0.2558     0.8021 0.104 0.000 0.000 0.868 0.000 0.028
#> GSM123213     4  0.0520     0.8857 0.000 0.000 0.000 0.984 0.008 0.008
#> GSM123214     4  0.0363     0.8872 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM123215     4  0.0146     0.8880 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM123216     1  0.2144     0.7704 0.908 0.000 0.048 0.000 0.040 0.004
#> GSM123217     1  0.4915     0.4845 0.668 0.000 0.248 0.000 0.048 0.036
#> GSM123218     3  0.2369     0.4698 0.008 0.004 0.900 0.000 0.028 0.060
#> GSM123219     3  0.6168     0.4375 0.208 0.000 0.564 0.028 0.008 0.192
#> GSM123220     1  0.2065     0.7745 0.912 0.000 0.032 0.000 0.052 0.004
#> GSM123221     1  0.4105     0.6733 0.784 0.000 0.072 0.000 0.032 0.112
#> GSM123222     5  0.4944     0.4111 0.308 0.000 0.040 0.000 0.624 0.028
#> GSM123223     2  0.3154     0.6014 0.000 0.800 0.012 0.184 0.000 0.004
#> GSM123224     1  0.2188     0.7602 0.912 0.000 0.036 0.000 0.020 0.032
#> GSM123225     1  0.1401     0.7790 0.948 0.000 0.020 0.000 0.028 0.004
#> GSM123226     3  0.6294     0.0742 0.404 0.000 0.432 0.000 0.112 0.052
#> GSM123227     5  0.3863     0.5159 0.012 0.000 0.164 0.000 0.776 0.048
#> GSM123228     5  0.2112     0.6111 0.088 0.000 0.016 0.000 0.896 0.000
#> GSM123229     1  0.5796     0.2129 0.548 0.000 0.328 0.000 0.052 0.072
#> GSM123230     5  0.6737     0.2134 0.184 0.000 0.268 0.000 0.476 0.072
#> GSM123231     3  0.4753     0.3934 0.004 0.080 0.740 0.000 0.132 0.044
#> GSM123232     1  0.1913     0.7793 0.924 0.000 0.016 0.000 0.044 0.016
#> GSM123233     5  0.1750     0.5808 0.000 0.004 0.008 0.004 0.928 0.056
#> GSM123234     5  0.4932     0.5374 0.052 0.000 0.172 0.000 0.708 0.068
#> GSM123235     3  0.7124     0.2339 0.152 0.308 0.448 0.000 0.020 0.072
#> GSM123236     6  0.6008     0.0385 0.020 0.000 0.176 0.000 0.276 0.528
#> GSM123237     1  0.2474     0.7389 0.880 0.000 0.080 0.000 0.000 0.040
#> GSM123238     1  0.2868     0.7131 0.852 0.000 0.000 0.112 0.004 0.032
#> GSM123239     2  0.2340     0.7248 0.000 0.896 0.044 0.000 0.056 0.004
#> GSM123240     1  0.0458     0.7750 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM123241     1  0.2958     0.7554 0.852 0.000 0.108 0.000 0.028 0.012
#> GSM123242     4  0.0767     0.8824 0.000 0.000 0.008 0.976 0.004 0.012
#> GSM123182     4  0.6078     0.3279 0.000 0.000 0.268 0.540 0.160 0.032
#> GSM123183     4  0.1686     0.8488 0.064 0.000 0.000 0.924 0.000 0.012
#> GSM123184     4  0.0146     0.8880 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM123185     5  0.1844     0.5758 0.000 0.000 0.004 0.024 0.924 0.048
#> GSM123186     3  0.6581     0.2077 0.108 0.004 0.488 0.320 0.000 0.080
#> GSM123187     2  0.6792     0.0429 0.004 0.452 0.008 0.312 0.036 0.188
#> GSM123188     1  0.1829     0.7604 0.920 0.000 0.056 0.000 0.000 0.024
#> GSM123189     3  0.3823     0.4838 0.052 0.000 0.788 0.004 0.008 0.148
#> GSM123190     3  0.3684     0.3514 0.000 0.004 0.692 0.000 0.004 0.300
#> GSM123191     3  0.5048     0.4517 0.284 0.004 0.640 0.000 0.036 0.036
#> GSM123192     1  0.5063     0.1423 0.508 0.000 0.032 0.440 0.012 0.008
#> GSM123193     1  0.4071     0.4380 0.672 0.000 0.304 0.000 0.004 0.020
#> GSM123194     3  0.5591     0.4265 0.172 0.000 0.584 0.004 0.004 0.236
#> GSM123195     2  0.1349     0.7613 0.000 0.940 0.056 0.000 0.000 0.004
#> GSM123196     3  0.6321     0.1906 0.360 0.004 0.484 0.000 0.080 0.072
#> GSM123197     1  0.4735     0.5861 0.728 0.168 0.000 0.036 0.004 0.064
#> GSM123198     6  0.4929     0.4402 0.000 0.280 0.052 0.000 0.024 0.644
#> GSM123199     1  0.4335     0.6618 0.756 0.000 0.060 0.000 0.152 0.032
#> GSM123200     2  0.0622     0.7721 0.000 0.980 0.008 0.000 0.000 0.012
#> GSM123201     5  0.3593     0.4652 0.000 0.000 0.024 0.000 0.748 0.228
#> GSM123202     2  0.0146     0.7725 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123203     1  0.3770     0.6464 0.760 0.000 0.012 0.000 0.204 0.024
#> GSM123204     2  0.1411     0.7400 0.000 0.936 0.000 0.000 0.004 0.060
#> GSM123205     6  0.4561     0.1719 0.000 0.464 0.008 0.000 0.020 0.508
#> GSM123206     2  0.0508     0.7718 0.000 0.984 0.004 0.000 0.000 0.012
#> GSM123207     5  0.5645     0.0371 0.020 0.080 0.004 0.000 0.516 0.380
#> GSM123208     2  0.1075     0.7666 0.000 0.952 0.048 0.000 0.000 0.000
#> GSM123209     2  0.5155     0.0382 0.064 0.572 0.004 0.000 0.008 0.352
#> GSM123210     1  0.0603     0.7758 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM123211     1  0.0865     0.7739 0.964 0.000 0.000 0.000 0.000 0.036

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) k
#> SD:NMF 55           0.2178 2
#> SD:NMF 58           0.0954 3
#> SD:NMF 46           0.0403 4
#> SD:NMF 51           0.0618 5
#> SD:NMF 36           0.1556 6

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


CV:hclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.436           0.805       0.902         0.4446 0.541   0.541
#> 3 3 0.428           0.753       0.829         0.1964 0.940   0.889
#> 4 4 0.541           0.728       0.841         0.3180 0.729   0.479
#> 5 5 0.645           0.660       0.767         0.0730 0.941   0.798
#> 6 6 0.678           0.644       0.819         0.0504 0.938   0.757

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
#> GSM123212     2  0.6343      0.791 0.160 0.840
#> GSM123213     2  0.9129      0.515 0.328 0.672
#> GSM123214     2  0.0672      0.858 0.008 0.992
#> GSM123215     2  0.0672      0.858 0.008 0.992
#> GSM123216     1  0.0000      0.892 1.000 0.000
#> GSM123217     1  0.0000      0.892 1.000 0.000
#> GSM123218     1  0.7056      0.789 0.808 0.192
#> GSM123219     1  0.5519      0.843 0.872 0.128
#> GSM123220     1  0.0000      0.892 1.000 0.000
#> GSM123221     1  0.1633      0.887 0.976 0.024
#> GSM123222     1  0.0672      0.891 0.992 0.008
#> GSM123223     2  0.0000      0.858 0.000 1.000
#> GSM123224     1  0.0000      0.892 1.000 0.000
#> GSM123225     1  0.0000      0.892 1.000 0.000
#> GSM123226     1  0.0000      0.892 1.000 0.000
#> GSM123227     1  0.5629      0.842 0.868 0.132
#> GSM123228     1  0.0000      0.892 1.000 0.000
#> GSM123229     1  0.3274      0.878 0.940 0.060
#> GSM123230     1  0.0376      0.891 0.996 0.004
#> GSM123231     1  0.7056      0.789 0.808 0.192
#> GSM123232     1  0.0000      0.892 1.000 0.000
#> GSM123233     1  0.9608      0.470 0.616 0.384
#> GSM123234     1  0.0376      0.891 0.996 0.004
#> GSM123235     1  0.3274      0.877 0.940 0.060
#> GSM123236     1  0.8327      0.705 0.736 0.264
#> GSM123237     1  0.0000      0.892 1.000 0.000
#> GSM123238     2  0.7602      0.732 0.220 0.780
#> GSM123239     1  0.8386      0.701 0.732 0.268
#> GSM123240     1  0.0000      0.892 1.000 0.000
#> GSM123241     1  0.0000      0.892 1.000 0.000
#> GSM123242     2  0.9129      0.515 0.328 0.672
#> GSM123182     2  0.9896      0.235 0.440 0.560
#> GSM123183     2  0.6343      0.791 0.160 0.840
#> GSM123184     2  0.0672      0.858 0.008 0.992
#> GSM123185     1  0.9608      0.470 0.616 0.384
#> GSM123186     1  0.5519      0.843 0.872 0.128
#> GSM123187     2  0.9129      0.515 0.328 0.672
#> GSM123188     1  0.0000      0.892 1.000 0.000
#> GSM123189     1  0.5842      0.834 0.860 0.140
#> GSM123190     1  0.9248      0.540 0.660 0.340
#> GSM123191     1  0.5519      0.843 0.872 0.128
#> GSM123192     1  0.1633      0.887 0.976 0.024
#> GSM123193     1  0.0000      0.892 1.000 0.000
#> GSM123194     1  0.5519      0.843 0.872 0.128
#> GSM123195     2  0.0000      0.858 0.000 1.000
#> GSM123196     1  0.3274      0.878 0.940 0.060
#> GSM123197     2  0.6343      0.791 0.160 0.840
#> GSM123198     2  0.4562      0.822 0.096 0.904
#> GSM123199     1  0.0000      0.892 1.000 0.000
#> GSM123200     2  0.0000      0.858 0.000 1.000
#> GSM123201     1  0.8327      0.705 0.736 0.264
#> GSM123202     2  0.0000      0.858 0.000 1.000
#> GSM123203     1  0.0000      0.892 1.000 0.000
#> GSM123204     2  0.0000      0.858 0.000 1.000
#> GSM123205     2  0.0000      0.858 0.000 1.000
#> GSM123206     2  0.0000      0.858 0.000 1.000
#> GSM123207     1  0.8327      0.705 0.736 0.264
#> GSM123208     2  0.0000      0.858 0.000 1.000
#> GSM123209     2  0.6247      0.777 0.156 0.844
#> GSM123210     1  0.0000      0.892 1.000 0.000
#> GSM123211     1  0.0000      0.892 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.3183      0.640 0.076 0.908 0.016
#> GSM123213     2  0.9648      0.431 0.304 0.460 0.236
#> GSM123214     2  0.4235      0.510 0.000 0.824 0.176
#> GSM123215     2  0.4235      0.510 0.000 0.824 0.176
#> GSM123216     1  0.2711      0.836 0.912 0.088 0.000
#> GSM123217     1  0.2537      0.840 0.920 0.080 0.000
#> GSM123218     1  0.6031      0.756 0.788 0.096 0.116
#> GSM123219     1  0.4660      0.812 0.856 0.072 0.072
#> GSM123220     1  0.2261      0.843 0.932 0.068 0.000
#> GSM123221     1  0.3116      0.834 0.892 0.108 0.000
#> GSM123222     1  0.0983      0.848 0.980 0.016 0.004
#> GSM123223     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123224     1  0.2261      0.843 0.932 0.068 0.000
#> GSM123225     1  0.2711      0.836 0.912 0.088 0.000
#> GSM123226     1  0.0424      0.845 0.992 0.008 0.000
#> GSM123227     1  0.4790      0.800 0.848 0.096 0.056
#> GSM123228     1  0.0424      0.845 0.992 0.008 0.000
#> GSM123229     1  0.2682      0.832 0.920 0.076 0.004
#> GSM123230     1  0.1163      0.845 0.972 0.028 0.000
#> GSM123231     1  0.6031      0.756 0.788 0.096 0.116
#> GSM123232     1  0.1860      0.845 0.948 0.052 0.000
#> GSM123233     1  0.8505      0.467 0.600 0.144 0.256
#> GSM123234     1  0.1163      0.845 0.972 0.028 0.000
#> GSM123235     1  0.2774      0.832 0.920 0.072 0.008
#> GSM123236     1  0.7011      0.689 0.720 0.092 0.188
#> GSM123237     1  0.2165      0.844 0.936 0.064 0.000
#> GSM123238     2  0.4345      0.620 0.136 0.848 0.016
#> GSM123239     1  0.7133      0.686 0.712 0.096 0.192
#> GSM123240     1  0.2711      0.836 0.912 0.088 0.000
#> GSM123241     1  0.2356      0.842 0.928 0.072 0.000
#> GSM123242     2  0.9648      0.431 0.304 0.460 0.236
#> GSM123182     2  0.8929      0.263 0.416 0.460 0.124
#> GSM123183     2  0.3183      0.640 0.076 0.908 0.016
#> GSM123184     2  0.4235      0.510 0.000 0.824 0.176
#> GSM123185     1  0.8561      0.464 0.600 0.156 0.244
#> GSM123186     1  0.4660      0.812 0.856 0.072 0.072
#> GSM123187     2  0.9648      0.431 0.304 0.460 0.236
#> GSM123188     1  0.2165      0.844 0.936 0.064 0.000
#> GSM123189     1  0.5010      0.796 0.840 0.076 0.084
#> GSM123190     1  0.7916      0.547 0.636 0.100 0.264
#> GSM123191     1  0.4660      0.812 0.856 0.072 0.072
#> GSM123192     1  0.3192      0.837 0.888 0.112 0.000
#> GSM123193     1  0.2537      0.840 0.920 0.080 0.000
#> GSM123194     1  0.4660      0.812 0.856 0.072 0.072
#> GSM123195     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123196     1  0.2682      0.832 0.920 0.076 0.004
#> GSM123197     2  0.3183      0.640 0.076 0.908 0.016
#> GSM123198     3  0.5260      0.713 0.080 0.092 0.828
#> GSM123199     1  0.1860      0.845 0.948 0.052 0.000
#> GSM123200     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123201     1  0.7011      0.689 0.720 0.092 0.188
#> GSM123202     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123203     1  0.1860      0.846 0.948 0.052 0.000
#> GSM123204     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123205     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123206     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123207     1  0.7011      0.689 0.720 0.092 0.188
#> GSM123208     3  0.0000      0.927 0.000 0.000 1.000
#> GSM123209     3  0.6363      0.587 0.136 0.096 0.768
#> GSM123210     1  0.2356      0.842 0.928 0.072 0.000
#> GSM123211     1  0.2711      0.836 0.912 0.088 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.5116      0.859 0.128 0.000 0.108 0.764
#> GSM123213     3  0.8778      0.100 0.064 0.176 0.388 0.372
#> GSM123214     4  0.0000      0.834 0.000 0.000 0.000 1.000
#> GSM123215     4  0.0000      0.834 0.000 0.000 0.000 1.000
#> GSM123216     1  0.0000      0.872 1.000 0.000 0.000 0.000
#> GSM123217     1  0.0336      0.875 0.992 0.000 0.008 0.000
#> GSM123218     3  0.1284      0.706 0.024 0.012 0.964 0.000
#> GSM123219     1  0.4713      0.651 0.700 0.004 0.292 0.004
#> GSM123220     1  0.1557      0.878 0.944 0.000 0.056 0.000
#> GSM123221     1  0.1637      0.848 0.940 0.000 0.060 0.000
#> GSM123222     1  0.4964      0.277 0.616 0.004 0.380 0.000
#> GSM123223     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123224     1  0.1022      0.879 0.968 0.000 0.032 0.000
#> GSM123225     1  0.0000      0.872 1.000 0.000 0.000 0.000
#> GSM123226     3  0.4713      0.464 0.360 0.000 0.640 0.000
#> GSM123227     3  0.2973      0.716 0.144 0.000 0.856 0.000
#> GSM123228     3  0.4713      0.464 0.360 0.000 0.640 0.000
#> GSM123229     3  0.3123      0.703 0.156 0.000 0.844 0.000
#> GSM123230     3  0.4134      0.624 0.260 0.000 0.740 0.000
#> GSM123231     3  0.1284      0.706 0.024 0.012 0.964 0.000
#> GSM123232     1  0.2408      0.856 0.896 0.000 0.104 0.000
#> GSM123233     3  0.6121      0.631 0.044 0.176 0.720 0.060
#> GSM123234     3  0.4134      0.624 0.260 0.000 0.740 0.000
#> GSM123235     3  0.2973      0.705 0.144 0.000 0.856 0.000
#> GSM123236     3  0.3548      0.713 0.068 0.068 0.864 0.000
#> GSM123237     1  0.1637      0.877 0.940 0.000 0.060 0.000
#> GSM123238     4  0.5653      0.791 0.192 0.000 0.096 0.712
#> GSM123239     3  0.3764      0.710 0.076 0.072 0.852 0.000
#> GSM123240     1  0.0000      0.872 1.000 0.000 0.000 0.000
#> GSM123241     1  0.1474      0.878 0.948 0.000 0.052 0.000
#> GSM123242     3  0.8778      0.100 0.064 0.176 0.388 0.372
#> GSM123182     3  0.8458      0.179 0.100 0.088 0.444 0.368
#> GSM123183     4  0.5116      0.859 0.128 0.000 0.108 0.764
#> GSM123184     4  0.0000      0.834 0.000 0.000 0.000 1.000
#> GSM123185     3  0.6327      0.628 0.044 0.176 0.708 0.072
#> GSM123186     1  0.4713      0.651 0.700 0.004 0.292 0.004
#> GSM123187     3  0.8778      0.100 0.064 0.176 0.388 0.372
#> GSM123188     1  0.1637      0.877 0.940 0.000 0.060 0.000
#> GSM123189     3  0.2665      0.708 0.088 0.008 0.900 0.004
#> GSM123190     3  0.5141      0.621 0.084 0.160 0.756 0.000
#> GSM123191     1  0.4509      0.656 0.708 0.004 0.288 0.000
#> GSM123192     1  0.1211      0.858 0.960 0.000 0.040 0.000
#> GSM123193     1  0.0336      0.875 0.992 0.000 0.008 0.000
#> GSM123194     1  0.4713      0.651 0.700 0.004 0.292 0.004
#> GSM123195     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123196     3  0.3123      0.703 0.156 0.000 0.844 0.000
#> GSM123197     4  0.5116      0.859 0.128 0.000 0.108 0.764
#> GSM123198     2  0.4331      0.627 0.000 0.712 0.288 0.000
#> GSM123199     1  0.2408      0.856 0.896 0.000 0.104 0.000
#> GSM123200     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123201     3  0.3548      0.713 0.068 0.068 0.864 0.000
#> GSM123202     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123203     1  0.2216      0.863 0.908 0.000 0.092 0.000
#> GSM123204     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123207     3  0.3548      0.713 0.068 0.068 0.864 0.000
#> GSM123208     2  0.0000      0.917 0.000 1.000 0.000 0.000
#> GSM123209     2  0.5815      0.544 0.060 0.652 0.288 0.000
#> GSM123210     1  0.1389      0.879 0.952 0.000 0.048 0.000
#> GSM123211     1  0.0000      0.872 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.6839      0.636 0.096 0.000 0.052 0.472 0.380
#> GSM123213     5  0.8084      0.658 0.060 0.060 0.100 0.368 0.412
#> GSM123214     4  0.0000      0.522 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000      0.522 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0404      0.869 0.988 0.000 0.000 0.000 0.012
#> GSM123217     1  0.0798      0.869 0.976 0.000 0.016 0.000 0.008
#> GSM123218     3  0.1830      0.594 0.008 0.000 0.924 0.000 0.068
#> GSM123219     1  0.4465      0.617 0.672 0.000 0.304 0.000 0.024
#> GSM123220     1  0.1300      0.870 0.956 0.000 0.028 0.000 0.016
#> GSM123221     1  0.2149      0.840 0.916 0.000 0.048 0.000 0.036
#> GSM123222     1  0.6054      0.166 0.560 0.000 0.280 0.000 0.160
#> GSM123223     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123224     1  0.0609      0.872 0.980 0.000 0.020 0.000 0.000
#> GSM123225     1  0.0404      0.869 0.988 0.000 0.000 0.000 0.012
#> GSM123226     3  0.6420      0.503 0.324 0.000 0.484 0.000 0.192
#> GSM123227     3  0.5357      0.572 0.096 0.000 0.640 0.000 0.264
#> GSM123228     3  0.6420      0.503 0.324 0.000 0.484 0.000 0.192
#> GSM123229     3  0.2516      0.641 0.140 0.000 0.860 0.000 0.000
#> GSM123230     3  0.3756      0.598 0.248 0.000 0.744 0.000 0.008
#> GSM123231     3  0.1830      0.594 0.008 0.000 0.924 0.000 0.068
#> GSM123232     1  0.2260      0.848 0.908 0.000 0.064 0.000 0.028
#> GSM123233     5  0.6271      0.463 0.000 0.060 0.292 0.060 0.588
#> GSM123234     3  0.4054      0.595 0.248 0.000 0.732 0.000 0.020
#> GSM123235     3  0.2536      0.640 0.128 0.000 0.868 0.000 0.004
#> GSM123236     3  0.4746      0.387 0.024 0.000 0.600 0.000 0.376
#> GSM123237     1  0.1386      0.869 0.952 0.000 0.032 0.000 0.016
#> GSM123238     4  0.7156      0.589 0.160 0.000 0.040 0.436 0.364
#> GSM123239     3  0.5012      0.383 0.032 0.004 0.600 0.000 0.364
#> GSM123240     1  0.0404      0.869 0.988 0.000 0.000 0.000 0.012
#> GSM123241     1  0.1211      0.871 0.960 0.000 0.024 0.000 0.016
#> GSM123242     5  0.8084      0.658 0.060 0.060 0.100 0.368 0.412
#> GSM123182     4  0.7863     -0.523 0.076 0.000 0.224 0.360 0.340
#> GSM123183     4  0.6839      0.636 0.096 0.000 0.052 0.472 0.380
#> GSM123184     4  0.0000      0.522 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.6364      0.477 0.000 0.060 0.288 0.068 0.584
#> GSM123186     1  0.4465      0.617 0.672 0.000 0.304 0.000 0.024
#> GSM123187     5  0.8084      0.658 0.060 0.060 0.100 0.368 0.412
#> GSM123188     1  0.1386      0.869 0.952 0.000 0.032 0.000 0.016
#> GSM123189     3  0.2193      0.603 0.060 0.000 0.912 0.000 0.028
#> GSM123190     3  0.5533      0.457 0.068 0.144 0.716 0.000 0.072
#> GSM123191     1  0.4213      0.627 0.680 0.000 0.308 0.000 0.012
#> GSM123192     1  0.1668      0.854 0.940 0.000 0.028 0.000 0.032
#> GSM123193     1  0.0798      0.869 0.976 0.000 0.016 0.000 0.008
#> GSM123194     1  0.4465      0.617 0.672 0.000 0.304 0.000 0.024
#> GSM123195     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.2516      0.641 0.140 0.000 0.860 0.000 0.000
#> GSM123197     4  0.6839      0.636 0.096 0.000 0.052 0.472 0.380
#> GSM123198     2  0.5489      0.458 0.000 0.648 0.216 0.000 0.136
#> GSM123199     1  0.2325      0.846 0.904 0.000 0.068 0.000 0.028
#> GSM123200     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123201     3  0.4746      0.387 0.024 0.000 0.600 0.000 0.376
#> GSM123202     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123203     1  0.2104      0.855 0.916 0.000 0.060 0.000 0.024
#> GSM123204     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123207     3  0.4746      0.387 0.024 0.000 0.600 0.000 0.376
#> GSM123208     2  0.0000      0.900 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.6732      0.340 0.060 0.588 0.216 0.000 0.136
#> GSM123210     1  0.1211      0.872 0.960 0.000 0.024 0.000 0.016
#> GSM123211     1  0.0671      0.867 0.980 0.000 0.004 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
#> GSM123212     4  0.0000    0.95815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123213     5  0.4473   -0.07485 0.000 0.000 0.008 0.020 0.576 0.396
#> GSM123214     6  0.2300    0.71713 0.000 0.000 0.000 0.144 0.000 0.856
#> GSM123215     6  0.2300    0.71713 0.000 0.000 0.000 0.144 0.000 0.856
#> GSM123216     1  0.1204    0.84692 0.944 0.000 0.000 0.056 0.000 0.000
#> GSM123217     1  0.2134    0.84052 0.904 0.000 0.044 0.052 0.000 0.000
#> GSM123218     3  0.2266    0.70323 0.012 0.000 0.880 0.000 0.108 0.000
#> GSM123219     1  0.5273    0.47694 0.576 0.000 0.348 0.004 0.028 0.044
#> GSM123220     1  0.0551    0.84807 0.984 0.000 0.008 0.004 0.004 0.000
#> GSM123221     1  0.2560    0.82124 0.872 0.000 0.036 0.092 0.000 0.000
#> GSM123222     1  0.6815    0.20264 0.488 0.000 0.220 0.048 0.232 0.012
#> GSM123223     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123224     1  0.1116    0.85018 0.960 0.000 0.008 0.028 0.004 0.000
#> GSM123225     1  0.1204    0.84692 0.944 0.000 0.000 0.056 0.000 0.000
#> GSM123226     5  0.6735    0.06045 0.324 0.000 0.272 0.000 0.368 0.036
#> GSM123227     5  0.5762    0.22401 0.084 0.000 0.352 0.000 0.528 0.036
#> GSM123228     5  0.6735    0.06045 0.324 0.000 0.272 0.000 0.368 0.036
#> GSM123229     3  0.2263    0.77481 0.100 0.000 0.884 0.016 0.000 0.000
#> GSM123230     3  0.3823    0.66829 0.184 0.000 0.764 0.048 0.004 0.000
#> GSM123231     3  0.2266    0.70323 0.012 0.000 0.880 0.000 0.108 0.000
#> GSM123232     1  0.1421    0.82612 0.944 0.000 0.028 0.000 0.028 0.000
#> GSM123233     5  0.1757    0.40540 0.000 0.000 0.008 0.000 0.916 0.076
#> GSM123234     3  0.4768    0.64084 0.184 0.000 0.724 0.048 0.032 0.012
#> GSM123235     3  0.1556    0.77312 0.080 0.000 0.920 0.000 0.000 0.000
#> GSM123236     5  0.3841    0.48474 0.028 0.000 0.256 0.000 0.716 0.000
#> GSM123237     1  0.0260    0.84710 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM123238     4  0.1327    0.87437 0.064 0.000 0.000 0.936 0.000 0.000
#> GSM123239     5  0.4181    0.48009 0.028 0.000 0.256 0.000 0.704 0.012
#> GSM123240     1  0.1204    0.84692 0.944 0.000 0.000 0.056 0.000 0.000
#> GSM123241     1  0.0291    0.84928 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM123242     5  0.4473   -0.07485 0.000 0.000 0.008 0.020 0.576 0.396
#> GSM123182     6  0.6500   -0.00688 0.012 0.000 0.184 0.016 0.392 0.396
#> GSM123183     4  0.0000    0.95815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123184     6  0.2300    0.71713 0.000 0.000 0.000 0.144 0.000 0.856
#> GSM123185     5  0.2002    0.39690 0.000 0.000 0.004 0.012 0.908 0.076
#> GSM123186     1  0.5273    0.47694 0.576 0.000 0.348 0.004 0.028 0.044
#> GSM123187     5  0.4473   -0.07485 0.000 0.000 0.008 0.020 0.576 0.396
#> GSM123188     1  0.0260    0.84710 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM123189     3  0.1321    0.72707 0.020 0.000 0.952 0.004 0.024 0.000
#> GSM123190     3  0.5684    0.47289 0.012 0.136 0.668 0.000 0.128 0.056
#> GSM123191     1  0.5378    0.49832 0.596 0.000 0.320 0.012 0.028 0.044
#> GSM123192     1  0.2404    0.83282 0.884 0.000 0.036 0.080 0.000 0.000
#> GSM123193     1  0.2134    0.84052 0.904 0.000 0.044 0.052 0.000 0.000
#> GSM123194     1  0.5273    0.47694 0.576 0.000 0.348 0.004 0.028 0.044
#> GSM123195     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.2263    0.77481 0.100 0.000 0.884 0.016 0.000 0.000
#> GSM123197     4  0.0000    0.95815 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123198     2  0.5417    0.44660 0.000 0.580 0.108 0.000 0.300 0.012
#> GSM123199     1  0.1572    0.82230 0.936 0.000 0.036 0.000 0.028 0.000
#> GSM123200     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.3841    0.48474 0.028 0.000 0.256 0.000 0.716 0.000
#> GSM123202     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123203     1  0.1485    0.83323 0.944 0.000 0.024 0.004 0.028 0.000
#> GSM123204     2  0.0260    0.88452 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM123205     2  0.0260    0.88452 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM123206     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.3841    0.48474 0.028 0.000 0.256 0.000 0.716 0.000
#> GSM123208     2  0.0000    0.88726 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.6172    0.35096 0.000 0.520 0.108 0.000 0.316 0.056
#> GSM123210     1  0.0520    0.85046 0.984 0.000 0.008 0.008 0.000 0.000
#> GSM123211     1  0.1327    0.84522 0.936 0.000 0.000 0.064 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) k
#> CV:hclust 58           0.1158 2
#> CV:hclust 55           0.0165 3
#> CV:hclust 54           0.0569 4
#> CV:hclust 50           0.0559 5
#> CV:hclust 40           0.1218 6

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


CV:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.779           0.847       0.940         0.4590 0.552   0.552
#> 3 3 0.524           0.442       0.659         0.3374 0.798   0.654
#> 4 4 0.636           0.779       0.853         0.1865 0.725   0.426
#> 5 5 0.650           0.654       0.771         0.0769 0.885   0.614
#> 6 6 0.668           0.532       0.747         0.0453 0.952   0.791

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
#> GSM123212     2   0.802      0.667 0.244 0.756
#> GSM123213     2   0.000      0.924 0.000 1.000
#> GSM123214     2   0.000      0.924 0.000 1.000
#> GSM123215     2   0.000      0.924 0.000 1.000
#> GSM123216     1   0.000      0.934 1.000 0.000
#> GSM123217     1   0.000      0.934 1.000 0.000
#> GSM123218     1   0.443      0.847 0.908 0.092
#> GSM123219     1   0.000      0.934 1.000 0.000
#> GSM123220     1   0.000      0.934 1.000 0.000
#> GSM123221     1   0.000      0.934 1.000 0.000
#> GSM123222     1   0.000      0.934 1.000 0.000
#> GSM123223     2   0.000      0.924 0.000 1.000
#> GSM123224     1   0.000      0.934 1.000 0.000
#> GSM123225     1   0.000      0.934 1.000 0.000
#> GSM123226     1   0.000      0.934 1.000 0.000
#> GSM123227     1   0.000      0.934 1.000 0.000
#> GSM123228     1   0.000      0.934 1.000 0.000
#> GSM123229     1   0.000      0.934 1.000 0.000
#> GSM123230     1   0.000      0.934 1.000 0.000
#> GSM123231     1   0.886      0.561 0.696 0.304
#> GSM123232     1   0.000      0.934 1.000 0.000
#> GSM123233     2   0.971      0.250 0.400 0.600
#> GSM123234     1   0.000      0.934 1.000 0.000
#> GSM123235     1   0.000      0.934 1.000 0.000
#> GSM123236     1   0.000      0.934 1.000 0.000
#> GSM123237     1   0.000      0.934 1.000 0.000
#> GSM123238     1   0.971      0.241 0.600 0.400
#> GSM123239     1   0.963      0.394 0.612 0.388
#> GSM123240     1   0.000      0.934 1.000 0.000
#> GSM123241     1   0.000      0.934 1.000 0.000
#> GSM123242     2   0.000      0.924 0.000 1.000
#> GSM123182     1   0.958      0.411 0.620 0.380
#> GSM123183     2   0.802      0.667 0.244 0.756
#> GSM123184     2   0.000      0.924 0.000 1.000
#> GSM123185     1   0.981      0.312 0.580 0.420
#> GSM123186     1   0.000      0.934 1.000 0.000
#> GSM123187     2   0.000      0.924 0.000 1.000
#> GSM123188     1   0.000      0.934 1.000 0.000
#> GSM123189     1   0.000      0.934 1.000 0.000
#> GSM123190     1   0.943      0.455 0.640 0.360
#> GSM123191     1   0.000      0.934 1.000 0.000
#> GSM123192     1   0.000      0.934 1.000 0.000
#> GSM123193     1   0.000      0.934 1.000 0.000
#> GSM123194     1   0.000      0.934 1.000 0.000
#> GSM123195     2   0.000      0.924 0.000 1.000
#> GSM123196     1   0.000      0.934 1.000 0.000
#> GSM123197     2   0.971      0.358 0.400 0.600
#> GSM123198     2   0.000      0.924 0.000 1.000
#> GSM123199     1   0.000      0.934 1.000 0.000
#> GSM123200     2   0.000      0.924 0.000 1.000
#> GSM123201     1   0.000      0.934 1.000 0.000
#> GSM123202     2   0.000      0.924 0.000 1.000
#> GSM123203     1   0.000      0.934 1.000 0.000
#> GSM123204     2   0.000      0.924 0.000 1.000
#> GSM123205     2   0.000      0.924 0.000 1.000
#> GSM123206     2   0.000      0.924 0.000 1.000
#> GSM123207     1   0.000      0.934 1.000 0.000
#> GSM123208     2   0.000      0.924 0.000 1.000
#> GSM123209     2   0.000      0.924 0.000 1.000
#> GSM123210     1   0.000      0.934 1.000 0.000
#> GSM123211     1   0.000      0.934 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.5331     0.6301 0.076 0.824 0.100
#> GSM123213     2  0.2165     0.6631 0.000 0.936 0.064
#> GSM123214     2  0.0237     0.7047 0.000 0.996 0.004
#> GSM123215     2  0.0237     0.7047 0.000 0.996 0.004
#> GSM123216     1  0.1529     0.7410 0.960 0.000 0.040
#> GSM123217     1  0.0592     0.7540 0.988 0.000 0.012
#> GSM123218     3  0.7744    -0.4453 0.448 0.048 0.504
#> GSM123219     1  0.8085     0.5490 0.584 0.084 0.332
#> GSM123220     1  0.0747     0.7549 0.984 0.000 0.016
#> GSM123221     1  0.1529     0.7410 0.960 0.000 0.040
#> GSM123222     1  0.2356     0.7515 0.928 0.000 0.072
#> GSM123223     2  0.6309    -0.1309 0.000 0.504 0.496
#> GSM123224     1  0.1163     0.7468 0.972 0.000 0.028
#> GSM123225     1  0.1031     0.7468 0.976 0.000 0.024
#> GSM123226     1  0.5016     0.6943 0.760 0.000 0.240
#> GSM123227     1  0.6468     0.5591 0.552 0.004 0.444
#> GSM123228     1  0.2959     0.7452 0.900 0.000 0.100
#> GSM123229     1  0.5397     0.6720 0.720 0.000 0.280
#> GSM123230     1  0.5016     0.6932 0.760 0.000 0.240
#> GSM123231     3  0.7624    -0.3355 0.392 0.048 0.560
#> GSM123232     1  0.0747     0.7547 0.984 0.000 0.016
#> GSM123233     3  0.6793     0.1757 0.100 0.160 0.740
#> GSM123234     1  0.6140     0.5961 0.596 0.000 0.404
#> GSM123235     1  0.6244     0.5681 0.560 0.000 0.440
#> GSM123236     1  0.6495     0.5257 0.536 0.004 0.460
#> GSM123237     1  0.0592     0.7544 0.988 0.000 0.012
#> GSM123238     1  0.7013     0.2849 0.640 0.324 0.036
#> GSM123239     3  0.1529     0.1890 0.040 0.000 0.960
#> GSM123240     1  0.1529     0.7408 0.960 0.000 0.040
#> GSM123241     1  0.0592     0.7544 0.988 0.000 0.012
#> GSM123242     2  0.1643     0.6909 0.000 0.956 0.044
#> GSM123182     3  0.9862    -0.1815 0.272 0.316 0.412
#> GSM123183     2  0.5331     0.6301 0.076 0.824 0.100
#> GSM123184     2  0.0237     0.7047 0.000 0.996 0.004
#> GSM123185     3  0.9901    -0.1812 0.328 0.276 0.396
#> GSM123186     1  0.9271     0.4064 0.528 0.244 0.228
#> GSM123187     2  0.6280    -0.0347 0.000 0.540 0.460
#> GSM123188     1  0.0592     0.7544 0.988 0.000 0.012
#> GSM123189     1  0.8403     0.4569 0.468 0.084 0.448
#> GSM123190     3  0.7690    -0.3832 0.416 0.048 0.536
#> GSM123191     1  0.6442     0.5716 0.564 0.004 0.432
#> GSM123192     1  0.5581     0.5755 0.788 0.176 0.036
#> GSM123193     1  0.1643     0.7456 0.956 0.000 0.044
#> GSM123194     1  0.6386     0.5845 0.584 0.004 0.412
#> GSM123195     3  0.6305     0.0245 0.000 0.484 0.516
#> GSM123196     1  0.6225     0.5754 0.568 0.000 0.432
#> GSM123197     2  0.7474     0.4516 0.216 0.684 0.100
#> GSM123198     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123199     1  0.2356     0.7514 0.928 0.000 0.072
#> GSM123200     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123201     1  0.6468     0.5591 0.552 0.004 0.444
#> GSM123202     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123203     1  0.2066     0.7525 0.940 0.000 0.060
#> GSM123204     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123205     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123206     3  0.6305     0.0245 0.000 0.484 0.516
#> GSM123207     1  0.6451     0.5517 0.560 0.004 0.436
#> GSM123208     3  0.6302     0.0341 0.000 0.480 0.520
#> GSM123209     3  0.6111    -0.0227 0.000 0.396 0.604
#> GSM123210     1  0.0592     0.7506 0.988 0.000 0.012
#> GSM123211     1  0.2414     0.7278 0.940 0.020 0.040

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.4105     0.7827 0.052 0.100 0.008 0.840
#> GSM123213     4  0.4399     0.7842 0.000 0.212 0.020 0.768
#> GSM123214     4  0.3801     0.7969 0.000 0.220 0.000 0.780
#> GSM123215     4  0.3801     0.7969 0.000 0.220 0.000 0.780
#> GSM123216     1  0.1677     0.8731 0.948 0.000 0.012 0.040
#> GSM123217     1  0.1488     0.8889 0.956 0.000 0.032 0.012
#> GSM123218     3  0.0927     0.7806 0.008 0.000 0.976 0.016
#> GSM123219     3  0.5312     0.6587 0.268 0.000 0.692 0.040
#> GSM123220     1  0.1767     0.8847 0.944 0.000 0.044 0.012
#> GSM123221     1  0.2522     0.8594 0.908 0.000 0.016 0.076
#> GSM123222     1  0.3245     0.8541 0.880 0.000 0.056 0.064
#> GSM123223     2  0.1118     0.9345 0.000 0.964 0.000 0.036
#> GSM123224     1  0.1297     0.8894 0.964 0.000 0.020 0.016
#> GSM123225     1  0.1284     0.8870 0.964 0.000 0.012 0.024
#> GSM123226     1  0.5894     0.2688 0.536 0.000 0.428 0.036
#> GSM123227     3  0.3082     0.7839 0.032 0.000 0.884 0.084
#> GSM123228     1  0.3894     0.8166 0.844 0.000 0.068 0.088
#> GSM123229     3  0.5708     0.0836 0.416 0.000 0.556 0.028
#> GSM123230     1  0.5992     0.2162 0.516 0.000 0.444 0.040
#> GSM123231     3  0.0967     0.7802 0.004 0.004 0.976 0.016
#> GSM123232     1  0.1913     0.8808 0.940 0.000 0.040 0.020
#> GSM123233     3  0.6307     0.6654 0.020 0.164 0.700 0.116
#> GSM123234     3  0.3840     0.7448 0.104 0.000 0.844 0.052
#> GSM123235     3  0.2032     0.7782 0.028 0.000 0.936 0.036
#> GSM123236     3  0.5265     0.7577 0.160 0.000 0.748 0.092
#> GSM123237     1  0.1174     0.8888 0.968 0.000 0.020 0.012
#> GSM123238     4  0.5147     0.0888 0.460 0.000 0.004 0.536
#> GSM123239     3  0.6315     0.6817 0.024 0.188 0.696 0.092
#> GSM123240     1  0.1022     0.8784 0.968 0.000 0.000 0.032
#> GSM123241     1  0.1545     0.8876 0.952 0.000 0.040 0.008
#> GSM123242     4  0.4406     0.7929 0.000 0.192 0.028 0.780
#> GSM123182     3  0.5951     0.7438 0.152 0.000 0.696 0.152
#> GSM123183     4  0.3778     0.7829 0.052 0.100 0.000 0.848
#> GSM123184     4  0.3801     0.7969 0.000 0.220 0.000 0.780
#> GSM123185     3  0.6006     0.6575 0.024 0.052 0.696 0.228
#> GSM123186     3  0.6617     0.4042 0.380 0.000 0.532 0.088
#> GSM123187     2  0.3617     0.8477 0.000 0.860 0.076 0.064
#> GSM123188     1  0.1488     0.8889 0.956 0.000 0.032 0.012
#> GSM123189     3  0.1356     0.7804 0.008 0.000 0.960 0.032
#> GSM123190     3  0.0524     0.7818 0.000 0.004 0.988 0.008
#> GSM123191     3  0.3695     0.7697 0.156 0.000 0.828 0.016
#> GSM123192     1  0.2714     0.8334 0.884 0.000 0.004 0.112
#> GSM123193     1  0.2521     0.8700 0.912 0.000 0.024 0.064
#> GSM123194     3  0.5204     0.7593 0.160 0.000 0.752 0.088
#> GSM123195     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123196     3  0.2500     0.7750 0.044 0.000 0.916 0.040
#> GSM123197     4  0.6720     0.7000 0.108 0.100 0.088 0.704
#> GSM123198     2  0.1256     0.9411 0.000 0.964 0.028 0.008
#> GSM123199     1  0.3088     0.8531 0.888 0.000 0.060 0.052
#> GSM123200     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123201     3  0.3354     0.7845 0.044 0.000 0.872 0.084
#> GSM123202     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123203     1  0.3009     0.8557 0.892 0.000 0.056 0.052
#> GSM123204     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0672     0.9532 0.000 0.984 0.008 0.008
#> GSM123206     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123207     3  0.5923     0.7121 0.216 0.000 0.684 0.100
#> GSM123208     2  0.0000     0.9597 0.000 1.000 0.000 0.000
#> GSM123209     2  0.2546     0.8739 0.000 0.900 0.092 0.008
#> GSM123210     1  0.1406     0.8880 0.960 0.000 0.024 0.016
#> GSM123211     1  0.2402     0.8551 0.912 0.000 0.012 0.076

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.4616      0.782 0.020 0.028 0.012 0.764 0.176
#> GSM123213     4  0.3303      0.785 0.000 0.076 0.000 0.848 0.076
#> GSM123214     4  0.2115      0.814 0.000 0.068 0.008 0.916 0.008
#> GSM123215     4  0.2115      0.814 0.000 0.068 0.008 0.916 0.008
#> GSM123216     1  0.1695      0.779 0.940 0.000 0.008 0.008 0.044
#> GSM123217     1  0.1630      0.791 0.944 0.000 0.016 0.004 0.036
#> GSM123218     3  0.2648      0.499 0.000 0.000 0.848 0.000 0.152
#> GSM123219     1  0.7449     -0.182 0.348 0.000 0.348 0.032 0.272
#> GSM123220     1  0.2868      0.774 0.884 0.000 0.072 0.012 0.032
#> GSM123221     1  0.3821      0.738 0.836 0.000 0.044 0.036 0.084
#> GSM123222     1  0.5647      0.652 0.684 0.000 0.128 0.024 0.164
#> GSM123223     2  0.2179      0.820 0.000 0.896 0.000 0.100 0.004
#> GSM123224     1  0.2026      0.789 0.928 0.000 0.044 0.012 0.016
#> GSM123225     1  0.1299      0.787 0.960 0.000 0.008 0.012 0.020
#> GSM123226     3  0.5692      0.248 0.372 0.000 0.556 0.012 0.060
#> GSM123227     5  0.4754      0.743 0.020 0.012 0.304 0.000 0.664
#> GSM123228     1  0.5801      0.511 0.608 0.000 0.092 0.012 0.288
#> GSM123229     3  0.4017      0.529 0.248 0.000 0.736 0.012 0.004
#> GSM123230     3  0.4935      0.419 0.304 0.000 0.656 0.024 0.016
#> GSM123231     3  0.2648      0.499 0.000 0.000 0.848 0.000 0.152
#> GSM123232     1  0.3253      0.766 0.864 0.000 0.068 0.012 0.056
#> GSM123233     5  0.6303      0.713 0.000 0.080 0.160 0.108 0.652
#> GSM123234     3  0.4844      0.472 0.052 0.000 0.744 0.028 0.176
#> GSM123235     3  0.0609      0.598 0.020 0.000 0.980 0.000 0.000
#> GSM123236     5  0.4898      0.768 0.052 0.012 0.228 0.000 0.708
#> GSM123237     1  0.1787      0.790 0.936 0.000 0.016 0.004 0.044
#> GSM123238     4  0.6901      0.313 0.352 0.000 0.024 0.460 0.164
#> GSM123239     5  0.5240      0.735 0.000 0.120 0.204 0.000 0.676
#> GSM123240     1  0.0865      0.787 0.972 0.000 0.004 0.000 0.024
#> GSM123241     1  0.1877      0.786 0.924 0.000 0.064 0.000 0.012
#> GSM123242     4  0.3186      0.801 0.000 0.056 0.020 0.872 0.052
#> GSM123182     5  0.6313      0.594 0.020 0.004 0.280 0.112 0.584
#> GSM123183     4  0.4290      0.784 0.016 0.028 0.012 0.792 0.152
#> GSM123184     4  0.2115      0.814 0.000 0.068 0.008 0.916 0.008
#> GSM123185     5  0.6112      0.699 0.000 0.036 0.152 0.164 0.648
#> GSM123186     1  0.7554     -0.092 0.372 0.000 0.308 0.040 0.280
#> GSM123187     2  0.6634      0.179 0.000 0.512 0.056 0.076 0.356
#> GSM123188     1  0.1547      0.791 0.948 0.000 0.016 0.004 0.032
#> GSM123189     3  0.3606      0.501 0.004 0.000 0.808 0.024 0.164
#> GSM123190     3  0.4523     -0.043 0.000 0.012 0.640 0.004 0.344
#> GSM123191     3  0.5740      0.312 0.120 0.000 0.656 0.016 0.208
#> GSM123192     1  0.4821      0.655 0.740 0.000 0.032 0.040 0.188
#> GSM123193     1  0.3708      0.719 0.816 0.000 0.044 0.004 0.136
#> GSM123194     5  0.6232      0.481 0.096 0.000 0.344 0.020 0.540
#> GSM123195     2  0.0404      0.884 0.000 0.988 0.000 0.012 0.000
#> GSM123196     3  0.1059      0.599 0.020 0.000 0.968 0.008 0.004
#> GSM123197     4  0.6623      0.699 0.040 0.028 0.088 0.628 0.216
#> GSM123198     2  0.2127      0.850 0.000 0.892 0.000 0.000 0.108
#> GSM123199     1  0.4941      0.682 0.736 0.000 0.100 0.012 0.152
#> GSM123200     2  0.0162      0.888 0.000 0.996 0.000 0.000 0.004
#> GSM123201     5  0.4646      0.759 0.024 0.012 0.268 0.000 0.696
#> GSM123202     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM123203     1  0.4941      0.686 0.736 0.000 0.100 0.012 0.152
#> GSM123204     2  0.0963      0.883 0.000 0.964 0.000 0.000 0.036
#> GSM123205     2  0.1121      0.882 0.000 0.956 0.000 0.000 0.044
#> GSM123206     2  0.0404      0.884 0.000 0.988 0.000 0.012 0.000
#> GSM123207     5  0.4927      0.745 0.056 0.012 0.188 0.008 0.736
#> GSM123208     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.4313      0.677 0.000 0.760 0.068 0.000 0.172
#> GSM123210     1  0.1522      0.790 0.944 0.000 0.044 0.012 0.000
#> GSM123211     1  0.3739      0.720 0.820 0.000 0.020 0.024 0.136

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.1434     0.6521 0.000 0.012 0.012 0.948 0.028 0.000
#> GSM123213     4  0.6422     0.6203 0.000 0.036 0.000 0.460 0.180 0.324
#> GSM123214     4  0.4742     0.7136 0.000 0.024 0.000 0.584 0.020 0.372
#> GSM123215     4  0.4742     0.7136 0.000 0.024 0.000 0.584 0.020 0.372
#> GSM123216     1  0.3062     0.6388 0.816 0.000 0.000 0.024 0.000 0.160
#> GSM123217     1  0.1577     0.6921 0.940 0.000 0.008 0.000 0.016 0.036
#> GSM123218     3  0.3274     0.5326 0.000 0.000 0.804 0.004 0.168 0.024
#> GSM123219     3  0.8037    -0.9234 0.260 0.000 0.296 0.040 0.108 0.296
#> GSM123220     1  0.1749     0.6858 0.936 0.000 0.032 0.004 0.016 0.012
#> GSM123221     1  0.5443     0.4868 0.672 0.000 0.044 0.156 0.004 0.124
#> GSM123222     1  0.6427     0.4775 0.596 0.000 0.112 0.028 0.200 0.064
#> GSM123223     2  0.2538     0.7822 0.000 0.860 0.000 0.000 0.016 0.124
#> GSM123224     1  0.2255     0.6915 0.892 0.000 0.004 0.016 0.000 0.088
#> GSM123225     1  0.2527     0.6763 0.868 0.000 0.000 0.024 0.000 0.108
#> GSM123226     3  0.6026     0.1405 0.408 0.000 0.468 0.004 0.068 0.052
#> GSM123227     5  0.3184     0.6635 0.016 0.000 0.120 0.000 0.836 0.028
#> GSM123228     1  0.5617     0.3991 0.584 0.000 0.052 0.004 0.308 0.052
#> GSM123229     3  0.3647     0.5328 0.160 0.000 0.796 0.020 0.020 0.004
#> GSM123230     3  0.5007     0.4859 0.192 0.000 0.708 0.020 0.040 0.040
#> GSM123231     3  0.3274     0.5326 0.000 0.000 0.804 0.004 0.168 0.024
#> GSM123232     1  0.3578     0.6376 0.832 0.000 0.032 0.004 0.080 0.052
#> GSM123233     5  0.2709     0.6885 0.000 0.028 0.020 0.004 0.884 0.064
#> GSM123234     3  0.5318     0.4721 0.028 0.000 0.676 0.044 0.216 0.036
#> GSM123235     3  0.1296     0.5718 0.012 0.000 0.952 0.000 0.032 0.004
#> GSM123236     5  0.1552     0.7047 0.020 0.000 0.036 0.000 0.940 0.004
#> GSM123237     1  0.1148     0.6967 0.960 0.000 0.004 0.000 0.020 0.016
#> GSM123238     4  0.4885     0.2918 0.204 0.000 0.016 0.684 0.000 0.096
#> GSM123239     5  0.2046     0.7049 0.000 0.044 0.032 0.000 0.916 0.008
#> GSM123240     1  0.2358     0.6752 0.876 0.000 0.000 0.016 0.000 0.108
#> GSM123241     1  0.1856     0.6922 0.920 0.000 0.032 0.000 0.000 0.048
#> GSM123242     4  0.6257     0.6454 0.000 0.024 0.004 0.492 0.164 0.316
#> GSM123182     5  0.5813     0.1679 0.000 0.000 0.216 0.000 0.488 0.296
#> GSM123183     4  0.0767     0.6522 0.000 0.012 0.008 0.976 0.004 0.000
#> GSM123184     4  0.4742     0.7136 0.000 0.024 0.000 0.584 0.020 0.372
#> GSM123185     5  0.2891     0.6798 0.000 0.008 0.024 0.012 0.868 0.088
#> GSM123186     6  0.8213     0.0000 0.280 0.000 0.252 0.056 0.112 0.300
#> GSM123187     5  0.5530     0.3748 0.000 0.224 0.000 0.000 0.560 0.216
#> GSM123188     1  0.0964     0.6967 0.968 0.000 0.004 0.000 0.016 0.012
#> GSM123189     3  0.3911     0.3570 0.000 0.000 0.760 0.004 0.056 0.180
#> GSM123190     5  0.5272     0.1718 0.000 0.000 0.428 0.004 0.484 0.084
#> GSM123191     3  0.6044    -0.1358 0.104 0.000 0.596 0.000 0.084 0.216
#> GSM123192     1  0.6740    -0.2089 0.444 0.000 0.060 0.156 0.004 0.336
#> GSM123193     1  0.6228     0.0397 0.572 0.000 0.092 0.072 0.008 0.256
#> GSM123194     5  0.6881    -0.1615 0.060 0.000 0.288 0.000 0.416 0.236
#> GSM123195     2  0.0000     0.8863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.1434     0.5739 0.012 0.000 0.948 0.012 0.028 0.000
#> GSM123197     4  0.4525     0.5659 0.020 0.012 0.056 0.792 0.076 0.044
#> GSM123198     2  0.4566     0.7245 0.000 0.712 0.004 0.000 0.148 0.136
#> GSM123199     1  0.4972     0.5415 0.704 0.000 0.052 0.004 0.188 0.052
#> GSM123200     2  0.0000     0.8863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.2706     0.6865 0.024 0.000 0.068 0.000 0.880 0.028
#> GSM123202     2  0.0146     0.8857 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123203     1  0.4969     0.5465 0.708 0.000 0.052 0.004 0.180 0.056
#> GSM123204     2  0.1700     0.8667 0.000 0.916 0.004 0.000 0.000 0.080
#> GSM123205     2  0.2402     0.8437 0.000 0.856 0.004 0.000 0.000 0.140
#> GSM123206     2  0.0146     0.8857 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123207     5  0.1409     0.7031 0.012 0.000 0.032 0.008 0.948 0.000
#> GSM123208     2  0.0000     0.8863 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.5141     0.5039 0.000 0.612 0.012 0.000 0.292 0.084
#> GSM123210     1  0.2765     0.6735 0.876 0.000 0.044 0.016 0.000 0.064
#> GSM123211     1  0.5303     0.4421 0.636 0.000 0.012 0.196 0.000 0.156

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) k
#> CV:kmeans 54           0.1016 2
#> CV:kmeans 39           0.9911 3
#> CV:kmeans 56           0.0277 4
#> CV:kmeans 49           0.0846 5
#> CV:kmeans 43           0.0313 6

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


CV:skmeans*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.932           0.908       0.965         0.5026 0.503   0.503
#> 3 3 0.596           0.503       0.772         0.3135 0.731   0.514
#> 4 4 0.753           0.842       0.894         0.1294 0.802   0.489
#> 5 5 0.725           0.699       0.848         0.0640 0.934   0.741
#> 6 6 0.782           0.756       0.855         0.0398 0.958   0.803

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
#> GSM123212     2   0.118      0.966 0.016 0.984
#> GSM123213     2   0.000      0.979 0.000 1.000
#> GSM123214     2   0.000      0.979 0.000 1.000
#> GSM123215     2   0.000      0.979 0.000 1.000
#> GSM123216     1   0.000      0.948 1.000 0.000
#> GSM123217     1   0.000      0.948 1.000 0.000
#> GSM123218     1   0.969      0.354 0.604 0.396
#> GSM123219     1   0.000      0.948 1.000 0.000
#> GSM123220     1   0.000      0.948 1.000 0.000
#> GSM123221     1   0.000      0.948 1.000 0.000
#> GSM123222     1   0.000      0.948 1.000 0.000
#> GSM123223     2   0.000      0.979 0.000 1.000
#> GSM123224     1   0.000      0.948 1.000 0.000
#> GSM123225     1   0.000      0.948 1.000 0.000
#> GSM123226     1   0.000      0.948 1.000 0.000
#> GSM123227     1   0.000      0.948 1.000 0.000
#> GSM123228     1   0.000      0.948 1.000 0.000
#> GSM123229     1   0.000      0.948 1.000 0.000
#> GSM123230     1   0.000      0.948 1.000 0.000
#> GSM123231     1   0.990      0.230 0.560 0.440
#> GSM123232     1   0.000      0.948 1.000 0.000
#> GSM123233     2   0.000      0.979 0.000 1.000
#> GSM123234     1   0.000      0.948 1.000 0.000
#> GSM123235     1   0.000      0.948 1.000 0.000
#> GSM123236     2   0.921      0.450 0.336 0.664
#> GSM123237     1   0.000      0.948 1.000 0.000
#> GSM123238     1   0.971      0.343 0.600 0.400
#> GSM123239     2   0.000      0.979 0.000 1.000
#> GSM123240     1   0.000      0.948 1.000 0.000
#> GSM123241     1   0.000      0.948 1.000 0.000
#> GSM123242     2   0.000      0.979 0.000 1.000
#> GSM123182     2   0.000      0.979 0.000 1.000
#> GSM123183     2   0.204      0.951 0.032 0.968
#> GSM123184     2   0.000      0.979 0.000 1.000
#> GSM123185     2   0.000      0.979 0.000 1.000
#> GSM123186     1   0.971      0.343 0.600 0.400
#> GSM123187     2   0.000      0.979 0.000 1.000
#> GSM123188     1   0.000      0.948 1.000 0.000
#> GSM123189     1   0.260      0.909 0.956 0.044
#> GSM123190     2   0.000      0.979 0.000 1.000
#> GSM123191     1   0.000      0.948 1.000 0.000
#> GSM123192     1   0.000      0.948 1.000 0.000
#> GSM123193     1   0.000      0.948 1.000 0.000
#> GSM123194     1   0.000      0.948 1.000 0.000
#> GSM123195     2   0.000      0.979 0.000 1.000
#> GSM123196     1   0.000      0.948 1.000 0.000
#> GSM123197     2   0.456      0.880 0.096 0.904
#> GSM123198     2   0.000      0.979 0.000 1.000
#> GSM123199     1   0.000      0.948 1.000 0.000
#> GSM123200     2   0.000      0.979 0.000 1.000
#> GSM123201     1   0.000      0.948 1.000 0.000
#> GSM123202     2   0.000      0.979 0.000 1.000
#> GSM123203     1   0.000      0.948 1.000 0.000
#> GSM123204     2   0.000      0.979 0.000 1.000
#> GSM123205     2   0.000      0.979 0.000 1.000
#> GSM123206     2   0.000      0.979 0.000 1.000
#> GSM123207     2   0.000      0.979 0.000 1.000
#> GSM123208     2   0.000      0.979 0.000 1.000
#> GSM123209     2   0.000      0.979 0.000 1.000
#> GSM123210     1   0.000      0.948 1.000 0.000
#> GSM123211     1   0.000      0.948 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123213     3  0.4002      0.499 0.000 0.160 0.840
#> GSM123214     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123215     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123216     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123217     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123218     3  0.7074      0.375 0.020 0.480 0.500
#> GSM123219     2  0.5497      0.316 0.292 0.708 0.000
#> GSM123220     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123221     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123222     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123223     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123224     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123225     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123226     1  0.6244      0.377 0.560 0.440 0.000
#> GSM123227     2  0.8814     -0.171 0.404 0.480 0.116
#> GSM123228     1  0.3752      0.691 0.856 0.144 0.000
#> GSM123229     1  0.6244      0.377 0.560 0.440 0.000
#> GSM123230     1  0.6244      0.377 0.560 0.440 0.000
#> GSM123231     3  0.7074      0.375 0.020 0.480 0.500
#> GSM123232     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123233     3  0.5968      0.500 0.000 0.364 0.636
#> GSM123234     1  0.6244      0.377 0.560 0.440 0.000
#> GSM123235     1  0.6299      0.319 0.524 0.476 0.000
#> GSM123236     3  0.6302      0.399 0.000 0.480 0.520
#> GSM123237     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123238     1  0.6677      0.227 0.652 0.324 0.024
#> GSM123239     3  0.6062      0.486 0.000 0.384 0.616
#> GSM123240     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123241     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123242     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123182     2  0.3573      0.285 0.004 0.876 0.120
#> GSM123183     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123184     2  0.6302      0.252 0.000 0.520 0.480
#> GSM123185     3  0.5968      0.500 0.000 0.364 0.636
#> GSM123186     2  0.8143      0.300 0.360 0.560 0.080
#> GSM123187     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123188     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123189     2  0.4002      0.265 0.160 0.840 0.000
#> GSM123190     3  0.6302      0.399 0.000 0.480 0.520
#> GSM123191     2  0.6192     -0.193 0.420 0.580 0.000
#> GSM123192     2  0.6302      0.113 0.480 0.520 0.000
#> GSM123193     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123194     2  0.6154     -0.155 0.408 0.592 0.000
#> GSM123195     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123196     1  0.6295      0.326 0.528 0.472 0.000
#> GSM123197     3  0.8720     -0.263 0.108 0.412 0.480
#> GSM123198     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123199     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123200     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123201     2  0.8859     -0.164 0.400 0.480 0.120
#> GSM123202     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123203     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123204     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123205     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123206     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123207     3  0.2448      0.647 0.076 0.000 0.924
#> GSM123208     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123209     3  0.0000      0.708 0.000 0.000 1.000
#> GSM123210     1  0.0000      0.812 1.000 0.000 0.000
#> GSM123211     1  0.0892      0.790 0.980 0.020 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.2149      0.827 0.000 0.088 0.000 0.912
#> GSM123213     4  0.4776      0.436 0.000 0.376 0.000 0.624
#> GSM123214     4  0.2401      0.827 0.000 0.092 0.004 0.904
#> GSM123215     4  0.2401      0.827 0.000 0.092 0.004 0.904
#> GSM123216     1  0.0336      0.977 0.992 0.000 0.000 0.008
#> GSM123217     1  0.0188      0.978 0.996 0.000 0.004 0.000
#> GSM123218     3  0.2281      0.754 0.000 0.096 0.904 0.000
#> GSM123219     4  0.5666      0.567 0.036 0.000 0.348 0.616
#> GSM123220     1  0.0000      0.978 1.000 0.000 0.000 0.000
#> GSM123221     1  0.0336      0.977 0.992 0.000 0.000 0.008
#> GSM123222     1  0.0921      0.961 0.972 0.000 0.000 0.028
#> GSM123223     2  0.1716      0.893 0.000 0.936 0.000 0.064
#> GSM123224     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> GSM123225     1  0.0336      0.977 0.992 0.000 0.000 0.008
#> GSM123226     3  0.4697      0.642 0.356 0.000 0.644 0.000
#> GSM123227     3  0.2803      0.749 0.012 0.008 0.900 0.080
#> GSM123228     1  0.1902      0.920 0.932 0.000 0.004 0.064
#> GSM123229     3  0.4741      0.681 0.328 0.000 0.668 0.004
#> GSM123230     3  0.4800      0.665 0.340 0.000 0.656 0.004
#> GSM123231     3  0.2469      0.751 0.000 0.108 0.892 0.000
#> GSM123232     1  0.0188      0.978 0.996 0.000 0.004 0.000
#> GSM123233     2  0.3521      0.872 0.000 0.864 0.052 0.084
#> GSM123234     3  0.5182      0.712 0.288 0.000 0.684 0.028
#> GSM123235     3  0.2480      0.784 0.088 0.000 0.904 0.008
#> GSM123236     2  0.4762      0.811 0.004 0.796 0.120 0.080
#> GSM123237     1  0.0188      0.978 0.996 0.000 0.004 0.000
#> GSM123238     4  0.4761      0.444 0.372 0.000 0.000 0.628
#> GSM123239     2  0.2342      0.893 0.000 0.912 0.008 0.080
#> GSM123240     1  0.0336      0.977 0.992 0.000 0.000 0.008
#> GSM123241     1  0.0000      0.978 1.000 0.000 0.000 0.000
#> GSM123242     4  0.2466      0.826 0.000 0.096 0.004 0.900
#> GSM123182     4  0.3688      0.691 0.000 0.000 0.208 0.792
#> GSM123183     4  0.2149      0.827 0.000 0.088 0.000 0.912
#> GSM123184     4  0.2401      0.827 0.000 0.092 0.004 0.904
#> GSM123185     2  0.5343      0.738 0.000 0.708 0.052 0.240
#> GSM123186     4  0.5782      0.686 0.052 0.012 0.240 0.696
#> GSM123187     2  0.0336      0.937 0.000 0.992 0.000 0.008
#> GSM123188     1  0.0188      0.978 0.996 0.000 0.004 0.000
#> GSM123189     3  0.1302      0.743 0.000 0.000 0.956 0.044
#> GSM123190     3  0.3219      0.710 0.000 0.164 0.836 0.000
#> GSM123191     3  0.2101      0.777 0.060 0.000 0.928 0.012
#> GSM123192     4  0.5750      0.635 0.216 0.000 0.088 0.696
#> GSM123193     1  0.2843      0.861 0.892 0.000 0.088 0.020
#> GSM123194     3  0.3894      0.744 0.088 0.000 0.844 0.068
#> GSM123195     2  0.0336      0.937 0.000 0.992 0.000 0.008
#> GSM123196     3  0.3831      0.778 0.204 0.000 0.792 0.004
#> GSM123197     4  0.2334      0.826 0.004 0.088 0.000 0.908
#> GSM123198     2  0.0188      0.937 0.000 0.996 0.004 0.000
#> GSM123199     1  0.0895      0.966 0.976 0.000 0.004 0.020
#> GSM123200     2  0.0188      0.938 0.000 0.996 0.000 0.004
#> GSM123201     3  0.5942      0.760 0.160 0.028 0.732 0.080
#> GSM123202     2  0.0336      0.937 0.000 0.992 0.000 0.008
#> GSM123203     1  0.0895      0.966 0.976 0.000 0.004 0.020
#> GSM123204     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0336      0.937 0.000 0.992 0.000 0.008
#> GSM123207     2  0.3292      0.878 0.004 0.880 0.036 0.080
#> GSM123208     2  0.0188      0.938 0.000 0.996 0.000 0.004
#> GSM123209     2  0.0000      0.938 0.000 1.000 0.000 0.000
#> GSM123210     1  0.0188      0.978 0.996 0.000 0.000 0.004
#> GSM123211     1  0.0336      0.977 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.0290     0.8119 0.000 0.000 0.000 0.992 0.008
#> GSM123213     4  0.2864     0.7236 0.000 0.112 0.000 0.864 0.024
#> GSM123214     4  0.1356     0.8136 0.000 0.004 0.012 0.956 0.028
#> GSM123215     4  0.1195     0.8142 0.000 0.000 0.012 0.960 0.028
#> GSM123216     1  0.0324     0.8956 0.992 0.000 0.004 0.004 0.000
#> GSM123217     1  0.1364     0.8949 0.952 0.000 0.012 0.000 0.036
#> GSM123218     3  0.3236     0.5747 0.000 0.020 0.828 0.000 0.152
#> GSM123219     3  0.6610    -0.1929 0.032 0.000 0.456 0.412 0.100
#> GSM123220     1  0.0955     0.8979 0.968 0.000 0.004 0.000 0.028
#> GSM123221     1  0.1331     0.8739 0.952 0.000 0.000 0.040 0.008
#> GSM123222     1  0.3266     0.7498 0.796 0.000 0.004 0.000 0.200
#> GSM123223     2  0.0992     0.9244 0.000 0.968 0.000 0.008 0.024
#> GSM123224     1  0.0000     0.8971 1.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.0000     0.8971 1.000 0.000 0.000 0.000 0.000
#> GSM123226     3  0.5294     0.3618 0.380 0.000 0.564 0.000 0.056
#> GSM123227     5  0.2462     0.6344 0.008 0.000 0.112 0.000 0.880
#> GSM123228     1  0.4559     0.2053 0.512 0.000 0.008 0.000 0.480
#> GSM123229     3  0.3885     0.5692 0.268 0.000 0.724 0.000 0.008
#> GSM123230     3  0.4639     0.4913 0.344 0.000 0.632 0.000 0.024
#> GSM123231     3  0.3704     0.5727 0.000 0.088 0.820 0.000 0.092
#> GSM123232     1  0.1892     0.8769 0.916 0.000 0.004 0.000 0.080
#> GSM123233     5  0.4029     0.5568 0.000 0.316 0.004 0.000 0.680
#> GSM123234     3  0.6326     0.1653 0.136 0.000 0.452 0.004 0.408
#> GSM123235     3  0.1364     0.6202 0.036 0.000 0.952 0.000 0.012
#> GSM123236     5  0.2672     0.7021 0.004 0.116 0.008 0.000 0.872
#> GSM123237     1  0.0955     0.8979 0.968 0.000 0.004 0.000 0.028
#> GSM123238     4  0.3957     0.5424 0.280 0.000 0.000 0.712 0.008
#> GSM123239     2  0.3999     0.3250 0.000 0.656 0.000 0.000 0.344
#> GSM123240     1  0.0000     0.8971 1.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.0771     0.8988 0.976 0.000 0.004 0.000 0.020
#> GSM123242     4  0.1356     0.8136 0.000 0.004 0.012 0.956 0.028
#> GSM123182     5  0.6631     0.0267 0.000 0.000 0.236 0.324 0.440
#> GSM123183     4  0.0290     0.8119 0.000 0.000 0.000 0.992 0.008
#> GSM123184     4  0.1195     0.8142 0.000 0.000 0.012 0.960 0.028
#> GSM123185     5  0.5443     0.6392 0.000 0.140 0.004 0.184 0.672
#> GSM123186     4  0.5506     0.4873 0.000 0.000 0.284 0.616 0.100
#> GSM123187     2  0.0290     0.9495 0.000 0.992 0.000 0.000 0.008
#> GSM123188     1  0.0955     0.8979 0.968 0.000 0.004 0.000 0.028
#> GSM123189     3  0.1892     0.5796 0.000 0.000 0.916 0.004 0.080
#> GSM123190     3  0.5759     0.4042 0.000 0.224 0.616 0.000 0.160
#> GSM123191     3  0.1942     0.5919 0.012 0.000 0.920 0.000 0.068
#> GSM123192     4  0.7629     0.2385 0.356 0.000 0.140 0.412 0.092
#> GSM123193     1  0.4930     0.6111 0.736 0.000 0.168 0.016 0.080
#> GSM123194     3  0.5118     0.0724 0.040 0.000 0.548 0.000 0.412
#> GSM123195     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.3013     0.6157 0.160 0.000 0.832 0.000 0.008
#> GSM123197     4  0.0693     0.8081 0.008 0.000 0.000 0.980 0.012
#> GSM123198     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123199     1  0.2707     0.8378 0.860 0.000 0.008 0.000 0.132
#> GSM123200     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.2677     0.6291 0.016 0.000 0.112 0.000 0.872
#> GSM123202     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123203     1  0.2563     0.8473 0.872 0.000 0.008 0.000 0.120
#> GSM123204     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.3003     0.6962 0.000 0.188 0.000 0.000 0.812
#> GSM123208     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.0000     0.9563 0.000 1.000 0.000 0.000 0.000
#> GSM123210     1  0.0162     0.8978 0.996 0.000 0.000 0.000 0.004
#> GSM123211     1  0.1408     0.8712 0.948 0.000 0.000 0.044 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.2831      0.815 0.000 0.000 0.048 0.872 0.016 0.064
#> GSM123213     4  0.1970      0.819 0.000 0.060 0.000 0.912 0.000 0.028
#> GSM123214     4  0.1701      0.846 0.000 0.008 0.000 0.920 0.000 0.072
#> GSM123215     4  0.1701      0.846 0.000 0.008 0.000 0.920 0.000 0.072
#> GSM123216     1  0.2052      0.847 0.912 0.000 0.028 0.000 0.004 0.056
#> GSM123217     1  0.1801      0.848 0.924 0.000 0.004 0.000 0.016 0.056
#> GSM123218     3  0.3027      0.670 0.000 0.000 0.824 0.000 0.148 0.028
#> GSM123219     6  0.2583      0.749 0.008 0.000 0.056 0.052 0.000 0.884
#> GSM123220     1  0.1369      0.859 0.952 0.000 0.016 0.000 0.016 0.016
#> GSM123221     1  0.4722      0.710 0.764 0.000 0.072 0.068 0.016 0.080
#> GSM123222     1  0.4737      0.634 0.664 0.000 0.048 0.000 0.268 0.020
#> GSM123223     2  0.1753      0.867 0.000 0.912 0.000 0.084 0.000 0.004
#> GSM123224     1  0.1334      0.859 0.948 0.000 0.032 0.000 0.000 0.020
#> GSM123225     1  0.1257      0.859 0.952 0.000 0.028 0.000 0.000 0.020
#> GSM123226     3  0.5430      0.211 0.416 0.000 0.500 0.000 0.056 0.028
#> GSM123227     5  0.0767      0.846 0.004 0.000 0.008 0.000 0.976 0.012
#> GSM123228     1  0.4420      0.663 0.692 0.000 0.020 0.000 0.256 0.032
#> GSM123229     3  0.2006      0.689 0.104 0.000 0.892 0.000 0.000 0.004
#> GSM123230     3  0.3750      0.623 0.200 0.000 0.764 0.000 0.016 0.020
#> GSM123231     3  0.3703      0.670 0.000 0.072 0.816 0.000 0.084 0.028
#> GSM123232     1  0.2831      0.826 0.868 0.000 0.016 0.000 0.084 0.032
#> GSM123233     5  0.4402      0.712 0.000 0.188 0.000 0.080 0.724 0.008
#> GSM123234     3  0.5283      0.363 0.064 0.000 0.580 0.004 0.336 0.016
#> GSM123235     3  0.1780      0.699 0.048 0.000 0.924 0.000 0.000 0.028
#> GSM123236     5  0.0653      0.851 0.004 0.012 0.000 0.000 0.980 0.004
#> GSM123237     1  0.1478      0.858 0.944 0.000 0.004 0.000 0.020 0.032
#> GSM123238     4  0.5762      0.571 0.164 0.000 0.076 0.664 0.016 0.080
#> GSM123239     2  0.3881      0.245 0.000 0.600 0.000 0.000 0.396 0.004
#> GSM123240     1  0.1421      0.858 0.944 0.000 0.028 0.000 0.000 0.028
#> GSM123241     1  0.1605      0.863 0.940 0.000 0.016 0.000 0.012 0.032
#> GSM123242     4  0.1701      0.846 0.000 0.008 0.000 0.920 0.000 0.072
#> GSM123182     6  0.3758      0.667 0.000 0.000 0.004 0.176 0.048 0.772
#> GSM123183     4  0.2831      0.815 0.000 0.000 0.048 0.872 0.016 0.064
#> GSM123184     4  0.1701      0.846 0.000 0.008 0.000 0.920 0.000 0.072
#> GSM123185     5  0.4398      0.699 0.000 0.044 0.000 0.220 0.716 0.020
#> GSM123186     6  0.2527      0.751 0.004 0.000 0.032 0.084 0.000 0.880
#> GSM123187     2  0.0972      0.921 0.000 0.964 0.000 0.028 0.000 0.008
#> GSM123188     1  0.1232      0.859 0.956 0.000 0.004 0.000 0.016 0.024
#> GSM123189     3  0.3810      0.299 0.000 0.000 0.572 0.000 0.000 0.428
#> GSM123190     3  0.6089      0.446 0.000 0.220 0.544 0.000 0.208 0.028
#> GSM123191     3  0.3221      0.532 0.000 0.000 0.736 0.000 0.000 0.264
#> GSM123192     6  0.4006      0.702 0.104 0.000 0.028 0.052 0.012 0.804
#> GSM123193     6  0.4510      0.381 0.384 0.000 0.012 0.012 0.004 0.588
#> GSM123194     6  0.3526      0.703 0.088 0.000 0.080 0.000 0.012 0.820
#> GSM123195     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.1285      0.702 0.052 0.000 0.944 0.000 0.000 0.004
#> GSM123197     4  0.3210      0.806 0.008 0.000 0.056 0.856 0.016 0.064
#> GSM123198     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123199     1  0.3428      0.799 0.820 0.000 0.020 0.000 0.128 0.032
#> GSM123200     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.0881      0.843 0.008 0.000 0.008 0.000 0.972 0.012
#> GSM123202     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123203     1  0.3428      0.799 0.820 0.000 0.020 0.000 0.128 0.032
#> GSM123204     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123206     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1757      0.835 0.000 0.076 0.008 0.000 0.916 0.000
#> GSM123208     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.0000      0.946 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123210     1  0.1793      0.854 0.928 0.000 0.032 0.004 0.000 0.036
#> GSM123211     1  0.4322      0.745 0.788 0.000 0.036 0.064 0.016 0.096

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) k
#> CV:skmeans 56          0.05592 2
#> CV:skmeans 32          0.00922 3
#> CV:skmeans 59          0.09529 4
#> CV:skmeans 50          0.04082 5
#> CV:skmeans 55          0.01371 6

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


CV:pam

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.837           0.905       0.961         0.4928 0.515   0.515
#> 3 3 0.544           0.778       0.852         0.3069 0.692   0.467
#> 4 4 0.691           0.785       0.830         0.0822 0.908   0.745
#> 5 5 0.737           0.691       0.835         0.1107 0.826   0.485
#> 6 6 0.679           0.606       0.789         0.0414 0.973   0.873

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
#> GSM123212     2  0.4939     0.8699 0.108 0.892
#> GSM123213     2  0.0000     0.9728 0.000 1.000
#> GSM123214     2  0.0000     0.9728 0.000 1.000
#> GSM123215     2  0.0000     0.9728 0.000 1.000
#> GSM123216     1  0.0000     0.9466 1.000 0.000
#> GSM123217     1  0.0000     0.9466 1.000 0.000
#> GSM123218     1  0.7219     0.7511 0.800 0.200
#> GSM123219     1  0.0000     0.9466 1.000 0.000
#> GSM123220     1  0.0000     0.9466 1.000 0.000
#> GSM123221     1  0.0000     0.9466 1.000 0.000
#> GSM123222     1  0.0000     0.9466 1.000 0.000
#> GSM123223     2  0.0000     0.9728 0.000 1.000
#> GSM123224     1  0.0000     0.9466 1.000 0.000
#> GSM123225     1  0.0000     0.9466 1.000 0.000
#> GSM123226     1  0.0000     0.9466 1.000 0.000
#> GSM123227     1  0.0000     0.9466 1.000 0.000
#> GSM123228     1  0.0000     0.9466 1.000 0.000
#> GSM123229     1  0.0000     0.9466 1.000 0.000
#> GSM123230     1  0.0000     0.9466 1.000 0.000
#> GSM123231     1  0.8443     0.6461 0.728 0.272
#> GSM123232     1  0.0000     0.9466 1.000 0.000
#> GSM123233     2  0.0000     0.9728 0.000 1.000
#> GSM123234     1  0.0000     0.9466 1.000 0.000
#> GSM123235     1  0.0000     0.9466 1.000 0.000
#> GSM123236     2  0.8861     0.5258 0.304 0.696
#> GSM123237     1  0.0000     0.9466 1.000 0.000
#> GSM123238     1  0.0000     0.9466 1.000 0.000
#> GSM123239     2  0.0376     0.9705 0.004 0.996
#> GSM123240     1  0.0000     0.9466 1.000 0.000
#> GSM123241     1  0.0000     0.9466 1.000 0.000
#> GSM123242     2  0.0000     0.9728 0.000 1.000
#> GSM123182     2  0.0376     0.9705 0.004 0.996
#> GSM123183     2  0.4939     0.8699 0.108 0.892
#> GSM123184     2  0.0000     0.9728 0.000 1.000
#> GSM123185     2  0.0000     0.9728 0.000 1.000
#> GSM123186     1  0.9552     0.3876 0.624 0.376
#> GSM123187     2  0.0000     0.9728 0.000 1.000
#> GSM123188     1  0.0000     0.9466 1.000 0.000
#> GSM123189     1  0.0000     0.9466 1.000 0.000
#> GSM123190     1  0.9000     0.5666 0.684 0.316
#> GSM123191     1  0.4431     0.8696 0.908 0.092
#> GSM123192     1  0.0000     0.9466 1.000 0.000
#> GSM123193     1  0.0000     0.9466 1.000 0.000
#> GSM123194     1  0.4161     0.8792 0.916 0.084
#> GSM123195     2  0.0000     0.9728 0.000 1.000
#> GSM123196     1  0.0000     0.9466 1.000 0.000
#> GSM123197     1  0.9996     0.0356 0.512 0.488
#> GSM123198     2  0.0000     0.9728 0.000 1.000
#> GSM123199     1  0.0000     0.9466 1.000 0.000
#> GSM123200     2  0.0000     0.9728 0.000 1.000
#> GSM123201     1  0.0000     0.9466 1.000 0.000
#> GSM123202     2  0.0000     0.9728 0.000 1.000
#> GSM123203     1  0.0000     0.9466 1.000 0.000
#> GSM123204     2  0.0000     0.9728 0.000 1.000
#> GSM123205     2  0.0000     0.9728 0.000 1.000
#> GSM123206     2  0.0000     0.9728 0.000 1.000
#> GSM123207     2  0.2423     0.9411 0.040 0.960
#> GSM123208     2  0.0000     0.9728 0.000 1.000
#> GSM123209     2  0.0376     0.9705 0.004 0.996
#> GSM123210     1  0.0000     0.9466 1.000 0.000
#> GSM123211     1  0.0000     0.9466 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.5581     0.7970 0.040 0.168 0.792
#> GSM123213     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123214     2  0.3752     0.8297 0.000 0.856 0.144
#> GSM123215     2  0.3752     0.8297 0.000 0.856 0.144
#> GSM123216     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123217     1  0.0237     0.8449 0.996 0.000 0.004
#> GSM123218     3  0.4128     0.8253 0.012 0.132 0.856
#> GSM123219     3  0.3879     0.7900 0.152 0.000 0.848
#> GSM123220     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123221     1  0.5650     0.6530 0.688 0.000 0.312
#> GSM123222     1  0.5650     0.6530 0.688 0.000 0.312
#> GSM123223     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123224     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123225     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123226     1  0.5650     0.6543 0.688 0.000 0.312
#> GSM123227     1  0.5859     0.6080 0.656 0.000 0.344
#> GSM123228     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123229     3  0.4062     0.7807 0.164 0.000 0.836
#> GSM123230     1  0.5650     0.6530 0.688 0.000 0.312
#> GSM123231     3  0.4033     0.8235 0.008 0.136 0.856
#> GSM123232     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123233     2  0.0661     0.9151 0.004 0.988 0.008
#> GSM123234     1  0.5760     0.6291 0.672 0.000 0.328
#> GSM123235     3  0.3879     0.7900 0.152 0.000 0.848
#> GSM123236     3  0.8512     0.6366 0.212 0.176 0.612
#> GSM123237     1  0.0237     0.8449 0.996 0.000 0.004
#> GSM123238     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123239     3  0.4629     0.7984 0.004 0.188 0.808
#> GSM123240     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123241     1  0.5465     0.6781 0.712 0.000 0.288
#> GSM123242     3  0.5216     0.7258 0.000 0.260 0.740
#> GSM123182     3  0.3752     0.8187 0.000 0.144 0.856
#> GSM123183     3  0.5956     0.2443 0.004 0.324 0.672
#> GSM123184     2  0.3752     0.8297 0.000 0.856 0.144
#> GSM123185     3  0.4834     0.7882 0.004 0.204 0.792
#> GSM123186     3  0.4164     0.7956 0.144 0.008 0.848
#> GSM123187     2  0.6215     0.0185 0.000 0.572 0.428
#> GSM123188     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123189     3  0.3879     0.7900 0.152 0.000 0.848
#> GSM123190     3  0.4099     0.8228 0.008 0.140 0.852
#> GSM123191     3  0.4609     0.8340 0.052 0.092 0.856
#> GSM123192     3  0.5216     0.6986 0.260 0.000 0.740
#> GSM123193     1  0.5431     0.6790 0.716 0.000 0.284
#> GSM123194     3  0.4660     0.8299 0.072 0.072 0.856
#> GSM123195     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123196     3  0.3879     0.7900 0.152 0.000 0.848
#> GSM123197     3  0.3983     0.7983 0.144 0.004 0.852
#> GSM123198     2  0.3267     0.8037 0.000 0.884 0.116
#> GSM123199     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123200     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123201     1  0.5859     0.6080 0.656 0.000 0.344
#> GSM123202     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123203     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123204     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123205     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123206     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123207     3  0.9239     0.4824 0.328 0.172 0.500
#> GSM123208     2  0.0424     0.9179 0.000 0.992 0.008
#> GSM123209     3  0.4399     0.7983 0.000 0.188 0.812
#> GSM123210     1  0.0000     0.8469 1.000 0.000 0.000
#> GSM123211     1  0.0000     0.8469 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.5323      0.514 0.020 0.000 0.352 0.628
#> GSM123213     4  0.6845      0.479 0.000 0.236 0.168 0.596
#> GSM123214     4  0.0188      0.797 0.000 0.004 0.000 0.996
#> GSM123215     4  0.0188      0.797 0.000 0.004 0.000 0.996
#> GSM123216     1  0.0707      0.826 0.980 0.000 0.020 0.000
#> GSM123217     1  0.1118      0.821 0.964 0.000 0.036 0.000
#> GSM123218     3  0.0707      0.852 0.000 0.020 0.980 0.000
#> GSM123219     3  0.0000      0.849 0.000 0.000 1.000 0.000
#> GSM123220     1  0.0000      0.829 1.000 0.000 0.000 0.000
#> GSM123221     1  0.4632      0.669 0.688 0.000 0.308 0.004
#> GSM123222     1  0.4632      0.669 0.688 0.000 0.308 0.004
#> GSM123223     2  0.2760      0.830 0.000 0.872 0.000 0.128
#> GSM123224     1  0.0000      0.829 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0592      0.827 0.984 0.000 0.016 0.000
#> GSM123226     1  0.4643      0.654 0.656 0.000 0.344 0.000
#> GSM123227     1  0.4920      0.618 0.628 0.000 0.368 0.004
#> GSM123228     1  0.0707      0.826 0.980 0.000 0.020 0.000
#> GSM123229     3  0.1118      0.845 0.036 0.000 0.964 0.000
#> GSM123230     1  0.4632      0.669 0.688 0.000 0.308 0.004
#> GSM123231     3  0.0707      0.852 0.000 0.020 0.980 0.000
#> GSM123232     1  0.0336      0.829 0.992 0.000 0.008 0.000
#> GSM123233     3  0.4648      0.729 0.016 0.232 0.748 0.004
#> GSM123234     1  0.4720      0.648 0.672 0.000 0.324 0.004
#> GSM123235     3  0.0707      0.849 0.020 0.000 0.980 0.000
#> GSM123236     3  0.7292      0.487 0.220 0.216 0.560 0.004
#> GSM123237     1  0.1118      0.821 0.964 0.000 0.036 0.000
#> GSM123238     1  0.0188      0.829 0.996 0.000 0.000 0.004
#> GSM123239     3  0.4408      0.733 0.008 0.232 0.756 0.004
#> GSM123240     1  0.0000      0.829 1.000 0.000 0.000 0.000
#> GSM123241     1  0.4522      0.680 0.680 0.000 0.320 0.000
#> GSM123242     4  0.4088      0.605 0.000 0.232 0.004 0.764
#> GSM123182     3  0.0707      0.852 0.000 0.020 0.980 0.000
#> GSM123183     4  0.0000      0.795 0.000 0.000 0.000 1.000
#> GSM123184     4  0.0188      0.797 0.000 0.004 0.000 0.996
#> GSM123185     3  0.4648      0.729 0.016 0.232 0.748 0.004
#> GSM123186     3  0.0000      0.849 0.000 0.000 1.000 0.000
#> GSM123187     3  0.3907      0.737 0.000 0.232 0.768 0.000
#> GSM123188     1  0.0707      0.826 0.980 0.000 0.020 0.000
#> GSM123189     3  0.0000      0.849 0.000 0.000 1.000 0.000
#> GSM123190     3  0.1118      0.849 0.000 0.036 0.964 0.000
#> GSM123191     3  0.0707      0.849 0.020 0.000 0.980 0.000
#> GSM123192     3  0.2589      0.758 0.116 0.000 0.884 0.000
#> GSM123193     1  0.4522      0.681 0.680 0.000 0.320 0.000
#> GSM123194     3  0.0000      0.849 0.000 0.000 1.000 0.000
#> GSM123195     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123196     3  0.0707      0.849 0.020 0.000 0.980 0.000
#> GSM123197     3  0.1305      0.842 0.036 0.000 0.960 0.004
#> GSM123198     2  0.1474      0.903 0.000 0.948 0.052 0.000
#> GSM123199     1  0.0188      0.829 0.996 0.000 0.000 0.004
#> GSM123200     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123201     1  0.4837      0.621 0.648 0.000 0.348 0.004
#> GSM123202     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123203     1  0.0188      0.829 0.996 0.000 0.000 0.004
#> GSM123204     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123207     3  0.7778      0.283 0.340 0.212 0.444 0.004
#> GSM123208     2  0.0000      0.971 0.000 1.000 0.000 0.000
#> GSM123209     3  0.3907      0.737 0.000 0.232 0.768 0.000
#> GSM123210     1  0.0188      0.829 0.996 0.000 0.000 0.004
#> GSM123211     1  0.0188      0.829 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.4706     0.4753 0.004 0.000 0.344 0.632 0.020
#> GSM123213     4  0.5824     0.5534 0.000 0.012 0.088 0.596 0.304
#> GSM123214     4  0.0000     0.7859 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000     0.7859 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0162     0.8515 0.996 0.000 0.004 0.000 0.000
#> GSM123217     1  0.0162     0.8515 0.996 0.000 0.004 0.000 0.000
#> GSM123218     3  0.0162     0.8701 0.000 0.000 0.996 0.000 0.004
#> GSM123219     3  0.0510     0.8716 0.016 0.000 0.984 0.000 0.000
#> GSM123220     1  0.0510     0.8440 0.984 0.000 0.000 0.000 0.016
#> GSM123221     5  0.4192     0.6310 0.404 0.000 0.000 0.000 0.596
#> GSM123222     5  0.4182     0.6339 0.400 0.000 0.000 0.000 0.600
#> GSM123223     2  0.6318     0.5206 0.000 0.556 0.016 0.128 0.300
#> GSM123224     1  0.0510     0.8440 0.984 0.000 0.000 0.000 0.016
#> GSM123225     1  0.0000     0.8516 1.000 0.000 0.000 0.000 0.000
#> GSM123226     3  0.4446    -0.1091 0.476 0.000 0.520 0.000 0.004
#> GSM123227     5  0.4644     0.6518 0.280 0.000 0.040 0.000 0.680
#> GSM123228     1  0.0324     0.8502 0.992 0.000 0.004 0.000 0.004
#> GSM123229     3  0.1018     0.8662 0.016 0.000 0.968 0.000 0.016
#> GSM123230     5  0.4192     0.6310 0.404 0.000 0.000 0.000 0.596
#> GSM123231     3  0.0162     0.8701 0.000 0.000 0.996 0.000 0.004
#> GSM123232     1  0.0404     0.8491 0.988 0.000 0.000 0.000 0.012
#> GSM123233     5  0.0912     0.5121 0.000 0.012 0.016 0.000 0.972
#> GSM123234     5  0.4147     0.6589 0.316 0.000 0.008 0.000 0.676
#> GSM123235     3  0.0671     0.8701 0.004 0.000 0.980 0.000 0.016
#> GSM123236     5  0.3730     0.5001 0.048 0.012 0.112 0.000 0.828
#> GSM123237     1  0.0324     0.8502 0.992 0.000 0.004 0.000 0.004
#> GSM123238     5  0.4192     0.6310 0.404 0.000 0.000 0.000 0.596
#> GSM123239     5  0.3163     0.3662 0.000 0.012 0.164 0.000 0.824
#> GSM123240     1  0.0510     0.8440 0.984 0.000 0.000 0.000 0.016
#> GSM123241     1  0.4264     0.3938 0.620 0.000 0.376 0.000 0.004
#> GSM123242     4  0.4624     0.5945 0.000 0.012 0.016 0.676 0.296
#> GSM123182     3  0.0162     0.8701 0.000 0.000 0.996 0.000 0.004
#> GSM123183     4  0.0000     0.7859 0.000 0.000 0.000 1.000 0.000
#> GSM123184     4  0.0000     0.7859 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.1597     0.5071 0.000 0.012 0.048 0.000 0.940
#> GSM123186     3  0.0510     0.8716 0.016 0.000 0.984 0.000 0.000
#> GSM123187     3  0.4193     0.5460 0.000 0.012 0.684 0.000 0.304
#> GSM123188     1  0.0162     0.8515 0.996 0.000 0.004 0.000 0.000
#> GSM123189     3  0.0510     0.8716 0.016 0.000 0.984 0.000 0.000
#> GSM123190     3  0.2338     0.7925 0.000 0.004 0.884 0.000 0.112
#> GSM123191     3  0.0671     0.8701 0.004 0.000 0.980 0.000 0.016
#> GSM123192     3  0.2377     0.7824 0.128 0.000 0.872 0.000 0.000
#> GSM123193     1  0.4305     0.0898 0.512 0.000 0.488 0.000 0.000
#> GSM123194     3  0.0510     0.8716 0.016 0.000 0.984 0.000 0.000
#> GSM123195     2  0.0000     0.8253 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.0671     0.8701 0.004 0.000 0.980 0.000 0.016
#> GSM123197     5  0.4331     0.3419 0.004 0.000 0.400 0.000 0.596
#> GSM123198     2  0.5338     0.5438 0.000 0.544 0.056 0.000 0.400
#> GSM123199     5  0.4182     0.6311 0.400 0.000 0.000 0.000 0.600
#> GSM123200     2  0.0000     0.8253 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.4428     0.6599 0.268 0.000 0.032 0.000 0.700
#> GSM123202     2  0.3527     0.7439 0.000 0.792 0.016 0.000 0.192
#> GSM123203     5  0.4182     0.6311 0.400 0.000 0.000 0.000 0.600
#> GSM123204     2  0.0000     0.8253 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.3209     0.7611 0.000 0.812 0.008 0.000 0.180
#> GSM123206     2  0.0000     0.8253 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.0324     0.5352 0.004 0.004 0.000 0.000 0.992
#> GSM123208     2  0.0000     0.8253 0.000 1.000 0.000 0.000 0.000
#> GSM123209     3  0.4173     0.5511 0.000 0.012 0.688 0.000 0.300
#> GSM123210     1  0.3366     0.4561 0.768 0.000 0.000 0.000 0.232
#> GSM123211     5  0.4192     0.6310 0.404 0.000 0.000 0.000 0.596

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.3690     0.3676 0.000 0.000 0.288 0.700 0.012 0.000
#> GSM123213     4  0.4703    -0.3009 0.000 0.000 0.044 0.492 0.000 0.464
#> GSM123214     4  0.2527     0.6661 0.000 0.000 0.000 0.832 0.000 0.168
#> GSM123215     4  0.2527     0.6661 0.000 0.000 0.000 0.832 0.000 0.168
#> GSM123216     1  0.0937     0.8598 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM123217     1  0.0000     0.8660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0000     0.7803 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123219     3  0.1714     0.7754 0.092 0.000 0.908 0.000 0.000 0.000
#> GSM123220     1  0.0000     0.8660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123221     5  0.3950     0.6973 0.240 0.000 0.040 0.000 0.720 0.000
#> GSM123222     5  0.3653     0.6877 0.300 0.000 0.008 0.000 0.692 0.000
#> GSM123223     2  0.3854     0.0473 0.000 0.536 0.000 0.000 0.000 0.464
#> GSM123224     1  0.1007     0.8580 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM123225     1  0.0937     0.8598 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM123226     3  0.5274     0.1041 0.408 0.000 0.492 0.000 0.100 0.000
#> GSM123227     5  0.1219     0.6986 0.048 0.000 0.004 0.000 0.948 0.000
#> GSM123228     1  0.1814     0.8255 0.900 0.000 0.000 0.000 0.100 0.000
#> GSM123229     3  0.1700     0.7626 0.048 0.000 0.928 0.000 0.024 0.000
#> GSM123230     5  0.4769     0.6583 0.240 0.000 0.104 0.000 0.656 0.000
#> GSM123231     3  0.0000     0.7803 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123232     1  0.1814     0.8255 0.900 0.000 0.000 0.000 0.100 0.000
#> GSM123233     5  0.3266     0.5251 0.000 0.000 0.000 0.000 0.728 0.272
#> GSM123234     5  0.3189     0.7279 0.184 0.000 0.020 0.000 0.796 0.000
#> GSM123235     3  0.1075     0.7722 0.000 0.000 0.952 0.000 0.048 0.000
#> GSM123236     5  0.4474     0.5721 0.048 0.000 0.028 0.000 0.724 0.200
#> GSM123237     1  0.1814     0.8255 0.900 0.000 0.000 0.000 0.100 0.000
#> GSM123238     5  0.4319     0.6739 0.108 0.000 0.000 0.168 0.724 0.000
#> GSM123239     5  0.5192     0.2577 0.000 0.000 0.116 0.000 0.576 0.308
#> GSM123240     1  0.0937     0.8598 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM123241     1  0.4793     0.3947 0.628 0.000 0.288 0.000 0.084 0.000
#> GSM123242     6  0.3695    -0.1133 0.000 0.000 0.000 0.376 0.000 0.624
#> GSM123182     3  0.1983     0.7593 0.000 0.000 0.908 0.000 0.020 0.072
#> GSM123183     4  0.0260     0.6032 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM123184     4  0.2527     0.6661 0.000 0.000 0.000 0.832 0.000 0.168
#> GSM123185     5  0.4038     0.5610 0.000 0.000 0.044 0.000 0.712 0.244
#> GSM123186     3  0.1714     0.7754 0.092 0.000 0.908 0.000 0.000 0.000
#> GSM123187     3  0.4331     0.1834 0.000 0.000 0.516 0.000 0.020 0.464
#> GSM123188     1  0.0000     0.8660 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0000     0.7803 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123190     3  0.3592     0.6127 0.000 0.000 0.740 0.000 0.240 0.020
#> GSM123191     3  0.1444     0.7625 0.000 0.000 0.928 0.000 0.072 0.000
#> GSM123192     3  0.3284     0.7008 0.196 0.000 0.784 0.000 0.020 0.000
#> GSM123193     3  0.3867     0.1418 0.488 0.000 0.512 0.000 0.000 0.000
#> GSM123194     3  0.1714     0.7754 0.092 0.000 0.908 0.000 0.000 0.000
#> GSM123195     2  0.0000     0.7639 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.0000     0.7803 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123197     5  0.4701     0.5996 0.000 0.000 0.148 0.168 0.684 0.000
#> GSM123198     6  0.2632     0.4927 0.000 0.004 0.000 0.000 0.164 0.832
#> GSM123199     5  0.2941     0.6797 0.220 0.000 0.000 0.000 0.780 0.000
#> GSM123200     2  0.0146     0.7625 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123201     5  0.1075     0.6992 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM123202     2  0.2969     0.5405 0.000 0.776 0.000 0.000 0.000 0.224
#> GSM123203     5  0.2941     0.6797 0.220 0.000 0.000 0.000 0.780 0.000
#> GSM123204     2  0.3684     0.3707 0.000 0.628 0.000 0.000 0.000 0.372
#> GSM123205     6  0.4573     0.2950 0.000 0.236 0.000 0.000 0.088 0.676
#> GSM123206     2  0.0000     0.7639 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.2340     0.6476 0.000 0.000 0.000 0.000 0.852 0.148
#> GSM123208     2  0.0000     0.7639 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     3  0.4331     0.1834 0.000 0.000 0.516 0.000 0.020 0.464
#> GSM123210     1  0.3515     0.2818 0.676 0.000 0.000 0.000 0.324 0.000
#> GSM123211     5  0.3428     0.6535 0.304 0.000 0.000 0.000 0.696 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) k
#> CV:pam 59          0.09880 2
#> CV:pam 58          0.07213 3
#> CV:pam 58          0.00891 4
#> CV:pam 54          0.00595 5
#> CV:pam 47          0.01632 6

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


CV:mclust

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

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

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

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.380           0.867       0.893         0.3909 0.577   0.577
#> 3 3 0.424           0.770       0.850         0.3604 0.826   0.714
#> 4 4 0.581           0.645       0.827         0.1521 0.897   0.795
#> 5 5 0.703           0.724       0.836         0.2232 0.745   0.457
#> 6 6 0.672           0.636       0.733         0.0697 0.923   0.697

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
#> GSM123212     2  0.9522     0.6493 0.372 0.628
#> GSM123213     2  0.6973     0.9512 0.188 0.812
#> GSM123214     2  0.6623     0.9639 0.172 0.828
#> GSM123215     2  0.6623     0.9639 0.172 0.828
#> GSM123216     1  0.0000     0.9133 1.000 0.000
#> GSM123217     1  0.0000     0.9133 1.000 0.000
#> GSM123218     1  0.8861     0.6842 0.696 0.304
#> GSM123219     1  0.2043     0.9049 0.968 0.032
#> GSM123220     1  0.0000     0.9133 1.000 0.000
#> GSM123221     1  0.0938     0.9086 0.988 0.012
#> GSM123222     1  0.0000     0.9133 1.000 0.000
#> GSM123223     2  0.6623     0.9639 0.172 0.828
#> GSM123224     1  0.0000     0.9133 1.000 0.000
#> GSM123225     1  0.0000     0.9133 1.000 0.000
#> GSM123226     1  0.0000     0.9133 1.000 0.000
#> GSM123227     1  0.1414     0.9065 0.980 0.020
#> GSM123228     1  0.0000     0.9133 1.000 0.000
#> GSM123229     1  0.1843     0.8948 0.972 0.028
#> GSM123230     1  0.0376     0.9114 0.996 0.004
#> GSM123231     1  0.8861     0.6842 0.696 0.304
#> GSM123232     1  0.0000     0.9133 1.000 0.000
#> GSM123233     1  0.9850     0.0925 0.572 0.428
#> GSM123234     1  0.0000     0.9133 1.000 0.000
#> GSM123235     1  0.6531     0.7740 0.832 0.168
#> GSM123236     1  0.3114     0.8831 0.944 0.056
#> GSM123237     1  0.0000     0.9133 1.000 0.000
#> GSM123238     1  0.2236     0.8968 0.964 0.036
#> GSM123239     1  0.8327     0.6074 0.736 0.264
#> GSM123240     1  0.0000     0.9133 1.000 0.000
#> GSM123241     1  0.0000     0.9133 1.000 0.000
#> GSM123242     2  0.6712     0.9613 0.176 0.824
#> GSM123182     1  0.6438     0.7854 0.836 0.164
#> GSM123183     2  0.9044     0.7594 0.320 0.680
#> GSM123184     2  0.6623     0.9639 0.172 0.828
#> GSM123185     1  0.9000     0.4867 0.684 0.316
#> GSM123186     1  0.4562     0.8590 0.904 0.096
#> GSM123187     2  0.6623     0.9639 0.172 0.828
#> GSM123188     1  0.0000     0.9133 1.000 0.000
#> GSM123189     1  0.5946     0.8342 0.856 0.144
#> GSM123190     1  0.6148     0.7865 0.848 0.152
#> GSM123191     1  0.0938     0.9101 0.988 0.012
#> GSM123192     1  0.0672     0.9115 0.992 0.008
#> GSM123193     1  0.0000     0.9133 1.000 0.000
#> GSM123194     1  0.1184     0.9083 0.984 0.016
#> GSM123195     2  0.6438     0.9635 0.164 0.836
#> GSM123196     1  0.6148     0.7715 0.848 0.152
#> GSM123197     1  0.8207     0.6224 0.744 0.256
#> GSM123198     2  0.6438     0.9635 0.164 0.836
#> GSM123199     1  0.0000     0.9133 1.000 0.000
#> GSM123200     2  0.6438     0.9635 0.164 0.836
#> GSM123201     1  0.0672     0.9115 0.992 0.008
#> GSM123202     2  0.6438     0.9635 0.164 0.836
#> GSM123203     1  0.0000     0.9133 1.000 0.000
#> GSM123204     2  0.6438     0.9635 0.164 0.836
#> GSM123205     2  0.6438     0.9635 0.164 0.836
#> GSM123206     2  0.6438     0.9635 0.164 0.836
#> GSM123207     1  0.5946     0.8005 0.856 0.144
#> GSM123208     2  0.6438     0.9635 0.164 0.836
#> GSM123209     2  0.6973     0.9511 0.188 0.812
#> GSM123210     1  0.0000     0.9133 1.000 0.000
#> GSM123211     1  0.0938     0.9086 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.5619      0.693 0.244 0.744 0.012
#> GSM123213     2  0.3879      0.796 0.152 0.848 0.000
#> GSM123214     2  0.6526      0.770 0.112 0.760 0.128
#> GSM123215     2  0.6526      0.770 0.112 0.760 0.128
#> GSM123216     1  0.0747      0.859 0.984 0.016 0.000
#> GSM123217     1  0.0424      0.857 0.992 0.000 0.008
#> GSM123218     3  0.6231      0.869 0.148 0.080 0.772
#> GSM123219     1  0.6488      0.685 0.744 0.064 0.192
#> GSM123220     1  0.0237      0.858 0.996 0.000 0.004
#> GSM123221     1  0.2096      0.839 0.944 0.052 0.004
#> GSM123222     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123223     2  0.1411      0.796 0.036 0.964 0.000
#> GSM123224     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123225     1  0.0424      0.859 0.992 0.008 0.000
#> GSM123226     1  0.1289      0.855 0.968 0.000 0.032
#> GSM123227     1  0.5798      0.728 0.780 0.044 0.176
#> GSM123228     1  0.0661      0.859 0.988 0.004 0.008
#> GSM123229     1  0.2066      0.838 0.940 0.000 0.060
#> GSM123230     1  0.1411      0.848 0.964 0.000 0.036
#> GSM123231     3  0.6168      0.848 0.124 0.096 0.780
#> GSM123232     1  0.0747      0.857 0.984 0.000 0.016
#> GSM123233     2  0.4002      0.794 0.160 0.840 0.000
#> GSM123234     1  0.2050      0.853 0.952 0.028 0.020
#> GSM123235     3  0.5633      0.869 0.208 0.024 0.768
#> GSM123236     1  0.4953      0.727 0.808 0.176 0.016
#> GSM123237     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123238     1  0.6509     -0.115 0.524 0.472 0.004
#> GSM123239     2  0.6301      0.648 0.260 0.712 0.028
#> GSM123240     1  0.1267      0.855 0.972 0.024 0.004
#> GSM123241     1  0.0592      0.858 0.988 0.000 0.012
#> GSM123242     2  0.4346      0.770 0.184 0.816 0.000
#> GSM123182     1  0.6562      0.685 0.744 0.072 0.184
#> GSM123183     2  0.7001      0.719 0.200 0.716 0.084
#> GSM123184     2  0.6526      0.770 0.112 0.760 0.128
#> GSM123185     1  0.6047      0.526 0.680 0.312 0.008
#> GSM123186     1  0.6283      0.706 0.760 0.064 0.176
#> GSM123187     2  0.3619      0.802 0.136 0.864 0.000
#> GSM123188     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123189     1  0.6723      0.655 0.724 0.064 0.212
#> GSM123190     1  0.7097      0.658 0.724 0.128 0.148
#> GSM123191     1  0.5292      0.737 0.800 0.028 0.172
#> GSM123192     1  0.2165      0.840 0.936 0.064 0.000
#> GSM123193     1  0.2400      0.837 0.932 0.004 0.064
#> GSM123194     1  0.5574      0.720 0.784 0.032 0.184
#> GSM123195     2  0.2902      0.774 0.016 0.920 0.064
#> GSM123196     3  0.6205      0.739 0.336 0.008 0.656
#> GSM123197     2  0.6330      0.435 0.396 0.600 0.004
#> GSM123198     2  0.1999      0.782 0.012 0.952 0.036
#> GSM123199     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123200     2  0.2749      0.772 0.012 0.924 0.064
#> GSM123201     1  0.1832      0.854 0.956 0.036 0.008
#> GSM123202     2  0.0829      0.787 0.012 0.984 0.004
#> GSM123203     1  0.0747      0.857 0.984 0.000 0.016
#> GSM123204     2  0.2749      0.772 0.012 0.924 0.064
#> GSM123205     2  0.2749      0.772 0.012 0.924 0.064
#> GSM123206     2  0.2749      0.772 0.012 0.924 0.064
#> GSM123207     1  0.4931      0.671 0.768 0.232 0.000
#> GSM123208     2  0.2749      0.772 0.012 0.924 0.064
#> GSM123209     2  0.4002      0.791 0.160 0.840 0.000
#> GSM123210     1  0.0892      0.857 0.980 0.000 0.020
#> GSM123211     1  0.1267      0.855 0.972 0.024 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.6653    0.62045 0.136 0.076 0.084 0.704
#> GSM123213     2  0.7018    0.27994 0.168 0.592 0.004 0.236
#> GSM123214     4  0.1940    0.78143 0.000 0.076 0.000 0.924
#> GSM123215     4  0.1940    0.78143 0.000 0.076 0.000 0.924
#> GSM123216     1  0.0188    0.76742 0.996 0.000 0.004 0.000
#> GSM123217     1  0.1474    0.76714 0.948 0.000 0.000 0.052
#> GSM123218     3  0.0000    0.87243 0.000 0.000 1.000 0.000
#> GSM123219     1  0.4855    0.48302 0.600 0.000 0.400 0.000
#> GSM123220     1  0.0000    0.76692 1.000 0.000 0.000 0.000
#> GSM123221     1  0.0376    0.76743 0.992 0.004 0.004 0.000
#> GSM123222     1  0.1489    0.76851 0.952 0.000 0.004 0.044
#> GSM123223     2  0.0188    0.75880 0.000 0.996 0.000 0.004
#> GSM123224     1  0.0000    0.76692 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0000    0.76692 1.000 0.000 0.000 0.000
#> GSM123226     1  0.0707    0.76022 0.980 0.000 0.020 0.000
#> GSM123227     1  0.6499    0.46127 0.524 0.000 0.400 0.076
#> GSM123228     1  0.1792    0.76506 0.932 0.000 0.000 0.068
#> GSM123229     1  0.2589    0.73439 0.884 0.000 0.116 0.000
#> GSM123230     1  0.1211    0.75674 0.960 0.000 0.040 0.000
#> GSM123231     3  0.0000    0.87243 0.000 0.000 1.000 0.000
#> GSM123232     1  0.1792    0.76506 0.932 0.000 0.000 0.068
#> GSM123233     2  0.8475   -0.00637 0.352 0.420 0.188 0.040
#> GSM123234     1  0.3486    0.68160 0.812 0.000 0.188 0.000
#> GSM123235     3  0.0188    0.87169 0.004 0.000 0.996 0.000
#> GSM123236     1  0.6669    0.45980 0.520 0.004 0.400 0.076
#> GSM123237     1  0.1978    0.76447 0.928 0.004 0.000 0.068
#> GSM123238     1  0.5742    0.40883 0.696 0.068 0.004 0.232
#> GSM123239     1  0.7879    0.39108 0.480 0.072 0.380 0.068
#> GSM123240     1  0.1978    0.76447 0.928 0.004 0.000 0.068
#> GSM123241     1  0.0000    0.76692 1.000 0.000 0.000 0.000
#> GSM123242     4  0.9319    0.10890 0.252 0.124 0.200 0.424
#> GSM123182     1  0.6677    0.46844 0.528 0.012 0.400 0.060
#> GSM123183     4  0.2821    0.77523 0.020 0.076 0.004 0.900
#> GSM123184     4  0.1940    0.78143 0.000 0.076 0.000 0.924
#> GSM123185     1  0.8455    0.44205 0.520 0.188 0.224 0.068
#> GSM123186     1  0.5756    0.46905 0.568 0.032 0.400 0.000
#> GSM123187     2  0.4661    0.39722 0.348 0.652 0.000 0.000
#> GSM123188     1  0.1792    0.76506 0.932 0.000 0.000 0.068
#> GSM123189     1  0.4989    0.39017 0.528 0.000 0.472 0.000
#> GSM123190     1  0.6499    0.42745 0.524 0.076 0.400 0.000
#> GSM123191     1  0.4855    0.48302 0.600 0.000 0.400 0.000
#> GSM123192     1  0.0376    0.76743 0.992 0.004 0.004 0.000
#> GSM123193     1  0.0188    0.76742 0.996 0.000 0.004 0.000
#> GSM123194     1  0.6130    0.47681 0.548 0.000 0.400 0.052
#> GSM123195     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123196     3  0.3688    0.61281 0.208 0.000 0.792 0.000
#> GSM123197     1  0.6572    0.38241 0.664 0.080 0.028 0.228
#> GSM123198     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123199     1  0.1792    0.76506 0.932 0.000 0.000 0.068
#> GSM123200     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123201     1  0.6309    0.54219 0.588 0.000 0.336 0.076
#> GSM123202     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123203     1  0.1792    0.76506 0.932 0.000 0.000 0.068
#> GSM123204     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0188    0.75880 0.000 0.996 0.000 0.004
#> GSM123206     2  0.0188    0.75880 0.000 0.996 0.000 0.004
#> GSM123207     1  0.6179    0.59781 0.644 0.004 0.276 0.076
#> GSM123208     2  0.0000    0.76124 0.000 1.000 0.000 0.000
#> GSM123209     2  0.5143    0.37162 0.360 0.628 0.012 0.000
#> GSM123210     1  0.0000    0.76692 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0188    0.76671 0.996 0.004 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
#> GSM123212     4  0.1117     0.7511 0.016 0.000 0.000 0.964 0.020
#> GSM123213     4  0.4349     0.6833 0.000 0.176 0.000 0.756 0.068
#> GSM123214     4  0.4101     0.7103 0.000 0.000 0.000 0.628 0.372
#> GSM123215     4  0.4101     0.7103 0.000 0.000 0.000 0.628 0.372
#> GSM123216     1  0.0290     0.8511 0.992 0.000 0.008 0.000 0.000
#> GSM123217     1  0.0162     0.8523 0.996 0.000 0.004 0.000 0.000
#> GSM123218     3  0.1168     0.6885 0.008 0.000 0.960 0.000 0.032
#> GSM123219     1  0.4182     0.3595 0.600 0.000 0.400 0.000 0.000
#> GSM123220     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123221     1  0.2909     0.7469 0.848 0.000 0.000 0.140 0.012
#> GSM123222     1  0.1043     0.8367 0.960 0.000 0.000 0.040 0.000
#> GSM123223     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123224     1  0.0162     0.8522 0.996 0.000 0.000 0.004 0.000
#> GSM123225     1  0.0290     0.8511 0.992 0.000 0.008 0.000 0.000
#> GSM123226     1  0.3521     0.5623 0.764 0.000 0.232 0.000 0.004
#> GSM123227     5  0.4525     0.6879 0.016 0.000 0.360 0.000 0.624
#> GSM123228     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123229     3  0.4150     0.3797 0.388 0.000 0.612 0.000 0.000
#> GSM123230     1  0.4268    -0.0308 0.556 0.000 0.444 0.000 0.000
#> GSM123231     3  0.1168     0.6885 0.008 0.000 0.960 0.000 0.032
#> GSM123232     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123233     5  0.5902     0.7134 0.000 0.208 0.192 0.000 0.600
#> GSM123234     3  0.6653     0.2476 0.368 0.000 0.476 0.136 0.020
#> GSM123235     3  0.1386     0.6907 0.016 0.000 0.952 0.000 0.032
#> GSM123236     5  0.5769     0.6639 0.136 0.004 0.236 0.000 0.624
#> GSM123237     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123238     4  0.3534     0.4844 0.256 0.000 0.000 0.744 0.000
#> GSM123239     5  0.5995     0.7425 0.016 0.132 0.228 0.000 0.624
#> GSM123240     1  0.1197     0.8319 0.952 0.000 0.000 0.048 0.000
#> GSM123241     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123242     4  0.4956     0.6736 0.004 0.136 0.036 0.760 0.064
#> GSM123182     5  0.4392     0.6822 0.008 0.000 0.380 0.000 0.612
#> GSM123183     4  0.0794     0.7549 0.000 0.000 0.000 0.972 0.028
#> GSM123184     4  0.4101     0.7103 0.000 0.000 0.000 0.628 0.372
#> GSM123185     5  0.6647     0.7370 0.008 0.136 0.200 0.044 0.612
#> GSM123186     1  0.4182     0.3595 0.600 0.000 0.400 0.000 0.000
#> GSM123187     5  0.4150     0.4571 0.000 0.388 0.000 0.000 0.612
#> GSM123188     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123189     3  0.0290     0.6785 0.008 0.000 0.992 0.000 0.000
#> GSM123190     5  0.4525     0.6879 0.016 0.000 0.360 0.000 0.624
#> GSM123191     1  0.4763     0.3791 0.632 0.000 0.336 0.000 0.032
#> GSM123192     1  0.0960     0.8441 0.972 0.000 0.008 0.004 0.016
#> GSM123193     1  0.2424     0.7589 0.868 0.000 0.132 0.000 0.000
#> GSM123194     1  0.4675     0.3511 0.600 0.000 0.380 0.000 0.020
#> GSM123195     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.2886     0.6406 0.148 0.000 0.844 0.000 0.008
#> GSM123197     4  0.2769     0.7239 0.032 0.000 0.000 0.876 0.092
#> GSM123198     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123199     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123200     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.5664     0.6444 0.152 0.000 0.220 0.000 0.628
#> GSM123202     2  0.0510     0.9787 0.000 0.984 0.000 0.000 0.016
#> GSM123203     1  0.0162     0.8532 0.996 0.000 0.000 0.000 0.004
#> GSM123204     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.6330     0.6799 0.024 0.008 0.196 0.144 0.628
#> GSM123208     2  0.0000     0.9974 0.000 1.000 0.000 0.000 0.000
#> GSM123209     5  0.4510     0.3672 0.000 0.432 0.008 0.000 0.560
#> GSM123210     1  0.0000     0.8524 1.000 0.000 0.000 0.000 0.000
#> GSM123211     1  0.1270     0.8300 0.948 0.000 0.000 0.052 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
#> GSM123212     4  0.2118     0.7100 0.000 0.000 0.000 0.888 0.008 0.104
#> GSM123213     4  0.5093     0.6733 0.000 0.088 0.000 0.704 0.060 0.148
#> GSM123214     4  0.4493     0.6483 0.000 0.000 0.344 0.612 0.000 0.044
#> GSM123215     4  0.4493     0.6483 0.000 0.000 0.344 0.612 0.000 0.044
#> GSM123216     1  0.3868     0.3621 0.508 0.000 0.000 0.000 0.000 0.492
#> GSM123217     1  0.2446     0.6867 0.864 0.000 0.000 0.000 0.012 0.124
#> GSM123218     3  0.3672     0.6016 0.000 0.000 0.632 0.000 0.368 0.000
#> GSM123219     6  0.6676     0.6308 0.212 0.000 0.104 0.000 0.160 0.524
#> GSM123220     1  0.2402     0.6840 0.856 0.000 0.000 0.000 0.004 0.140
#> GSM123221     1  0.5149     0.3036 0.496 0.000 0.000 0.072 0.004 0.428
#> GSM123222     1  0.3674     0.6274 0.716 0.000 0.000 0.016 0.000 0.268
#> GSM123223     2  0.0405     0.9806 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM123224     1  0.3198     0.6433 0.740 0.000 0.000 0.000 0.000 0.260
#> GSM123225     1  0.2762     0.6392 0.804 0.000 0.000 0.000 0.000 0.196
#> GSM123226     1  0.3261     0.4770 0.780 0.000 0.204 0.000 0.016 0.000
#> GSM123227     5  0.1498     0.7198 0.028 0.000 0.032 0.000 0.940 0.000
#> GSM123228     1  0.1858     0.5907 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM123229     3  0.4714     0.4160 0.348 0.000 0.604 0.000 0.012 0.036
#> GSM123230     3  0.4570     0.2611 0.436 0.000 0.528 0.000 0.000 0.036
#> GSM123231     3  0.3795     0.6039 0.000 0.000 0.632 0.000 0.364 0.004
#> GSM123232     1  0.0146     0.6744 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123233     5  0.3201     0.6883 0.000 0.208 0.000 0.000 0.780 0.012
#> GSM123234     3  0.6463     0.5395 0.224 0.000 0.560 0.048 0.152 0.016
#> GSM123235     3  0.4593     0.6151 0.000 0.000 0.620 0.000 0.324 0.056
#> GSM123236     5  0.0777     0.7458 0.024 0.000 0.004 0.000 0.972 0.000
#> GSM123237     1  0.0146     0.6744 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123238     4  0.5463     0.3917 0.148 0.000 0.000 0.540 0.000 0.312
#> GSM123239     5  0.0993     0.7492 0.000 0.024 0.000 0.000 0.964 0.012
#> GSM123240     1  0.4230     0.5153 0.612 0.000 0.000 0.024 0.000 0.364
#> GSM123241     1  0.3383     0.6344 0.728 0.000 0.000 0.000 0.004 0.268
#> GSM123242     4  0.5055     0.6723 0.000 0.072 0.000 0.704 0.064 0.160
#> GSM123182     5  0.4976     0.5326 0.016 0.000 0.052 0.008 0.652 0.272
#> GSM123183     4  0.0767     0.7141 0.000 0.000 0.004 0.976 0.008 0.012
#> GSM123184     4  0.4493     0.6483 0.000 0.000 0.344 0.612 0.000 0.044
#> GSM123185     5  0.4010     0.7056 0.000 0.072 0.012 0.128 0.784 0.004
#> GSM123186     6  0.5810     0.5941 0.120 0.000 0.056 0.012 0.160 0.652
#> GSM123187     5  0.4131     0.4509 0.000 0.356 0.000 0.000 0.624 0.020
#> GSM123188     1  0.0146     0.6744 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123189     3  0.5418     0.5309 0.020 0.000 0.636 0.000 0.160 0.184
#> GSM123190     5  0.1245     0.7266 0.016 0.000 0.032 0.000 0.952 0.000
#> GSM123191     6  0.7468     0.4682 0.180 0.000 0.184 0.000 0.260 0.376
#> GSM123192     6  0.4117     0.1630 0.296 0.000 0.000 0.032 0.000 0.672
#> GSM123193     1  0.4250     0.3330 0.528 0.000 0.000 0.000 0.016 0.456
#> GSM123194     5  0.6494     0.0561 0.264 0.000 0.064 0.000 0.512 0.160
#> GSM123195     2  0.0260     0.9822 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123196     3  0.5824     0.6040 0.168 0.000 0.616 0.000 0.168 0.048
#> GSM123197     4  0.3775     0.6441 0.012 0.000 0.000 0.744 0.016 0.228
#> GSM123198     2  0.1151     0.9593 0.000 0.956 0.000 0.000 0.032 0.012
#> GSM123199     1  0.0146     0.6744 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123200     2  0.0260     0.9822 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123201     5  0.1682     0.7314 0.052 0.000 0.020 0.000 0.928 0.000
#> GSM123202     2  0.1625     0.9292 0.000 0.928 0.000 0.000 0.060 0.012
#> GSM123203     1  0.0291     0.6752 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM123204     2  0.0000     0.9802 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9802 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9802 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.2316     0.7401 0.020 0.004 0.000 0.044 0.908 0.024
#> GSM123208     2  0.0260     0.9822 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123209     5  0.3420     0.6310 0.000 0.240 0.000 0.000 0.748 0.012
#> GSM123210     1  0.3428     0.6029 0.696 0.000 0.000 0.000 0.000 0.304
#> GSM123211     1  0.4407     0.3165 0.492 0.000 0.000 0.024 0.000 0.484

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) k
#> CV:mclust 59           0.1336 2
#> CV:mclust 59           0.3605 3
#> CV:mclust 43           0.0378 4
#> CV:mclust 51           0.0902 5
#> CV:mclust 49           0.0885 6

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


CV:NMF

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.742           0.828       0.933         0.4798 0.515   0.515
#> 3 3 0.672           0.781       0.911         0.2879 0.789   0.616
#> 4 4 0.598           0.657       0.829         0.1606 0.798   0.525
#> 5 5 0.703           0.719       0.865         0.0792 0.869   0.578
#> 6 6 0.654           0.603       0.768         0.0481 0.926   0.690

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
#> GSM123212     2  0.9754      0.287 0.408 0.592
#> GSM123213     2  0.0000      0.888 0.000 1.000
#> GSM123214     2  0.0000      0.888 0.000 1.000
#> GSM123215     2  0.0000      0.888 0.000 1.000
#> GSM123216     1  0.0000      0.943 1.000 0.000
#> GSM123217     1  0.0000      0.943 1.000 0.000
#> GSM123218     1  0.6048      0.778 0.852 0.148
#> GSM123219     1  0.0000      0.943 1.000 0.000
#> GSM123220     1  0.0000      0.943 1.000 0.000
#> GSM123221     1  0.0000      0.943 1.000 0.000
#> GSM123222     1  0.0000      0.943 1.000 0.000
#> GSM123223     2  0.0000      0.888 0.000 1.000
#> GSM123224     1  0.0000      0.943 1.000 0.000
#> GSM123225     1  0.0000      0.943 1.000 0.000
#> GSM123226     1  0.0000      0.943 1.000 0.000
#> GSM123227     1  0.3733      0.875 0.928 0.072
#> GSM123228     1  0.0000      0.943 1.000 0.000
#> GSM123229     1  0.0000      0.943 1.000 0.000
#> GSM123230     1  0.0000      0.943 1.000 0.000
#> GSM123231     1  0.9661      0.243 0.608 0.392
#> GSM123232     1  0.0000      0.943 1.000 0.000
#> GSM123233     2  0.1184      0.878 0.016 0.984
#> GSM123234     1  0.0000      0.943 1.000 0.000
#> GSM123235     1  0.0000      0.943 1.000 0.000
#> GSM123236     2  0.9983      0.183 0.476 0.524
#> GSM123237     1  0.0000      0.943 1.000 0.000
#> GSM123238     1  0.7376      0.694 0.792 0.208
#> GSM123239     2  0.0376      0.886 0.004 0.996
#> GSM123240     1  0.0000      0.943 1.000 0.000
#> GSM123241     1  0.0000      0.943 1.000 0.000
#> GSM123242     2  0.0000      0.888 0.000 1.000
#> GSM123182     2  0.9580      0.440 0.380 0.620
#> GSM123183     1  0.9833      0.219 0.576 0.424
#> GSM123184     2  0.0000      0.888 0.000 1.000
#> GSM123185     2  0.9661      0.413 0.392 0.608
#> GSM123186     1  0.2948      0.897 0.948 0.052
#> GSM123187     2  0.0000      0.888 0.000 1.000
#> GSM123188     1  0.0000      0.943 1.000 0.000
#> GSM123189     1  0.0000      0.943 1.000 0.000
#> GSM123190     2  0.9358      0.494 0.352 0.648
#> GSM123191     1  0.0000      0.943 1.000 0.000
#> GSM123192     1  0.0000      0.943 1.000 0.000
#> GSM123193     1  0.0000      0.943 1.000 0.000
#> GSM123194     1  0.0000      0.943 1.000 0.000
#> GSM123195     2  0.0000      0.888 0.000 1.000
#> GSM123196     1  0.0000      0.943 1.000 0.000
#> GSM123197     1  0.9881      0.182 0.564 0.436
#> GSM123198     2  0.0000      0.888 0.000 1.000
#> GSM123199     1  0.0000      0.943 1.000 0.000
#> GSM123200     2  0.0000      0.888 0.000 1.000
#> GSM123201     1  0.1843      0.919 0.972 0.028
#> GSM123202     2  0.0000      0.888 0.000 1.000
#> GSM123203     1  0.0000      0.943 1.000 0.000
#> GSM123204     2  0.0000      0.888 0.000 1.000
#> GSM123205     2  0.0000      0.888 0.000 1.000
#> GSM123206     2  0.0000      0.888 0.000 1.000
#> GSM123207     2  0.8861      0.580 0.304 0.696
#> GSM123208     2  0.0000      0.888 0.000 1.000
#> GSM123209     2  0.0000      0.888 0.000 1.000
#> GSM123210     1  0.0000      0.943 1.000 0.000
#> GSM123211     1  0.0000      0.943 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0000     0.8288 0.000 1.000 0.000
#> GSM123213     2  0.1411     0.8127 0.000 0.964 0.036
#> GSM123214     2  0.1289     0.8145 0.000 0.968 0.032
#> GSM123215     2  0.0000     0.8288 0.000 1.000 0.000
#> GSM123216     1  0.2448     0.8673 0.924 0.076 0.000
#> GSM123217     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123218     3  0.6308     0.0941 0.492 0.000 0.508
#> GSM123219     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123220     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123221     1  0.1529     0.8991 0.960 0.040 0.000
#> GSM123222     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123223     2  0.6260     0.1497 0.000 0.552 0.448
#> GSM123224     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123225     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123226     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123227     1  0.6308    -0.1046 0.508 0.000 0.492
#> GSM123228     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123229     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123230     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123231     3  0.4178     0.7358 0.172 0.000 0.828
#> GSM123232     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123233     3  0.0237     0.8483 0.004 0.000 0.996
#> GSM123234     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123235     1  0.4002     0.7614 0.840 0.000 0.160
#> GSM123236     3  0.3879     0.7566 0.152 0.000 0.848
#> GSM123237     1  0.1753     0.8929 0.952 0.048 0.000
#> GSM123238     2  0.5291     0.6472 0.268 0.732 0.000
#> GSM123239     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123240     1  0.3116     0.8330 0.892 0.108 0.000
#> GSM123241     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123242     2  0.0000     0.8288 0.000 1.000 0.000
#> GSM123182     2  0.4345     0.7542 0.136 0.848 0.016
#> GSM123183     2  0.0000     0.8288 0.000 1.000 0.000
#> GSM123184     2  0.0000     0.8288 0.000 1.000 0.000
#> GSM123185     3  0.8813     0.4852 0.236 0.184 0.580
#> GSM123186     2  0.5397     0.6318 0.280 0.720 0.000
#> GSM123187     3  0.4399     0.6640 0.000 0.188 0.812
#> GSM123188     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123189     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123190     3  0.2066     0.8209 0.060 0.000 0.940
#> GSM123191     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123192     1  0.5810     0.4395 0.664 0.336 0.000
#> GSM123193     1  0.1643     0.8959 0.956 0.044 0.000
#> GSM123194     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123195     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123196     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123197     2  0.5560     0.5938 0.300 0.700 0.000
#> GSM123198     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123199     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123200     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123201     1  0.6140     0.2263 0.596 0.000 0.404
#> GSM123202     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123203     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123204     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123205     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123206     3  0.3038     0.7667 0.000 0.104 0.896
#> GSM123207     3  0.6168     0.3665 0.412 0.000 0.588
#> GSM123208     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123209     3  0.0000     0.8495 0.000 0.000 1.000
#> GSM123210     1  0.0000     0.9251 1.000 0.000 0.000
#> GSM123211     1  0.4235     0.7449 0.824 0.176 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.1975     0.7709 0.048 0.016 0.000 0.936
#> GSM123213     4  0.1256     0.7706 0.000 0.028 0.008 0.964
#> GSM123214     4  0.0592     0.7797 0.000 0.016 0.000 0.984
#> GSM123215     4  0.0188     0.7852 0.000 0.004 0.000 0.996
#> GSM123216     1  0.0469     0.8183 0.988 0.000 0.000 0.012
#> GSM123217     1  0.3681     0.7038 0.816 0.000 0.176 0.008
#> GSM123218     3  0.5728     0.6030 0.104 0.188 0.708 0.000
#> GSM123219     3  0.6340     0.3613 0.344 0.000 0.580 0.076
#> GSM123220     1  0.1118     0.8160 0.964 0.000 0.036 0.000
#> GSM123221     1  0.1936     0.8060 0.940 0.000 0.032 0.028
#> GSM123222     1  0.2011     0.7837 0.920 0.000 0.080 0.000
#> GSM123223     2  0.4477     0.6041 0.000 0.688 0.000 0.312
#> GSM123224     1  0.0469     0.8193 0.988 0.000 0.012 0.000
#> GSM123225     1  0.0657     0.8203 0.984 0.000 0.012 0.004
#> GSM123226     1  0.4431     0.5437 0.696 0.000 0.304 0.000
#> GSM123227     3  0.4544     0.6564 0.164 0.048 0.788 0.000
#> GSM123228     3  0.4955     0.1941 0.444 0.000 0.556 0.000
#> GSM123229     1  0.3764     0.6908 0.784 0.000 0.216 0.000
#> GSM123230     1  0.3311     0.7251 0.828 0.000 0.172 0.000
#> GSM123231     3  0.4599     0.5208 0.016 0.248 0.736 0.000
#> GSM123232     1  0.0469     0.8190 0.988 0.000 0.012 0.000
#> GSM123233     3  0.4677     0.4041 0.004 0.316 0.680 0.000
#> GSM123234     1  0.5112     0.1356 0.560 0.004 0.436 0.000
#> GSM123235     1  0.7073     0.1703 0.504 0.132 0.364 0.000
#> GSM123236     3  0.5247     0.5681 0.052 0.228 0.720 0.000
#> GSM123237     1  0.0524     0.8189 0.988 0.000 0.004 0.008
#> GSM123238     4  0.5378     0.2474 0.448 0.012 0.000 0.540
#> GSM123239     2  0.1978     0.8729 0.004 0.928 0.068 0.000
#> GSM123240     1  0.0817     0.8146 0.976 0.000 0.000 0.024
#> GSM123241     1  0.0921     0.8154 0.972 0.000 0.028 0.000
#> GSM123242     4  0.0188     0.7852 0.000 0.004 0.000 0.996
#> GSM123182     3  0.5923     0.3416 0.036 0.008 0.620 0.336
#> GSM123183     4  0.1118     0.7802 0.036 0.000 0.000 0.964
#> GSM123184     4  0.0000     0.7850 0.000 0.000 0.000 1.000
#> GSM123185     3  0.6970     0.5345 0.036 0.144 0.660 0.160
#> GSM123186     4  0.6366     0.4043 0.120 0.000 0.240 0.640
#> GSM123187     2  0.4194     0.7528 0.000 0.800 0.028 0.172
#> GSM123188     1  0.0376     0.8193 0.992 0.000 0.004 0.004
#> GSM123189     3  0.4356     0.4846 0.292 0.000 0.708 0.000
#> GSM123190     3  0.5038     0.4644 0.020 0.296 0.684 0.000
#> GSM123191     1  0.4907     0.3190 0.580 0.000 0.420 0.000
#> GSM123192     4  0.4996     0.1151 0.484 0.000 0.000 0.516
#> GSM123193     1  0.3325     0.7585 0.864 0.000 0.112 0.024
#> GSM123194     3  0.4072     0.5881 0.252 0.000 0.748 0.000
#> GSM123195     2  0.1743     0.8782 0.000 0.940 0.056 0.004
#> GSM123196     1  0.5024     0.4652 0.632 0.008 0.360 0.000
#> GSM123197     1  0.6140     0.0688 0.556 0.036 0.008 0.400
#> GSM123198     2  0.0592     0.8902 0.000 0.984 0.016 0.000
#> GSM123199     1  0.1211     0.8153 0.960 0.000 0.040 0.000
#> GSM123200     2  0.0469     0.8912 0.000 0.988 0.012 0.000
#> GSM123201     3  0.6566     0.6007 0.236 0.140 0.624 0.000
#> GSM123202     2  0.0188     0.8914 0.000 0.996 0.000 0.004
#> GSM123203     1  0.0817     0.8178 0.976 0.000 0.024 0.000
#> GSM123204     2  0.0707     0.8877 0.000 0.980 0.020 0.000
#> GSM123205     2  0.0804     0.8898 0.000 0.980 0.012 0.008
#> GSM123206     2  0.2660     0.8720 0.000 0.908 0.056 0.036
#> GSM123207     2  0.5845     0.5394 0.076 0.672 0.252 0.000
#> GSM123208     2  0.1824     0.8767 0.000 0.936 0.060 0.004
#> GSM123209     2  0.0707     0.8900 0.000 0.980 0.020 0.000
#> GSM123210     1  0.0657     0.8191 0.984 0.000 0.004 0.012
#> GSM123211     1  0.1302     0.8054 0.956 0.000 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.1364     0.8142 0.036 0.012 0.000 0.952 0.000
#> GSM123213     4  0.1399     0.8091 0.000 0.028 0.000 0.952 0.020
#> GSM123214     4  0.0000     0.8294 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000     0.8294 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0162     0.8767 0.996 0.000 0.004 0.000 0.000
#> GSM123217     1  0.3203     0.6969 0.820 0.000 0.168 0.000 0.012
#> GSM123218     3  0.1341     0.6084 0.000 0.000 0.944 0.000 0.056
#> GSM123219     3  0.5789     0.4358 0.124 0.000 0.612 0.260 0.004
#> GSM123220     1  0.0703     0.8678 0.976 0.000 0.024 0.000 0.000
#> GSM123221     1  0.1282     0.8518 0.952 0.000 0.004 0.000 0.044
#> GSM123222     1  0.2890     0.7486 0.836 0.000 0.004 0.000 0.160
#> GSM123223     2  0.2890     0.8076 0.000 0.836 0.004 0.160 0.000
#> GSM123224     1  0.0162     0.8773 0.996 0.000 0.004 0.000 0.000
#> GSM123225     1  0.0324     0.8774 0.992 0.000 0.004 0.000 0.004
#> GSM123226     3  0.4450     0.2005 0.488 0.000 0.508 0.000 0.004
#> GSM123227     5  0.3612     0.6063 0.000 0.000 0.268 0.000 0.732
#> GSM123228     5  0.3970     0.6879 0.104 0.000 0.096 0.000 0.800
#> GSM123229     1  0.4522    -0.0696 0.552 0.000 0.440 0.000 0.008
#> GSM123230     1  0.4959     0.4663 0.684 0.000 0.240 0.000 0.076
#> GSM123231     3  0.1522     0.6119 0.000 0.044 0.944 0.000 0.012
#> GSM123232     1  0.0162     0.8771 0.996 0.000 0.000 0.000 0.004
#> GSM123233     5  0.0613     0.7926 0.004 0.004 0.008 0.000 0.984
#> GSM123234     5  0.3569     0.7015 0.104 0.000 0.068 0.000 0.828
#> GSM123235     3  0.5422     0.6030 0.212 0.132 0.656 0.000 0.000
#> GSM123236     5  0.2361     0.7807 0.000 0.012 0.096 0.000 0.892
#> GSM123237     1  0.0290     0.8760 0.992 0.000 0.008 0.000 0.000
#> GSM123238     1  0.3391     0.6863 0.800 0.000 0.000 0.188 0.012
#> GSM123239     2  0.2124     0.9029 0.000 0.916 0.056 0.000 0.028
#> GSM123240     1  0.0000     0.8774 1.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.0510     0.8729 0.984 0.000 0.016 0.000 0.000
#> GSM123242     4  0.0000     0.8294 0.000 0.000 0.000 1.000 0.000
#> GSM123182     4  0.6336     0.1328 0.000 0.000 0.172 0.488 0.340
#> GSM123183     4  0.0609     0.8253 0.020 0.000 0.000 0.980 0.000
#> GSM123184     4  0.0000     0.8294 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.1016     0.7928 0.004 0.004 0.012 0.008 0.972
#> GSM123186     4  0.5028     0.4832 0.072 0.000 0.260 0.668 0.000
#> GSM123187     2  0.2956     0.8881 0.000 0.872 0.020 0.012 0.096
#> GSM123188     1  0.0000     0.8774 1.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.1845     0.6457 0.056 0.000 0.928 0.000 0.016
#> GSM123190     3  0.1430     0.6089 0.000 0.004 0.944 0.000 0.052
#> GSM123191     3  0.4101     0.5055 0.372 0.000 0.628 0.000 0.000
#> GSM123192     4  0.4313     0.3808 0.356 0.000 0.008 0.636 0.000
#> GSM123193     1  0.2852     0.7015 0.828 0.000 0.172 0.000 0.000
#> GSM123194     3  0.5798     0.2250 0.108 0.000 0.556 0.000 0.336
#> GSM123195     2  0.0703     0.9245 0.000 0.976 0.024 0.000 0.000
#> GSM123196     3  0.4045     0.5247 0.356 0.000 0.644 0.000 0.000
#> GSM123197     1  0.4599     0.6366 0.760 0.172 0.000 0.040 0.028
#> GSM123198     2  0.3932     0.8282 0.000 0.796 0.064 0.000 0.140
#> GSM123199     1  0.0798     0.8746 0.976 0.000 0.008 0.000 0.016
#> GSM123200     2  0.0609     0.9262 0.000 0.980 0.020 0.000 0.000
#> GSM123201     5  0.1357     0.7957 0.004 0.000 0.048 0.000 0.948
#> GSM123202     2  0.0290     0.9257 0.000 0.992 0.008 0.000 0.000
#> GSM123203     1  0.0771     0.8729 0.976 0.000 0.004 0.000 0.020
#> GSM123204     2  0.1408     0.9219 0.000 0.948 0.008 0.000 0.044
#> GSM123205     2  0.2612     0.8777 0.000 0.868 0.008 0.000 0.124
#> GSM123206     2  0.0510     0.9250 0.000 0.984 0.016 0.000 0.000
#> GSM123207     5  0.5253     0.1030 0.016 0.396 0.024 0.000 0.564
#> GSM123208     2  0.1041     0.9217 0.000 0.964 0.032 0.000 0.004
#> GSM123209     2  0.1493     0.9216 0.000 0.948 0.028 0.000 0.024
#> GSM123210     1  0.0162     0.8773 0.996 0.000 0.004 0.000 0.000
#> GSM123211     1  0.0162     0.8773 0.996 0.000 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
#> GSM123212     4  0.2274     0.7640 0.088 0.008 0.000 0.892 0.000 0.012
#> GSM123213     4  0.0862     0.8162 0.004 0.008 0.000 0.972 0.000 0.016
#> GSM123214     4  0.0291     0.8213 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM123215     4  0.0000     0.8214 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123216     1  0.1657     0.8101 0.928 0.000 0.056 0.000 0.000 0.016
#> GSM123217     1  0.4074     0.6343 0.752 0.000 0.108 0.000 0.000 0.140
#> GSM123218     3  0.3637     0.5069 0.000 0.000 0.780 0.000 0.056 0.164
#> GSM123219     6  0.6582     0.4534 0.232 0.004 0.200 0.052 0.000 0.512
#> GSM123220     1  0.1471     0.8161 0.932 0.000 0.064 0.000 0.000 0.004
#> GSM123221     1  0.4129     0.6203 0.744 0.000 0.200 0.000 0.036 0.020
#> GSM123222     5  0.6047     0.1896 0.292 0.000 0.220 0.000 0.480 0.008
#> GSM123223     2  0.3617     0.6534 0.000 0.736 0.020 0.244 0.000 0.000
#> GSM123224     1  0.2520     0.7674 0.844 0.000 0.152 0.000 0.000 0.004
#> GSM123225     1  0.2724     0.8028 0.876 0.000 0.076 0.000 0.032 0.016
#> GSM123226     3  0.3043     0.6273 0.196 0.000 0.796 0.000 0.004 0.004
#> GSM123227     5  0.5999     0.0136 0.008 0.000 0.220 0.000 0.496 0.276
#> GSM123228     5  0.2908     0.5681 0.048 0.000 0.104 0.000 0.848 0.000
#> GSM123229     3  0.4033     0.5945 0.224 0.000 0.724 0.000 0.052 0.000
#> GSM123230     3  0.4795     0.5387 0.152 0.000 0.672 0.000 0.176 0.000
#> GSM123231     3  0.3273     0.5638 0.000 0.044 0.848 0.000 0.036 0.072
#> GSM123232     1  0.1049     0.8164 0.960 0.000 0.032 0.000 0.000 0.008
#> GSM123233     5  0.0603     0.5977 0.000 0.000 0.016 0.000 0.980 0.004
#> GSM123234     5  0.4411     0.1873 0.012 0.000 0.400 0.000 0.576 0.012
#> GSM123235     3  0.3066     0.5908 0.044 0.124 0.832 0.000 0.000 0.000
#> GSM123236     6  0.5005    -0.1528 0.020 0.000 0.036 0.000 0.404 0.540
#> GSM123237     1  0.1913     0.7739 0.908 0.000 0.012 0.000 0.000 0.080
#> GSM123238     1  0.2488     0.7480 0.864 0.000 0.004 0.124 0.000 0.008
#> GSM123239     2  0.3513     0.7749 0.000 0.824 0.056 0.000 0.100 0.020
#> GSM123240     1  0.0260     0.8106 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM123241     1  0.1196     0.8173 0.952 0.000 0.040 0.000 0.000 0.008
#> GSM123242     4  0.0881     0.8182 0.000 0.000 0.008 0.972 0.008 0.012
#> GSM123182     4  0.6634     0.2651 0.000 0.000 0.088 0.524 0.188 0.200
#> GSM123183     4  0.1010     0.8095 0.036 0.004 0.000 0.960 0.000 0.000
#> GSM123184     4  0.0146     0.8210 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM123185     5  0.0935     0.5926 0.000 0.000 0.004 0.032 0.964 0.000
#> GSM123186     4  0.7469    -0.2538 0.148 0.004 0.172 0.368 0.000 0.308
#> GSM123187     2  0.5227     0.7312 0.012 0.724 0.008 0.128 0.048 0.080
#> GSM123188     1  0.1738     0.8013 0.928 0.000 0.016 0.000 0.004 0.052
#> GSM123189     3  0.5299     0.0395 0.076 0.000 0.540 0.000 0.012 0.372
#> GSM123190     6  0.4131     0.0808 0.000 0.000 0.384 0.000 0.016 0.600
#> GSM123191     3  0.4508     0.5165 0.116 0.000 0.716 0.000 0.004 0.164
#> GSM123192     1  0.5151     0.1755 0.508 0.000 0.044 0.428 0.000 0.020
#> GSM123193     1  0.3921     0.6341 0.768 0.000 0.116 0.000 0.000 0.116
#> GSM123194     6  0.6467     0.4668 0.248 0.000 0.196 0.004 0.040 0.512
#> GSM123195     2  0.1788     0.8207 0.000 0.916 0.076 0.000 0.004 0.004
#> GSM123196     3  0.3183     0.6625 0.128 0.000 0.828 0.000 0.040 0.004
#> GSM123197     1  0.6081     0.3610 0.572 0.288 0.056 0.072 0.004 0.008
#> GSM123198     2  0.4649     0.5116 0.000 0.492 0.000 0.000 0.040 0.468
#> GSM123199     1  0.2592     0.7902 0.864 0.000 0.116 0.000 0.016 0.004
#> GSM123200     2  0.1148     0.8319 0.000 0.960 0.020 0.000 0.004 0.016
#> GSM123201     5  0.3010     0.5502 0.000 0.004 0.020 0.000 0.828 0.148
#> GSM123202     2  0.0547     0.8309 0.000 0.980 0.020 0.000 0.000 0.000
#> GSM123203     1  0.4166     0.7023 0.760 0.000 0.108 0.000 0.124 0.008
#> GSM123204     2  0.1801     0.8247 0.000 0.924 0.004 0.000 0.016 0.056
#> GSM123205     2  0.4565     0.6861 0.000 0.664 0.000 0.000 0.076 0.260
#> GSM123206     2  0.0508     0.8315 0.000 0.984 0.012 0.000 0.004 0.000
#> GSM123207     5  0.5409     0.3664 0.008 0.204 0.000 0.000 0.612 0.176
#> GSM123208     2  0.1606     0.8251 0.000 0.932 0.056 0.000 0.004 0.008
#> GSM123209     2  0.4408     0.7532 0.052 0.756 0.012 0.000 0.020 0.160
#> GSM123210     1  0.0363     0.8134 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM123211     1  0.1327     0.8007 0.936 0.000 0.064 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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) k
#> CV:NMF 53           0.1454 2
#> CV:NMF 54           0.0615 3
#> CV:NMF 47           0.0134 4
#> CV:NMF 52           0.0540 5
#> CV:NMF 48           0.0435 6

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


MAD:hclust

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.524           0.814       0.905         0.4540 0.541   0.541
#> 3 3 0.462           0.769       0.852         0.2187 0.940   0.889
#> 4 4 0.517           0.747       0.827         0.2709 0.782   0.547
#> 5 5 0.552           0.690       0.717         0.0709 0.985   0.942
#> 6 6 0.644           0.674       0.759         0.0509 0.951   0.801

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
#> GSM123212     2  0.9209      0.597 0.336 0.664
#> GSM123213     2  0.5519      0.834 0.128 0.872
#> GSM123214     2  0.2778      0.865 0.048 0.952
#> GSM123215     2  0.2778      0.865 0.048 0.952
#> GSM123216     1  0.0000      0.901 1.000 0.000
#> GSM123217     1  0.0376      0.900 0.996 0.004
#> GSM123218     1  0.7815      0.735 0.768 0.232
#> GSM123219     1  0.4298      0.857 0.912 0.088
#> GSM123220     1  0.0000      0.901 1.000 0.000
#> GSM123221     1  0.0672      0.899 0.992 0.008
#> GSM123222     1  0.0000      0.901 1.000 0.000
#> GSM123223     2  0.0000      0.867 0.000 1.000
#> GSM123224     1  0.0000      0.901 1.000 0.000
#> GSM123225     1  0.0000      0.901 1.000 0.000
#> GSM123226     1  0.0000      0.901 1.000 0.000
#> GSM123227     1  0.7299      0.765 0.796 0.204
#> GSM123228     1  0.0000      0.901 1.000 0.000
#> GSM123229     1  0.1843      0.891 0.972 0.028
#> GSM123230     1  0.0000      0.901 1.000 0.000
#> GSM123231     1  0.7815      0.735 0.768 0.232
#> GSM123232     1  0.0000      0.901 1.000 0.000
#> GSM123233     1  0.9896      0.313 0.560 0.440
#> GSM123234     1  0.0000      0.901 1.000 0.000
#> GSM123235     1  0.1843      0.891 0.972 0.028
#> GSM123236     1  0.8386      0.686 0.732 0.268
#> GSM123237     1  0.0000      0.901 1.000 0.000
#> GSM123238     2  0.9491      0.543 0.368 0.632
#> GSM123239     1  0.8955      0.618 0.688 0.312
#> GSM123240     1  0.0000      0.901 1.000 0.000
#> GSM123241     1  0.0000      0.901 1.000 0.000
#> GSM123242     2  0.5519      0.834 0.128 0.872
#> GSM123182     2  0.9732      0.463 0.404 0.596
#> GSM123183     2  0.9209      0.597 0.336 0.664
#> GSM123184     2  0.2778      0.865 0.048 0.952
#> GSM123185     1  0.9881      0.323 0.564 0.436
#> GSM123186     1  0.4298      0.857 0.912 0.088
#> GSM123187     2  0.5519      0.834 0.128 0.872
#> GSM123188     1  0.0000      0.901 1.000 0.000
#> GSM123189     1  0.3879      0.868 0.924 0.076
#> GSM123190     1  0.7815      0.735 0.768 0.232
#> GSM123191     1  0.2948      0.881 0.948 0.052
#> GSM123192     1  0.2423      0.878 0.960 0.040
#> GSM123193     1  0.0376      0.900 0.996 0.004
#> GSM123194     1  0.2948      0.881 0.948 0.052
#> GSM123195     2  0.0000      0.867 0.000 1.000
#> GSM123196     1  0.1843      0.891 0.972 0.028
#> GSM123197     2  0.9209      0.597 0.336 0.664
#> GSM123198     2  0.0938      0.868 0.012 0.988
#> GSM123199     1  0.0000      0.901 1.000 0.000
#> GSM123200     2  0.0000      0.867 0.000 1.000
#> GSM123201     1  0.8386      0.686 0.732 0.268
#> GSM123202     2  0.0672      0.867 0.008 0.992
#> GSM123203     1  0.0000      0.901 1.000 0.000
#> GSM123204     2  0.0000      0.867 0.000 1.000
#> GSM123205     2  0.0000      0.867 0.000 1.000
#> GSM123206     2  0.0000      0.867 0.000 1.000
#> GSM123207     1  0.8386      0.686 0.732 0.268
#> GSM123208     2  0.0000      0.867 0.000 1.000
#> GSM123209     2  0.4690      0.844 0.100 0.900
#> GSM123210     1  0.0000      0.901 1.000 0.000
#> GSM123211     1  0.0000      0.901 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.4346      0.711 0.184 0.816 0.000
#> GSM123213     2  0.7749      0.536 0.072 0.616 0.312
#> GSM123214     2  0.3941      0.645 0.000 0.844 0.156
#> GSM123215     2  0.3941      0.645 0.000 0.844 0.156
#> GSM123216     1  0.3879      0.795 0.848 0.152 0.000
#> GSM123217     1  0.3340      0.817 0.880 0.120 0.000
#> GSM123218     1  0.6208      0.702 0.756 0.052 0.192
#> GSM123219     1  0.5119      0.790 0.816 0.152 0.032
#> GSM123220     1  0.2165      0.832 0.936 0.064 0.000
#> GSM123221     1  0.4002      0.792 0.840 0.160 0.000
#> GSM123222     1  0.1031      0.834 0.976 0.024 0.000
#> GSM123223     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123224     1  0.2711      0.828 0.912 0.088 0.000
#> GSM123225     1  0.3879      0.795 0.848 0.152 0.000
#> GSM123226     1  0.0592      0.834 0.988 0.012 0.000
#> GSM123227     1  0.6001      0.713 0.772 0.052 0.176
#> GSM123228     1  0.0592      0.834 0.988 0.012 0.000
#> GSM123229     1  0.1585      0.830 0.964 0.008 0.028
#> GSM123230     1  0.0892      0.832 0.980 0.020 0.000
#> GSM123231     1  0.6208      0.702 0.756 0.052 0.192
#> GSM123232     1  0.0592      0.835 0.988 0.012 0.000
#> GSM123233     1  0.7203      0.382 0.556 0.028 0.416
#> GSM123234     1  0.0892      0.832 0.980 0.020 0.000
#> GSM123235     1  0.2050      0.825 0.952 0.020 0.028
#> GSM123236     1  0.6742      0.644 0.708 0.052 0.240
#> GSM123237     1  0.2711      0.825 0.912 0.088 0.000
#> GSM123238     2  0.4750      0.691 0.216 0.784 0.000
#> GSM123239     1  0.7128      0.595 0.664 0.052 0.284
#> GSM123240     1  0.3879      0.795 0.848 0.152 0.000
#> GSM123241     1  0.2537      0.827 0.920 0.080 0.000
#> GSM123242     2  0.7749      0.536 0.072 0.616 0.312
#> GSM123182     2  0.8137      0.552 0.316 0.592 0.092
#> GSM123183     2  0.4346      0.711 0.184 0.816 0.000
#> GSM123184     2  0.3941      0.645 0.000 0.844 0.156
#> GSM123185     1  0.7464      0.391 0.560 0.040 0.400
#> GSM123186     1  0.5119      0.790 0.816 0.152 0.032
#> GSM123187     2  0.7820      0.518 0.072 0.604 0.324
#> GSM123188     1  0.2711      0.825 0.912 0.088 0.000
#> GSM123189     1  0.3791      0.814 0.892 0.048 0.060
#> GSM123190     1  0.6208      0.702 0.756 0.052 0.192
#> GSM123191     1  0.4519      0.817 0.852 0.116 0.032
#> GSM123192     1  0.4399      0.762 0.812 0.188 0.000
#> GSM123193     1  0.3412      0.818 0.876 0.124 0.000
#> GSM123194     1  0.4519      0.817 0.852 0.116 0.032
#> GSM123195     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123196     1  0.1585      0.830 0.964 0.008 0.028
#> GSM123197     2  0.4346      0.711 0.184 0.816 0.000
#> GSM123198     3  0.1877      0.928 0.012 0.032 0.956
#> GSM123199     1  0.0424      0.835 0.992 0.008 0.000
#> GSM123200     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123201     1  0.6742      0.644 0.708 0.052 0.240
#> GSM123202     3  0.0424      0.957 0.008 0.000 0.992
#> GSM123203     1  0.0592      0.835 0.988 0.012 0.000
#> GSM123204     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123205     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123206     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123207     1  0.6742      0.644 0.708 0.052 0.240
#> GSM123208     3  0.0000      0.965 0.000 0.000 1.000
#> GSM123209     3  0.5710      0.717 0.080 0.116 0.804
#> GSM123210     1  0.2537      0.827 0.920 0.080 0.000
#> GSM123211     1  0.3879      0.795 0.848 0.152 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.5113      0.728 0.252 0.000 0.036 0.712
#> GSM123213     4  0.7695      0.589 0.076 0.216 0.104 0.604
#> GSM123214     4  0.0188      0.700 0.000 0.004 0.000 0.996
#> GSM123215     4  0.0188      0.700 0.000 0.004 0.000 0.996
#> GSM123216     1  0.0376      0.836 0.992 0.000 0.004 0.004
#> GSM123217     1  0.2048      0.855 0.928 0.000 0.064 0.008
#> GSM123218     3  0.4046      0.741 0.060 0.072 0.852 0.016
#> GSM123219     1  0.5254      0.741 0.724 0.000 0.220 0.056
#> GSM123220     1  0.2868      0.827 0.864 0.000 0.136 0.000
#> GSM123221     1  0.1151      0.825 0.968 0.000 0.024 0.008
#> GSM123222     3  0.4382      0.653 0.296 0.000 0.704 0.000
#> GSM123223     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123224     1  0.2530      0.837 0.888 0.000 0.112 0.000
#> GSM123225     1  0.0376      0.836 0.992 0.000 0.004 0.004
#> GSM123226     3  0.4697      0.543 0.356 0.000 0.644 0.000
#> GSM123227     3  0.1837      0.742 0.028 0.028 0.944 0.000
#> GSM123228     3  0.4697      0.543 0.356 0.000 0.644 0.000
#> GSM123229     3  0.4356      0.657 0.292 0.000 0.708 0.000
#> GSM123230     3  0.4304      0.665 0.284 0.000 0.716 0.000
#> GSM123231     3  0.4046      0.741 0.060 0.072 0.852 0.016
#> GSM123232     1  0.4277      0.629 0.720 0.000 0.280 0.000
#> GSM123233     3  0.4661      0.519 0.000 0.256 0.728 0.016
#> GSM123234     3  0.4304      0.665 0.284 0.000 0.716 0.000
#> GSM123235     3  0.3975      0.696 0.240 0.000 0.760 0.000
#> GSM123236     3  0.2197      0.724 0.004 0.080 0.916 0.000
#> GSM123237     1  0.1867      0.855 0.928 0.000 0.072 0.000
#> GSM123238     4  0.5182      0.689 0.288 0.000 0.028 0.684
#> GSM123239     3  0.3217      0.701 0.012 0.128 0.860 0.000
#> GSM123240     1  0.0376      0.836 0.992 0.000 0.004 0.004
#> GSM123241     1  0.2408      0.850 0.896 0.000 0.104 0.000
#> GSM123242     4  0.7695      0.589 0.076 0.216 0.104 0.604
#> GSM123182     4  0.7753      0.519 0.244 0.024 0.184 0.548
#> GSM123183     4  0.5113      0.728 0.252 0.000 0.036 0.712
#> GSM123184     4  0.0188      0.700 0.000 0.004 0.000 0.996
#> GSM123185     3  0.4993      0.513 0.000 0.260 0.712 0.028
#> GSM123186     1  0.5254      0.741 0.724 0.000 0.220 0.056
#> GSM123187     4  0.7823      0.578 0.076 0.220 0.112 0.592
#> GSM123188     1  0.1867      0.855 0.928 0.000 0.072 0.000
#> GSM123189     3  0.4012      0.704 0.184 0.000 0.800 0.016
#> GSM123190     3  0.4046      0.741 0.060 0.072 0.852 0.016
#> GSM123191     1  0.4576      0.758 0.748 0.000 0.232 0.020
#> GSM123192     1  0.2111      0.816 0.932 0.000 0.024 0.044
#> GSM123193     1  0.2198      0.854 0.920 0.000 0.072 0.008
#> GSM123194     1  0.4507      0.763 0.756 0.000 0.224 0.020
#> GSM123195     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123196     3  0.4356      0.657 0.292 0.000 0.708 0.000
#> GSM123197     4  0.5113      0.728 0.252 0.000 0.036 0.712
#> GSM123198     2  0.2976      0.829 0.000 0.872 0.120 0.008
#> GSM123199     1  0.4382      0.608 0.704 0.000 0.296 0.000
#> GSM123200     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123201     3  0.2197      0.724 0.004 0.080 0.916 0.000
#> GSM123202     2  0.0336      0.939 0.008 0.992 0.000 0.000
#> GSM123203     1  0.4304      0.625 0.716 0.000 0.284 0.000
#> GSM123204     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123207     3  0.2342      0.724 0.008 0.080 0.912 0.000
#> GSM123208     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123209     2  0.6441      0.631 0.084 0.720 0.124 0.072
#> GSM123210     1  0.2469      0.849 0.892 0.000 0.108 0.000
#> GSM123211     1  0.0779      0.833 0.980 0.000 0.016 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
#> GSM123212     3  0.5806      0.953 0.144 0.000 0.636 0.212 0.008
#> GSM123213     4  0.6621      0.598 0.000 0.100 0.180 0.620 0.100
#> GSM123214     4  0.1851      0.507 0.000 0.000 0.088 0.912 0.000
#> GSM123215     4  0.1851      0.507 0.000 0.000 0.088 0.912 0.000
#> GSM123216     1  0.0865      0.752 0.972 0.000 0.024 0.000 0.004
#> GSM123217     1  0.3055      0.764 0.864 0.000 0.064 0.000 0.072
#> GSM123218     5  0.3072      0.680 0.004 0.016 0.100 0.012 0.868
#> GSM123219     1  0.7061      0.548 0.556 0.000 0.144 0.076 0.224
#> GSM123220     1  0.2605      0.757 0.852 0.000 0.000 0.000 0.148
#> GSM123221     1  0.2358      0.706 0.888 0.000 0.104 0.000 0.008
#> GSM123222     5  0.4194      0.624 0.260 0.000 0.016 0.004 0.720
#> GSM123223     2  0.0000      0.913 0.000 1.000 0.000 0.000 0.000
#> GSM123224     1  0.2329      0.763 0.876 0.000 0.000 0.000 0.124
#> GSM123225     1  0.0865      0.752 0.972 0.000 0.024 0.000 0.004
#> GSM123226     5  0.5996      0.495 0.352 0.000 0.124 0.000 0.524
#> GSM123227     5  0.3141      0.692 0.016 0.000 0.152 0.000 0.832
#> GSM123228     5  0.5996      0.495 0.352 0.000 0.124 0.000 0.524
#> GSM123229     5  0.3756      0.629 0.248 0.000 0.008 0.000 0.744
#> GSM123230     5  0.3550      0.642 0.236 0.000 0.004 0.000 0.760
#> GSM123231     5  0.3072      0.680 0.004 0.016 0.100 0.012 0.868
#> GSM123232     1  0.4138      0.573 0.708 0.000 0.016 0.000 0.276
#> GSM123233     5  0.5452      0.497 0.000 0.056 0.344 0.008 0.592
#> GSM123234     5  0.3671      0.643 0.236 0.000 0.008 0.000 0.756
#> GSM123235     5  0.3492      0.670 0.188 0.000 0.016 0.000 0.796
#> GSM123236     5  0.3366      0.669 0.004 0.000 0.212 0.000 0.784
#> GSM123237     1  0.2694      0.782 0.892 0.000 0.008 0.032 0.068
#> GSM123238     3  0.6138      0.862 0.208 0.000 0.596 0.188 0.008
#> GSM123239     5  0.4256      0.646 0.000 0.044 0.192 0.004 0.760
#> GSM123240     1  0.0865      0.752 0.972 0.000 0.024 0.000 0.004
#> GSM123241     1  0.2230      0.777 0.884 0.000 0.000 0.000 0.116
#> GSM123242     4  0.6621      0.598 0.000 0.100 0.180 0.620 0.100
#> GSM123182     4  0.7135      0.321 0.080 0.000 0.176 0.556 0.188
#> GSM123183     3  0.5806      0.953 0.144 0.000 0.636 0.212 0.008
#> GSM123184     4  0.1851      0.507 0.000 0.000 0.088 0.912 0.000
#> GSM123185     5  0.5777      0.485 0.000 0.060 0.340 0.020 0.580
#> GSM123186     1  0.7061      0.548 0.556 0.000 0.144 0.076 0.224
#> GSM123187     4  0.6725      0.591 0.000 0.100 0.188 0.608 0.104
#> GSM123188     1  0.2694      0.782 0.892 0.000 0.008 0.032 0.068
#> GSM123189     5  0.3959      0.670 0.068 0.000 0.104 0.012 0.816
#> GSM123190     5  0.3072      0.680 0.004 0.016 0.100 0.012 0.868
#> GSM123191     1  0.6745      0.593 0.588 0.000 0.108 0.076 0.228
#> GSM123192     1  0.4160      0.678 0.804 0.000 0.124 0.048 0.024
#> GSM123193     1  0.3239      0.760 0.852 0.000 0.068 0.000 0.080
#> GSM123194     1  0.6721      0.593 0.592 0.000 0.108 0.076 0.224
#> GSM123195     2  0.0000      0.913 0.000 1.000 0.000 0.000 0.000
#> GSM123196     5  0.3756      0.629 0.248 0.000 0.008 0.000 0.744
#> GSM123197     3  0.5806      0.953 0.144 0.000 0.636 0.212 0.008
#> GSM123198     2  0.5074      0.656 0.000 0.740 0.120 0.024 0.116
#> GSM123199     1  0.4290      0.540 0.680 0.000 0.016 0.000 0.304
#> GSM123200     2  0.0000      0.913 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.3366      0.669 0.004 0.000 0.212 0.000 0.784
#> GSM123202     2  0.0404      0.907 0.000 0.988 0.000 0.000 0.012
#> GSM123203     1  0.4161      0.569 0.704 0.000 0.016 0.000 0.280
#> GSM123204     2  0.0000      0.913 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0404      0.908 0.000 0.988 0.000 0.012 0.000
#> GSM123206     2  0.0000      0.913 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.3522      0.667 0.004 0.000 0.212 0.004 0.780
#> GSM123208     2  0.0162      0.912 0.000 0.996 0.000 0.000 0.004
#> GSM123209     2  0.6908      0.424 0.000 0.588 0.192 0.092 0.128
#> GSM123210     1  0.2280      0.777 0.880 0.000 0.000 0.000 0.120
#> GSM123211     1  0.1168      0.749 0.960 0.000 0.032 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     6  0.0837      0.961 0.020 0.000 0.004 0.004 0.000 0.972
#> GSM123213     4  0.6047      0.675 0.000 0.012 0.080 0.584 0.268 0.056
#> GSM123214     4  0.1444      0.625 0.000 0.000 0.000 0.928 0.000 0.072
#> GSM123215     4  0.1444      0.625 0.000 0.000 0.000 0.928 0.000 0.072
#> GSM123216     1  0.1588      0.758 0.924 0.000 0.004 0.000 0.000 0.072
#> GSM123217     1  0.2747      0.743 0.860 0.000 0.096 0.000 0.000 0.044
#> GSM123218     3  0.2191      0.574 0.004 0.000 0.876 0.000 0.120 0.000
#> GSM123219     1  0.6507      0.509 0.560 0.000 0.260 0.028 0.084 0.068
#> GSM123220     1  0.2135      0.705 0.872 0.000 0.128 0.000 0.000 0.000
#> GSM123221     1  0.2664      0.704 0.816 0.000 0.000 0.000 0.000 0.184
#> GSM123222     3  0.4516      0.629 0.260 0.000 0.668 0.000 0.072 0.000
#> GSM123223     2  0.0000      0.896 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123224     1  0.2312      0.720 0.876 0.000 0.112 0.000 0.000 0.012
#> GSM123225     1  0.1588      0.758 0.924 0.000 0.004 0.000 0.000 0.072
#> GSM123226     5  0.6094      0.119 0.356 0.000 0.280 0.000 0.364 0.000
#> GSM123227     5  0.4300      0.610 0.028 0.000 0.364 0.000 0.608 0.000
#> GSM123228     5  0.6094      0.119 0.356 0.000 0.280 0.000 0.364 0.000
#> GSM123229     3  0.3151      0.706 0.252 0.000 0.748 0.000 0.000 0.000
#> GSM123230     3  0.2996      0.711 0.228 0.000 0.772 0.000 0.000 0.000
#> GSM123231     3  0.2191      0.574 0.004 0.000 0.876 0.000 0.120 0.000
#> GSM123232     1  0.3964      0.515 0.724 0.000 0.232 0.000 0.044 0.000
#> GSM123233     5  0.2205      0.528 0.000 0.008 0.088 0.004 0.896 0.004
#> GSM123234     3  0.3740      0.693 0.228 0.000 0.740 0.000 0.032 0.000
#> GSM123235     3  0.2631      0.720 0.180 0.000 0.820 0.000 0.000 0.000
#> GSM123236     5  0.4029      0.677 0.028 0.000 0.292 0.000 0.680 0.000
#> GSM123237     1  0.1755      0.758 0.932 0.000 0.028 0.000 0.032 0.008
#> GSM123238     6  0.1858      0.881 0.092 0.000 0.000 0.004 0.000 0.904
#> GSM123239     5  0.4834      0.658 0.020 0.044 0.272 0.004 0.660 0.000
#> GSM123240     1  0.1531      0.757 0.928 0.000 0.004 0.000 0.000 0.068
#> GSM123241     1  0.1765      0.733 0.904 0.000 0.096 0.000 0.000 0.000
#> GSM123242     4  0.6047      0.675 0.000 0.012 0.080 0.584 0.268 0.056
#> GSM123182     4  0.7425      0.498 0.080 0.000 0.212 0.504 0.136 0.068
#> GSM123183     6  0.0837      0.961 0.020 0.000 0.004 0.004 0.000 0.972
#> GSM123184     4  0.1444      0.625 0.000 0.000 0.000 0.928 0.000 0.072
#> GSM123185     5  0.2957      0.490 0.000 0.008 0.116 0.016 0.852 0.008
#> GSM123186     1  0.6507      0.509 0.560 0.000 0.260 0.028 0.084 0.068
#> GSM123187     4  0.6125      0.667 0.000 0.012 0.084 0.572 0.276 0.056
#> GSM123188     1  0.1755      0.758 0.932 0.000 0.028 0.000 0.032 0.008
#> GSM123189     3  0.3103      0.583 0.076 0.000 0.856 0.000 0.024 0.044
#> GSM123190     3  0.2191      0.574 0.004 0.000 0.876 0.000 0.120 0.000
#> GSM123191     1  0.6011      0.544 0.600 0.000 0.260 0.028 0.068 0.044
#> GSM123192     1  0.4645      0.702 0.756 0.000 0.040 0.012 0.064 0.128
#> GSM123193     1  0.2889      0.739 0.848 0.000 0.108 0.000 0.000 0.044
#> GSM123194     1  0.6011      0.545 0.600 0.000 0.260 0.028 0.068 0.044
#> GSM123195     2  0.0000      0.896 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.3151      0.706 0.252 0.000 0.748 0.000 0.000 0.000
#> GSM123197     6  0.0837      0.961 0.020 0.000 0.004 0.004 0.000 0.972
#> GSM123198     2  0.5495      0.565 0.000 0.652 0.092 0.044 0.208 0.004
#> GSM123199     1  0.4173      0.470 0.688 0.000 0.268 0.000 0.044 0.000
#> GSM123200     2  0.0000      0.896 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.4029      0.677 0.028 0.000 0.292 0.000 0.680 0.000
#> GSM123202     2  0.0436      0.891 0.000 0.988 0.004 0.004 0.004 0.000
#> GSM123203     1  0.3989      0.511 0.720 0.000 0.236 0.000 0.044 0.000
#> GSM123204     2  0.0000      0.896 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.1152      0.870 0.000 0.952 0.000 0.044 0.004 0.000
#> GSM123206     2  0.0000      0.896 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.4009      0.677 0.028 0.000 0.288 0.000 0.684 0.000
#> GSM123208     2  0.0146      0.894 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123209     2  0.7018      0.319 0.000 0.504 0.096 0.064 0.284 0.052
#> GSM123210     1  0.1814      0.732 0.900 0.000 0.100 0.000 0.000 0.000
#> GSM123211     1  0.1814      0.750 0.900 0.000 0.000 0.000 0.000 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-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) k
#> MAD:hclust 58           0.1158 2
#> MAD:hclust 59           0.0169 3
#> MAD:hclust 61           0.0279 4
#> MAD:hclust 55           0.0988 5
#> MAD:hclust 55           0.1336 6

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


MAD:kmeans

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.744           0.822       0.930         0.4617 0.522   0.522
#> 3 3 0.459           0.534       0.680         0.3359 0.781   0.634
#> 4 4 0.610           0.675       0.825         0.1851 0.736   0.465
#> 5 5 0.614           0.532       0.729         0.0746 0.921   0.719
#> 6 6 0.662           0.627       0.731         0.0489 0.892   0.554

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
#> GSM123212     2  0.9710      0.342 0.400 0.600
#> GSM123213     2  0.0000      0.851 0.000 1.000
#> GSM123214     2  0.0000      0.851 0.000 1.000
#> GSM123215     2  0.0000      0.851 0.000 1.000
#> GSM123216     1  0.0000      0.956 1.000 0.000
#> GSM123217     1  0.0000      0.956 1.000 0.000
#> GSM123218     1  0.7950      0.609 0.760 0.240
#> GSM123219     1  0.0000      0.956 1.000 0.000
#> GSM123220     1  0.0000      0.956 1.000 0.000
#> GSM123221     1  0.0000      0.956 1.000 0.000
#> GSM123222     1  0.0000      0.956 1.000 0.000
#> GSM123223     2  0.0000      0.851 0.000 1.000
#> GSM123224     1  0.0000      0.956 1.000 0.000
#> GSM123225     1  0.0000      0.956 1.000 0.000
#> GSM123226     1  0.0000      0.956 1.000 0.000
#> GSM123227     1  0.0000      0.956 1.000 0.000
#> GSM123228     1  0.0000      0.956 1.000 0.000
#> GSM123229     1  0.0000      0.956 1.000 0.000
#> GSM123230     1  0.0000      0.956 1.000 0.000
#> GSM123231     1  0.9686      0.196 0.604 0.396
#> GSM123232     1  0.0000      0.956 1.000 0.000
#> GSM123233     2  0.9323      0.497 0.348 0.652
#> GSM123234     1  0.0000      0.956 1.000 0.000
#> GSM123235     1  0.0000      0.956 1.000 0.000
#> GSM123236     1  0.4022      0.868 0.920 0.080
#> GSM123237     1  0.0000      0.956 1.000 0.000
#> GSM123238     1  0.6887      0.713 0.816 0.184
#> GSM123239     2  0.9954      0.264 0.460 0.540
#> GSM123240     1  0.0000      0.956 1.000 0.000
#> GSM123241     1  0.0000      0.956 1.000 0.000
#> GSM123242     2  0.0000      0.851 0.000 1.000
#> GSM123182     2  0.9963      0.253 0.464 0.536
#> GSM123183     2  0.9710      0.342 0.400 0.600
#> GSM123184     2  0.0000      0.851 0.000 1.000
#> GSM123185     2  0.9710      0.402 0.400 0.600
#> GSM123186     1  0.0000      0.956 1.000 0.000
#> GSM123187     2  0.0000      0.851 0.000 1.000
#> GSM123188     1  0.0000      0.956 1.000 0.000
#> GSM123189     1  0.0000      0.956 1.000 0.000
#> GSM123190     2  0.9970      0.242 0.468 0.532
#> GSM123191     1  0.0000      0.956 1.000 0.000
#> GSM123192     1  0.0000      0.956 1.000 0.000
#> GSM123193     1  0.0000      0.956 1.000 0.000
#> GSM123194     1  0.0000      0.956 1.000 0.000
#> GSM123195     2  0.0000      0.851 0.000 1.000
#> GSM123196     1  0.0000      0.956 1.000 0.000
#> GSM123197     1  0.9710      0.224 0.600 0.400
#> GSM123198     2  0.0000      0.851 0.000 1.000
#> GSM123199     1  0.0000      0.956 1.000 0.000
#> GSM123200     2  0.0000      0.851 0.000 1.000
#> GSM123201     1  0.0000      0.956 1.000 0.000
#> GSM123202     2  0.0000      0.851 0.000 1.000
#> GSM123203     1  0.0000      0.956 1.000 0.000
#> GSM123204     2  0.0000      0.851 0.000 1.000
#> GSM123205     2  0.0000      0.851 0.000 1.000
#> GSM123206     2  0.0000      0.851 0.000 1.000
#> GSM123207     1  0.0938      0.945 0.988 0.012
#> GSM123208     2  0.0000      0.851 0.000 1.000
#> GSM123209     2  0.0000      0.851 0.000 1.000
#> GSM123210     1  0.0000      0.956 1.000 0.000
#> GSM123211     1  0.0000      0.956 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.6313     0.4776 0.016 0.676 0.308
#> GSM123213     2  0.2261     0.4993 0.000 0.932 0.068
#> GSM123214     2  0.0000     0.5848 0.000 1.000 0.000
#> GSM123215     2  0.0000     0.5848 0.000 1.000 0.000
#> GSM123216     1  0.6274     0.6748 0.544 0.000 0.456
#> GSM123217     1  0.6244     0.6832 0.560 0.000 0.440
#> GSM123218     1  0.4045     0.5925 0.872 0.024 0.104
#> GSM123219     1  0.6585     0.6378 0.736 0.064 0.200
#> GSM123220     1  0.6235     0.6832 0.564 0.000 0.436
#> GSM123221     1  0.6280     0.6740 0.540 0.000 0.460
#> GSM123222     1  0.4654     0.7272 0.792 0.000 0.208
#> GSM123223     3  0.6305     0.5461 0.000 0.484 0.516
#> GSM123224     1  0.6274     0.6748 0.544 0.000 0.456
#> GSM123225     1  0.6280     0.6748 0.540 0.000 0.460
#> GSM123226     1  0.4399     0.7281 0.812 0.000 0.188
#> GSM123227     1  0.1015     0.6749 0.980 0.012 0.008
#> GSM123228     1  0.4452     0.7282 0.808 0.000 0.192
#> GSM123229     1  0.4702     0.7265 0.788 0.000 0.212
#> GSM123230     1  0.4605     0.7270 0.796 0.000 0.204
#> GSM123231     1  0.5842     0.4478 0.768 0.036 0.196
#> GSM123232     1  0.5835     0.7093 0.660 0.000 0.340
#> GSM123233     3  0.9299     0.2592 0.324 0.180 0.496
#> GSM123234     1  0.3425     0.7146 0.884 0.004 0.112
#> GSM123235     1  0.0747     0.6867 0.984 0.000 0.016
#> GSM123236     1  0.3987     0.5925 0.872 0.020 0.108
#> GSM123237     1  0.6244     0.6832 0.560 0.000 0.440
#> GSM123238     3  0.9527    -0.3307 0.204 0.332 0.464
#> GSM123239     3  0.7043     0.1963 0.448 0.020 0.532
#> GSM123240     1  0.6280     0.6748 0.540 0.000 0.460
#> GSM123241     1  0.6235     0.6832 0.564 0.000 0.436
#> GSM123242     2  0.1337     0.5755 0.012 0.972 0.016
#> GSM123182     1  0.7213     0.0157 0.552 0.420 0.028
#> GSM123183     2  0.6047     0.4788 0.008 0.680 0.312
#> GSM123184     2  0.0000     0.5848 0.000 1.000 0.000
#> GSM123185     1  0.8455     0.2419 0.584 0.296 0.120
#> GSM123186     1  0.9709     0.1726 0.452 0.296 0.252
#> GSM123187     2  0.6267    -0.5110 0.000 0.548 0.452
#> GSM123188     1  0.6244     0.6832 0.560 0.000 0.440
#> GSM123189     1  0.3530     0.6440 0.900 0.068 0.032
#> GSM123190     1  0.5167     0.5041 0.804 0.024 0.172
#> GSM123191     1  0.1919     0.6722 0.956 0.020 0.024
#> GSM123192     3  0.9626    -0.4398 0.260 0.268 0.472
#> GSM123193     1  0.6260     0.6817 0.552 0.000 0.448
#> GSM123194     1  0.2313     0.6731 0.944 0.024 0.032
#> GSM123195     3  0.6299     0.5548 0.000 0.476 0.524
#> GSM123196     1  0.3192     0.7167 0.888 0.000 0.112
#> GSM123197     2  0.9353     0.2377 0.200 0.504 0.296
#> GSM123198     3  0.6664     0.5528 0.008 0.464 0.528
#> GSM123199     1  0.4452     0.7282 0.808 0.000 0.192
#> GSM123200     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123201     1  0.1015     0.6744 0.980 0.012 0.008
#> GSM123202     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123203     1  0.4555     0.7283 0.800 0.000 0.200
#> GSM123204     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123205     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123206     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123207     1  0.3539     0.6029 0.888 0.012 0.100
#> GSM123208     3  0.6295     0.5590 0.000 0.472 0.528
#> GSM123209     3  0.8465     0.4592 0.096 0.376 0.528
#> GSM123210     1  0.6260     0.6787 0.552 0.000 0.448
#> GSM123211     1  0.6280     0.6740 0.540 0.000 0.460

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.3607      0.711 0.124 0.016 0.008 0.852
#> GSM123213     4  0.4262      0.701 0.000 0.236 0.008 0.756
#> GSM123214     4  0.3982      0.724 0.000 0.220 0.004 0.776
#> GSM123215     4  0.3982      0.724 0.000 0.220 0.004 0.776
#> GSM123216     1  0.1743      0.717 0.940 0.000 0.004 0.056
#> GSM123217     1  0.1388      0.732 0.960 0.000 0.028 0.012
#> GSM123218     3  0.2654      0.804 0.004 0.000 0.888 0.108
#> GSM123219     3  0.6674      0.461 0.300 0.000 0.584 0.116
#> GSM123220     1  0.2002      0.727 0.936 0.000 0.044 0.020
#> GSM123221     1  0.2469      0.695 0.892 0.000 0.000 0.108
#> GSM123222     3  0.6009     -0.231 0.468 0.000 0.492 0.040
#> GSM123223     2  0.0592      0.951 0.000 0.984 0.000 0.016
#> GSM123224     1  0.1109      0.730 0.968 0.000 0.004 0.028
#> GSM123225     1  0.1661      0.719 0.944 0.000 0.004 0.052
#> GSM123226     1  0.5838      0.273 0.524 0.000 0.444 0.032
#> GSM123227     3  0.0592      0.803 0.016 0.000 0.984 0.000
#> GSM123228     1  0.5288      0.261 0.520 0.000 0.472 0.008
#> GSM123229     1  0.6826      0.197 0.484 0.000 0.416 0.100
#> GSM123230     1  0.6395      0.180 0.472 0.000 0.464 0.064
#> GSM123231     3  0.2928      0.806 0.000 0.012 0.880 0.108
#> GSM123232     1  0.3498      0.683 0.832 0.000 0.160 0.008
#> GSM123233     3  0.4789      0.665 0.004 0.224 0.748 0.024
#> GSM123234     3  0.4017      0.701 0.128 0.000 0.828 0.044
#> GSM123235     3  0.3691      0.784 0.068 0.000 0.856 0.076
#> GSM123236     3  0.1284      0.806 0.012 0.000 0.964 0.024
#> GSM123237     1  0.1151      0.733 0.968 0.000 0.024 0.008
#> GSM123238     4  0.4985      0.156 0.468 0.000 0.000 0.532
#> GSM123239     3  0.3027      0.783 0.004 0.088 0.888 0.020
#> GSM123240     1  0.1557      0.718 0.944 0.000 0.000 0.056
#> GSM123241     1  0.2089      0.727 0.932 0.000 0.048 0.020
#> GSM123242     4  0.4204      0.721 0.000 0.192 0.020 0.788
#> GSM123182     3  0.4604      0.763 0.036 0.004 0.784 0.176
#> GSM123183     4  0.3663      0.710 0.128 0.016 0.008 0.848
#> GSM123184     4  0.3982      0.724 0.000 0.220 0.004 0.776
#> GSM123185     3  0.5287      0.688 0.008 0.076 0.760 0.156
#> GSM123186     1  0.7784     -0.119 0.392 0.000 0.364 0.244
#> GSM123187     2  0.3495      0.797 0.000 0.844 0.016 0.140
#> GSM123188     1  0.1284      0.733 0.964 0.000 0.024 0.012
#> GSM123189     3  0.4017      0.786 0.044 0.000 0.828 0.128
#> GSM123190     3  0.2958      0.806 0.004 0.004 0.876 0.116
#> GSM123191     3  0.5339      0.711 0.156 0.000 0.744 0.100
#> GSM123192     1  0.2714      0.684 0.884 0.000 0.004 0.112
#> GSM123193     1  0.2596      0.709 0.908 0.000 0.024 0.068
#> GSM123194     3  0.5452      0.713 0.156 0.000 0.736 0.108
#> GSM123195     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM123196     3  0.5293      0.693 0.152 0.000 0.748 0.100
#> GSM123197     4  0.6860      0.470 0.272 0.016 0.100 0.612
#> GSM123198     2  0.1256      0.938 0.000 0.964 0.028 0.008
#> GSM123199     1  0.5285      0.269 0.524 0.000 0.468 0.008
#> GSM123200     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM123201     3  0.1042      0.801 0.020 0.000 0.972 0.008
#> GSM123202     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM123203     1  0.5263      0.312 0.544 0.000 0.448 0.008
#> GSM123204     2  0.0188      0.960 0.000 0.996 0.000 0.004
#> GSM123205     2  0.0188      0.960 0.000 0.996 0.000 0.004
#> GSM123206     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM123207     3  0.1174      0.801 0.020 0.000 0.968 0.012
#> GSM123208     2  0.0000      0.961 0.000 1.000 0.000 0.000
#> GSM123209     2  0.2796      0.852 0.000 0.892 0.092 0.016
#> GSM123210     1  0.1174      0.732 0.968 0.000 0.012 0.020
#> GSM123211     1  0.2149      0.705 0.912 0.000 0.000 0.088

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.4901     0.6963 0.032 0.008 0.240 0.708 0.012
#> GSM123213     4  0.2935     0.7531 0.000 0.088 0.012 0.876 0.024
#> GSM123214     4  0.1608     0.7681 0.000 0.072 0.000 0.928 0.000
#> GSM123215     4  0.1608     0.7681 0.000 0.072 0.000 0.928 0.000
#> GSM123216     1  0.1818     0.6985 0.932 0.000 0.044 0.024 0.000
#> GSM123217     1  0.2241     0.6760 0.908 0.000 0.076 0.008 0.008
#> GSM123218     5  0.4594    -0.2017 0.004 0.000 0.484 0.004 0.508
#> GSM123219     3  0.6410     0.5967 0.204 0.000 0.552 0.008 0.236
#> GSM123220     1  0.1787     0.7009 0.936 0.000 0.044 0.004 0.016
#> GSM123221     1  0.4059     0.6045 0.776 0.000 0.172 0.052 0.000
#> GSM123222     5  0.6191     0.0195 0.364 0.000 0.104 0.012 0.520
#> GSM123223     2  0.2011     0.8719 0.000 0.908 0.004 0.088 0.000
#> GSM123224     1  0.1648     0.7105 0.940 0.000 0.040 0.020 0.000
#> GSM123225     1  0.1579     0.7018 0.944 0.000 0.032 0.024 0.000
#> GSM123226     1  0.6707     0.2243 0.480 0.000 0.208 0.008 0.304
#> GSM123227     5  0.0671     0.5003 0.004 0.000 0.016 0.000 0.980
#> GSM123228     5  0.6029    -0.1785 0.448 0.000 0.088 0.008 0.456
#> GSM123229     1  0.6912     0.1426 0.436 0.000 0.336 0.012 0.216
#> GSM123230     1  0.6954     0.0961 0.412 0.000 0.220 0.012 0.356
#> GSM123231     5  0.4593    -0.1951 0.004 0.000 0.480 0.004 0.512
#> GSM123232     1  0.3994     0.6253 0.804 0.000 0.056 0.008 0.132
#> GSM123233     5  0.4211     0.4448 0.000 0.152 0.016 0.044 0.788
#> GSM123234     5  0.4497     0.3920 0.092 0.000 0.120 0.012 0.776
#> GSM123235     3  0.6218     0.1014 0.108 0.000 0.444 0.008 0.440
#> GSM123236     5  0.2536     0.4097 0.004 0.000 0.128 0.000 0.868
#> GSM123237     1  0.0960     0.7083 0.972 0.000 0.016 0.004 0.008
#> GSM123238     4  0.6633     0.1714 0.384 0.000 0.220 0.396 0.000
#> GSM123239     5  0.2966     0.4601 0.000 0.136 0.016 0.000 0.848
#> GSM123240     1  0.1741     0.6998 0.936 0.000 0.040 0.024 0.000
#> GSM123241     1  0.1862     0.7008 0.932 0.000 0.048 0.004 0.016
#> GSM123242     4  0.2902     0.7591 0.000 0.056 0.028 0.888 0.028
#> GSM123182     3  0.5735     0.3486 0.004 0.000 0.492 0.072 0.432
#> GSM123183     4  0.4740     0.6989 0.032 0.008 0.232 0.720 0.008
#> GSM123184     4  0.1608     0.7681 0.000 0.072 0.000 0.928 0.000
#> GSM123185     5  0.4667     0.4349 0.000 0.044 0.052 0.128 0.776
#> GSM123186     3  0.6603     0.4999 0.240 0.000 0.576 0.036 0.148
#> GSM123187     2  0.5590     0.7069 0.000 0.708 0.044 0.124 0.124
#> GSM123188     1  0.0981     0.7087 0.972 0.000 0.012 0.008 0.008
#> GSM123189     3  0.4715     0.4916 0.024 0.000 0.668 0.008 0.300
#> GSM123190     5  0.4572    -0.1748 0.004 0.000 0.452 0.004 0.540
#> GSM123191     3  0.5920     0.6092 0.160 0.000 0.588 0.000 0.252
#> GSM123192     1  0.5002     0.4038 0.612 0.000 0.344 0.044 0.000
#> GSM123193     1  0.4297     0.4796 0.692 0.000 0.288 0.020 0.000
#> GSM123194     3  0.6085     0.6025 0.164 0.000 0.556 0.000 0.280
#> GSM123195     2  0.0162     0.9282 0.000 0.996 0.004 0.000 0.000
#> GSM123196     3  0.6870     0.1008 0.204 0.000 0.440 0.012 0.344
#> GSM123197     4  0.7907     0.5136 0.124 0.008 0.224 0.488 0.156
#> GSM123198     2  0.2580     0.8870 0.000 0.892 0.044 0.000 0.064
#> GSM123199     1  0.6018     0.1548 0.480 0.000 0.088 0.008 0.424
#> GSM123200     2  0.0000     0.9286 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0579     0.5037 0.008 0.000 0.008 0.000 0.984
#> GSM123202     2  0.0162     0.9282 0.000 0.996 0.004 0.000 0.000
#> GSM123203     1  0.6018     0.1548 0.480 0.000 0.088 0.008 0.424
#> GSM123204     2  0.0794     0.9241 0.000 0.972 0.028 0.000 0.000
#> GSM123205     2  0.1043     0.9214 0.000 0.960 0.040 0.000 0.000
#> GSM123206     2  0.0000     0.9286 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.1243     0.5059 0.008 0.000 0.028 0.004 0.960
#> GSM123208     2  0.0000     0.9286 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.3460     0.8163 0.000 0.828 0.044 0.000 0.128
#> GSM123210     1  0.1461     0.7076 0.952 0.000 0.028 0.004 0.016
#> GSM123211     1  0.3844     0.6185 0.792 0.000 0.164 0.044 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
#> GSM123212     4  0.6494    0.68387 0.084 0.000 0.164 0.604 0.028 0.120
#> GSM123213     4  0.3505    0.74935 0.000 0.028 0.028 0.836 0.096 0.012
#> GSM123214     4  0.0547    0.78751 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM123215     4  0.0547    0.78751 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM123216     1  0.0405    0.74398 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM123217     1  0.3366    0.71804 0.824 0.000 0.080 0.000 0.004 0.092
#> GSM123218     6  0.5979    0.41751 0.000 0.000 0.252 0.000 0.308 0.440
#> GSM123219     6  0.4008    0.64884 0.184 0.000 0.008 0.004 0.044 0.760
#> GSM123220     1  0.3656    0.60828 0.728 0.000 0.256 0.000 0.004 0.012
#> GSM123221     1  0.3338    0.68588 0.840 0.000 0.104 0.012 0.012 0.032
#> GSM123222     3  0.5757    0.47475 0.132 0.000 0.480 0.004 0.380 0.004
#> GSM123223     2  0.2454    0.78703 0.000 0.876 0.000 0.104 0.016 0.004
#> GSM123224     1  0.1501    0.73609 0.924 0.000 0.076 0.000 0.000 0.000
#> GSM123225     1  0.0665    0.74493 0.980 0.000 0.008 0.000 0.004 0.008
#> GSM123226     3  0.5042    0.63537 0.172 0.000 0.676 0.004 0.140 0.008
#> GSM123227     5  0.3122    0.70201 0.000 0.000 0.160 0.004 0.816 0.020
#> GSM123228     3  0.5886    0.58260 0.176 0.000 0.512 0.004 0.304 0.004
#> GSM123229     3  0.5677    0.51204 0.152 0.000 0.632 0.004 0.032 0.180
#> GSM123230     3  0.4983    0.62794 0.144 0.000 0.684 0.004 0.160 0.008
#> GSM123231     6  0.5994    0.40647 0.000 0.000 0.252 0.000 0.316 0.432
#> GSM123232     1  0.5003    0.00607 0.504 0.000 0.440 0.004 0.048 0.004
#> GSM123233     5  0.2996    0.74913 0.000 0.064 0.020 0.032 0.872 0.012
#> GSM123234     5  0.4348   -0.10446 0.008 0.000 0.464 0.004 0.520 0.004
#> GSM123235     3  0.5089    0.34377 0.024 0.000 0.632 0.000 0.064 0.280
#> GSM123236     5  0.2094    0.75264 0.000 0.000 0.020 0.000 0.900 0.080
#> GSM123237     1  0.2715    0.72447 0.860 0.000 0.112 0.000 0.004 0.024
#> GSM123238     1  0.7379   -0.19790 0.416 0.000 0.168 0.300 0.016 0.100
#> GSM123239     5  0.2358    0.76578 0.000 0.056 0.016 0.000 0.900 0.028
#> GSM123240     1  0.0291    0.74448 0.992 0.000 0.004 0.000 0.000 0.004
#> GSM123241     1  0.3656    0.60828 0.728 0.000 0.256 0.000 0.004 0.012
#> GSM123242     4  0.3279    0.75583 0.000 0.008 0.028 0.848 0.092 0.024
#> GSM123182     6  0.4330    0.56022 0.012 0.000 0.000 0.044 0.236 0.708
#> GSM123183     4  0.6350    0.68430 0.084 0.000 0.164 0.612 0.020 0.120
#> GSM123184     4  0.0547    0.78751 0.000 0.020 0.000 0.980 0.000 0.000
#> GSM123185     5  0.3428    0.72881 0.000 0.024 0.024 0.088 0.844 0.020
#> GSM123186     6  0.4360    0.61359 0.196 0.000 0.012 0.016 0.036 0.740
#> GSM123187     2  0.7441    0.44002 0.000 0.464 0.048 0.128 0.272 0.088
#> GSM123188     1  0.2480    0.72887 0.872 0.000 0.104 0.000 0.000 0.024
#> GSM123189     6  0.4050    0.64325 0.012 0.000 0.132 0.004 0.072 0.780
#> GSM123190     6  0.5824    0.37486 0.000 0.000 0.192 0.000 0.356 0.452
#> GSM123191     6  0.4349    0.68215 0.132 0.000 0.044 0.000 0.060 0.764
#> GSM123192     1  0.4645    0.34871 0.616 0.000 0.040 0.000 0.008 0.336
#> GSM123193     1  0.3971    0.54472 0.704 0.000 0.024 0.000 0.004 0.268
#> GSM123194     6  0.4141    0.67677 0.140 0.000 0.008 0.000 0.092 0.760
#> GSM123195     2  0.0000    0.86088 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.5610    0.37458 0.064 0.000 0.612 0.004 0.052 0.268
#> GSM123197     4  0.7556    0.45385 0.076 0.000 0.344 0.404 0.072 0.104
#> GSM123198     2  0.5052    0.72599 0.000 0.696 0.068 0.000 0.180 0.056
#> GSM123199     3  0.5862    0.58484 0.172 0.000 0.516 0.004 0.304 0.004
#> GSM123200     2  0.0260    0.86208 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123201     5  0.2673    0.73511 0.000 0.000 0.132 0.004 0.852 0.012
#> GSM123202     2  0.0260    0.86208 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123203     3  0.5862    0.58484 0.172 0.000 0.516 0.004 0.304 0.004
#> GSM123204     2  0.1518    0.85123 0.000 0.944 0.024 0.000 0.008 0.024
#> GSM123205     2  0.2985    0.82934 0.000 0.864 0.060 0.000 0.020 0.056
#> GSM123206     2  0.0000    0.86088 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1398    0.78043 0.000 0.000 0.052 0.000 0.940 0.008
#> GSM123208     2  0.0260    0.86208 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123209     2  0.5195    0.66549 0.000 0.668 0.056 0.000 0.216 0.060
#> GSM123210     1  0.2902    0.67452 0.800 0.000 0.196 0.004 0.000 0.000
#> GSM123211     1  0.2507    0.70678 0.884 0.000 0.072 0.004 0.000 0.040

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) k
#> MAD:kmeans 52           0.0913 2
#> MAD:kmeans 47           0.0168 3
#> MAD:kmeans 50           0.0161 4
#> MAD:kmeans 38           0.0157 5
#> MAD:kmeans 49           0.0227 6

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


MAD:skmeans

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.774           0.865       0.947         0.5033 0.495   0.495
#> 3 3 0.626           0.642       0.722         0.3120 0.721   0.500
#> 4 4 0.566           0.545       0.770         0.1168 0.848   0.599
#> 5 5 0.720           0.641       0.832         0.0751 0.864   0.548
#> 6 6 0.767           0.643       0.820         0.0431 0.921   0.645

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
#> GSM123212     2  0.7674      0.687 0.224 0.776
#> GSM123213     2  0.0000      0.922 0.000 1.000
#> GSM123214     2  0.0000      0.922 0.000 1.000
#> GSM123215     2  0.0000      0.922 0.000 1.000
#> GSM123216     1  0.0000      0.954 1.000 0.000
#> GSM123217     1  0.0000      0.954 1.000 0.000
#> GSM123218     2  0.9754      0.314 0.408 0.592
#> GSM123219     1  0.0000      0.954 1.000 0.000
#> GSM123220     1  0.0000      0.954 1.000 0.000
#> GSM123221     1  0.0000      0.954 1.000 0.000
#> GSM123222     1  0.0000      0.954 1.000 0.000
#> GSM123223     2  0.0000      0.922 0.000 1.000
#> GSM123224     1  0.0000      0.954 1.000 0.000
#> GSM123225     1  0.0000      0.954 1.000 0.000
#> GSM123226     1  0.0000      0.954 1.000 0.000
#> GSM123227     1  0.3274      0.897 0.940 0.060
#> GSM123228     1  0.0000      0.954 1.000 0.000
#> GSM123229     1  0.0000      0.954 1.000 0.000
#> GSM123230     1  0.0000      0.954 1.000 0.000
#> GSM123231     2  0.9710      0.335 0.400 0.600
#> GSM123232     1  0.0000      0.954 1.000 0.000
#> GSM123233     2  0.0000      0.922 0.000 1.000
#> GSM123234     1  0.0000      0.954 1.000 0.000
#> GSM123235     1  0.0000      0.954 1.000 0.000
#> GSM123236     2  0.5059      0.822 0.112 0.888
#> GSM123237     1  0.0000      0.954 1.000 0.000
#> GSM123238     1  0.8608      0.562 0.716 0.284
#> GSM123239     2  0.0000      0.922 0.000 1.000
#> GSM123240     1  0.0000      0.954 1.000 0.000
#> GSM123241     1  0.0000      0.954 1.000 0.000
#> GSM123242     2  0.0000      0.922 0.000 1.000
#> GSM123182     2  0.0000      0.922 0.000 1.000
#> GSM123183     2  0.9661      0.369 0.392 0.608
#> GSM123184     2  0.0000      0.922 0.000 1.000
#> GSM123185     2  0.0000      0.922 0.000 1.000
#> GSM123186     1  0.9635      0.311 0.612 0.388
#> GSM123187     2  0.0000      0.922 0.000 1.000
#> GSM123188     1  0.0000      0.954 1.000 0.000
#> GSM123189     1  0.6801      0.747 0.820 0.180
#> GSM123190     2  0.0000      0.922 0.000 1.000
#> GSM123191     1  0.0000      0.954 1.000 0.000
#> GSM123192     1  0.0000      0.954 1.000 0.000
#> GSM123193     1  0.0000      0.954 1.000 0.000
#> GSM123194     1  0.0376      0.951 0.996 0.004
#> GSM123195     2  0.0000      0.922 0.000 1.000
#> GSM123196     1  0.0000      0.954 1.000 0.000
#> GSM123197     2  0.9635      0.379 0.388 0.612
#> GSM123198     2  0.0000      0.922 0.000 1.000
#> GSM123199     1  0.0000      0.954 1.000 0.000
#> GSM123200     2  0.0000      0.922 0.000 1.000
#> GSM123201     1  0.9522      0.362 0.628 0.372
#> GSM123202     2  0.0000      0.922 0.000 1.000
#> GSM123203     1  0.0000      0.954 1.000 0.000
#> GSM123204     2  0.0000      0.922 0.000 1.000
#> GSM123205     2  0.0000      0.922 0.000 1.000
#> GSM123206     2  0.0000      0.922 0.000 1.000
#> GSM123207     2  0.0000      0.922 0.000 1.000
#> GSM123208     2  0.0000      0.922 0.000 1.000
#> GSM123209     2  0.0000      0.922 0.000 1.000
#> GSM123210     1  0.0000      0.954 1.000 0.000
#> GSM123211     1  0.0000      0.954 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.6796     0.6038 0.024 0.632 0.344
#> GSM123213     3  0.5397     0.2425 0.000 0.280 0.720
#> GSM123214     2  0.5988     0.5883 0.000 0.632 0.368
#> GSM123215     2  0.5988     0.5883 0.000 0.632 0.368
#> GSM123216     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123217     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123218     3  0.7644     0.7006 0.296 0.072 0.632
#> GSM123219     2  0.0592     0.5832 0.012 0.988 0.000
#> GSM123220     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123221     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123222     1  0.0237     0.7199 0.996 0.004 0.000
#> GSM123223     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123224     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123225     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123226     1  0.0000     0.7231 1.000 0.000 0.000
#> GSM123227     3  0.8071     0.6084 0.380 0.072 0.548
#> GSM123228     1  0.0000     0.7231 1.000 0.000 0.000
#> GSM123229     1  0.0424     0.7258 0.992 0.008 0.000
#> GSM123230     1  0.0000     0.7231 1.000 0.000 0.000
#> GSM123231     3  0.7644     0.7006 0.296 0.072 0.632
#> GSM123232     1  0.4702     0.7631 0.788 0.212 0.000
#> GSM123233     3  0.6482     0.7200 0.296 0.024 0.680
#> GSM123234     1  0.0747     0.7091 0.984 0.016 0.000
#> GSM123235     1  0.0747     0.7098 0.984 0.016 0.000
#> GSM123236     3  0.7644     0.7006 0.296 0.072 0.632
#> GSM123237     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123238     2  0.7601    -0.2288 0.416 0.540 0.044
#> GSM123239     3  0.6714     0.7174 0.296 0.032 0.672
#> GSM123240     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123241     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123242     2  0.5988     0.5883 0.000 0.632 0.368
#> GSM123182     2  0.5016     0.6139 0.000 0.760 0.240
#> GSM123183     2  0.7140     0.6097 0.040 0.632 0.328
#> GSM123184     2  0.5988     0.5883 0.000 0.632 0.368
#> GSM123185     3  0.6482     0.7200 0.296 0.024 0.680
#> GSM123186     2  0.0747     0.5946 0.000 0.984 0.016
#> GSM123187     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123188     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123189     2  0.4654     0.5017 0.208 0.792 0.000
#> GSM123190     3  0.7145     0.7193 0.236 0.072 0.692
#> GSM123191     2  0.6215    -0.3218 0.428 0.572 0.000
#> GSM123192     2  0.2356     0.5481 0.072 0.928 0.000
#> GSM123193     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123194     2  0.5431     0.0973 0.284 0.716 0.000
#> GSM123195     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123196     1  0.0424     0.7258 0.992 0.008 0.000
#> GSM123197     1  0.9956    -0.3341 0.376 0.296 0.328
#> GSM123198     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123199     1  0.0000     0.7231 1.000 0.000 0.000
#> GSM123200     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123201     3  0.7644     0.7006 0.296 0.072 0.632
#> GSM123202     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123203     1  0.0000     0.7231 1.000 0.000 0.000
#> GSM123204     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123205     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123206     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123207     3  0.6482     0.7200 0.296 0.024 0.680
#> GSM123208     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123209     3  0.0000     0.7491 0.000 0.000 1.000
#> GSM123210     1  0.5529     0.7757 0.704 0.296 0.000
#> GSM123211     1  0.5529     0.7757 0.704 0.296 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.3806     0.7878 0.020 0.156 0.000 0.824
#> GSM123213     4  0.3942     0.7577 0.000 0.236 0.000 0.764
#> GSM123214     4  0.3569     0.7945 0.000 0.196 0.000 0.804
#> GSM123215     4  0.3569     0.7945 0.000 0.196 0.000 0.804
#> GSM123216     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123217     1  0.3893     0.4918 0.796 0.000 0.196 0.008
#> GSM123218     3  0.4535     0.2992 0.000 0.292 0.704 0.004
#> GSM123219     3  0.7058     0.2663 0.228 0.000 0.572 0.200
#> GSM123220     1  0.0188     0.7195 0.996 0.000 0.000 0.004
#> GSM123221     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123222     1  0.6552     0.5006 0.628 0.000 0.228 0.144
#> GSM123223     2  0.2530     0.7086 0.000 0.888 0.000 0.112
#> GSM123224     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123226     1  0.6477     0.3857 0.552 0.000 0.368 0.080
#> GSM123227     3  0.6357     0.3072 0.000 0.184 0.656 0.160
#> GSM123228     1  0.6522     0.5051 0.632 0.000 0.224 0.144
#> GSM123229     1  0.4955     0.4290 0.648 0.000 0.344 0.008
#> GSM123230     1  0.6652     0.3278 0.516 0.000 0.396 0.088
#> GSM123231     3  0.4872     0.1852 0.000 0.356 0.640 0.004
#> GSM123232     1  0.4312     0.6362 0.812 0.000 0.132 0.056
#> GSM123233     2  0.6566     0.4885 0.000 0.624 0.236 0.140
#> GSM123234     1  0.7371     0.1608 0.424 0.000 0.416 0.160
#> GSM123235     3  0.5377     0.0125 0.376 0.004 0.608 0.012
#> GSM123236     2  0.7077     0.3710 0.000 0.536 0.316 0.148
#> GSM123237     1  0.0336     0.7148 0.992 0.000 0.008 0.000
#> GSM123238     4  0.4981     0.1506 0.464 0.000 0.000 0.536
#> GSM123239     2  0.4188     0.6821 0.000 0.812 0.040 0.148
#> GSM123240     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123241     1  0.0188     0.7195 0.996 0.000 0.000 0.004
#> GSM123242     4  0.3569     0.7945 0.000 0.196 0.000 0.804
#> GSM123182     4  0.4889     0.3908 0.000 0.004 0.360 0.636
#> GSM123183     4  0.3862     0.7862 0.024 0.152 0.000 0.824
#> GSM123184     4  0.3569     0.7945 0.000 0.196 0.000 0.804
#> GSM123185     2  0.7698     0.3004 0.000 0.440 0.236 0.324
#> GSM123186     4  0.6822     0.2476 0.100 0.000 0.412 0.488
#> GSM123187     2  0.0707     0.8045 0.000 0.980 0.000 0.020
#> GSM123188     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123189     3  0.5003     0.4443 0.148 0.000 0.768 0.084
#> GSM123190     2  0.5383     0.1734 0.000 0.536 0.452 0.012
#> GSM123191     3  0.5577     0.3621 0.328 0.000 0.636 0.036
#> GSM123192     1  0.7631    -0.0470 0.456 0.000 0.224 0.320
#> GSM123193     1  0.4799     0.4090 0.744 0.000 0.224 0.032
#> GSM123194     3  0.5883     0.3908 0.300 0.000 0.640 0.060
#> GSM123195     2  0.0336     0.8104 0.000 0.992 0.000 0.008
#> GSM123196     3  0.5295    -0.1395 0.488 0.000 0.504 0.008
#> GSM123197     4  0.5853     0.6925 0.132 0.148 0.004 0.716
#> GSM123198     2  0.0592     0.8043 0.000 0.984 0.016 0.000
#> GSM123199     1  0.6313     0.5248 0.652 0.000 0.220 0.128
#> GSM123200     2  0.0000     0.8113 0.000 1.000 0.000 0.000
#> GSM123201     3  0.7225     0.0370 0.000 0.328 0.512 0.160
#> GSM123202     2  0.0336     0.8104 0.000 0.992 0.000 0.008
#> GSM123203     1  0.6313     0.5248 0.652 0.000 0.220 0.128
#> GSM123204     2  0.0000     0.8113 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0000     0.8113 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0336     0.8104 0.000 0.992 0.000 0.008
#> GSM123207     2  0.6616     0.5025 0.000 0.624 0.220 0.156
#> GSM123208     2  0.0336     0.8104 0.000 0.992 0.000 0.008
#> GSM123209     2  0.0000     0.8113 0.000 1.000 0.000 0.000
#> GSM123210     1  0.0000     0.7203 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0000     0.7203 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.1362     0.8727 0.008 0.012 0.004 0.960 0.016
#> GSM123213     4  0.1270     0.8936 0.000 0.052 0.000 0.948 0.000
#> GSM123214     4  0.1270     0.8936 0.000 0.052 0.000 0.948 0.000
#> GSM123215     4  0.1270     0.8936 0.000 0.052 0.000 0.948 0.000
#> GSM123216     1  0.0693     0.8021 0.980 0.000 0.012 0.008 0.000
#> GSM123217     1  0.3525     0.6577 0.800 0.000 0.184 0.008 0.008
#> GSM123218     3  0.4803     0.5315 0.000 0.096 0.720 0.000 0.184
#> GSM123219     3  0.2144     0.6438 0.068 0.000 0.912 0.020 0.000
#> GSM123220     1  0.0404     0.7957 0.988 0.000 0.000 0.000 0.012
#> GSM123221     1  0.1913     0.7750 0.932 0.000 0.008 0.044 0.016
#> GSM123222     5  0.4283     0.5269 0.348 0.000 0.000 0.008 0.644
#> GSM123223     2  0.0880     0.9134 0.000 0.968 0.000 0.032 0.000
#> GSM123224     1  0.0451     0.7996 0.988 0.000 0.000 0.008 0.004
#> GSM123225     1  0.0693     0.8021 0.980 0.000 0.012 0.008 0.000
#> GSM123226     1  0.6811    -0.2080 0.408 0.000 0.236 0.004 0.352
#> GSM123227     5  0.0566     0.5900 0.000 0.012 0.004 0.000 0.984
#> GSM123228     5  0.4211     0.5073 0.360 0.000 0.000 0.004 0.636
#> GSM123229     1  0.5787     0.2312 0.564 0.000 0.340 0.004 0.092
#> GSM123230     5  0.6121     0.3718 0.376 0.000 0.116 0.004 0.504
#> GSM123231     3  0.5740     0.3845 0.000 0.272 0.600 0.000 0.128
#> GSM123232     1  0.3534     0.4473 0.744 0.000 0.000 0.000 0.256
#> GSM123233     5  0.4467     0.3653 0.000 0.344 0.000 0.016 0.640
#> GSM123234     5  0.3170     0.6111 0.120 0.000 0.012 0.016 0.852
#> GSM123235     3  0.6417     0.2194 0.272 0.000 0.528 0.004 0.196
#> GSM123236     5  0.3048     0.5365 0.000 0.176 0.004 0.000 0.820
#> GSM123237     1  0.1087     0.8007 0.968 0.000 0.016 0.008 0.008
#> GSM123238     4  0.4647     0.3967 0.352 0.000 0.004 0.628 0.016
#> GSM123239     2  0.2377     0.8201 0.000 0.872 0.000 0.000 0.128
#> GSM123240     1  0.0579     0.8018 0.984 0.000 0.008 0.008 0.000
#> GSM123241     1  0.0404     0.7957 0.988 0.000 0.000 0.000 0.012
#> GSM123242     4  0.1270     0.8936 0.000 0.052 0.000 0.948 0.000
#> GSM123182     3  0.5184     0.0342 0.004 0.000 0.508 0.456 0.032
#> GSM123183     4  0.1362     0.8727 0.008 0.012 0.004 0.960 0.016
#> GSM123184     4  0.1270     0.8936 0.000 0.052 0.000 0.948 0.000
#> GSM123185     5  0.5602     0.4537 0.000 0.148 0.000 0.216 0.636
#> GSM123186     3  0.4610     0.1854 0.016 0.000 0.596 0.388 0.000
#> GSM123187     2  0.0510     0.9269 0.000 0.984 0.000 0.016 0.000
#> GSM123188     1  0.0981     0.8011 0.972 0.000 0.012 0.008 0.008
#> GSM123189     3  0.0162     0.6531 0.004 0.000 0.996 0.000 0.000
#> GSM123190     2  0.6498     0.0603 0.000 0.460 0.340 0.000 0.200
#> GSM123191     3  0.0798     0.6555 0.016 0.000 0.976 0.008 0.000
#> GSM123192     1  0.6334     0.2266 0.520 0.000 0.316 0.160 0.004
#> GSM123193     1  0.4773     0.4509 0.656 0.000 0.312 0.024 0.008
#> GSM123194     3  0.1883     0.6502 0.048 0.000 0.932 0.008 0.012
#> GSM123195     2  0.0290     0.9319 0.000 0.992 0.000 0.008 0.000
#> GSM123196     3  0.5930     0.2216 0.360 0.000 0.536 0.004 0.100
#> GSM123197     4  0.2932     0.8191 0.052 0.012 0.004 0.888 0.044
#> GSM123198     2  0.0404     0.9289 0.000 0.988 0.000 0.000 0.012
#> GSM123199     5  0.4420     0.3665 0.448 0.000 0.000 0.004 0.548
#> GSM123200     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0566     0.5900 0.000 0.012 0.004 0.000 0.984
#> GSM123202     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123203     5  0.4443     0.3178 0.472 0.000 0.000 0.004 0.524
#> GSM123204     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.2690     0.5641 0.000 0.156 0.000 0.000 0.844
#> GSM123208     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.0000     0.9363 0.000 1.000 0.000 0.000 0.000
#> GSM123210     1  0.0162     0.7965 0.996 0.000 0.000 0.000 0.004
#> GSM123211     1  0.1455     0.7876 0.952 0.000 0.008 0.032 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.3141      0.825 0.000 0.004 0.112 0.836 0.000 0.048
#> GSM123213     4  0.0622      0.859 0.000 0.008 0.000 0.980 0.000 0.012
#> GSM123214     4  0.0508      0.861 0.000 0.004 0.000 0.984 0.000 0.012
#> GSM123215     4  0.0405      0.862 0.000 0.004 0.000 0.988 0.000 0.008
#> GSM123216     1  0.0632      0.774 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM123217     1  0.3318      0.669 0.796 0.000 0.032 0.000 0.000 0.172
#> GSM123218     3  0.5539      0.234 0.000 0.028 0.620 0.000 0.124 0.228
#> GSM123219     6  0.1906      0.751 0.032 0.000 0.036 0.008 0.000 0.924
#> GSM123220     1  0.1787      0.755 0.920 0.000 0.068 0.000 0.004 0.008
#> GSM123221     1  0.2978      0.690 0.856 0.000 0.084 0.008 0.000 0.052
#> GSM123222     5  0.6122      0.193 0.292 0.000 0.208 0.004 0.488 0.008
#> GSM123223     2  0.1349      0.877 0.000 0.940 0.000 0.056 0.000 0.004
#> GSM123224     1  0.0146      0.772 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM123225     1  0.0632      0.774 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM123226     3  0.6014      0.376 0.276 0.000 0.536 0.004 0.168 0.016
#> GSM123227     5  0.0363      0.663 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM123228     5  0.6449      0.087 0.300 0.000 0.244 0.004 0.436 0.016
#> GSM123229     3  0.3534      0.604 0.244 0.000 0.740 0.000 0.016 0.000
#> GSM123230     3  0.5960      0.384 0.288 0.000 0.520 0.004 0.180 0.008
#> GSM123231     3  0.5922      0.294 0.000 0.176 0.620 0.000 0.076 0.128
#> GSM123232     1  0.5232      0.451 0.668 0.000 0.156 0.004 0.156 0.016
#> GSM123233     5  0.4371      0.517 0.000 0.236 0.000 0.036 0.708 0.020
#> GSM123234     5  0.4663      0.484 0.072 0.000 0.220 0.004 0.696 0.008
#> GSM123235     3  0.3111      0.623 0.088 0.000 0.852 0.000 0.040 0.020
#> GSM123236     5  0.1773      0.652 0.000 0.036 0.016 0.000 0.932 0.016
#> GSM123237     1  0.2146      0.767 0.908 0.000 0.044 0.000 0.004 0.044
#> GSM123238     4  0.6123      0.476 0.300 0.000 0.120 0.532 0.000 0.048
#> GSM123239     2  0.2854      0.701 0.000 0.792 0.000 0.000 0.208 0.000
#> GSM123240     1  0.0458      0.774 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM123241     1  0.1845      0.753 0.916 0.000 0.072 0.000 0.004 0.008
#> GSM123242     4  0.0508      0.861 0.000 0.004 0.000 0.984 0.000 0.012
#> GSM123182     6  0.3374      0.641 0.000 0.000 0.000 0.208 0.020 0.772
#> GSM123183     4  0.3141      0.825 0.000 0.004 0.112 0.836 0.000 0.048
#> GSM123184     4  0.0405      0.862 0.000 0.004 0.000 0.988 0.000 0.008
#> GSM123185     5  0.4722      0.527 0.000 0.056 0.000 0.244 0.680 0.020
#> GSM123186     6  0.1913      0.739 0.012 0.000 0.000 0.080 0.000 0.908
#> GSM123187     2  0.1152      0.890 0.000 0.952 0.000 0.044 0.000 0.004
#> GSM123188     1  0.1933      0.769 0.920 0.000 0.044 0.000 0.004 0.032
#> GSM123189     6  0.3309      0.580 0.000 0.000 0.280 0.000 0.000 0.720
#> GSM123190     2  0.7183     -0.153 0.000 0.352 0.348 0.000 0.200 0.100
#> GSM123191     6  0.3729      0.564 0.012 0.000 0.296 0.000 0.000 0.692
#> GSM123192     6  0.4166      0.400 0.324 0.000 0.028 0.000 0.000 0.648
#> GSM123193     1  0.4079      0.246 0.608 0.000 0.008 0.004 0.000 0.380
#> GSM123194     6  0.2046      0.746 0.032 0.000 0.044 0.000 0.008 0.916
#> GSM123195     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.3310      0.622 0.132 0.000 0.824 0.000 0.016 0.028
#> GSM123197     4  0.4757      0.774 0.040 0.004 0.140 0.752 0.016 0.048
#> GSM123198     2  0.0363      0.912 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM123199     1  0.6526     -0.143 0.380 0.000 0.248 0.004 0.352 0.016
#> GSM123200     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.0363      0.663 0.000 0.000 0.012 0.000 0.988 0.000
#> GSM123202     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123203     1  0.6515     -0.098 0.396 0.000 0.248 0.004 0.336 0.016
#> GSM123204     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0146      0.916 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123206     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1442      0.663 0.000 0.040 0.004 0.000 0.944 0.012
#> GSM123208     2  0.0000      0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.0146      0.916 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123210     1  0.0363      0.773 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM123211     1  0.2146      0.739 0.908 0.000 0.024 0.008 0.000 0.060

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) k
#> MAD:skmeans 55           0.0858 2
#> MAD:skmeans 56           0.0382 3
#> MAD:skmeans 37           0.0113 4
#> MAD:skmeans 44           0.0364 5
#> MAD:skmeans 47           0.0393 6

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


MAD:pam

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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 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-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.835           0.893       0.956         0.4872 0.515   0.515
#> 3 3 0.581           0.787       0.882         0.3462 0.661   0.432
#> 4 4 0.510           0.663       0.774         0.0852 0.885   0.698
#> 5 5 0.760           0.798       0.879         0.1028 0.843   0.529
#> 6 6 0.730           0.644       0.798         0.0354 0.967   0.844

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
#> GSM123212     2  0.6048     0.8314 0.148 0.852
#> GSM123213     2  0.0000     0.9518 0.000 1.000
#> GSM123214     2  0.0000     0.9518 0.000 1.000
#> GSM123215     2  0.0000     0.9518 0.000 1.000
#> GSM123216     1  0.0000     0.9500 1.000 0.000
#> GSM123217     1  0.0000     0.9500 1.000 0.000
#> GSM123218     1  0.7219     0.7288 0.800 0.200
#> GSM123219     1  0.0000     0.9500 1.000 0.000
#> GSM123220     1  0.0000     0.9500 1.000 0.000
#> GSM123221     1  0.0000     0.9500 1.000 0.000
#> GSM123222     1  0.0000     0.9500 1.000 0.000
#> GSM123223     2  0.0000     0.9518 0.000 1.000
#> GSM123224     1  0.0000     0.9500 1.000 0.000
#> GSM123225     1  0.0000     0.9500 1.000 0.000
#> GSM123226     1  0.0000     0.9500 1.000 0.000
#> GSM123227     1  0.0000     0.9500 1.000 0.000
#> GSM123228     1  0.0000     0.9500 1.000 0.000
#> GSM123229     1  0.0000     0.9500 1.000 0.000
#> GSM123230     1  0.0000     0.9500 1.000 0.000
#> GSM123231     1  0.9686     0.3393 0.604 0.396
#> GSM123232     1  0.0000     0.9500 1.000 0.000
#> GSM123233     2  0.0000     0.9518 0.000 1.000
#> GSM123234     1  0.0000     0.9500 1.000 0.000
#> GSM123235     1  0.0000     0.9500 1.000 0.000
#> GSM123236     2  0.9635     0.3524 0.388 0.612
#> GSM123237     1  0.0000     0.9500 1.000 0.000
#> GSM123238     1  0.0000     0.9500 1.000 0.000
#> GSM123239     2  0.2423     0.9393 0.040 0.960
#> GSM123240     1  0.0000     0.9500 1.000 0.000
#> GSM123241     1  0.0000     0.9500 1.000 0.000
#> GSM123242     2  0.2236     0.9413 0.036 0.964
#> GSM123182     2  0.2423     0.9393 0.040 0.960
#> GSM123183     2  0.7453     0.7426 0.212 0.788
#> GSM123184     2  0.0000     0.9518 0.000 1.000
#> GSM123185     2  0.2236     0.9413 0.036 0.964
#> GSM123186     1  0.9954     0.0934 0.540 0.460
#> GSM123187     2  0.2236     0.9413 0.036 0.964
#> GSM123188     1  0.0000     0.9500 1.000 0.000
#> GSM123189     1  0.0376     0.9470 0.996 0.004
#> GSM123190     1  0.9686     0.3393 0.604 0.396
#> GSM123191     1  0.0376     0.9470 0.996 0.004
#> GSM123192     1  0.0000     0.9500 1.000 0.000
#> GSM123193     1  0.0000     0.9500 1.000 0.000
#> GSM123194     1  0.1414     0.9335 0.980 0.020
#> GSM123195     2  0.0000     0.9518 0.000 1.000
#> GSM123196     1  0.0000     0.9500 1.000 0.000
#> GSM123197     1  0.6712     0.7540 0.824 0.176
#> GSM123198     2  0.0000     0.9518 0.000 1.000
#> GSM123199     1  0.0000     0.9500 1.000 0.000
#> GSM123200     2  0.0000     0.9518 0.000 1.000
#> GSM123201     1  0.0000     0.9500 1.000 0.000
#> GSM123202     2  0.0000     0.9518 0.000 1.000
#> GSM123203     1  0.0000     0.9500 1.000 0.000
#> GSM123204     2  0.0000     0.9518 0.000 1.000
#> GSM123205     2  0.0000     0.9518 0.000 1.000
#> GSM123206     2  0.0000     0.9518 0.000 1.000
#> GSM123207     2  0.3431     0.9214 0.064 0.936
#> GSM123208     2  0.0000     0.9518 0.000 1.000
#> GSM123209     2  0.2423     0.9393 0.040 0.960
#> GSM123210     1  0.0000     0.9500 1.000 0.000
#> GSM123211     1  0.0000     0.9500 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.2866      0.831 0.076 0.008 0.916
#> GSM123213     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123214     2  0.0424      0.986 0.000 0.992 0.008
#> GSM123215     2  0.0424      0.986 0.000 0.992 0.008
#> GSM123216     1  0.3482      0.805 0.872 0.000 0.128
#> GSM123217     1  0.2537      0.816 0.920 0.000 0.080
#> GSM123218     3  0.3030      0.836 0.004 0.092 0.904
#> GSM123219     3  0.1289      0.825 0.032 0.000 0.968
#> GSM123220     1  0.2356      0.816 0.928 0.000 0.072
#> GSM123221     1  0.6180      0.308 0.584 0.000 0.416
#> GSM123222     1  0.5760      0.465 0.672 0.000 0.328
#> GSM123223     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123224     1  0.0424      0.828 0.992 0.000 0.008
#> GSM123225     1  0.2448      0.817 0.924 0.000 0.076
#> GSM123226     1  0.1964      0.829 0.944 0.000 0.056
#> GSM123227     3  0.6045      0.227 0.380 0.000 0.620
#> GSM123228     1  0.0424      0.828 0.992 0.000 0.008
#> GSM123229     3  0.5760      0.495 0.328 0.000 0.672
#> GSM123230     1  0.5760      0.465 0.672 0.000 0.328
#> GSM123231     3  0.2878      0.835 0.000 0.096 0.904
#> GSM123232     1  0.0000      0.829 1.000 0.000 0.000
#> GSM123233     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123234     1  0.5810      0.453 0.664 0.000 0.336
#> GSM123235     3  0.2796      0.826 0.092 0.000 0.908
#> GSM123236     3  0.6573      0.743 0.140 0.104 0.756
#> GSM123237     1  0.5465      0.612 0.712 0.000 0.288
#> GSM123238     1  0.0747      0.826 0.984 0.000 0.016
#> GSM123239     3  0.3038      0.833 0.000 0.104 0.896
#> GSM123240     1  0.0000      0.829 1.000 0.000 0.000
#> GSM123241     1  0.4121      0.791 0.832 0.000 0.168
#> GSM123242     3  0.3038      0.833 0.000 0.104 0.896
#> GSM123182     3  0.2878      0.835 0.000 0.096 0.904
#> GSM123183     3  0.3682      0.809 0.116 0.008 0.876
#> GSM123184     2  0.0424      0.986 0.000 0.992 0.008
#> GSM123185     3  0.4504      0.776 0.000 0.196 0.804
#> GSM123186     3  0.1411      0.824 0.036 0.000 0.964
#> GSM123187     3  0.6008      0.507 0.000 0.372 0.628
#> GSM123188     1  0.2356      0.816 0.928 0.000 0.072
#> GSM123189     3  0.1129      0.829 0.020 0.004 0.976
#> GSM123190     3  0.4295      0.830 0.032 0.104 0.864
#> GSM123191     3  0.2711      0.828 0.088 0.000 0.912
#> GSM123192     3  0.1860      0.819 0.052 0.000 0.948
#> GSM123193     1  0.6180      0.427 0.584 0.000 0.416
#> GSM123194     3  0.1031      0.828 0.024 0.000 0.976
#> GSM123195     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123196     3  0.2796      0.826 0.092 0.000 0.908
#> GSM123197     3  0.2878      0.825 0.096 0.000 0.904
#> GSM123198     2  0.1031      0.981 0.000 0.976 0.024
#> GSM123199     1  0.0892      0.826 0.980 0.000 0.020
#> GSM123200     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123201     3  0.6267      0.205 0.452 0.000 0.548
#> GSM123202     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123203     1  0.0747      0.826 0.984 0.000 0.016
#> GSM123204     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123205     2  0.0592      0.992 0.000 0.988 0.012
#> GSM123206     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123207     3  0.6473      0.583 0.312 0.020 0.668
#> GSM123208     2  0.0424      0.995 0.000 0.992 0.008
#> GSM123209     3  0.3038      0.833 0.000 0.104 0.896
#> GSM123210     1  0.3879      0.747 0.848 0.000 0.152
#> GSM123211     1  0.3816      0.748 0.852 0.000 0.148

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     3  0.6506     -0.186 0.072 0.000 0.472 0.456
#> GSM123213     4  0.5613      0.595 0.000 0.380 0.028 0.592
#> GSM123214     4  0.3975      0.769 0.000 0.240 0.000 0.760
#> GSM123215     4  0.3975      0.769 0.000 0.240 0.000 0.760
#> GSM123216     1  0.2973      0.731 0.856 0.000 0.144 0.000
#> GSM123217     1  0.3074      0.715 0.848 0.000 0.152 0.000
#> GSM123218     3  0.3745      0.749 0.000 0.088 0.852 0.060
#> GSM123219     3  0.0592      0.753 0.016 0.000 0.984 0.000
#> GSM123220     1  0.2281      0.732 0.904 0.000 0.096 0.000
#> GSM123221     1  0.6968      0.415 0.552 0.000 0.308 0.140
#> GSM123222     1  0.6193      0.590 0.672 0.000 0.180 0.148
#> GSM123223     2  0.2011      0.855 0.000 0.920 0.000 0.080
#> GSM123224     1  0.0336      0.745 0.992 0.000 0.008 0.000
#> GSM123225     1  0.2011      0.736 0.920 0.000 0.080 0.000
#> GSM123226     1  0.2859      0.745 0.880 0.000 0.112 0.008
#> GSM123227     3  0.7774     -0.199 0.372 0.000 0.388 0.240
#> GSM123228     1  0.0672      0.746 0.984 0.000 0.008 0.008
#> GSM123229     3  0.4454      0.442 0.308 0.000 0.692 0.000
#> GSM123230     1  0.6193      0.590 0.672 0.000 0.180 0.148
#> GSM123231     3  0.2149      0.754 0.000 0.088 0.912 0.000
#> GSM123232     1  0.0336      0.746 0.992 0.000 0.000 0.008
#> GSM123233     3  0.8281      0.538 0.076 0.244 0.540 0.140
#> GSM123234     1  0.6267      0.583 0.664 0.000 0.188 0.148
#> GSM123235     3  0.1867      0.753 0.072 0.000 0.928 0.000
#> GSM123236     3  0.7432      0.632 0.120 0.140 0.648 0.092
#> GSM123237     1  0.4730      0.479 0.636 0.000 0.364 0.000
#> GSM123238     1  0.3495      0.717 0.844 0.000 0.016 0.140
#> GSM123239     3  0.7054      0.656 0.028 0.140 0.640 0.192
#> GSM123240     1  0.0000      0.745 1.000 0.000 0.000 0.000
#> GSM123241     1  0.4008      0.674 0.756 0.000 0.244 0.000
#> GSM123242     4  0.5770      0.595 0.000 0.140 0.148 0.712
#> GSM123182     3  0.2149      0.754 0.000 0.088 0.912 0.000
#> GSM123183     4  0.5030      0.645 0.060 0.000 0.188 0.752
#> GSM123184     4  0.3975      0.769 0.000 0.240 0.000 0.760
#> GSM123185     3  0.8285      0.565 0.076 0.200 0.552 0.172
#> GSM123186     3  0.0592      0.753 0.016 0.000 0.984 0.000
#> GSM123187     3  0.4468      0.679 0.000 0.232 0.752 0.016
#> GSM123188     1  0.3024      0.715 0.852 0.000 0.148 0.000
#> GSM123189     3  0.0376      0.755 0.004 0.004 0.992 0.000
#> GSM123190     3  0.5499      0.720 0.020 0.124 0.764 0.092
#> GSM123191     3  0.1867      0.753 0.072 0.000 0.928 0.000
#> GSM123192     3  0.1118      0.751 0.036 0.000 0.964 0.000
#> GSM123193     1  0.4977      0.303 0.540 0.000 0.460 0.000
#> GSM123194     3  0.0592      0.753 0.016 0.000 0.984 0.000
#> GSM123195     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123196     3  0.1867      0.753 0.072 0.000 0.928 0.000
#> GSM123197     3  0.5815      0.585 0.152 0.000 0.708 0.140
#> GSM123198     2  0.2909      0.841 0.000 0.888 0.020 0.092
#> GSM123199     1  0.3708      0.714 0.832 0.000 0.020 0.148
#> GSM123200     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123201     1  0.7697      0.180 0.444 0.000 0.316 0.240
#> GSM123202     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123203     1  0.3597      0.715 0.836 0.000 0.016 0.148
#> GSM123204     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123205     2  0.2216      0.857 0.000 0.908 0.000 0.092
#> GSM123206     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123207     1  0.8934     -0.112 0.364 0.056 0.340 0.240
#> GSM123208     2  0.0000      0.946 0.000 1.000 0.000 0.000
#> GSM123209     3  0.3907      0.734 0.000 0.140 0.828 0.032
#> GSM123210     1  0.2921      0.705 0.860 0.000 0.140 0.000
#> GSM123211     1  0.2760      0.708 0.872 0.000 0.128 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
#> GSM123212     4  0.5443      0.463 0.000 0.000 0.312 0.604 0.084
#> GSM123213     4  0.4948      0.697 0.000 0.016 0.084 0.736 0.164
#> GSM123214     4  0.0000      0.859 0.000 0.000 0.000 1.000 0.000
#> GSM123215     4  0.0000      0.859 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0162      0.902 0.996 0.000 0.004 0.000 0.000
#> GSM123218     3  0.0510      0.875 0.000 0.000 0.984 0.000 0.016
#> GSM123219     3  0.1544      0.875 0.068 0.000 0.932 0.000 0.000
#> GSM123220     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123221     5  0.4713      0.659 0.280 0.000 0.044 0.000 0.676
#> GSM123222     5  0.2852      0.738 0.172 0.000 0.000 0.000 0.828
#> GSM123223     2  0.2632      0.843 0.000 0.892 0.032 0.072 0.004
#> GSM123224     1  0.1608      0.895 0.928 0.000 0.000 0.000 0.072
#> GSM123225     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123226     1  0.1701      0.901 0.936 0.000 0.016 0.000 0.048
#> GSM123227     5  0.1956      0.705 0.076 0.000 0.008 0.000 0.916
#> GSM123228     1  0.2074      0.870 0.896 0.000 0.000 0.000 0.104
#> GSM123229     3  0.4734      0.640 0.188 0.000 0.724 0.000 0.088
#> GSM123230     5  0.4713      0.659 0.280 0.000 0.044 0.000 0.676
#> GSM123231     3  0.0290      0.876 0.000 0.008 0.992 0.000 0.000
#> GSM123232     1  0.1478      0.900 0.936 0.000 0.000 0.000 0.064
#> GSM123233     5  0.2110      0.672 0.000 0.016 0.072 0.000 0.912
#> GSM123234     5  0.0703      0.739 0.024 0.000 0.000 0.000 0.976
#> GSM123235     3  0.1792      0.859 0.000 0.000 0.916 0.000 0.084
#> GSM123236     3  0.4384      0.533 0.000 0.016 0.660 0.000 0.324
#> GSM123237     1  0.2966      0.722 0.816 0.000 0.184 0.000 0.000
#> GSM123238     5  0.3913      0.624 0.324 0.000 0.000 0.000 0.676
#> GSM123239     5  0.4090      0.490 0.000 0.016 0.268 0.000 0.716
#> GSM123240     1  0.1478      0.900 0.936 0.000 0.000 0.000 0.064
#> GSM123241     1  0.2230      0.812 0.884 0.000 0.116 0.000 0.000
#> GSM123242     4  0.2331      0.821 0.000 0.016 0.068 0.908 0.008
#> GSM123182     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000
#> GSM123183     4  0.0510      0.855 0.000 0.000 0.000 0.984 0.016
#> GSM123184     4  0.0000      0.859 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.3264      0.662 0.000 0.016 0.164 0.000 0.820
#> GSM123186     3  0.1608      0.873 0.072 0.000 0.928 0.000 0.000
#> GSM123187     3  0.1211      0.865 0.000 0.016 0.960 0.000 0.024
#> GSM123188     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.1544      0.875 0.068 0.000 0.932 0.000 0.000
#> GSM123190     3  0.3304      0.752 0.000 0.016 0.816 0.000 0.168
#> GSM123191     3  0.1792      0.859 0.000 0.000 0.916 0.000 0.084
#> GSM123192     3  0.1965      0.864 0.096 0.000 0.904 0.000 0.000
#> GSM123193     1  0.2813      0.748 0.832 0.000 0.168 0.000 0.000
#> GSM123194     3  0.1608      0.873 0.072 0.000 0.928 0.000 0.000
#> GSM123195     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.1792      0.859 0.000 0.000 0.916 0.000 0.084
#> GSM123197     5  0.3274      0.633 0.000 0.000 0.220 0.000 0.780
#> GSM123198     2  0.5441      0.531 0.000 0.596 0.080 0.000 0.324
#> GSM123199     5  0.3913      0.624 0.324 0.000 0.000 0.000 0.676
#> GSM123200     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0451      0.733 0.008 0.000 0.004 0.000 0.988
#> GSM123202     2  0.3180      0.823 0.000 0.856 0.068 0.000 0.076
#> GSM123203     5  0.3707      0.672 0.284 0.000 0.000 0.000 0.716
#> GSM123204     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.1121      0.888 0.000 0.956 0.000 0.000 0.044
#> GSM123206     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.0162      0.729 0.000 0.000 0.004 0.000 0.996
#> GSM123208     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000
#> GSM123209     3  0.0912      0.869 0.000 0.016 0.972 0.000 0.012
#> GSM123210     1  0.1544      0.898 0.932 0.000 0.000 0.000 0.068
#> GSM123211     1  0.1544      0.898 0.932 0.000 0.000 0.000 0.068

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     6  0.6284    -0.3935 0.000 0.000 0.308 0.196 0.024 0.472
#> GSM123213     6  0.0790     0.0664 0.000 0.000 0.000 0.032 0.000 0.968
#> GSM123214     4  0.3706     0.9427 0.000 0.000 0.000 0.620 0.000 0.380
#> GSM123215     4  0.3706     0.9427 0.000 0.000 0.000 0.620 0.000 0.380
#> GSM123216     1  0.0363     0.8766 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM123217     1  0.0146     0.8769 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM123218     3  0.1461     0.8758 0.000 0.000 0.940 0.000 0.016 0.044
#> GSM123219     3  0.0865     0.8830 0.036 0.000 0.964 0.000 0.000 0.000
#> GSM123220     1  0.0000     0.8772 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123221     5  0.5634     0.5107 0.212 0.000 0.204 0.000 0.576 0.008
#> GSM123222     5  0.5794     0.6124 0.124 0.000 0.036 0.000 0.588 0.252
#> GSM123223     2  0.2260     0.6909 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM123224     1  0.1320     0.8666 0.948 0.000 0.036 0.000 0.016 0.000
#> GSM123225     1  0.0363     0.8766 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM123226     1  0.3967     0.5993 0.632 0.000 0.012 0.000 0.356 0.000
#> GSM123227     5  0.0777     0.5830 0.000 0.000 0.004 0.000 0.972 0.024
#> GSM123228     1  0.3823     0.4772 0.564 0.000 0.000 0.000 0.436 0.000
#> GSM123229     3  0.2852     0.7701 0.064 0.000 0.856 0.000 0.080 0.000
#> GSM123230     5  0.2912     0.6041 0.116 0.000 0.040 0.000 0.844 0.000
#> GSM123231     3  0.1204     0.8759 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM123232     1  0.3482     0.6547 0.684 0.000 0.000 0.000 0.316 0.000
#> GSM123233     5  0.3847     0.3951 0.000 0.000 0.000 0.000 0.544 0.456
#> GSM123234     5  0.4759     0.5875 0.028 0.000 0.036 0.000 0.656 0.280
#> GSM123235     3  0.2092     0.8257 0.000 0.000 0.876 0.000 0.124 0.000
#> GSM123236     6  0.5347     0.0411 0.000 0.000 0.412 0.000 0.108 0.480
#> GSM123237     1  0.1649     0.8536 0.932 0.000 0.036 0.000 0.032 0.000
#> GSM123238     5  0.5796     0.4852 0.296 0.000 0.036 0.000 0.564 0.104
#> GSM123239     6  0.5438    -0.1316 0.000 0.000 0.124 0.000 0.380 0.496
#> GSM123240     1  0.0993     0.8728 0.964 0.000 0.024 0.000 0.012 0.000
#> GSM123241     1  0.3285     0.7766 0.820 0.000 0.116 0.000 0.064 0.000
#> GSM123242     6  0.3695    -0.5666 0.000 0.000 0.000 0.376 0.000 0.624
#> GSM123182     3  0.0865     0.8807 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM123183     4  0.4722     0.8196 0.000 0.000 0.024 0.488 0.012 0.476
#> GSM123184     4  0.3706     0.9427 0.000 0.000 0.000 0.620 0.000 0.380
#> GSM123185     5  0.4473     0.3037 0.000 0.000 0.028 0.000 0.488 0.484
#> GSM123186     3  0.0865     0.8830 0.036 0.000 0.964 0.000 0.000 0.000
#> GSM123187     3  0.3457     0.6975 0.000 0.000 0.752 0.000 0.016 0.232
#> GSM123188     1  0.0000     0.8772 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0865     0.8830 0.036 0.000 0.964 0.000 0.000 0.000
#> GSM123190     3  0.4358     0.6466 0.000 0.000 0.716 0.000 0.100 0.184
#> GSM123191     3  0.0713     0.8677 0.000 0.000 0.972 0.000 0.028 0.000
#> GSM123192     3  0.1141     0.8789 0.052 0.000 0.948 0.000 0.000 0.000
#> GSM123193     1  0.1204     0.8524 0.944 0.000 0.056 0.000 0.000 0.000
#> GSM123194     3  0.0865     0.8830 0.036 0.000 0.964 0.000 0.000 0.000
#> GSM123195     2  0.0000     0.7805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.0891     0.8657 0.008 0.000 0.968 0.000 0.024 0.000
#> GSM123197     5  0.5286     0.4151 0.000 0.000 0.296 0.000 0.572 0.132
#> GSM123198     6  0.5502     0.2086 0.000 0.008 0.000 0.380 0.104 0.508
#> GSM123199     5  0.2003     0.5849 0.116 0.000 0.000 0.000 0.884 0.000
#> GSM123200     2  0.0000     0.7805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.3426     0.5812 0.000 0.000 0.004 0.000 0.720 0.276
#> GSM123202     2  0.3944     0.2916 0.000 0.568 0.000 0.000 0.004 0.428
#> GSM123203     5  0.2003     0.5849 0.116 0.000 0.000 0.000 0.884 0.000
#> GSM123204     2  0.3706     0.5784 0.000 0.620 0.000 0.380 0.000 0.000
#> GSM123205     2  0.5684     0.4441 0.000 0.476 0.000 0.380 0.004 0.140
#> GSM123206     2  0.0000     0.7805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.3758     0.5493 0.000 0.000 0.008 0.000 0.668 0.324
#> GSM123208     2  0.0000     0.7805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     3  0.3271     0.7052 0.000 0.000 0.760 0.000 0.008 0.232
#> GSM123210     1  0.1572     0.8569 0.936 0.000 0.036 0.000 0.028 0.000
#> GSM123211     1  0.1225     0.8680 0.952 0.000 0.036 0.000 0.012 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) k
#> MAD:pam 57          0.08379 2
#> MAD:pam 53          0.06363 3
#> MAD:pam 53          0.00858 4
#> MAD:pam 59          0.03362 5
#> MAD:pam 48          0.13885 6

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


MAD:mclust

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.407           0.828       0.893         0.4197 0.541   0.541
#> 3 3 0.434           0.660       0.755         0.2529 0.915   0.849
#> 4 4 0.731           0.695       0.867         0.2827 0.789   0.599
#> 5 5 0.636           0.547       0.798         0.1045 0.889   0.697
#> 6 6 0.641           0.441       0.688         0.0662 0.854   0.521

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
#> GSM123212     2  0.9580      0.571 0.380 0.620
#> GSM123213     2  0.5842      0.893 0.140 0.860
#> GSM123214     2  0.5519      0.894 0.128 0.872
#> GSM123215     2  0.5519      0.894 0.128 0.872
#> GSM123216     1  0.0376      0.912 0.996 0.004
#> GSM123217     1  0.0376      0.912 0.996 0.004
#> GSM123218     1  0.6531      0.761 0.832 0.168
#> GSM123219     1  0.4431      0.843 0.908 0.092
#> GSM123220     1  0.0000      0.912 1.000 0.000
#> GSM123221     1  0.0376      0.912 0.996 0.004
#> GSM123222     1  0.0000      0.912 1.000 0.000
#> GSM123223     2  0.5294      0.896 0.120 0.880
#> GSM123224     1  0.0000      0.912 1.000 0.000
#> GSM123225     1  0.0376      0.912 0.996 0.004
#> GSM123226     1  0.0376      0.912 0.996 0.004
#> GSM123227     1  0.5294      0.822 0.880 0.120
#> GSM123228     1  0.3274      0.878 0.940 0.060
#> GSM123229     1  0.0000      0.912 1.000 0.000
#> GSM123230     1  0.0376      0.912 0.996 0.004
#> GSM123231     1  0.9580      0.265 0.620 0.380
#> GSM123232     1  0.0000      0.912 1.000 0.000
#> GSM123233     2  0.9460      0.603 0.364 0.636
#> GSM123234     1  0.3274      0.878 0.940 0.060
#> GSM123235     1  0.3274      0.878 0.940 0.060
#> GSM123236     1  0.6247      0.778 0.844 0.156
#> GSM123237     1  0.0000      0.912 1.000 0.000
#> GSM123238     1  0.0376      0.912 0.996 0.004
#> GSM123239     2  0.9815      0.476 0.420 0.580
#> GSM123240     1  0.0376      0.912 0.996 0.004
#> GSM123241     1  0.0000      0.912 1.000 0.000
#> GSM123242     2  0.5842      0.893 0.140 0.860
#> GSM123182     1  0.9710      0.304 0.600 0.400
#> GSM123183     2  0.9552      0.567 0.376 0.624
#> GSM123184     2  0.5519      0.894 0.128 0.872
#> GSM123185     2  0.9522      0.590 0.372 0.628
#> GSM123186     1  0.4431      0.843 0.908 0.092
#> GSM123187     2  0.5842      0.893 0.140 0.860
#> GSM123188     1  0.0000      0.912 1.000 0.000
#> GSM123189     1  0.4431      0.843 0.908 0.092
#> GSM123190     1  0.9044      0.447 0.680 0.320
#> GSM123191     1  0.0376      0.912 0.996 0.004
#> GSM123192     1  0.0376      0.912 0.996 0.004
#> GSM123193     1  0.3584      0.865 0.932 0.068
#> GSM123194     1  0.4431      0.843 0.908 0.092
#> GSM123195     2  0.4690      0.892 0.100 0.900
#> GSM123196     1  0.0000      0.912 1.000 0.000
#> GSM123197     1  0.8267      0.587 0.740 0.260
#> GSM123198     2  0.4690      0.892 0.100 0.900
#> GSM123199     1  0.0000      0.912 1.000 0.000
#> GSM123200     2  0.4690      0.892 0.100 0.900
#> GSM123201     1  0.4939      0.834 0.892 0.108
#> GSM123202     2  0.5178      0.896 0.116 0.884
#> GSM123203     1  0.0000      0.912 1.000 0.000
#> GSM123204     2  0.4690      0.892 0.100 0.900
#> GSM123205     2  0.4690      0.892 0.100 0.900
#> GSM123206     2  0.4690      0.892 0.100 0.900
#> GSM123207     1  0.6623      0.755 0.828 0.172
#> GSM123208     2  0.4690      0.892 0.100 0.900
#> GSM123209     2  0.5842      0.893 0.140 0.860
#> GSM123210     1  0.0000      0.912 1.000 0.000
#> GSM123211     1  0.0376      0.912 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     3  0.5678     0.3520 0.316 0.000 0.684
#> GSM123213     3  0.4934     0.2459 0.024 0.156 0.820
#> GSM123214     3  0.0424     0.3720 0.008 0.000 0.992
#> GSM123215     3  0.0424     0.3720 0.008 0.000 0.992
#> GSM123216     1  0.0592     0.8474 0.988 0.000 0.012
#> GSM123217     1  0.0747     0.8482 0.984 0.016 0.000
#> GSM123218     1  0.8659     0.6045 0.596 0.228 0.176
#> GSM123219     1  0.6151     0.7579 0.772 0.160 0.068
#> GSM123220     1  0.0592     0.8493 0.988 0.012 0.000
#> GSM123221     1  0.1163     0.8484 0.972 0.000 0.028
#> GSM123222     1  0.2448     0.8476 0.924 0.076 0.000
#> GSM123223     3  0.6796    -0.4344 0.020 0.368 0.612
#> GSM123224     1  0.0237     0.8469 0.996 0.004 0.000
#> GSM123225     1  0.0424     0.8464 0.992 0.000 0.008
#> GSM123226     1  0.2448     0.8474 0.924 0.076 0.000
#> GSM123227     1  0.6083     0.8085 0.772 0.168 0.060
#> GSM123228     1  0.2878     0.8441 0.904 0.096 0.000
#> GSM123229     1  0.1163     0.8515 0.972 0.028 0.000
#> GSM123230     1  0.2356     0.8480 0.928 0.072 0.000
#> GSM123231     1  0.9405     0.3244 0.484 0.324 0.192
#> GSM123232     1  0.2448     0.8478 0.924 0.076 0.000
#> GSM123233     3  0.9340     0.2509 0.192 0.308 0.500
#> GSM123234     1  0.4556     0.8342 0.860 0.080 0.060
#> GSM123235     1  0.6354     0.7893 0.748 0.196 0.056
#> GSM123236     1  0.7615     0.7126 0.688 0.164 0.148
#> GSM123237     1  0.0892     0.8491 0.980 0.020 0.000
#> GSM123238     1  0.3267     0.7993 0.884 0.000 0.116
#> GSM123239     1  0.9969    -0.1958 0.372 0.320 0.308
#> GSM123240     1  0.0424     0.8464 0.992 0.000 0.008
#> GSM123241     1  0.0592     0.8493 0.988 0.012 0.000
#> GSM123242     3  0.4708     0.3151 0.036 0.120 0.844
#> GSM123182     1  0.8275     0.4829 0.596 0.108 0.296
#> GSM123183     3  0.5882     0.3342 0.348 0.000 0.652
#> GSM123184     3  0.0424     0.3720 0.008 0.000 0.992
#> GSM123185     3  0.9446     0.2788 0.228 0.272 0.500
#> GSM123186     1  0.6239     0.7561 0.768 0.160 0.072
#> GSM123187     3  0.7825    -0.0871 0.080 0.300 0.620
#> GSM123188     1  0.0592     0.8486 0.988 0.012 0.000
#> GSM123189     1  0.6897     0.7548 0.712 0.220 0.068
#> GSM123190     1  0.8722     0.4928 0.576 0.152 0.272
#> GSM123191     1  0.3683     0.8320 0.896 0.044 0.060
#> GSM123192     1  0.2845     0.8396 0.920 0.012 0.068
#> GSM123193     1  0.2636     0.8421 0.932 0.048 0.020
#> GSM123194     1  0.7062     0.7518 0.696 0.236 0.068
#> GSM123195     2  0.6373     0.9265 0.004 0.588 0.408
#> GSM123196     1  0.3918     0.8262 0.856 0.140 0.004
#> GSM123197     1  0.4842     0.7126 0.776 0.000 0.224
#> GSM123198     2  0.6495     0.8403 0.004 0.536 0.460
#> GSM123199     1  0.2537     0.8468 0.920 0.080 0.000
#> GSM123200     2  0.6359     0.9254 0.004 0.592 0.404
#> GSM123201     1  0.5631     0.8161 0.804 0.132 0.064
#> GSM123202     2  0.6809     0.8022 0.012 0.524 0.464
#> GSM123203     1  0.2537     0.8468 0.920 0.080 0.000
#> GSM123204     2  0.6140     0.9236 0.000 0.596 0.404
#> GSM123205     2  0.6140     0.9236 0.000 0.596 0.404
#> GSM123206     2  0.6359     0.9254 0.004 0.592 0.404
#> GSM123207     1  0.7180     0.7440 0.716 0.168 0.116
#> GSM123208     2  0.6442     0.9013 0.004 0.564 0.432
#> GSM123209     3  0.8404    -0.5350 0.084 0.452 0.464
#> GSM123210     1  0.0000     0.8470 1.000 0.000 0.000
#> GSM123211     1  0.0592     0.8474 0.988 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.4786      0.742 0.064 0.132 0.008 0.796
#> GSM123213     4  0.4817      0.389 0.000 0.000 0.388 0.612
#> GSM123214     4  0.0336      0.825 0.000 0.000 0.008 0.992
#> GSM123215     4  0.0336      0.825 0.000 0.000 0.008 0.992
#> GSM123216     1  0.0376      0.867 0.992 0.000 0.004 0.004
#> GSM123217     1  0.0524      0.866 0.988 0.008 0.000 0.004
#> GSM123218     2  0.7795     -0.569 0.268 0.420 0.312 0.000
#> GSM123219     1  0.5016      0.414 0.600 0.396 0.000 0.004
#> GSM123220     1  0.0376      0.867 0.992 0.004 0.000 0.004
#> GSM123221     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM123222     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM123223     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123224     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0376      0.867 0.992 0.000 0.004 0.004
#> GSM123226     1  0.0564      0.867 0.988 0.004 0.004 0.004
#> GSM123227     3  0.5560      0.779 0.024 0.392 0.584 0.000
#> GSM123228     1  0.1389      0.843 0.952 0.000 0.048 0.000
#> GSM123229     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM123230     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM123231     3  0.6354      0.746 0.064 0.416 0.520 0.000
#> GSM123232     1  0.0336      0.866 0.992 0.000 0.008 0.000
#> GSM123233     3  0.0707      0.268 0.020 0.000 0.980 0.000
#> GSM123234     1  0.4817      0.284 0.612 0.000 0.388 0.000
#> GSM123235     1  0.5799      0.354 0.552 0.420 0.024 0.004
#> GSM123236     3  0.5465      0.779 0.020 0.392 0.588 0.000
#> GSM123237     1  0.0524      0.866 0.988 0.008 0.000 0.004
#> GSM123238     1  0.4500      0.447 0.684 0.000 0.000 0.316
#> GSM123239     3  0.5440      0.779 0.020 0.384 0.596 0.000
#> GSM123240     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM123241     1  0.0376      0.867 0.992 0.004 0.000 0.004
#> GSM123242     4  0.4248      0.650 0.000 0.220 0.012 0.768
#> GSM123182     3  0.6959      0.738 0.100 0.392 0.504 0.004
#> GSM123183     4  0.2546      0.777 0.092 0.000 0.008 0.900
#> GSM123184     4  0.0336      0.825 0.000 0.000 0.008 0.992
#> GSM123185     3  0.3708      0.553 0.020 0.148 0.832 0.000
#> GSM123186     1  0.5016      0.414 0.600 0.396 0.000 0.004
#> GSM123187     3  0.6220     -0.261 0.020 0.032 0.600 0.348
#> GSM123188     1  0.0376      0.867 0.992 0.004 0.000 0.004
#> GSM123189     1  0.5441      0.395 0.588 0.396 0.012 0.004
#> GSM123190     3  0.7442      0.736 0.096 0.392 0.488 0.024
#> GSM123191     1  0.5190      0.414 0.596 0.396 0.004 0.004
#> GSM123192     1  0.0564      0.866 0.988 0.004 0.004 0.004
#> GSM123193     1  0.0524      0.866 0.988 0.004 0.000 0.008
#> GSM123194     1  0.5441      0.395 0.588 0.396 0.012 0.004
#> GSM123195     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123196     1  0.1909      0.845 0.940 0.048 0.008 0.004
#> GSM123197     1  0.4119      0.667 0.796 0.012 0.004 0.188
#> GSM123198     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123199     1  0.0376      0.867 0.992 0.004 0.004 0.000
#> GSM123200     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123201     3  0.5548      0.780 0.024 0.388 0.588 0.000
#> GSM123202     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123203     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM123204     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123205     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123206     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123207     3  0.6014      0.771 0.052 0.360 0.588 0.000
#> GSM123208     2  0.5582      0.822 0.000 0.576 0.400 0.024
#> GSM123209     2  0.3705      0.190 0.020 0.864 0.092 0.024
#> GSM123210     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0000      0.867 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.6066     0.5902 0.164 0.000 0.196 0.624 0.016
#> GSM123213     4  0.4938     0.6510 0.012 0.208 0.000 0.716 0.064
#> GSM123214     4  0.0290     0.8156 0.000 0.000 0.008 0.992 0.000
#> GSM123215     4  0.0000     0.8168 0.000 0.000 0.000 1.000 0.000
#> GSM123216     1  0.1544     0.6505 0.932 0.000 0.068 0.000 0.000
#> GSM123217     1  0.0794     0.6699 0.972 0.000 0.028 0.000 0.000
#> GSM123218     5  0.5250     0.5220 0.040 0.004 0.404 0.000 0.552
#> GSM123219     1  0.4415    -0.4521 0.552 0.000 0.444 0.000 0.004
#> GSM123220     1  0.2446     0.6618 0.900 0.000 0.056 0.000 0.044
#> GSM123221     1  0.1809     0.6493 0.928 0.000 0.060 0.000 0.012
#> GSM123222     1  0.3297     0.6303 0.848 0.000 0.068 0.000 0.084
#> GSM123223     2  0.0703     0.8569 0.000 0.976 0.000 0.000 0.024
#> GSM123224     1  0.0404     0.6750 0.988 0.000 0.000 0.000 0.012
#> GSM123225     1  0.1197     0.6589 0.952 0.000 0.048 0.000 0.000
#> GSM123226     1  0.3579     0.6132 0.828 0.000 0.072 0.000 0.100
#> GSM123227     5  0.1059     0.6888 0.020 0.004 0.008 0.000 0.968
#> GSM123228     1  0.5480     0.1783 0.560 0.000 0.072 0.000 0.368
#> GSM123229     1  0.2300     0.6605 0.904 0.000 0.072 0.000 0.024
#> GSM123230     1  0.2914     0.6499 0.872 0.000 0.076 0.000 0.052
#> GSM123231     5  0.5080     0.5516 0.020 0.012 0.396 0.000 0.572
#> GSM123232     1  0.3476     0.6368 0.836 0.000 0.076 0.000 0.088
#> GSM123233     5  0.3910     0.4488 0.000 0.272 0.008 0.000 0.720
#> GSM123234     5  0.5449     0.0864 0.376 0.000 0.068 0.000 0.556
#> GSM123235     5  0.6653     0.1815 0.228 0.000 0.364 0.000 0.408
#> GSM123236     5  0.0727     0.6902 0.012 0.004 0.004 0.000 0.980
#> GSM123237     1  0.1205     0.6778 0.956 0.000 0.004 0.000 0.040
#> GSM123238     1  0.6335     0.0979 0.572 0.000 0.172 0.244 0.012
#> GSM123239     5  0.1121     0.6789 0.000 0.044 0.000 0.000 0.956
#> GSM123240     1  0.1740     0.6505 0.932 0.000 0.056 0.000 0.012
#> GSM123241     1  0.1251     0.6775 0.956 0.000 0.008 0.000 0.036
#> GSM123242     4  0.4655     0.7280 0.012 0.112 0.000 0.764 0.112
#> GSM123182     5  0.4779     0.3445 0.016 0.004 0.396 0.000 0.584
#> GSM123183     4  0.4234     0.7491 0.040 0.000 0.172 0.776 0.012
#> GSM123184     4  0.0000     0.8168 0.000 0.000 0.000 1.000 0.000
#> GSM123185     5  0.3840     0.5354 0.012 0.208 0.008 0.000 0.772
#> GSM123186     3  0.6182     0.3017 0.240 0.000 0.584 0.168 0.008
#> GSM123187     2  0.7295    -0.1652 0.008 0.332 0.008 0.328 0.324
#> GSM123188     1  0.0955     0.6762 0.968 0.000 0.004 0.000 0.028
#> GSM123189     3  0.5638     0.5867 0.432 0.000 0.492 0.000 0.076
#> GSM123190     5  0.5119     0.5518 0.028 0.008 0.388 0.000 0.576
#> GSM123191     1  0.4825    -0.3828 0.568 0.000 0.408 0.000 0.024
#> GSM123192     1  0.4088     0.0249 0.632 0.000 0.368 0.000 0.000
#> GSM123193     1  0.3480     0.3499 0.752 0.000 0.248 0.000 0.000
#> GSM123194     3  0.5680     0.5787 0.428 0.000 0.492 0.000 0.080
#> GSM123195     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123196     1  0.5583     0.1822 0.564 0.000 0.352 0.000 0.084
#> GSM123197     1  0.7758    -0.0408 0.456 0.000 0.180 0.264 0.100
#> GSM123198     2  0.0794     0.8545 0.000 0.972 0.000 0.000 0.028
#> GSM123199     1  0.3586     0.6152 0.828 0.000 0.076 0.000 0.096
#> GSM123200     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123201     5  0.0613     0.6902 0.004 0.008 0.004 0.000 0.984
#> GSM123202     2  0.1270     0.8382 0.000 0.948 0.000 0.000 0.052
#> GSM123203     1  0.3639     0.6237 0.824 0.000 0.076 0.000 0.100
#> GSM123204     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.8594 0.000 1.000 0.000 0.000 0.000
#> GSM123207     5  0.0613     0.6845 0.004 0.004 0.008 0.000 0.984
#> GSM123208     2  0.0609     0.8578 0.000 0.980 0.000 0.000 0.020
#> GSM123209     2  0.5801     0.1895 0.004 0.532 0.084 0.000 0.380
#> GSM123210     1  0.0992     0.6779 0.968 0.000 0.008 0.000 0.024
#> GSM123211     1  0.2248     0.6257 0.900 0.000 0.088 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
#> GSM123212     4  0.5689     0.6200 0.008 0.000 0.172 0.556 0.000 0.264
#> GSM123213     4  0.5178     0.6811 0.008 0.156 0.036 0.724 0.028 0.048
#> GSM123214     4  0.0000     0.7315 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123215     4  0.0000     0.7315 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123216     6  0.4650    -0.0273 0.416 0.000 0.008 0.000 0.028 0.548
#> GSM123217     1  0.4443     0.4635 0.596 0.000 0.036 0.000 0.000 0.368
#> GSM123218     3  0.4535     0.6387 0.032 0.000 0.488 0.000 0.480 0.000
#> GSM123219     6  0.5982     0.4183 0.192 0.000 0.264 0.000 0.016 0.528
#> GSM123220     1  0.3774     0.5343 0.664 0.000 0.000 0.000 0.008 0.328
#> GSM123221     6  0.4884     0.3274 0.220 0.000 0.128 0.000 0.000 0.652
#> GSM123222     1  0.4670     0.4457 0.580 0.000 0.028 0.000 0.012 0.380
#> GSM123223     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123224     1  0.3789     0.4467 0.584 0.000 0.000 0.000 0.000 0.416
#> GSM123225     6  0.4667    -0.0646 0.428 0.000 0.008 0.000 0.028 0.536
#> GSM123226     1  0.0260     0.5312 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM123227     5  0.0937     0.4158 0.040 0.000 0.000 0.000 0.960 0.000
#> GSM123228     1  0.1075     0.4941 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM123229     1  0.3945     0.4928 0.612 0.000 0.008 0.000 0.000 0.380
#> GSM123230     1  0.1531     0.5171 0.928 0.000 0.004 0.000 0.000 0.068
#> GSM123231     5  0.4535    -0.8251 0.032 0.000 0.484 0.000 0.484 0.000
#> GSM123232     1  0.0260     0.5312 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM123233     5  0.4492     0.3630 0.000 0.216 0.080 0.000 0.700 0.004
#> GSM123234     5  0.6665     0.0714 0.392 0.000 0.124 0.000 0.404 0.080
#> GSM123235     3  0.5864     0.6801 0.120 0.000 0.488 0.000 0.372 0.020
#> GSM123236     5  0.1074     0.4064 0.028 0.000 0.012 0.000 0.960 0.000
#> GSM123237     1  0.3847     0.5212 0.644 0.000 0.000 0.000 0.008 0.348
#> GSM123238     6  0.6134     0.1659 0.132 0.000 0.080 0.196 0.000 0.592
#> GSM123239     5  0.1970     0.3479 0.028 0.000 0.060 0.000 0.912 0.000
#> GSM123240     6  0.4039    -0.0567 0.424 0.000 0.008 0.000 0.000 0.568
#> GSM123241     1  0.3833     0.5239 0.648 0.000 0.000 0.000 0.008 0.344
#> GSM123242     4  0.5252     0.6951 0.004 0.128 0.060 0.728 0.032 0.048
#> GSM123182     5  0.5391     0.2129 0.000 0.000 0.244 0.000 0.580 0.176
#> GSM123183     4  0.5296     0.6321 0.000 0.000 0.168 0.596 0.000 0.236
#> GSM123184     4  0.0000     0.7315 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123185     5  0.4716     0.3868 0.004 0.152 0.084 0.000 0.732 0.028
#> GSM123186     6  0.3990     0.4488 0.016 0.000 0.256 0.004 0.008 0.716
#> GSM123187     4  0.7722     0.1553 0.000 0.260 0.088 0.360 0.264 0.028
#> GSM123188     1  0.3819     0.5296 0.652 0.000 0.000 0.000 0.008 0.340
#> GSM123189     6  0.6672     0.4115 0.152 0.000 0.312 0.000 0.072 0.464
#> GSM123190     5  0.4763    -0.8181 0.032 0.000 0.476 0.000 0.484 0.008
#> GSM123191     6  0.6334     0.3929 0.224 0.000 0.216 0.000 0.040 0.520
#> GSM123192     6  0.2629     0.4522 0.048 0.000 0.036 0.000 0.028 0.888
#> GSM123193     6  0.5768     0.2762 0.316 0.000 0.196 0.000 0.000 0.488
#> GSM123194     6  0.7200     0.3558 0.240 0.000 0.276 0.000 0.096 0.388
#> GSM123195     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     1  0.5487     0.1687 0.480 0.000 0.428 0.000 0.020 0.072
#> GSM123197     6  0.7413    -0.1621 0.020 0.000 0.168 0.188 0.148 0.476
#> GSM123198     2  0.0547     0.9594 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM123199     1  0.0260     0.5312 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM123200     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.0713     0.4141 0.028 0.000 0.000 0.000 0.972 0.000
#> GSM123202     2  0.2699     0.8223 0.000 0.864 0.020 0.000 0.108 0.008
#> GSM123203     1  0.0790     0.5391 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM123204     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123206     2  0.0000     0.9732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123207     5  0.1483     0.4176 0.008 0.000 0.012 0.000 0.944 0.036
#> GSM123208     2  0.0363     0.9656 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM123209     5  0.6305    -0.3011 0.000 0.316 0.292 0.000 0.384 0.008
#> GSM123210     1  0.3756     0.4746 0.600 0.000 0.000 0.000 0.000 0.400
#> GSM123211     6  0.3390     0.2331 0.296 0.000 0.000 0.000 0.000 0.704

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) k
#> MAD:mclust 57           0.1375 2
#> MAD:mclust 45           0.0078 3
#> MAD:mclust 48           0.0521 4
#> MAD:mclust 46           0.0120 5
#> MAD:mclust 27           0.0212 6

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


MAD:NMF

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.771           0.853       0.941         0.4856 0.508   0.508
#> 3 3 0.842           0.871       0.944         0.2824 0.776   0.590
#> 4 4 0.596           0.595       0.825         0.1536 0.842   0.601
#> 5 5 0.731           0.749       0.861         0.0805 0.901   0.674
#> 6 6 0.607           0.539       0.738         0.0436 0.928   0.717

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
#> GSM123212     2   0.975      0.295 0.408 0.592
#> GSM123213     2   0.000      0.902 0.000 1.000
#> GSM123214     2   0.000      0.902 0.000 1.000
#> GSM123215     2   0.000      0.902 0.000 1.000
#> GSM123216     1   0.000      0.952 1.000 0.000
#> GSM123217     1   0.000      0.952 1.000 0.000
#> GSM123218     1   0.932      0.387 0.652 0.348
#> GSM123219     1   0.000      0.952 1.000 0.000
#> GSM123220     1   0.000      0.952 1.000 0.000
#> GSM123221     1   0.000      0.952 1.000 0.000
#> GSM123222     1   0.000      0.952 1.000 0.000
#> GSM123223     2   0.000      0.902 0.000 1.000
#> GSM123224     1   0.000      0.952 1.000 0.000
#> GSM123225     1   0.000      0.952 1.000 0.000
#> GSM123226     1   0.000      0.952 1.000 0.000
#> GSM123227     1   0.295      0.904 0.948 0.052
#> GSM123228     1   0.000      0.952 1.000 0.000
#> GSM123229     1   0.000      0.952 1.000 0.000
#> GSM123230     1   0.000      0.952 1.000 0.000
#> GSM123231     2   0.998      0.194 0.472 0.528
#> GSM123232     1   0.000      0.952 1.000 0.000
#> GSM123233     2   0.000      0.902 0.000 1.000
#> GSM123234     1   0.000      0.952 1.000 0.000
#> GSM123235     1   0.000      0.952 1.000 0.000
#> GSM123236     2   0.932      0.512 0.348 0.652
#> GSM123237     1   0.000      0.952 1.000 0.000
#> GSM123238     1   0.184      0.928 0.972 0.028
#> GSM123239     2   0.000      0.902 0.000 1.000
#> GSM123240     1   0.000      0.952 1.000 0.000
#> GSM123241     1   0.000      0.952 1.000 0.000
#> GSM123242     2   0.000      0.902 0.000 1.000
#> GSM123182     2   0.833      0.651 0.264 0.736
#> GSM123183     1   0.963      0.332 0.612 0.388
#> GSM123184     2   0.000      0.902 0.000 1.000
#> GSM123185     2   0.788      0.690 0.236 0.764
#> GSM123186     1   0.311      0.901 0.944 0.056
#> GSM123187     2   0.000      0.902 0.000 1.000
#> GSM123188     1   0.000      0.952 1.000 0.000
#> GSM123189     1   0.000      0.952 1.000 0.000
#> GSM123190     2   0.327      0.861 0.060 0.940
#> GSM123191     1   0.000      0.952 1.000 0.000
#> GSM123192     1   0.000      0.952 1.000 0.000
#> GSM123193     1   0.000      0.952 1.000 0.000
#> GSM123194     1   0.000      0.952 1.000 0.000
#> GSM123195     2   0.000      0.902 0.000 1.000
#> GSM123196     1   0.000      0.952 1.000 0.000
#> GSM123197     1   0.939      0.413 0.644 0.356
#> GSM123198     2   0.000      0.902 0.000 1.000
#> GSM123199     1   0.000      0.952 1.000 0.000
#> GSM123200     2   0.000      0.902 0.000 1.000
#> GSM123201     1   0.767      0.663 0.776 0.224
#> GSM123202     2   0.000      0.902 0.000 1.000
#> GSM123203     1   0.000      0.952 1.000 0.000
#> GSM123204     2   0.000      0.902 0.000 1.000
#> GSM123205     2   0.000      0.902 0.000 1.000
#> GSM123206     2   0.000      0.902 0.000 1.000
#> GSM123207     2   0.955      0.452 0.376 0.624
#> GSM123208     2   0.000      0.902 0.000 1.000
#> GSM123209     2   0.000      0.902 0.000 1.000
#> GSM123210     1   0.000      0.952 1.000 0.000
#> GSM123211     1   0.000      0.952 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0237      0.875 0.004 0.996 0.000
#> GSM123213     2  0.1031      0.865 0.000 0.976 0.024
#> GSM123214     2  0.0592      0.871 0.000 0.988 0.012
#> GSM123215     2  0.0237      0.874 0.000 0.996 0.004
#> GSM123216     1  0.1031      0.953 0.976 0.024 0.000
#> GSM123217     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123218     3  0.6505      0.212 0.468 0.004 0.528
#> GSM123219     1  0.0424      0.968 0.992 0.008 0.000
#> GSM123220     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123221     1  0.1163      0.950 0.972 0.028 0.000
#> GSM123222     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123223     3  0.2356      0.851 0.000 0.072 0.928
#> GSM123224     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123225     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123226     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123227     1  0.6345      0.210 0.596 0.004 0.400
#> GSM123228     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123229     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123230     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123231     3  0.2945      0.853 0.088 0.004 0.908
#> GSM123232     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123233     3  0.0237      0.898 0.004 0.000 0.996
#> GSM123234     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123235     1  0.0475      0.967 0.992 0.004 0.004
#> GSM123236     3  0.2625      0.857 0.084 0.000 0.916
#> GSM123237     1  0.0592      0.966 0.988 0.012 0.000
#> GSM123238     2  0.5560      0.638 0.300 0.700 0.000
#> GSM123239     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123240     1  0.1163      0.950 0.972 0.028 0.000
#> GSM123241     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123242     2  0.0237      0.874 0.000 0.996 0.004
#> GSM123182     2  0.2703      0.841 0.056 0.928 0.016
#> GSM123183     2  0.0237      0.875 0.004 0.996 0.000
#> GSM123184     2  0.0237      0.874 0.000 0.996 0.004
#> GSM123185     3  0.3038      0.842 0.104 0.000 0.896
#> GSM123186     2  0.1411      0.865 0.036 0.964 0.000
#> GSM123187     3  0.3551      0.795 0.000 0.132 0.868
#> GSM123188     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123189     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123190     3  0.0829      0.894 0.012 0.004 0.984
#> GSM123191     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123192     2  0.5497      0.651 0.292 0.708 0.000
#> GSM123193     1  0.1163      0.954 0.972 0.028 0.000
#> GSM123194     1  0.0237      0.969 0.996 0.004 0.000
#> GSM123195     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123196     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123197     2  0.6126      0.436 0.400 0.600 0.000
#> GSM123198     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123199     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123200     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123201     3  0.5835      0.547 0.340 0.000 0.660
#> GSM123202     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123203     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123204     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123205     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123206     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123207     3  0.4887      0.708 0.228 0.000 0.772
#> GSM123208     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123209     3  0.0000      0.899 0.000 0.000 1.000
#> GSM123210     1  0.0000      0.971 1.000 0.000 0.000
#> GSM123211     1  0.3412      0.830 0.876 0.124 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.0672     0.8180 0.008 0.008 0.000 0.984
#> GSM123213     4  0.2921     0.7050 0.000 0.140 0.000 0.860
#> GSM123214     4  0.0000     0.8211 0.000 0.000 0.000 1.000
#> GSM123215     4  0.0000     0.8211 0.000 0.000 0.000 1.000
#> GSM123216     1  0.1004     0.8359 0.972 0.000 0.024 0.004
#> GSM123217     1  0.4103     0.6512 0.744 0.000 0.256 0.000
#> GSM123218     3  0.7012     0.2664 0.156 0.284 0.560 0.000
#> GSM123219     3  0.6070     0.0517 0.404 0.000 0.548 0.048
#> GSM123220     1  0.1118     0.8348 0.964 0.000 0.036 0.000
#> GSM123221     1  0.0592     0.8306 0.984 0.000 0.016 0.000
#> GSM123222     1  0.3801     0.5881 0.780 0.000 0.220 0.000
#> GSM123223     2  0.3873     0.6128 0.000 0.772 0.000 0.228
#> GSM123224     1  0.0000     0.8355 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0707     0.8371 0.980 0.000 0.020 0.000
#> GSM123226     1  0.3172     0.7638 0.840 0.000 0.160 0.000
#> GSM123227     3  0.4939     0.4390 0.220 0.040 0.740 0.000
#> GSM123228     3  0.4989     0.0464 0.472 0.000 0.528 0.000
#> GSM123229     1  0.0336     0.8368 0.992 0.000 0.008 0.000
#> GSM123230     1  0.1557     0.8122 0.944 0.000 0.056 0.000
#> GSM123231     3  0.4933    -0.0194 0.000 0.432 0.568 0.000
#> GSM123232     1  0.0000     0.8355 1.000 0.000 0.000 0.000
#> GSM123233     3  0.4977     0.0278 0.000 0.460 0.540 0.000
#> GSM123234     1  0.5372     0.0574 0.544 0.012 0.444 0.000
#> GSM123235     1  0.3852     0.7285 0.800 0.008 0.192 0.000
#> GSM123236     3  0.5793     0.2355 0.040 0.360 0.600 0.000
#> GSM123237     1  0.3402     0.7524 0.832 0.000 0.164 0.004
#> GSM123238     4  0.5438     0.2261 0.452 0.008 0.004 0.536
#> GSM123239     2  0.1211     0.8080 0.000 0.960 0.040 0.000
#> GSM123240     1  0.0188     0.8355 0.996 0.000 0.000 0.004
#> GSM123241     1  0.2408     0.8014 0.896 0.000 0.104 0.000
#> GSM123242     4  0.0000     0.8211 0.000 0.000 0.000 1.000
#> GSM123182     3  0.4040     0.2650 0.000 0.000 0.752 0.248
#> GSM123183     4  0.0524     0.8194 0.008 0.004 0.000 0.988
#> GSM123184     4  0.0000     0.8211 0.000 0.000 0.000 1.000
#> GSM123185     3  0.5702     0.1389 0.016 0.404 0.572 0.008
#> GSM123186     4  0.5615     0.4405 0.032 0.000 0.356 0.612
#> GSM123187     2  0.4277     0.5402 0.000 0.720 0.000 0.280
#> GSM123188     1  0.1022     0.8355 0.968 0.000 0.032 0.000
#> GSM123189     3  0.4991     0.1164 0.388 0.000 0.608 0.004
#> GSM123190     2  0.6031     0.0847 0.044 0.536 0.420 0.000
#> GSM123191     1  0.4500     0.5617 0.684 0.000 0.316 0.000
#> GSM123192     4  0.5111     0.6000 0.204 0.000 0.056 0.740
#> GSM123193     1  0.4304     0.6099 0.716 0.000 0.284 0.000
#> GSM123194     3  0.3688     0.4172 0.208 0.000 0.792 0.000
#> GSM123195     2  0.0188     0.8217 0.000 0.996 0.004 0.000
#> GSM123196     1  0.3074     0.7715 0.848 0.000 0.152 0.000
#> GSM123197     1  0.6021     0.0522 0.556 0.024 0.012 0.408
#> GSM123198     2  0.0336     0.8208 0.000 0.992 0.008 0.000
#> GSM123199     1  0.0921     0.8323 0.972 0.000 0.028 0.000
#> GSM123200     2  0.0188     0.8215 0.000 0.996 0.004 0.000
#> GSM123201     3  0.6592     0.1705 0.084 0.392 0.524 0.000
#> GSM123202     2  0.0000     0.8212 0.000 1.000 0.000 0.000
#> GSM123203     1  0.0592     0.8317 0.984 0.000 0.016 0.000
#> GSM123204     2  0.0188     0.8204 0.000 0.996 0.004 0.000
#> GSM123205     2  0.0000     0.8212 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0188     0.8217 0.000 0.996 0.004 0.000
#> GSM123207     2  0.6826    -0.0541 0.100 0.484 0.416 0.000
#> GSM123208     2  0.2814     0.7188 0.000 0.868 0.132 0.000
#> GSM123209     2  0.1118     0.8060 0.000 0.964 0.036 0.000
#> GSM123210     1  0.0000     0.8355 1.000 0.000 0.000 0.000
#> GSM123211     1  0.0592     0.8339 0.984 0.000 0.000 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.1082      0.920 0.028 0.000 0.000 0.964 0.008
#> GSM123213     4  0.1195      0.915 0.000 0.028 0.000 0.960 0.012
#> GSM123214     4  0.0324      0.931 0.000 0.004 0.004 0.992 0.000
#> GSM123215     4  0.0162      0.932 0.000 0.000 0.004 0.996 0.000
#> GSM123216     1  0.1653      0.810 0.944 0.000 0.024 0.004 0.028
#> GSM123217     1  0.5294      0.331 0.564 0.000 0.380 0.000 0.056
#> GSM123218     3  0.2095      0.763 0.008 0.012 0.920 0.000 0.060
#> GSM123219     3  0.3213      0.758 0.028 0.000 0.872 0.040 0.060
#> GSM123220     1  0.2230      0.800 0.912 0.000 0.044 0.000 0.044
#> GSM123221     1  0.1124      0.803 0.960 0.000 0.000 0.004 0.036
#> GSM123222     1  0.4420      0.219 0.548 0.000 0.004 0.000 0.448
#> GSM123223     2  0.1618      0.930 0.000 0.944 0.008 0.040 0.008
#> GSM123224     1  0.0000      0.808 1.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.1653      0.811 0.944 0.000 0.024 0.004 0.028
#> GSM123226     1  0.5382      0.451 0.592 0.000 0.336 0.000 0.072
#> GSM123227     5  0.3381      0.716 0.016 0.000 0.176 0.000 0.808
#> GSM123228     5  0.3060      0.756 0.128 0.000 0.024 0.000 0.848
#> GSM123229     1  0.2136      0.786 0.904 0.000 0.088 0.000 0.008
#> GSM123230     1  0.4326      0.621 0.708 0.000 0.028 0.000 0.264
#> GSM123231     3  0.2390      0.755 0.004 0.044 0.908 0.000 0.044
#> GSM123232     1  0.1571      0.807 0.936 0.000 0.004 0.000 0.060
#> GSM123233     5  0.2295      0.817 0.008 0.088 0.004 0.000 0.900
#> GSM123234     5  0.2701      0.802 0.092 0.012 0.012 0.000 0.884
#> GSM123235     1  0.5465      0.405 0.588 0.056 0.348 0.000 0.008
#> GSM123236     5  0.3264      0.770 0.004 0.024 0.132 0.000 0.840
#> GSM123237     1  0.2597      0.764 0.872 0.000 0.120 0.004 0.004
#> GSM123238     1  0.3516      0.698 0.812 0.004 0.000 0.164 0.020
#> GSM123239     2  0.1364      0.935 0.000 0.952 0.036 0.000 0.012
#> GSM123240     1  0.0613      0.807 0.984 0.000 0.004 0.004 0.008
#> GSM123241     1  0.1357      0.806 0.948 0.000 0.048 0.000 0.004
#> GSM123242     4  0.1205      0.919 0.000 0.000 0.004 0.956 0.040
#> GSM123182     3  0.6712      0.255 0.000 0.000 0.412 0.332 0.256
#> GSM123183     4  0.0566      0.930 0.012 0.000 0.000 0.984 0.004
#> GSM123184     4  0.0162      0.932 0.000 0.000 0.004 0.996 0.000
#> GSM123185     5  0.2451      0.819 0.008 0.072 0.004 0.012 0.904
#> GSM123186     3  0.5186      0.316 0.012 0.000 0.556 0.408 0.024
#> GSM123187     2  0.3437      0.781 0.000 0.808 0.004 0.176 0.012
#> GSM123188     1  0.1124      0.809 0.960 0.000 0.036 0.000 0.004
#> GSM123189     3  0.1981      0.762 0.016 0.000 0.920 0.000 0.064
#> GSM123190     3  0.2585      0.756 0.008 0.024 0.896 0.000 0.072
#> GSM123191     3  0.4166      0.294 0.348 0.000 0.648 0.000 0.004
#> GSM123192     4  0.3929      0.642 0.208 0.000 0.028 0.764 0.000
#> GSM123193     1  0.4752      0.311 0.568 0.000 0.412 0.000 0.020
#> GSM123194     3  0.2251      0.749 0.052 0.008 0.916 0.000 0.024
#> GSM123195     2  0.0992      0.937 0.000 0.968 0.024 0.000 0.008
#> GSM123196     1  0.4350      0.363 0.588 0.000 0.408 0.000 0.004
#> GSM123197     1  0.4458      0.606 0.744 0.216 0.004 0.016 0.020
#> GSM123198     2  0.2740      0.883 0.000 0.876 0.028 0.000 0.096
#> GSM123199     1  0.1894      0.801 0.920 0.000 0.008 0.000 0.072
#> GSM123200     2  0.0290      0.940 0.000 0.992 0.008 0.000 0.000
#> GSM123201     5  0.1904      0.830 0.020 0.028 0.016 0.000 0.936
#> GSM123202     2  0.0968      0.939 0.004 0.972 0.012 0.000 0.012
#> GSM123203     1  0.1638      0.804 0.932 0.000 0.004 0.000 0.064
#> GSM123204     2  0.0898      0.937 0.000 0.972 0.008 0.000 0.020
#> GSM123205     2  0.1740      0.918 0.000 0.932 0.012 0.000 0.056
#> GSM123206     2  0.0404      0.939 0.000 0.988 0.012 0.000 0.000
#> GSM123207     5  0.4194      0.633 0.016 0.260 0.004 0.000 0.720
#> GSM123208     2  0.2519      0.890 0.000 0.884 0.100 0.000 0.016
#> GSM123209     2  0.1503      0.931 0.020 0.952 0.020 0.000 0.008
#> GSM123210     1  0.0290      0.807 0.992 0.000 0.000 0.000 0.008
#> GSM123211     1  0.0613      0.807 0.984 0.000 0.008 0.004 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.3531     0.7122 0.108 0.004 0.008 0.820 0.000 0.060
#> GSM123213     4  0.0551     0.7994 0.000 0.004 0.000 0.984 0.004 0.008
#> GSM123214     4  0.0405     0.8019 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM123215     4  0.0436     0.8018 0.000 0.000 0.004 0.988 0.004 0.004
#> GSM123216     1  0.2992     0.7250 0.864 0.000 0.068 0.000 0.024 0.044
#> GSM123217     1  0.5558     0.3751 0.588 0.000 0.288 0.000 0.028 0.096
#> GSM123218     3  0.3009     0.5453 0.004 0.024 0.860 0.000 0.020 0.092
#> GSM123219     3  0.5788     0.5394 0.152 0.000 0.620 0.048 0.000 0.180
#> GSM123220     1  0.2577     0.7400 0.888 0.000 0.056 0.000 0.040 0.016
#> GSM123221     1  0.3602     0.7198 0.824 0.000 0.048 0.008 0.016 0.104
#> GSM123222     5  0.5351     0.2754 0.376 0.000 0.060 0.000 0.540 0.024
#> GSM123223     2  0.3525     0.6217 0.000 0.796 0.024 0.168 0.004 0.008
#> GSM123224     1  0.2513     0.7272 0.888 0.000 0.060 0.000 0.008 0.044
#> GSM123225     1  0.3278     0.7258 0.848 0.000 0.064 0.000 0.032 0.056
#> GSM123226     1  0.5997     0.3534 0.524 0.000 0.336 0.000 0.084 0.056
#> GSM123227     5  0.4350     0.4932 0.044 0.000 0.116 0.000 0.768 0.072
#> GSM123228     5  0.2793     0.5800 0.112 0.000 0.028 0.000 0.856 0.004
#> GSM123229     1  0.5240     0.4978 0.636 0.000 0.256 0.000 0.028 0.080
#> GSM123230     5  0.6888     0.1034 0.372 0.000 0.172 0.000 0.380 0.076
#> GSM123231     3  0.4689     0.4890 0.008 0.084 0.760 0.000 0.068 0.080
#> GSM123232     1  0.1858     0.7432 0.924 0.000 0.012 0.000 0.052 0.012
#> GSM123233     5  0.1749     0.5130 0.000 0.016 0.004 0.004 0.932 0.044
#> GSM123234     5  0.4861     0.5346 0.084 0.000 0.112 0.000 0.732 0.072
#> GSM123235     3  0.7800     0.1348 0.232 0.264 0.376 0.000 0.036 0.092
#> GSM123236     6  0.6118     0.0592 0.012 0.012 0.144 0.000 0.328 0.504
#> GSM123237     1  0.4225     0.6304 0.748 0.000 0.124 0.004 0.000 0.124
#> GSM123238     1  0.3531     0.6773 0.816 0.004 0.004 0.128 0.004 0.044
#> GSM123239     2  0.2772     0.7122 0.000 0.876 0.048 0.000 0.060 0.016
#> GSM123240     1  0.2452     0.7217 0.884 0.000 0.028 0.004 0.000 0.084
#> GSM123241     1  0.2317     0.7403 0.900 0.000 0.064 0.000 0.016 0.020
#> GSM123242     4  0.2095     0.7679 0.000 0.000 0.016 0.904 0.004 0.076
#> GSM123182     4  0.6622     0.0500 0.000 0.000 0.328 0.448 0.168 0.056
#> GSM123183     4  0.2237     0.7728 0.064 0.004 0.004 0.904 0.000 0.024
#> GSM123184     4  0.0551     0.8016 0.000 0.000 0.004 0.984 0.008 0.004
#> GSM123185     5  0.1864     0.5173 0.000 0.004 0.000 0.040 0.924 0.032
#> GSM123186     3  0.6366     0.3013 0.084 0.000 0.524 0.288 0.000 0.104
#> GSM123187     2  0.5627     0.2434 0.000 0.544 0.000 0.328 0.016 0.112
#> GSM123188     1  0.3196     0.6937 0.828 0.000 0.064 0.000 0.000 0.108
#> GSM123189     3  0.3345     0.5942 0.052 0.000 0.828 0.004 0.004 0.112
#> GSM123190     3  0.4734     0.4329 0.004 0.016 0.624 0.000 0.028 0.328
#> GSM123191     3  0.4421     0.4637 0.232 0.008 0.716 0.004 0.012 0.028
#> GSM123192     4  0.6068     0.3195 0.308 0.000 0.076 0.540 0.000 0.076
#> GSM123193     1  0.5036     0.2730 0.564 0.000 0.360 0.000 0.004 0.072
#> GSM123194     3  0.5318     0.5332 0.112 0.000 0.632 0.004 0.012 0.240
#> GSM123195     2  0.2006     0.7358 0.000 0.904 0.080 0.000 0.000 0.016
#> GSM123196     1  0.6553     0.1591 0.440 0.024 0.400 0.000 0.044 0.092
#> GSM123197     1  0.5239     0.5520 0.688 0.208 0.004 0.024 0.024 0.052
#> GSM123198     6  0.5699     0.4238 0.000 0.344 0.056 0.000 0.056 0.544
#> GSM123199     1  0.3956     0.6635 0.792 0.000 0.072 0.000 0.112 0.024
#> GSM123200     2  0.1225     0.7487 0.000 0.952 0.036 0.000 0.000 0.012
#> GSM123201     5  0.4345     0.4301 0.028 0.008 0.016 0.000 0.720 0.228
#> GSM123202     2  0.0508     0.7482 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM123203     1  0.4201     0.6244 0.760 0.000 0.056 0.000 0.160 0.024
#> GSM123204     2  0.2834     0.6561 0.000 0.852 0.008 0.000 0.020 0.120
#> GSM123205     6  0.5174     0.2385 0.000 0.460 0.008 0.000 0.064 0.468
#> GSM123206     2  0.0935     0.7397 0.000 0.964 0.004 0.000 0.000 0.032
#> GSM123207     5  0.5542    -0.0627 0.004 0.132 0.000 0.000 0.528 0.336
#> GSM123208     2  0.2199     0.7317 0.000 0.892 0.088 0.000 0.000 0.020
#> GSM123209     2  0.4980     0.1293 0.064 0.600 0.004 0.000 0.004 0.328
#> GSM123210     1  0.1226     0.7398 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM123211     1  0.1946     0.7358 0.912 0.000 0.012 0.004 0.000 0.072

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) k
#> MAD:NMF 55           0.1371 2
#> MAD:NMF 58           0.0362 3
#> MAD:NMF 43           0.0188 4
#> MAD:NMF 52           0.0822 5
#> MAD:NMF 39           0.3170 6

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


ATC:hclust**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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 1.000           0.989       0.994         0.4439 0.552   0.552
#> 3 3 0.777           0.877       0.916         0.4646 0.770   0.584
#> 4 4 0.683           0.753       0.858         0.0768 0.950   0.846
#> 5 5 0.834           0.748       0.834         0.0816 0.919   0.719
#> 6 6 0.829           0.610       0.811         0.0625 0.940   0.753

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
#> GSM123212     2  0.0000      0.981 0.000 1.000
#> GSM123213     2  0.0000      0.981 0.000 1.000
#> GSM123214     2  0.0000      0.981 0.000 1.000
#> GSM123215     2  0.0000      0.981 0.000 1.000
#> GSM123216     1  0.0000      0.999 1.000 0.000
#> GSM123217     1  0.0000      0.999 1.000 0.000
#> GSM123218     1  0.0000      0.999 1.000 0.000
#> GSM123219     1  0.0000      0.999 1.000 0.000
#> GSM123220     1  0.0000      0.999 1.000 0.000
#> GSM123221     1  0.0000      0.999 1.000 0.000
#> GSM123222     1  0.0000      0.999 1.000 0.000
#> GSM123223     2  0.0000      0.981 0.000 1.000
#> GSM123224     1  0.0000      0.999 1.000 0.000
#> GSM123225     1  0.0000      0.999 1.000 0.000
#> GSM123226     1  0.0000      0.999 1.000 0.000
#> GSM123227     1  0.0000      0.999 1.000 0.000
#> GSM123228     1  0.0000      0.999 1.000 0.000
#> GSM123229     1  0.0000      0.999 1.000 0.000
#> GSM123230     1  0.0000      0.999 1.000 0.000
#> GSM123231     1  0.0000      0.999 1.000 0.000
#> GSM123232     1  0.0000      0.999 1.000 0.000
#> GSM123233     1  0.0376      0.996 0.996 0.004
#> GSM123234     1  0.0000      0.999 1.000 0.000
#> GSM123235     1  0.0000      0.999 1.000 0.000
#> GSM123236     1  0.0376      0.996 0.996 0.004
#> GSM123237     1  0.0000      0.999 1.000 0.000
#> GSM123238     2  0.0000      0.981 0.000 1.000
#> GSM123239     1  0.0376      0.996 0.996 0.004
#> GSM123240     1  0.0000      0.999 1.000 0.000
#> GSM123241     1  0.0000      0.999 1.000 0.000
#> GSM123242     2  0.4022      0.925 0.080 0.920
#> GSM123182     1  0.0376      0.996 0.996 0.004
#> GSM123183     2  0.0000      0.981 0.000 1.000
#> GSM123184     2  0.0000      0.981 0.000 1.000
#> GSM123185     1  0.0376      0.996 0.996 0.004
#> GSM123186     1  0.0000      0.999 1.000 0.000
#> GSM123187     2  0.4022      0.925 0.080 0.920
#> GSM123188     1  0.0000      0.999 1.000 0.000
#> GSM123189     1  0.0000      0.999 1.000 0.000
#> GSM123190     1  0.0376      0.996 0.996 0.004
#> GSM123191     1  0.0000      0.999 1.000 0.000
#> GSM123192     1  0.0000      0.999 1.000 0.000
#> GSM123193     1  0.0000      0.999 1.000 0.000
#> GSM123194     1  0.0000      0.999 1.000 0.000
#> GSM123195     2  0.0000      0.981 0.000 1.000
#> GSM123196     1  0.0000      0.999 1.000 0.000
#> GSM123197     2  0.0000      0.981 0.000 1.000
#> GSM123198     2  0.2603      0.955 0.044 0.956
#> GSM123199     1  0.0000      0.999 1.000 0.000
#> GSM123200     2  0.0000      0.981 0.000 1.000
#> GSM123201     1  0.0000      0.999 1.000 0.000
#> GSM123202     2  0.2236      0.960 0.036 0.964
#> GSM123203     1  0.0000      0.999 1.000 0.000
#> GSM123204     2  0.0000      0.981 0.000 1.000
#> GSM123205     2  0.0000      0.981 0.000 1.000
#> GSM123206     2  0.0000      0.981 0.000 1.000
#> GSM123207     1  0.0376      0.996 0.996 0.004
#> GSM123208     2  0.0000      0.981 0.000 1.000
#> GSM123209     2  0.5408      0.876 0.124 0.876
#> GSM123210     1  0.0000      0.999 1.000 0.000
#> GSM123211     1  0.0000      0.999 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123213     2  0.0237      0.979 0.000 0.996 0.004
#> GSM123214     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123215     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123216     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123217     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123218     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123219     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123220     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123221     3  0.0424      0.925 0.008 0.000 0.992
#> GSM123222     3  0.0592      0.924 0.012 0.000 0.988
#> GSM123223     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123224     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123225     1  0.4399      0.855 0.812 0.000 0.188
#> GSM123226     1  0.4399      0.855 0.812 0.000 0.188
#> GSM123227     1  0.5291      0.846 0.732 0.000 0.268
#> GSM123228     1  0.4399      0.855 0.812 0.000 0.188
#> GSM123229     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123230     1  0.4399      0.855 0.812 0.000 0.188
#> GSM123231     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123232     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123233     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123234     3  0.5882      0.321 0.348 0.000 0.652
#> GSM123235     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123236     3  0.0592      0.920 0.012 0.000 0.988
#> GSM123237     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123238     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123239     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123240     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123241     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123242     2  0.2625      0.926 0.000 0.916 0.084
#> GSM123182     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123183     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123184     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123185     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123186     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123187     2  0.2625      0.926 0.000 0.916 0.084
#> GSM123188     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123189     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123190     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123191     3  0.0424      0.925 0.008 0.000 0.992
#> GSM123192     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123193     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123194     3  0.6062      0.145 0.384 0.000 0.616
#> GSM123195     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123196     1  0.0424      0.774 0.992 0.000 0.008
#> GSM123197     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123198     2  0.1753      0.955 0.000 0.952 0.048
#> GSM123199     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123200     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123201     3  0.5431      0.478 0.284 0.000 0.716
#> GSM123202     2  0.1529      0.959 0.000 0.960 0.040
#> GSM123203     1  0.5254      0.852 0.736 0.000 0.264
#> GSM123204     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123205     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123206     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123207     3  0.0000      0.923 0.000 0.000 1.000
#> GSM123208     2  0.0000      0.981 0.000 1.000 0.000
#> GSM123209     2  0.3482      0.883 0.000 0.872 0.128
#> GSM123210     3  0.0747      0.925 0.016 0.000 0.984
#> GSM123211     3  0.0747      0.925 0.016 0.000 0.984

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     4  0.2814      0.737 0.000 0.132 0.000 0.868
#> GSM123213     4  0.4008      0.695 0.000 0.244 0.000 0.756
#> GSM123214     2  0.5000     -0.446 0.000 0.500 0.000 0.500
#> GSM123215     4  0.5000      0.300 0.000 0.500 0.000 0.500
#> GSM123216     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123217     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123218     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123219     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123220     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123221     3  0.0524      0.922 0.004 0.000 0.988 0.008
#> GSM123222     3  0.0188      0.922 0.004 0.000 0.996 0.000
#> GSM123223     4  0.5000      0.300 0.000 0.500 0.000 0.500
#> GSM123224     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123225     1  0.3486      0.851 0.812 0.000 0.188 0.000
#> GSM123226     1  0.3486      0.851 0.812 0.000 0.188 0.000
#> GSM123227     1  0.4250      0.841 0.724 0.000 0.276 0.000
#> GSM123228     1  0.3486      0.851 0.812 0.000 0.188 0.000
#> GSM123229     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123230     1  0.3486      0.851 0.812 0.000 0.188 0.000
#> GSM123231     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123232     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123233     3  0.0592      0.921 0.000 0.000 0.984 0.016
#> GSM123234     3  0.4624      0.327 0.340 0.000 0.660 0.000
#> GSM123235     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123236     3  0.1059      0.917 0.012 0.000 0.972 0.016
#> GSM123237     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123238     4  0.2814      0.737 0.000 0.132 0.000 0.868
#> GSM123239     3  0.0592      0.921 0.000 0.000 0.984 0.016
#> GSM123240     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123241     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123242     4  0.2124      0.704 0.000 0.028 0.040 0.932
#> GSM123182     3  0.0592      0.921 0.000 0.000 0.984 0.016
#> GSM123183     4  0.2814      0.737 0.000 0.132 0.000 0.868
#> GSM123184     4  0.4972      0.329 0.000 0.456 0.000 0.544
#> GSM123185     3  0.0592      0.921 0.000 0.000 0.984 0.016
#> GSM123186     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123187     4  0.2124      0.704 0.000 0.028 0.040 0.932
#> GSM123188     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123189     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123190     3  0.0707      0.919 0.000 0.000 0.980 0.020
#> GSM123191     3  0.0524      0.922 0.004 0.000 0.988 0.008
#> GSM123192     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123193     3  0.0524      0.923 0.008 0.000 0.988 0.004
#> GSM123194     3  0.4776      0.152 0.376 0.000 0.624 0.000
#> GSM123195     2  0.0000      0.819 0.000 1.000 0.000 0.000
#> GSM123196     1  0.0336      0.752 0.992 0.000 0.008 0.000
#> GSM123197     4  0.2814      0.737 0.000 0.132 0.000 0.868
#> GSM123198     4  0.2412      0.703 0.000 0.084 0.008 0.908
#> GSM123199     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123200     2  0.2281      0.744 0.000 0.904 0.000 0.096
#> GSM123201     3  0.4250      0.483 0.276 0.000 0.724 0.000
#> GSM123202     4  0.4661      0.321 0.000 0.348 0.000 0.652
#> GSM123203     1  0.4222      0.847 0.728 0.000 0.272 0.000
#> GSM123204     2  0.0000      0.819 0.000 1.000 0.000 0.000
#> GSM123205     2  0.2011      0.756 0.000 0.920 0.000 0.080
#> GSM123206     2  0.1302      0.791 0.000 0.956 0.000 0.044
#> GSM123207     3  0.0592      0.921 0.000 0.000 0.984 0.016
#> GSM123208     2  0.0000      0.819 0.000 1.000 0.000 0.000
#> GSM123209     4  0.2882      0.674 0.000 0.024 0.084 0.892
#> GSM123210     3  0.0336      0.923 0.008 0.000 0.992 0.000
#> GSM123211     3  0.0336      0.923 0.008 0.000 0.992 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
#> GSM123212     4  0.0000     0.6459 0.000 0.000 0.000 1.000 0.000
#> GSM123213     4  0.5909     0.5345 0.164 0.244 0.000 0.592 0.000
#> GSM123214     4  0.4307     0.0666 0.000 0.500 0.000 0.500 0.000
#> GSM123215     2  0.4307    -0.2457 0.000 0.500 0.000 0.500 0.000
#> GSM123216     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123217     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123218     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123219     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972
#> GSM123220     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123221     5  0.0963     0.9100 0.036 0.000 0.000 0.000 0.964
#> GSM123222     5  0.0794     0.9100 0.028 0.000 0.000 0.000 0.972
#> GSM123223     2  0.4307    -0.2457 0.000 0.500 0.000 0.500 0.000
#> GSM123224     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123225     1  0.4227     0.8409 0.580 0.000 0.420 0.000 0.000
#> GSM123226     1  0.4227     0.8409 0.580 0.000 0.420 0.000 0.000
#> GSM123227     1  0.5470     0.9308 0.588 0.000 0.332 0.000 0.080
#> GSM123228     1  0.4227     0.8409 0.580 0.000 0.420 0.000 0.000
#> GSM123229     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123230     1  0.4227     0.8409 0.580 0.000 0.420 0.000 0.000
#> GSM123231     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123232     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123233     5  0.1341     0.9059 0.056 0.000 0.000 0.000 0.944
#> GSM123234     5  0.4873     0.4631 0.044 0.000 0.312 0.000 0.644
#> GSM123235     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123236     5  0.1597     0.9049 0.048 0.000 0.012 0.000 0.940
#> GSM123237     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972
#> GSM123238     4  0.0000     0.6459 0.000 0.000 0.000 1.000 0.000
#> GSM123239     5  0.1341     0.9059 0.056 0.000 0.000 0.000 0.944
#> GSM123240     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972
#> GSM123241     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123242     4  0.5322     0.6361 0.360 0.028 0.000 0.592 0.020
#> GSM123182     5  0.1341     0.9059 0.056 0.000 0.000 0.000 0.944
#> GSM123183     4  0.0000     0.6459 0.000 0.000 0.000 1.000 0.000
#> GSM123184     4  0.4811     0.1251 0.020 0.452 0.000 0.528 0.000
#> GSM123185     5  0.1341     0.9059 0.056 0.000 0.000 0.000 0.944
#> GSM123186     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972
#> GSM123187     4  0.5322     0.6361 0.360 0.028 0.000 0.592 0.020
#> GSM123188     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123189     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123190     5  0.1410     0.9046 0.060 0.000 0.000 0.000 0.940
#> GSM123191     5  0.0963     0.9100 0.036 0.000 0.000 0.000 0.964
#> GSM123192     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972
#> GSM123193     5  0.0404     0.9108 0.012 0.000 0.000 0.000 0.988
#> GSM123194     5  0.5516     0.3534 0.096 0.000 0.296 0.000 0.608
#> GSM123195     2  0.0000     0.6889 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM123197     4  0.0000     0.6459 0.000 0.000 0.000 1.000 0.000
#> GSM123198     4  0.5896     0.6103 0.336 0.084 0.000 0.568 0.012
#> GSM123199     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123200     2  0.1965     0.6455 0.096 0.904 0.000 0.000 0.000
#> GSM123201     5  0.4243     0.5801 0.024 0.000 0.264 0.000 0.712
#> GSM123202     2  0.6954    -0.2304 0.336 0.348 0.000 0.312 0.004
#> GSM123203     1  0.5484     0.9409 0.584 0.000 0.336 0.000 0.080
#> GSM123204     2  0.0000     0.6889 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.2036     0.6543 0.024 0.920 0.000 0.056 0.000
#> GSM123206     2  0.1399     0.6673 0.020 0.952 0.000 0.028 0.000
#> GSM123207     5  0.1197     0.9071 0.048 0.000 0.000 0.000 0.952
#> GSM123208     2  0.0000     0.6889 0.000 1.000 0.000 0.000 0.000
#> GSM123209     4  0.5765     0.6124 0.368 0.024 0.000 0.560 0.048
#> GSM123210     5  0.0703     0.9100 0.024 0.000 0.000 0.000 0.976
#> GSM123211     5  0.0794     0.9093 0.028 0.000 0.000 0.000 0.972

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.0000     0.5329 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123213     4  0.5890    -0.0239 0.000 0.240 0.000 0.472 0.000 0.288
#> GSM123214     2  0.4592    -0.0309 0.000 0.496 0.000 0.468 0.000 0.036
#> GSM123215     2  0.4592    -0.0309 0.000 0.496 0.000 0.468 0.000 0.036
#> GSM123216     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123217     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123218     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123219     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM123220     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123221     5  0.4051     0.7435 0.008 0.000 0.432 0.000 0.560 0.000
#> GSM123222     5  0.3898     0.7349 0.012 0.000 0.336 0.000 0.652 0.000
#> GSM123223     2  0.4592    -0.0309 0.000 0.496 0.000 0.468 0.000 0.036
#> GSM123224     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123225     1  0.0363     0.8109 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM123226     1  0.0363     0.8109 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM123227     1  0.1501     0.8644 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123228     1  0.0363     0.8109 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM123229     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123230     1  0.0632     0.8008 0.976 0.000 0.024 0.000 0.000 0.000
#> GSM123231     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123232     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123233     5  0.3996     0.7338 0.004 0.000 0.484 0.000 0.512 0.000
#> GSM123234     1  0.6128    -0.3066 0.344 0.000 0.340 0.000 0.316 0.000
#> GSM123235     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123236     5  0.4250     0.7360 0.016 0.000 0.456 0.000 0.528 0.000
#> GSM123237     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM123238     4  0.0000     0.5329 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123239     5  0.3996     0.7338 0.004 0.000 0.484 0.000 0.512 0.000
#> GSM123240     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM123241     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123242     4  0.5226    -0.2955 0.000 0.016 0.044 0.472 0.004 0.464
#> GSM123182     5  0.3996     0.7338 0.004 0.000 0.484 0.000 0.512 0.000
#> GSM123183     4  0.0000     0.5329 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123184     4  0.5422    -0.0981 0.000 0.436 0.012 0.472 0.000 0.080
#> GSM123185     5  0.3996     0.7338 0.004 0.000 0.484 0.000 0.512 0.000
#> GSM123186     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM123187     4  0.5226    -0.2955 0.000 0.016 0.044 0.472 0.004 0.464
#> GSM123188     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123189     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123190     5  0.4126     0.7336 0.004 0.000 0.480 0.000 0.512 0.004
#> GSM123191     5  0.4051     0.7435 0.008 0.000 0.432 0.000 0.560 0.000
#> GSM123192     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM123193     5  0.0508     0.6915 0.004 0.000 0.012 0.000 0.984 0.000
#> GSM123194     1  0.6074    -0.1291 0.388 0.000 0.340 0.000 0.272 0.000
#> GSM123195     2  0.0000     0.6585 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.5472     1.0000 0.132 0.000 0.504 0.000 0.000 0.364
#> GSM123197     4  0.0000     0.5329 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123198     6  0.5271     0.4864 0.000 0.084 0.012 0.328 0.000 0.576
#> GSM123199     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123200     2  0.1765     0.5775 0.000 0.904 0.000 0.000 0.000 0.096
#> GSM123201     5  0.6099     0.3519 0.288 0.000 0.336 0.000 0.376 0.000
#> GSM123202     6  0.5298     0.4213 0.000 0.348 0.004 0.100 0.000 0.548
#> GSM123203     1  0.1501     0.8702 0.924 0.000 0.000 0.000 0.076 0.000
#> GSM123204     2  0.0000     0.6585 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.1610     0.5991 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM123206     2  0.1578     0.6281 0.000 0.936 0.012 0.004 0.000 0.048
#> GSM123207     5  0.3993     0.7359 0.004 0.000 0.476 0.000 0.520 0.000
#> GSM123208     2  0.0000     0.6585 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     6  0.5476     0.4497 0.000 0.012 0.092 0.324 0.004 0.568
#> GSM123210     5  0.0508     0.6909 0.012 0.000 0.004 0.000 0.984 0.000
#> GSM123211     5  0.0260     0.6896 0.008 0.000 0.000 0.000 0.992 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) k
#> ATC:hclust 61           0.1461 2
#> ATC:hclust 58           0.0308 3
#> ATC:hclust 53           0.0101 4
#> ATC:hclust 54           0.0187 5
#> ATC:hclust 48           0.0224 6

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


ATC:kmeans**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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.999       0.999         0.4490 0.552   0.552
#> 3 3 0.598           0.306       0.753         0.3853 0.978   0.960
#> 4 4 0.688           0.832       0.806         0.1592 0.671   0.408
#> 5 5 0.721           0.769       0.819         0.0820 0.958   0.833
#> 6 6 0.750           0.605       0.754         0.0495 0.943   0.739

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
#> GSM123212     2   0.000      1.000 0.000 1.000
#> GSM123213     2   0.000      1.000 0.000 1.000
#> GSM123214     2   0.000      1.000 0.000 1.000
#> GSM123215     2   0.000      1.000 0.000 1.000
#> GSM123216     1   0.000      0.999 1.000 0.000
#> GSM123217     1   0.000      0.999 1.000 0.000
#> GSM123218     1   0.000      0.999 1.000 0.000
#> GSM123219     1   0.000      0.999 1.000 0.000
#> GSM123220     1   0.000      0.999 1.000 0.000
#> GSM123221     1   0.000      0.999 1.000 0.000
#> GSM123222     1   0.000      0.999 1.000 0.000
#> GSM123223     2   0.000      1.000 0.000 1.000
#> GSM123224     1   0.000      0.999 1.000 0.000
#> GSM123225     1   0.000      0.999 1.000 0.000
#> GSM123226     1   0.000      0.999 1.000 0.000
#> GSM123227     1   0.000      0.999 1.000 0.000
#> GSM123228     1   0.000      0.999 1.000 0.000
#> GSM123229     1   0.000      0.999 1.000 0.000
#> GSM123230     1   0.000      0.999 1.000 0.000
#> GSM123231     1   0.000      0.999 1.000 0.000
#> GSM123232     1   0.000      0.999 1.000 0.000
#> GSM123233     1   0.000      0.999 1.000 0.000
#> GSM123234     1   0.000      0.999 1.000 0.000
#> GSM123235     1   0.000      0.999 1.000 0.000
#> GSM123236     1   0.000      0.999 1.000 0.000
#> GSM123237     1   0.000      0.999 1.000 0.000
#> GSM123238     2   0.000      1.000 0.000 1.000
#> GSM123239     1   0.000      0.999 1.000 0.000
#> GSM123240     1   0.000      0.999 1.000 0.000
#> GSM123241     1   0.000      0.999 1.000 0.000
#> GSM123242     2   0.000      1.000 0.000 1.000
#> GSM123182     1   0.000      0.999 1.000 0.000
#> GSM123183     2   0.000      1.000 0.000 1.000
#> GSM123184     2   0.000      1.000 0.000 1.000
#> GSM123185     1   0.000      0.999 1.000 0.000
#> GSM123186     1   0.204      0.967 0.968 0.032
#> GSM123187     2   0.000      1.000 0.000 1.000
#> GSM123188     1   0.000      0.999 1.000 0.000
#> GSM123189     1   0.000      0.999 1.000 0.000
#> GSM123190     1   0.000      0.999 1.000 0.000
#> GSM123191     1   0.000      0.999 1.000 0.000
#> GSM123192     1   0.000      0.999 1.000 0.000
#> GSM123193     1   0.000      0.999 1.000 0.000
#> GSM123194     1   0.000      0.999 1.000 0.000
#> GSM123195     2   0.000      1.000 0.000 1.000
#> GSM123196     1   0.000      0.999 1.000 0.000
#> GSM123197     2   0.000      1.000 0.000 1.000
#> GSM123198     2   0.000      1.000 0.000 1.000
#> GSM123199     1   0.000      0.999 1.000 0.000
#> GSM123200     2   0.000      1.000 0.000 1.000
#> GSM123201     1   0.000      0.999 1.000 0.000
#> GSM123202     2   0.000      1.000 0.000 1.000
#> GSM123203     1   0.000      0.999 1.000 0.000
#> GSM123204     2   0.000      1.000 0.000 1.000
#> GSM123205     2   0.000      1.000 0.000 1.000
#> GSM123206     2   0.000      1.000 0.000 1.000
#> GSM123207     1   0.000      0.999 1.000 0.000
#> GSM123208     2   0.000      1.000 0.000 1.000
#> GSM123209     2   0.000      1.000 0.000 1.000
#> GSM123210     1   0.000      0.999 1.000 0.000
#> GSM123211     1   0.000      0.999 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.4291     0.8881 0.000 0.820 0.180
#> GSM123213     2  0.3752     0.8936 0.000 0.856 0.144
#> GSM123214     2  0.3192     0.8991 0.000 0.888 0.112
#> GSM123215     2  0.3482     0.8988 0.000 0.872 0.128
#> GSM123216     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123217     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123218     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123219     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123220     1  0.2878     0.4158 0.904 0.000 0.096
#> GSM123221     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123222     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123223     2  0.0237     0.8991 0.000 0.996 0.004
#> GSM123224     1  0.2878     0.4158 0.904 0.000 0.096
#> GSM123225     1  0.3551     0.4122 0.868 0.000 0.132
#> GSM123226     1  0.6225     0.3544 0.568 0.000 0.432
#> GSM123227     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123228     1  0.3551     0.4122 0.868 0.000 0.132
#> GSM123229     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123230     1  0.6225     0.3544 0.568 0.000 0.432
#> GSM123231     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123232     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123233     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123234     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123235     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123236     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123237     1  0.5948    -0.4260 0.640 0.000 0.360
#> GSM123238     2  0.4291     0.8881 0.000 0.820 0.180
#> GSM123239     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123240     1  0.5948    -0.4260 0.640 0.000 0.360
#> GSM123241     1  0.1964     0.4130 0.944 0.000 0.056
#> GSM123242     2  0.3752     0.8936 0.000 0.856 0.144
#> GSM123182     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123183     2  0.4291     0.8881 0.000 0.820 0.180
#> GSM123184     2  0.3619     0.8980 0.000 0.864 0.136
#> GSM123185     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123186     3  0.6799     0.0000 0.456 0.012 0.532
#> GSM123187     2  0.6267     0.4677 0.000 0.548 0.452
#> GSM123188     1  0.0424     0.4043 0.992 0.000 0.008
#> GSM123189     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123190     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123191     1  0.4555     0.0447 0.800 0.000 0.200
#> GSM123192     1  0.6215    -0.5978 0.572 0.000 0.428
#> GSM123193     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123194     1  0.0424     0.4043 0.992 0.000 0.008
#> GSM123195     2  0.0592     0.8989 0.000 0.988 0.012
#> GSM123196     1  0.6274     0.3565 0.544 0.000 0.456
#> GSM123197     2  0.4291     0.8881 0.000 0.820 0.180
#> GSM123198     2  0.0000     0.8999 0.000 1.000 0.000
#> GSM123199     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123200     2  0.0237     0.8991 0.000 0.996 0.004
#> GSM123201     1  0.1031     0.3893 0.976 0.000 0.024
#> GSM123202     2  0.0237     0.9005 0.000 0.996 0.004
#> GSM123203     1  0.0000     0.4010 1.000 0.000 0.000
#> GSM123204     2  0.0237     0.8991 0.000 0.996 0.004
#> GSM123205     2  0.0237     0.8991 0.000 0.996 0.004
#> GSM123206     2  0.1031     0.8976 0.000 0.976 0.024
#> GSM123207     1  0.6168    -0.5340 0.588 0.000 0.412
#> GSM123208     2  0.0592     0.8989 0.000 0.988 0.012
#> GSM123209     2  0.6280     0.4069 0.000 0.540 0.460
#> GSM123210     1  0.6062    -0.4249 0.616 0.000 0.384
#> GSM123211     1  0.6225    -0.6117 0.568 0.000 0.432

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     2  0.7146      0.780 0.000 0.560 0.212 0.228
#> GSM123213     2  0.6531      0.809 0.000 0.636 0.204 0.160
#> GSM123214     2  0.5950      0.818 0.000 0.696 0.156 0.148
#> GSM123215     2  0.6360      0.813 0.000 0.656 0.180 0.164
#> GSM123216     1  0.1256      0.850 0.964 0.000 0.008 0.028
#> GSM123217     1  0.0188      0.868 0.996 0.000 0.004 0.000
#> GSM123218     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123219     3  0.4692      0.901 0.212 0.000 0.756 0.032
#> GSM123220     1  0.1389      0.828 0.952 0.000 0.000 0.048
#> GSM123221     3  0.3873      0.908 0.228 0.000 0.772 0.000
#> GSM123222     3  0.4867      0.902 0.232 0.000 0.736 0.032
#> GSM123223     2  0.0469      0.825 0.000 0.988 0.000 0.012
#> GSM123224     1  0.1389      0.828 0.952 0.000 0.000 0.048
#> GSM123225     1  0.1867      0.799 0.928 0.000 0.000 0.072
#> GSM123226     4  0.4522      0.943 0.320 0.000 0.000 0.680
#> GSM123227     1  0.0336      0.867 0.992 0.000 0.008 0.000
#> GSM123228     1  0.2081      0.785 0.916 0.000 0.000 0.084
#> GSM123229     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123230     4  0.4543      0.942 0.324 0.000 0.000 0.676
#> GSM123231     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123232     1  0.0188      0.868 0.996 0.000 0.004 0.000
#> GSM123233     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123234     4  0.4655      0.953 0.312 0.000 0.004 0.684
#> GSM123235     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123236     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123237     1  0.5272      0.313 0.680 0.000 0.288 0.032
#> GSM123238     2  0.7252      0.772 0.000 0.544 0.228 0.228
#> GSM123239     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123240     1  0.5272      0.313 0.680 0.000 0.288 0.032
#> GSM123241     1  0.1109      0.848 0.968 0.000 0.004 0.028
#> GSM123242     2  0.6531      0.809 0.000 0.636 0.204 0.160
#> GSM123182     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123183     2  0.7146      0.780 0.000 0.560 0.212 0.228
#> GSM123184     2  0.6550      0.809 0.000 0.636 0.184 0.180
#> GSM123185     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123186     3  0.4136      0.896 0.196 0.000 0.788 0.016
#> GSM123187     3  0.4182      0.432 0.000 0.180 0.796 0.024
#> GSM123188     1  0.0000      0.867 1.000 0.000 0.000 0.000
#> GSM123189     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123190     3  0.3907      0.908 0.232 0.000 0.768 0.000
#> GSM123191     3  0.4898      0.593 0.416 0.000 0.584 0.000
#> GSM123192     3  0.4617      0.898 0.204 0.000 0.764 0.032
#> GSM123193     3  0.4932      0.892 0.240 0.000 0.728 0.032
#> GSM123194     1  0.0188      0.867 0.996 0.000 0.004 0.000
#> GSM123195     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM123196     4  0.4401      0.976 0.272 0.000 0.004 0.724
#> GSM123197     2  0.7227      0.775 0.000 0.548 0.224 0.228
#> GSM123198     2  0.0524      0.825 0.000 0.988 0.008 0.004
#> GSM123199     1  0.0188      0.868 0.996 0.000 0.004 0.000
#> GSM123200     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM123201     1  0.3400      0.665 0.820 0.000 0.180 0.000
#> GSM123202     2  0.0336      0.825 0.000 0.992 0.008 0.000
#> GSM123203     1  0.0657      0.863 0.984 0.000 0.004 0.012
#> GSM123204     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0469      0.825 0.000 0.988 0.000 0.012
#> GSM123206     2  0.1042      0.822 0.000 0.972 0.008 0.020
#> GSM123207     3  0.3908      0.905 0.212 0.000 0.784 0.004
#> GSM123208     2  0.0000      0.824 0.000 1.000 0.000 0.000
#> GSM123209     3  0.4284      0.643 0.000 0.224 0.764 0.012
#> GSM123210     3  0.4932      0.892 0.240 0.000 0.728 0.032
#> GSM123211     3  0.4655      0.897 0.208 0.000 0.760 0.032

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.4794      0.839 0.000 0.344 0.032 0.624 0.000
#> GSM123213     4  0.5477      0.727 0.004 0.448 0.016 0.508 0.024
#> GSM123214     2  0.5253     -0.663 0.004 0.516 0.004 0.448 0.028
#> GSM123215     2  0.4976     -0.703 0.000 0.504 0.000 0.468 0.028
#> GSM123216     1  0.1498      0.868 0.952 0.000 0.024 0.016 0.008
#> GSM123217     1  0.0451      0.883 0.988 0.000 0.000 0.008 0.004
#> GSM123218     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123219     5  0.4701      0.837 0.036 0.000 0.028 0.192 0.744
#> GSM123220     1  0.0324      0.880 0.992 0.000 0.004 0.004 0.000
#> GSM123221     5  0.1750      0.872 0.036 0.000 0.000 0.028 0.936
#> GSM123222     5  0.4682      0.846 0.056 0.000 0.028 0.152 0.764
#> GSM123223     2  0.1300      0.757 0.000 0.956 0.000 0.016 0.028
#> GSM123224     1  0.0451      0.879 0.988 0.000 0.004 0.008 0.000
#> GSM123225     1  0.2616      0.813 0.880 0.000 0.020 0.100 0.000
#> GSM123226     3  0.5678      0.691 0.284 0.000 0.600 0.116 0.000
#> GSM123227     1  0.2446      0.834 0.900 0.000 0.000 0.044 0.056
#> GSM123228     1  0.2915      0.799 0.860 0.000 0.024 0.116 0.000
#> GSM123229     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123230     3  0.4649      0.818 0.220 0.000 0.716 0.064 0.000
#> GSM123231     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123232     1  0.0451      0.883 0.988 0.000 0.000 0.008 0.004
#> GSM123233     5  0.1661      0.868 0.036 0.000 0.000 0.024 0.940
#> GSM123234     3  0.3650      0.877 0.176 0.000 0.796 0.028 0.000
#> GSM123235     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123236     5  0.1469      0.869 0.036 0.000 0.000 0.016 0.948
#> GSM123237     1  0.5647      0.616 0.684 0.000 0.028 0.180 0.108
#> GSM123238     4  0.4714      0.817 0.000 0.324 0.032 0.644 0.000
#> GSM123239     5  0.1568      0.869 0.036 0.000 0.000 0.020 0.944
#> GSM123240     1  0.5647      0.616 0.684 0.000 0.028 0.180 0.108
#> GSM123241     1  0.0613      0.881 0.984 0.000 0.004 0.004 0.008
#> GSM123242     4  0.5545      0.721 0.004 0.432 0.020 0.520 0.024
#> GSM123182     5  0.1469      0.869 0.036 0.000 0.000 0.016 0.948
#> GSM123183     4  0.4794      0.839 0.000 0.344 0.032 0.624 0.000
#> GSM123184     4  0.4974      0.711 0.000 0.464 0.000 0.508 0.028
#> GSM123185     5  0.1568      0.869 0.036 0.000 0.000 0.020 0.944
#> GSM123186     5  0.4654      0.836 0.028 0.000 0.024 0.216 0.732
#> GSM123187     5  0.4793      0.686 0.004 0.120 0.020 0.088 0.768
#> GSM123188     1  0.0451      0.883 0.988 0.000 0.000 0.008 0.004
#> GSM123189     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123190     5  0.1124      0.870 0.036 0.000 0.000 0.004 0.960
#> GSM123191     5  0.3152      0.819 0.136 0.000 0.000 0.024 0.840
#> GSM123192     5  0.4892      0.831 0.036 0.000 0.028 0.216 0.720
#> GSM123193     5  0.5937      0.773 0.132 0.000 0.028 0.184 0.656
#> GSM123194     1  0.1116      0.872 0.964 0.000 0.004 0.004 0.028
#> GSM123195     2  0.0609      0.785 0.000 0.980 0.020 0.000 0.000
#> GSM123196     3  0.2020      0.930 0.100 0.000 0.900 0.000 0.000
#> GSM123197     4  0.4779      0.838 0.000 0.340 0.032 0.628 0.000
#> GSM123198     2  0.1093      0.775 0.004 0.968 0.020 0.004 0.004
#> GSM123199     1  0.0324      0.883 0.992 0.000 0.000 0.004 0.004
#> GSM123200     2  0.1187      0.784 0.004 0.964 0.024 0.004 0.004
#> GSM123201     1  0.4873      0.468 0.644 0.000 0.000 0.044 0.312
#> GSM123202     2  0.0994      0.778 0.004 0.972 0.016 0.004 0.004
#> GSM123203     1  0.0740      0.881 0.980 0.000 0.008 0.008 0.004
#> GSM123204     2  0.0609      0.785 0.000 0.980 0.020 0.000 0.000
#> GSM123205     2  0.1622      0.755 0.004 0.948 0.004 0.016 0.028
#> GSM123206     2  0.1560      0.758 0.000 0.948 0.020 0.028 0.004
#> GSM123207     5  0.2437      0.873 0.032 0.000 0.004 0.060 0.904
#> GSM123208     2  0.0771      0.785 0.000 0.976 0.020 0.000 0.004
#> GSM123209     5  0.3864      0.765 0.004 0.076 0.020 0.064 0.836
#> GSM123210     5  0.5937      0.773 0.132 0.000 0.028 0.184 0.656
#> GSM123211     5  0.5295      0.818 0.060 0.000 0.028 0.216 0.696

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.2178     0.7244 0.000 0.132 0.000 0.868 0.000 0.000
#> GSM123213     4  0.6077     0.6965 0.000 0.224 0.012 0.496 0.268 0.000
#> GSM123214     4  0.6046     0.6276 0.000 0.328 0.004 0.444 0.224 0.000
#> GSM123215     4  0.5949     0.6772 0.000 0.292 0.004 0.484 0.220 0.000
#> GSM123216     1  0.0260     0.8344 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM123217     1  0.0000     0.8360 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123219     6  0.0260     0.5203 0.008 0.000 0.000 0.000 0.000 0.992
#> GSM123220     1  0.0547     0.8322 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM123221     6  0.4034    -0.2532 0.004 0.000 0.000 0.012 0.336 0.648
#> GSM123222     6  0.3834     0.2161 0.024 0.000 0.000 0.004 0.244 0.728
#> GSM123223     2  0.3081     0.7268 0.000 0.776 0.004 0.000 0.220 0.000
#> GSM123224     1  0.0935     0.8278 0.964 0.000 0.000 0.004 0.032 0.000
#> GSM123225     1  0.3563     0.7169 0.796 0.000 0.000 0.072 0.132 0.000
#> GSM123226     3  0.6930     0.3640 0.316 0.000 0.424 0.084 0.176 0.000
#> GSM123227     1  0.4048     0.6800 0.756 0.000 0.000 0.032 0.188 0.024
#> GSM123228     1  0.3857     0.7012 0.776 0.000 0.004 0.072 0.148 0.000
#> GSM123229     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123230     3  0.5854     0.6774 0.180 0.000 0.624 0.068 0.128 0.000
#> GSM123231     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123232     1  0.0000     0.8360 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123233     5  0.3993     0.6809 0.000 0.000 0.000 0.004 0.520 0.476
#> GSM123234     3  0.4819     0.7434 0.164 0.000 0.716 0.036 0.084 0.000
#> GSM123235     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123236     5  0.4185     0.6566 0.000 0.000 0.000 0.012 0.496 0.492
#> GSM123237     1  0.3984     0.4232 0.596 0.000 0.000 0.008 0.000 0.396
#> GSM123238     4  0.2350     0.7081 0.000 0.100 0.000 0.880 0.000 0.020
#> GSM123239     5  0.3868     0.6630 0.000 0.000 0.000 0.000 0.504 0.496
#> GSM123240     1  0.3984     0.4232 0.596 0.000 0.000 0.008 0.000 0.396
#> GSM123241     1  0.1672     0.8139 0.932 0.000 0.000 0.004 0.016 0.048
#> GSM123242     4  0.6711     0.6842 0.000 0.204 0.040 0.492 0.252 0.012
#> GSM123182     5  0.3996     0.6805 0.000 0.000 0.000 0.004 0.512 0.484
#> GSM123183     4  0.2178     0.7244 0.000 0.132 0.000 0.868 0.000 0.000
#> GSM123184     4  0.5858     0.7005 0.000 0.264 0.004 0.512 0.220 0.000
#> GSM123185     5  0.3993     0.6809 0.000 0.000 0.000 0.004 0.520 0.476
#> GSM123186     6  0.0405     0.5170 0.000 0.000 0.000 0.008 0.004 0.988
#> GSM123187     5  0.6433     0.0321 0.000 0.044 0.040 0.072 0.536 0.308
#> GSM123188     1  0.0000     0.8360 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123190     6  0.4152    -0.5788 0.000 0.000 0.000 0.012 0.440 0.548
#> GSM123191     6  0.5282    -0.3306 0.076 0.000 0.000 0.012 0.364 0.548
#> GSM123192     6  0.0405     0.5170 0.000 0.000 0.000 0.008 0.004 0.988
#> GSM123193     6  0.2325     0.4990 0.100 0.000 0.000 0.008 0.008 0.884
#> GSM123194     1  0.1053     0.8268 0.964 0.000 0.000 0.004 0.012 0.020
#> GSM123195     2  0.0146     0.8817 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123196     3  0.0937     0.8676 0.040 0.000 0.960 0.000 0.000 0.000
#> GSM123197     4  0.2191     0.7224 0.000 0.120 0.000 0.876 0.000 0.004
#> GSM123198     2  0.3009     0.8302 0.000 0.844 0.040 0.004 0.112 0.000
#> GSM123199     1  0.0000     0.8360 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123200     2  0.0508     0.8825 0.000 0.984 0.004 0.000 0.012 0.000
#> GSM123201     1  0.6524     0.0800 0.436 0.000 0.000 0.040 0.340 0.184
#> GSM123202     2  0.2940     0.8323 0.000 0.848 0.036 0.004 0.112 0.000
#> GSM123203     1  0.0000     0.8360 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123204     2  0.0000     0.8828 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.2964     0.7531 0.000 0.792 0.004 0.000 0.204 0.000
#> GSM123206     2  0.0891     0.8670 0.000 0.968 0.000 0.024 0.008 0.000
#> GSM123207     6  0.3797    -0.5046 0.000 0.000 0.000 0.000 0.420 0.580
#> GSM123208     2  0.0405     0.8821 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM123209     6  0.5387    -0.2320 0.000 0.028 0.036 0.008 0.412 0.516
#> GSM123210     6  0.2325     0.4990 0.100 0.000 0.000 0.008 0.008 0.884
#> GSM123211     6  0.1686     0.5114 0.064 0.000 0.000 0.012 0.000 0.924

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) k
#> ATC:kmeans 61          0.14613 2
#> ATC:kmeans 18               NA 3
#> ATC:kmeans 58          0.09875 4
#> ATC:kmeans 58          0.00857 5
#> ATC:kmeans 48          0.04552 6

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


ATC:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.994       0.997         0.4918 0.508   0.508
#> 3 3 0.798           0.891       0.934         0.3461 0.760   0.554
#> 4 4 0.757           0.862       0.886         0.0890 0.938   0.816
#> 5 5 0.840           0.785       0.897         0.0696 0.913   0.711
#> 6 6 0.793           0.690       0.843         0.0441 0.937   0.740

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
#> GSM123212     2   0.000      0.995 0.000 1.000
#> GSM123213     2   0.000      0.995 0.000 1.000
#> GSM123214     2   0.000      0.995 0.000 1.000
#> GSM123215     2   0.000      0.995 0.000 1.000
#> GSM123216     1   0.000      0.999 1.000 0.000
#> GSM123217     1   0.000      0.999 1.000 0.000
#> GSM123218     1   0.000      0.999 1.000 0.000
#> GSM123219     1   0.278      0.949 0.952 0.048
#> GSM123220     1   0.000      0.999 1.000 0.000
#> GSM123221     1   0.000      0.999 1.000 0.000
#> GSM123222     1   0.000      0.999 1.000 0.000
#> GSM123223     2   0.000      0.995 0.000 1.000
#> GSM123224     1   0.000      0.999 1.000 0.000
#> GSM123225     1   0.000      0.999 1.000 0.000
#> GSM123226     1   0.000      0.999 1.000 0.000
#> GSM123227     1   0.000      0.999 1.000 0.000
#> GSM123228     1   0.000      0.999 1.000 0.000
#> GSM123229     1   0.000      0.999 1.000 0.000
#> GSM123230     1   0.000      0.999 1.000 0.000
#> GSM123231     1   0.000      0.999 1.000 0.000
#> GSM123232     1   0.000      0.999 1.000 0.000
#> GSM123233     1   0.000      0.999 1.000 0.000
#> GSM123234     1   0.000      0.999 1.000 0.000
#> GSM123235     1   0.000      0.999 1.000 0.000
#> GSM123236     1   0.000      0.999 1.000 0.000
#> GSM123237     1   0.000      0.999 1.000 0.000
#> GSM123238     2   0.000      0.995 0.000 1.000
#> GSM123239     2   0.563      0.849 0.132 0.868
#> GSM123240     1   0.000      0.999 1.000 0.000
#> GSM123241     1   0.000      0.999 1.000 0.000
#> GSM123242     2   0.000      0.995 0.000 1.000
#> GSM123182     1   0.000      0.999 1.000 0.000
#> GSM123183     2   0.000      0.995 0.000 1.000
#> GSM123184     2   0.000      0.995 0.000 1.000
#> GSM123185     1   0.000      0.999 1.000 0.000
#> GSM123186     2   0.000      0.995 0.000 1.000
#> GSM123187     2   0.000      0.995 0.000 1.000
#> GSM123188     1   0.000      0.999 1.000 0.000
#> GSM123189     1   0.000      0.999 1.000 0.000
#> GSM123190     1   0.000      0.999 1.000 0.000
#> GSM123191     1   0.000      0.999 1.000 0.000
#> GSM123192     2   0.000      0.995 0.000 1.000
#> GSM123193     1   0.000      0.999 1.000 0.000
#> GSM123194     1   0.000      0.999 1.000 0.000
#> GSM123195     2   0.000      0.995 0.000 1.000
#> GSM123196     1   0.000      0.999 1.000 0.000
#> GSM123197     2   0.000      0.995 0.000 1.000
#> GSM123198     2   0.000      0.995 0.000 1.000
#> GSM123199     1   0.000      0.999 1.000 0.000
#> GSM123200     2   0.000      0.995 0.000 1.000
#> GSM123201     1   0.000      0.999 1.000 0.000
#> GSM123202     2   0.000      0.995 0.000 1.000
#> GSM123203     1   0.000      0.999 1.000 0.000
#> GSM123204     2   0.000      0.995 0.000 1.000
#> GSM123205     2   0.000      0.995 0.000 1.000
#> GSM123206     2   0.000      0.995 0.000 1.000
#> GSM123207     2   0.000      0.995 0.000 1.000
#> GSM123208     2   0.000      0.995 0.000 1.000
#> GSM123209     2   0.000      0.995 0.000 1.000
#> GSM123210     1   0.000      0.999 1.000 0.000
#> GSM123211     2   0.000      0.995 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
#> GSM123212     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123213     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123214     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123215     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123216     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123217     1   0.400     0.8745 0.840 0.000 0.160
#> GSM123218     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123219     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123220     1   0.470     0.8538 0.788 0.000 0.212
#> GSM123221     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123222     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123223     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123224     1   0.470     0.8538 0.788 0.000 0.212
#> GSM123225     1   0.470     0.8538 0.788 0.000 0.212
#> GSM123226     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123227     1   0.480     0.8477 0.780 0.000 0.220
#> GSM123228     1   0.470     0.8538 0.788 0.000 0.212
#> GSM123229     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123230     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123231     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123232     1   0.400     0.8745 0.840 0.000 0.160
#> GSM123233     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123234     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123235     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123236     1   0.611     0.6103 0.604 0.000 0.396
#> GSM123237     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123238     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123239     3   0.629     0.0682 0.000 0.468 0.532
#> GSM123240     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123241     1   0.412     0.8722 0.832 0.000 0.168
#> GSM123242     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123182     1   0.571     0.7375 0.680 0.000 0.320
#> GSM123183     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123184     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123185     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123186     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123187     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123188     1   0.400     0.8745 0.840 0.000 0.160
#> GSM123189     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123190     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123191     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123192     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123193     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123194     1   0.579     0.7217 0.668 0.000 0.332
#> GSM123195     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123196     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123197     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123198     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123199     1   0.400     0.8745 0.840 0.000 0.160
#> GSM123200     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123201     3   0.000     0.9597 0.000 0.000 1.000
#> GSM123202     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123203     1   0.400     0.8745 0.840 0.000 0.160
#> GSM123204     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123205     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123206     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123207     2   0.625     0.1471 0.444 0.556 0.000
#> GSM123208     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123209     2   0.000     0.9762 0.000 1.000 0.000
#> GSM123210     1   0.000     0.8520 1.000 0.000 0.000
#> GSM123211     1   0.000     0.8520 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     2  0.0336      0.983 0.000 0.992 0.000 0.008
#> GSM123213     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123214     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123215     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123216     1  0.1610      0.782 0.952 0.000 0.016 0.032
#> GSM123217     1  0.2760      0.815 0.872 0.000 0.128 0.000
#> GSM123218     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123219     1  0.3942      0.671 0.764 0.000 0.000 0.236
#> GSM123220     1  0.3356      0.794 0.824 0.000 0.176 0.000
#> GSM123221     3  0.0188      0.934 0.004 0.000 0.996 0.000
#> GSM123222     1  0.2589      0.734 0.884 0.000 0.000 0.116
#> GSM123223     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123224     1  0.3356      0.794 0.824 0.000 0.176 0.000
#> GSM123225     1  0.3356      0.794 0.824 0.000 0.176 0.000
#> GSM123226     3  0.3837      0.685 0.224 0.000 0.776 0.000
#> GSM123227     1  0.6049      0.648 0.684 0.000 0.184 0.132
#> GSM123228     1  0.3400      0.791 0.820 0.000 0.180 0.000
#> GSM123229     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123230     3  0.2216      0.852 0.092 0.000 0.908 0.000
#> GSM123231     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123232     1  0.2760      0.815 0.872 0.000 0.128 0.000
#> GSM123233     4  0.4328      0.712 0.008 0.000 0.244 0.748
#> GSM123234     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123235     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123236     4  0.5566      0.736 0.224 0.000 0.072 0.704
#> GSM123237     1  0.3801      0.681 0.780 0.000 0.000 0.220
#> GSM123238     2  0.0592      0.978 0.000 0.984 0.000 0.016
#> GSM123239     4  0.5730      0.750 0.036 0.132 0.076 0.756
#> GSM123240     1  0.3837      0.680 0.776 0.000 0.000 0.224
#> GSM123241     1  0.4008      0.812 0.820 0.000 0.148 0.032
#> GSM123242     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123182     4  0.4549      0.794 0.188 0.000 0.036 0.776
#> GSM123183     2  0.0336      0.983 0.000 0.992 0.000 0.008
#> GSM123184     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123185     4  0.5314      0.801 0.108 0.000 0.144 0.748
#> GSM123186     2  0.2760      0.854 0.000 0.872 0.000 0.128
#> GSM123187     2  0.0000      0.987 0.000 1.000 0.000 0.000
#> GSM123188     1  0.2760      0.815 0.872 0.000 0.128 0.000
#> GSM123189     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123190     3  0.0817      0.907 0.000 0.000 0.976 0.024
#> GSM123191     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123192     1  0.4328      0.657 0.748 0.008 0.000 0.244
#> GSM123193     1  0.3245      0.769 0.872 0.000 0.028 0.100
#> GSM123194     1  0.3908      0.760 0.784 0.000 0.212 0.004
#> GSM123195     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123196     3  0.0000      0.937 0.000 0.000 1.000 0.000
#> GSM123197     2  0.0469      0.981 0.000 0.988 0.000 0.012
#> GSM123198     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123199     1  0.2760      0.815 0.872 0.000 0.128 0.000
#> GSM123200     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123201     3  0.4194      0.735 0.172 0.000 0.800 0.028
#> GSM123202     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123203     1  0.2760      0.815 0.872 0.000 0.128 0.000
#> GSM123204     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123205     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123206     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123207     4  0.1798      0.740 0.040 0.016 0.000 0.944
#> GSM123208     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123209     2  0.0336      0.988 0.000 0.992 0.000 0.008
#> GSM123210     1  0.2805      0.761 0.888 0.000 0.012 0.100
#> GSM123211     1  0.4328      0.657 0.748 0.008 0.000 0.244

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     2  0.5061      0.716 0.000 0.696 0.028 0.240 0.036
#> GSM123213     2  0.2775      0.879 0.000 0.888 0.008 0.068 0.036
#> GSM123214     2  0.1630      0.901 0.000 0.944 0.004 0.016 0.036
#> GSM123215     2  0.1728      0.900 0.000 0.940 0.004 0.020 0.036
#> GSM123216     1  0.1768      0.781 0.924 0.000 0.000 0.072 0.004
#> GSM123217     1  0.0000      0.840 1.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123219     4  0.3013      0.640 0.160 0.000 0.000 0.832 0.008
#> GSM123220     1  0.0703      0.841 0.976 0.000 0.024 0.000 0.000
#> GSM123221     3  0.0880      0.960 0.032 0.000 0.968 0.000 0.000
#> GSM123222     1  0.3942      0.490 0.728 0.000 0.000 0.260 0.012
#> GSM123223     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123224     1  0.0703      0.841 0.976 0.000 0.024 0.000 0.000
#> GSM123225     1  0.0703      0.841 0.976 0.000 0.024 0.000 0.000
#> GSM123226     1  0.3661      0.561 0.724 0.000 0.276 0.000 0.000
#> GSM123227     1  0.1579      0.824 0.944 0.000 0.024 0.000 0.032
#> GSM123228     1  0.0703      0.841 0.976 0.000 0.024 0.000 0.000
#> GSM123229     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123230     3  0.3707      0.599 0.284 0.000 0.716 0.000 0.000
#> GSM123231     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123232     1  0.0000      0.840 1.000 0.000 0.000 0.000 0.000
#> GSM123233     5  0.1443      0.859 0.004 0.000 0.044 0.004 0.948
#> GSM123234     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123235     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123236     5  0.4212      0.639 0.236 0.000 0.024 0.004 0.736
#> GSM123237     4  0.4045      0.489 0.356 0.000 0.000 0.644 0.000
#> GSM123238     2  0.5502      0.595 0.000 0.612 0.028 0.324 0.036
#> GSM123239     5  0.1430      0.849 0.000 0.052 0.000 0.004 0.944
#> GSM123240     4  0.4074      0.476 0.364 0.000 0.000 0.636 0.000
#> GSM123241     1  0.1074      0.837 0.968 0.000 0.012 0.016 0.004
#> GSM123242     2  0.2838      0.877 0.000 0.884 0.008 0.072 0.036
#> GSM123182     5  0.1121      0.869 0.044 0.000 0.000 0.000 0.956
#> GSM123183     2  0.5061      0.716 0.000 0.696 0.028 0.240 0.036
#> GSM123184     2  0.2283      0.892 0.000 0.916 0.008 0.040 0.036
#> GSM123185     5  0.1386      0.873 0.032 0.000 0.016 0.000 0.952
#> GSM123186     4  0.5320      0.216 0.000 0.284 0.028 0.652 0.036
#> GSM123187     2  0.1469      0.902 0.000 0.948 0.000 0.016 0.036
#> GSM123188     1  0.0000      0.840 1.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123190     3  0.0898      0.955 0.020 0.000 0.972 0.000 0.008
#> GSM123191     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123192     4  0.0609      0.620 0.020 0.000 0.000 0.980 0.000
#> GSM123193     1  0.4238      0.285 0.628 0.000 0.000 0.368 0.004
#> GSM123194     1  0.0963      0.834 0.964 0.000 0.036 0.000 0.000
#> GSM123195     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.0794      0.964 0.028 0.000 0.972 0.000 0.000
#> GSM123197     2  0.5113      0.707 0.000 0.688 0.028 0.248 0.036
#> GSM123198     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123199     1  0.0000      0.840 1.000 0.000 0.000 0.000 0.000
#> GSM123200     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123201     1  0.5039      0.031 0.512 0.000 0.456 0.000 0.032
#> GSM123202     2  0.0162      0.908 0.000 0.996 0.000 0.004 0.000
#> GSM123203     1  0.0000      0.840 1.000 0.000 0.000 0.000 0.000
#> GSM123204     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123206     2  0.0162      0.908 0.000 0.996 0.000 0.004 0.000
#> GSM123207     5  0.3280      0.760 0.000 0.004 0.012 0.160 0.824
#> GSM123208     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.0000      0.908 0.000 1.000 0.000 0.000 0.000
#> GSM123210     1  0.4135      0.352 0.656 0.000 0.000 0.340 0.004
#> GSM123211     4  0.0510      0.618 0.016 0.000 0.000 0.984 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.4135    0.83853 0.000 0.300 0.000 0.668 0.000 0.032
#> GSM123213     2  0.3862   -0.00373 0.000 0.524 0.000 0.476 0.000 0.000
#> GSM123214     2  0.3592    0.39454 0.000 0.656 0.000 0.344 0.000 0.000
#> GSM123215     2  0.3782    0.23160 0.000 0.588 0.000 0.412 0.000 0.000
#> GSM123216     1  0.1970    0.77699 0.900 0.000 0.000 0.008 0.000 0.092
#> GSM123217     1  0.0260    0.86486 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM123218     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123219     6  0.2591    0.57563 0.052 0.000 0.000 0.064 0.004 0.880
#> GSM123220     1  0.0146    0.86497 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM123221     3  0.1536    0.91120 0.012 0.000 0.944 0.024 0.000 0.020
#> GSM123222     1  0.4904    0.14654 0.620 0.000 0.000 0.040 0.024 0.316
#> GSM123223     2  0.1387    0.71664 0.000 0.932 0.000 0.068 0.000 0.000
#> GSM123224     1  0.0146    0.86497 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM123225     1  0.0146    0.86514 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM123226     1  0.3183    0.61178 0.788 0.000 0.200 0.008 0.000 0.004
#> GSM123227     1  0.1622    0.83028 0.940 0.000 0.000 0.016 0.028 0.016
#> GSM123228     1  0.0146    0.86514 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM123229     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123230     3  0.4148    0.40588 0.344 0.000 0.636 0.016 0.000 0.004
#> GSM123231     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123232     1  0.0260    0.86486 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM123233     5  0.0976    0.82276 0.000 0.000 0.016 0.008 0.968 0.008
#> GSM123234     3  0.0767    0.93405 0.008 0.000 0.976 0.012 0.000 0.004
#> GSM123235     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123236     5  0.4854    0.42243 0.308 0.000 0.016 0.040 0.632 0.004
#> GSM123237     6  0.4185    0.58428 0.332 0.000 0.000 0.020 0.004 0.644
#> GSM123238     4  0.4382    0.83274 0.000 0.264 0.000 0.676 0.000 0.060
#> GSM123239     5  0.3448    0.79200 0.000 0.028 0.004 0.116 0.828 0.024
#> GSM123240     6  0.4185    0.58428 0.332 0.000 0.000 0.020 0.004 0.644
#> GSM123241     1  0.2006    0.77340 0.892 0.000 0.000 0.004 0.000 0.104
#> GSM123242     2  0.3860    0.01651 0.000 0.528 0.000 0.472 0.000 0.000
#> GSM123182     5  0.0748    0.82178 0.004 0.000 0.000 0.016 0.976 0.004
#> GSM123183     4  0.4135    0.83853 0.000 0.300 0.000 0.668 0.000 0.032
#> GSM123184     2  0.3854    0.05242 0.000 0.536 0.000 0.464 0.000 0.000
#> GSM123185     5  0.0551    0.82485 0.004 0.000 0.004 0.008 0.984 0.000
#> GSM123186     4  0.4988    0.59238 0.000 0.116 0.000 0.660 0.008 0.216
#> GSM123187     2  0.3390    0.47771 0.000 0.704 0.000 0.296 0.000 0.000
#> GSM123188     1  0.0260    0.86486 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM123189     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123190     3  0.0603    0.93705 0.004 0.000 0.980 0.016 0.000 0.000
#> GSM123191     3  0.0363    0.94025 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM123192     6  0.3196    0.51233 0.008 0.000 0.000 0.156 0.020 0.816
#> GSM123193     6  0.4676    0.37003 0.428 0.000 0.000 0.044 0.000 0.528
#> GSM123194     1  0.0520    0.86093 0.984 0.000 0.008 0.008 0.000 0.000
#> GSM123195     2  0.0000    0.74257 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.0146    0.94373 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123197     4  0.4079    0.84559 0.000 0.288 0.000 0.680 0.000 0.032
#> GSM123198     2  0.0000    0.74257 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123199     1  0.0146    0.86535 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM123200     2  0.0000    0.74257 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     1  0.5214    0.18731 0.532 0.000 0.404 0.028 0.032 0.004
#> GSM123202     2  0.0363    0.73968 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM123203     1  0.0260    0.86486 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM123204     2  0.0000    0.74257 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123205     2  0.0547    0.74141 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123206     2  0.0547    0.74040 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123207     5  0.4599    0.69218 0.000 0.000 0.004 0.192 0.700 0.104
#> GSM123208     2  0.0000    0.74257 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.0713    0.73023 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM123210     6  0.4591    0.29942 0.464 0.000 0.000 0.036 0.000 0.500
#> GSM123211     6  0.2260    0.53243 0.000 0.000 0.000 0.140 0.000 0.860

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) k
#> ATC:skmeans 61           0.0285 2
#> ATC:skmeans 59           0.1350 3
#> ATC:skmeans 61           0.2406 4
#> ATC:skmeans 54           0.2436 5
#> ATC:skmeans 49           0.0765 6

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


ATC:pam**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 21168 rows and 61 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           1.000       1.000         0.4368 0.564   0.564
#> 3 3 0.748           0.858       0.934         0.5231 0.773   0.597
#> 4 4 0.705           0.703       0.847         0.0964 0.819   0.534
#> 5 5 0.875           0.830       0.930         0.0654 0.920   0.714
#> 6 6 0.859           0.795       0.912         0.0591 0.911   0.635

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
#> GSM123212     2  0.0000      1.000 0.000 1.000
#> GSM123213     2  0.0000      1.000 0.000 1.000
#> GSM123214     2  0.0000      1.000 0.000 1.000
#> GSM123215     2  0.0000      1.000 0.000 1.000
#> GSM123216     1  0.0000      1.000 1.000 0.000
#> GSM123217     1  0.0000      1.000 1.000 0.000
#> GSM123218     1  0.0000      1.000 1.000 0.000
#> GSM123219     1  0.0000      1.000 1.000 0.000
#> GSM123220     1  0.0000      1.000 1.000 0.000
#> GSM123221     1  0.0000      1.000 1.000 0.000
#> GSM123222     1  0.0000      1.000 1.000 0.000
#> GSM123223     2  0.0000      1.000 0.000 1.000
#> GSM123224     1  0.0000      1.000 1.000 0.000
#> GSM123225     1  0.0000      1.000 1.000 0.000
#> GSM123226     1  0.0000      1.000 1.000 0.000
#> GSM123227     1  0.0000      1.000 1.000 0.000
#> GSM123228     1  0.0000      1.000 1.000 0.000
#> GSM123229     1  0.0000      1.000 1.000 0.000
#> GSM123230     1  0.0000      1.000 1.000 0.000
#> GSM123231     1  0.0000      1.000 1.000 0.000
#> GSM123232     1  0.0000      1.000 1.000 0.000
#> GSM123233     1  0.0000      1.000 1.000 0.000
#> GSM123234     1  0.0000      1.000 1.000 0.000
#> GSM123235     1  0.0000      1.000 1.000 0.000
#> GSM123236     1  0.0000      1.000 1.000 0.000
#> GSM123237     1  0.0000      1.000 1.000 0.000
#> GSM123238     2  0.0000      1.000 0.000 1.000
#> GSM123239     1  0.0000      1.000 1.000 0.000
#> GSM123240     1  0.0000      1.000 1.000 0.000
#> GSM123241     1  0.0000      1.000 1.000 0.000
#> GSM123242     2  0.0000      1.000 0.000 1.000
#> GSM123182     1  0.0000      1.000 1.000 0.000
#> GSM123183     2  0.0000      1.000 0.000 1.000
#> GSM123184     2  0.0000      1.000 0.000 1.000
#> GSM123185     1  0.0000      1.000 1.000 0.000
#> GSM123186     1  0.0000      1.000 1.000 0.000
#> GSM123187     2  0.0000      1.000 0.000 1.000
#> GSM123188     1  0.0000      1.000 1.000 0.000
#> GSM123189     1  0.0000      1.000 1.000 0.000
#> GSM123190     1  0.0000      1.000 1.000 0.000
#> GSM123191     1  0.0000      1.000 1.000 0.000
#> GSM123192     1  0.0000      1.000 1.000 0.000
#> GSM123193     1  0.0000      1.000 1.000 0.000
#> GSM123194     1  0.0000      1.000 1.000 0.000
#> GSM123195     2  0.0000      1.000 0.000 1.000
#> GSM123196     1  0.0000      1.000 1.000 0.000
#> GSM123197     2  0.0000      1.000 0.000 1.000
#> GSM123198     2  0.0000      1.000 0.000 1.000
#> GSM123199     1  0.0000      1.000 1.000 0.000
#> GSM123200     2  0.0000      1.000 0.000 1.000
#> GSM123201     1  0.0000      1.000 1.000 0.000
#> GSM123202     2  0.0000      1.000 0.000 1.000
#> GSM123203     1  0.0000      1.000 1.000 0.000
#> GSM123204     2  0.0000      1.000 0.000 1.000
#> GSM123205     2  0.0000      1.000 0.000 1.000
#> GSM123206     2  0.0000      1.000 0.000 1.000
#> GSM123207     1  0.0000      1.000 1.000 0.000
#> GSM123208     2  0.0000      1.000 0.000 1.000
#> GSM123209     1  0.0938      0.988 0.988 0.012
#> GSM123210     1  0.0000      1.000 1.000 0.000
#> GSM123211     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123213     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123214     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123215     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123216     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123217     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123218     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123219     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123220     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123221     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123222     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123223     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123224     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123225     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123226     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123227     1  0.3619      0.773 0.864 0.000 0.136
#> GSM123228     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123229     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123230     3  0.6026      0.460 0.376 0.000 0.624
#> GSM123231     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123232     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123233     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123234     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123235     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123236     3  0.4062      0.758 0.164 0.000 0.836
#> GSM123237     1  0.3116      0.821 0.892 0.000 0.108
#> GSM123238     2  0.1163      0.965 0.000 0.972 0.028
#> GSM123239     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123240     1  0.3038      0.824 0.896 0.000 0.104
#> GSM123241     1  0.6126      0.232 0.600 0.000 0.400
#> GSM123242     2  0.2537      0.924 0.000 0.920 0.080
#> GSM123182     3  0.4974      0.656 0.236 0.000 0.764
#> GSM123183     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123184     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123185     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123186     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123187     2  0.3116      0.896 0.000 0.892 0.108
#> GSM123188     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123189     3  0.2711      0.870 0.088 0.000 0.912
#> GSM123190     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123191     3  0.2711      0.870 0.088 0.000 0.912
#> GSM123192     3  0.4291      0.738 0.180 0.000 0.820
#> GSM123193     3  0.2711      0.870 0.088 0.000 0.912
#> GSM123194     1  0.6095      0.194 0.608 0.000 0.392
#> GSM123195     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123196     3  0.3116      0.863 0.108 0.000 0.892
#> GSM123197     2  0.2625      0.921 0.000 0.916 0.084
#> GSM123198     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123199     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123200     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123201     3  0.6225      0.283 0.432 0.000 0.568
#> GSM123202     2  0.0237      0.981 0.000 0.996 0.004
#> GSM123203     1  0.0000      0.907 1.000 0.000 0.000
#> GSM123204     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123205     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123206     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123207     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123208     2  0.0000      0.983 0.000 1.000 0.000
#> GSM123209     3  0.0000      0.880 0.000 0.000 1.000
#> GSM123210     3  0.5216      0.700 0.260 0.000 0.740
#> GSM123211     3  0.0000      0.880 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     2  0.4624    0.67605 0.000 0.660 0.000 0.340
#> GSM123213     2  0.0000    0.94709 0.000 1.000 0.000 0.000
#> GSM123214     2  0.0000    0.94709 0.000 1.000 0.000 0.000
#> GSM123215     2  0.0592    0.94070 0.000 0.984 0.000 0.016
#> GSM123216     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123217     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123218     4  0.4713    0.86619 0.000 0.000 0.360 0.640
#> GSM123219     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123220     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123221     3  0.4655   -0.08469 0.004 0.000 0.684 0.312
#> GSM123222     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123223     2  0.0000    0.94709 0.000 1.000 0.000 0.000
#> GSM123224     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123225     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123226     1  0.4356    0.57419 0.708 0.000 0.000 0.292
#> GSM123227     1  0.3801    0.68001 0.780 0.000 0.220 0.000
#> GSM123228     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123229     4  0.4713    0.86619 0.000 0.000 0.360 0.640
#> GSM123230     4  0.7628    0.43298 0.348 0.000 0.212 0.440
#> GSM123231     4  0.4713    0.86619 0.000 0.000 0.360 0.640
#> GSM123232     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123233     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123234     4  0.7495    0.64774 0.184 0.000 0.368 0.448
#> GSM123235     4  0.4713    0.86619 0.000 0.000 0.360 0.640
#> GSM123236     3  0.1022    0.66234 0.032 0.000 0.968 0.000
#> GSM123237     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123238     3  0.7355    0.30733 0.000 0.172 0.488 0.340
#> GSM123239     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123240     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123241     1  0.2408    0.80655 0.896 0.000 0.104 0.000
#> GSM123242     3  0.5080    0.24015 0.000 0.420 0.576 0.004
#> GSM123182     3  0.1474    0.64691 0.052 0.000 0.948 0.000
#> GSM123183     2  0.4624    0.67605 0.000 0.660 0.000 0.340
#> GSM123184     2  0.0000    0.94709 0.000 1.000 0.000 0.000
#> GSM123185     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123186     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123187     3  0.4776    0.33780 0.000 0.376 0.624 0.000
#> GSM123188     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123189     4  0.4746    0.85728 0.000 0.000 0.368 0.632
#> GSM123190     3  0.4477   -0.07361 0.000 0.000 0.688 0.312
#> GSM123191     3  0.7820   -0.50619 0.276 0.000 0.412 0.312
#> GSM123192     3  0.1118    0.65973 0.036 0.000 0.964 0.000
#> GSM123193     1  0.4888    0.19975 0.588 0.000 0.412 0.000
#> GSM123194     1  0.3726    0.64035 0.788 0.000 0.212 0.000
#> GSM123195     2  0.0707    0.94739 0.000 0.980 0.000 0.020
#> GSM123196     4  0.4713    0.86619 0.000 0.000 0.360 0.640
#> GSM123197     3  0.6494    0.37325 0.000 0.088 0.572 0.340
#> GSM123198     2  0.0707    0.94739 0.000 0.980 0.000 0.020
#> GSM123199     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123200     2  0.0707    0.94739 0.000 0.980 0.000 0.020
#> GSM123201     1  0.3726    0.67639 0.788 0.000 0.212 0.000
#> GSM123202     2  0.1042    0.94293 0.000 0.972 0.008 0.020
#> GSM123203     1  0.0000    0.89194 1.000 0.000 0.000 0.000
#> GSM123204     2  0.0707    0.94739 0.000 0.980 0.000 0.020
#> GSM123205     2  0.0000    0.94709 0.000 1.000 0.000 0.000
#> GSM123206     2  0.0592    0.94767 0.000 0.984 0.000 0.016
#> GSM123207     3  0.0000    0.67596 0.000 0.000 1.000 0.000
#> GSM123208     2  0.0707    0.94739 0.000 0.980 0.000 0.020
#> GSM123209     3  0.0188    0.67470 0.000 0.000 0.996 0.004
#> GSM123210     3  0.4981    0.00531 0.464 0.000 0.536 0.000
#> GSM123211     3  0.0000    0.67596 0.000 0.000 1.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
#> GSM123212     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> GSM123213     2  0.1908      0.938 0.000 0.908 0.000 0.092 0.000
#> GSM123214     2  0.1908      0.938 0.000 0.908 0.000 0.092 0.000
#> GSM123215     2  0.2966      0.852 0.000 0.816 0.000 0.184 0.000
#> GSM123216     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0000      0.751 0.000 0.000 1.000 0.000 0.000
#> GSM123219     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123220     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123221     3  0.4562     -0.027 0.008 0.000 0.496 0.000 0.496
#> GSM123222     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123223     2  0.1671      0.941 0.000 0.924 0.000 0.076 0.000
#> GSM123224     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123226     1  0.4287      0.140 0.540 0.000 0.460 0.000 0.000
#> GSM123227     1  0.3210      0.683 0.788 0.000 0.000 0.000 0.212
#> GSM123228     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123229     3  0.0000      0.751 0.000 0.000 1.000 0.000 0.000
#> GSM123230     3  0.3857      0.547 0.312 0.000 0.688 0.000 0.000
#> GSM123231     3  0.0000      0.751 0.000 0.000 1.000 0.000 0.000
#> GSM123232     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123233     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123234     3  0.4229      0.586 0.276 0.000 0.704 0.000 0.020
#> GSM123235     3  0.0000      0.751 0.000 0.000 1.000 0.000 0.000
#> GSM123236     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123237     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123238     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> GSM123239     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123240     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123242     5  0.3759      0.726 0.000 0.092 0.000 0.092 0.816
#> GSM123182     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123183     4  0.0000      0.990 0.000 0.000 0.000 1.000 0.000
#> GSM123184     2  0.1908      0.938 0.000 0.908 0.000 0.092 0.000
#> GSM123185     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123186     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123187     5  0.1082      0.904 0.000 0.028 0.000 0.008 0.964
#> GSM123188     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123189     3  0.0609      0.743 0.000 0.000 0.980 0.000 0.020
#> GSM123190     5  0.4307     -0.115 0.000 0.000 0.496 0.000 0.504
#> GSM123191     3  0.5867      0.284 0.404 0.000 0.496 0.000 0.100
#> GSM123192     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123193     1  0.2020      0.828 0.900 0.000 0.000 0.000 0.100
#> GSM123194     1  0.0609      0.905 0.980 0.000 0.000 0.000 0.020
#> GSM123195     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000
#> GSM123196     3  0.0000      0.751 0.000 0.000 1.000 0.000 0.000
#> GSM123197     4  0.0609      0.971 0.000 0.000 0.000 0.980 0.020
#> GSM123198     2  0.1043      0.945 0.000 0.960 0.000 0.040 0.000
#> GSM123199     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123200     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000
#> GSM123201     1  0.1197      0.886 0.952 0.000 0.000 0.000 0.048
#> GSM123202     2  0.1168      0.931 0.000 0.960 0.000 0.008 0.032
#> GSM123203     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000
#> GSM123204     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000
#> GSM123205     2  0.1908      0.938 0.000 0.908 0.000 0.092 0.000
#> GSM123206     2  0.0162      0.942 0.000 0.996 0.000 0.004 0.000
#> GSM123207     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123208     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000
#> GSM123209     5  0.0000      0.940 0.000 0.000 0.000 0.000 1.000
#> GSM123210     1  0.4030      0.475 0.648 0.000 0.000 0.000 0.352
#> GSM123211     5  0.0000      0.940 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
#> GSM123212     4  0.0000    0.98985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123213     2  0.1967    0.92563 0.000 0.904 0.000 0.084 0.000 0.012
#> GSM123214     2  0.1967    0.92563 0.000 0.904 0.000 0.084 0.000 0.012
#> GSM123215     2  0.2946    0.84331 0.000 0.812 0.000 0.176 0.000 0.012
#> GSM123216     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123218     3  0.0000    0.86155 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123219     6  0.3409    0.52565 0.000 0.000 0.000 0.000 0.300 0.700
#> GSM123220     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123221     6  0.1196    0.77799 0.000 0.000 0.008 0.000 0.040 0.952
#> GSM123222     5  0.0000    0.90189 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123223     2  0.2122    0.92965 0.000 0.900 0.000 0.076 0.000 0.024
#> GSM123224     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123225     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123226     3  0.3515    0.53433 0.324 0.000 0.676 0.000 0.000 0.000
#> GSM123227     1  0.4447    0.56691 0.704 0.000 0.000 0.000 0.196 0.100
#> GSM123228     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123229     3  0.0000    0.86155 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123230     3  0.4441    0.60530 0.208 0.000 0.700 0.000 0.000 0.092
#> GSM123231     3  0.0000    0.86155 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123232     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123233     5  0.2491    0.76224 0.000 0.000 0.000 0.000 0.836 0.164
#> GSM123234     6  0.1196    0.76996 0.040 0.000 0.008 0.000 0.000 0.952
#> GSM123235     3  0.0000    0.86155 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123236     6  0.3851    0.06253 0.000 0.000 0.000 0.000 0.460 0.540
#> GSM123237     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123238     4  0.0000    0.98985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123239     5  0.0000    0.90189 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123240     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.3747    0.27639 0.604 0.000 0.000 0.000 0.000 0.396
#> GSM123242     5  0.2842    0.78856 0.000 0.028 0.000 0.084 0.868 0.020
#> GSM123182     5  0.0547    0.89240 0.000 0.000 0.000 0.000 0.980 0.020
#> GSM123183     4  0.0000    0.98985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123184     2  0.1967    0.92563 0.000 0.904 0.000 0.084 0.000 0.012
#> GSM123185     5  0.2491    0.76224 0.000 0.000 0.000 0.000 0.836 0.164
#> GSM123186     5  0.0000    0.90189 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123187     5  0.0405    0.89535 0.000 0.004 0.000 0.000 0.988 0.008
#> GSM123188     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123189     6  0.1075    0.76239 0.000 0.000 0.048 0.000 0.000 0.952
#> GSM123190     6  0.1196    0.77799 0.000 0.000 0.008 0.000 0.040 0.952
#> GSM123191     6  0.1346    0.78129 0.016 0.000 0.008 0.000 0.024 0.952
#> GSM123192     5  0.0000    0.90189 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123193     6  0.1261    0.78086 0.024 0.000 0.000 0.000 0.024 0.952
#> GSM123194     1  0.3869   -0.08978 0.500 0.000 0.000 0.000 0.000 0.500
#> GSM123195     2  0.0713    0.92797 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM123196     3  0.0000    0.86155 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123197     4  0.0547    0.96941 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM123198     2  0.1168    0.93220 0.000 0.956 0.000 0.028 0.000 0.016
#> GSM123199     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123200     2  0.0713    0.92797 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM123201     6  0.4091   -0.00693 0.472 0.000 0.000 0.000 0.008 0.520
#> GSM123202     2  0.0937    0.91837 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM123203     1  0.0000    0.89819 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123204     2  0.0713    0.92797 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM123205     2  0.1967    0.92563 0.000 0.904 0.000 0.084 0.000 0.012
#> GSM123206     2  0.1074    0.93037 0.000 0.960 0.000 0.012 0.000 0.028
#> GSM123207     5  0.0000    0.90189 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123208     2  0.0713    0.92797 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM123209     5  0.3727    0.25799 0.000 0.000 0.000 0.000 0.612 0.388
#> GSM123210     6  0.3612    0.63262 0.200 0.000 0.000 0.000 0.036 0.764
#> GSM123211     5  0.0000    0.90189 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-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) k
#> ATC:pam 61           0.2332 2
#> ATC:pam 57           0.0488 3
#> ATC:pam 51           0.1110 4
#> ATC:pam 56           0.2298 5
#> ATC:pam 56           0.0617 6

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


ATC:mclust

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.393           0.895       0.869         0.3832 0.552   0.552
#> 3 3 0.803           0.877       0.897         0.4546 0.885   0.792
#> 4 4 0.624           0.646       0.790         0.1928 0.964   0.917
#> 5 5 0.776           0.809       0.899         0.0704 0.881   0.715
#> 6 6 0.672           0.670       0.811         0.0976 0.862   0.581

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
#> GSM123212     2   0.795      0.986 0.240 0.760
#> GSM123213     2   0.781      0.992 0.232 0.768
#> GSM123214     2   0.781      0.992 0.232 0.768
#> GSM123215     2   0.781      0.992 0.232 0.768
#> GSM123216     1   0.000      0.889 1.000 0.000
#> GSM123217     1   0.781      0.669 0.768 0.232
#> GSM123218     1   0.529      0.860 0.880 0.120
#> GSM123219     1   0.000      0.889 1.000 0.000
#> GSM123220     1   0.000      0.889 1.000 0.000
#> GSM123221     1   0.000      0.889 1.000 0.000
#> GSM123222     1   0.327      0.883 0.940 0.060
#> GSM123223     2   0.781      0.992 0.232 0.768
#> GSM123224     1   0.000      0.889 1.000 0.000
#> GSM123225     1   0.000      0.889 1.000 0.000
#> GSM123226     1   0.358      0.882 0.932 0.068
#> GSM123227     1   0.000      0.889 1.000 0.000
#> GSM123228     1   0.000      0.889 1.000 0.000
#> GSM123229     1   0.529      0.860 0.880 0.120
#> GSM123230     1   0.000      0.889 1.000 0.000
#> GSM123231     1   0.529      0.860 0.880 0.120
#> GSM123232     1   0.781      0.669 0.768 0.232
#> GSM123233     1   0.529      0.860 0.880 0.120
#> GSM123234     1   0.184      0.888 0.972 0.028
#> GSM123235     1   0.529      0.860 0.880 0.120
#> GSM123236     1   0.278      0.886 0.952 0.048
#> GSM123237     1   0.402      0.878 0.920 0.080
#> GSM123238     2   0.795      0.986 0.240 0.760
#> GSM123239     1   0.529      0.860 0.880 0.120
#> GSM123240     1   0.506      0.864 0.888 0.112
#> GSM123241     1   0.000      0.889 1.000 0.000
#> GSM123242     2   0.781      0.992 0.232 0.768
#> GSM123182     1   0.529      0.860 0.880 0.120
#> GSM123183     2   0.795      0.986 0.240 0.760
#> GSM123184     2   0.781      0.992 0.232 0.768
#> GSM123185     1   0.529      0.860 0.880 0.120
#> GSM123186     1   0.506      0.864 0.888 0.112
#> GSM123187     2   0.795      0.984 0.240 0.760
#> GSM123188     1   0.781      0.669 0.768 0.232
#> GSM123189     1   0.529      0.860 0.880 0.120
#> GSM123190     1   0.529      0.860 0.880 0.120
#> GSM123191     1   0.000      0.889 1.000 0.000
#> GSM123192     1   0.224      0.888 0.964 0.036
#> GSM123193     1   0.000      0.889 1.000 0.000
#> GSM123194     1   0.000      0.889 1.000 0.000
#> GSM123195     2   0.781      0.992 0.232 0.768
#> GSM123196     1   0.529      0.860 0.880 0.120
#> GSM123197     2   0.795      0.986 0.240 0.760
#> GSM123198     2   0.781      0.992 0.232 0.768
#> GSM123199     1   0.781      0.669 0.768 0.232
#> GSM123200     2   0.781      0.992 0.232 0.768
#> GSM123201     1   0.000      0.889 1.000 0.000
#> GSM123202     2   0.781      0.992 0.232 0.768
#> GSM123203     1   0.781      0.669 0.768 0.232
#> GSM123204     2   0.781      0.992 0.232 0.768
#> GSM123205     2   0.781      0.992 0.232 0.768
#> GSM123206     2   0.781      0.992 0.232 0.768
#> GSM123207     1   0.456      0.872 0.904 0.096
#> GSM123208     2   0.781      0.992 0.232 0.768
#> GSM123209     2   0.876      0.899 0.296 0.704
#> GSM123210     1   0.000      0.889 1.000 0.000
#> GSM123211     1   0.506      0.864 0.888 0.112

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.6200      0.837 0.012 0.676 0.312
#> GSM123213     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123214     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123215     2  0.0424      0.800 0.000 0.992 0.008
#> GSM123216     1  0.0424      0.943 0.992 0.000 0.008
#> GSM123217     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123218     3  0.5919      0.983 0.276 0.012 0.712
#> GSM123219     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123220     1  0.0892      0.935 0.980 0.000 0.020
#> GSM123221     1  0.0592      0.942 0.988 0.012 0.000
#> GSM123222     1  0.1289      0.925 0.968 0.000 0.032
#> GSM123223     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123224     1  0.0892      0.935 0.980 0.000 0.020
#> GSM123225     1  0.1267      0.932 0.972 0.004 0.024
#> GSM123226     1  0.1620      0.930 0.964 0.012 0.024
#> GSM123227     1  0.0892      0.939 0.980 0.020 0.000
#> GSM123228     1  0.1267      0.932 0.972 0.004 0.024
#> GSM123229     3  0.6019      0.974 0.288 0.012 0.700
#> GSM123230     1  0.1620      0.930 0.964 0.012 0.024
#> GSM123231     3  0.5919      0.983 0.276 0.012 0.712
#> GSM123232     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123233     1  0.4796      0.642 0.780 0.220 0.000
#> GSM123234     1  0.1482      0.933 0.968 0.012 0.020
#> GSM123235     3  0.5919      0.983 0.276 0.012 0.712
#> GSM123236     1  0.0892      0.939 0.980 0.020 0.000
#> GSM123237     1  0.0424      0.943 0.992 0.000 0.008
#> GSM123238     2  0.6200      0.837 0.012 0.676 0.312
#> GSM123239     1  0.0892      0.939 0.980 0.020 0.000
#> GSM123240     1  0.0424      0.943 0.992 0.000 0.008
#> GSM123241     1  0.0747      0.938 0.984 0.000 0.016
#> GSM123242     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123182     1  0.5733      0.454 0.676 0.324 0.000
#> GSM123183     2  0.6200      0.837 0.012 0.676 0.312
#> GSM123184     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123185     1  0.5733      0.454 0.676 0.324 0.000
#> GSM123186     1  0.0424      0.941 0.992 0.008 0.000
#> GSM123187     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123188     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123189     3  0.6282      0.931 0.324 0.012 0.664
#> GSM123190     1  0.1482      0.928 0.968 0.012 0.020
#> GSM123191     1  0.0592      0.942 0.988 0.012 0.000
#> GSM123192     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123193     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123194     1  0.0592      0.942 0.988 0.012 0.000
#> GSM123195     2  0.5650      0.842 0.000 0.688 0.312
#> GSM123196     3  0.5919      0.983 0.276 0.012 0.712
#> GSM123197     2  0.6200      0.837 0.012 0.676 0.312
#> GSM123198     2  0.5591      0.844 0.000 0.696 0.304
#> GSM123199     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123200     2  0.5650      0.842 0.000 0.688 0.312
#> GSM123201     1  0.0592      0.942 0.988 0.012 0.000
#> GSM123202     2  0.5591      0.844 0.000 0.696 0.304
#> GSM123203     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123204     2  0.5591      0.844 0.000 0.696 0.304
#> GSM123205     2  0.0000      0.798 0.000 1.000 0.000
#> GSM123206     2  0.5591      0.844 0.000 0.696 0.304
#> GSM123207     1  0.0592      0.942 0.988 0.012 0.000
#> GSM123208     2  0.5650      0.842 0.000 0.688 0.312
#> GSM123209     2  0.6355      0.426 0.280 0.696 0.024
#> GSM123210     1  0.0000      0.943 1.000 0.000 0.000
#> GSM123211     1  0.1643      0.916 0.956 0.000 0.044

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     2  0.6852      0.534 0.000 0.600 0.192 0.208
#> GSM123213     2  0.4855      0.638 0.000 0.600 0.000 0.400
#> GSM123214     2  0.4830      0.641 0.000 0.608 0.000 0.392
#> GSM123215     2  0.4817      0.643 0.000 0.612 0.000 0.388
#> GSM123216     1  0.4391      0.728 0.740 0.000 0.008 0.252
#> GSM123217     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123218     3  0.3528      0.917 0.000 0.192 0.808 0.000
#> GSM123219     1  0.1022      0.664 0.968 0.000 0.000 0.032
#> GSM123220     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123221     1  0.1022      0.664 0.968 0.000 0.000 0.032
#> GSM123222     1  0.0817      0.669 0.976 0.000 0.000 0.024
#> GSM123223     2  0.4830      0.641 0.000 0.608 0.000 0.392
#> GSM123224     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123225     1  0.4220      0.732 0.748 0.000 0.004 0.248
#> GSM123226     1  0.4807      0.723 0.728 0.000 0.024 0.248
#> GSM123227     1  0.3444      0.725 0.816 0.000 0.000 0.184
#> GSM123228     1  0.4220      0.732 0.748 0.000 0.004 0.248
#> GSM123229     3  0.4842      0.881 0.048 0.192 0.760 0.000
#> GSM123230     1  0.6412      0.411 0.592 0.000 0.320 0.088
#> GSM123231     3  0.3528      0.917 0.000 0.192 0.808 0.000
#> GSM123232     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123233     1  0.5000     -0.902 0.504 0.000 0.000 0.496
#> GSM123234     1  0.4795      0.610 0.776 0.020 0.184 0.020
#> GSM123235     3  0.3569      0.916 0.000 0.196 0.804 0.000
#> GSM123236     1  0.2408      0.548 0.896 0.000 0.000 0.104
#> GSM123237     1  0.3300      0.730 0.848 0.000 0.008 0.144
#> GSM123238     2  0.6852      0.534 0.000 0.600 0.192 0.208
#> GSM123239     1  0.1022      0.664 0.968 0.000 0.000 0.032
#> GSM123240     1  0.3498      0.732 0.832 0.000 0.008 0.160
#> GSM123241     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123242     2  0.4855      0.638 0.000 0.600 0.000 0.400
#> GSM123182     4  0.4977      1.000 0.460 0.000 0.000 0.540
#> GSM123183     2  0.6852      0.534 0.000 0.600 0.192 0.208
#> GSM123184     2  0.4830      0.641 0.000 0.608 0.000 0.392
#> GSM123185     4  0.4977      1.000 0.460 0.000 0.000 0.540
#> GSM123186     1  0.1356      0.656 0.960 0.008 0.000 0.032
#> GSM123187     2  0.4830      0.641 0.000 0.608 0.000 0.392
#> GSM123188     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123189     3  0.6790      0.630 0.200 0.192 0.608 0.000
#> GSM123190     1  0.4500      0.311 0.776 0.192 0.000 0.032
#> GSM123191     1  0.0592      0.675 0.984 0.000 0.000 0.016
#> GSM123192     1  0.1022      0.664 0.968 0.000 0.000 0.032
#> GSM123193     1  0.0921      0.667 0.972 0.000 0.000 0.028
#> GSM123194     1  0.4072      0.718 0.748 0.000 0.000 0.252
#> GSM123195     2  0.0000      0.677 0.000 1.000 0.000 0.000
#> GSM123196     3  0.3528      0.917 0.000 0.192 0.808 0.000
#> GSM123197     2  0.6852      0.534 0.000 0.600 0.192 0.208
#> GSM123198     2  0.0000      0.677 0.000 1.000 0.000 0.000
#> GSM123199     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123200     2  0.0000      0.677 0.000 1.000 0.000 0.000
#> GSM123201     1  0.1389      0.705 0.952 0.000 0.000 0.048
#> GSM123202     2  0.0188      0.677 0.004 0.996 0.000 0.000
#> GSM123203     1  0.4072      0.732 0.748 0.000 0.000 0.252
#> GSM123204     2  0.0336      0.677 0.000 0.992 0.000 0.008
#> GSM123205     2  0.4830      0.641 0.000 0.608 0.000 0.392
#> GSM123206     2  0.0000      0.677 0.000 1.000 0.000 0.000
#> GSM123207     1  0.1118      0.660 0.964 0.000 0.000 0.036
#> GSM123208     2  0.0000      0.677 0.000 1.000 0.000 0.000
#> GSM123209     2  0.3933      0.472 0.200 0.792 0.000 0.008
#> GSM123210     1  0.0188      0.686 0.996 0.000 0.000 0.004
#> GSM123211     1  0.8234     -0.255 0.532 0.052 0.192 0.224

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     4  0.0703      0.998 0.000 0.024 0.000 0.976 0.000
#> GSM123213     5  0.3143      0.701 0.000 0.204 0.000 0.000 0.796
#> GSM123214     5  0.4278      0.487 0.000 0.452 0.000 0.000 0.548
#> GSM123215     2  0.4126     -0.030 0.000 0.620 0.000 0.000 0.380
#> GSM123216     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.0162      0.902 0.996 0.000 0.000 0.004 0.000
#> GSM123218     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM123219     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123220     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123221     1  0.0324      0.901 0.992 0.004 0.000 0.004 0.000
#> GSM123222     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123223     5  0.4278      0.487 0.000 0.452 0.000 0.000 0.548
#> GSM123224     1  0.0162      0.902 0.996 0.000 0.000 0.004 0.000
#> GSM123225     1  0.0162      0.902 0.996 0.000 0.000 0.004 0.000
#> GSM123226     1  0.3387      0.768 0.796 0.004 0.196 0.004 0.000
#> GSM123227     1  0.3333      0.792 0.788 0.000 0.000 0.004 0.208
#> GSM123228     1  0.3231      0.799 0.800 0.000 0.000 0.004 0.196
#> GSM123229     3  0.0566      0.976 0.012 0.004 0.984 0.000 0.000
#> GSM123230     1  0.4545      0.363 0.560 0.004 0.432 0.004 0.000
#> GSM123231     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM123232     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123233     5  0.0865      0.614 0.024 0.000 0.000 0.004 0.972
#> GSM123234     1  0.3352      0.772 0.800 0.004 0.192 0.004 0.000
#> GSM123235     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM123236     1  0.4455      0.562 0.588 0.000 0.000 0.008 0.404
#> GSM123237     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123238     4  0.0703      0.998 0.000 0.024 0.000 0.976 0.000
#> GSM123239     1  0.4310      0.583 0.604 0.004 0.000 0.000 0.392
#> GSM123240     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123241     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123242     5  0.3143      0.701 0.000 0.204 0.000 0.000 0.796
#> GSM123182     5  0.0510      0.629 0.000 0.000 0.000 0.016 0.984
#> GSM123183     4  0.0703      0.998 0.000 0.024 0.000 0.976 0.000
#> GSM123184     5  0.4278      0.487 0.000 0.452 0.000 0.000 0.548
#> GSM123185     5  0.0510      0.629 0.000 0.000 0.000 0.016 0.984
#> GSM123186     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123187     5  0.3109      0.701 0.000 0.200 0.000 0.000 0.800
#> GSM123188     1  0.0162      0.902 0.996 0.000 0.000 0.004 0.000
#> GSM123189     3  0.0932      0.961 0.020 0.004 0.972 0.004 0.000
#> GSM123190     1  0.1991      0.849 0.916 0.004 0.076 0.004 0.000
#> GSM123191     1  0.0324      0.901 0.992 0.004 0.000 0.004 0.000
#> GSM123192     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123193     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123194     1  0.3300      0.794 0.792 0.000 0.000 0.004 0.204
#> GSM123195     2  0.0162      0.888 0.000 0.996 0.004 0.000 0.000
#> GSM123196     3  0.0000      0.986 0.000 0.000 1.000 0.000 0.000
#> GSM123197     4  0.0703      0.998 0.000 0.024 0.000 0.976 0.000
#> GSM123198     2  0.0000      0.889 0.000 1.000 0.000 0.000 0.000
#> GSM123199     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123200     2  0.0162      0.888 0.000 0.996 0.004 0.000 0.000
#> GSM123201     1  0.3422      0.795 0.792 0.004 0.000 0.004 0.200
#> GSM123202     2  0.0000      0.889 0.000 1.000 0.000 0.000 0.000
#> GSM123203     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123204     2  0.0000      0.889 0.000 1.000 0.000 0.000 0.000
#> GSM123205     5  0.4192      0.548 0.000 0.404 0.000 0.000 0.596
#> GSM123206     2  0.0000      0.889 0.000 1.000 0.000 0.000 0.000
#> GSM123207     1  0.4464      0.554 0.584 0.000 0.000 0.008 0.408
#> GSM123208     2  0.0162      0.888 0.000 0.996 0.004 0.000 0.000
#> GSM123209     2  0.3920      0.623 0.120 0.812 0.000 0.008 0.060
#> GSM123210     1  0.0000      0.903 1.000 0.000 0.000 0.000 0.000
#> GSM123211     4  0.0771      0.992 0.004 0.020 0.000 0.976 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123212     4  0.0000     0.9528 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123213     6  0.2003     0.9953 0.000 0.116 0.000 0.000 0.000 0.884
#> GSM123214     6  0.2146     0.9965 0.000 0.116 0.000 0.000 0.004 0.880
#> GSM123215     2  0.3999    -0.2468 0.004 0.500 0.000 0.000 0.000 0.496
#> GSM123216     1  0.1588     0.7754 0.924 0.000 0.004 0.000 0.072 0.000
#> GSM123217     1  0.2302     0.7568 0.872 0.000 0.000 0.000 0.120 0.008
#> GSM123218     3  0.0000     0.7128 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123219     1  0.0508     0.7885 0.984 0.000 0.000 0.000 0.012 0.004
#> GSM123220     1  0.1152     0.7715 0.952 0.000 0.004 0.000 0.044 0.000
#> GSM123221     1  0.3266     0.4728 0.728 0.000 0.000 0.000 0.272 0.000
#> GSM123222     1  0.1531     0.7779 0.928 0.000 0.000 0.000 0.068 0.004
#> GSM123223     6  0.2146     0.9965 0.000 0.116 0.000 0.000 0.004 0.880
#> GSM123224     1  0.1700     0.7447 0.916 0.000 0.004 0.000 0.080 0.000
#> GSM123225     1  0.3341     0.7174 0.816 0.000 0.000 0.000 0.068 0.116
#> GSM123226     3  0.7380     0.0937 0.276 0.000 0.336 0.000 0.276 0.112
#> GSM123227     5  0.3695     0.5882 0.376 0.000 0.000 0.000 0.624 0.000
#> GSM123228     1  0.5320     0.1480 0.532 0.000 0.000 0.000 0.352 0.116
#> GSM123229     3  0.0000     0.7128 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123230     3  0.5697     0.2981 0.208 0.000 0.520 0.000 0.272 0.000
#> GSM123231     3  0.0000     0.7128 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123232     1  0.2234     0.7531 0.872 0.000 0.000 0.000 0.124 0.004
#> GSM123233     5  0.5219     0.4372 0.116 0.000 0.000 0.000 0.568 0.316
#> GSM123234     3  0.6075     0.0166 0.332 0.000 0.392 0.000 0.276 0.000
#> GSM123235     3  0.0000     0.7128 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123236     5  0.3766     0.6669 0.304 0.000 0.000 0.000 0.684 0.012
#> GSM123237     1  0.1444     0.7759 0.928 0.000 0.000 0.000 0.072 0.000
#> GSM123238     4  0.0000     0.9528 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123239     5  0.3464     0.6517 0.312 0.000 0.000 0.000 0.688 0.000
#> GSM123240     1  0.1444     0.7759 0.928 0.000 0.000 0.000 0.072 0.000
#> GSM123241     1  0.0405     0.7848 0.988 0.000 0.004 0.000 0.008 0.000
#> GSM123242     6  0.2003     0.9953 0.000 0.116 0.000 0.000 0.000 0.884
#> GSM123182     5  0.5320     0.3922 0.116 0.000 0.000 0.000 0.532 0.352
#> GSM123183     4  0.0000     0.9528 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123184     6  0.2003     0.9953 0.000 0.116 0.000 0.000 0.000 0.884
#> GSM123185     5  0.5310     0.3926 0.116 0.000 0.000 0.000 0.536 0.348
#> GSM123186     1  0.0547     0.7886 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM123187     6  0.2146     0.9965 0.000 0.116 0.000 0.000 0.004 0.880
#> GSM123188     1  0.2212     0.7566 0.880 0.000 0.000 0.000 0.112 0.008
#> GSM123189     3  0.1753     0.6841 0.004 0.000 0.912 0.000 0.084 0.000
#> GSM123190     1  0.6088    -0.2745 0.368 0.000 0.356 0.000 0.276 0.000
#> GSM123191     1  0.3288     0.4664 0.724 0.000 0.000 0.000 0.276 0.000
#> GSM123192     1  0.1327     0.7795 0.936 0.000 0.000 0.000 0.064 0.000
#> GSM123193     1  0.0146     0.7868 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM123194     5  0.3428     0.6618 0.304 0.000 0.000 0.000 0.696 0.000
#> GSM123195     2  0.0000     0.8134 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123196     3  0.0000     0.7128 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123197     4  0.0000     0.9528 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123198     2  0.0146     0.8123 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM123199     1  0.2100     0.7570 0.884 0.000 0.000 0.000 0.112 0.004
#> GSM123200     2  0.0000     0.8134 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123201     5  0.3659     0.5789 0.364 0.000 0.000 0.000 0.636 0.000
#> GSM123202     2  0.1531     0.7939 0.004 0.928 0.000 0.000 0.000 0.068
#> GSM123203     1  0.2212     0.7566 0.880 0.000 0.000 0.000 0.112 0.008
#> GSM123204     2  0.2823     0.6919 0.000 0.796 0.000 0.000 0.000 0.204
#> GSM123205     6  0.2146     0.9965 0.000 0.116 0.000 0.000 0.004 0.880
#> GSM123206     2  0.2994     0.6887 0.004 0.788 0.000 0.000 0.000 0.208
#> GSM123207     1  0.4461    -0.2176 0.564 0.000 0.000 0.000 0.404 0.032
#> GSM123208     2  0.0000     0.8134 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123209     2  0.4055     0.6358 0.064 0.780 0.000 0.000 0.132 0.024
#> GSM123210     1  0.0146     0.7868 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM123211     4  0.2003     0.7955 0.116 0.000 0.000 0.884 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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) k
#> ATC:mclust 61           0.1461 2
#> ATC:mclust 58           0.2012 3
#> ATC:mclust 56           0.1323 4
#> ATC:mclust 56           0.0380 5
#> ATC:mclust 49           0.0729 6

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


ATC:NMF

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.900           0.923       0.970         0.4847 0.515   0.515
#> 3 3 0.663           0.790       0.884         0.3198 0.779   0.592
#> 4 4 0.586           0.469       0.724         0.1505 0.871   0.659
#> 5 5 0.642           0.640       0.809         0.0725 0.865   0.563
#> 6 6 0.595           0.536       0.724         0.0356 0.940   0.735

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
#> GSM123212     2   0.000      0.963 0.000 1.000
#> GSM123213     2   0.000      0.963 0.000 1.000
#> GSM123214     2   0.000      0.963 0.000 1.000
#> GSM123215     2   0.000      0.963 0.000 1.000
#> GSM123216     1   0.000      0.970 1.000 0.000
#> GSM123217     1   0.000      0.970 1.000 0.000
#> GSM123218     1   0.000      0.970 1.000 0.000
#> GSM123219     1   0.529      0.853 0.880 0.120
#> GSM123220     1   0.000      0.970 1.000 0.000
#> GSM123221     1   0.000      0.970 1.000 0.000
#> GSM123222     1   0.000      0.970 1.000 0.000
#> GSM123223     2   0.000      0.963 0.000 1.000
#> GSM123224     1   0.000      0.970 1.000 0.000
#> GSM123225     1   0.000      0.970 1.000 0.000
#> GSM123226     1   0.000      0.970 1.000 0.000
#> GSM123227     1   0.000      0.970 1.000 0.000
#> GSM123228     1   0.000      0.970 1.000 0.000
#> GSM123229     1   0.000      0.970 1.000 0.000
#> GSM123230     1   0.000      0.970 1.000 0.000
#> GSM123231     1   0.000      0.970 1.000 0.000
#> GSM123232     1   0.000      0.970 1.000 0.000
#> GSM123233     1   0.943      0.437 0.640 0.360
#> GSM123234     1   0.000      0.970 1.000 0.000
#> GSM123235     1   0.000      0.970 1.000 0.000
#> GSM123236     1   0.000      0.970 1.000 0.000
#> GSM123237     1   0.000      0.970 1.000 0.000
#> GSM123238     2   0.000      0.963 0.000 1.000
#> GSM123239     2   0.876      0.563 0.296 0.704
#> GSM123240     1   0.000      0.970 1.000 0.000
#> GSM123241     1   0.000      0.970 1.000 0.000
#> GSM123242     2   0.000      0.963 0.000 1.000
#> GSM123182     1   0.311      0.920 0.944 0.056
#> GSM123183     2   0.000      0.963 0.000 1.000
#> GSM123184     2   0.000      0.963 0.000 1.000
#> GSM123185     1   0.000      0.970 1.000 0.000
#> GSM123186     2   0.000      0.963 0.000 1.000
#> GSM123187     2   0.000      0.963 0.000 1.000
#> GSM123188     1   0.000      0.970 1.000 0.000
#> GSM123189     1   0.000      0.970 1.000 0.000
#> GSM123190     1   0.529      0.853 0.880 0.120
#> GSM123191     1   0.000      0.970 1.000 0.000
#> GSM123192     2   0.995      0.117 0.460 0.540
#> GSM123193     1   0.000      0.970 1.000 0.000
#> GSM123194     1   0.000      0.970 1.000 0.000
#> GSM123195     2   0.000      0.963 0.000 1.000
#> GSM123196     1   0.000      0.970 1.000 0.000
#> GSM123197     2   0.000      0.963 0.000 1.000
#> GSM123198     2   0.000      0.963 0.000 1.000
#> GSM123199     1   0.000      0.970 1.000 0.000
#> GSM123200     2   0.000      0.963 0.000 1.000
#> GSM123201     1   0.000      0.970 1.000 0.000
#> GSM123202     2   0.000      0.963 0.000 1.000
#> GSM123203     1   0.000      0.970 1.000 0.000
#> GSM123204     2   0.000      0.963 0.000 1.000
#> GSM123205     2   0.000      0.963 0.000 1.000
#> GSM123206     2   0.000      0.963 0.000 1.000
#> GSM123207     2   0.311      0.910 0.056 0.944
#> GSM123208     2   0.000      0.963 0.000 1.000
#> GSM123209     2   0.000      0.963 0.000 1.000
#> GSM123210     1   0.000      0.970 1.000 0.000
#> GSM123211     1   0.949      0.416 0.632 0.368

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123212     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123213     2  0.3551     0.8479 0.132 0.868 0.000
#> GSM123214     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123215     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123216     1  0.2878     0.8700 0.904 0.000 0.096
#> GSM123217     1  0.0892     0.8638 0.980 0.000 0.020
#> GSM123218     3  0.0000     0.7689 0.000 0.000 1.000
#> GSM123219     1  0.1529     0.8282 0.960 0.040 0.000
#> GSM123220     1  0.4702     0.7845 0.788 0.000 0.212
#> GSM123221     1  0.4047     0.8464 0.848 0.004 0.148
#> GSM123222     1  0.4702     0.7842 0.788 0.000 0.212
#> GSM123223     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123224     1  0.4555     0.7987 0.800 0.000 0.200
#> GSM123225     1  0.4235     0.8238 0.824 0.000 0.176
#> GSM123226     3  0.6307     0.0181 0.488 0.000 0.512
#> GSM123227     1  0.3482     0.8612 0.872 0.000 0.128
#> GSM123228     1  0.4974     0.7483 0.764 0.000 0.236
#> GSM123229     3  0.1289     0.7619 0.032 0.000 0.968
#> GSM123230     3  0.4291     0.6607 0.180 0.000 0.820
#> GSM123231     3  0.0000     0.7689 0.000 0.000 1.000
#> GSM123232     1  0.3340     0.8637 0.880 0.000 0.120
#> GSM123233     3  0.7575     0.0665 0.040 0.456 0.504
#> GSM123234     3  0.2796     0.7336 0.092 0.000 0.908
#> GSM123235     3  0.0000     0.7689 0.000 0.000 1.000
#> GSM123236     1  0.1529     0.8695 0.960 0.000 0.040
#> GSM123237     1  0.0000     0.8556 1.000 0.000 0.000
#> GSM123238     2  0.3752     0.8253 0.144 0.856 0.000
#> GSM123239     2  0.1647     0.9166 0.036 0.960 0.004
#> GSM123240     1  0.0000     0.8556 1.000 0.000 0.000
#> GSM123241     1  0.3551     0.8586 0.868 0.000 0.132
#> GSM123242     2  0.3752     0.8362 0.144 0.856 0.000
#> GSM123182     1  0.0237     0.8535 0.996 0.004 0.000
#> GSM123183     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123184     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123185     1  0.0000     0.8556 1.000 0.000 0.000
#> GSM123186     2  0.6140     0.4280 0.404 0.596 0.000
#> GSM123187     2  0.0424     0.9441 0.008 0.992 0.000
#> GSM123188     1  0.2165     0.8715 0.936 0.000 0.064
#> GSM123189     3  0.0000     0.7689 0.000 0.000 1.000
#> GSM123190     3  0.3116     0.6869 0.000 0.108 0.892
#> GSM123191     3  0.6295     0.0774 0.472 0.000 0.528
#> GSM123192     1  0.3267     0.7400 0.884 0.116 0.000
#> GSM123193     1  0.1529     0.8695 0.960 0.000 0.040
#> GSM123194     1  0.2878     0.8703 0.904 0.000 0.096
#> GSM123195     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123196     3  0.0000     0.7689 0.000 0.000 1.000
#> GSM123197     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123198     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123199     1  0.3551     0.8586 0.868 0.000 0.132
#> GSM123200     2  0.2711     0.8757 0.000 0.912 0.088
#> GSM123201     3  0.6305     0.0344 0.484 0.000 0.516
#> GSM123202     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123203     1  0.3482     0.8610 0.872 0.000 0.128
#> GSM123204     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123205     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123206     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123207     1  0.5178     0.5206 0.744 0.256 0.000
#> GSM123208     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123209     2  0.0000     0.9485 0.000 1.000 0.000
#> GSM123210     1  0.0237     0.8576 0.996 0.000 0.004
#> GSM123211     1  0.3340     0.7353 0.880 0.120 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123212     2  0.5038      0.500 0.012 0.652 0.000 0.336
#> GSM123213     4  0.4981     -0.351 0.000 0.464 0.000 0.536
#> GSM123214     2  0.3801      0.675 0.000 0.780 0.000 0.220
#> GSM123215     2  0.3266      0.718 0.000 0.832 0.000 0.168
#> GSM123216     1  0.4624      0.477 0.660 0.000 0.000 0.340
#> GSM123217     1  0.4250      0.502 0.724 0.000 0.000 0.276
#> GSM123218     3  0.0000      0.879 0.000 0.000 1.000 0.000
#> GSM123219     1  0.5750      0.350 0.532 0.028 0.000 0.440
#> GSM123220     1  0.4843      0.523 0.784 0.000 0.104 0.112
#> GSM123221     4  0.7068     -0.357 0.404 0.004 0.108 0.484
#> GSM123222     1  0.3338      0.459 0.884 0.008 0.052 0.056
#> GSM123223     2  0.0592      0.776 0.000 0.984 0.000 0.016
#> GSM123224     1  0.4292      0.527 0.820 0.000 0.080 0.100
#> GSM123225     1  0.2399      0.481 0.920 0.000 0.048 0.032
#> GSM123226     1  0.5489      0.284 0.700 0.000 0.240 0.060
#> GSM123227     4  0.5168      0.118 0.496 0.000 0.004 0.500
#> GSM123228     1  0.4036      0.411 0.836 0.000 0.076 0.088
#> GSM123229     3  0.2124      0.857 0.068 0.000 0.924 0.008
#> GSM123230     3  0.4502      0.720 0.236 0.000 0.748 0.016
#> GSM123231     3  0.0188      0.881 0.004 0.000 0.996 0.000
#> GSM123232     1  0.1452      0.523 0.956 0.000 0.008 0.036
#> GSM123233     4  0.8828      0.272 0.192 0.220 0.096 0.492
#> GSM123234     3  0.4814      0.736 0.172 0.004 0.776 0.048
#> GSM123235     3  0.0336      0.882 0.008 0.000 0.992 0.000
#> GSM123236     1  0.5688     -0.205 0.512 0.000 0.024 0.464
#> GSM123237     1  0.4776      0.451 0.624 0.000 0.000 0.376
#> GSM123238     2  0.6932      0.214 0.112 0.492 0.000 0.396
#> GSM123239     2  0.5165      0.596 0.052 0.784 0.028 0.136
#> GSM123240     1  0.4585      0.479 0.668 0.000 0.000 0.332
#> GSM123241     1  0.6078      0.465 0.620 0.000 0.068 0.312
#> GSM123242     2  0.5168      0.346 0.004 0.500 0.000 0.496
#> GSM123182     4  0.4790      0.246 0.380 0.000 0.000 0.620
#> GSM123183     2  0.4761      0.515 0.004 0.664 0.000 0.332
#> GSM123184     2  0.3975      0.660 0.000 0.760 0.000 0.240
#> GSM123185     4  0.4843      0.237 0.396 0.000 0.000 0.604
#> GSM123186     4  0.7499     -0.184 0.180 0.400 0.000 0.420
#> GSM123187     2  0.4925      0.344 0.000 0.572 0.000 0.428
#> GSM123188     1  0.3196      0.531 0.856 0.000 0.008 0.136
#> GSM123189     3  0.0469      0.882 0.012 0.000 0.988 0.000
#> GSM123190     3  0.1004      0.866 0.004 0.024 0.972 0.000
#> GSM123191     3  0.5206      0.527 0.308 0.000 0.668 0.024
#> GSM123192     4  0.6605     -0.322 0.440 0.080 0.000 0.480
#> GSM123193     1  0.4888      0.415 0.588 0.000 0.000 0.412
#> GSM123194     1  0.5384      0.124 0.648 0.000 0.028 0.324
#> GSM123195     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM123196     3  0.0188      0.881 0.004 0.000 0.996 0.000
#> GSM123197     2  0.5897      0.394 0.044 0.588 0.000 0.368
#> GSM123198     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM123199     1  0.1151      0.506 0.968 0.000 0.024 0.008
#> GSM123200     2  0.0469      0.774 0.000 0.988 0.012 0.000
#> GSM123201     1  0.7853     -0.152 0.436 0.004 0.232 0.328
#> GSM123202     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM123203     1  0.0937      0.507 0.976 0.000 0.012 0.012
#> GSM123204     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM123205     2  0.0188      0.778 0.000 0.996 0.000 0.004
#> GSM123206     2  0.0188      0.778 0.000 0.996 0.000 0.004
#> GSM123207     1  0.7894     -0.310 0.372 0.296 0.000 0.332
#> GSM123208     2  0.0000      0.778 0.000 1.000 0.000 0.000
#> GSM123209     2  0.2399      0.758 0.000 0.920 0.032 0.048
#> GSM123210     1  0.4991      0.432 0.608 0.004 0.000 0.388
#> GSM123211     1  0.6384      0.334 0.532 0.068 0.000 0.400

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123212     2  0.5731     0.2740 0.072 0.556 0.000 0.364 0.008
#> GSM123213     4  0.3269     0.7541 0.000 0.096 0.000 0.848 0.056
#> GSM123214     4  0.2563     0.7544 0.000 0.120 0.000 0.872 0.008
#> GSM123215     4  0.3399     0.7278 0.000 0.168 0.000 0.812 0.020
#> GSM123216     1  0.0000     0.7252 1.000 0.000 0.000 0.000 0.000
#> GSM123217     1  0.2278     0.7342 0.916 0.000 0.008 0.032 0.044
#> GSM123218     3  0.0000     0.9167 0.000 0.000 1.000 0.000 0.000
#> GSM123219     4  0.4683     0.4914 0.356 0.008 0.000 0.624 0.012
#> GSM123220     1  0.2592     0.7257 0.892 0.000 0.056 0.000 0.052
#> GSM123221     4  0.4778     0.6066 0.052 0.000 0.188 0.740 0.020
#> GSM123222     1  0.7200     0.1568 0.452 0.220 0.016 0.008 0.304
#> GSM123223     2  0.1764     0.7883 0.000 0.928 0.000 0.064 0.008
#> GSM123224     1  0.3442     0.7022 0.836 0.000 0.060 0.000 0.104
#> GSM123225     1  0.5159     0.3120 0.556 0.000 0.044 0.000 0.400
#> GSM123226     1  0.6440     0.2312 0.496 0.000 0.148 0.008 0.348
#> GSM123227     5  0.2521     0.6694 0.068 0.000 0.008 0.024 0.900
#> GSM123228     5  0.5195     0.1020 0.388 0.000 0.048 0.000 0.564
#> GSM123229     3  0.0865     0.9110 0.000 0.000 0.972 0.004 0.024
#> GSM123230     3  0.4552     0.7337 0.068 0.000 0.756 0.008 0.168
#> GSM123231     3  0.0000     0.9167 0.000 0.000 1.000 0.000 0.000
#> GSM123232     1  0.3093     0.6842 0.824 0.000 0.008 0.000 0.168
#> GSM123233     5  0.3751     0.6481 0.000 0.108 0.032 0.028 0.832
#> GSM123234     3  0.4080     0.7276 0.016 0.000 0.760 0.012 0.212
#> GSM123235     3  0.1095     0.9128 0.012 0.000 0.968 0.008 0.012
#> GSM123236     5  0.3738     0.6299 0.128 0.000 0.024 0.024 0.824
#> GSM123237     1  0.3128     0.6326 0.824 0.004 0.000 0.168 0.004
#> GSM123238     2  0.7096    -0.0596 0.332 0.380 0.000 0.276 0.012
#> GSM123239     2  0.1960     0.7659 0.000 0.928 0.004 0.020 0.048
#> GSM123240     1  0.0771     0.7215 0.976 0.000 0.000 0.020 0.004
#> GSM123241     1  0.1059     0.7274 0.968 0.000 0.020 0.004 0.008
#> GSM123242     4  0.1774     0.7559 0.000 0.052 0.000 0.932 0.016
#> GSM123182     5  0.4219     0.2286 0.000 0.000 0.000 0.416 0.584
#> GSM123183     2  0.5552     0.3548 0.064 0.588 0.000 0.340 0.008
#> GSM123184     4  0.4184     0.5351 0.000 0.284 0.000 0.700 0.016
#> GSM123185     5  0.3292     0.6328 0.008 0.000 0.016 0.140 0.836
#> GSM123186     4  0.4750     0.6876 0.208 0.052 0.000 0.728 0.012
#> GSM123187     4  0.3953     0.7140 0.000 0.148 0.000 0.792 0.060
#> GSM123188     1  0.2407     0.7274 0.896 0.000 0.012 0.004 0.088
#> GSM123189     3  0.0000     0.9167 0.000 0.000 1.000 0.000 0.000
#> GSM123190     3  0.0693     0.9084 0.000 0.008 0.980 0.000 0.012
#> GSM123191     3  0.2962     0.8357 0.084 0.000 0.868 0.000 0.048
#> GSM123192     4  0.3840     0.6782 0.208 0.008 0.000 0.772 0.012
#> GSM123193     1  0.4403     0.2692 0.648 0.000 0.008 0.340 0.004
#> GSM123194     5  0.6177     0.4349 0.248 0.000 0.036 0.100 0.616
#> GSM123195     2  0.0162     0.7995 0.000 0.996 0.000 0.004 0.000
#> GSM123196     3  0.0162     0.9164 0.000 0.000 0.996 0.004 0.000
#> GSM123197     2  0.5388     0.5825 0.148 0.696 0.000 0.144 0.012
#> GSM123198     2  0.0703     0.7990 0.000 0.976 0.000 0.024 0.000
#> GSM123199     1  0.3783     0.6073 0.740 0.000 0.008 0.000 0.252
#> GSM123200     2  0.0324     0.7965 0.000 0.992 0.004 0.000 0.004
#> GSM123201     5  0.3779     0.6609 0.028 0.028 0.080 0.016 0.848
#> GSM123202     2  0.0404     0.7993 0.000 0.988 0.000 0.012 0.000
#> GSM123203     1  0.4039     0.5864 0.720 0.000 0.008 0.004 0.268
#> GSM123204     2  0.0992     0.7979 0.000 0.968 0.000 0.024 0.008
#> GSM123205     2  0.1914     0.7895 0.000 0.924 0.000 0.060 0.016
#> GSM123206     2  0.1197     0.7951 0.000 0.952 0.000 0.048 0.000
#> GSM123207     5  0.6553     0.2658 0.132 0.376 0.000 0.016 0.476
#> GSM123208     2  0.0000     0.7986 0.000 1.000 0.000 0.000 0.000
#> GSM123209     2  0.5523     0.3896 0.000 0.584 0.060 0.348 0.008
#> GSM123210     1  0.2389     0.6781 0.880 0.000 0.004 0.116 0.000
#> GSM123211     1  0.2967     0.6549 0.868 0.012 0.000 0.104 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
#> GSM123212     2  0.6151     0.4014 0.060 0.568 0.000 0.236 0.000 NA
#> GSM123213     4  0.3910     0.6055 0.000 0.140 0.000 0.788 0.028 NA
#> GSM123214     4  0.3624     0.5959 0.000 0.156 0.000 0.784 0.000 NA
#> GSM123215     4  0.4702     0.5488 0.000 0.220 0.000 0.680 0.004 NA
#> GSM123216     1  0.0891     0.6810 0.968 0.000 0.000 0.008 0.000 NA
#> GSM123217     1  0.3133     0.6661 0.856 0.000 0.000 0.040 0.072 NA
#> GSM123218     3  0.0891     0.8323 0.000 0.000 0.968 0.000 0.008 NA
#> GSM123219     4  0.6105     0.1449 0.336 0.004 0.000 0.452 0.004 NA
#> GSM123220     1  0.2758     0.6576 0.872 0.000 0.036 0.000 0.080 NA
#> GSM123221     4  0.5109     0.4213 0.088 0.000 0.232 0.660 0.004 NA
#> GSM123222     5  0.7972     0.3036 0.164 0.328 0.032 0.004 0.340 NA
#> GSM123223     2  0.1480     0.7360 0.000 0.940 0.000 0.040 0.000 NA
#> GSM123224     1  0.4894     0.4560 0.704 0.000 0.088 0.000 0.176 NA
#> GSM123225     5  0.4778     0.1270 0.452 0.000 0.012 0.000 0.508 NA
#> GSM123226     5  0.6566     0.2699 0.320 0.000 0.200 0.000 0.440 NA
#> GSM123227     5  0.5996     0.4524 0.072 0.000 0.028 0.024 0.548 NA
#> GSM123228     5  0.4436     0.4524 0.272 0.000 0.020 0.000 0.680 NA
#> GSM123229     3  0.2993     0.8017 0.016 0.000 0.864 0.004 0.080 NA
#> GSM123230     3  0.6245     0.5187 0.088 0.000 0.580 0.000 0.200 NA
#> GSM123231     3  0.0520     0.8368 0.000 0.000 0.984 0.000 0.008 NA
#> GSM123232     1  0.2848     0.5981 0.816 0.000 0.000 0.000 0.176 NA
#> GSM123233     5  0.3594     0.4897 0.000 0.064 0.012 0.016 0.832 NA
#> GSM123234     3  0.5152     0.4337 0.012 0.004 0.556 0.000 0.376 NA
#> GSM123235     3  0.2316     0.8294 0.004 0.004 0.900 0.000 0.028 NA
#> GSM123236     5  0.4848     0.5218 0.176 0.008 0.000 0.004 0.696 NA
#> GSM123237     1  0.4259     0.5947 0.744 0.000 0.000 0.164 0.008 NA
#> GSM123238     2  0.7441     0.0164 0.308 0.332 0.000 0.132 0.000 NA
#> GSM123239     2  0.3554     0.6543 0.016 0.812 0.004 0.004 0.144 NA
#> GSM123240     1  0.2277     0.6823 0.908 0.000 0.000 0.032 0.032 NA
#> GSM123241     1  0.4578     0.5975 0.748 0.000 0.060 0.016 0.020 NA
#> GSM123242     4  0.2688     0.6202 0.000 0.064 0.000 0.868 0.000 NA
#> GSM123182     4  0.5160     0.0900 0.004 0.000 0.000 0.476 0.448 NA
#> GSM123183     2  0.6043     0.4833 0.060 0.596 0.000 0.172 0.000 NA
#> GSM123184     4  0.4989     0.3410 0.000 0.360 0.000 0.568 0.004 NA
#> GSM123185     5  0.3083     0.4882 0.004 0.000 0.004 0.064 0.852 NA
#> GSM123186     4  0.5394     0.4030 0.292 0.036 0.000 0.604 0.000 NA
#> GSM123187     4  0.5131     0.5437 0.000 0.140 0.000 0.648 0.008 NA
#> GSM123188     1  0.3275     0.6423 0.828 0.000 0.000 0.008 0.120 NA
#> GSM123189     3  0.1267     0.8181 0.000 0.000 0.940 0.000 0.000 NA
#> GSM123190     3  0.1824     0.8297 0.004 0.024 0.936 0.004 0.012 NA
#> GSM123191     3  0.4993     0.7269 0.108 0.000 0.744 0.024 0.060 NA
#> GSM123192     4  0.4319     0.4444 0.248 0.004 0.000 0.696 0.000 NA
#> GSM123193     1  0.4796     0.4361 0.664 0.000 0.004 0.252 0.004 NA
#> GSM123194     5  0.6612     0.4025 0.256 0.000 0.000 0.080 0.508 NA
#> GSM123195     2  0.0632     0.7437 0.000 0.976 0.000 0.000 0.000 NA
#> GSM123196     3  0.0820     0.8383 0.000 0.000 0.972 0.000 0.016 NA
#> GSM123197     2  0.5295     0.5717 0.076 0.668 0.000 0.056 0.000 NA
#> GSM123198     2  0.3558     0.6604 0.000 0.780 0.004 0.032 0.000 NA
#> GSM123199     1  0.4649     0.3696 0.656 0.000 0.020 0.000 0.288 NA
#> GSM123200     2  0.1889     0.7373 0.000 0.920 0.020 0.004 0.000 NA
#> GSM123201     5  0.5489     0.5183 0.076 0.000 0.096 0.000 0.668 NA
#> GSM123202     2  0.1082     0.7433 0.000 0.956 0.000 0.004 0.000 NA
#> GSM123203     1  0.4841     0.1101 0.544 0.000 0.008 0.004 0.412 NA
#> GSM123204     2  0.2278     0.7078 0.000 0.868 0.000 0.004 0.000 NA
#> GSM123205     2  0.4547     0.5348 0.000 0.656 0.000 0.068 0.000 NA
#> GSM123206     2  0.1341     0.7386 0.000 0.948 0.000 0.028 0.000 NA
#> GSM123207     5  0.5694     0.1402 0.072 0.404 0.000 0.008 0.496 NA
#> GSM123208     2  0.1204     0.7419 0.000 0.944 0.000 0.000 0.000 NA
#> GSM123209     4  0.7609     0.1805 0.004 0.316 0.176 0.328 0.000 NA
#> GSM123210     1  0.3961     0.6033 0.764 0.000 0.000 0.124 0.000 NA
#> GSM123211     1  0.4411     0.5519 0.720 0.008 0.000 0.076 0.000 NA

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) k
#> ATC:NMF 58           0.0681 2
#> ATC:NMF 56           0.2544 3
#> ATC:NMF 32           0.1862 4
#> ATC:NMF 48           0.2100 5
#> ATC:NMF 37           0.0936 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