cola Report for GDS2362

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 71 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    71

Density distribution

The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.

library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list), 
    col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
    mc.cores = 4)

plot of chunk density-heatmap

Suggest the best k

Folowing table shows the best k (number of partitions) for each combination of top-value methods and partition methods. Clicking on the method name in the table goes to the section for a single combination of methods.

The cola vignette explains the definition of the metrics used for determining the best number of partitions.

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:kmeans 2 1.000 0.984 0.994 **
SD:NMF 2 1.000 0.983 0.993 **
CV:kmeans 2 1.000 0.987 0.995 **
CV:skmeans 2 1.000 1.000 1.000 **
CV:NMF 2 1.000 0.992 0.997 **
MAD:kmeans 2 1.000 1.000 1.000 **
MAD:skmeans 2 1.000 0.999 0.999 **
MAD:pam 3 1.000 0.971 0.987 ** 2
MAD:NMF 2 1.000 0.987 0.995 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:skmeans 2 1.000 1.000 1.000 **
ATC:mclust 4 1.000 0.980 0.985 ** 2,3
ATC:NMF 2 1.000 0.952 0.983 **
SD:pam 3 0.982 0.943 0.979 ** 2
ATC:pam 5 0.956 0.932 0.966 ** 2
MAD:mclust 3 0.948 0.937 0.970 * 2
SD:skmeans 3 0.946 0.934 0.971 * 2
SD:mclust 4 0.940 0.919 0.966 * 2,3
CV:mclust 5 0.938 0.895 0.941 * 2,4
CV:pam 3 0.915 0.940 0.965 *
ATC:hclust 4 0.871 0.880 0.941
SD:hclust 6 0.724 0.736 0.846
MAD:hclust 2 0.559 0.874 0.899
CV:hclust 3 0.532 0.798 0.892

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

CDF of consensus matrices

Cumulative distribution function curves of consensus matrix for all methods.

collect_plots(res_list, fun = plot_ecdf)

plot of chunk collect-plots

Consensus heatmap

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

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

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

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

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

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

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

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

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

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

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

Membership heatmap

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

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

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

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

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

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

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

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

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

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

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

Signature heatmap

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

Note in following heatmaps, rows are scaled.

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

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

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

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

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

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

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

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

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

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

Statistics table

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

get_stats(res_list, k = 2)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      2 1.000           0.983       0.993          0.480 0.522   0.522
#> CV:NMF      2 1.000           0.992       0.997          0.477 0.522   0.522
#> MAD:NMF     2 1.000           0.987       0.995          0.481 0.522   0.522
#> ATC:NMF     2 1.000           0.952       0.983          0.491 0.505   0.505
#> SD:skmeans  2 1.000           0.999       1.000          0.479 0.522   0.522
#> CV:skmeans  2 1.000           1.000       1.000          0.479 0.522   0.522
#> MAD:skmeans 2 1.000           0.999       0.999          0.479 0.522   0.522
#> ATC:skmeans 2 1.000           1.000       1.000          0.485 0.515   0.515
#> SD:mclust   2 1.000           0.999       1.000          0.471 0.529   0.529
#> CV:mclust   2 1.000           0.994       0.997          0.464 0.537   0.537
#> MAD:mclust  2 1.000           1.000       1.000          0.471 0.529   0.529
#> ATC:mclust  2 1.000           1.000       1.000          0.471 0.529   0.529
#> SD:kmeans   2 1.000           0.984       0.994          0.476 0.522   0.522
#> CV:kmeans   2 1.000           0.987       0.995          0.476 0.522   0.522
#> MAD:kmeans  2 1.000           1.000       1.000          0.479 0.522   0.522
#> ATC:kmeans  2 1.000           1.000       1.000          0.471 0.529   0.529
#> SD:pam      2 1.000           0.993       0.997          0.478 0.522   0.522
#> CV:pam      2 0.862           0.953       0.974          0.486 0.522   0.522
#> MAD:pam     2 1.000           0.985       0.993          0.482 0.522   0.522
#> ATC:pam     2 1.000           0.984       0.994          0.475 0.529   0.529
#> SD:hclust   2 0.232           0.641       0.815          0.385 0.566   0.566
#> CV:hclust   2 0.499           0.750       0.856          0.263 0.892   0.892
#> MAD:hclust  2 0.559           0.874       0.899          0.467 0.522   0.522
#> ATC:hclust  2 0.370           0.260       0.690          0.409 0.820   0.820
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.865           0.877       0.939          0.384 0.794   0.611
#> CV:NMF      3 0.883           0.893       0.944          0.390 0.794   0.611
#> MAD:NMF     3 0.711           0.813       0.887          0.355 0.808   0.637
#> ATC:NMF     3 0.816           0.847       0.916          0.344 0.776   0.582
#> SD:skmeans  3 0.946           0.934       0.971          0.407 0.786   0.597
#> CV:skmeans  3 0.848           0.871       0.941          0.402 0.806   0.628
#> MAD:skmeans 3 0.826           0.870       0.933          0.402 0.806   0.628
#> ATC:skmeans 3 0.819           0.863       0.895          0.379 0.801   0.619
#> SD:mclust   3 1.000           0.969       0.987          0.311 0.849   0.716
#> CV:mclust   3 0.849           0.896       0.938          0.316 0.855   0.730
#> MAD:mclust  3 0.948           0.937       0.970          0.280 0.859   0.734
#> ATC:mclust  3 1.000           0.998       0.999          0.336 0.841   0.699
#> SD:kmeans   3 0.796           0.833       0.897          0.393 0.791   0.605
#> CV:kmeans   3 0.723           0.803       0.877          0.363 0.806   0.628
#> MAD:kmeans  3 0.716           0.819       0.854          0.368 0.805   0.627
#> ATC:kmeans  3 0.710           0.737       0.865          0.333 0.849   0.716
#> SD:pam      3 0.982           0.943       0.979          0.382 0.820   0.655
#> CV:pam      3 0.915           0.940       0.965          0.357 0.825   0.665
#> MAD:pam     3 1.000           0.971       0.987          0.374 0.815   0.646
#> ATC:pam     3 0.850           0.945       0.966          0.399 0.801   0.624
#> SD:hclust   3 0.309           0.535       0.778          0.378 0.870   0.781
#> CV:hclust   3 0.532           0.798       0.892          0.817 0.602   0.553
#> MAD:hclust  3 0.479           0.695       0.827          0.195 0.858   0.745
#> ATC:hclust  3 0.806           0.835       0.896          0.450 0.585   0.503
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.784           0.833       0.887         0.1023 0.899   0.706
#> CV:NMF      4 0.786           0.793       0.882         0.1052 0.908   0.731
#> MAD:NMF     4 0.825           0.780       0.890         0.1111 0.901   0.721
#> ATC:NMF     4 0.757           0.808       0.886         0.1114 0.862   0.628
#> SD:skmeans  4 0.815           0.848       0.909         0.0910 0.886   0.675
#> CV:skmeans  4 0.753           0.729       0.850         0.0940 0.882   0.666
#> MAD:skmeans 4 0.765           0.773       0.870         0.0885 0.911   0.741
#> ATC:skmeans 4 0.898           0.872       0.943         0.0990 0.860   0.618
#> SD:mclust   4 0.940           0.919       0.966         0.1549 0.895   0.727
#> CV:mclust   4 0.900           0.846       0.935         0.2002 0.826   0.580
#> MAD:mclust  4 0.865           0.853       0.920         0.1860 0.878   0.693
#> ATC:mclust  4 1.000           0.980       0.985         0.1391 0.913   0.765
#> SD:kmeans   4 0.755           0.864       0.882         0.1000 0.920   0.762
#> CV:kmeans   4 0.855           0.813       0.898         0.1164 0.899   0.714
#> MAD:kmeans  4 0.671           0.786       0.829         0.1152 0.893   0.695
#> ATC:kmeans  4 0.731           0.871       0.854         0.1282 0.850   0.628
#> SD:pam      4 0.889           0.856       0.944         0.0343 0.989   0.968
#> CV:pam      4 0.880           0.864       0.938         0.0388 0.989   0.968
#> MAD:pam     4 0.943           0.901       0.950         0.0338 0.990   0.969
#> ATC:pam     4 0.899           0.836       0.897         0.0844 0.948   0.845
#> SD:hclust   4 0.403           0.371       0.697         0.1061 0.942   0.883
#> CV:hclust   4 0.562           0.737       0.865         0.1245 0.999   0.998
#> MAD:hclust  4 0.654           0.720       0.811         0.2003 0.813   0.606
#> ATC:hclust  4 0.871           0.880       0.941         0.1351 0.870   0.700
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.722           0.682       0.815         0.0525 0.934   0.766
#> CV:NMF      5 0.773           0.758       0.844         0.0497 0.948   0.810
#> MAD:NMF     5 0.711           0.697       0.817         0.0588 0.945   0.802
#> ATC:NMF     5 0.771           0.705       0.831         0.0496 0.960   0.854
#> SD:skmeans  5 0.731           0.744       0.811         0.0490 1.000   1.000
#> CV:skmeans  5 0.712           0.548       0.762         0.0482 0.963   0.867
#> MAD:skmeans 5 0.739           0.702       0.789         0.0483 1.000   1.000
#> ATC:skmeans 5 0.884           0.822       0.896         0.0435 0.926   0.739
#> SD:mclust   5 0.897           0.855       0.905         0.0686 0.933   0.768
#> CV:mclust   5 0.938           0.895       0.941         0.0446 0.948   0.810
#> MAD:mclust  5 0.844           0.766       0.882         0.0561 0.930   0.761
#> ATC:mclust  5 0.825           0.841       0.889         0.0798 0.957   0.846
#> SD:kmeans   5 0.746           0.709       0.823         0.0555 0.982   0.933
#> CV:kmeans   5 0.774           0.759       0.836         0.0506 0.937   0.794
#> MAD:kmeans  5 0.722           0.720       0.793         0.0592 0.959   0.850
#> ATC:kmeans  5 0.767           0.835       0.858         0.0735 1.000   1.000
#> SD:pam      5 0.859           0.830       0.926         0.0212 0.994   0.982
#> CV:pam      5 0.846           0.843       0.915         0.0131 0.994   0.983
#> MAD:pam     5 0.886           0.860       0.933         0.0184 0.994   0.980
#> ATC:pam     5 0.956           0.932       0.966         0.0480 0.938   0.790
#> SD:hclust   5 0.469           0.624       0.738         0.1172 0.779   0.541
#> CV:hclust   5 0.520           0.607       0.836         0.0732 0.913   0.825
#> MAD:hclust  5 0.692           0.714       0.854         0.0539 0.947   0.840
#> ATC:hclust  5 0.853           0.816       0.923         0.0452 0.990   0.966
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.746           0.639       0.787        0.03139 0.958   0.829
#> CV:NMF      6 0.779           0.675       0.801        0.02638 0.966   0.858
#> MAD:NMF     6 0.704           0.660       0.773        0.03537 0.990   0.959
#> ATC:NMF     6 0.821           0.743       0.851        0.02695 0.959   0.837
#> SD:skmeans  6 0.696           0.596       0.725        0.03552 0.962   0.861
#> CV:skmeans  6 0.649           0.535       0.699        0.03517 0.976   0.906
#> MAD:skmeans 6 0.662           0.592       0.712        0.03857 0.972   0.896
#> ATC:skmeans 6 0.878           0.773       0.853        0.02645 0.984   0.932
#> SD:mclust   6 0.814           0.851       0.889        0.03525 0.956   0.820
#> CV:mclust   6 0.864           0.850       0.893        0.03114 0.973   0.885
#> MAD:mclust  6 0.719           0.634       0.796        0.04523 0.973   0.891
#> ATC:mclust  6 0.832           0.838       0.898        0.05782 0.909   0.638
#> SD:kmeans   6 0.766           0.675       0.791        0.03873 0.986   0.945
#> CV:kmeans   6 0.761           0.705       0.801        0.03992 0.947   0.810
#> MAD:kmeans  6 0.754           0.735       0.799        0.03346 0.994   0.977
#> ATC:kmeans  6 0.799           0.658       0.791        0.04717 0.925   0.731
#> SD:pam      6 0.842           0.791       0.914        0.01345 0.994   0.983
#> CV:pam      6 0.829           0.846       0.927        0.00937 0.995   0.984
#> MAD:pam     6 0.884           0.859       0.932        0.00926 0.994   0.981
#> ATC:pam     6 0.932           0.898       0.932        0.01133 0.998   0.990
#> SD:hclust   6 0.724           0.736       0.846        0.08175 0.965   0.885
#> CV:hclust   6 0.573           0.578       0.802        0.08546 0.915   0.797
#> MAD:hclust  6 0.775           0.656       0.824        0.03400 0.989   0.961
#> ATC:hclust  6 0.899           0.837       0.925        0.08264 0.938   0.791

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) infection(p) agent(p) k
#> SD:NMF      70         6.31e-16     6.31e-16 7.57e-06 2
#> CV:NMF      71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:NMF     70         6.31e-16     6.31e-16 7.57e-06 2
#> ATC:NMF     69         7.45e-15     7.45e-15 1.80e-05 2
#> SD:skmeans  71         3.82e-16     3.82e-16 6.04e-06 2
#> CV:skmeans  71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:skmeans 71         3.82e-16     3.82e-16 6.04e-06 2
#> ATC:skmeans 71         2.82e-15     2.82e-15 1.16e-05 2
#> SD:mclust   71         3.04e-15     3.04e-15 5.99e-05 2
#> CV:mclust   71         2.21e-14     2.21e-14 4.70e-04 2
#> MAD:mclust  71         3.04e-15     3.04e-15 5.99e-05 2
#> ATC:mclust  71         3.04e-15     3.04e-15 5.99e-05 2
#> SD:kmeans   70         6.31e-16     6.31e-16 1.30e-05 2
#> CV:kmeans   70         6.31e-16     6.31e-16 1.30e-05 2
#> MAD:kmeans  71         3.82e-16     3.82e-16 6.04e-06 2
#> ATC:kmeans  71         3.04e-15     3.04e-15 5.99e-05 2
#> SD:pam      71         3.82e-16     3.82e-16 6.04e-06 2
#> CV:pam      71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:pam     71         3.82e-16     3.82e-16 6.04e-06 2
#> ATC:pam     70         6.31e-16     6.31e-16 1.30e-05 2
#> SD:hclust   58         6.76e-07     6.76e-07 1.31e-02 2
#> CV:hclust   71         8.91e-03     8.91e-03 8.09e-01 2
#> MAD:hclust  68         1.71e-15     1.71e-15 1.19e-05 2
#> ATC:hclust  33         6.83e-08     6.83e-08 9.77e-02 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) infection(p) agent(p) k
#> SD:NMF      68         3.48e-13     3.48e-13 1.34e-04 3
#> CV:NMF      69         2.55e-13     2.55e-13 1.10e-04 3
#> MAD:NMF     66         1.87e-14     1.87e-14 3.89e-05 3
#> ATC:NMF     66         2.39e-15     2.39e-15 3.89e-05 3
#> SD:skmeans  69         2.33e-14     2.33e-14 2.00e-05 3
#> CV:skmeans  65         1.81e-13     1.81e-13 3.18e-05 3
#> MAD:skmeans 68         2.27e-14     2.27e-14 1.57e-05 3
#> ATC:skmeans 71         4.65e-26     4.65e-26 7.76e-06 3
#> SD:mclust   70         1.59e-16     1.59e-16 9.67e-05 3
#> CV:mclust   68         9.72e-16     9.72e-16 2.49e-04 3
#> MAD:mclust  68         1.89e-15     1.89e-15 1.47e-04 3
#> ATC:mclust  71         1.36e-17     1.36e-17 7.83e-05 3
#> SD:kmeans   67         3.52e-14     3.52e-14 3.11e-05 3
#> CV:kmeans   65         2.11e-13     2.11e-13 4.87e-05 3
#> MAD:kmeans  71         1.05e-14     1.05e-14 7.76e-06 3
#> ATC:kmeans  64         7.70e-15     7.70e-15 3.36e-04 3
#> SD:pam      69         6.35e-16     6.35e-16 1.24e-05 3
#> CV:pam      71         2.84e-16     2.84e-16 7.76e-06 3
#> MAD:pam     70         8.95e-17     8.95e-17 9.81e-06 3
#> ATC:pam     70         7.72e-15     7.72e-15 8.91e-05 3
#> SD:hclust   44         1.84e-09     1.84e-09 1.40e-02 3
#> CV:hclust   65         6.35e-07     6.35e-07 1.01e-02 3
#> MAD:hclust  59         5.77e-16     5.77e-16 1.33e-04 3
#> ATC:hclust  70         1.22e-14     1.22e-14 9.77e-05 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) infection(p) agent(p) k
#> SD:NMF      68         1.48e-19     1.48e-19 4.65e-04 4
#> CV:NMF      64         1.54e-16     1.54e-16 1.04e-03 4
#> MAD:NMF     63         5.50e-18     5.50e-18 1.23e-03 4
#> ATC:NMF     66         6.20e-19     6.20e-19 6.63e-04 4
#> SD:skmeans  66         2.65e-19     2.65e-19 1.47e-04 4
#> CV:skmeans  61         8.44e-17     8.44e-17 4.26e-04 4
#> MAD:skmeans 62         2.04e-18     2.04e-18 2.38e-04 4
#> ATC:skmeans 66         3.18e-19     3.18e-19 1.47e-04 4
#> SD:mclust   70         4.14e-18     4.14e-18 3.33e-04 4
#> CV:mclust   65         9.70e-17     9.70e-17 8.58e-04 4
#> MAD:mclust  66         7.76e-17     7.76e-17 7.28e-04 4
#> ATC:mclust  71         2.80e-18     2.80e-18 2.74e-04 4
#> SD:kmeans   68         3.09e-20     3.09e-20 9.57e-05 4
#> CV:kmeans   66         5.12e-14     5.12e-14 1.47e-04 4
#> MAD:kmeans  66         1.35e-19     1.35e-19 9.64e-05 4
#> ATC:kmeans  70         4.19e-24     4.19e-24 3.28e-04 4
#> SD:pam      67         1.38e-15     1.38e-15 1.98e-05 4
#> CV:pam      68         7.80e-16     7.80e-16 1.57e-05 4
#> MAD:pam     69         7.37e-17     7.37e-17 1.24e-05 4
#> ATC:pam     67         1.04e-15     1.04e-15 5.81e-04 4
#> SD:hclust   27               NA           NA       NA 4
#> CV:hclust   65         9.68e-07     9.68e-07 1.01e-02 4
#> MAD:hclust  60         1.90e-16     1.90e-16 3.75e-04 4
#> ATC:hclust  69         6.33e-18     6.33e-18 4.11e-04 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) infection(p) agent(p) k
#> SD:NMF      60         1.21e-16     1.21e-16 5.34e-03 5
#> CV:NMF      64         8.87e-16     8.87e-16 2.61e-03 5
#> MAD:NMF     58         1.09e-15     1.09e-15 7.82e-03 5
#> ATC:NMF     57         1.80e-17     1.80e-17 3.72e-03 5
#> SD:skmeans  64         8.56e-19     8.56e-19 2.25e-04 5
#> CV:skmeans  42         6.21e-09     6.21e-09 1.02e-02 5
#> MAD:skmeans 61         6.26e-18     6.26e-18 2.99e-04 5
#> ATC:skmeans 63         5.94e-18     5.94e-18 7.98e-04 5
#> SD:mclust   70         5.03e-21     5.03e-21 8.80e-04 5
#> CV:mclust   68         1.85e-17     1.85e-17 1.24e-03 5
#> MAD:mclust  60         1.36e-19     1.36e-19 1.47e-03 5
#> ATC:mclust  68         4.03e-20     4.03e-20 1.28e-03 5
#> SD:kmeans   62         1.60e-19     1.60e-19 3.44e-04 5
#> CV:kmeans   60         2.17e-16     2.17e-16 1.47e-03 5
#> MAD:kmeans  61         7.87e-18     7.87e-18 2.99e-04 5
#> ATC:kmeans  70         2.59e-25     2.59e-25 6.26e-05 5
#> SD:pam      66         3.88e-15     3.88e-15 2.51e-05 5
#> CV:pam      67         2.36e-15     2.36e-15 1.98e-05 5
#> MAD:pam     68         2.23e-16     2.23e-16 1.57e-05 5
#> ATC:pam     70         1.17e-20     1.17e-20 8.51e-04 5
#> SD:hclust   49         3.46e-10     3.46e-10 1.54e-03 5
#> CV:hclust   47         2.63e-06     2.63e-06 3.50e-02 5
#> MAD:hclust  56         5.29e-15     5.29e-15 2.74e-04 5
#> ATC:hclust  63         2.54e-17     2.54e-17 4.06e-04 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) infection(p) agent(p) k
#> SD:NMF      53         2.41e-13     2.41e-13 2.03e-02 6
#> CV:NMF      55         1.63e-12     1.63e-12 4.05e-03 6
#> MAD:NMF     57         2.94e-15     2.94e-15 9.47e-03 6
#> ATC:NMF     64         3.05e-17     3.05e-17 5.53e-03 6
#> SD:skmeans  50         1.20e-13     1.20e-13 4.60e-03 6
#> CV:skmeans  41         2.70e-09     2.70e-09 1.31e-02 6
#> MAD:skmeans 46         6.15e-11     6.15e-11 3.30e-03 6
#> ATC:skmeans 61         6.91e-20     6.91e-20 1.20e-03 6
#> SD:mclust   69         3.18e-21     3.18e-21 2.44e-03 6
#> CV:mclust   69         4.89e-17     4.89e-17 2.48e-03 6
#> MAD:mclust  50         9.85e-17     9.85e-17 1.65e-02 6
#> ATC:mclust  66         1.85e-18     1.85e-18 2.27e-03 6
#> SD:kmeans   56         2.41e-18     2.41e-18 3.31e-03 6
#> CV:kmeans   62         1.40e-14     1.40e-14 2.36e-03 6
#> MAD:kmeans  66         4.79e-18     4.79e-18 2.91e-04 6
#> ATC:kmeans  60         8.10e-19     8.10e-19 4.61e-03 6
#> SD:pam      65         1.11e-14     1.11e-14 3.18e-05 6
#> CV:pam      67         2.36e-15     2.36e-15 1.98e-05 6
#> MAD:pam     67         6.88e-16     6.88e-16 1.98e-05 6
#> ATC:pam     69         2.96e-20     2.96e-20 1.03e-03 6
#> SD:hclust   62         4.60e-19     4.60e-19 6.90e-04 6
#> CV:hclust   49         3.96e-10     3.96e-10 9.91e-03 6
#> MAD:hclust  55         1.94e-18     1.94e-18 1.18e-03 6
#> ATC:hclust  67         9.96e-23     9.96e-23 1.23e-03 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 71 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 6.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-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.232           0.641       0.815         0.3849 0.566   0.566
#> 3 3 0.309           0.535       0.778         0.3781 0.870   0.781
#> 4 4 0.403           0.371       0.697         0.1061 0.942   0.883
#> 5 5 0.469           0.624       0.738         0.1172 0.779   0.541
#> 6 6 0.724           0.736       0.846         0.0818 0.965   0.885

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

suggest_best_k(res)
#> [1] 6

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     2   0.909     0.4947 0.324 0.676
#> GSM123736     2   0.932     0.4578 0.348 0.652
#> GSM123740     2   0.932     0.4578 0.348 0.652
#> GSM123744     2   1.000    -0.1277 0.492 0.508
#> GSM123746     1   0.998     0.2579 0.528 0.472
#> GSM123750     2   1.000    -0.1277 0.492 0.508
#> GSM123752     2   0.996    -0.0185 0.464 0.536
#> GSM123756     1   0.689     0.8282 0.816 0.184
#> GSM123758     2   0.946     0.3960 0.364 0.636
#> GSM123761     1   0.730     0.8265 0.796 0.204
#> GSM123763     1   0.697     0.8290 0.812 0.188
#> GSM123765     2   0.900     0.5070 0.316 0.684
#> GSM123769     1   0.689     0.8282 0.816 0.184
#> GSM123771     1   0.689     0.8282 0.816 0.184
#> GSM123774     1   0.689     0.8282 0.816 0.184
#> GSM123778     2   0.900     0.5070 0.316 0.684
#> GSM123780     2   0.900     0.5070 0.316 0.684
#> GSM123784     2   0.900     0.5070 0.316 0.684
#> GSM123787     2   0.900     0.5070 0.316 0.684
#> GSM123791     2   0.900     0.5070 0.316 0.684
#> GSM123795     2   0.932     0.4578 0.348 0.652
#> GSM123799     2   0.932     0.4578 0.348 0.652
#> GSM123730     2   0.850     0.5671 0.276 0.724
#> GSM123734     1   0.000     0.6551 1.000 0.000
#> GSM123738     1   0.745     0.7226 0.788 0.212
#> GSM123742     1   0.932     0.6965 0.652 0.348
#> GSM123745     1   0.802     0.8290 0.756 0.244
#> GSM123748     1   0.876     0.7768 0.704 0.296
#> GSM123751     1   0.821     0.8200 0.744 0.256
#> GSM123754     1   0.802     0.8290 0.756 0.244
#> GSM123757     1   0.998     0.2579 0.528 0.472
#> GSM123760     1   0.932     0.6965 0.652 0.348
#> GSM123762     1   0.689     0.8282 0.816 0.184
#> GSM123764     2   0.971     0.2036 0.400 0.600
#> GSM123767     1   0.802     0.8290 0.756 0.244
#> GSM123770     1   0.802     0.8290 0.756 0.244
#> GSM123773     1   0.802     0.8290 0.756 0.244
#> GSM123777     2   0.850     0.5671 0.276 0.724
#> GSM123779     2   0.767     0.6098 0.224 0.776
#> GSM123782     2   0.966     0.2378 0.392 0.608
#> GSM123786     2   0.900     0.5070 0.316 0.684
#> GSM123789     2   0.767     0.6098 0.224 0.776
#> GSM123793     1   0.416     0.6971 0.916 0.084
#> GSM123797     1   0.745     0.7226 0.788 0.212
#> GSM123729     2   0.000     0.7622 0.000 1.000
#> GSM123733     2   0.000     0.7622 0.000 1.000
#> GSM123737     2   0.000     0.7622 0.000 1.000
#> GSM123741     2   0.000     0.7622 0.000 1.000
#> GSM123747     2   0.000     0.7622 0.000 1.000
#> GSM123753     2   0.000     0.7622 0.000 1.000
#> GSM123759     2   0.000     0.7622 0.000 1.000
#> GSM123766     2   0.000     0.7622 0.000 1.000
#> GSM123772     2   0.000     0.7622 0.000 1.000
#> GSM123775     2   0.000     0.7622 0.000 1.000
#> GSM123781     2   0.000     0.7622 0.000 1.000
#> GSM123785     2   0.000     0.7622 0.000 1.000
#> GSM123788     2   0.000     0.7622 0.000 1.000
#> GSM123792     2   0.000     0.7622 0.000 1.000
#> GSM123796     2   0.000     0.7622 0.000 1.000
#> GSM123731     2   0.000     0.7622 0.000 1.000
#> GSM123735     2   0.000     0.7622 0.000 1.000
#> GSM123739     2   0.000     0.7622 0.000 1.000
#> GSM123743     2   0.000     0.7622 0.000 1.000
#> GSM123749     2   0.000     0.7622 0.000 1.000
#> GSM123755     2   0.000     0.7622 0.000 1.000
#> GSM123768     2   0.000     0.7622 0.000 1.000
#> GSM123776     2   0.671     0.6652 0.176 0.824
#> GSM123783     2   0.000     0.7622 0.000 1.000
#> GSM123790     2   0.000     0.7622 0.000 1.000
#> GSM123794     2   0.000     0.7622 0.000 1.000
#> GSM123798     2   0.000     0.7622 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
#> GSM123732     2  0.8876     0.1193 0.412 0.468 0.120
#> GSM123736     2  0.9241     0.1036 0.388 0.456 0.156
#> GSM123740     2  0.9241     0.1036 0.388 0.456 0.156
#> GSM123744     1  0.7872     0.4210 0.620 0.296 0.084
#> GSM123746     1  0.8233     0.4886 0.616 0.264 0.120
#> GSM123750     1  0.7872     0.4210 0.620 0.296 0.084
#> GSM123752     1  0.8582     0.3791 0.568 0.308 0.124
#> GSM123756     1  0.0592     0.5473 0.988 0.000 0.012
#> GSM123758     1  0.8774     0.0448 0.476 0.412 0.112
#> GSM123761     1  0.1529     0.5456 0.960 0.000 0.040
#> GSM123763     1  0.0747     0.5473 0.984 0.000 0.016
#> GSM123765     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123769     1  0.0592     0.5473 0.988 0.000 0.012
#> GSM123771     1  0.0592     0.5473 0.988 0.000 0.012
#> GSM123774     1  0.0592     0.5473 0.988 0.000 0.012
#> GSM123778     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123780     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123784     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123787     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123791     2  0.8808     0.1552 0.400 0.484 0.116
#> GSM123795     2  0.9241     0.1036 0.388 0.456 0.156
#> GSM123799     2  0.9241     0.1036 0.388 0.456 0.156
#> GSM123730     2  0.6404     0.4490 0.012 0.644 0.344
#> GSM123734     3  0.3192     0.7247 0.112 0.000 0.888
#> GSM123738     3  0.3771     0.8070 0.012 0.112 0.876
#> GSM123742     1  0.9441     0.4011 0.484 0.200 0.316
#> GSM123745     1  0.8196     0.4732 0.624 0.124 0.252
#> GSM123748     1  0.8823     0.4685 0.564 0.156 0.280
#> GSM123751     1  0.8343     0.4759 0.612 0.132 0.256
#> GSM123754     1  0.7824     0.5296 0.664 0.124 0.212
#> GSM123757     1  0.8349     0.4909 0.608 0.264 0.128
#> GSM123760     1  0.9372     0.4302 0.500 0.200 0.300
#> GSM123762     1  0.0892     0.5445 0.980 0.000 0.020
#> GSM123764     2  0.9212     0.1967 0.180 0.516 0.304
#> GSM123767     1  0.7824     0.5296 0.664 0.124 0.212
#> GSM123770     1  0.7824     0.5296 0.664 0.124 0.212
#> GSM123773     1  0.7824     0.5296 0.664 0.124 0.212
#> GSM123777     2  0.6404     0.4490 0.012 0.644 0.344
#> GSM123779     2  0.7078     0.5456 0.088 0.712 0.200
#> GSM123782     2  0.9172     0.2167 0.180 0.524 0.296
#> GSM123786     2  0.8836     0.1828 0.388 0.492 0.120
#> GSM123789     2  0.7078     0.5456 0.088 0.712 0.200
#> GSM123793     3  0.2050     0.8085 0.028 0.020 0.952
#> GSM123797     3  0.3771     0.8070 0.012 0.112 0.876
#> GSM123729     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123733     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123737     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123741     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123747     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123753     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123759     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123766     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123772     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123775     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123781     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123785     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123788     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123792     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123796     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123731     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123735     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123739     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123743     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123749     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123755     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123768     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123776     2  0.4634     0.6366 0.164 0.824 0.012
#> GSM123783     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123790     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123794     2  0.0000     0.7531 0.000 1.000 0.000
#> GSM123798     2  0.0000     0.7531 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     2   0.788     0.0880 0.304 0.384 0.000 0.312
#> GSM123736     2   0.825     0.0794 0.284 0.376 0.012 0.328
#> GSM123740     2   0.825     0.0794 0.284 0.376 0.012 0.328
#> GSM123744     1   0.744     0.2442 0.512 0.244 0.000 0.244
#> GSM123746     1   0.759     0.2530 0.504 0.212 0.004 0.280
#> GSM123750     1   0.744     0.2442 0.512 0.244 0.000 0.244
#> GSM123752     1   0.765     0.2157 0.460 0.240 0.000 0.300
#> GSM123756     1   0.000     0.4507 1.000 0.000 0.000 0.000
#> GSM123758     1   0.790     0.0279 0.368 0.336 0.000 0.296
#> GSM123761     1   0.253     0.4094 0.888 0.000 0.000 0.112
#> GSM123763     1   0.288     0.4115 0.892 0.000 0.024 0.084
#> GSM123765     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123769     1   0.000     0.4507 1.000 0.000 0.000 0.000
#> GSM123771     1   0.000     0.4507 1.000 0.000 0.000 0.000
#> GSM123774     1   0.000     0.4507 1.000 0.000 0.000 0.000
#> GSM123778     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123780     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123784     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123787     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123791     2   0.785     0.1226 0.292 0.400 0.000 0.308
#> GSM123795     2   0.825     0.0794 0.284 0.376 0.012 0.328
#> GSM123799     2   0.825     0.0794 0.284 0.376 0.012 0.328
#> GSM123730     2   0.654     0.0864 0.000 0.528 0.080 0.392
#> GSM123734     3   0.292     0.0000 0.028 0.000 0.892 0.080
#> GSM123738     4   0.531    -0.1489 0.000 0.036 0.280 0.684
#> GSM123742     4   0.800    -0.0454 0.336 0.116 0.048 0.500
#> GSM123745     1   0.759     0.2025 0.528 0.080 0.048 0.344
#> GSM123748     1   0.790     0.1132 0.460 0.096 0.048 0.396
#> GSM123751     1   0.762     0.1923 0.516 0.080 0.048 0.356
#> GSM123754     1   0.738     0.2618 0.568 0.080 0.044 0.308
#> GSM123757     1   0.763     0.2480 0.496 0.212 0.004 0.288
#> GSM123760     4   0.798    -0.0766 0.356 0.116 0.044 0.484
#> GSM123762     1   0.301     0.4042 0.888 0.000 0.032 0.080
#> GSM123764     4   0.778     0.1825 0.096 0.424 0.040 0.440
#> GSM123767     1   0.738     0.2618 0.568 0.080 0.044 0.308
#> GSM123770     1   0.738     0.2618 0.568 0.080 0.044 0.308
#> GSM123773     1   0.738     0.2618 0.568 0.080 0.044 0.308
#> GSM123777     2   0.654     0.0864 0.000 0.528 0.080 0.392
#> GSM123779     2   0.657     0.2723 0.052 0.632 0.032 0.284
#> GSM123782     4   0.778     0.1576 0.096 0.432 0.040 0.432
#> GSM123786     2   0.783     0.1452 0.280 0.408 0.000 0.312
#> GSM123789     2   0.657     0.2723 0.052 0.632 0.032 0.284
#> GSM123793     4   0.490    -0.4506 0.000 0.000 0.416 0.584
#> GSM123797     4   0.531    -0.1489 0.000 0.036 0.280 0.684
#> GSM123729     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123733     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123737     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123741     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123747     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123753     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123759     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123766     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123772     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123775     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123781     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123785     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123788     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123792     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123796     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123731     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123735     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123739     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123743     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123749     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123755     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123768     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123776     2   0.359     0.5675 0.168 0.824 0.000 0.008
#> GSM123783     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123790     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123794     2   0.000     0.7060 0.000 1.000 0.000 0.000
#> GSM123798     2   0.000     0.7060 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3   0.415     0.8686 0.020 0.240 0.736 0.004 0.000
#> GSM123736     3   0.394     0.8633 0.000 0.232 0.748 0.020 0.000
#> GSM123740     3   0.394     0.8633 0.000 0.232 0.748 0.020 0.000
#> GSM123744     3   0.585     0.7173 0.220 0.156 0.620 0.004 0.000
#> GSM123746     3   0.668     0.6560 0.220 0.140 0.588 0.052 0.000
#> GSM123750     3   0.585     0.7173 0.220 0.156 0.620 0.004 0.000
#> GSM123752     3   0.577     0.7388 0.160 0.144 0.672 0.024 0.000
#> GSM123756     1   0.297     0.5318 0.816 0.000 0.184 0.000 0.000
#> GSM123758     3   0.461     0.8374 0.072 0.200 0.728 0.000 0.000
#> GSM123761     1   0.465     0.2934 0.600 0.000 0.384 0.012 0.004
#> GSM123763     1   0.270     0.4930 0.884 0.000 0.088 0.024 0.004
#> GSM123765     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123769     1   0.297     0.5318 0.816 0.000 0.184 0.000 0.000
#> GSM123771     1   0.297     0.5318 0.816 0.000 0.184 0.000 0.000
#> GSM123774     1   0.297     0.5318 0.816 0.000 0.184 0.000 0.000
#> GSM123778     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123780     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123784     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123787     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123791     3   0.353     0.8701 0.000 0.256 0.744 0.000 0.000
#> GSM123795     3   0.394     0.8633 0.000 0.232 0.748 0.020 0.000
#> GSM123799     3   0.394     0.8633 0.000 0.232 0.748 0.020 0.000
#> GSM123730     2   0.779    -0.0371 0.008 0.428 0.252 0.260 0.052
#> GSM123734     5   0.154     0.0000 0.000 0.000 0.000 0.068 0.932
#> GSM123738     4   0.531    -0.1317 0.004 0.000 0.284 0.640 0.072
#> GSM123742     4   0.728     0.0369 0.264 0.036 0.240 0.460 0.000
#> GSM123745     1   0.564     0.3387 0.488 0.024 0.032 0.456 0.000
#> GSM123748     4   0.674    -0.2913 0.400 0.032 0.116 0.452 0.000
#> GSM123751     1   0.583     0.3188 0.476 0.024 0.044 0.456 0.000
#> GSM123754     1   0.593     0.3950 0.500 0.024 0.052 0.424 0.000
#> GSM123757     3   0.672     0.6474 0.228 0.140 0.580 0.052 0.000
#> GSM123760     4   0.733     0.0187 0.272 0.036 0.248 0.444 0.000
#> GSM123762     1   0.240     0.4818 0.904 0.000 0.068 0.024 0.004
#> GSM123764     4   0.771     0.1754 0.052 0.292 0.296 0.360 0.000
#> GSM123767     1   0.593     0.3950 0.500 0.024 0.052 0.424 0.000
#> GSM123770     1   0.593     0.3950 0.500 0.024 0.052 0.424 0.000
#> GSM123773     1   0.593     0.3950 0.500 0.024 0.052 0.424 0.000
#> GSM123777     2   0.779    -0.0371 0.008 0.428 0.252 0.260 0.052
#> GSM123779     2   0.718     0.0692 0.044 0.500 0.204 0.252 0.000
#> GSM123782     4   0.773     0.1465 0.052 0.308 0.296 0.344 0.000
#> GSM123786     3   0.374     0.8674 0.000 0.264 0.732 0.004 0.000
#> GSM123789     2   0.718     0.0692 0.044 0.500 0.204 0.252 0.000
#> GSM123793     4   0.622    -0.3262 0.004 0.000 0.232 0.568 0.196
#> GSM123797     4   0.531    -0.1317 0.004 0.000 0.284 0.640 0.072
#> GSM123729     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123781     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123776     2   0.370     0.7176 0.128 0.824 0.036 0.012 0.000
#> GSM123783     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123790     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2   0.000     0.9117 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3   0.164     0.8816 0.000 0.076 0.920 0.000 0.004 0.000
#> GSM123736     3   0.259     0.8800 0.000 0.084 0.872 0.044 0.000 0.000
#> GSM123740     3   0.259     0.8800 0.000 0.084 0.872 0.044 0.000 0.000
#> GSM123744     3   0.437     0.7113 0.024 0.056 0.740 0.000 0.000 0.180
#> GSM123746     3   0.525     0.6612 0.104 0.056 0.688 0.000 0.000 0.152
#> GSM123750     3   0.440     0.7061 0.024 0.056 0.736 0.000 0.000 0.184
#> GSM123752     3   0.429     0.7635 0.064 0.056 0.776 0.000 0.000 0.104
#> GSM123756     6   0.541     0.7921 0.260 0.000 0.168 0.000 0.000 0.572
#> GSM123758     3   0.263     0.8517 0.016 0.064 0.884 0.000 0.000 0.036
#> GSM123761     6   0.536     0.4754 0.080 0.000 0.380 0.000 0.012 0.528
#> GSM123763     6   0.384     0.5773 0.148 0.000 0.056 0.000 0.012 0.784
#> GSM123765     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123769     6   0.541     0.7921 0.260 0.000 0.168 0.000 0.000 0.572
#> GSM123771     6   0.541     0.7921 0.260 0.000 0.168 0.000 0.000 0.572
#> GSM123774     6   0.541     0.7921 0.260 0.000 0.168 0.000 0.000 0.572
#> GSM123778     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123780     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123784     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123787     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123791     3   0.171     0.8871 0.000 0.092 0.908 0.000 0.000 0.000
#> GSM123795     3   0.259     0.8800 0.000 0.084 0.872 0.044 0.000 0.000
#> GSM123799     3   0.259     0.8800 0.000 0.084 0.872 0.044 0.000 0.000
#> GSM123730     2   0.770    -0.1768 0.052 0.364 0.148 0.084 0.352 0.000
#> GSM123734     5   0.613     0.0000 0.028 0.000 0.064 0.168 0.636 0.104
#> GSM123738     4   0.395     0.7954 0.008 0.000 0.008 0.672 0.312 0.000
#> GSM123742     1   0.440     0.5881 0.748 0.004 0.180 0.004 0.024 0.040
#> GSM123745     1   0.081     0.6991 0.976 0.004 0.008 0.000 0.004 0.008
#> GSM123748     1   0.226     0.6831 0.892 0.004 0.092 0.000 0.004 0.008
#> GSM123751     1   0.110     0.7021 0.964 0.004 0.020 0.000 0.004 0.008
#> GSM123754     1   0.158     0.6908 0.936 0.004 0.012 0.000 0.000 0.048
#> GSM123757     3   0.533     0.6516 0.112 0.056 0.680 0.000 0.000 0.152
#> GSM123760     1   0.483     0.5805 0.716 0.004 0.180 0.004 0.020 0.076
#> GSM123762     6   0.370     0.5547 0.160 0.000 0.040 0.000 0.012 0.788
#> GSM123764     1   0.727     0.2823 0.424 0.252 0.256 0.004 0.028 0.036
#> GSM123767     1   0.158     0.6908 0.936 0.004 0.012 0.000 0.000 0.048
#> GSM123770     1   0.158     0.6908 0.936 0.004 0.012 0.000 0.000 0.048
#> GSM123773     1   0.158     0.6908 0.936 0.004 0.012 0.000 0.000 0.048
#> GSM123777     2   0.770    -0.1768 0.052 0.364 0.148 0.084 0.352 0.000
#> GSM123779     2   0.702    -0.0605 0.288 0.424 0.216 0.000 0.068 0.004
#> GSM123782     1   0.725     0.2686 0.412 0.264 0.260 0.004 0.024 0.036
#> GSM123786     3   0.196     0.8863 0.000 0.100 0.896 0.000 0.004 0.000
#> GSM123789     2   0.704    -0.0707 0.288 0.420 0.220 0.000 0.068 0.004
#> GSM123793     4   0.026     0.4844 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM123797     4   0.395     0.7954 0.008 0.000 0.008 0.672 0.312 0.000
#> GSM123729     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123733     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123737     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123741     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123772     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123775     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123781     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123788     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123792     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123731     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123739     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123743     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123776     2   0.334     0.7335 0.048 0.824 0.008 0.000 0.000 0.120
#> GSM123783     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123790     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123794     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123798     2   0.000     0.9087 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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) infection(p) agent(p) k
#> SD:hclust 58         6.76e-07     6.76e-07  0.01310 2
#> SD:hclust 44         1.84e-09     1.84e-09  0.01402 3
#> SD:hclust 27               NA           NA       NA 4
#> SD:hclust 49         3.46e-10     3.46e-10  0.00154 5
#> SD:hclust 62         4.60e-19     4.60e-19  0.00069 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 71 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 1.000           0.984       0.994         0.4756 0.522   0.522
#> 3 3 0.796           0.833       0.897         0.3934 0.791   0.605
#> 4 4 0.755           0.864       0.882         0.1000 0.920   0.762
#> 5 5 0.746           0.709       0.823         0.0555 0.982   0.933
#> 6 6 0.766           0.675       0.791         0.0387 0.986   0.945

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
#> GSM123732     1    0.00      1.000 1.000 0.000
#> GSM123736     1    0.00      1.000 1.000 0.000
#> GSM123740     1    0.00      1.000 1.000 0.000
#> GSM123744     1    0.00      1.000 1.000 0.000
#> GSM123746     1    0.00      1.000 1.000 0.000
#> GSM123750     1    0.00      1.000 1.000 0.000
#> GSM123752     1    0.00      1.000 1.000 0.000
#> GSM123756     1    0.00      1.000 1.000 0.000
#> GSM123758     1    0.00      1.000 1.000 0.000
#> GSM123761     1    0.00      1.000 1.000 0.000
#> GSM123763     1    0.00      1.000 1.000 0.000
#> GSM123765     1    0.00      1.000 1.000 0.000
#> GSM123769     1    0.00      1.000 1.000 0.000
#> GSM123771     1    0.00      1.000 1.000 0.000
#> GSM123774     1    0.00      1.000 1.000 0.000
#> GSM123778     1    0.00      1.000 1.000 0.000
#> GSM123780     1    0.00      1.000 1.000 0.000
#> GSM123784     1    0.00      1.000 1.000 0.000
#> GSM123787     1    0.00      1.000 1.000 0.000
#> GSM123791     1    0.00      1.000 1.000 0.000
#> GSM123795     1    0.00      1.000 1.000 0.000
#> GSM123799     1    0.00      1.000 1.000 0.000
#> GSM123730     1    0.00      1.000 1.000 0.000
#> GSM123734     1    0.00      1.000 1.000 0.000
#> GSM123738     1    0.00      1.000 1.000 0.000
#> GSM123742     1    0.00      1.000 1.000 0.000
#> GSM123745     1    0.00      1.000 1.000 0.000
#> GSM123748     1    0.00      1.000 1.000 0.000
#> GSM123751     1    0.00      1.000 1.000 0.000
#> GSM123754     1    0.00      1.000 1.000 0.000
#> GSM123757     1    0.00      1.000 1.000 0.000
#> GSM123760     1    0.00      1.000 1.000 0.000
#> GSM123762     1    0.00      1.000 1.000 0.000
#> GSM123764     1    0.00      1.000 1.000 0.000
#> GSM123767     1    0.00      1.000 1.000 0.000
#> GSM123770     1    0.00      1.000 1.000 0.000
#> GSM123773     1    0.00      1.000 1.000 0.000
#> GSM123777     1    0.00      1.000 1.000 0.000
#> GSM123779     1    0.00      1.000 1.000 0.000
#> GSM123782     1    0.00      1.000 1.000 0.000
#> GSM123786     1    0.00      1.000 1.000 0.000
#> GSM123789     1    0.00      1.000 1.000 0.000
#> GSM123793     1    0.00      1.000 1.000 0.000
#> GSM123797     1    0.00      1.000 1.000 0.000
#> GSM123729     2    0.00      0.984 0.000 1.000
#> GSM123733     2    0.00      0.984 0.000 1.000
#> GSM123737     2    0.00      0.984 0.000 1.000
#> GSM123741     2    0.00      0.984 0.000 1.000
#> GSM123747     2    0.00      0.984 0.000 1.000
#> GSM123753     2    0.00      0.984 0.000 1.000
#> GSM123759     2    0.00      0.984 0.000 1.000
#> GSM123766     2    0.00      0.984 0.000 1.000
#> GSM123772     2    0.00      0.984 0.000 1.000
#> GSM123775     2    0.00      0.984 0.000 1.000
#> GSM123781     2    0.00      0.984 0.000 1.000
#> GSM123785     2    0.00      0.984 0.000 1.000
#> GSM123788     2    0.00      0.984 0.000 1.000
#> GSM123792     2    0.00      0.984 0.000 1.000
#> GSM123796     2    0.00      0.984 0.000 1.000
#> GSM123731     2    0.00      0.984 0.000 1.000
#> GSM123735     2    0.00      0.984 0.000 1.000
#> GSM123739     2    0.00      0.984 0.000 1.000
#> GSM123743     2    0.00      0.984 0.000 1.000
#> GSM123749     2    0.00      0.984 0.000 1.000
#> GSM123755     2    0.00      0.984 0.000 1.000
#> GSM123768     2    0.00      0.984 0.000 1.000
#> GSM123776     2    0.98      0.288 0.416 0.584
#> GSM123783     2    0.00      0.984 0.000 1.000
#> GSM123790     2    0.00      0.984 0.000 1.000
#> GSM123794     2    0.00      0.984 0.000 1.000
#> GSM123798     2    0.00      0.984 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
#> GSM123732     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123736     3  0.0237      0.820 0.004 0.000 0.996
#> GSM123740     3  0.0237      0.820 0.004 0.000 0.996
#> GSM123744     3  0.5706      0.306 0.320 0.000 0.680
#> GSM123746     1  0.5529      0.769 0.704 0.000 0.296
#> GSM123750     3  0.5810      0.254 0.336 0.000 0.664
#> GSM123752     3  0.5591      0.352 0.304 0.000 0.696
#> GSM123756     1  0.5529      0.769 0.704 0.000 0.296
#> GSM123758     3  0.0592      0.820 0.012 0.000 0.988
#> GSM123761     1  0.5529      0.769 0.704 0.000 0.296
#> GSM123763     1  0.5497      0.772 0.708 0.000 0.292
#> GSM123765     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123769     1  0.5529      0.769 0.704 0.000 0.296
#> GSM123771     1  0.5529      0.769 0.704 0.000 0.296
#> GSM123774     1  0.5497      0.771 0.708 0.000 0.292
#> GSM123778     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123780     3  0.0892      0.821 0.020 0.000 0.980
#> GSM123784     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123787     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123791     3  0.0592      0.820 0.012 0.000 0.988
#> GSM123795     3  0.0237      0.820 0.004 0.000 0.996
#> GSM123799     3  0.0237      0.820 0.004 0.000 0.996
#> GSM123730     3  0.5138      0.734 0.252 0.000 0.748
#> GSM123734     1  0.1964      0.784 0.944 0.000 0.056
#> GSM123738     3  0.5138      0.734 0.252 0.000 0.748
#> GSM123742     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123745     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123748     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123751     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123754     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123757     1  0.5291      0.782 0.732 0.000 0.268
#> GSM123760     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123762     1  0.4504      0.802 0.804 0.000 0.196
#> GSM123764     3  0.4887      0.743 0.228 0.000 0.772
#> GSM123767     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123770     1  0.2448      0.819 0.924 0.000 0.076
#> GSM123773     1  0.2537      0.819 0.920 0.000 0.080
#> GSM123777     3  0.5138      0.734 0.252 0.000 0.748
#> GSM123779     3  0.5465      0.686 0.288 0.000 0.712
#> GSM123782     3  0.4887      0.743 0.228 0.000 0.772
#> GSM123786     3  0.0424      0.822 0.008 0.000 0.992
#> GSM123789     3  0.4887      0.743 0.228 0.000 0.772
#> GSM123793     3  0.5138      0.734 0.252 0.000 0.748
#> GSM123797     3  0.5138      0.734 0.252 0.000 0.748
#> GSM123729     2  0.1529      0.979 0.040 0.960 0.000
#> GSM123733     2  0.0892      0.989 0.020 0.980 0.000
#> GSM123737     2  0.1529      0.979 0.040 0.960 0.000
#> GSM123741     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123747     2  0.0237      0.990 0.004 0.996 0.000
#> GSM123753     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123775     2  0.1411      0.981 0.036 0.964 0.000
#> GSM123781     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123785     2  0.0892      0.989 0.020 0.980 0.000
#> GSM123788     2  0.0892      0.989 0.020 0.980 0.000
#> GSM123792     2  0.0747      0.989 0.016 0.984 0.000
#> GSM123796     2  0.0747      0.989 0.016 0.984 0.000
#> GSM123731     2  0.0237      0.990 0.004 0.996 0.000
#> GSM123735     2  0.1163      0.986 0.028 0.972 0.000
#> GSM123739     2  0.1529      0.979 0.040 0.960 0.000
#> GSM123743     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.991 0.000 1.000 0.000
#> GSM123776     1  0.7446      0.147 0.532 0.432 0.036
#> GSM123783     2  0.0424      0.990 0.008 0.992 0.000
#> GSM123790     2  0.1163      0.986 0.028 0.972 0.000
#> GSM123794     2  0.0747      0.989 0.016 0.984 0.000
#> GSM123798     2  0.0000      0.991 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0376      0.942 0.004 0.000 0.992 0.004
#> GSM123736     3  0.1356      0.931 0.008 0.000 0.960 0.032
#> GSM123740     3  0.1356      0.931 0.008 0.000 0.960 0.032
#> GSM123744     3  0.3858      0.819 0.100 0.000 0.844 0.056
#> GSM123746     1  0.4037      0.803 0.832 0.000 0.112 0.056
#> GSM123750     3  0.4037      0.804 0.112 0.000 0.832 0.056
#> GSM123752     3  0.3464      0.834 0.108 0.000 0.860 0.032
#> GSM123756     1  0.2530      0.817 0.896 0.000 0.100 0.004
#> GSM123758     3  0.0804      0.940 0.012 0.000 0.980 0.008
#> GSM123761     1  0.4055      0.801 0.832 0.000 0.108 0.060
#> GSM123763     1  0.3894      0.802 0.844 0.000 0.088 0.068
#> GSM123765     3  0.0524      0.941 0.004 0.000 0.988 0.008
#> GSM123769     1  0.2530      0.817 0.896 0.000 0.100 0.004
#> GSM123771     1  0.2530      0.817 0.896 0.000 0.100 0.004
#> GSM123774     1  0.2466      0.818 0.900 0.000 0.096 0.004
#> GSM123778     3  0.0376      0.942 0.004 0.000 0.992 0.004
#> GSM123780     3  0.0657      0.938 0.004 0.000 0.984 0.012
#> GSM123784     3  0.0524      0.941 0.004 0.000 0.988 0.008
#> GSM123787     3  0.0524      0.941 0.004 0.000 0.988 0.008
#> GSM123791     3  0.0524      0.941 0.004 0.000 0.988 0.008
#> GSM123795     3  0.1356      0.931 0.008 0.000 0.960 0.032
#> GSM123799     3  0.1256      0.933 0.008 0.000 0.964 0.028
#> GSM123730     4  0.4053      0.870 0.004 0.000 0.228 0.768
#> GSM123734     4  0.3881      0.632 0.172 0.000 0.016 0.812
#> GSM123738     4  0.3801      0.865 0.000 0.000 0.220 0.780
#> GSM123742     1  0.5776      0.342 0.504 0.000 0.028 0.468
#> GSM123745     1  0.4399      0.767 0.768 0.000 0.020 0.212
#> GSM123748     1  0.4675      0.760 0.736 0.000 0.020 0.244
#> GSM123751     1  0.4610      0.751 0.744 0.000 0.020 0.236
#> GSM123754     1  0.4323      0.773 0.776 0.000 0.020 0.204
#> GSM123757     1  0.2949      0.822 0.888 0.000 0.088 0.024
#> GSM123760     4  0.5078      0.403 0.272 0.000 0.028 0.700
#> GSM123762     1  0.3758      0.808 0.848 0.000 0.048 0.104
#> GSM123764     4  0.5047      0.806 0.016 0.000 0.316 0.668
#> GSM123767     1  0.4535      0.742 0.744 0.000 0.016 0.240
#> GSM123770     1  0.3037      0.810 0.880 0.000 0.020 0.100
#> GSM123773     1  0.4323      0.773 0.776 0.000 0.020 0.204
#> GSM123777     4  0.4252      0.865 0.004 0.000 0.252 0.744
#> GSM123779     4  0.4609      0.867 0.024 0.000 0.224 0.752
#> GSM123782     4  0.5110      0.792 0.016 0.000 0.328 0.656
#> GSM123786     3  0.0524      0.941 0.004 0.000 0.988 0.008
#> GSM123789     4  0.4776      0.852 0.016 0.000 0.272 0.712
#> GSM123793     4  0.3668      0.863 0.004 0.000 0.188 0.808
#> GSM123797     4  0.3688      0.868 0.000 0.000 0.208 0.792
#> GSM123729     2  0.4203      0.882 0.068 0.824 0.000 0.108
#> GSM123733     2  0.1913      0.952 0.020 0.940 0.000 0.040
#> GSM123737     2  0.4203      0.882 0.068 0.824 0.000 0.108
#> GSM123741     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0592      0.958 0.000 0.984 0.000 0.016
#> GSM123753     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123759     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123766     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123772     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> GSM123775     2  0.4274      0.882 0.072 0.820 0.000 0.108
#> GSM123781     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123785     2  0.1913      0.952 0.020 0.940 0.000 0.040
#> GSM123788     2  0.1913      0.952 0.020 0.940 0.000 0.040
#> GSM123792     2  0.1305      0.956 0.004 0.960 0.000 0.036
#> GSM123796     2  0.1452      0.955 0.008 0.956 0.000 0.036
#> GSM123731     2  0.0524      0.960 0.008 0.988 0.000 0.004
#> GSM123735     2  0.2521      0.943 0.024 0.912 0.000 0.064
#> GSM123739     2  0.4203      0.882 0.068 0.824 0.000 0.108
#> GSM123743     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0000      0.960 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123768     2  0.0188      0.960 0.004 0.996 0.000 0.000
#> GSM123776     1  0.6303      0.445 0.660 0.228 0.004 0.108
#> GSM123783     2  0.1406      0.952 0.016 0.960 0.000 0.024
#> GSM123790     2  0.2722      0.939 0.032 0.904 0.000 0.064
#> GSM123794     2  0.1677      0.954 0.012 0.948 0.000 0.040
#> GSM123798     2  0.0188      0.960 0.004 0.996 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0579     0.9395 0.000 0.000 0.984 0.008 0.008
#> GSM123736     3  0.1525     0.9293 0.004 0.000 0.948 0.036 0.012
#> GSM123740     3  0.1525     0.9293 0.004 0.000 0.948 0.036 0.012
#> GSM123744     3  0.3617     0.8298 0.060 0.000 0.836 0.008 0.096
#> GSM123746     1  0.4722     0.2142 0.716 0.000 0.040 0.012 0.232
#> GSM123750     3  0.4014     0.7974 0.060 0.000 0.804 0.008 0.128
#> GSM123752     3  0.2681     0.8833 0.052 0.000 0.892 0.004 0.052
#> GSM123756     1  0.3099     0.5082 0.848 0.000 0.028 0.000 0.124
#> GSM123758     3  0.1205     0.9306 0.004 0.000 0.956 0.000 0.040
#> GSM123761     1  0.5614    -0.4861 0.476 0.000 0.040 0.016 0.468
#> GSM123763     5  0.5781     0.3511 0.452 0.000 0.032 0.032 0.484
#> GSM123765     3  0.0451     0.9393 0.000 0.000 0.988 0.008 0.004
#> GSM123769     1  0.3099     0.5082 0.848 0.000 0.028 0.000 0.124
#> GSM123771     1  0.3099     0.5082 0.848 0.000 0.028 0.000 0.124
#> GSM123774     1  0.3099     0.5082 0.848 0.000 0.028 0.000 0.124
#> GSM123778     3  0.0579     0.9395 0.000 0.000 0.984 0.008 0.008
#> GSM123780     3  0.0451     0.9393 0.000 0.000 0.988 0.008 0.004
#> GSM123784     3  0.0451     0.9393 0.000 0.000 0.988 0.008 0.004
#> GSM123787     3  0.0579     0.9395 0.000 0.000 0.984 0.008 0.008
#> GSM123791     3  0.0290     0.9393 0.000 0.000 0.992 0.000 0.008
#> GSM123795     3  0.1525     0.9293 0.004 0.000 0.948 0.036 0.012
#> GSM123799     3  0.1525     0.9293 0.004 0.000 0.948 0.036 0.012
#> GSM123730     4  0.3981     0.7794 0.004 0.000 0.136 0.800 0.060
#> GSM123734     4  0.3547     0.6224 0.100 0.000 0.004 0.836 0.060
#> GSM123738     4  0.2304     0.7596 0.000 0.000 0.100 0.892 0.008
#> GSM123742     1  0.6999    -0.4036 0.408 0.000 0.016 0.208 0.368
#> GSM123745     1  0.4030     0.5211 0.808 0.000 0.012 0.120 0.060
#> GSM123748     1  0.5258     0.3442 0.704 0.000 0.012 0.108 0.176
#> GSM123751     1  0.4322     0.4987 0.788 0.000 0.012 0.124 0.076
#> GSM123754     1  0.2805     0.5669 0.872 0.000 0.012 0.108 0.008
#> GSM123757     1  0.2769     0.5492 0.892 0.000 0.024 0.020 0.064
#> GSM123760     5  0.7093     0.0482 0.240 0.000 0.016 0.340 0.404
#> GSM123762     5  0.5731     0.3592 0.456 0.000 0.016 0.048 0.480
#> GSM123764     4  0.7485     0.5766 0.056 0.000 0.216 0.456 0.272
#> GSM123767     1  0.3216     0.5519 0.852 0.000 0.012 0.116 0.020
#> GSM123770     1  0.1978     0.5678 0.932 0.000 0.012 0.032 0.024
#> GSM123773     1  0.2805     0.5669 0.872 0.000 0.012 0.108 0.008
#> GSM123777     4  0.4214     0.7753 0.004 0.000 0.152 0.780 0.064
#> GSM123779     4  0.6156     0.7313 0.052 0.000 0.132 0.656 0.160
#> GSM123782     4  0.7625     0.5541 0.064 0.000 0.228 0.440 0.268
#> GSM123786     3  0.0579     0.9395 0.000 0.000 0.984 0.008 0.008
#> GSM123789     4  0.6588     0.7069 0.036 0.000 0.184 0.588 0.192
#> GSM123793     4  0.2460     0.7544 0.004 0.000 0.072 0.900 0.024
#> GSM123797     4  0.2249     0.7609 0.000 0.000 0.096 0.896 0.008
#> GSM123729     2  0.5103     0.7687 0.020 0.692 0.000 0.048 0.240
#> GSM123733     2  0.3582     0.8490 0.000 0.768 0.000 0.008 0.224
#> GSM123737     2  0.5076     0.7720 0.020 0.696 0.000 0.048 0.236
#> GSM123741     2  0.0324     0.8881 0.000 0.992 0.000 0.004 0.004
#> GSM123747     2  0.2753     0.8683 0.000 0.856 0.000 0.008 0.136
#> GSM123753     2  0.0324     0.8870 0.004 0.992 0.000 0.000 0.004
#> GSM123759     2  0.0451     0.8869 0.004 0.988 0.000 0.000 0.008
#> GSM123766     2  0.0324     0.8870 0.004 0.992 0.000 0.000 0.004
#> GSM123772     2  0.0324     0.8881 0.000 0.992 0.000 0.004 0.004
#> GSM123775     2  0.5089     0.7658 0.016 0.684 0.000 0.048 0.252
#> GSM123781     2  0.0324     0.8870 0.004 0.992 0.000 0.000 0.004
#> GSM123785     2  0.3582     0.8490 0.000 0.768 0.000 0.008 0.224
#> GSM123788     2  0.3582     0.8490 0.000 0.768 0.000 0.008 0.224
#> GSM123792     2  0.3388     0.8571 0.000 0.792 0.000 0.008 0.200
#> GSM123796     2  0.3388     0.8571 0.000 0.792 0.000 0.008 0.200
#> GSM123731     2  0.0771     0.8893 0.004 0.976 0.000 0.000 0.020
#> GSM123735     2  0.3988     0.8372 0.000 0.732 0.000 0.016 0.252
#> GSM123739     2  0.5076     0.7720 0.020 0.696 0.000 0.048 0.236
#> GSM123743     2  0.0451     0.8885 0.000 0.988 0.000 0.004 0.008
#> GSM123749     2  0.0324     0.8881 0.000 0.992 0.000 0.004 0.004
#> GSM123755     2  0.0324     0.8870 0.004 0.992 0.000 0.000 0.004
#> GSM123768     2  0.0324     0.8870 0.004 0.992 0.000 0.000 0.004
#> GSM123776     1  0.6903     0.1121 0.552 0.164 0.000 0.048 0.236
#> GSM123783     2  0.1569     0.8767 0.004 0.944 0.000 0.008 0.044
#> GSM123790     2  0.4065     0.8335 0.000 0.720 0.000 0.016 0.264
#> GSM123794     2  0.3563     0.8557 0.000 0.780 0.000 0.012 0.208
#> GSM123798     2  0.0324     0.8870 0.004 0.992 0.000 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
#> GSM123732     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123736     3  0.2737     0.8917 0.004 0.000 0.876 0.056 NA 0.004
#> GSM123740     3  0.2737     0.8917 0.004 0.000 0.876 0.056 NA 0.004
#> GSM123744     3  0.3718     0.8001 0.004 0.000 0.780 0.000 NA 0.164
#> GSM123746     1  0.5675     0.0101 0.584 0.000 0.052 0.000 NA 0.292
#> GSM123750     3  0.4348     0.7178 0.012 0.000 0.716 0.000 NA 0.220
#> GSM123752     3  0.2872     0.8736 0.008 0.000 0.864 0.000 NA 0.076
#> GSM123756     1  0.4227     0.4822 0.692 0.000 0.000 0.000 NA 0.256
#> GSM123758     3  0.1511     0.9096 0.004 0.000 0.940 0.000 NA 0.012
#> GSM123761     6  0.3881     0.4916 0.252 0.000 0.004 0.000 NA 0.720
#> GSM123763     6  0.4230     0.5729 0.224 0.000 0.000 0.004 NA 0.716
#> GSM123765     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123769     1  0.4227     0.4822 0.692 0.000 0.000 0.000 NA 0.256
#> GSM123771     1  0.4227     0.4822 0.692 0.000 0.000 0.000 NA 0.256
#> GSM123774     1  0.4227     0.4822 0.692 0.000 0.000 0.000 NA 0.256
#> GSM123778     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123780     3  0.0520     0.9149 0.000 0.000 0.984 0.008 NA 0.000
#> GSM123784     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123787     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123791     3  0.0000     0.9187 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123795     3  0.2737     0.8917 0.004 0.000 0.876 0.056 NA 0.004
#> GSM123799     3  0.2737     0.8917 0.004 0.000 0.876 0.056 NA 0.004
#> GSM123730     4  0.3807     0.6429 0.016 0.000 0.040 0.824 NA 0.036
#> GSM123734     4  0.5982     0.4630 0.144 0.000 0.000 0.624 NA 0.104
#> GSM123738     4  0.0862     0.6156 0.000 0.000 0.016 0.972 NA 0.008
#> GSM123742     6  0.6606     0.3422 0.372 0.000 0.000 0.084 NA 0.432
#> GSM123745     1  0.3720     0.4836 0.816 0.000 0.000 0.036 NA 0.092
#> GSM123748     1  0.5079     0.1692 0.652 0.000 0.000 0.024 NA 0.248
#> GSM123751     1  0.4379     0.4210 0.764 0.000 0.000 0.040 NA 0.120
#> GSM123754     1  0.1152     0.5855 0.952 0.000 0.000 0.044 NA 0.004
#> GSM123757     1  0.2721     0.5301 0.868 0.000 0.000 0.004 NA 0.088
#> GSM123760     6  0.7004     0.2535 0.228 0.000 0.000 0.160 NA 0.476
#> GSM123762     6  0.4255     0.5743 0.228 0.000 0.000 0.004 NA 0.712
#> GSM123764     4  0.8601     0.3863 0.084 0.000 0.180 0.300 NA 0.232
#> GSM123767     1  0.2146     0.5629 0.908 0.000 0.000 0.060 NA 0.024
#> GSM123770     1  0.2173     0.5740 0.904 0.000 0.000 0.004 NA 0.064
#> GSM123773     1  0.1152     0.5855 0.952 0.000 0.000 0.044 NA 0.004
#> GSM123777     4  0.4301     0.6401 0.012 0.000 0.080 0.788 NA 0.036
#> GSM123779     4  0.7951     0.5080 0.136 0.000 0.080 0.448 NA 0.132
#> GSM123782     4  0.8636     0.3841 0.088 0.000 0.184 0.296 NA 0.224
#> GSM123786     3  0.0291     0.9188 0.000 0.000 0.992 0.004 NA 0.000
#> GSM123789     4  0.8149     0.5076 0.068 0.000 0.164 0.408 NA 0.160
#> GSM123793     4  0.2164     0.5991 0.000 0.000 0.008 0.908 NA 0.028
#> GSM123797     4  0.0520     0.6167 0.000 0.000 0.008 0.984 NA 0.008
#> GSM123729     2  0.5317     0.6392 0.000 0.568 0.000 0.004 NA 0.112
#> GSM123733     2  0.3634     0.7551 0.000 0.644 0.000 0.000 NA 0.000
#> GSM123737     2  0.5317     0.6392 0.000 0.568 0.000 0.004 NA 0.112
#> GSM123741     2  0.0363     0.8256 0.000 0.988 0.000 0.000 NA 0.000
#> GSM123747     2  0.2883     0.7886 0.000 0.788 0.000 0.000 NA 0.000
#> GSM123753     2  0.0000     0.8243 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123759     2  0.0146     0.8242 0.000 0.996 0.000 0.000 NA 0.000
#> GSM123766     2  0.0146     0.8248 0.000 0.996 0.000 0.000 NA 0.000
#> GSM123772     2  0.0363     0.8256 0.000 0.988 0.000 0.000 NA 0.000
#> GSM123775     2  0.5136     0.6554 0.000 0.584 0.000 0.004 NA 0.092
#> GSM123781     2  0.0000     0.8243 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123785     2  0.3634     0.7551 0.000 0.644 0.000 0.000 NA 0.000
#> GSM123788     2  0.3620     0.7571 0.000 0.648 0.000 0.000 NA 0.000
#> GSM123792     2  0.3499     0.7687 0.000 0.680 0.000 0.000 NA 0.000
#> GSM123796     2  0.3515     0.7675 0.000 0.676 0.000 0.000 NA 0.000
#> GSM123731     2  0.0713     0.8258 0.000 0.972 0.000 0.000 NA 0.000
#> GSM123735     2  0.3747     0.7405 0.000 0.604 0.000 0.000 NA 0.000
#> GSM123739     2  0.5317     0.6392 0.000 0.568 0.000 0.004 NA 0.112
#> GSM123743     2  0.0547     0.8260 0.000 0.980 0.000 0.000 NA 0.000
#> GSM123749     2  0.0260     0.8256 0.000 0.992 0.000 0.000 NA 0.000
#> GSM123755     2  0.0146     0.8242 0.000 0.996 0.000 0.000 NA 0.000
#> GSM123768     2  0.0146     0.8242 0.000 0.996 0.000 0.000 NA 0.000
#> GSM123776     1  0.7329     0.1248 0.416 0.136 0.000 0.004 NA 0.168
#> GSM123783     2  0.1007     0.8156 0.000 0.956 0.000 0.000 NA 0.000
#> GSM123790     2  0.3782     0.7319 0.000 0.588 0.000 0.000 NA 0.000
#> GSM123794     2  0.3607     0.7630 0.000 0.652 0.000 0.000 NA 0.000
#> GSM123798     2  0.0146     0.8242 0.000 0.996 0.000 0.000 NA 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-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) infection(p) agent(p) k
#> SD:kmeans 70         6.31e-16     6.31e-16 1.30e-05 2
#> SD:kmeans 67         3.52e-14     3.52e-14 3.11e-05 3
#> SD:kmeans 68         3.09e-20     3.09e-20 9.57e-05 4
#> SD:kmeans 62         1.60e-19     1.60e-19 3.44e-04 5
#> SD:kmeans 56         2.41e-18     2.41e-18 3.31e-03 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 71 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.999       1.000         0.4787 0.522   0.522
#> 3 3 0.946           0.934       0.971         0.4068 0.786   0.597
#> 4 4 0.815           0.848       0.909         0.0910 0.886   0.675
#> 5 5 0.731           0.744       0.811         0.0490 1.000   1.000
#> 6 6 0.696           0.596       0.725         0.0355 0.962   0.861

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      1.000 1.000 0.000
#> GSM123736     1  0.0000      1.000 1.000 0.000
#> GSM123740     1  0.0000      1.000 1.000 0.000
#> GSM123744     1  0.0000      1.000 1.000 0.000
#> GSM123746     1  0.0000      1.000 1.000 0.000
#> GSM123750     1  0.0000      1.000 1.000 0.000
#> GSM123752     1  0.0000      1.000 1.000 0.000
#> GSM123756     1  0.0000      1.000 1.000 0.000
#> GSM123758     1  0.0000      1.000 1.000 0.000
#> GSM123761     1  0.0000      1.000 1.000 0.000
#> GSM123763     1  0.0000      1.000 1.000 0.000
#> GSM123765     1  0.0000      1.000 1.000 0.000
#> GSM123769     1  0.0000      1.000 1.000 0.000
#> GSM123771     1  0.0000      1.000 1.000 0.000
#> GSM123774     1  0.0000      1.000 1.000 0.000
#> GSM123778     1  0.0000      1.000 1.000 0.000
#> GSM123780     1  0.0000      1.000 1.000 0.000
#> GSM123784     1  0.0000      1.000 1.000 0.000
#> GSM123787     1  0.0000      1.000 1.000 0.000
#> GSM123791     1  0.0000      1.000 1.000 0.000
#> GSM123795     1  0.0000      1.000 1.000 0.000
#> GSM123799     1  0.0000      1.000 1.000 0.000
#> GSM123730     1  0.1184      0.984 0.984 0.016
#> GSM123734     1  0.0000      1.000 1.000 0.000
#> GSM123738     1  0.0000      1.000 1.000 0.000
#> GSM123742     1  0.0000      1.000 1.000 0.000
#> GSM123745     1  0.0000      1.000 1.000 0.000
#> GSM123748     1  0.0000      1.000 1.000 0.000
#> GSM123751     1  0.0000      1.000 1.000 0.000
#> GSM123754     1  0.0000      1.000 1.000 0.000
#> GSM123757     1  0.0000      1.000 1.000 0.000
#> GSM123760     1  0.0000      1.000 1.000 0.000
#> GSM123762     1  0.0000      1.000 1.000 0.000
#> GSM123764     1  0.0000      1.000 1.000 0.000
#> GSM123767     1  0.0000      1.000 1.000 0.000
#> GSM123770     1  0.0000      1.000 1.000 0.000
#> GSM123773     1  0.0000      1.000 1.000 0.000
#> GSM123777     1  0.0000      1.000 1.000 0.000
#> GSM123779     1  0.0000      1.000 1.000 0.000
#> GSM123782     1  0.0000      1.000 1.000 0.000
#> GSM123786     1  0.0000      1.000 1.000 0.000
#> GSM123789     1  0.0000      1.000 1.000 0.000
#> GSM123793     1  0.0000      1.000 1.000 0.000
#> GSM123797     1  0.0000      1.000 1.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000
#> GSM123733     2  0.0000      1.000 0.000 1.000
#> GSM123737     2  0.0000      1.000 0.000 1.000
#> GSM123741     2  0.0000      1.000 0.000 1.000
#> GSM123747     2  0.0000      1.000 0.000 1.000
#> GSM123753     2  0.0000      1.000 0.000 1.000
#> GSM123759     2  0.0000      1.000 0.000 1.000
#> GSM123766     2  0.0000      1.000 0.000 1.000
#> GSM123772     2  0.0000      1.000 0.000 1.000
#> GSM123775     2  0.0000      1.000 0.000 1.000
#> GSM123781     2  0.0000      1.000 0.000 1.000
#> GSM123785     2  0.0000      1.000 0.000 1.000
#> GSM123788     2  0.0000      1.000 0.000 1.000
#> GSM123792     2  0.0000      1.000 0.000 1.000
#> GSM123796     2  0.0000      1.000 0.000 1.000
#> GSM123731     2  0.0000      1.000 0.000 1.000
#> GSM123735     2  0.0000      1.000 0.000 1.000
#> GSM123739     2  0.0000      1.000 0.000 1.000
#> GSM123743     2  0.0000      1.000 0.000 1.000
#> GSM123749     2  0.0000      1.000 0.000 1.000
#> GSM123755     2  0.0000      1.000 0.000 1.000
#> GSM123768     2  0.0000      1.000 0.000 1.000
#> GSM123776     2  0.0376      0.996 0.004 0.996
#> GSM123783     2  0.0000      1.000 0.000 1.000
#> GSM123790     2  0.0000      1.000 0.000 1.000
#> GSM123794     2  0.0000      1.000 0.000 1.000
#> GSM123798     2  0.0000      1.000 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
#> GSM123732     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123736     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123740     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123744     1  0.5497     0.6023 0.708 0.000 0.292
#> GSM123746     1  0.0424     0.9261 0.992 0.000 0.008
#> GSM123750     1  0.3816     0.8112 0.852 0.000 0.148
#> GSM123752     1  0.3340     0.8389 0.880 0.000 0.120
#> GSM123756     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123758     3  0.2165     0.9266 0.064 0.000 0.936
#> GSM123761     1  0.0237     0.9281 0.996 0.000 0.004
#> GSM123763     1  0.0237     0.9284 0.996 0.000 0.004
#> GSM123765     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123769     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123771     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123774     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123778     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123780     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123784     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123787     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123791     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123795     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123799     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123730     3  0.1129     0.9636 0.020 0.004 0.976
#> GSM123734     1  0.1411     0.9076 0.964 0.000 0.036
#> GSM123738     3  0.0592     0.9687 0.012 0.000 0.988
#> GSM123742     1  0.0237     0.9284 0.996 0.000 0.004
#> GSM123745     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123748     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123751     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123754     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123757     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123760     1  0.0892     0.9198 0.980 0.000 0.020
#> GSM123762     1  0.0237     0.9284 0.996 0.000 0.004
#> GSM123764     3  0.1411     0.9551 0.036 0.000 0.964
#> GSM123767     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123770     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123773     1  0.0000     0.9296 1.000 0.000 0.000
#> GSM123777     3  0.0237     0.9717 0.004 0.000 0.996
#> GSM123779     1  0.6095     0.3388 0.608 0.000 0.392
#> GSM123782     3  0.4235     0.7917 0.176 0.000 0.824
#> GSM123786     3  0.0000     0.9730 0.000 0.000 1.000
#> GSM123789     3  0.3340     0.8748 0.120 0.000 0.880
#> GSM123793     3  0.2356     0.9264 0.072 0.000 0.928
#> GSM123797     3  0.0747     0.9671 0.016 0.000 0.984
#> GSM123729     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123733     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123737     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123741     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123747     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123753     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123759     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123766     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123772     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123775     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123781     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123785     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123788     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123792     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123796     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123731     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123735     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123739     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123743     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123749     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123755     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123768     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123776     1  0.6308     0.0469 0.508 0.492 0.000
#> GSM123783     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123790     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123794     2  0.0000     1.0000 0.000 1.000 0.000
#> GSM123798     2  0.0000     1.0000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.1118      0.859 0.000 0.000 0.964 0.036
#> GSM123736     3  0.1743      0.856 0.004 0.000 0.940 0.056
#> GSM123740     3  0.1576      0.857 0.004 0.000 0.948 0.048
#> GSM123744     3  0.5109      0.666 0.212 0.000 0.736 0.052
#> GSM123746     1  0.2926      0.809 0.896 0.000 0.056 0.048
#> GSM123750     3  0.6278      0.296 0.408 0.000 0.532 0.060
#> GSM123752     3  0.5869      0.463 0.360 0.000 0.596 0.044
#> GSM123756     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM123758     3  0.2032      0.839 0.036 0.000 0.936 0.028
#> GSM123761     1  0.3144      0.799 0.884 0.000 0.072 0.044
#> GSM123763     1  0.4105      0.753 0.812 0.000 0.032 0.156
#> GSM123765     3  0.2011      0.854 0.000 0.000 0.920 0.080
#> GSM123769     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM123771     1  0.0000      0.846 1.000 0.000 0.000 0.000
#> GSM123774     1  0.0469      0.845 0.988 0.000 0.000 0.012
#> GSM123778     3  0.1118      0.860 0.000 0.000 0.964 0.036
#> GSM123780     3  0.2921      0.785 0.000 0.000 0.860 0.140
#> GSM123784     3  0.2011      0.847 0.000 0.000 0.920 0.080
#> GSM123787     3  0.1302      0.859 0.000 0.000 0.956 0.044
#> GSM123791     3  0.1151      0.861 0.008 0.000 0.968 0.024
#> GSM123795     3  0.2799      0.831 0.008 0.000 0.884 0.108
#> GSM123799     3  0.1576      0.858 0.004 0.000 0.948 0.048
#> GSM123730     4  0.2342      0.822 0.008 0.000 0.080 0.912
#> GSM123734     4  0.4560      0.529 0.296 0.000 0.004 0.700
#> GSM123738     4  0.3539      0.783 0.004 0.000 0.176 0.820
#> GSM123742     1  0.5523      0.400 0.596 0.000 0.024 0.380
#> GSM123745     1  0.3172      0.798 0.840 0.000 0.000 0.160
#> GSM123748     1  0.2760      0.825 0.872 0.000 0.000 0.128
#> GSM123751     1  0.3688      0.759 0.792 0.000 0.000 0.208
#> GSM123754     1  0.2345      0.836 0.900 0.000 0.000 0.100
#> GSM123757     1  0.0921      0.848 0.972 0.000 0.000 0.028
#> GSM123760     4  0.5313      0.301 0.376 0.000 0.016 0.608
#> GSM123762     1  0.2662      0.826 0.900 0.000 0.016 0.084
#> GSM123764     4  0.4171      0.819 0.060 0.000 0.116 0.824
#> GSM123767     1  0.4304      0.635 0.716 0.000 0.000 0.284
#> GSM123770     1  0.1118      0.845 0.964 0.000 0.000 0.036
#> GSM123773     1  0.2760      0.820 0.872 0.000 0.000 0.128
#> GSM123777     4  0.3356      0.771 0.000 0.000 0.176 0.824
#> GSM123779     4  0.3325      0.780 0.112 0.000 0.024 0.864
#> GSM123782     4  0.4906      0.775 0.084 0.000 0.140 0.776
#> GSM123786     3  0.1716      0.855 0.000 0.000 0.936 0.064
#> GSM123789     4  0.4285      0.821 0.076 0.000 0.104 0.820
#> GSM123793     4  0.3143      0.826 0.024 0.000 0.100 0.876
#> GSM123797     4  0.3032      0.815 0.008 0.000 0.124 0.868
#> GSM123729     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123733     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123737     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123741     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123753     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123766     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123781     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123785     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123788     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123792     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123796     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123731     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123735     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123739     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123743     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123749     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123768     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123776     1  0.5254      0.459 0.672 0.300 0.000 0.028
#> GSM123783     2  0.0188      0.996 0.000 0.996 0.000 0.004
#> GSM123790     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123794     2  0.0188      0.998 0.000 0.996 0.000 0.004
#> GSM123798     2  0.0000      0.998 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.2104      0.752 0.000 0.000 0.916 0.024 0.060
#> GSM123736     3  0.4172      0.735 0.004 0.000 0.792 0.092 0.112
#> GSM123740     3  0.4158      0.733 0.000 0.000 0.784 0.092 0.124
#> GSM123744     3  0.6719      0.459 0.204 0.000 0.472 0.008 0.316
#> GSM123746     1  0.4973      0.625 0.692 0.000 0.068 0.004 0.236
#> GSM123750     3  0.7047      0.180 0.300 0.000 0.348 0.008 0.344
#> GSM123752     3  0.6700      0.222 0.356 0.000 0.400 0.000 0.244
#> GSM123756     1  0.1341      0.726 0.944 0.000 0.000 0.000 0.056
#> GSM123758     3  0.3615      0.730 0.036 0.000 0.808 0.000 0.156
#> GSM123761     1  0.5550      0.572 0.636 0.000 0.068 0.016 0.280
#> GSM123763     1  0.6636      0.464 0.544 0.000 0.032 0.132 0.292
#> GSM123765     3  0.1914      0.754 0.000 0.000 0.924 0.060 0.016
#> GSM123769     1  0.1608      0.726 0.928 0.000 0.000 0.000 0.072
#> GSM123771     1  0.1478      0.727 0.936 0.000 0.000 0.000 0.064
#> GSM123774     1  0.0794      0.728 0.972 0.000 0.000 0.000 0.028
#> GSM123778     3  0.2370      0.750 0.000 0.000 0.904 0.040 0.056
#> GSM123780     3  0.4164      0.682 0.000 0.000 0.784 0.120 0.096
#> GSM123784     3  0.3043      0.748 0.000 0.000 0.864 0.080 0.056
#> GSM123787     3  0.2124      0.757 0.000 0.000 0.916 0.028 0.056
#> GSM123791     3  0.4901      0.703 0.004 0.000 0.716 0.084 0.196
#> GSM123795     3  0.5309      0.686 0.012 0.000 0.704 0.140 0.144
#> GSM123799     3  0.4203      0.738 0.000 0.000 0.780 0.092 0.128
#> GSM123730     4  0.2228      0.720 0.000 0.000 0.048 0.912 0.040
#> GSM123734     4  0.6269      0.521 0.196 0.000 0.012 0.588 0.204
#> GSM123738     4  0.4197      0.664 0.000 0.000 0.148 0.776 0.076
#> GSM123742     1  0.6968      0.117 0.380 0.000 0.008 0.252 0.360
#> GSM123745     1  0.5083      0.622 0.700 0.000 0.000 0.140 0.160
#> GSM123748     1  0.4869      0.651 0.712 0.000 0.000 0.096 0.192
#> GSM123751     1  0.5575      0.573 0.644 0.000 0.000 0.168 0.188
#> GSM123754     1  0.3608      0.691 0.824 0.000 0.000 0.112 0.064
#> GSM123757     1  0.2621      0.727 0.876 0.000 0.004 0.008 0.112
#> GSM123760     4  0.6864      0.238 0.252 0.000 0.004 0.384 0.360
#> GSM123762     1  0.5636      0.600 0.652 0.000 0.016 0.092 0.240
#> GSM123764     4  0.6604      0.638 0.052 0.000 0.088 0.544 0.316
#> GSM123767     1  0.5531      0.519 0.632 0.000 0.000 0.248 0.120
#> GSM123770     1  0.1830      0.723 0.932 0.000 0.000 0.028 0.040
#> GSM123773     1  0.3994      0.672 0.792 0.000 0.000 0.140 0.068
#> GSM123777     4  0.3863      0.661 0.000 0.000 0.152 0.796 0.052
#> GSM123779     4  0.5095      0.668 0.104 0.000 0.032 0.744 0.120
#> GSM123782     4  0.7174      0.589 0.064 0.000 0.124 0.476 0.336
#> GSM123786     3  0.2628      0.749 0.000 0.000 0.884 0.028 0.088
#> GSM123789     4  0.5861      0.697 0.036 0.000 0.088 0.656 0.220
#> GSM123793     4  0.3960      0.729 0.008 0.000 0.044 0.800 0.148
#> GSM123797     4  0.3346      0.712 0.000 0.000 0.092 0.844 0.064
#> GSM123729     2  0.2377      0.917 0.000 0.872 0.000 0.000 0.128
#> GSM123733     2  0.1341      0.953 0.000 0.944 0.000 0.000 0.056
#> GSM123737     2  0.2020      0.933 0.000 0.900 0.000 0.000 0.100
#> GSM123741     2  0.0510      0.959 0.000 0.984 0.000 0.000 0.016
#> GSM123747     2  0.0703      0.960 0.000 0.976 0.000 0.000 0.024
#> GSM123753     2  0.0963      0.958 0.000 0.964 0.000 0.000 0.036
#> GSM123759     2  0.1121      0.959 0.000 0.956 0.000 0.000 0.044
#> GSM123766     2  0.1043      0.958 0.000 0.960 0.000 0.000 0.040
#> GSM123772     2  0.0609      0.960 0.000 0.980 0.000 0.000 0.020
#> GSM123775     2  0.2329      0.929 0.000 0.876 0.000 0.000 0.124
#> GSM123781     2  0.0880      0.956 0.000 0.968 0.000 0.000 0.032
#> GSM123785     2  0.1544      0.949 0.000 0.932 0.000 0.000 0.068
#> GSM123788     2  0.1270      0.954 0.000 0.948 0.000 0.000 0.052
#> GSM123792     2  0.0794      0.958 0.000 0.972 0.000 0.000 0.028
#> GSM123796     2  0.1043      0.958 0.000 0.960 0.000 0.000 0.040
#> GSM123731     2  0.1410      0.959 0.000 0.940 0.000 0.000 0.060
#> GSM123735     2  0.1851      0.947 0.000 0.912 0.000 0.000 0.088
#> GSM123739     2  0.2329      0.921 0.000 0.876 0.000 0.000 0.124
#> GSM123743     2  0.0609      0.961 0.000 0.980 0.000 0.000 0.020
#> GSM123749     2  0.0510      0.960 0.000 0.984 0.000 0.000 0.016
#> GSM123755     2  0.0963      0.956 0.000 0.964 0.000 0.000 0.036
#> GSM123768     2  0.1121      0.956 0.000 0.956 0.000 0.000 0.044
#> GSM123776     1  0.5850      0.442 0.624 0.176 0.000 0.004 0.196
#> GSM123783     2  0.2127      0.939 0.000 0.892 0.000 0.000 0.108
#> GSM123790     2  0.2233      0.934 0.000 0.892 0.000 0.004 0.104
#> GSM123794     2  0.1478      0.953 0.000 0.936 0.000 0.000 0.064
#> GSM123798     2  0.1043      0.957 0.000 0.960 0.000 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.2058    0.70008 0.000 0.000 0.916 0.012 0.048 0.024
#> GSM123736     3  0.5642    0.63434 0.004 0.000 0.644 0.208 0.072 0.072
#> GSM123740     3  0.5765    0.64517 0.004 0.000 0.644 0.184 0.088 0.080
#> GSM123744     3  0.7994   -0.07414 0.248 0.000 0.284 0.016 0.180 0.272
#> GSM123746     1  0.5831    0.36274 0.604 0.000 0.024 0.008 0.144 0.220
#> GSM123750     6  0.7730   -0.03918 0.308 0.000 0.196 0.008 0.168 0.320
#> GSM123752     1  0.7964   -0.10502 0.320 0.000 0.256 0.016 0.220 0.188
#> GSM123756     1  0.1461    0.57214 0.940 0.000 0.000 0.000 0.016 0.044
#> GSM123758     3  0.5832    0.55107 0.060 0.000 0.632 0.004 0.188 0.116
#> GSM123761     1  0.6290    0.17086 0.484 0.000 0.036 0.008 0.116 0.356
#> GSM123763     1  0.6873    0.00491 0.408 0.000 0.024 0.080 0.084 0.404
#> GSM123765     3  0.2901    0.70804 0.000 0.000 0.872 0.040 0.056 0.032
#> GSM123769     1  0.1867    0.56826 0.916 0.000 0.000 0.000 0.020 0.064
#> GSM123771     1  0.2147    0.55986 0.896 0.000 0.000 0.000 0.020 0.084
#> GSM123774     1  0.0909    0.57722 0.968 0.000 0.000 0.000 0.020 0.012
#> GSM123778     3  0.2908    0.69489 0.000 0.000 0.864 0.012 0.076 0.048
#> GSM123780     3  0.4784    0.62362 0.000 0.000 0.736 0.112 0.096 0.056
#> GSM123784     3  0.3240    0.70235 0.004 0.000 0.856 0.056 0.032 0.052
#> GSM123787     3  0.3530    0.69304 0.000 0.000 0.824 0.028 0.104 0.044
#> GSM123791     3  0.6103    0.58078 0.020 0.000 0.628 0.056 0.124 0.172
#> GSM123795     3  0.6481    0.52158 0.004 0.000 0.532 0.272 0.088 0.104
#> GSM123799     3  0.5649    0.65501 0.004 0.000 0.656 0.176 0.068 0.096
#> GSM123730     4  0.2926    0.56272 0.004 0.000 0.040 0.876 0.040 0.040
#> GSM123734     4  0.6212    0.16696 0.144 0.000 0.004 0.500 0.028 0.324
#> GSM123738     4  0.4199    0.51017 0.000 0.000 0.108 0.780 0.040 0.072
#> GSM123742     6  0.6047    0.25066 0.200 0.000 0.008 0.180 0.028 0.584
#> GSM123745     1  0.5895    0.42058 0.592 0.000 0.000 0.136 0.044 0.228
#> GSM123748     1  0.5617    0.32681 0.516 0.000 0.000 0.060 0.040 0.384
#> GSM123751     1  0.5933    0.33321 0.528 0.000 0.000 0.152 0.020 0.300
#> GSM123754     1  0.4756    0.53119 0.736 0.000 0.000 0.108 0.048 0.108
#> GSM123757     1  0.3764    0.55651 0.804 0.000 0.004 0.008 0.084 0.100
#> GSM123760     6  0.6291    0.21297 0.116 0.000 0.008 0.276 0.052 0.548
#> GSM123762     1  0.5646    0.22956 0.504 0.000 0.000 0.048 0.052 0.396
#> GSM123764     6  0.6842   -0.01576 0.012 0.000 0.088 0.336 0.104 0.460
#> GSM123767     1  0.5959    0.39274 0.584 0.000 0.000 0.228 0.044 0.144
#> GSM123770     1  0.2764    0.56935 0.872 0.000 0.000 0.024 0.020 0.084
#> GSM123773     1  0.4962    0.51706 0.716 0.000 0.000 0.124 0.048 0.112
#> GSM123777     4  0.4421    0.49953 0.000 0.000 0.152 0.752 0.048 0.048
#> GSM123779     4  0.6947    0.34732 0.104 0.000 0.048 0.560 0.092 0.196
#> GSM123782     6  0.8010    0.00596 0.040 0.000 0.132 0.296 0.184 0.348
#> GSM123786     3  0.3222    0.68440 0.000 0.000 0.844 0.024 0.096 0.036
#> GSM123789     4  0.6808    0.18379 0.008 0.000 0.080 0.476 0.128 0.308
#> GSM123793     4  0.4640    0.45835 0.004 0.000 0.032 0.692 0.028 0.244
#> GSM123797     4  0.2467    0.56996 0.000 0.000 0.048 0.896 0.020 0.036
#> GSM123729     2  0.3314    0.83569 0.000 0.764 0.000 0.000 0.224 0.012
#> GSM123733     2  0.2527    0.89169 0.000 0.832 0.000 0.000 0.168 0.000
#> GSM123737     2  0.3014    0.86604 0.000 0.804 0.000 0.000 0.184 0.012
#> GSM123741     2  0.0603    0.92133 0.000 0.980 0.000 0.000 0.016 0.004
#> GSM123747     2  0.1387    0.92180 0.000 0.932 0.000 0.000 0.068 0.000
#> GSM123753     2  0.0790    0.91985 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM123759     2  0.0777    0.91947 0.000 0.972 0.000 0.000 0.024 0.004
#> GSM123766     2  0.1152    0.92091 0.000 0.952 0.000 0.000 0.044 0.004
#> GSM123772     2  0.1010    0.92197 0.000 0.960 0.000 0.000 0.036 0.004
#> GSM123775     2  0.3052    0.85510 0.000 0.780 0.000 0.000 0.216 0.004
#> GSM123781     2  0.1082    0.91795 0.000 0.956 0.000 0.000 0.040 0.004
#> GSM123785     2  0.2135    0.90528 0.000 0.872 0.000 0.000 0.128 0.000
#> GSM123788     2  0.2092    0.90638 0.000 0.876 0.000 0.000 0.124 0.000
#> GSM123792     2  0.1714    0.91753 0.000 0.908 0.000 0.000 0.092 0.000
#> GSM123796     2  0.1910    0.91101 0.000 0.892 0.000 0.000 0.108 0.000
#> GSM123731     2  0.1556    0.91858 0.000 0.920 0.000 0.000 0.080 0.000
#> GSM123735     2  0.2632    0.89410 0.000 0.832 0.000 0.000 0.164 0.004
#> GSM123739     2  0.3342    0.83559 0.000 0.760 0.000 0.000 0.228 0.012
#> GSM123743     2  0.1141    0.92225 0.000 0.948 0.000 0.000 0.052 0.000
#> GSM123749     2  0.0405    0.92070 0.000 0.988 0.000 0.000 0.008 0.004
#> GSM123755     2  0.0937    0.91846 0.000 0.960 0.000 0.000 0.040 0.000
#> GSM123768     2  0.1285    0.91400 0.000 0.944 0.000 0.000 0.052 0.004
#> GSM123776     1  0.6228    0.25315 0.528 0.100 0.000 0.008 0.316 0.048
#> GSM123783     2  0.2558    0.88211 0.000 0.840 0.000 0.000 0.156 0.004
#> GSM123790     2  0.3192    0.86043 0.000 0.776 0.000 0.004 0.216 0.004
#> GSM123794     2  0.2300    0.90433 0.000 0.856 0.000 0.000 0.144 0.000
#> GSM123798     2  0.1349    0.91455 0.000 0.940 0.000 0.000 0.056 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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) infection(p) agent(p) k
#> SD:skmeans 71         3.82e-16     3.82e-16 6.04e-06 2
#> SD:skmeans 69         2.33e-14     2.33e-14 2.00e-05 3
#> SD:skmeans 66         2.65e-19     2.65e-19 1.47e-04 4
#> SD:skmeans 64         8.56e-19     8.56e-19 2.25e-04 5
#> SD:skmeans 50         1.20e-13     1.20e-13 4.60e-03 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.993       0.997         0.4780 0.522   0.522
#> 3 3 0.982           0.943       0.979         0.3821 0.820   0.655
#> 4 4 0.889           0.856       0.944         0.0343 0.989   0.968
#> 5 5 0.859           0.830       0.926         0.0212 0.994   0.982
#> 6 6 0.842           0.791       0.914         0.0134 0.994   0.983

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      0.998 1.000 0.000
#> GSM123736     1  0.0000      0.998 1.000 0.000
#> GSM123740     1  0.0000      0.998 1.000 0.000
#> GSM123744     1  0.0000      0.998 1.000 0.000
#> GSM123746     1  0.0000      0.998 1.000 0.000
#> GSM123750     1  0.0000      0.998 1.000 0.000
#> GSM123752     1  0.0000      0.998 1.000 0.000
#> GSM123756     1  0.0000      0.998 1.000 0.000
#> GSM123758     1  0.0000      0.998 1.000 0.000
#> GSM123761     1  0.0000      0.998 1.000 0.000
#> GSM123763     1  0.0000      0.998 1.000 0.000
#> GSM123765     1  0.0000      0.998 1.000 0.000
#> GSM123769     1  0.0000      0.998 1.000 0.000
#> GSM123771     1  0.0000      0.998 1.000 0.000
#> GSM123774     1  0.0000      0.998 1.000 0.000
#> GSM123778     1  0.0000      0.998 1.000 0.000
#> GSM123780     1  0.0000      0.998 1.000 0.000
#> GSM123784     1  0.0000      0.998 1.000 0.000
#> GSM123787     1  0.0000      0.998 1.000 0.000
#> GSM123791     1  0.0000      0.998 1.000 0.000
#> GSM123795     1  0.0000      0.998 1.000 0.000
#> GSM123799     1  0.0000      0.998 1.000 0.000
#> GSM123730     1  0.0376      0.994 0.996 0.004
#> GSM123734     1  0.0000      0.998 1.000 0.000
#> GSM123738     1  0.0000      0.998 1.000 0.000
#> GSM123742     1  0.0000      0.998 1.000 0.000
#> GSM123745     1  0.3733      0.922 0.928 0.072
#> GSM123748     1  0.0000      0.998 1.000 0.000
#> GSM123751     1  0.0000      0.998 1.000 0.000
#> GSM123754     1  0.0000      0.998 1.000 0.000
#> GSM123757     1  0.0000      0.998 1.000 0.000
#> GSM123760     1  0.0000      0.998 1.000 0.000
#> GSM123762     1  0.0000      0.998 1.000 0.000
#> GSM123764     1  0.0000      0.998 1.000 0.000
#> GSM123767     1  0.0672      0.991 0.992 0.008
#> GSM123770     1  0.0000      0.998 1.000 0.000
#> GSM123773     1  0.0000      0.998 1.000 0.000
#> GSM123777     1  0.0000      0.998 1.000 0.000
#> GSM123779     1  0.0000      0.998 1.000 0.000
#> GSM123782     1  0.0000      0.998 1.000 0.000
#> GSM123786     1  0.0000      0.998 1.000 0.000
#> GSM123789     1  0.0000      0.998 1.000 0.000
#> GSM123793     1  0.0000      0.998 1.000 0.000
#> GSM123797     1  0.0000      0.998 1.000 0.000
#> GSM123729     2  0.0000      0.994 0.000 1.000
#> GSM123733     2  0.0000      0.994 0.000 1.000
#> GSM123737     2  0.0000      0.994 0.000 1.000
#> GSM123741     2  0.0000      0.994 0.000 1.000
#> GSM123747     2  0.0000      0.994 0.000 1.000
#> GSM123753     2  0.0000      0.994 0.000 1.000
#> GSM123759     2  0.0000      0.994 0.000 1.000
#> GSM123766     2  0.0000      0.994 0.000 1.000
#> GSM123772     2  0.0000      0.994 0.000 1.000
#> GSM123775     2  0.0000      0.994 0.000 1.000
#> GSM123781     2  0.0000      0.994 0.000 1.000
#> GSM123785     2  0.0000      0.994 0.000 1.000
#> GSM123788     2  0.0000      0.994 0.000 1.000
#> GSM123792     2  0.0000      0.994 0.000 1.000
#> GSM123796     2  0.0000      0.994 0.000 1.000
#> GSM123731     2  0.0000      0.994 0.000 1.000
#> GSM123735     2  0.0000      0.994 0.000 1.000
#> GSM123739     2  0.0000      0.994 0.000 1.000
#> GSM123743     2  0.0000      0.994 0.000 1.000
#> GSM123749     2  0.0000      0.994 0.000 1.000
#> GSM123755     2  0.0000      0.994 0.000 1.000
#> GSM123768     2  0.0000      0.994 0.000 1.000
#> GSM123776     2  0.6048      0.826 0.148 0.852
#> GSM123783     2  0.0000      0.994 0.000 1.000
#> GSM123790     2  0.0000      0.994 0.000 1.000
#> GSM123794     2  0.0000      0.994 0.000 1.000
#> GSM123798     2  0.0000      0.994 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
#> GSM123732     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123736     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123740     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123744     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123746     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123750     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123752     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123756     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123758     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123761     3  0.3619     0.8318 0.136 0.000 0.864
#> GSM123763     3  0.6204     0.2542 0.424 0.000 0.576
#> GSM123765     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123769     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123771     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123774     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123778     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123780     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123784     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123787     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123791     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123795     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123799     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123730     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123734     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123738     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123742     1  0.0237     0.9629 0.996 0.000 0.004
#> GSM123745     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123748     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123751     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123754     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123757     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123760     1  0.6302     0.0402 0.520 0.000 0.480
#> GSM123762     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123764     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123767     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123770     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123773     1  0.0000     0.9666 1.000 0.000 0.000
#> GSM123777     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123779     3  0.4452     0.7529 0.192 0.000 0.808
#> GSM123782     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123786     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123789     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123793     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123797     3  0.0000     0.9709 0.000 0.000 1.000
#> GSM123729     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123733     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123737     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123741     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123747     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123753     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123759     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123766     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123772     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123775     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123781     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123785     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123788     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123792     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123796     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123731     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123735     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123739     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123743     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123749     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123755     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123768     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123776     2  0.5465     0.5926 0.288 0.712 0.000
#> GSM123783     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123790     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123794     2  0.0000     0.9887 0.000 1.000 0.000
#> GSM123798     2  0.0000     0.9887 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1   p2    p3    p4
#> GSM123732     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123736     3  0.1118     0.8587 0.000 0.00 0.964 0.036
#> GSM123740     3  0.1211     0.8586 0.000 0.00 0.960 0.040
#> GSM123744     3  0.2647     0.7850 0.000 0.00 0.880 0.120
#> GSM123746     3  0.4405     0.6786 0.048 0.00 0.800 0.152
#> GSM123750     3  0.2469     0.7981 0.000 0.00 0.892 0.108
#> GSM123752     3  0.3370     0.7689 0.048 0.00 0.872 0.080
#> GSM123756     1  0.1716     0.8949 0.936 0.00 0.000 0.064
#> GSM123758     3  0.0469     0.8749 0.000 0.00 0.988 0.012
#> GSM123761     3  0.6215     0.4212 0.140 0.00 0.668 0.192
#> GSM123763     3  0.7302    -0.0500 0.332 0.00 0.500 0.168
#> GSM123765     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123769     1  0.1716     0.8949 0.936 0.00 0.000 0.064
#> GSM123771     1  0.1716     0.8949 0.936 0.00 0.000 0.064
#> GSM123774     1  0.1716     0.8949 0.936 0.00 0.000 0.064
#> GSM123778     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123780     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123784     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123787     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123791     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123795     3  0.1118     0.8587 0.000 0.00 0.964 0.036
#> GSM123799     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123730     3  0.0592     0.8709 0.016 0.00 0.984 0.000
#> GSM123734     1  0.2760     0.8298 0.872 0.00 0.000 0.128
#> GSM123738     3  0.2868     0.7377 0.000 0.00 0.864 0.136
#> GSM123742     1  0.2469     0.8616 0.892 0.00 0.000 0.108
#> GSM123745     1  0.0000     0.9071 1.000 0.00 0.000 0.000
#> GSM123748     1  0.1389     0.8973 0.952 0.00 0.000 0.048
#> GSM123751     1  0.1022     0.9034 0.968 0.00 0.000 0.032
#> GSM123754     1  0.1302     0.9011 0.956 0.00 0.000 0.044
#> GSM123757     1  0.2741     0.8674 0.892 0.00 0.012 0.096
#> GSM123760     1  0.6946    -0.0455 0.504 0.00 0.380 0.116
#> GSM123762     1  0.1940     0.8988 0.924 0.00 0.000 0.076
#> GSM123764     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123767     1  0.0000     0.9071 1.000 0.00 0.000 0.000
#> GSM123770     1  0.0000     0.9071 1.000 0.00 0.000 0.000
#> GSM123773     1  0.0000     0.9071 1.000 0.00 0.000 0.000
#> GSM123777     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123779     3  0.4086     0.5713 0.216 0.00 0.776 0.008
#> GSM123782     3  0.1174     0.8610 0.020 0.00 0.968 0.012
#> GSM123786     3  0.0000     0.8785 0.000 0.00 1.000 0.000
#> GSM123789     3  0.0188     0.8775 0.000 0.00 0.996 0.004
#> GSM123793     4  0.5090     0.0000 0.016 0.00 0.324 0.660
#> GSM123797     3  0.3324     0.7220 0.012 0.00 0.852 0.136
#> GSM123729     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123733     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123737     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123741     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123747     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123753     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123759     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123766     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123772     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123775     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123781     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123785     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123788     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123792     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123796     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123731     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123735     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123739     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123743     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123749     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123755     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123768     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123776     2  0.4428     0.5890 0.276 0.72 0.000 0.004
#> GSM123783     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123790     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123794     2  0.0000     0.9875 0.000 1.00 0.000 0.000
#> GSM123798     2  0.0000     0.9875 0.000 1.00 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
#> GSM123732     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123736     3  0.1121     0.8681 0.000 0.000 0.956 0.044 0.000
#> GSM123740     3  0.1282     0.8675 0.000 0.000 0.952 0.044 0.004
#> GSM123744     3  0.2732     0.7992 0.000 0.000 0.840 0.000 0.160
#> GSM123746     3  0.5073     0.6460 0.100 0.000 0.688 0.000 0.212
#> GSM123750     3  0.2605     0.8082 0.000 0.000 0.852 0.000 0.148
#> GSM123752     3  0.4072     0.7437 0.100 0.000 0.792 0.000 0.108
#> GSM123756     1  0.2708     0.7928 0.884 0.000 0.000 0.044 0.072
#> GSM123758     3  0.0404     0.8798 0.000 0.000 0.988 0.000 0.012
#> GSM123761     3  0.5948     0.4732 0.156 0.000 0.580 0.000 0.264
#> GSM123763     3  0.7027     0.1726 0.296 0.000 0.460 0.020 0.224
#> GSM123765     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123769     1  0.2708     0.7928 0.884 0.000 0.000 0.044 0.072
#> GSM123771     1  0.2708     0.7928 0.884 0.000 0.000 0.044 0.072
#> GSM123774     1  0.2708     0.7928 0.884 0.000 0.000 0.044 0.072
#> GSM123778     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123784     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123787     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123795     3  0.1121     0.8681 0.000 0.000 0.956 0.044 0.000
#> GSM123799     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123730     3  0.1197     0.8633 0.000 0.000 0.952 0.048 0.000
#> GSM123734     5  0.5594     0.0000 0.232 0.000 0.000 0.136 0.632
#> GSM123738     3  0.3561     0.6769 0.000 0.000 0.740 0.260 0.000
#> GSM123742     1  0.2674     0.7402 0.856 0.000 0.004 0.000 0.140
#> GSM123745     1  0.1121     0.8221 0.956 0.000 0.000 0.044 0.000
#> GSM123748     1  0.1608     0.8022 0.928 0.000 0.000 0.000 0.072
#> GSM123751     1  0.1444     0.8191 0.948 0.000 0.000 0.012 0.040
#> GSM123754     1  0.1571     0.8105 0.936 0.000 0.000 0.004 0.060
#> GSM123757     1  0.2230     0.7687 0.884 0.000 0.000 0.000 0.116
#> GSM123760     1  0.6282     0.0901 0.524 0.000 0.336 0.008 0.132
#> GSM123762     1  0.3214     0.7557 0.844 0.000 0.000 0.036 0.120
#> GSM123764     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123767     1  0.1121     0.8221 0.956 0.000 0.000 0.044 0.000
#> GSM123770     1  0.1121     0.8221 0.956 0.000 0.000 0.044 0.000
#> GSM123773     1  0.1121     0.8221 0.956 0.000 0.000 0.044 0.000
#> GSM123777     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123779     3  0.4134     0.6768 0.196 0.000 0.760 0.044 0.000
#> GSM123782     3  0.1469     0.8624 0.036 0.000 0.948 0.000 0.016
#> GSM123786     3  0.0000     0.8812 0.000 0.000 1.000 0.000 0.000
#> GSM123789     3  0.0510     0.8776 0.016 0.000 0.984 0.000 0.000
#> GSM123793     4  0.1768     0.0000 0.004 0.000 0.072 0.924 0.000
#> GSM123797     3  0.3906     0.6340 0.004 0.000 0.704 0.292 0.000
#> GSM123729     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123781     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123776     2  0.3741     0.5733 0.264 0.732 0.000 0.000 0.004
#> GSM123783     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123790     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2  0.0000     0.9878 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123736     3  0.1349     0.8565 0.000 0.000 0.940 0.000 0.056 0.004
#> GSM123740     3  0.1462     0.8558 0.000 0.000 0.936 0.000 0.056 0.008
#> GSM123744     3  0.2738     0.7861 0.000 0.000 0.820 0.004 0.000 0.176
#> GSM123746     3  0.5239     0.5398 0.152 0.000 0.600 0.000 0.000 0.248
#> GSM123750     3  0.2632     0.7946 0.000 0.000 0.832 0.004 0.000 0.164
#> GSM123752     3  0.4464     0.6600 0.148 0.000 0.712 0.000 0.000 0.140
#> GSM123756     1  0.2884     0.6506 0.824 0.000 0.000 0.008 0.004 0.164
#> GSM123758     3  0.0363     0.8715 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM123761     3  0.5751     0.3710 0.168 0.000 0.508 0.004 0.000 0.320
#> GSM123763     3  0.6269     0.1158 0.244 0.000 0.432 0.012 0.000 0.312
#> GSM123765     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123769     1  0.2884     0.6506 0.824 0.000 0.000 0.008 0.004 0.164
#> GSM123771     1  0.2884     0.6506 0.824 0.000 0.000 0.008 0.004 0.164
#> GSM123774     1  0.2884     0.6506 0.824 0.000 0.000 0.008 0.004 0.164
#> GSM123778     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123780     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123784     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123791     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123795     3  0.1349     0.8565 0.000 0.000 0.940 0.000 0.056 0.004
#> GSM123799     3  0.0146     0.8721 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123730     3  0.1194     0.8612 0.008 0.000 0.956 0.032 0.004 0.000
#> GSM123734     4  0.1075     0.0000 0.048 0.000 0.000 0.952 0.000 0.000
#> GSM123738     3  0.4676     0.6561 0.000 0.000 0.696 0.036 0.228 0.040
#> GSM123742     1  0.2632     0.6212 0.832 0.000 0.000 0.000 0.004 0.164
#> GSM123745     1  0.0858     0.7496 0.968 0.000 0.000 0.028 0.004 0.000
#> GSM123748     1  0.1663     0.7163 0.912 0.000 0.000 0.000 0.000 0.088
#> GSM123751     1  0.1411     0.7345 0.936 0.000 0.000 0.004 0.000 0.060
#> GSM123754     1  0.1444     0.7272 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM123757     1  0.2340     0.6515 0.852 0.000 0.000 0.000 0.000 0.148
#> GSM123760     1  0.5843    -0.0147 0.532 0.000 0.288 0.000 0.012 0.168
#> GSM123762     6  0.3728     0.0000 0.344 0.000 0.000 0.004 0.000 0.652
#> GSM123764     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123767     1  0.0858     0.7496 0.968 0.000 0.000 0.028 0.004 0.000
#> GSM123770     1  0.1003     0.7487 0.964 0.000 0.000 0.028 0.004 0.004
#> GSM123773     1  0.0858     0.7496 0.968 0.000 0.000 0.028 0.004 0.000
#> GSM123777     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123779     3  0.3837     0.6836 0.212 0.000 0.752 0.028 0.004 0.004
#> GSM123782     3  0.1349     0.8514 0.056 0.000 0.940 0.000 0.000 0.004
#> GSM123786     3  0.0000     0.8725 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123789     3  0.0603     0.8684 0.016 0.000 0.980 0.000 0.000 0.004
#> GSM123793     5  0.0748     0.0000 0.004 0.000 0.004 0.016 0.976 0.000
#> GSM123797     3  0.4887     0.6404 0.000 0.000 0.680 0.048 0.232 0.040
#> GSM123729     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123737     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123781     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123788     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123792     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123731     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123739     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123776     2  0.3380     0.6121 0.244 0.748 0.000 0.004 0.000 0.004
#> GSM123783     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123790     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123794     2  0.0146     0.9859 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123798     2  0.0000     0.9874 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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) infection(p) agent(p) k
#> SD:pam 71         3.82e-16     3.82e-16 6.04e-06 2
#> SD:pam 69         6.35e-16     6.35e-16 1.24e-05 3
#> SD:pam 67         1.38e-15     1.38e-15 1.98e-05 4
#> SD:pam 66         3.88e-15     3.88e-15 2.51e-05 5
#> SD:pam 65         1.11e-14     1.11e-14 3.18e-05 6

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


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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.999       1.000         0.4711 0.529   0.529
#> 3 3 1.000           0.969       0.987         0.3107 0.849   0.716
#> 4 4 0.940           0.919       0.966         0.1549 0.895   0.727
#> 5 5 0.897           0.855       0.905         0.0686 0.933   0.768
#> 6 6 0.814           0.851       0.889         0.0353 0.956   0.820

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      1.000 1.000 0.000
#> GSM123736     1  0.0000      1.000 1.000 0.000
#> GSM123740     1  0.0000      1.000 1.000 0.000
#> GSM123744     1  0.0000      1.000 1.000 0.000
#> GSM123746     1  0.0000      1.000 1.000 0.000
#> GSM123750     1  0.0000      1.000 1.000 0.000
#> GSM123752     1  0.0000      1.000 1.000 0.000
#> GSM123756     1  0.0000      1.000 1.000 0.000
#> GSM123758     1  0.0000      1.000 1.000 0.000
#> GSM123761     1  0.0000      1.000 1.000 0.000
#> GSM123763     1  0.0000      1.000 1.000 0.000
#> GSM123765     1  0.0000      1.000 1.000 0.000
#> GSM123769     1  0.0000      1.000 1.000 0.000
#> GSM123771     1  0.0000      1.000 1.000 0.000
#> GSM123774     1  0.0000      1.000 1.000 0.000
#> GSM123778     1  0.0000      1.000 1.000 0.000
#> GSM123780     1  0.0000      1.000 1.000 0.000
#> GSM123784     1  0.0000      1.000 1.000 0.000
#> GSM123787     1  0.0000      1.000 1.000 0.000
#> GSM123791     1  0.0000      1.000 1.000 0.000
#> GSM123795     1  0.0000      1.000 1.000 0.000
#> GSM123799     1  0.0000      1.000 1.000 0.000
#> GSM123730     1  0.0000      1.000 1.000 0.000
#> GSM123734     1  0.0000      1.000 1.000 0.000
#> GSM123738     1  0.0000      1.000 1.000 0.000
#> GSM123742     1  0.0000      1.000 1.000 0.000
#> GSM123745     1  0.0000      1.000 1.000 0.000
#> GSM123748     1  0.0000      1.000 1.000 0.000
#> GSM123751     1  0.0000      1.000 1.000 0.000
#> GSM123754     1  0.0000      1.000 1.000 0.000
#> GSM123757     1  0.0000      1.000 1.000 0.000
#> GSM123760     1  0.0000      1.000 1.000 0.000
#> GSM123762     1  0.0000      1.000 1.000 0.000
#> GSM123764     1  0.0000      1.000 1.000 0.000
#> GSM123767     1  0.0000      1.000 1.000 0.000
#> GSM123770     1  0.0000      1.000 1.000 0.000
#> GSM123773     1  0.0000      1.000 1.000 0.000
#> GSM123777     1  0.0000      1.000 1.000 0.000
#> GSM123779     1  0.0000      1.000 1.000 0.000
#> GSM123782     1  0.0000      1.000 1.000 0.000
#> GSM123786     1  0.0000      1.000 1.000 0.000
#> GSM123789     1  0.0000      1.000 1.000 0.000
#> GSM123793     1  0.0000      1.000 1.000 0.000
#> GSM123797     1  0.0000      1.000 1.000 0.000
#> GSM123729     2  0.0000      0.999 0.000 1.000
#> GSM123733     2  0.0000      0.999 0.000 1.000
#> GSM123737     2  0.0000      0.999 0.000 1.000
#> GSM123741     2  0.0000      0.999 0.000 1.000
#> GSM123747     2  0.0000      0.999 0.000 1.000
#> GSM123753     2  0.0000      0.999 0.000 1.000
#> GSM123759     2  0.0000      0.999 0.000 1.000
#> GSM123766     2  0.0000      0.999 0.000 1.000
#> GSM123772     2  0.0000      0.999 0.000 1.000
#> GSM123775     2  0.0000      0.999 0.000 1.000
#> GSM123781     2  0.0000      0.999 0.000 1.000
#> GSM123785     2  0.0000      0.999 0.000 1.000
#> GSM123788     2  0.0000      0.999 0.000 1.000
#> GSM123792     2  0.0000      0.999 0.000 1.000
#> GSM123796     2  0.0000      0.999 0.000 1.000
#> GSM123731     2  0.0000      0.999 0.000 1.000
#> GSM123735     2  0.0000      0.999 0.000 1.000
#> GSM123739     2  0.0000      0.999 0.000 1.000
#> GSM123743     2  0.0000      0.999 0.000 1.000
#> GSM123749     2  0.0000      0.999 0.000 1.000
#> GSM123755     2  0.0000      0.999 0.000 1.000
#> GSM123768     2  0.0000      0.999 0.000 1.000
#> GSM123776     1  0.0000      1.000 1.000 0.000
#> GSM123783     2  0.0672      0.992 0.008 0.992
#> GSM123790     2  0.1414      0.980 0.020 0.980
#> GSM123794     2  0.0000      0.999 0.000 1.000
#> GSM123798     2  0.0000      0.999 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
#> GSM123732     3   0.153      0.909 0.040  0 0.960
#> GSM123736     3   0.319      0.865 0.112  0 0.888
#> GSM123740     3   0.000      0.926 0.000  0 1.000
#> GSM123744     1   0.000      0.991 1.000  0 0.000
#> GSM123746     1   0.000      0.991 1.000  0 0.000
#> GSM123750     1   0.000      0.991 1.000  0 0.000
#> GSM123752     1   0.000      0.991 1.000  0 0.000
#> GSM123756     1   0.000      0.991 1.000  0 0.000
#> GSM123758     1   0.000      0.991 1.000  0 0.000
#> GSM123761     1   0.000      0.991 1.000  0 0.000
#> GSM123763     1   0.000      0.991 1.000  0 0.000
#> GSM123765     3   0.000      0.926 0.000  0 1.000
#> GSM123769     1   0.000      0.991 1.000  0 0.000
#> GSM123771     1   0.000      0.991 1.000  0 0.000
#> GSM123774     1   0.000      0.991 1.000  0 0.000
#> GSM123778     3   0.000      0.926 0.000  0 1.000
#> GSM123780     3   0.604      0.435 0.380  0 0.620
#> GSM123784     3   0.000      0.926 0.000  0 1.000
#> GSM123787     3   0.000      0.926 0.000  0 1.000
#> GSM123791     3   0.375      0.834 0.144  0 0.856
#> GSM123795     1   0.536      0.583 0.724  0 0.276
#> GSM123799     3   0.000      0.926 0.000  0 1.000
#> GSM123730     1   0.000      0.991 1.000  0 0.000
#> GSM123734     1   0.000      0.991 1.000  0 0.000
#> GSM123738     1   0.000      0.991 1.000  0 0.000
#> GSM123742     1   0.000      0.991 1.000  0 0.000
#> GSM123745     1   0.000      0.991 1.000  0 0.000
#> GSM123748     1   0.000      0.991 1.000  0 0.000
#> GSM123751     1   0.000      0.991 1.000  0 0.000
#> GSM123754     1   0.000      0.991 1.000  0 0.000
#> GSM123757     1   0.000      0.991 1.000  0 0.000
#> GSM123760     1   0.000      0.991 1.000  0 0.000
#> GSM123762     1   0.000      0.991 1.000  0 0.000
#> GSM123764     1   0.000      0.991 1.000  0 0.000
#> GSM123767     1   0.000      0.991 1.000  0 0.000
#> GSM123770     1   0.000      0.991 1.000  0 0.000
#> GSM123773     1   0.000      0.991 1.000  0 0.000
#> GSM123777     1   0.000      0.991 1.000  0 0.000
#> GSM123779     1   0.000      0.991 1.000  0 0.000
#> GSM123782     1   0.000      0.991 1.000  0 0.000
#> GSM123786     3   0.000      0.926 0.000  0 1.000
#> GSM123789     1   0.000      0.991 1.000  0 0.000
#> GSM123793     1   0.000      0.991 1.000  0 0.000
#> GSM123797     1   0.000      0.991 1.000  0 0.000
#> GSM123729     2   0.000      1.000 0.000  1 0.000
#> GSM123733     2   0.000      1.000 0.000  1 0.000
#> GSM123737     2   0.000      1.000 0.000  1 0.000
#> GSM123741     2   0.000      1.000 0.000  1 0.000
#> GSM123747     2   0.000      1.000 0.000  1 0.000
#> GSM123753     2   0.000      1.000 0.000  1 0.000
#> GSM123759     2   0.000      1.000 0.000  1 0.000
#> GSM123766     2   0.000      1.000 0.000  1 0.000
#> GSM123772     2   0.000      1.000 0.000  1 0.000
#> GSM123775     2   0.000      1.000 0.000  1 0.000
#> GSM123781     2   0.000      1.000 0.000  1 0.000
#> GSM123785     2   0.000      1.000 0.000  1 0.000
#> GSM123788     2   0.000      1.000 0.000  1 0.000
#> GSM123792     2   0.000      1.000 0.000  1 0.000
#> GSM123796     2   0.000      1.000 0.000  1 0.000
#> GSM123731     2   0.000      1.000 0.000  1 0.000
#> GSM123735     2   0.000      1.000 0.000  1 0.000
#> GSM123739     2   0.000      1.000 0.000  1 0.000
#> GSM123743     2   0.000      1.000 0.000  1 0.000
#> GSM123749     2   0.000      1.000 0.000  1 0.000
#> GSM123755     2   0.000      1.000 0.000  1 0.000
#> GSM123768     2   0.000      1.000 0.000  1 0.000
#> GSM123776     1   0.000      0.991 1.000  0 0.000
#> GSM123783     2   0.000      1.000 0.000  1 0.000
#> GSM123790     2   0.000      1.000 0.000  1 0.000
#> GSM123794     2   0.000      1.000 0.000  1 0.000
#> GSM123798     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM123732     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123736     3  0.0188      0.961 0.000  0 0.996 0.004
#> GSM123740     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123744     1  0.1118      0.925 0.964  0 0.036 0.000
#> GSM123746     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123750     1  0.1022      0.929 0.968  0 0.032 0.000
#> GSM123752     1  0.1022      0.929 0.968  0 0.032 0.000
#> GSM123756     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123758     1  0.2345      0.854 0.900  0 0.100 0.000
#> GSM123761     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123763     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123765     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123769     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123771     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123774     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123778     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123780     3  0.3494      0.784 0.004  0 0.824 0.172
#> GSM123784     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123787     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123791     3  0.1022      0.936 0.032  0 0.968 0.000
#> GSM123795     3  0.3616      0.808 0.112  0 0.852 0.036
#> GSM123799     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123730     4  0.0000      0.820 0.000  0 0.000 1.000
#> GSM123734     4  0.4277      0.701 0.280  0 0.000 0.720
#> GSM123738     4  0.0000      0.820 0.000  0 0.000 1.000
#> GSM123742     1  0.0592      0.942 0.984  0 0.000 0.016
#> GSM123745     1  0.0336      0.946 0.992  0 0.000 0.008
#> GSM123748     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123751     1  0.0469      0.944 0.988  0 0.000 0.012
#> GSM123754     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123757     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123760     1  0.4989     -0.119 0.528  0 0.000 0.472
#> GSM123762     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123764     4  0.3751      0.779 0.196  0 0.004 0.800
#> GSM123767     1  0.0592      0.942 0.984  0 0.000 0.016
#> GSM123770     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123773     1  0.0336      0.946 0.992  0 0.000 0.008
#> GSM123777     4  0.0000      0.820 0.000  0 0.000 1.000
#> GSM123779     4  0.4713      0.553 0.360  0 0.000 0.640
#> GSM123782     1  0.4283      0.584 0.740  0 0.004 0.256
#> GSM123786     3  0.0000      0.963 0.000  0 1.000 0.000
#> GSM123789     4  0.4072      0.735 0.252  0 0.000 0.748
#> GSM123793     4  0.0000      0.820 0.000  0 0.000 1.000
#> GSM123797     4  0.0000      0.820 0.000  0 0.000 1.000
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123776     1  0.0000      0.949 1.000  0 0.000 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 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
#> GSM123732     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123736     3  0.0404     0.9518 0.000 0.000 0.988 0.012 0.000
#> GSM123740     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123744     1  0.0771     0.5846 0.976 0.000 0.020 0.000 0.004
#> GSM123746     1  0.2471     0.6373 0.864 0.000 0.000 0.000 0.136
#> GSM123750     1  0.0771     0.5846 0.976 0.000 0.020 0.000 0.004
#> GSM123752     1  0.0771     0.5846 0.976 0.000 0.020 0.000 0.004
#> GSM123756     1  0.4171     0.6553 0.604 0.000 0.000 0.000 0.396
#> GSM123758     1  0.1357     0.5598 0.948 0.000 0.048 0.000 0.004
#> GSM123761     1  0.1965     0.6269 0.904 0.000 0.000 0.000 0.096
#> GSM123763     1  0.5185     0.5866 0.568 0.000 0.000 0.048 0.384
#> GSM123765     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123769     1  0.4171     0.6553 0.604 0.000 0.000 0.000 0.396
#> GSM123771     1  0.4171     0.6553 0.604 0.000 0.000 0.000 0.396
#> GSM123774     1  0.4171     0.6553 0.604 0.000 0.000 0.000 0.396
#> GSM123778     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.3160     0.7790 0.000 0.000 0.808 0.188 0.004
#> GSM123784     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123787     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.2179     0.8858 0.112 0.000 0.888 0.000 0.000
#> GSM123795     3  0.2516     0.8427 0.000 0.000 0.860 0.140 0.000
#> GSM123799     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123730     4  0.0000     0.9053 0.000 0.000 0.000 1.000 0.000
#> GSM123734     4  0.2970     0.8787 0.004 0.000 0.000 0.828 0.168
#> GSM123738     4  0.0000     0.9053 0.000 0.000 0.000 1.000 0.000
#> GSM123742     5  0.5953    -0.0712 0.384 0.000 0.000 0.112 0.504
#> GSM123745     5  0.1357     0.8160 0.004 0.000 0.000 0.048 0.948
#> GSM123748     5  0.4170     0.6246 0.192 0.000 0.000 0.048 0.760
#> GSM123751     5  0.2054     0.8164 0.028 0.000 0.000 0.052 0.920
#> GSM123754     5  0.2903     0.7848 0.080 0.000 0.000 0.048 0.872
#> GSM123757     1  0.5107     0.6252 0.596 0.000 0.000 0.048 0.356
#> GSM123760     4  0.3013     0.8831 0.008 0.000 0.000 0.832 0.160
#> GSM123762     1  0.5176     0.5958 0.572 0.000 0.000 0.048 0.380
#> GSM123764     4  0.2124     0.9079 0.004 0.000 0.000 0.900 0.096
#> GSM123767     5  0.1502     0.8106 0.004 0.000 0.000 0.056 0.940
#> GSM123770     1  0.5256     0.5145 0.532 0.000 0.000 0.048 0.420
#> GSM123773     5  0.1357     0.8160 0.004 0.000 0.000 0.048 0.948
#> GSM123777     4  0.0000     0.9053 0.000 0.000 0.000 1.000 0.000
#> GSM123779     4  0.2848     0.8881 0.004 0.000 0.000 0.840 0.156
#> GSM123782     4  0.3495     0.8838 0.036 0.000 0.008 0.836 0.120
#> GSM123786     3  0.0000     0.9578 0.000 0.000 1.000 0.000 0.000
#> GSM123789     4  0.2646     0.9019 0.004 0.000 0.004 0.868 0.124
#> GSM123793     4  0.0000     0.9053 0.000 0.000 0.000 1.000 0.000
#> GSM123797     4  0.0000     0.9053 0.000 0.000 0.000 1.000 0.000
#> GSM123729     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123733     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123741     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123781     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123739     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123743     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000
#> GSM123776     1  0.5107     0.6252 0.596 0.000 0.000 0.048 0.356
#> GSM123783     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123790     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123794     2  0.0162     0.9975 0.000 0.996 0.000 0.000 0.004
#> GSM123798     2  0.0000     0.9989 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123736     3  0.0603      0.951 0.000 0.000 0.980 0.016 0.004 0.000
#> GSM123740     3  0.0146      0.958 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM123744     5  0.3288      0.895 0.000 0.000 0.016 0.008 0.800 0.176
#> GSM123746     5  0.3713      0.815 0.008 0.000 0.000 0.004 0.704 0.284
#> GSM123750     5  0.3288      0.895 0.000 0.000 0.016 0.008 0.800 0.176
#> GSM123752     5  0.3288      0.895 0.000 0.000 0.016 0.008 0.800 0.176
#> GSM123756     6  0.1007      1.000 0.044 0.000 0.000 0.000 0.000 0.956
#> GSM123758     5  0.4490      0.794 0.000 0.000 0.108 0.004 0.716 0.172
#> GSM123761     5  0.3595      0.811 0.008 0.000 0.000 0.000 0.704 0.288
#> GSM123763     1  0.4918      0.677 0.612 0.000 0.000 0.004 0.076 0.308
#> GSM123765     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123769     6  0.1007      1.000 0.044 0.000 0.000 0.000 0.000 0.956
#> GSM123771     6  0.1007      1.000 0.044 0.000 0.000 0.000 0.000 0.956
#> GSM123774     6  0.1007      1.000 0.044 0.000 0.000 0.000 0.000 0.956
#> GSM123778     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123780     3  0.2454      0.825 0.000 0.000 0.840 0.160 0.000 0.000
#> GSM123784     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123791     3  0.2234      0.864 0.000 0.000 0.872 0.004 0.124 0.000
#> GSM123795     3  0.2325      0.878 0.000 0.000 0.884 0.100 0.008 0.008
#> GSM123799     3  0.0146      0.958 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM123730     4  0.0000      0.763 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123734     4  0.3804      0.633 0.336 0.000 0.000 0.656 0.000 0.008
#> GSM123738     4  0.0000      0.763 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123742     1  0.4981      0.702 0.680 0.000 0.000 0.116 0.016 0.188
#> GSM123745     1  0.0260      0.747 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM123748     1  0.2653      0.770 0.844 0.000 0.000 0.000 0.012 0.144
#> GSM123751     1  0.0692      0.753 0.976 0.000 0.000 0.004 0.000 0.020
#> GSM123754     1  0.1501      0.766 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM123757     1  0.4809      0.652 0.600 0.000 0.000 0.000 0.072 0.328
#> GSM123760     4  0.4400      0.462 0.428 0.000 0.004 0.552 0.004 0.012
#> GSM123762     1  0.4062      0.710 0.660 0.000 0.000 0.000 0.024 0.316
#> GSM123764     4  0.3329      0.751 0.180 0.000 0.012 0.796 0.000 0.012
#> GSM123767     1  0.0260      0.747 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM123770     1  0.3482      0.720 0.684 0.000 0.000 0.000 0.000 0.316
#> GSM123773     1  0.0260      0.747 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM123777     4  0.0000      0.763 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123779     4  0.4178      0.483 0.428 0.000 0.004 0.560 0.000 0.008
#> GSM123782     4  0.4710      0.687 0.260 0.000 0.028 0.680 0.012 0.020
#> GSM123786     3  0.0000      0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123789     4  0.3702      0.733 0.224 0.000 0.008 0.752 0.004 0.012
#> GSM123793     4  0.0000      0.763 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123797     4  0.0000      0.763 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123729     2  0.2595      0.893 0.000 0.836 0.000 0.000 0.160 0.004
#> GSM123733     2  0.1498      0.920 0.000 0.940 0.000 0.000 0.028 0.032
#> GSM123737     2  0.2482      0.900 0.000 0.848 0.000 0.000 0.148 0.004
#> GSM123741     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2  0.2815      0.904 0.000 0.848 0.000 0.000 0.120 0.032
#> GSM123772     2  0.1341      0.919 0.000 0.948 0.000 0.000 0.024 0.028
#> GSM123775     2  0.2595      0.893 0.000 0.836 0.000 0.000 0.160 0.004
#> GSM123781     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2  0.3176      0.888 0.000 0.812 0.000 0.000 0.156 0.032
#> GSM123788     2  0.1341      0.919 0.000 0.948 0.000 0.000 0.024 0.028
#> GSM123792     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2  0.1341      0.919 0.000 0.948 0.000 0.000 0.024 0.028
#> GSM123731     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0260      0.936 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123739     2  0.2595      0.893 0.000 0.836 0.000 0.000 0.160 0.004
#> GSM123743     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2  0.2402      0.902 0.000 0.856 0.000 0.000 0.140 0.004
#> GSM123776     1  0.4224      0.687 0.632 0.000 0.000 0.000 0.028 0.340
#> GSM123783     2  0.2482      0.899 0.000 0.848 0.000 0.000 0.148 0.004
#> GSM123790     2  0.2482      0.899 0.000 0.848 0.000 0.000 0.148 0.004
#> GSM123794     2  0.2191      0.910 0.000 0.876 0.000 0.000 0.120 0.004
#> GSM123798     2  0.0000      0.937 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) infection(p) agent(p) k
#> SD:mclust 71         3.04e-15     3.04e-15 5.99e-05 2
#> SD:mclust 70         1.59e-16     1.59e-16 9.67e-05 3
#> SD:mclust 70         4.14e-18     4.14e-18 3.33e-04 4
#> SD:mclust 70         5.03e-21     5.03e-21 8.80e-04 5
#> SD:mclust 69         3.18e-21     3.18e-21 2.44e-03 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 71 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 1.000           0.983       0.993         0.4800 0.522   0.522
#> 3 3 0.865           0.877       0.939         0.3840 0.794   0.611
#> 4 4 0.784           0.833       0.887         0.1023 0.899   0.706
#> 5 5 0.722           0.682       0.815         0.0525 0.934   0.766
#> 6 6 0.746           0.639       0.787         0.0314 0.958   0.829

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
#> GSM123732     1  0.0000      0.992 1.000 0.000
#> GSM123736     1  0.0000      0.992 1.000 0.000
#> GSM123740     1  0.0000      0.992 1.000 0.000
#> GSM123744     1  0.0000      0.992 1.000 0.000
#> GSM123746     1  0.0000      0.992 1.000 0.000
#> GSM123750     1  0.0000      0.992 1.000 0.000
#> GSM123752     1  0.0000      0.992 1.000 0.000
#> GSM123756     1  0.0000      0.992 1.000 0.000
#> GSM123758     1  0.0000      0.992 1.000 0.000
#> GSM123761     1  0.0000      0.992 1.000 0.000
#> GSM123763     1  0.0000      0.992 1.000 0.000
#> GSM123765     1  0.0000      0.992 1.000 0.000
#> GSM123769     1  0.0000      0.992 1.000 0.000
#> GSM123771     1  0.0000      0.992 1.000 0.000
#> GSM123774     1  0.0000      0.992 1.000 0.000
#> GSM123778     1  0.0000      0.992 1.000 0.000
#> GSM123780     1  0.0000      0.992 1.000 0.000
#> GSM123784     1  0.0000      0.992 1.000 0.000
#> GSM123787     1  0.0000      0.992 1.000 0.000
#> GSM123791     1  0.0000      0.992 1.000 0.000
#> GSM123795     1  0.0000      0.992 1.000 0.000
#> GSM123799     1  0.0000      0.992 1.000 0.000
#> GSM123730     1  0.9393      0.442 0.644 0.356
#> GSM123734     1  0.0000      0.992 1.000 0.000
#> GSM123738     1  0.0000      0.992 1.000 0.000
#> GSM123742     1  0.0000      0.992 1.000 0.000
#> GSM123745     1  0.0000      0.992 1.000 0.000
#> GSM123748     1  0.0000      0.992 1.000 0.000
#> GSM123751     1  0.0000      0.992 1.000 0.000
#> GSM123754     1  0.0000      0.992 1.000 0.000
#> GSM123757     1  0.0000      0.992 1.000 0.000
#> GSM123760     1  0.0000      0.992 1.000 0.000
#> GSM123762     1  0.0000      0.992 1.000 0.000
#> GSM123764     1  0.0000      0.992 1.000 0.000
#> GSM123767     1  0.0000      0.992 1.000 0.000
#> GSM123770     1  0.0000      0.992 1.000 0.000
#> GSM123773     1  0.0000      0.992 1.000 0.000
#> GSM123777     1  0.0000      0.992 1.000 0.000
#> GSM123779     1  0.0000      0.992 1.000 0.000
#> GSM123782     1  0.0376      0.988 0.996 0.004
#> GSM123786     1  0.0000      0.992 1.000 0.000
#> GSM123789     1  0.0000      0.992 1.000 0.000
#> GSM123793     1  0.0000      0.992 1.000 0.000
#> GSM123797     1  0.0000      0.992 1.000 0.000
#> GSM123729     2  0.0000      0.995 0.000 1.000
#> GSM123733     2  0.0000      0.995 0.000 1.000
#> GSM123737     2  0.0000      0.995 0.000 1.000
#> GSM123741     2  0.0000      0.995 0.000 1.000
#> GSM123747     2  0.0000      0.995 0.000 1.000
#> GSM123753     2  0.0000      0.995 0.000 1.000
#> GSM123759     2  0.0000      0.995 0.000 1.000
#> GSM123766     2  0.0000      0.995 0.000 1.000
#> GSM123772     2  0.0000      0.995 0.000 1.000
#> GSM123775     2  0.0000      0.995 0.000 1.000
#> GSM123781     2  0.0000      0.995 0.000 1.000
#> GSM123785     2  0.0000      0.995 0.000 1.000
#> GSM123788     2  0.0000      0.995 0.000 1.000
#> GSM123792     2  0.0000      0.995 0.000 1.000
#> GSM123796     2  0.0000      0.995 0.000 1.000
#> GSM123731     2  0.0000      0.995 0.000 1.000
#> GSM123735     2  0.0000      0.995 0.000 1.000
#> GSM123739     2  0.0000      0.995 0.000 1.000
#> GSM123743     2  0.0000      0.995 0.000 1.000
#> GSM123749     2  0.0000      0.995 0.000 1.000
#> GSM123755     2  0.0000      0.995 0.000 1.000
#> GSM123768     2  0.0000      0.995 0.000 1.000
#> GSM123776     2  0.5629      0.846 0.132 0.868
#> GSM123783     2  0.0000      0.995 0.000 1.000
#> GSM123790     2  0.0000      0.995 0.000 1.000
#> GSM123794     2  0.0000      0.995 0.000 1.000
#> GSM123798     2  0.0000      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
#> GSM123732     3  0.0000     0.8983 0.000 0.000 1.000
#> GSM123736     3  0.1031     0.9035 0.024 0.000 0.976
#> GSM123740     3  0.1031     0.9035 0.024 0.000 0.976
#> GSM123744     3  0.5529     0.5917 0.296 0.000 0.704
#> GSM123746     1  0.2066     0.8898 0.940 0.000 0.060
#> GSM123750     3  0.6008     0.4205 0.372 0.000 0.628
#> GSM123752     1  0.5138     0.6705 0.748 0.000 0.252
#> GSM123756     1  0.1031     0.9006 0.976 0.000 0.024
#> GSM123758     3  0.4521     0.7537 0.180 0.004 0.816
#> GSM123761     1  0.3816     0.8201 0.852 0.000 0.148
#> GSM123763     1  0.5785     0.5112 0.668 0.000 0.332
#> GSM123765     3  0.0424     0.9015 0.008 0.000 0.992
#> GSM123769     1  0.1163     0.9011 0.972 0.000 0.028
#> GSM123771     1  0.0424     0.8934 0.992 0.000 0.008
#> GSM123774     1  0.0237     0.8872 0.996 0.004 0.000
#> GSM123778     3  0.0237     0.8959 0.000 0.004 0.996
#> GSM123780     3  0.0237     0.9000 0.004 0.000 0.996
#> GSM123784     3  0.0592     0.9024 0.012 0.000 0.988
#> GSM123787     3  0.0000     0.8983 0.000 0.000 1.000
#> GSM123791     3  0.1289     0.9023 0.032 0.000 0.968
#> GSM123795     3  0.1163     0.9031 0.028 0.000 0.972
#> GSM123799     3  0.1163     0.9031 0.028 0.000 0.972
#> GSM123730     3  0.1636     0.8879 0.016 0.020 0.964
#> GSM123734     3  0.6307     0.0168 0.488 0.000 0.512
#> GSM123738     3  0.0747     0.9030 0.016 0.000 0.984
#> GSM123742     1  0.6235     0.2104 0.564 0.000 0.436
#> GSM123745     1  0.0892     0.8995 0.980 0.000 0.020
#> GSM123748     1  0.1529     0.8996 0.960 0.000 0.040
#> GSM123751     1  0.1529     0.9000 0.960 0.000 0.040
#> GSM123754     1  0.1643     0.8984 0.956 0.000 0.044
#> GSM123757     1  0.0592     0.8960 0.988 0.000 0.012
#> GSM123760     3  0.5016     0.6937 0.240 0.000 0.760
#> GSM123762     1  0.3879     0.8102 0.848 0.000 0.152
#> GSM123764     3  0.1411     0.9011 0.036 0.000 0.964
#> GSM123767     1  0.1129     0.8982 0.976 0.004 0.020
#> GSM123770     1  0.1031     0.9007 0.976 0.000 0.024
#> GSM123773     1  0.1289     0.9009 0.968 0.000 0.032
#> GSM123777     3  0.0592     0.9022 0.012 0.000 0.988
#> GSM123779     3  0.5497     0.5993 0.292 0.000 0.708
#> GSM123782     3  0.1753     0.8942 0.048 0.000 0.952
#> GSM123786     3  0.0000     0.8983 0.000 0.000 1.000
#> GSM123789     3  0.1860     0.8935 0.052 0.000 0.948
#> GSM123793     3  0.1529     0.8995 0.040 0.000 0.960
#> GSM123797     3  0.1411     0.9011 0.036 0.000 0.964
#> GSM123729     2  0.1129     0.9844 0.020 0.976 0.004
#> GSM123733     2  0.0237     0.9923 0.004 0.996 0.000
#> GSM123737     2  0.0592     0.9902 0.012 0.988 0.000
#> GSM123741     2  0.0000     0.9930 0.000 1.000 0.000
#> GSM123747     2  0.0237     0.9924 0.000 0.996 0.004
#> GSM123753     2  0.0475     0.9914 0.004 0.992 0.004
#> GSM123759     2  0.0237     0.9928 0.004 0.996 0.000
#> GSM123766     2  0.0237     0.9923 0.004 0.996 0.000
#> GSM123772     2  0.0237     0.9923 0.004 0.996 0.000
#> GSM123775     2  0.1289     0.9772 0.032 0.968 0.000
#> GSM123781     2  0.0000     0.9930 0.000 1.000 0.000
#> GSM123785     2  0.0475     0.9909 0.004 0.992 0.004
#> GSM123788     2  0.0000     0.9930 0.000 1.000 0.000
#> GSM123792     2  0.0000     0.9930 0.000 1.000 0.000
#> GSM123796     2  0.0237     0.9923 0.004 0.996 0.000
#> GSM123731     2  0.0237     0.9928 0.004 0.996 0.000
#> GSM123735     2  0.0237     0.9928 0.004 0.996 0.000
#> GSM123739     2  0.1031     0.9833 0.024 0.976 0.000
#> GSM123743     2  0.0000     0.9930 0.000 1.000 0.000
#> GSM123749     2  0.0237     0.9928 0.004 0.996 0.000
#> GSM123755     2  0.0237     0.9928 0.004 0.996 0.000
#> GSM123768     2  0.0829     0.9890 0.004 0.984 0.012
#> GSM123776     1  0.3340     0.7814 0.880 0.120 0.000
#> GSM123783     2  0.0829     0.9890 0.004 0.984 0.012
#> GSM123790     2  0.1399     0.9737 0.004 0.968 0.028
#> GSM123794     2  0.0475     0.9923 0.004 0.992 0.004
#> GSM123798     2  0.0475     0.9920 0.004 0.992 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.1256      0.844 0.000 0.028 0.964 0.008
#> GSM123736     3  0.1940      0.844 0.000 0.000 0.924 0.076
#> GSM123740     3  0.1452      0.864 0.008 0.000 0.956 0.036
#> GSM123744     3  0.2799      0.794 0.108 0.000 0.884 0.008
#> GSM123746     1  0.2737      0.837 0.888 0.000 0.104 0.008
#> GSM123750     3  0.4049      0.672 0.212 0.000 0.780 0.008
#> GSM123752     3  0.6602      0.238 0.388 0.040 0.548 0.024
#> GSM123756     1  0.0376      0.888 0.992 0.000 0.004 0.004
#> GSM123758     3  0.3562      0.761 0.016 0.084 0.872 0.028
#> GSM123761     1  0.4284      0.707 0.764 0.000 0.224 0.012
#> GSM123763     1  0.4692      0.713 0.756 0.000 0.212 0.032
#> GSM123765     3  0.1557      0.857 0.000 0.000 0.944 0.056
#> GSM123769     1  0.0657      0.889 0.984 0.000 0.004 0.012
#> GSM123771     1  0.0188      0.887 0.996 0.000 0.004 0.000
#> GSM123774     1  0.0188      0.887 0.996 0.000 0.004 0.000
#> GSM123778     3  0.1004      0.850 0.000 0.024 0.972 0.004
#> GSM123780     3  0.2266      0.834 0.004 0.000 0.912 0.084
#> GSM123784     3  0.1557      0.857 0.000 0.000 0.944 0.056
#> GSM123787     3  0.0336      0.859 0.000 0.008 0.992 0.000
#> GSM123791     3  0.1256      0.864 0.008 0.000 0.964 0.028
#> GSM123795     3  0.2466      0.820 0.004 0.000 0.900 0.096
#> GSM123799     3  0.1722      0.861 0.008 0.000 0.944 0.048
#> GSM123730     4  0.2313      0.701 0.000 0.032 0.044 0.924
#> GSM123734     4  0.4261      0.755 0.068 0.000 0.112 0.820
#> GSM123738     4  0.4872      0.681 0.004 0.000 0.356 0.640
#> GSM123742     4  0.7165      0.369 0.372 0.000 0.140 0.488
#> GSM123745     1  0.3356      0.802 0.824 0.000 0.000 0.176
#> GSM123748     1  0.1978      0.876 0.928 0.000 0.004 0.068
#> GSM123751     1  0.4220      0.697 0.748 0.000 0.004 0.248
#> GSM123754     1  0.2469      0.857 0.892 0.000 0.000 0.108
#> GSM123757     1  0.0188      0.887 0.996 0.000 0.004 0.000
#> GSM123760     4  0.5687      0.762 0.068 0.000 0.248 0.684
#> GSM123762     1  0.2722      0.870 0.904 0.000 0.064 0.032
#> GSM123764     4  0.5372      0.529 0.012 0.000 0.444 0.544
#> GSM123767     4  0.4877      0.145 0.408 0.000 0.000 0.592
#> GSM123770     1  0.0895      0.888 0.976 0.000 0.004 0.020
#> GSM123773     1  0.3219      0.814 0.836 0.000 0.000 0.164
#> GSM123777     4  0.3873      0.769 0.000 0.000 0.228 0.772
#> GSM123779     4  0.3013      0.742 0.032 0.000 0.080 0.888
#> GSM123782     4  0.5352      0.738 0.020 0.008 0.296 0.676
#> GSM123786     3  0.0524      0.859 0.004 0.008 0.988 0.000
#> GSM123789     4  0.5465      0.630 0.020 0.000 0.392 0.588
#> GSM123793     4  0.4364      0.776 0.016 0.000 0.220 0.764
#> GSM123797     4  0.4011      0.775 0.008 0.000 0.208 0.784
#> GSM123729     2  0.1786      0.952 0.008 0.948 0.008 0.036
#> GSM123733     2  0.1716      0.951 0.000 0.936 0.000 0.064
#> GSM123737     2  0.1022      0.960 0.000 0.968 0.000 0.032
#> GSM123741     2  0.0592      0.963 0.000 0.984 0.000 0.016
#> GSM123747     2  0.0992      0.960 0.004 0.976 0.008 0.012
#> GSM123753     2  0.1042      0.959 0.000 0.972 0.008 0.020
#> GSM123759     2  0.1042      0.959 0.000 0.972 0.008 0.020
#> GSM123766     2  0.1867      0.947 0.000 0.928 0.000 0.072
#> GSM123772     2  0.1211      0.959 0.000 0.960 0.000 0.040
#> GSM123775     2  0.1677      0.959 0.012 0.948 0.000 0.040
#> GSM123781     2  0.0895      0.963 0.000 0.976 0.004 0.020
#> GSM123785     2  0.3074      0.886 0.000 0.848 0.000 0.152
#> GSM123788     2  0.1557      0.954 0.000 0.944 0.000 0.056
#> GSM123792     2  0.0188      0.963 0.000 0.996 0.000 0.004
#> GSM123796     2  0.1716      0.951 0.000 0.936 0.000 0.064
#> GSM123731     2  0.0927      0.960 0.000 0.976 0.008 0.016
#> GSM123735     2  0.1022      0.960 0.000 0.968 0.000 0.032
#> GSM123739     2  0.1824      0.955 0.004 0.936 0.000 0.060
#> GSM123743     2  0.0336      0.963 0.000 0.992 0.000 0.008
#> GSM123749     2  0.1109      0.959 0.000 0.968 0.004 0.028
#> GSM123755     2  0.1151      0.958 0.000 0.968 0.008 0.024
#> GSM123768     2  0.2494      0.930 0.000 0.916 0.048 0.036
#> GSM123776     1  0.1706      0.859 0.948 0.036 0.000 0.016
#> GSM123783     2  0.3016      0.916 0.004 0.896 0.060 0.040
#> GSM123790     2  0.1762      0.957 0.004 0.944 0.004 0.048
#> GSM123794     2  0.1339      0.957 0.004 0.964 0.008 0.024
#> GSM123798     2  0.1388      0.956 0.000 0.960 0.012 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
#> GSM123732     3  0.1836     0.7664 0.008 0.000 0.936 0.016 0.040
#> GSM123736     3  0.4627     0.7131 0.020 0.000 0.760 0.056 0.164
#> GSM123740     3  0.4245     0.7515 0.028 0.000 0.800 0.048 0.124
#> GSM123744     3  0.5049     0.6400 0.148 0.000 0.732 0.104 0.016
#> GSM123746     1  0.4555     0.6198 0.776 0.000 0.112 0.096 0.016
#> GSM123750     3  0.6151     0.5076 0.232 0.000 0.620 0.120 0.028
#> GSM123752     1  0.6234     0.0340 0.476 0.012 0.436 0.016 0.060
#> GSM123756     1  0.0727     0.7168 0.980 0.000 0.004 0.012 0.004
#> GSM123758     3  0.4669     0.6677 0.052 0.024 0.792 0.020 0.112
#> GSM123761     1  0.6433     0.3004 0.516 0.000 0.184 0.296 0.004
#> GSM123763     1  0.6886     0.0595 0.436 0.000 0.144 0.392 0.028
#> GSM123765     3  0.3190     0.7522 0.012 0.000 0.840 0.008 0.140
#> GSM123769     1  0.1074     0.7157 0.968 0.000 0.012 0.016 0.004
#> GSM123771     1  0.0955     0.7168 0.968 0.000 0.004 0.028 0.000
#> GSM123774     1  0.0566     0.7157 0.984 0.000 0.000 0.012 0.004
#> GSM123778     3  0.1087     0.7713 0.008 0.000 0.968 0.016 0.008
#> GSM123780     3  0.3086     0.7119 0.000 0.000 0.816 0.004 0.180
#> GSM123784     3  0.3001     0.7510 0.004 0.000 0.844 0.008 0.144
#> GSM123787     3  0.2491     0.7598 0.004 0.004 0.904 0.064 0.024
#> GSM123791     3  0.3658     0.7496 0.016 0.000 0.832 0.116 0.036
#> GSM123795     3  0.5591     0.6034 0.016 0.000 0.668 0.104 0.212
#> GSM123799     3  0.3734     0.7588 0.020 0.000 0.824 0.028 0.128
#> GSM123730     5  0.5326     0.6054 0.000 0.028 0.064 0.212 0.696
#> GSM123734     4  0.4691     0.2057 0.004 0.000 0.020 0.636 0.340
#> GSM123738     5  0.5909     0.5245 0.004 0.000 0.352 0.100 0.544
#> GSM123742     4  0.2707     0.5873 0.080 0.000 0.024 0.888 0.008
#> GSM123745     4  0.5345     0.3284 0.404 0.000 0.000 0.540 0.056
#> GSM123748     4  0.4101     0.3801 0.372 0.000 0.000 0.628 0.000
#> GSM123751     4  0.5341     0.3773 0.376 0.000 0.000 0.564 0.060
#> GSM123754     1  0.3133     0.6692 0.864 0.000 0.004 0.052 0.080
#> GSM123757     1  0.2054     0.6998 0.916 0.000 0.004 0.072 0.008
#> GSM123760     4  0.2599     0.5752 0.044 0.000 0.024 0.904 0.028
#> GSM123762     4  0.5050    -0.0663 0.476 0.000 0.024 0.496 0.004
#> GSM123764     4  0.2899     0.5321 0.008 0.000 0.076 0.880 0.036
#> GSM123767     1  0.6889    -0.1478 0.396 0.000 0.004 0.272 0.328
#> GSM123770     1  0.1124     0.7130 0.960 0.000 0.000 0.036 0.004
#> GSM123773     1  0.3705     0.6312 0.816 0.000 0.000 0.064 0.120
#> GSM123777     5  0.5386     0.6884 0.000 0.008 0.276 0.072 0.644
#> GSM123779     5  0.6024     0.5590 0.016 0.016 0.080 0.252 0.636
#> GSM123782     4  0.3727     0.5219 0.004 0.000 0.068 0.824 0.104
#> GSM123786     3  0.3012     0.7347 0.000 0.004 0.872 0.052 0.072
#> GSM123789     4  0.5811     0.1719 0.004 0.000 0.120 0.604 0.272
#> GSM123793     4  0.5448     0.0450 0.000 0.000 0.076 0.584 0.340
#> GSM123797     5  0.5818     0.7064 0.004 0.000 0.196 0.172 0.628
#> GSM123729     2  0.0898     0.9412 0.008 0.972 0.000 0.000 0.020
#> GSM123733     2  0.1671     0.9238 0.000 0.924 0.000 0.000 0.076
#> GSM123737     2  0.1124     0.9377 0.004 0.960 0.000 0.000 0.036
#> GSM123741     2  0.1121     0.9376 0.000 0.956 0.000 0.000 0.044
#> GSM123747     2  0.1538     0.9405 0.000 0.948 0.008 0.008 0.036
#> GSM123753     2  0.2179     0.9236 0.000 0.912 0.008 0.008 0.072
#> GSM123759     2  0.1731     0.9298 0.000 0.932 0.004 0.004 0.060
#> GSM123766     2  0.1597     0.9394 0.000 0.940 0.000 0.012 0.048
#> GSM123772     2  0.1251     0.9391 0.000 0.956 0.000 0.008 0.036
#> GSM123775     2  0.0771     0.9422 0.004 0.976 0.000 0.000 0.020
#> GSM123781     2  0.2722     0.9014 0.000 0.872 0.000 0.020 0.108
#> GSM123785     2  0.2411     0.9015 0.000 0.884 0.000 0.008 0.108
#> GSM123788     2  0.1410     0.9307 0.000 0.940 0.000 0.000 0.060
#> GSM123792     2  0.0703     0.9390 0.000 0.976 0.000 0.000 0.024
#> GSM123796     2  0.1341     0.9321 0.000 0.944 0.000 0.000 0.056
#> GSM123731     2  0.1059     0.9420 0.000 0.968 0.004 0.008 0.020
#> GSM123735     2  0.1410     0.9306 0.000 0.940 0.000 0.000 0.060
#> GSM123739     2  0.1484     0.9354 0.008 0.944 0.000 0.000 0.048
#> GSM123743     2  0.0510     0.9414 0.000 0.984 0.000 0.000 0.016
#> GSM123749     2  0.1502     0.9319 0.000 0.940 0.000 0.004 0.056
#> GSM123755     2  0.2228     0.9238 0.000 0.912 0.008 0.012 0.068
#> GSM123768     2  0.3632     0.8603 0.000 0.816 0.016 0.016 0.152
#> GSM123776     1  0.2908     0.6170 0.868 0.108 0.000 0.008 0.016
#> GSM123783     2  0.4311     0.8318 0.000 0.788 0.044 0.024 0.144
#> GSM123790     2  0.3022     0.8725 0.000 0.848 0.012 0.004 0.136
#> GSM123794     2  0.1699     0.9396 0.004 0.944 0.008 0.008 0.036
#> GSM123798     2  0.2574     0.9175 0.004 0.896 0.008 0.012 0.080

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.2089     0.6163 0.000 0.004 0.908 0.072 0.012 0.004
#> GSM123736     5  0.5723     0.1286 0.024 0.000 0.376 0.072 0.520 0.008
#> GSM123740     5  0.5343    -0.0822 0.012 0.000 0.456 0.060 0.468 0.004
#> GSM123744     3  0.5638     0.4153 0.052 0.000 0.616 0.000 0.244 0.088
#> GSM123746     1  0.5708     0.5659 0.668 0.000 0.144 0.012 0.064 0.112
#> GSM123750     3  0.6307     0.3410 0.108 0.000 0.568 0.000 0.220 0.104
#> GSM123752     3  0.6412     0.2950 0.296 0.008 0.552 0.036 0.080 0.028
#> GSM123756     1  0.1003     0.8332 0.964 0.000 0.004 0.000 0.028 0.004
#> GSM123758     3  0.3458     0.5670 0.016 0.004 0.844 0.052 0.076 0.008
#> GSM123761     5  0.6708     0.1367 0.176 0.000 0.076 0.000 0.488 0.260
#> GSM123763     5  0.5727     0.1937 0.084 0.000 0.056 0.000 0.600 0.260
#> GSM123765     3  0.5135     0.4505 0.004 0.000 0.656 0.164 0.172 0.004
#> GSM123769     1  0.1429     0.8286 0.940 0.000 0.004 0.000 0.052 0.004
#> GSM123771     1  0.1296     0.8297 0.948 0.000 0.004 0.000 0.044 0.004
#> GSM123774     1  0.0405     0.8326 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM123778     3  0.1690     0.6229 0.000 0.004 0.940 0.020 0.020 0.016
#> GSM123780     3  0.4039     0.5128 0.000 0.000 0.724 0.232 0.040 0.004
#> GSM123784     3  0.4275     0.5573 0.004 0.000 0.756 0.156 0.072 0.012
#> GSM123787     3  0.2978     0.6007 0.000 0.000 0.856 0.008 0.084 0.052
#> GSM123791     3  0.5693     0.0761 0.004 0.000 0.476 0.020 0.420 0.080
#> GSM123795     5  0.5654     0.2534 0.016 0.000 0.296 0.084 0.588 0.016
#> GSM123799     3  0.5337     0.1422 0.016 0.000 0.540 0.072 0.372 0.000
#> GSM123730     4  0.3387     0.6340 0.000 0.004 0.024 0.836 0.032 0.104
#> GSM123734     6  0.6039     0.1052 0.004 0.000 0.000 0.228 0.316 0.452
#> GSM123738     4  0.6556     0.3002 0.000 0.000 0.156 0.428 0.364 0.052
#> GSM123742     6  0.2360     0.6143 0.024 0.000 0.008 0.020 0.040 0.908
#> GSM123745     6  0.5410     0.5068 0.224 0.000 0.000 0.148 0.012 0.616
#> GSM123748     6  0.3720     0.5887 0.196 0.000 0.000 0.016 0.020 0.768
#> GSM123751     6  0.5995     0.4473 0.268 0.000 0.000 0.140 0.036 0.556
#> GSM123754     1  0.2587     0.8021 0.888 0.000 0.004 0.068 0.012 0.028
#> GSM123757     1  0.2638     0.8066 0.888 0.000 0.012 0.012 0.020 0.068
#> GSM123760     6  0.2734     0.5948 0.024 0.000 0.008 0.000 0.104 0.864
#> GSM123762     6  0.6404     0.1736 0.236 0.000 0.020 0.000 0.320 0.424
#> GSM123764     6  0.3059     0.5948 0.000 0.000 0.072 0.028 0.040 0.860
#> GSM123767     1  0.5913     0.2222 0.480 0.000 0.000 0.356 0.012 0.152
#> GSM123770     1  0.0551     0.8336 0.984 0.000 0.000 0.004 0.004 0.008
#> GSM123773     1  0.3314     0.7489 0.816 0.000 0.000 0.144 0.008 0.032
#> GSM123777     4  0.4366     0.6255 0.000 0.000 0.168 0.748 0.048 0.036
#> GSM123779     4  0.4318     0.5456 0.012 0.004 0.028 0.756 0.020 0.180
#> GSM123782     6  0.4960     0.5531 0.004 0.004 0.100 0.072 0.080 0.740
#> GSM123786     3  0.2252     0.6055 0.000 0.000 0.908 0.028 0.020 0.044
#> GSM123789     6  0.6729     0.2571 0.000 0.000 0.116 0.252 0.128 0.504
#> GSM123793     5  0.5830    -0.0833 0.000 0.000 0.008 0.156 0.492 0.344
#> GSM123797     4  0.6090     0.5929 0.000 0.000 0.064 0.572 0.248 0.116
#> GSM123729     2  0.1313     0.9405 0.004 0.952 0.000 0.016 0.028 0.000
#> GSM123733     2  0.2493     0.9076 0.004 0.884 0.000 0.076 0.036 0.000
#> GSM123737     2  0.1080     0.9385 0.004 0.960 0.000 0.004 0.032 0.000
#> GSM123741     2  0.0665     0.9390 0.000 0.980 0.000 0.008 0.008 0.004
#> GSM123747     2  0.0717     0.9413 0.000 0.976 0.000 0.016 0.008 0.000
#> GSM123753     2  0.1485     0.9283 0.000 0.944 0.000 0.024 0.028 0.004
#> GSM123759     2  0.1138     0.9348 0.000 0.960 0.000 0.024 0.012 0.004
#> GSM123766     2  0.1232     0.9387 0.000 0.956 0.000 0.016 0.024 0.004
#> GSM123772     2  0.0767     0.9396 0.000 0.976 0.000 0.008 0.012 0.004
#> GSM123775     2  0.1346     0.9397 0.016 0.952 0.000 0.008 0.024 0.000
#> GSM123781     2  0.3052     0.8897 0.000 0.868 0.008 0.048 0.056 0.020
#> GSM123785     2  0.2487     0.9010 0.000 0.876 0.000 0.092 0.032 0.000
#> GSM123788     2  0.2119     0.9182 0.000 0.904 0.000 0.060 0.036 0.000
#> GSM123792     2  0.0891     0.9397 0.000 0.968 0.000 0.008 0.024 0.000
#> GSM123796     2  0.1498     0.9334 0.000 0.940 0.000 0.032 0.028 0.000
#> GSM123731     2  0.0508     0.9409 0.000 0.984 0.000 0.004 0.012 0.000
#> GSM123735     2  0.2078     0.9236 0.004 0.912 0.000 0.044 0.040 0.000
#> GSM123739     2  0.1296     0.9377 0.004 0.952 0.000 0.012 0.032 0.000
#> GSM123743     2  0.0260     0.9400 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123749     2  0.0914     0.9353 0.000 0.968 0.000 0.016 0.016 0.000
#> GSM123755     2  0.1710     0.9249 0.000 0.936 0.004 0.028 0.028 0.004
#> GSM123768     2  0.4022     0.8314 0.000 0.808 0.044 0.072 0.068 0.008
#> GSM123776     1  0.3434     0.7261 0.840 0.084 0.004 0.008 0.056 0.008
#> GSM123783     2  0.4743     0.7603 0.000 0.748 0.112 0.072 0.064 0.004
#> GSM123790     2  0.3382     0.8538 0.000 0.820 0.008 0.124 0.048 0.000
#> GSM123794     2  0.1492     0.9357 0.000 0.940 0.000 0.024 0.036 0.000
#> GSM123798     2  0.1977     0.9184 0.000 0.920 0.008 0.040 0.032 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-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) infection(p) agent(p) k
#> SD:NMF 70         6.31e-16     6.31e-16 7.57e-06 2
#> SD:NMF 68         3.48e-13     3.48e-13 1.34e-04 3
#> SD:NMF 68         1.48e-19     1.48e-19 4.65e-04 4
#> SD:NMF 60         1.21e-16     1.21e-16 5.34e-03 5
#> SD:NMF 53         2.41e-13     2.41e-13 2.03e-02 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.499           0.750       0.856         0.2633 0.892   0.892
#> 3 3 0.532           0.798       0.892         0.8167 0.602   0.553
#> 4 4 0.562           0.737       0.865         0.1245 0.999   0.998
#> 5 5 0.520           0.607       0.836         0.0732 0.913   0.825
#> 6 6 0.573           0.578       0.802         0.0855 0.915   0.797

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
#> GSM123732     1  0.3274      0.818 0.940 0.060
#> GSM123736     1  0.9710      0.504 0.600 0.400
#> GSM123740     1  0.9710      0.504 0.600 0.400
#> GSM123744     1  0.8267      0.714 0.740 0.260
#> GSM123746     1  0.8813      0.684 0.700 0.300
#> GSM123750     1  0.8813      0.685 0.700 0.300
#> GSM123752     1  0.8555      0.700 0.720 0.280
#> GSM123756     1  0.9710      0.576 0.600 0.400
#> GSM123758     1  0.8555      0.700 0.720 0.280
#> GSM123761     1  0.9552      0.608 0.624 0.376
#> GSM123763     1  0.8661      0.694 0.712 0.288
#> GSM123765     1  0.2778      0.820 0.952 0.048
#> GSM123769     1  0.9710      0.576 0.600 0.400
#> GSM123771     1  0.9710      0.576 0.600 0.400
#> GSM123774     1  0.9710      0.576 0.600 0.400
#> GSM123778     1  0.2778      0.820 0.952 0.048
#> GSM123780     1  0.2236      0.823 0.964 0.036
#> GSM123784     1  0.2778      0.820 0.952 0.048
#> GSM123787     1  0.3274      0.817 0.940 0.060
#> GSM123791     1  0.4161      0.808 0.916 0.084
#> GSM123795     1  0.9710      0.504 0.600 0.400
#> GSM123799     1  0.9710      0.504 0.600 0.400
#> GSM123730     1  0.0672      0.824 0.992 0.008
#> GSM123734     2  0.0000      0.937 0.000 1.000
#> GSM123738     2  0.3879      0.930 0.076 0.924
#> GSM123742     1  0.9427      0.627 0.640 0.360
#> GSM123745     1  0.9710      0.576 0.600 0.400
#> GSM123748     1  0.9552      0.608 0.624 0.376
#> GSM123751     1  0.9710      0.576 0.600 0.400
#> GSM123754     1  0.9661      0.587 0.608 0.392
#> GSM123757     1  0.8763      0.688 0.704 0.296
#> GSM123760     1  0.9460      0.622 0.636 0.364
#> GSM123762     1  0.9732      0.570 0.596 0.404
#> GSM123764     1  0.2948      0.820 0.948 0.052
#> GSM123767     1  0.9661      0.587 0.608 0.392
#> GSM123770     1  0.9661      0.587 0.608 0.392
#> GSM123773     1  0.9661      0.587 0.608 0.392
#> GSM123777     1  0.0672      0.824 0.992 0.008
#> GSM123779     1  0.0672      0.824 0.992 0.008
#> GSM123782     1  0.2778      0.821 0.952 0.048
#> GSM123786     1  0.2778      0.820 0.952 0.048
#> GSM123789     1  0.1414      0.825 0.980 0.020
#> GSM123793     2  0.0376      0.938 0.004 0.996
#> GSM123797     2  0.3733      0.933 0.072 0.928
#> GSM123729     1  0.0000      0.825 1.000 0.000
#> GSM123733     1  0.0000      0.825 1.000 0.000
#> GSM123737     1  0.0000      0.825 1.000 0.000
#> GSM123741     1  0.0000      0.825 1.000 0.000
#> GSM123747     1  0.0000      0.825 1.000 0.000
#> GSM123753     1  0.0000      0.825 1.000 0.000
#> GSM123759     1  0.0000      0.825 1.000 0.000
#> GSM123766     1  0.0000      0.825 1.000 0.000
#> GSM123772     1  0.0000      0.825 1.000 0.000
#> GSM123775     1  0.0000      0.825 1.000 0.000
#> GSM123781     1  0.0000      0.825 1.000 0.000
#> GSM123785     1  0.0000      0.825 1.000 0.000
#> GSM123788     1  0.0000      0.825 1.000 0.000
#> GSM123792     1  0.0000      0.825 1.000 0.000
#> GSM123796     1  0.0000      0.825 1.000 0.000
#> GSM123731     1  0.0000      0.825 1.000 0.000
#> GSM123735     1  0.0000      0.825 1.000 0.000
#> GSM123739     1  0.0000      0.825 1.000 0.000
#> GSM123743     1  0.0000      0.825 1.000 0.000
#> GSM123749     1  0.0000      0.825 1.000 0.000
#> GSM123755     1  0.0000      0.825 1.000 0.000
#> GSM123768     1  0.0000      0.825 1.000 0.000
#> GSM123776     1  0.1633      0.824 0.976 0.024
#> GSM123783     1  0.0000      0.825 1.000 0.000
#> GSM123790     1  0.0000      0.825 1.000 0.000
#> GSM123794     1  0.0000      0.825 1.000 0.000
#> GSM123798     1  0.0000      0.825 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
#> GSM123732     2  0.5760      0.378 0.328 0.672 0.000
#> GSM123736     2  0.8705      0.289 0.116 0.524 0.360
#> GSM123740     2  0.8705      0.289 0.116 0.524 0.360
#> GSM123744     1  0.6252      0.450 0.556 0.444 0.000
#> GSM123746     1  0.6111      0.561 0.604 0.396 0.000
#> GSM123750     1  0.6140      0.546 0.596 0.404 0.000
#> GSM123752     1  0.6180      0.520 0.584 0.416 0.000
#> GSM123756     1  0.2711      0.800 0.912 0.088 0.000
#> GSM123758     1  0.6192      0.512 0.580 0.420 0.000
#> GSM123761     1  0.3116      0.806 0.892 0.108 0.000
#> GSM123763     1  0.4605      0.705 0.796 0.204 0.000
#> GSM123765     2  0.3192      0.824 0.112 0.888 0.000
#> GSM123769     1  0.2625      0.797 0.916 0.084 0.000
#> GSM123771     1  0.2625      0.797 0.916 0.084 0.000
#> GSM123774     1  0.2711      0.800 0.912 0.088 0.000
#> GSM123778     2  0.3192      0.824 0.112 0.888 0.000
#> GSM123780     2  0.2772      0.855 0.080 0.916 0.004
#> GSM123784     2  0.3192      0.824 0.112 0.888 0.000
#> GSM123787     2  0.3551      0.800 0.132 0.868 0.000
#> GSM123791     2  0.4121      0.749 0.168 0.832 0.000
#> GSM123795     2  0.8705      0.289 0.116 0.524 0.360
#> GSM123799     2  0.8745      0.293 0.120 0.524 0.356
#> GSM123730     2  0.0661      0.907 0.004 0.988 0.008
#> GSM123734     3  0.0237      0.928 0.004 0.000 0.996
#> GSM123738     3  0.3234      0.922 0.020 0.072 0.908
#> GSM123742     1  0.4110      0.791 0.844 0.152 0.004
#> GSM123745     1  0.2878      0.801 0.904 0.096 0.000
#> GSM123748     1  0.3340      0.806 0.880 0.120 0.000
#> GSM123751     1  0.2711      0.798 0.912 0.088 0.000
#> GSM123754     1  0.3038      0.807 0.896 0.104 0.000
#> GSM123757     1  0.6126      0.553 0.600 0.400 0.000
#> GSM123760     1  0.4351      0.778 0.828 0.168 0.004
#> GSM123762     1  0.0424      0.653 0.992 0.000 0.008
#> GSM123764     2  0.1964      0.879 0.056 0.944 0.000
#> GSM123767     1  0.3038      0.807 0.896 0.104 0.000
#> GSM123770     1  0.3038      0.807 0.896 0.104 0.000
#> GSM123773     1  0.3038      0.807 0.896 0.104 0.000
#> GSM123777     2  0.0661      0.907 0.004 0.988 0.008
#> GSM123779     2  0.0829      0.904 0.012 0.984 0.004
#> GSM123782     2  0.2066      0.877 0.060 0.940 0.000
#> GSM123786     2  0.2878      0.840 0.096 0.904 0.000
#> GSM123789     2  0.1163      0.899 0.028 0.972 0.000
#> GSM123793     3  0.0000      0.928 0.000 0.000 1.000
#> GSM123797     3  0.3141      0.927 0.020 0.068 0.912
#> GSM123729     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123733     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123737     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123741     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123747     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123753     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123775     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123781     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123785     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123788     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123792     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123796     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123731     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123735     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123739     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123743     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123776     2  0.1163      0.898 0.028 0.972 0.000
#> GSM123783     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123790     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123794     2  0.0000      0.913 0.000 1.000 0.000
#> GSM123798     2  0.0000      0.913 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     2  0.7045      0.191 0.352 0.528 0.116 0.004
#> GSM123736     2  0.8466      0.154 0.120 0.436 0.072 0.372
#> GSM123740     2  0.8466      0.154 0.120 0.436 0.072 0.372
#> GSM123744     1  0.6979      0.504 0.556 0.320 0.120 0.004
#> GSM123746     1  0.6618      0.573 0.608 0.284 0.104 0.004
#> GSM123750     1  0.6661      0.564 0.600 0.292 0.104 0.004
#> GSM123752     1  0.6751      0.555 0.588 0.300 0.108 0.004
#> GSM123756     1  0.1042      0.765 0.972 0.020 0.008 0.000
#> GSM123758     1  0.6770      0.551 0.584 0.304 0.108 0.004
#> GSM123761     1  0.2861      0.748 0.888 0.016 0.096 0.000
#> GSM123763     1  0.5971      0.624 0.704 0.124 0.168 0.004
#> GSM123765     2  0.5193      0.726 0.116 0.768 0.112 0.004
#> GSM123769     1  0.0927      0.761 0.976 0.016 0.008 0.000
#> GSM123771     1  0.1059      0.762 0.972 0.016 0.012 0.000
#> GSM123774     1  0.1042      0.765 0.972 0.020 0.008 0.000
#> GSM123778     2  0.5193      0.726 0.116 0.768 0.112 0.004
#> GSM123780     2  0.4496      0.777 0.084 0.820 0.088 0.008
#> GSM123784     2  0.5193      0.726 0.116 0.768 0.112 0.004
#> GSM123787     2  0.5613      0.691 0.128 0.736 0.132 0.004
#> GSM123791     2  0.6248      0.610 0.172 0.680 0.144 0.004
#> GSM123795     2  0.8466      0.154 0.120 0.436 0.072 0.372
#> GSM123799     2  0.8513      0.158 0.120 0.436 0.076 0.368
#> GSM123730     2  0.2040      0.852 0.004 0.936 0.012 0.048
#> GSM123734     3  0.4585      0.000 0.000 0.000 0.668 0.332
#> GSM123738     4  0.1296      0.876 0.004 0.028 0.004 0.964
#> GSM123742     1  0.3944      0.750 0.848 0.068 0.080 0.004
#> GSM123745     1  0.2111      0.752 0.932 0.044 0.024 0.000
#> GSM123748     1  0.2578      0.767 0.912 0.036 0.052 0.000
#> GSM123751     1  0.1624      0.760 0.952 0.028 0.020 0.000
#> GSM123754     1  0.1302      0.770 0.956 0.044 0.000 0.000
#> GSM123757     1  0.6503      0.570 0.612 0.292 0.092 0.004
#> GSM123760     1  0.4783      0.730 0.804 0.072 0.112 0.012
#> GSM123762     1  0.3925      0.573 0.808 0.000 0.176 0.016
#> GSM123764     2  0.3462      0.815 0.020 0.860 0.116 0.004
#> GSM123767     1  0.1302      0.770 0.956 0.044 0.000 0.000
#> GSM123770     1  0.1302      0.770 0.956 0.044 0.000 0.000
#> GSM123773     1  0.1302      0.770 0.956 0.044 0.000 0.000
#> GSM123777     2  0.2040      0.852 0.004 0.936 0.012 0.048
#> GSM123779     2  0.1139      0.873 0.012 0.972 0.008 0.008
#> GSM123782     2  0.3619      0.816 0.036 0.860 0.100 0.004
#> GSM123786     2  0.4844      0.750 0.092 0.792 0.112 0.004
#> GSM123789     2  0.2500      0.847 0.040 0.916 0.044 0.000
#> GSM123793     4  0.2216      0.725 0.000 0.000 0.092 0.908
#> GSM123797     4  0.1109      0.877 0.004 0.028 0.000 0.968
#> GSM123729     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123733     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123737     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123741     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123753     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123766     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123781     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123785     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123788     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123792     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123796     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123731     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123735     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123739     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123743     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123768     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123776     2  0.1109      0.869 0.028 0.968 0.000 0.004
#> GSM123783     2  0.0336      0.881 0.000 0.992 0.008 0.000
#> GSM123790     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123794     2  0.0000      0.884 0.000 1.000 0.000 0.000
#> GSM123798     2  0.0000      0.884 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     2  0.6820     -0.139 0.348 0.408 0.000 0.004 0.240
#> GSM123736     3  0.7857      0.496 0.116 0.364 0.376 0.000 0.144
#> GSM123740     3  0.7857      0.496 0.116 0.364 0.376 0.000 0.144
#> GSM123744     1  0.6353      0.280 0.544 0.252 0.000 0.004 0.200
#> GSM123746     1  0.5957      0.351 0.604 0.232 0.000 0.004 0.160
#> GSM123750     1  0.5918      0.335 0.592 0.240 0.000 0.000 0.168
#> GSM123752     1  0.6113      0.336 0.584 0.232 0.000 0.004 0.180
#> GSM123756     1  0.0510      0.614 0.984 0.000 0.000 0.000 0.016
#> GSM123758     1  0.6135      0.332 0.580 0.236 0.000 0.004 0.180
#> GSM123761     1  0.3039      0.520 0.836 0.000 0.000 0.012 0.152
#> GSM123763     5  0.5890      0.287 0.400 0.076 0.004 0.004 0.516
#> GSM123765     2  0.5530      0.453 0.108 0.644 0.000 0.004 0.244
#> GSM123769     1  0.0609      0.612 0.980 0.000 0.000 0.000 0.020
#> GSM123771     1  0.0771      0.612 0.976 0.000 0.000 0.004 0.020
#> GSM123774     1  0.0510      0.614 0.984 0.000 0.000 0.000 0.016
#> GSM123778     2  0.5530      0.453 0.108 0.644 0.000 0.004 0.244
#> GSM123780     2  0.4921      0.582 0.084 0.724 0.008 0.000 0.184
#> GSM123784     2  0.5530      0.453 0.108 0.644 0.000 0.004 0.244
#> GSM123787     2  0.5810      0.375 0.124 0.608 0.000 0.004 0.264
#> GSM123791     2  0.6097      0.241 0.168 0.556 0.000 0.000 0.276
#> GSM123795     3  0.7857      0.496 0.116 0.364 0.376 0.000 0.144
#> GSM123799     3  0.7881      0.493 0.116 0.364 0.372 0.000 0.148
#> GSM123730     2  0.2208      0.802 0.000 0.908 0.072 0.000 0.020
#> GSM123734     4  0.0794      0.000 0.000 0.000 0.028 0.972 0.000
#> GSM123738     3  0.0404     -0.118 0.000 0.012 0.988 0.000 0.000
#> GSM123742     1  0.3415      0.550 0.840 0.028 0.004 0.004 0.124
#> GSM123745     1  0.1741      0.569 0.936 0.024 0.000 0.000 0.040
#> GSM123748     1  0.2110      0.600 0.912 0.016 0.000 0.000 0.072
#> GSM123751     1  0.1267      0.601 0.960 0.012 0.000 0.004 0.024
#> GSM123754     1  0.0703      0.621 0.976 0.024 0.000 0.000 0.000
#> GSM123757     1  0.5933      0.350 0.608 0.228 0.000 0.004 0.160
#> GSM123760     1  0.4279      0.465 0.772 0.028 0.008 0.008 0.184
#> GSM123762     5  0.4774      0.212 0.308 0.000 0.012 0.020 0.660
#> GSM123764     2  0.3737      0.659 0.008 0.764 0.000 0.004 0.224
#> GSM123767     1  0.0703      0.621 0.976 0.024 0.000 0.000 0.000
#> GSM123770     1  0.0703      0.621 0.976 0.024 0.000 0.000 0.000
#> GSM123773     1  0.0703      0.621 0.976 0.024 0.000 0.000 0.000
#> GSM123777     2  0.2208      0.802 0.000 0.908 0.072 0.000 0.020
#> GSM123779     2  0.1200      0.850 0.012 0.964 0.008 0.000 0.016
#> GSM123782     2  0.4052      0.660 0.028 0.764 0.000 0.004 0.204
#> GSM123786     2  0.5269      0.497 0.088 0.668 0.000 0.004 0.240
#> GSM123789     2  0.3130      0.760 0.048 0.856 0.000 0.000 0.096
#> GSM123793     3  0.2905     -0.225 0.000 0.000 0.868 0.096 0.036
#> GSM123797     3  0.0566     -0.119 0.000 0.012 0.984 0.004 0.000
#> GSM123729     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123781     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123776     2  0.1041      0.843 0.032 0.964 0.000 0.000 0.004
#> GSM123783     2  0.0609      0.857 0.000 0.980 0.000 0.000 0.020
#> GSM123790     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2  0.0000      0.869 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.6077     0.4032 0.300 0.248 0.448 0.000 0.000 0.004
#> GSM123736     4  0.7037     0.2176 0.072 0.232 0.320 0.376 0.000 0.000
#> GSM123740     4  0.7037     0.2176 0.072 0.232 0.320 0.376 0.000 0.000
#> GSM123744     1  0.6224     0.2601 0.488 0.156 0.324 0.000 0.000 0.032
#> GSM123746     1  0.6022     0.3883 0.548 0.152 0.268 0.000 0.000 0.032
#> GSM123750     1  0.6157     0.3521 0.528 0.156 0.280 0.000 0.000 0.036
#> GSM123752     1  0.5978     0.3541 0.532 0.152 0.292 0.000 0.000 0.024
#> GSM123756     1  0.1007     0.6609 0.956 0.000 0.044 0.000 0.000 0.000
#> GSM123758     1  0.6005     0.3433 0.528 0.156 0.292 0.000 0.000 0.024
#> GSM123761     1  0.4162     0.5327 0.744 0.000 0.120 0.000 0.000 0.136
#> GSM123763     6  0.6525     0.2024 0.320 0.024 0.216 0.004 0.000 0.436
#> GSM123765     3  0.5117     0.8124 0.068 0.448 0.480 0.000 0.000 0.004
#> GSM123769     1  0.0937     0.6600 0.960 0.000 0.040 0.000 0.000 0.000
#> GSM123771     1  0.1082     0.6601 0.956 0.000 0.040 0.000 0.000 0.004
#> GSM123774     1  0.1007     0.6609 0.956 0.000 0.044 0.000 0.000 0.000
#> GSM123778     3  0.4988     0.8128 0.068 0.448 0.484 0.000 0.000 0.000
#> GSM123780     2  0.4923    -0.6192 0.048 0.544 0.400 0.008 0.000 0.000
#> GSM123784     3  0.4988     0.8128 0.068 0.448 0.484 0.000 0.000 0.000
#> GSM123787     3  0.4893     0.7903 0.064 0.400 0.536 0.000 0.000 0.000
#> GSM123791     3  0.5726     0.7110 0.100 0.352 0.524 0.000 0.000 0.024
#> GSM123795     4  0.7037     0.2176 0.072 0.232 0.320 0.376 0.000 0.000
#> GSM123799     4  0.7040     0.2090 0.072 0.232 0.324 0.372 0.000 0.000
#> GSM123730     2  0.2230     0.7705 0.000 0.892 0.024 0.084 0.000 0.000
#> GSM123734     5  0.0000     0.0000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM123738     4  0.0000    -0.0164 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123742     1  0.4200     0.5342 0.764 0.016 0.156 0.004 0.000 0.060
#> GSM123745     1  0.1950     0.5961 0.924 0.016 0.028 0.000 0.000 0.032
#> GSM123748     1  0.2344     0.6383 0.896 0.008 0.068 0.000 0.000 0.028
#> GSM123751     1  0.1059     0.6402 0.964 0.004 0.016 0.000 0.000 0.016
#> GSM123754     1  0.0603     0.6603 0.980 0.016 0.004 0.000 0.000 0.000
#> GSM123757     1  0.5889     0.3907 0.556 0.152 0.268 0.000 0.000 0.024
#> GSM123760     1  0.5488     0.2558 0.584 0.000 0.264 0.008 0.000 0.144
#> GSM123762     6  0.1644    -0.1356 0.076 0.000 0.004 0.000 0.000 0.920
#> GSM123764     2  0.3955    -0.1964 0.008 0.608 0.384 0.000 0.000 0.000
#> GSM123767     1  0.0603     0.6603 0.980 0.016 0.004 0.000 0.000 0.000
#> GSM123770     1  0.0603     0.6603 0.980 0.016 0.004 0.000 0.000 0.000
#> GSM123773     1  0.0603     0.6603 0.980 0.016 0.004 0.000 0.000 0.000
#> GSM123777     2  0.2230     0.7705 0.000 0.892 0.024 0.084 0.000 0.000
#> GSM123779     2  0.1251     0.8543 0.012 0.956 0.024 0.008 0.000 0.000
#> GSM123782     2  0.4230    -0.0710 0.024 0.648 0.324 0.000 0.000 0.004
#> GSM123786     2  0.4853    -0.7675 0.056 0.488 0.456 0.000 0.000 0.000
#> GSM123789     2  0.3242     0.5990 0.032 0.816 0.148 0.000 0.000 0.004
#> GSM123793     4  0.5074    -0.2343 0.000 0.000 0.252 0.652 0.068 0.028
#> GSM123797     4  0.0146    -0.0176 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM123729     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123737     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123781     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123788     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123792     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123731     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123739     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123776     2  0.1003     0.8533 0.028 0.964 0.004 0.000 0.000 0.004
#> GSM123783     2  0.0547     0.8724 0.000 0.980 0.020 0.000 0.000 0.000
#> GSM123790     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123794     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123798     2  0.0000     0.8953 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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) infection(p) agent(p) k
#> CV:hclust 71         8.91e-03     8.91e-03  0.80894 2
#> CV:hclust 65         6.35e-07     6.35e-07  0.01006 3
#> CV:hclust 65         9.68e-07     9.68e-07  0.01006 4
#> CV:hclust 47         2.63e-06     2.63e-06  0.03501 5
#> CV:hclust 49         3.96e-10     3.96e-10  0.00991 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 71 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 1.000           0.987       0.995         0.4760 0.522   0.522
#> 3 3 0.723           0.803       0.877         0.3629 0.806   0.628
#> 4 4 0.855           0.813       0.898         0.1164 0.899   0.714
#> 5 5 0.774           0.759       0.836         0.0506 0.937   0.794
#> 6 6 0.761           0.705       0.801         0.0399 0.947   0.810

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
#> GSM123732     1   0.000      1.000 1.000 0.000
#> GSM123736     1   0.000      1.000 1.000 0.000
#> GSM123740     1   0.000      1.000 1.000 0.000
#> GSM123744     1   0.000      1.000 1.000 0.000
#> GSM123746     1   0.000      1.000 1.000 0.000
#> GSM123750     1   0.000      1.000 1.000 0.000
#> GSM123752     1   0.000      1.000 1.000 0.000
#> GSM123756     1   0.000      1.000 1.000 0.000
#> GSM123758     1   0.000      1.000 1.000 0.000
#> GSM123761     1   0.000      1.000 1.000 0.000
#> GSM123763     1   0.000      1.000 1.000 0.000
#> GSM123765     1   0.000      1.000 1.000 0.000
#> GSM123769     1   0.000      1.000 1.000 0.000
#> GSM123771     1   0.000      1.000 1.000 0.000
#> GSM123774     1   0.000      1.000 1.000 0.000
#> GSM123778     1   0.000      1.000 1.000 0.000
#> GSM123780     1   0.000      1.000 1.000 0.000
#> GSM123784     1   0.000      1.000 1.000 0.000
#> GSM123787     1   0.000      1.000 1.000 0.000
#> GSM123791     1   0.000      1.000 1.000 0.000
#> GSM123795     1   0.000      1.000 1.000 0.000
#> GSM123799     1   0.000      1.000 1.000 0.000
#> GSM123730     1   0.000      1.000 1.000 0.000
#> GSM123734     1   0.000      1.000 1.000 0.000
#> GSM123738     1   0.000      1.000 1.000 0.000
#> GSM123742     1   0.000      1.000 1.000 0.000
#> GSM123745     1   0.000      1.000 1.000 0.000
#> GSM123748     1   0.000      1.000 1.000 0.000
#> GSM123751     1   0.000      1.000 1.000 0.000
#> GSM123754     1   0.000      1.000 1.000 0.000
#> GSM123757     1   0.000      1.000 1.000 0.000
#> GSM123760     1   0.000      1.000 1.000 0.000
#> GSM123762     1   0.000      1.000 1.000 0.000
#> GSM123764     1   0.000      1.000 1.000 0.000
#> GSM123767     1   0.000      1.000 1.000 0.000
#> GSM123770     1   0.000      1.000 1.000 0.000
#> GSM123773     1   0.000      1.000 1.000 0.000
#> GSM123777     1   0.000      1.000 1.000 0.000
#> GSM123779     1   0.000      1.000 1.000 0.000
#> GSM123782     1   0.000      1.000 1.000 0.000
#> GSM123786     1   0.000      1.000 1.000 0.000
#> GSM123789     1   0.000      1.000 1.000 0.000
#> GSM123793     1   0.000      1.000 1.000 0.000
#> GSM123797     1   0.000      1.000 1.000 0.000
#> GSM123729     2   0.000      0.986 0.000 1.000
#> GSM123733     2   0.000      0.986 0.000 1.000
#> GSM123737     2   0.000      0.986 0.000 1.000
#> GSM123741     2   0.000      0.986 0.000 1.000
#> GSM123747     2   0.000      0.986 0.000 1.000
#> GSM123753     2   0.000      0.986 0.000 1.000
#> GSM123759     2   0.000      0.986 0.000 1.000
#> GSM123766     2   0.000      0.986 0.000 1.000
#> GSM123772     2   0.000      0.986 0.000 1.000
#> GSM123775     2   0.000      0.986 0.000 1.000
#> GSM123781     2   0.000      0.986 0.000 1.000
#> GSM123785     2   0.000      0.986 0.000 1.000
#> GSM123788     2   0.000      0.986 0.000 1.000
#> GSM123792     2   0.000      0.986 0.000 1.000
#> GSM123796     2   0.000      0.986 0.000 1.000
#> GSM123731     2   0.000      0.986 0.000 1.000
#> GSM123735     2   0.000      0.986 0.000 1.000
#> GSM123739     2   0.000      0.986 0.000 1.000
#> GSM123743     2   0.000      0.986 0.000 1.000
#> GSM123749     2   0.000      0.986 0.000 1.000
#> GSM123755     2   0.000      0.986 0.000 1.000
#> GSM123768     2   0.000      0.986 0.000 1.000
#> GSM123776     2   0.946      0.428 0.364 0.636
#> GSM123783     2   0.000      0.986 0.000 1.000
#> GSM123790     2   0.000      0.986 0.000 1.000
#> GSM123794     2   0.000      0.986 0.000 1.000
#> GSM123798     2   0.000      0.986 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
#> GSM123732     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123736     3  0.5254     0.7585 0.264 0.000 0.736
#> GSM123740     3  0.5291     0.7597 0.268 0.000 0.732
#> GSM123744     1  0.4931     0.4917 0.768 0.000 0.232
#> GSM123746     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123750     1  0.2165     0.8173 0.936 0.000 0.064
#> GSM123752     1  0.1643     0.8319 0.956 0.000 0.044
#> GSM123756     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123758     1  0.6244    -0.3170 0.560 0.000 0.440
#> GSM123761     1  0.2165     0.8330 0.936 0.000 0.064
#> GSM123763     3  0.6168     0.2860 0.412 0.000 0.588
#> GSM123765     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123769     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123771     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123774     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123778     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123780     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123784     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123787     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123791     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123795     3  0.5216     0.7577 0.260 0.000 0.740
#> GSM123799     3  0.5291     0.7597 0.268 0.000 0.732
#> GSM123730     3  0.3412     0.7329 0.124 0.000 0.876
#> GSM123734     3  0.5859     0.1998 0.344 0.000 0.656
#> GSM123738     3  0.1860     0.6686 0.052 0.000 0.948
#> GSM123742     1  0.4002     0.7553 0.840 0.000 0.160
#> GSM123745     1  0.2878     0.7974 0.904 0.000 0.096
#> GSM123748     1  0.1031     0.8597 0.976 0.000 0.024
#> GSM123751     1  0.1163     0.8582 0.972 0.000 0.028
#> GSM123754     1  0.1289     0.8569 0.968 0.000 0.032
#> GSM123757     1  0.0000     0.8604 1.000 0.000 0.000
#> GSM123760     1  0.6307    -0.0347 0.512 0.000 0.488
#> GSM123762     1  0.5254     0.6337 0.736 0.000 0.264
#> GSM123764     3  0.5016     0.7675 0.240 0.000 0.760
#> GSM123767     1  0.1289     0.8569 0.968 0.000 0.032
#> GSM123770     1  0.0592     0.8612 0.988 0.000 0.012
#> GSM123773     1  0.1289     0.8569 0.968 0.000 0.032
#> GSM123777     3  0.3482     0.7345 0.128 0.000 0.872
#> GSM123779     3  0.5178     0.7678 0.256 0.000 0.744
#> GSM123782     3  0.5397     0.7719 0.280 0.000 0.720
#> GSM123786     3  0.5948     0.7626 0.360 0.000 0.640
#> GSM123789     3  0.5178     0.7698 0.256 0.000 0.744
#> GSM123793     3  0.1860     0.6686 0.052 0.000 0.948
#> GSM123797     3  0.1860     0.6686 0.052 0.000 0.948
#> GSM123729     2  0.0592     0.9768 0.000 0.988 0.012
#> GSM123733     2  0.0747     0.9759 0.000 0.984 0.016
#> GSM123737     2  0.0592     0.9768 0.000 0.988 0.012
#> GSM123741     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123747     2  0.0237     0.9781 0.000 0.996 0.004
#> GSM123753     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123759     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123766     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123772     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123775     2  0.0747     0.9755 0.000 0.984 0.016
#> GSM123781     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123785     2  0.0747     0.9759 0.000 0.984 0.016
#> GSM123788     2  0.0592     0.9771 0.000 0.988 0.012
#> GSM123792     2  0.0237     0.9781 0.000 0.996 0.004
#> GSM123796     2  0.0237     0.9781 0.000 0.996 0.004
#> GSM123731     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123735     2  0.0747     0.9755 0.000 0.984 0.016
#> GSM123739     2  0.0592     0.9768 0.000 0.988 0.012
#> GSM123743     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123749     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123755     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123768     2  0.0000     0.9789 0.000 1.000 0.000
#> GSM123776     2  0.7192     0.2690 0.412 0.560 0.028
#> GSM123783     2  0.0237     0.9783 0.000 0.996 0.004
#> GSM123790     2  0.0892     0.9745 0.000 0.980 0.020
#> GSM123794     2  0.0747     0.9762 0.000 0.984 0.016
#> GSM123798     2  0.0000     0.9789 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0817      0.825 0.024 0.000 0.976 0.000
#> GSM123736     3  0.4675      0.659 0.020 0.000 0.736 0.244
#> GSM123740     3  0.4675      0.659 0.020 0.000 0.736 0.244
#> GSM123744     3  0.4792      0.472 0.312 0.000 0.680 0.008
#> GSM123746     1  0.1042      0.841 0.972 0.000 0.020 0.008
#> GSM123750     1  0.5281      0.160 0.528 0.000 0.464 0.008
#> GSM123752     1  0.5112      0.377 0.608 0.000 0.384 0.008
#> GSM123756     1  0.0707      0.843 0.980 0.000 0.020 0.000
#> GSM123758     3  0.2334      0.777 0.088 0.000 0.908 0.004
#> GSM123761     1  0.5070      0.592 0.748 0.000 0.060 0.192
#> GSM123763     4  0.5815      0.767 0.152 0.000 0.140 0.708
#> GSM123765     3  0.0817      0.825 0.024 0.000 0.976 0.000
#> GSM123769     1  0.0707      0.843 0.980 0.000 0.020 0.000
#> GSM123771     1  0.0707      0.843 0.980 0.000 0.020 0.000
#> GSM123774     1  0.0707      0.843 0.980 0.000 0.020 0.000
#> GSM123778     3  0.0817      0.825 0.024 0.000 0.976 0.000
#> GSM123780     3  0.0707      0.825 0.020 0.000 0.980 0.000
#> GSM123784     3  0.0707      0.825 0.020 0.000 0.980 0.000
#> GSM123787     3  0.0707      0.825 0.020 0.000 0.980 0.000
#> GSM123791     3  0.0817      0.825 0.024 0.000 0.976 0.000
#> GSM123795     3  0.4737      0.648 0.020 0.000 0.728 0.252
#> GSM123799     3  0.4610      0.669 0.020 0.000 0.744 0.236
#> GSM123730     3  0.4567      0.592 0.008 0.000 0.716 0.276
#> GSM123734     4  0.2751      0.816 0.040 0.000 0.056 0.904
#> GSM123738     4  0.2345      0.808 0.000 0.000 0.100 0.900
#> GSM123742     1  0.5810      0.409 0.660 0.000 0.064 0.276
#> GSM123745     1  0.0779      0.832 0.980 0.000 0.016 0.004
#> GSM123748     1  0.0804      0.834 0.980 0.000 0.012 0.008
#> GSM123751     1  0.0657      0.840 0.984 0.000 0.012 0.004
#> GSM123754     1  0.0592      0.843 0.984 0.000 0.016 0.000
#> GSM123757     1  0.0707      0.843 0.980 0.000 0.020 0.000
#> GSM123760     4  0.6295      0.732 0.196 0.000 0.144 0.660
#> GSM123762     4  0.5673      0.605 0.288 0.000 0.052 0.660
#> GSM123764     3  0.3647      0.727 0.016 0.000 0.832 0.152
#> GSM123767     1  0.0707      0.841 0.980 0.000 0.020 0.000
#> GSM123770     1  0.0592      0.843 0.984 0.000 0.016 0.000
#> GSM123773     1  0.0707      0.841 0.980 0.000 0.020 0.000
#> GSM123777     3  0.4123      0.673 0.008 0.000 0.772 0.220
#> GSM123779     3  0.4365      0.694 0.028 0.000 0.784 0.188
#> GSM123782     3  0.2522      0.793 0.016 0.000 0.908 0.076
#> GSM123786     3  0.0817      0.825 0.024 0.000 0.976 0.000
#> GSM123789     3  0.3969      0.712 0.016 0.000 0.804 0.180
#> GSM123793     4  0.2216      0.811 0.000 0.000 0.092 0.908
#> GSM123797     4  0.2345      0.808 0.000 0.000 0.100 0.900
#> GSM123729     2  0.2010      0.960 0.004 0.932 0.004 0.060
#> GSM123733     2  0.1305      0.972 0.004 0.960 0.000 0.036
#> GSM123737     2  0.1930      0.961 0.004 0.936 0.004 0.056
#> GSM123741     2  0.0188      0.975 0.000 0.996 0.000 0.004
#> GSM123747     2  0.0469      0.975 0.000 0.988 0.000 0.012
#> GSM123753     2  0.0188      0.975 0.000 0.996 0.000 0.004
#> GSM123759     2  0.0188      0.975 0.000 0.996 0.000 0.004
#> GSM123766     2  0.0188      0.975 0.000 0.996 0.000 0.004
#> GSM123772     2  0.0469      0.975 0.000 0.988 0.000 0.012
#> GSM123775     2  0.2088      0.958 0.004 0.928 0.004 0.064
#> GSM123781     2  0.0336      0.975 0.000 0.992 0.000 0.008
#> GSM123785     2  0.1305      0.972 0.004 0.960 0.000 0.036
#> GSM123788     2  0.1305      0.972 0.004 0.960 0.000 0.036
#> GSM123792     2  0.1209      0.973 0.004 0.964 0.000 0.032
#> GSM123796     2  0.1305      0.972 0.004 0.960 0.000 0.036
#> GSM123731     2  0.0188      0.976 0.000 0.996 0.000 0.004
#> GSM123735     2  0.1847      0.967 0.004 0.940 0.004 0.052
#> GSM123739     2  0.1930      0.961 0.004 0.936 0.004 0.056
#> GSM123743     2  0.0336      0.976 0.000 0.992 0.000 0.008
#> GSM123749     2  0.0188      0.975 0.000 0.996 0.000 0.004
#> GSM123755     2  0.0336      0.975 0.000 0.992 0.000 0.008
#> GSM123768     2  0.0336      0.975 0.000 0.992 0.000 0.008
#> GSM123776     1  0.6891      0.022 0.484 0.436 0.016 0.064
#> GSM123783     2  0.1305      0.968 0.000 0.960 0.004 0.036
#> GSM123790     2  0.2384      0.955 0.008 0.916 0.004 0.072
#> GSM123794     2  0.1847      0.967 0.004 0.940 0.004 0.052
#> GSM123798     2  0.0336      0.975 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0290      0.713 0.008 0.000 0.992 0.000 0.000
#> GSM123736     3  0.4549      0.574 0.004 0.000 0.728 0.220 0.048
#> GSM123740     3  0.4518      0.577 0.004 0.000 0.732 0.216 0.048
#> GSM123744     3  0.4630      0.559 0.140 0.000 0.744 0.000 0.116
#> GSM123746     1  0.2464      0.879 0.888 0.000 0.016 0.000 0.096
#> GSM123750     3  0.5680      0.390 0.240 0.000 0.620 0.000 0.140
#> GSM123752     3  0.5126      0.403 0.300 0.000 0.636 0.000 0.064
#> GSM123756     1  0.0798      0.955 0.976 0.000 0.008 0.000 0.016
#> GSM123758     3  0.2291      0.688 0.036 0.000 0.908 0.000 0.056
#> GSM123761     5  0.6509      0.390 0.420 0.000 0.020 0.112 0.448
#> GSM123763     5  0.5715      0.398 0.032 0.000 0.032 0.396 0.540
#> GSM123765     3  0.0290      0.713 0.008 0.000 0.992 0.000 0.000
#> GSM123769     1  0.0798      0.955 0.976 0.000 0.008 0.000 0.016
#> GSM123771     1  0.0798      0.955 0.976 0.000 0.008 0.000 0.016
#> GSM123774     1  0.0798      0.955 0.976 0.000 0.008 0.000 0.016
#> GSM123778     3  0.0290      0.713 0.008 0.000 0.992 0.000 0.000
#> GSM123780     3  0.2722      0.674 0.008 0.000 0.868 0.004 0.120
#> GSM123784     3  0.0451      0.712 0.008 0.000 0.988 0.004 0.000
#> GSM123787     3  0.0290      0.713 0.008 0.000 0.992 0.000 0.000
#> GSM123791     3  0.0451      0.712 0.008 0.000 0.988 0.000 0.004
#> GSM123795     3  0.4481      0.565 0.000 0.000 0.720 0.232 0.048
#> GSM123799     3  0.4457      0.585 0.004 0.000 0.740 0.208 0.048
#> GSM123730     3  0.7095      0.130 0.012 0.000 0.388 0.316 0.284
#> GSM123734     4  0.2102      0.915 0.004 0.000 0.012 0.916 0.068
#> GSM123738     4  0.0912      0.933 0.000 0.000 0.016 0.972 0.012
#> GSM123742     5  0.6341      0.501 0.384 0.000 0.012 0.116 0.488
#> GSM123745     1  0.1197      0.940 0.952 0.000 0.000 0.000 0.048
#> GSM123748     1  0.2179      0.867 0.888 0.000 0.000 0.000 0.112
#> GSM123751     1  0.1205      0.944 0.956 0.000 0.004 0.000 0.040
#> GSM123754     1  0.0798      0.956 0.976 0.000 0.008 0.000 0.016
#> GSM123757     1  0.0898      0.955 0.972 0.000 0.008 0.000 0.020
#> GSM123760     5  0.6044      0.506 0.076 0.000 0.024 0.332 0.568
#> GSM123762     5  0.5940      0.519 0.100 0.000 0.004 0.364 0.532
#> GSM123764     3  0.5892      0.334 0.004 0.000 0.500 0.088 0.408
#> GSM123767     1  0.0798      0.956 0.976 0.000 0.008 0.000 0.016
#> GSM123770     1  0.0290      0.956 0.992 0.000 0.008 0.000 0.000
#> GSM123773     1  0.0798      0.956 0.976 0.000 0.008 0.000 0.016
#> GSM123777     3  0.6751      0.275 0.004 0.000 0.456 0.256 0.284
#> GSM123779     3  0.6838      0.298 0.020 0.000 0.456 0.164 0.360
#> GSM123782     3  0.5256      0.455 0.004 0.000 0.592 0.048 0.356
#> GSM123786     3  0.0290      0.713 0.008 0.000 0.992 0.000 0.000
#> GSM123789     3  0.6020      0.382 0.004 0.000 0.524 0.108 0.364
#> GSM123793     4  0.1757      0.932 0.004 0.000 0.012 0.936 0.048
#> GSM123797     4  0.0798      0.936 0.000 0.000 0.016 0.976 0.008
#> GSM123729     2  0.3023      0.891 0.004 0.852 0.004 0.008 0.132
#> GSM123733     2  0.2629      0.902 0.000 0.860 0.000 0.004 0.136
#> GSM123737     2  0.3023      0.891 0.004 0.852 0.004 0.008 0.132
#> GSM123741     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.1430      0.914 0.000 0.944 0.000 0.004 0.052
#> GSM123753     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123759     2  0.0566      0.919 0.000 0.984 0.000 0.004 0.012
#> GSM123766     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123772     2  0.0771      0.920 0.000 0.976 0.000 0.004 0.020
#> GSM123775     2  0.3023      0.887 0.004 0.852 0.004 0.008 0.132
#> GSM123781     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123785     2  0.2629      0.902 0.000 0.860 0.000 0.004 0.136
#> GSM123788     2  0.2583      0.903 0.000 0.864 0.000 0.004 0.132
#> GSM123792     2  0.2338      0.909 0.000 0.884 0.000 0.004 0.112
#> GSM123796     2  0.2536      0.904 0.000 0.868 0.000 0.004 0.128
#> GSM123731     2  0.0162      0.920 0.000 0.996 0.000 0.000 0.004
#> GSM123735     2  0.2741      0.904 0.000 0.860 0.004 0.004 0.132
#> GSM123739     2  0.3023      0.891 0.004 0.852 0.004 0.008 0.132
#> GSM123743     2  0.0510      0.921 0.000 0.984 0.000 0.000 0.016
#> GSM123749     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123755     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123768     2  0.0162      0.919 0.000 0.996 0.000 0.000 0.004
#> GSM123776     2  0.6942      0.150 0.400 0.428 0.016 0.008 0.148
#> GSM123783     2  0.0609      0.917 0.000 0.980 0.000 0.000 0.020
#> GSM123790     2  0.3160      0.879 0.000 0.808 0.000 0.004 0.188
#> GSM123794     2  0.2583      0.904 0.000 0.864 0.000 0.004 0.132
#> GSM123798     2  0.0162      0.919 0.000 0.996 0.000 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
#> GSM123732     3  0.0146    0.66913 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123736     3  0.5981    0.48616 0.008 0.000 0.568 0.112 0.280 0.032
#> GSM123740     3  0.5981    0.48616 0.008 0.000 0.568 0.112 0.280 0.032
#> GSM123744     3  0.5228    0.59447 0.084 0.000 0.728 0.044 0.036 0.108
#> GSM123746     1  0.3926    0.74259 0.816 0.000 0.040 0.040 0.016 0.088
#> GSM123750     3  0.6305    0.47656 0.164 0.000 0.600 0.044 0.024 0.168
#> GSM123752     3  0.5318    0.52883 0.216 0.000 0.676 0.044 0.036 0.028
#> GSM123756     1  0.1010    0.85619 0.960 0.000 0.000 0.000 0.004 0.036
#> GSM123758     3  0.3010    0.65644 0.028 0.000 0.876 0.044 0.036 0.016
#> GSM123761     6  0.3836    0.72358 0.176 0.000 0.000 0.040 0.012 0.772
#> GSM123763     6  0.1078    0.76461 0.012 0.000 0.000 0.016 0.008 0.964
#> GSM123765     3  0.0146    0.66913 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123769     1  0.1010    0.85619 0.960 0.000 0.000 0.000 0.004 0.036
#> GSM123771     1  0.1010    0.85619 0.960 0.000 0.000 0.000 0.004 0.036
#> GSM123774     1  0.0935    0.85735 0.964 0.000 0.000 0.000 0.004 0.032
#> GSM123778     3  0.0146    0.66913 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123780     3  0.2838    0.41525 0.004 0.000 0.808 0.188 0.000 0.000
#> GSM123784     3  0.0405    0.66585 0.004 0.000 0.988 0.008 0.000 0.000
#> GSM123787     3  0.0146    0.66913 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123791     3  0.0508    0.66994 0.004 0.000 0.984 0.000 0.000 0.012
#> GSM123795     3  0.5981    0.48616 0.008 0.000 0.568 0.112 0.280 0.032
#> GSM123799     3  0.5981    0.48616 0.008 0.000 0.568 0.112 0.280 0.032
#> GSM123730     4  0.5103    0.66432 0.008 0.000 0.308 0.616 0.012 0.056
#> GSM123734     4  0.6082   -0.86377 0.000 0.000 0.004 0.392 0.384 0.220
#> GSM123738     5  0.5701    0.89630 0.000 0.000 0.004 0.356 0.492 0.148
#> GSM123742     6  0.4720    0.68385 0.228 0.000 0.000 0.076 0.012 0.684
#> GSM123745     1  0.1984    0.84007 0.912 0.000 0.000 0.032 0.000 0.056
#> GSM123748     1  0.3739    0.67405 0.768 0.000 0.000 0.056 0.000 0.176
#> GSM123751     1  0.1789    0.84516 0.924 0.000 0.000 0.032 0.000 0.044
#> GSM123754     1  0.0865    0.86039 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM123757     1  0.1586    0.84987 0.940 0.000 0.004 0.040 0.004 0.012
#> GSM123760     6  0.2197    0.76884 0.044 0.000 0.000 0.056 0.000 0.900
#> GSM123762     6  0.1116    0.78009 0.028 0.000 0.000 0.008 0.004 0.960
#> GSM123764     4  0.6091    0.60729 0.004 0.000 0.404 0.416 0.008 0.168
#> GSM123767     1  0.0865    0.86039 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM123770     1  0.0291    0.86214 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM123773     1  0.0865    0.86039 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM123777     4  0.5147    0.66516 0.008 0.000 0.336 0.592 0.012 0.052
#> GSM123779     4  0.5814    0.67200 0.020 0.000 0.332 0.524 0.000 0.124
#> GSM123782     3  0.5608   -0.61483 0.004 0.000 0.468 0.416 0.004 0.108
#> GSM123786     3  0.0146    0.66913 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123789     4  0.5928    0.62513 0.008 0.000 0.400 0.448 0.004 0.140
#> GSM123793     5  0.5997    0.79451 0.000 0.000 0.004 0.396 0.404 0.196
#> GSM123797     5  0.5715    0.89942 0.000 0.000 0.004 0.364 0.484 0.148
#> GSM123729     2  0.4290    0.75650 0.000 0.668 0.000 0.028 0.296 0.008
#> GSM123733     2  0.2883    0.84173 0.000 0.788 0.000 0.000 0.212 0.000
#> GSM123737     2  0.4213    0.76965 0.000 0.684 0.000 0.028 0.280 0.008
#> GSM123741     2  0.0000    0.87590 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.1714    0.86556 0.000 0.908 0.000 0.000 0.092 0.000
#> GSM123753     2  0.0146    0.87534 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123759     2  0.0547    0.87522 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM123766     2  0.0146    0.87534 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123772     2  0.0632    0.87507 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM123775     2  0.4397    0.74643 0.000 0.664 0.000 0.024 0.296 0.016
#> GSM123781     2  0.0260    0.87508 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123785     2  0.2912    0.84041 0.000 0.784 0.000 0.000 0.216 0.000
#> GSM123788     2  0.2854    0.84312 0.000 0.792 0.000 0.000 0.208 0.000
#> GSM123792     2  0.2697    0.84916 0.000 0.812 0.000 0.000 0.188 0.000
#> GSM123796     2  0.2762    0.84636 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM123731     2  0.0260    0.87665 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123735     2  0.3288    0.82111 0.000 0.724 0.000 0.000 0.276 0.000
#> GSM123739     2  0.4193    0.77080 0.000 0.688 0.000 0.028 0.276 0.008
#> GSM123743     2  0.0713    0.87811 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM123749     2  0.0146    0.87534 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123755     2  0.0260    0.87508 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123768     2  0.0260    0.87508 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM123776     1  0.7296    0.00861 0.372 0.276 0.004 0.044 0.288 0.016
#> GSM123783     2  0.2278    0.83865 0.000 0.868 0.000 0.000 0.128 0.004
#> GSM123790     2  0.3934    0.75018 0.000 0.616 0.000 0.000 0.376 0.008
#> GSM123794     2  0.3351    0.81509 0.000 0.712 0.000 0.000 0.288 0.000
#> GSM123798     2  0.0260    0.87508 0.000 0.992 0.000 0.000 0.008 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) infection(p) agent(p) k
#> CV:kmeans 70         6.31e-16     6.31e-16 1.30e-05 2
#> CV:kmeans 65         2.11e-13     2.11e-13 4.87e-05 3
#> CV:kmeans 66         5.12e-14     5.12e-14 1.47e-04 4
#> CV:kmeans 60         2.17e-16     2.17e-16 1.47e-03 5
#> CV:kmeans 62         1.40e-14     1.40e-14 2.36e-03 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 71 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 1.000           1.000       1.000         0.4787 0.522   0.522
#> 3 3 0.848           0.871       0.941         0.4023 0.806   0.628
#> 4 4 0.753           0.729       0.850         0.0940 0.882   0.666
#> 5 5 0.712           0.548       0.762         0.0482 0.963   0.867
#> 6 6 0.649           0.535       0.699         0.0352 0.976   0.906

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
#> GSM123732     1   0.000      1.000 1.000 0.000
#> GSM123736     1   0.000      1.000 1.000 0.000
#> GSM123740     1   0.000      1.000 1.000 0.000
#> GSM123744     1   0.000      1.000 1.000 0.000
#> GSM123746     1   0.000      1.000 1.000 0.000
#> GSM123750     1   0.000      1.000 1.000 0.000
#> GSM123752     1   0.000      1.000 1.000 0.000
#> GSM123756     1   0.000      1.000 1.000 0.000
#> GSM123758     1   0.000      1.000 1.000 0.000
#> GSM123761     1   0.000      1.000 1.000 0.000
#> GSM123763     1   0.000      1.000 1.000 0.000
#> GSM123765     1   0.000      1.000 1.000 0.000
#> GSM123769     1   0.000      1.000 1.000 0.000
#> GSM123771     1   0.000      1.000 1.000 0.000
#> GSM123774     1   0.000      1.000 1.000 0.000
#> GSM123778     1   0.000      1.000 1.000 0.000
#> GSM123780     1   0.000      1.000 1.000 0.000
#> GSM123784     1   0.000      1.000 1.000 0.000
#> GSM123787     1   0.000      1.000 1.000 0.000
#> GSM123791     1   0.000      1.000 1.000 0.000
#> GSM123795     1   0.000      1.000 1.000 0.000
#> GSM123799     1   0.000      1.000 1.000 0.000
#> GSM123730     1   0.118      0.984 0.984 0.016
#> GSM123734     1   0.000      1.000 1.000 0.000
#> GSM123738     1   0.000      1.000 1.000 0.000
#> GSM123742     1   0.000      1.000 1.000 0.000
#> GSM123745     1   0.000      1.000 1.000 0.000
#> GSM123748     1   0.000      1.000 1.000 0.000
#> GSM123751     1   0.000      1.000 1.000 0.000
#> GSM123754     1   0.000      1.000 1.000 0.000
#> GSM123757     1   0.000      1.000 1.000 0.000
#> GSM123760     1   0.000      1.000 1.000 0.000
#> GSM123762     1   0.000      1.000 1.000 0.000
#> GSM123764     1   0.000      1.000 1.000 0.000
#> GSM123767     1   0.000      1.000 1.000 0.000
#> GSM123770     1   0.000      1.000 1.000 0.000
#> GSM123773     1   0.000      1.000 1.000 0.000
#> GSM123777     1   0.000      1.000 1.000 0.000
#> GSM123779     1   0.000      1.000 1.000 0.000
#> GSM123782     1   0.000      1.000 1.000 0.000
#> GSM123786     1   0.000      1.000 1.000 0.000
#> GSM123789     1   0.000      1.000 1.000 0.000
#> GSM123793     1   0.000      1.000 1.000 0.000
#> GSM123797     1   0.000      1.000 1.000 0.000
#> GSM123729     2   0.000      1.000 0.000 1.000
#> GSM123733     2   0.000      1.000 0.000 1.000
#> GSM123737     2   0.000      1.000 0.000 1.000
#> GSM123741     2   0.000      1.000 0.000 1.000
#> GSM123747     2   0.000      1.000 0.000 1.000
#> GSM123753     2   0.000      1.000 0.000 1.000
#> GSM123759     2   0.000      1.000 0.000 1.000
#> GSM123766     2   0.000      1.000 0.000 1.000
#> GSM123772     2   0.000      1.000 0.000 1.000
#> GSM123775     2   0.000      1.000 0.000 1.000
#> GSM123781     2   0.000      1.000 0.000 1.000
#> GSM123785     2   0.000      1.000 0.000 1.000
#> GSM123788     2   0.000      1.000 0.000 1.000
#> GSM123792     2   0.000      1.000 0.000 1.000
#> GSM123796     2   0.000      1.000 0.000 1.000
#> GSM123731     2   0.000      1.000 0.000 1.000
#> GSM123735     2   0.000      1.000 0.000 1.000
#> GSM123739     2   0.000      1.000 0.000 1.000
#> GSM123743     2   0.000      1.000 0.000 1.000
#> GSM123749     2   0.000      1.000 0.000 1.000
#> GSM123755     2   0.000      1.000 0.000 1.000
#> GSM123768     2   0.000      1.000 0.000 1.000
#> GSM123776     2   0.000      1.000 0.000 1.000
#> GSM123783     2   0.000      1.000 0.000 1.000
#> GSM123790     2   0.000      1.000 0.000 1.000
#> GSM123794     2   0.000      1.000 0.000 1.000
#> GSM123798     2   0.000      1.000 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
#> GSM123732     3  0.0892      0.895 0.020 0.00 0.980
#> GSM123736     3  0.0892      0.900 0.020 0.00 0.980
#> GSM123740     3  0.0747      0.900 0.016 0.00 0.984
#> GSM123744     1  0.6192      0.347 0.580 0.00 0.420
#> GSM123746     1  0.0747      0.897 0.984 0.00 0.016
#> GSM123750     1  0.3816      0.815 0.852 0.00 0.148
#> GSM123752     1  0.3267      0.833 0.884 0.00 0.116
#> GSM123756     1  0.0424      0.899 0.992 0.00 0.008
#> GSM123758     1  0.6225      0.295 0.568 0.00 0.432
#> GSM123761     1  0.1964      0.878 0.944 0.00 0.056
#> GSM123763     3  0.6267      0.226 0.452 0.00 0.548
#> GSM123765     3  0.0000      0.898 0.000 0.00 1.000
#> GSM123769     1  0.0424      0.899 0.992 0.00 0.008
#> GSM123771     1  0.0424      0.899 0.992 0.00 0.008
#> GSM123774     1  0.0424      0.899 0.992 0.00 0.008
#> GSM123778     3  0.0237      0.898 0.004 0.00 0.996
#> GSM123780     3  0.0000      0.898 0.000 0.00 1.000
#> GSM123784     3  0.0000      0.898 0.000 0.00 1.000
#> GSM123787     3  0.0237      0.898 0.004 0.00 0.996
#> GSM123791     3  0.0747      0.900 0.016 0.00 0.984
#> GSM123795     3  0.1031      0.900 0.024 0.00 0.976
#> GSM123799     3  0.1031      0.900 0.024 0.00 0.976
#> GSM123730     3  0.2537      0.877 0.080 0.00 0.920
#> GSM123734     3  0.6299      0.160 0.476 0.00 0.524
#> GSM123738     3  0.2261      0.885 0.068 0.00 0.932
#> GSM123742     1  0.2537      0.858 0.920 0.00 0.080
#> GSM123745     1  0.0237      0.898 0.996 0.00 0.004
#> GSM123748     1  0.0237      0.899 0.996 0.00 0.004
#> GSM123751     1  0.0424      0.897 0.992 0.00 0.008
#> GSM123754     1  0.0000      0.899 1.000 0.00 0.000
#> GSM123757     1  0.0424      0.899 0.992 0.00 0.008
#> GSM123760     1  0.6008      0.376 0.628 0.00 0.372
#> GSM123762     1  0.3879      0.782 0.848 0.00 0.152
#> GSM123764     3  0.1753      0.893 0.048 0.00 0.952
#> GSM123767     1  0.0000      0.899 1.000 0.00 0.000
#> GSM123770     1  0.0000      0.899 1.000 0.00 0.000
#> GSM123773     1  0.0000      0.899 1.000 0.00 0.000
#> GSM123777     3  0.0747      0.899 0.016 0.00 0.984
#> GSM123779     3  0.6215      0.312 0.428 0.00 0.572
#> GSM123782     3  0.3038      0.855 0.104 0.00 0.896
#> GSM123786     3  0.0237      0.898 0.004 0.00 0.996
#> GSM123789     3  0.3192      0.847 0.112 0.00 0.888
#> GSM123793     3  0.3412      0.845 0.124 0.00 0.876
#> GSM123797     3  0.2165      0.887 0.064 0.00 0.936
#> GSM123729     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123733     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123737     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123741     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123747     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123753     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123759     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123766     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123772     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123775     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123781     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123785     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123788     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123792     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123796     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123731     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123735     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123739     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123743     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123749     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123755     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123768     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123776     2  0.4796      0.717 0.220 0.78 0.000
#> GSM123783     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123790     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123794     2  0.0000      0.991 0.000 1.00 0.000
#> GSM123798     2  0.0000      0.991 0.000 1.00 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.1807     0.7116 0.008 0.000 0.940 0.052
#> GSM123736     3  0.5152     0.5900 0.020 0.000 0.664 0.316
#> GSM123740     3  0.4776     0.6450 0.016 0.000 0.712 0.272
#> GSM123744     3  0.6894     0.2717 0.320 0.000 0.552 0.128
#> GSM123746     1  0.3787     0.7007 0.840 0.000 0.124 0.036
#> GSM123750     1  0.7526     0.1078 0.468 0.000 0.332 0.200
#> GSM123752     1  0.5512     0.4877 0.660 0.000 0.300 0.040
#> GSM123756     1  0.0188     0.7718 0.996 0.000 0.000 0.004
#> GSM123758     3  0.4741     0.5163 0.228 0.000 0.744 0.028
#> GSM123761     1  0.6894     0.2473 0.552 0.000 0.128 0.320
#> GSM123763     4  0.6157     0.5729 0.232 0.000 0.108 0.660
#> GSM123765     3  0.3725     0.7105 0.008 0.000 0.812 0.180
#> GSM123769     1  0.0336     0.7720 0.992 0.000 0.000 0.008
#> GSM123771     1  0.0188     0.7717 0.996 0.000 0.000 0.004
#> GSM123774     1  0.0000     0.7716 1.000 0.000 0.000 0.000
#> GSM123778     3  0.2149     0.7107 0.000 0.000 0.912 0.088
#> GSM123780     3  0.4175     0.6746 0.012 0.000 0.776 0.212
#> GSM123784     3  0.3123     0.7157 0.000 0.000 0.844 0.156
#> GSM123787     3  0.2714     0.7121 0.004 0.000 0.884 0.112
#> GSM123791     3  0.4220     0.6092 0.004 0.000 0.748 0.248
#> GSM123795     3  0.5793     0.4281 0.036 0.000 0.580 0.384
#> GSM123799     3  0.4690     0.6566 0.016 0.000 0.724 0.260
#> GSM123730     4  0.4057     0.6031 0.028 0.000 0.160 0.812
#> GSM123734     4  0.5314     0.6221 0.176 0.000 0.084 0.740
#> GSM123738     4  0.4744     0.5151 0.024 0.000 0.240 0.736
#> GSM123742     1  0.6921    -0.0227 0.468 0.000 0.108 0.424
#> GSM123745     1  0.3355     0.7029 0.836 0.000 0.004 0.160
#> GSM123748     1  0.3672     0.6999 0.824 0.000 0.012 0.164
#> GSM123751     1  0.3196     0.7225 0.856 0.000 0.008 0.136
#> GSM123754     1  0.1716     0.7619 0.936 0.000 0.000 0.064
#> GSM123757     1  0.0895     0.7714 0.976 0.000 0.004 0.020
#> GSM123760     4  0.6013     0.5970 0.196 0.000 0.120 0.684
#> GSM123762     4  0.6330     0.0661 0.448 0.000 0.060 0.492
#> GSM123764     4  0.5668     0.5313 0.048 0.000 0.300 0.652
#> GSM123767     1  0.2345     0.7476 0.900 0.000 0.000 0.100
#> GSM123770     1  0.0592     0.7714 0.984 0.000 0.000 0.016
#> GSM123773     1  0.1557     0.7643 0.944 0.000 0.000 0.056
#> GSM123777     4  0.5339     0.3669 0.016 0.000 0.384 0.600
#> GSM123779     4  0.5863     0.5848 0.180 0.000 0.120 0.700
#> GSM123782     4  0.5915     0.3547 0.040 0.000 0.400 0.560
#> GSM123786     3  0.1637     0.7090 0.000 0.000 0.940 0.060
#> GSM123789     4  0.6013     0.5522 0.072 0.000 0.288 0.640
#> GSM123793     4  0.3606     0.6139 0.024 0.000 0.132 0.844
#> GSM123797     4  0.3978     0.5772 0.012 0.000 0.192 0.796
#> GSM123729     2  0.0524     0.9928 0.000 0.988 0.004 0.008
#> GSM123733     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123737     2  0.0336     0.9945 0.000 0.992 0.000 0.008
#> GSM123741     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123747     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123753     2  0.0000     0.9954 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0469     0.9946 0.000 0.988 0.000 0.012
#> GSM123766     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123772     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123775     2  0.0376     0.9937 0.000 0.992 0.004 0.004
#> GSM123781     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123785     2  0.0336     0.9942 0.000 0.992 0.000 0.008
#> GSM123788     2  0.0336     0.9942 0.000 0.992 0.000 0.008
#> GSM123792     2  0.0000     0.9954 0.000 1.000 0.000 0.000
#> GSM123796     2  0.0336     0.9942 0.000 0.992 0.000 0.008
#> GSM123731     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123735     2  0.0524     0.9929 0.000 0.988 0.004 0.008
#> GSM123739     2  0.0336     0.9945 0.000 0.992 0.000 0.008
#> GSM123743     2  0.0000     0.9954 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123755     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123768     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123776     1  0.6639     0.1516 0.500 0.436 0.016 0.048
#> GSM123783     2  0.0188     0.9951 0.000 0.996 0.000 0.004
#> GSM123790     2  0.0707     0.9862 0.000 0.980 0.000 0.020
#> GSM123794     2  0.0188     0.9950 0.000 0.996 0.000 0.004
#> GSM123798     2  0.0188     0.9951 0.000 0.996 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.2628     0.5131 0.000 0.000 0.884 0.028 0.088
#> GSM123736     4  0.6350    -0.2628 0.008 0.000 0.432 0.436 0.124
#> GSM123740     3  0.6225     0.2492 0.004 0.000 0.472 0.400 0.124
#> GSM123744     3  0.7813     0.1555 0.200 0.000 0.436 0.092 0.272
#> GSM123746     1  0.5340     0.6320 0.716 0.000 0.060 0.048 0.176
#> GSM123750     1  0.8226    -0.0769 0.356 0.000 0.264 0.120 0.260
#> GSM123752     1  0.6862     0.3207 0.524 0.000 0.256 0.028 0.192
#> GSM123756     1  0.0898     0.7391 0.972 0.000 0.000 0.008 0.020
#> GSM123758     3  0.6204     0.3102 0.196 0.000 0.620 0.024 0.160
#> GSM123761     1  0.8008    -0.0973 0.352 0.000 0.084 0.296 0.268
#> GSM123763     4  0.6422     0.1611 0.100 0.000 0.064 0.620 0.216
#> GSM123765     3  0.4393     0.4930 0.004 0.000 0.768 0.152 0.076
#> GSM123769     1  0.1845     0.7392 0.928 0.000 0.000 0.016 0.056
#> GSM123771     1  0.1549     0.7406 0.944 0.000 0.000 0.016 0.040
#> GSM123774     1  0.0451     0.7379 0.988 0.000 0.000 0.004 0.008
#> GSM123778     3  0.3065     0.5125 0.008 0.000 0.872 0.048 0.072
#> GSM123780     3  0.5969     0.2726 0.008 0.000 0.620 0.184 0.188
#> GSM123784     3  0.4892     0.4776 0.016 0.000 0.748 0.112 0.124
#> GSM123787     3  0.4203     0.4607 0.000 0.000 0.780 0.128 0.092
#> GSM123791     3  0.6215     0.2901 0.012 0.000 0.596 0.192 0.200
#> GSM123795     4  0.6548    -0.0369 0.032 0.000 0.332 0.528 0.108
#> GSM123799     3  0.6357     0.2698 0.012 0.000 0.496 0.372 0.120
#> GSM123730     4  0.6644    -0.0404 0.040 0.000 0.140 0.572 0.248
#> GSM123734     4  0.5111     0.2750 0.152 0.000 0.044 0.740 0.064
#> GSM123738     4  0.4652     0.2677 0.008 0.000 0.144 0.756 0.092
#> GSM123742     4  0.7483     0.0297 0.264 0.000 0.048 0.440 0.248
#> GSM123745     1  0.4634     0.6317 0.744 0.000 0.000 0.136 0.120
#> GSM123748     1  0.5847     0.5546 0.664 0.000 0.024 0.152 0.160
#> GSM123751     1  0.4149     0.6885 0.792 0.000 0.004 0.124 0.080
#> GSM123754     1  0.2654     0.7317 0.884 0.000 0.000 0.032 0.084
#> GSM123757     1  0.2712     0.7178 0.880 0.000 0.032 0.000 0.088
#> GSM123760     4  0.6711     0.0798 0.156 0.000 0.052 0.588 0.204
#> GSM123762     4  0.7534     0.0498 0.312 0.000 0.052 0.420 0.216
#> GSM123764     4  0.6513    -0.3069 0.012 0.000 0.208 0.548 0.232
#> GSM123767     1  0.2645     0.7178 0.888 0.000 0.000 0.068 0.044
#> GSM123770     1  0.0693     0.7380 0.980 0.000 0.000 0.008 0.012
#> GSM123773     1  0.2074     0.7317 0.920 0.000 0.000 0.036 0.044
#> GSM123777     4  0.7114    -0.2479 0.020 0.000 0.320 0.428 0.232
#> GSM123779     4  0.7661    -0.1240 0.164 0.000 0.096 0.464 0.276
#> GSM123782     5  0.7629     0.0000 0.044 0.000 0.284 0.332 0.340
#> GSM123786     3  0.2903     0.5091 0.000 0.000 0.872 0.048 0.080
#> GSM123789     4  0.7023    -0.2827 0.032 0.000 0.228 0.508 0.232
#> GSM123793     4  0.3191     0.2696 0.012 0.000 0.060 0.868 0.060
#> GSM123797     4  0.4156     0.2807 0.012 0.000 0.120 0.800 0.068
#> GSM123729     2  0.1671     0.9541 0.000 0.924 0.000 0.000 0.076
#> GSM123733     2  0.1270     0.9629 0.000 0.948 0.000 0.000 0.052
#> GSM123737     2  0.1671     0.9580 0.000 0.924 0.000 0.000 0.076
#> GSM123741     2  0.0880     0.9627 0.000 0.968 0.000 0.000 0.032
#> GSM123747     2  0.0963     0.9663 0.000 0.964 0.000 0.000 0.036
#> GSM123753     2  0.1121     0.9607 0.000 0.956 0.000 0.000 0.044
#> GSM123759     2  0.1341     0.9643 0.000 0.944 0.000 0.000 0.056
#> GSM123766     2  0.1270     0.9627 0.000 0.948 0.000 0.000 0.052
#> GSM123772     2  0.0963     0.9649 0.000 0.964 0.000 0.000 0.036
#> GSM123775     2  0.1908     0.9468 0.000 0.908 0.000 0.000 0.092
#> GSM123781     2  0.1043     0.9620 0.000 0.960 0.000 0.000 0.040
#> GSM123785     2  0.1410     0.9609 0.000 0.940 0.000 0.000 0.060
#> GSM123788     2  0.1197     0.9619 0.000 0.952 0.000 0.000 0.048
#> GSM123792     2  0.0963     0.9627 0.000 0.964 0.000 0.000 0.036
#> GSM123796     2  0.0794     0.9661 0.000 0.972 0.000 0.000 0.028
#> GSM123731     2  0.0963     0.9661 0.000 0.964 0.000 0.000 0.036
#> GSM123735     2  0.1410     0.9606 0.000 0.940 0.000 0.000 0.060
#> GSM123739     2  0.1671     0.9584 0.000 0.924 0.000 0.000 0.076
#> GSM123743     2  0.0963     0.9646 0.000 0.964 0.000 0.000 0.036
#> GSM123749     2  0.0794     0.9664 0.000 0.972 0.000 0.000 0.028
#> GSM123755     2  0.1121     0.9597 0.000 0.956 0.000 0.000 0.044
#> GSM123768     2  0.1197     0.9629 0.000 0.952 0.000 0.000 0.048
#> GSM123776     1  0.7099     0.0924 0.416 0.348 0.008 0.008 0.220
#> GSM123783     2  0.1908     0.9517 0.000 0.908 0.000 0.000 0.092
#> GSM123790     2  0.2942     0.8927 0.000 0.856 0.008 0.008 0.128
#> GSM123794     2  0.1478     0.9591 0.000 0.936 0.000 0.000 0.064
#> GSM123798     2  0.1043     0.9632 0.000 0.960 0.000 0.000 0.040

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.4127     0.5165 0.008 0.000 0.784 0.016 0.072 0.120
#> GSM123736     4  0.6295    -0.2138 0.004 0.000 0.356 0.428 0.012 0.200
#> GSM123740     3  0.6844     0.1835 0.004 0.000 0.372 0.364 0.044 0.216
#> GSM123744     6  0.7559     0.1526 0.176 0.000 0.244 0.084 0.044 0.452
#> GSM123746     1  0.6104     0.2861 0.572 0.000 0.056 0.020 0.064 0.288
#> GSM123750     6  0.7247     0.2628 0.336 0.000 0.136 0.060 0.040 0.428
#> GSM123752     1  0.7321    -0.2370 0.380 0.000 0.164 0.016 0.088 0.352
#> GSM123756     1  0.1844     0.7197 0.924 0.000 0.000 0.004 0.024 0.048
#> GSM123758     3  0.7090     0.1341 0.116 0.000 0.452 0.028 0.076 0.328
#> GSM123761     6  0.7393     0.2080 0.308 0.000 0.032 0.216 0.052 0.392
#> GSM123763     4  0.6979     0.2211 0.088 0.000 0.056 0.512 0.064 0.280
#> GSM123765     3  0.4822     0.5294 0.004 0.000 0.740 0.076 0.060 0.120
#> GSM123769     1  0.2344     0.7169 0.896 0.000 0.000 0.008 0.028 0.068
#> GSM123771     1  0.2796     0.7052 0.868 0.000 0.000 0.008 0.044 0.080
#> GSM123774     1  0.0717     0.7221 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM123778     3  0.5317     0.4900 0.008 0.000 0.700 0.072 0.076 0.144
#> GSM123780     3  0.6385     0.4243 0.000 0.000 0.568 0.096 0.184 0.152
#> GSM123784     3  0.4930     0.5219 0.000 0.000 0.728 0.088 0.084 0.100
#> GSM123787     3  0.5391     0.4751 0.004 0.000 0.688 0.064 0.104 0.140
#> GSM123791     3  0.7770     0.2310 0.016 0.000 0.356 0.176 0.160 0.292
#> GSM123795     4  0.6790    -0.0385 0.020 0.000 0.296 0.492 0.052 0.140
#> GSM123799     3  0.7020     0.2615 0.016 0.000 0.408 0.316 0.040 0.220
#> GSM123730     4  0.7505     0.2940 0.044 0.004 0.108 0.492 0.228 0.124
#> GSM123734     4  0.4625     0.3649 0.120 0.000 0.016 0.760 0.032 0.072
#> GSM123738     4  0.4905     0.3580 0.008 0.000 0.112 0.740 0.068 0.072
#> GSM123742     4  0.7923    -0.0764 0.228 0.000 0.048 0.332 0.084 0.308
#> GSM123745     1  0.5107     0.5934 0.708 0.000 0.000 0.132 0.088 0.072
#> GSM123748     1  0.6249     0.3345 0.576 0.000 0.004 0.092 0.092 0.236
#> GSM123751     1  0.5482     0.5649 0.692 0.000 0.008 0.116 0.092 0.092
#> GSM123754     1  0.3347     0.7046 0.848 0.000 0.004 0.040 0.072 0.036
#> GSM123757     1  0.3964     0.6552 0.792 0.000 0.016 0.004 0.068 0.120
#> GSM123760     4  0.7153     0.1362 0.136 0.000 0.028 0.456 0.072 0.308
#> GSM123762     4  0.7586    -0.1162 0.268 0.000 0.044 0.364 0.048 0.276
#> GSM123764     4  0.8062     0.1474 0.028 0.000 0.200 0.328 0.172 0.272
#> GSM123767     1  0.3798     0.6704 0.812 0.000 0.000 0.060 0.088 0.040
#> GSM123770     1  0.0622     0.7218 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM123773     1  0.2965     0.6867 0.864 0.000 0.000 0.036 0.076 0.024
#> GSM123777     4  0.7803     0.0936 0.020 0.000 0.248 0.368 0.232 0.132
#> GSM123779     4  0.8228     0.2245 0.104 0.000 0.092 0.376 0.256 0.172
#> GSM123782     6  0.8203    -0.1382 0.040 0.000 0.280 0.228 0.152 0.300
#> GSM123786     3  0.4370     0.5042 0.000 0.000 0.748 0.040 0.044 0.168
#> GSM123789     4  0.7860     0.2597 0.040 0.000 0.164 0.428 0.160 0.208
#> GSM123793     4  0.3010     0.4126 0.008 0.000 0.036 0.872 0.028 0.056
#> GSM123797     4  0.3784     0.4120 0.016 0.000 0.072 0.828 0.044 0.040
#> GSM123729     2  0.2442     0.8710 0.000 0.852 0.000 0.000 0.144 0.004
#> GSM123733     2  0.2219     0.8779 0.000 0.864 0.000 0.000 0.136 0.000
#> GSM123737     2  0.2320     0.8819 0.000 0.864 0.000 0.000 0.132 0.004
#> GSM123741     2  0.1082     0.9049 0.000 0.956 0.000 0.000 0.040 0.004
#> GSM123747     2  0.1204     0.9055 0.000 0.944 0.000 0.000 0.056 0.000
#> GSM123753     2  0.1219     0.8971 0.000 0.948 0.000 0.000 0.048 0.004
#> GSM123759     2  0.1285     0.8990 0.000 0.944 0.000 0.000 0.052 0.004
#> GSM123766     2  0.1265     0.9023 0.000 0.948 0.000 0.000 0.044 0.008
#> GSM123772     2  0.1349     0.9071 0.000 0.940 0.000 0.000 0.056 0.004
#> GSM123775     2  0.2527     0.8356 0.000 0.832 0.000 0.000 0.168 0.000
#> GSM123781     2  0.1584     0.8897 0.000 0.928 0.000 0.000 0.064 0.008
#> GSM123785     2  0.1765     0.8983 0.000 0.904 0.000 0.000 0.096 0.000
#> GSM123788     2  0.2212     0.8914 0.000 0.880 0.000 0.000 0.112 0.008
#> GSM123792     2  0.1910     0.8905 0.000 0.892 0.000 0.000 0.108 0.000
#> GSM123796     2  0.2053     0.8895 0.000 0.888 0.000 0.000 0.108 0.004
#> GSM123731     2  0.1531     0.9062 0.000 0.928 0.000 0.000 0.068 0.004
#> GSM123735     2  0.2219     0.8766 0.000 0.864 0.000 0.000 0.136 0.000
#> GSM123739     2  0.2300     0.8741 0.000 0.856 0.000 0.000 0.144 0.000
#> GSM123743     2  0.1387     0.9049 0.000 0.932 0.000 0.000 0.068 0.000
#> GSM123749     2  0.1075     0.8992 0.000 0.952 0.000 0.000 0.048 0.000
#> GSM123755     2  0.1700     0.8953 0.000 0.916 0.000 0.000 0.080 0.004
#> GSM123768     2  0.1584     0.8900 0.000 0.928 0.000 0.000 0.064 0.008
#> GSM123776     5  0.7306     0.0000 0.344 0.236 0.008 0.016 0.356 0.040
#> GSM123783     2  0.2377     0.8640 0.000 0.868 0.004 0.000 0.124 0.004
#> GSM123790     2  0.4002     0.7109 0.000 0.736 0.016 0.004 0.228 0.016
#> GSM123794     2  0.2520     0.8608 0.000 0.844 0.000 0.000 0.152 0.004
#> GSM123798     2  0.1462     0.8971 0.000 0.936 0.000 0.000 0.056 0.008

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) infection(p) agent(p) k
#> CV:skmeans 71         3.82e-16     3.82e-16 6.04e-06 2
#> CV:skmeans 65         1.81e-13     1.81e-13 3.18e-05 3
#> CV:skmeans 61         8.44e-17     8.44e-17 4.26e-04 4
#> CV:skmeans 42         6.21e-09     6.21e-09 1.02e-02 5
#> CV:skmeans 41         2.70e-09     2.70e-09 1.31e-02 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 71 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-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.862           0.953       0.974        0.48594 0.522   0.522
#> 3 3 0.915           0.940       0.965        0.35676 0.825   0.665
#> 4 4 0.880           0.864       0.938        0.03884 0.989   0.968
#> 5 5 0.846           0.843       0.915        0.01308 0.994   0.983
#> 6 6 0.829           0.846       0.927        0.00937 0.995   0.984

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
#> GSM123732     1  0.6887      0.816 0.816 0.184
#> GSM123736     1  0.0000      0.957 1.000 0.000
#> GSM123740     1  0.0000      0.957 1.000 0.000
#> GSM123744     1  0.0000      0.957 1.000 0.000
#> GSM123746     1  0.0000      0.957 1.000 0.000
#> GSM123750     1  0.0000      0.957 1.000 0.000
#> GSM123752     1  0.0000      0.957 1.000 0.000
#> GSM123756     1  0.0000      0.957 1.000 0.000
#> GSM123758     1  0.0000      0.957 1.000 0.000
#> GSM123761     1  0.0000      0.957 1.000 0.000
#> GSM123763     1  0.0000      0.957 1.000 0.000
#> GSM123765     1  0.5946      0.860 0.856 0.144
#> GSM123769     1  0.0000      0.957 1.000 0.000
#> GSM123771     1  0.0000      0.957 1.000 0.000
#> GSM123774     1  0.0000      0.957 1.000 0.000
#> GSM123778     1  0.5294      0.881 0.880 0.120
#> GSM123780     1  0.6247      0.848 0.844 0.156
#> GSM123784     1  0.0376      0.955 0.996 0.004
#> GSM123787     1  0.4562      0.900 0.904 0.096
#> GSM123791     1  0.0000      0.957 1.000 0.000
#> GSM123795     1  0.0376      0.955 0.996 0.004
#> GSM123799     1  0.1633      0.946 0.976 0.024
#> GSM123730     1  0.8207      0.718 0.744 0.256
#> GSM123734     1  0.0000      0.957 1.000 0.000
#> GSM123738     1  0.0000      0.957 1.000 0.000
#> GSM123742     1  0.0000      0.957 1.000 0.000
#> GSM123745     1  0.7219      0.761 0.800 0.200
#> GSM123748     1  0.0000      0.957 1.000 0.000
#> GSM123751     1  0.0000      0.957 1.000 0.000
#> GSM123754     1  0.0000      0.957 1.000 0.000
#> GSM123757     1  0.0000      0.957 1.000 0.000
#> GSM123760     1  0.0000      0.957 1.000 0.000
#> GSM123762     1  0.0000      0.957 1.000 0.000
#> GSM123764     1  0.3274      0.926 0.940 0.060
#> GSM123767     1  0.2423      0.934 0.960 0.040
#> GSM123770     1  0.0000      0.957 1.000 0.000
#> GSM123773     1  0.0000      0.957 1.000 0.000
#> GSM123777     1  0.8207      0.718 0.744 0.256
#> GSM123779     1  0.1843      0.945 0.972 0.028
#> GSM123782     1  0.5842      0.864 0.860 0.140
#> GSM123786     1  0.5737      0.868 0.864 0.136
#> GSM123789     1  0.0000      0.957 1.000 0.000
#> GSM123793     1  0.0000      0.957 1.000 0.000
#> GSM123797     1  0.0000      0.957 1.000 0.000
#> GSM123729     2  0.0000      0.999 0.000 1.000
#> GSM123733     2  0.0000      0.999 0.000 1.000
#> GSM123737     2  0.0000      0.999 0.000 1.000
#> GSM123741     2  0.0000      0.999 0.000 1.000
#> GSM123747     2  0.0000      0.999 0.000 1.000
#> GSM123753     2  0.0000      0.999 0.000 1.000
#> GSM123759     2  0.0000      0.999 0.000 1.000
#> GSM123766     2  0.0000      0.999 0.000 1.000
#> GSM123772     2  0.0000      0.999 0.000 1.000
#> GSM123775     2  0.0000      0.999 0.000 1.000
#> GSM123781     2  0.0000      0.999 0.000 1.000
#> GSM123785     2  0.0000      0.999 0.000 1.000
#> GSM123788     2  0.0000      0.999 0.000 1.000
#> GSM123792     2  0.0000      0.999 0.000 1.000
#> GSM123796     2  0.0000      0.999 0.000 1.000
#> GSM123731     2  0.0000      0.999 0.000 1.000
#> GSM123735     2  0.0000      0.999 0.000 1.000
#> GSM123739     2  0.0000      0.999 0.000 1.000
#> GSM123743     2  0.0000      0.999 0.000 1.000
#> GSM123749     2  0.0000      0.999 0.000 1.000
#> GSM123755     2  0.0000      0.999 0.000 1.000
#> GSM123768     2  0.0000      0.999 0.000 1.000
#> GSM123776     2  0.1184      0.983 0.016 0.984
#> GSM123783     2  0.0000      0.999 0.000 1.000
#> GSM123790     2  0.0000      0.999 0.000 1.000
#> GSM123794     2  0.0000      0.999 0.000 1.000
#> GSM123798     2  0.0000      0.999 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
#> GSM123732     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123736     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123740     3  0.2796      0.885 0.092 0.000 0.908
#> GSM123744     3  0.1860      0.903 0.052 0.000 0.948
#> GSM123746     3  0.5363      0.724 0.276 0.000 0.724
#> GSM123750     3  0.0747      0.916 0.016 0.000 0.984
#> GSM123752     3  0.5098      0.759 0.248 0.000 0.752
#> GSM123756     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123758     3  0.4931      0.776 0.232 0.000 0.768
#> GSM123761     3  0.5760      0.644 0.328 0.000 0.672
#> GSM123763     3  0.5058      0.763 0.244 0.000 0.756
#> GSM123765     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123769     1  0.1163      0.968 0.972 0.000 0.028
#> GSM123771     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123774     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123778     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123780     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123784     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123787     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123791     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123795     3  0.0237      0.919 0.004 0.000 0.996
#> GSM123799     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123730     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123734     1  0.1643      0.953 0.956 0.000 0.044
#> GSM123738     3  0.3752      0.855 0.144 0.000 0.856
#> GSM123742     1  0.2165      0.928 0.936 0.000 0.064
#> GSM123745     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123748     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123751     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123754     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123757     1  0.0592      0.980 0.988 0.000 0.012
#> GSM123760     3  0.5760      0.622 0.328 0.000 0.672
#> GSM123762     1  0.0237      0.986 0.996 0.000 0.004
#> GSM123764     3  0.0237      0.919 0.004 0.000 0.996
#> GSM123767     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123770     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123773     1  0.0000      0.988 1.000 0.000 0.000
#> GSM123777     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123779     3  0.3551      0.863 0.132 0.000 0.868
#> GSM123782     3  0.0237      0.919 0.004 0.000 0.996
#> GSM123786     3  0.0000      0.919 0.000 0.000 1.000
#> GSM123789     3  0.3879      0.848 0.152 0.000 0.848
#> GSM123793     3  0.0424      0.917 0.008 0.000 0.992
#> GSM123797     3  0.0592      0.916 0.012 0.000 0.988
#> GSM123729     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123733     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123737     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123741     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123747     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123753     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123775     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123781     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123785     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123788     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123792     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123796     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123731     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123735     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123739     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123743     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123776     2  0.2096      0.941 0.052 0.944 0.004
#> GSM123783     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123790     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123794     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123798     2  0.0000      0.998 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123736     3  0.1302      0.848 0.000 0.000 0.956 0.044
#> GSM123740     3  0.3354      0.818 0.084 0.000 0.872 0.044
#> GSM123744     3  0.1389      0.850 0.048 0.000 0.952 0.000
#> GSM123746     3  0.4594      0.654 0.280 0.000 0.712 0.008
#> GSM123750     3  0.0895      0.859 0.020 0.000 0.976 0.004
#> GSM123752     3  0.4040      0.700 0.248 0.000 0.752 0.000
#> GSM123756     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM123758     3  0.3837      0.727 0.224 0.000 0.776 0.000
#> GSM123761     3  0.6873      0.502 0.252 0.000 0.588 0.160
#> GSM123763     3  0.6079      0.532 0.072 0.000 0.628 0.300
#> GSM123765     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123769     1  0.1913      0.903 0.940 0.000 0.020 0.040
#> GSM123771     1  0.0817      0.918 0.976 0.000 0.000 0.024
#> GSM123774     1  0.0921      0.918 0.972 0.000 0.000 0.028
#> GSM123778     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123780     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123784     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123787     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123791     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123795     3  0.1489      0.848 0.004 0.000 0.952 0.044
#> GSM123799     3  0.0188      0.861 0.000 0.000 0.996 0.004
#> GSM123730     3  0.0657      0.860 0.004 0.000 0.984 0.012
#> GSM123734     1  0.4877      0.375 0.592 0.000 0.000 0.408
#> GSM123738     3  0.5050      0.653 0.028 0.000 0.704 0.268
#> GSM123742     1  0.1474      0.871 0.948 0.000 0.052 0.000
#> GSM123745     1  0.0592      0.921 0.984 0.000 0.000 0.016
#> GSM123748     1  0.0000      0.920 1.000 0.000 0.000 0.000
#> GSM123751     1  0.0188      0.922 0.996 0.000 0.000 0.004
#> GSM123754     1  0.0336      0.922 0.992 0.000 0.000 0.008
#> GSM123757     1  0.0657      0.913 0.984 0.000 0.012 0.004
#> GSM123760     3  0.7554      0.213 0.244 0.000 0.488 0.268
#> GSM123762     1  0.4632      0.550 0.688 0.000 0.004 0.308
#> GSM123764     3  0.0524      0.862 0.004 0.000 0.988 0.008
#> GSM123767     1  0.0592      0.921 0.984 0.000 0.000 0.016
#> GSM123770     1  0.0817      0.920 0.976 0.000 0.000 0.024
#> GSM123773     1  0.0592      0.921 0.984 0.000 0.000 0.016
#> GSM123777     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123779     3  0.3529      0.784 0.152 0.000 0.836 0.012
#> GSM123782     3  0.0188      0.862 0.004 0.000 0.996 0.000
#> GSM123786     3  0.0000      0.862 0.000 0.000 1.000 0.000
#> GSM123789     3  0.4605      0.771 0.108 0.000 0.800 0.092
#> GSM123793     4  0.2124      0.000 0.008 0.000 0.068 0.924
#> GSM123797     3  0.4360      0.692 0.008 0.000 0.744 0.248
#> GSM123729     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123733     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123737     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123741     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123753     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123766     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123781     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123785     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123788     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123792     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123796     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123731     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123735     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123739     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123743     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123768     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123776     2  0.1545      0.942 0.040 0.952 0.008 0.000
#> GSM123783     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123790     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123794     2  0.0000      0.998 0.000 1.000 0.000 0.000
#> GSM123798     2  0.0000      0.998 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1   p2    p3    p4    p5
#> GSM123732     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123736     3  0.2707      0.814 0.000 0.00 0.860 0.008 0.132
#> GSM123740     3  0.3857      0.801 0.048 0.00 0.812 0.008 0.132
#> GSM123744     3  0.1197      0.852 0.048 0.00 0.952 0.000 0.000
#> GSM123746     3  0.4088      0.652 0.304 0.00 0.688 0.000 0.008
#> GSM123750     3  0.0771      0.859 0.020 0.00 0.976 0.000 0.004
#> GSM123752     3  0.3661      0.691 0.276 0.00 0.724 0.000 0.000
#> GSM123756     1  0.2172      0.862 0.908 0.00 0.000 0.076 0.016
#> GSM123758     3  0.3480      0.721 0.248 0.00 0.752 0.000 0.000
#> GSM123761     3  0.6540      0.515 0.276 0.00 0.572 0.044 0.108
#> GSM123763     3  0.6487      0.577 0.064 0.00 0.620 0.116 0.200
#> GSM123765     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123769     1  0.2930      0.847 0.880 0.00 0.012 0.076 0.032
#> GSM123771     1  0.2046      0.867 0.916 0.00 0.000 0.068 0.016
#> GSM123774     1  0.2270      0.861 0.904 0.00 0.000 0.076 0.020
#> GSM123778     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123780     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123784     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123787     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123791     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123795     3  0.2865      0.814 0.004 0.00 0.856 0.008 0.132
#> GSM123799     3  0.0162      0.861 0.000 0.00 0.996 0.000 0.004
#> GSM123730     3  0.0566      0.859 0.004 0.00 0.984 0.000 0.012
#> GSM123734     5  0.4577      0.000 0.176 0.00 0.000 0.084 0.740
#> GSM123738     3  0.4676      0.709 0.032 0.00 0.696 0.008 0.264
#> GSM123742     1  0.1270      0.839 0.948 0.00 0.052 0.000 0.000
#> GSM123745     1  0.0510      0.897 0.984 0.00 0.000 0.000 0.016
#> GSM123748     1  0.0000      0.895 1.000 0.00 0.000 0.000 0.000
#> GSM123751     1  0.0162      0.897 0.996 0.00 0.000 0.000 0.004
#> GSM123754     1  0.0290      0.898 0.992 0.00 0.000 0.000 0.008
#> GSM123757     1  0.0566      0.887 0.984 0.00 0.012 0.000 0.004
#> GSM123760     3  0.7621      0.228 0.264 0.00 0.468 0.084 0.184
#> GSM123762     1  0.6315     -0.148 0.484 0.00 0.004 0.140 0.372
#> GSM123764     3  0.0451      0.861 0.004 0.00 0.988 0.000 0.008
#> GSM123767     1  0.0671      0.897 0.980 0.00 0.000 0.004 0.016
#> GSM123770     1  0.1018      0.896 0.968 0.00 0.000 0.016 0.016
#> GSM123773     1  0.0510      0.897 0.984 0.00 0.000 0.000 0.016
#> GSM123777     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123779     3  0.3039      0.796 0.152 0.00 0.836 0.000 0.012
#> GSM123782     3  0.0162      0.861 0.004 0.00 0.996 0.000 0.000
#> GSM123786     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000
#> GSM123789     3  0.4338      0.789 0.112 0.00 0.800 0.040 0.048
#> GSM123793     4  0.2077      0.000 0.000 0.00 0.008 0.908 0.084
#> GSM123797     3  0.4209      0.735 0.008 0.00 0.732 0.016 0.244
#> GSM123729     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123733     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123737     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123741     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123759     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123766     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123775     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123781     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123785     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123788     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123731     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123735     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123739     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123743     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123749     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123755     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123768     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123776     2  0.2201      0.906 0.040 0.92 0.008 0.032 0.000
#> GSM123783     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123790     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123794     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000
#> GSM123798     2  0.0000      0.997 0.000 1.00 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1   p2    p3    p4    p5    p6
#> GSM123732     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123736     3  0.2680      0.815 0.000 0.00 0.856 0.124 0.016 0.004
#> GSM123740     3  0.3712      0.802 0.048 0.00 0.808 0.124 0.016 0.004
#> GSM123744     3  0.1075      0.852 0.048 0.00 0.952 0.000 0.000 0.000
#> GSM123746     3  0.3714      0.629 0.340 0.00 0.656 0.000 0.000 0.004
#> GSM123750     3  0.0692      0.859 0.020 0.00 0.976 0.000 0.000 0.004
#> GSM123752     3  0.3482      0.660 0.316 0.00 0.684 0.000 0.000 0.000
#> GSM123756     1  0.2697      0.822 0.812 0.00 0.000 0.000 0.000 0.188
#> GSM123758     3  0.3309      0.699 0.280 0.00 0.720 0.000 0.000 0.000
#> GSM123761     3  0.5424      0.551 0.288 0.00 0.580 0.008 0.000 0.124
#> GSM123763     3  0.5953      0.606 0.072 0.00 0.632 0.060 0.024 0.212
#> GSM123765     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123769     1  0.3515      0.804 0.780 0.00 0.012 0.016 0.000 0.192
#> GSM123771     1  0.2416      0.843 0.844 0.00 0.000 0.000 0.000 0.156
#> GSM123774     1  0.2697      0.822 0.812 0.00 0.000 0.000 0.000 0.188
#> GSM123778     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123780     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123784     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123791     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123795     3  0.2822      0.814 0.004 0.00 0.852 0.124 0.016 0.004
#> GSM123799     3  0.0260      0.860 0.000 0.00 0.992 0.008 0.000 0.000
#> GSM123730     3  0.0458      0.859 0.000 0.00 0.984 0.016 0.000 0.000
#> GSM123734     4  0.2662      0.000 0.000 0.00 0.000 0.856 0.024 0.120
#> GSM123738     3  0.4602      0.743 0.028 0.00 0.724 0.204 0.016 0.028
#> GSM123742     1  0.1010      0.880 0.960 0.00 0.036 0.000 0.000 0.004
#> GSM123745     1  0.0717      0.913 0.976 0.00 0.000 0.016 0.000 0.008
#> GSM123748     1  0.0000      0.909 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM123751     1  0.0405      0.912 0.988 0.00 0.000 0.008 0.000 0.004
#> GSM123754     1  0.0291      0.911 0.992 0.00 0.000 0.004 0.000 0.004
#> GSM123757     1  0.0363      0.903 0.988 0.00 0.012 0.000 0.000 0.000
#> GSM123760     3  0.7024      0.302 0.292 0.00 0.472 0.060 0.024 0.152
#> GSM123762     6  0.2510      0.000 0.024 0.00 0.000 0.060 0.024 0.892
#> GSM123764     3  0.0405      0.861 0.004 0.00 0.988 0.008 0.000 0.000
#> GSM123767     1  0.0820      0.912 0.972 0.00 0.000 0.016 0.000 0.012
#> GSM123770     1  0.1461      0.904 0.940 0.00 0.000 0.016 0.000 0.044
#> GSM123773     1  0.0717      0.912 0.976 0.00 0.000 0.016 0.000 0.008
#> GSM123777     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123779     3  0.2945      0.793 0.156 0.00 0.824 0.020 0.000 0.000
#> GSM123782     3  0.0146      0.861 0.004 0.00 0.996 0.000 0.000 0.000
#> GSM123786     3  0.0000      0.861 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM123789     3  0.4146      0.785 0.120 0.00 0.792 0.028 0.016 0.044
#> GSM123793     5  0.0146      0.000 0.000 0.00 0.000 0.000 0.996 0.004
#> GSM123797     3  0.3945      0.767 0.000 0.00 0.764 0.184 0.024 0.028
#> GSM123729     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123737     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123781     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123739     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123776     2  0.2586      0.858 0.032 0.88 0.008 0.000 0.000 0.080
#> GSM123783     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123790     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM123798     2  0.0000      0.995 0.000 1.00 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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) infection(p) agent(p) k
#> CV:pam 71         3.82e-16     3.82e-16 6.04e-06 2
#> CV:pam 71         2.84e-16     2.84e-16 7.76e-06 3
#> CV:pam 68         7.80e-16     7.80e-16 1.57e-05 4
#> CV:pam 67         2.36e-15     2.36e-15 1.98e-05 5
#> CV:pam 67         2.36e-15     2.36e-15 1.98e-05 6

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


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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.994       0.997         0.4636 0.537   0.537
#> 3 3 0.849           0.896       0.938         0.3158 0.855   0.730
#> 4 4 0.900           0.846       0.935         0.2002 0.826   0.580
#> 5 5 0.938           0.895       0.941         0.0446 0.948   0.810
#> 6 6 0.864           0.850       0.893         0.0311 0.973   0.885

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      0.997 1.000 0.000
#> GSM123736     1  0.0000      0.997 1.000 0.000
#> GSM123740     1  0.0000      0.997 1.000 0.000
#> GSM123744     1  0.0000      0.997 1.000 0.000
#> GSM123746     1  0.0000      0.997 1.000 0.000
#> GSM123750     1  0.0000      0.997 1.000 0.000
#> GSM123752     1  0.0000      0.997 1.000 0.000
#> GSM123756     1  0.0000      0.997 1.000 0.000
#> GSM123758     1  0.0000      0.997 1.000 0.000
#> GSM123761     1  0.0000      0.997 1.000 0.000
#> GSM123763     1  0.0000      0.997 1.000 0.000
#> GSM123765     1  0.0000      0.997 1.000 0.000
#> GSM123769     1  0.0000      0.997 1.000 0.000
#> GSM123771     1  0.0000      0.997 1.000 0.000
#> GSM123774     1  0.0000      0.997 1.000 0.000
#> GSM123778     1  0.0000      0.997 1.000 0.000
#> GSM123780     1  0.0000      0.997 1.000 0.000
#> GSM123784     1  0.0000      0.997 1.000 0.000
#> GSM123787     1  0.0000      0.997 1.000 0.000
#> GSM123791     1  0.0000      0.997 1.000 0.000
#> GSM123795     1  0.0000      0.997 1.000 0.000
#> GSM123799     1  0.0000      0.997 1.000 0.000
#> GSM123730     1  0.0000      0.997 1.000 0.000
#> GSM123734     1  0.0000      0.997 1.000 0.000
#> GSM123738     1  0.0000      0.997 1.000 0.000
#> GSM123742     1  0.0000      0.997 1.000 0.000
#> GSM123745     1  0.0000      0.997 1.000 0.000
#> GSM123748     1  0.0000      0.997 1.000 0.000
#> GSM123751     1  0.0000      0.997 1.000 0.000
#> GSM123754     1  0.0000      0.997 1.000 0.000
#> GSM123757     1  0.0000      0.997 1.000 0.000
#> GSM123760     1  0.0000      0.997 1.000 0.000
#> GSM123762     1  0.0000      0.997 1.000 0.000
#> GSM123764     1  0.0000      0.997 1.000 0.000
#> GSM123767     1  0.0000      0.997 1.000 0.000
#> GSM123770     1  0.0000      0.997 1.000 0.000
#> GSM123773     1  0.0000      0.997 1.000 0.000
#> GSM123777     1  0.0000      0.997 1.000 0.000
#> GSM123779     1  0.0000      0.997 1.000 0.000
#> GSM123782     1  0.0000      0.997 1.000 0.000
#> GSM123786     1  0.0000      0.997 1.000 0.000
#> GSM123789     1  0.0000      0.997 1.000 0.000
#> GSM123793     1  0.0000      0.997 1.000 0.000
#> GSM123797     1  0.0000      0.997 1.000 0.000
#> GSM123729     2  0.0000      0.996 0.000 1.000
#> GSM123733     2  0.0000      0.996 0.000 1.000
#> GSM123737     2  0.0000      0.996 0.000 1.000
#> GSM123741     2  0.0000      0.996 0.000 1.000
#> GSM123747     2  0.0000      0.996 0.000 1.000
#> GSM123753     2  0.0000      0.996 0.000 1.000
#> GSM123759     2  0.0000      0.996 0.000 1.000
#> GSM123766     2  0.0000      0.996 0.000 1.000
#> GSM123772     2  0.0000      0.996 0.000 1.000
#> GSM123775     2  0.0672      0.989 0.008 0.992
#> GSM123781     2  0.0000      0.996 0.000 1.000
#> GSM123785     2  0.0000      0.996 0.000 1.000
#> GSM123788     2  0.0000      0.996 0.000 1.000
#> GSM123792     2  0.0000      0.996 0.000 1.000
#> GSM123796     2  0.0000      0.996 0.000 1.000
#> GSM123731     2  0.0000      0.996 0.000 1.000
#> GSM123735     2  0.0000      0.996 0.000 1.000
#> GSM123739     2  0.0000      0.996 0.000 1.000
#> GSM123743     2  0.0000      0.996 0.000 1.000
#> GSM123749     2  0.0000      0.996 0.000 1.000
#> GSM123755     2  0.0000      0.996 0.000 1.000
#> GSM123768     2  0.0000      0.996 0.000 1.000
#> GSM123776     1  0.0000      0.997 1.000 0.000
#> GSM123783     2  0.3879      0.918 0.076 0.924
#> GSM123790     1  0.5408      0.858 0.876 0.124
#> GSM123794     2  0.0000      0.996 0.000 1.000
#> GSM123798     2  0.0000      0.996 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
#> GSM123732     3  0.6062      0.594 0.384 0.000 0.616
#> GSM123736     3  0.6280      0.398 0.460 0.000 0.540
#> GSM123740     3  0.3619      0.916 0.136 0.000 0.864
#> GSM123744     1  0.1753      0.882 0.952 0.000 0.048
#> GSM123746     1  0.2261      0.900 0.932 0.000 0.068
#> GSM123750     1  0.1529      0.888 0.960 0.000 0.040
#> GSM123752     1  0.1753      0.882 0.952 0.000 0.048
#> GSM123756     1  0.3482      0.861 0.872 0.000 0.128
#> GSM123758     1  0.1753      0.882 0.952 0.000 0.048
#> GSM123761     1  0.0237      0.910 0.996 0.000 0.004
#> GSM123763     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123765     3  0.3551      0.916 0.132 0.000 0.868
#> GSM123769     1  0.3482      0.861 0.872 0.000 0.128
#> GSM123771     1  0.3482      0.861 0.872 0.000 0.128
#> GSM123774     1  0.3482      0.861 0.872 0.000 0.128
#> GSM123778     3  0.3482      0.916 0.128 0.000 0.872
#> GSM123780     1  0.6299     -0.271 0.524 0.000 0.476
#> GSM123784     3  0.3482      0.916 0.128 0.000 0.872
#> GSM123787     3  0.3482      0.916 0.128 0.000 0.872
#> GSM123791     3  0.3619      0.916 0.136 0.000 0.864
#> GSM123795     1  0.2356      0.857 0.928 0.000 0.072
#> GSM123799     3  0.3752      0.911 0.144 0.000 0.856
#> GSM123730     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123734     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123738     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123742     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123745     1  0.2796      0.886 0.908 0.000 0.092
#> GSM123748     1  0.2796      0.886 0.908 0.000 0.092
#> GSM123751     1  0.2711      0.888 0.912 0.000 0.088
#> GSM123754     1  0.2959      0.881 0.900 0.000 0.100
#> GSM123757     1  0.2537      0.891 0.920 0.000 0.080
#> GSM123760     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123762     1  0.0237      0.910 0.996 0.000 0.004
#> GSM123764     1  0.1289      0.894 0.968 0.000 0.032
#> GSM123767     1  0.2356      0.895 0.928 0.000 0.072
#> GSM123770     1  0.3412      0.864 0.876 0.000 0.124
#> GSM123773     1  0.2878      0.883 0.904 0.000 0.096
#> GSM123777     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123779     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123782     1  0.0592      0.905 0.988 0.000 0.012
#> GSM123786     3  0.3482      0.916 0.128 0.000 0.872
#> GSM123789     1  0.0237      0.909 0.996 0.000 0.004
#> GSM123793     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123797     1  0.0000      0.910 1.000 0.000 0.000
#> GSM123729     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123733     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123737     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123741     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123747     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123753     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123775     2  0.0424      0.989 0.008 0.992 0.000
#> GSM123781     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123785     2  0.0237      0.993 0.004 0.996 0.000
#> GSM123788     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123792     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123796     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123731     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123735     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123739     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123743     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123776     1  0.0747      0.909 0.984 0.000 0.016
#> GSM123783     2  0.1411      0.953 0.036 0.964 0.000
#> GSM123790     1  0.6008      0.318 0.628 0.372 0.000
#> GSM123794     2  0.0000      0.997 0.000 1.000 0.000
#> GSM123798     2  0.0000      0.997 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0188    0.87811 0.000 0.000 0.996 0.004
#> GSM123736     3  0.1211    0.85003 0.000 0.000 0.960 0.040
#> GSM123740     3  0.0188    0.87811 0.000 0.000 0.996 0.004
#> GSM123744     3  0.5143    0.08783 0.456 0.000 0.540 0.004
#> GSM123746     1  0.0817    0.88316 0.976 0.000 0.024 0.000
#> GSM123750     1  0.5167   -0.00594 0.508 0.000 0.488 0.004
#> GSM123752     1  0.5004    0.32781 0.604 0.000 0.392 0.004
#> GSM123756     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123758     3  0.5147    0.07432 0.460 0.000 0.536 0.004
#> GSM123761     1  0.3542    0.79300 0.852 0.000 0.120 0.028
#> GSM123763     4  0.4656    0.72078 0.160 0.000 0.056 0.784
#> GSM123765     3  0.0000    0.87806 0.000 0.000 1.000 0.000
#> GSM123769     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123771     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123774     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123778     3  0.0000    0.87806 0.000 0.000 1.000 0.000
#> GSM123780     3  0.2345    0.78163 0.000 0.000 0.900 0.100
#> GSM123784     3  0.0000    0.87806 0.000 0.000 1.000 0.000
#> GSM123787     3  0.0000    0.87806 0.000 0.000 1.000 0.000
#> GSM123791     3  0.0188    0.87811 0.000 0.000 0.996 0.004
#> GSM123795     4  0.5229    0.35833 0.008 0.000 0.428 0.564
#> GSM123799     3  0.0188    0.87811 0.000 0.000 0.996 0.004
#> GSM123730     4  0.0000    0.85092 0.000 0.000 0.000 1.000
#> GSM123734     4  0.0000    0.85092 0.000 0.000 0.000 1.000
#> GSM123738     4  0.0000    0.85092 0.000 0.000 0.000 1.000
#> GSM123742     1  0.5454    0.68713 0.732 0.000 0.096 0.172
#> GSM123745     1  0.0817    0.89105 0.976 0.000 0.000 0.024
#> GSM123748     1  0.0592    0.89266 0.984 0.000 0.000 0.016
#> GSM123751     1  0.0817    0.89105 0.976 0.000 0.000 0.024
#> GSM123754     1  0.0188    0.89253 0.996 0.000 0.000 0.004
#> GSM123757     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123760     4  0.2174    0.83695 0.020 0.000 0.052 0.928
#> GSM123762     1  0.5003    0.55194 0.676 0.000 0.016 0.308
#> GSM123764     4  0.3649    0.74336 0.000 0.000 0.204 0.796
#> GSM123767     1  0.0817    0.89105 0.976 0.000 0.000 0.024
#> GSM123770     1  0.0000    0.89205 1.000 0.000 0.000 0.000
#> GSM123773     1  0.0592    0.89266 0.984 0.000 0.000 0.016
#> GSM123777     4  0.0707    0.84979 0.000 0.000 0.020 0.980
#> GSM123779     4  0.1209    0.84340 0.032 0.000 0.004 0.964
#> GSM123782     4  0.6366    0.26993 0.064 0.000 0.424 0.512
#> GSM123786     3  0.0000    0.87806 0.000 0.000 1.000 0.000
#> GSM123789     4  0.3726    0.73586 0.000 0.000 0.212 0.788
#> GSM123793     4  0.0000    0.85092 0.000 0.000 0.000 1.000
#> GSM123797     4  0.0000    0.85092 0.000 0.000 0.000 1.000
#> GSM123729     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123733     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123737     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123741     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123753     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123766     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123781     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123785     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123788     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123792     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123796     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123731     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123735     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123739     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123743     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123768     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123776     1  0.0921    0.88925 0.972 0.000 0.000 0.028
#> GSM123783     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123790     2  0.1389    0.94517 0.000 0.952 0.000 0.048
#> GSM123794     2  0.0000    0.99791 0.000 1.000 0.000 0.000
#> GSM123798     2  0.0000    0.99791 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0703      0.930 0.000 0.000 0.976 0.000 0.024
#> GSM123736     3  0.2825      0.800 0.000 0.000 0.860 0.124 0.016
#> GSM123740     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123744     5  0.3011      0.868 0.016 0.000 0.140 0.000 0.844
#> GSM123746     5  0.4045      0.431 0.356 0.000 0.000 0.000 0.644
#> GSM123750     5  0.3532      0.868 0.048 0.000 0.128 0.000 0.824
#> GSM123752     5  0.3060      0.876 0.024 0.000 0.128 0.000 0.848
#> GSM123756     1  0.0510      0.937 0.984 0.000 0.000 0.000 0.016
#> GSM123758     5  0.3016      0.874 0.020 0.000 0.132 0.000 0.848
#> GSM123761     1  0.5708     -0.173 0.480 0.000 0.024 0.036 0.460
#> GSM123763     4  0.1393      0.883 0.012 0.000 0.008 0.956 0.024
#> GSM123765     3  0.0162      0.943 0.000 0.000 0.996 0.000 0.004
#> GSM123769     1  0.0510      0.937 0.984 0.000 0.000 0.000 0.016
#> GSM123771     1  0.0510      0.937 0.984 0.000 0.000 0.000 0.016
#> GSM123774     1  0.0510      0.937 0.984 0.000 0.000 0.000 0.016
#> GSM123778     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.3877      0.673 0.000 0.000 0.764 0.212 0.024
#> GSM123784     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123787     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123795     4  0.3381      0.770 0.000 0.000 0.176 0.808 0.016
#> GSM123799     3  0.0324      0.941 0.000 0.000 0.992 0.004 0.004
#> GSM123730     4  0.0963      0.883 0.000 0.000 0.000 0.964 0.036
#> GSM123734     4  0.1270      0.878 0.000 0.000 0.000 0.948 0.052
#> GSM123738     4  0.0609      0.883 0.000 0.000 0.000 0.980 0.020
#> GSM123742     4  0.4565      0.648 0.240 0.000 0.016 0.720 0.024
#> GSM123745     1  0.1041      0.926 0.964 0.000 0.000 0.004 0.032
#> GSM123748     1  0.0510      0.936 0.984 0.000 0.000 0.000 0.016
#> GSM123751     1  0.0693      0.932 0.980 0.000 0.000 0.008 0.012
#> GSM123754     1  0.0290      0.935 0.992 0.000 0.000 0.000 0.008
#> GSM123757     1  0.0609      0.934 0.980 0.000 0.000 0.000 0.020
#> GSM123760     4  0.1117      0.884 0.000 0.000 0.016 0.964 0.020
#> GSM123762     4  0.5015      0.359 0.392 0.000 0.004 0.576 0.028
#> GSM123764     4  0.2450      0.858 0.000 0.000 0.076 0.896 0.028
#> GSM123767     1  0.1041      0.926 0.964 0.000 0.000 0.004 0.032
#> GSM123770     1  0.0404      0.937 0.988 0.000 0.000 0.000 0.012
#> GSM123773     1  0.0880      0.927 0.968 0.000 0.000 0.000 0.032
#> GSM123777     4  0.0912      0.885 0.000 0.000 0.012 0.972 0.016
#> GSM123779     4  0.1329      0.885 0.008 0.000 0.004 0.956 0.032
#> GSM123782     4  0.3278      0.792 0.000 0.000 0.156 0.824 0.020
#> GSM123786     3  0.0000      0.945 0.000 0.000 1.000 0.000 0.000
#> GSM123789     4  0.1992      0.873 0.000 0.000 0.044 0.924 0.032
#> GSM123793     4  0.1270      0.878 0.000 0.000 0.000 0.948 0.052
#> GSM123797     4  0.1270      0.878 0.000 0.000 0.000 0.948 0.052
#> GSM123729     2  0.1043      0.971 0.000 0.960 0.000 0.000 0.040
#> GSM123733     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0510      0.982 0.000 0.984 0.000 0.000 0.016
#> GSM123741     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.1043      0.971 0.000 0.960 0.000 0.000 0.040
#> GSM123781     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.1121      0.969 0.000 0.956 0.000 0.000 0.044
#> GSM123788     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0162      0.986 0.000 0.996 0.000 0.000 0.004
#> GSM123739     2  0.1043      0.971 0.000 0.960 0.000 0.000 0.040
#> GSM123743     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.1043      0.971 0.000 0.960 0.000 0.000 0.040
#> GSM123776     1  0.1195      0.925 0.960 0.000 0.000 0.012 0.028
#> GSM123783     2  0.1043      0.971 0.000 0.960 0.000 0.000 0.040
#> GSM123790     2  0.2304      0.921 0.000 0.908 0.000 0.048 0.044
#> GSM123794     2  0.0404      0.983 0.000 0.988 0.000 0.000 0.012
#> GSM123798     2  0.0000      0.987 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.1082      0.907 0.000 0.000 0.956 0.000 0.040 0.004
#> GSM123736     3  0.3023      0.705 0.000 0.000 0.768 0.000 0.000 0.232
#> GSM123740     3  0.0363      0.928 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM123744     5  0.1757      0.796 0.012 0.000 0.052 0.000 0.928 0.008
#> GSM123746     5  0.3601      0.574 0.312 0.000 0.000 0.000 0.684 0.004
#> GSM123750     5  0.1977      0.800 0.032 0.000 0.040 0.000 0.920 0.008
#> GSM123752     5  0.1555      0.799 0.012 0.000 0.040 0.000 0.940 0.008
#> GSM123756     1  0.2201      0.908 0.896 0.000 0.000 0.076 0.028 0.000
#> GSM123758     5  0.1624      0.800 0.012 0.000 0.044 0.000 0.936 0.008
#> GSM123761     5  0.5188      0.337 0.388 0.000 0.008 0.004 0.540 0.060
#> GSM123763     6  0.1010      0.719 0.004 0.000 0.000 0.036 0.000 0.960
#> GSM123765     3  0.0363      0.928 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM123769     1  0.2201      0.908 0.896 0.000 0.000 0.076 0.028 0.000
#> GSM123771     1  0.2201      0.908 0.896 0.000 0.000 0.076 0.028 0.000
#> GSM123774     1  0.2201      0.908 0.896 0.000 0.000 0.076 0.028 0.000
#> GSM123778     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123780     3  0.3448      0.616 0.000 0.000 0.716 0.004 0.000 0.280
#> GSM123784     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123791     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123795     6  0.2597      0.621 0.000 0.000 0.176 0.000 0.000 0.824
#> GSM123799     3  0.0865      0.915 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM123730     4  0.3955      0.799 0.004 0.000 0.000 0.560 0.000 0.436
#> GSM123734     4  0.3371      0.891 0.000 0.000 0.000 0.708 0.000 0.292
#> GSM123738     4  0.3817      0.781 0.000 0.000 0.000 0.568 0.000 0.432
#> GSM123742     6  0.3161      0.594 0.156 0.000 0.012 0.004 0.008 0.820
#> GSM123745     1  0.1714      0.911 0.936 0.000 0.000 0.024 0.024 0.016
#> GSM123748     1  0.1369      0.921 0.952 0.000 0.000 0.016 0.016 0.016
#> GSM123751     1  0.1452      0.915 0.948 0.000 0.000 0.020 0.012 0.020
#> GSM123754     1  0.0520      0.923 0.984 0.000 0.000 0.008 0.000 0.008
#> GSM123757     1  0.2100      0.869 0.884 0.000 0.000 0.000 0.112 0.004
#> GSM123760     6  0.1155      0.720 0.000 0.000 0.004 0.036 0.004 0.956
#> GSM123762     6  0.5020      0.142 0.428 0.000 0.000 0.040 0.016 0.516
#> GSM123764     6  0.1556      0.714 0.000 0.000 0.080 0.000 0.000 0.920
#> GSM123767     1  0.1620      0.913 0.940 0.000 0.000 0.024 0.024 0.012
#> GSM123770     1  0.1408      0.919 0.944 0.000 0.000 0.036 0.020 0.000
#> GSM123773     1  0.1518      0.914 0.944 0.000 0.000 0.024 0.024 0.008
#> GSM123777     6  0.2053      0.614 0.000 0.000 0.004 0.108 0.000 0.888
#> GSM123779     6  0.1633      0.691 0.024 0.000 0.000 0.044 0.000 0.932
#> GSM123782     6  0.2520      0.641 0.000 0.000 0.152 0.004 0.000 0.844
#> GSM123786     3  0.0000      0.930 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123789     6  0.0547      0.726 0.000 0.000 0.020 0.000 0.000 0.980
#> GSM123793     4  0.3371      0.892 0.000 0.000 0.000 0.708 0.000 0.292
#> GSM123797     4  0.3351      0.890 0.000 0.000 0.000 0.712 0.000 0.288
#> GSM123729     2  0.2212      0.916 0.000 0.880 0.000 0.112 0.008 0.000
#> GSM123733     2  0.0777      0.949 0.000 0.972 0.000 0.024 0.004 0.000
#> GSM123737     2  0.1196      0.946 0.000 0.952 0.000 0.040 0.008 0.000
#> GSM123741     2  0.0508      0.950 0.000 0.984 0.000 0.012 0.004 0.000
#> GSM123747     2  0.0146      0.950 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM123753     2  0.0603      0.949 0.000 0.980 0.000 0.016 0.004 0.000
#> GSM123759     2  0.0405      0.950 0.000 0.988 0.000 0.008 0.004 0.000
#> GSM123766     2  0.0790      0.947 0.000 0.968 0.000 0.032 0.000 0.000
#> GSM123772     2  0.0713      0.946 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM123775     2  0.2257      0.913 0.000 0.876 0.000 0.116 0.008 0.000
#> GSM123781     2  0.0603      0.949 0.000 0.980 0.000 0.016 0.004 0.000
#> GSM123785     2  0.2706      0.893 0.000 0.832 0.000 0.160 0.008 0.000
#> GSM123788     2  0.1152      0.946 0.000 0.952 0.000 0.044 0.004 0.000
#> GSM123792     2  0.0405      0.950 0.000 0.988 0.000 0.008 0.004 0.000
#> GSM123796     2  0.0865      0.947 0.000 0.964 0.000 0.036 0.000 0.000
#> GSM123731     2  0.0777      0.947 0.000 0.972 0.000 0.024 0.004 0.000
#> GSM123735     2  0.1010      0.947 0.000 0.960 0.000 0.036 0.004 0.000
#> GSM123739     2  0.2118      0.920 0.000 0.888 0.000 0.104 0.008 0.000
#> GSM123743     2  0.0603      0.949 0.000 0.980 0.000 0.016 0.004 0.000
#> GSM123749     2  0.0777      0.947 0.000 0.972 0.000 0.024 0.004 0.000
#> GSM123755     2  0.0777      0.947 0.000 0.972 0.000 0.024 0.004 0.000
#> GSM123768     2  0.2146      0.915 0.000 0.880 0.000 0.116 0.004 0.000
#> GSM123776     1  0.2726      0.884 0.884 0.004 0.000 0.044 0.016 0.052
#> GSM123783     2  0.2288      0.913 0.000 0.876 0.000 0.116 0.004 0.004
#> GSM123790     2  0.3164      0.879 0.000 0.824 0.000 0.140 0.004 0.032
#> GSM123794     2  0.1471      0.939 0.000 0.932 0.000 0.064 0.004 0.000
#> GSM123798     2  0.0777      0.947 0.000 0.972 0.000 0.024 0.004 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-CV-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) infection(p) agent(p) k
#> CV:mclust 71         2.21e-14     2.21e-14 0.000470 2
#> CV:mclust 68         9.72e-16     9.72e-16 0.000249 3
#> CV:mclust 65         9.70e-17     9.70e-17 0.000858 4
#> CV:mclust 68         1.85e-17     1.85e-17 0.001245 5
#> CV:mclust 69         4.89e-17     4.89e-17 0.002482 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.992       0.997         0.4770 0.522   0.522
#> 3 3 0.883           0.893       0.944         0.3903 0.794   0.611
#> 4 4 0.786           0.793       0.882         0.1052 0.908   0.731
#> 5 5 0.773           0.758       0.844         0.0497 0.948   0.810
#> 6 6 0.779           0.675       0.801         0.0264 0.966   0.858

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
#> GSM123732     1  0.0000      1.000 1.000 0.000
#> GSM123736     1  0.0000      1.000 1.000 0.000
#> GSM123740     1  0.0000      1.000 1.000 0.000
#> GSM123744     1  0.0000      1.000 1.000 0.000
#> GSM123746     1  0.0000      1.000 1.000 0.000
#> GSM123750     1  0.0000      1.000 1.000 0.000
#> GSM123752     1  0.0000      1.000 1.000 0.000
#> GSM123756     1  0.0000      1.000 1.000 0.000
#> GSM123758     1  0.0000      1.000 1.000 0.000
#> GSM123761     1  0.0000      1.000 1.000 0.000
#> GSM123763     1  0.0000      1.000 1.000 0.000
#> GSM123765     1  0.0000      1.000 1.000 0.000
#> GSM123769     1  0.0000      1.000 1.000 0.000
#> GSM123771     1  0.0000      1.000 1.000 0.000
#> GSM123774     1  0.0000      1.000 1.000 0.000
#> GSM123778     1  0.0000      1.000 1.000 0.000
#> GSM123780     1  0.0000      1.000 1.000 0.000
#> GSM123784     1  0.0000      1.000 1.000 0.000
#> GSM123787     1  0.0000      1.000 1.000 0.000
#> GSM123791     1  0.0000      1.000 1.000 0.000
#> GSM123795     1  0.0000      1.000 1.000 0.000
#> GSM123799     1  0.0000      1.000 1.000 0.000
#> GSM123730     1  0.0938      0.988 0.988 0.012
#> GSM123734     1  0.0000      1.000 1.000 0.000
#> GSM123738     1  0.0000      1.000 1.000 0.000
#> GSM123742     1  0.0000      1.000 1.000 0.000
#> GSM123745     1  0.0000      1.000 1.000 0.000
#> GSM123748     1  0.0000      1.000 1.000 0.000
#> GSM123751     1  0.0000      1.000 1.000 0.000
#> GSM123754     1  0.0000      1.000 1.000 0.000
#> GSM123757     1  0.0000      1.000 1.000 0.000
#> GSM123760     1  0.0000      1.000 1.000 0.000
#> GSM123762     1  0.0000      1.000 1.000 0.000
#> GSM123764     1  0.0000      1.000 1.000 0.000
#> GSM123767     1  0.0000      1.000 1.000 0.000
#> GSM123770     1  0.0000      1.000 1.000 0.000
#> GSM123773     1  0.0000      1.000 1.000 0.000
#> GSM123777     1  0.0000      1.000 1.000 0.000
#> GSM123779     1  0.0000      1.000 1.000 0.000
#> GSM123782     1  0.0000      1.000 1.000 0.000
#> GSM123786     1  0.0000      1.000 1.000 0.000
#> GSM123789     1  0.0000      1.000 1.000 0.000
#> GSM123793     1  0.0000      1.000 1.000 0.000
#> GSM123797     1  0.0000      1.000 1.000 0.000
#> GSM123729     2  0.0000      0.991 0.000 1.000
#> GSM123733     2  0.0000      0.991 0.000 1.000
#> GSM123737     2  0.0000      0.991 0.000 1.000
#> GSM123741     2  0.0000      0.991 0.000 1.000
#> GSM123747     2  0.0000      0.991 0.000 1.000
#> GSM123753     2  0.0000      0.991 0.000 1.000
#> GSM123759     2  0.0000      0.991 0.000 1.000
#> GSM123766     2  0.0000      0.991 0.000 1.000
#> GSM123772     2  0.0000      0.991 0.000 1.000
#> GSM123775     2  0.0000      0.991 0.000 1.000
#> GSM123781     2  0.0000      0.991 0.000 1.000
#> GSM123785     2  0.0000      0.991 0.000 1.000
#> GSM123788     2  0.0000      0.991 0.000 1.000
#> GSM123792     2  0.0000      0.991 0.000 1.000
#> GSM123796     2  0.0000      0.991 0.000 1.000
#> GSM123731     2  0.0000      0.991 0.000 1.000
#> GSM123735     2  0.0000      0.991 0.000 1.000
#> GSM123739     2  0.0000      0.991 0.000 1.000
#> GSM123743     2  0.0000      0.991 0.000 1.000
#> GSM123749     2  0.0000      0.991 0.000 1.000
#> GSM123755     2  0.0000      0.991 0.000 1.000
#> GSM123768     2  0.0000      0.991 0.000 1.000
#> GSM123776     2  0.7745      0.705 0.228 0.772
#> GSM123783     2  0.0000      0.991 0.000 1.000
#> GSM123790     2  0.0000      0.991 0.000 1.000
#> GSM123794     2  0.0000      0.991 0.000 1.000
#> GSM123798     2  0.0000      0.991 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
#> GSM123732     3  0.0747    0.91514 0.016 0.000 0.984
#> GSM123736     3  0.1411    0.91651 0.036 0.000 0.964
#> GSM123740     3  0.1411    0.91646 0.036 0.000 0.964
#> GSM123744     3  0.6305    0.00995 0.484 0.000 0.516
#> GSM123746     1  0.1643    0.91190 0.956 0.000 0.044
#> GSM123750     1  0.5058    0.71238 0.756 0.000 0.244
#> GSM123752     1  0.1163    0.91497 0.972 0.000 0.028
#> GSM123756     1  0.0892    0.91441 0.980 0.000 0.020
#> GSM123758     1  0.5291    0.67641 0.732 0.000 0.268
#> GSM123761     1  0.4702    0.75916 0.788 0.000 0.212
#> GSM123763     3  0.4750    0.73455 0.216 0.000 0.784
#> GSM123765     3  0.0892    0.91779 0.020 0.000 0.980
#> GSM123769     1  0.1031    0.91597 0.976 0.000 0.024
#> GSM123771     1  0.0747    0.91239 0.984 0.000 0.016
#> GSM123774     1  0.0848    0.90057 0.984 0.008 0.008
#> GSM123778     3  0.0592    0.91328 0.012 0.000 0.988
#> GSM123780     3  0.0237    0.91300 0.004 0.000 0.996
#> GSM123784     3  0.0892    0.91789 0.020 0.000 0.980
#> GSM123787     3  0.0424    0.91472 0.008 0.000 0.992
#> GSM123791     3  0.1411    0.91651 0.036 0.000 0.964
#> GSM123795     3  0.1753    0.91059 0.048 0.000 0.952
#> GSM123799     3  0.1529    0.91476 0.040 0.000 0.960
#> GSM123730     3  0.0661    0.90085 0.004 0.008 0.988
#> GSM123734     3  0.3941    0.81771 0.156 0.000 0.844
#> GSM123738     3  0.1289    0.91733 0.032 0.000 0.968
#> GSM123742     3  0.6308   -0.00569 0.492 0.000 0.508
#> GSM123745     1  0.1031    0.91597 0.976 0.000 0.024
#> GSM123748     1  0.2165    0.90253 0.936 0.000 0.064
#> GSM123751     1  0.2537    0.89217 0.920 0.000 0.080
#> GSM123754     1  0.1860    0.90867 0.948 0.000 0.052
#> GSM123757     1  0.0592    0.90983 0.988 0.000 0.012
#> GSM123760     3  0.2959    0.87198 0.100 0.000 0.900
#> GSM123762     1  0.5835    0.51373 0.660 0.000 0.340
#> GSM123764     3  0.0424    0.91472 0.008 0.000 0.992
#> GSM123767     1  0.1031    0.91597 0.976 0.000 0.024
#> GSM123770     1  0.1031    0.91597 0.976 0.000 0.024
#> GSM123773     1  0.1031    0.91597 0.976 0.000 0.024
#> GSM123777     3  0.0237    0.90765 0.004 0.000 0.996
#> GSM123779     3  0.4452    0.77354 0.192 0.000 0.808
#> GSM123782     3  0.1129    0.91655 0.020 0.004 0.976
#> GSM123786     3  0.0000    0.91049 0.000 0.000 1.000
#> GSM123789     3  0.1411    0.91642 0.036 0.000 0.964
#> GSM123793     3  0.1031    0.91818 0.024 0.000 0.976
#> GSM123797     3  0.1031    0.91817 0.024 0.000 0.976
#> GSM123729     2  0.0747    0.98656 0.016 0.984 0.000
#> GSM123733     2  0.0424    0.99102 0.000 0.992 0.008
#> GSM123737     2  0.0424    0.98991 0.008 0.992 0.000
#> GSM123741     2  0.0237    0.99099 0.004 0.996 0.000
#> GSM123747     2  0.0661    0.99047 0.004 0.988 0.008
#> GSM123753     2  0.0661    0.99047 0.004 0.988 0.008
#> GSM123759     2  0.0475    0.99125 0.004 0.992 0.004
#> GSM123766     2  0.0661    0.99047 0.004 0.988 0.008
#> GSM123772     2  0.0829    0.98913 0.004 0.984 0.012
#> GSM123775     2  0.1031    0.98158 0.024 0.976 0.000
#> GSM123781     2  0.0237    0.99152 0.000 0.996 0.004
#> GSM123785     2  0.1170    0.98522 0.008 0.976 0.016
#> GSM123788     2  0.0000    0.99140 0.000 1.000 0.000
#> GSM123792     2  0.0424    0.99102 0.000 0.992 0.008
#> GSM123796     2  0.0829    0.98866 0.004 0.984 0.012
#> GSM123731     2  0.0237    0.99098 0.004 0.996 0.000
#> GSM123735     2  0.0424    0.98991 0.008 0.992 0.000
#> GSM123739     2  0.0892    0.98432 0.020 0.980 0.000
#> GSM123743     2  0.0237    0.99099 0.004 0.996 0.000
#> GSM123749     2  0.0237    0.99099 0.004 0.996 0.000
#> GSM123755     2  0.0000    0.99140 0.000 1.000 0.000
#> GSM123768     2  0.0424    0.99116 0.008 0.992 0.000
#> GSM123776     1  0.3425    0.80621 0.884 0.112 0.004
#> GSM123783     2  0.0592    0.99016 0.012 0.988 0.000
#> GSM123790     2  0.1711    0.97294 0.008 0.960 0.032
#> GSM123794     2  0.0829    0.98913 0.004 0.984 0.012
#> GSM123798     2  0.0237    0.99144 0.004 0.996 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.1124     0.7567 0.004 0.012 0.972 0.012
#> GSM123736     3  0.3688     0.7045 0.000 0.000 0.792 0.208
#> GSM123740     3  0.2921     0.7686 0.000 0.000 0.860 0.140
#> GSM123744     3  0.3335     0.7164 0.120 0.000 0.860 0.020
#> GSM123746     1  0.3048     0.8011 0.876 0.000 0.108 0.016
#> GSM123750     3  0.5237     0.3936 0.356 0.000 0.628 0.016
#> GSM123752     1  0.5615     0.2510 0.556 0.004 0.424 0.016
#> GSM123756     1  0.0804     0.8589 0.980 0.000 0.008 0.012
#> GSM123758     3  0.3791     0.6753 0.092 0.032 0.860 0.016
#> GSM123761     1  0.4904     0.6668 0.744 0.000 0.216 0.040
#> GSM123763     4  0.6112     0.6310 0.096 0.000 0.248 0.656
#> GSM123765     3  0.2216     0.7898 0.000 0.000 0.908 0.092
#> GSM123769     1  0.1151     0.8610 0.968 0.000 0.008 0.024
#> GSM123771     1  0.0657     0.8588 0.984 0.000 0.004 0.012
#> GSM123774     1  0.0188     0.8570 0.996 0.000 0.000 0.004
#> GSM123778     3  0.0376     0.7749 0.000 0.004 0.992 0.004
#> GSM123780     3  0.2589     0.7825 0.000 0.000 0.884 0.116
#> GSM123784     3  0.2216     0.7892 0.000 0.000 0.908 0.092
#> GSM123787     3  0.0895     0.7806 0.004 0.000 0.976 0.020
#> GSM123791     3  0.2266     0.7906 0.004 0.000 0.912 0.084
#> GSM123795     3  0.4955     0.1898 0.000 0.000 0.556 0.444
#> GSM123799     3  0.2760     0.7764 0.000 0.000 0.872 0.128
#> GSM123730     4  0.2010     0.7369 0.008 0.040 0.012 0.940
#> GSM123734     4  0.2908     0.7856 0.040 0.000 0.064 0.896
#> GSM123738     4  0.3852     0.7549 0.012 0.000 0.180 0.808
#> GSM123742     4  0.6965     0.0654 0.428 0.000 0.112 0.460
#> GSM123745     1  0.3486     0.7985 0.812 0.000 0.000 0.188
#> GSM123748     1  0.2546     0.8533 0.900 0.000 0.008 0.092
#> GSM123751     1  0.3356     0.8079 0.824 0.000 0.000 0.176
#> GSM123754     1  0.2149     0.8543 0.912 0.000 0.000 0.088
#> GSM123757     1  0.0804     0.8497 0.980 0.000 0.012 0.008
#> GSM123760     4  0.4197     0.7704 0.036 0.000 0.156 0.808
#> GSM123762     1  0.5690     0.5918 0.672 0.000 0.060 0.268
#> GSM123764     3  0.4994     0.0482 0.000 0.000 0.520 0.480
#> GSM123767     1  0.3355     0.8171 0.836 0.000 0.004 0.160
#> GSM123770     1  0.1022     0.8603 0.968 0.000 0.000 0.032
#> GSM123773     1  0.2530     0.8455 0.888 0.000 0.000 0.112
#> GSM123777     4  0.3852     0.7220 0.000 0.008 0.192 0.800
#> GSM123779     4  0.2399     0.7661 0.048 0.000 0.032 0.920
#> GSM123782     3  0.4713     0.4388 0.000 0.000 0.640 0.360
#> GSM123786     3  0.0672     0.7742 0.000 0.008 0.984 0.008
#> GSM123789     4  0.5050     0.3003 0.004 0.000 0.408 0.588
#> GSM123793     4  0.2924     0.7918 0.016 0.000 0.100 0.884
#> GSM123797     4  0.2662     0.7905 0.016 0.000 0.084 0.900
#> GSM123729     2  0.2210     0.9536 0.016 0.936 0.020 0.028
#> GSM123733     2  0.1209     0.9649 0.000 0.964 0.004 0.032
#> GSM123737     2  0.0712     0.9713 0.004 0.984 0.004 0.008
#> GSM123741     2  0.0336     0.9714 0.000 0.992 0.000 0.008
#> GSM123747     2  0.0657     0.9721 0.000 0.984 0.004 0.012
#> GSM123753     2  0.0672     0.9716 0.000 0.984 0.008 0.008
#> GSM123759     2  0.0657     0.9715 0.000 0.984 0.004 0.012
#> GSM123766     2  0.1109     0.9669 0.000 0.968 0.004 0.028
#> GSM123772     2  0.0336     0.9719 0.000 0.992 0.000 0.008
#> GSM123775     2  0.1674     0.9641 0.012 0.952 0.004 0.032
#> GSM123781     2  0.0524     0.9716 0.000 0.988 0.004 0.008
#> GSM123785     2  0.2053     0.9433 0.000 0.924 0.004 0.072
#> GSM123788     2  0.1209     0.9650 0.000 0.964 0.004 0.032
#> GSM123792     2  0.0188     0.9721 0.000 0.996 0.004 0.000
#> GSM123796     2  0.1398     0.9617 0.000 0.956 0.004 0.040
#> GSM123731     2  0.0657     0.9714 0.000 0.984 0.004 0.012
#> GSM123735     2  0.0469     0.9712 0.000 0.988 0.000 0.012
#> GSM123739     2  0.1484     0.9673 0.016 0.960 0.004 0.020
#> GSM123743     2  0.0000     0.9721 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0844     0.9712 0.004 0.980 0.004 0.012
#> GSM123755     2  0.1484     0.9642 0.004 0.960 0.020 0.016
#> GSM123768     2  0.2809     0.9282 0.004 0.904 0.064 0.028
#> GSM123776     1  0.2998     0.7929 0.892 0.080 0.004 0.024
#> GSM123783     2  0.3301     0.9029 0.004 0.876 0.092 0.028
#> GSM123790     2  0.1637     0.9532 0.000 0.940 0.000 0.060
#> GSM123794     2  0.0804     0.9705 0.000 0.980 0.008 0.012
#> GSM123798     2  0.1624     0.9594 0.000 0.952 0.028 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.2016    0.72929 0.020 0.012 0.936 0.020 0.012
#> GSM123736     3  0.6042    0.45167 0.028 0.000 0.576 0.324 0.072
#> GSM123740     3  0.5793    0.56630 0.032 0.000 0.636 0.264 0.068
#> GSM123744     3  0.4726    0.67824 0.108 0.000 0.752 0.008 0.132
#> GSM123746     1  0.3080    0.79214 0.872 0.000 0.060 0.008 0.060
#> GSM123750     3  0.6486    0.25329 0.324 0.000 0.472 0.000 0.204
#> GSM123752     1  0.5066    0.25287 0.584 0.004 0.384 0.004 0.024
#> GSM123756     1  0.0451    0.83173 0.988 0.000 0.000 0.004 0.008
#> GSM123758     3  0.3846    0.67284 0.100 0.036 0.836 0.016 0.012
#> GSM123761     5  0.5375    0.51441 0.276 0.000 0.080 0.004 0.640
#> GSM123763     5  0.4014    0.69607 0.024 0.000 0.060 0.096 0.820
#> GSM123765     3  0.3400    0.72160 0.000 0.000 0.828 0.136 0.036
#> GSM123769     1  0.1278    0.83334 0.960 0.000 0.004 0.020 0.016
#> GSM123771     1  0.0609    0.83138 0.980 0.000 0.000 0.000 0.020
#> GSM123774     1  0.0290    0.83195 0.992 0.000 0.000 0.000 0.008
#> GSM123778     3  0.2356    0.74030 0.004 0.004 0.912 0.024 0.056
#> GSM123780     3  0.4062    0.67466 0.000 0.000 0.764 0.196 0.040
#> GSM123784     3  0.2959    0.73635 0.000 0.000 0.864 0.100 0.036
#> GSM123787     3  0.3239    0.70714 0.004 0.000 0.828 0.012 0.156
#> GSM123791     3  0.4220    0.69969 0.004 0.000 0.768 0.048 0.180
#> GSM123795     4  0.6572    0.00519 0.016 0.000 0.392 0.460 0.132
#> GSM123799     3  0.5520    0.58955 0.028 0.000 0.656 0.260 0.056
#> GSM123730     4  0.3283    0.64367 0.000 0.008 0.028 0.848 0.116
#> GSM123734     4  0.5176    0.53102 0.012 0.000 0.032 0.608 0.348
#> GSM123738     4  0.4930    0.65013 0.000 0.000 0.144 0.716 0.140
#> GSM123742     5  0.4203    0.69903 0.108 0.000 0.032 0.052 0.808
#> GSM123745     1  0.5478    0.42450 0.592 0.000 0.004 0.068 0.336
#> GSM123748     1  0.4666    0.36994 0.596 0.000 0.004 0.012 0.388
#> GSM123751     1  0.3882    0.73381 0.788 0.000 0.000 0.044 0.168
#> GSM123754     1  0.1901    0.82612 0.928 0.000 0.004 0.056 0.012
#> GSM123757     1  0.0898    0.83092 0.972 0.000 0.008 0.000 0.020
#> GSM123760     5  0.3256    0.72236 0.012 0.000 0.060 0.064 0.864
#> GSM123762     5  0.4312    0.66215 0.176 0.000 0.020 0.032 0.772
#> GSM123764     5  0.3386    0.70586 0.000 0.000 0.128 0.040 0.832
#> GSM123767     1  0.3431    0.77542 0.828 0.000 0.008 0.144 0.020
#> GSM123770     1  0.0671    0.83125 0.980 0.000 0.000 0.016 0.004
#> GSM123773     1  0.2629    0.80674 0.880 0.000 0.004 0.104 0.012
#> GSM123777     4  0.4796    0.64072 0.000 0.000 0.120 0.728 0.152
#> GSM123779     4  0.4758    0.57303 0.012 0.000 0.032 0.696 0.260
#> GSM123782     5  0.4413    0.61423 0.000 0.000 0.232 0.044 0.724
#> GSM123786     3  0.2575    0.73040 0.004 0.000 0.884 0.012 0.100
#> GSM123789     5  0.4801    0.63327 0.000 0.000 0.148 0.124 0.728
#> GSM123793     4  0.5325    0.40195 0.000 0.000 0.052 0.520 0.428
#> GSM123797     4  0.3934    0.68140 0.000 0.000 0.076 0.800 0.124
#> GSM123729     2  0.1095    0.96572 0.000 0.968 0.008 0.012 0.012
#> GSM123733     2  0.1282    0.95748 0.000 0.952 0.000 0.044 0.004
#> GSM123737     2  0.0992    0.96291 0.000 0.968 0.000 0.024 0.008
#> GSM123741     2  0.0566    0.96641 0.000 0.984 0.000 0.004 0.012
#> GSM123747     2  0.0740    0.96477 0.000 0.980 0.008 0.004 0.008
#> GSM123753     2  0.1095    0.96198 0.000 0.968 0.008 0.012 0.012
#> GSM123759     2  0.1074    0.96693 0.000 0.968 0.004 0.016 0.012
#> GSM123766     2  0.1195    0.96274 0.000 0.960 0.000 0.028 0.012
#> GSM123772     2  0.0693    0.96565 0.000 0.980 0.000 0.012 0.008
#> GSM123775     2  0.1356    0.96357 0.000 0.956 0.004 0.028 0.012
#> GSM123781     2  0.0854    0.96601 0.000 0.976 0.004 0.012 0.008
#> GSM123785     2  0.2470    0.91142 0.000 0.884 0.000 0.104 0.012
#> GSM123788     2  0.1205    0.95915 0.000 0.956 0.000 0.040 0.004
#> GSM123792     2  0.0162    0.96653 0.000 0.996 0.000 0.004 0.000
#> GSM123796     2  0.1251    0.95995 0.000 0.956 0.000 0.036 0.008
#> GSM123731     2  0.0613    0.96527 0.000 0.984 0.004 0.008 0.004
#> GSM123735     2  0.1041    0.96350 0.000 0.964 0.000 0.032 0.004
#> GSM123739     2  0.1267    0.96220 0.000 0.960 0.004 0.024 0.012
#> GSM123743     2  0.0162    0.96648 0.000 0.996 0.000 0.000 0.004
#> GSM123749     2  0.0867    0.96383 0.000 0.976 0.008 0.008 0.008
#> GSM123755     2  0.1200    0.96078 0.000 0.964 0.008 0.016 0.012
#> GSM123768     2  0.2606    0.92001 0.000 0.900 0.056 0.032 0.012
#> GSM123776     1  0.3755    0.71077 0.828 0.116 0.008 0.004 0.044
#> GSM123783     2  0.2938    0.89595 0.000 0.876 0.084 0.032 0.008
#> GSM123790     2  0.2629    0.91196 0.000 0.880 0.004 0.104 0.012
#> GSM123794     2  0.0981    0.96583 0.000 0.972 0.008 0.008 0.012
#> GSM123798     2  0.1503    0.95516 0.000 0.952 0.020 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
#> GSM123732     3  0.2194     0.6926 0.008 0.000 0.912 0.040 0.036 0.004
#> GSM123736     4  0.4796     0.3813 0.032 0.000 0.352 0.600 0.004 0.012
#> GSM123740     4  0.5061     0.2804 0.048 0.000 0.404 0.536 0.004 0.008
#> GSM123744     3  0.5641     0.5717 0.124 0.000 0.696 0.080 0.040 0.060
#> GSM123746     1  0.4602     0.6631 0.756 0.000 0.056 0.008 0.048 0.132
#> GSM123750     3  0.7384     0.2506 0.268 0.000 0.448 0.056 0.044 0.184
#> GSM123752     1  0.6012     0.1573 0.536 0.004 0.340 0.076 0.036 0.008
#> GSM123756     1  0.0806     0.7712 0.972 0.000 0.000 0.008 0.020 0.000
#> GSM123758     3  0.6039     0.4875 0.144 0.024 0.668 0.084 0.068 0.012
#> GSM123761     6  0.6055     0.5505 0.164 0.000 0.052 0.052 0.080 0.652
#> GSM123763     6  0.5845     0.5149 0.012 0.000 0.048 0.156 0.140 0.644
#> GSM123765     3  0.3854     0.6539 0.000 0.000 0.788 0.140 0.056 0.016
#> GSM123769     1  0.1086     0.7730 0.964 0.000 0.000 0.012 0.012 0.012
#> GSM123771     1  0.1693     0.7720 0.936 0.000 0.000 0.012 0.032 0.020
#> GSM123774     1  0.0665     0.7745 0.980 0.000 0.000 0.004 0.008 0.008
#> GSM123778     3  0.2266     0.7119 0.000 0.000 0.908 0.028 0.040 0.024
#> GSM123780     3  0.4747     0.5660 0.000 0.000 0.712 0.132 0.140 0.016
#> GSM123784     3  0.4002     0.6783 0.004 0.000 0.792 0.088 0.100 0.016
#> GSM123787     3  0.3332     0.6843 0.000 0.000 0.832 0.016 0.044 0.108
#> GSM123791     3  0.5408     0.5907 0.000 0.000 0.668 0.060 0.096 0.176
#> GSM123795     4  0.4138     0.4598 0.020 0.000 0.184 0.752 0.000 0.044
#> GSM123799     4  0.4999     0.1811 0.040 0.000 0.448 0.500 0.004 0.008
#> GSM123730     5  0.5751     0.5989 0.004 0.008 0.040 0.372 0.532 0.044
#> GSM123734     4  0.4620     0.2133 0.012 0.000 0.000 0.696 0.072 0.220
#> GSM123738     4  0.3041     0.3156 0.000 0.000 0.036 0.864 0.056 0.044
#> GSM123742     6  0.4821     0.5679 0.060 0.000 0.024 0.108 0.052 0.756
#> GSM123745     1  0.6175     0.0950 0.452 0.000 0.000 0.056 0.092 0.400
#> GSM123748     6  0.5583    -0.0454 0.428 0.000 0.008 0.040 0.036 0.488
#> GSM123751     1  0.5590     0.5158 0.636 0.000 0.000 0.088 0.060 0.216
#> GSM123754     1  0.3033     0.7452 0.856 0.000 0.004 0.032 0.096 0.012
#> GSM123757     1  0.1755     0.7700 0.932 0.000 0.008 0.000 0.028 0.032
#> GSM123760     6  0.2656     0.6142 0.008 0.000 0.044 0.036 0.020 0.892
#> GSM123762     6  0.4744     0.6098 0.056 0.000 0.032 0.044 0.104 0.764
#> GSM123764     6  0.4786     0.5526 0.000 0.000 0.160 0.028 0.096 0.716
#> GSM123767     1  0.4441     0.6828 0.752 0.000 0.004 0.080 0.144 0.020
#> GSM123770     1  0.0748     0.7749 0.976 0.000 0.000 0.004 0.016 0.004
#> GSM123773     1  0.3569     0.7330 0.824 0.000 0.004 0.056 0.100 0.016
#> GSM123777     5  0.6329     0.6491 0.000 0.004 0.184 0.260 0.520 0.032
#> GSM123779     5  0.6036     0.6395 0.012 0.000 0.088 0.144 0.640 0.116
#> GSM123782     6  0.5211     0.4955 0.004 0.000 0.224 0.008 0.120 0.644
#> GSM123786     3  0.1957     0.7090 0.000 0.000 0.920 0.008 0.024 0.048
#> GSM123789     6  0.6651     0.2095 0.000 0.000 0.276 0.040 0.248 0.436
#> GSM123793     4  0.4843     0.1455 0.004 0.000 0.004 0.592 0.048 0.352
#> GSM123797     4  0.4399     0.0913 0.000 0.000 0.024 0.728 0.200 0.048
#> GSM123729     2  0.0790     0.9601 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM123733     2  0.1225     0.9522 0.000 0.952 0.000 0.012 0.036 0.000
#> GSM123737     2  0.0777     0.9597 0.000 0.972 0.000 0.004 0.024 0.000
#> GSM123741     2  0.0858     0.9586 0.000 0.968 0.000 0.000 0.028 0.004
#> GSM123747     2  0.0653     0.9617 0.000 0.980 0.004 0.000 0.012 0.004
#> GSM123753     2  0.1225     0.9548 0.000 0.956 0.004 0.004 0.032 0.004
#> GSM123759     2  0.1080     0.9568 0.000 0.960 0.004 0.004 0.032 0.000
#> GSM123766     2  0.1116     0.9608 0.000 0.960 0.000 0.004 0.028 0.008
#> GSM123772     2  0.0837     0.9609 0.000 0.972 0.000 0.004 0.020 0.004
#> GSM123775     2  0.1307     0.9585 0.000 0.952 0.000 0.008 0.032 0.008
#> GSM123781     2  0.1440     0.9511 0.000 0.944 0.004 0.004 0.044 0.004
#> GSM123785     2  0.2525     0.8952 0.000 0.876 0.000 0.012 0.100 0.012
#> GSM123788     2  0.1074     0.9550 0.000 0.960 0.000 0.012 0.028 0.000
#> GSM123792     2  0.0547     0.9608 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM123796     2  0.1074     0.9550 0.000 0.960 0.000 0.012 0.028 0.000
#> GSM123731     2  0.0551     0.9614 0.000 0.984 0.004 0.000 0.008 0.004
#> GSM123735     2  0.1049     0.9566 0.000 0.960 0.000 0.008 0.032 0.000
#> GSM123739     2  0.1036     0.9605 0.000 0.964 0.000 0.008 0.024 0.004
#> GSM123743     2  0.0692     0.9599 0.000 0.976 0.000 0.004 0.020 0.000
#> GSM123749     2  0.0748     0.9590 0.000 0.976 0.004 0.000 0.016 0.004
#> GSM123755     2  0.1299     0.9534 0.000 0.952 0.004 0.004 0.036 0.004
#> GSM123768     2  0.2291     0.9258 0.000 0.904 0.016 0.008 0.064 0.008
#> GSM123776     1  0.6106     0.4518 0.600 0.152 0.000 0.012 0.196 0.040
#> GSM123783     2  0.2369     0.9214 0.000 0.900 0.028 0.004 0.060 0.008
#> GSM123790     2  0.3086     0.8283 0.000 0.820 0.004 0.020 0.156 0.000
#> GSM123794     2  0.1080     0.9617 0.000 0.960 0.004 0.000 0.032 0.004
#> GSM123798     2  0.1452     0.9521 0.000 0.948 0.008 0.004 0.032 0.008

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) infection(p) agent(p) k
#> CV:NMF 71         3.82e-16     3.82e-16 6.04e-06 2
#> CV:NMF 69         2.55e-13     2.55e-13 1.10e-04 3
#> CV:NMF 64         1.54e-16     1.54e-16 1.04e-03 4
#> CV:NMF 64         8.87e-16     8.87e-16 2.61e-03 5
#> CV:NMF 55         1.63e-12     1.63e-12 4.05e-03 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 71 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.559           0.874       0.899         0.4669 0.522   0.522
#> 3 3 0.479           0.695       0.827         0.1946 0.858   0.745
#> 4 4 0.654           0.720       0.811         0.2003 0.813   0.606
#> 5 5 0.692           0.714       0.854         0.0539 0.947   0.840
#> 6 6 0.775           0.656       0.824         0.0340 0.989   0.961

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
#> GSM123732     1  0.8386      0.802 0.732 0.268
#> GSM123736     1  0.7376      0.837 0.792 0.208
#> GSM123740     1  0.7376      0.837 0.792 0.208
#> GSM123744     1  0.6887      0.844 0.816 0.184
#> GSM123746     1  0.6887      0.844 0.816 0.184
#> GSM123750     1  0.6801      0.845 0.820 0.180
#> GSM123752     1  0.6887      0.844 0.816 0.184
#> GSM123756     1  0.0000      0.828 1.000 0.000
#> GSM123758     1  0.7056      0.842 0.808 0.192
#> GSM123761     1  0.0000      0.828 1.000 0.000
#> GSM123763     1  0.0376      0.830 0.996 0.004
#> GSM123765     1  0.8386      0.802 0.732 0.268
#> GSM123769     1  0.0000      0.828 1.000 0.000
#> GSM123771     1  0.0000      0.828 1.000 0.000
#> GSM123774     1  0.0000      0.828 1.000 0.000
#> GSM123778     1  0.8386      0.802 0.732 0.268
#> GSM123780     1  0.8386      0.802 0.732 0.268
#> GSM123784     1  0.8386      0.802 0.732 0.268
#> GSM123787     1  0.8386      0.802 0.732 0.268
#> GSM123791     1  0.8267      0.808 0.740 0.260
#> GSM123795     1  0.7376      0.837 0.792 0.208
#> GSM123799     1  0.7376      0.837 0.792 0.208
#> GSM123730     1  0.9944      0.495 0.544 0.456
#> GSM123734     1  0.0000      0.828 1.000 0.000
#> GSM123738     1  0.4562      0.848 0.904 0.096
#> GSM123742     1  0.3879      0.846 0.924 0.076
#> GSM123745     1  0.2236      0.841 0.964 0.036
#> GSM123748     1  0.2423      0.842 0.960 0.040
#> GSM123751     1  0.2236      0.841 0.964 0.036
#> GSM123754     1  0.2236      0.841 0.964 0.036
#> GSM123757     1  0.6887      0.844 0.816 0.184
#> GSM123760     1  0.3879      0.846 0.924 0.076
#> GSM123762     1  0.0000      0.828 1.000 0.000
#> GSM123764     1  0.9248      0.711 0.660 0.340
#> GSM123767     1  0.2236      0.841 0.964 0.036
#> GSM123770     1  0.2236      0.841 0.964 0.036
#> GSM123773     1  0.2236      0.841 0.964 0.036
#> GSM123777     1  0.9944      0.495 0.544 0.456
#> GSM123779     1  0.9977      0.473 0.528 0.472
#> GSM123782     1  0.9323      0.695 0.652 0.348
#> GSM123786     1  0.8386      0.802 0.732 0.268
#> GSM123789     1  0.9815      0.585 0.580 0.420
#> GSM123793     1  0.0672      0.832 0.992 0.008
#> GSM123797     1  0.4431      0.848 0.908 0.092
#> GSM123729     2  0.0000      1.000 0.000 1.000
#> GSM123733     2  0.0000      1.000 0.000 1.000
#> GSM123737     2  0.0000      1.000 0.000 1.000
#> GSM123741     2  0.0000      1.000 0.000 1.000
#> GSM123747     2  0.0000      1.000 0.000 1.000
#> GSM123753     2  0.0000      1.000 0.000 1.000
#> GSM123759     2  0.0000      1.000 0.000 1.000
#> GSM123766     2  0.0000      1.000 0.000 1.000
#> GSM123772     2  0.0000      1.000 0.000 1.000
#> GSM123775     2  0.0000      1.000 0.000 1.000
#> GSM123781     2  0.0000      1.000 0.000 1.000
#> GSM123785     2  0.0000      1.000 0.000 1.000
#> GSM123788     2  0.0000      1.000 0.000 1.000
#> GSM123792     2  0.0000      1.000 0.000 1.000
#> GSM123796     2  0.0000      1.000 0.000 1.000
#> GSM123731     2  0.0000      1.000 0.000 1.000
#> GSM123735     2  0.0000      1.000 0.000 1.000
#> GSM123739     2  0.0000      1.000 0.000 1.000
#> GSM123743     2  0.0000      1.000 0.000 1.000
#> GSM123749     2  0.0000      1.000 0.000 1.000
#> GSM123755     2  0.0000      1.000 0.000 1.000
#> GSM123768     2  0.0000      1.000 0.000 1.000
#> GSM123776     2  0.0000      1.000 0.000 1.000
#> GSM123783     2  0.0000      1.000 0.000 1.000
#> GSM123790     2  0.0000      1.000 0.000 1.000
#> GSM123794     2  0.0000      1.000 0.000 1.000
#> GSM123798     2  0.0000      1.000 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
#> GSM123732     1  0.5881      0.660 0.728 0.256 0.016
#> GSM123736     1  0.5406      0.692 0.780 0.200 0.020
#> GSM123740     1  0.5406      0.692 0.780 0.200 0.020
#> GSM123744     1  0.4805      0.697 0.812 0.176 0.012
#> GSM123746     1  0.5348      0.698 0.796 0.176 0.028
#> GSM123750     1  0.5412      0.695 0.796 0.172 0.032
#> GSM123752     1  0.4645      0.696 0.816 0.176 0.008
#> GSM123756     1  0.4121      0.534 0.832 0.000 0.168
#> GSM123758     1  0.4861      0.695 0.808 0.180 0.012
#> GSM123761     1  0.2711      0.576 0.912 0.000 0.088
#> GSM123763     1  0.2066      0.587 0.940 0.000 0.060
#> GSM123765     1  0.5881      0.660 0.728 0.256 0.016
#> GSM123769     1  0.4121      0.534 0.832 0.000 0.168
#> GSM123771     1  0.4121      0.534 0.832 0.000 0.168
#> GSM123774     1  0.4121      0.534 0.832 0.000 0.168
#> GSM123778     1  0.6143      0.659 0.720 0.256 0.024
#> GSM123780     1  0.6143      0.659 0.720 0.256 0.024
#> GSM123784     1  0.6143      0.659 0.720 0.256 0.024
#> GSM123787     1  0.6143      0.659 0.720 0.256 0.024
#> GSM123791     1  0.6187      0.667 0.724 0.248 0.028
#> GSM123795     1  0.5406      0.692 0.780 0.200 0.020
#> GSM123799     1  0.5406      0.692 0.780 0.200 0.020
#> GSM123730     2  0.9616     -0.165 0.212 0.444 0.344
#> GSM123734     3  0.0892      0.700 0.020 0.000 0.980
#> GSM123738     3  0.7169      0.766 0.208 0.088 0.704
#> GSM123742     1  0.6933      0.555 0.716 0.076 0.208
#> GSM123745     1  0.7084      0.449 0.628 0.036 0.336
#> GSM123748     1  0.5850      0.570 0.772 0.040 0.188
#> GSM123751     1  0.7037      0.459 0.636 0.036 0.328
#> GSM123754     1  0.7061      0.454 0.632 0.036 0.332
#> GSM123757     1  0.5348      0.698 0.796 0.176 0.028
#> GSM123760     1  0.6794      0.569 0.728 0.076 0.196
#> GSM123762     1  0.3038      0.570 0.896 0.000 0.104
#> GSM123764     1  0.8808      0.458 0.536 0.332 0.132
#> GSM123767     1  0.7037      0.455 0.636 0.036 0.328
#> GSM123770     1  0.7061      0.454 0.632 0.036 0.332
#> GSM123773     1  0.7061      0.454 0.632 0.036 0.332
#> GSM123777     2  0.9616     -0.165 0.212 0.444 0.344
#> GSM123779     2  0.9479     -0.215 0.348 0.460 0.192
#> GSM123782     1  0.8891      0.424 0.524 0.340 0.136
#> GSM123786     1  0.6143      0.659 0.720 0.256 0.024
#> GSM123789     1  0.9299      0.268 0.432 0.408 0.160
#> GSM123793     3  0.4002      0.786 0.160 0.000 0.840
#> GSM123797     3  0.7092      0.770 0.208 0.084 0.708
#> GSM123729     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123733     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123737     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123741     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123747     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123753     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123775     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123781     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123785     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123788     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123792     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123796     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123731     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123735     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123739     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123743     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123776     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123783     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123790     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123794     2  0.0000      0.933 0.000 1.000 0.000
#> GSM123798     2  0.0000      0.933 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3   0.123      0.692 0.004 0.020 0.968 0.008
#> GSM123736     3   0.342      0.672 0.088 0.016 0.876 0.020
#> GSM123740     3   0.342      0.672 0.088 0.016 0.876 0.020
#> GSM123744     3   0.420      0.610 0.160 0.012 0.812 0.016
#> GSM123746     3   0.434      0.596 0.184 0.012 0.792 0.012
#> GSM123750     3   0.465      0.568 0.192 0.012 0.776 0.020
#> GSM123752     3   0.412      0.609 0.164 0.012 0.812 0.012
#> GSM123756     1   0.413      0.743 0.740 0.000 0.260 0.000
#> GSM123758     3   0.402      0.622 0.156 0.016 0.820 0.008
#> GSM123761     3   0.621     -0.289 0.460 0.000 0.488 0.052
#> GSM123763     1   0.620      0.415 0.508 0.000 0.440 0.052
#> GSM123765     3   0.123      0.692 0.004 0.020 0.968 0.008
#> GSM123769     1   0.413      0.743 0.740 0.000 0.260 0.000
#> GSM123771     1   0.413      0.743 0.740 0.000 0.260 0.000
#> GSM123774     1   0.413      0.743 0.740 0.000 0.260 0.000
#> GSM123778     3   0.148      0.691 0.004 0.020 0.960 0.016
#> GSM123780     3   0.160      0.690 0.004 0.020 0.956 0.020
#> GSM123784     3   0.148      0.691 0.004 0.020 0.960 0.016
#> GSM123787     3   0.160      0.690 0.004 0.020 0.956 0.020
#> GSM123791     3   0.176      0.691 0.012 0.016 0.952 0.020
#> GSM123795     3   0.342      0.672 0.088 0.016 0.876 0.020
#> GSM123799     3   0.342      0.672 0.088 0.016 0.876 0.020
#> GSM123730     3   0.898     -0.216 0.068 0.228 0.412 0.292
#> GSM123734     4   0.482      0.476 0.296 0.000 0.012 0.692
#> GSM123738     4   0.589      0.720 0.072 0.000 0.268 0.660
#> GSM123742     3   0.719     -0.140 0.404 0.004 0.472 0.120
#> GSM123745     1   0.551      0.758 0.736 0.004 0.172 0.088
#> GSM123748     1   0.687      0.545 0.540 0.004 0.356 0.100
#> GSM123751     1   0.581      0.759 0.708 0.004 0.196 0.092
#> GSM123754     1   0.556      0.762 0.732 0.004 0.176 0.088
#> GSM123757     3   0.430      0.588 0.192 0.012 0.788 0.008
#> GSM123760     3   0.708     -0.102 0.388 0.000 0.484 0.128
#> GSM123762     1   0.601      0.673 0.652 0.000 0.268 0.080
#> GSM123764     3   0.676      0.489 0.108 0.112 0.700 0.080
#> GSM123767     1   0.560      0.760 0.728 0.004 0.180 0.088
#> GSM123770     1   0.556      0.762 0.732 0.004 0.176 0.088
#> GSM123773     1   0.556      0.762 0.732 0.004 0.176 0.088
#> GSM123777     3   0.898     -0.216 0.068 0.228 0.412 0.292
#> GSM123779     3   0.807      0.182 0.072 0.232 0.564 0.132
#> GSM123782     3   0.732      0.449 0.124 0.136 0.656 0.084
#> GSM123786     3   0.160      0.690 0.004 0.020 0.956 0.020
#> GSM123789     3   0.732      0.346 0.076 0.172 0.648 0.104
#> GSM123793     4   0.485      0.731 0.072 0.000 0.152 0.776
#> GSM123797     4   0.593      0.725 0.076 0.000 0.264 0.660
#> GSM123729     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123733     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123737     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123741     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123747     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123753     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123759     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123766     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123772     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123775     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123781     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123785     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123788     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123792     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123796     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123731     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123735     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123739     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123743     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123749     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123755     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123768     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123776     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123783     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123790     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123794     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM123798     2   0.000      1.000 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3   0.123     0.7551 0.004 0.004 0.964 0.016 0.012
#> GSM123736     3   0.288     0.7596 0.060 0.000 0.888 0.028 0.024
#> GSM123740     3   0.288     0.7596 0.060 0.000 0.888 0.028 0.024
#> GSM123744     3   0.356     0.7172 0.136 0.000 0.824 0.004 0.036
#> GSM123746     3   0.373     0.7037 0.160 0.000 0.804 0.004 0.032
#> GSM123750     3   0.410     0.6849 0.160 0.000 0.784 0.004 0.052
#> GSM123752     3   0.352     0.7159 0.140 0.000 0.824 0.004 0.032
#> GSM123756     1   0.444     0.6029 0.756 0.000 0.156 0.000 0.088
#> GSM123758     3   0.351     0.7260 0.132 0.004 0.832 0.004 0.028
#> GSM123761     3   0.646    -0.1373 0.400 0.000 0.440 0.004 0.156
#> GSM123763     1   0.680     0.4097 0.476 0.000 0.328 0.016 0.180
#> GSM123765     3   0.107     0.7536 0.000 0.004 0.968 0.016 0.012
#> GSM123769     1   0.444     0.6029 0.756 0.000 0.156 0.000 0.088
#> GSM123771     1   0.444     0.6029 0.756 0.000 0.156 0.000 0.088
#> GSM123774     1   0.444     0.6029 0.756 0.000 0.156 0.000 0.088
#> GSM123778     3   0.128     0.7509 0.000 0.004 0.960 0.020 0.016
#> GSM123780     3   0.137     0.7489 0.000 0.004 0.956 0.024 0.016
#> GSM123784     3   0.128     0.7509 0.000 0.004 0.960 0.020 0.016
#> GSM123787     3   0.137     0.7489 0.000 0.004 0.956 0.024 0.016
#> GSM123791     3   0.118     0.7560 0.004 0.000 0.964 0.016 0.016
#> GSM123795     3   0.288     0.7596 0.060 0.000 0.888 0.028 0.024
#> GSM123799     3   0.288     0.7596 0.060 0.000 0.888 0.028 0.024
#> GSM123730     4   0.772     0.4819 0.040 0.208 0.268 0.464 0.020
#> GSM123734     5   0.550     0.0000 0.212 0.000 0.000 0.140 0.648
#> GSM123738     4   0.301     0.4637 0.036 0.000 0.104 0.860 0.000
#> GSM123742     1   0.745     0.2652 0.444 0.000 0.348 0.108 0.100
#> GSM123745     1   0.295     0.6232 0.884 0.000 0.044 0.056 0.016
#> GSM123748     1   0.605     0.5395 0.652 0.000 0.212 0.068 0.068
#> GSM123751     1   0.326     0.6259 0.868 0.000 0.056 0.056 0.020
#> GSM123754     1   0.299     0.6307 0.880 0.000 0.052 0.056 0.012
#> GSM123757     3   0.377     0.6949 0.172 0.000 0.796 0.004 0.028
#> GSM123760     1   0.777     0.2165 0.400 0.000 0.352 0.112 0.136
#> GSM123762     1   0.513     0.4603 0.664 0.000 0.036 0.020 0.280
#> GSM123764     3   0.752     0.3357 0.116 0.096 0.608 0.100 0.080
#> GSM123767     1   0.305     0.6283 0.876 0.000 0.052 0.060 0.012
#> GSM123770     1   0.299     0.6307 0.880 0.000 0.052 0.056 0.012
#> GSM123773     1   0.299     0.6307 0.880 0.000 0.052 0.056 0.012
#> GSM123777     4   0.772     0.4819 0.040 0.208 0.268 0.464 0.020
#> GSM123779     3   0.797    -0.1882 0.072 0.204 0.476 0.228 0.020
#> GSM123782     3   0.781     0.2940 0.128 0.120 0.576 0.112 0.064
#> GSM123786     3   0.137     0.7489 0.000 0.004 0.956 0.024 0.016
#> GSM123789     3   0.767     0.1207 0.072 0.144 0.568 0.168 0.048
#> GSM123793     4   0.468     0.0266 0.036 0.000 0.036 0.756 0.172
#> GSM123797     4   0.304     0.4582 0.040 0.000 0.100 0.860 0.000
#> GSM123729     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123781     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123776     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123783     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123790     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2   0.000     1.0000 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM123732     3  0.1444     0.7278 0.000 0.000 0.928 0.000 NA 0.000
#> GSM123736     3  0.2180     0.7213 0.048 0.000 0.912 0.028 NA 0.008
#> GSM123740     3  0.2180     0.7213 0.048 0.000 0.912 0.028 NA 0.008
#> GSM123744     3  0.3089     0.6837 0.092 0.000 0.844 0.000 NA 0.060
#> GSM123746     3  0.3324     0.6710 0.112 0.000 0.824 0.000 NA 0.060
#> GSM123750     3  0.3817     0.6536 0.104 0.000 0.796 0.000 NA 0.088
#> GSM123752     3  0.2948     0.6841 0.092 0.000 0.848 0.000 NA 0.060
#> GSM123756     1  0.5219     0.2850 0.612 0.000 0.176 0.000 NA 0.212
#> GSM123758     3  0.2876     0.6945 0.080 0.000 0.860 0.000 NA 0.056
#> GSM123761     3  0.6016    -0.1272 0.220 0.000 0.456 0.000 NA 0.320
#> GSM123763     6  0.6711     0.0150 0.308 0.000 0.304 0.000 NA 0.356
#> GSM123765     3  0.1501     0.7269 0.000 0.000 0.924 0.000 NA 0.000
#> GSM123769     1  0.5219     0.2850 0.612 0.000 0.176 0.000 NA 0.212
#> GSM123771     1  0.5219     0.2850 0.612 0.000 0.176 0.000 NA 0.212
#> GSM123774     1  0.5219     0.2850 0.612 0.000 0.176 0.000 NA 0.212
#> GSM123778     3  0.1610     0.7245 0.000 0.000 0.916 0.000 NA 0.000
#> GSM123780     3  0.1918     0.7198 0.000 0.000 0.904 0.008 NA 0.000
#> GSM123784     3  0.1610     0.7245 0.000 0.000 0.916 0.000 NA 0.000
#> GSM123787     3  0.1908     0.7202 0.000 0.000 0.900 0.004 NA 0.000
#> GSM123791     3  0.2202     0.7265 0.008 0.000 0.904 0.004 NA 0.012
#> GSM123795     3  0.2180     0.7213 0.048 0.000 0.912 0.028 NA 0.008
#> GSM123799     3  0.2180     0.7213 0.048 0.000 0.912 0.028 NA 0.008
#> GSM123730     4  0.7580     0.5076 0.024 0.160 0.208 0.468 NA 0.004
#> GSM123734     6  0.6416    -0.0330 0.208 0.000 0.000 0.024 NA 0.408
#> GSM123738     4  0.1643     0.5707 0.008 0.000 0.068 0.924 NA 0.000
#> GSM123742     1  0.7251     0.0428 0.452 0.000 0.180 0.016 NA 0.088
#> GSM123745     1  0.0260     0.5520 0.992 0.000 0.008 0.000 NA 0.000
#> GSM123748     1  0.5580     0.2751 0.680 0.000 0.136 0.008 NA 0.084
#> GSM123751     1  0.1129     0.5465 0.964 0.000 0.012 0.004 NA 0.008
#> GSM123754     1  0.0458     0.5585 0.984 0.000 0.016 0.000 NA 0.000
#> GSM123757     3  0.3395     0.6630 0.124 0.000 0.816 0.000 NA 0.056
#> GSM123760     1  0.7552    -0.0363 0.380 0.000 0.164 0.016 NA 0.124
#> GSM123762     6  0.5310     0.0237 0.376 0.000 0.020 0.004 NA 0.548
#> GSM123764     3  0.7014     0.0798 0.128 0.060 0.412 0.012 NA 0.008
#> GSM123767     1  0.0603     0.5566 0.980 0.000 0.016 0.004 NA 0.000
#> GSM123770     1  0.0458     0.5585 0.984 0.000 0.016 0.000 NA 0.000
#> GSM123773     1  0.0458     0.5585 0.984 0.000 0.016 0.000 NA 0.000
#> GSM123777     4  0.7580     0.5076 0.024 0.160 0.208 0.468 NA 0.004
#> GSM123779     3  0.8719    -0.2766 0.128 0.156 0.320 0.140 NA 0.004
#> GSM123782     3  0.7418     0.0529 0.148 0.084 0.400 0.016 NA 0.008
#> GSM123786     3  0.1858     0.7205 0.000 0.000 0.904 0.004 NA 0.000
#> GSM123789     3  0.7914    -0.0795 0.128 0.104 0.388 0.072 NA 0.000
#> GSM123793     4  0.5110     0.3040 0.012 0.000 0.004 0.656 NA 0.096
#> GSM123797     4  0.1686     0.5688 0.012 0.000 0.064 0.924 NA 0.000
#> GSM123729     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123733     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123737     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123741     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123747     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123753     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123759     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123766     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123772     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123775     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123781     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123785     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123788     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123792     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123796     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123731     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123735     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123739     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123743     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123749     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123755     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123768     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123776     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123783     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123790     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123794     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123798     2  0.0000     1.0000 0.000 1.000 0.000 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) infection(p) agent(p) k
#> MAD:hclust 68         1.71e-15     1.71e-15 1.19e-05 2
#> MAD:hclust 59         5.77e-16     5.77e-16 1.33e-04 3
#> MAD:hclust 60         1.90e-16     1.90e-16 3.75e-04 4
#> MAD:hclust 56         5.29e-15     5.29e-15 2.74e-04 5
#> MAD:hclust 55         1.94e-18     1.94e-18 1.18e-03 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 71 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 1.000           1.000       1.000         0.4786 0.522   0.522
#> 3 3 0.716           0.819       0.854         0.3684 0.805   0.627
#> 4 4 0.671           0.786       0.829         0.1152 0.893   0.695
#> 5 5 0.722           0.720       0.793         0.0592 0.959   0.850
#> 6 6 0.754           0.735       0.799         0.0335 0.994   0.977

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
#> GSM123732     1       0          1  1  0
#> GSM123736     1       0          1  1  0
#> GSM123740     1       0          1  1  0
#> GSM123744     1       0          1  1  0
#> GSM123746     1       0          1  1  0
#> GSM123750     1       0          1  1  0
#> GSM123752     1       0          1  1  0
#> GSM123756     1       0          1  1  0
#> GSM123758     1       0          1  1  0
#> GSM123761     1       0          1  1  0
#> GSM123763     1       0          1  1  0
#> GSM123765     1       0          1  1  0
#> GSM123769     1       0          1  1  0
#> GSM123771     1       0          1  1  0
#> GSM123774     1       0          1  1  0
#> GSM123778     1       0          1  1  0
#> GSM123780     1       0          1  1  0
#> GSM123784     1       0          1  1  0
#> GSM123787     1       0          1  1  0
#> GSM123791     1       0          1  1  0
#> GSM123795     1       0          1  1  0
#> GSM123799     1       0          1  1  0
#> GSM123730     1       0          1  1  0
#> GSM123734     1       0          1  1  0
#> GSM123738     1       0          1  1  0
#> GSM123742     1       0          1  1  0
#> GSM123745     1       0          1  1  0
#> GSM123748     1       0          1  1  0
#> GSM123751     1       0          1  1  0
#> GSM123754     1       0          1  1  0
#> GSM123757     1       0          1  1  0
#> GSM123760     1       0          1  1  0
#> GSM123762     1       0          1  1  0
#> GSM123764     1       0          1  1  0
#> GSM123767     1       0          1  1  0
#> GSM123770     1       0          1  1  0
#> GSM123773     1       0          1  1  0
#> GSM123777     1       0          1  1  0
#> GSM123779     1       0          1  1  0
#> GSM123782     1       0          1  1  0
#> GSM123786     1       0          1  1  0
#> GSM123789     1       0          1  1  0
#> GSM123793     1       0          1  1  0
#> GSM123797     1       0          1  1  0
#> GSM123729     2       0          1  0  1
#> GSM123733     2       0          1  0  1
#> GSM123737     2       0          1  0  1
#> GSM123741     2       0          1  0  1
#> GSM123747     2       0          1  0  1
#> GSM123753     2       0          1  0  1
#> GSM123759     2       0          1  0  1
#> GSM123766     2       0          1  0  1
#> GSM123772     2       0          1  0  1
#> GSM123775     2       0          1  0  1
#> GSM123781     2       0          1  0  1
#> GSM123785     2       0          1  0  1
#> GSM123788     2       0          1  0  1
#> GSM123792     2       0          1  0  1
#> GSM123796     2       0          1  0  1
#> GSM123731     2       0          1  0  1
#> GSM123735     2       0          1  0  1
#> GSM123739     2       0          1  0  1
#> GSM123743     2       0          1  0  1
#> GSM123749     2       0          1  0  1
#> GSM123755     2       0          1  0  1
#> GSM123768     2       0          1  0  1
#> GSM123776     2       0          1  0  1
#> GSM123783     2       0          1  0  1
#> GSM123790     2       0          1  0  1
#> GSM123794     2       0          1  0  1
#> GSM123798     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123732     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123736     3  0.5621      0.788 0.308 0.000 0.692
#> GSM123740     3  0.5621      0.788 0.308 0.000 0.692
#> GSM123744     1  0.5138      0.541 0.748 0.000 0.252
#> GSM123746     1  0.3267      0.727 0.884 0.000 0.116
#> GSM123750     1  0.4235      0.674 0.824 0.000 0.176
#> GSM123752     1  0.4931      0.583 0.768 0.000 0.232
#> GSM123756     1  0.3267      0.727 0.884 0.000 0.116
#> GSM123758     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123761     1  0.3879      0.701 0.848 0.000 0.152
#> GSM123763     1  0.4346      0.704 0.816 0.000 0.184
#> GSM123765     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123769     1  0.3267      0.727 0.884 0.000 0.116
#> GSM123771     1  0.3267      0.727 0.884 0.000 0.116
#> GSM123774     1  0.3340      0.729 0.880 0.000 0.120
#> GSM123778     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123780     3  0.5363      0.788 0.276 0.000 0.724
#> GSM123784     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123787     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123791     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123795     3  0.5621      0.788 0.308 0.000 0.692
#> GSM123799     3  0.5621      0.788 0.308 0.000 0.692
#> GSM123730     3  0.0592      0.671 0.012 0.000 0.988
#> GSM123734     1  0.6180      0.726 0.584 0.000 0.416
#> GSM123738     3  0.0424      0.677 0.008 0.000 0.992
#> GSM123742     1  0.6140      0.732 0.596 0.000 0.404
#> GSM123745     1  0.6140      0.737 0.596 0.000 0.404
#> GSM123748     1  0.6008      0.744 0.628 0.000 0.372
#> GSM123751     1  0.6140      0.737 0.596 0.000 0.404
#> GSM123754     1  0.6140      0.737 0.596 0.000 0.404
#> GSM123757     1  0.3412      0.731 0.876 0.000 0.124
#> GSM123760     1  0.6168      0.726 0.588 0.000 0.412
#> GSM123762     1  0.5760      0.752 0.672 0.000 0.328
#> GSM123764     3  0.1753      0.692 0.048 0.000 0.952
#> GSM123767     1  0.6180      0.726 0.584 0.000 0.416
#> GSM123770     1  0.6140      0.737 0.596 0.000 0.404
#> GSM123773     1  0.6140      0.737 0.596 0.000 0.404
#> GSM123777     3  0.0000      0.679 0.000 0.000 1.000
#> GSM123779     3  0.0592      0.671 0.012 0.000 0.988
#> GSM123782     3  0.1753      0.688 0.048 0.000 0.952
#> GSM123786     3  0.5560      0.792 0.300 0.000 0.700
#> GSM123789     3  0.1860      0.691 0.052 0.000 0.948
#> GSM123793     3  0.0892      0.667 0.020 0.000 0.980
#> GSM123797     3  0.0892      0.667 0.020 0.000 0.980
#> GSM123729     2  0.2066      0.965 0.060 0.940 0.000
#> GSM123733     2  0.1753      0.965 0.048 0.952 0.000
#> GSM123737     2  0.1860      0.965 0.052 0.948 0.000
#> GSM123741     2  0.0892      0.970 0.020 0.980 0.000
#> GSM123747     2  0.1411      0.968 0.036 0.964 0.000
#> GSM123753     2  0.1031      0.970 0.024 0.976 0.000
#> GSM123759     2  0.1163      0.969 0.028 0.972 0.000
#> GSM123766     2  0.0892      0.970 0.020 0.980 0.000
#> GSM123772     2  0.0892      0.970 0.020 0.980 0.000
#> GSM123775     2  0.2261      0.963 0.068 0.932 0.000
#> GSM123781     2  0.1163      0.969 0.028 0.972 0.000
#> GSM123785     2  0.1753      0.965 0.048 0.952 0.000
#> GSM123788     2  0.1643      0.966 0.044 0.956 0.000
#> GSM123792     2  0.1529      0.966 0.040 0.960 0.000
#> GSM123796     2  0.1643      0.966 0.044 0.956 0.000
#> GSM123731     2  0.1289      0.969 0.032 0.968 0.000
#> GSM123735     2  0.2711      0.955 0.088 0.912 0.000
#> GSM123739     2  0.1860      0.965 0.052 0.948 0.000
#> GSM123743     2  0.0000      0.971 0.000 1.000 0.000
#> GSM123749     2  0.1031      0.970 0.024 0.976 0.000
#> GSM123755     2  0.1163      0.969 0.028 0.972 0.000
#> GSM123768     2  0.1163      0.969 0.028 0.972 0.000
#> GSM123776     2  0.2356      0.961 0.072 0.928 0.000
#> GSM123783     2  0.2261      0.963 0.068 0.932 0.000
#> GSM123790     2  0.2711      0.955 0.088 0.912 0.000
#> GSM123794     2  0.2625      0.956 0.084 0.916 0.000
#> GSM123798     2  0.1163      0.969 0.028 0.972 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0469      0.860 0.000 0.000 0.988 0.012
#> GSM123736     3  0.2174      0.841 0.020 0.000 0.928 0.052
#> GSM123740     3  0.2174      0.841 0.020 0.000 0.928 0.052
#> GSM123744     3  0.5249      0.552 0.248 0.000 0.708 0.044
#> GSM123746     1  0.3946      0.760 0.812 0.000 0.168 0.020
#> GSM123750     3  0.6009      0.191 0.380 0.000 0.572 0.048
#> GSM123752     3  0.4452      0.576 0.260 0.000 0.732 0.008
#> GSM123756     1  0.3208      0.773 0.848 0.000 0.148 0.004
#> GSM123758     3  0.0469      0.858 0.012 0.000 0.988 0.000
#> GSM123761     1  0.6000      0.460 0.592 0.000 0.356 0.052
#> GSM123763     1  0.7105      0.501 0.556 0.000 0.176 0.268
#> GSM123765     3  0.0469      0.860 0.000 0.000 0.988 0.012
#> GSM123769     1  0.3208      0.773 0.848 0.000 0.148 0.004
#> GSM123771     1  0.3208      0.773 0.848 0.000 0.148 0.004
#> GSM123774     1  0.3157      0.775 0.852 0.000 0.144 0.004
#> GSM123778     3  0.0592      0.858 0.000 0.000 0.984 0.016
#> GSM123780     3  0.1059      0.844 0.012 0.000 0.972 0.016
#> GSM123784     3  0.0592      0.858 0.000 0.000 0.984 0.016
#> GSM123787     3  0.0592      0.858 0.000 0.000 0.984 0.016
#> GSM123791     3  0.0188      0.860 0.000 0.000 0.996 0.004
#> GSM123795     3  0.2174      0.841 0.020 0.000 0.928 0.052
#> GSM123799     3  0.2174      0.841 0.020 0.000 0.928 0.052
#> GSM123730     4  0.6794      0.815 0.136 0.000 0.280 0.584
#> GSM123734     4  0.5244      0.394 0.388 0.000 0.012 0.600
#> GSM123738     4  0.6479      0.810 0.140 0.000 0.224 0.636
#> GSM123742     1  0.6453      0.265 0.560 0.000 0.080 0.360
#> GSM123745     1  0.2255      0.745 0.920 0.000 0.012 0.068
#> GSM123748     1  0.3149      0.758 0.880 0.000 0.032 0.088
#> GSM123751     1  0.2402      0.740 0.912 0.000 0.012 0.076
#> GSM123754     1  0.2402      0.742 0.912 0.000 0.012 0.076
#> GSM123757     1  0.2973      0.775 0.856 0.000 0.144 0.000
#> GSM123760     4  0.6696      0.102 0.428 0.000 0.088 0.484
#> GSM123762     1  0.5292      0.621 0.724 0.000 0.060 0.216
#> GSM123764     4  0.6837      0.729 0.104 0.000 0.392 0.504
#> GSM123767     1  0.3718      0.640 0.820 0.000 0.012 0.168
#> GSM123770     1  0.1059      0.763 0.972 0.000 0.012 0.016
#> GSM123773     1  0.2402      0.742 0.912 0.000 0.012 0.076
#> GSM123777     4  0.6813      0.810 0.132 0.000 0.292 0.576
#> GSM123779     4  0.6815      0.814 0.136 0.000 0.284 0.580
#> GSM123782     4  0.6830      0.737 0.104 0.000 0.388 0.508
#> GSM123786     3  0.0592      0.858 0.000 0.000 0.984 0.016
#> GSM123789     4  0.6766      0.746 0.100 0.000 0.380 0.520
#> GSM123793     4  0.6084      0.805 0.120 0.000 0.204 0.676
#> GSM123797     4  0.6479      0.810 0.140 0.000 0.224 0.636
#> GSM123729     2  0.3978      0.887 0.012 0.796 0.000 0.192
#> GSM123733     2  0.3311      0.895 0.000 0.828 0.000 0.172
#> GSM123737     2  0.3764      0.893 0.012 0.816 0.000 0.172
#> GSM123741     2  0.0000      0.912 0.000 1.000 0.000 0.000
#> GSM123747     2  0.2216      0.904 0.000 0.908 0.000 0.092
#> GSM123753     2  0.0188      0.912 0.000 0.996 0.000 0.004
#> GSM123759     2  0.0336      0.911 0.000 0.992 0.000 0.008
#> GSM123766     2  0.0188      0.912 0.000 0.996 0.000 0.004
#> GSM123772     2  0.0188      0.912 0.000 0.996 0.000 0.004
#> GSM123775     2  0.4137      0.877 0.012 0.780 0.000 0.208
#> GSM123781     2  0.0336      0.911 0.000 0.992 0.000 0.008
#> GSM123785     2  0.3311      0.895 0.000 0.828 0.000 0.172
#> GSM123788     2  0.3311      0.895 0.000 0.828 0.000 0.172
#> GSM123792     2  0.3266      0.896 0.000 0.832 0.000 0.168
#> GSM123796     2  0.3311      0.895 0.000 0.828 0.000 0.172
#> GSM123731     2  0.0336      0.911 0.000 0.992 0.000 0.008
#> GSM123735     2  0.4134      0.868 0.000 0.740 0.000 0.260
#> GSM123739     2  0.3764      0.893 0.012 0.816 0.000 0.172
#> GSM123743     2  0.1389      0.914 0.000 0.952 0.000 0.048
#> GSM123749     2  0.0188      0.912 0.000 0.996 0.000 0.004
#> GSM123755     2  0.0336      0.911 0.000 0.992 0.000 0.008
#> GSM123768     2  0.0336      0.911 0.000 0.992 0.000 0.008
#> GSM123776     2  0.4284      0.873 0.012 0.764 0.000 0.224
#> GSM123783     2  0.3032      0.883 0.008 0.868 0.000 0.124
#> GSM123790     2  0.4277      0.859 0.000 0.720 0.000 0.280
#> GSM123794     2  0.4222      0.863 0.000 0.728 0.000 0.272
#> GSM123798     2  0.0336      0.911 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123736     3  0.2694   0.867945 0.008 0.000 0.892 0.032 0.068
#> GSM123740     3  0.2694   0.867945 0.008 0.000 0.892 0.032 0.068
#> GSM123744     3  0.4394   0.723320 0.100 0.000 0.764 0.000 0.136
#> GSM123746     1  0.3336   0.789368 0.844 0.000 0.060 0.000 0.096
#> GSM123750     3  0.5927   0.403613 0.236 0.000 0.592 0.000 0.172
#> GSM123752     3  0.3670   0.784878 0.112 0.000 0.820 0.000 0.068
#> GSM123756     1  0.2708   0.829501 0.884 0.000 0.044 0.000 0.072
#> GSM123758     3  0.0992   0.889103 0.008 0.000 0.968 0.000 0.024
#> GSM123761     5  0.6844   0.092503 0.376 0.000 0.212 0.008 0.404
#> GSM123763     5  0.5611   0.322968 0.344 0.000 0.060 0.012 0.584
#> GSM123765     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123769     1  0.2708   0.829501 0.884 0.000 0.044 0.000 0.072
#> GSM123771     1  0.2708   0.829501 0.884 0.000 0.044 0.000 0.072
#> GSM123774     1  0.2370   0.838613 0.904 0.000 0.040 0.000 0.056
#> GSM123778     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123780     3  0.0968   0.883172 0.004 0.000 0.972 0.012 0.012
#> GSM123784     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123787     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123791     3  0.0162   0.893675 0.000 0.000 0.996 0.000 0.004
#> GSM123795     3  0.2775   0.866054 0.008 0.000 0.888 0.036 0.068
#> GSM123799     3  0.2694   0.867945 0.008 0.000 0.892 0.032 0.068
#> GSM123730     4  0.6865   0.807196 0.044 0.000 0.108 0.440 0.408
#> GSM123734     4  0.6460   0.593852 0.180 0.000 0.000 0.412 0.408
#> GSM123738     4  0.6318   0.782215 0.044 0.000 0.056 0.468 0.432
#> GSM123742     5  0.4854   0.406766 0.340 0.000 0.028 0.004 0.628
#> GSM123745     1  0.1907   0.837325 0.928 0.000 0.000 0.028 0.044
#> GSM123748     1  0.2864   0.770455 0.852 0.000 0.012 0.000 0.136
#> GSM123751     1  0.2209   0.826991 0.912 0.000 0.000 0.032 0.056
#> GSM123754     1  0.1907   0.837325 0.928 0.000 0.000 0.028 0.044
#> GSM123757     1  0.1043   0.849185 0.960 0.000 0.040 0.000 0.000
#> GSM123760     5  0.4829   0.369884 0.272 0.000 0.032 0.012 0.684
#> GSM123762     5  0.5146   0.219045 0.432 0.000 0.020 0.012 0.536
#> GSM123764     5  0.6331   0.018704 0.040 0.000 0.240 0.112 0.608
#> GSM123767     1  0.3780   0.681322 0.808 0.000 0.000 0.060 0.132
#> GSM123770     1  0.0451   0.850608 0.988 0.000 0.000 0.004 0.008
#> GSM123773     1  0.1907   0.837325 0.928 0.000 0.000 0.028 0.044
#> GSM123777     4  0.6961   0.799303 0.044 0.000 0.120 0.436 0.400
#> GSM123779     4  0.7133   0.780688 0.052 0.000 0.128 0.412 0.408
#> GSM123782     5  0.6342  -0.000315 0.040 0.000 0.228 0.120 0.612
#> GSM123786     3  0.0451   0.893721 0.000 0.000 0.988 0.004 0.008
#> GSM123789     5  0.6239  -0.036085 0.040 0.000 0.212 0.120 0.628
#> GSM123793     5  0.6204  -0.803349 0.040 0.000 0.052 0.432 0.476
#> GSM123797     4  0.6313   0.786120 0.044 0.000 0.056 0.476 0.424
#> GSM123729     2  0.4878   0.793725 0.000 0.676 0.000 0.264 0.060
#> GSM123733     2  0.3816   0.806007 0.000 0.696 0.000 0.304 0.000
#> GSM123737     2  0.4878   0.795913 0.000 0.676 0.000 0.264 0.060
#> GSM123741     2  0.0162   0.840416 0.000 0.996 0.000 0.004 0.000
#> GSM123747     2  0.3210   0.821717 0.000 0.788 0.000 0.212 0.000
#> GSM123753     2  0.0000   0.840028 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0162   0.839297 0.000 0.996 0.000 0.004 0.000
#> GSM123766     2  0.0162   0.840416 0.000 0.996 0.000 0.004 0.000
#> GSM123772     2  0.0290   0.840557 0.000 0.992 0.000 0.008 0.000
#> GSM123775     2  0.4983   0.778573 0.000 0.664 0.000 0.272 0.064
#> GSM123781     2  0.0162   0.839297 0.000 0.996 0.000 0.004 0.000
#> GSM123785     2  0.3816   0.806007 0.000 0.696 0.000 0.304 0.000
#> GSM123788     2  0.3816   0.806007 0.000 0.696 0.000 0.304 0.000
#> GSM123792     2  0.3816   0.806007 0.000 0.696 0.000 0.304 0.000
#> GSM123796     2  0.3816   0.806007 0.000 0.696 0.000 0.304 0.000
#> GSM123731     2  0.0451   0.839166 0.000 0.988 0.000 0.008 0.004
#> GSM123735     2  0.4331   0.772137 0.000 0.596 0.000 0.400 0.004
#> GSM123739     2  0.4878   0.795913 0.000 0.676 0.000 0.264 0.060
#> GSM123743     2  0.1608   0.844337 0.000 0.928 0.000 0.072 0.000
#> GSM123749     2  0.0000   0.840028 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0162   0.839297 0.000 0.996 0.000 0.004 0.000
#> GSM123768     2  0.0162   0.839297 0.000 0.996 0.000 0.004 0.000
#> GSM123776     2  0.5342   0.754873 0.000 0.612 0.000 0.312 0.076
#> GSM123783     2  0.3284   0.800764 0.000 0.828 0.000 0.148 0.024
#> GSM123790     2  0.4268   0.748717 0.000 0.556 0.000 0.444 0.000
#> GSM123794     2  0.4182   0.773629 0.000 0.600 0.000 0.400 0.000
#> GSM123798     2  0.0162   0.839297 0.000 0.996 0.000 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
#> GSM123732     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123736     3  0.4403      0.797 0.000 0.000 0.760 0.096 NA 0.032
#> GSM123740     3  0.4403      0.797 0.000 0.000 0.760 0.096 NA 0.032
#> GSM123744     3  0.5673      0.655 0.044 0.000 0.632 0.000 NA 0.152
#> GSM123746     1  0.4483      0.728 0.728 0.000 0.008 0.000 NA 0.144
#> GSM123750     3  0.6698      0.457 0.096 0.000 0.516 0.000 NA 0.216
#> GSM123752     3  0.5274      0.713 0.076 0.000 0.688 0.000 NA 0.080
#> GSM123756     1  0.3791      0.801 0.788 0.000 0.004 0.000 NA 0.116
#> GSM123758     3  0.2398      0.828 0.000 0.000 0.876 0.000 NA 0.020
#> GSM123761     6  0.5612      0.475 0.148 0.000 0.044 0.000 NA 0.640
#> GSM123763     6  0.4990      0.566 0.132 0.000 0.012 0.040 NA 0.728
#> GSM123765     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123769     1  0.3791      0.801 0.788 0.000 0.004 0.000 NA 0.116
#> GSM123771     1  0.3791      0.801 0.788 0.000 0.004 0.000 NA 0.116
#> GSM123774     1  0.3554      0.810 0.808 0.000 0.004 0.000 NA 0.108
#> GSM123778     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123780     3  0.1592      0.797 0.000 0.000 0.940 0.008 NA 0.032
#> GSM123784     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123787     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123791     3  0.0260      0.841 0.000 0.000 0.992 0.000 NA 0.000
#> GSM123795     3  0.4448      0.795 0.000 0.000 0.756 0.100 NA 0.032
#> GSM123799     3  0.4403      0.797 0.000 0.000 0.760 0.096 NA 0.032
#> GSM123730     4  0.5144      0.704 0.020 0.000 0.068 0.732 NA 0.080
#> GSM123734     4  0.4672      0.591 0.168 0.000 0.000 0.728 NA 0.044
#> GSM123738     4  0.1078      0.736 0.000 0.000 0.016 0.964 NA 0.012
#> GSM123742     6  0.5031      0.551 0.224 0.000 0.008 0.064 NA 0.680
#> GSM123745     1  0.1780      0.826 0.932 0.000 0.000 0.028 NA 0.028
#> GSM123748     1  0.3374      0.681 0.772 0.000 0.000 0.000 NA 0.208
#> GSM123751     1  0.1760      0.829 0.936 0.000 0.004 0.028 NA 0.020
#> GSM123754     1  0.1116      0.838 0.960 0.000 0.004 0.028 NA 0.000
#> GSM123757     1  0.1793      0.841 0.928 0.000 0.004 0.000 NA 0.036
#> GSM123760     6  0.4528      0.554 0.168 0.000 0.012 0.084 NA 0.732
#> GSM123762     6  0.4795      0.563 0.148 0.000 0.000 0.040 NA 0.724
#> GSM123764     6  0.7129      0.332 0.016 0.000 0.196 0.160 NA 0.508
#> GSM123767     1  0.2114      0.796 0.904 0.000 0.000 0.076 NA 0.008
#> GSM123770     1  0.0291      0.844 0.992 0.000 0.004 0.000 NA 0.004
#> GSM123773     1  0.1116      0.838 0.960 0.000 0.004 0.028 NA 0.000
#> GSM123777     4  0.5536      0.662 0.004 0.000 0.144 0.676 NA 0.076
#> GSM123779     4  0.6822      0.560 0.032 0.000 0.136 0.576 NA 0.148
#> GSM123782     6  0.7264      0.312 0.016 0.000 0.212 0.164 NA 0.484
#> GSM123786     3  0.0000      0.841 0.000 0.000 1.000 0.000 NA 0.000
#> GSM123789     6  0.7269      0.299 0.016 0.000 0.220 0.164 NA 0.480
#> GSM123793     4  0.3146      0.685 0.000 0.000 0.012 0.848 NA 0.080
#> GSM123797     4  0.0748      0.738 0.000 0.000 0.016 0.976 NA 0.004
#> GSM123729     2  0.5067      0.735 0.004 0.612 0.000 0.012 NA 0.060
#> GSM123733     2  0.3531      0.769 0.000 0.672 0.000 0.000 NA 0.000
#> GSM123737     2  0.5020      0.743 0.004 0.624 0.000 0.012 NA 0.060
#> GSM123741     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123747     2  0.2762      0.789 0.000 0.804 0.000 0.000 NA 0.000
#> GSM123753     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123759     2  0.0146      0.812 0.000 0.996 0.000 0.000 NA 0.004
#> GSM123766     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123772     2  0.0146      0.812 0.000 0.996 0.000 0.000 NA 0.000
#> GSM123775     2  0.5133      0.718 0.004 0.604 0.000 0.012 NA 0.064
#> GSM123781     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123785     2  0.3515      0.769 0.000 0.676 0.000 0.000 NA 0.000
#> GSM123788     2  0.3531      0.769 0.000 0.672 0.000 0.000 NA 0.000
#> GSM123792     2  0.3515      0.770 0.000 0.676 0.000 0.000 NA 0.000
#> GSM123796     2  0.3515      0.770 0.000 0.676 0.000 0.000 NA 0.000
#> GSM123731     2  0.0725      0.812 0.000 0.976 0.000 0.000 NA 0.012
#> GSM123735     2  0.4311      0.729 0.004 0.556 0.000 0.008 NA 0.004
#> GSM123739     2  0.5020      0.743 0.004 0.624 0.000 0.012 NA 0.060
#> GSM123743     2  0.1610      0.816 0.000 0.916 0.000 0.000 NA 0.000
#> GSM123749     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 0.000
#> GSM123755     2  0.0146      0.812 0.000 0.996 0.000 0.000 NA 0.004
#> GSM123768     2  0.0146      0.812 0.000 0.996 0.000 0.000 NA 0.004
#> GSM123776     2  0.5217      0.700 0.004 0.564 0.000 0.012 NA 0.060
#> GSM123783     2  0.3637      0.760 0.000 0.788 0.000 0.008 NA 0.040
#> GSM123790     2  0.3867      0.700 0.000 0.512 0.000 0.000 NA 0.000
#> GSM123794     2  0.3854      0.715 0.000 0.536 0.000 0.000 NA 0.000
#> GSM123798     2  0.0000      0.812 0.000 1.000 0.000 0.000 NA 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-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) infection(p) agent(p) k
#> MAD:kmeans 71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:kmeans 71         1.05e-14     1.05e-14 7.76e-06 3
#> MAD:kmeans 66         1.35e-19     1.35e-19 9.64e-05 4
#> MAD:kmeans 61         7.87e-18     7.87e-18 2.99e-04 5
#> MAD:kmeans 66         4.79e-18     4.79e-18 2.91e-04 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 71 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 1.000           0.999       0.999         0.4789 0.522   0.522
#> 3 3 0.826           0.870       0.933         0.4017 0.806   0.628
#> 4 4 0.765           0.773       0.870         0.0885 0.911   0.741
#> 5 5 0.739           0.702       0.789         0.0483 1.000   1.000
#> 6 6 0.662           0.592       0.712         0.0386 0.972   0.896

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
#> GSM123732     1    0.00      0.999 1.000 0.000
#> GSM123736     1    0.00      0.999 1.000 0.000
#> GSM123740     1    0.00      0.999 1.000 0.000
#> GSM123744     1    0.00      0.999 1.000 0.000
#> GSM123746     1    0.00      0.999 1.000 0.000
#> GSM123750     1    0.00      0.999 1.000 0.000
#> GSM123752     1    0.00      0.999 1.000 0.000
#> GSM123756     1    0.00      0.999 1.000 0.000
#> GSM123758     1    0.00      0.999 1.000 0.000
#> GSM123761     1    0.00      0.999 1.000 0.000
#> GSM123763     1    0.00      0.999 1.000 0.000
#> GSM123765     1    0.00      0.999 1.000 0.000
#> GSM123769     1    0.00      0.999 1.000 0.000
#> GSM123771     1    0.00      0.999 1.000 0.000
#> GSM123774     1    0.00      0.999 1.000 0.000
#> GSM123778     1    0.00      0.999 1.000 0.000
#> GSM123780     1    0.00      0.999 1.000 0.000
#> GSM123784     1    0.00      0.999 1.000 0.000
#> GSM123787     1    0.00      0.999 1.000 0.000
#> GSM123791     1    0.00      0.999 1.000 0.000
#> GSM123795     1    0.00      0.999 1.000 0.000
#> GSM123799     1    0.00      0.999 1.000 0.000
#> GSM123730     1    0.26      0.954 0.956 0.044
#> GSM123734     1    0.00      0.999 1.000 0.000
#> GSM123738     1    0.00      0.999 1.000 0.000
#> GSM123742     1    0.00      0.999 1.000 0.000
#> GSM123745     1    0.00      0.999 1.000 0.000
#> GSM123748     1    0.00      0.999 1.000 0.000
#> GSM123751     1    0.00      0.999 1.000 0.000
#> GSM123754     1    0.00      0.999 1.000 0.000
#> GSM123757     1    0.00      0.999 1.000 0.000
#> GSM123760     1    0.00      0.999 1.000 0.000
#> GSM123762     1    0.00      0.999 1.000 0.000
#> GSM123764     1    0.00      0.999 1.000 0.000
#> GSM123767     1    0.00      0.999 1.000 0.000
#> GSM123770     1    0.00      0.999 1.000 0.000
#> GSM123773     1    0.00      0.999 1.000 0.000
#> GSM123777     1    0.00      0.999 1.000 0.000
#> GSM123779     1    0.00      0.999 1.000 0.000
#> GSM123782     1    0.00      0.999 1.000 0.000
#> GSM123786     1    0.00      0.999 1.000 0.000
#> GSM123789     1    0.00      0.999 1.000 0.000
#> GSM123793     1    0.00      0.999 1.000 0.000
#> GSM123797     1    0.00      0.999 1.000 0.000
#> GSM123729     2    0.00      1.000 0.000 1.000
#> GSM123733     2    0.00      1.000 0.000 1.000
#> GSM123737     2    0.00      1.000 0.000 1.000
#> GSM123741     2    0.00      1.000 0.000 1.000
#> GSM123747     2    0.00      1.000 0.000 1.000
#> GSM123753     2    0.00      1.000 0.000 1.000
#> GSM123759     2    0.00      1.000 0.000 1.000
#> GSM123766     2    0.00      1.000 0.000 1.000
#> GSM123772     2    0.00      1.000 0.000 1.000
#> GSM123775     2    0.00      1.000 0.000 1.000
#> GSM123781     2    0.00      1.000 0.000 1.000
#> GSM123785     2    0.00      1.000 0.000 1.000
#> GSM123788     2    0.00      1.000 0.000 1.000
#> GSM123792     2    0.00      1.000 0.000 1.000
#> GSM123796     2    0.00      1.000 0.000 1.000
#> GSM123731     2    0.00      1.000 0.000 1.000
#> GSM123735     2    0.00      1.000 0.000 1.000
#> GSM123739     2    0.00      1.000 0.000 1.000
#> GSM123743     2    0.00      1.000 0.000 1.000
#> GSM123749     2    0.00      1.000 0.000 1.000
#> GSM123755     2    0.00      1.000 0.000 1.000
#> GSM123768     2    0.00      1.000 0.000 1.000
#> GSM123776     2    0.00      1.000 0.000 1.000
#> GSM123783     2    0.00      1.000 0.000 1.000
#> GSM123790     2    0.00      1.000 0.000 1.000
#> GSM123794     2    0.00      1.000 0.000 1.000
#> GSM123798     2    0.00      1.000 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
#> GSM123732     3  0.0000      0.866 0.000  0 1.000
#> GSM123736     3  0.0892      0.862 0.020  0 0.980
#> GSM123740     3  0.0592      0.864 0.012  0 0.988
#> GSM123744     1  0.6215      0.384 0.572  0 0.428
#> GSM123746     1  0.2959      0.856 0.900  0 0.100
#> GSM123750     1  0.5363      0.673 0.724  0 0.276
#> GSM123752     1  0.5678      0.613 0.684  0 0.316
#> GSM123756     1  0.2066      0.879 0.940  0 0.060
#> GSM123758     3  0.3412      0.778 0.124  0 0.876
#> GSM123761     1  0.3879      0.816 0.848  0 0.152
#> GSM123763     1  0.3619      0.838 0.864  0 0.136
#> GSM123765     3  0.0000      0.866 0.000  0 1.000
#> GSM123769     1  0.2066      0.879 0.940  0 0.060
#> GSM123771     1  0.2066      0.879 0.940  0 0.060
#> GSM123774     1  0.1860      0.882 0.948  0 0.052
#> GSM123778     3  0.0000      0.866 0.000  0 1.000
#> GSM123780     3  0.0892      0.861 0.020  0 0.980
#> GSM123784     3  0.0000      0.866 0.000  0 1.000
#> GSM123787     3  0.0000      0.866 0.000  0 1.000
#> GSM123791     3  0.0000      0.866 0.000  0 1.000
#> GSM123795     3  0.1753      0.849 0.048  0 0.952
#> GSM123799     3  0.0747      0.863 0.016  0 0.984
#> GSM123730     3  0.5397      0.706 0.280  0 0.720
#> GSM123734     1  0.1529      0.862 0.960  0 0.040
#> GSM123738     3  0.4452      0.788 0.192  0 0.808
#> GSM123742     1  0.0747      0.883 0.984  0 0.016
#> GSM123745     1  0.0000      0.880 1.000  0 0.000
#> GSM123748     1  0.0424      0.882 0.992  0 0.008
#> GSM123751     1  0.0000      0.880 1.000  0 0.000
#> GSM123754     1  0.0000      0.880 1.000  0 0.000
#> GSM123757     1  0.1860      0.882 0.948  0 0.052
#> GSM123760     1  0.2066      0.848 0.940  0 0.060
#> GSM123762     1  0.1163      0.884 0.972  0 0.028
#> GSM123764     3  0.5363      0.706 0.276  0 0.724
#> GSM123767     1  0.0000      0.880 1.000  0 0.000
#> GSM123770     1  0.0237      0.881 0.996  0 0.004
#> GSM123773     1  0.0000      0.880 1.000  0 0.000
#> GSM123777     3  0.3192      0.829 0.112  0 0.888
#> GSM123779     3  0.6168      0.487 0.412  0 0.588
#> GSM123782     1  0.6291     -0.103 0.532  0 0.468
#> GSM123786     3  0.0000      0.866 0.000  0 1.000
#> GSM123789     3  0.5650      0.665 0.312  0 0.688
#> GSM123793     3  0.5968      0.595 0.364  0 0.636
#> GSM123797     3  0.5431      0.707 0.284  0 0.716
#> GSM123729     2  0.0000      1.000 0.000  1 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000
#> GSM123776     2  0.0000      1.000 0.000  1 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.1489     0.8404 0.004 0.000 0.952 0.044
#> GSM123736     3  0.3229     0.8207 0.048 0.000 0.880 0.072
#> GSM123740     3  0.2996     0.8244 0.044 0.000 0.892 0.064
#> GSM123744     3  0.6426     0.3018 0.352 0.000 0.568 0.080
#> GSM123746     1  0.3088     0.7147 0.888 0.000 0.060 0.052
#> GSM123750     1  0.6374     0.3245 0.556 0.000 0.372 0.072
#> GSM123752     1  0.6235     0.1603 0.524 0.000 0.420 0.056
#> GSM123756     1  0.0657     0.7410 0.984 0.000 0.012 0.004
#> GSM123758     3  0.3107     0.8011 0.080 0.000 0.884 0.036
#> GSM123761     1  0.6298     0.4542 0.632 0.000 0.268 0.100
#> GSM123763     1  0.6873     0.3383 0.580 0.000 0.148 0.272
#> GSM123765     3  0.2480     0.8347 0.008 0.000 0.904 0.088
#> GSM123769     1  0.0927     0.7403 0.976 0.000 0.016 0.008
#> GSM123771     1  0.0524     0.7414 0.988 0.000 0.008 0.004
#> GSM123774     1  0.0188     0.7413 0.996 0.000 0.000 0.004
#> GSM123778     3  0.1743     0.8406 0.004 0.000 0.940 0.056
#> GSM123780     3  0.4072     0.6568 0.000 0.000 0.748 0.252
#> GSM123784     3  0.2814     0.8072 0.000 0.000 0.868 0.132
#> GSM123787     3  0.1557     0.8403 0.000 0.000 0.944 0.056
#> GSM123791     3  0.2124     0.8354 0.008 0.000 0.924 0.068
#> GSM123795     3  0.4990     0.7022 0.060 0.000 0.756 0.184
#> GSM123799     3  0.2830     0.8287 0.040 0.000 0.900 0.060
#> GSM123730     4  0.3700     0.6986 0.036 0.008 0.096 0.860
#> GSM123734     4  0.5353     0.1518 0.432 0.000 0.012 0.556
#> GSM123738     4  0.5478     0.6275 0.056 0.000 0.248 0.696
#> GSM123742     1  0.6264     0.3014 0.560 0.000 0.064 0.376
#> GSM123745     1  0.3649     0.6551 0.796 0.000 0.000 0.204
#> GSM123748     1  0.2654     0.7263 0.888 0.000 0.004 0.108
#> GSM123751     1  0.3528     0.6729 0.808 0.000 0.000 0.192
#> GSM123754     1  0.3074     0.6973 0.848 0.000 0.000 0.152
#> GSM123757     1  0.1109     0.7415 0.968 0.000 0.004 0.028
#> GSM123760     4  0.6655     0.0507 0.440 0.000 0.084 0.476
#> GSM123762     1  0.5144     0.5851 0.732 0.000 0.052 0.216
#> GSM123764     4  0.5935     0.5709 0.080 0.000 0.256 0.664
#> GSM123767     1  0.4477     0.4934 0.688 0.000 0.000 0.312
#> GSM123770     1  0.1302     0.7377 0.956 0.000 0.000 0.044
#> GSM123773     1  0.3123     0.6889 0.844 0.000 0.000 0.156
#> GSM123777     4  0.4621     0.5479 0.008 0.000 0.284 0.708
#> GSM123779     4  0.4599     0.6906 0.112 0.000 0.088 0.800
#> GSM123782     4  0.5994     0.6433 0.152 0.000 0.156 0.692
#> GSM123786     3  0.2345     0.8272 0.000 0.000 0.900 0.100
#> GSM123789     4  0.5454     0.6746 0.096 0.000 0.172 0.732
#> GSM123793     4  0.5113     0.7085 0.088 0.000 0.152 0.760
#> GSM123797     4  0.5143     0.6963 0.076 0.000 0.172 0.752
#> GSM123729     2  0.0336     0.9930 0.000 0.992 0.000 0.008
#> GSM123733     2  0.0188     0.9942 0.000 0.996 0.000 0.004
#> GSM123737     2  0.0188     0.9942 0.000 0.996 0.000 0.004
#> GSM123741     2  0.0000     0.9948 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0336     0.9941 0.000 0.992 0.000 0.008
#> GSM123753     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123759     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123766     2  0.0000     0.9948 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000     0.9948 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0336     0.9940 0.000 0.992 0.000 0.008
#> GSM123781     2  0.0336     0.9940 0.000 0.992 0.000 0.008
#> GSM123785     2  0.0188     0.9942 0.000 0.996 0.000 0.004
#> GSM123788     2  0.0188     0.9942 0.000 0.996 0.000 0.004
#> GSM123792     2  0.0336     0.9937 0.000 0.992 0.000 0.008
#> GSM123796     2  0.0188     0.9942 0.000 0.996 0.000 0.004
#> GSM123731     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123735     2  0.0188     0.9941 0.000 0.996 0.000 0.004
#> GSM123739     2  0.0336     0.9930 0.000 0.992 0.000 0.008
#> GSM123743     2  0.0000     0.9948 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123755     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123768     2  0.0188     0.9946 0.000 0.996 0.000 0.004
#> GSM123776     2  0.1388     0.9629 0.028 0.960 0.000 0.012
#> GSM123783     2  0.0336     0.9940 0.000 0.992 0.000 0.008
#> GSM123790     2  0.0336     0.9924 0.000 0.992 0.000 0.008
#> GSM123794     2  0.0336     0.9932 0.000 0.992 0.000 0.008
#> GSM123798     2  0.0336     0.9940 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM123732     3  0.1393    0.74881 0.008 0.000 0.956 0.012 NA
#> GSM123736     3  0.5684    0.68174 0.048 0.000 0.700 0.108 NA
#> GSM123740     3  0.5307    0.69741 0.032 0.000 0.716 0.080 NA
#> GSM123744     3  0.7326    0.14034 0.332 0.000 0.408 0.032 NA
#> GSM123746     1  0.4791    0.60918 0.748 0.000 0.064 0.020 NA
#> GSM123750     1  0.7159    0.33586 0.476 0.000 0.228 0.032 NA
#> GSM123752     1  0.6642    0.22815 0.492 0.000 0.304 0.008 NA
#> GSM123756     1  0.1041    0.66639 0.964 0.000 0.004 0.000 NA
#> GSM123758     3  0.4363    0.71591 0.072 0.000 0.792 0.020 NA
#> GSM123761     1  0.6824    0.44311 0.536 0.000 0.116 0.052 NA
#> GSM123763     1  0.7990    0.15975 0.396 0.000 0.116 0.176 NA
#> GSM123765     3  0.3504    0.74283 0.004 0.000 0.840 0.064 NA
#> GSM123769     1  0.2054    0.66620 0.916 0.000 0.008 0.004 NA
#> GSM123771     1  0.2237    0.66354 0.904 0.000 0.004 0.008 NA
#> GSM123774     1  0.0510    0.66412 0.984 0.000 0.000 0.000 NA
#> GSM123778     3  0.2459    0.74406 0.004 0.000 0.904 0.052 NA
#> GSM123780     3  0.5470    0.61210 0.012 0.000 0.684 0.180 NA
#> GSM123784     3  0.3390    0.72028 0.000 0.000 0.840 0.100 NA
#> GSM123787     3  0.3432    0.73426 0.000 0.000 0.828 0.040 NA
#> GSM123791     3  0.4923    0.69266 0.020 0.000 0.736 0.068 NA
#> GSM123795     3  0.6820    0.59342 0.072 0.000 0.592 0.152 NA
#> GSM123799     3  0.5297    0.70451 0.040 0.000 0.716 0.064 NA
#> GSM123730     4  0.3445    0.62673 0.048 0.000 0.032 0.860 NA
#> GSM123734     4  0.6232    0.30596 0.300 0.000 0.008 0.552 NA
#> GSM123738     4  0.5941    0.53577 0.032 0.000 0.180 0.660 NA
#> GSM123742     1  0.7627    0.00107 0.352 0.000 0.044 0.316 NA
#> GSM123745     1  0.4930    0.53788 0.696 0.000 0.000 0.220 NA
#> GSM123748     1  0.5148    0.59868 0.688 0.000 0.000 0.120 NA
#> GSM123751     1  0.5553    0.53590 0.664 0.000 0.008 0.204 NA
#> GSM123754     1  0.3752    0.61766 0.804 0.000 0.000 0.148 NA
#> GSM123757     1  0.2332    0.66705 0.904 0.000 0.004 0.016 NA
#> GSM123760     4  0.7277    0.09659 0.292 0.000 0.020 0.360 NA
#> GSM123762     1  0.6079    0.50391 0.604 0.000 0.016 0.124 NA
#> GSM123764     4  0.6997    0.54013 0.048 0.000 0.120 0.456 NA
#> GSM123767     1  0.5273    0.33572 0.588 0.000 0.000 0.352 NA
#> GSM123770     1  0.2708    0.64492 0.884 0.000 0.000 0.072 NA
#> GSM123773     1  0.4303    0.56585 0.752 0.000 0.000 0.192 NA
#> GSM123777     4  0.5602    0.46601 0.008 0.000 0.244 0.644 NA
#> GSM123779     4  0.5177    0.62001 0.068 0.000 0.040 0.732 NA
#> GSM123782     4  0.7390    0.52527 0.076 0.000 0.128 0.432 NA
#> GSM123786     3  0.3180    0.73304 0.000 0.000 0.856 0.068 NA
#> GSM123789     4  0.7466    0.51580 0.084 0.000 0.172 0.500 NA
#> GSM123793     4  0.5496    0.63112 0.036 0.000 0.076 0.696 NA
#> GSM123797     4  0.5194    0.61737 0.060 0.000 0.096 0.748 NA
#> GSM123729     2  0.1671    0.95138 0.000 0.924 0.000 0.000 NA
#> GSM123733     2  0.1502    0.95330 0.000 0.940 0.000 0.004 NA
#> GSM123737     2  0.1197    0.95797 0.000 0.952 0.000 0.000 NA
#> GSM123741     2  0.0510    0.96045 0.000 0.984 0.000 0.000 NA
#> GSM123747     2  0.1121    0.96096 0.000 0.956 0.000 0.000 NA
#> GSM123753     2  0.1043    0.95831 0.000 0.960 0.000 0.000 NA
#> GSM123759     2  0.1043    0.96033 0.000 0.960 0.000 0.000 NA
#> GSM123766     2  0.1197    0.95912 0.000 0.952 0.000 0.000 NA
#> GSM123772     2  0.0794    0.96016 0.000 0.972 0.000 0.000 NA
#> GSM123775     2  0.1908    0.94091 0.000 0.908 0.000 0.000 NA
#> GSM123781     2  0.1270    0.95473 0.000 0.948 0.000 0.000 NA
#> GSM123785     2  0.1430    0.95719 0.000 0.944 0.000 0.004 NA
#> GSM123788     2  0.1043    0.95802 0.000 0.960 0.000 0.000 NA
#> GSM123792     2  0.1124    0.95897 0.000 0.960 0.000 0.004 NA
#> GSM123796     2  0.1502    0.95428 0.000 0.940 0.000 0.004 NA
#> GSM123731     2  0.1043    0.96123 0.000 0.960 0.000 0.000 NA
#> GSM123735     2  0.1768    0.95110 0.000 0.924 0.000 0.004 NA
#> GSM123739     2  0.1270    0.95466 0.000 0.948 0.000 0.000 NA
#> GSM123743     2  0.0963    0.96106 0.000 0.964 0.000 0.000 NA
#> GSM123749     2  0.0510    0.96005 0.000 0.984 0.000 0.000 NA
#> GSM123755     2  0.1341    0.95433 0.000 0.944 0.000 0.000 NA
#> GSM123768     2  0.1410    0.95358 0.000 0.940 0.000 0.000 NA
#> GSM123776     2  0.4499    0.79860 0.060 0.764 0.000 0.012 NA
#> GSM123783     2  0.1965    0.94133 0.000 0.904 0.000 0.000 NA
#> GSM123790     2  0.2304    0.93355 0.000 0.892 0.000 0.008 NA
#> GSM123794     2  0.1671    0.95327 0.000 0.924 0.000 0.000 NA
#> GSM123798     2  0.1197    0.95553 0.000 0.952 0.000 0.000 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM123732     3   0.447     0.6570 0.008 0.000 0.768 0.064 NA 0.040
#> GSM123736     3   0.584     0.6034 0.040 0.000 0.684 0.092 NA 0.100
#> GSM123740     3   0.534     0.6322 0.028 0.000 0.720 0.072 NA 0.076
#> GSM123744     3   0.725     0.0930 0.352 0.000 0.400 0.016 NA 0.128
#> GSM123746     1   0.497     0.4879 0.728 0.000 0.068 0.004 NA 0.124
#> GSM123750     1   0.726     0.1534 0.456 0.000 0.212 0.012 NA 0.224
#> GSM123752     1   0.725     0.1902 0.468 0.000 0.256 0.020 NA 0.092
#> GSM123756     1   0.100     0.5877 0.964 0.000 0.000 0.000 NA 0.016
#> GSM123758     3   0.585     0.5660 0.140 0.000 0.652 0.012 NA 0.060
#> GSM123761     1   0.699     0.1874 0.492 0.000 0.128 0.016 NA 0.272
#> GSM123763     6   0.783     0.1302 0.356 0.000 0.108 0.096 NA 0.360
#> GSM123765     3   0.463     0.6532 0.008 0.000 0.764 0.088 NA 0.072
#> GSM123769     1   0.248     0.5786 0.900 0.000 0.028 0.004 NA 0.044
#> GSM123771     1   0.210     0.5785 0.912 0.000 0.008 0.000 NA 0.052
#> GSM123774     1   0.148     0.5907 0.944 0.000 0.000 0.008 NA 0.036
#> GSM123778     3   0.503     0.6429 0.004 0.000 0.720 0.076 NA 0.064
#> GSM123780     3   0.629     0.5240 0.004 0.000 0.596 0.172 NA 0.100
#> GSM123784     3   0.465     0.6199 0.000 0.000 0.744 0.128 NA 0.052
#> GSM123787     3   0.537     0.6414 0.016 0.000 0.700 0.052 NA 0.088
#> GSM123791     3   0.617     0.5983 0.032 0.000 0.644 0.076 NA 0.108
#> GSM123795     3   0.699     0.4836 0.072 0.000 0.572 0.148 NA 0.136
#> GSM123799     3   0.575     0.6205 0.060 0.000 0.696 0.068 NA 0.080
#> GSM123730     4   0.365     0.4300 0.020 0.000 0.024 0.836 NA 0.056
#> GSM123734     4   0.641     0.1154 0.152 0.000 0.008 0.464 NA 0.348
#> GSM123738     4   0.674     0.3729 0.024 0.000 0.212 0.540 NA 0.172
#> GSM123742     6   0.644     0.3110 0.240 0.000 0.028 0.112 NA 0.572
#> GSM123745     1   0.654     0.3170 0.480 0.000 0.000 0.216 NA 0.260
#> GSM123748     1   0.588     0.3275 0.516 0.000 0.004 0.064 NA 0.368
#> GSM123751     1   0.654     0.3404 0.516 0.000 0.008 0.160 NA 0.268
#> GSM123754     1   0.502     0.5033 0.696 0.000 0.000 0.164 NA 0.108
#> GSM123757     1   0.316     0.5815 0.856 0.000 0.008 0.016 NA 0.084
#> GSM123760     6   0.587     0.3261 0.160 0.000 0.016 0.168 NA 0.628
#> GSM123762     1   0.665     0.0408 0.460 0.000 0.040 0.060 NA 0.380
#> GSM123764     6   0.682     0.2341 0.044 0.000 0.092 0.204 NA 0.568
#> GSM123767     1   0.618     0.2869 0.492 0.000 0.000 0.340 NA 0.128
#> GSM123770     1   0.362     0.5609 0.820 0.000 0.000 0.068 NA 0.088
#> GSM123773     1   0.559     0.4467 0.632 0.000 0.000 0.212 NA 0.112
#> GSM123777     4   0.509     0.3421 0.000 0.000 0.164 0.696 NA 0.044
#> GSM123779     4   0.633     0.2869 0.048 0.000 0.032 0.588 NA 0.236
#> GSM123782     6   0.720     0.1639 0.044 0.000 0.060 0.248 NA 0.492
#> GSM123786     3   0.540     0.6263 0.008 0.000 0.672 0.048 NA 0.076
#> GSM123789     6   0.732     0.0892 0.040 0.000 0.104 0.284 NA 0.468
#> GSM123793     4   0.617     0.2464 0.024 0.000 0.084 0.484 NA 0.384
#> GSM123797     4   0.587     0.4400 0.036 0.000 0.096 0.640 NA 0.200
#> GSM123729     2   0.273     0.8877 0.000 0.808 0.000 0.000 NA 0.000
#> GSM123733     2   0.226     0.8962 0.000 0.860 0.000 0.000 NA 0.000
#> GSM123737     2   0.256     0.8905 0.000 0.828 0.000 0.000 NA 0.000
#> GSM123741     2   0.133     0.9098 0.000 0.936 0.000 0.000 NA 0.000
#> GSM123747     2   0.133     0.9079 0.000 0.936 0.000 0.000 NA 0.000
#> GSM123753     2   0.120     0.9019 0.000 0.944 0.000 0.000 NA 0.000
#> GSM123759     2   0.161     0.8957 0.000 0.916 0.000 0.000 NA 0.000
#> GSM123766     2   0.156     0.9044 0.000 0.920 0.000 0.000 NA 0.000
#> GSM123772     2   0.139     0.9079 0.000 0.932 0.000 0.000 NA 0.000
#> GSM123775     2   0.285     0.8587 0.000 0.792 0.000 0.000 NA 0.000
#> GSM123781     2   0.161     0.8956 0.000 0.916 0.000 0.000 NA 0.000
#> GSM123785     2   0.205     0.9003 0.000 0.880 0.000 0.000 NA 0.000
#> GSM123788     2   0.218     0.8960 0.000 0.868 0.000 0.000 NA 0.000
#> GSM123792     2   0.209     0.9018 0.000 0.876 0.000 0.000 NA 0.000
#> GSM123796     2   0.214     0.8982 0.000 0.872 0.000 0.000 NA 0.000
#> GSM123731     2   0.150     0.9083 0.000 0.924 0.000 0.000 NA 0.000
#> GSM123735     2   0.226     0.8982 0.000 0.860 0.000 0.000 NA 0.000
#> GSM123739     2   0.273     0.8860 0.000 0.808 0.000 0.000 NA 0.000
#> GSM123743     2   0.181     0.9098 0.000 0.900 0.000 0.000 NA 0.000
#> GSM123749     2   0.144     0.9059 0.000 0.928 0.000 0.000 NA 0.000
#> GSM123755     2   0.139     0.8983 0.000 0.932 0.000 0.000 NA 0.000
#> GSM123768     2   0.205     0.8838 0.000 0.880 0.000 0.000 NA 0.000
#> GSM123776     2   0.565     0.5722 0.060 0.540 0.000 0.024 NA 0.012
#> GSM123783     2   0.290     0.8640 0.000 0.800 0.000 0.004 NA 0.000
#> GSM123790     2   0.326     0.8561 0.000 0.780 0.000 0.016 NA 0.000
#> GSM123794     2   0.260     0.8868 0.000 0.836 0.000 0.004 NA 0.000
#> GSM123798     2   0.171     0.8970 0.000 0.908 0.000 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n disease.state(p) infection(p) agent(p) k
#> MAD:skmeans 71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:skmeans 68         2.27e-14     2.27e-14 1.57e-05 3
#> MAD:skmeans 62         2.04e-18     2.04e-18 2.38e-04 4
#> MAD:skmeans 61         6.26e-18     6.26e-18 2.99e-04 5
#> MAD:skmeans 46         6.15e-11     6.15e-11 3.30e-03 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.985       0.993        0.48151 0.522   0.522
#> 3 3 1.000           0.971       0.987        0.37383 0.815   0.646
#> 4 4 0.943           0.901       0.950        0.03376 0.990   0.969
#> 5 5 0.886           0.860       0.933        0.01836 0.994   0.980
#> 6 6 0.884           0.859       0.932        0.00926 0.994   0.981

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1   0.000      0.989 1.000 0.000
#> GSM123736     1   0.000      0.989 1.000 0.000
#> GSM123740     1   0.000      0.989 1.000 0.000
#> GSM123744     1   0.000      0.989 1.000 0.000
#> GSM123746     1   0.000      0.989 1.000 0.000
#> GSM123750     1   0.000      0.989 1.000 0.000
#> GSM123752     1   0.000      0.989 1.000 0.000
#> GSM123756     1   0.000      0.989 1.000 0.000
#> GSM123758     1   0.000      0.989 1.000 0.000
#> GSM123761     1   0.000      0.989 1.000 0.000
#> GSM123763     1   0.000      0.989 1.000 0.000
#> GSM123765     1   0.000      0.989 1.000 0.000
#> GSM123769     1   0.000      0.989 1.000 0.000
#> GSM123771     1   0.000      0.989 1.000 0.000
#> GSM123774     1   0.000      0.989 1.000 0.000
#> GSM123778     1   0.000      0.989 1.000 0.000
#> GSM123780     1   0.000      0.989 1.000 0.000
#> GSM123784     1   0.000      0.989 1.000 0.000
#> GSM123787     1   0.000      0.989 1.000 0.000
#> GSM123791     1   0.000      0.989 1.000 0.000
#> GSM123795     1   0.000      0.989 1.000 0.000
#> GSM123799     1   0.000      0.989 1.000 0.000
#> GSM123730     1   0.327      0.933 0.940 0.060
#> GSM123734     1   0.000      0.989 1.000 0.000
#> GSM123738     1   0.000      0.989 1.000 0.000
#> GSM123742     1   0.000      0.989 1.000 0.000
#> GSM123745     1   0.855      0.618 0.720 0.280
#> GSM123748     1   0.000      0.989 1.000 0.000
#> GSM123751     1   0.000      0.989 1.000 0.000
#> GSM123754     1   0.000      0.989 1.000 0.000
#> GSM123757     1   0.000      0.989 1.000 0.000
#> GSM123760     1   0.000      0.989 1.000 0.000
#> GSM123762     1   0.000      0.989 1.000 0.000
#> GSM123764     1   0.000      0.989 1.000 0.000
#> GSM123767     1   0.469      0.888 0.900 0.100
#> GSM123770     1   0.000      0.989 1.000 0.000
#> GSM123773     1   0.000      0.989 1.000 0.000
#> GSM123777     1   0.204      0.960 0.968 0.032
#> GSM123779     1   0.000      0.989 1.000 0.000
#> GSM123782     1   0.000      0.989 1.000 0.000
#> GSM123786     1   0.000      0.989 1.000 0.000
#> GSM123789     1   0.000      0.989 1.000 0.000
#> GSM123793     1   0.000      0.989 1.000 0.000
#> GSM123797     1   0.000      0.989 1.000 0.000
#> GSM123729     2   0.000      1.000 0.000 1.000
#> GSM123733     2   0.000      1.000 0.000 1.000
#> GSM123737     2   0.000      1.000 0.000 1.000
#> GSM123741     2   0.000      1.000 0.000 1.000
#> GSM123747     2   0.000      1.000 0.000 1.000
#> GSM123753     2   0.000      1.000 0.000 1.000
#> GSM123759     2   0.000      1.000 0.000 1.000
#> GSM123766     2   0.000      1.000 0.000 1.000
#> GSM123772     2   0.000      1.000 0.000 1.000
#> GSM123775     2   0.000      1.000 0.000 1.000
#> GSM123781     2   0.000      1.000 0.000 1.000
#> GSM123785     2   0.000      1.000 0.000 1.000
#> GSM123788     2   0.000      1.000 0.000 1.000
#> GSM123792     2   0.000      1.000 0.000 1.000
#> GSM123796     2   0.000      1.000 0.000 1.000
#> GSM123731     2   0.000      1.000 0.000 1.000
#> GSM123735     2   0.000      1.000 0.000 1.000
#> GSM123739     2   0.000      1.000 0.000 1.000
#> GSM123743     2   0.000      1.000 0.000 1.000
#> GSM123749     2   0.000      1.000 0.000 1.000
#> GSM123755     2   0.000      1.000 0.000 1.000
#> GSM123768     2   0.000      1.000 0.000 1.000
#> GSM123776     2   0.000      1.000 0.000 1.000
#> GSM123783     2   0.000      1.000 0.000 1.000
#> GSM123790     2   0.000      1.000 0.000 1.000
#> GSM123794     2   0.000      1.000 0.000 1.000
#> GSM123798     2   0.000      1.000 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
#> GSM123732     3  0.0000      0.987 0.000  0 1.000
#> GSM123736     3  0.0000      0.987 0.000  0 1.000
#> GSM123740     3  0.0000      0.987 0.000  0 1.000
#> GSM123744     3  0.0237      0.985 0.004  0 0.996
#> GSM123746     3  0.3752      0.837 0.144  0 0.856
#> GSM123750     3  0.0000      0.987 0.000  0 1.000
#> GSM123752     3  0.0747      0.978 0.016  0 0.984
#> GSM123756     1  0.0000      0.962 1.000  0 0.000
#> GSM123758     3  0.0747      0.978 0.016  0 0.984
#> GSM123761     3  0.1163      0.969 0.028  0 0.972
#> GSM123763     3  0.2066      0.940 0.060  0 0.940
#> GSM123765     3  0.0000      0.987 0.000  0 1.000
#> GSM123769     1  0.0000      0.962 1.000  0 0.000
#> GSM123771     1  0.0000      0.962 1.000  0 0.000
#> GSM123774     1  0.0000      0.962 1.000  0 0.000
#> GSM123778     3  0.0000      0.987 0.000  0 1.000
#> GSM123780     3  0.0000      0.987 0.000  0 1.000
#> GSM123784     3  0.0000      0.987 0.000  0 1.000
#> GSM123787     3  0.0000      0.987 0.000  0 1.000
#> GSM123791     3  0.0000      0.987 0.000  0 1.000
#> GSM123795     3  0.0000      0.987 0.000  0 1.000
#> GSM123799     3  0.0000      0.987 0.000  0 1.000
#> GSM123730     3  0.0000      0.987 0.000  0 1.000
#> GSM123734     1  0.0000      0.962 1.000  0 0.000
#> GSM123738     3  0.1411      0.960 0.036  0 0.964
#> GSM123742     1  0.1031      0.945 0.976  0 0.024
#> GSM123745     1  0.0000      0.962 1.000  0 0.000
#> GSM123748     1  0.0000      0.962 1.000  0 0.000
#> GSM123751     1  0.0000      0.962 1.000  0 0.000
#> GSM123754     1  0.0000      0.962 1.000  0 0.000
#> GSM123757     1  0.0592      0.954 0.988  0 0.012
#> GSM123760     1  0.4178      0.790 0.828  0 0.172
#> GSM123762     1  0.0000      0.962 1.000  0 0.000
#> GSM123764     3  0.0000      0.987 0.000  0 1.000
#> GSM123767     1  0.0000      0.962 1.000  0 0.000
#> GSM123770     1  0.0000      0.962 1.000  0 0.000
#> GSM123773     1  0.0000      0.962 1.000  0 0.000
#> GSM123777     3  0.0000      0.987 0.000  0 1.000
#> GSM123779     3  0.0424      0.983 0.008  0 0.992
#> GSM123782     3  0.0000      0.987 0.000  0 1.000
#> GSM123786     3  0.0000      0.987 0.000  0 1.000
#> GSM123789     3  0.0237      0.985 0.004  0 0.996
#> GSM123793     3  0.0747      0.977 0.016  0 0.984
#> GSM123797     1  0.6111      0.373 0.604  0 0.396
#> GSM123729     2  0.0000      1.000 0.000  1 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000
#> GSM123776     2  0.0000      1.000 0.000  1 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM123732     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123736     3  0.1557      0.903 0.000  0 0.944 0.056
#> GSM123740     3  0.1557      0.903 0.000  0 0.944 0.056
#> GSM123744     3  0.1356      0.918 0.008  0 0.960 0.032
#> GSM123746     3  0.5653      0.544 0.096  0 0.712 0.192
#> GSM123750     3  0.0469      0.928 0.012  0 0.988 0.000
#> GSM123752     3  0.1975      0.891 0.016  0 0.936 0.048
#> GSM123756     1  0.3610      0.848 0.800  0 0.000 0.200
#> GSM123758     3  0.2412      0.857 0.008  0 0.908 0.084
#> GSM123761     3  0.4182      0.707 0.024  0 0.796 0.180
#> GSM123763     3  0.3962      0.767 0.044  0 0.832 0.124
#> GSM123765     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123769     1  0.1867      0.870 0.928  0 0.000 0.072
#> GSM123771     1  0.1867      0.872 0.928  0 0.000 0.072
#> GSM123774     1  0.1940      0.872 0.924  0 0.000 0.076
#> GSM123778     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123780     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123784     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123787     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123791     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123795     3  0.1557      0.903 0.000  0 0.944 0.056
#> GSM123799     3  0.1389      0.908 0.000  0 0.952 0.048
#> GSM123730     3  0.0895      0.921 0.020  0 0.976 0.004
#> GSM123734     1  0.0921      0.870 0.972  0 0.000 0.028
#> GSM123738     3  0.3587      0.822 0.052  0 0.860 0.088
#> GSM123742     1  0.2868      0.858 0.864  0 0.000 0.136
#> GSM123745     1  0.0469      0.879 0.988  0 0.000 0.012
#> GSM123748     1  0.2921      0.856 0.860  0 0.000 0.140
#> GSM123751     1  0.2081      0.875 0.916  0 0.000 0.084
#> GSM123754     1  0.3569      0.848 0.804  0 0.000 0.196
#> GSM123757     1  0.3024      0.856 0.852  0 0.000 0.148
#> GSM123760     1  0.4514      0.803 0.800  0 0.064 0.136
#> GSM123762     1  0.2011      0.867 0.920  0 0.000 0.080
#> GSM123764     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123767     1  0.0336      0.876 0.992  0 0.000 0.008
#> GSM123770     1  0.0336      0.876 0.992  0 0.000 0.008
#> GSM123773     1  0.0188      0.877 0.996  0 0.000 0.004
#> GSM123777     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123779     3  0.1109      0.916 0.028  0 0.968 0.004
#> GSM123782     3  0.0524      0.928 0.008  0 0.988 0.004
#> GSM123786     3  0.0000      0.930 0.000  0 1.000 0.000
#> GSM123789     3  0.0937      0.923 0.012  0 0.976 0.012
#> GSM123793     4  0.4542      0.000 0.020  0 0.228 0.752
#> GSM123797     1  0.6568      0.128 0.572  0 0.332 0.096
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123776     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 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
#> GSM123732     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123736     3  0.2020      0.882 0.000  0 0.900 0.100 0.000
#> GSM123740     3  0.2020      0.882 0.000  0 0.900 0.100 0.000
#> GSM123744     3  0.1569      0.915 0.008  0 0.948 0.032 0.012
#> GSM123746     3  0.5433      0.568 0.084  0 0.652 0.008 0.256
#> GSM123750     3  0.0960      0.919 0.016  0 0.972 0.004 0.008
#> GSM123752     3  0.2478      0.883 0.028  0 0.904 0.008 0.060
#> GSM123756     1  0.3766      0.712 0.728  0 0.000 0.004 0.268
#> GSM123758     3  0.2304      0.866 0.008  0 0.892 0.000 0.100
#> GSM123761     3  0.4625      0.669 0.036  0 0.712 0.008 0.244
#> GSM123763     3  0.4181      0.760 0.032  0 0.780 0.016 0.172
#> GSM123765     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123769     1  0.2389      0.726 0.880  0 0.000 0.004 0.116
#> GSM123771     1  0.2439      0.731 0.876  0 0.000 0.004 0.120
#> GSM123774     1  0.2488      0.732 0.872  0 0.000 0.004 0.124
#> GSM123778     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123780     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123784     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123787     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123791     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123795     3  0.2020      0.882 0.000  0 0.900 0.100 0.000
#> GSM123799     3  0.1671      0.896 0.000  0 0.924 0.076 0.000
#> GSM123730     3  0.0833      0.919 0.016  0 0.976 0.004 0.004
#> GSM123734     1  0.3051      0.637 0.852  0 0.000 0.028 0.120
#> GSM123738     3  0.4015      0.786 0.024  0 0.788 0.172 0.016
#> GSM123742     1  0.3093      0.755 0.824  0 0.000 0.008 0.168
#> GSM123745     1  0.0566      0.770 0.984  0 0.000 0.004 0.012
#> GSM123748     1  0.2929      0.762 0.840  0 0.000 0.008 0.152
#> GSM123751     1  0.1908      0.781 0.908  0 0.000 0.000 0.092
#> GSM123754     1  0.3715      0.717 0.736  0 0.000 0.004 0.260
#> GSM123757     1  0.3132      0.754 0.820  0 0.000 0.008 0.172
#> GSM123760     1  0.3928      0.728 0.788  0 0.028 0.008 0.176
#> GSM123762     5  0.3876      0.000 0.316  0 0.000 0.000 0.684
#> GSM123764     3  0.0324      0.923 0.000  0 0.992 0.004 0.004
#> GSM123767     1  0.0451      0.765 0.988  0 0.000 0.004 0.008
#> GSM123770     1  0.0451      0.765 0.988  0 0.000 0.004 0.008
#> GSM123773     1  0.0324      0.766 0.992  0 0.000 0.004 0.004
#> GSM123777     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123779     3  0.1026      0.916 0.024  0 0.968 0.004 0.004
#> GSM123782     3  0.0613      0.922 0.008  0 0.984 0.004 0.004
#> GSM123786     3  0.0000      0.923 0.000  0 1.000 0.000 0.000
#> GSM123789     3  0.1018      0.919 0.016  0 0.968 0.000 0.016
#> GSM123793     4  0.1670      0.000 0.012  0 0.052 0.936 0.000
#> GSM123797     1  0.6602      0.143 0.560  0 0.240 0.176 0.024
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123776     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM123732     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123736     3  0.2069      0.892 0.000  0 0.908 0.020 0.068 0.004
#> GSM123740     3  0.2069      0.892 0.000  0 0.908 0.020 0.068 0.004
#> GSM123744     3  0.1448      0.917 0.016  0 0.948 0.000 0.024 0.012
#> GSM123746     3  0.4954      0.552 0.260  0 0.628 0.000 0.000 0.112
#> GSM123750     3  0.1010      0.915 0.036  0 0.960 0.000 0.000 0.004
#> GSM123752     3  0.2006      0.877 0.104  0 0.892 0.000 0.000 0.004
#> GSM123756     1  0.2491      0.749 0.836  0 0.000 0.000 0.000 0.164
#> GSM123758     3  0.2118      0.868 0.104  0 0.888 0.000 0.000 0.008
#> GSM123761     3  0.4503      0.668 0.204  0 0.696 0.000 0.000 0.100
#> GSM123763     3  0.4175      0.759 0.100  0 0.768 0.008 0.004 0.120
#> GSM123765     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123769     1  0.3595      0.749 0.704  0 0.000 0.008 0.000 0.288
#> GSM123771     1  0.3555      0.753 0.712  0 0.000 0.008 0.000 0.280
#> GSM123774     1  0.3534      0.755 0.716  0 0.000 0.008 0.000 0.276
#> GSM123778     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123780     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123784     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123791     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123795     3  0.2069      0.892 0.000  0 0.908 0.020 0.068 0.004
#> GSM123799     3  0.1826      0.900 0.000  0 0.924 0.020 0.052 0.004
#> GSM123730     3  0.0508      0.923 0.004  0 0.984 0.012 0.000 0.000
#> GSM123734     4  0.3041      0.000 0.040  0 0.000 0.832 0.000 0.128
#> GSM123738     3  0.4256      0.760 0.004  0 0.756 0.160 0.068 0.012
#> GSM123742     1  0.0547      0.788 0.980  0 0.000 0.000 0.000 0.020
#> GSM123745     1  0.2704      0.798 0.844  0 0.000 0.016 0.000 0.140
#> GSM123748     1  0.0146      0.794 0.996  0 0.000 0.000 0.000 0.004
#> GSM123751     1  0.1838      0.808 0.916  0 0.000 0.016 0.000 0.068
#> GSM123754     1  0.2320      0.752 0.864  0 0.000 0.004 0.000 0.132
#> GSM123757     1  0.0458      0.787 0.984  0 0.000 0.000 0.000 0.016
#> GSM123760     1  0.1176      0.773 0.956  0 0.020 0.000 0.000 0.024
#> GSM123762     6  0.1563      0.000 0.056  0 0.000 0.012 0.000 0.932
#> GSM123764     3  0.0291      0.925 0.004  0 0.992 0.000 0.004 0.000
#> GSM123767     1  0.2869      0.794 0.832  0 0.000 0.020 0.000 0.148
#> GSM123770     1  0.2907      0.792 0.828  0 0.000 0.020 0.000 0.152
#> GSM123773     1  0.2821      0.794 0.832  0 0.000 0.016 0.000 0.152
#> GSM123777     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123779     3  0.0725      0.921 0.012  0 0.976 0.012 0.000 0.000
#> GSM123782     3  0.0632      0.922 0.024  0 0.976 0.000 0.000 0.000
#> GSM123786     3  0.0000      0.924 0.000  0 1.000 0.000 0.000 0.000
#> GSM123789     3  0.0790      0.921 0.032  0 0.968 0.000 0.000 0.000
#> GSM123793     5  0.0000      0.000 0.000  0 0.000 0.000 1.000 0.000
#> GSM123797     1  0.6660      0.250 0.544  0 0.208 0.168 0.068 0.012
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123776     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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) infection(p) agent(p) k
#> MAD:pam 71         3.82e-16     3.82e-16 6.04e-06 2
#> MAD:pam 70         8.95e-17     8.95e-17 9.81e-06 3
#> MAD:pam 69         7.37e-17     7.37e-17 1.24e-05 4
#> MAD:pam 68         2.23e-16     2.23e-16 1.57e-05 5
#> MAD:pam 67         6.88e-16     6.88e-16 1.98e-05 6

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


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

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4714 0.529   0.529
#> 3 3 0.948           0.937       0.970         0.2802 0.859   0.734
#> 4 4 0.865           0.853       0.920         0.1860 0.878   0.693
#> 5 5 0.844           0.766       0.882         0.0561 0.930   0.761
#> 6 6 0.719           0.634       0.796         0.0452 0.973   0.891

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM123732     1       0          1  1  0
#> GSM123736     1       0          1  1  0
#> GSM123740     1       0          1  1  0
#> GSM123744     1       0          1  1  0
#> GSM123746     1       0          1  1  0
#> GSM123750     1       0          1  1  0
#> GSM123752     1       0          1  1  0
#> GSM123756     1       0          1  1  0
#> GSM123758     1       0          1  1  0
#> GSM123761     1       0          1  1  0
#> GSM123763     1       0          1  1  0
#> GSM123765     1       0          1  1  0
#> GSM123769     1       0          1  1  0
#> GSM123771     1       0          1  1  0
#> GSM123774     1       0          1  1  0
#> GSM123778     1       0          1  1  0
#> GSM123780     1       0          1  1  0
#> GSM123784     1       0          1  1  0
#> GSM123787     1       0          1  1  0
#> GSM123791     1       0          1  1  0
#> GSM123795     1       0          1  1  0
#> GSM123799     1       0          1  1  0
#> GSM123730     1       0          1  1  0
#> GSM123734     1       0          1  1  0
#> GSM123738     1       0          1  1  0
#> GSM123742     1       0          1  1  0
#> GSM123745     1       0          1  1  0
#> GSM123748     1       0          1  1  0
#> GSM123751     1       0          1  1  0
#> GSM123754     1       0          1  1  0
#> GSM123757     1       0          1  1  0
#> GSM123760     1       0          1  1  0
#> GSM123762     1       0          1  1  0
#> GSM123764     1       0          1  1  0
#> GSM123767     1       0          1  1  0
#> GSM123770     1       0          1  1  0
#> GSM123773     1       0          1  1  0
#> GSM123777     1       0          1  1  0
#> GSM123779     1       0          1  1  0
#> GSM123782     1       0          1  1  0
#> GSM123786     1       0          1  1  0
#> GSM123789     1       0          1  1  0
#> GSM123793     1       0          1  1  0
#> GSM123797     1       0          1  1  0
#> GSM123729     2       0          1  0  1
#> GSM123733     2       0          1  0  1
#> GSM123737     2       0          1  0  1
#> GSM123741     2       0          1  0  1
#> GSM123747     2       0          1  0  1
#> GSM123753     2       0          1  0  1
#> GSM123759     2       0          1  0  1
#> GSM123766     2       0          1  0  1
#> GSM123772     2       0          1  0  1
#> GSM123775     2       0          1  0  1
#> GSM123781     2       0          1  0  1
#> GSM123785     2       0          1  0  1
#> GSM123788     2       0          1  0  1
#> GSM123792     2       0          1  0  1
#> GSM123796     2       0          1  0  1
#> GSM123731     2       0          1  0  1
#> GSM123735     2       0          1  0  1
#> GSM123739     2       0          1  0  1
#> GSM123743     2       0          1  0  1
#> GSM123749     2       0          1  0  1
#> GSM123755     2       0          1  0  1
#> GSM123768     2       0          1  0  1
#> GSM123776     1       0          1  1  0
#> GSM123783     2       0          1  0  1
#> GSM123790     2       0          1  0  1
#> GSM123794     2       0          1  0  1
#> GSM123798     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1 p2    p3
#> GSM123732     3  0.0000      0.838 0.000  0 1.000
#> GSM123736     1  0.5859      0.369 0.656  0 0.344
#> GSM123740     3  0.5058      0.718 0.244  0 0.756
#> GSM123744     1  0.1031      0.963 0.976  0 0.024
#> GSM123746     1  0.0000      0.973 1.000  0 0.000
#> GSM123750     1  0.0424      0.972 0.992  0 0.008
#> GSM123752     1  0.0000      0.973 1.000  0 0.000
#> GSM123756     1  0.0000      0.973 1.000  0 0.000
#> GSM123758     1  0.4235      0.759 0.824  0 0.176
#> GSM123761     1  0.0000      0.973 1.000  0 0.000
#> GSM123763     1  0.0424      0.972 0.992  0 0.008
#> GSM123765     3  0.0237      0.839 0.004  0 0.996
#> GSM123769     1  0.0000      0.973 1.000  0 0.000
#> GSM123771     1  0.0000      0.973 1.000  0 0.000
#> GSM123774     1  0.0000      0.973 1.000  0 0.000
#> GSM123778     3  0.0000      0.838 0.000  0 1.000
#> GSM123780     3  0.6235      0.354 0.436  0 0.564
#> GSM123784     3  0.2959      0.828 0.100  0 0.900
#> GSM123787     3  0.0000      0.838 0.000  0 1.000
#> GSM123791     3  0.3619      0.811 0.136  0 0.864
#> GSM123795     1  0.2261      0.916 0.932  0 0.068
#> GSM123799     3  0.6095      0.475 0.392  0 0.608
#> GSM123730     1  0.0592      0.971 0.988  0 0.012
#> GSM123734     1  0.0000      0.973 1.000  0 0.000
#> GSM123738     1  0.0747      0.969 0.984  0 0.016
#> GSM123742     1  0.0592      0.971 0.988  0 0.012
#> GSM123745     1  0.0000      0.973 1.000  0 0.000
#> GSM123748     1  0.0000      0.973 1.000  0 0.000
#> GSM123751     1  0.0000      0.973 1.000  0 0.000
#> GSM123754     1  0.0000      0.973 1.000  0 0.000
#> GSM123757     1  0.0000      0.973 1.000  0 0.000
#> GSM123760     1  0.0592      0.971 0.988  0 0.012
#> GSM123762     1  0.0000      0.973 1.000  0 0.000
#> GSM123764     1  0.1163      0.959 0.972  0 0.028
#> GSM123767     1  0.0000      0.973 1.000  0 0.000
#> GSM123770     1  0.0000      0.973 1.000  0 0.000
#> GSM123773     1  0.0000      0.973 1.000  0 0.000
#> GSM123777     1  0.0747      0.969 0.984  0 0.016
#> GSM123779     1  0.0592      0.971 0.988  0 0.012
#> GSM123782     1  0.0592      0.971 0.988  0 0.012
#> GSM123786     3  0.0000      0.838 0.000  0 1.000
#> GSM123789     1  0.1031      0.963 0.976  0 0.024
#> GSM123793     1  0.0747      0.969 0.984  0 0.016
#> GSM123797     1  0.0592      0.971 0.988  0 0.012
#> GSM123729     2  0.0000      1.000 0.000  1 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000
#> GSM123776     1  0.0000      0.973 1.000  0 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0336     0.8389 0.000 0.000 0.992 0.008
#> GSM123736     3  0.5188     0.7045 0.044 0.000 0.716 0.240
#> GSM123740     3  0.3636     0.8017 0.008 0.000 0.820 0.172
#> GSM123744     1  0.5312     0.6675 0.712 0.000 0.052 0.236
#> GSM123746     1  0.0336     0.8452 0.992 0.000 0.000 0.008
#> GSM123750     1  0.3881     0.7748 0.812 0.000 0.016 0.172
#> GSM123752     1  0.3636     0.7804 0.820 0.000 0.008 0.172
#> GSM123756     1  0.0817     0.8336 0.976 0.000 0.000 0.024
#> GSM123758     1  0.7702     0.0369 0.416 0.000 0.360 0.224
#> GSM123761     1  0.2999     0.8100 0.864 0.000 0.004 0.132
#> GSM123763     1  0.4053     0.7286 0.768 0.000 0.004 0.228
#> GSM123765     3  0.0707     0.8420 0.000 0.000 0.980 0.020
#> GSM123769     1  0.0707     0.8344 0.980 0.000 0.000 0.020
#> GSM123771     1  0.0817     0.8336 0.976 0.000 0.000 0.024
#> GSM123774     1  0.0817     0.8336 0.976 0.000 0.000 0.024
#> GSM123778     3  0.0188     0.8370 0.000 0.000 0.996 0.004
#> GSM123780     3  0.4609     0.7509 0.024 0.000 0.752 0.224
#> GSM123784     3  0.2412     0.8401 0.008 0.000 0.908 0.084
#> GSM123787     3  0.0188     0.8370 0.000 0.000 0.996 0.004
#> GSM123791     3  0.1716     0.8444 0.000 0.000 0.936 0.064
#> GSM123795     3  0.6992     0.4579 0.156 0.000 0.564 0.280
#> GSM123799     3  0.4540     0.7671 0.032 0.000 0.772 0.196
#> GSM123730     4  0.0921     0.9143 0.028 0.000 0.000 0.972
#> GSM123734     1  0.4713     0.4783 0.640 0.000 0.000 0.360
#> GSM123738     4  0.1004     0.9141 0.024 0.000 0.004 0.972
#> GSM123742     1  0.3975     0.7203 0.760 0.000 0.000 0.240
#> GSM123745     1  0.1022     0.8500 0.968 0.000 0.000 0.032
#> GSM123748     1  0.0592     0.8490 0.984 0.000 0.000 0.016
#> GSM123751     1  0.1211     0.8496 0.960 0.000 0.000 0.040
#> GSM123754     1  0.0921     0.8501 0.972 0.000 0.000 0.028
#> GSM123757     1  0.0188     0.8440 0.996 0.000 0.000 0.004
#> GSM123760     1  0.5295     0.1632 0.504 0.000 0.008 0.488
#> GSM123762     1  0.1118     0.8508 0.964 0.000 0.000 0.036
#> GSM123764     4  0.2036     0.8918 0.032 0.000 0.032 0.936
#> GSM123767     1  0.2216     0.8349 0.908 0.000 0.000 0.092
#> GSM123770     1  0.0707     0.8493 0.980 0.000 0.000 0.020
#> GSM123773     1  0.1022     0.8500 0.968 0.000 0.000 0.032
#> GSM123777     4  0.1004     0.9141 0.024 0.000 0.004 0.972
#> GSM123779     4  0.0921     0.9143 0.028 0.000 0.000 0.972
#> GSM123782     4  0.4855     0.1788 0.400 0.000 0.000 0.600
#> GSM123786     3  0.0188     0.8370 0.000 0.000 0.996 0.004
#> GSM123789     4  0.2443     0.8778 0.060 0.000 0.024 0.916
#> GSM123793     4  0.1004     0.9141 0.024 0.000 0.004 0.972
#> GSM123797     4  0.0921     0.9143 0.028 0.000 0.000 0.972
#> GSM123729     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123733     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123737     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123741     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123753     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123759     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123766     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123772     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123775     2  0.0376     0.9941 0.000 0.992 0.004 0.004
#> GSM123781     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123785     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123788     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123792     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123796     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123731     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123735     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123739     2  0.0188     0.9965 0.000 0.996 0.004 0.000
#> GSM123743     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123749     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123755     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123768     2  0.0000     0.9988 0.000 1.000 0.000 0.000
#> GSM123776     1  0.2773     0.8255 0.880 0.000 0.004 0.116
#> GSM123783     2  0.0376     0.9941 0.000 0.992 0.004 0.004
#> GSM123790     2  0.0376     0.9941 0.000 0.992 0.004 0.004
#> GSM123794     2  0.0376     0.9941 0.000 0.992 0.004 0.004
#> GSM123798     2  0.0000     0.9988 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0000     0.9234 0.000 0.000 1.000 0.000 0.000
#> GSM123736     3  0.1591     0.9145 0.004 0.000 0.940 0.052 0.004
#> GSM123740     3  0.1124     0.9238 0.000 0.000 0.960 0.036 0.004
#> GSM123744     1  0.7149     0.4036 0.452 0.000 0.308 0.028 0.212
#> GSM123746     1  0.2629     0.5579 0.860 0.000 0.000 0.004 0.136
#> GSM123750     1  0.6419     0.5031 0.584 0.000 0.188 0.020 0.208
#> GSM123752     1  0.6669     0.4812 0.552 0.000 0.232 0.024 0.192
#> GSM123756     1  0.0000     0.5689 1.000 0.000 0.000 0.000 0.000
#> GSM123758     3  0.6739     0.0702 0.324 0.000 0.508 0.028 0.140
#> GSM123761     1  0.5263     0.5364 0.696 0.000 0.080 0.016 0.208
#> GSM123763     1  0.6382     0.4682 0.616 0.000 0.228 0.056 0.100
#> GSM123765     3  0.0162     0.9244 0.000 0.000 0.996 0.004 0.000
#> GSM123769     1  0.0000     0.5689 1.000 0.000 0.000 0.000 0.000
#> GSM123771     1  0.0000     0.5689 1.000 0.000 0.000 0.000 0.000
#> GSM123774     1  0.0000     0.5689 1.000 0.000 0.000 0.000 0.000
#> GSM123778     3  0.0000     0.9234 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.1608     0.8983 0.000 0.000 0.928 0.072 0.000
#> GSM123784     3  0.0865     0.9260 0.000 0.000 0.972 0.024 0.004
#> GSM123787     3  0.0000     0.9234 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.0703     0.9263 0.000 0.000 0.976 0.024 0.000
#> GSM123795     3  0.2517     0.8661 0.008 0.000 0.884 0.104 0.004
#> GSM123799     3  0.1285     0.9229 0.004 0.000 0.956 0.036 0.004
#> GSM123730     4  0.0162     0.8422 0.000 0.000 0.004 0.996 0.000
#> GSM123734     4  0.6733    -0.2192 0.288 0.000 0.000 0.416 0.296
#> GSM123738     4  0.0000     0.8417 0.000 0.000 0.000 1.000 0.000
#> GSM123742     1  0.7117     0.1917 0.548 0.000 0.068 0.180 0.204
#> GSM123745     5  0.3491     0.7656 0.228 0.000 0.000 0.004 0.768
#> GSM123748     1  0.4225    -0.2135 0.632 0.000 0.000 0.004 0.364
#> GSM123751     5  0.4425     0.6470 0.452 0.000 0.000 0.004 0.544
#> GSM123754     5  0.4430     0.6386 0.456 0.000 0.000 0.004 0.540
#> GSM123757     1  0.0162     0.5694 0.996 0.000 0.000 0.004 0.000
#> GSM123760     4  0.6926     0.4190 0.180 0.000 0.080 0.584 0.156
#> GSM123762     1  0.3509     0.3595 0.792 0.000 0.004 0.008 0.196
#> GSM123764     4  0.2230     0.7980 0.000 0.000 0.116 0.884 0.000
#> GSM123767     5  0.4067     0.7762 0.300 0.000 0.000 0.008 0.692
#> GSM123770     1  0.3983    -0.0825 0.660 0.000 0.000 0.000 0.340
#> GSM123773     5  0.3491     0.7656 0.228 0.000 0.000 0.004 0.768
#> GSM123777     4  0.0162     0.8422 0.000 0.000 0.004 0.996 0.000
#> GSM123779     4  0.0162     0.8422 0.000 0.000 0.004 0.996 0.000
#> GSM123782     4  0.3547     0.7709 0.060 0.000 0.100 0.836 0.004
#> GSM123786     3  0.0000     0.9234 0.000 0.000 1.000 0.000 0.000
#> GSM123789     4  0.2377     0.7895 0.000 0.000 0.128 0.872 0.000
#> GSM123793     4  0.0000     0.8417 0.000 0.000 0.000 1.000 0.000
#> GSM123797     4  0.0000     0.8417 0.000 0.000 0.000 1.000 0.000
#> GSM123729     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123737     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123772     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123775     2  0.0404     0.9902 0.000 0.988 0.000 0.000 0.012
#> GSM123781     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123788     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123792     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0162     0.9958 0.000 0.996 0.000 0.000 0.004
#> GSM123731     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000
#> GSM123776     1  0.4684     0.2153 0.664 0.308 0.000 0.012 0.016
#> GSM123783     2  0.0510     0.9872 0.000 0.984 0.000 0.000 0.016
#> GSM123790     2  0.0510     0.9872 0.000 0.984 0.000 0.000 0.016
#> GSM123794     2  0.0404     0.9902 0.000 0.988 0.000 0.000 0.012
#> GSM123798     2  0.0000     0.9971 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.0291    0.82804 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM123736     3  0.3714    0.77817 0.000 0.000 0.760 0.196 0.044 0.000
#> GSM123740     3  0.2912    0.80835 0.000 0.000 0.816 0.172 0.012 0.000
#> GSM123744     6  0.6511    0.31277 0.000 0.000 0.252 0.156 0.072 0.520
#> GSM123746     6  0.3133    0.50660 0.072 0.000 0.008 0.016 0.044 0.860
#> GSM123750     6  0.5663    0.46360 0.000 0.000 0.144 0.132 0.072 0.652
#> GSM123752     6  0.6334    0.44945 0.012 0.000 0.156 0.176 0.064 0.592
#> GSM123756     6  0.4127    0.47125 0.172 0.000 0.000 0.000 0.088 0.740
#> GSM123758     3  0.5772    0.41201 0.000 0.000 0.556 0.152 0.016 0.276
#> GSM123761     6  0.4339    0.49752 0.000 0.000 0.076 0.080 0.068 0.776
#> GSM123763     6  0.8200    0.32077 0.108 0.000 0.136 0.200 0.136 0.420
#> GSM123765     3  0.0146    0.82891 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM123769     6  0.4127    0.47125 0.172 0.000 0.000 0.000 0.088 0.740
#> GSM123771     6  0.4127    0.47125 0.172 0.000 0.000 0.000 0.088 0.740
#> GSM123774     6  0.4159    0.46702 0.176 0.000 0.000 0.000 0.088 0.736
#> GSM123778     3  0.0146    0.82592 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123780     3  0.3962    0.77624 0.004 0.000 0.772 0.128 0.096 0.000
#> GSM123784     3  0.1890    0.83560 0.000 0.000 0.916 0.060 0.024 0.000
#> GSM123787     3  0.0146    0.82592 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123791     3  0.2191    0.83147 0.000 0.000 0.876 0.120 0.004 0.000
#> GSM123795     3  0.4948    0.68012 0.004 0.000 0.664 0.224 0.104 0.004
#> GSM123799     3  0.3037    0.80645 0.000 0.000 0.808 0.176 0.016 0.000
#> GSM123730     4  0.0260    0.84920 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM123734     4  0.5315   -0.04948 0.436 0.000 0.000 0.472 0.004 0.088
#> GSM123738     4  0.0000    0.85010 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123742     1  0.7635   -0.00171 0.328 0.000 0.012 0.312 0.112 0.236
#> GSM123745     1  0.0000    0.63066 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123748     1  0.3852    0.45217 0.612 0.000 0.000 0.000 0.004 0.384
#> GSM123751     1  0.3459    0.63095 0.768 0.000 0.000 0.016 0.004 0.212
#> GSM123754     1  0.3314    0.61421 0.740 0.000 0.000 0.000 0.004 0.256
#> GSM123757     6  0.2772    0.47310 0.180 0.000 0.000 0.000 0.004 0.816
#> GSM123760     4  0.6288    0.55464 0.180 0.000 0.020 0.612 0.116 0.072
#> GSM123762     6  0.4802   -0.00900 0.404 0.000 0.000 0.028 0.016 0.552
#> GSM123764     4  0.3185    0.80392 0.004 0.000 0.048 0.832 0.116 0.000
#> GSM123767     1  0.0964    0.63902 0.968 0.000 0.000 0.016 0.004 0.012
#> GSM123770     1  0.4228    0.41666 0.588 0.000 0.000 0.000 0.020 0.392
#> GSM123773     1  0.0146    0.62846 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123777     4  0.0260    0.84920 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM123779     4  0.0363    0.84994 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM123782     4  0.3515    0.80062 0.008 0.000 0.040 0.824 0.116 0.012
#> GSM123786     3  0.0146    0.82592 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123789     4  0.3309    0.79914 0.004 0.000 0.056 0.824 0.116 0.000
#> GSM123793     4  0.0260    0.84967 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM123797     4  0.0260    0.84920 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM123729     2  0.2912    0.62532 0.000 0.784 0.000 0.000 0.216 0.000
#> GSM123733     2  0.2762    0.67013 0.000 0.804 0.000 0.000 0.196 0.000
#> GSM123737     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2  0.3050    0.64306 0.000 0.764 0.000 0.000 0.236 0.000
#> GSM123772     2  0.2823    0.66194 0.000 0.796 0.000 0.000 0.204 0.000
#> GSM123775     2  0.3634    0.34405 0.000 0.644 0.000 0.000 0.356 0.000
#> GSM123781     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2  0.3371    0.60350 0.000 0.708 0.000 0.000 0.292 0.000
#> GSM123788     2  0.2883    0.65292 0.000 0.788 0.000 0.000 0.212 0.000
#> GSM123792     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2  0.2883    0.65292 0.000 0.788 0.000 0.000 0.212 0.000
#> GSM123731     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123739     2  0.2730    0.65919 0.000 0.808 0.000 0.000 0.192 0.000
#> GSM123743     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2  0.2378    0.70262 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM123776     5  0.6886    0.00000 0.128 0.232 0.000 0.000 0.492 0.148
#> GSM123783     2  0.3578    0.38741 0.000 0.660 0.000 0.000 0.340 0.000
#> GSM123790     2  0.3563    0.39713 0.000 0.664 0.000 0.000 0.336 0.000
#> GSM123794     2  0.3428    0.46603 0.000 0.696 0.000 0.000 0.304 0.000
#> GSM123798     2  0.0000    0.81457 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) infection(p) agent(p) k
#> MAD:mclust 71         3.04e-15     3.04e-15 5.99e-05 2
#> MAD:mclust 68         1.89e-15     1.89e-15 1.47e-04 3
#> MAD:mclust 66         7.76e-17     7.76e-17 7.28e-04 4
#> MAD:mclust 60         1.36e-19     1.36e-19 1.47e-03 5
#> MAD:mclust 50         9.85e-17     9.85e-17 1.65e-02 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.987       0.995         0.4809 0.522   0.522
#> 3 3 0.711           0.813       0.887         0.3554 0.808   0.637
#> 4 4 0.825           0.780       0.890         0.1111 0.901   0.721
#> 5 5 0.711           0.697       0.817         0.0588 0.945   0.802
#> 6 6 0.704           0.660       0.773         0.0354 0.990   0.959

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
#> GSM123732     1   0.000      0.992 1.000 0.000
#> GSM123736     1   0.000      0.992 1.000 0.000
#> GSM123740     1   0.000      0.992 1.000 0.000
#> GSM123744     1   0.000      0.992 1.000 0.000
#> GSM123746     1   0.000      0.992 1.000 0.000
#> GSM123750     1   0.000      0.992 1.000 0.000
#> GSM123752     1   0.000      0.992 1.000 0.000
#> GSM123756     1   0.000      0.992 1.000 0.000
#> GSM123758     1   0.000      0.992 1.000 0.000
#> GSM123761     1   0.000      0.992 1.000 0.000
#> GSM123763     1   0.000      0.992 1.000 0.000
#> GSM123765     1   0.000      0.992 1.000 0.000
#> GSM123769     1   0.000      0.992 1.000 0.000
#> GSM123771     1   0.000      0.992 1.000 0.000
#> GSM123774     1   0.000      0.992 1.000 0.000
#> GSM123778     1   0.000      0.992 1.000 0.000
#> GSM123780     1   0.000      0.992 1.000 0.000
#> GSM123784     1   0.000      0.992 1.000 0.000
#> GSM123787     1   0.000      0.992 1.000 0.000
#> GSM123791     1   0.000      0.992 1.000 0.000
#> GSM123795     1   0.000      0.992 1.000 0.000
#> GSM123799     1   0.000      0.992 1.000 0.000
#> GSM123730     1   0.936      0.457 0.648 0.352
#> GSM123734     1   0.000      0.992 1.000 0.000
#> GSM123738     1   0.000      0.992 1.000 0.000
#> GSM123742     1   0.000      0.992 1.000 0.000
#> GSM123745     1   0.000      0.992 1.000 0.000
#> GSM123748     1   0.000      0.992 1.000 0.000
#> GSM123751     1   0.000      0.992 1.000 0.000
#> GSM123754     1   0.000      0.992 1.000 0.000
#> GSM123757     1   0.000      0.992 1.000 0.000
#> GSM123760     1   0.000      0.992 1.000 0.000
#> GSM123762     1   0.000      0.992 1.000 0.000
#> GSM123764     1   0.000      0.992 1.000 0.000
#> GSM123767     1   0.000      0.992 1.000 0.000
#> GSM123770     1   0.000      0.992 1.000 0.000
#> GSM123773     1   0.000      0.992 1.000 0.000
#> GSM123777     1   0.000      0.992 1.000 0.000
#> GSM123779     1   0.000      0.992 1.000 0.000
#> GSM123782     1   0.000      0.992 1.000 0.000
#> GSM123786     1   0.000      0.992 1.000 0.000
#> GSM123789     1   0.000      0.992 1.000 0.000
#> GSM123793     1   0.000      0.992 1.000 0.000
#> GSM123797     1   0.000      0.992 1.000 0.000
#> GSM123729     2   0.000      1.000 0.000 1.000
#> GSM123733     2   0.000      1.000 0.000 1.000
#> GSM123737     2   0.000      1.000 0.000 1.000
#> GSM123741     2   0.000      1.000 0.000 1.000
#> GSM123747     2   0.000      1.000 0.000 1.000
#> GSM123753     2   0.000      1.000 0.000 1.000
#> GSM123759     2   0.000      1.000 0.000 1.000
#> GSM123766     2   0.000      1.000 0.000 1.000
#> GSM123772     2   0.000      1.000 0.000 1.000
#> GSM123775     2   0.000      1.000 0.000 1.000
#> GSM123781     2   0.000      1.000 0.000 1.000
#> GSM123785     2   0.000      1.000 0.000 1.000
#> GSM123788     2   0.000      1.000 0.000 1.000
#> GSM123792     2   0.000      1.000 0.000 1.000
#> GSM123796     2   0.000      1.000 0.000 1.000
#> GSM123731     2   0.000      1.000 0.000 1.000
#> GSM123735     2   0.000      1.000 0.000 1.000
#> GSM123739     2   0.000      1.000 0.000 1.000
#> GSM123743     2   0.000      1.000 0.000 1.000
#> GSM123749     2   0.000      1.000 0.000 1.000
#> GSM123755     2   0.000      1.000 0.000 1.000
#> GSM123768     2   0.000      1.000 0.000 1.000
#> GSM123776     2   0.000      1.000 0.000 1.000
#> GSM123783     2   0.000      1.000 0.000 1.000
#> GSM123790     2   0.000      1.000 0.000 1.000
#> GSM123794     2   0.000      1.000 0.000 1.000
#> GSM123798     2   0.000      1.000 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
#> GSM123732     3  0.0829     0.8166 0.004 0.012 0.984
#> GSM123736     3  0.1031     0.8204 0.024 0.000 0.976
#> GSM123740     3  0.0592     0.8214 0.012 0.000 0.988
#> GSM123744     3  0.3340     0.7685 0.120 0.000 0.880
#> GSM123746     1  0.5835     0.6647 0.660 0.000 0.340
#> GSM123750     3  0.5254     0.5634 0.264 0.000 0.736
#> GSM123752     3  0.6489    -0.0888 0.456 0.004 0.540
#> GSM123756     1  0.4796     0.8276 0.780 0.000 0.220
#> GSM123758     3  0.2280     0.8052 0.052 0.008 0.940
#> GSM123761     3  0.5968     0.3010 0.364 0.000 0.636
#> GSM123763     3  0.4796     0.6608 0.220 0.000 0.780
#> GSM123765     3  0.0237     0.8207 0.004 0.000 0.996
#> GSM123769     1  0.4887     0.8208 0.772 0.000 0.228
#> GSM123771     1  0.4504     0.8402 0.804 0.000 0.196
#> GSM123774     1  0.3752     0.8398 0.856 0.000 0.144
#> GSM123778     3  0.0661     0.8162 0.004 0.008 0.988
#> GSM123780     3  0.1163     0.8144 0.028 0.000 0.972
#> GSM123784     3  0.0424     0.8212 0.008 0.000 0.992
#> GSM123787     3  0.0237     0.8190 0.004 0.000 0.996
#> GSM123791     3  0.0424     0.8212 0.008 0.000 0.992
#> GSM123795     3  0.1643     0.8164 0.044 0.000 0.956
#> GSM123799     3  0.1289     0.8198 0.032 0.000 0.968
#> GSM123730     3  0.8143     0.4384 0.360 0.080 0.560
#> GSM123734     1  0.5178     0.6164 0.744 0.000 0.256
#> GSM123738     3  0.3686     0.7853 0.140 0.000 0.860
#> GSM123742     3  0.6235     0.1221 0.436 0.000 0.564
#> GSM123745     1  0.2537     0.8118 0.920 0.000 0.080
#> GSM123748     1  0.4654     0.8375 0.792 0.000 0.208
#> GSM123751     1  0.4002     0.8414 0.840 0.000 0.160
#> GSM123754     1  0.4235     0.8457 0.824 0.000 0.176
#> GSM123757     1  0.4399     0.8439 0.812 0.000 0.188
#> GSM123760     3  0.5138     0.6501 0.252 0.000 0.748
#> GSM123762     1  0.6045     0.5595 0.620 0.000 0.380
#> GSM123764     3  0.1964     0.8185 0.056 0.000 0.944
#> GSM123767     1  0.2301     0.7934 0.936 0.004 0.060
#> GSM123770     1  0.3752     0.8416 0.856 0.000 0.144
#> GSM123773     1  0.2537     0.8136 0.920 0.000 0.080
#> GSM123777     3  0.4413     0.7460 0.160 0.008 0.832
#> GSM123779     3  0.5926     0.5715 0.356 0.000 0.644
#> GSM123782     3  0.4931     0.7226 0.212 0.004 0.784
#> GSM123786     3  0.0848     0.8143 0.008 0.008 0.984
#> GSM123789     3  0.2711     0.8086 0.088 0.000 0.912
#> GSM123793     3  0.4842     0.7346 0.224 0.000 0.776
#> GSM123797     3  0.5098     0.7142 0.248 0.000 0.752
#> GSM123729     2  0.0592     0.9841 0.012 0.988 0.000
#> GSM123733     2  0.1031     0.9828 0.024 0.976 0.000
#> GSM123737     2  0.0747     0.9845 0.016 0.984 0.000
#> GSM123741     2  0.0592     0.9857 0.012 0.988 0.000
#> GSM123747     2  0.0475     0.9860 0.004 0.992 0.004
#> GSM123753     2  0.0848     0.9848 0.008 0.984 0.008
#> GSM123759     2  0.0237     0.9860 0.000 0.996 0.004
#> GSM123766     2  0.1031     0.9828 0.024 0.976 0.000
#> GSM123772     2  0.0983     0.9838 0.016 0.980 0.004
#> GSM123775     2  0.1964     0.9577 0.056 0.944 0.000
#> GSM123781     2  0.0424     0.9864 0.008 0.992 0.000
#> GSM123785     2  0.2066     0.9603 0.060 0.940 0.000
#> GSM123788     2  0.0892     0.9841 0.020 0.980 0.000
#> GSM123792     2  0.0000     0.9866 0.000 1.000 0.000
#> GSM123796     2  0.1163     0.9814 0.028 0.972 0.000
#> GSM123731     2  0.0000     0.9866 0.000 1.000 0.000
#> GSM123735     2  0.0237     0.9865 0.004 0.996 0.000
#> GSM123739     2  0.1031     0.9813 0.024 0.976 0.000
#> GSM123743     2  0.0592     0.9857 0.012 0.988 0.000
#> GSM123749     2  0.0000     0.9866 0.000 1.000 0.000
#> GSM123755     2  0.0000     0.9866 0.000 1.000 0.000
#> GSM123768     2  0.0829     0.9828 0.004 0.984 0.012
#> GSM123776     1  0.5678     0.4375 0.684 0.316 0.000
#> GSM123783     2  0.0983     0.9809 0.004 0.980 0.016
#> GSM123790     2  0.2297     0.9609 0.036 0.944 0.020
#> GSM123794     2  0.0000     0.9866 0.000 1.000 0.000
#> GSM123798     2  0.0424     0.9852 0.000 0.992 0.008

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0592      0.807 0.000 0.000 0.984 0.016
#> GSM123736     3  0.0376      0.810 0.004 0.000 0.992 0.004
#> GSM123740     3  0.0000      0.811 0.000 0.000 1.000 0.000
#> GSM123744     3  0.2401      0.746 0.092 0.000 0.904 0.004
#> GSM123746     1  0.2125      0.850 0.920 0.000 0.076 0.004
#> GSM123750     3  0.4509      0.507 0.288 0.000 0.708 0.004
#> GSM123752     1  0.5339      0.313 0.600 0.000 0.384 0.016
#> GSM123756     1  0.0657      0.887 0.984 0.000 0.012 0.004
#> GSM123758     3  0.2634      0.763 0.028 0.020 0.920 0.032
#> GSM123761     3  0.5132      0.164 0.448 0.000 0.548 0.004
#> GSM123763     3  0.4103      0.556 0.256 0.000 0.744 0.000
#> GSM123765     3  0.0000      0.811 0.000 0.000 1.000 0.000
#> GSM123769     1  0.1004      0.885 0.972 0.000 0.024 0.004
#> GSM123771     1  0.0376      0.885 0.992 0.000 0.004 0.004
#> GSM123774     1  0.0000      0.885 1.000 0.000 0.000 0.000
#> GSM123778     3  0.0336      0.810 0.000 0.000 0.992 0.008
#> GSM123780     3  0.0921      0.796 0.000 0.000 0.972 0.028
#> GSM123784     3  0.0188      0.810 0.000 0.000 0.996 0.004
#> GSM123787     3  0.0469      0.809 0.000 0.000 0.988 0.012
#> GSM123791     3  0.0188      0.811 0.000 0.000 0.996 0.004
#> GSM123795     3  0.0592      0.804 0.000 0.000 0.984 0.016
#> GSM123799     3  0.0188      0.810 0.000 0.000 0.996 0.004
#> GSM123730     4  0.1796      0.632 0.004 0.016 0.032 0.948
#> GSM123734     4  0.4898      0.608 0.156 0.000 0.072 0.772
#> GSM123738     4  0.5000      0.393 0.000 0.000 0.496 0.504
#> GSM123742     3  0.7920     -0.376 0.340 0.000 0.344 0.316
#> GSM123745     1  0.3266      0.794 0.832 0.000 0.000 0.168
#> GSM123748     1  0.1211      0.884 0.960 0.000 0.000 0.040
#> GSM123751     1  0.3649      0.744 0.796 0.000 0.000 0.204
#> GSM123754     1  0.2149      0.864 0.912 0.000 0.000 0.088
#> GSM123757     1  0.0188      0.886 0.996 0.000 0.004 0.000
#> GSM123760     4  0.6885      0.452 0.104 0.000 0.436 0.460
#> GSM123762     1  0.3367      0.819 0.864 0.000 0.108 0.028
#> GSM123764     3  0.3801      0.488 0.000 0.000 0.780 0.220
#> GSM123767     4  0.5000     -0.155 0.496 0.000 0.000 0.504
#> GSM123770     1  0.0921      0.887 0.972 0.000 0.000 0.028
#> GSM123773     1  0.2011      0.870 0.920 0.000 0.000 0.080
#> GSM123777     4  0.4730      0.614 0.000 0.000 0.364 0.636
#> GSM123779     4  0.2861      0.670 0.016 0.000 0.096 0.888
#> GSM123782     4  0.6158      0.572 0.056 0.000 0.384 0.560
#> GSM123786     3  0.0336      0.810 0.000 0.000 0.992 0.008
#> GSM123789     3  0.4040      0.413 0.000 0.000 0.752 0.248
#> GSM123793     4  0.4781      0.643 0.004 0.000 0.336 0.660
#> GSM123797     4  0.3908      0.683 0.004 0.000 0.212 0.784
#> GSM123729     2  0.1109      0.971 0.004 0.968 0.000 0.028
#> GSM123733     2  0.1302      0.959 0.000 0.956 0.000 0.044
#> GSM123737     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> GSM123741     2  0.0336      0.974 0.000 0.992 0.000 0.008
#> GSM123747     2  0.0592      0.974 0.000 0.984 0.000 0.016
#> GSM123753     2  0.0592      0.974 0.000 0.984 0.000 0.016
#> GSM123759     2  0.0817      0.973 0.000 0.976 0.000 0.024
#> GSM123766     2  0.1389      0.957 0.000 0.952 0.000 0.048
#> GSM123772     2  0.0592      0.971 0.000 0.984 0.000 0.016
#> GSM123775     2  0.0937      0.971 0.012 0.976 0.000 0.012
#> GSM123781     2  0.0188      0.974 0.000 0.996 0.000 0.004
#> GSM123785     2  0.3726      0.796 0.000 0.788 0.000 0.212
#> GSM123788     2  0.1211      0.961 0.000 0.960 0.000 0.040
#> GSM123792     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> GSM123796     2  0.1211      0.962 0.000 0.960 0.000 0.040
#> GSM123731     2  0.0817      0.973 0.000 0.976 0.000 0.024
#> GSM123735     2  0.0000      0.974 0.000 1.000 0.000 0.000
#> GSM123739     2  0.0592      0.973 0.000 0.984 0.000 0.016
#> GSM123743     2  0.0469      0.975 0.000 0.988 0.000 0.012
#> GSM123749     2  0.0817      0.973 0.000 0.976 0.000 0.024
#> GSM123755     2  0.0817      0.973 0.000 0.976 0.000 0.024
#> GSM123768     2  0.1118      0.969 0.000 0.964 0.000 0.036
#> GSM123776     1  0.2124      0.825 0.924 0.068 0.000 0.008
#> GSM123783     2  0.1211      0.967 0.000 0.960 0.000 0.040
#> GSM123790     2  0.1867      0.942 0.000 0.928 0.000 0.072
#> GSM123794     2  0.0336      0.975 0.000 0.992 0.000 0.008
#> GSM123798     2  0.0817      0.973 0.000 0.976 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.1869     0.8057 0.016 0.000 0.936 0.012 0.036
#> GSM123736     3  0.3385     0.7935 0.036 0.000 0.864 0.056 0.044
#> GSM123740     3  0.2768     0.8046 0.040 0.000 0.896 0.024 0.040
#> GSM123744     3  0.4364     0.7225 0.112 0.000 0.768 0.000 0.120
#> GSM123746     1  0.3734     0.6891 0.812 0.000 0.060 0.000 0.128
#> GSM123750     3  0.6139     0.3304 0.260 0.000 0.556 0.000 0.184
#> GSM123752     1  0.4812     0.4132 0.652 0.000 0.312 0.004 0.032
#> GSM123756     1  0.2110     0.7306 0.912 0.000 0.072 0.000 0.016
#> GSM123758     3  0.3747     0.7718 0.052 0.000 0.844 0.044 0.060
#> GSM123761     5  0.6932     0.2197 0.348 0.000 0.288 0.004 0.360
#> GSM123763     3  0.6598    -0.1558 0.216 0.000 0.428 0.000 0.356
#> GSM123765     3  0.1653     0.8155 0.004 0.000 0.944 0.024 0.028
#> GSM123769     1  0.2473     0.7355 0.896 0.000 0.072 0.000 0.032
#> GSM123771     1  0.1915     0.7484 0.928 0.000 0.040 0.000 0.032
#> GSM123774     1  0.0898     0.7527 0.972 0.000 0.008 0.000 0.020
#> GSM123778     3  0.1704     0.8083 0.000 0.000 0.928 0.004 0.068
#> GSM123780     3  0.3142     0.7641 0.004 0.000 0.856 0.108 0.032
#> GSM123784     3  0.1818     0.8084 0.000 0.000 0.932 0.044 0.024
#> GSM123787     3  0.2976     0.7817 0.004 0.000 0.852 0.012 0.132
#> GSM123791     3  0.2074     0.8002 0.000 0.000 0.896 0.000 0.104
#> GSM123795     3  0.4513     0.7433 0.044 0.000 0.792 0.104 0.060
#> GSM123799     3  0.2523     0.8082 0.040 0.000 0.908 0.028 0.024
#> GSM123730     4  0.3259     0.5861 0.004 0.028 0.028 0.872 0.068
#> GSM123734     4  0.5954     0.3335 0.068 0.000 0.024 0.572 0.336
#> GSM123738     4  0.5724     0.2710 0.004 0.000 0.420 0.504 0.072
#> GSM123742     5  0.4981     0.6068 0.132 0.000 0.056 0.056 0.756
#> GSM123745     1  0.5872     0.0558 0.492 0.000 0.000 0.100 0.408
#> GSM123748     5  0.4528     0.0851 0.444 0.000 0.000 0.008 0.548
#> GSM123751     1  0.5973     0.2295 0.552 0.000 0.004 0.112 0.332
#> GSM123754     1  0.3301     0.7155 0.848 0.000 0.000 0.072 0.080
#> GSM123757     1  0.1908     0.7376 0.908 0.000 0.000 0.000 0.092
#> GSM123760     5  0.4858     0.6042 0.100 0.000 0.064 0.064 0.772
#> GSM123762     5  0.4969     0.4870 0.292 0.000 0.056 0.000 0.652
#> GSM123764     5  0.4245     0.5393 0.024 0.004 0.180 0.016 0.776
#> GSM123767     4  0.5714     0.1019 0.412 0.004 0.000 0.512 0.072
#> GSM123770     1  0.1618     0.7537 0.944 0.000 0.008 0.008 0.040
#> GSM123773     1  0.3731     0.6986 0.816 0.000 0.000 0.112 0.072
#> GSM123777     4  0.4936     0.5339 0.000 0.008 0.284 0.668 0.040
#> GSM123779     4  0.4378     0.5880 0.012 0.004 0.048 0.780 0.156
#> GSM123782     5  0.4747     0.5730 0.060 0.004 0.076 0.072 0.788
#> GSM123786     3  0.3688     0.7662 0.004 0.000 0.812 0.036 0.148
#> GSM123789     5  0.5821     0.4279 0.020 0.000 0.308 0.072 0.600
#> GSM123793     5  0.6603    -0.0979 0.016 0.000 0.140 0.368 0.476
#> GSM123797     4  0.5220     0.6026 0.012 0.000 0.124 0.712 0.152
#> GSM123729     2  0.2253     0.9343 0.016 0.920 0.000 0.036 0.028
#> GSM123733     2  0.2393     0.9120 0.004 0.900 0.000 0.080 0.016
#> GSM123737     2  0.1461     0.9365 0.004 0.952 0.000 0.028 0.016
#> GSM123741     2  0.0912     0.9419 0.000 0.972 0.000 0.012 0.016
#> GSM123747     2  0.1012     0.9433 0.000 0.968 0.000 0.020 0.012
#> GSM123753     2  0.1750     0.9380 0.000 0.936 0.000 0.036 0.028
#> GSM123759     2  0.1981     0.9346 0.000 0.924 0.000 0.048 0.028
#> GSM123766     2  0.1992     0.9376 0.000 0.924 0.000 0.032 0.044
#> GSM123772     2  0.1399     0.9423 0.000 0.952 0.000 0.028 0.020
#> GSM123775     2  0.1989     0.9409 0.016 0.932 0.000 0.020 0.032
#> GSM123781     2  0.2378     0.9283 0.000 0.904 0.000 0.048 0.048
#> GSM123785     2  0.3381     0.8353 0.000 0.808 0.000 0.176 0.016
#> GSM123788     2  0.1662     0.9291 0.004 0.936 0.000 0.056 0.004
#> GSM123792     2  0.0566     0.9416 0.000 0.984 0.000 0.012 0.004
#> GSM123796     2  0.1768     0.9228 0.000 0.924 0.000 0.072 0.004
#> GSM123731     2  0.1012     0.9422 0.000 0.968 0.000 0.020 0.012
#> GSM123735     2  0.1471     0.9363 0.004 0.952 0.000 0.024 0.020
#> GSM123739     2  0.1419     0.9397 0.012 0.956 0.000 0.016 0.016
#> GSM123743     2  0.0854     0.9423 0.004 0.976 0.000 0.012 0.008
#> GSM123749     2  0.1582     0.9384 0.000 0.944 0.000 0.028 0.028
#> GSM123755     2  0.2193     0.9308 0.000 0.912 0.000 0.060 0.028
#> GSM123768     2  0.3384     0.8991 0.000 0.848 0.004 0.088 0.060
#> GSM123776     1  0.4220     0.5483 0.768 0.180 0.004 0.000 0.048
#> GSM123783     2  0.3407     0.9014 0.004 0.864 0.020 0.064 0.048
#> GSM123790     2  0.3745     0.8019 0.000 0.780 0.000 0.196 0.024
#> GSM123794     2  0.1564     0.9376 0.004 0.948 0.000 0.024 0.024
#> GSM123798     2  0.2193     0.9307 0.000 0.912 0.000 0.060 0.028

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4 p5    p6
#> GSM123732     3  0.2302    0.69058 0.012 0.000 0.900 0.012 NA 0.004
#> GSM123736     3  0.5869    0.57796 0.032 0.000 0.584 0.044 NA 0.040
#> GSM123740     3  0.5476    0.60868 0.032 0.000 0.624 0.032 NA 0.032
#> GSM123744     3  0.6394    0.55744 0.080 0.000 0.568 0.004 NA 0.136
#> GSM123746     1  0.4013    0.70305 0.800 0.000 0.060 0.000 NA 0.076
#> GSM123750     3  0.7656    0.10572 0.212 0.000 0.356 0.004 NA 0.252
#> GSM123752     1  0.5913    0.29386 0.532 0.000 0.256 0.000 NA 0.012
#> GSM123756     1  0.1261    0.76151 0.956 0.000 0.008 0.004 NA 0.004
#> GSM123758     3  0.4416    0.63987 0.048 0.004 0.724 0.004 NA 0.008
#> GSM123761     6  0.7238    0.43506 0.156 0.000 0.136 0.008 NA 0.464
#> GSM123763     6  0.7100    0.43998 0.112 0.000 0.136 0.012 NA 0.480
#> GSM123765     3  0.3253    0.69448 0.008 0.000 0.852 0.032 NA 0.024
#> GSM123769     1  0.2973    0.74168 0.864 0.000 0.032 0.004 NA 0.016
#> GSM123771     1  0.1718    0.75908 0.932 0.000 0.008 0.000 NA 0.016
#> GSM123774     1  0.0725    0.75981 0.976 0.000 0.000 0.000 NA 0.012
#> GSM123778     3  0.2186    0.68057 0.000 0.000 0.908 0.008 NA 0.036
#> GSM123780     3  0.3050    0.64830 0.000 0.000 0.852 0.092 NA 0.012
#> GSM123784     3  0.2411    0.68487 0.000 0.000 0.900 0.044 NA 0.024
#> GSM123787     3  0.3768    0.63302 0.000 0.000 0.796 0.008 NA 0.104
#> GSM123791     3  0.3716    0.64406 0.000 0.000 0.792 0.004 NA 0.128
#> GSM123795     3  0.6723    0.47521 0.028 0.000 0.496 0.080 NA 0.072
#> GSM123799     3  0.5225    0.62523 0.040 0.000 0.652 0.020 NA 0.028
#> GSM123730     4  0.2466    0.54053 0.004 0.012 0.024 0.908 NA 0.028
#> GSM123734     4  0.6437    0.29206 0.028 0.000 0.016 0.528 NA 0.260
#> GSM123738     4  0.6982    0.25422 0.004 0.000 0.280 0.448 NA 0.076
#> GSM123742     6  0.3689    0.56523 0.028 0.000 0.016 0.048 NA 0.832
#> GSM123745     1  0.6606    0.09507 0.432 0.000 0.000 0.112 NA 0.372
#> GSM123748     6  0.5441    0.28214 0.304 0.000 0.000 0.036 NA 0.592
#> GSM123751     1  0.6676    0.33998 0.504 0.000 0.004 0.152 NA 0.268
#> GSM123754     1  0.2202    0.74240 0.904 0.000 0.004 0.072 NA 0.012
#> GSM123757     1  0.2857    0.75351 0.880 0.000 0.020 0.008 NA 0.052
#> GSM123760     6  0.2319    0.58577 0.012 0.000 0.020 0.028 NA 0.912
#> GSM123762     6  0.5128    0.56295 0.160 0.000 0.024 0.008 NA 0.696
#> GSM123764     6  0.4631    0.55268 0.000 0.004 0.108 0.052 NA 0.756
#> GSM123767     4  0.5249   -0.15967 0.460 0.000 0.000 0.472 NA 0.040
#> GSM123770     1  0.1542    0.76333 0.944 0.000 0.000 0.016 NA 0.016
#> GSM123773     1  0.3476    0.68626 0.808 0.000 0.000 0.148 NA 0.024
#> GSM123777     4  0.4876    0.48444 0.000 0.004 0.276 0.656 NA 0.028
#> GSM123779     4  0.4757    0.53211 0.004 0.012 0.084 0.764 NA 0.080
#> GSM123782     6  0.5766    0.50178 0.016 0.004 0.092 0.104 NA 0.684
#> GSM123786     3  0.3566    0.64810 0.000 0.000 0.812 0.008 NA 0.076
#> GSM123789     6  0.6102    0.36427 0.000 0.000 0.320 0.072 NA 0.528
#> GSM123793     6  0.6785    0.00883 0.000 0.000 0.044 0.300 NA 0.396
#> GSM123797     4  0.5471    0.53311 0.008 0.000 0.100 0.688 NA 0.068
#> GSM123729     2  0.1204    0.91971 0.000 0.944 0.000 0.000 NA 0.000
#> GSM123733     2  0.2390    0.88968 0.000 0.888 0.000 0.056 NA 0.000
#> GSM123737     2  0.1257    0.91456 0.000 0.952 0.000 0.020 NA 0.000
#> GSM123741     2  0.1387    0.91296 0.000 0.932 0.000 0.000 NA 0.000
#> GSM123747     2  0.1074    0.91989 0.000 0.960 0.000 0.012 NA 0.000
#> GSM123753     2  0.1765    0.90579 0.000 0.904 0.000 0.000 NA 0.000
#> GSM123759     2  0.2048    0.89570 0.000 0.880 0.000 0.000 NA 0.000
#> GSM123766     2  0.1349    0.91684 0.000 0.940 0.000 0.000 NA 0.004
#> GSM123772     2  0.0937    0.91985 0.000 0.960 0.000 0.000 NA 0.000
#> GSM123775     2  0.2203    0.90929 0.000 0.896 0.000 0.004 NA 0.016
#> GSM123781     2  0.2527    0.86981 0.000 0.832 0.000 0.000 NA 0.000
#> GSM123785     2  0.3355    0.83933 0.000 0.816 0.000 0.132 NA 0.004
#> GSM123788     2  0.1863    0.90604 0.000 0.920 0.000 0.044 NA 0.000
#> GSM123792     2  0.1003    0.91614 0.000 0.964 0.000 0.016 NA 0.000
#> GSM123796     2  0.1930    0.90232 0.000 0.916 0.000 0.048 NA 0.000
#> GSM123731     2  0.0790    0.91943 0.000 0.968 0.000 0.000 NA 0.000
#> GSM123735     2  0.2119    0.90092 0.000 0.904 0.000 0.036 NA 0.000
#> GSM123739     2  0.1168    0.91788 0.000 0.956 0.000 0.016 NA 0.000
#> GSM123743     2  0.0725    0.91870 0.000 0.976 0.000 0.012 NA 0.000
#> GSM123749     2  0.1444    0.91065 0.000 0.928 0.000 0.000 NA 0.000
#> GSM123755     2  0.2092    0.89420 0.000 0.876 0.000 0.000 NA 0.000
#> GSM123768     2  0.2902    0.84586 0.000 0.800 0.000 0.000 NA 0.004
#> GSM123776     1  0.5496    0.52703 0.692 0.148 0.004 0.016 NA 0.040
#> GSM123783     2  0.4050    0.80177 0.000 0.756 0.056 0.004 NA 0.004
#> GSM123790     2  0.3993    0.81601 0.000 0.792 0.016 0.108 NA 0.004
#> GSM123794     2  0.1970    0.90542 0.000 0.912 0.000 0.028 NA 0.000
#> GSM123798     2  0.2092    0.89591 0.000 0.876 0.000 0.000 NA 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-NMF-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) infection(p) agent(p) k
#> MAD:NMF 70         6.31e-16     6.31e-16 7.57e-06 2
#> MAD:NMF 66         1.87e-14     1.87e-14 3.89e-05 3
#> MAD:NMF 63         5.50e-18     5.50e-18 1.23e-03 4
#> MAD:NMF 58         1.09e-15     1.09e-15 7.82e-03 5
#> MAD:NMF 57         2.94e-15     2.94e-15 9.47e-03 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 71 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.370           0.260       0.690         0.4093 0.820   0.820
#> 3 3 0.806           0.835       0.896         0.4496 0.585   0.503
#> 4 4 0.871           0.880       0.941         0.1351 0.870   0.700
#> 5 5 0.853           0.816       0.923         0.0452 0.990   0.966
#> 6 6 0.899           0.837       0.925         0.0826 0.938   0.791

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

suggest_best_k(res)
#> [1] 4

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.9460     -0.267 0.636 0.364
#> GSM123736     1  0.9460     -0.267 0.636 0.364
#> GSM123740     1  0.9460     -0.267 0.636 0.364
#> GSM123744     1  0.9460     -0.267 0.636 0.364
#> GSM123746     1  0.9460     -0.267 0.636 0.364
#> GSM123750     1  0.9460     -0.267 0.636 0.364
#> GSM123752     1  0.9460     -0.267 0.636 0.364
#> GSM123756     2  0.9580      1.000 0.380 0.620
#> GSM123758     1  0.9460     -0.267 0.636 0.364
#> GSM123761     2  0.9580      1.000 0.380 0.620
#> GSM123763     2  0.9580      1.000 0.380 0.620
#> GSM123765     1  0.9460     -0.267 0.636 0.364
#> GSM123769     2  0.9580      1.000 0.380 0.620
#> GSM123771     2  0.9580      1.000 0.380 0.620
#> GSM123774     2  0.9580      1.000 0.380 0.620
#> GSM123778     1  0.9460     -0.267 0.636 0.364
#> GSM123780     1  0.9460     -0.267 0.636 0.364
#> GSM123784     1  0.9460     -0.267 0.636 0.364
#> GSM123787     1  0.9460     -0.267 0.636 0.364
#> GSM123791     1  0.9460     -0.267 0.636 0.364
#> GSM123795     1  0.9460     -0.267 0.636 0.364
#> GSM123799     1  0.9460     -0.267 0.636 0.364
#> GSM123730     1  0.0000      0.384 1.000 0.000
#> GSM123734     1  0.0000      0.384 1.000 0.000
#> GSM123738     1  0.0000      0.384 1.000 0.000
#> GSM123742     1  0.0000      0.384 1.000 0.000
#> GSM123745     1  0.9460     -0.267 0.636 0.364
#> GSM123748     1  0.0376      0.380 0.996 0.004
#> GSM123751     1  0.9286     -0.240 0.656 0.344
#> GSM123754     1  0.9460     -0.267 0.636 0.364
#> GSM123757     1  0.9460     -0.267 0.636 0.364
#> GSM123760     1  0.0000      0.384 1.000 0.000
#> GSM123762     2  0.9580      1.000 0.380 0.620
#> GSM123764     1  0.0000      0.384 1.000 0.000
#> GSM123767     1  0.9460     -0.267 0.636 0.364
#> GSM123770     1  0.9460     -0.267 0.636 0.364
#> GSM123773     1  0.9460     -0.267 0.636 0.364
#> GSM123777     1  0.0000      0.384 1.000 0.000
#> GSM123779     1  0.9427     -0.262 0.640 0.360
#> GSM123782     1  0.0000      0.384 1.000 0.000
#> GSM123786     1  0.9460     -0.267 0.636 0.364
#> GSM123789     1  0.0000      0.384 1.000 0.000
#> GSM123793     1  0.0000      0.384 1.000 0.000
#> GSM123797     1  0.0000      0.384 1.000 0.000
#> GSM123729     1  0.9580      0.530 0.620 0.380
#> GSM123733     1  0.9580      0.530 0.620 0.380
#> GSM123737     1  0.9580      0.530 0.620 0.380
#> GSM123741     1  0.9580      0.530 0.620 0.380
#> GSM123747     1  0.9580      0.530 0.620 0.380
#> GSM123753     1  0.9580      0.530 0.620 0.380
#> GSM123759     1  0.9580      0.530 0.620 0.380
#> GSM123766     1  0.9580      0.530 0.620 0.380
#> GSM123772     1  0.9580      0.530 0.620 0.380
#> GSM123775     1  0.9580      0.530 0.620 0.380
#> GSM123781     1  0.9580      0.530 0.620 0.380
#> GSM123785     1  0.9580      0.530 0.620 0.380
#> GSM123788     1  0.9580      0.530 0.620 0.380
#> GSM123792     1  0.9580      0.530 0.620 0.380
#> GSM123796     1  0.9580      0.530 0.620 0.380
#> GSM123731     1  0.9580      0.530 0.620 0.380
#> GSM123735     1  0.9580      0.530 0.620 0.380
#> GSM123739     1  0.9580      0.530 0.620 0.380
#> GSM123743     1  0.9580      0.530 0.620 0.380
#> GSM123749     1  0.9580      0.530 0.620 0.380
#> GSM123755     1  0.9580      0.530 0.620 0.380
#> GSM123768     1  0.9580      0.530 0.620 0.380
#> GSM123776     1  0.9460     -0.267 0.636 0.364
#> GSM123783     1  0.9580      0.530 0.620 0.380
#> GSM123790     1  0.9580      0.530 0.620 0.380
#> GSM123794     1  0.9580      0.530 0.620 0.380
#> GSM123798     1  0.9580      0.530 0.620 0.380

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123732     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123736     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123740     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123744     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123746     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123750     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123752     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123756     1  0.5968      0.999 0.636 0.000 0.364
#> GSM123758     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123761     1  0.5988      0.994 0.632 0.000 0.368
#> GSM123763     1  0.5968      0.999 0.636 0.000 0.364
#> GSM123765     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123769     1  0.5968      0.999 0.636 0.000 0.364
#> GSM123771     1  0.5968      0.999 0.636 0.000 0.364
#> GSM123774     3  0.6274     -0.626 0.456 0.000 0.544
#> GSM123778     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123780     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123784     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123787     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123791     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123795     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123799     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123730     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123734     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123738     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123742     3  0.6359      0.607 0.364 0.008 0.628
#> GSM123745     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123748     3  0.6339      0.609 0.360 0.008 0.632
#> GSM123751     3  0.1315      0.786 0.020 0.008 0.972
#> GSM123754     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123757     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123760     3  0.6359      0.607 0.364 0.008 0.628
#> GSM123762     1  0.5968      0.999 0.636 0.000 0.364
#> GSM123764     3  0.6359      0.607 0.364 0.008 0.628
#> GSM123767     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123770     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123773     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123777     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123779     3  0.0661      0.795 0.004 0.008 0.988
#> GSM123782     3  0.6359      0.607 0.364 0.008 0.628
#> GSM123786     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123789     3  0.6359      0.607 0.364 0.008 0.628
#> GSM123793     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123797     3  0.5968      0.601 0.364 0.000 0.636
#> GSM123729     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123733     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123737     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123741     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123747     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123753     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123759     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123766     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123772     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123775     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123781     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123785     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123788     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123792     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123796     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123731     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123735     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123739     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123743     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123749     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123755     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123768     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123776     3  0.0424      0.797 0.000 0.008 0.992
#> GSM123783     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123790     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123794     2  0.0000      1.000 0.000 1.000 0.000
#> GSM123798     2  0.0000      1.000 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM123732     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123736     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123740     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123744     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123746     3  0.0336     0.9421 0.000  0 0.992 0.008
#> GSM123750     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123752     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123756     1  0.4730     0.7642 0.636  0 0.364 0.000
#> GSM123758     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123761     1  0.4746     0.7583 0.632  0 0.368 0.000
#> GSM123763     1  0.0000     0.5501 1.000  0 0.000 0.000
#> GSM123765     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123769     1  0.4730     0.7642 0.636  0 0.364 0.000
#> GSM123771     1  0.4730     0.7642 0.636  0 0.364 0.000
#> GSM123774     3  0.4972    -0.3856 0.456  0 0.544 0.000
#> GSM123778     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123780     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123784     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123787     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123791     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123795     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123799     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123730     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123734     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123738     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123742     4  0.4356     0.7440 0.000  0 0.292 0.708
#> GSM123745     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123748     4  0.4454     0.7222 0.000  0 0.308 0.692
#> GSM123751     3  0.0817     0.9208 0.000  0 0.976 0.024
#> GSM123754     3  0.0336     0.9421 0.000  0 0.992 0.008
#> GSM123757     3  0.0336     0.9421 0.000  0 0.992 0.008
#> GSM123760     4  0.4356     0.7440 0.000  0 0.292 0.708
#> GSM123762     1  0.0592     0.5679 0.984  0 0.016 0.000
#> GSM123764     4  0.4331     0.7461 0.000  0 0.288 0.712
#> GSM123767     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123770     3  0.0336     0.9421 0.000  0 0.992 0.008
#> GSM123773     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123777     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123779     3  0.4948     0.0591 0.000  0 0.560 0.440
#> GSM123782     4  0.4331     0.7461 0.000  0 0.288 0.712
#> GSM123786     3  0.0188     0.9459 0.000  0 0.996 0.004
#> GSM123789     4  0.4356     0.7440 0.000  0 0.292 0.708
#> GSM123793     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123797     4  0.0000     0.7577 0.000  0 0.000 1.000
#> GSM123729     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123733     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123737     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123741     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123747     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123753     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123759     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123766     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123772     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123775     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123781     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123785     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123788     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123792     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123796     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123731     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123735     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123739     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123743     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123749     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123755     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123768     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123776     3  0.0000     0.9469 0.000  0 1.000 0.000
#> GSM123783     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123790     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123794     2  0.0000     1.0000 0.000  1 0.000 0.000
#> GSM123798     2  0.0000     1.0000 0.000  1 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
#> GSM123732     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123736     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123740     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123744     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123746     3  0.0579     0.9275 0.000  0 0.984 0.008 0.008
#> GSM123750     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123752     3  0.0290     0.9292 0.000  0 0.992 0.000 0.008
#> GSM123756     1  0.4182     0.0420 0.600  0 0.000 0.000 0.400
#> GSM123758     3  0.0290     0.9292 0.000  0 0.992 0.000 0.008
#> GSM123761     1  0.4299     0.0242 0.608  0 0.004 0.000 0.388
#> GSM123763     1  0.4227     0.0701 0.580  0 0.000 0.000 0.420
#> GSM123765     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123769     1  0.4182     0.0420 0.600  0 0.000 0.000 0.400
#> GSM123771     1  0.4182     0.0420 0.600  0 0.000 0.000 0.400
#> GSM123774     5  0.4227     0.0000 0.420  0 0.000 0.000 0.580
#> GSM123778     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123780     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123784     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123787     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123791     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123795     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123799     3  0.0000     0.9310 0.000  0 1.000 0.000 0.000
#> GSM123730     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123734     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123738     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123742     4  0.3752     0.7490 0.000  0 0.292 0.708 0.000
#> GSM123745     3  0.2929     0.8321 0.000  0 0.820 0.000 0.180
#> GSM123748     4  0.3837     0.7292 0.000  0 0.308 0.692 0.000
#> GSM123751     3  0.3565     0.8142 0.000  0 0.800 0.024 0.176
#> GSM123754     3  0.0898     0.9233 0.000  0 0.972 0.008 0.020
#> GSM123757     3  0.0898     0.9233 0.000  0 0.972 0.008 0.020
#> GSM123760     4  0.3752     0.7490 0.000  0 0.292 0.708 0.000
#> GSM123762     1  0.0000     0.0994 1.000  0 0.000 0.000 0.000
#> GSM123764     4  0.3730     0.7503 0.000  0 0.288 0.712 0.000
#> GSM123767     3  0.2929     0.8321 0.000  0 0.820 0.000 0.180
#> GSM123770     3  0.3053     0.8387 0.000  0 0.828 0.008 0.164
#> GSM123773     3  0.2929     0.8321 0.000  0 0.820 0.000 0.180
#> GSM123777     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123779     3  0.4262     0.1034 0.000  0 0.560 0.440 0.000
#> GSM123782     4  0.3730     0.7503 0.000  0 0.288 0.712 0.000
#> GSM123786     3  0.0162     0.9308 0.000  0 0.996 0.004 0.000
#> GSM123789     4  0.3752     0.7490 0.000  0 0.292 0.708 0.000
#> GSM123793     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123797     4  0.0000     0.7375 0.000  0 0.000 1.000 0.000
#> GSM123729     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123733     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123737     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123741     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123747     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123753     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123759     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123766     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123772     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123775     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123781     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123785     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123788     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123792     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123796     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123731     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123735     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123739     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123743     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123749     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123755     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123768     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123776     3  0.2929     0.8321 0.000  0 0.820 0.000 0.180
#> GSM123783     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123790     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123794     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000
#> GSM123798     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5    p6
#> GSM123732     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123736     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123740     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123744     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123746     3  0.3468     0.6338 0.264  0 0.728 0.000 0.000 0.008
#> GSM123750     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123752     3  0.3221     0.6409 0.264  0 0.736 0.000 0.000 0.000
#> GSM123756     5  0.0000     0.8322 0.000  0 0.000 0.000 1.000 0.000
#> GSM123758     3  0.3221     0.6409 0.264  0 0.736 0.000 0.000 0.000
#> GSM123761     5  0.0405     0.8257 0.000  0 0.004 0.000 0.988 0.008
#> GSM123763     6  0.2631     0.0000 0.000  0 0.000 0.000 0.180 0.820
#> GSM123765     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123769     5  0.0000     0.8322 0.000  0 0.000 0.000 1.000 0.000
#> GSM123771     5  0.0000     0.8322 0.000  0 0.000 0.000 1.000 0.000
#> GSM123774     5  0.3101     0.6363 0.148  0 0.000 0.000 0.820 0.032
#> GSM123778     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123780     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123784     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123787     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123791     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123795     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123799     3  0.0000     0.9103 0.000  0 1.000 0.000 0.000 0.000
#> GSM123730     4  0.0000     0.6825 0.000  0 0.000 1.000 0.000 0.000
#> GSM123734     4  0.2340     0.6719 0.000  0 0.000 0.852 0.000 0.148
#> GSM123738     4  0.0000     0.6825 0.000  0 0.000 1.000 0.000 0.000
#> GSM123742     4  0.5169     0.7041 0.000  0 0.292 0.588 0.000 0.120
#> GSM123745     1  0.0000     0.8615 1.000  0 0.000 0.000 0.000 0.000
#> GSM123748     4  0.6256     0.6686 0.088  0 0.220 0.572 0.000 0.120
#> GSM123751     1  0.1053     0.8412 0.964  0 0.012 0.020 0.000 0.004
#> GSM123754     1  0.2882     0.6466 0.812  0 0.180 0.000 0.000 0.008
#> GSM123757     3  0.3934     0.4266 0.376  0 0.616 0.000 0.000 0.008
#> GSM123760     4  0.5169     0.7041 0.000  0 0.292 0.588 0.000 0.120
#> GSM123762     5  0.3756     0.0401 0.000  0 0.000 0.000 0.600 0.400
#> GSM123764     4  0.5153     0.7062 0.000  0 0.288 0.592 0.000 0.120
#> GSM123767     1  0.0000     0.8615 1.000  0 0.000 0.000 0.000 0.000
#> GSM123770     1  0.0622     0.8543 0.980  0 0.012 0.000 0.000 0.008
#> GSM123773     1  0.0000     0.8615 1.000  0 0.000 0.000 0.000 0.000
#> GSM123777     4  0.0000     0.6825 0.000  0 0.000 1.000 0.000 0.000
#> GSM123779     1  0.4617     0.3037 0.544  0 0.016 0.424 0.000 0.016
#> GSM123782     4  0.5153     0.7062 0.000  0 0.288 0.592 0.000 0.120
#> GSM123786     3  0.0146     0.9099 0.000  0 0.996 0.004 0.000 0.000
#> GSM123789     4  0.5169     0.7041 0.000  0 0.292 0.588 0.000 0.120
#> GSM123793     4  0.0000     0.6825 0.000  0 0.000 1.000 0.000 0.000
#> GSM123797     4  0.0000     0.6825 0.000  0 0.000 1.000 0.000 0.000
#> GSM123729     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123737     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123781     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123788     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123792     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123731     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123739     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123776     1  0.0000     0.8615 1.000  0 0.000 0.000 0.000 0.000
#> GSM123783     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123790     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123794     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000
#> GSM123798     2  0.0000     1.0000 0.000  1 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) infection(p) agent(p) k
#> ATC:hclust 33         6.83e-08     6.83e-08 9.77e-02 2
#> ATC:hclust 70         1.22e-14     1.22e-14 9.77e-05 3
#> ATC:hclust 69         6.33e-18     6.33e-18 4.11e-04 4
#> ATC:hclust 63         2.54e-17     2.54e-17 4.06e-04 5
#> ATC:hclust 67         9.96e-23     9.96e-23 1.23e-03 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 71 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           1.000       1.000         0.4714 0.529   0.529
#> 3 3 0.710           0.737       0.865         0.3327 0.849   0.716
#> 4 4 0.731           0.871       0.854         0.1282 0.850   0.628
#> 5 5 0.767           0.835       0.858         0.0735 1.000   1.000
#> 6 6 0.799           0.658       0.791         0.0472 0.925   0.731

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
#> GSM123732     1  0.0000      1.000 1.000 0.000
#> GSM123736     1  0.0000      1.000 1.000 0.000
#> GSM123740     1  0.0000      1.000 1.000 0.000
#> GSM123744     1  0.0000      1.000 1.000 0.000
#> GSM123746     1  0.0000      1.000 1.000 0.000
#> GSM123750     1  0.0000      1.000 1.000 0.000
#> GSM123752     1  0.0000      1.000 1.000 0.000
#> GSM123756     1  0.0000      1.000 1.000 0.000
#> GSM123758     1  0.0000      1.000 1.000 0.000
#> GSM123761     1  0.0000      1.000 1.000 0.000
#> GSM123763     1  0.0000      1.000 1.000 0.000
#> GSM123765     1  0.0000      1.000 1.000 0.000
#> GSM123769     1  0.0000      1.000 1.000 0.000
#> GSM123771     1  0.0000      1.000 1.000 0.000
#> GSM123774     1  0.0000      1.000 1.000 0.000
#> GSM123778     1  0.0000      1.000 1.000 0.000
#> GSM123780     1  0.0000      1.000 1.000 0.000
#> GSM123784     1  0.0000      1.000 1.000 0.000
#> GSM123787     1  0.0000      1.000 1.000 0.000
#> GSM123791     1  0.0000      1.000 1.000 0.000
#> GSM123795     1  0.0000      1.000 1.000 0.000
#> GSM123799     1  0.0000      1.000 1.000 0.000
#> GSM123730     1  0.0000      1.000 1.000 0.000
#> GSM123734     1  0.0000      1.000 1.000 0.000
#> GSM123738     1  0.0000      1.000 1.000 0.000
#> GSM123742     1  0.0000      1.000 1.000 0.000
#> GSM123745     1  0.0000      1.000 1.000 0.000
#> GSM123748     1  0.0000      1.000 1.000 0.000
#> GSM123751     1  0.0000      1.000 1.000 0.000
#> GSM123754     1  0.0000      1.000 1.000 0.000
#> GSM123757     1  0.0000      1.000 1.000 0.000
#> GSM123760     1  0.0000      1.000 1.000 0.000
#> GSM123762     1  0.0000      1.000 1.000 0.000
#> GSM123764     1  0.0000      1.000 1.000 0.000
#> GSM123767     1  0.0000      1.000 1.000 0.000
#> GSM123770     1  0.0000      1.000 1.000 0.000
#> GSM123773     1  0.0000      1.000 1.000 0.000
#> GSM123777     1  0.0000      1.000 1.000 0.000
#> GSM123779     1  0.0000      1.000 1.000 0.000
#> GSM123782     1  0.0000      1.000 1.000 0.000
#> GSM123786     1  0.0000      1.000 1.000 0.000
#> GSM123789     1  0.0000      1.000 1.000 0.000
#> GSM123793     1  0.0000      1.000 1.000 0.000
#> GSM123797     1  0.0000      1.000 1.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000
#> GSM123733     2  0.0000      1.000 0.000 1.000
#> GSM123737     2  0.0000      1.000 0.000 1.000
#> GSM123741     2  0.0000      1.000 0.000 1.000
#> GSM123747     2  0.0000      1.000 0.000 1.000
#> GSM123753     2  0.0000      1.000 0.000 1.000
#> GSM123759     2  0.0000      1.000 0.000 1.000
#> GSM123766     2  0.0000      1.000 0.000 1.000
#> GSM123772     2  0.0000      1.000 0.000 1.000
#> GSM123775     2  0.0000      1.000 0.000 1.000
#> GSM123781     2  0.0000      1.000 0.000 1.000
#> GSM123785     2  0.0000      1.000 0.000 1.000
#> GSM123788     2  0.0000      1.000 0.000 1.000
#> GSM123792     2  0.0000      1.000 0.000 1.000
#> GSM123796     2  0.0000      1.000 0.000 1.000
#> GSM123731     2  0.0000      1.000 0.000 1.000
#> GSM123735     2  0.0000      1.000 0.000 1.000
#> GSM123739     2  0.0000      1.000 0.000 1.000
#> GSM123743     2  0.0000      1.000 0.000 1.000
#> GSM123749     2  0.0000      1.000 0.000 1.000
#> GSM123755     2  0.0000      1.000 0.000 1.000
#> GSM123768     2  0.0000      1.000 0.000 1.000
#> GSM123776     1  0.0376      0.996 0.996 0.004
#> GSM123783     2  0.0000      1.000 0.000 1.000
#> GSM123790     2  0.0000      1.000 0.000 1.000
#> GSM123794     2  0.0000      1.000 0.000 1.000
#> GSM123798     2  0.0000      1.000 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
#> GSM123732     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123736     3  0.5785     0.5081 0.332 0.000 0.668
#> GSM123740     3  0.5785     0.5081 0.332 0.000 0.668
#> GSM123744     1  0.3192     0.8292 0.888 0.000 0.112
#> GSM123746     1  0.5988     0.3440 0.632 0.000 0.368
#> GSM123750     1  0.6299    -0.1089 0.524 0.000 0.476
#> GSM123752     3  0.6305     0.1679 0.484 0.000 0.516
#> GSM123756     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123758     3  0.6215     0.2927 0.428 0.000 0.572
#> GSM123761     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123763     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123765     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123769     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123771     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123774     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123778     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123780     3  0.2537     0.6944 0.080 0.000 0.920
#> GSM123784     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123787     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123791     3  0.5882     0.4749 0.348 0.000 0.652
#> GSM123795     3  0.5760     0.5150 0.328 0.000 0.672
#> GSM123799     3  0.5785     0.5081 0.332 0.000 0.668
#> GSM123730     3  0.2313     0.6635 0.032 0.024 0.944
#> GSM123734     3  0.2261     0.6936 0.068 0.000 0.932
#> GSM123738     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123742     3  0.2448     0.6896 0.076 0.000 0.924
#> GSM123745     3  0.3482     0.6539 0.128 0.000 0.872
#> GSM123748     3  0.3482     0.6539 0.128 0.000 0.872
#> GSM123751     3  0.3482     0.6539 0.128 0.000 0.872
#> GSM123754     3  0.3482     0.6539 0.128 0.000 0.872
#> GSM123757     3  0.6008     0.4186 0.372 0.000 0.628
#> GSM123760     3  0.2261     0.6936 0.068 0.000 0.932
#> GSM123762     1  0.3116     0.8333 0.892 0.000 0.108
#> GSM123764     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123767     3  0.1964     0.6986 0.056 0.000 0.944
#> GSM123770     1  0.6309     0.0587 0.500 0.000 0.500
#> GSM123773     3  0.3192     0.6668 0.112 0.000 0.888
#> GSM123777     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123779     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123782     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123786     3  0.5733     0.5214 0.324 0.000 0.676
#> GSM123789     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123793     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123797     3  0.0000     0.7098 0.000 0.000 1.000
#> GSM123729     2  0.2448     0.9539 0.076 0.924 0.000
#> GSM123733     2  0.1031     0.9736 0.024 0.976 0.000
#> GSM123737     2  0.1529     0.9709 0.040 0.960 0.000
#> GSM123741     2  0.0000     0.9774 0.000 1.000 0.000
#> GSM123747     2  0.0000     0.9774 0.000 1.000 0.000
#> GSM123753     2  0.0000     0.9774 0.000 1.000 0.000
#> GSM123759     2  0.1163     0.9744 0.028 0.972 0.000
#> GSM123766     2  0.1289     0.9708 0.032 0.968 0.000
#> GSM123772     2  0.1289     0.9708 0.032 0.968 0.000
#> GSM123775     2  0.2448     0.9539 0.076 0.924 0.000
#> GSM123781     2  0.1289     0.9727 0.032 0.968 0.000
#> GSM123785     2  0.1289     0.9708 0.032 0.968 0.000
#> GSM123788     2  0.1031     0.9736 0.024 0.976 0.000
#> GSM123792     2  0.0237     0.9773 0.004 0.996 0.000
#> GSM123796     2  0.1031     0.9736 0.024 0.976 0.000
#> GSM123731     2  0.1163     0.9744 0.028 0.972 0.000
#> GSM123735     2  0.0237     0.9773 0.004 0.996 0.000
#> GSM123739     2  0.1529     0.9709 0.040 0.960 0.000
#> GSM123743     2  0.0000     0.9774 0.000 1.000 0.000
#> GSM123749     2  0.1163     0.9744 0.028 0.972 0.000
#> GSM123755     2  0.1163     0.9744 0.028 0.972 0.000
#> GSM123768     2  0.2165     0.9602 0.064 0.936 0.000
#> GSM123776     3  0.6075     0.5094 0.316 0.008 0.676
#> GSM123783     2  0.2448     0.9539 0.076 0.924 0.000
#> GSM123790     2  0.1031     0.9736 0.024 0.976 0.000
#> GSM123794     2  0.0237     0.9773 0.004 0.996 0.000
#> GSM123798     2  0.1163     0.9744 0.028 0.972 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0469      0.908 0.000 0.000 0.988 0.012
#> GSM123736     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123740     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123744     3  0.5997     -0.101 0.376 0.000 0.576 0.048
#> GSM123746     3  0.4656      0.686 0.072 0.000 0.792 0.136
#> GSM123750     3  0.2197      0.846 0.024 0.000 0.928 0.048
#> GSM123752     3  0.3048      0.812 0.016 0.000 0.876 0.108
#> GSM123756     1  0.4719      0.990 0.772 0.000 0.180 0.048
#> GSM123758     3  0.2142      0.865 0.016 0.000 0.928 0.056
#> GSM123761     1  0.4801      0.988 0.764 0.000 0.188 0.048
#> GSM123763     1  0.4990      0.984 0.756 0.000 0.184 0.060
#> GSM123765     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123769     1  0.4719      0.990 0.772 0.000 0.180 0.048
#> GSM123771     1  0.4719      0.990 0.772 0.000 0.180 0.048
#> GSM123774     1  0.4789      0.978 0.772 0.000 0.172 0.056
#> GSM123778     3  0.0469      0.908 0.000 0.000 0.988 0.012
#> GSM123780     3  0.2999      0.721 0.004 0.000 0.864 0.132
#> GSM123784     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123787     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123791     3  0.0336      0.898 0.008 0.000 0.992 0.000
#> GSM123795     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123799     3  0.0336      0.910 0.000 0.000 0.992 0.008
#> GSM123730     4  0.5291      0.847 0.032 0.004 0.264 0.700
#> GSM123734     4  0.3610      0.866 0.000 0.000 0.200 0.800
#> GSM123738     4  0.5182      0.845 0.028 0.000 0.288 0.684
#> GSM123742     4  0.4194      0.865 0.008 0.000 0.228 0.764
#> GSM123745     4  0.3479      0.849 0.012 0.000 0.148 0.840
#> GSM123748     4  0.3925      0.849 0.016 0.000 0.176 0.808
#> GSM123751     4  0.3836      0.850 0.016 0.000 0.168 0.816
#> GSM123754     4  0.3764      0.850 0.012 0.000 0.172 0.816
#> GSM123757     4  0.5322      0.652 0.028 0.000 0.312 0.660
#> GSM123760     4  0.4194      0.865 0.008 0.000 0.228 0.764
#> GSM123762     1  0.4990      0.984 0.756 0.000 0.184 0.060
#> GSM123764     4  0.4632      0.845 0.004 0.000 0.308 0.688
#> GSM123767     4  0.3725      0.862 0.008 0.000 0.180 0.812
#> GSM123770     4  0.6078      0.610 0.152 0.000 0.164 0.684
#> GSM123773     4  0.3401      0.852 0.008 0.000 0.152 0.840
#> GSM123777     4  0.5157      0.846 0.028 0.000 0.284 0.688
#> GSM123779     4  0.4456      0.854 0.004 0.000 0.280 0.716
#> GSM123782     4  0.4608      0.848 0.004 0.000 0.304 0.692
#> GSM123786     3  0.0469      0.908 0.000 0.000 0.988 0.012
#> GSM123789     4  0.4677      0.842 0.004 0.000 0.316 0.680
#> GSM123793     4  0.5157      0.846 0.028 0.000 0.284 0.688
#> GSM123797     4  0.5157      0.846 0.028 0.000 0.284 0.688
#> GSM123729     2  0.4805      0.815 0.132 0.784 0.000 0.084
#> GSM123733     2  0.0927      0.947 0.016 0.976 0.000 0.008
#> GSM123737     2  0.1174      0.943 0.012 0.968 0.000 0.020
#> GSM123741     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM123747     2  0.0804      0.947 0.012 0.980 0.000 0.008
#> GSM123753     2  0.0336      0.947 0.008 0.992 0.000 0.000
#> GSM123759     2  0.1151      0.944 0.024 0.968 0.000 0.008
#> GSM123766     2  0.1388      0.939 0.028 0.960 0.000 0.012
#> GSM123772     2  0.1388      0.939 0.028 0.960 0.000 0.012
#> GSM123775     2  0.5423      0.775 0.144 0.740 0.000 0.116
#> GSM123781     2  0.1677      0.938 0.040 0.948 0.000 0.012
#> GSM123785     2  0.1820      0.934 0.036 0.944 0.000 0.020
#> GSM123788     2  0.0927      0.947 0.016 0.976 0.000 0.008
#> GSM123792     2  0.0804      0.947 0.012 0.980 0.000 0.008
#> GSM123796     2  0.0927      0.947 0.016 0.976 0.000 0.008
#> GSM123731     2  0.0927      0.945 0.016 0.976 0.000 0.008
#> GSM123735     2  0.0804      0.947 0.012 0.980 0.000 0.008
#> GSM123739     2  0.1174      0.943 0.012 0.968 0.000 0.020
#> GSM123743     2  0.0336      0.948 0.008 0.992 0.000 0.000
#> GSM123749     2  0.1151      0.944 0.024 0.968 0.000 0.008
#> GSM123755     2  0.0592      0.947 0.016 0.984 0.000 0.000
#> GSM123768     2  0.5080      0.801 0.144 0.764 0.000 0.092
#> GSM123776     4  0.5900      0.555 0.148 0.052 0.056 0.744
#> GSM123783     2  0.5462      0.775 0.152 0.736 0.000 0.112
#> GSM123790     2  0.0927      0.947 0.016 0.976 0.000 0.008
#> GSM123794     2  0.0804      0.947 0.012 0.980 0.000 0.008
#> GSM123798     2  0.1284      0.943 0.024 0.964 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM123732     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123736     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123740     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123744     3  0.4318      0.536 0.296 0.000 0.688 0.008 0.008
#> GSM123746     3  0.3120      0.846 0.048 0.000 0.864 0.084 0.004
#> GSM123750     3  0.1267      0.929 0.024 0.000 0.960 0.012 0.004
#> GSM123752     3  0.2429      0.884 0.020 0.000 0.900 0.076 0.004
#> GSM123756     1  0.1981      0.970 0.920 0.000 0.064 0.016 0.000
#> GSM123758     3  0.1646      0.917 0.020 0.000 0.944 0.032 0.004
#> GSM123761     1  0.2141      0.969 0.916 0.000 0.064 0.016 0.004
#> GSM123763     1  0.3845      0.943 0.824 0.000 0.064 0.012 0.100
#> GSM123765     3  0.0162      0.950 0.000 0.000 0.996 0.004 0.000
#> GSM123769     1  0.1981      0.970 0.920 0.000 0.064 0.016 0.000
#> GSM123771     1  0.1981      0.970 0.920 0.000 0.064 0.016 0.000
#> GSM123774     1  0.2153      0.941 0.916 0.000 0.040 0.044 0.000
#> GSM123778     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123780     3  0.1444      0.910 0.000 0.000 0.948 0.040 0.012
#> GSM123784     3  0.0162      0.950 0.000 0.000 0.996 0.004 0.000
#> GSM123787     3  0.0162      0.950 0.000 0.000 0.996 0.004 0.000
#> GSM123791     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123795     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123799     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123730     4  0.5980      0.758 0.016 0.000 0.092 0.584 0.308
#> GSM123734     4  0.4234      0.808 0.000 0.000 0.056 0.760 0.184
#> GSM123738     4  0.5933      0.758 0.012 0.000 0.096 0.584 0.308
#> GSM123742     4  0.3159      0.804 0.000 0.000 0.056 0.856 0.088
#> GSM123745     4  0.1216      0.777 0.020 0.000 0.020 0.960 0.000
#> GSM123748     4  0.1211      0.777 0.016 0.000 0.024 0.960 0.000
#> GSM123751     4  0.1211      0.777 0.016 0.000 0.024 0.960 0.000
#> GSM123754     4  0.1310      0.776 0.020 0.000 0.024 0.956 0.000
#> GSM123757     4  0.4039      0.615 0.036 0.000 0.184 0.776 0.004
#> GSM123760     4  0.4114      0.808 0.000 0.000 0.060 0.776 0.164
#> GSM123762     1  0.3845      0.943 0.824 0.000 0.064 0.012 0.100
#> GSM123764     4  0.4867      0.804 0.000 0.000 0.104 0.716 0.180
#> GSM123767     4  0.1211      0.779 0.016 0.000 0.024 0.960 0.000
#> GSM123770     4  0.3183      0.643 0.156 0.000 0.016 0.828 0.000
#> GSM123773     4  0.1211      0.779 0.016 0.000 0.024 0.960 0.000
#> GSM123777     4  0.5933      0.758 0.012 0.000 0.096 0.584 0.308
#> GSM123779     4  0.4964      0.800 0.000 0.000 0.096 0.700 0.204
#> GSM123782     4  0.4948      0.803 0.000 0.000 0.108 0.708 0.184
#> GSM123786     3  0.0324      0.950 0.000 0.000 0.992 0.004 0.004
#> GSM123789     4  0.4879      0.804 0.000 0.000 0.108 0.716 0.176
#> GSM123793     4  0.5933      0.758 0.012 0.000 0.096 0.584 0.308
#> GSM123797     4  0.5933      0.758 0.012 0.000 0.096 0.584 0.308
#> GSM123729     2  0.5189      0.649 0.020 0.584 0.004 0.012 0.380
#> GSM123733     2  0.1525      0.873 0.012 0.948 0.000 0.004 0.036
#> GSM123737     2  0.2633      0.862 0.012 0.892 0.004 0.008 0.084
#> GSM123741     2  0.0404      0.877 0.000 0.988 0.000 0.000 0.012
#> GSM123747     2  0.1251      0.874 0.008 0.956 0.000 0.000 0.036
#> GSM123753     2  0.1197      0.876 0.000 0.952 0.000 0.000 0.048
#> GSM123759     2  0.2648      0.854 0.000 0.848 0.000 0.000 0.152
#> GSM123766     2  0.2959      0.856 0.016 0.864 0.000 0.008 0.112
#> GSM123772     2  0.2857      0.856 0.012 0.868 0.000 0.008 0.112
#> GSM123775     2  0.5316      0.565 0.020 0.508 0.004 0.012 0.456
#> GSM123781     2  0.3403      0.845 0.012 0.820 0.000 0.008 0.160
#> GSM123785     2  0.2692      0.849 0.016 0.884 0.000 0.008 0.092
#> GSM123788     2  0.1525      0.873 0.012 0.948 0.000 0.004 0.036
#> GSM123792     2  0.1251      0.874 0.008 0.956 0.000 0.000 0.036
#> GSM123796     2  0.1525      0.873 0.012 0.948 0.000 0.004 0.036
#> GSM123731     2  0.2074      0.868 0.000 0.896 0.000 0.000 0.104
#> GSM123735     2  0.1251      0.874 0.008 0.956 0.000 0.000 0.036
#> GSM123739     2  0.2633      0.862 0.012 0.892 0.004 0.008 0.084
#> GSM123743     2  0.0162      0.877 0.000 0.996 0.000 0.000 0.004
#> GSM123749     2  0.2648      0.854 0.000 0.848 0.000 0.000 0.152
#> GSM123755     2  0.2329      0.862 0.000 0.876 0.000 0.000 0.124
#> GSM123768     2  0.4350      0.658 0.004 0.588 0.000 0.000 0.408
#> GSM123776     4  0.5998      0.293 0.048 0.016 0.012 0.540 0.384
#> GSM123783     2  0.4809      0.581 0.008 0.516 0.000 0.008 0.468
#> GSM123790     2  0.1525      0.873 0.012 0.948 0.000 0.004 0.036
#> GSM123794     2  0.1251      0.874 0.008 0.956 0.000 0.000 0.036
#> GSM123798     2  0.2732      0.852 0.000 0.840 0.000 0.000 0.160

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.0767     0.9541 0.004 0.000 0.976 0.012 0.008 0.000
#> GSM123736     3  0.0146     0.9546 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123740     3  0.0146     0.9546 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123744     3  0.3884     0.6595 0.012 0.000 0.736 0.000 0.020 0.232
#> GSM123746     3  0.2594     0.8903 0.084 0.000 0.880 0.004 0.028 0.004
#> GSM123750     3  0.0914     0.9457 0.016 0.000 0.968 0.000 0.016 0.000
#> GSM123752     3  0.2199     0.8958 0.088 0.000 0.892 0.000 0.020 0.000
#> GSM123756     6  0.0547     0.9318 0.000 0.000 0.020 0.000 0.000 0.980
#> GSM123758     3  0.1616     0.9245 0.048 0.000 0.932 0.000 0.020 0.000
#> GSM123761     6  0.1262     0.9295 0.008 0.000 0.020 0.000 0.016 0.956
#> GSM123763     6  0.4431     0.8628 0.148 0.000 0.020 0.008 0.068 0.756
#> GSM123765     3  0.0653     0.9542 0.004 0.000 0.980 0.012 0.004 0.000
#> GSM123769     6  0.0547     0.9318 0.000 0.000 0.020 0.000 0.000 0.980
#> GSM123771     6  0.0837     0.9304 0.004 0.000 0.020 0.000 0.004 0.972
#> GSM123774     6  0.1985     0.8877 0.064 0.000 0.008 0.008 0.004 0.916
#> GSM123778     3  0.0767     0.9541 0.004 0.000 0.976 0.012 0.008 0.000
#> GSM123780     3  0.0951     0.9506 0.004 0.000 0.968 0.020 0.008 0.000
#> GSM123784     3  0.0653     0.9542 0.004 0.000 0.980 0.012 0.004 0.000
#> GSM123787     3  0.0653     0.9542 0.004 0.000 0.980 0.012 0.004 0.000
#> GSM123791     3  0.0146     0.9546 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123795     3  0.0146     0.9546 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123799     3  0.0146     0.9546 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123730     4  0.5461     0.5742 0.108 0.000 0.024 0.648 0.212 0.008
#> GSM123734     4  0.2118     0.5587 0.048 0.000 0.020 0.916 0.012 0.004
#> GSM123738     4  0.5405     0.5777 0.096 0.000 0.024 0.660 0.208 0.012
#> GSM123742     4  0.3971     0.0170 0.268 0.000 0.024 0.704 0.004 0.000
#> GSM123745     1  0.3950     0.7361 0.564 0.000 0.004 0.432 0.000 0.000
#> GSM123748     4  0.4089    -0.6295 0.468 0.000 0.008 0.524 0.000 0.000
#> GSM123751     4  0.3997    -0.6639 0.488 0.000 0.004 0.508 0.000 0.000
#> GSM123754     1  0.4018     0.7451 0.580 0.000 0.008 0.412 0.000 0.000
#> GSM123757     1  0.5548     0.6298 0.580 0.000 0.108 0.292 0.020 0.000
#> GSM123760     4  0.2760     0.4652 0.116 0.000 0.024 0.856 0.004 0.000
#> GSM123762     6  0.4431     0.8628 0.148 0.000 0.020 0.008 0.068 0.756
#> GSM123764     4  0.1511     0.5785 0.012 0.000 0.044 0.940 0.004 0.000
#> GSM123767     1  0.4189     0.7312 0.552 0.000 0.004 0.436 0.008 0.000
#> GSM123770     1  0.4987     0.7017 0.584 0.000 0.000 0.328 0.000 0.088
#> GSM123773     1  0.4184     0.7351 0.556 0.000 0.004 0.432 0.008 0.000
#> GSM123777     4  0.5461     0.5742 0.108 0.000 0.024 0.648 0.212 0.008
#> GSM123779     4  0.1718     0.5836 0.020 0.000 0.024 0.936 0.020 0.000
#> GSM123782     4  0.1887     0.5734 0.016 0.000 0.048 0.924 0.012 0.000
#> GSM123786     3  0.0767     0.9541 0.004 0.000 0.976 0.012 0.008 0.000
#> GSM123789     4  0.1888     0.5638 0.012 0.000 0.068 0.916 0.004 0.000
#> GSM123793     4  0.5405     0.5777 0.096 0.000 0.024 0.660 0.208 0.012
#> GSM123797     4  0.5405     0.5777 0.096 0.000 0.024 0.660 0.208 0.012
#> GSM123729     5  0.4671     0.8227 0.044 0.424 0.000 0.000 0.532 0.000
#> GSM123733     2  0.0146     0.7249 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123737     2  0.3409     0.5797 0.044 0.808 0.000 0.000 0.144 0.004
#> GSM123741     2  0.1508     0.7147 0.004 0.940 0.000 0.004 0.048 0.004
#> GSM123747     2  0.0146     0.7252 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM123753     2  0.2519     0.6699 0.004 0.864 0.000 0.004 0.124 0.004
#> GSM123759     2  0.3717     0.0332 0.000 0.616 0.000 0.000 0.384 0.000
#> GSM123766     2  0.4219     0.5862 0.060 0.764 0.000 0.012 0.156 0.008
#> GSM123772     2  0.4219     0.5862 0.060 0.764 0.000 0.012 0.156 0.008
#> GSM123775     5  0.4736     0.8510 0.060 0.352 0.000 0.000 0.588 0.000
#> GSM123781     2  0.5124     0.2576 0.060 0.620 0.000 0.012 0.300 0.008
#> GSM123785     2  0.2007     0.6609 0.044 0.916 0.000 0.004 0.036 0.000
#> GSM123788     2  0.0146     0.7249 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123792     2  0.0146     0.7252 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0146     0.7249 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM123731     2  0.3464     0.2444 0.000 0.688 0.000 0.000 0.312 0.000
#> GSM123735     2  0.0291     0.7241 0.004 0.992 0.000 0.000 0.004 0.000
#> GSM123739     2  0.3409     0.5797 0.044 0.808 0.000 0.000 0.144 0.004
#> GSM123743     2  0.1080     0.7198 0.004 0.960 0.000 0.000 0.032 0.004
#> GSM123749     2  0.3717     0.0332 0.000 0.616 0.000 0.000 0.384 0.000
#> GSM123755     2  0.3659     0.1188 0.000 0.636 0.000 0.000 0.364 0.000
#> GSM123768     5  0.3765     0.8258 0.000 0.404 0.000 0.000 0.596 0.000
#> GSM123776     1  0.5549     0.4127 0.556 0.008 0.000 0.132 0.304 0.000
#> GSM123783     5  0.3954     0.8695 0.012 0.352 0.000 0.000 0.636 0.000
#> GSM123790     2  0.0405     0.7236 0.004 0.988 0.000 0.000 0.008 0.000
#> GSM123794     2  0.0291     0.7241 0.004 0.992 0.000 0.000 0.004 0.000
#> GSM123798     2  0.3717     0.0332 0.000 0.616 0.000 0.000 0.384 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) infection(p) agent(p) k
#> ATC:kmeans 71         3.04e-15     3.04e-15 5.99e-05 2
#> ATC:kmeans 64         7.70e-15     7.70e-15 3.36e-04 3
#> ATC:kmeans 70         4.19e-24     4.19e-24 3.28e-04 4
#> ATC:kmeans 70         2.59e-25     2.59e-25 6.26e-05 5
#> ATC:kmeans 60         8.10e-19     8.10e-19 4.61e-03 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 71 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           1.000       1.000         0.4850 0.515   0.515
#> 3 3 0.819           0.863       0.895         0.3793 0.801   0.619
#> 4 4 0.898           0.872       0.943         0.0990 0.860   0.618
#> 5 5 0.884           0.822       0.896         0.0435 0.926   0.739
#> 6 6 0.878           0.773       0.853         0.0265 0.984   0.932

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
#> GSM123732     1       0          1  1  0
#> GSM123736     1       0          1  1  0
#> GSM123740     1       0          1  1  0
#> GSM123744     1       0          1  1  0
#> GSM123746     1       0          1  1  0
#> GSM123750     1       0          1  1  0
#> GSM123752     1       0          1  1  0
#> GSM123756     1       0          1  1  0
#> GSM123758     1       0          1  1  0
#> GSM123761     1       0          1  1  0
#> GSM123763     1       0          1  1  0
#> GSM123765     1       0          1  1  0
#> GSM123769     1       0          1  1  0
#> GSM123771     1       0          1  1  0
#> GSM123774     1       0          1  1  0
#> GSM123778     1       0          1  1  0
#> GSM123780     1       0          1  1  0
#> GSM123784     1       0          1  1  0
#> GSM123787     1       0          1  1  0
#> GSM123791     1       0          1  1  0
#> GSM123795     1       0          1  1  0
#> GSM123799     1       0          1  1  0
#> GSM123730     2       0          1  0  1
#> GSM123734     1       0          1  1  0
#> GSM123738     1       0          1  1  0
#> GSM123742     1       0          1  1  0
#> GSM123745     1       0          1  1  0
#> GSM123748     1       0          1  1  0
#> GSM123751     1       0          1  1  0
#> GSM123754     1       0          1  1  0
#> GSM123757     1       0          1  1  0
#> GSM123760     1       0          1  1  0
#> GSM123762     1       0          1  1  0
#> GSM123764     1       0          1  1  0
#> GSM123767     1       0          1  1  0
#> GSM123770     1       0          1  1  0
#> GSM123773     1       0          1  1  0
#> GSM123777     1       0          1  1  0
#> GSM123779     1       0          1  1  0
#> GSM123782     1       0          1  1  0
#> GSM123786     1       0          1  1  0
#> GSM123789     1       0          1  1  0
#> GSM123793     1       0          1  1  0
#> GSM123797     1       0          1  1  0
#> GSM123729     2       0          1  0  1
#> GSM123733     2       0          1  0  1
#> GSM123737     2       0          1  0  1
#> GSM123741     2       0          1  0  1
#> GSM123747     2       0          1  0  1
#> GSM123753     2       0          1  0  1
#> GSM123759     2       0          1  0  1
#> GSM123766     2       0          1  0  1
#> GSM123772     2       0          1  0  1
#> GSM123775     2       0          1  0  1
#> GSM123781     2       0          1  0  1
#> GSM123785     2       0          1  0  1
#> GSM123788     2       0          1  0  1
#> GSM123792     2       0          1  0  1
#> GSM123796     2       0          1  0  1
#> GSM123731     2       0          1  0  1
#> GSM123735     2       0          1  0  1
#> GSM123739     2       0          1  0  1
#> GSM123743     2       0          1  0  1
#> GSM123749     2       0          1  0  1
#> GSM123755     2       0          1  0  1
#> GSM123768     2       0          1  0  1
#> GSM123776     2       0          1  0  1
#> GSM123783     2       0          1  0  1
#> GSM123790     2       0          1  0  1
#> GSM123794     2       0          1  0  1
#> GSM123798     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM123732     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123736     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123740     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123744     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123746     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123750     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123752     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123756     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123758     3  0.0237      0.807 0.004 0.000 0.996
#> GSM123761     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123763     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123765     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123769     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123771     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123774     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123778     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123780     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123784     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123787     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123791     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123795     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123799     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123730     1  0.4235      0.697 0.824 0.176 0.000
#> GSM123734     1  0.5327      0.790 0.728 0.000 0.272
#> GSM123738     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123742     1  0.5431      0.786 0.716 0.000 0.284
#> GSM123745     1  0.5397      0.788 0.720 0.000 0.280
#> GSM123748     1  0.5431      0.786 0.716 0.000 0.284
#> GSM123751     1  0.5397      0.788 0.720 0.000 0.280
#> GSM123754     1  0.6154      0.652 0.592 0.000 0.408
#> GSM123757     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123760     1  0.5327      0.790 0.728 0.000 0.272
#> GSM123762     3  0.0000      0.807 0.000 0.000 1.000
#> GSM123764     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123767     1  0.5397      0.788 0.720 0.000 0.280
#> GSM123770     1  0.6286      0.555 0.536 0.000 0.464
#> GSM123773     1  0.5397      0.788 0.720 0.000 0.280
#> GSM123777     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123779     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123782     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123786     3  0.5397      0.793 0.280 0.000 0.720
#> GSM123789     1  0.0237      0.768 0.996 0.000 0.004
#> GSM123793     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123797     1  0.0000      0.771 1.000 0.000 0.000
#> GSM123729     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123733     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123737     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123741     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123747     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123753     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123759     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123766     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123772     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123775     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123781     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123785     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123788     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123792     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123796     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123731     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123735     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123739     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123743     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123749     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123755     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123768     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123776     2  0.1753      0.945 0.000 0.952 0.048
#> GSM123783     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123790     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123794     2  0.0000      0.998 0.000 1.000 0.000
#> GSM123798     2  0.0000      0.998 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1   p2    p3    p4
#> GSM123732     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123736     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123740     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123744     3  0.4925      0.278 0.428 0.00 0.572 0.000
#> GSM123746     1  0.1118      0.862 0.964 0.00 0.036 0.000
#> GSM123750     3  0.4941      0.256 0.436 0.00 0.564 0.000
#> GSM123752     1  0.3873      0.648 0.772 0.00 0.228 0.000
#> GSM123756     1  0.1022      0.863 0.968 0.00 0.032 0.000
#> GSM123758     3  0.1389      0.883 0.048 0.00 0.952 0.000
#> GSM123761     1  0.1211      0.860 0.960 0.00 0.040 0.000
#> GSM123763     1  0.1118      0.862 0.964 0.00 0.036 0.000
#> GSM123765     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123769     1  0.1022      0.863 0.968 0.00 0.032 0.000
#> GSM123771     1  0.1022      0.863 0.968 0.00 0.032 0.000
#> GSM123774     1  0.0000      0.858 1.000 0.00 0.000 0.000
#> GSM123778     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123780     3  0.0469      0.910 0.000 0.00 0.988 0.012
#> GSM123784     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123787     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123791     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123795     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123799     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123730     4  0.0000      0.893 0.000 0.00 0.000 1.000
#> GSM123734     4  0.0817      0.884 0.024 0.00 0.000 0.976
#> GSM123738     4  0.0188      0.893 0.000 0.00 0.004 0.996
#> GSM123742     1  0.5038      0.578 0.684 0.00 0.020 0.296
#> GSM123745     1  0.3266      0.751 0.832 0.00 0.000 0.168
#> GSM123748     1  0.3123      0.761 0.844 0.00 0.000 0.156
#> GSM123751     1  0.3266      0.751 0.832 0.00 0.000 0.168
#> GSM123754     1  0.0000      0.858 1.000 0.00 0.000 0.000
#> GSM123757     1  0.0000      0.858 1.000 0.00 0.000 0.000
#> GSM123760     4  0.4843      0.277 0.396 0.00 0.000 0.604
#> GSM123762     1  0.1118      0.862 0.964 0.00 0.036 0.000
#> GSM123764     4  0.3450      0.807 0.008 0.00 0.156 0.836
#> GSM123767     4  0.1302      0.872 0.044 0.00 0.000 0.956
#> GSM123770     1  0.0000      0.858 1.000 0.00 0.000 0.000
#> GSM123773     1  0.4888      0.338 0.588 0.00 0.000 0.412
#> GSM123777     4  0.0188      0.893 0.000 0.00 0.004 0.996
#> GSM123779     4  0.0188      0.893 0.000 0.00 0.004 0.996
#> GSM123782     4  0.3852      0.774 0.008 0.00 0.192 0.800
#> GSM123786     3  0.0000      0.922 0.000 0.00 1.000 0.000
#> GSM123789     4  0.4988      0.708 0.036 0.00 0.236 0.728
#> GSM123793     4  0.0000      0.893 0.000 0.00 0.000 1.000
#> GSM123797     4  0.0000      0.893 0.000 0.00 0.000 1.000
#> GSM123729     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123776     1  0.4624      0.463 0.660 0.34 0.000 0.000
#> GSM123783     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000 1.00 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000 1.00 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
#> GSM123732     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123736     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123740     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123744     1  0.3759      0.638 0.764 0.000 0.220 0.000 0.016
#> GSM123746     1  0.1205      0.808 0.956 0.000 0.004 0.000 0.040
#> GSM123750     1  0.4010      0.645 0.760 0.000 0.208 0.000 0.032
#> GSM123752     1  0.3119      0.770 0.860 0.000 0.072 0.000 0.068
#> GSM123756     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM123758     3  0.4681      0.567 0.252 0.000 0.696 0.000 0.052
#> GSM123761     1  0.0566      0.814 0.984 0.000 0.004 0.000 0.012
#> GSM123763     1  0.1544      0.789 0.932 0.000 0.000 0.000 0.068
#> GSM123765     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123769     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM123771     1  0.0000      0.816 1.000 0.000 0.000 0.000 0.000
#> GSM123774     1  0.0963      0.808 0.964 0.000 0.000 0.000 0.036
#> GSM123778     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.0451      0.959 0.000 0.000 0.988 0.004 0.008
#> GSM123784     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123787     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.0798      0.949 0.016 0.000 0.976 0.000 0.008
#> GSM123795     3  0.0451      0.959 0.008 0.000 0.988 0.000 0.004
#> GSM123799     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123730     4  0.0290      0.790 0.000 0.000 0.000 0.992 0.008
#> GSM123734     5  0.4976      0.380 0.028 0.000 0.000 0.468 0.504
#> GSM123738     4  0.0290      0.790 0.000 0.000 0.000 0.992 0.008
#> GSM123742     5  0.5470      0.593 0.268 0.000 0.000 0.104 0.628
#> GSM123745     5  0.4305      0.478 0.200 0.000 0.000 0.052 0.748
#> GSM123748     5  0.4594      0.542 0.284 0.000 0.000 0.036 0.680
#> GSM123751     5  0.4477      0.537 0.252 0.000 0.000 0.040 0.708
#> GSM123754     1  0.3838      0.606 0.716 0.000 0.000 0.004 0.280
#> GSM123757     1  0.3210      0.723 0.788 0.000 0.000 0.000 0.212
#> GSM123760     5  0.5983      0.589 0.168 0.000 0.000 0.252 0.580
#> GSM123762     1  0.1608      0.787 0.928 0.000 0.000 0.000 0.072
#> GSM123764     5  0.5476      0.425 0.008 0.000 0.044 0.440 0.508
#> GSM123767     4  0.4264      0.435 0.004 0.000 0.000 0.620 0.376
#> GSM123770     1  0.3508      0.645 0.748 0.000 0.000 0.000 0.252
#> GSM123773     4  0.5856      0.257 0.100 0.000 0.000 0.504 0.396
#> GSM123777     4  0.0000      0.792 0.000 0.000 0.000 1.000 0.000
#> GSM123779     4  0.2011      0.710 0.000 0.000 0.004 0.908 0.088
#> GSM123782     5  0.5876      0.449 0.000 0.000 0.104 0.384 0.512
#> GSM123786     3  0.0000      0.967 0.000 0.000 1.000 0.000 0.000
#> GSM123789     5  0.6525      0.500 0.044 0.000 0.080 0.364 0.512
#> GSM123793     4  0.0963      0.769 0.000 0.000 0.000 0.964 0.036
#> GSM123797     4  0.0000      0.792 0.000 0.000 0.000 1.000 0.000
#> GSM123729     2  0.1043      0.974 0.000 0.960 0.000 0.000 0.040
#> GSM123733     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0404      0.988 0.000 0.988 0.000 0.000 0.012
#> GSM123741     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0162      0.990 0.000 0.996 0.000 0.000 0.004
#> GSM123759     2  0.0609      0.985 0.000 0.980 0.000 0.000 0.020
#> GSM123766     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.1341      0.963 0.000 0.944 0.000 0.000 0.056
#> GSM123781     2  0.0162      0.990 0.000 0.996 0.000 0.000 0.004
#> GSM123785     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0290      0.989 0.000 0.992 0.000 0.000 0.008
#> GSM123735     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.0404      0.988 0.000 0.988 0.000 0.000 0.012
#> GSM123743     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0609      0.985 0.000 0.980 0.000 0.000 0.020
#> GSM123755     2  0.0510      0.986 0.000 0.984 0.000 0.000 0.016
#> GSM123768     2  0.0963      0.977 0.000 0.964 0.000 0.000 0.036
#> GSM123776     1  0.6422      0.281 0.508 0.256 0.000 0.000 0.236
#> GSM123783     2  0.1121      0.971 0.000 0.956 0.000 0.000 0.044
#> GSM123790     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      0.991 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2  0.0609      0.985 0.000 0.980 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.0260     0.9199 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM123736     3  0.0870     0.9199 0.004 0.000 0.972 0.000 0.012 0.012
#> GSM123740     3  0.0870     0.9199 0.004 0.000 0.972 0.000 0.012 0.012
#> GSM123744     1  0.3713     0.7038 0.812 0.000 0.108 0.000 0.032 0.048
#> GSM123746     1  0.2766     0.7251 0.852 0.000 0.004 0.000 0.124 0.020
#> GSM123750     1  0.3873     0.7055 0.804 0.000 0.104 0.000 0.044 0.048
#> GSM123752     1  0.3966     0.6738 0.776 0.000 0.020 0.000 0.156 0.048
#> GSM123756     1  0.0291     0.7744 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM123758     3  0.6569    -0.1128 0.388 0.000 0.404 0.000 0.156 0.052
#> GSM123761     1  0.1592     0.7708 0.940 0.000 0.008 0.000 0.020 0.032
#> GSM123763     1  0.2425     0.7525 0.884 0.000 0.004 0.000 0.024 0.088
#> GSM123765     3  0.0146     0.9220 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM123769     1  0.0653     0.7750 0.980 0.000 0.004 0.000 0.004 0.012
#> GSM123771     1  0.0291     0.7744 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM123774     1  0.1152     0.7569 0.952 0.000 0.000 0.000 0.044 0.004
#> GSM123778     3  0.0508     0.9182 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM123780     3  0.0653     0.9160 0.000 0.000 0.980 0.004 0.004 0.012
#> GSM123784     3  0.0405     0.9222 0.004 0.000 0.988 0.000 0.000 0.008
#> GSM123787     3  0.0520     0.9219 0.000 0.000 0.984 0.000 0.008 0.008
#> GSM123791     3  0.2335     0.8684 0.044 0.000 0.904 0.000 0.024 0.028
#> GSM123795     3  0.1616     0.9016 0.012 0.000 0.940 0.000 0.020 0.028
#> GSM123799     3  0.0767     0.9206 0.004 0.000 0.976 0.000 0.008 0.012
#> GSM123730     4  0.0000     0.9042 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123734     6  0.5218     0.5011 0.012 0.000 0.000 0.312 0.084 0.592
#> GSM123738     4  0.0865     0.9028 0.000 0.000 0.000 0.964 0.000 0.036
#> GSM123742     6  0.3461     0.5776 0.152 0.000 0.000 0.008 0.036 0.804
#> GSM123745     5  0.5595     0.0748 0.100 0.000 0.000 0.012 0.472 0.416
#> GSM123748     6  0.4701     0.4396 0.168 0.000 0.000 0.000 0.148 0.684
#> GSM123751     6  0.5309     0.1227 0.128 0.000 0.000 0.000 0.312 0.560
#> GSM123754     1  0.5524    -0.0431 0.464 0.000 0.000 0.000 0.404 0.132
#> GSM123757     1  0.4957     0.4320 0.584 0.000 0.000 0.000 0.332 0.084
#> GSM123760     6  0.3668     0.6486 0.088 0.000 0.000 0.084 0.016 0.812
#> GSM123762     1  0.2526     0.7481 0.876 0.000 0.004 0.000 0.024 0.096
#> GSM123764     6  0.3965     0.5975 0.000 0.000 0.024 0.248 0.008 0.720
#> GSM123767     5  0.5790     0.3875 0.008 0.000 0.000 0.388 0.464 0.140
#> GSM123770     1  0.5221     0.1682 0.560 0.000 0.000 0.000 0.328 0.112
#> GSM123773     5  0.6456     0.4991 0.060 0.000 0.000 0.300 0.496 0.144
#> GSM123777     4  0.0000     0.9042 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123779     4  0.3635     0.7097 0.000 0.000 0.008 0.780 0.032 0.180
#> GSM123782     6  0.4341     0.6182 0.000 0.000 0.048 0.192 0.024 0.736
#> GSM123786     3  0.0508     0.9182 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM123789     6  0.4383     0.6389 0.020 0.000 0.040 0.192 0.008 0.740
#> GSM123793     4  0.1957     0.8480 0.000 0.000 0.000 0.888 0.000 0.112
#> GSM123797     4  0.0260     0.9067 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM123729     2  0.1444     0.9455 0.000 0.928 0.000 0.000 0.072 0.000
#> GSM123733     2  0.0508     0.9647 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM123737     2  0.0632     0.9646 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM123741     2  0.0000     0.9664 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0146     0.9663 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123753     2  0.0858     0.9636 0.000 0.968 0.000 0.000 0.028 0.004
#> GSM123759     2  0.1411     0.9548 0.000 0.936 0.000 0.000 0.060 0.004
#> GSM123766     2  0.0777     0.9647 0.000 0.972 0.000 0.000 0.024 0.004
#> GSM123772     2  0.0603     0.9659 0.000 0.980 0.000 0.000 0.016 0.004
#> GSM123775     2  0.2378     0.8706 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM123781     2  0.1124     0.9612 0.000 0.956 0.000 0.000 0.036 0.008
#> GSM123785     2  0.0622     0.9636 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM123788     2  0.0508     0.9647 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM123792     2  0.0405     0.9654 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM123796     2  0.0508     0.9647 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM123731     2  0.0865     0.9631 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM123735     2  0.0405     0.9654 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM123739     2  0.0790     0.9626 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM123743     2  0.0000     0.9664 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.1285     0.9580 0.000 0.944 0.000 0.000 0.052 0.004
#> GSM123755     2  0.1349     0.9564 0.000 0.940 0.000 0.000 0.056 0.004
#> GSM123768     2  0.1753     0.9430 0.000 0.912 0.000 0.000 0.084 0.004
#> GSM123776     5  0.5899     0.1196 0.324 0.120 0.000 0.000 0.528 0.028
#> GSM123783     2  0.1958     0.9322 0.000 0.896 0.000 0.000 0.100 0.004
#> GSM123790     2  0.0508     0.9647 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM123794     2  0.0405     0.9654 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM123798     2  0.1531     0.9521 0.000 0.928 0.000 0.000 0.068 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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) infection(p) agent(p) k
#> ATC:skmeans 71         2.82e-15     2.82e-15 1.16e-05 2
#> ATC:skmeans 71         4.65e-26     4.65e-26 7.76e-06 3
#> ATC:skmeans 66         3.18e-19     3.18e-19 1.47e-04 4
#> ATC:skmeans 63         5.94e-18     5.94e-18 7.98e-04 5
#> ATC:skmeans 61         6.91e-20     6.91e-20 1.20e-03 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 71 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 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.984       0.994         0.4745 0.529   0.529
#> 3 3 0.850           0.945       0.966         0.3990 0.801   0.624
#> 4 4 0.899           0.836       0.897         0.0844 0.948   0.845
#> 5 5 0.956           0.932       0.966         0.0480 0.938   0.790
#> 6 6 0.932           0.898       0.932         0.0113 0.998   0.990

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      0.990 1.000 0.000
#> GSM123736     1  0.0000      0.990 1.000 0.000
#> GSM123740     1  0.0000      0.990 1.000 0.000
#> GSM123744     1  0.0000      0.990 1.000 0.000
#> GSM123746     1  0.0000      0.990 1.000 0.000
#> GSM123750     1  0.0000      0.990 1.000 0.000
#> GSM123752     1  0.0000      0.990 1.000 0.000
#> GSM123756     1  0.0000      0.990 1.000 0.000
#> GSM123758     1  0.0000      0.990 1.000 0.000
#> GSM123761     1  0.0000      0.990 1.000 0.000
#> GSM123763     1  0.0000      0.990 1.000 0.000
#> GSM123765     1  0.0000      0.990 1.000 0.000
#> GSM123769     1  0.0000      0.990 1.000 0.000
#> GSM123771     1  0.0000      0.990 1.000 0.000
#> GSM123774     1  0.0000      0.990 1.000 0.000
#> GSM123778     1  0.0000      0.990 1.000 0.000
#> GSM123780     1  0.0000      0.990 1.000 0.000
#> GSM123784     1  0.0000      0.990 1.000 0.000
#> GSM123787     1  0.0000      0.990 1.000 0.000
#> GSM123791     1  0.0000      0.990 1.000 0.000
#> GSM123795     1  0.0000      0.990 1.000 0.000
#> GSM123799     1  0.0000      0.990 1.000 0.000
#> GSM123730     1  0.2423      0.951 0.960 0.040
#> GSM123734     1  0.0000      0.990 1.000 0.000
#> GSM123738     1  0.0000      0.990 1.000 0.000
#> GSM123742     1  0.0000      0.990 1.000 0.000
#> GSM123745     1  0.0000      0.990 1.000 0.000
#> GSM123748     1  0.0000      0.990 1.000 0.000
#> GSM123751     1  0.0000      0.990 1.000 0.000
#> GSM123754     1  0.0000      0.990 1.000 0.000
#> GSM123757     1  0.0000      0.990 1.000 0.000
#> GSM123760     1  0.0000      0.990 1.000 0.000
#> GSM123762     1  0.0000      0.990 1.000 0.000
#> GSM123764     1  0.0000      0.990 1.000 0.000
#> GSM123767     1  0.0376      0.986 0.996 0.004
#> GSM123770     1  0.0000      0.990 1.000 0.000
#> GSM123773     1  0.0000      0.990 1.000 0.000
#> GSM123777     1  0.0000      0.990 1.000 0.000
#> GSM123779     1  0.0000      0.990 1.000 0.000
#> GSM123782     1  0.0000      0.990 1.000 0.000
#> GSM123786     1  0.0000      0.990 1.000 0.000
#> GSM123789     1  0.0000      0.990 1.000 0.000
#> GSM123793     1  0.0000      0.990 1.000 0.000
#> GSM123797     1  0.0000      0.990 1.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000
#> GSM123733     2  0.0000      1.000 0.000 1.000
#> GSM123737     2  0.0000      1.000 0.000 1.000
#> GSM123741     2  0.0000      1.000 0.000 1.000
#> GSM123747     2  0.0000      1.000 0.000 1.000
#> GSM123753     2  0.0000      1.000 0.000 1.000
#> GSM123759     2  0.0000      1.000 0.000 1.000
#> GSM123766     2  0.0000      1.000 0.000 1.000
#> GSM123772     2  0.0000      1.000 0.000 1.000
#> GSM123775     2  0.0000      1.000 0.000 1.000
#> GSM123781     2  0.0000      1.000 0.000 1.000
#> GSM123785     2  0.0000      1.000 0.000 1.000
#> GSM123788     2  0.0000      1.000 0.000 1.000
#> GSM123792     2  0.0000      1.000 0.000 1.000
#> GSM123796     2  0.0000      1.000 0.000 1.000
#> GSM123731     2  0.0000      1.000 0.000 1.000
#> GSM123735     2  0.0000      1.000 0.000 1.000
#> GSM123739     2  0.0000      1.000 0.000 1.000
#> GSM123743     2  0.0000      1.000 0.000 1.000
#> GSM123749     2  0.0000      1.000 0.000 1.000
#> GSM123755     2  0.0000      1.000 0.000 1.000
#> GSM123768     2  0.0000      1.000 0.000 1.000
#> GSM123776     1  0.9710      0.337 0.600 0.400
#> GSM123783     2  0.0000      1.000 0.000 1.000
#> GSM123790     2  0.0000      1.000 0.000 1.000
#> GSM123794     2  0.0000      1.000 0.000 1.000
#> GSM123798     2  0.0000      1.000 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
#> GSM123732     3   0.000      0.960 0.000  0 1.000
#> GSM123736     3   0.000      0.960 0.000  0 1.000
#> GSM123740     3   0.000      0.960 0.000  0 1.000
#> GSM123744     3   0.465      0.760 0.208  0 0.792
#> GSM123746     3   0.536      0.659 0.276  0 0.724
#> GSM123750     3   0.175      0.922 0.048  0 0.952
#> GSM123752     3   0.000      0.960 0.000  0 1.000
#> GSM123756     1   0.000      0.909 1.000  0 0.000
#> GSM123758     3   0.000      0.960 0.000  0 1.000
#> GSM123761     1   0.000      0.909 1.000  0 0.000
#> GSM123763     1   0.000      0.909 1.000  0 0.000
#> GSM123765     3   0.000      0.960 0.000  0 1.000
#> GSM123769     1   0.000      0.909 1.000  0 0.000
#> GSM123771     1   0.000      0.909 1.000  0 0.000
#> GSM123774     1   0.000      0.909 1.000  0 0.000
#> GSM123778     3   0.000      0.960 0.000  0 1.000
#> GSM123780     3   0.000      0.960 0.000  0 1.000
#> GSM123784     3   0.000      0.960 0.000  0 1.000
#> GSM123787     3   0.000      0.960 0.000  0 1.000
#> GSM123791     3   0.000      0.960 0.000  0 1.000
#> GSM123795     3   0.000      0.960 0.000  0 1.000
#> GSM123799     3   0.000      0.960 0.000  0 1.000
#> GSM123730     3   0.000      0.960 0.000  0 1.000
#> GSM123734     1   0.355      0.929 0.868  0 0.132
#> GSM123738     3   0.000      0.960 0.000  0 1.000
#> GSM123742     1   0.355      0.929 0.868  0 0.132
#> GSM123745     1   0.355      0.929 0.868  0 0.132
#> GSM123748     1   0.355      0.929 0.868  0 0.132
#> GSM123751     1   0.355      0.929 0.868  0 0.132
#> GSM123754     1   0.355      0.929 0.868  0 0.132
#> GSM123757     1   0.355      0.929 0.868  0 0.132
#> GSM123760     1   0.355      0.929 0.868  0 0.132
#> GSM123762     1   0.000      0.909 1.000  0 0.000
#> GSM123764     3   0.000      0.960 0.000  0 1.000
#> GSM123767     1   0.355      0.929 0.868  0 0.132
#> GSM123770     1   0.000      0.909 1.000  0 0.000
#> GSM123773     1   0.355      0.929 0.868  0 0.132
#> GSM123777     3   0.000      0.960 0.000  0 1.000
#> GSM123779     3   0.000      0.960 0.000  0 1.000
#> GSM123782     3   0.000      0.960 0.000  0 1.000
#> GSM123786     3   0.000      0.960 0.000  0 1.000
#> GSM123789     3   0.000      0.960 0.000  0 1.000
#> GSM123793     3   0.619      0.128 0.420  0 0.580
#> GSM123797     3   0.000      0.960 0.000  0 1.000
#> GSM123729     2   0.000      1.000 0.000  1 0.000
#> GSM123733     2   0.000      1.000 0.000  1 0.000
#> GSM123737     2   0.000      1.000 0.000  1 0.000
#> GSM123741     2   0.000      1.000 0.000  1 0.000
#> GSM123747     2   0.000      1.000 0.000  1 0.000
#> GSM123753     2   0.000      1.000 0.000  1 0.000
#> GSM123759     2   0.000      1.000 0.000  1 0.000
#> GSM123766     2   0.000      1.000 0.000  1 0.000
#> GSM123772     2   0.000      1.000 0.000  1 0.000
#> GSM123775     2   0.000      1.000 0.000  1 0.000
#> GSM123781     2   0.000      1.000 0.000  1 0.000
#> GSM123785     2   0.000      1.000 0.000  1 0.000
#> GSM123788     2   0.000      1.000 0.000  1 0.000
#> GSM123792     2   0.000      1.000 0.000  1 0.000
#> GSM123796     2   0.000      1.000 0.000  1 0.000
#> GSM123731     2   0.000      1.000 0.000  1 0.000
#> GSM123735     2   0.000      1.000 0.000  1 0.000
#> GSM123739     2   0.000      1.000 0.000  1 0.000
#> GSM123743     2   0.000      1.000 0.000  1 0.000
#> GSM123749     2   0.000      1.000 0.000  1 0.000
#> GSM123755     2   0.000      1.000 0.000  1 0.000
#> GSM123768     2   0.000      1.000 0.000  1 0.000
#> GSM123776     1   0.375      0.917 0.856  0 0.144
#> GSM123783     2   0.000      1.000 0.000  1 0.000
#> GSM123790     2   0.000      1.000 0.000  1 0.000
#> GSM123794     2   0.000      1.000 0.000  1 0.000
#> GSM123798     2   0.000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM123732     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123736     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123740     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123744     3  0.4697      0.397 0.356  0 0.644 0.000
#> GSM123746     3  0.1004      0.885 0.024  0 0.972 0.004
#> GSM123750     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123752     3  0.0188      0.903 0.000  0 0.996 0.004
#> GSM123756     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123758     3  0.0188      0.903 0.000  0 0.996 0.004
#> GSM123761     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123763     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123765     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123769     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123771     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123774     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123778     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123780     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123784     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123787     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123791     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123795     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123799     3  0.0000      0.905 0.000  0 1.000 0.000
#> GSM123730     4  0.4916      0.526 0.000  0 0.424 0.576
#> GSM123734     4  0.0657      0.437 0.012  0 0.004 0.984
#> GSM123738     4  0.4925      0.517 0.000  0 0.428 0.572
#> GSM123742     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123745     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123748     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123751     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123754     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123757     1  0.5220      0.763 0.568  0 0.008 0.424
#> GSM123760     1  0.5366      0.739 0.548  0 0.012 0.440
#> GSM123762     1  0.0000      0.656 1.000  0 0.000 0.000
#> GSM123764     3  0.2973      0.750 0.000  0 0.856 0.144
#> GSM123767     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123770     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123773     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123777     4  0.4916      0.526 0.000  0 0.424 0.576
#> GSM123779     3  0.3907      0.592 0.000  0 0.768 0.232
#> GSM123782     3  0.0707      0.902 0.000  0 0.980 0.020
#> GSM123786     3  0.0469      0.904 0.000  0 0.988 0.012
#> GSM123789     3  0.4830      0.242 0.000  0 0.608 0.392
#> GSM123793     4  0.0188      0.455 0.000  0 0.004 0.996
#> GSM123797     4  0.2814      0.594 0.000  0 0.132 0.868
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123776     1  0.4933      0.768 0.568  0 0.000 0.432
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 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
#> GSM123732     3  0.2377      0.890 0.000 0.000 0.872 0.128 0.000
#> GSM123736     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123740     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123744     3  0.3661      0.590 0.000 0.000 0.724 0.000 0.276
#> GSM123746     3  0.0579      0.911 0.008 0.000 0.984 0.000 0.008
#> GSM123750     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123752     3  0.1041      0.904 0.032 0.000 0.964 0.004 0.000
#> GSM123756     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123758     3  0.0162      0.912 0.004 0.000 0.996 0.000 0.000
#> GSM123761     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123763     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123765     3  0.2280      0.893 0.000 0.000 0.880 0.120 0.000
#> GSM123769     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123771     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123774     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123778     3  0.2377      0.890 0.000 0.000 0.872 0.128 0.000
#> GSM123780     3  0.2377      0.890 0.000 0.000 0.872 0.128 0.000
#> GSM123784     3  0.2377      0.890 0.000 0.000 0.872 0.128 0.000
#> GSM123787     3  0.0162      0.913 0.000 0.000 0.996 0.004 0.000
#> GSM123791     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123795     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123799     3  0.0000      0.913 0.000 0.000 1.000 0.000 0.000
#> GSM123730     4  0.0000      0.964 0.000 0.000 0.000 1.000 0.000
#> GSM123734     1  0.0162      0.920 0.996 0.000 0.000 0.004 0.000
#> GSM123738     4  0.0404      0.957 0.000 0.000 0.012 0.988 0.000
#> GSM123742     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123745     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123748     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123751     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123754     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123757     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123760     1  0.0162      0.920 0.996 0.000 0.000 0.004 0.000
#> GSM123762     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM123764     3  0.4637      0.761 0.128 0.000 0.744 0.128 0.000
#> GSM123767     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123770     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123773     1  0.0000      0.922 1.000 0.000 0.000 0.000 0.000
#> GSM123777     4  0.0000      0.964 0.000 0.000 0.000 1.000 0.000
#> GSM123779     1  0.6455      0.219 0.500 0.000 0.236 0.264 0.000
#> GSM123782     3  0.2377      0.890 0.000 0.000 0.872 0.128 0.000
#> GSM123786     3  0.2329      0.892 0.000 0.000 0.876 0.124 0.000
#> GSM123789     1  0.5025      0.566 0.704 0.000 0.172 0.124 0.000
#> GSM123793     4  0.1851      0.869 0.088 0.000 0.000 0.912 0.000
#> GSM123797     4  0.0000      0.964 0.000 0.000 0.000 1.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123776     1  0.1484      0.862 0.944 0.048 0.000 0.008 0.000
#> GSM123783     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.1267      0.898 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM123736     3  0.1584      0.891 0.000 0.000 0.928 0.008 0.064 0.000
#> GSM123740     3  0.1584      0.891 0.000 0.000 0.928 0.008 0.064 0.000
#> GSM123744     3  0.4917      0.591 0.000 0.000 0.664 0.008 0.104 0.224
#> GSM123746     3  0.3043      0.820 0.004 0.000 0.796 0.000 0.196 0.004
#> GSM123750     3  0.3816      0.800 0.096 0.000 0.792 0.008 0.104 0.000
#> GSM123752     3  0.1584      0.890 0.008 0.000 0.928 0.000 0.064 0.000
#> GSM123756     6  0.0000      0.976 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM123758     3  0.1471      0.891 0.004 0.000 0.932 0.000 0.064 0.000
#> GSM123761     6  0.0713      0.957 0.000 0.000 0.000 0.000 0.028 0.972
#> GSM123763     5  0.3482      0.000 0.000 0.000 0.000 0.000 0.684 0.316
#> GSM123765     3  0.2136      0.903 0.000 0.000 0.904 0.048 0.048 0.000
#> GSM123769     6  0.0000      0.976 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM123771     6  0.0000      0.976 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM123774     6  0.0260      0.968 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM123778     3  0.1267      0.898 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM123780     3  0.1267      0.898 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM123784     3  0.2451      0.901 0.000 0.000 0.884 0.060 0.056 0.000
#> GSM123787     3  0.0458      0.903 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM123791     3  0.2118      0.873 0.000 0.000 0.888 0.008 0.104 0.000
#> GSM123795     3  0.1701      0.888 0.000 0.000 0.920 0.008 0.072 0.000
#> GSM123799     3  0.1462      0.893 0.000 0.000 0.936 0.008 0.056 0.000
#> GSM123730     4  0.0260      0.958 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM123734     1  0.1765      0.845 0.924 0.000 0.000 0.024 0.052 0.000
#> GSM123738     4  0.0632      0.930 0.000 0.000 0.024 0.976 0.000 0.000
#> GSM123742     1  0.0260      0.845 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM123745     1  0.0260      0.847 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM123748     1  0.0146      0.845 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123751     1  0.0000      0.846 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM123754     1  0.2762      0.821 0.804 0.000 0.000 0.000 0.196 0.000
#> GSM123757     1  0.2260      0.830 0.860 0.000 0.000 0.000 0.140 0.000
#> GSM123760     1  0.0146      0.845 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123762     6  0.0790      0.952 0.000 0.000 0.000 0.000 0.032 0.968
#> GSM123764     3  0.3368      0.801 0.116 0.000 0.820 0.060 0.004 0.000
#> GSM123767     1  0.2597      0.827 0.824 0.000 0.000 0.000 0.176 0.000
#> GSM123770     1  0.2562      0.828 0.828 0.000 0.000 0.000 0.172 0.000
#> GSM123773     1  0.2597      0.827 0.824 0.000 0.000 0.000 0.176 0.000
#> GSM123777     4  0.0260      0.958 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM123779     1  0.5911      0.256 0.464 0.000 0.296 0.240 0.000 0.000
#> GSM123782     3  0.1267      0.898 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM123786     3  0.1267      0.898 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM123789     1  0.4005      0.593 0.748 0.000 0.192 0.056 0.004 0.000
#> GSM123793     4  0.1501      0.886 0.076 0.000 0.000 0.924 0.000 0.000
#> GSM123797     4  0.0260      0.958 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123776     1  0.3481      0.775 0.792 0.048 0.000 0.000 0.160 0.000
#> GSM123783     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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) infection(p) agent(p) k
#> ATC:pam 70         6.31e-16     6.31e-16 1.30e-05 2
#> ATC:pam 70         7.72e-15     7.72e-15 8.91e-05 3
#> ATC:pam 67         1.04e-15     1.04e-15 5.81e-04 4
#> ATC:pam 70         1.17e-20     1.17e-20 8.51e-04 5
#> ATC:pam 69         2.96e-20     2.96e-20 1.03e-03 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 71 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4713 0.529   0.529
#> 3 3 1.000           0.998       0.999         0.3363 0.841   0.699
#> 4 4 1.000           0.980       0.985         0.1391 0.913   0.765
#> 5 5 0.825           0.841       0.889         0.0798 0.957   0.846
#> 6 6 0.832           0.838       0.898         0.0578 0.909   0.638

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM123732     1  0.0000      1.000 1.000 0.000
#> GSM123736     1  0.0000      1.000 1.000 0.000
#> GSM123740     1  0.0000      1.000 1.000 0.000
#> GSM123744     1  0.0000      1.000 1.000 0.000
#> GSM123746     1  0.0000      1.000 1.000 0.000
#> GSM123750     1  0.0000      1.000 1.000 0.000
#> GSM123752     1  0.0000      1.000 1.000 0.000
#> GSM123756     1  0.0000      1.000 1.000 0.000
#> GSM123758     1  0.0000      1.000 1.000 0.000
#> GSM123761     1  0.0000      1.000 1.000 0.000
#> GSM123763     1  0.0000      1.000 1.000 0.000
#> GSM123765     1  0.0000      1.000 1.000 0.000
#> GSM123769     1  0.0000      1.000 1.000 0.000
#> GSM123771     1  0.0000      1.000 1.000 0.000
#> GSM123774     1  0.0000      1.000 1.000 0.000
#> GSM123778     1  0.0000      1.000 1.000 0.000
#> GSM123780     1  0.0000      1.000 1.000 0.000
#> GSM123784     1  0.0000      1.000 1.000 0.000
#> GSM123787     1  0.0000      1.000 1.000 0.000
#> GSM123791     1  0.0000      1.000 1.000 0.000
#> GSM123795     1  0.0000      1.000 1.000 0.000
#> GSM123799     1  0.0000      1.000 1.000 0.000
#> GSM123730     1  0.0000      1.000 1.000 0.000
#> GSM123734     1  0.0000      1.000 1.000 0.000
#> GSM123738     1  0.0000      1.000 1.000 0.000
#> GSM123742     1  0.0000      1.000 1.000 0.000
#> GSM123745     1  0.0000      1.000 1.000 0.000
#> GSM123748     1  0.0000      1.000 1.000 0.000
#> GSM123751     1  0.0000      1.000 1.000 0.000
#> GSM123754     1  0.0000      1.000 1.000 0.000
#> GSM123757     1  0.0000      1.000 1.000 0.000
#> GSM123760     1  0.0000      1.000 1.000 0.000
#> GSM123762     1  0.0000      1.000 1.000 0.000
#> GSM123764     1  0.0000      1.000 1.000 0.000
#> GSM123767     1  0.0000      1.000 1.000 0.000
#> GSM123770     1  0.0000      1.000 1.000 0.000
#> GSM123773     1  0.0000      1.000 1.000 0.000
#> GSM123777     1  0.0000      1.000 1.000 0.000
#> GSM123779     1  0.0000      1.000 1.000 0.000
#> GSM123782     1  0.0000      1.000 1.000 0.000
#> GSM123786     1  0.0000      1.000 1.000 0.000
#> GSM123789     1  0.0000      1.000 1.000 0.000
#> GSM123793     1  0.0000      1.000 1.000 0.000
#> GSM123797     1  0.0000      1.000 1.000 0.000
#> GSM123729     2  0.0000      1.000 0.000 1.000
#> GSM123733     2  0.0000      1.000 0.000 1.000
#> GSM123737     2  0.0000      1.000 0.000 1.000
#> GSM123741     2  0.0000      1.000 0.000 1.000
#> GSM123747     2  0.0000      1.000 0.000 1.000
#> GSM123753     2  0.0000      1.000 0.000 1.000
#> GSM123759     2  0.0000      1.000 0.000 1.000
#> GSM123766     2  0.0000      1.000 0.000 1.000
#> GSM123772     2  0.0000      1.000 0.000 1.000
#> GSM123775     2  0.0000      1.000 0.000 1.000
#> GSM123781     2  0.0000      1.000 0.000 1.000
#> GSM123785     2  0.0000      1.000 0.000 1.000
#> GSM123788     2  0.0000      1.000 0.000 1.000
#> GSM123792     2  0.0000      1.000 0.000 1.000
#> GSM123796     2  0.0000      1.000 0.000 1.000
#> GSM123731     2  0.0000      1.000 0.000 1.000
#> GSM123735     2  0.0000      1.000 0.000 1.000
#> GSM123739     2  0.0000      1.000 0.000 1.000
#> GSM123743     2  0.0000      1.000 0.000 1.000
#> GSM123749     2  0.0000      1.000 0.000 1.000
#> GSM123755     2  0.0000      1.000 0.000 1.000
#> GSM123768     2  0.0000      1.000 0.000 1.000
#> GSM123776     1  0.0000      1.000 1.000 0.000
#> GSM123783     2  0.0376      0.996 0.004 0.996
#> GSM123790     2  0.0000      1.000 0.000 1.000
#> GSM123794     2  0.0000      1.000 0.000 1.000
#> GSM123798     2  0.0000      1.000 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
#> GSM123732     3  0.0000      0.992 0.000  0 1.000
#> GSM123736     3  0.0000      0.992 0.000  0 1.000
#> GSM123740     3  0.0000      0.992 0.000  0 1.000
#> GSM123744     1  0.0000      1.000 1.000  0 0.000
#> GSM123746     1  0.0000      1.000 1.000  0 0.000
#> GSM123750     1  0.0000      1.000 1.000  0 0.000
#> GSM123752     1  0.0000      1.000 1.000  0 0.000
#> GSM123756     1  0.0000      1.000 1.000  0 0.000
#> GSM123758     1  0.0000      1.000 1.000  0 0.000
#> GSM123761     1  0.0000      1.000 1.000  0 0.000
#> GSM123763     1  0.0000      1.000 1.000  0 0.000
#> GSM123765     3  0.0000      0.992 0.000  0 1.000
#> GSM123769     1  0.0000      1.000 1.000  0 0.000
#> GSM123771     1  0.0000      1.000 1.000  0 0.000
#> GSM123774     1  0.0000      1.000 1.000  0 0.000
#> GSM123778     3  0.0000      0.992 0.000  0 1.000
#> GSM123780     3  0.2356      0.921 0.072  0 0.928
#> GSM123784     3  0.0000      0.992 0.000  0 1.000
#> GSM123787     3  0.0000      0.992 0.000  0 1.000
#> GSM123791     3  0.0000      0.992 0.000  0 1.000
#> GSM123795     3  0.0424      0.986 0.008  0 0.992
#> GSM123799     3  0.0000      0.992 0.000  0 1.000
#> GSM123730     1  0.0000      1.000 1.000  0 0.000
#> GSM123734     1  0.0000      1.000 1.000  0 0.000
#> GSM123738     1  0.0000      1.000 1.000  0 0.000
#> GSM123742     1  0.0000      1.000 1.000  0 0.000
#> GSM123745     1  0.0000      1.000 1.000  0 0.000
#> GSM123748     1  0.0000      1.000 1.000  0 0.000
#> GSM123751     1  0.0000      1.000 1.000  0 0.000
#> GSM123754     1  0.0000      1.000 1.000  0 0.000
#> GSM123757     1  0.0000      1.000 1.000  0 0.000
#> GSM123760     1  0.0000      1.000 1.000  0 0.000
#> GSM123762     1  0.0000      1.000 1.000  0 0.000
#> GSM123764     1  0.0000      1.000 1.000  0 0.000
#> GSM123767     1  0.0000      1.000 1.000  0 0.000
#> GSM123770     1  0.0000      1.000 1.000  0 0.000
#> GSM123773     1  0.0000      1.000 1.000  0 0.000
#> GSM123777     1  0.0000      1.000 1.000  0 0.000
#> GSM123779     1  0.0000      1.000 1.000  0 0.000
#> GSM123782     1  0.0000      1.000 1.000  0 0.000
#> GSM123786     3  0.0000      0.992 0.000  0 1.000
#> GSM123789     1  0.0000      1.000 1.000  0 0.000
#> GSM123793     1  0.0000      1.000 1.000  0 0.000
#> GSM123797     1  0.0000      1.000 1.000  0 0.000
#> GSM123729     2  0.0000      1.000 0.000  1 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000
#> GSM123776     1  0.0000      1.000 1.000  0 0.000
#> GSM123783     2  0.0000      1.000 0.000  1 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1 p2    p3    p4
#> GSM123732     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123736     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123740     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123744     1  0.0336      0.961 0.992  0 0.000 0.008
#> GSM123746     1  0.0817      0.968 0.976  0 0.000 0.024
#> GSM123750     1  0.1022      0.967 0.968  0 0.000 0.032
#> GSM123752     1  0.1022      0.967 0.968  0 0.000 0.032
#> GSM123756     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123758     1  0.1022      0.967 0.968  0 0.000 0.032
#> GSM123761     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123763     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123765     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123769     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123771     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123774     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123778     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123780     3  0.1557      0.937 0.000  0 0.944 0.056
#> GSM123784     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123787     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123791     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123795     3  0.0188      0.991 0.000  0 0.996 0.004
#> GSM123799     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123730     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123734     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123738     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123742     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123745     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123748     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123751     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123754     1  0.1867      0.957 0.928  0 0.000 0.072
#> GSM123757     1  0.0817      0.968 0.976  0 0.000 0.024
#> GSM123760     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123762     1  0.0000      0.962 1.000  0 0.000 0.000
#> GSM123764     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123767     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123770     1  0.0817      0.968 0.976  0 0.000 0.024
#> GSM123773     1  0.1940      0.956 0.924  0 0.000 0.076
#> GSM123777     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123779     4  0.0707      0.962 0.020  0 0.000 0.980
#> GSM123782     4  0.2589      0.851 0.116  0 0.000 0.884
#> GSM123786     3  0.0000      0.994 0.000  0 1.000 0.000
#> GSM123789     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123793     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123797     4  0.0000      0.978 0.000  0 0.000 1.000
#> GSM123729     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123733     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123737     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123741     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123747     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123753     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123759     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123766     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123772     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123775     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123781     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123785     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123788     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123792     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123796     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123731     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123735     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123739     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123743     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123749     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123755     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123768     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123776     1  0.0817      0.968 0.976  0 0.000 0.024
#> GSM123783     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123790     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123794     2  0.0000      1.000 0.000  1 0.000 0.000
#> GSM123798     2  0.0000      1.000 0.000  1 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
#> GSM123732     3  0.0162      0.986 0.000 0.000 0.996 0.000 0.004
#> GSM123736     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123740     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123744     1  0.2230      0.784 0.884 0.000 0.000 0.116 0.000
#> GSM123746     1  0.0963      0.817 0.964 0.000 0.000 0.000 0.036
#> GSM123750     1  0.3242      0.773 0.844 0.000 0.000 0.116 0.040
#> GSM123752     1  0.1364      0.817 0.952 0.000 0.000 0.012 0.036
#> GSM123756     1  0.0000      0.812 1.000 0.000 0.000 0.000 0.000
#> GSM123758     1  0.1364      0.817 0.952 0.000 0.000 0.012 0.036
#> GSM123761     1  0.0000      0.812 1.000 0.000 0.000 0.000 0.000
#> GSM123763     1  0.2230      0.784 0.884 0.000 0.000 0.116 0.000
#> GSM123765     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123769     1  0.0000      0.812 1.000 0.000 0.000 0.000 0.000
#> GSM123771     1  0.0000      0.812 1.000 0.000 0.000 0.000 0.000
#> GSM123774     1  0.0510      0.816 0.984 0.000 0.000 0.000 0.016
#> GSM123778     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123780     3  0.2291      0.886 0.000 0.000 0.908 0.036 0.056
#> GSM123784     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123787     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123791     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123795     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123799     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123730     4  0.3857      0.976 0.000 0.000 0.000 0.688 0.312
#> GSM123734     1  0.6783     -0.196 0.388 0.000 0.000 0.296 0.316
#> GSM123738     4  0.3752      0.966 0.000 0.000 0.000 0.708 0.292
#> GSM123742     1  0.6783     -0.196 0.388 0.000 0.000 0.296 0.316
#> GSM123745     5  0.0290      0.979 0.008 0.000 0.000 0.000 0.992
#> GSM123748     5  0.0000      0.981 0.000 0.000 0.000 0.000 1.000
#> GSM123751     5  0.0000      0.981 0.000 0.000 0.000 0.000 1.000
#> GSM123754     5  0.0880      0.935 0.032 0.000 0.000 0.000 0.968
#> GSM123757     1  0.1197      0.815 0.952 0.000 0.000 0.000 0.048
#> GSM123760     1  0.6820     -0.307 0.352 0.000 0.000 0.332 0.316
#> GSM123762     1  0.2230      0.784 0.884 0.000 0.000 0.116 0.000
#> GSM123764     4  0.3876      0.975 0.000 0.000 0.000 0.684 0.316
#> GSM123767     5  0.0162      0.983 0.004 0.000 0.000 0.000 0.996
#> GSM123770     1  0.3210      0.698 0.788 0.000 0.000 0.000 0.212
#> GSM123773     5  0.0162      0.983 0.004 0.000 0.000 0.000 0.996
#> GSM123777     4  0.3837      0.975 0.000 0.000 0.000 0.692 0.308
#> GSM123779     4  0.3876      0.975 0.000 0.000 0.000 0.684 0.316
#> GSM123782     4  0.4522      0.941 0.024 0.000 0.000 0.660 0.316
#> GSM123786     3  0.0000      0.990 0.000 0.000 1.000 0.000 0.000
#> GSM123789     4  0.3876      0.975 0.000 0.000 0.000 0.684 0.316
#> GSM123793     4  0.3752      0.966 0.000 0.000 0.000 0.708 0.292
#> GSM123797     4  0.3752      0.966 0.000 0.000 0.000 0.708 0.292
#> GSM123729     2  0.5659      0.714 0.116 0.604 0.000 0.280 0.000
#> GSM123733     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123737     2  0.4219      0.813 0.116 0.780 0.000 0.104 0.000
#> GSM123741     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123747     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123753     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123759     2  0.3586      0.808 0.000 0.736 0.000 0.264 0.000
#> GSM123766     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123772     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123775     2  0.5659      0.714 0.116 0.604 0.000 0.280 0.000
#> GSM123781     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123785     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123788     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123792     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123796     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123731     2  0.2773      0.853 0.000 0.836 0.000 0.164 0.000
#> GSM123735     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123739     2  0.4457      0.807 0.116 0.760 0.000 0.124 0.000
#> GSM123743     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123749     2  0.3366      0.825 0.000 0.768 0.000 0.232 0.000
#> GSM123755     2  0.2891      0.849 0.000 0.824 0.000 0.176 0.000
#> GSM123768     2  0.3684      0.799 0.000 0.720 0.000 0.280 0.000
#> GSM123776     1  0.1197      0.815 0.952 0.000 0.000 0.000 0.048
#> GSM123783     2  0.5659      0.714 0.116 0.604 0.000 0.280 0.000
#> GSM123790     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123794     2  0.0000      0.894 0.000 1.000 0.000 0.000 0.000
#> GSM123798     2  0.3684      0.799 0.000 0.720 0.000 0.280 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
#> GSM123732     3  0.0146     0.9565 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM123736     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123740     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123744     1  0.1821     0.8960 0.928 0.000 0.000 0.040 0.024 0.008
#> GSM123746     1  0.2146     0.8970 0.880 0.000 0.000 0.000 0.116 0.004
#> GSM123750     1  0.3560     0.8717 0.816 0.000 0.004 0.056 0.116 0.008
#> GSM123752     1  0.2573     0.8932 0.856 0.000 0.004 0.000 0.132 0.008
#> GSM123756     1  0.0547     0.8860 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM123758     1  0.2876     0.8917 0.844 0.000 0.016 0.000 0.132 0.008
#> GSM123761     1  0.0520     0.8901 0.984 0.000 0.000 0.000 0.008 0.008
#> GSM123763     1  0.1826     0.8861 0.924 0.000 0.000 0.052 0.020 0.004
#> GSM123765     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123769     1  0.0547     0.8860 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM123771     1  0.0547     0.8860 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM123774     1  0.2039     0.9033 0.904 0.000 0.000 0.000 0.076 0.020
#> GSM123778     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123780     3  0.4934     0.4244 0.000 0.000 0.628 0.264 0.108 0.000
#> GSM123784     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123787     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123791     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123795     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123799     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123730     4  0.1007     0.9025 0.000 0.000 0.000 0.956 0.044 0.000
#> GSM123734     4  0.3141     0.8276 0.012 0.000 0.000 0.788 0.200 0.000
#> GSM123738     4  0.0000     0.8796 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123742     4  0.3333     0.8247 0.024 0.000 0.000 0.784 0.192 0.000
#> GSM123745     5  0.0820     0.9447 0.012 0.000 0.000 0.016 0.972 0.000
#> GSM123748     5  0.0458     0.9443 0.000 0.000 0.000 0.016 0.984 0.000
#> GSM123751     5  0.0458     0.9443 0.000 0.000 0.000 0.016 0.984 0.000
#> GSM123754     5  0.1168     0.9300 0.028 0.000 0.000 0.016 0.956 0.000
#> GSM123757     1  0.3068     0.8830 0.840 0.000 0.000 0.016 0.124 0.020
#> GSM123760     4  0.2946     0.8503 0.012 0.000 0.000 0.812 0.176 0.000
#> GSM123762     1  0.1826     0.8861 0.924 0.000 0.000 0.052 0.020 0.004
#> GSM123764     4  0.1663     0.9073 0.000 0.000 0.000 0.912 0.088 0.000
#> GSM123767     5  0.2980     0.7357 0.008 0.000 0.000 0.192 0.800 0.000
#> GSM123770     1  0.3231     0.8347 0.784 0.000 0.000 0.016 0.200 0.000
#> GSM123773     5  0.0717     0.9457 0.008 0.000 0.000 0.016 0.976 0.000
#> GSM123777     4  0.0713     0.8965 0.000 0.000 0.000 0.972 0.028 0.000
#> GSM123779     4  0.1663     0.9079 0.000 0.000 0.000 0.912 0.088 0.000
#> GSM123782     4  0.2053     0.8997 0.000 0.000 0.004 0.888 0.108 0.000
#> GSM123786     3  0.0000     0.9609 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM123789     4  0.1910     0.9005 0.000 0.000 0.000 0.892 0.108 0.000
#> GSM123793     4  0.0000     0.8796 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123797     4  0.0000     0.8796 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM123729     6  0.0713     0.7848 0.000 0.028 0.000 0.000 0.000 0.972
#> GSM123733     2  0.0000     0.8547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123737     2  0.3810     0.1930 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM123741     2  0.1814     0.8671 0.000 0.900 0.000 0.000 0.000 0.100
#> GSM123747     2  0.1714     0.8677 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM123753     2  0.1863     0.8653 0.000 0.896 0.000 0.000 0.000 0.104
#> GSM123759     6  0.2969     0.7589 0.000 0.224 0.000 0.000 0.000 0.776
#> GSM123766     2  0.0146     0.8539 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123772     2  0.0146     0.8539 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123775     6  0.0858     0.7841 0.004 0.028 0.000 0.000 0.000 0.968
#> GSM123781     2  0.1327     0.8692 0.000 0.936 0.000 0.000 0.000 0.064
#> GSM123785     2  0.0146     0.8539 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM123788     2  0.0000     0.8547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123792     2  0.1863     0.8653 0.000 0.896 0.000 0.000 0.000 0.104
#> GSM123796     2  0.0000     0.8547 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM123731     6  0.3782     0.4509 0.000 0.412 0.000 0.000 0.000 0.588
#> GSM123735     2  0.1714     0.8677 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM123739     2  0.3868    -0.0986 0.000 0.508 0.000 0.000 0.000 0.492
#> GSM123743     2  0.1714     0.8677 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM123749     6  0.3198     0.7214 0.000 0.260 0.000 0.000 0.000 0.740
#> GSM123755     6  0.3804     0.4261 0.000 0.424 0.000 0.000 0.000 0.576
#> GSM123768     6  0.1700     0.7975 0.004 0.080 0.000 0.000 0.000 0.916
#> GSM123776     1  0.3068     0.8830 0.840 0.000 0.000 0.016 0.124 0.020
#> GSM123783     6  0.1168     0.7795 0.016 0.028 0.000 0.000 0.000 0.956
#> GSM123790     2  0.2092     0.8525 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM123794     2  0.2416     0.8267 0.000 0.844 0.000 0.000 0.000 0.156
#> GSM123798     6  0.2178     0.7963 0.000 0.132 0.000 0.000 0.000 0.868

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) infection(p) agent(p) k
#> ATC:mclust 71         3.04e-15     3.04e-15 5.99e-05 2
#> ATC:mclust 71         1.36e-17     1.36e-17 7.83e-05 3
#> ATC:mclust 71         2.80e-18     2.80e-18 2.74e-04 4
#> ATC:mclust 68         4.03e-20     4.03e-20 1.28e-03 5
#> ATC:mclust 66         1.85e-18     1.85e-18 2.27e-03 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 71 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 1.000           0.952       0.983         0.4914 0.505   0.505
#> 3 3 0.816           0.847       0.916         0.3444 0.776   0.582
#> 4 4 0.757           0.808       0.886         0.1114 0.862   0.628
#> 5 5 0.771           0.705       0.831         0.0496 0.960   0.854
#> 6 6 0.821           0.743       0.851         0.0270 0.959   0.837

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
#> GSM123732     1  0.0376    0.99094 0.996 0.004
#> GSM123736     1  0.0000    0.99345 1.000 0.000
#> GSM123740     1  0.0000    0.99345 1.000 0.000
#> GSM123744     1  0.0000    0.99345 1.000 0.000
#> GSM123746     1  0.0000    0.99345 1.000 0.000
#> GSM123750     1  0.0000    0.99345 1.000 0.000
#> GSM123752     1  0.0000    0.99345 1.000 0.000
#> GSM123756     1  0.0000    0.99345 1.000 0.000
#> GSM123758     1  0.0000    0.99345 1.000 0.000
#> GSM123761     1  0.0000    0.99345 1.000 0.000
#> GSM123763     1  0.0000    0.99345 1.000 0.000
#> GSM123765     1  0.0000    0.99345 1.000 0.000
#> GSM123769     1  0.0000    0.99345 1.000 0.000
#> GSM123771     1  0.0000    0.99345 1.000 0.000
#> GSM123774     1  0.0000    0.99345 1.000 0.000
#> GSM123778     1  0.0376    0.99094 0.996 0.004
#> GSM123780     1  0.0672    0.98763 0.992 0.008
#> GSM123784     1  0.0000    0.99345 1.000 0.000
#> GSM123787     1  0.0000    0.99345 1.000 0.000
#> GSM123791     1  0.0000    0.99345 1.000 0.000
#> GSM123795     1  0.0000    0.99345 1.000 0.000
#> GSM123799     1  0.0000    0.99345 1.000 0.000
#> GSM123730     2  0.0000    0.96583 0.000 1.000
#> GSM123734     1  0.0000    0.99345 1.000 0.000
#> GSM123738     1  0.0000    0.99345 1.000 0.000
#> GSM123742     1  0.0000    0.99345 1.000 0.000
#> GSM123745     1  0.0000    0.99345 1.000 0.000
#> GSM123748     1  0.0000    0.99345 1.000 0.000
#> GSM123751     1  0.0000    0.99345 1.000 0.000
#> GSM123754     1  0.0000    0.99345 1.000 0.000
#> GSM123757     1  0.0000    0.99345 1.000 0.000
#> GSM123760     1  0.0000    0.99345 1.000 0.000
#> GSM123762     1  0.0000    0.99345 1.000 0.000
#> GSM123764     1  0.0672    0.98763 0.992 0.008
#> GSM123767     2  0.9977    0.11506 0.472 0.528
#> GSM123770     1  0.0000    0.99345 1.000 0.000
#> GSM123773     1  0.0000    0.99345 1.000 0.000
#> GSM123777     2  1.0000    0.00876 0.500 0.500
#> GSM123779     1  0.1843    0.96780 0.972 0.028
#> GSM123782     1  0.6973    0.76007 0.812 0.188
#> GSM123786     1  0.0376    0.99094 0.996 0.004
#> GSM123789     1  0.0000    0.99345 1.000 0.000
#> GSM123793     1  0.0376    0.99094 0.996 0.004
#> GSM123797     1  0.0376    0.99094 0.996 0.004
#> GSM123729     2  0.0000    0.96583 0.000 1.000
#> GSM123733     2  0.0000    0.96583 0.000 1.000
#> GSM123737     2  0.0000    0.96583 0.000 1.000
#> GSM123741     2  0.0000    0.96583 0.000 1.000
#> GSM123747     2  0.0000    0.96583 0.000 1.000
#> GSM123753     2  0.0000    0.96583 0.000 1.000
#> GSM123759     2  0.0000    0.96583 0.000 1.000
#> GSM123766     2  0.0000    0.96583 0.000 1.000
#> GSM123772     2  0.0000    0.96583 0.000 1.000
#> GSM123775     2  0.0000    0.96583 0.000 1.000
#> GSM123781     2  0.0000    0.96583 0.000 1.000
#> GSM123785     2  0.0000    0.96583 0.000 1.000
#> GSM123788     2  0.0000    0.96583 0.000 1.000
#> GSM123792     2  0.0000    0.96583 0.000 1.000
#> GSM123796     2  0.0000    0.96583 0.000 1.000
#> GSM123731     2  0.0000    0.96583 0.000 1.000
#> GSM123735     2  0.0000    0.96583 0.000 1.000
#> GSM123739     2  0.0000    0.96583 0.000 1.000
#> GSM123743     2  0.0000    0.96583 0.000 1.000
#> GSM123749     2  0.0000    0.96583 0.000 1.000
#> GSM123755     2  0.0000    0.96583 0.000 1.000
#> GSM123768     2  0.0000    0.96583 0.000 1.000
#> GSM123776     2  0.0000    0.96583 0.000 1.000
#> GSM123783     2  0.0000    0.96583 0.000 1.000
#> GSM123790     2  0.0000    0.96583 0.000 1.000
#> GSM123794     2  0.0000    0.96583 0.000 1.000
#> GSM123798     2  0.0000    0.96583 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
#> GSM123732     3  0.5115     0.7202 0.228 0.004 0.768
#> GSM123736     3  0.2878     0.8412 0.096 0.000 0.904
#> GSM123740     3  0.6225     0.3414 0.432 0.000 0.568
#> GSM123744     1  0.1964     0.9271 0.944 0.000 0.056
#> GSM123746     1  0.1411     0.9311 0.964 0.000 0.036
#> GSM123750     1  0.2261     0.9206 0.932 0.000 0.068
#> GSM123752     1  0.0983     0.9026 0.980 0.016 0.004
#> GSM123756     1  0.1411     0.9311 0.964 0.000 0.036
#> GSM123758     1  0.1636     0.9044 0.964 0.020 0.016
#> GSM123761     1  0.1529     0.9315 0.960 0.000 0.040
#> GSM123763     1  0.2448     0.9149 0.924 0.000 0.076
#> GSM123765     3  0.1860     0.8518 0.052 0.000 0.948
#> GSM123769     1  0.1643     0.9312 0.956 0.000 0.044
#> GSM123771     1  0.1163     0.9283 0.972 0.000 0.028
#> GSM123774     1  0.0475     0.9112 0.992 0.004 0.004
#> GSM123778     3  0.4575     0.7711 0.184 0.004 0.812
#> GSM123780     3  0.1267     0.8467 0.004 0.024 0.972
#> GSM123784     3  0.2165     0.8499 0.064 0.000 0.936
#> GSM123787     3  0.2959     0.8381 0.100 0.000 0.900
#> GSM123791     3  0.6299     0.2075 0.476 0.000 0.524
#> GSM123795     3  0.2356     0.8490 0.072 0.000 0.928
#> GSM123799     3  0.5968     0.5039 0.364 0.000 0.636
#> GSM123730     3  0.2066     0.8227 0.000 0.060 0.940
#> GSM123734     3  0.1289     0.8523 0.032 0.000 0.968
#> GSM123738     3  0.1315     0.8478 0.008 0.020 0.972
#> GSM123742     3  0.2356     0.8491 0.072 0.000 0.928
#> GSM123745     1  0.6386     0.2856 0.584 0.004 0.412
#> GSM123748     3  0.6308     0.0793 0.492 0.000 0.508
#> GSM123751     3  0.3816     0.8058 0.148 0.000 0.852
#> GSM123754     1  0.4796     0.7198 0.780 0.000 0.220
#> GSM123757     1  0.1163     0.9287 0.972 0.000 0.028
#> GSM123760     3  0.1643     0.8522 0.044 0.000 0.956
#> GSM123762     1  0.2448     0.9149 0.924 0.000 0.076
#> GSM123764     3  0.1399     0.8453 0.004 0.028 0.968
#> GSM123767     3  0.2878     0.7942 0.000 0.096 0.904
#> GSM123770     1  0.1643     0.9312 0.956 0.000 0.044
#> GSM123773     3  0.5024     0.6969 0.220 0.004 0.776
#> GSM123777     3  0.1643     0.8348 0.000 0.044 0.956
#> GSM123779     3  0.1647     0.8398 0.004 0.036 0.960
#> GSM123782     3  0.1289     0.8416 0.000 0.032 0.968
#> GSM123786     3  0.3715     0.8190 0.128 0.004 0.868
#> GSM123789     3  0.1289     0.8523 0.032 0.000 0.968
#> GSM123793     3  0.1399     0.8441 0.004 0.028 0.968
#> GSM123797     3  0.1399     0.8441 0.004 0.028 0.968
#> GSM123729     2  0.1031     0.9541 0.024 0.976 0.000
#> GSM123733     2  0.1411     0.9603 0.000 0.964 0.036
#> GSM123737     2  0.0747     0.9584 0.016 0.984 0.000
#> GSM123741     2  0.0747     0.9644 0.000 0.984 0.016
#> GSM123747     2  0.1031     0.9644 0.000 0.976 0.024
#> GSM123753     2  0.1031     0.9644 0.000 0.976 0.024
#> GSM123759     2  0.0592     0.9598 0.012 0.988 0.000
#> GSM123766     2  0.1860     0.9503 0.000 0.948 0.052
#> GSM123772     2  0.1289     0.9620 0.000 0.968 0.032
#> GSM123775     2  0.1289     0.9495 0.032 0.968 0.000
#> GSM123781     2  0.1163     0.9634 0.000 0.972 0.028
#> GSM123785     2  0.1860     0.9503 0.000 0.948 0.052
#> GSM123788     2  0.1163     0.9634 0.000 0.972 0.028
#> GSM123792     2  0.1031     0.9644 0.000 0.976 0.024
#> GSM123796     2  0.1411     0.9603 0.000 0.964 0.036
#> GSM123731     2  0.0237     0.9618 0.004 0.996 0.000
#> GSM123735     2  0.1031     0.9644 0.000 0.976 0.024
#> GSM123739     2  0.0747     0.9584 0.016 0.984 0.000
#> GSM123743     2  0.0892     0.9645 0.000 0.980 0.020
#> GSM123749     2  0.0747     0.9584 0.016 0.984 0.000
#> GSM123755     2  0.0000     0.9624 0.000 1.000 0.000
#> GSM123768     2  0.1267     0.9527 0.024 0.972 0.004
#> GSM123776     2  0.6204     0.3129 0.424 0.576 0.000
#> GSM123783     2  0.0829     0.9589 0.012 0.984 0.004
#> GSM123790     2  0.1529     0.9583 0.000 0.960 0.040
#> GSM123794     2  0.1031     0.9644 0.000 0.976 0.024
#> GSM123798     2  0.0747     0.9584 0.016 0.984 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM123732     3  0.0927      0.843 0.000 0.016 0.976 0.008
#> GSM123736     3  0.1151      0.855 0.008 0.000 0.968 0.024
#> GSM123740     3  0.0524      0.856 0.004 0.000 0.988 0.008
#> GSM123744     3  0.4222      0.542 0.272 0.000 0.728 0.000
#> GSM123746     1  0.2530      0.856 0.896 0.000 0.100 0.004
#> GSM123750     3  0.3074      0.738 0.152 0.000 0.848 0.000
#> GSM123752     1  0.4551      0.802 0.796 0.004 0.156 0.044
#> GSM123756     1  0.1211      0.869 0.960 0.000 0.040 0.000
#> GSM123758     3  0.8052      0.314 0.220 0.144 0.568 0.068
#> GSM123761     1  0.3052      0.839 0.860 0.000 0.136 0.004
#> GSM123763     1  0.4632      0.611 0.688 0.000 0.308 0.004
#> GSM123765     3  0.1109      0.855 0.004 0.000 0.968 0.028
#> GSM123769     1  0.1398      0.869 0.956 0.000 0.040 0.004
#> GSM123771     1  0.0817      0.866 0.976 0.000 0.024 0.000
#> GSM123774     1  0.0712      0.854 0.984 0.008 0.004 0.004
#> GSM123778     3  0.0937      0.844 0.000 0.012 0.976 0.012
#> GSM123780     3  0.1732      0.847 0.008 0.004 0.948 0.040
#> GSM123784     3  0.1256      0.854 0.008 0.000 0.964 0.028
#> GSM123787     3  0.0000      0.853 0.000 0.000 1.000 0.000
#> GSM123791     3  0.1042      0.856 0.008 0.000 0.972 0.020
#> GSM123795     3  0.1545      0.849 0.008 0.000 0.952 0.040
#> GSM123799     3  0.0524      0.856 0.004 0.000 0.988 0.008
#> GSM123730     4  0.2660      0.755 0.000 0.056 0.036 0.908
#> GSM123734     4  0.3659      0.784 0.024 0.000 0.136 0.840
#> GSM123738     4  0.5050      0.406 0.000 0.004 0.408 0.588
#> GSM123742     4  0.5949      0.623 0.068 0.000 0.288 0.644
#> GSM123745     4  0.4193      0.609 0.268 0.000 0.000 0.732
#> GSM123748     4  0.5273      0.235 0.456 0.000 0.008 0.536
#> GSM123751     4  0.4277      0.606 0.280 0.000 0.000 0.720
#> GSM123754     1  0.4456      0.501 0.716 0.000 0.004 0.280
#> GSM123757     1  0.0657      0.862 0.984 0.000 0.012 0.004
#> GSM123760     4  0.4818      0.731 0.036 0.000 0.216 0.748
#> GSM123762     1  0.3626      0.798 0.812 0.000 0.184 0.004
#> GSM123764     3  0.4872      0.345 0.004 0.000 0.640 0.356
#> GSM123767     4  0.3051      0.709 0.028 0.088 0.000 0.884
#> GSM123770     1  0.0707      0.852 0.980 0.000 0.000 0.020
#> GSM123773     4  0.3172      0.702 0.160 0.000 0.000 0.840
#> GSM123777     4  0.3852      0.755 0.000 0.008 0.192 0.800
#> GSM123779     4  0.3280      0.782 0.000 0.016 0.124 0.860
#> GSM123782     3  0.4392      0.641 0.004 0.012 0.768 0.216
#> GSM123786     3  0.0336      0.851 0.000 0.008 0.992 0.000
#> GSM123789     3  0.4914      0.459 0.012 0.000 0.676 0.312
#> GSM123793     4  0.3208      0.779 0.000 0.004 0.148 0.848
#> GSM123797     4  0.3355      0.775 0.000 0.004 0.160 0.836
#> GSM123729     2  0.1042      0.952 0.008 0.972 0.000 0.020
#> GSM123733     2  0.2149      0.936 0.000 0.912 0.000 0.088
#> GSM123737     2  0.1545      0.955 0.008 0.952 0.000 0.040
#> GSM123741     2  0.1118      0.956 0.000 0.964 0.000 0.036
#> GSM123747     2  0.0564      0.958 0.004 0.988 0.004 0.004
#> GSM123753     2  0.0188      0.958 0.000 0.996 0.004 0.000
#> GSM123759     2  0.0804      0.954 0.000 0.980 0.008 0.012
#> GSM123766     2  0.3219      0.871 0.000 0.836 0.000 0.164
#> GSM123772     2  0.1867      0.945 0.000 0.928 0.000 0.072
#> GSM123775     2  0.0937      0.954 0.012 0.976 0.000 0.012
#> GSM123781     2  0.1474      0.953 0.000 0.948 0.000 0.052
#> GSM123785     2  0.3402      0.869 0.004 0.832 0.000 0.164
#> GSM123788     2  0.2011      0.941 0.000 0.920 0.000 0.080
#> GSM123792     2  0.0376      0.959 0.000 0.992 0.004 0.004
#> GSM123796     2  0.1474      0.953 0.000 0.948 0.000 0.052
#> GSM123731     2  0.0188      0.958 0.000 0.996 0.000 0.004
#> GSM123735     2  0.0336      0.959 0.000 0.992 0.000 0.008
#> GSM123739     2  0.1888      0.952 0.016 0.940 0.000 0.044
#> GSM123743     2  0.0921      0.957 0.000 0.972 0.000 0.028
#> GSM123749     2  0.0188      0.958 0.000 0.996 0.000 0.004
#> GSM123755     2  0.0376      0.957 0.000 0.992 0.004 0.004
#> GSM123768     2  0.2722      0.907 0.000 0.904 0.032 0.064
#> GSM123776     1  0.2799      0.767 0.884 0.108 0.000 0.008
#> GSM123783     2  0.3189      0.895 0.004 0.888 0.048 0.060
#> GSM123790     2  0.1743      0.952 0.004 0.940 0.000 0.056
#> GSM123794     2  0.0524      0.958 0.004 0.988 0.008 0.000
#> GSM123798     2  0.0779      0.954 0.000 0.980 0.004 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
#> GSM123732     3  0.1894      0.763 0.000 0.008 0.920 0.000 0.072
#> GSM123736     3  0.2970      0.761 0.000 0.000 0.828 0.004 0.168
#> GSM123740     3  0.2020      0.787 0.000 0.000 0.900 0.000 0.100
#> GSM123744     3  0.6361      0.172 0.176 0.000 0.484 0.000 0.340
#> GSM123746     1  0.1597      0.757 0.940 0.000 0.012 0.000 0.048
#> GSM123750     3  0.4888      0.614 0.064 0.000 0.700 0.004 0.232
#> GSM123752     1  0.6015      0.336 0.584 0.004 0.268 0.000 0.144
#> GSM123756     1  0.2017      0.752 0.912 0.000 0.008 0.000 0.080
#> GSM123758     3  0.5985      0.487 0.096 0.044 0.656 0.000 0.204
#> GSM123761     1  0.4421      0.502 0.704 0.000 0.024 0.004 0.268
#> GSM123763     5  0.6189      0.448 0.216 0.000 0.188 0.008 0.588
#> GSM123765     3  0.3016      0.773 0.000 0.000 0.848 0.020 0.132
#> GSM123769     1  0.3087      0.698 0.836 0.000 0.008 0.004 0.152
#> GSM123771     1  0.0963      0.768 0.964 0.000 0.000 0.000 0.036
#> GSM123774     1  0.0162      0.769 0.996 0.000 0.000 0.000 0.004
#> GSM123778     3  0.1557      0.772 0.000 0.008 0.940 0.000 0.052
#> GSM123780     3  0.2446      0.781 0.000 0.000 0.900 0.044 0.056
#> GSM123784     3  0.2873      0.777 0.000 0.000 0.860 0.020 0.120
#> GSM123787     3  0.0510      0.789 0.000 0.000 0.984 0.000 0.016
#> GSM123791     3  0.4151      0.564 0.004 0.000 0.652 0.000 0.344
#> GSM123795     3  0.3724      0.724 0.000 0.000 0.776 0.020 0.204
#> GSM123799     3  0.0404      0.790 0.000 0.000 0.988 0.000 0.012
#> GSM123730     4  0.1913      0.627 0.000 0.024 0.020 0.936 0.020
#> GSM123734     4  0.3278      0.631 0.000 0.000 0.020 0.824 0.156
#> GSM123738     4  0.5714      0.288 0.000 0.000 0.312 0.580 0.108
#> GSM123742     4  0.5586      0.266 0.012 0.000 0.044 0.480 0.464
#> GSM123745     4  0.5405      0.514 0.204 0.000 0.000 0.660 0.136
#> GSM123748     4  0.6649      0.378 0.192 0.000 0.012 0.512 0.284
#> GSM123751     4  0.4647      0.598 0.092 0.000 0.000 0.736 0.172
#> GSM123754     1  0.4235      0.366 0.656 0.000 0.000 0.336 0.008
#> GSM123757     1  0.3008      0.723 0.868 0.000 0.004 0.036 0.092
#> GSM123760     4  0.5001      0.499 0.004 0.000 0.036 0.620 0.340
#> GSM123762     5  0.5673      0.214 0.388 0.000 0.056 0.012 0.544
#> GSM123764     4  0.5757      0.315 0.000 0.000 0.088 0.496 0.416
#> GSM123767     4  0.1299      0.630 0.008 0.020 0.000 0.960 0.012
#> GSM123770     1  0.1106      0.768 0.964 0.000 0.000 0.024 0.012
#> GSM123773     4  0.3531      0.559 0.152 0.016 0.000 0.820 0.012
#> GSM123777     4  0.4677      0.482 0.000 0.008 0.204 0.732 0.056
#> GSM123779     4  0.2353      0.632 0.000 0.004 0.060 0.908 0.028
#> GSM123782     4  0.6651      0.203 0.000 0.000 0.256 0.444 0.300
#> GSM123786     3  0.2280      0.737 0.000 0.000 0.880 0.000 0.120
#> GSM123789     5  0.6261     -0.252 0.000 0.000 0.156 0.356 0.488
#> GSM123793     4  0.3291      0.645 0.000 0.000 0.064 0.848 0.088
#> GSM123797     4  0.3134      0.602 0.000 0.000 0.120 0.848 0.032
#> GSM123729     2  0.0703      0.953 0.000 0.976 0.000 0.000 0.024
#> GSM123733     2  0.1965      0.934 0.000 0.924 0.000 0.052 0.024
#> GSM123737     2  0.1386      0.946 0.000 0.952 0.000 0.032 0.016
#> GSM123741     2  0.0693      0.955 0.000 0.980 0.000 0.008 0.012
#> GSM123747     2  0.0566      0.954 0.000 0.984 0.004 0.000 0.012
#> GSM123753     2  0.0880      0.951 0.000 0.968 0.000 0.000 0.032
#> GSM123759     2  0.1502      0.942 0.000 0.940 0.004 0.000 0.056
#> GSM123766     2  0.1579      0.949 0.000 0.944 0.000 0.024 0.032
#> GSM123772     2  0.1082      0.955 0.000 0.964 0.000 0.008 0.028
#> GSM123775     2  0.0703      0.952 0.000 0.976 0.000 0.000 0.024
#> GSM123781     2  0.2733      0.908 0.000 0.872 0.004 0.012 0.112
#> GSM123785     2  0.2171      0.926 0.000 0.912 0.000 0.064 0.024
#> GSM123788     2  0.1725      0.941 0.000 0.936 0.000 0.044 0.020
#> GSM123792     2  0.0290      0.954 0.000 0.992 0.000 0.000 0.008
#> GSM123796     2  0.1399      0.947 0.000 0.952 0.000 0.028 0.020
#> GSM123731     2  0.0290      0.954 0.000 0.992 0.000 0.000 0.008
#> GSM123735     2  0.0579      0.954 0.000 0.984 0.000 0.008 0.008
#> GSM123739     2  0.1386      0.946 0.000 0.952 0.000 0.032 0.016
#> GSM123743     2  0.0566      0.954 0.000 0.984 0.000 0.004 0.012
#> GSM123749     2  0.1124      0.949 0.000 0.960 0.004 0.000 0.036
#> GSM123755     2  0.1502      0.942 0.000 0.940 0.004 0.000 0.056
#> GSM123768     2  0.3656      0.824 0.000 0.800 0.032 0.000 0.168
#> GSM123776     1  0.2536      0.650 0.868 0.128 0.000 0.000 0.004
#> GSM123783     2  0.2864      0.879 0.000 0.852 0.012 0.000 0.136
#> GSM123790     2  0.2390      0.913 0.000 0.896 0.000 0.084 0.020
#> GSM123794     2  0.0290      0.954 0.000 0.992 0.000 0.000 0.008
#> GSM123798     2  0.1502      0.942 0.000 0.940 0.004 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM123732     3  0.1269      0.806 0.000 0.000 0.956 0.020 0.012 0.012
#> GSM123736     3  0.3321      0.779 0.000 0.000 0.820 0.080 0.100 0.000
#> GSM123740     3  0.1616      0.810 0.000 0.000 0.932 0.020 0.048 0.000
#> GSM123744     5  0.4859      0.319 0.084 0.000 0.304 0.000 0.612 0.000
#> GSM123746     1  0.1082      0.771 0.956 0.000 0.040 0.000 0.004 0.000
#> GSM123750     3  0.5377      0.473 0.036 0.000 0.608 0.000 0.288 0.068
#> GSM123752     1  0.5391      0.131 0.516 0.000 0.400 0.004 0.012 0.068
#> GSM123756     1  0.1663      0.764 0.912 0.000 0.000 0.000 0.088 0.000
#> GSM123758     3  0.4924      0.575 0.144 0.000 0.720 0.012 0.020 0.104
#> GSM123761     5  0.4067      0.107 0.444 0.000 0.008 0.000 0.548 0.000
#> GSM123763     5  0.1275      0.617 0.012 0.000 0.016 0.000 0.956 0.016
#> GSM123765     3  0.3092      0.785 0.000 0.000 0.836 0.104 0.060 0.000
#> GSM123769     1  0.2969      0.625 0.776 0.000 0.000 0.000 0.224 0.000
#> GSM123771     1  0.0632      0.785 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM123774     1  0.0146      0.785 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM123778     3  0.0881      0.806 0.000 0.000 0.972 0.008 0.012 0.008
#> GSM123780     3  0.2092      0.789 0.000 0.000 0.876 0.124 0.000 0.000
#> GSM123784     3  0.3017      0.756 0.000 0.000 0.816 0.164 0.020 0.000
#> GSM123787     3  0.1624      0.799 0.000 0.000 0.936 0.004 0.020 0.040
#> GSM123791     3  0.4098      0.150 0.000 0.000 0.496 0.000 0.496 0.008
#> GSM123795     3  0.4024      0.718 0.000 0.000 0.744 0.072 0.184 0.000
#> GSM123799     3  0.0951      0.810 0.000 0.000 0.968 0.004 0.020 0.008
#> GSM123730     4  0.1265      0.709 0.000 0.000 0.008 0.948 0.000 0.044
#> GSM123734     4  0.4344      0.187 0.000 0.000 0.000 0.612 0.032 0.356
#> GSM123738     4  0.3559      0.614 0.000 0.000 0.240 0.744 0.012 0.004
#> GSM123742     6  0.4294      0.693 0.000 0.000 0.000 0.048 0.280 0.672
#> GSM123745     6  0.4945      0.511 0.084 0.000 0.000 0.328 0.000 0.588
#> GSM123748     6  0.4321      0.739 0.008 0.000 0.000 0.140 0.108 0.744
#> GSM123751     6  0.4456      0.487 0.028 0.000 0.000 0.372 0.004 0.596
#> GSM123754     1  0.3018      0.680 0.816 0.000 0.000 0.168 0.004 0.012
#> GSM123757     1  0.2584      0.718 0.848 0.000 0.000 0.004 0.004 0.144
#> GSM123760     6  0.4945      0.676 0.000 0.000 0.000 0.084 0.328 0.588
#> GSM123762     5  0.1364      0.619 0.020 0.000 0.012 0.000 0.952 0.016
#> GSM123764     6  0.4087      0.734 0.000 0.000 0.016 0.116 0.092 0.776
#> GSM123767     4  0.2909      0.630 0.012 0.004 0.000 0.828 0.000 0.156
#> GSM123770     1  0.1599      0.783 0.940 0.000 0.000 0.024 0.028 0.008
#> GSM123773     4  0.3536      0.516 0.252 0.004 0.000 0.736 0.000 0.008
#> GSM123777     4  0.2793      0.649 0.000 0.000 0.200 0.800 0.000 0.000
#> GSM123779     4  0.2257      0.720 0.000 0.000 0.048 0.904 0.008 0.040
#> GSM123782     6  0.2001      0.662 0.000 0.000 0.040 0.048 0.000 0.912
#> GSM123786     3  0.2262      0.773 0.000 0.000 0.896 0.008 0.016 0.080
#> GSM123789     6  0.5540      0.600 0.000 0.000 0.012 0.100 0.372 0.516
#> GSM123793     4  0.3577      0.597 0.000 0.000 0.016 0.772 0.012 0.200
#> GSM123797     4  0.2611      0.707 0.000 0.000 0.116 0.864 0.008 0.012
#> GSM123729     2  0.0665      0.954 0.000 0.980 0.000 0.008 0.008 0.004
#> GSM123733     2  0.0713      0.953 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM123737     2  0.0891      0.954 0.000 0.968 0.000 0.024 0.008 0.000
#> GSM123741     2  0.0260      0.955 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM123747     2  0.0260      0.955 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM123753     2  0.0862      0.951 0.000 0.972 0.000 0.008 0.004 0.016
#> GSM123759     2  0.1442      0.942 0.000 0.944 0.000 0.012 0.004 0.040
#> GSM123766     2  0.1668      0.934 0.000 0.928 0.000 0.008 0.004 0.060
#> GSM123772     2  0.0820      0.953 0.000 0.972 0.000 0.012 0.000 0.016
#> GSM123775     2  0.0779      0.953 0.000 0.976 0.000 0.008 0.008 0.008
#> GSM123781     2  0.4241      0.583 0.000 0.644 0.004 0.016 0.004 0.332
#> GSM123785     2  0.0865      0.950 0.000 0.964 0.000 0.036 0.000 0.000
#> GSM123788     2  0.0713      0.953 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM123792     2  0.0547      0.954 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123796     2  0.0632      0.953 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM123731     2  0.0405      0.956 0.000 0.988 0.000 0.008 0.004 0.000
#> GSM123735     2  0.0547      0.954 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123739     2  0.0806      0.954 0.000 0.972 0.000 0.020 0.008 0.000
#> GSM123743     2  0.0363      0.955 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM123749     2  0.1223      0.949 0.000 0.960 0.004 0.008 0.012 0.016
#> GSM123755     2  0.1729      0.938 0.000 0.936 0.004 0.012 0.012 0.036
#> GSM123768     2  0.3770      0.836 0.000 0.812 0.036 0.016 0.016 0.120
#> GSM123776     1  0.2805      0.616 0.828 0.160 0.000 0.000 0.012 0.000
#> GSM123783     2  0.2665      0.909 0.000 0.892 0.024 0.016 0.016 0.052
#> GSM123790     2  0.1075      0.945 0.000 0.952 0.000 0.048 0.000 0.000
#> GSM123794     2  0.0547      0.954 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM123798     2  0.1555      0.941 0.000 0.940 0.000 0.012 0.008 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-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) infection(p) agent(p) k
#> ATC:NMF 69         7.45e-15     7.45e-15 1.80e-05 2
#> ATC:NMF 66         2.39e-15     2.39e-15 3.89e-05 3
#> ATC:NMF 66         6.20e-19     6.20e-19 6.63e-04 4
#> ATC:NMF 57         1.80e-17     1.80e-17 3.72e-03 5
#> ATC:NMF 64         3.05e-17     3.05e-17 5.53e-03 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